authhero 9.30.0 → 9.33.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 (67) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +73 -73
  3. package/dist/authhero.d.ts +498 -270
  4. package/dist/authhero.mjs +11270 -10741
  5. package/dist/mfa-attempts-DNgUKmta.js +275 -0
  6. package/dist/{mfa-attempts-CQiD6hxP.mjs → mfa-attempts-dhkGMzI5.mjs} +6287 -5852
  7. package/dist/{passkey-enrollment-D_WVyvv2.js → passkey-enrollment-B_o8pQ1z.js} +1 -1
  8. package/dist/tsconfig.types.tsbuildinfo +1 -1
  9. package/dist/types/authentication-flows/common.d.ts +12 -1
  10. package/dist/types/authentication-flows/passwordless.d.ts +16 -5
  11. package/dist/types/authentication-flows/refresh-token.d.ts +1 -0
  12. package/dist/types/helpers/cimd.d.ts +8 -0
  13. package/dist/types/helpers/client.d.ts +17 -1
  14. package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
  15. package/dist/types/helpers/login-session-tenant.d.ts +22 -0
  16. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  17. package/dist/types/helpers/session-transfer.d.ts +158 -0
  18. package/dist/types/hooks/lifecycle-codehooks.d.ts +22 -0
  19. package/dist/types/hooks/pre-account-action.d.ts +65 -0
  20. package/dist/types/index.d.ts +397 -267
  21. package/dist/types/routes/auth-api/authorize.d.ts +6 -0
  22. package/dist/types/routes/auth-api/index.d.ts +44 -27
  23. package/dist/types/routes/auth-api/oidc-logout.d.ts +3 -3
  24. package/dist/types/routes/auth-api/passwordless.d.ts +12 -12
  25. package/dist/types/routes/auth-api/register/index.d.ts +2 -2
  26. package/dist/types/routes/auth-api/token.d.ts +21 -10
  27. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  28. package/dist/types/routes/management-api/actions.d.ts +1 -1
  29. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  30. package/dist/types/routes/management-api/branding.d.ts +14 -14
  31. package/dist/types/routes/management-api/clients.d.ts +86 -18
  32. package/dist/types/routes/management-api/connections.d.ts +7 -7
  33. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  34. package/dist/types/routes/management-api/failed-events.d.ts +2 -2
  35. package/dist/types/routes/management-api/forms.d.ts +144 -144
  36. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  37. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  38. package/dist/types/routes/management-api/hooks.d.ts +7 -7
  39. package/dist/types/routes/management-api/index.d.ts +368 -255
  40. package/dist/types/routes/management-api/keys.d.ts +8 -8
  41. package/dist/types/routes/management-api/logs.d.ts +4 -4
  42. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  43. package/dist/types/routes/management-api/organizations.d.ts +2 -2
  44. package/dist/types/routes/management-api/prompts.d.ts +6 -6
  45. package/dist/types/routes/management-api/refresh_tokens.d.ts +5 -0
  46. package/dist/types/routes/management-api/sessions.d.ts +5 -0
  47. package/dist/types/routes/management-api/tenant-operations.d.ts +9 -9
  48. package/dist/types/routes/management-api/tenants.d.ts +7 -7
  49. package/dist/types/routes/management-api/themes.d.ts +9 -9
  50. package/dist/types/routes/management-api/users.d.ts +42 -12
  51. package/dist/types/routes/saml/index.d.ts +6 -6
  52. package/dist/types/routes/saml/samlp.d.ts +6 -6
  53. package/dist/types/routes/universal-login/common.d.ts +39 -12
  54. package/dist/types/routes/universal-login/flow-api.d.ts +12 -12
  55. package/dist/types/routes/universal-login/impersonate.d.ts +2 -2
  56. package/dist/types/routes/universal-login/index.d.ts +2 -2
  57. package/dist/types/routes/universal-login/screens/account-helpers.d.ts +27 -1
  58. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  59. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  60. package/dist/types/state-machines/login-session.d.ts +2 -0
  61. package/dist/types/types/GrantFlowResult.d.ts +13 -0
  62. package/dist/types/types/Hooks.d.ts +71 -0
  63. package/dist/types/types/Variables.d.ts +12 -1
  64. package/dist/types/utils/cookies.d.ts +15 -0
  65. package/dist/types/utils/session-transfer-token.d.ts +56 -0
  66. package/package.json +6 -6
  67. package/dist/mfa-attempts-DwATCXqC.js +0 -254
@@ -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;
@@ -391,7 +391,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
391
391
  } | undefined;
392
392
  unique?: boolean | undefined;
393
393
  profile_required?: boolean | undefined;
394
- verification_method?: "link" | "code" | undefined;
394
+ verification_method?: "code" | "link" | undefined;
395
395
  } | undefined;
396
396
  username?: {
397
397
  identifier?: {
@@ -464,7 +464,17 @@ export declare function passwordlessGrantUser(ctx: Context<{
464
464
  client_aliases?: string[] | undefined;
465
465
  allowed_clients?: string[] | undefined;
466
466
  allowed_logout_urls?: string[] | undefined;
467
- session_transfer?: Record<string, any> | undefined;
467
+ session_transfer?: {
468
+ [x: string]: unknown;
469
+ can_create_session_transfer_token?: boolean | undefined;
470
+ enforce_cascade_revocation?: boolean | undefined;
471
+ allowed_authentication_methods?: ("query" | "cookie")[] | undefined;
472
+ enforce_device_binding?: "none" | "ip" | "asn" | undefined;
473
+ allow_refresh_token?: boolean | undefined;
474
+ enforce_online_refresh_tokens?: boolean | undefined;
475
+ allow_onward_transfer?: boolean | undefined;
476
+ trust_forwarded_ip?: boolean | undefined;
477
+ } | undefined;
468
478
  oidc_logout?: {
469
479
  [x: string]: unknown;
470
480
  backchannel_logout_urls?: string[] | undefined;
@@ -483,7 +493,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
483
493
  custom_login_page_preview?: string | undefined;
484
494
  form_template?: string | undefined;
485
495
  addons?: Record<string, any> | undefined;
486
- token_endpoint_auth_method?: "none" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | "private_key_jwt" | undefined;
496
+ token_endpoint_auth_method?: "none" | "private_key_jwt" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | undefined;
487
497
  client_metadata?: Record<string, string> | undefined;
488
498
  hide_sign_up_disabled_error?: boolean | undefined;
489
499
  mobile?: Record<string, any> | undefined;
@@ -568,9 +578,10 @@ export declare function passwordlessGrantUser(ctx: Context<{
568
578
  strategy_type: string;
569
579
  } | undefined;
570
580
  authenticated_at?: string | undefined;
581
+ tenant_id?: string | undefined;
571
582
  };
572
- connectionType: "email" | "sms" | "username";
573
- authConnection: "email" | "sms" | "username";
583
+ connectionType: "sms" | "email" | "username";
584
+ authConnection: "sms" | "email" | "username";
574
585
  session_id: string | undefined;
575
586
  authParams: {
576
587
  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;
@@ -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<{
@@ -24,10 +24,10 @@ export declare const dcrRequestSchema: z.ZodObject<{
24
24
  response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
25
  token_endpoint_auth_method: z.ZodOptional<z.ZodEnum<{
26
26
  none: "none";
27
+ private_key_jwt: "private_key_jwt";
27
28
  client_secret_post: "client_secret_post";
28
29
  client_secret_basic: "client_secret_basic";
29
30
  client_secret_jwt: "client_secret_jwt";
30
- private_key_jwt: "private_key_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: ("sub" | "sid" | "client_id" | "scope" | "tenant_id" | "org_name" | "jti" | "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: ("client_id" | "sid" | "scope" | "tenant_id" | "org_name" | "jti" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "gty" | "permissions" | "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: ("sub" | "sid" | "client_id" | "scope" | "tenant_id" | "org_name" | "jti" | "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: ("client_id" | "sid" | "scope" | "tenant_id" | "org_name" | "jti" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "gty" | "permissions" | "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 {};
@@ -1,6 +1,28 @@
1
1
  import { Context } from "hono";
2
2
  import { Bindings, Variables } from "../types";
3
3
  import { CodeHookEventInput } from "./codehooks";
4
+ /**
5
+ * The enabled code hooks bound to `triggerId`, highest priority first. Reads
6
+ * through the executor data, so platform-scoped policies hidden from
7
+ * management reads are included.
8
+ */
9
+ export declare function listEnabledCodeHooks(ctx: Context<{
10
+ Bindings: Bindings;
11
+ Variables: Variables;
12
+ }>, tenantId: string, triggerId: string): Promise<{
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
+ enabled: boolean;
15
+ synchronous: boolean;
16
+ created_at: string;
17
+ updated_at: string;
18
+ hook_id: string;
19
+ code_id: string;
20
+ scope?: "shared" | "local" | "platform" | undefined;
21
+ override?: "none" | "secrets" | "fields" | undefined;
22
+ enforce?: boolean | undefined;
23
+ priority?: number | undefined;
24
+ metadata?: Record<string, unknown> | undefined;
25
+ }[]>;
4
26
  /** Blocking policies run before signup validation or a write, and fail closed. */
5
27
  export declare function runBlockingActions(ctx: Context<{
6
28
  Bindings: Bindings;
@@ -0,0 +1,65 @@
1
+ import { Context } from "hono";
2
+ import { User } from "@authhero/adapter-interfaces";
3
+ import { Bindings, Variables } from "../types";
4
+ import { AccountActionOperation } from "../types/Hooks";
5
+ import { EnrichedClient } from "../helpers/client";
6
+ export declare const PRE_ACCOUNT_ACTION_TRIGGER = "pre-account-action";
7
+ /**
8
+ * Host wait for the `onExecutePreAccountAction` config callback, matching the
9
+ * bound on code Actions. A callback that never settles must not leave account
10
+ * requests hanging.
11
+ */
12
+ export declare const PRE_ACCOUNT_ACTION_TIMEOUT_MS = 5000;
13
+ /** Shown when an action denies without a reason, or fails. */
14
+ export declare const DEFAULT_ACCOUNT_ACTION_DENIAL = "This action isn't available for your account.";
15
+ export type PreAccountActionDecision = {
16
+ type: "continue";
17
+ } | {
18
+ type: "redirect";
19
+ url: string;
20
+ } | {
21
+ type: "deny";
22
+ reason: string;
23
+ };
24
+ /**
25
+ * Thrown by the universal-login account screens when a `pre-account-action`
26
+ * Action denies the operation. The universal-login error handler renders
27
+ * `reason` on the branded error page (other error messages are replaced by a
28
+ * generic text there, which would hide the tenant's explanation).
29
+ */
30
+ export declare class AccountActionDeniedError extends Error {
31
+ readonly reason: string;
32
+ readonly status = 403;
33
+ constructor(reason: string);
34
+ }
35
+ /**
36
+ * Run the `pre-account-action` trigger: the `onExecutePreAccountAction` config
37
+ * hook first, then the code Actions bound to the trigger in priority order.
38
+ * The first one that redirects or denies decides the outcome and later ones
39
+ * don't run. An Action that throws or fails denies the operation (fail
40
+ * closed), like the other blocking triggers.
41
+ */
42
+ export declare function runPreAccountAction(ctx: Context<{
43
+ Bindings: Bindings;
44
+ Variables: Variables;
45
+ }>, params: {
46
+ tenantId: string;
47
+ operation: AccountActionOperation;
48
+ /**
49
+ * The user, or a loader for it. A loader only runs when something is bound
50
+ * to the trigger, so screens don't pay for the lookup otherwise.
51
+ */
52
+ user?: User | (() => Promise<User | undefined>);
53
+ client?: EnrichedClient;
54
+ details?: Record<string, string>;
55
+ }): Promise<PreAccountActionDecision>;
56
+ /**
57
+ * Run the trigger from a universal-login route and act on the result: throws
58
+ * `RedirectException` to send the user elsewhere and `AccountActionDeniedError`
59
+ * to stop the operation. Both are rendered by the universal-login error
60
+ * handler. Returns normally when the operation may continue.
61
+ */
62
+ export declare function enforcePreAccountAction(ctx: Context<{
63
+ Bindings: Bindings;
64
+ Variables: Variables;
65
+ }>, params: Parameters<typeof runPreAccountAction>[1]): Promise<void>;