authhero 9.39.0 → 9.40.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 (77) 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-603aa8fa.entry.js +1 -0
  4. package/dist/assets/u/widget/p-d0eb5acc.entry.js +1 -0
  5. package/dist/authhero.cjs +172 -167
  6. package/dist/authhero.d.ts +533 -441
  7. package/dist/authhero.mjs +13325 -12051
  8. package/dist/{mfa-Dh6nNiRX.js → mfa-BlaRHQgI.js} +2 -2
  9. package/dist/{mfa-DMThiuUR.mjs → mfa-Ddp9JT1l.mjs} +38 -38
  10. package/dist/{mfa-attempts-O0x4jJzl.mjs → mfa-attempts-YsmteBp0.mjs} +6705 -6193
  11. package/dist/mfa-attempts-bPJnyu2c.js +385 -0
  12. package/dist/{passkey-enrollment-CSeOQWv1.js → passkey-enrollment-CLg7RteL.js} +1 -1
  13. package/dist/tsconfig.types.tsbuildinfo +1 -1
  14. package/dist/types/authentication-flows/common.d.ts +4 -1
  15. package/dist/types/generated/locale-types.d.ts +39 -0
  16. package/dist/types/helpers/client.d.ts +1 -0
  17. package/dist/types/helpers/code-recipient.d.ts +37 -0
  18. package/dist/types/helpers/reserved-claims.d.ts +2 -2
  19. package/dist/types/hooks/helpers/action-users.d.ts +56 -0
  20. package/dist/types/hooks/helpers/post-login-account-linking.d.ts +18 -4
  21. package/dist/types/hooks/lifecycle-codehooks.d.ts +2 -2
  22. package/dist/types/hooks/pre-screen.d.ts +114 -0
  23. package/dist/types/index.d.ts +461 -415
  24. package/dist/types/routes/auth-api/device.d.ts +8 -8
  25. package/dist/types/routes/auth-api/index.d.ts +12 -12
  26. package/dist/types/routes/auth-api/passwordless.d.ts +6 -6
  27. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  28. package/dist/types/routes/management-api/action-executions.d.ts +1 -1
  29. package/dist/types/routes/management-api/action-triggers.d.ts +2 -2
  30. package/dist/types/routes/management-api/actions.d.ts +13 -13
  31. package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
  32. package/dist/types/routes/management-api/branding-uploads.d.ts +4 -4
  33. package/dist/types/routes/management-api/branding.d.ts +21 -21
  34. package/dist/types/routes/management-api/clients.d.ts +12 -10
  35. package/dist/types/routes/management-api/connections.d.ts +14 -8
  36. package/dist/types/routes/management-api/emails.d.ts +6 -6
  37. package/dist/types/routes/management-api/forms.d.ts +24 -0
  38. package/dist/types/routes/management-api/guardian.d.ts +1 -1
  39. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  40. package/dist/types/routes/management-api/hooks.d.ts +42 -42
  41. package/dist/types/routes/management-api/index.d.ts +430 -398
  42. package/dist/types/routes/management-api/jobs.d.ts +2 -2
  43. package/dist/types/routes/management-api/keys.d.ts +12 -12
  44. package/dist/types/routes/management-api/log-streams.d.ts +12 -12
  45. package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
  46. package/dist/types/routes/management-api/organizations.d.ts +6 -6
  47. package/dist/types/routes/management-api/prompts.d.ts +8 -8
  48. package/dist/types/routes/management-api/resource-servers.d.ts +8 -8
  49. package/dist/types/routes/management-api/rollouts.d.ts +6 -6
  50. package/dist/types/routes/management-api/self-service-profiles.d.ts +9 -9
  51. package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
  52. package/dist/types/routes/management-api/tenant-members.d.ts +8 -8
  53. package/dist/types/routes/management-api/tenant-operations.d.ts +4 -4
  54. package/dist/types/routes/management-api/tenants.d.ts +10 -10
  55. package/dist/types/routes/management-api/themes.d.ts +9 -9
  56. package/dist/types/routes/management-api/users.d.ts +21 -21
  57. package/dist/types/routes/universal-login/common.d.ts +10 -10
  58. package/dist/types/routes/universal-login/pre-screen-gates.d.ts +31 -0
  59. package/dist/types/routes/universal-login/screens/account-change-email.d.ts +52 -0
  60. package/dist/types/routes/universal-login/screens/account-helpers.d.ts +19 -24
  61. package/dist/types/routes/universal-login/screens/account.d.ts +6 -0
  62. package/dist/types/routes/universal-login/screens/index.d.ts +4 -2
  63. package/dist/types/routes/universal-login/screens/invalid-session.d.ts +10 -0
  64. package/dist/types/routes/universal-login/screens/login-otp.d.ts +2 -2
  65. package/dist/types/routes/universal-login/screens/signup.d.ts +0 -3
  66. package/dist/types/routes/universal-login/screens/social-connections.d.ts +31 -0
  67. package/dist/types/routes/universal-login/screens/types.d.ts +3 -0
  68. package/dist/types/routes/universal-login/u2-index.d.ts +19 -5
  69. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  70. package/dist/types/routes/universal-login/u2-widget-page.d.ts +1 -4
  71. package/dist/types/state-machines/login-session.d.ts +13 -1
  72. package/dist/types/types/Hooks.d.ts +62 -17
  73. package/dist/types/utils/embedded-browser.d.ts +4 -0
  74. package/package.json +6 -6
  75. package/dist/assets/u/widget/p-32247347.entry.js +0 -1
  76. package/dist/assets/u/widget/p-3f908508.entry.js +0 -1
  77. package/dist/mfa-attempts-BaKbuGvZ.js +0 -321
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Shared helpers for account management screens
3
3
  */
4
- import type { User, Session } from "@authhero/adapter-interfaces";
5
- import type { ScreenContext, ScreenFactory, ScreenHandler } from "./types";
6
- import type { AccountActionOperation } from "../../../types/Hooks";
4
+ import type { LoginSession, User, Session } from "@authhero/adapter-interfaces";
5
+ import type { ScreenContext } from "./types";
7
6
  /**
8
7
  * Resolve the authenticated user from the session cookie.
9
8
  * Used by all account screens that need the current user.
@@ -13,27 +12,23 @@ export declare function resolveAccountUser(context: ScreenContext): Promise<{
13
12
  session: Session;
14
13
  }>;
15
14
  /**
16
- * Run the `pre-account-action` trigger for an operation the user is starting.
17
- * Returns the URL to send the user to when an Action redirects, `undefined`
18
- * to continue, and throws `AccountActionDeniedError` when an Action denies.
15
+ * Resolve the account user either mid-login or from a session cookie.
16
+ *
17
+ * When a form hook redirects to an account page mid-login, the login session
18
+ * is AWAITING_CONTINUATION with a scope naming that page (`account`,
19
+ * `change-email`). That scope authorizes the page and names the user, so no
20
+ * session cookie is needed. The first of `scopes` the login session carries is
21
+ * returned as `continuationScope`; without one, a signed-in session cookie is
22
+ * required as on every other account page.
19
23
  */
20
- export declare function gateAccountOperation(context: ScreenContext, operation: AccountActionOperation, options?: {
21
- user?: User | (() => Promise<User | undefined>);
22
- details?: Record<string, string>;
23
- }): Promise<string | undefined>;
24
- /**
25
- * Wrap a screen's GET factory so the trigger fires when the user opens the
26
- * screen. POST handlers that re-render the screen call the unwrapped factory.
27
- */
28
- export declare function gatedScreen(operation: AccountActionOperation, factory: ScreenFactory, options?: {
29
- details?: Record<string, string>;
30
- user?: (context: ScreenContext) => Promise<User | undefined>;
31
- }): ScreenFactory;
24
+ export declare function resolveAccountUserOrContinuation(context: ScreenContext, scopes: readonly string[]): Promise<{
25
+ user: User;
26
+ session: Session | null;
27
+ loginSession: LoginSession;
28
+ continuationScope?: string;
29
+ }>;
32
30
  /**
33
- * Wrap a screen's POST handler so the trigger also runs where the change
34
- * happens. Gating only the GET would let a direct POST skip a denial.
31
+ * Where "continue" sends a user who reached an account page mid-login: the
32
+ * return URL stored when the continuation started (`/u2/continue?state=…`).
35
33
  */
36
- export declare function gatedPost(operation: AccountActionOperation, post: NonNullable<ScreenHandler["post"]>, options?: {
37
- details?: Record<string, string>;
38
- user?: (context: ScreenContext, data: Record<string, unknown>) => Promise<User | undefined>;
39
- }): NonNullable<ScreenHandler["post"]>;
34
+ export declare function getContinuationReturnUrl(loginSession: LoginSession): string | undefined;
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Account screen - main hub for account management
3
3
  *
4
+ * Signed in (session cookie) it links to every account sub-screen. Mid-login,
5
+ * when a form hook redirects here, the login session carries the `account`
6
+ * continuation scope instead: the hub then shows the user, a change-email
7
+ * entry (the only sub-screen that accepts that scope) and a button that
8
+ * continues the login, matching what /u/account offered mid-login.
9
+ *
4
10
  * Corresponds to: /u2/account
5
11
  */
6
12
  import type { ScreenContext, ScreenResult, ScreenDefinition } from "./types";
@@ -13,8 +13,10 @@
13
13
  * - forgot-password: /u/forgot-password
14
14
  * - reset-password: /u/reset-password
15
15
  * - impersonate: /u/impersonate
16
- * - pre-signup: /u/pre-signup
17
- * - pre-signup-sent: /u/pre-signup-sent
16
+ *
17
+ * /u/pre-signup and /u/pre-signup-sent have no u2 screen: u2 signup creates
18
+ * the account directly and verifies the address afterwards, and redeems the
19
+ * `code` of pre-signup emails sent from /u (see screens/signup.ts).
18
20
  */
19
21
  export { identifierScreen } from "./identifier";
20
22
  export { emailOtpChallengeScreen } from "./email-otp-challenge";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Invalid session screen - a passwordless link was opened somewhere it can't
3
+ * complete (another browser or IP than the login started in, or the code had
4
+ * already been used or expired).
5
+ *
6
+ * Corresponds to: /u2/invalid-session (u2 equivalent of /u/invalid-session)
7
+ */
8
+ import type { ScreenContext, ScreenResult, ScreenDefinition } from "./types";
9
+ export declare function invalidSessionScreen(context: ScreenContext): Promise<ScreenResult>;
10
+ export declare const invalidSessionScreenDefinition: ScreenDefinition;
@@ -3,8 +3,8 @@ import type { LoginSession } from "@authhero/adapter-interfaces";
3
3
  import type { EnrichedClient } from "../../../helpers/client";
4
4
  import type { Bindings, Variables } from "../../../types";
5
5
  /**
6
- * Create a one-time code bound to the login session and deliver it to the
7
- * user, either as a code or (for magic-link email connections) as a link.
6
+ * Create a one-time code bound to the login session and to `to`, and deliver
7
+ * it to the user, either as a code or (for magic-link email connections) as a link.
8
8
  */
9
9
  export declare function sendLoginOtp(ctx: Context<{
10
10
  Bindings: Bindings;
@@ -56,8 +56,5 @@ export declare function localizePasswordPolicyError(error: unknown, locale: stri
56
56
  * Create the signup screen
57
57
  */
58
58
  export declare function signupScreen(context: ScreenContext): Promise<ScreenResult>;
59
- /**
60
- * Screen definition for the signup screen
61
- */
62
59
  export declare const signupScreenDefinition: ScreenDefinition;
63
60
  export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Which of a client's connections the u2 login screens show as social /
3
+ * enterprise buttons. Same rules as the legacy /u identifier page:
4
+ *
5
+ * - Email, SMS and database connections are form inputs, not buttons.
6
+ * - `show_as_button: false` always hides a connection.
7
+ * - Connections with `domain_aliases` are reached by home realm discovery
8
+ * (email-domain routing) and hidden unless `show_as_button: true`, on
9
+ * screens that do that routing (the identifier screen).
10
+ * - Strategies that refuse embedded browsers (Google) are hidden in in-app
11
+ * browsers, where the provider would reject the sign-in.
12
+ *
13
+ * Unlike /u, strategies without a built-in handler (custom OAuth2/OIDC set up
14
+ * through the `STRATEGIES` env) are kept: they fall back to their name and a
15
+ * generic icon.
16
+ */
17
+ import type { Connection } from "@authhero/adapter-interfaces";
18
+ export declare function isFormConnection(connection: Connection): boolean;
19
+ export declare function isShownAsButton(connection: Connection, options: {
20
+ embeddedBrowser: boolean;
21
+ hideHrdConnections?: boolean;
22
+ }): boolean;
23
+ /** The connections to render as social / enterprise buttons, in client order. */
24
+ export declare function getButtonConnections(connections: Connection[], userAgent: string | undefined, options?: {
25
+ /**
26
+ * Hide HRD connections (default). Only screens whose submit routes the
27
+ * identifier by email domain may hide them; elsewhere the button is the
28
+ * connection's only way in.
29
+ */
30
+ hideHrdConnections?: boolean;
31
+ }): Connection[];
@@ -160,6 +160,9 @@ export interface ScreenDefinition {
160
160
  /** The screen handler */
161
161
  handler: ScreenHandler;
162
162
  }
163
+ export declare function screenUsesUrlCode(screenId: string): boolean;
164
+ /** `&code=…` for the form action of a screen that carries a URL code. */
165
+ export declare function urlCodeSuffix(screenId: string, code: string | undefined): string;
163
166
  /**
164
167
  * Get the correct login path based on the tenant's identifier_first setting.
165
168
  * Returns "/u2/login" for password-first or "/u2/login/identifier" for identifier-first.
@@ -195,7 +195,7 @@ export default function createU2App(config: AuthHeroConfig): OpenAPIHono<{
195
195
  $get: {
196
196
  input: {
197
197
  param: {
198
- screen: "impersonate" | "signup" | "reset-password" | "account" | "consent" | "login" | "enter-password" | "try-connection-result" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
198
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "account" | "enter-password" | "invalid-session" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "try-connection-result" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
199
199
  };
200
200
  } & {
201
201
  query: {
@@ -211,7 +211,7 @@ export default function createU2App(config: AuthHeroConfig): OpenAPIHono<{
211
211
  } | {
212
212
  input: {
213
213
  param: {
214
- screen: "impersonate" | "signup" | "reset-password" | "account" | "consent" | "login" | "enter-password" | "try-connection-result" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
214
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "account" | "enter-password" | "invalid-session" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "try-connection-result" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
215
215
  };
216
216
  } & {
217
217
  query: {
@@ -227,7 +227,7 @@ export default function createU2App(config: AuthHeroConfig): OpenAPIHono<{
227
227
  } | {
228
228
  input: {
229
229
  param: {
230
- screen: "impersonate" | "signup" | "reset-password" | "account" | "consent" | "login" | "enter-password" | "try-connection-result" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
230
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "account" | "enter-password" | "invalid-session" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "try-connection-result" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
231
231
  };
232
232
  } & {
233
233
  query: {
@@ -247,7 +247,7 @@ export default function createU2App(config: AuthHeroConfig): OpenAPIHono<{
247
247
  $post: {
248
248
  input: {
249
249
  param: {
250
- screen: "impersonate" | "signup" | "reset-password" | "consent" | "login" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
250
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
251
251
  };
252
252
  } & {
253
253
  query: {
@@ -265,7 +265,7 @@ export default function createU2App(config: AuthHeroConfig): OpenAPIHono<{
265
265
  } | {
266
266
  input: {
267
267
  param: {
268
- screen: "impersonate" | "signup" | "reset-password" | "consent" | "login" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
268
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
269
269
  };
270
270
  } & {
271
271
  query: {
@@ -283,6 +283,20 @@ export default function createU2App(config: AuthHeroConfig): OpenAPIHono<{
283
283
  };
284
284
  };
285
285
  }, "/"> & import("hono/types").MergeSchemaPath<{
286
+ "/": {
287
+ $get: {
288
+ input: {
289
+ query: {
290
+ error?: string | undefined;
291
+ error_description?: string | undefined;
292
+ };
293
+ };
294
+ output: {};
295
+ outputFormat: string;
296
+ status: 200;
297
+ };
298
+ };
299
+ }, "/error"> & import("hono/types").MergeSchemaPath<{
286
300
  "/": {
287
301
  $get: {
288
302
  input: {
@@ -200,7 +200,7 @@ export declare const u2Routes: OpenAPIHono<{
200
200
  $get: {
201
201
  input: {
202
202
  param: {
203
- screen: "impersonate" | "signup" | "reset-password" | "account" | "consent" | "login" | "enter-password" | "try-connection-result" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
203
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "account" | "enter-password" | "invalid-session" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "try-connection-result" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
204
204
  };
205
205
  } & {
206
206
  query: {
@@ -216,7 +216,7 @@ export declare const u2Routes: OpenAPIHono<{
216
216
  } | {
217
217
  input: {
218
218
  param: {
219
- screen: "impersonate" | "signup" | "reset-password" | "account" | "consent" | "login" | "enter-password" | "try-connection-result" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
219
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "account" | "enter-password" | "invalid-session" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "try-connection-result" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
220
220
  };
221
221
  } & {
222
222
  query: {
@@ -232,7 +232,7 @@ export declare const u2Routes: OpenAPIHono<{
232
232
  } | {
233
233
  input: {
234
234
  param: {
235
- screen: "impersonate" | "signup" | "reset-password" | "account" | "consent" | "login" | "enter-password" | "try-connection-result" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
235
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "account" | "enter-password" | "invalid-session" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "try-connection-result" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation" | "device/complete";
236
236
  };
237
237
  } & {
238
238
  query: {
@@ -252,7 +252,7 @@ export declare const u2Routes: OpenAPIHono<{
252
252
  $post: {
253
253
  input: {
254
254
  param: {
255
- screen: "impersonate" | "signup" | "reset-password" | "consent" | "login" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
255
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
256
256
  };
257
257
  } & {
258
258
  query: {
@@ -270,7 +270,7 @@ export declare const u2Routes: OpenAPIHono<{
270
270
  } | {
271
271
  input: {
272
272
  param: {
273
- screen: "impersonate" | "signup" | "reset-password" | "consent" | "login" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
273
+ screen: "login" | "signup" | "consent" | "impersonate" | "reset-password" | "enter-password" | "reset-password/request" | "reset-password/code" | "login/email-verification" | "login/email-verification-sent" | "account/change-email" | "account/change-email/verify" | "login/identifier" | "login/email-otp-challenge" | "login/sms-otp-challenge" | "login/login-passwordless-identifier" | "mfa/login-options" | "mfa/totp-challenge" | "mfa/totp-enrollment" | "mfa/phone-challenge" | "mfa/phone-enrollment" | "passkey/challenge" | "passkey/enrollment" | "passkey/enrollment-nudge" | "account/profile" | "account/security" | "account/security/totp-enrollment" | "account/security/phone-enrollment" | "account/linked" | "account/delete" | "account/passkeys" | "connect/start" | "connect/select-tenant" | "self-service/app" | "device/code" | "device/confirmation";
274
274
  };
275
275
  } & {
276
276
  query: {
@@ -121,10 +121,7 @@ export type WidgetPageProps = {
121
121
  name?: string;
122
122
  };
123
123
  };
124
- /** Detects in-app browsers from the request's User-Agent. */
125
- export declare function detectEmbeddedBrowser(userAgent: string | undefined): {
126
- name?: string;
127
- } | undefined;
124
+ export { detectEmbeddedBrowser } from "../../utils/embedded-browser";
128
125
  /** Localized display names for the language picker, in the given order. */
129
126
  export declare function buildLanguageOptions(availableLanguages?: string[]): LanguageOption[] | undefined;
130
127
  /** The short "Terms & Privacy" label, in the page's language. */
@@ -32,6 +32,18 @@ export interface LoginSessionData {
32
32
  mfa_failed_attempts?: number;
33
33
  mfa_sms_sent?: number;
34
34
  pending_email_verification?: unknown;
35
+ /** u2 change-email: the address a code was sent to, shown on the verify step */
36
+ pending_email_change?: {
37
+ email: string;
38
+ };
39
+ /**
40
+ * u2 change-email: the address the last change set. The verify step shows
41
+ * the confirmation from it on GET, so it survives a no-JS form post, which
42
+ * redirects instead of rendering the POST result.
43
+ */
44
+ email_change_done?: {
45
+ email: string;
46
+ };
35
47
  hookId?: string;
36
48
  form_values?: Record<string, unknown>;
37
49
  continuationScope?: string[];
@@ -252,7 +264,7 @@ export declare const loginSessionMachine: import("xstate").StateMachine<LoginSes
252
264
  }, {
253
265
  type: "passwordResetRequested";
254
266
  params: unknown;
255
- }, never, "failed" | "pending" | "expired" | "authenticated" | "awaiting_email_verification" | "awaiting_mfa" | "awaiting_consent" | "awaiting_hook" | "awaiting_continuation" | "completed", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, {
267
+ }, never, "pending" | "failed" | "expired" | "authenticated" | "awaiting_email_verification" | "awaiting_mfa" | "awaiting_consent" | "awaiting_hook" | "awaiting_continuation" | "completed", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, {
256
268
  id: "loginSession";
257
269
  states: {
258
270
  readonly pending: {};
@@ -1,4 +1,4 @@
1
- import { AuthorizationResponseMode, AuthorizationResponseType, DataAdapters, LinkCandidate, RolePermissionInsert, User } from "@authhero/adapter-interfaces";
1
+ import { AuthorizationResponseMode, AuthorizationResponseType, DataAdapters, LinkCandidate, PreScreenOperation, PreScreenPhase, RolePermissionInsert, User } from "@authhero/adapter-interfaces";
2
2
  import { EnrichedClient } from "../helpers/client";
3
3
  import { Context } from "hono";
4
4
  import { Bindings } from "./Bindings";
@@ -251,20 +251,58 @@ export type OnExecutePostUserDeletion = (event: HookEvent & {
251
251
  user_id: string;
252
252
  }, api: OnExecutePostUserDeletionAPI) => Promise<void>;
253
253
  /**
254
- * Self-service account operations that fire the `pre-account-action` trigger
255
- * (an AuthHero extension; Auth0 has no equivalent). The trigger runs once when
256
- * the user starts the operation, before any form, code or write.
254
+ * The authorization request a universal-login screen belongs to, plus the
255
+ * phase the `pre-screen` trigger runs in. The login session id is not
256
+ * included: it is the key to the transaction, not a request parameter.
257
257
  */
258
- export type AccountActionOperation = "change-email" | "update-profile" | "reset-password" | "enroll-mfa" | "remove-mfa" | "enroll-passkey" | "remove-passkey" | "unlink-identity" | "delete-account";
259
- export type PreAccountActionEvent = {
258
+ export type PreScreenTransaction = {
259
+ /** `render` before the screen is shown, `submit` when it is submitted. */
260
+ phase: PreScreenPhase;
261
+ locale: string;
262
+ client_id?: string;
263
+ redirect_uri?: string;
264
+ requested_scopes: string[];
265
+ response_type?: AuthorizationResponseType;
266
+ response_mode?: AuthorizationResponseMode;
267
+ /** The application's `state` parameter. */
268
+ state?: string;
269
+ audience?: string;
270
+ prompt?: string;
271
+ ui_locales?: string;
272
+ acr_values?: string;
273
+ /** The identifier entered or passed as `login_hint` so far. */
274
+ login_hint?: string;
275
+ /** `screen_hint` from the authorization request. */
276
+ screen_hint?: string;
277
+ };
278
+ /**
279
+ * Event of the `pre-screen` trigger (an AuthHero extension; Auth0 has no
280
+ * pre-login trigger). Fires before a universal-login screen is shown and when
281
+ * it is submitted.
282
+ */
283
+ export type PreScreenEvent = {
260
284
  ctx: Context<{
261
285
  Bindings: Bindings;
262
286
  Variables: Variables;
263
287
  }>;
264
- operation: AccountActionOperation;
288
+ screen: {
289
+ name: string;
290
+ };
291
+ prompt: {
292
+ name: string;
293
+ };
294
+ transaction: PreScreenTransaction;
295
+ /**
296
+ * Submit phase only: the operation the submission performs, e.g.
297
+ * `remove-mfa` for the remove button on `account-security`.
298
+ */
299
+ operation?: PreScreenOperation;
300
+ /** Operation-specific detail, e.g. `{ factor: "totp" }` for `enroll-mfa`. */
301
+ details?: Record<string, string>;
265
302
  /**
266
- * The signed-in user. Undefined only for `reset-password` when the
267
- * identifier entered so far doesn't match a user (or none was entered).
303
+ * The user when known: the signed-in user on account screens, the user the
304
+ * identifier entered so far matches on login and password-reset screens,
305
+ * the authenticated user on MFA and consent screens.
268
306
  */
269
307
  user?: User;
270
308
  /** Connection of the user's primary identity. */
@@ -274,27 +312,31 @@ export type PreAccountActionEvent = {
274
312
  strategy?: string;
275
313
  };
276
314
  client?: EnrichedClient;
315
+ organization?: {
316
+ id: string;
317
+ name: string;
318
+ display_name?: string;
319
+ metadata?: Record<string, unknown>;
320
+ };
277
321
  tenant: {
278
322
  id: string;
279
323
  };
280
324
  request: HookRequest;
281
- /** Operation-specific detail, e.g. `{ factor: "totp" }` for `enroll-mfa`. */
282
- details?: Record<string, string>;
283
325
  };
284
- export type OnExecutePreAccountActionAPI = {
326
+ export type OnExecutePreScreenAPI = {
285
327
  redirect: {
286
- /** Send the user to `url` instead of running the operation here. */
328
+ /** Send the user to `url` instead of showing or submitting the screen. */
287
329
  sendUserTo: (url: string, options?: {
288
330
  query?: Record<string, string>;
289
331
  }) => void;
290
332
  };
291
333
  access: {
292
- /** Stop the operation and show `reason` to the user. */
334
+ /** Stop the screen and show `reason` to the user. */
293
335
  deny: (reason?: string) => void;
294
336
  };
295
337
  token: TokenAPI;
296
338
  };
297
- export type OnExecutePreAccountAction = (event: PreAccountActionEvent, api: OnExecutePreAccountActionAPI) => Promise<void>;
339
+ export type OnExecutePreScreen = (event: PreScreenEvent, api: OnExecutePreScreenAPI) => Promise<void>;
298
340
  export type OnExecuteValidateRegistrationUsernameAPI = {
299
341
  deny: (reason?: string) => void;
300
342
  token: TokenAPI;
@@ -333,8 +375,11 @@ export type Hooks = {
333
375
  onExecutePreUserDeletion?: OnExecutePreUserDeletion;
334
376
  onExecutePostUserDeletion?: OnExecutePostUserDeletion;
335
377
  onExecuteValidateRegistrationUsername?: OnExecuteValidateRegistrationUsername;
336
- /** Called when a user starts a self-service account operation (AuthHero extension) */
337
- onExecutePreAccountAction?: OnExecutePreAccountAction;
378
+ /**
379
+ * Called before a universal-login screen is shown and when it is submitted
380
+ * (AuthHero extension, the `pre-screen` trigger)
381
+ */
382
+ onExecutePreScreen?: OnExecutePreScreen;
338
383
  /** Called when /userinfo endpoint is accessed to add custom claims */
339
384
  onFetchUserInfo?: OnFetchUserInfo;
340
385
  };
@@ -0,0 +1,4 @@
1
+ /** Detects in-app browsers from the request's User-Agent. */
2
+ export declare function detectEmbeddedBrowser(userAgent: string | undefined): {
3
+ name?: string;
4
+ } | undefined;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/sesamyab/authhero"
13
13
  },
14
- "version": "9.39.0",
14
+ "version": "9.40.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -63,8 +63,8 @@
63
63
  "vite": "^8.0.14",
64
64
  "vite-plugin-dts": "^4.5.4",
65
65
  "vitest": "^4.1.7",
66
- "@authhero/kysely-adapter": "12.24.1",
67
- "@authhero/widget": "0.42.1"
66
+ "@authhero/kysely-adapter": "12.24.2",
67
+ "@authhero/widget": "0.43.0"
68
68
  },
69
69
  "dependencies": {
70
70
  "@peculiar/x509": "^1.14.3",
@@ -82,9 +82,9 @@
82
82
  "qrcode": "^1.5.4",
83
83
  "sanitize-html": "^2.17.4",
84
84
  "xstate": "^5.31.1",
85
- "@authhero/adapter-interfaces": "4.34.0",
86
- "@authhero/proxy": "0.11.21",
87
- "@authhero/saml": "0.6.14"
85
+ "@authhero/adapter-interfaces": "4.35.0",
86
+ "@authhero/proxy": "0.11.22",
87
+ "@authhero/saml": "0.6.15"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@authhero/widget": ">=0.38.9",