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.
- package/dist/assets/u/widget/authhero-widget.esm.js +1 -1
- package/dist/assets/u/widget/index.esm.js +1 -1
- package/dist/assets/u/widget/p-603aa8fa.entry.js +1 -0
- package/dist/assets/u/widget/p-d0eb5acc.entry.js +1 -0
- package/dist/authhero.cjs +172 -167
- package/dist/authhero.d.ts +533 -441
- package/dist/authhero.mjs +13325 -12051
- package/dist/{mfa-Dh6nNiRX.js → mfa-BlaRHQgI.js} +2 -2
- package/dist/{mfa-DMThiuUR.mjs → mfa-Ddp9JT1l.mjs} +38 -38
- package/dist/{mfa-attempts-O0x4jJzl.mjs → mfa-attempts-YsmteBp0.mjs} +6705 -6193
- package/dist/mfa-attempts-bPJnyu2c.js +385 -0
- package/dist/{passkey-enrollment-CSeOQWv1.js → passkey-enrollment-CLg7RteL.js} +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/authentication-flows/common.d.ts +4 -1
- package/dist/types/generated/locale-types.d.ts +39 -0
- package/dist/types/helpers/client.d.ts +1 -0
- package/dist/types/helpers/code-recipient.d.ts +37 -0
- package/dist/types/helpers/reserved-claims.d.ts +2 -2
- package/dist/types/hooks/helpers/action-users.d.ts +56 -0
- package/dist/types/hooks/helpers/post-login-account-linking.d.ts +18 -4
- package/dist/types/hooks/lifecycle-codehooks.d.ts +2 -2
- package/dist/types/hooks/pre-screen.d.ts +114 -0
- package/dist/types/index.d.ts +461 -415
- package/dist/types/routes/auth-api/device.d.ts +8 -8
- package/dist/types/routes/auth-api/index.d.ts +12 -12
- package/dist/types/routes/auth-api/passwordless.d.ts +6 -6
- package/dist/types/routes/auth-api/revoke.d.ts +6 -6
- package/dist/types/routes/management-api/action-executions.d.ts +1 -1
- package/dist/types/routes/management-api/action-triggers.d.ts +2 -2
- package/dist/types/routes/management-api/actions.d.ts +13 -13
- package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
- package/dist/types/routes/management-api/branding-uploads.d.ts +4 -4
- package/dist/types/routes/management-api/branding.d.ts +21 -21
- package/dist/types/routes/management-api/clients.d.ts +12 -10
- package/dist/types/routes/management-api/connections.d.ts +14 -8
- package/dist/types/routes/management-api/emails.d.ts +6 -6
- package/dist/types/routes/management-api/forms.d.ts +24 -0
- package/dist/types/routes/management-api/guardian.d.ts +1 -1
- package/dist/types/routes/management-api/helpers.d.ts +1 -1
- package/dist/types/routes/management-api/hooks.d.ts +42 -42
- package/dist/types/routes/management-api/index.d.ts +430 -398
- package/dist/types/routes/management-api/jobs.d.ts +2 -2
- package/dist/types/routes/management-api/keys.d.ts +12 -12
- package/dist/types/routes/management-api/log-streams.d.ts +12 -12
- package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
- package/dist/types/routes/management-api/organizations.d.ts +6 -6
- package/dist/types/routes/management-api/prompts.d.ts +8 -8
- package/dist/types/routes/management-api/resource-servers.d.ts +8 -8
- package/dist/types/routes/management-api/rollouts.d.ts +6 -6
- package/dist/types/routes/management-api/self-service-profiles.d.ts +9 -9
- package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
- package/dist/types/routes/management-api/tenant-members.d.ts +8 -8
- package/dist/types/routes/management-api/tenant-operations.d.ts +4 -4
- package/dist/types/routes/management-api/tenants.d.ts +10 -10
- package/dist/types/routes/management-api/themes.d.ts +9 -9
- package/dist/types/routes/management-api/users.d.ts +21 -21
- package/dist/types/routes/universal-login/common.d.ts +10 -10
- package/dist/types/routes/universal-login/pre-screen-gates.d.ts +31 -0
- package/dist/types/routes/universal-login/screens/account-change-email.d.ts +52 -0
- package/dist/types/routes/universal-login/screens/account-helpers.d.ts +19 -24
- package/dist/types/routes/universal-login/screens/account.d.ts +6 -0
- package/dist/types/routes/universal-login/screens/index.d.ts +4 -2
- package/dist/types/routes/universal-login/screens/invalid-session.d.ts +10 -0
- package/dist/types/routes/universal-login/screens/login-otp.d.ts +2 -2
- package/dist/types/routes/universal-login/screens/signup.d.ts +0 -3
- package/dist/types/routes/universal-login/screens/social-connections.d.ts +31 -0
- package/dist/types/routes/universal-login/screens/types.d.ts +3 -0
- package/dist/types/routes/universal-login/u2-index.d.ts +19 -5
- package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
- package/dist/types/routes/universal-login/u2-widget-page.d.ts +1 -4
- package/dist/types/state-machines/login-session.d.ts +13 -1
- package/dist/types/types/Hooks.d.ts +62 -17
- package/dist/types/utils/embedded-browser.d.ts +4 -0
- package/package.json +6 -6
- package/dist/assets/u/widget/p-32247347.entry.js +0 -1
- package/dist/assets/u/widget/p-3f908508.entry.js +0 -1
- package/dist/mfa-attempts-BaKbuGvZ.js +0 -321
|
@@ -246,7 +246,10 @@ export declare function completeLoginSessionContinuation(ctx: Context<{
|
|
|
246
246
|
Variables: Variables;
|
|
247
247
|
}>, tenantId: string, loginSession: LoginSession): Promise<string | undefined>;
|
|
248
248
|
/**
|
|
249
|
-
* Check if a login session allows access to a given scope during continuation
|
|
249
|
+
* Check if a login session allows access to a given scope during continuation.
|
|
250
|
+
* The scope stands in for a signed-in session, so it ends when the login
|
|
251
|
+
* session expires: adapters return expired rows and nothing else on the
|
|
252
|
+
* continuation paths checks `expires_at`.
|
|
250
253
|
*/
|
|
251
254
|
export declare function hasValidContinuationScope(loginSession: LoginSession, requiredScope: string): boolean;
|
|
252
255
|
export interface CreateAuthResponseParams {
|
|
@@ -59,6 +59,8 @@ export interface CommonAccountScreen {
|
|
|
59
59
|
deleteAccountLabel: () => string;
|
|
60
60
|
deleteAccountDetail: () => string;
|
|
61
61
|
logoutText: () => string;
|
|
62
|
+
changeEmailLabel: () => string;
|
|
63
|
+
continueText: () => string;
|
|
62
64
|
}
|
|
63
65
|
export interface CommonAccountProfileScreen {
|
|
64
66
|
title: () => string;
|
|
@@ -71,6 +73,7 @@ export interface CommonAccountProfileScreen {
|
|
|
71
73
|
buttonText: () => string;
|
|
72
74
|
backToAccountText: () => string;
|
|
73
75
|
updateFailed: () => string;
|
|
76
|
+
changeEmailText: () => string;
|
|
74
77
|
}
|
|
75
78
|
export interface CommonAccountDeleteScreen {
|
|
76
79
|
title: () => string;
|
|
@@ -186,6 +189,39 @@ export interface CommonAccountMfaTotpEnrollmentScreen {
|
|
|
186
189
|
verificationFailedText: () => string;
|
|
187
190
|
tooManyFailuresText: () => string;
|
|
188
191
|
}
|
|
192
|
+
export interface CommonInvalidSessionScreen {
|
|
193
|
+
title: () => string;
|
|
194
|
+
description: () => string;
|
|
195
|
+
backText: () => string;
|
|
196
|
+
}
|
|
197
|
+
export interface CommonAccountChangeEmailScreen {
|
|
198
|
+
title: () => string;
|
|
199
|
+
description: () => string;
|
|
200
|
+
currentEmailLabel: () => string;
|
|
201
|
+
emailLabel: () => string;
|
|
202
|
+
invalidEmail: () => string;
|
|
203
|
+
buttonText: () => string;
|
|
204
|
+
sendFailed: () => string;
|
|
205
|
+
backToAccountText: () => string;
|
|
206
|
+
}
|
|
207
|
+
export interface CommonAccountChangeEmailVerifyScreen {
|
|
208
|
+
title: () => string;
|
|
209
|
+
description: (vars: {
|
|
210
|
+
email: string;
|
|
211
|
+
}) => string;
|
|
212
|
+
codeLabel: () => string;
|
|
213
|
+
buttonText: () => string;
|
|
214
|
+
noCode: () => string;
|
|
215
|
+
invalidCode: () => string;
|
|
216
|
+
tooManyAttempts: () => string;
|
|
217
|
+
emailTaken: () => string;
|
|
218
|
+
successTitle: () => string;
|
|
219
|
+
successDescription: (vars: {
|
|
220
|
+
email: string;
|
|
221
|
+
}) => string;
|
|
222
|
+
continueText: () => string;
|
|
223
|
+
backText: () => string;
|
|
224
|
+
}
|
|
189
225
|
export interface ConsentScreen {
|
|
190
226
|
buttonText: () => string;
|
|
191
227
|
cancelButtonText: () => string;
|
|
@@ -1057,6 +1093,9 @@ export interface ScreenMap {
|
|
|
1057
1093
|
"common.account-passkeys": CommonAccountPasskeysScreen;
|
|
1058
1094
|
"common.account-mfa-phone-enrollment": CommonAccountMfaPhoneEnrollmentScreen;
|
|
1059
1095
|
"common.account-mfa-totp-enrollment": CommonAccountMfaTotpEnrollmentScreen;
|
|
1096
|
+
"common.invalid-session": CommonInvalidSessionScreen;
|
|
1097
|
+
"common.account-change-email": CommonAccountChangeEmailScreen;
|
|
1098
|
+
"common.account-change-email-verify": CommonAccountChangeEmailVerifyScreen;
|
|
1060
1099
|
"consent.consent": ConsentScreen;
|
|
1061
1100
|
"consent.connect-consent": ConsentConnectConsentScreen;
|
|
1062
1101
|
"consent.connect-tenant-select": ConsentConnectTenantSelectScreen;
|
|
@@ -541,6 +541,7 @@ export declare const enrichedClientSchema: z.ZodObject<{
|
|
|
541
541
|
max: z.ZodOptional<z.ZodNumber>;
|
|
542
542
|
}, z.core.$strip>>;
|
|
543
543
|
}, z.core.$strip>>;
|
|
544
|
+
allow_action_users: z.ZodOptional<z.ZodBoolean>;
|
|
544
545
|
set_user_root_attributes: z.ZodOptional<z.ZodEnum<{
|
|
545
546
|
on_each_login: "on_each_login";
|
|
546
547
|
on_first_login: "on_first_login";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import type { Code, CodesAdapter } from "@authhero/adapter-interfaces";
|
|
3
|
+
import type { CountryCode } from "libphonenumber-js";
|
|
4
|
+
/**
|
|
5
|
+
* Login and pre-signup codes are delivered to one address, and only that
|
|
6
|
+
* address may redeem them. The address is stored on the code when it is
|
|
7
|
+
* created (`state.recipient`), normalized like the identifier it is later
|
|
8
|
+
* compared with, because the login session's username can change after the
|
|
9
|
+
* code was sent.
|
|
10
|
+
*
|
|
11
|
+
* Codes without a stored recipient (minted before the recipient was stored)
|
|
12
|
+
* are not accepted: login codes expire within 30 minutes and are simply
|
|
13
|
+
* requested again, and a pre-signup code without one only means the signup
|
|
14
|
+
* continues unverified and a verification email is sent instead.
|
|
15
|
+
*/
|
|
16
|
+
/** `state.purpose` of a pre-signup `email_verification` code. */
|
|
17
|
+
export declare const PRE_SIGNUP_CODE_PURPOSE = "pre_signup";
|
|
18
|
+
export declare function normalizeCodeRecipient(identifier: string, countryCode?: CountryCode): string;
|
|
19
|
+
export declare function codeRecipientState(recipient: string, countryCode?: CountryCode, extra?: Record<string, unknown>): string;
|
|
20
|
+
export declare function parseCodeState(code: Pick<Code, "state">): Record<string, unknown>;
|
|
21
|
+
/** The address the code was sent to, if it was stored when it was created. */
|
|
22
|
+
export declare function getCodeRecipient(code: Pick<Code, "state">): string | undefined;
|
|
23
|
+
/** Whether `identifier` is the address the code was sent to. */
|
|
24
|
+
export declare function isCodeRecipient(code: Pick<Code, "state">, identifier: string | undefined, countryCode?: CountryCode): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Retire a login session's unused login codes that were sent to another
|
|
27
|
+
* address than `recipient`, for when the session's username changes. Best
|
|
28
|
+
* effort: redemption checks the recipient regardless, so a failure here is
|
|
29
|
+
* logged and ignored.
|
|
30
|
+
*/
|
|
31
|
+
export declare function invalidateOtherLoginCodes(ctx: Context<any>, codes: CodesAdapter, tenantId: string, loginId: string, recipient: string): Promise<void>;
|
|
32
|
+
export declare function preSignupCodeState(recipient: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Whether `stored` is an unexpired, unused pre-signup code minted for this
|
|
35
|
+
* login session and sent to `email`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isPreSignupCodeFor(stored: Code | null | undefined, loginId: string, email: string | undefined): stored is Code;
|
|
@@ -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: ("
|
|
17
|
+
export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("client_id" | "scope" | "sub" | "tenant_id" | "org_name" | "jti" | "sid" | "org_id" | "iss" | "exp" | "iat" | "aud" | "auth_time" | "acr" | "amr" | "gty" | "nbf" | "act" | "permissions" | "requested_userinfo_claims")[];
|
|
18
18
|
/** Client-bound mints: `azp` must stay the registered client id. */
|
|
19
|
-
export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("
|
|
19
|
+
export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("client_id" | "scope" | "sub" | "tenant_id" | "org_name" | "jti" | "sid" | "org_id" | "iss" | "exp" | "iat" | "aud" | "auth_time" | "acr" | "amr" | "azp" | "gty" | "nbf" | "act" | "permissions" | "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,56 @@
|
|
|
1
|
+
import { Context } from "hono";
|
|
2
|
+
import { Connection, DataAdapters, User } from "@authhero/adapter-interfaces";
|
|
3
|
+
import { Bindings, Variables } from "../../types";
|
|
4
|
+
/** Most `api.users.ensure` calls one action execution may make. */
|
|
5
|
+
export declare const MAX_ENSURED_USERS_PER_EXECUTION = 5;
|
|
6
|
+
/**
|
|
7
|
+
* Lazily loads the tenant's connections once per execution. Used to resolve
|
|
8
|
+
* the connection `ensure` writes to and to tell whether a user is an anchor
|
|
9
|
+
* (a primary whose connection is an external connection) without a lookup
|
|
10
|
+
* per call.
|
|
11
|
+
*
|
|
12
|
+
* `injectedStrategies` are the names of strategies supplied through
|
|
13
|
+
* `env.STRATEGIES`: a login connection using one stores its users under that
|
|
14
|
+
* name, so an external connection must not reuse it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createExternalConnectionLookup(data: DataAdapters, tenantId: string, injectedStrategies?: Iterable<string>): {
|
|
17
|
+
/**
|
|
18
|
+
* The external connection named `name` if actions may create users in it:
|
|
19
|
+
* opted in with `allow_action_users`, and not named like a prefix that
|
|
20
|
+
* login identities use.
|
|
21
|
+
*/
|
|
22
|
+
getActionUsersConnection: (name: string) => Promise<Connection | undefined>;
|
|
23
|
+
/** True when `user` lives in one of the tenant's external connections. */
|
|
24
|
+
isExternalUser: (user: Pick<User, "connection" | "provider">) => Promise<boolean>;
|
|
25
|
+
};
|
|
26
|
+
export type ExternalConnectionLookup = ReturnType<typeof createExternalConnectionLookup>;
|
|
27
|
+
/**
|
|
28
|
+
* Builds the host implementation of `api.users.ensure` (issue #1802).
|
|
29
|
+
*
|
|
30
|
+
* The isolate only records the call; this runs when it is replayed. It
|
|
31
|
+
* creates `<connection>|<id>` if missing, otherwise merges the profile and
|
|
32
|
+
* `app_metadata` into it. Every refusal logs `FAILED_HOOK` and writes nothing.
|
|
33
|
+
*
|
|
34
|
+
* Writes go through the transaction's adapters, which are undecorated: no
|
|
35
|
+
* registration or update hooks, no built-in email linking (which would demote
|
|
36
|
+
* a new anchor under an older same-email user), and no post-registration
|
|
37
|
+
* webhook or outbox event — the user is a record, not a signup.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createActionUsersApi(params: {
|
|
40
|
+
ctx: Context<{
|
|
41
|
+
Bindings: Bindings;
|
|
42
|
+
Variables: Variables;
|
|
43
|
+
}>;
|
|
44
|
+
data: DataAdapters;
|
|
45
|
+
tenantId: string;
|
|
46
|
+
triggerId: string;
|
|
47
|
+
externalConnections: ExternalConnectionLookup;
|
|
48
|
+
}): {
|
|
49
|
+
api: {
|
|
50
|
+
users: {
|
|
51
|
+
ensure: (raw: unknown) => Promise<void>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** user_ids that `ensure` created or updated during this execution. */
|
|
55
|
+
ensuredUserIds: Set<string>;
|
|
56
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Context } from "hono";
|
|
2
2
|
import { DataAdapters, User } from "@authhero/adapter-interfaces";
|
|
3
3
|
import { Bindings, Variables } from "../../types";
|
|
4
|
+
import { ExternalConnectionLookup } from "./action-users";
|
|
4
5
|
/**
|
|
5
6
|
* The `user` namespace exposed to `post-user-login` code hooks. `setLinkedTo`
|
|
6
7
|
* is the programmable account-linking verb (issue #1184): an action reads
|
|
@@ -28,10 +29,16 @@ export type PostLoginUserApi = {
|
|
|
28
29
|
* - **Verified-email gate.** When `requireVerifiedEmail` (the default), the
|
|
29
30
|
* logging-in user must have a verified email, regardless of what the action
|
|
30
31
|
* asserts.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* Users created by `api.users.ensure` in the same execution are also
|
|
33
|
+
* allowed (issue #1802); they skip the verified-email gate because the
|
|
34
|
+
* action resolved the person against its own system of record.
|
|
35
|
+
* - **Direction.** A primary in an `external` connection (an anchor) always
|
|
36
|
+
* stays primary. Otherwise the older account wins (`compareUsersByAge`):
|
|
37
|
+
* if the logging-in user pre-dates the target, the target is demoted
|
|
38
|
+
* instead. Either way the write goes through the update decorator's
|
|
39
|
+
* `linkUserTo` chokepoint, which keeps the cluster a single hop deep.
|
|
40
|
+
* - **No re-anchoring.** A user already under one anchor is never moved
|
|
41
|
+
* under a different one by a login; that is an admin operation.
|
|
35
42
|
* - **Idempotency.** A no-op when the user is already linked to the target.
|
|
36
43
|
*/
|
|
37
44
|
export declare function createPostLoginUserApi(params: {
|
|
@@ -46,6 +53,13 @@ export declare function createPostLoginUserApi(params: {
|
|
|
46
53
|
candidates: User[];
|
|
47
54
|
/** @default true */
|
|
48
55
|
requireVerifiedEmail?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* user_ids created or updated by `api.users.ensure` earlier in the same
|
|
58
|
+
* execution. Read at replay time, so it must be the live set.
|
|
59
|
+
*/
|
|
60
|
+
ensuredUserIds?: ReadonlySet<string>;
|
|
61
|
+
/** Tells anchors (users in an `external` connection) apart. */
|
|
62
|
+
externalConnections?: ExternalConnectionLookup;
|
|
49
63
|
}): {
|
|
50
64
|
api: PostLoginUserApi;
|
|
51
65
|
/** The user id of the primary after linking, or null if nothing linked. */
|
|
@@ -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" | "credentials-exchange" | "pre-user-registration" | "post-user-registration" | "post-user-update" | "validate-registration-username" | "pre-user-deletion" | "post-user-deletion" | "pre-user-update" | "pre-
|
|
13
|
+
trigger_id: "post-user-login" | "credentials-exchange" | "pre-user-registration" | "post-user-registration" | "post-user-update" | "validate-registration-username" | "pre-user-deletion" | "post-user-deletion" | "pre-user-update" | "pre-screen" | "custom-email-provider" | "custom-phone-provider";
|
|
14
14
|
enabled: boolean;
|
|
15
15
|
synchronous: boolean;
|
|
16
16
|
created_at: string;
|
|
@@ -18,7 +18,7 @@ export declare function listEnabledCodeHooks(ctx: Context<{
|
|
|
18
18
|
hook_id: string;
|
|
19
19
|
code_id: string;
|
|
20
20
|
scope?: "local" | "shared" | "platform" | undefined;
|
|
21
|
-
override?: "
|
|
21
|
+
override?: "none" | "secrets" | "fields" | undefined;
|
|
22
22
|
enforce?: boolean | undefined;
|
|
23
23
|
priority?: number | undefined;
|
|
24
24
|
metadata?: Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Context } from "hono";
|
|
2
|
+
import { Hook, LoginSession, PreScreenOperation, PreScreenPhase, User } from "@authhero/adapter-interfaces";
|
|
3
|
+
import { Bindings, Variables } from "../types";
|
|
4
|
+
import { EnrichedClient } from "../helpers/client";
|
|
5
|
+
type Ctx = Context<{
|
|
6
|
+
Bindings: Bindings;
|
|
7
|
+
Variables: Variables;
|
|
8
|
+
}>;
|
|
9
|
+
type CodeHook = Extract<Hook, {
|
|
10
|
+
code_id: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const PRE_SCREEN_TRIGGER = "pre-screen";
|
|
13
|
+
/**
|
|
14
|
+
* Host wait for the `onExecutePreScreen` config callback, matching the bound
|
|
15
|
+
* on code Actions. A callback that never settles must not leave the screen
|
|
16
|
+
* hanging.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PRE_SCREEN_TIMEOUT_MS = 5000;
|
|
19
|
+
/** Shown when an action denies without a reason, or fails closed. */
|
|
20
|
+
export declare const DEFAULT_PRE_SCREEN_DENIAL = "This isn't available for your account.";
|
|
21
|
+
export type PreScreenDecision = {
|
|
22
|
+
type: "continue";
|
|
23
|
+
} | {
|
|
24
|
+
type: "redirect";
|
|
25
|
+
url: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: "deny";
|
|
28
|
+
reason: string;
|
|
29
|
+
};
|
|
30
|
+
/** What a submission does, for the submit phase's `event.operation`. */
|
|
31
|
+
export type PreScreenSubmission = {
|
|
32
|
+
operation: PreScreenOperation;
|
|
33
|
+
details?: Record<string, string>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Thrown when a `pre-screen` Action denies a screen or its submission. The
|
|
37
|
+
* universal-login error handler renders `reason` on the branded error page
|
|
38
|
+
* (other error messages are replaced by a generic text there, which would
|
|
39
|
+
* hide the tenant's explanation).
|
|
40
|
+
*/
|
|
41
|
+
export declare class ScreenDeniedError extends Error {
|
|
42
|
+
readonly reason: string;
|
|
43
|
+
readonly status = 403;
|
|
44
|
+
constructor(reason: string);
|
|
45
|
+
}
|
|
46
|
+
/** A loader that only runs when something is bound to the screen. */
|
|
47
|
+
type Lazy<T> = () => Promise<T>;
|
|
48
|
+
export interface PreScreenParams {
|
|
49
|
+
tenantId: string;
|
|
50
|
+
/** Screen name from `PRE_SCREEN_SCREENS`, e.g. `login-id`. */
|
|
51
|
+
screen: string;
|
|
52
|
+
phase: PreScreenPhase;
|
|
53
|
+
/**
|
|
54
|
+
* Everything below is only loaded when something is bound to the screen,
|
|
55
|
+
* so unbound screens pay nothing beyond the (cached) hook list.
|
|
56
|
+
*/
|
|
57
|
+
client?: Lazy<EnrichedClient | undefined>;
|
|
58
|
+
loginSession?: Lazy<LoginSession | undefined>;
|
|
59
|
+
user?: Lazy<User | undefined>;
|
|
60
|
+
/** Submit phase: the operation the submission performs, if any. */
|
|
61
|
+
submission?: Lazy<PreScreenSubmission | undefined>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The enabled code hooks bound to `pre-screen` that run for `screen`, highest
|
|
65
|
+
* priority first. Reads the unparameterized hook list, which the client bundle
|
|
66
|
+
* serves from cache, and only queries when that page is full.
|
|
67
|
+
*/
|
|
68
|
+
export declare function findPreScreenHooks(ctx: Ctx, tenantId: string, screen: string): Promise<CodeHook[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Resolve a redirect target from an Action. Only the URL and query the Action
|
|
71
|
+
* returned are used: relative URLs resolve against the current request and
|
|
72
|
+
* anything other than http(s) is rejected, so an Action can't send the
|
|
73
|
+
* browser to `javascript:` or `data:` URLs. Nothing from the request (its
|
|
74
|
+
* query, `redirect_uri`, the login session) is added, so the trigger can't be
|
|
75
|
+
* used as an open redirect. No `state` is appended: the user leaves this
|
|
76
|
+
* transaction, which stays resumable until the login session expires.
|
|
77
|
+
*/
|
|
78
|
+
export declare function buildPreScreenRedirectUrl(requestUrl: string, url: unknown, options: unknown): string;
|
|
79
|
+
/**
|
|
80
|
+
* Run the `pre-screen` trigger: the `onExecutePreScreen` config hook first,
|
|
81
|
+
* then the code Actions bound to the screen in priority order. The first one
|
|
82
|
+
* that redirects or denies decides and later ones don't run.
|
|
83
|
+
*
|
|
84
|
+
* An Action that throws, times out or fails denies a submission (fail
|
|
85
|
+
* closed). In the render phase it is logged and the screen is shown, unless
|
|
86
|
+
* the binding set `metadata.fail_closed`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function runPreScreen(ctx: Ctx, params: PreScreenParams): Promise<PreScreenDecision>;
|
|
89
|
+
/**
|
|
90
|
+
* Run the trigger and act on the result: throws `RedirectException` to send
|
|
91
|
+
* the user elsewhere and `ScreenDeniedError` to stop. Both are rendered by the
|
|
92
|
+
* universal-login error handler. Returns normally when the screen may go on.
|
|
93
|
+
*/
|
|
94
|
+
export declare function enforcePreScreen(ctx: Ctx, params: PreScreenParams): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* The user an identifier (email, phone number or username) entered on a
|
|
97
|
+
* login, signup or password-reset screen belongs to, resolved to the primary
|
|
98
|
+
* user. Undefined when no user matches.
|
|
99
|
+
*/
|
|
100
|
+
export declare function findUserByIdentifier(ctx: Ctx, tenantId: string, identifier: unknown): Promise<User | undefined>;
|
|
101
|
+
/**
|
|
102
|
+
* The user of a login-flow screen: the identifier just submitted (pass it
|
|
103
|
+
* only for screens where the user enters one), then the user the transaction
|
|
104
|
+
* already authenticated (MFA, consent, passkey enrollment), then the
|
|
105
|
+
* identifier entered earlier in the flow.
|
|
106
|
+
*/
|
|
107
|
+
export declare function findLoginScreenUser(ctx: Ctx, tenantId: string, loginSession: LoginSession | undefined, submittedIdentifier?: unknown): Promise<User | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* The user of an account screen: the signed-in session's user, or, mid-login
|
|
110
|
+
* (a form hook sent the user to an account page), the user the transaction
|
|
111
|
+
* authenticated. The screen still enforces its own access rules afterwards.
|
|
112
|
+
*/
|
|
113
|
+
export declare function findAccountScreenUser(ctx: Ctx, tenantId: string, loginSession: LoginSession | undefined): Promise<User | undefined>;
|
|
114
|
+
export {};
|