authhero 9.14.0 → 9.16.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 (66) 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-36898e2d.entry.js +1 -0
  4. package/dist/assets/u/widget/p-Che3Wd7J.js +1 -0
  5. package/dist/assets/u/widget/p-c6ec4c36.entry.js +1 -0
  6. package/dist/authhero.cjs +141 -141
  7. package/dist/authhero.d.ts +526 -243
  8. package/dist/authhero.mjs +14292 -13163
  9. package/dist/tsconfig.types.tsbuildinfo +1 -1
  10. package/dist/types/authentication-flows/custom-token-exchange.d.ts +21 -0
  11. package/dist/types/authentication-flows/passwordless.d.ts +3 -0
  12. package/dist/types/authentication-flows/token-exchange.d.ts +19 -0
  13. package/dist/types/generated/locale-types.d.ts +3 -0
  14. package/dist/types/helpers/client-assertion-replay.d.ts +17 -0
  15. package/dist/types/helpers/client-keys.d.ts +9 -0
  16. package/dist/types/helpers/client.d.ts +3 -0
  17. package/dist/types/helpers/dcr/metadata-mapping.d.ts +2 -2
  18. package/dist/types/helpers/organization-branding.d.ts +18 -0
  19. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  20. package/dist/types/helpers/signing-certificate-authority.d.ts +99 -0
  21. package/dist/types/helpers/signing-keys.d.ts +7 -0
  22. package/dist/types/index.d.ts +399 -241
  23. package/dist/types/middlewares/reject-unknown-hosts.d.ts +13 -0
  24. package/dist/types/routes/auth-api/index.d.ts +140 -29
  25. package/dist/types/routes/auth-api/passwordless.d.ts +14 -14
  26. package/dist/types/routes/auth-api/revoke.d.ts +2 -2
  27. package/dist/types/routes/auth-api/token.d.ts +122 -12
  28. package/dist/types/routes/auth-api/well-known.d.ts +2 -1
  29. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  30. package/dist/types/routes/management-api/actions.d.ts +1 -1
  31. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  32. package/dist/types/routes/management-api/client-grants.d.ts +9 -9
  33. package/dist/types/routes/management-api/clients.d.ts +24 -0
  34. package/dist/types/routes/management-api/connections.d.ts +1 -1
  35. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  36. package/dist/types/routes/management-api/failed-events.d.ts +1 -1
  37. package/dist/types/routes/management-api/forms.d.ts +147 -126
  38. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  39. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  40. package/dist/types/routes/management-api/index.d.ts +258 -213
  41. package/dist/types/routes/management-api/keys.d.ts +8 -8
  42. package/dist/types/routes/management-api/logs.d.ts +4 -4
  43. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  44. package/dist/types/routes/management-api/organizations.d.ts +1 -1
  45. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  46. package/dist/types/routes/management-api/roles.d.ts +1 -1
  47. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  48. package/dist/types/routes/management-api/tenant-operations.d.ts +1 -1
  49. package/dist/types/routes/management-api/tenants.d.ts +8 -8
  50. package/dist/types/routes/management-api/token-exchange-profiles.d.ts +327 -0
  51. package/dist/types/routes/management-api/users.d.ts +21 -21
  52. package/dist/types/routes/universal-login/common.d.ts +8 -2
  53. package/dist/types/routes/universal-login/flow-api.d.ts +8 -8
  54. package/dist/types/routes/universal-login/screens/login-otp.d.ts +17 -0
  55. package/dist/types/routes/universal-login/screens/types.d.ts +6 -0
  56. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  57. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  58. package/dist/types/state-machines/login-session.d.ts +1 -1
  59. package/dist/types/types/AuthHeroConfig.d.ts +38 -0
  60. package/dist/types/types/Bindings.d.ts +3 -0
  61. package/dist/types/utils/encryption.d.ts +20 -0
  62. package/dist/types/utils/jwks.d.ts +6 -3
  63. package/dist/types/utils/jws-verify.d.ts +46 -0
  64. package/package.json +6 -6
  65. package/dist/assets/u/widget/p-1471c0f2.entry.js +0 -1
  66. 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: {
@@ -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
+ }>;
@@ -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: {
@@ -98,6 +99,7 @@ export interface LoginScreen {
98
99
  editEmailText: () => string;
99
100
  emailPlaceholder: () => string;
100
101
  enterACodeBtn: () => string;
102
+ enterACodeShortBtn: () => string;
101
103
  federatedConnectionButtonText: (vars: {
102
104
  connectionName: string;
103
105
  }) => string;
@@ -269,6 +271,7 @@ export interface LoginPasswordScreen {
269
271
  unverifiedEmail: () => string;
270
272
  "user-blocked": () => string;
271
273
  "wrong-credentials": () => string;
274
+ sendCodeText: () => string;
272
275
  }
273
276
  export interface LoginPasswordlessScreen {
274
277
  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";
@@ -23,11 +23,11 @@ export declare const dcrRequestSchema: z.ZodObject<{
23
23
  grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
24
  response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
25
  token_endpoint_auth_method: z.ZodOptional<z.ZodEnum<{
26
- none: "none";
27
- private_key_jwt: "private_key_jwt";
28
26
  client_secret_post: "client_secret_post";
29
27
  client_secret_basic: "client_secret_basic";
28
+ none: "none";
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>>;
@@ -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 {};
@@ -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: ("iss" | "tenant_id" | "scope" | "client_id" | "org_name" | "org_id" | "sub" | "aud" | "exp" | "nbf" | "iat" | "jti" | "auth_time" | "acr" | "amr" | "act" | "sid" | "permissions" | "requested_userinfo_claims" | "gty")[];
17
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "scope" | "sid" | "sub" | "org_name" | "aud" | "auth_time" | "exp" | "iat" | "iss" | "permissions" | "org_id" | "acr" | "amr" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
18
18
  /** Client-bound mints: `azp` must stay the registered client id. */
19
- export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("iss" | "tenant_id" | "scope" | "client_id" | "org_name" | "org_id" | "sub" | "aud" | "exp" | "nbf" | "iat" | "jti" | "azp" | "auth_time" | "acr" | "amr" | "act" | "sid" | "permissions" | "requested_userinfo_claims" | "gty")[];
19
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "scope" | "sid" | "sub" | "org_name" | "aud" | "auth_time" | "exp" | "iat" | "iss" | "permissions" | "org_id" | "acr" | "amr" | "azp" | "nbf" | "jti" | "act" | "requested_userinfo_claims" | "gty")[];
20
20
  export type AccessTokenReservedClaim = (typeof ACCESS_TOKEN_RESERVED_CLAIMS)[number];
21
21
  export type IdTokenReservedClaim = (typeof ID_TOKEN_RESERVED_CLAIMS)[number];
22
22
  /**
@@ -0,0 +1,99 @@
1
+ import * as x509 from "@peculiar/x509";
2
+ /**
3
+ * A request to certify a signing key. Everything is plain data so an issuer
4
+ * can forward it over HTTP: the CA key never has to live in the auth worker.
5
+ */
6
+ export interface SigningCertificateRequest {
7
+ /** The key to certify, as an SPKI `PUBLIC KEY` PEM. */
8
+ publicKey: string;
9
+ /** Subject distinguished name, e.g. `CN=acme`. */
10
+ subject: string;
11
+ /** URI placed in the SubjectAlternativeName, e.g. `urn:authhero:tenant:acme`. */
12
+ uri: string;
13
+ notBefore: Date;
14
+ notAfter: Date;
15
+ }
16
+ /**
17
+ * Issues signing-key certificates from an intermediate CA.
18
+ *
19
+ * `issueCertificate` returns the leaf only. `getIssuerCertificates` returns
20
+ * every intermediate that may have signed a leaf that is still published —
21
+ * the current one plus any that were rotated out recently — so the JWKS can
22
+ * attach the right chain to each key.
23
+ */
24
+ export interface CertificateIssuer {
25
+ issueCertificate(request: SigningCertificateRequest): Promise<string>;
26
+ getIssuerCertificates(): Promise<string[]>;
27
+ }
28
+ export interface SigningCertificateAuthority {
29
+ issuer: CertificateIssuer;
30
+ /**
31
+ * Lifetime of issued certificates, in days. Renewal keeps the key and the
32
+ * `kid`, so short lifetimes are cheap.
33
+ *
34
+ * @default 30
35
+ */
36
+ validityDays?: number;
37
+ /**
38
+ * The SAN URI that binds a key to its owner. Receives the key's `tenant_id`,
39
+ * which is undefined for control-plane keys.
40
+ *
41
+ * Override this where the storage scope doesn't match ownership — a WFP
42
+ * tenant worker stores its own keys without a `tenant_id`.
43
+ *
44
+ * @default tenant keys → `urn:authhero:tenant:<tenant_id>`, control-plane
45
+ * keys → `urn:authhero:control-plane`
46
+ */
47
+ subjectUri?: (scope: {
48
+ tenant_id?: string;
49
+ }) => string;
50
+ }
51
+ export declare const DEFAULT_CA_CERT_VALIDITY_DAYS = 30;
52
+ export declare const TENANT_URI_PREFIX = "urn:authhero:tenant:";
53
+ export declare const CONTROL_PLANE_URI = "urn:authhero:control-plane";
54
+ /** Parameters `createX509Certificate` / `renewX509Certificate` need to issue from the CA. */
55
+ export interface CertificateAuthorityIssuance {
56
+ issuer: CertificateIssuer;
57
+ uri: string;
58
+ }
59
+ /**
60
+ * Resolve how a key should be certified. Only `jwt_signing` keys are
61
+ * CA-issued: SAML service providers pin certificates for years and gain
62
+ * nothing from a chain.
63
+ */
64
+ export declare function certificateAuthorityIssuance(ca: SigningCertificateAuthority | undefined, key: {
65
+ type: string;
66
+ tenant_id?: string;
67
+ }): CertificateAuthorityIssuance | undefined;
68
+ export interface LocalCertificateIssuerOptions {
69
+ /** The issuing (intermediate) CA certificate, PEM. */
70
+ certificate: string;
71
+ /** The issuing CA's PKCS#8 private key, PEM. */
72
+ privateKey: string;
73
+ /**
74
+ * Intermediates that were rotated out but may still have signed a
75
+ * published leaf. They are only used to build `x5c`, never to sign.
76
+ */
77
+ previousCertificates?: string[];
78
+ }
79
+ /**
80
+ * An in-process issuer holding the intermediate's private key. Keep the root
81
+ * offline; this only ever needs the intermediate.
82
+ */
83
+ export declare function createLocalCertificateIssuer(options: LocalCertificateIssuerOptions): CertificateIssuer;
84
+ /** True when the certificate was issued by someone other than itself. */
85
+ export declare function isCaIssued(cert: x509.X509Certificate): boolean;
86
+ /**
87
+ * The published chain for a CA-issued certificate: `x5c` (leaf first, then
88
+ * its issuer, standard base64 DER per RFC 7517 §4.7) and `x5t#S256`.
89
+ *
90
+ * The issuer is matched by name *and* by verifying the leaf's signature, so a
91
+ * CA that computes key identifiers differently can't produce a wrong chain.
92
+ * Returns undefined for self-signed certificates and when no known
93
+ * intermediate signed the leaf — publishing no chain beats publishing a
94
+ * wrong one.
95
+ */
96
+ export declare function certificateChainMembers(cert: x509.X509Certificate, issuerCertificates: x509.X509Certificate[]): Promise<{
97
+ x5c: string[];
98
+ "x5t#S256": string;
99
+ } | undefined>;
@@ -1,5 +1,6 @@
1
1
  import { SigningKey, KeysAdapter } from "@authhero/adapter-interfaces";
2
2
  import { SigningKeyMode, SigningKeyModeOption } from "../types/AuthHeroConfig";
3
+ import { SigningCertificateAuthority } from "./signing-certificate-authority";
3
4
  export declare function listControlPlaneKeys(keys: KeysAdapter, type?: string): Promise<SigningKey[]>;
4
5
  export declare function resolveSigningKeyMode(option: SigningKeyModeOption | undefined, tenantId: string): Promise<SigningKeyMode>;
5
6
  export interface ResolveSigningKeysOptions {
@@ -42,6 +43,12 @@ export interface EnsureSigningKeyOptions {
42
43
  name?: string;
43
44
  /** Defaults to `"jwt_signing"`. */
44
45
  type?: SigningKey["type"];
46
+ /**
47
+ * Issue the new key's certificate from this CA (`jwt_signing` only). The
48
+ * SAN is resolved from `tenantId`, so a WFP tenant worker that stores its
49
+ * keys without one should set `subjectUri` on the CA config.
50
+ */
51
+ certificateAuthority?: SigningCertificateAuthority;
45
52
  }
46
53
  export interface EnsureSigningKeyResult {
47
54
  /** True when a new key was minted; false when a signable key already existed. */