authhero 8.23.1 → 8.25.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 (54) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +139 -142
  3. package/dist/authhero.d.ts +1073 -292
  4. package/dist/authhero.mjs +20321 -15480
  5. package/dist/tsconfig.types.tsbuildinfo +1 -1
  6. package/dist/types/adapters/control-plane-custom-domains.d.ts +35 -0
  7. package/dist/types/authentication-flows/passwordless.d.ts +4 -4
  8. package/dist/types/helpers/control-plane-client.d.ts +46 -0
  9. package/dist/types/helpers/control-plane-sync-events.d.ts +12 -28
  10. package/dist/types/index.d.ts +326 -246
  11. package/dist/types/routes/auth-api/index.d.ts +28 -28
  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/revoke.d.ts +2 -2
  15. package/dist/types/routes/auth-api/token.d.ts +12 -12
  16. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  17. package/dist/types/routes/management-api/clients.d.ts +14 -14
  18. package/dist/types/routes/management-api/connections.d.ts +16 -16
  19. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  20. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  21. package/dist/types/routes/management-api/forms.d.ts +126 -126
  22. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  23. package/dist/types/routes/management-api/helpers.d.ts +47 -0
  24. package/dist/types/routes/management-api/index.d.ts +280 -211
  25. package/dist/types/routes/management-api/logs.d.ts +4 -4
  26. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  27. package/dist/types/routes/management-api/organizations.d.ts +8 -8
  28. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  29. package/dist/types/routes/management-api/roles.d.ts +1 -1
  30. package/dist/types/routes/management-api/tenant-members.d.ts +304 -0
  31. package/dist/types/routes/management-api/tenant-members.test.d.ts +1 -0
  32. package/dist/types/routes/management-api/tenants.d.ts +8 -8
  33. package/dist/types/routes/management-api/users.d.ts +71 -2
  34. package/dist/types/routes/proxy-control-plane/custom-domains.d.ts +45 -0
  35. package/dist/types/routes/proxy-control-plane/index.d.ts +47 -6
  36. package/dist/types/routes/proxy-control-plane/scopes.d.ts +20 -0
  37. package/dist/types/routes/proxy-control-plane/tenant-members.d.ts +37 -0
  38. package/dist/types/routes/proxy-control-plane/verify.d.ts +29 -4
  39. package/dist/types/routes/proxy-control-plane/verify.test.d.ts +1 -0
  40. package/dist/types/routes/universal-login/common.d.ts +8 -8
  41. package/dist/types/routes/universal-login/flow-api.d.ts +12 -12
  42. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  43. package/dist/types/routes/universal-login/index.d.ts +2 -2
  44. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  45. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  46. package/dist/types/tenant-members/control-plane-roundtrip.test.d.ts +1 -0
  47. package/dist/types/tenant-members/local-backend.d.ts +43 -0
  48. package/dist/types/tenant-members/local-backend.test.d.ts +1 -0
  49. package/dist/types/tenant-members/remote-backend.d.ts +17 -0
  50. package/dist/types/tenant-members/types.d.ts +112 -0
  51. package/dist/types/tenant-members/wire.d.ts +28 -0
  52. package/dist/types/types/AuthHeroConfig.d.ts +54 -7
  53. package/dist/types/types/IdToken.d.ts +4 -4
  54. package/package.json +6 -6
@@ -0,0 +1,35 @@
1
+ import { CustomDomainsAdapter } from "@authhero/adapter-interfaces";
2
+ import { ControlPlaneClient } from "../helpers/control-plane-client";
3
+ export declare const CONTROL_PLANE_CUSTOM_DOMAINS_PATH = "/api/v2/proxy/control-plane/custom-domains";
4
+ export interface ControlPlaneCustomDomainsOptions {
5
+ /** Authed transport to the control plane. */
6
+ client: ControlPlaneClient;
7
+ /**
8
+ * Local read-cache for custom domains — normally the shard's own database
9
+ * adapter (`database.customDomains`). The control plane owns the row; this
10
+ * mirror exists so `getByDomain` (tenant resolution, a hot path) and `list`
11
+ * don't need a network hop.
12
+ */
13
+ mirror: CustomDomainsAdapter;
14
+ /** Override the control-plane resource path (tests, custom mounts). */
15
+ basePath?: string;
16
+ }
17
+ /**
18
+ * A `CustomDomainsAdapter` for a tenant shard that cannot register hostnames
19
+ * itself: a CF-for-SaaS custom hostname is an account-global resource in one
20
+ * shared zone, and only the control plane holds the account credentials — and
21
+ * only something above all shards can see that `login.acme.com` is already
22
+ * claimed by another tenant.
23
+ *
24
+ * So the control plane is authoritative: writes go there synchronously and the
25
+ * result is mirrored into the shard's own database as a read cache. On a
26
+ * conflict nothing is written locally, which is what prevents the
27
+ * half-provisioned, unroutable row this replaces.
28
+ *
29
+ * Reads trust the mirror once a domain is `ready`. A `pending` domain flips to
30
+ * `ready` on Cloudflare's timeline (after the customer adds the DV record) and
31
+ * that transition happens at the control plane, so a non-ready row is
32
+ * refreshed from upstream on read. `getByDomain` always reads the mirror — it
33
+ * is on the tenant-resolution path and must not take a network hop.
34
+ */
35
+ export declare function createControlPlaneCustomDomainsAdapter(options: ControlPlaneCustomDomainsOptions): CustomDomainsAdapter;
@@ -367,7 +367,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
367
367
  active?: boolean | undefined;
368
368
  } | undefined;
369
369
  signup?: {
370
- status?: "required" | "optional" | "disabled" | undefined;
370
+ status?: "optional" | "required" | "disabled" | undefined;
371
371
  verification?: {
372
372
  active?: boolean | undefined;
373
373
  } | undefined;
@@ -384,7 +384,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
384
384
  active?: boolean | undefined;
385
385
  } | undefined;
386
386
  signup?: {
387
- status?: "required" | "optional" | "disabled" | undefined;
387
+ status?: "optional" | "required" | "disabled" | undefined;
388
388
  } | undefined;
389
389
  validation?: {
390
390
  max_length?: number | undefined;
@@ -401,7 +401,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
401
401
  active?: boolean | undefined;
402
402
  } | undefined;
403
403
  signup?: {
404
- status?: "required" | "optional" | "disabled" | undefined;
404
+ status?: "optional" | "required" | "disabled" | undefined;
405
405
  } | undefined;
406
406
  } | undefined;
407
407
  } | undefined;
@@ -466,7 +466,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
466
466
  custom_login_page_preview?: string | undefined;
467
467
  form_template?: string | undefined;
468
468
  addons?: Record<string, any> | undefined;
469
- token_endpoint_auth_method?: "none" | "private_key_jwt" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | undefined;
469
+ token_endpoint_auth_method?: "client_secret_post" | "client_secret_basic" | "none" | "client_secret_jwt" | "private_key_jwt" | undefined;
470
470
  client_metadata?: Record<string, string> | undefined;
471
471
  hide_sign_up_disabled_error?: boolean | undefined;
472
472
  mobile?: Record<string, any> | undefined;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Mints a bearer token for a tenant against the control plane. On a tenant
3
+ * shard this is `createServiceTokenCore` bound to the shard's own tenants/keys
4
+ * adapters — the control plane verifies it against the shard's published JWKS,
5
+ * so no shared client secret is involved.
6
+ */
7
+ export type GetControlPlaneToken = (tenantId: string, scope: string) => Promise<string>;
8
+ export interface ControlPlaneClientOptions {
9
+ /** Base URL of the control-plane authhero instance, no trailing slash required. */
10
+ baseUrl: string;
11
+ getServiceToken: GetControlPlaneToken;
12
+ /** Per-request timeout (default: 5s). */
13
+ timeoutMs?: number;
14
+ /** Refresh a cached token this many seconds before it expires (default: 60). */
15
+ tokenRefreshSkewSeconds?: number;
16
+ /** Override for tests, or to route over a Cloudflare service binding. */
17
+ fetchImpl?: typeof fetch;
18
+ }
19
+ export interface ControlPlaneRequest {
20
+ tenantId: string;
21
+ scope: string;
22
+ method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
23
+ /** Path below the base URL, e.g. `/api/v2/proxy/control-plane/custom-domains`. */
24
+ path: string;
25
+ body?: unknown;
26
+ }
27
+ export interface ControlPlaneResponse {
28
+ status: number;
29
+ /** Parsed JSON body, or null for empty/non-JSON responses. */
30
+ data: unknown;
31
+ }
32
+ export interface ControlPlaneClient {
33
+ /**
34
+ * Perform an authed request. Returns the status and parsed body for ANY HTTP
35
+ * response — including 4xx/5xx — so callers can map status to domain
36
+ * semantics (409 → conflict, 404 → null). Throws only when the request never
37
+ * produced a response (network error, timeout, token minting failure).
38
+ */
39
+ request(req: ControlPlaneRequest): Promise<ControlPlaneResponse>;
40
+ }
41
+ /**
42
+ * Authed transport to the control plane with an in-memory, per-(tenant, scope)
43
+ * token cache and single-flight minting. Shared by every control-plane-backed
44
+ * adapter so the token handling exists once.
45
+ */
46
+ export declare function createControlPlaneClient(options: ControlPlaneClientOptions): ControlPlaneClient;
@@ -1,8 +1,16 @@
1
1
  import { Context } from "hono";
2
- import { CustomDomain, ProxyRoute } from "@authhero/adapter-interfaces";
2
+ import { ProxyRoute } from "@authhero/adapter-interfaces";
3
3
  import { Bindings, Variables } from "../types";
4
4
  export declare const CONTROL_PLANE_SYNC_EVENT_PREFIX = "controlplane.sync.";
5
- export type SyncEntity = "custom_domain" | "proxy_route";
5
+ /**
6
+ * Only `proxy_route` replicates upward. Custom domains used to sync the same
7
+ * way, which is exactly what left them half-provisioned: the row reached the
8
+ * control plane but nothing ever registered the hostname in Cloudflare. They
9
+ * are now written through the control plane synchronously
10
+ * (`createControlPlaneCustomDomainsAdapter`), which owns the row and performs
11
+ * the account-level side effect.
12
+ */
13
+ export type SyncEntity = "proxy_route";
6
14
  export type SyncOp = "created" | "updated" | "deleted";
7
15
  /**
8
16
  * Wire shape posted from the tenant shard to the control plane. The destination
@@ -11,34 +19,10 @@ export type SyncOp = "created" | "updated" | "deleted";
11
19
  * batched-delivery destination.
12
20
  */
13
21
  export type SyncEvent = {
14
- event_id: string;
15
- tenant_id: string;
16
- entity: "custom_domain";
17
- op: "created" | "updated";
18
- aggregate_id: string;
19
- payload: CustomDomain;
20
- occurred_at: string;
21
- } | {
22
- event_id: string;
23
- tenant_id: string;
24
- entity: "custom_domain";
25
- op: "deleted";
26
- aggregate_id: string;
27
- payload: CustomDomain;
28
- occurred_at: string;
29
- } | {
30
22
  event_id: string;
31
23
  tenant_id: string;
32
24
  entity: "proxy_route";
33
- op: "created" | "updated";
34
- aggregate_id: string;
35
- payload: ProxyRoute;
36
- occurred_at: string;
37
- } | {
38
- event_id: string;
39
- tenant_id: string;
40
- entity: "proxy_route";
41
- op: "deleted";
25
+ op: SyncOp;
42
26
  aggregate_id: string;
43
27
  payload: ProxyRoute;
44
28
  occurred_at: string;
@@ -48,7 +32,7 @@ interface EnqueueArgs {
48
32
  entity: SyncEntity;
49
33
  op: SyncOp;
50
34
  aggregateId: string;
51
- payload: CustomDomain | ProxyRoute;
35
+ payload: ProxyRoute;
52
36
  }
53
37
  /**
54
38
  * Enqueue a `controlplane.sync.*` event to the outbox so the