authhero 9.11.0 → 9.12.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 (52) hide show
  1. package/dist/assets/u/widget/authhero-widget.esm.js +1 -1
  2. package/dist/assets/u/widget/{p-f94037cd.entry.js → p-74f95441.entry.js} +1 -1
  3. package/dist/authhero.cjs +292 -160
  4. package/dist/authhero.d.ts +121 -96
  5. package/dist/authhero.mjs +81495 -89257
  6. package/dist/tsconfig.types.tsbuildinfo +1 -1
  7. package/dist/types/authentication-flows/passwordless.d.ts +2 -2
  8. package/dist/types/emails/render.d.ts +2 -0
  9. package/dist/types/helpers/action-executions-cleanup.d.ts +6 -3
  10. package/dist/types/helpers/dcr/metadata-mapping.d.ts +2 -2
  11. package/dist/types/helpers/logging.d.ts +11 -3
  12. package/dist/types/helpers/reserved-claims.d.ts +19 -3
  13. package/dist/types/helpers/run-retention.d.ts +1 -1
  14. package/dist/types/helpers/saml.d.ts +1 -1
  15. package/dist/types/helpers/scopes-permissions.d.ts +16 -0
  16. package/dist/types/helpers/users-import/map.d.ts +14 -0
  17. package/dist/types/hooks/codehooks.d.ts +28 -1
  18. package/dist/types/index.d.ts +92 -92
  19. package/dist/types/routes/auth-api/index.d.ts +16 -16
  20. package/dist/types/routes/auth-api/passwordless.d.ts +14 -14
  21. package/dist/types/routes/auth-api/register/index.d.ts +2 -2
  22. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  23. package/dist/types/routes/management-api/branding.d.ts +1 -1
  24. package/dist/types/routes/management-api/client-grants.d.ts +9 -9
  25. package/dist/types/routes/management-api/clients.d.ts +8 -8
  26. package/dist/types/routes/management-api/connections.d.ts +1 -1
  27. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  28. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  29. package/dist/types/routes/management-api/failed-events.d.ts +2 -2
  30. package/dist/types/routes/management-api/forms.d.ts +126 -126
  31. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  32. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  33. package/dist/types/routes/management-api/index.d.ts +62 -62
  34. package/dist/types/routes/management-api/keys.d.ts +16 -16
  35. package/dist/types/routes/management-api/logs.d.ts +4 -4
  36. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  37. package/dist/types/routes/management-api/organizations.d.ts +4 -4
  38. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  39. package/dist/types/routes/management-api/roles.d.ts +1 -1
  40. package/dist/types/routes/management-api/tenants.d.ts +12 -12
  41. package/dist/types/routes/management-api/users.d.ts +21 -21
  42. package/dist/types/routes/universal-login/common.d.ts +6 -6
  43. package/dist/types/routes/universal-login/flow-api.d.ts +12 -12
  44. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  45. package/dist/types/routes/universal-login/index.d.ts +2 -2
  46. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  47. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  48. package/dist/types/routes/universal-login/u2-widget-page.d.ts +13 -42
  49. package/dist/types/routes/universal-login/universal-login-template.d.ts +1 -1
  50. package/dist/types/types/AuthHeroConfig.d.ts +21 -0
  51. package/dist/types/types/Bindings.d.ts +1 -0
  52. package/package.json +7 -7
@@ -239,7 +239,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
239
239
  pushed_authorization_requests_supported?: boolean | undefined;
240
240
  authorization_response_iss_parameter_supported?: boolean | undefined;
241
241
  deployment_type?: "shared" | "wfp" | undefined;
242
- provisioning_state?: "pending" | "ready" | "failed" | undefined;
242
+ provisioning_state?: "pending" | "failed" | "ready" | undefined;
243
243
  provisioning_error?: string | undefined;
244
244
  provisioning_state_changed_at?: string | undefined;
245
245
  bundle_configuration?: string | undefined;
@@ -475,7 +475,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
475
475
  custom_login_page_preview?: string | undefined;
476
476
  form_template?: string | undefined;
477
477
  addons?: Record<string, any> | undefined;
478
- token_endpoint_auth_method?: "client_secret_post" | "client_secret_basic" | "none" | "client_secret_jwt" | "private_key_jwt" | undefined;
478
+ token_endpoint_auth_method?: "none" | "private_key_jwt" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | undefined;
479
479
  client_metadata?: Record<string, string> | undefined;
480
480
  hide_sign_up_disabled_error?: boolean | undefined;
481
481
  mobile?: Record<string, any> | undefined;
@@ -1,6 +1,8 @@
1
1
  import { Context } from "hono";
2
+ import { Liquid } from "liquidjs";
2
3
  import { EmailTemplateName } from "@authhero/adapter-interfaces";
3
4
  import { Bindings, Variables } from "../types";
5
+ export declare function getLiquid(): Liquid;
4
6
  export interface RenderedEmail {
5
7
  subject: string;
6
8
  html: string;
@@ -1,12 +1,15 @@
1
1
  import { ActionExecutionsAdapter } from "@authhero/adapter-interfaces";
2
2
  export interface ActionExecutionsCleanupParams {
3
3
  /**
4
- * Days of execution history to keep. Defaults to 30.
4
+ * Days of execution history to keep. Defaults to 10, matching Auth0
5
+ * ("Executions will only be stored for 10 days after their creation").
5
6
  *
6
7
  * Unlike `codes`, these rows have no expiry — they are diagnostic history,
7
8
  * referenced from logs when debugging an action. The window is a genuine
8
9
  * retention policy: long enough to investigate a report that arrives late,
9
- * short enough that the table stops growing without bound.
10
+ * short enough that the table stops growing without bound. Rows can carry
11
+ * whatever a tenant's action wrote to `console`, so a shorter window is also
12
+ * the safer one.
10
13
  */
11
14
  retentionDays?: number;
12
15
  }
@@ -26,7 +29,7 @@ export interface ActionExecutionsCleanupParams {
26
29
  * // Cloudflare Workers scheduled handler
27
30
  * async scheduled(_event, env) {
28
31
  * await cleanupActionExecutions(dataAdapter.actionExecutions, {
29
- * retentionDays: 30,
32
+ * retentionDays: 10,
30
33
  * });
31
34
  * }
32
35
  * ```
@@ -23,11 +23,11 @@ export declare const dcrRequestSchema: z.ZodObject<{
23
23
  grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
24
  response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
25
  token_endpoint_auth_method: z.ZodOptional<z.ZodEnum<{
26
+ none: "none";
27
+ private_key_jwt: "private_key_jwt";
26
28
  client_secret_post: "client_secret_post";
27
29
  client_secret_basic: "client_secret_basic";
28
- none: "none";
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>>;
@@ -52,11 +52,19 @@ export type LogParams = {
52
52
  body?: unknown;
53
53
  };
54
54
  /**
55
- * When provided, replaces the auto-generated details object entirely.
56
- * Use this to store a compact, pre-built details payload (e.g. for webhook logs)
57
- * that fits within storage limits (Analytics Engine blob: 1024 bytes).
55
+ * When provided, replaces the auto-generated `{ request, response? }` details
56
+ * object entirely. Use this to store a compact, pre-built details payload
57
+ * (e.g. for webhook logs) that fits within storage limits (Analytics Engine
58
+ * blob: 1024 bytes). `execution_id` is still merged on top when set — pass it
59
+ * via its own field rather than inlining it here, or the request block is lost.
58
60
  */
59
61
  details?: Record<string, unknown>;
62
+ /**
63
+ * The action execution this event resulted from. Merged into `details` rather
64
+ * than replacing it, so a login log keeps its request snapshot while still
65
+ * linking to the execution (Auth0 reaches executions via the tenant logs).
66
+ */
67
+ execution_id?: string;
60
68
  /**
61
69
  * If true, wait for the log to complete before returning.
62
70
  * If false (default), execute logging asynchronously in the background.
@@ -15,9 +15,9 @@ export declare const USERINFO_RESERVED_CLAIMS: readonly ["iss", "sub", "aud", "e
15
15
  * vendor/tenant for downstream APIs while `sub` stays `auth-service`.
16
16
  * Client-bound mints keep `azp` locked (see below).
17
17
  */
18
- export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("client_id" | "scope" | "sid" | "tenant_id" | "sub" | "org_name" | "permissions" | "iat" | "org_id" | "exp" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
18
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "sid" | "scope" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "permissions" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
19
19
  /** Client-bound mints: `azp` must stay the registered client id. */
20
- export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("client_id" | "scope" | "sid" | "tenant_id" | "sub" | "org_name" | "permissions" | "iat" | "org_id" | "exp" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
20
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "sid" | "scope" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "permissions" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
21
21
  export type AccessTokenReservedClaim = (typeof ACCESS_TOKEN_RESERVED_CLAIMS)[number];
22
22
  export type IdTokenReservedClaim = (typeof ID_TOKEN_RESERVED_CLAIMS)[number];
23
23
  /**
@@ -31,7 +31,23 @@ export type ServerOwnedAccessTokenClaims = Partial<Record<AccessTokenReservedCla
31
31
  export type ServerOwnedIdTokenClaims = Partial<Record<IdTokenReservedClaim, unknown>>;
32
32
  /** Which payload a custom claim is being written to. */
33
33
  export type ClaimPayloadKind = "access_token" | "id_token" | "userinfo" | "service_token" | "client_service_token";
34
- export declare function isReservedClaim(claim: string, kind: ClaimPayloadKind): boolean;
34
+ /**
35
+ * Transitional escape hatch for `init({ unsafeAllowAzpCustomClaim: true })`.
36
+ *
37
+ * A deployment that shipped `azp` as a tenant-owned claim before this module
38
+ * existed cannot un-reserve it atomically: every downstream service reading
39
+ * `azp` has to be moved off it first, and until then reserving the name simply
40
+ * deletes the claim from the token (the mint never emits `azp` itself). The
41
+ * flag keeps those tokens intact while that migration runs.
42
+ *
43
+ * It is unsafe because `middlewares/authentication.ts` reads `azp` as the
44
+ * calling client's id, so a hook-supplied value lands in the request context
45
+ * where a registered client id is expected. Enable it only to buy time, and
46
+ * only where the hooks writing `azp` are first-party code.
47
+ */
48
+ export declare function isReservedClaim(claim: string, kind: ClaimPayloadKind, options?: {
49
+ allowAzpOverride?: boolean;
50
+ }): boolean;
35
51
  export interface ApplyCustomClaimOptions {
36
52
  /** Which payload is being written to — selects the reserved set. */
37
53
  kind: ClaimPayloadKind;
@@ -6,7 +6,7 @@ export interface RunRetentionConfig {
6
6
  codesRetentionDays?: number;
7
7
  /** Days to keep processed/dead-lettered outbox events. Default 7. */
8
8
  outboxRetentionDays?: number;
9
- /** Days of action execution history to keep. Default 30. */
9
+ /** Days of action execution history to keep. Default 10, matching Auth0. */
10
10
  actionExecutionsRetentionDays?: number;
11
11
  /**
12
12
  * Hours to keep finished bulk user-import jobs and their staged rows.
@@ -1 +1 @@
1
- export * from "@authhero/saml";
1
+ export * from "@authhero/saml/core";
@@ -41,6 +41,22 @@ export declare function userHasGlobalOrgAdminPermission(ctx: Context<{
41
41
  Bindings: Bindings;
42
42
  Variables: Variables;
43
43
  }>, tenantId: string, userId: string): Promise<boolean>;
44
+ /**
45
+ * Returns the subset of `scopes` that the resource server matching `audience`
46
+ * does not define — the scopes that would silently vanish from an issued token.
47
+ *
48
+ * Returns an empty list when no resource server matches the audience: those
49
+ * grants (control-plane, cross-tenant) have no scope catalogue to check
50
+ * against, so there is nothing to flag.
51
+ */
52
+ export declare function findUndefinedResourceServerScopes(ctx: Context<{
53
+ Bindings: Bindings;
54
+ Variables: Variables;
55
+ }>, params: {
56
+ tenantId: string;
57
+ audience: string;
58
+ scopes: string[];
59
+ }): Promise<string[]>;
44
60
  /**
45
61
  * Calculates the scopes and permissions for a user based on the audience and resource server configuration.
46
62
  * This function implements Auth0-like behavior for RBAC and token dialects.
@@ -121,6 +121,20 @@ export declare function redactEntry(entry: unknown): Record<string, unknown>;
121
121
  * import. {@link redactEntry} is applied when the row is read back out.
122
122
  */
123
123
  export declare function toStagedPayload(entry: unknown): Record<string, unknown>;
124
+ export type IdentityField = "user_id" | "email" | "username" | "phone_number";
125
+ /**
126
+ * Normalize one identity value so two spellings of the same identity compare
127
+ * equal.
128
+ *
129
+ * `email` and `username` are case-insensitive; `user_id` and `phone_number`
130
+ * are compared exactly, because lowercasing an id could collapse two genuinely
131
+ * distinct users. `entryIdentityKeys` below applies the same rule, and the
132
+ * batched import probe uses this so its in-memory lookups agree with what the
133
+ * database considers the same row — on MySQL an `email` probe is resolved with
134
+ * a case-insensitive collation and can return a different spelling than the one
135
+ * asked for.
136
+ */
137
+ export declare function identityKey(field: IdentityField, value: string): string;
124
138
  /**
125
139
  * Identity keys Auth0 dedupes an import file on: a repeat of any of these
126
140
  * within one file is an error rather than a silent overwrite.
@@ -1,5 +1,5 @@
1
1
  import { Context } from "hono";
2
- import { ActionExecutionResult, CodeExecutionLog, CodeExecutor, DataAdapters, Hook } from "@authhero/adapter-interfaces";
2
+ import { ActionExecutionLogs, ActionExecutionResult, CodeExecutionLog, CodeExecutor, DataAdapters, Hook } from "@authhero/adapter-interfaces";
3
3
  import { Bindings, Variables } from "../types";
4
4
  import { HookEvent, OnExecuteCredentialsExchangeAPI } from "../types/Hooks";
5
5
  import { EnrichedClient } from "../helpers/client";
@@ -125,6 +125,33 @@ export declare function handleCodeHook(ctx: Context<{
125
125
  code_id: string;
126
126
  hook_id: string;
127
127
  }, event: HookEvent, triggerId: string, api: CodeHookApi): Promise<HandleCodeHookOutcome | null>;
128
+ /**
129
+ * Budget, in characters, for the console output persisted with a single
130
+ * execution record. The number comes from Auth0 ("A maximum of 256 characters
131
+ * may be persistently stored for `console.log()` outputs for each Action"),
132
+ * but the unit deliberately does not: Auth0 charges the budget per Action,
133
+ * AuthHero charges it once for the whole execution, so an execution with
134
+ * several bound actions is stricter here than on Auth0.
135
+ *
136
+ * That is the point. Each executor already caps its own capture (50 entries
137
+ * x 500 chars), so the per-action axis is bounded; what was not bounded is the
138
+ * number of actions bound to one trigger multiplying that ceiling. And
139
+ * `action_executions.logs` is written on every token exchange — including
140
+ * refresh grants — so the aggregate is what needs a ceiling.
141
+ *
142
+ * It is a budget, not a per-line trim: it is spent across lines in order.
143
+ */
144
+ export declare const MAX_PERSISTED_LOG_CHARS = 256;
145
+ /**
146
+ * Trim aggregated per-action console output down to
147
+ * `MAX_PERSISTED_LOG_CHARS` characters, in order, and append an explicit
148
+ * marker so a reader can tell the record is truncated rather than complete.
149
+ *
150
+ * A line that straddles the budget is cut at the boundary and kept; the lines
151
+ * after it are dropped. The marker is appended to the last entry that retained
152
+ * output and is not itself charged against the budget.
153
+ */
154
+ export declare function capActionExecutionLogs(logs: ActionExecutionLogs, budget?: number): ActionExecutionLogs;
128
155
  /**
129
156
  * Aggregate per-action outcomes into an Auth0-shape execution record and
130
157
  * persist it via the adapter. Returns the generated execution_id (uuid)