authhero 9.13.1 → 9.15.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 (67) 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-1471c0f2.entry.js → p-1eb7f287.entry.js} +1 -1
  4. package/dist/assets/u/widget/p-398d72df.entry.js +1 -0
  5. package/dist/authhero.cjs +144 -144
  6. package/dist/authhero.d.ts +469 -288
  7. package/dist/authhero.mjs +14662 -13647
  8. package/dist/tsconfig.types.tsbuildinfo +1 -1
  9. package/dist/types/authentication-flows/custom-token-exchange.d.ts +21 -0
  10. package/dist/types/authentication-flows/passwordless.d.ts +5 -2
  11. package/dist/types/authentication-flows/token-exchange.d.ts +19 -0
  12. package/dist/types/emails/index.d.ts +8 -9
  13. package/dist/types/emails/render.d.ts +2 -6
  14. package/dist/types/generated/locale-types.d.ts +2 -0
  15. package/dist/types/helpers/client-assertion-replay.d.ts +17 -0
  16. package/dist/types/helpers/client-keys.d.ts +9 -0
  17. package/dist/types/helpers/client.d.ts +3 -0
  18. package/dist/types/helpers/connection.d.ts +2 -6
  19. package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
  20. package/dist/types/helpers/logging.d.ts +2 -5
  21. package/dist/types/helpers/organization-branding.d.ts +18 -0
  22. package/dist/types/helpers/reserved-claims.d.ts +4 -8
  23. package/dist/types/helpers/service-token.d.ts +2 -5
  24. package/dist/types/helpers/wait-until.d.ts +3 -1
  25. package/dist/types/index.d.ts +430 -282
  26. package/dist/types/routes/auth-api/index.d.ts +129 -19
  27. package/dist/types/routes/auth-api/passwordless.d.ts +16 -16
  28. package/dist/types/routes/auth-api/token.d.ts +110 -0
  29. package/dist/types/routes/auth-api/well-known.d.ts +1 -1
  30. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  31. package/dist/types/routes/management-api/actions.d.ts +3 -3
  32. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  33. package/dist/types/routes/management-api/client-grants.d.ts +9 -9
  34. package/dist/types/routes/management-api/clients.d.ts +24 -0
  35. package/dist/types/routes/management-api/email-templates.d.ts +20 -20
  36. package/dist/types/routes/management-api/emails.d.ts +2 -2
  37. package/dist/types/routes/management-api/failed-events.d.ts +1 -1
  38. package/dist/types/routes/management-api/forms.d.ts +14 -0
  39. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  40. package/dist/types/routes/management-api/hooks.d.ts +4 -4
  41. package/dist/types/routes/management-api/index.d.ts +288 -250
  42. package/dist/types/routes/management-api/keys.d.ts +12 -12
  43. package/dist/types/routes/management-api/logs.d.ts +4 -4
  44. package/dist/types/routes/management-api/organizations.d.ts +7 -7
  45. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  46. package/dist/types/routes/management-api/tenants.d.ts +6 -6
  47. package/dist/types/routes/management-api/token-exchange-profiles.d.ts +321 -0
  48. package/dist/types/routes/management-api/users.d.ts +14 -14
  49. package/dist/types/routes/proxy-control-plane/tenant-members.d.ts +9 -2
  50. package/dist/types/routes/proxy-control-plane/verify.d.ts +15 -0
  51. package/dist/types/routes/universal-login/common.d.ts +6 -0
  52. package/dist/types/routes/universal-login/flow-api.d.ts +4 -4
  53. package/dist/types/routes/universal-login/form-node.d.ts +4 -4
  54. package/dist/types/routes/universal-login/index.d.ts +6 -6
  55. package/dist/types/routes/universal-login/screens/login-otp.d.ts +17 -0
  56. package/dist/types/routes/universal-login/screens/types.d.ts +6 -0
  57. package/dist/types/routes/universal-login/u2-form-node.d.ts +2 -2
  58. package/dist/types/routes/universal-login/u2-index.d.ts +7 -7
  59. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  60. package/dist/types/state-machines/login-session.d.ts +1 -1
  61. package/dist/types/tenant-members/local-backend.d.ts +11 -3
  62. package/dist/types/types/RequestContext.d.ts +16 -0
  63. package/dist/types/types/index.d.ts +1 -0
  64. package/dist/types/utils/jwks.d.ts +2 -2
  65. package/dist/types/utils/jws-verify.d.ts +46 -0
  66. package/package.json +6 -6
  67. package/dist/assets/u/widget/p-c2744f87.entry.js +0 -1
@@ -0,0 +1,21 @@
1
+ import { Context } from "hono";
2
+ import { z } from "@hono/zod-openapi";
3
+ import { Bindings, Variables, GrantFlowUserResult } from "../types";
4
+ import { EnrichedClient } from "../helpers/client";
5
+ export declare const customTokenExchangeParamsSchema: z.ZodObject<{
6
+ grant_type: z.ZodLiteral<"urn:ietf:params:oauth:grant-type:token-exchange">;
7
+ client_id: z.ZodString;
8
+ client_secret: z.ZodOptional<z.ZodString>;
9
+ subject_token: z.ZodString;
10
+ subject_token_type: z.ZodString;
11
+ audience: z.ZodOptional<z.ZodString>;
12
+ scope: z.ZodOptional<z.ZodString>;
13
+ organization: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ export type CustomTokenExchangeParams = z.infer<typeof customTokenExchangeParamsSchema>;
16
+ type Ctx = Context<{
17
+ Bindings: Bindings;
18
+ Variables: Variables;
19
+ }>;
20
+ export declare function customTokenExchangeGrant(ctx: Ctx, params: CustomTokenExchangeParams, client: EnrichedClient): Promise<GrantFlowUserResult>;
21
+ export {};
@@ -501,6 +501,9 @@ export declare function passwordlessGrantUser(ctx: Context<{
501
501
  owner_user_id?: string | undefined;
502
502
  registration_type?: "manual" | "open_dcr" | "iat_dcr" | undefined;
503
503
  registration_metadata?: Record<string, any> | undefined;
504
+ token_exchange?: {
505
+ allow_any_profile_of_type?: "custom_authentication"[] | undefined;
506
+ } | undefined;
504
507
  user_linking_mode?: "builtin" | "off" | undefined;
505
508
  };
506
509
  loginSession: {
@@ -558,8 +561,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
558
561
  } | undefined;
559
562
  authenticated_at?: string | undefined;
560
563
  };
561
- connectionType: "username" | "sms" | "email";
562
- authConnection: "username" | "sms" | "email";
564
+ connectionType: "sms" | "email" | "username";
565
+ authConnection: "sms" | "email" | "username";
563
566
  session_id: string | undefined;
564
567
  authParams: {
565
568
  audience?: string | undefined;
@@ -2,6 +2,7 @@ import { Context } from "hono";
2
2
  import { z } from "@hono/zod-openapi";
3
3
  import { Bindings, Variables, GrantFlowUserResult } from "../types";
4
4
  import { EnrichedClient } from "../helpers/client";
5
+ export declare const SUBJECT_TOKEN_TYPE_ACCESS_TOKEN = "urn:ietf:params:oauth:token-type:access_token";
5
6
  export declare const TOKEN_EXCHANGE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
6
7
  export declare const tokenExchangeParamsSchema: z.ZodObject<{
7
8
  grant_type: z.ZodLiteral<"urn:ietf:params:oauth:grant-type:token-exchange">;
@@ -18,3 +19,21 @@ export declare function tokenExchangeGrant(ctx: Context<{
18
19
  Bindings: Bindings;
19
20
  Variables: Variables;
20
21
  }>, params: TokenExchangeParams, preloadedClient?: EnrichedClient): Promise<GrantFlowUserResult>;
22
+ /**
23
+ * Resolve the organization a token-exchange request asks for and check the
24
+ * user may act in it: a member, or a holder of the global
25
+ * `admin:organizations` permission when the tenant opts into inheriting it.
26
+ * Shared by the org-switch exchange and Custom Token Exchange.
27
+ */
28
+ export declare function authorizeOrganizationAccess(ctx: Context<{
29
+ Bindings: Bindings;
30
+ Variables: Variables;
31
+ }>, params: {
32
+ tenantId: string;
33
+ userId: string;
34
+ organizationId: string;
35
+ failLog: (description: string) => void;
36
+ }): Promise<{
37
+ id: string;
38
+ name: string;
39
+ }>;
@@ -1,5 +1,5 @@
1
1
  import { Context } from "hono";
2
- import { Bindings, Variables } from "../types";
2
+ import { Bindings, RequestContext, Variables } from "../types";
3
3
  import { AuthParams, EmailTemplateName, User } from "@authhero/adapter-interfaces";
4
4
  export type SendEmailParams = {
5
5
  to: string;
@@ -10,10 +10,7 @@ export type SendEmailParams = {
10
10
  data: Record<string, string>;
11
11
  from?: string;
12
12
  };
13
- export declare function sendEmail(ctx: Context<{
14
- Bindings: Bindings;
15
- Variables: Variables;
16
- }>, params: SendEmailParams): Promise<void>;
13
+ export declare function sendEmail(ctx: RequestContext, params: SendEmailParams, tenantIdOverride?: string): Promise<void>;
17
14
  export type SendSmsParams = {
18
15
  to: string;
19
16
  from?: string;
@@ -63,11 +60,13 @@ export interface SendInvitationParams {
63
60
  organizationName: string;
64
61
  ttlSec: number;
65
62
  language?: string;
63
+ /**
64
+ * Tenant whose email provider, branding, templates and locales are used.
65
+ * Defaults to the request's tenant.
66
+ */
67
+ tenantId?: string;
66
68
  }
67
- export declare function sendInvitation(ctx: Context<{
68
- Bindings: Bindings;
69
- Variables: Variables;
70
- }>, { to, invitationUrl, inviterName, organizationName, ttlSec, language, }: SendInvitationParams): Promise<void>;
69
+ export declare function sendInvitation(ctx: RequestContext, { to, invitationUrl, inviterName, organizationName, ttlSec, language, tenantId: tenantIdOverride, }: SendInvitationParams): Promise<void>;
71
70
  export interface SendTestEmailParams {
72
71
  to: string;
73
72
  templateName: EmailTemplateName;
@@ -1,7 +1,6 @@
1
- import { Context } from "hono";
2
1
  import { Liquid } from "liquidjs";
3
2
  import { EmailTemplateName } from "@authhero/adapter-interfaces";
4
- import { Bindings, Variables } from "../types";
3
+ import { RequestContext } from "../types";
5
4
  export declare function getLiquid(): Liquid;
6
5
  export interface RenderedEmail {
7
6
  subject: string;
@@ -29,10 +28,7 @@ export type RenderResult = {
29
28
  * 2. Bundled default (compiled from MJML at build time).
30
29
  * 3. `{ kind: "none" }` if neither exists.
31
30
  */
32
- export declare function renderEmailTemplate(ctx: Context<{
33
- Bindings: Bindings;
34
- Variables: Variables;
35
- }>, templateName: EmailTemplateName, vars: Record<string, unknown>, fallbackFrom: string): Promise<RenderResult>;
31
+ export declare function renderEmailTemplate(ctx: RequestContext, templateName: EmailTemplateName, vars: Record<string, unknown>, fallbackFrom: string, tenantId: string): Promise<RenderResult>;
36
32
  /**
37
33
  * Render the bundled default template directly, without consulting the
38
34
  * adapter. Exposed for tests and tooling.
@@ -64,6 +64,7 @@ export interface EmailOtpChallengeScreen {
64
64
  sessionExpired: () => string;
65
65
  title: () => string;
66
66
  unexpectedError: () => string;
67
+ usePasswordText: () => string;
67
68
  }
68
69
  export interface EmailVerificationScreen {
69
70
  description: (vars: {
@@ -269,6 +270,7 @@ export interface LoginPasswordScreen {
269
270
  unverifiedEmail: () => string;
270
271
  "user-blocked": () => string;
271
272
  "wrong-credentials": () => string;
273
+ sendCodeText: () => string;
272
274
  }
273
275
  export interface LoginPasswordlessScreen {
274
276
  authMethodEmail: () => string;
@@ -1,5 +1,22 @@
1
1
  import { Context } from "hono";
2
+ import { CodeType } from "@authhero/adapter-interfaces";
2
3
  import { Bindings, Variables } from "../types";
4
+ /**
5
+ * Record a presented token's `jti` as spent.
6
+ *
7
+ * @returns false when the same `(namespace, jti)` was already spent, true
8
+ * otherwise.
9
+ */
10
+ export declare function consumeSingleUseJti(ctx: Context<{
11
+ Bindings: Bindings;
12
+ Variables: Variables;
13
+ }>, tenantId: string, params: {
14
+ codeType: Extract<CodeType, "client_assertion_jti" | "subject_token_jti">;
15
+ namespace: string;
16
+ jti: string;
17
+ /** The token's `exp`, in seconds — when the marker becomes collectable. */
18
+ exp: number;
19
+ }): Promise<boolean>;
3
20
  export interface ConsumeClientAssertionJtiParams {
4
21
  clientId: string;
5
22
  /** The assertion's `jti`. When absent there is nothing to spend. */
@@ -25,3 +25,12 @@ export interface ClientWithKeys {
25
25
  * asymmetric algs do).
26
26
  */
27
27
  export declare function loadClientJwks(client: ClientWithKeys, opts?: LoadClientKeysOptions): Promise<Jwk[]>;
28
+ /**
29
+ * Resolve verification keys published inline (`jwks`) or by reference
30
+ * (`jwks_uri`). Inline takes precedence. The remote fetch goes through the
31
+ * SSRF guard. Returns an empty array when neither is set.
32
+ */
33
+ export declare function loadJwks(source: {
34
+ jwks?: unknown;
35
+ jwks_uri?: unknown;
36
+ }, opts?: LoadClientKeysOptions): Promise<Jwk[]>;
@@ -134,6 +134,9 @@ export declare const enrichedClientSchema: z.ZodObject<{
134
134
  iat_dcr: "iat_dcr";
135
135
  }>>;
136
136
  registration_metadata: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>>;
137
+ token_exchange: z.ZodOptional<z.ZodObject<{
138
+ allow_any_profile_of_type: z.ZodOptional<z.ZodArray<z.ZodLiteral<"custom_authentication">>>;
139
+ }, z.core.$strip>>;
137
140
  user_linking_mode: z.ZodOptional<z.ZodEnum<{
138
141
  builtin: "builtin";
139
142
  off: "off";
@@ -1,6 +1,5 @@
1
- import { Context } from "hono";
2
1
  import { LoginSession, User } from "@authhero/adapter-interfaces";
3
- import { Bindings, Variables } from "../types";
2
+ import { RequestContext } from "../types";
4
3
  import { HookEvent } from "../types/Hooks";
5
4
  export type ConnectionInfo = NonNullable<HookEvent["connection"]>;
6
5
  export interface ConnectionNameSources {
@@ -34,7 +33,4 @@ export declare function resolveConnectionName(sources: ConnectionNameSources): s
34
33
  * Returns `undefined` when the name is empty or doesn't resolve to a known
35
34
  * connection — callers decide whether to synthesize a fallback.
36
35
  */
37
- export declare function getConnectionInfo(ctx: Context<{
38
- Bindings: Bindings;
39
- Variables: Variables;
40
- }>, tenantId: string, connectionName: string | undefined, user?: Pick<User, "provider"> | null): Promise<ConnectionInfo | undefined>;
36
+ export declare function getConnectionInfo(ctx: RequestContext, tenantId: string, connectionName: string | undefined, user?: Pick<User, "provider"> | null): Promise<ConnectionInfo | undefined>;
@@ -24,10 +24,10 @@ export declare const dcrRequestSchema: z.ZodObject<{
24
24
  response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
25
  token_endpoint_auth_method: z.ZodOptional<z.ZodEnum<{
26
26
  none: "none";
27
- private_key_jwt: "private_key_jwt";
28
27
  client_secret_post: "client_secret_post";
29
28
  client_secret_basic: "client_secret_basic";
30
29
  client_secret_jwt: "client_secret_jwt";
30
+ private_key_jwt: "private_key_jwt";
31
31
  }>>;
32
32
  jwks_uri: z.ZodOptional<z.ZodString>;
33
33
  jwks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1,6 +1,6 @@
1
1
  import { Context } from "hono";
2
2
  import { DataAdapters, LogType } from "@authhero/adapter-interfaces";
3
- import { Variables, Bindings } from "../types";
3
+ import { Variables, Bindings, RequestContext } from "../types";
4
4
  export type LogParams = {
5
5
  type: LogType;
6
6
  description?: string;
@@ -80,10 +80,7 @@ export type LogParams = {
80
80
  /** Entity ID being mutated */
81
81
  targetId?: string;
82
82
  };
83
- export declare function logMessage(ctx: Context<{
84
- Bindings: Bindings;
85
- Variables: Variables;
86
- }>, tenantId: string, params: LogParams): Promise<void>;
83
+ export declare function logMessage(ctx: RequestContext, tenantId: string, params: LogParams): Promise<void>;
87
84
  /**
88
85
  * Transactional variant of {@link logMessage}. Writes the audit event to the
89
86
  * outbox through the caller-provided `trxData` so the insert commits (or rolls
@@ -0,0 +1,18 @@
1
+ import { Branding, Organization, Theme } from "@authhero/adapter-interfaces";
2
+ type OrganizationBranding = NonNullable<Organization["branding"]>;
3
+ /**
4
+ * Layer an organization's branding over the tenant's branding and theme, the
5
+ * way Auth0 does when a login runs in the context of an organization.
6
+ *
7
+ * The login pages let the theme win over branding (`theme.widget.logo_url`
8
+ * before `branding.logo_url`, `theme.colors.primary_button` before
9
+ * `branding.colors.primary`, `theme.page_background` before
10
+ * `branding.colors.page_background`), and a theme always exists because of
11
+ * the DEFAULT_THEME fallback. So each org value is written into both, or it
12
+ * would never be visible.
13
+ */
14
+ export declare function applyOrganizationBranding(branding: Branding | null, theme: Theme, orgBranding: OrganizationBranding | undefined): {
15
+ branding: Branding | null;
16
+ theme: Theme;
17
+ };
18
+ export {};
@@ -1,5 +1,4 @@
1
- import { Context } from "hono";
2
- import { Bindings, Variables } from "../types";
1
+ import { RequestContext } from "../types";
3
2
  /** RFC 9068 §2.2 + AuthHero-owned access-token claims. */
4
3
  export declare const ACCESS_TOKEN_RESERVED_CLAIMS: readonly ["iss", "sub", "aud", "exp", "nbf", "iat", "jti", "client_id", "azp", "scope", "auth_time", "acr", "amr", "act", "sid", "permissions", "tenant_id", "org_id", "org_name", "requested_userinfo_claims", "gty"];
5
4
  /** OIDC Core ID-token claims: the access-token set plus the ID-token-only ones. */
@@ -15,9 +14,9 @@ export declare const USERINFO_RESERVED_CLAIMS: readonly ["iss", "sub", "aud", "e
15
14
  * vendor/tenant for downstream APIs while `sub` stays `auth-service`.
16
15
  * Client-bound mints keep `azp` locked (see below).
17
16
  */
18
- export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "scope" | "sid" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "permissions" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
17
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("sid" | "client_id" | "scope" | "tenant_id" | "org_name" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "permissions" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
19
18
  /** Client-bound mints: `azp` must stay the registered client id. */
20
- export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "scope" | "sid" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "permissions" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
19
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("sid" | "client_id" | "scope" | "tenant_id" | "org_name" | "sub" | "exp" | "iat" | "org_id" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "permissions" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
21
20
  export type AccessTokenReservedClaim = (typeof ACCESS_TOKEN_RESERVED_CLAIMS)[number];
22
21
  export type IdTokenReservedClaim = (typeof ID_TOKEN_RESERVED_CLAIMS)[number];
23
22
  /**
@@ -58,10 +57,7 @@ export interface ApplyCustomClaimOptions {
58
57
  */
59
58
  source: string;
60
59
  /** Request context, when there is one — the warning goes to the tenant log. */
61
- ctx?: Context<{
62
- Bindings: Bindings;
63
- Variables: Variables;
64
- }>;
60
+ ctx?: RequestContext;
65
61
  /** Tenant to log against. Defaults to `ctx.var.tenant_id`. */
66
62
  tenantId?: string;
67
63
  }
@@ -1,6 +1,6 @@
1
1
  import { Context } from "hono";
2
2
  import { KeysAdapter, TenantsDataAdapter } from "@authhero/adapter-interfaces";
3
- import { Bindings, Variables } from "../types";
3
+ import { Bindings, RequestContext, Variables } from "../types";
4
4
  import { SigningKeyModeOption } from "../types/AuthHeroConfig";
5
5
  declare const AUTH_SERVICE_CLIENT_ID = "auth-service";
6
6
  export interface ServiceTokenResponse {
@@ -89,8 +89,5 @@ export interface CreateClientServiceTokenOptions {
89
89
  * Fails closed: rejects if the client has no grant for the (audience), or if
90
90
  * any requested scope is not in `grant.scope`.
91
91
  */
92
- export declare function createClientServiceToken(ctx: Context<{
93
- Bindings: Bindings;
94
- Variables: Variables;
95
- }>, tenantId: string, params: CreateClientServiceTokenParams, options?: CreateClientServiceTokenOptions): Promise<ServiceTokenResponse>;
92
+ export declare function createClientServiceToken(ctx: RequestContext, tenantId: string, params: CreateClientServiceTokenParams, options?: CreateClientServiceTokenOptions): Promise<ServiceTokenResponse>;
96
93
  export { AUTH_SERVICE_CLIENT_ID };
@@ -12,7 +12,9 @@ import { Context } from "hono";
12
12
  * webhook dispatches) completes, producing flaky test behavior and requests
13
13
  * that occasionally lose tail work if the process exits.
14
14
  */
15
- export declare function waitUntil(ctx: Context, promise: Promise<unknown>): void;
15
+ export declare function waitUntil(ctx: Pick<Context, "executionCtx" | "var"> & {
16
+ set(key: "backgroundPromises", value: Promise<void>[]): void;
17
+ }, promise: Promise<unknown>): void;
16
18
  /**
17
19
  * Await any `waitUntil` promises registered during the current request. Invoke
18
20
  * from a middleware's finally block (after `await next()`) so non-Workers