authhero 9.34.0 → 9.36.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 (65) hide show
  1. package/dist/assets/u/widget/index.esm.js +1 -1
  2. package/dist/authhero.cjs +105 -104
  3. package/dist/authhero.d.ts +304 -220
  4. package/dist/authhero.mjs +16782 -15989
  5. package/dist/{mfa-CDFRupfM.mjs → mfa-B044FRjD.mjs} +18 -18
  6. package/dist/{mfa-DF3O3Z8H.js → mfa-DPwn1ajo.js} +1 -1
  7. package/dist/mfa-attempts-BiU_pMOV.js +275 -0
  8. package/dist/{mfa-attempts-C06Bkdy9.mjs → mfa-attempts-DGOLb2oh.mjs} +6417 -6092
  9. package/dist/{passkey-enrollment-RGw-WaSq.js → passkey-enrollment-BDboqoaP.js} +1 -1
  10. package/dist/tsconfig.types.tsbuildinfo +1 -1
  11. package/dist/types/authentication-flows/passwordless.d.ts +6 -412
  12. package/dist/types/emails/from-address.d.ts +21 -0
  13. package/dist/types/errors/management-api-error.d.ts +3 -0
  14. package/dist/types/helpers/branding-assets.d.ts +28 -0
  15. package/dist/types/helpers/client.d.ts +5 -2
  16. package/dist/types/helpers/database-connection-scope.d.ts +67 -0
  17. package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
  18. package/dist/types/helpers/link-candidates.d.ts +7 -1
  19. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  20. package/dist/types/helpers/self-service-connections.d.ts +42 -0
  21. package/dist/types/helpers/sso-access-tickets.d.ts +18 -0
  22. package/dist/types/helpers/users.d.ts +29 -4
  23. package/dist/types/index.d.ts +298 -217
  24. package/dist/types/routes/assets.d.ts +11 -0
  25. package/dist/types/routes/auth-api/device.d.ts +8 -8
  26. package/dist/types/routes/auth-api/index.d.ts +40 -38
  27. package/dist/types/routes/auth-api/passwordless.d.ts +14 -12
  28. package/dist/types/routes/auth-api/register/index.d.ts +2 -2
  29. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  30. package/dist/types/routes/auth-api/token.d.ts +10 -10
  31. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  32. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  33. package/dist/types/routes/management-api/branding-uploads.d.ts +85 -0
  34. package/dist/types/routes/management-api/branding.d.ts +92 -13
  35. package/dist/types/routes/management-api/clients.d.ts +32 -32
  36. package/dist/types/routes/management-api/connections.d.ts +24 -24
  37. package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
  38. package/dist/types/routes/management-api/email-templates.d.ts +18 -18
  39. package/dist/types/routes/management-api/failed-events.d.ts +2 -2
  40. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  41. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  42. package/dist/types/routes/management-api/hook-code.d.ts +2 -2
  43. package/dist/types/routes/management-api/index.d.ts +251 -172
  44. package/dist/types/routes/management-api/keys.d.ts +8 -8
  45. package/dist/types/routes/management-api/log-streams.d.ts +6 -6
  46. package/dist/types/routes/management-api/logs.d.ts +4 -4
  47. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  48. package/dist/types/routes/management-api/organizations.d.ts +4 -4
  49. package/dist/types/routes/management-api/prompts.d.ts +6 -6
  50. package/dist/types/routes/management-api/self-service-profiles.d.ts +345 -0
  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 +10 -10
  53. package/dist/types/routes/management-api/tenants.d.ts +13 -13
  54. package/dist/types/routes/management-api/themes.d.ts +9 -9
  55. package/dist/types/routes/management-api/users.d.ts +29 -29
  56. package/dist/types/routes/universal-login/common.d.ts +12 -828
  57. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  58. package/dist/types/routes/universal-login/index.d.ts +2 -2
  59. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  60. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  61. package/dist/types/state-machines/login-session.d.ts +1 -1
  62. package/dist/types/types/Bindings.d.ts +1 -0
  63. package/dist/types/utils/username-password-provider.d.ts +14 -3
  64. package/package.json +6 -6
  65. package/dist/mfa-attempts-BOWgbEPg.js +0 -275
@@ -0,0 +1,42 @@
1
+ import type { Connection, ConnectionSelfService, ConnectionsAdapter, User } from "@authhero/adapter-interfaces";
2
+ /**
3
+ * Self-Service SSO (#1763) lets an outside admin configure a connection's
4
+ * identity provider through a ticket. Whoever controls that identity provider
5
+ * controls what it asserts, including `email_verified: true` for any address.
6
+ * Email-based account linking trusts `email_verified`, so without a guard such
7
+ * a connection could take over existing accounts, or capture accounts created
8
+ * later with the same email.
9
+ *
10
+ * The guard: for a self-service connection, an email is trusted only when its
11
+ * domain is verified for that connection.
12
+ * - `email_verified` is forced to `false` outside verified domains
13
+ * ({@link isUntrustedSelfServiceEmail});
14
+ * - a user of such a connection whose email domain is not verified is never
15
+ * picked as an email-linking target ({@link filterTrustedLinkTargets}).
16
+ */
17
+ /** The connection without its internal Self-Service SSO state. */
18
+ export declare function withoutSelfService<T extends Pick<Connection, "self_service">>(connection: T): Omit<T, "self_service">;
19
+ /** The lowercased domain of an email address, or `undefined`. */
20
+ export declare function emailDomain(email: string | undefined): string | undefined;
21
+ /**
22
+ * True when the email's domain is verified for the self-service connection.
23
+ * Exact match: verifying `example.com` does not cover `sub.example.com`.
24
+ */
25
+ export declare function isEmailDomainVerified(selfService: ConnectionSelfService, email: string | undefined): boolean;
26
+ /**
27
+ * True when the connection is a self-service connection that does not vouch
28
+ * for this email (its domain is not verified for it), i.e. the guard has to
29
+ * force `email_verified` to `false`. Always false for an ordinary connection,
30
+ * whose assertions are stored as they come.
31
+ */
32
+ export declare function isUntrustedSelfServiceEmail(selfService: ConnectionSelfService | null | undefined, email: string | undefined): boolean;
33
+ /**
34
+ * Drops the candidates that must never become an email-linking target: users
35
+ * of a self-service connection whose email domain is not verified for it.
36
+ * Their identity provider could assert someone else's email, so linking a new
37
+ * account into them would hand that account to whoever runs the provider.
38
+ *
39
+ * Reads the tenant's connections only when there are candidates, so the
40
+ * common path (no existing user with the email) costs nothing.
41
+ */
42
+ export declare function filterTrustedLinkTargets(connections: Pick<ConnectionsAdapter, "list">, tenantId: string, candidates: User[]): Promise<User[]>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Self-Service SSO access tickets (#1763). The ticket id is the bearer value
3
+ * in the ticket URL: random, returned once, and stored only as its hash.
4
+ */
5
+ /** Default and maximum ticket lifetime. Auth0's default is 5 days. */
6
+ export declare const SSO_TICKET_DEFAULT_TTL_SEC = 432000;
7
+ export declare const SSO_TICKET_MAX_TTL_SEC: number;
8
+ /** A new ticket id: 32 random bytes, base64url (43 characters). */
9
+ export declare function generateSsoTicketId(): string;
10
+ /** The stored form of a ticket id: hex SHA-256. */
11
+ export declare function hashSsoTicketId(ticketId: string): Promise<string>;
12
+ /** The setup assistant's path on the tenant's own domain. */
13
+ export declare const SSO_TICKET_PATH = "u2/self-service";
14
+ /**
15
+ * The request path with an SSO ticket id replaced, for logs: a log reader
16
+ * must never get a usable ticket (a failed revoke leaves it valid).
17
+ */
18
+ export declare function redactSsoTicketPath(path: string): string;
@@ -1,7 +1,8 @@
1
- import { User, UserDataAdapter } from "@authhero/adapter-interfaces";
1
+ import { ConnectionSelfService, User, UserDataAdapter } from "@authhero/adapter-interfaces";
2
2
  import { EnrichedClient } from "./client";
3
3
  import { Context } from "hono";
4
4
  import { Bindings, Variables } from "../types";
5
+ import { DatabaseConnectionScope } from "./database-connection-scope";
5
6
  export declare function getUsersByEmail(userAdapter: UserDataAdapter, tenantId: string, email: string): Promise<User[]>;
6
7
  /**
7
8
  * Every user sharing `email`, across all pages.
@@ -20,8 +21,15 @@ interface GetUserByProviderParams {
20
21
  tenant_id: string;
21
22
  username: string;
22
23
  provider: string;
24
+ /**
25
+ * Limit the match to one database connection. Every database connection
26
+ * shares the `auth0` provider, so without a scope a lookup can return a
27
+ * user from another database connection. Build it with
28
+ * `resolveDatabaseConnectionScope`; `undefined` keeps the unscoped lookup.
29
+ */
30
+ connection?: DatabaseConnectionScope;
23
31
  }
24
- export declare function getUserByProvider({ userAdapter, tenant_id, username, provider, }: GetUserByProviderParams): Promise<User | null>;
32
+ export declare function getUserByProvider({ userAdapter, tenant_id, username, provider, connection, }: GetUserByProviderParams): Promise<User | null>;
25
33
  /**
26
34
  * Order users by age (oldest first). When account-linking has to choose
27
35
  * which of two matching users should remain primary, the older account
@@ -64,6 +72,14 @@ interface GetPrimaryUserByEmailParams {
64
72
  userAdapter: UserDataAdapter;
65
73
  tenant_id: string;
66
74
  email: string;
75
+ /**
76
+ * Account-linking paths pass this to drop users that must never be a link
77
+ * target (see `filterTrustedLinkTargets`). Applied to the primaries, or to
78
+ * the resolved root when every match is a secondary. When it drops them all,
79
+ * no user is returned. Read paths (login lookup, forgot password) leave it
80
+ * unset.
81
+ */
82
+ filterCandidates?: (users: User[]) => Promise<User[]>;
67
83
  /**
68
84
  * Log when more than one primary shares the email. Only meaningful on
69
85
  * account-linking paths, where duplicate primaries mean linking failed to
@@ -73,7 +89,7 @@ interface GetPrimaryUserByEmailParams {
73
89
  */
74
90
  warnOnMultiplePrimaries?: boolean;
75
91
  }
76
- export declare function getPrimaryUserByEmail({ userAdapter, tenant_id, email, warnOnMultiplePrimaries, }: GetPrimaryUserByEmailParams): Promise<User | undefined>;
92
+ export declare function getPrimaryUserByEmail({ userAdapter, tenant_id, email, warnOnMultiplePrimaries, filterCandidates, }: GetPrimaryUserByEmailParams): Promise<User | undefined>;
77
93
  interface GetLastUsedUserByEmailParams {
78
94
  userAdapter: UserDataAdapter;
79
95
  tenant_id: string;
@@ -260,13 +276,22 @@ interface GetPrimaryUserByProviderParams {
260
276
  tenant_id: string;
261
277
  username: string;
262
278
  provider: string;
279
+ /** See {@link GetUserByProviderParams.connection}. */
280
+ connection?: DatabaseConnectionScope;
263
281
  }
264
- export declare function getPrimaryUserByProvider({ userAdapter, tenant_id, username, provider, }: GetPrimaryUserByProviderParams): Promise<User | null>;
282
+ export declare function getPrimaryUserByProvider({ userAdapter, tenant_id, username, provider, connection, }: GetPrimaryUserByProviderParams): Promise<User | null>;
265
283
  interface GetOrCreateUserByProviderParams {
266
284
  client: EnrichedClient;
267
285
  username: string;
268
286
  provider: string;
269
287
  connection: string;
288
+ /**
289
+ * The connection's Self-Service SSO state (#1763). When set, an email is
290
+ * only trusted inside the domains verified for the connection: elsewhere
291
+ * `email_verified` is stored as `false`, whatever the identity provider
292
+ * asserted, so email-based linking never acts on it.
293
+ */
294
+ selfService?: ConnectionSelfService | null;
270
295
  userId?: string;
271
296
  profileData?: Record<string, unknown>;
272
297
  ip?: string;