authhero 9.31.0 → 9.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +137 -137
  3. package/dist/authhero.d.ts +605 -392
  4. package/dist/authhero.mjs +16303 -15968
  5. package/dist/mfa-CDFRupfM.mjs +128 -0
  6. package/dist/mfa-DF3O3Z8H.js +1 -0
  7. package/dist/mfa-attempts-BOWgbEPg.js +275 -0
  8. package/dist/{mfa-attempts-Dl3I8pop.mjs → mfa-attempts-C06Bkdy9.mjs} +14352 -13847
  9. package/dist/{passkey-enrollment-2Toeaevy.js → passkey-enrollment-RGw-WaSq.js} +1 -1
  10. package/dist/tsconfig.types.tsbuildinfo +1 -1
  11. package/dist/types/authentication-flows/common.d.ts +12 -1
  12. package/dist/types/authentication-flows/passwordless.d.ts +24 -11
  13. package/dist/types/authentication-flows/refresh-token.d.ts +1 -0
  14. package/dist/types/authentication-flows/remember-browser.d.ts +77 -0
  15. package/dist/types/constants.d.ts +1 -0
  16. package/dist/types/generated/locale-types.d.ts +6 -0
  17. package/dist/types/helpers/cimd.d.ts +8 -0
  18. package/dist/types/helpers/client.d.ts +25 -7
  19. package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
  20. package/dist/types/helpers/login-session-tenant.d.ts +22 -0
  21. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  22. package/dist/types/helpers/session-transfer.d.ts +158 -0
  23. package/dist/types/hooks/lifecycle-codehooks.d.ts +1 -1
  24. package/dist/types/index.d.ts +536 -376
  25. package/dist/types/routes/auth-api/authorize.d.ts +6 -0
  26. package/dist/types/routes/auth-api/device.d.ts +8 -8
  27. package/dist/types/routes/auth-api/index.d.ts +49 -32
  28. package/dist/types/routes/auth-api/passwordless.d.ts +6 -6
  29. package/dist/types/routes/auth-api/register/index.d.ts +2 -2
  30. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  31. package/dist/types/routes/auth-api/token.d.ts +21 -10
  32. package/dist/types/routes/management-api/action-triggers.d.ts +25 -25
  33. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  34. package/dist/types/routes/management-api/clients.d.ts +100 -32
  35. package/dist/types/routes/management-api/connections.d.ts +25 -25
  36. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  37. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  38. package/dist/types/routes/management-api/failed-events.d.ts +2 -2
  39. package/dist/types/routes/management-api/forms.d.ts +144 -144
  40. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  41. package/dist/types/routes/management-api/helpers.d.ts +11 -1
  42. package/dist/types/routes/management-api/hooks.d.ts +21 -21
  43. package/dist/types/routes/management-api/index.d.ts +480 -337
  44. package/dist/types/routes/management-api/jobs.d.ts +2 -2
  45. package/dist/types/routes/management-api/keys.d.ts +12 -12
  46. package/dist/types/routes/management-api/logs.d.ts +4 -4
  47. package/dist/types/routes/management-api/organizations.d.ts +7 -7
  48. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  49. package/dist/types/routes/management-api/refresh_tokens.d.ts +5 -0
  50. package/dist/types/routes/management-api/rollouts.d.ts +6 -6
  51. package/dist/types/routes/management-api/sessions.d.ts +5 -0
  52. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  53. package/dist/types/routes/management-api/tenant-members.d.ts +8 -8
  54. package/dist/types/routes/management-api/tenant-operations.d.ts +4 -4
  55. package/dist/types/routes/management-api/tenants.d.ts +24 -16
  56. package/dist/types/routes/management-api/users.d.ts +84 -24
  57. package/dist/types/routes/universal-login/common.d.ts +57 -22
  58. package/dist/types/routes/universal-login/flow-api.d.ts +8 -8
  59. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  60. package/dist/types/routes/universal-login/index.d.ts +2 -2
  61. package/dist/types/routes/universal-login/screens/mfa-remember-browser.d.ts +28 -0
  62. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  63. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  64. package/dist/types/state-machines/login-session.d.ts +7 -2
  65. package/dist/types/types/GrantFlowResult.d.ts +13 -0
  66. package/dist/types/types/Hooks.d.ts +24 -0
  67. package/dist/types/types/Variables.d.ts +12 -1
  68. package/dist/types/utils/cookies.d.ts +29 -0
  69. package/dist/types/utils/session-transfer-token.d.ts +56 -0
  70. package/package.json +6 -6
  71. package/dist/mfa-attempts-DXiY4U74.js +0 -275
@@ -1,4 +1,4 @@
1
- import { AuthorizationResponseType, AuthParams, LoginSession, LoginSessionAuthStrategy, RefreshToken, User, TokenResponse } from "@authhero/adapter-interfaces";
1
+ import { AuthorizationResponseType, AuthParams, LoginSession, LoginSessionAuthStrategy, RefreshToken, SessionTransferProvenance, User, TokenResponse } from "@authhero/adapter-interfaces";
2
2
  import { EnrichedClient } from "../helpers/client";
3
3
  import { Context } from "hono";
4
4
  import { Bindings, Variables } from "../types";
@@ -103,6 +103,17 @@ export interface CreateRefreshTokenParams {
103
103
  organization?: string;
104
104
  auth_connection?: string;
105
105
  auth_strategy?: LoginSessionAuthStrategy;
106
+ /**
107
+ * Set when the session came from a session_transfer_token. The token then
108
+ * carries the same provenance, so it ends with the refresh token the
109
+ * session was transferred from.
110
+ */
111
+ session_transfer?: SessionTransferProvenance;
112
+ /**
113
+ * Upper bound for the token's absolute and idle expiry. Used to tie a
114
+ * refresh token to the lifetime of the session it was issued under.
115
+ */
116
+ max_expires_at?: string;
106
117
  }
107
118
  export interface CreatedRefreshToken {
108
119
  row: RefreshToken;
@@ -243,7 +243,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
243
243
  pushed_authorization_requests_supported?: boolean | undefined;
244
244
  authorization_response_iss_parameter_supported?: boolean | undefined;
245
245
  deployment_type?: "shared" | "wfp" | undefined;
246
- provisioning_state?: "failed" | "pending" | "ready" | undefined;
246
+ provisioning_state?: "pending" | "ready" | "failed" | undefined;
247
247
  provisioning_error?: string | undefined;
248
248
  provisioning_state_changed_at?: string | undefined;
249
249
  bundle_configuration?: string | undefined;
@@ -291,7 +291,6 @@ export declare function passwordlessGrantUser(ctx: Context<{
291
291
  } | undefined;
292
292
  } | undefined;
293
293
  mfa?: {
294
- policy?: "never" | "always" | "all-applications" | "confidence-score" | undefined;
295
294
  factors?: {
296
295
  sms: boolean;
297
296
  otp: boolean;
@@ -314,6 +313,9 @@ export declare function passwordlessGrantUser(ctx: Context<{
314
313
  phone_message?: {
315
314
  message?: string | undefined;
316
315
  } | undefined;
316
+ allow_remember_browser?: boolean | undefined;
317
+ remember_browser_lifetime_in_days?: number | undefined;
318
+ policy?: "never" | "always" | "all-applications" | "confidence-score" | undefined;
317
319
  } | undefined;
318
320
  is_control_plane?: boolean | undefined;
319
321
  has_children?: boolean | undefined;
@@ -381,7 +383,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
381
383
  active?: boolean | undefined;
382
384
  } | undefined;
383
385
  signup?: {
384
- status?: "optional" | "required" | "disabled" | undefined;
386
+ status?: "required" | "optional" | "disabled" | undefined;
385
387
  verification?: {
386
388
  active?: boolean | undefined;
387
389
  } | undefined;
@@ -391,14 +393,14 @@ export declare function passwordlessGrantUser(ctx: Context<{
391
393
  } | undefined;
392
394
  unique?: boolean | undefined;
393
395
  profile_required?: boolean | undefined;
394
- verification_method?: "code" | "link" | undefined;
396
+ verification_method?: "link" | "code" | undefined;
395
397
  } | undefined;
396
398
  username?: {
397
399
  identifier?: {
398
400
  active?: boolean | undefined;
399
401
  } | undefined;
400
402
  signup?: {
401
- status?: "optional" | "required" | "disabled" | undefined;
403
+ status?: "required" | "optional" | "disabled" | undefined;
402
404
  } | undefined;
403
405
  validation?: {
404
406
  max_length?: number | undefined;
@@ -415,7 +417,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
415
417
  active?: boolean | undefined;
416
418
  } | undefined;
417
419
  signup?: {
418
- status?: "optional" | "required" | "disabled" | undefined;
420
+ status?: "required" | "optional" | "disabled" | undefined;
419
421
  } | undefined;
420
422
  } | undefined;
421
423
  } | undefined;
@@ -456,7 +458,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
456
458
  }[];
457
459
  description?: string | undefined;
458
460
  client_secret?: string | undefined;
459
- app_type?: "native" | "spa" | "regular_web" | "non_interactive" | "resource_server" | "express_configuration" | "rms" | "box" | "cloudbees" | "concur" | "dropbox" | "mscrm" | "echosign" | "egnyte" | "newrelic" | "office365" | "salesforce" | "sentry" | "sharepoint" | "slack" | "springcm" | "zendesk" | "zoom" | "sso_integration" | "oag" | undefined;
461
+ app_type?: "resource_server" | "native" | "spa" | "regular_web" | "non_interactive" | "express_configuration" | "rms" | "box" | "cloudbees" | "concur" | "dropbox" | "mscrm" | "echosign" | "egnyte" | "newrelic" | "office365" | "salesforce" | "sentry" | "sharepoint" | "slack" | "springcm" | "zendesk" | "zoom" | "sso_integration" | "oag" | undefined;
460
462
  logo_uri?: string | undefined;
461
463
  callbacks?: string[] | undefined;
462
464
  allowed_origins?: string[] | undefined;
@@ -464,7 +466,17 @@ export declare function passwordlessGrantUser(ctx: Context<{
464
466
  client_aliases?: string[] | undefined;
465
467
  allowed_clients?: string[] | undefined;
466
468
  allowed_logout_urls?: string[] | undefined;
467
- session_transfer?: Record<string, any> | undefined;
469
+ session_transfer?: {
470
+ [x: string]: unknown;
471
+ can_create_session_transfer_token?: boolean | undefined;
472
+ enforce_cascade_revocation?: boolean | undefined;
473
+ allowed_authentication_methods?: ("query" | "cookie")[] | undefined;
474
+ enforce_device_binding?: "none" | "ip" | "asn" | undefined;
475
+ allow_refresh_token?: boolean | undefined;
476
+ enforce_online_refresh_tokens?: boolean | undefined;
477
+ allow_onward_transfer?: boolean | undefined;
478
+ trust_forwarded_ip?: boolean | undefined;
479
+ } | undefined;
468
480
  oidc_logout?: {
469
481
  [x: string]: unknown;
470
482
  backchannel_logout_urls?: string[] | undefined;
@@ -483,7 +495,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
483
495
  custom_login_page_preview?: string | undefined;
484
496
  form_template?: string | undefined;
485
497
  addons?: Record<string, any> | undefined;
486
- token_endpoint_auth_method?: "none" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | "private_key_jwt" | undefined;
498
+ token_endpoint_auth_method?: "none" | "client_secret_post" | "client_secret_basic" | "private_key_jwt" | "client_secret_jwt" | undefined;
487
499
  client_metadata?: Record<string, string> | undefined;
488
500
  hide_sign_up_disabled_error?: boolean | undefined;
489
501
  mobile?: Record<string, any> | undefined;
@@ -568,9 +580,10 @@ export declare function passwordlessGrantUser(ctx: Context<{
568
580
  strategy_type: string;
569
581
  } | undefined;
570
582
  authenticated_at?: string | undefined;
583
+ tenant_id?: string | undefined;
571
584
  };
572
- connectionType: "username" | "email" | "sms";
573
- authConnection: "username" | "email" | "sms";
585
+ connectionType: "username" | "sms" | "email";
586
+ authConnection: "username" | "sms" | "email";
574
587
  session_id: string | undefined;
575
588
  authParams: {
576
589
  audience?: string | undefined;
@@ -9,6 +9,7 @@ export declare const refreshTokenParamsSchema: z.ZodObject<{
9
9
  refresh_token: z.ZodString;
10
10
  client_secret: z.ZodOptional<z.ZodString>;
11
11
  organization: z.ZodOptional<z.ZodString>;
12
+ audience: z.ZodOptional<z.ZodString>;
12
13
  }, z.core.$strip>;
13
14
  export declare function refreshTokenGrant(ctx: Context<{
14
15
  Bindings: Bindings;
@@ -0,0 +1,77 @@
1
+ import { Context } from "hono";
2
+ import { Tenant } from "@authhero/adapter-interfaces";
3
+ import { Bindings, Variables } from "../types";
4
+ import { MfaRequiredByAction } from "../state-machines/login-session";
5
+ /**
6
+ * "Remember this device" for MFA (#1670).
7
+ *
8
+ * After a successful MFA challenge the user can ask for the browser to be
9
+ * remembered. The browser then gets an opaque random token in a cookie, and
10
+ * only the token's SHA-256 is stored, as a `codes` row of type
11
+ * `mfa_remember_browser` that carries the user id and expiry. A later login
12
+ * of the same user from that browser skips the MFA challenge until the token
13
+ * expires, the user's remembered browsers are invalidated, or the user no
14
+ * longer has a confirmed MFA enrollment.
15
+ *
16
+ * A remembered browser satisfies MFA but is not MFA: no `amr` claim is
17
+ * emitted and the browser session is not marked as having completed MFA.
18
+ */
19
+ type RememberBrowserContext = Context<{
20
+ Bindings: Bindings;
21
+ Variables: Variables;
22
+ }>;
23
+ export declare const MFA_REMEMBER_BROWSER_DEFAULT_LIFETIME_IN_DAYS = 30;
24
+ /** How long a remembered browser skips MFA for this tenant, in days. */
25
+ export declare function rememberBrowserLifetimeInDays(tenant: Pick<Tenant, "mfa">): number;
26
+ /**
27
+ * Whether a remembered browser may stand in for MFA in this login. Every
28
+ * source that requires MFA must allow it: the tenant policy through
29
+ * `mfa.allow_remember_browser`, and a post-login action through
30
+ * `api.multifactor.enable(provider, { allowRememberBrowser: true })`.
31
+ */
32
+ export declare function isRememberBrowserAllowed(tenant: Pick<Tenant, "mfa">, actionRequest: MfaRequiredByAction | undefined): boolean;
33
+ /** `isRememberBrowserAllowed` for the MFA a login session is going through. */
34
+ export declare function isRememberBrowserAllowedForLoginSession(tenant: Pick<Tenant, "mfa">, loginSession: {
35
+ state_data?: string | null;
36
+ }): boolean;
37
+ /** The value of the "remember this device" checkbox in a screen POST. */
38
+ export declare function wantsRememberBrowser(value: unknown): boolean;
39
+ /** Form field id of the "remember this device" checkbox. */
40
+ export declare const REMEMBER_BROWSER_FIELD = "remember_browser";
41
+ /**
42
+ * Remember this browser for `userId`: store a new token and return the
43
+ * Set-Cookie values that hand it to the browser. Tokens of other users the
44
+ * browser is remembered for are kept; this user's older tokens and tokens that
45
+ * no longer resolve are dropped.
46
+ */
47
+ export declare function rememberBrowser(ctx: RememberBrowserContext, params: {
48
+ tenant: Pick<Tenant, "id" | "mfa">;
49
+ userId: string;
50
+ loginId?: string;
51
+ }): Promise<string[]>;
52
+ /**
53
+ * Whether this browser is remembered for `userId`, so the MFA challenge can be
54
+ * skipped. False unless remembering is allowed for this login (see
55
+ * `isRememberBrowserAllowed`), the browser presents a live token of this user
56
+ * issued after the user's last invalidation and within the tenant's current
57
+ * lifetime, and the user still has a confirmed MFA enrollment.
58
+ */
59
+ export declare function isBrowserRememberedForMfa(ctx: RememberBrowserContext, params: {
60
+ tenant: Pick<Tenant, "id" | "mfa">;
61
+ userId: string;
62
+ actionRequest?: MfaRequiredByAction;
63
+ }): Promise<boolean>;
64
+ /**
65
+ * Forget every browser remembered for `userId` (Auth0
66
+ * `POST /users/{id}/multifactor/actions/invalidate-remember-browser`). Records
67
+ * the time instead of deleting rows, because codes can't be listed by user in
68
+ * every adapter. The marker outlives every token issued before it.
69
+ *
70
+ * The new marker goes into an empty slot, or replaces the older of the two.
71
+ * The newer marker, the one in force, is left alone, so validation never sees
72
+ * an earlier invalidation undone, not even while this runs or if it fails. Two
73
+ * invalidations racing for the same slot both succeed: the one that loses the
74
+ * write finds the winner's marker, which covers it.
75
+ */
76
+ export declare function invalidateRememberedBrowsers(ctx: RememberBrowserContext, tenantId: string, userId: string): Promise<void>;
77
+ export {};
@@ -7,6 +7,7 @@ export declare const UNIVERSAL_AUTH_SESSION_EXPIRES_IN_SECONDS: number;
7
7
  export declare const SILENT_COOKIE_NAME = "auth-token";
8
8
  export declare const LAST_USED_CONNECTION_COOKIE_NAME = "last-used-connection";
9
9
  export declare const LAST_USED_CONNECTION_MAX_AGE_IN_SECONDS: number;
10
+ export declare const MFA_REMEMBER_BROWSER_COOKIE_NAME = "mfa-remember-browser";
10
11
  export declare const OTP_EXPIRATION_TIME: number;
11
12
  export declare const EMAIL_VERIFICATION_EXPIRATION_TIME: number;
12
13
  export declare const AUTHORIZATION_CODE_EXPIRES_IN_SECONDS: number;
@@ -636,6 +636,9 @@ export interface MfaOtpMfaTotpChallengeScreen {
636
636
  clientName: string;
637
637
  }) => string;
638
638
  "too-many-failures": () => string;
639
+ rememberMeText: (vars: {
640
+ days: string;
641
+ }) => string;
639
642
  }
640
643
  export interface MfaPhoneMfaPhoneChallengeScreen {
641
644
  pageTitle: (vars: {
@@ -669,6 +672,9 @@ export interface MfaPhoneMfaPhoneChallengeScreen {
669
672
  resendSuccess: () => string;
670
673
  enrollmentComplete: () => string;
671
674
  "too-many-failures": () => string;
675
+ rememberMeText: (vars: {
676
+ days: string;
677
+ }) => string;
672
678
  }
673
679
  export interface MfaPhoneMfaPhoneEnrollmentScreen {
674
680
  pageTitle: (vars: {
@@ -6,6 +6,14 @@ import { SsrfFetchOptions } from "../utils/ssrf-fetch";
6
6
  * (length, path, fetch, document shape) happens in {@link resolveCimdClient}.
7
7
  */
8
8
  export declare function isCimdClientId(clientId: string): boolean;
9
+ /**
10
+ * Tenant hint for `getEnrichedClient` on a host-scoped route that takes the
11
+ * client_id from the request. A registered client_id is globally unique and
12
+ * resolves its own tenant, so it gets no hint (unchanged behavior). A CIMD
13
+ * client_id (https URL) has a stub row in every tenant that uses it and can't
14
+ * identify the tenant, so it gets the request's tenant, as /authorize does.
15
+ */
16
+ export declare function cimdTenantHint(clientId: string, requestTenantId: string | undefined): string | undefined;
9
17
  export declare const cimdDocumentSchema: z.ZodObject<{
10
18
  client_id: z.ZodString;
11
19
  client_name: z.ZodString;
@@ -52,7 +52,23 @@ export declare const enrichedClientSchema: z.ZodObject<{
52
52
  client_aliases: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
53
53
  allowed_clients: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
54
54
  allowed_logout_urls: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
55
- session_transfer: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>>;
55
+ session_transfer: z.ZodOptional<z.ZodObject<{
56
+ can_create_session_transfer_token: z.ZodOptional<z.ZodBoolean>;
57
+ enforce_cascade_revocation: z.ZodOptional<z.ZodBoolean>;
58
+ allowed_authentication_methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
59
+ query: "query";
60
+ cookie: "cookie";
61
+ }>>>;
62
+ enforce_device_binding: z.ZodOptional<z.ZodEnum<{
63
+ none: "none";
64
+ ip: "ip";
65
+ asn: "asn";
66
+ }>>;
67
+ allow_refresh_token: z.ZodOptional<z.ZodBoolean>;
68
+ enforce_online_refresh_tokens: z.ZodOptional<z.ZodBoolean>;
69
+ allow_onward_transfer: z.ZodOptional<z.ZodBoolean>;
70
+ trust_forwarded_ip: z.ZodOptional<z.ZodBoolean>;
71
+ }, z.core.$loose>>;
56
72
  oidc_logout: z.ZodOptional<z.ZodDefault<z.ZodObject<{
57
73
  backchannel_logout_urls: z.ZodOptional<z.ZodArray<z.ZodString>>;
58
74
  backchannel_logout_initiators: z.ZodOptional<z.ZodObject<{
@@ -322,12 +338,6 @@ export declare const enrichedClientSchema: z.ZodObject<{
322
338
  }, z.core.$strip>>;
323
339
  }, z.core.$strip>>;
324
340
  mfa: z.ZodOptional<z.ZodObject<{
325
- policy: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
326
- never: "never";
327
- always: "always";
328
- "all-applications": "all-applications";
329
- "confidence-score": "confidence-score";
330
- }>>>;
331
341
  factors: z.ZodOptional<z.ZodObject<{
332
342
  sms: z.ZodDefault<z.ZodBoolean>;
333
343
  otp: z.ZodDefault<z.ZodBoolean>;
@@ -355,6 +365,14 @@ export declare const enrichedClientSchema: z.ZodObject<{
355
365
  phone_message: z.ZodOptional<z.ZodObject<{
356
366
  message: z.ZodOptional<z.ZodString>;
357
367
  }, z.core.$strip>>;
368
+ allow_remember_browser: z.ZodOptional<z.ZodBoolean>;
369
+ remember_browser_lifetime_in_days: z.ZodOptional<z.ZodNumber>;
370
+ policy: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
371
+ never: "never";
372
+ always: "always";
373
+ "all-applications": "all-applications";
374
+ "confidence-score": "confidence-score";
375
+ }>>>;
358
376
  }, z.core.$strip>>;
359
377
  id: z.ZodString;
360
378
  is_control_plane: z.ZodOptional<z.ZodBoolean>;
@@ -26,8 +26,8 @@ export declare const dcrRequestSchema: z.ZodObject<{
26
26
  none: "none";
27
27
  client_secret_post: "client_secret_post";
28
28
  client_secret_basic: "client_secret_basic";
29
- client_secret_jwt: "client_secret_jwt";
30
29
  private_key_jwt: "private_key_jwt";
30
+ client_secret_jwt: "client_secret_jwt";
31
31
  }>>;
32
32
  jwks_uri: z.ZodOptional<z.ZodString>;
33
33
  jwks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -0,0 +1,22 @@
1
+ import { LoginSession } from "@authhero/adapter-interfaces";
2
+ export type LoginSessionTenant = {
3
+ ok: true;
4
+ tenantId: string | undefined;
5
+ } | {
6
+ ok: false;
7
+ };
8
+ /**
9
+ * The tenant a state-keyed request (/callback, /authorize/resume, the
10
+ * universal login screens) runs in.
11
+ *
12
+ * A request whose host or header resolved a tenant only ever serves that
13
+ * tenant's login sessions. Some adapters (kysely) load the session by id
14
+ * alone, so a session of another tenant can come back here: callers must
15
+ * treat `ok: false` exactly like a missing session, otherwise one tenant's
16
+ * login screens could be served on another tenant's domain.
17
+ *
18
+ * When the request carries no tenant, the session row is the authoritative
19
+ * record of the flow's tenant. A CIMD client_id (https URL) has a stub row in
20
+ * every tenant that uses it, so it can't identify the tenant (#1731).
21
+ */
22
+ export declare function resolveLoginSessionTenant(requestTenantId: string | undefined, loginSession: Pick<LoginSession, "tenant_id">): LoginSessionTenant;
@@ -14,9 +14,9 @@ export declare const USERINFO_RESERVED_CLAIMS: readonly ["iss", "sub", "aud", "e
14
14
  * vendor/tenant for downstream APIs while `sub` stays `auth-service`.
15
15
  * Client-bound mints keep `azp` locked (see below).
16
16
  */
17
- export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("client_id" | "scope" | "sub" | "tenant_id" | "org_name" | "jti" | "sid" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "gty" | "permissions" | "nbf" | "act" | "requested_userinfo_claims")[];
17
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("sub" | "scope" | "tenant_id" | "client_id" | "org_name" | "sid" | "jti" | "permissions" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
18
18
  /** Client-bound mints: `azp` must stay the registered client id. */
19
- export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("client_id" | "scope" | "sub" | "tenant_id" | "org_name" | "jti" | "sid" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "gty" | "permissions" | "nbf" | "act" | "requested_userinfo_claims")[];
19
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("sub" | "scope" | "tenant_id" | "client_id" | "org_name" | "sid" | "jti" | "permissions" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
20
20
  export type AccessTokenReservedClaim = (typeof ACCESS_TOKEN_RESERVED_CLAIMS)[number];
21
21
  export type IdTokenReservedClaim = (typeof ID_TOKEN_RESERVED_CLAIMS)[number];
22
22
  /**
@@ -0,0 +1,158 @@
1
+ import { Context } from "hono";
2
+ import { z } from "@hono/zod-openapi";
3
+ import { DataAdapters, RefreshToken, Session, SessionTransferAuthenticationMethod, SessionTransferProvenance, User } from "@authhero/adapter-interfaces";
4
+ import { Bindings, Variables } from "../types";
5
+ import { EnrichedClient } from "./client";
6
+ /**
7
+ * Minting and redeeming session_transfer_tokens (#1710, Auth0 "Native to Web
8
+ * SSO"), and the checks a session or refresh token created from one is subject
9
+ * to afterwards.
10
+ *
11
+ * A token is stored as two rows: a `codes` row keyed by the token's hash, which
12
+ * gives single use and the 60 second lifetime, and a "carrier" login session
13
+ * that holds what the redeeming /authorize needs to rebuild the login: the
14
+ * user, the connection they authenticated with, the device the token is bound
15
+ * to and the refresh token family it was minted from.
16
+ */
17
+ type Ctx = Context<{
18
+ Bindings: Bindings;
19
+ Variables: Variables;
20
+ }>;
21
+ /**
22
+ * Descriptions of the `w` log written when a presented token does not log the
23
+ * user in. The first five are Auth0's, word for word, so log queries written
24
+ * against Auth0 keep matching. The rest cover checks Auth0 does not make.
25
+ */
26
+ export declare const SESSION_TRANSFER_WARNINGS: {
27
+ readonly notFound: "Single Sign-On failed: Session Transfer Token not found or expired. This may indicate token reuse or expiration.";
28
+ readonly deviceBinding: "Single Sign-On failed: Session Transfer Token device binding validation failed due to IP/ASN mismatch.";
29
+ readonly organization: "Single Sign-On failed: Session Transfer Token organization mismatch detected.";
30
+ readonly userMismatch: "Single Sign-On failed: Session Transfer Token user mismatch detected.";
31
+ readonly parentNotFound: "Single Sign-On failed: Parent refresh token not found. Session Transfer Token won't be used for session establishment.";
32
+ readonly methodNotAllowed: "Single Sign-On failed: Session Transfer Token authentication method is not allowed for this client.";
33
+ readonly connectionNotEnabled: "Single Sign-On failed: Session Transfer Token user's connection is not enabled for this client.";
34
+ readonly userUnavailable: "Single Sign-On failed: Session Transfer Token user is blocked or no longer exists.";
35
+ };
36
+ /** What the carrier login session keeps in its context (`state_data`). */
37
+ declare const carrierStateSchema: z.ZodObject<{
38
+ session_transfer: z.ZodObject<{
39
+ family_id: z.ZodString;
40
+ cascade_revocation: z.ZodBoolean;
41
+ asn: z.ZodOptional<z.ZodString>;
42
+ authentication: z.ZodOptional<z.ZodObject<{
43
+ methods: z.ZodArray<z.ZodObject<{
44
+ name: z.ZodString;
45
+ timestamp: z.ZodString;
46
+ type: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strip>>;
48
+ }, z.core.$strip>>;
49
+ organization: z.ZodOptional<z.ZodObject<{
50
+ id: z.ZodString;
51
+ name: z.ZodString;
52
+ }, z.core.$strip>>;
53
+ }, z.core.$strip>;
54
+ }, z.core.$strip>;
55
+ export type SessionTransferCarrierState = z.infer<typeof carrierStateSchema>["session_transfer"];
56
+ /**
57
+ * The autonomous system number of the caller's network, when the runtime
58
+ * reports one (Cloudflare Workers put it on `request.cf.asn`). Undefined
59
+ * everywhere else: the binding check treats that as "cannot verify".
60
+ */
61
+ export declare function getRequestAsn(ctx: Ctx): string | undefined;
62
+ export interface MintSessionTransferTokenParams {
63
+ /** The client the refresh token belongs to (the sender). */
64
+ client: EnrichedClient;
65
+ user: User;
66
+ /** The refresh token presented to the exchange, before rotation. */
67
+ refreshToken: RefreshToken;
68
+ sessionId?: string;
69
+ organization?: {
70
+ id: string;
71
+ name: string;
72
+ };
73
+ authConnection?: string;
74
+ authStrategy?: RefreshToken["auth_strategy"];
75
+ /**
76
+ * Whether the client proved its identity on this request (secret or
77
+ * assertion). Only then may it name the end user's IP address.
78
+ */
79
+ clientAuthenticated: boolean;
80
+ }
81
+ /**
82
+ * Mint a session_transfer_token for the user behind a refresh token. The
83
+ * caller has already validated the refresh token and checked that the client
84
+ * may mint. Returns the wire token; only its hash is stored.
85
+ */
86
+ export declare function mintSessionTransferToken(ctx: Ctx, params: MintSessionTransferTokenParams): Promise<string>;
87
+ export interface RedeemSessionTransferTokenParams {
88
+ /** The client the /authorize request is for (the receiver). */
89
+ client: EnrichedClient;
90
+ token: string;
91
+ /** How the token reached /authorize. */
92
+ method: SessionTransferAuthenticationMethod;
93
+ /** The browser's current valid session, if it has one. */
94
+ existingSession?: Session;
95
+ /** The `organization` parameter of the /authorize request (id or name). */
96
+ organization?: string;
97
+ }
98
+ export type RedeemSessionTransferTokenResult =
99
+ /** The token did not log the user in; continue as if it was not sent. */
100
+ {
101
+ outcome: "rejected";
102
+ }
103
+ /** A new session for the token's user. */
104
+ | {
105
+ outcome: "session_created";
106
+ session: Session;
107
+ }
108
+ /** The browser already had a session for the token's user; it is kept. */
109
+ | {
110
+ outcome: "session_kept";
111
+ }
112
+ /** The browser had a session for another user; it has been revoked. */
113
+ | {
114
+ outcome: "session_revoked";
115
+ };
116
+ /**
117
+ * Redeem a session_transfer_token presented to /authorize. Never throws for an
118
+ * unusable token: every refusal writes a `w` log and reports `rejected`, and
119
+ * the caller carries on with the normal login flow.
120
+ */
121
+ export declare function redeemSessionTransferToken(ctx: Ctx, params: RedeemSessionTransferTokenParams): Promise<RedeemSessionTransferTokenResult>;
122
+ /**
123
+ * Whether the refresh token a transferred session or refresh token descends
124
+ * from is still usable. Only call this for rows that carry provenance with
125
+ * `cascade_revocation`, so ordinary logins pay nothing for it.
126
+ */
127
+ export declare function isSessionTransferParentActive(data: DataAdapters, tenantId: string, provenance: SessionTransferProvenance): Promise<boolean>;
128
+ /**
129
+ * Whether a session can still back an "online" refresh token: it exists, has
130
+ * not been revoked and has not passed its absolute or idle expiry.
131
+ */
132
+ export declare function isSessionLive(session: Session | null | undefined, now?: number): session is Session;
133
+ /**
134
+ * The idle expiry a session should move to after one of its online refresh
135
+ * tokens was exchanged, or undefined when it should be left alone. Exchanging
136
+ * the token is the only sign of life such a session gets from an application
137
+ * that never returns to /authorize, so without the slide the session, and the
138
+ * refresh token bound to it, would end after one idle period however active
139
+ * the user is. Never moves past the session's absolute expiry.
140
+ */
141
+ export declare function nextOnlineSessionIdleExpiry(client: EnrichedClient, session: Pick<Session, "idle_expires_at" | "expires_at">, now?: number): string | undefined;
142
+ export type TransferredRefreshTokenPolicy = {
143
+ allowed: false;
144
+ } | {
145
+ allowed: true;
146
+ session_transfer?: SessionTransferProvenance;
147
+ /** Absolute expiry the refresh token may not outlive. */
148
+ max_expires_at?: string;
149
+ };
150
+ /**
151
+ * What applies to a refresh token about to be issued under `session`. A
152
+ * session that did not come from a session_transfer_token is unaffected. One
153
+ * that did gets a refresh token only if the client opted in, and that token
154
+ * records where it came from and, unless the client turned it off, ends with
155
+ * the session ("online" refresh token).
156
+ */
157
+ export declare function resolveTransferredRefreshTokenPolicy(client: EnrichedClient, session: Pick<Session, "session_transfer" | "expires_at"> | null | undefined): TransferredRefreshTokenPolicy;
158
+ export {};
@@ -10,7 +10,7 @@ export declare function listEnabledCodeHooks(ctx: Context<{
10
10
  Bindings: Bindings;
11
11
  Variables: Variables;
12
12
  }>, tenantId: string, triggerId: string): Promise<{
13
- trigger_id: "post-user-login" | "credentials-exchange" | "pre-user-registration" | "post-user-registration" | "post-user-update" | "validate-registration-username" | "pre-user-deletion" | "post-user-deletion" | "pre-user-update" | "pre-account-action";
13
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "post-user-update" | "validate-registration-username" | "pre-user-deletion" | "post-user-deletion" | "credentials-exchange" | "pre-user-update" | "pre-account-action";
14
14
  enabled: boolean;
15
15
  synchronous: boolean;
16
16
  created_at: string;