authhero 9.25.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 (91) 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 +157 -157
  5. package/dist/authhero.d.ts +914 -264
  6. package/dist/authhero.mjs +27723 -25733
  7. package/dist/tsconfig.types.tsbuildinfo +1 -1
  8. package/dist/types/adapters/createEncryptedDataAdapter.d.ts +2 -1
  9. package/dist/types/adapters/index.d.ts +1 -1
  10. package/dist/types/authentication-flows/device-code.d.ts +11 -0
  11. package/dist/types/authentication-flows/passwordless.d.ts +9 -5
  12. package/dist/types/errors/management-api-error.d.ts +113 -0
  13. package/dist/types/generated/locale-types.d.ts +16 -0
  14. package/dist/types/helpers/client.d.ts +8 -0
  15. package/dist/types/helpers/codes-cleanup.d.ts +1 -1
  16. package/dist/types/helpers/control-plane-caller.d.ts +15 -0
  17. package/dist/types/helpers/device-flow.d.ts +25 -0
  18. package/dist/types/helpers/hook-events.d.ts +8 -4
  19. package/dist/types/helpers/hook-user-payload.d.ts +2 -0
  20. package/dist/types/helpers/logging.d.ts +2 -1
  21. package/dist/types/helpers/outbox-destinations/code-hooks.d.ts +8 -3
  22. package/dist/types/helpers/outbox-destinations/webhooks.d.ts +3 -0
  23. package/dist/types/helpers/platform-rows.d.ts +27 -0
  24. package/dist/types/helpers/request-data.d.ts +12 -0
  25. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  26. package/dist/types/helpers/scopes-permissions.d.ts +1 -1
  27. package/dist/types/helpers/synced-rows.d.ts +1 -0
  28. package/dist/types/hooks/lifecycle-codehooks.d.ts +16 -0
  29. package/dist/types/hooks/user-deletion.d.ts +9 -0
  30. package/dist/types/index.d.ts +540 -256
  31. package/dist/types/routes/auth-api/account.d.ts +2 -2
  32. package/dist/types/routes/auth-api/device.d.ts +139 -0
  33. package/dist/types/routes/auth-api/index.d.ts +238 -37
  34. package/dist/types/routes/auth-api/passwordless.d.ts +14 -14
  35. package/dist/types/routes/auth-api/revoke.d.ts +8 -8
  36. package/dist/types/routes/auth-api/token.d.ts +82 -12
  37. package/dist/types/routes/auth-api/well-known.d.ts +3 -1
  38. package/dist/types/routes/management-api/action-executions.d.ts +2 -2
  39. package/dist/types/routes/management-api/action-triggers.d.ts +27 -2
  40. package/dist/types/routes/management-api/actions.d.ts +12 -12
  41. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  42. package/dist/types/routes/management-api/branding.d.ts +4 -4
  43. package/dist/types/routes/management-api/client-grants.d.ts +13 -0
  44. package/dist/types/routes/management-api/clients.d.ts +17 -4
  45. package/dist/types/routes/management-api/connections.d.ts +27 -14
  46. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  47. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  48. package/dist/types/routes/management-api/emails.d.ts +6 -6
  49. package/dist/types/routes/management-api/failed-events.d.ts +2 -2
  50. package/dist/types/routes/management-api/flows.d.ts +8 -8
  51. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  52. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  53. package/dist/types/routes/management-api/hooks.d.ts +42 -42
  54. package/dist/types/routes/management-api/index.d.ts +288 -211
  55. package/dist/types/routes/management-api/keys.d.ts +16 -16
  56. package/dist/types/routes/management-api/log-streams.d.ts +6 -6
  57. package/dist/types/routes/management-api/logs.d.ts +4 -4
  58. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  59. package/dist/types/routes/management-api/organizations.d.ts +5 -5
  60. package/dist/types/routes/management-api/prompts.d.ts +8 -8
  61. package/dist/types/routes/management-api/resource-servers.d.ts +21 -8
  62. package/dist/types/routes/management-api/roles.d.ts +1 -1
  63. package/dist/types/routes/management-api/rollouts.d.ts +261 -0
  64. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  65. package/dist/types/routes/management-api/tenant-members-requests.test.d.ts +1 -0
  66. package/dist/types/routes/management-api/tenant-members.d.ts +155 -1
  67. package/dist/types/routes/management-api/tenant-operations.d.ts +17 -10
  68. package/dist/types/routes/management-api/tenants.d.ts +39 -13
  69. package/dist/types/routes/management-api/token-exchange-profiles.d.ts +6 -6
  70. package/dist/types/routes/management-api/users.d.ts +20 -20
  71. package/dist/types/routes/proxy-control-plane/tenant-members.d.ts +11 -0
  72. package/dist/types/routes/scim/index.d.ts +1 -0
  73. package/dist/types/routes/universal-login/common.d.ts +26 -10
  74. package/dist/types/routes/universal-login/flow-api.d.ts +4 -4
  75. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  76. package/dist/types/routes/universal-login/index.d.ts +2 -2
  77. package/dist/types/routes/universal-login/screens/device-flow.d.ts +4 -0
  78. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  79. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  80. package/dist/types/state-machines/login-session.d.ts +6 -1
  81. package/dist/types/tenant-members/request-notifier.d.ts +9 -0
  82. package/dist/types/tenant-members/request-notify.test.d.ts +1 -0
  83. package/dist/types/tenant-members/requests.d.ts +79 -0
  84. package/dist/types/tenant-members/requests.test.d.ts +1 -0
  85. package/dist/types/tenant-members/wire.d.ts +10 -0
  86. package/dist/types/types/AuthHeroConfig.d.ts +47 -1
  87. package/dist/types/types/Bindings.d.ts +2 -1
  88. package/dist/types/types/Variables.d.ts +8 -1
  89. package/dist/types/utils/field-encryption.d.ts +7 -0
  90. package/dist/types/utils/jwks.d.ts +2 -2
  91. package/package.json +6 -6
@@ -22,7 +22,8 @@ interface EncryptionOptions {
22
22
  * Encrypted columns: clients.client_secret, connections.options
23
23
  * (client_secret/app_secret/twilio_token/configuration.client_secret),
24
24
  * email_providers.credentials, authentication_methods.totp_secret,
25
- * migration_sources.credentials.client_secret.
25
+ * migration_sources.credentials.client_secret, actions.secrets[].value,
26
+ * action_versions.secrets[].value, hook_code.secrets values.
26
27
  *
27
28
  * clientConnections.listByClient is also wrapped so its returned Connection
28
29
  * objects are decrypted — getEnrichedClient uses this path to load connections
@@ -1,5 +1,5 @@
1
1
  export * from "./cache";
2
2
  export { createEncryptedDataAdapter, createEncryptedDataAdapterWithKeyRing, } from "./createEncryptedDataAdapter";
3
3
  export type { EncryptKeyIdResolver } from "./createEncryptedDataAdapter";
4
- export { loadEncryptionKey, encryptField, decryptField, encryptFieldWithRing, decryptFieldWithRing, parseKeyId, isEncrypted, } from "../utils/field-encryption";
4
+ export { loadEncryptionKey, encryptField, decryptField, encryptFieldWithRing, decryptFieldWithRing, parseKeyId, isEncrypted, canDecrypt, } from "../utils/field-encryption";
5
5
  export type { KeyRing } from "../utils/field-encryption";
@@ -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,6 +137,9 @@ 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" | "detached" | null | undefined;
141
+ config_sync_hash?: string | null | undefined;
142
+ config_synced_at?: string | null | undefined;
140
143
  audience?: string | undefined;
141
144
  picture_url?: string | undefined;
142
145
  support_email?: string | undefined;
@@ -240,7 +243,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
240
243
  pushed_authorization_requests_supported?: boolean | undefined;
241
244
  authorization_response_iss_parameter_supported?: boolean | undefined;
242
245
  deployment_type?: "shared" | "wfp" | undefined;
243
- provisioning_state?: "pending" | "ready" | "failed" | undefined;
246
+ provisioning_state?: "pending" | "failed" | "ready" | undefined;
244
247
  provisioning_error?: string | undefined;
245
248
  provisioning_state_changed_at?: string | undefined;
246
249
  bundle_configuration?: string | undefined;
@@ -313,6 +316,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
313
316
  } | undefined;
314
317
  } | undefined;
315
318
  is_control_plane?: boolean | undefined;
319
+ has_children?: boolean | undefined;
316
320
  };
317
321
  connections: {
318
322
  created_at: string;
@@ -387,7 +391,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
387
391
  } | undefined;
388
392
  unique?: boolean | undefined;
389
393
  profile_required?: boolean | undefined;
390
- verification_method?: "link" | "code" | undefined;
394
+ verification_method?: "code" | "link" | undefined;
391
395
  } | undefined;
392
396
  username?: {
393
397
  identifier?: {
@@ -437,7 +441,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
437
441
  } | undefined;
438
442
  set_user_root_attributes?: "on_each_login" | "on_first_login" | "never_on_login" | undefined;
439
443
  };
440
- scope?: "shared" | "local" | "platform" | undefined;
444
+ scope?: "local" | "shared" | "platform" | undefined;
441
445
  override?: "none" | "secrets" | "fields" | undefined;
442
446
  enforce?: boolean | undefined;
443
447
  id?: string | undefined;
@@ -565,8 +569,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
565
569
  } | undefined;
566
570
  authenticated_at?: string | undefined;
567
571
  };
568
- connectionType: "username" | "email" | "sms";
569
- authConnection: "username" | "email" | "sms";
572
+ connectionType: "email" | "username" | "sms";
573
+ authConnection: "email" | "username" | "sms";
570
574
  session_id: string | undefined;
571
575
  authParams: {
572
576
  audience?: string | undefined;
@@ -0,0 +1,113 @@
1
+ import { Context } from "hono";
2
+ import { ContentfulStatusCode } from "hono/utils/http-status";
3
+ import { JSONHTTPException } from "./json-http-exception";
4
+ /**
5
+ * Management API errors in Auth0's wire shape. Auth0 SDKs (go-auth0, the
6
+ * Terraform provider, node-auth0) parse `{ statusCode, error, message,
7
+ * errorCode }` and branch on `errorCode`.
8
+ *
9
+ * The bodies below are a superset of Auth0's: where Auth0 returns a message or
10
+ * errorCode we return the same bytes (captured from a live tenant, see
11
+ * apps/docs/api/error-codes.md), and where Auth0 omits `errorCode` we add one.
12
+ * Every added code is listed under "AuthHero extensions" in that doc page —
13
+ * keep the two in sync.
14
+ */
15
+ export declare const ERROR_TEXT_BY_STATUS: Record<number, string>;
16
+ export interface ManagementErrorBody {
17
+ statusCode: number;
18
+ error: string;
19
+ message: string;
20
+ errorCode?: string;
21
+ }
22
+ export declare function managementErrorBody(status: number, message: string, errorCode?: string): ManagementErrorBody;
23
+ export declare function managementError(status: ContentfulStatusCode, message: string, errorCode?: string): JSONHTTPException;
24
+ /**
25
+ * 404s per resource. Messages marked "auth0" are byte-identical to Auth0
26
+ * (including its inconsistent trailing periods); the rest are AuthHero
27
+ * resources or Auth0 resources without an errorCode, and follow the
28
+ * `The <resource> does not exist.` / `inexistent_<resource>` convention.
29
+ */
30
+ export declare const notFound: {
31
+ user: () => JSONHTTPException;
32
+ users: () => JSONHTTPException;
33
+ client: () => JSONHTTPException;
34
+ clientOnUpdate: () => JSONHTTPException;
35
+ connection: () => JSONHTTPException;
36
+ resourceServer: () => JSONHTTPException;
37
+ resourceServerByIdentifier: (identifier: string) => JSONHTTPException;
38
+ clientGrant: () => JSONHTTPException;
39
+ log: () => JSONHTTPException;
40
+ job: () => JSONHTTPException;
41
+ customDomain: (id: string) => JSONHTTPException;
42
+ key: (kid: string) => JSONHTTPException;
43
+ hook: () => JSONHTTPException;
44
+ enrollment: () => JSONHTTPException;
45
+ role: () => JSONHTTPException;
46
+ roleOnUpdate: () => JSONHTTPException;
47
+ organization: () => JSONHTTPException;
48
+ action: () => JSONHTTPException;
49
+ tenant: () => JSONHTTPException;
50
+ invitation: () => JSONHTTPException;
51
+ member: () => JSONHTTPException;
52
+ identity: () => JSONHTTPException;
53
+ session: () => JSONHTTPException;
54
+ refreshToken: () => JSONHTTPException;
55
+ grant: () => JSONHTTPException;
56
+ logStream: () => JSONHTTPException;
57
+ form: () => JSONHTTPException;
58
+ flow: () => JSONHTTPException;
59
+ emailTemplate: () => JSONHTTPException;
60
+ emailProvider: () => JSONHTTPException;
61
+ authenticationMethod: () => JSONHTTPException;
62
+ actionExecution: () => JSONHTTPException;
63
+ actionVersion: () => JSONHTTPException;
64
+ hookCode: () => JSONHTTPException;
65
+ failedEvent: () => JSONHTTPException;
66
+ migrationSource: () => JSONHTTPException;
67
+ proxyRoute: () => JSONHTTPException;
68
+ scimConfiguration: () => JSONHTTPException;
69
+ scimToken: () => JSONHTTPException;
70
+ tenantOperation: () => JSONHTTPException;
71
+ rollout: () => JSONHTTPException;
72
+ tokenExchangeProfile: () => JSONHTTPException;
73
+ };
74
+ /**
75
+ * 409s. `userExists`, `resourceServer` and `organizationName` are Auth0's
76
+ * bodies (the "identifer" typo is Auth0's, kept byte-identical); the
77
+ * organization errorCode is added.
78
+ */
79
+ export declare const conflict: {
80
+ userExists: () => JSONHTTPException;
81
+ resourceServer: (identifier: string) => JSONHTTPException;
82
+ organizationName: () => JSONHTTPException;
83
+ /** Any other AuthHero conflict: own message, shared code. */
84
+ other: (message: string) => JSONHTTPException;
85
+ };
86
+ export declare const authErrors: {
87
+ missingAuthentication: () => JSONHTTPException;
88
+ invalidToken: (message?: string) => JSONHTTPException;
89
+ insufficientScope: (expected: string[]) => JSONHTTPException;
90
+ };
91
+ /**
92
+ * Formats zod issues the way Auth0 does:
93
+ * `Payload validation error: 'Missing required property: name'.`, joined with
94
+ * ` (also) ` when there are several. Auth0 also appends each property's
95
+ * schema description, which we don't have at this layer.
96
+ */
97
+ export declare function formatValidationMessage(target: string, issues: unknown[], data: unknown): ManagementErrorBody;
98
+ /**
99
+ * `defaultHook` for every management-api OpenAPIHono app. The hook is the only
100
+ * place zod-openapi exposes which part of the request failed, which is what
101
+ * picks Auth0's invalid_body / invalid_query_string / invalid_uri code.
102
+ */
103
+ export declare function managementValidationHook(result: {
104
+ success: boolean;
105
+ target: string;
106
+ data?: unknown;
107
+ error?: unknown;
108
+ }, ctx: Context): (Response & import("hono").TypedResponse<{
109
+ statusCode: number;
110
+ error: string;
111
+ message: string;
112
+ errorCode?: string | undefined;
113
+ }, 400, "json">) | 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;
@@ -146,6 +146,13 @@ export declare const enrichedClientSchema: z.ZodObject<{
146
146
  created_at: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string, string | null>>;
147
147
  updated_at: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string, string | null>>;
148
148
  parent_tenant_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
149
+ config_sync: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
150
+ "inherit-on-read": "inherit-on-read";
151
+ synced: "synced";
152
+ detached: "detached";
153
+ }>>>;
154
+ config_sync_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
155
+ config_synced_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
149
156
  audience: z.ZodOptional<z.ZodString>;
150
157
  friendly_name: z.ZodString;
151
158
  picture_url: z.ZodOptional<z.ZodString>;
@@ -349,6 +356,7 @@ export declare const enrichedClientSchema: z.ZodObject<{
349
356
  }, z.core.$strip>>;
350
357
  id: z.ZodString;
351
358
  is_control_plane: z.ZodOptional<z.ZodBoolean>;
359
+ has_children: z.ZodOptional<z.ZodBoolean>;
352
360
  }, z.core.$strip>;
353
361
  connections: z.ZodArray<z.ZodObject<{
354
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,15 @@
1
+ /**
2
+ * True when the caller's token comes from the control plane (or the deployment
3
+ * is single-tenant, which is effectively a control plane). Organization-scoped
4
+ * tokens are tenant-level credentials and do not count.
5
+ */
6
+ export declare function callerIsControlPlane(ctx: {
7
+ env: {
8
+ data: {
9
+ multiTenancyConfig?: {
10
+ controlPlaneTenantId?: string;
11
+ };
12
+ };
13
+ };
14
+ var: object;
15
+ }): boolean;
@@ -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;
@@ -0,0 +1,27 @@
1
+ import { DataAdapters } from "@authhero/adapter-interfaces";
2
+ /**
3
+ * Hides `scope: "platform"` rows that a config sync delivered into a tenant
4
+ * from that tenant's own management API. Such rows must run (the code-hook
5
+ * executor reads them through other adapters) but their code and secrets are
6
+ * never shown, listed, edited or referenced by the tenant's admins.
7
+ *
8
+ * A row is hidden when it is platform-scoped **and** has a synced id. The
9
+ * control plane's own origin rows are platform-scoped too, but they are
10
+ * owned by the tenant that publishes them and stay visible there. Operators
11
+ * (control-plane credentials) see everything.
12
+ *
13
+ * A hidden row behaves as if it did not exist: `get` returns `null`, lists omit
14
+ * it, and writes against it are refused as not found. List totals and
15
+ * checkpoint cursors are not adjusted for hidden rows.
16
+ *
17
+ * Limit: this protects against the tenant's management API. The code and
18
+ * (encrypted) secrets are still stored in the tenant's database, so anyone
19
+ * with access to the database or the worker environment can read them.
20
+ */
21
+ export interface PlatformRowsOptions {
22
+ /** The tenant whose management API is being served. */
23
+ tenantId: string;
24
+ /** Control-plane credentials see platform rows. */
25
+ isOperator: boolean;
26
+ }
27
+ export declare function withPlatformRowsHidden(data: DataAdapters, options: PlatformRowsOptions): DataAdapters;
@@ -13,6 +13,18 @@ export declare function setRequestData(ctx: Context<{
13
13
  Bindings: Bindings;
14
14
  Variables: Variables;
15
15
  }>, data: DataAdapters): void;
16
+ /**
17
+ * The adapter stack code-hook and webhook execution reads.
18
+ *
19
+ * The management API hides platform-scoped rows that a config sync delivered
20
+ * from `ctx.var.data`, but hooks that run inline inside a management request
21
+ * (pre-registration, pre-deletion, ...) must still see and run them. Where no
22
+ * separate stack was installed this is the request's own stack.
23
+ */
24
+ export declare function getExecutorData(ctx: Context<{
25
+ Bindings: Bindings;
26
+ Variables: Variables;
27
+ }>): DataAdapters;
16
28
  /**
17
29
  * The raw adapter a route group composes its per-request stack on: the base
18
30
  * an earlier middleware installed on `ctx.var.baseData` (per-tenant database
@@ -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" | "exp" | "iat" | "tenant_id" | "client_id" | "org_name" | "jti" | "scope" | "gty" | "org_id" | "sid" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "permissions" | "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: ("sub" | "exp" | "iat" | "tenant_id" | "client_id" | "org_name" | "jti" | "scope" | "azp" | "gty" | "org_id" | "sid" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "permissions" | "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 @@
1
+ export declare function isSyncedRowId(id: string | undefined | null): boolean;
@@ -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>;