authhero 9.15.0 → 9.17.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 (61) 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 +144 -144
  7. package/dist/authhero.d.ts +381 -249
  8. package/dist/authhero.mjs +13183 -13003
  9. package/dist/tsconfig.types.tsbuildinfo +1 -1
  10. package/dist/types/authentication-flows/passwordless.d.ts +2 -2
  11. package/dist/types/generated/locale-types.d.ts +1 -0
  12. package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
  13. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  14. package/dist/types/helpers/scopes-permissions.d.ts +51 -12
  15. package/dist/types/helpers/signing-certificate-authority.d.ts +99 -0
  16. package/dist/types/helpers/signing-keys.d.ts +7 -0
  17. package/dist/types/index.d.ts +257 -247
  18. package/dist/types/middlewares/authentication.d.ts +1 -0
  19. package/dist/types/middlewares/reject-unknown-hosts.d.ts +13 -0
  20. package/dist/types/routes/auth-api/index.d.ts +25 -24
  21. package/dist/types/routes/auth-api/passwordless.d.ts +8 -8
  22. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  23. package/dist/types/routes/auth-api/token.d.ts +10 -10
  24. package/dist/types/routes/auth-api/well-known.d.ts +1 -0
  25. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  26. package/dist/types/routes/management-api/actions.d.ts +3 -3
  27. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  28. package/dist/types/routes/management-api/branding.d.ts +1 -1
  29. package/dist/types/routes/management-api/client-grants.d.ts +9 -9
  30. package/dist/types/routes/management-api/connections.d.ts +1 -1
  31. package/dist/types/routes/management-api/email-templates.d.ts +2 -2
  32. package/dist/types/routes/management-api/emails.d.ts +2 -2
  33. package/dist/types/routes/management-api/failed-events.d.ts +1 -1
  34. package/dist/types/routes/management-api/forms.d.ts +133 -126
  35. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  36. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  37. package/dist/types/routes/management-api/hooks.d.ts +4 -4
  38. package/dist/types/routes/management-api/index.d.ts +219 -212
  39. package/dist/types/routes/management-api/keys.d.ts +8 -8
  40. package/dist/types/routes/management-api/logs.d.ts +4 -4
  41. package/dist/types/routes/management-api/organizations.d.ts +7 -7
  42. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  43. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  44. package/dist/types/routes/management-api/tenant-operations.d.ts +4 -4
  45. package/dist/types/routes/management-api/token-exchange-profiles.d.ts +6 -0
  46. package/dist/types/routes/management-api/users.d.ts +26 -26
  47. package/dist/types/routes/universal-login/flow-api.d.ts +12 -12
  48. package/dist/types/routes/universal-login/form-node.d.ts +4 -4
  49. package/dist/types/routes/universal-login/index.d.ts +4 -4
  50. package/dist/types/routes/universal-login/screens/connect-authz.d.ts +16 -0
  51. package/dist/types/routes/universal-login/u2-form-node.d.ts +2 -2
  52. package/dist/types/routes/universal-login/u2-index.d.ts +7 -7
  53. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  54. package/dist/types/state-machines/login-session.d.ts +1 -1
  55. package/dist/types/types/AuthHeroConfig.d.ts +38 -0
  56. package/dist/types/types/Bindings.d.ts +3 -0
  57. package/dist/types/utils/encryption.d.ts +20 -0
  58. package/dist/types/utils/jwks.d.ts +4 -1
  59. package/package.json +6 -6
  60. package/dist/assets/u/widget/p-1eb7f287.entry.js +0 -1
  61. package/dist/assets/u/widget/p-398d72df.entry.js +0 -1
@@ -561,8 +561,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
561
561
  } | undefined;
562
562
  authenticated_at?: string | undefined;
563
563
  };
564
- connectionType: "sms" | "email" | "username";
565
- authConnection: "sms" | "email" | "username";
564
+ connectionType: "email" | "sms" | "username";
565
+ authConnection: "email" | "sms" | "username";
566
566
  session_id: string | undefined;
567
567
  authParams: {
568
568
  audience?: string | undefined;
@@ -99,6 +99,7 @@ export interface LoginScreen {
99
99
  editEmailText: () => string;
100
100
  emailPlaceholder: () => string;
101
101
  enterACodeBtn: () => string;
102
+ enterACodeShortBtn: () => string;
102
103
  federatedConnectionButtonText: (vars: {
103
104
  connectionName: string;
104
105
  }) => string;
@@ -23,9 +23,9 @@ 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
26
  client_secret_post: "client_secret_post";
28
27
  client_secret_basic: "client_secret_basic";
28
+ none: "none";
29
29
  client_secret_jwt: "client_secret_jwt";
30
30
  private_key_jwt: "private_key_jwt";
31
31
  }>>;
@@ -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: ("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")[];
17
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "sid" | "permissions" | "scope" | "sub" | "auth_time" | "iss" | "aud" | "exp" | "nbf" | "iat" | "jti" | "acr" | "amr" | "act" | "org_id" | "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: ("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")[];
19
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "sid" | "permissions" | "scope" | "sub" | "auth_time" | "iss" | "aud" | "exp" | "nbf" | "iat" | "jti" | "azp" | "acr" | "amr" | "act" | "org_id" | "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
  /**
@@ -24,23 +24,62 @@ export interface ScopesAndPermissionsResult {
24
24
  token_lifetime_for_web: number;
25
25
  }
26
26
  /**
27
- * True when the user holds the global `admin:organizations` escape hatch — the
28
- * single canonical key for "may act on any organization without being a
29
- * member". It is a management-plane permission, so it is always matched against
30
- * the Management API audience, never the requested token's audience.
27
+ * Management API permission that lets a user act on any organization without
28
+ * being a member. Doubles as a tenant-admin permission on the multi-tenancy
29
+ * `/tenants` routes, and only bypasses org membership when the tenant has the
30
+ * `inherit_global_permissions_in_organizations` flag.
31
+ */
32
+ export declare const ADMIN_ORGANIZATIONS_PERMISSION = "admin:organizations";
33
+ /**
34
+ * Management API permission that lets a user get org-scoped tokens for (and
35
+ * list) every organization without being a member. Unlike
36
+ * `admin:organizations` it carries no tenant-admin rights and needs no tenant
37
+ * flag: holding the permission is the opt-in.
38
+ */
39
+ export declare const ACCESS_ALL_ORGANIZATIONS_PERMISSION = "access:all_organizations";
40
+ /**
41
+ * True when the user holds `permissionName` at global scope on the Management
42
+ * API audience, directly or through a role.
43
+ */
44
+ export declare function userHasGlobalManagementPermission(ctx: Context<{
45
+ Bindings: Bindings;
46
+ Variables: Variables;
47
+ }>, tenantId: string, userId: string, permissionName: string): Promise<boolean>;
48
+ /**
49
+ * Single rule for "may this user get an org-scoped token for an organization
50
+ * they are not a member of?". Used by every org-membership gate
51
+ * (calculateScopesAndPermissions, token exchange, refresh token) so they can
52
+ * never disagree.
31
53
  *
32
- * "Global" means an assignment with an empty organization scope (`""`). Both
33
- * directly-assigned user permissions AND role-derived permissions count, so a
34
- * user granted the permission either way is treated consistently (see #1198).
54
+ * True when the user holds, at global scope on the Management API audience:
55
+ * - `access:all_organizations` (no tenant flag needed), or
56
+ * - `admin:organizations` AND the tenant has
57
+ * `inherit_global_permissions_in_organizations` (legacy behaviour).
35
58
  *
36
- * The caller is responsible for gating on the
37
- * `inherit_global_permissions_in_organizations` tenant flag; this helper only
38
- * answers whether the permission is present.
59
+ * Pass `tenant` when the caller already loaded it to skip a second fetch.
60
+ */
61
+ export declare function userCanAccessAllOrganizations(ctx: Context<{
62
+ Bindings: Bindings;
63
+ Variables: Variables;
64
+ }>, tenantId: string, userId: string, tenant?: {
65
+ flags?: {
66
+ inherit_global_permissions_in_organizations?: boolean;
67
+ };
68
+ } | null): Promise<boolean>;
69
+ /**
70
+ * True when the user may get an org-scoped token for `organizationId`: either
71
+ * they may access every organization (see `userCanAccessAllOrganizations`) or
72
+ * they are a member of it. Every org gate (login, silent auth, token grants)
73
+ * goes through here so they apply the same rule.
39
74
  */
40
- export declare function userHasGlobalOrgAdminPermission(ctx: Context<{
75
+ export declare function userCanAccessOrganization(ctx: Context<{
41
76
  Bindings: Bindings;
42
77
  Variables: Variables;
43
- }>, tenantId: string, userId: string): Promise<boolean>;
78
+ }>, tenantId: string, userId: string, organizationId: string, tenant?: {
79
+ flags?: {
80
+ inherit_global_permissions_in_organizations?: boolean;
81
+ };
82
+ } | null): Promise<boolean>;
44
83
  /**
45
84
  * Returns the subset of `scopes` that the resource server matching `audience`
46
85
  * does not define — the scopes that would silently vanish from an issued token.
@@ -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. */