authhero 8.19.0 → 8.20.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 (36) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +112 -112
  3. package/dist/authhero.d.ts +256 -256
  4. package/dist/authhero.mjs +10565 -10524
  5. package/dist/tsconfig.types.tsbuildinfo +1 -1
  6. package/dist/types/authentication-flows/passwordless.d.ts +3 -3
  7. package/dist/types/helpers/hook-events.d.ts +35 -15
  8. package/dist/types/hooks/link-users.d.ts +9 -1
  9. package/dist/types/hooks/user-registration.d.ts +8 -5
  10. package/dist/types/index.d.ts +256 -256
  11. package/dist/types/routes/auth-api/index.d.ts +24 -24
  12. package/dist/types/routes/auth-api/passwordless.d.ts +12 -12
  13. package/dist/types/routes/auth-api/register/index.d.ts +2 -2
  14. package/dist/types/routes/auth-api/token.d.ts +10 -10
  15. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  16. package/dist/types/routes/management-api/clients.d.ts +7 -7
  17. package/dist/types/routes/management-api/connections.d.ts +1 -1
  18. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  19. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  20. package/dist/types/routes/management-api/forms.d.ts +126 -126
  21. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  22. package/dist/types/routes/management-api/hooks.d.ts +24 -24
  23. package/dist/types/routes/management-api/index.d.ts +227 -227
  24. package/dist/types/routes/management-api/logs.d.ts +3 -3
  25. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  26. package/dist/types/routes/management-api/organizations.d.ts +2 -2
  27. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  28. package/dist/types/routes/management-api/roles.d.ts +6 -6
  29. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  30. package/dist/types/routes/management-api/users.d.ts +2 -2
  31. package/dist/types/routes/universal-login/common.d.ts +2 -2
  32. package/dist/types/routes/universal-login/flow-api.d.ts +8 -8
  33. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  34. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  35. package/dist/types/types/IdToken.d.ts +1 -1
  36. package/package.json +6 -6
@@ -458,7 +458,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
458
458
  custom_login_page_preview?: string | undefined;
459
459
  form_template?: string | undefined;
460
460
  addons?: Record<string, any> | undefined;
461
- token_endpoint_auth_method?: "none" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | "private_key_jwt" | undefined;
461
+ token_endpoint_auth_method?: "none" | "private_key_jwt" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | undefined;
462
462
  client_metadata?: Record<string, string> | undefined;
463
463
  hide_sign_up_disabled_error?: boolean | undefined;
464
464
  mobile?: Record<string, any> | undefined;
@@ -541,8 +541,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
541
541
  } | undefined;
542
542
  authenticated_at?: string | undefined;
543
543
  };
544
- connectionType: "username" | "email" | "sms";
545
- authConnection: "username" | "email" | "sms";
544
+ connectionType: "username" | "sms" | "email";
545
+ authConnection: "username" | "sms" | "email";
546
546
  session_id: string | undefined;
547
547
  authParams: {
548
548
  client_id: string;
@@ -1,20 +1,40 @@
1
1
  import { Context } from "hono";
2
- import { User } from "@authhero/adapter-interfaces";
2
+ import { OutboxEventInsert, User } from "@authhero/adapter-interfaces";
3
3
  import { Bindings, Variables } from "../types";
4
+ type HookCtx = Context<{
5
+ Bindings: Bindings;
6
+ Variables: Variables;
7
+ }>;
4
8
  /**
5
- * Enqueue a `hook.{triggerId}` event to the outbox so the `WebhookDestination`
6
- * (and future `CodeHookDestination`) can dispatch the hook asynchronously with
7
- * retries instead of firing inline while the request is being served.
8
- *
9
- * Mirrors the synchronous-push pattern used by `logMessage`: the promise from
10
- * `outbox.create` is pushed onto `ctx.var.outboxEventPromises` so the outbox
11
- * middleware can await it in its finally block and then relay the resulting
12
- * event IDs.
9
+ * Whether the outbox is configured for this request. When false, hook dispatch
10
+ * falls back to inline webhook invocation (no retry / dead-letter).
11
+ */
12
+ export declare function outboxEnabled(ctx: HookCtx): boolean;
13
+ /**
14
+ * Build a `hook.{triggerId}` outbox event with a caller-assigned id, or
15
+ * `undefined` when the outbox is not configured (the caller then falls back to
16
+ * inline dispatch via {@link dispatchPostHookInline}).
13
17
  *
14
- * When the outbox is not configured, falls back to inline webhook invocation
15
- * (via `waitUntil`) so tenants without outbox still receive webhook calls.
18
+ * The returned event is meant to be handed to an event-emitting user write
19
+ * (`rawCreate` / `remove`) via its `outboxEvents` option so it commits in the
20
+ * same atomic unit as the business row (issue #1057). Because the id is fixed
21
+ * up front, the caller can relay it with {@link relayOutboxEvent} once the
22
+ * write commits without needing a return value from the adapter.
16
23
  */
17
- export declare function enqueuePostHookEvent(ctx: Context<{
18
- Bindings: Bindings;
19
- Variables: Variables;
20
- }>, tenantId: string, triggerId: string, user: User): void;
24
+ export declare function buildPostHookEvent(ctx: HookCtx, tenantId: string, triggerId: string, user: User): OutboxEventInsert | undefined;
25
+ /**
26
+ * Relay an outbox event that has already been persisted (atomically with its
27
+ * business write) so the outbox middleware picks it up for delivery. Mirrors
28
+ * the synchronous-push pattern used by `logMessage`: the id is pushed onto
29
+ * `ctx.var.outboxEventPromises`, which the outbox middleware drains and hands
30
+ * to `processOutboxEvents`.
31
+ */
32
+ export declare function relayOutboxEvent(ctx: HookCtx, id: string): void;
33
+ /**
34
+ * Fallback dispatch for when the outbox is not configured: invoke the
35
+ * post-hook webhooks inline (fire-and-forget via `waitUntil`). No retry /
36
+ * dead-letter support in this mode — configure the outbox for durable
37
+ * delivery.
38
+ */
39
+ export declare function dispatchPostHookInline(ctx: HookCtx, tenantId: string, triggerId: string, user: User): void;
40
+ export {};
@@ -1,4 +1,4 @@
1
- import { DataAdapters, User } from "@authhero/adapter-interfaces";
1
+ import { DataAdapters, OutboxEventInsert, User } from "@authhero/adapter-interfaces";
2
2
  export interface CommitUserResult {
3
3
  user: User;
4
4
  created: boolean;
@@ -16,6 +16,14 @@ export interface CommitUserOptions {
16
16
  * goes away entirely).
17
17
  */
18
18
  resolveEmailLinkedPrimary?: boolean;
19
+ /**
20
+ * Post-registration outbox events to persist in the same atomic unit as the
21
+ * user row (issue #1057). Forwarded to `rawCreate`'s `outboxEvents` option so
22
+ * the event and the user commit together — a race-loser whose `rawCreate`
23
+ * rolls back never leaves a stranded event. The caller relays the event ids
24
+ * (via `relayOutboxEvent`) only after `created === true`.
25
+ */
26
+ outboxEvents?: OutboxEventInsert[];
19
27
  }
20
28
  /**
21
29
  * Commits a new user inside a transaction. Validates `linked_to` (if set),
@@ -8,11 +8,14 @@ import { Bindings, Variables } from "../types";
8
8
  * 1. Pre-registration blocking hooks (outside any transaction so webhook
9
9
  * latency and user-authored code don't hold a DB connection).
10
10
  * 2. `commitUserHook` — the internal transactional step that atomically
11
- * writes the user row (via `rawCreate`) and, when the built-in
12
- * email-based linking path is enabled, also resolves `linked_to` from
13
- * the existing primary inside the same transaction.
14
- * 3. Post-registration hooks webhook delivery is handed to the outbox
15
- * (`enqueuePostHookEvent`) for retryable / idempotent dispatch; code
11
+ * writes the user row (via `rawCreate`), the post-registration outbox
12
+ * event (via `rawCreate`'s `outboxEvents` option, so business row and
13
+ * event commit together issue #1057), and, when the built-in
14
+ * email-based linking path is enabled, resolves `linked_to` from the
15
+ * existing primary inside the same transaction.
16
+ * 3. Post-registration hooks — the already-persisted event id is relayed
17
+ * (`relayOutboxEvent`) for retryable / idempotent webhook dispatch, or
18
+ * `dispatchPostHookInline` runs when the outbox isn't configured; code
16
19
  * hooks currently still run inline with ctx.
17
20
  */
18
21
  export declare function createUserHooks(ctx: Context<{