authhero 8.0.0 → 8.1.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/authhero.cjs +105 -105
  2. package/dist/authhero.d.ts +269 -209
  3. package/dist/authhero.mjs +11216 -11105
  4. package/dist/stats.html +1 -1
  5. package/dist/tsconfig.types.tsbuildinfo +1 -1
  6. package/dist/types/authentication-flows/passwordless.d.ts +3 -3
  7. package/dist/types/helpers/client-bundle.d.ts +15 -1
  8. package/dist/types/helpers/compose-auth-data.d.ts +44 -0
  9. package/dist/types/helpers/prefetch-client-bundle.d.ts +33 -0
  10. package/dist/types/hooks/webhooks.d.ts +14 -0
  11. package/dist/types/index.d.ts +269 -209
  12. package/dist/types/routes/auth-api/account.d.ts +2 -2
  13. package/dist/types/routes/auth-api/index.d.ts +34 -34
  14. package/dist/types/routes/auth-api/passwordless.d.ts +14 -14
  15. package/dist/types/routes/auth-api/register/index.d.ts +2 -2
  16. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  17. package/dist/types/routes/auth-api/token.d.ts +10 -10
  18. package/dist/types/routes/management-api/action-triggers.d.ts +1 -1
  19. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  20. package/dist/types/routes/management-api/clients.d.ts +7 -7
  21. package/dist/types/routes/management-api/connections.d.ts +1 -1
  22. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  23. package/dist/types/routes/management-api/flows.d.ts +7 -7
  24. package/dist/types/routes/management-api/forms.d.ts +119 -119
  25. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  26. package/dist/types/routes/management-api/hooks.d.ts +60 -0
  27. package/dist/types/routes/management-api/index.d.ts +229 -169
  28. package/dist/types/routes/management-api/logs.d.ts +3 -3
  29. package/dist/types/routes/management-api/organizations.d.ts +1 -1
  30. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  31. package/dist/types/routes/management-api/users.d.ts +2 -2
  32. package/dist/types/routes/universal-login/common.d.ts +2 -2
  33. package/dist/types/routes/universal-login/flow-api.d.ts +12 -12
  34. package/dist/types/routes/universal-login/u2-index.d.ts +6 -6
  35. package/dist/types/routes/universal-login/u2-routes.d.ts +6 -6
  36. package/package.json +3 -3
@@ -457,7 +457,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
457
457
  custom_login_page_preview?: string | undefined;
458
458
  form_template?: string | undefined;
459
459
  addons?: Record<string, any> | undefined;
460
- token_endpoint_auth_method?: "none" | "private_key_jwt" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | undefined;
460
+ token_endpoint_auth_method?: "none" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | "private_key_jwt" | undefined;
461
461
  client_metadata?: Record<string, string> | undefined;
462
462
  hide_sign_up_disabled_error?: boolean | undefined;
463
463
  mobile?: Record<string, any> | undefined;
@@ -540,8 +540,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
540
540
  } | undefined;
541
541
  authenticated_at?: string | undefined;
542
542
  };
543
- connectionType: "username" | "sms" | "email";
544
- authConnection: "username" | "sms" | "email";
543
+ connectionType: "username" | "email" | "sms";
544
+ authConnection: "username" | "email" | "sms";
545
545
  session_id: string | undefined;
546
546
  authParams: {
547
547
  client_id: string;
@@ -1,4 +1,4 @@
1
- import { CacheAdapter, Client, Connection, ClientWithTenantId, DataAdapters, ListConnectionsResponse, ListResourceServersResponse, ListHooksResponse, Branding, PromptSetting, Tenant } from "@authhero/adapter-interfaces";
1
+ import { CacheAdapter, Client, Connection, ClientWithTenantId, DataAdapters, ListConnectionsResponse, ListResourceServersResponse, ListHooksResponse, Branding, PromptSetting, Tenant, Theme } from "@authhero/adapter-interfaces";
2
2
  /**
3
3
  * One snapshot of every per-(tenant, client) read that the request path
4
4
  * touches outside of user-specific data. Loaded once per request and held
@@ -17,6 +17,11 @@ export interface ClientBundle {
17
17
  resourceServers: ListResourceServersResponse;
18
18
  promptSettings: PromptSetting | null;
19
19
  hooks: ListHooksResponse;
20
+ /** The tenant's default theme. Universal-login routes always fetch this
21
+ * one ("default") key, so bundling it saves a round-trip on every UI
22
+ * render. Non-UI routes get the field for free; the payload is small.
23
+ */
24
+ defaultTheme: Theme | null;
20
25
  }
21
26
  export interface ClientBundleConfig {
22
27
  /** Seconds the bundle is served without a refresh. Default 300. */
@@ -27,6 +32,15 @@ export interface ClientBundleConfig {
27
32
  keyPrefix?: string;
28
33
  }
29
34
  export declare function clientBundleKey(tenantId: string, clientId: string, prefix?: string): string;
35
+ /**
36
+ * Entity names covered by the {@link ClientBundle}. Single source of truth
37
+ * used by {@link composeAuthData} so individual apps don't need to enumerate
38
+ * the bundled entities themselves — they only declare their long-tail
39
+ * (non-bundle) entities.
40
+ *
41
+ * Keep in sync with {@link fetchBundle} above.
42
+ */
43
+ export declare const BUNDLE_ENTITIES: readonly ["tenants", "clients", "connections", "clientConnections", "branding", "resourceServers", "promptSettings", "hooks", "themes"];
30
44
  /**
31
45
  * Look up — and on miss, populate — the per-(tenant, client) bundle.
32
46
  *
@@ -0,0 +1,44 @@
1
+ import { Context } from "hono";
2
+ import { CacheAdapter, DataAdapters } from "@authhero/adapter-interfaces";
3
+ import { Bindings, Variables } from "../types";
4
+ /**
5
+ * Composes the per-request data-adapter wrapper stack used by every app
6
+ * that serves authenticated/tenant-scoped traffic (auth-api, universal-
7
+ * login v1/v2, saml). Keeps the layer order — and the safety constraints
8
+ * between layers — in one place so individual apps can't drift.
9
+ *
10
+ * Layering (outermost first; that's the order callers hit on each read):
11
+ * addTimingLogs — server-timing instrumentation
12
+ * withClientBundle — L0: per-(tenant_id, client_id) snapshot
13
+ * addBundleWritePurge — local-edge bundle invalidation on writes
14
+ * addRequestScopedDedup — L1: in-request Promise memoization
15
+ * addCaching — L2: cross-request cache (CF Cache API in prod)
16
+ * addDataHooks — user lifecycle hooks
17
+ * raw dataAdapter — underlying DB
18
+ *
19
+ * Apps declare only their `nonBundleEntities` — the long-tail entities they
20
+ * read that aren't covered by {@link BUNDLE_ENTITIES}. Those get cross-
21
+ * request caching via L2 (`addCaching`). Bundle entities are intentionally
22
+ * NOT in L2 — the bundle (L0) is their cross-request cache, and double-
23
+ * caching them under per-entity keys would waste edge storage and create a
24
+ * second invalidation surface.
25
+ *
26
+ * L1 (`addRequestScopedDedup`) covers both sets, since in-request dedup is
27
+ * essentially free and a useful backstop for the rare bundle fall-through
28
+ * (mismatched ctx.var args, non-default list params).
29
+ *
30
+ * Transactional entities (sessions, codes, loginSessions, users, refresh-
31
+ * Tokens, clientGrants, logs, …) MUST NOT be included in `nonBundleEntities`
32
+ * — see request-scoped-dedup.ts for the rationale.
33
+ */
34
+ export declare function composeAuthData(opts: {
35
+ ctx: Context<{
36
+ Bindings: Bindings;
37
+ Variables: Variables;
38
+ }>;
39
+ rawData: DataAdapters;
40
+ cacheAdapter: CacheAdapter;
41
+ defaultTtl: number;
42
+ /** Entities outside the ClientBundle that should still be cached cross-request. */
43
+ nonBundleEntities: string[];
44
+ }): DataAdapters;
@@ -0,0 +1,33 @@
1
+ import { Context } from "hono";
2
+ import { Client, Tenant } from "@authhero/adapter-interfaces";
3
+ import { Bindings, Variables } from "../types";
4
+ /**
5
+ * Explicit prefetch for the per-(tenant_id, client_id) bundle.
6
+ *
7
+ * Called once at the top of a route handler. Discovers tenant_id from
8
+ * client_id (if not provided), populates `ctx.var.{client_id, tenant_id}`,
9
+ * and warms the bundle so every downstream bundle-covered read in this
10
+ * request is served from one cache key.
11
+ *
12
+ * Why explicit instead of relying on the wrapper alone: the wrapper hooks
13
+ * via ctx.var, but several helpers (e.g. getEnrichedClient) need to read
14
+ * config BEFORE the route has resolved client_id/tenant_id. With this
15
+ * prefetch you set those upfront, so all the subsequent reads — including
16
+ * the ones inside getEnrichedClient's Promise.all — engage the bundle.
17
+ *
18
+ * Throws 403 if the client_id can't be resolved, 404 if its tenant is
19
+ * missing — matching the contract of getEnrichedClient. Does NOT handle
20
+ * CIMD clients (URL-based client_ids); callers that may receive a CIMD
21
+ * client_id should continue to use {@link getEnrichedClient} which has
22
+ * the CIMD-specific resolution path.
23
+ */
24
+ export declare function prefetchClientBundle(ctx: Context<{
25
+ Bindings: Bindings;
26
+ Variables: Variables;
27
+ }>, opts: {
28
+ client_id: string;
29
+ tenant_id?: string;
30
+ }): Promise<{
31
+ tenant: Tenant;
32
+ client: Client;
33
+ }>;
@@ -1,6 +1,20 @@
1
1
  import { DataAdapters, Hook, User } from "@authhero/adapter-interfaces";
2
2
  import { Context } from "hono";
3
3
  import { Variables, Bindings } from "../types";
4
+ export interface WebHookResult {
5
+ ok: boolean;
6
+ status?: number;
7
+ body?: string;
8
+ error?: string;
9
+ }
10
+ export declare function invokeWebHook(ctx: Context<{
11
+ Bindings: Bindings;
12
+ Variables: Variables;
13
+ }>, hook: Hook & {
14
+ url: string;
15
+ }, data: any & {
16
+ tenant_id: string;
17
+ }): Promise<WebHookResult>;
4
18
  export declare function invokeHooks(ctx: Context<{
5
19
  Bindings: Bindings;
6
20
  Variables: Variables;