authhero 9.26.0 → 9.27.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 (70) hide show
  1. package/dist/assets/u/widget/authhero-widget.esm.js +1 -1
  2. package/dist/assets/u/widget/index.esm.js +1 -1
  3. package/dist/assets/u/widget/{p-210f06bf.entry.js → p-ce8560f6.entry.js} +1 -1
  4. package/dist/authhero.cjs +116 -116
  5. package/dist/authhero.d.ts +838 -338
  6. package/dist/authhero.mjs +23941 -22665
  7. package/dist/tsconfig.types.tsbuildinfo +1 -1
  8. package/dist/types/authentication-flows/device-code.d.ts +11 -0
  9. package/dist/types/authentication-flows/passwordless.d.ts +4 -3
  10. package/dist/types/generated/locale-types.d.ts +16 -0
  11. package/dist/types/helpers/client.d.ts +2 -0
  12. package/dist/types/helpers/codes-cleanup.d.ts +1 -1
  13. package/dist/types/helpers/device-flow.d.ts +25 -0
  14. package/dist/types/helpers/hook-events.d.ts +8 -4
  15. package/dist/types/helpers/hook-user-payload.d.ts +2 -0
  16. package/dist/types/helpers/logging.d.ts +2 -1
  17. package/dist/types/helpers/outbox-destinations/code-hooks.d.ts +8 -3
  18. package/dist/types/helpers/outbox-destinations/webhooks.d.ts +3 -0
  19. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  20. package/dist/types/helpers/scopes-permissions.d.ts +1 -1
  21. package/dist/types/hooks/lifecycle-codehooks.d.ts +16 -0
  22. package/dist/types/hooks/user-deletion.d.ts +9 -0
  23. package/dist/types/index.d.ts +559 -331
  24. package/dist/types/routes/auth-api/device.d.ts +139 -0
  25. package/dist/types/routes/auth-api/index.d.ts +225 -24
  26. package/dist/types/routes/auth-api/passwordless.d.ts +10 -10
  27. package/dist/types/routes/auth-api/revoke.d.ts +2 -2
  28. package/dist/types/routes/auth-api/token.d.ts +82 -12
  29. package/dist/types/routes/auth-api/well-known.d.ts +2 -0
  30. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  31. package/dist/types/routes/management-api/action-triggers.d.ts +27 -2
  32. package/dist/types/routes/management-api/actions.d.ts +11 -11
  33. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  34. package/dist/types/routes/management-api/branding.d.ts +5 -5
  35. package/dist/types/routes/management-api/clients.d.ts +2 -2
  36. package/dist/types/routes/management-api/connections.d.ts +9 -9
  37. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  38. package/dist/types/routes/management-api/emails.d.ts +6 -6
  39. package/dist/types/routes/management-api/forms.d.ts +144 -144
  40. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  41. package/dist/types/routes/management-api/hook-code.d.ts +2 -2
  42. package/dist/types/routes/management-api/hooks.d.ts +56 -56
  43. package/dist/types/routes/management-api/index.d.ts +326 -301
  44. package/dist/types/routes/management-api/log-streams.d.ts +6 -6
  45. package/dist/types/routes/management-api/logs.d.ts +4 -4
  46. package/dist/types/routes/management-api/organizations.d.ts +8 -8
  47. package/dist/types/routes/management-api/prompts.d.ts +8 -8
  48. package/dist/types/routes/management-api/resource-servers.d.ts +8 -8
  49. package/dist/types/routes/management-api/roles.d.ts +1 -1
  50. package/dist/types/routes/management-api/tenant-members-requests.test.d.ts +1 -0
  51. package/dist/types/routes/management-api/tenant-members.d.ts +155 -1
  52. package/dist/types/routes/management-api/tenant-operations.d.ts +12 -10
  53. package/dist/types/routes/management-api/tenants.d.ts +26 -12
  54. package/dist/types/routes/management-api/users.d.ts +15 -15
  55. package/dist/types/routes/proxy-control-plane/tenant-members.d.ts +11 -0
  56. package/dist/types/routes/scim/index.d.ts +1 -0
  57. package/dist/types/routes/universal-login/common.d.ts +16 -12
  58. package/dist/types/routes/universal-login/flow-api.d.ts +8 -8
  59. package/dist/types/routes/universal-login/screens/device-flow.d.ts +4 -0
  60. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  61. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  62. package/dist/types/state-machines/login-session.d.ts +5 -0
  63. package/dist/types/tenant-members/request-notifier.d.ts +9 -0
  64. package/dist/types/tenant-members/request-notify.test.d.ts +1 -0
  65. package/dist/types/tenant-members/requests.d.ts +79 -0
  66. package/dist/types/tenant-members/requests.test.d.ts +1 -0
  67. package/dist/types/tenant-members/wire.d.ts +10 -0
  68. package/dist/types/types/AuthHeroConfig.d.ts +10 -0
  69. package/dist/types/types/Variables.d.ts +3 -1
  70. package/package.json +6 -6
@@ -0,0 +1,11 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ import { type DeviceContext } from "../helpers/device-flow";
3
+ import type { EnrichedClient } from "../helpers/client";
4
+ import type { GrantFlowUserResult } from "../types/GrantFlowResult";
5
+ export declare const deviceCodeGrantParamsSchema: z.ZodObject<{
6
+ grant_type: z.ZodLiteral<"urn:ietf:params:oauth:grant-type:device_code">;
7
+ device_code: z.ZodString;
8
+ client_id: z.ZodString;
9
+ client_secret: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ export declare function deviceCodeGrant(ctx: DeviceContext, params: z.infer<typeof deviceCodeGrantParamsSchema>, client: EnrichedClient): Promise<GrantFlowUserResult>;
@@ -137,7 +137,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
137
137
  friendly_name: string;
138
138
  id: string;
139
139
  parent_tenant_id?: string | null | undefined;
140
- config_sync?: "inherit-on-read" | "synced" | null | undefined;
140
+ config_sync?: "inherit-on-read" | "synced" | "detached" | null | undefined;
141
141
  config_sync_hash?: string | null | undefined;
142
142
  config_synced_at?: string | null | undefined;
143
143
  audience?: string | undefined;
@@ -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?: "pending" | "ready" | "failed" | undefined;
246
+ provisioning_state?: "pending" | "failed" | "ready" | undefined;
247
247
  provisioning_error?: string | undefined;
248
248
  provisioning_state_changed_at?: string | undefined;
249
249
  bundle_configuration?: string | undefined;
@@ -316,6 +316,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
316
316
  } | undefined;
317
317
  } | undefined;
318
318
  is_control_plane?: boolean | undefined;
319
+ has_children?: boolean | undefined;
319
320
  };
320
321
  connections: {
321
322
  created_at: string;
@@ -441,7 +442,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
441
442
  set_user_root_attributes?: "on_each_login" | "on_first_login" | "never_on_login" | undefined;
442
443
  };
443
444
  scope?: "local" | "shared" | "platform" | undefined;
444
- override?: "secrets" | "none" | "fields" | undefined;
445
+ override?: "none" | "secrets" | "fields" | undefined;
445
446
  enforce?: boolean | undefined;
446
447
  id?: string | undefined;
447
448
  display_name?: string | undefined;
@@ -254,6 +254,22 @@ export interface DeviceFlowScreen {
254
254
  clientName: string;
255
255
  }) => string;
256
256
  title: () => string;
257
+ codeLabel: () => string;
258
+ confirmTitle: () => string;
259
+ confirmDescription: () => string;
260
+ requestDescription: (vars: {
261
+ clientName: string;
262
+ }) => string;
263
+ scopesLabel: () => string;
264
+ audienceLabel: () => string;
265
+ decisionLabel: () => string;
266
+ approveText: () => string;
267
+ denyText: () => string;
268
+ completeTitle: () => string;
269
+ approvedDescription: () => string;
270
+ deniedDescription: () => string;
271
+ alreadyCompleted: () => string;
272
+ sessionExpired: () => string;
257
273
  }
258
274
  export interface EmailOtpChallengeScreen {
259
275
  buttonText: () => string;
@@ -149,6 +149,7 @@ export declare const enrichedClientSchema: z.ZodObject<{
149
149
  config_sync: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
150
150
  "inherit-on-read": "inherit-on-read";
151
151
  synced: "synced";
152
+ detached: "detached";
152
153
  }>>>;
153
154
  config_sync_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
155
  config_synced_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -355,6 +356,7 @@ export declare const enrichedClientSchema: z.ZodObject<{
355
356
  }, z.core.$strip>>;
356
357
  id: z.ZodString;
357
358
  is_control_plane: z.ZodOptional<z.ZodBoolean>;
359
+ has_children: z.ZodOptional<z.ZodBoolean>;
358
360
  }, z.core.$strip>;
359
361
  connections: z.ZodArray<z.ZodObject<{
360
362
  created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -25,4 +25,4 @@ export interface CodesCleanupParams {
25
25
  * }
26
26
  * ```
27
27
  */
28
- export declare function cleanupCodes(codes: CodesAdapter, params?: CodesCleanupParams): Promise<number>;
28
+ export declare function cleanupCodes(codes: Pick<CodesAdapter, "cleanup">, params?: CodesCleanupParams): Promise<number>;
@@ -0,0 +1,25 @@
1
+ import type { Context } from "hono";
2
+ import type { DataAdapters, LoginSession } from "@authhero/adapter-interfaces";
3
+ import type { Bindings, Variables } from "../types";
4
+ import type { EnrichedClient } from "./client";
5
+ export type DeviceContext = Context<{
6
+ Bindings: Bindings;
7
+ Variables: Variables;
8
+ }>;
9
+ export declare const DEVICE_CODE_LIFETIME = 600;
10
+ export declare const DEVICE_POLL_INTERVAL = 5;
11
+ export declare function hashDeviceCode(value: string): Promise<string>;
12
+ export declare function normalizeUserCode(value: string): string;
13
+ export declare function requireDeviceCodes(data: DataAdapters): import("@authhero/adapter-interfaces").DeviceCodesAdapter;
14
+ export declare function assertDeviceGrantAllowed(client: EnrichedClient): void;
15
+ export declare function authenticateDeviceClient(ctx: DeviceContext, client: EnrichedClient, secret?: string, basic?: boolean): void;
16
+ /** Fixed windows are persisted, so limits survive isolate restarts and work without a rate-limit binding. */
17
+ export declare function limitDeviceRequests(ctx: DeviceContext, tenantId: string, purpose: string, limit: number, identity?: string): Promise<void>;
18
+ export declare function deviceFlowData(session: LoginSession): {
19
+ deviceCodeHash?: string;
20
+ userCode?: string;
21
+ ready?: boolean;
22
+ } | undefined;
23
+ export declare function isDeviceLoginSession(raw?: string | null): boolean;
24
+ export declare function deviceBrowserCookie(session: LoginSession): string;
25
+ export declare function assertDeviceBrowser(ctx: DeviceContext, session: LoginSession): void;
@@ -5,6 +5,10 @@ type HookCtx = Context<{
5
5
  Bindings: Bindings;
6
6
  Variables: Variables;
7
7
  }>;
8
+ interface HookChangeContext {
9
+ previousUser?: User;
10
+ updates?: Partial<User>;
11
+ }
8
12
  /**
9
13
  * Whether the outbox is configured for this request. When false, hook dispatch
10
14
  * falls back to inline webhook invocation (no retry / dead-letter).
@@ -21,7 +25,7 @@ export declare function outboxEnabled(ctx: HookCtx): boolean;
21
25
  * up front, the caller can relay it with {@link relayOutboxEvent} once the
22
26
  * write commits without needing a return value from the adapter.
23
27
  */
24
- export declare function buildPostHookEvent(ctx: HookCtx, tenantId: string, triggerId: string, user: User): OutboxEventInsert | undefined;
28
+ export declare function buildPostHookEvent(ctx: HookCtx, tenantId: string, triggerId: string, user: User, changes?: HookChangeContext): OutboxEventInsert | undefined;
25
29
  /**
26
30
  * Relay an outbox event that has already been persisted (atomically with its
27
31
  * business write) so the outbox middleware picks it up for delivery. Mirrors
@@ -31,10 +35,10 @@ export declare function buildPostHookEvent(ctx: HookCtx, tenantId: string, trigg
31
35
  */
32
36
  export declare function relayOutboxEvent(ctx: HookCtx, id: string): void;
33
37
  /**
34
- * Fallback dispatch for when the outbox is not configured: invoke the
35
- * post-hook webhooks inline (fire-and-forget via `waitUntil`). No retry /
38
+ * Fallback dispatch for when the outbox is not configured: invoke post-hook
39
+ * webhooks and update/deletion Actions via `waitUntil`. No retry /
36
40
  * dead-letter support in this mode — configure the outbox for durable
37
41
  * delivery.
38
42
  */
39
- export declare function dispatchPostHookInline(ctx: HookCtx, tenantId: string, triggerId: string, user: User): void;
43
+ export declare function dispatchPostHookInline(ctx: HookCtx, tenantId: string, triggerId: string, user: User, changes?: HookChangeContext): void;
40
44
  export {};
@@ -6,3 +6,5 @@ export type ExternalUser = Omit<User, "registration_completed_at">;
6
6
  * `onExecutePostLogin` event, outbox `target.after`, etc.).
7
7
  */
8
8
  export declare function stripInternalUserFields(user: User): ExternalUser;
9
+ /** Update payloads can arrive from internal callers as well as validated APIs. */
10
+ export declare function sanitizeUserUpdates(updates: Partial<User>): Partial<User>;
@@ -58,7 +58,8 @@ export type LogParams = {
58
58
  };
59
59
  /**
60
60
  * When provided, replaces the auto-generated `{ request, response? }` details
61
- * object entirely. Use this to store a compact, pre-built details payload
61
+ * object, except for verified caller attribution. Use this to store a compact,
62
+ * pre-built details payload
62
63
  * (e.g. for webhook logs) that fits within storage limits (Analytics Engine
63
64
  * blob: 1024 bytes). `execution_id` is still merged on top when set — pass it
64
65
  * via its own field rather than inlining it here, or the request block is lost.
@@ -8,6 +8,9 @@ interface CodeHookInvocation {
8
8
  triggerId: string;
9
9
  /** Serialized user snapshot from the audit event (`target.after`). */
10
10
  user?: unknown;
11
+ userId?: string;
12
+ previousUser?: unknown;
13
+ updates?: unknown;
11
14
  /** Serialized request context from the audit event. */
12
15
  request?: unknown;
13
16
  }
@@ -35,9 +38,9 @@ interface CodeHookInvocation {
35
38
  * Constructed per-request (via `getDestinations(ctx)`) so it can close over
36
39
  * `ctx.env.codeExecutor`. The same class is used by the cron `drainOutbox`
37
40
  * safety net when a `codeExecutor` is supplied to `createDefaultDestinations`.
38
- * When no executor is configured, code hooks cannot run (nor be deployed), so
39
- * `deliver` is a no-op success — matching the inline `handleCodeHook` which
40
- * returns `null` without an executor.
41
+ * Missing executors fail delivery for post-update/deletion so the event can be
42
+ * retried when the configuration is repaired. Registration retains its legacy
43
+ * no-op behavior without an executor.
41
44
  */
42
45
  export declare class CodeHookDestination implements EventDestination {
43
46
  name: string;
@@ -48,7 +51,9 @@ export declare class CodeHookDestination implements EventDestination {
48
51
  logCapture?: ActionExecutionLogCapture;
49
52
  });
50
53
  accepts(event: AuditEvent): boolean;
54
+ /** Recover the user write and stable delivery ID from a persisted hook event. */
51
55
  transform(event: AuditEvent): CodeHookInvocation;
56
+ /** Run matching Actions, record outcomes, and fail delivery when the relay must retry. */
52
57
  deliver(invocations: CodeHookInvocation[]): Promise<void>;
53
58
  /**
54
59
  * Fetch every hook for the tenant, paging past the adapter's default page
@@ -15,6 +15,8 @@ interface WebhookInvocation {
15
15
  trigger_id: string;
16
16
  user?: unknown;
17
17
  request?: unknown;
18
+ previous_user?: unknown;
19
+ updates?: unknown;
18
20
  };
19
21
  }
20
22
  export interface WebhookDestinationOptions {
@@ -49,6 +51,7 @@ export declare class WebhookDestination implements EventDestination {
49
51
  private webhookInvoker?;
50
52
  constructor(hooks: HooksAdapter, getServiceToken: GetServiceToken, options?: WebhookDestinationOptions);
51
53
  accepts(event: AuditEvent): boolean;
54
+ /** Build the webhook payload from the event's committed user and update snapshots. */
52
55
  transform(event: AuditEvent): WebhookInvocation;
53
56
  deliver(events: WebhookInvocation[]): Promise<void>;
54
57
  private invokeCustom;
@@ -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: ("tenant_id" | "client_id" | "org_name" | "sub" | "scope" | "sid" | "permissions" | "jti" | "org_id" | "iat" | "exp" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
17
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "sub" | "org_name" | "scope" | "sid" | "permissions" | "iat" | "jti" | "org_id" | "exp" | "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: ("tenant_id" | "client_id" | "org_name" | "sub" | "scope" | "sid" | "permissions" | "jti" | "org_id" | "iat" | "exp" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
19
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "sub" | "org_name" | "scope" | "sid" | "permissions" | "iat" | "jti" | "org_id" | "exp" | "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
  /**
@@ -13,7 +13,7 @@ interface ClientCredentialsScopesAndPermissionsParams extends BaseScopesAndPermi
13
13
  userId?: never;
14
14
  }
15
15
  interface UserBasedScopesAndPermissionsParams extends BaseScopesAndPermissionsParams {
16
- grantType?: GrantType.AuthorizationCode | GrantType.RefreshToken | GrantType.Password | GrantType.Passwordless | GrantType.OTP | GrantType.TokenExchange | undefined;
16
+ grantType?: GrantType.DeviceCode | GrantType.AuthorizationCode | GrantType.RefreshToken | GrantType.Password | GrantType.Passwordless | GrantType.OTP | GrantType.TokenExchange | undefined;
17
17
  userId: string;
18
18
  }
19
19
  export type CalculateScopesAndPermissionsParams = ClientCredentialsScopesAndPermissionsParams | UserBasedScopesAndPermissionsParams;
@@ -0,0 +1,16 @@
1
+ import { Context } from "hono";
2
+ import { Bindings, Variables } from "../types";
3
+ import { CodeHookEventInput } from "./codehooks";
4
+ /** Blocking policies run before signup validation or a write, and fail closed. */
5
+ export declare function runBlockingActions(ctx: Context<{
6
+ Bindings: Bindings;
7
+ Variables: Variables;
8
+ }>, tenantId: string, triggerId: "validate-registration-username" | "pre-user-update" | "pre-user-deletion", event: CodeHookEventInput): Promise<{
9
+ allowed: boolean;
10
+ reason?: string;
11
+ }>;
12
+ /** Cancel lifecycle writes when a blocking Action denies or fails. */
13
+ export declare function runPreUserActions(ctx: Context<{
14
+ Bindings: Bindings;
15
+ Variables: Variables;
16
+ }>, tenantId: string, triggerId: "pre-user-update" | "pre-user-deletion", event: CodeHookEventInput): Promise<void>;
@@ -12,3 +12,12 @@ export declare function createUserDeletionHooks(ctx: Context<{
12
12
  Bindings: Bindings;
13
13
  Variables: Variables;
14
14
  }>, data: DataAdapters): (tenant_id: string, user_id: string) => Promise<boolean>;
15
+ /**
16
+ * Approve deletion before a caller performs retryable access/mapping cleanup.
17
+ * The returned commit runs the existing transactional delete and post hooks;
18
+ * it never repeats pre hooks. If cleanup fails, the user still exists for retry.
19
+ */
20
+ export declare function prepareUserDeletion(ctx: Context<{
21
+ Bindings: Bindings;
22
+ Variables: Variables;
23
+ }>, data: DataAdapters, tenant_id: string, user_id: string): Promise<(() => Promise<boolean>) | null>;