authhero 9.17.0 → 9.19.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 (44) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +144 -144
  3. package/dist/authhero.d.ts +362 -233
  4. package/dist/authhero.mjs +13301 -13145
  5. package/dist/tsconfig.types.tsbuildinfo +1 -1
  6. package/dist/types/authentication-flows/passwordless.d.ts +2 -2
  7. package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
  8. package/dist/types/helpers/http-certificate-issuer.d.ts +55 -0
  9. package/dist/types/helpers/logging.d.ts +5 -0
  10. package/dist/types/helpers/outbox-destinations/log-streams.d.ts +3 -0
  11. package/dist/types/helpers/renew-signing-certificates.d.ts +61 -0
  12. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  13. package/dist/types/index.d.ts +250 -231
  14. package/dist/types/routes/auth-api/index.d.ts +14 -14
  15. package/dist/types/routes/auth-api/passwordless.d.ts +8 -8
  16. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  17. package/dist/types/routes/management-api/action-executions.d.ts +2 -2
  18. package/dist/types/routes/management-api/action-triggers.d.ts +1 -1
  19. package/dist/types/routes/management-api/actions.d.ts +1 -1
  20. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  21. package/dist/types/routes/management-api/branding.d.ts +1 -1
  22. package/dist/types/routes/management-api/connections.d.ts +1 -1
  23. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  24. package/dist/types/routes/management-api/failed-events.d.ts +3 -1
  25. package/dist/types/routes/management-api/forms.d.ts +126 -126
  26. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  27. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  28. package/dist/types/routes/management-api/index.d.ts +225 -210
  29. package/dist/types/routes/management-api/keys.d.ts +8 -8
  30. package/dist/types/routes/management-api/log-streams.d.ts +6 -6
  31. package/dist/types/routes/management-api/organizations.d.ts +6 -6
  32. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  33. package/dist/types/routes/management-api/roles.d.ts +13 -0
  34. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  35. package/dist/types/routes/management-api/tenant-operations.d.ts +4 -4
  36. package/dist/types/routes/management-api/tenants.d.ts +6 -6
  37. package/dist/types/routes/management-api/users.d.ts +24 -24
  38. package/dist/types/routes/universal-login/flow-api.d.ts +8 -8
  39. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  40. package/dist/types/routes/universal-login/index.d.ts +2 -2
  41. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  42. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  43. package/dist/types/state-machines/login-session.d.ts +1 -1
  44. package/package.json +6 -6
@@ -561,8 +561,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
561
561
  } | undefined;
562
562
  authenticated_at?: string | undefined;
563
563
  };
564
- connectionType: "email" | "sms" | "username";
565
- authConnection: "email" | "sms" | "username";
564
+ connectionType: "username" | "email" | "sms";
565
+ authConnection: "username" | "email" | "sms";
566
566
  session_id: string | undefined;
567
567
  authParams: {
568
568
  audience?: string | undefined;
@@ -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";
26
27
  client_secret_post: "client_secret_post";
27
28
  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
  }>>;
@@ -0,0 +1,55 @@
1
+ import { Hono } from "hono";
2
+ import { CertificateIssuer, SigningCertificateRequest } from "./signing-certificate-authority";
3
+ export interface HttpCertificateIssuerOptions {
4
+ /** Base URL of a service mounted with `createCertificateIssuerApp`. */
5
+ url: string;
6
+ /**
7
+ * Headers sent with every certificate request — typically the credential
8
+ * that identifies this caller to the CA service.
9
+ */
10
+ headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
11
+ /**
12
+ * How long to cache the issuer certificates used to build `x5c`.
13
+ *
14
+ * @default 300
15
+ */
16
+ issuerCertificatesTtlSeconds?: number;
17
+ /** Override for tests or a service binding's `fetch`. */
18
+ fetch?: typeof fetch;
19
+ }
20
+ /**
21
+ * A `CertificateIssuer` that asks a remote CA service to certify keys, so the
22
+ * CA private key never has to live in the auth worker. Pair it with
23
+ * `createCertificateIssuerApp` on the service side.
24
+ */
25
+ export declare function createHttpCertificateIssuer(options: HttpCertificateIssuerOptions): CertificateIssuer;
26
+ export interface CertificateIssuerAppOptions {
27
+ /** The issuer that actually signs, typically `createLocalCertificateIssuer`. */
28
+ issuer: CertificateIssuer;
29
+ /**
30
+ * Decide whether the caller may have this certificate. This is the only
31
+ * thing stopping one tenant from obtaining a certificate that names another
32
+ * tenant, or the control plane, so check the caller's identity against
33
+ * `certificateRequest.uri`.
34
+ */
35
+ authorize: (params: {
36
+ request: Request;
37
+ certificateRequest: SigningCertificateRequest;
38
+ }) => boolean | Promise<boolean>;
39
+ /**
40
+ * The longest lifetime and time from now until expiry a caller may request.
41
+ * Keeps a compromised caller
42
+ * from minting a certificate that outlives its access.
43
+ *
44
+ * @default 90
45
+ */
46
+ maxValidityDays?: number;
47
+ }
48
+ /**
49
+ * Serves a `CertificateIssuer` over HTTP for `createHttpCertificateIssuer`.
50
+ *
51
+ * - `POST /certificates` issues a leaf after `authorize` approves it.
52
+ * - `GET /issuer-certificates` returns the intermediates. They are published
53
+ * in every JWKS `x5c` anyway, so this route is not authorized.
54
+ */
55
+ export declare function createCertificateIssuerApp(options: CertificateIssuerAppOptions): Hono;
@@ -44,6 +44,11 @@ export type LogParams = {
44
44
  * both authorizing as the same client).
45
45
  */
46
46
  redirect_uri?: string;
47
+ /**
48
+ * The original `/authorize` URL of the login. Carried on the audit event
49
+ * (and so to log streams) but not written to the log's `details`.
50
+ */
51
+ authorization_url?: string;
47
52
  /**
48
53
  * Response details to include in the log (for Management API operations)
49
54
  */
@@ -24,11 +24,14 @@ interface LogStreamData {
24
24
  path: string;
25
25
  qs?: Record<string, string>;
26
26
  body?: unknown;
27
+ redirect_uri?: string;
28
+ authorization_url?: string;
27
29
  };
28
30
  response?: {
29
31
  statusCode: number;
30
32
  body?: unknown;
31
33
  };
34
+ execution_id?: string;
32
35
  };
33
36
  }
34
37
  interface LogStreamPayload {
@@ -0,0 +1,61 @@
1
+ import { DataAdapters } from "@authhero/adapter-interfaces";
2
+ import { SigningCertificateAuthority } from "./signing-certificate-authority";
3
+ export interface RenewSigningCertificatesConfig {
4
+ /** Same `DataAdapters` passed to `init()`. */
5
+ dataAdapter: Pick<DataAdapters, "keys">;
6
+ /** Same value passed to `init({ signingCertificateAuthority })`. */
7
+ certificateAuthority: SigningCertificateAuthority;
8
+ /**
9
+ * Renew certificates that expire within this many days.
10
+ *
11
+ * @default a third of the CA's `validityDays` (10 days for the 30-day
12
+ * default), and at least one day
13
+ */
14
+ renewBeforeDays?: number;
15
+ /** Clock override for tests. */
16
+ now?: () => Date;
17
+ }
18
+ export interface RenewSigningCertificatesResult {
19
+ /** Keys whose certificate was re-issued. The `kid` is unchanged. */
20
+ renewed: string[];
21
+ /** CA-issued keys that are not due yet. */
22
+ notDue: number;
23
+ failed: {
24
+ kid: string;
25
+ error: unknown;
26
+ }[];
27
+ }
28
+ /** Thrown after every key has been tried, when at least one renewal failed. */
29
+ export declare class SigningCertificateRenewalError extends Error {
30
+ result: RenewSigningCertificatesResult;
31
+ constructor(result: RenewSigningCertificatesResult);
32
+ }
33
+ /**
34
+ * Re-issues CA-issued `jwt_signing` certificates that are close to expiry.
35
+ *
36
+ * Renewal keeps the key pair, so the `kid` and every token already signed
37
+ * stay valid; only the certificate — and therefore the `x5c` a resource
38
+ * server validates — moves forward. Call it from a scheduled handler at least
39
+ * daily.
40
+ *
41
+ * Only certificates the CA issued are touched. Self-signed keys created
42
+ * before the CA was configured keep their certificate until they are rotated
43
+ * out, and public-only rows (a WFP tenant's copy of the control plane's
44
+ * verify keys) are skipped because there is no private key to certify.
45
+ *
46
+ * Every key is tried even if an earlier one fails. If any failed, a
47
+ * `SigningCertificateRenewalError` carrying the result is thrown at the end.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * export default {
52
+ * async scheduled(_event, env) {
53
+ * await renewSigningCertificates({
54
+ * dataAdapter,
55
+ * certificateAuthority: signingCertificateAuthority,
56
+ * });
57
+ * },
58
+ * };
59
+ * ```
60
+ */
61
+ export declare function renewSigningCertificates(config: RenewSigningCertificatesConfig): Promise<RenewSigningCertificatesResult>;
@@ -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: ("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")[];
17
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "scope" | "org_id" | "sid" | "sub" | "exp" | "iat" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "permissions" | "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: ("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")[];
19
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("tenant_id" | "client_id" | "org_name" | "scope" | "org_id" | "sid" | "sub" | "exp" | "iat" | "iss" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "permissions" | "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
  /**