authhero 9.18.0 → 9.20.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 (63) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +185 -173
  3. package/dist/authhero.d.ts +389 -159
  4. package/dist/authhero.mjs +19766 -17178
  5. package/dist/tsconfig.types.tsbuildinfo +1 -1
  6. package/dist/types/authentication-flows/email-verification.d.ts +74 -0
  7. package/dist/types/authentication-flows/password.d.ts +3 -2
  8. package/dist/types/authentication-flows/passwordless.d.ts +2 -2
  9. package/dist/types/emails/index.d.ts +27 -1
  10. package/dist/types/generated/locale-types.d.ts +282 -0
  11. package/dist/types/helpers/dcr/metadata-mapping.d.ts +2 -2
  12. package/dist/types/helpers/default-destinations.d.ts +7 -1
  13. package/dist/types/helpers/http-certificate-issuer.d.ts +55 -0
  14. package/dist/types/helpers/logging.d.ts +5 -0
  15. package/dist/types/helpers/outbox-destinations/code-hooks.d.ts +5 -1
  16. package/dist/types/helpers/outbox-destinations/log-streams.d.ts +3 -0
  17. package/dist/types/helpers/renew-signing-certificates.d.ts +61 -0
  18. package/dist/types/helpers/request-data.d.ts +15 -0
  19. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  20. package/dist/types/helpers/run-outbox-relay.d.ts +7 -1
  21. package/dist/types/hooks/codehooks.d.ts +14 -1
  22. package/dist/types/index.d.ts +211 -155
  23. package/dist/types/routes/auth-api/index.d.ts +26 -26
  24. package/dist/types/routes/auth-api/passwordless.d.ts +18 -18
  25. package/dist/types/routes/auth-api/token.d.ts +10 -10
  26. package/dist/types/routes/management-api/action-executions.d.ts +2 -2
  27. package/dist/types/routes/management-api/actions.d.ts +1 -1
  28. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  29. package/dist/types/routes/management-api/branding.d.ts +1 -1
  30. package/dist/types/routes/management-api/client-grants.d.ts +9 -9
  31. package/dist/types/routes/management-api/connections.d.ts +6 -6
  32. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  33. package/dist/types/routes/management-api/failed-events.d.ts +53 -1
  34. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  35. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  36. package/dist/types/routes/management-api/hook-code.d.ts +2 -2
  37. package/dist/types/routes/management-api/index.d.ts +178 -126
  38. package/dist/types/routes/management-api/keys.d.ts +8 -8
  39. package/dist/types/routes/management-api/log-streams.d.ts +6 -6
  40. package/dist/types/routes/management-api/logs.d.ts +4 -4
  41. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  42. package/dist/types/routes/management-api/organizations.d.ts +3 -3
  43. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  44. package/dist/types/routes/management-api/tenant-operations.d.ts +5 -5
  45. package/dist/types/routes/management-api/tenants.d.ts +1 -1
  46. package/dist/types/routes/management-api/themes.d.ts +6 -6
  47. package/dist/types/routes/management-api/users.d.ts +33 -33
  48. package/dist/types/routes/universal-login/common.d.ts +4 -4
  49. package/dist/types/routes/universal-login/error-page.d.ts +9 -2
  50. package/dist/types/routes/universal-login/flow-api.d.ts +4 -4
  51. package/dist/types/routes/universal-login/sanitization-utils.d.ts +7 -0
  52. package/dist/types/routes/universal-login/screen-prompt-map.d.ts +2 -0
  53. package/dist/types/routes/universal-login/screens/email-verification.d.ts +29 -0
  54. package/dist/types/routes/universal-login/screens/handler-error.d.ts +11 -0
  55. package/dist/types/routes/universal-login/screens/reset-password.d.ts +5 -1
  56. package/dist/types/routes/universal-login/screens/signup.d.ts +6 -0
  57. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  58. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  59. package/dist/types/state-machines/login-session.d.ts +1 -1
  60. package/dist/types/types/AuthHeroConfig.d.ts +25 -0
  61. package/dist/types/types/Bindings.d.ts +8 -1
  62. package/dist/types/types/Variables.d.ts +18 -1
  63. package/package.json +6 -6
@@ -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>;
@@ -0,0 +1,15 @@
1
+ import { Context } from "hono";
2
+ import { DataAdapters } from "@authhero/adapter-interfaces";
3
+ import { Bindings, Variables } from "../types";
4
+ /**
5
+ * Installs `data` as this request's adapter stack on `ctx.var.data`.
6
+ *
7
+ * Also writes it to `ctx.env.data`, a deprecated alias kept for readers that
8
+ * have not moved to `ctx.var.data` yet, including consumers outside this repo.
9
+ * The env write is only safe because `applyConfigMiddleware` gives every
10
+ * request its own shallow copy of `env`. Drop it in the next major (#140).
11
+ */
12
+ export declare function setRequestData(ctx: Context<{
13
+ Bindings: Bindings;
14
+ Variables: Variables;
15
+ }>, data: DataAdapters): void;
@@ -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" | "sub" | "sid" | "scope" | "permissions" | "iat" | "org_id" | "aud" | "auth_time" | "exp" | "iss" | "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: ("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" | "sub" | "sid" | "scope" | "permissions" | "iat" | "org_id" | "aud" | "auth_time" | "exp" | "iss" | "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
  /**
@@ -1,5 +1,5 @@
1
1
  import { CodeExecutor, DataAdapters } from "@authhero/adapter-interfaces";
2
- import type { WebhookInvoker } from "../types/AuthHeroConfig";
2
+ import type { ActionExecutionLogCapture, WebhookInvoker } from "../types/AuthHeroConfig";
3
3
  import type { OutboxMetricsSink } from "../types/OutboxMetrics";
4
4
  export interface RunOutboxRelayConfig {
5
5
  /** Same `DataAdapters` passed to `init()`. Must include `outbox` to drain. */
@@ -32,6 +32,12 @@ export interface RunOutboxRelayConfig {
32
32
  * silently skipped.
33
33
  */
34
34
  codeExecutor?: CodeExecutor;
35
+ /**
36
+ * Same value as `init({ actionExecutionLogs })`, so code hooks run by this
37
+ * cron drain persist console output the same way as inline deliveries.
38
+ * Defaults to `"full"`.
39
+ */
40
+ actionExecutionLogs?: ActionExecutionLogCapture;
35
41
  /**
36
42
  * Optional metrics sink — same shape as `init({ outbox: { metrics } })`.
37
43
  * Receives `outbox_events_processed_total`,
@@ -1,6 +1,7 @@
1
1
  import { Context } from "hono";
2
2
  import { ActionExecutionLogs, ActionExecutionResult, CodeExecutionLog, CodeExecutor, DataAdapters, Hook } from "@authhero/adapter-interfaces";
3
3
  import { Bindings, Variables } from "../types";
4
+ import type { ActionExecutionLogCapture } from "../types/AuthHeroConfig";
4
5
  import { HookEvent, OnExecuteCredentialsExchangeAPI } from "../types/Hooks";
5
6
  import { EnrichedClient } from "../helpers/client";
6
7
  /**
@@ -152,12 +153,24 @@ export declare const MAX_PERSISTED_LOG_CHARS = 256;
152
153
  * output and is not itself charged against the budget.
153
154
  */
154
155
  export declare function capActionExecutionLogs(logs: ActionExecutionLogs, budget?: number): ActionExecutionLogs;
156
+ /**
157
+ * Select the outcomes whose console output may be persisted under the
158
+ * configured `actionExecutionLogs` mode. `"errors"` keeps only outcomes that
159
+ * errored or denied access. Any value other than the documented modes (a
160
+ * JS caller passing `"OFF"`, say) fails closed and persists nothing.
161
+ */
162
+ export declare function selectPersistedLogOutcomes(outcomes: HandleCodeHookOutcome[], logCapture?: ActionExecutionLogCapture): HandleCodeHookOutcome[];
155
163
  /**
156
164
  * Aggregate per-action outcomes into an Auth0-shape execution record and
157
165
  * persist it via the adapter. Returns the generated execution_id (uuid)
158
166
  * so the caller can embed it in the surrounding tenant log.
167
+ *
168
+ * `options.logCapture` (from `init({ actionExecutionLogs })`) decides which
169
+ * console output reaches `logs`; the rest of the record is always written.
159
170
  */
160
- export declare function persistActionExecution(data: Pick<DataAdapters, "actionExecutions">, tenant_id: string, triggerId: string, outcomes: HandleCodeHookOutcome[]): Promise<string | null>;
171
+ export declare function persistActionExecution(data: Pick<DataAdapters, "actionExecutions">, tenant_id: string, triggerId: string, outcomes: HandleCodeHookOutcome[], options?: {
172
+ logCapture?: ActionExecutionLogCapture;
173
+ }): Promise<string | null>;
161
174
  /**
162
175
  * Execute code hooks for the credentials-exchange trigger.
163
176
  * Filters enabled code hooks from the provided hooks list and executes them.