authhero 9.41.0 → 9.42.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 (74) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +114 -111
  3. package/dist/authhero.d.ts +534 -272
  4. package/dist/authhero.mjs +16181 -12453
  5. package/dist/{mfa-Dx8-AJ6U.js → mfa-C8qBEQeH.js} +2 -2
  6. package/dist/{mfa-CdC-9ysu.mjs → mfa-CVF4Wbdz.mjs} +115 -115
  7. package/dist/mfa-attempts-CzGjIGzD.js +395 -0
  8. package/dist/{mfa-attempts-mBkfX0wf.mjs → mfa-attempts-sV0Xs59R.mjs} +5151 -4696
  9. package/dist/{passkey-enrollment-KQcVF_QM.js → passkey-enrollment-CAb2zWEF.js} +1 -1
  10. package/dist/tsconfig.types.tsbuildinfo +1 -1
  11. package/dist/types/authentication-flows/passwordless.d.ts +2 -2
  12. package/dist/types/helpers/client.d.ts +26 -0
  13. package/dist/types/helpers/login-migration.d.ts +56 -0
  14. package/dist/types/helpers/login-version.d.ts +18 -0
  15. package/dist/types/helpers/management-audience.d.ts +11 -0
  16. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  17. package/dist/types/helpers/saml-connection-options.d.ts +24 -0
  18. package/dist/types/helpers/saml-request-signature.d.ts +36 -0
  19. package/dist/types/hooks/lifecycle-codehooks.d.ts +1 -1
  20. package/dist/types/index.d.ts +490 -271
  21. package/dist/types/routes/auth-api/authorize.d.ts +13 -13
  22. package/dist/types/routes/auth-api/callback.d.ts +42 -6
  23. package/dist/types/routes/auth-api/device.d.ts +21 -21
  24. package/dist/types/routes/auth-api/index.d.ts +113 -77
  25. package/dist/types/routes/auth-api/logout.d.ts +2 -2
  26. package/dist/types/routes/auth-api/oidc-logout.d.ts +3 -3
  27. package/dist/types/routes/auth-api/passwordless.d.ts +14 -14
  28. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  29. package/dist/types/routes/auth-api/token.d.ts +12 -12
  30. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  31. package/dist/types/routes/management-api/action-triggers.d.ts +2 -2
  32. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  33. package/dist/types/routes/management-api/branding-uploads.d.ts +4 -4
  34. package/dist/types/routes/management-api/branding.d.ts +19 -19
  35. package/dist/types/routes/management-api/client-registration-tokens.d.ts +3 -3
  36. package/dist/types/routes/management-api/clients.d.ts +38 -8
  37. package/dist/types/routes/management-api/connections.d.ts +90 -0
  38. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  39. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  40. package/dist/types/routes/management-api/failed-events.d.ts +4 -4
  41. package/dist/types/routes/management-api/forms.d.ts +8 -8
  42. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  43. package/dist/types/routes/management-api/hooks.d.ts +21 -21
  44. package/dist/types/routes/management-api/index.d.ts +287 -167
  45. package/dist/types/routes/management-api/keys.d.ts +12 -12
  46. package/dist/types/routes/management-api/log-streams.d.ts +12 -12
  47. package/dist/types/routes/management-api/logs.d.ts +4 -4
  48. package/dist/types/routes/management-api/organizations.d.ts +6 -6
  49. package/dist/types/routes/management-api/prompts.d.ts +6 -6
  50. package/dist/types/routes/management-api/self-service-profiles.d.ts +8 -8
  51. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  52. package/dist/types/routes/management-api/tenant-operations.d.ts +5 -5
  53. package/dist/types/routes/management-api/tenants.d.ts +27 -23
  54. package/dist/types/routes/management-api/themes.d.ts +9 -9
  55. package/dist/types/routes/management-api/users.d.ts +26 -26
  56. package/dist/types/routes/saml/index.d.ts +72 -9
  57. package/dist/types/routes/saml/samlp.d.ts +72 -9
  58. package/dist/types/routes/universal-login/common.d.ts +12 -10
  59. package/dist/types/routes/universal-login/continue.d.ts +4 -4
  60. package/dist/types/routes/universal-login/flow-api.d.ts +4 -4
  61. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  62. package/dist/types/routes/universal-login/impersonate.d.ts +4 -4
  63. package/dist/types/routes/universal-login/index.d.ts +8 -8
  64. package/dist/types/routes/universal-login/u2-index.d.ts +9 -9
  65. package/dist/types/routes/universal-login/u2-routes.d.ts +7 -7
  66. package/dist/types/state-machines/login-session.d.ts +1 -1
  67. package/dist/types/strategies/index.d.ts +2 -0
  68. package/dist/types/strategies/samlp.d.ts +58 -0
  69. package/dist/types/types/AuthHeroConfig.d.ts +15 -1
  70. package/dist/types/types/Bindings.d.ts +2 -1
  71. package/dist/types/utils/ssrf-fetch.d.ts +2 -0
  72. package/dist/types/variables.d.ts +7 -6
  73. package/package.json +9 -6
  74. package/dist/mfa-attempts-CtWWceg2.js +0 -393
@@ -175,8 +175,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
175
175
  authenticated_at?: string | undefined;
176
176
  tenant_id?: string | undefined;
177
177
  };
178
- connectionType: "username" | "email" | "sms";
179
- authConnection: "username" | "email" | "sms";
178
+ connectionType: "email" | "username" | "sms";
179
+ authConnection: "email" | "username" | "sms";
180
180
  session_id: string | undefined;
181
181
  authParams: {
182
182
  audience?: string | undefined;
@@ -236,6 +236,10 @@ export declare const enrichedClientSchema: z.ZodObject<{
236
236
  use_scope_descriptions_for_consent: z.ZodOptional<z.ZodBoolean>;
237
237
  inherit_global_permissions_in_organizations: z.ZodOptional<z.ZodBoolean>;
238
238
  restrict_undefined_scopes: z.ZodOptional<z.ZodBoolean>;
239
+ universal_login_version: z.ZodOptional<z.ZodEnum<{
240
+ 1: "1";
241
+ 2: "2";
242
+ }>>;
239
243
  }, z.core.$strip>>;
240
244
  sandbox_version: z.ZodOptional<z.ZodString>;
241
245
  legacy_sandbox_version: z.ZodOptional<z.ZodString>;
@@ -547,6 +551,28 @@ export declare const enrichedClientSchema: z.ZodObject<{
547
551
  on_first_login: "on_first_login";
548
552
  never_on_login: "never_on_login";
549
553
  }>>;
554
+ signInEndpoint: z.ZodOptional<z.ZodString>;
555
+ signOutEndpoint: z.ZodOptional<z.ZodString>;
556
+ signingCert: z.ZodOptional<z.ZodString>;
557
+ signingCerts: z.ZodOptional<z.ZodArray<z.ZodString>>;
558
+ metadataUrl: z.ZodOptional<z.ZodString>;
559
+ metadataXml: z.ZodOptional<z.ZodString>;
560
+ signSAMLRequest: z.ZodOptional<z.ZodBoolean>;
561
+ signatureAlgorithm: z.ZodOptional<z.ZodEnum<{
562
+ "rsa-sha256": "rsa-sha256";
563
+ "rsa-sha1": "rsa-sha1";
564
+ }>>;
565
+ digestAlgorithm: z.ZodOptional<z.ZodEnum<{
566
+ sha256: "sha256";
567
+ sha1: "sha1";
568
+ }>>;
569
+ protocolBinding: z.ZodOptional<z.ZodEnum<{
570
+ "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect";
571
+ "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";
572
+ }>>;
573
+ user_id_attribute: z.ZodOptional<z.ZodString>;
574
+ fieldsMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
575
+ entityId: z.ZodOptional<z.ZodString>;
550
576
  }, z.core.$strip>>>;
551
577
  enabled_clients: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
552
578
  response_type: z.ZodOptional<z.ZodEnum<typeof import("@authhero/adapter-interfaces").AuthorizationResponseType>>;
@@ -0,0 +1,56 @@
1
+ import { Client, DataAdapters, Tenant } from "@authhero/adapter-interfaces";
2
+ import { LoginRoutePrefix } from "./login-version";
3
+ /**
4
+ * Tooling for moving tenants from the classic login (/u) to the widget login
5
+ * (/u2). Adapter-agnostic so the CLI in `scripts/login-migration.ts` can run
6
+ * it against any database.
7
+ */
8
+ export type LoginMigrationData = Pick<DataAdapters, "tenants" | "clients" | "promptSettings" | "themes" | "branding" | "universalLoginTemplates" | "customText" | "promptPartials">;
9
+ export type CheckStatus = "ok" | "warn" | "info";
10
+ export interface LoginMigrationCheck {
11
+ id: string;
12
+ status: CheckStatus;
13
+ message: string;
14
+ }
15
+ export interface LoginMigrationClient {
16
+ client_id: string;
17
+ name: string;
18
+ override?: string;
19
+ prefix: LoginRoutePrefix;
20
+ }
21
+ export interface LoginMigrationReport {
22
+ tenant_id: string;
23
+ /** The tenant flag `flags.universal_login_version`, if set. */
24
+ tenant_version?: string;
25
+ clients: LoginMigrationClient[];
26
+ /** Clients that resolve to /u today. */
27
+ unmigrated: number;
28
+ checks: LoginMigrationCheck[];
29
+ }
30
+ export declare function listAllClients(data: Pick<DataAdapters, "clients">, tenantId: string): Promise<Client[]>;
31
+ export declare function listAllTenants(data: Pick<DataAdapters, "tenants">): Promise<Tenant[]>;
32
+ /** How each of a tenant's clients resolves today. */
33
+ export declare function resolveTenantClients(tenant: Tenant, clients: Client[]): LoginMigrationClient[];
34
+ export declare function auditLoginMigration(data: LoginMigrationData, tenantId: string): Promise<LoginMigrationReport>;
35
+ /**
36
+ * Probes whether the widget bundle is served from a deployment. The database
37
+ * can't tell whether `widgetHandler` is mounted, and deployments that ship the
38
+ * bundle as static assets have no handler at all.
39
+ */
40
+ export declare function checkWidgetServed(baseUrl: string, fetchFn?: typeof fetch): Promise<LoginMigrationCheck>;
41
+ export interface SetTenantVersionResult {
42
+ tenant_id: string;
43
+ from?: string;
44
+ to?: string;
45
+ /** Clients pinned to /u by a "1" override, which stay on /u. */
46
+ pinned: string[];
47
+ }
48
+ /**
49
+ * Sets (or with `undefined`, removes) the tenant flag
50
+ * `flags.universal_login_version`. Client overrides are left untouched.
51
+ * Removing the flag restores the earlier routing only if the tenant had no
52
+ * flag or "1" before; `from` in the result reports the previous value.
53
+ */
54
+ export declare function setTenantLoginVersion(data: Pick<LoginMigrationData, "tenants" | "clients">, tenantId: string, version: "1" | "2" | undefined, { dryRun }?: {
55
+ dryRun?: boolean;
56
+ }): Promise<SetTenantVersionResult>;
@@ -0,0 +1,18 @@
1
+ export type LoginRoutePrefix = "/u" | "/u2";
2
+ type ClientLike = {
3
+ client_metadata?: Record<string, unknown> | null;
4
+ tenant?: {
5
+ flags?: {
6
+ universal_login_version?: string;
7
+ } | null;
8
+ } | null;
9
+ };
10
+ /**
11
+ * Picks the universal login a client uses.
12
+ *
13
+ * A client can override the tenant with `client_metadata.universal_login_version`
14
+ * ("2" → /u2, "1" → /u). Without an override the tenant flag
15
+ * `flags.universal_login_version` decides ("2" → /u2, "1" or unset → /u).
16
+ */
17
+ export declare function resolveLoginRoutePrefix(client: ClientLike): LoginRoutePrefix;
18
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { Context } from "hono";
2
+ import type { Bindings, Variables } from "../types";
3
+ /**
4
+ * True when `audience` is one the Management API accepts for this tenant: the
5
+ * built-in `urn:authhero:management` identifier, or one of the extra audiences
6
+ * the deployment configured with `init({ additionalManagementAudiences })`.
7
+ */
8
+ export declare function isManagementApiAudience(ctx: Context<{
9
+ Bindings: Bindings;
10
+ Variables: Variables;
11
+ }>, tenantId: string | undefined, audience: string): Promise<boolean>;
@@ -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: ("sub" | "scope" | "tenant_id" | "jti" | "client_id" | "org_name" | "sid" | "permissions" | "auth_time" | "iss" | "aud" | "exp" | "nbf" | "iat" | "acr" | "amr" | "act" | "org_id" | "requested_userinfo_claims" | "gty")[];
17
+ export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("scope" | "client_id" | "sid" | "tenant_id" | "org_name" | "iss" | "sub" | "aud" | "exp" | "iat" | "auth_time" | "acr" | "amr" | "jti" | "permissions" | "org_id" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
18
18
  /** Client-bound mints: `azp` must stay the registered client id. */
19
- export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("sub" | "scope" | "tenant_id" | "jti" | "client_id" | "org_name" | "sid" | "permissions" | "auth_time" | "iss" | "aud" | "exp" | "nbf" | "iat" | "azp" | "acr" | "amr" | "act" | "org_id" | "requested_userinfo_claims" | "gty")[];
19
+ export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("scope" | "client_id" | "sid" | "tenant_id" | "org_name" | "iss" | "sub" | "aud" | "exp" | "iat" | "auth_time" | "acr" | "amr" | "azp" | "jti" | "permissions" | "org_id" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
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,24 @@
1
+ import { Context } from "hono";
2
+ import { Connection } from "@authhero/adapter-interfaces";
3
+ import { Bindings, Variables } from "../types";
4
+ type ConnectionOptions = Connection["options"];
5
+ /**
6
+ * Fills a `samlp` connection's options from IdP metadata, the way Auth0 does
7
+ * when `metadataXml` or `metadataUrl` is set: signInEndpoint, signOutEndpoint,
8
+ * signingCert(s) and the IdP entity ID (stored as `issuer`, which responses
9
+ * are then checked against).
10
+ *
11
+ * Metadata is (re)read when it is new or changed, when clearing
12
+ * `metadataXml` leaves `metadataUrl` as the only source, when the request
13
+ * binding changed, or when the options still lack a sign-in endpoint or
14
+ * certificate, so the saved values always come from the current source and
15
+ * the saved endpoint is one the IdP offers for the saved binding.
16
+ * Then validates the result, so a bad configuration fails the save rather
17
+ * than every login: certificates must parse as X.509, and signed requests
18
+ * need the HTTP-Redirect binding.
19
+ */
20
+ export declare function resolveSamlConnectionOptions(ctx: Context<{
21
+ Bindings: Bindings;
22
+ Variables: Variables;
23
+ }>, options: ConnectionOptions, previous?: ConnectionOptions): Promise<ConnectionOptions>;
24
+ export {};
@@ -0,0 +1,36 @@
1
+ import { Context } from "hono";
2
+ import { Bindings, Variables } from "../types";
3
+ import { EnrichedClient } from "./client";
4
+ type SamlRequestToVerify = {
5
+ binding: "redirect";
6
+ /** The raw, still URL-encoded query string of the request. */
7
+ rawQuery: string;
8
+ } | {
9
+ binding: "post";
10
+ xml: string;
11
+ /** The root element the signature must cover. */
12
+ rootElement: "AuthnRequest" | "LogoutRequest";
13
+ };
14
+ export declare class SamlRequestSignatureError extends Error {
15
+ constructor(message: string);
16
+ }
17
+ /**
18
+ * Enforces signed SAML requests from a service provider, as Auth0 does: when
19
+ * the client's samlp addon has a `signingCert`, every AuthnRequest and
20
+ * LogoutRequest must be signed with it. `require_signed_requests` without a
21
+ * certificate fails closed, since nothing can be verified.
22
+ *
23
+ * HTTP-Redirect signatures are checked with WebCrypto. HTTP-POST requests
24
+ * carry an XML signature, checked with `ctx.env.samlVerifier`; it must cover
25
+ * the document's root request element itself: a signed reference counts only
26
+ * when its root has exactly the posted root's ID, and IDs are unique (the
27
+ * verifier refuses duplicates), so a signed element wrapped in an unsigned
28
+ * request is refused.
29
+ *
30
+ * @throws SamlRequestSignatureError when the request must be signed and isn't.
31
+ */
32
+ export declare function verifySamlRequestSignature(ctx: Context<{
33
+ Bindings: Bindings;
34
+ Variables: Variables;
35
+ }>, client: EnrichedClient, request: SamlRequestToVerify): Promise<void>;
36
+ export {};
@@ -10,7 +10,7 @@ export declare function listEnabledCodeHooks(ctx: Context<{
10
10
  Bindings: Bindings;
11
11
  Variables: Variables;
12
12
  }>, tenantId: string, triggerId: string): Promise<{
13
- trigger_id: "post-user-login" | "pre-user-registration" | "post-user-registration" | "post-user-update" | "validate-registration-username" | "pre-user-deletion" | "post-user-deletion" | "credentials-exchange" | "pre-user-update" | "pre-screen" | "custom-email-provider" | "custom-phone-provider";
13
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "post-user-update" | "validate-registration-username" | "pre-user-deletion" | "post-user-deletion" | "credentials-exchange" | "pre-user-update" | "pre-screen" | "custom-email-provider" | "custom-phone-provider";
14
14
  enabled: boolean;
15
15
  synchronous: boolean;
16
16
  created_at: string;