alibi-core 0.7.0

Shared authentication contracts and backend-independent services for Alibi
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
/// Explicit upstream error codes, ordered by message for binary search.
pub(in crate::error) const UPSTREAM_ERROR_CODES: &[(&str, &str)] = &[
    (
        "API Key getter returned an invalid key type. Expected string.",
        "INVALID_API_KEY_GETTER_RETURN_TYPE",
    ),
    ("API Key has expired", "KEY_EXPIRED"),
    ("API Key has reached its usage limit", "USAGE_EXCEEDED"),
    ("API Key is disabled", "KEY_DISABLED"),
    ("API Key is not recoverable", "KEY_NOT_RECOVERABLE"),
    ("API Key name is required.", "NAME_REQUIRED"),
    ("API Key not found", "KEY_NOT_FOUND"),
    ("Access denied", "ACCESS_DENIED"),
    ("Access token not found", "ACCESS_TOKEN_NOT_FOUND"),
    (
        "Account is not associated with a configured social provider.",
        "PROVIDER_NOT_CONFIGURED",
    ),
    ("Account not found", "ACCOUNT_NOT_FOUND"),
    (
        "Account not linked - different emails not allowed",
        "LINKING_DIFFERENT_EMAILS_NOT_ALLOWED",
    ),
    (
        "Account not linked - linking not allowed",
        "LINKING_NOT_ALLOWED",
    ),
    (
        "Account not linked - unable to create account",
        "LINKING_FAILED",
    ),
    (
        "Anonymous users cannot sign in again anonymously",
        "ANONYMOUS_USERS_CANNOT_SIGN_IN_AGAIN_ANONYMOUSLY",
    ),
    (
        "Async validation is not supported",
        "ASYNC_VALIDATION_NOT_SUPPORTED",
    ),
    ("Auth cancelled", "AUTH_CANCELLED"),
    ("Authentication failed", "AUTHENTICATION_FAILED"),
    ("Authentication required", "AUTHENTICATION_REQUIRED"),
    ("Authorization pending", "AUTHORIZATION_PENDING"),
    ("Backup codes aren't enabled", "BACKUP_CODES_NOT_ENABLED"),
    ("Body must be an object", "BODY_MUST_BE_AN_OBJECT"),
    ("CAPTCHA service unavailable", "SERVICE_UNAVAILABLE"),
    (
        "Cannot delete a pre-defined role",
        "CANNOT_DELETE_A_PRE_DEFINED_ROLE",
    ),
    (
        "Cannot delete a role that is assigned to members. Please reassign the members to a different role first",
        "ROLE_IS_ASSIGNED_TO_MEMBERS",
    ),
    ("Captcha verification failed", "VERIFICATION_FAILED"),
    ("Challenge not found", "CHALLENGE_NOT_FOUND"),
    ("Change email is disabled", "CHANGE_EMAIL_DISABLED"),
    ("Could not create session", "COULD_NOT_CREATE_SESSION"),
    (
        "Credential account not found",
        "CREDENTIAL_ACCOUNT_NOT_FOUND",
    ),
    (
        "Cross-site navigation login blocked. This request appears to be a CSRF attack.",
        "CROSS_SITE_NAVIGATION_LOGIN_BLOCKED",
    ),
    (
        "Custom key expiration values are disabled.",
        "KEY_DISABLED_EXPIRATION",
    ),
    (
        "Deleting anonymous users is disabled",
        "DELETE_ANONYMOUS_USER_DISABLED",
    ),
    (
        "Device code already processed",
        "DEVICE_CODE_ALREADY_PROCESSED",
    ),
    ("Device code has expired", "EXPIRED_DEVICE_CODE"),
    (
        "Device code has not been claimed by a verifying session; call `GET /device` with the `user_code` while signed in before approving or denying",
        "DEVICE_CODE_NOT_CLAIMED",
    ),
    ("Display username is invalid", "INVALID_DISPLAY_USERNAME"),
    (
        "Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information",
        "MISSING_AC_INSTANCE",
    ),
    (
        "Either userId or session is required",
        "USER_ID_OR_SESSION_REQUIRED",
    ),
    (
        "Email and password is not enabled",
        "EMAIL_PASSWORD_DISABLED",
    ),
    (
        "Email and password sign up is not enabled",
        "EMAIL_PASSWORD_SIGN_UP_DISABLED",
    ),
    ("Email can not be updated", "EMAIL_CAN_NOT_BE_UPDATED"),
    ("Email is already verified", "EMAIL_ALREADY_VERIFIED"),
    ("Email mismatch", "EMAIL_MISMATCH"),
    ("Email not verified", "EMAIL_NOT_VERIFIED"),
    (
        "Email verification required before accepting or rejecting invitation",
        "EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION",
    ),
    (
        "Email verification required to view or list invitations for the session email",
        "EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION",
    ),
    (
        "Email was not generated in a valid format",
        "INVALID_EMAIL_FORMAT",
    ),
    ("Failed to create session", "FAILED_TO_CREATE_SESSION"),
    ("Failed to create user", "FAILED_TO_CREATE_USER"),
    (
        "Failed to delete anonymous user",
        "FAILED_TO_DELETE_ANONYMOUS_USER",
    ),
    (
        "Failed to delete anonymous user sessions",
        "FAILED_TO_DELETE_ANONYMOUS_USER_SESSIONS",
    ),
    (
        "Failed to get a valid access token",
        "FAILED_TO_GET_ACCESS_TOKEN",
    ),
    ("Failed to get session", "FAILED_TO_GET_SESSION"),
    ("Failed to get user info", "FAILED_TO_GET_USER_INFO"),
    (
        "Failed to refresh access token",
        "FAILED_TO_REFRESH_ACCESS_TOKEN",
    ),
    (
        "Failed to retrieve invitation",
        "FAILED_TO_RETRIEVE_INVITATION",
    ),
    ("Failed to update API key", "FAILED_TO_UPDATE_API_KEY"),
    ("Failed to update passkey", "FAILED_TO_UPDATE_PASSKEY"),
    ("Failed to update user", "FAILED_TO_UPDATE_USER"),
    (
        "Failed to verify registration",
        "FAILED_TO_VERIFY_REGISTRATION",
    ),
    ("Field is required", "MISSING_FIELD"),
    ("Field not allowed to be set", "FIELD_NOT_ALLOWED"),
    ("Internal Server Error", "INTERNAL_SERVER_ERROR"),
    ("Invalid API key.", "INVALID_API_KEY"),
    ("Invalid OAuth configuration", "INVALID_OAUTH_CONFIGURATION"),
    ("Invalid OAuth configuration.", "INVALID_OAUTH_CONFIG"),
    (
        "Invalid OAuth configuration. Token URL not found.",
        "TOKEN_URL_NOT_FOUND",
    ),
    ("Invalid OTP", "INVALID_OTP"),
    ("Invalid backup code", "INVALID_BACKUP_CODE"),
    ("Invalid callbackURL", "INVALID_CALLBACK_URL"),
    ("Invalid code", "INVALID_CODE"),
    ("Invalid device code", "INVALID_DEVICE_CODE"),
    ("Invalid device code status", "INVALID_DEVICE_CODE_STATUS"),
    ("Invalid email", "INVALID_EMAIL"),
    ("Invalid email or password", "INVALID_EMAIL_OR_PASSWORD"),
    ("Invalid errorCallbackURL", "INVALID_ERROR_CALLBACK_URL"),
    (
        "Invalid newUserCallbackURL",
        "INVALID_NEW_USER_CALLBACK_URL",
    ),
    ("Invalid origin", "INVALID_ORIGIN"),
    ("Invalid password", "INVALID_PASSWORD"),
    ("Invalid phone number", "INVALID_PHONE_NUMBER"),
    (
        "Invalid phone number or password",
        "INVALID_PHONE_NUMBER_OR_PASSWORD",
    ),
    ("Invalid redirectURL", "INVALID_REDIRECT_URL"),
    ("Invalid role type", "INVALID_ROLE_TYPE"),
    ("Invalid token", "INVALID_TOKEN"),
    ("Invalid two factor cookie", "INVALID_TWO_FACTOR_COOKIE"),
    ("Invalid user", "INVALID_USER"),
    ("Invalid user code", "INVALID_USER_CODE"),
    (
        "Invalid username or password",
        "INVALID_USERNAME_OR_PASSWORD",
    ),
    ("Invitation limit reached", "INVITATION_LIMIT_REACHED"),
    ("Invitation not found", "INVITATION_NOT_FOUND"),
    ("Invitation not found!", "INVITATION_NOT_FOUND"),
    (
        "Inviter is no longer a member of the organization",
        "INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION",
    ),
    (
        "Linked account already exists",
        "LINKED_ACCOUNT_ALREADY_EXISTS",
    ),
    ("Member not found", "MEMBER_NOT_FOUND"),
    ("Metadata is disabled.", "METADATA_DISABLED"),
    ("Missing CAPTCHA response", "MISSING_RESPONSE"),
    ("Missing or null Origin", "MISSING_OR_NULL_ORIGIN"),
    ("Missing secret key", "MISSING_SECRET_KEY"),
    (
        "Multiple accounts share this account ID. Pass a providerId to disambiguate.",
        "AMBIGUOUS_ACCOUNT",
    ),
    ("No active organization", "NO_ACTIVE_ORGANIZATION"),
    ("No config found for provider", "PROVIDER_CONFIG_NOT_FOUND"),
    ("No data to update", "NO_DATA_TO_UPDATE"),
    (
        "No default api-key configuration found.",
        "NO_DEFAULT_API_KEY_CONFIGURATION_FOUND",
    ),
    ("No values to update.", "NO_VALUES_TO_UPDATE"),
    ("Not found", "NOT_FOUND"),
    (
        "OAuth issuer mismatch. The authorization server issuer does not match the expected value (RFC 9207).",
        "ISSUER_MISMATCH",
    ),
    (
        "OAuth issuer parameter missing. The authorization server did not include the required iss parameter (RFC 9207).",
        "ISSUER_MISSING",
    ),
    ("OTP expired", "OTP_EXPIRED"),
    ("OTP has expired", "OTP_HAS_EXPIRED"),
    ("OTP not enabled", "OTP_NOT_ENABLED"),
    ("OTP not found", "OTP_NOT_FOUND"),
    (
        "Organization ID is required for organization-owned API keys.",
        "ORGANIZATION_ID_REQUIRED",
    ),
    ("Organization already exists", "ORGANIZATION_ALREADY_EXISTS"),
    (
        "Organization deletion is disabled",
        "ORGANIZATION_DELETION_DISABLED",
    ),
    (
        "Organization membership limit reached",
        "ORGANIZATION_MEMBERSHIP_LIMIT_REACHED",
    ),
    ("Organization not found", "ORGANIZATION_NOT_FOUND"),
    (
        "Organization plugin is required for organization-owned API keys. Please install and configure the organization plugin.",
        "ORGANIZATION_PLUGIN_REQUIRED",
    ),
    (
        "Organization slug already taken",
        "ORGANIZATION_SLUG_ALREADY_TAKEN",
    ),
    (
        "POST method requires deferSessionRefresh to be enabled in session config",
        "METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED",
    ),
    ("Passkey not found", "PASSKEY_NOT_FOUND"),
    (
        "Passkey registration requires an authenticated session",
        "SESSION_REQUIRED",
    ),
    (
        "Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false",
        "RESOLVE_USER_REQUIRED",
    ),
    (
        "Password cannot be updated through update-user. Use the set-user-password endpoint instead",
        "PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER",
    ),
    ("Password too long", "PASSWORD_TOO_LONG"),
    ("Password too short", "PASSWORD_TOO_SHORT"),
    ("Phone number already exists", "PHONE_NUMBER_EXIST"),
    (
        "Phone number cannot be updated",
        "PHONE_NUMBER_CANNOT_BE_UPDATED",
    ),
    ("Phone number not verified", "PHONE_NUMBER_NOT_VERIFIED"),
    ("Polling too frequently", "POLLING_TOO_FREQUENTLY"),
    ("Popup sign-in failed", "POPUP_SIGN_IN_FAILED"),
    ("Previously registered", "PREVIOUSLY_REGISTERED"),
    ("Provider ID is required", "PROVIDER_ID_REQUIRED"),
    ("Provider not found", "PROVIDER_NOT_FOUND"),
    ("Rate limit exceeded.", "RATE_LIMIT_EXCEEDED"),
    ("Refresh token not found", "REFRESH_TOKEN_NOT_FOUND"),
    ("Registration cancelled", "REGISTRATION_CANCELLED"),
    ("Reset password isn't enabled", "RESET_PASSWORD_DISABLED"),
    ("Resolved user is invalid", "RESOLVED_USER_INVALID"),
    ("Role not found", "ROLE_NOT_FOUND"),
    (
        "Session expired. Re-authenticate to perform this action.",
        "SESSION_EXPIRED",
    ),
    ("Session is not fresh", "SESSION_NOT_FRESH"),
    ("Session is required", "SESSION_REQUIRED"),
    ("Sign-in popup timed out", "POPUP_TIMEOUT"),
    ("Sign-in popup was blocked by the browser", "POPUP_BLOCKED"),
    ("Sign-in popup was closed before completing", "POPUP_CLOSED"),
    (
        "Social account already linked",
        "SOCIAL_ACCOUNT_ALREADY_LINKED",
    ),
    ("Something went wrong", "UNKNOWN_ERROR"),
    ("TOTP not enabled", "TOTP_NOT_ENABLED"),
    ("Team already exists", "TEAM_ALREADY_EXISTS"),
    ("Team id contains a reserved character", "INVALID_TEAM_ID"),
    ("Team member limit reached", "TEAM_MEMBER_LIMIT_REACHED"),
    ("Team not found", "TEAM_NOT_FOUND"),
    (
        "That role name is already taken",
        "ROLE_NAME_IS_ALREADY_TAKEN",
    ),
    (
        "The expiresIn is larger than the predefined maximum value.",
        "EXPIRES_IN_IS_TOO_LARGE",
    ),
    (
        "The expiresIn is smaller than the predefined minimum value.",
        "EXPIRES_IN_IS_TOO_SMALL",
    ),
    (
        "The name length is either too large or too small.",
        "INVALID_NAME_LENGTH",
    ),
    (
        "The prefix length is either too large or too small.",
        "INVALID_PREFIX_LENGTH",
    ),
    (
        "The property you're trying to set can only be set from the server auth instance only.",
        "SERVER_ONLY_PROPERTY",
    ),
    (
        "The provided permission includes an invalid resource",
        "INVALID_RESOURCE",
    ),
    (
        "The reference id from the API key is invalid.",
        "INVALID_REFERENCE_ID_FROM_API_KEY",
    ),
    (
        "The remaining count is either too large or too small.",
        "INVALID_REMAINING",
    ),
    (
        "The user id from the API key is invalid.",
        "INVALID_USER_ID_FROM_API_KEY",
    ),
    ("This organization has too many roles", "TOO_MANY_ROLES"),
    ("Token expired", "TOKEN_EXPIRED"),
    ("Too many attempts", "TOO_MANY_ATTEMPTS"),
    (
        "Too many attempts. Please request a new code.",
        "TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE",
    ),
    (
        "Too many failed verification attempts. Your account is temporarily locked. Please try again later.",
        "ACCOUNT_TEMPORARILY_LOCKED",
    ),
    ("Two factor isn't enabled", "TWO_FACTOR_NOT_ENABLED"),
    ("Unable to create session", "UNABLE_TO_CREATE_SESSION"),
    (
        "Unable to create verification",
        "FAILED_TO_CREATE_VERIFICATION",
    ),
    ("Unable to remove last team", "UNABLE_TO_REMOVE_LAST_TEAM"),
    ("Unauthorized", "UNAUTHORIZED"),
    ("Unauthorized or invalid session", "UNAUTHORIZED_SESSION"),
    ("Unexpected error", "UNEXPECTED_ERROR"),
    ("Unknown error", "UNKNOWN_ERROR"),
    ("User already exists.", "USER_ALREADY_EXISTS"),
    (
        "User already exists. Use another email.",
        "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL",
    ),
    ("User already has a password set", "PASSWORD_ALREADY_SET"),
    (
        "User already has a password. Provide that to delete the account.",
        "USER_ALREADY_HAS_PASSWORD",
    ),
    ("User code has expired", "EXPIRED_USER_CODE"),
    ("User email not found", "USER_EMAIL_NOT_FOUND"),
    (
        "User is already a member of this organization",
        "USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION",
    ),
    (
        "User is already invited to this organization",
        "USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION",
    ),
    ("User is banned", "USER_BANNED"),
    (
        "User is not a member of the organization",
        "USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION",
    ),
    (
        "User is not a member of the team",
        "USER_IS_NOT_A_MEMBER_OF_THE_TEAM",
    ),
    ("User is not anonymous", "USER_IS_NOT_ANONYMOUS"),
    ("User not found", "USER_NOT_FOUND"),
    (
        "Username is already taken. Please try another.",
        "USERNAME_IS_ALREADY_TAKEN",
    ),
    ("Username is invalid", "INVALID_USERNAME"),
    ("Username is too long", "USERNAME_TOO_LONG"),
    ("Username is too short", "USERNAME_TOO_SHORT"),
    ("Validation Error", "VALIDATION_ERROR"),
    (
        "Verification email isn't enabled",
        "VERIFICATION_EMAIL_NOT_ENABLED",
    ),
    (
        "You are not a member of the organization that owns this API key.",
        "USER_NOT_MEMBER_OF_ORGANIZATION",
    ),
    (
        "You are not a member of this organization",
        "YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION",
    ),
    (
        "You are not allowed to access this organization as an owner",
        "YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION",
    ),
    (
        "You are not allowed to ban users",
        "YOU_ARE_NOT_ALLOWED_TO_BAN_USERS",
    ),
    (
        "You are not allowed to cancel this invitation",
        "YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION",
    ),
    (
        "You are not allowed to change users role",
        "YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE",
    ),
    (
        "You are not allowed to create a new member",
        "YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER",
    ),
    (
        "You are not allowed to create a new organization",
        "YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION",
    ),
    (
        "You are not allowed to create a new team",
        "YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM",
    ),
    (
        "You are not allowed to create a role",
        "YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE",
    ),
    (
        "You are not allowed to create teams in this organization",
        "YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION",
    ),
    (
        "You are not allowed to create users",
        "YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS",
    ),
    (
        "You are not allowed to delete a role",
        "YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE",
    ),
    (
        "You are not allowed to delete teams in this organization",
        "YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION",
    ),
    (
        "You are not allowed to delete this member",
        "YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER",
    ),
    (
        "You are not allowed to delete this organization",
        "YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION",
    ),
    (
        "You are not allowed to delete this team",
        "YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM",
    ),
    (
        "You are not allowed to delete users",
        "YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS",
    ),
    (
        "You are not allowed to get a role",
        "YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE",
    ),
    (
        "You are not allowed to get user",
        "YOU_ARE_NOT_ALLOWED_TO_GET_USER",
    ),
    (
        "You are not allowed to impersonate users",
        "YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS",
    ),
    (
        "You are not allowed to invite a user with this role",
        "YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE",
    ),
    (
        "You are not allowed to invite users to this organization",
        "YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION",
    ),
    (
        "You are not allowed to list a role",
        "YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE",
    ),
    (
        "You are not allowed to list the members of this team",
        "YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM",
    ),
    (
        "You are not allowed to list users",
        "YOU_ARE_NOT_ALLOWED_TO_LIST_USERS",
    ),
    (
        "You are not allowed to list users sessions",
        "YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS",
    ),
    (
        "You are not allowed to read a role",
        "YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE",
    ),
    (
        "You are not allowed to register this passkey",
        "YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY",
    ),
    (
        "You are not allowed to remove a team member",
        "YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER",
    ),
    (
        "You are not allowed to revoke users sessions",
        "YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS",
    ),
    (
        "You are not allowed to set a non-existent role value",
        "YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE",
    ),
    (
        "You are not allowed to set users password",
        "YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD",
    ),
    (
        "You are not allowed to update a role",
        "YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE",
    ),
    (
        "You are not allowed to update this member",
        "YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER",
    ),
    (
        "You are not allowed to update this organization",
        "YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION",
    ),
    (
        "You are not allowed to update this team",
        "YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM",
    ),
    (
        "You are not allowed to update users",
        "YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS",
    ),
    (
        "You are not allowed to update users email",
        "YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL",
    ),
    (
        "You are not the recipient of the invitation",
        "YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION",
    ),
    (
        "You can't unlink your last account",
        "FAILED_TO_UNLINK_LAST_ACCOUNT",
    ),
    ("You cannot ban yourself", "YOU_CANNOT_BAN_YOURSELF"),
    (
        "You cannot impersonate admins",
        "YOU_CANNOT_IMPERSONATE_ADMINS",
    ),
    (
        "You cannot leave the organization as the only owner",
        "YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER",
    ),
    (
        "You cannot leave the organization without an owner",
        "YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER",
    ),
    ("You cannot remove yourself", "YOU_CANNOT_REMOVE_YOURSELF"),
    (
        "You do not have an active team",
        "YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM",
    ),
    (
        "You do not have permission to perform this action on organization API keys.",
        "INSUFFICIENT_API_KEY_PERMISSIONS",
    ),
    ("You have been banned from this application", "BANNED_USER"),
    (
        "You have reached the maximum number of organizations",
        "YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS",
    ),
    (
        "You have reached the maximum number of teams",
        "YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS",
    ),
    (
        "You must be in an organization to create a role",
        "YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE",
    ),
    ("callbackURL is required", "CALLBACK_URL_REQUIRED"),
    ("failed to create session", "FAILED_TO_CREATE_SESSION"),
    ("id_token not supported", "ID_TOKEN_NOT_SUPPORTED"),
    (
        "metadata must be an object or undefined",
        "INVALID_METADATA_TYPE",
    ),
    ("otp isn't configured", "OTP_NOT_CONFIGURED"),
    ("phone number isn't registered", "PHONE_NUMBER_NOT_EXIST"),
    (
        "refillAmount is required when refillInterval is provided",
        "REFILL_AMOUNT_AND_INTERVAL_REQUIRED",
    ),
    (
        "refillInterval is required when refillAmount is provided",
        "REFILL_INTERVAL_AND_AMOUNT_REQUIRED",
    ),
    ("sendOTP not implemented", "SEND_OTP_NOT_IMPLEMENTED"),
    ("totp isn't configured", "TOTP_NOT_CONFIGURED"),
];

pub(in crate::error) fn upstream_code(message: &str) -> Option<&'static str> {
    UPSTREAM_ERROR_CODES
        .binary_search_by_key(&message, |(candidate, _)| candidate)
        .ok()
        .and_then(|index| UPSTREAM_ERROR_CODES.get(index))
        .map(|(_, code)| *code)
}