@atlasauth/js 0.15.0 → 0.16.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/CHANGELOG.md +12 -0
- package/dist/account-hints.d.ts +53 -0
- package/dist/account-hints.js +114 -0
- package/dist/account-hints.js.map +1 -0
- package/dist/attempt.d.ts +3 -1
- package/dist/attempt.js.map +1 -1
- package/dist/captcha-controller.d.ts +21 -0
- package/dist/captcha-controller.js +35 -0
- package/dist/captcha-controller.js.map +1 -1
- package/dist/environment.d.ts +48 -0
- package/dist/environment.js +54 -1
- package/dist/environment.js.map +1 -1
- package/dist/fapi.d.ts +29 -0
- package/dist/fapi.js +90 -7
- package/dist/fapi.js.map +1 -1
- package/dist/impersonation.d.ts +44 -0
- package/dist/impersonation.js +47 -0
- package/dist/impersonation.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/instance-settings.d.ts +7 -1
- package/dist/instance-settings.js +15 -1
- package/dist/instance-settings.js.map +1 -1
- package/dist/mfa-enrollment.d.ts +154 -0
- package/dist/mfa-enrollment.js +288 -0
- package/dist/mfa-enrollment.js.map +1 -0
- package/dist/organization-audit-log.d.ts +63 -0
- package/dist/organization-audit-log.js +96 -0
- package/dist/organization-audit-log.js.map +1 -0
- package/dist/organizations.d.ts +330 -0
- package/dist/organizations.js +375 -0
- package/dist/organizations.js.map +1 -0
- package/dist/passkey-sign-in.d.ts +40 -0
- package/dist/passkey-sign-in.js +41 -0
- package/dist/passkey-sign-in.js.map +1 -0
- package/dist/passkey-sign-up.d.ts +46 -0
- package/dist/passkey-sign-up.js +98 -0
- package/dist/passkey-sign-up.js.map +1 -0
- package/dist/password-reset.d.ts +12 -0
- package/dist/password-reset.js +15 -0
- package/dist/password-reset.js.map +1 -1
- package/dist/phone-numbers.d.ts +43 -0
- package/dist/phone-numbers.js +65 -0
- package/dist/phone-numbers.js.map +1 -0
- package/dist/profile.d.ts +24 -0
- package/dist/profile.js +24 -0
- package/dist/profile.js.map +1 -0
- package/dist/referral-detect.js +1 -1
- package/dist/referral.d.ts +1 -1
- package/dist/referral.js +3 -2
- package/dist/referral.js.map +1 -1
- package/dist/sign-out-guard.d.ts +8 -0
- package/dist/sign-out-guard.js +15 -0
- package/dist/sign-out-guard.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlasauth/js changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.0 — 2026-10-23
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `createOrganizationAuditLog(client, { pageSize, action })`: the framework-agnostic pager behind every SDK's `<OrganizationAuditLog/>`, with `organizationAuditLogPath`, `describeAuditAction` and the `OrganizationAuditLogEntry` type.
|
|
8
|
+
- Sign-up starts, and every start that can create an account (social, enterprise SSO and SAML, DiscourseConnect, native id_token, external JWT, LDAP, Telegram and wallet sign-ins), send the stable device id, so an instance's accounts-per-device limit counts devices rather than networks, across email and social sign-ups alike. `DEVICE_ID_ROUTES` lists them.
|
|
9
|
+
- The recovery codes an MFA enrolment completes the sign-in with: `advance` moves `backup_codes` off the attempt into `FlowState.recoveryCodes` (memory only), and the components show them before exchanging the ticket with `pendingRecoveryCodes`, `acknowledgeRecoveryCodes`, `copyRecoveryCodes`, `downloadRecoveryCodes` / `canDownloadRecoveryCodes` (a `recovery-codes.txt` file), `recoveryCodesText` and `recoveryCodesFrom`.
|
|
10
|
+
- The sign-in's MFA steps, shared by every framework SDK: `createMfaEnrollment` (the enrolment step's state and requests: authenticator app with `qrCode`, or a texted code), `prepareMfaEnrollment`, `enrollmentSubmitKey`, `groupSetupKey`, `prepareSecondFactorCode` (`sms` or `email_code`) and `mfaChoicesFrom`.
|
|
11
|
+
- `requestForStep` posts a texted enrolment as `{ factor_id, code }` (values with `enrollStrategy: 'phone_code'`).
|
|
12
|
+
- `AccountUx.mfa` (`{ totp, sms, totpCodes }`), read from `account.mfa` when the server sends it.
|
|
13
|
+
- `beginPasskeySignIn(client, { captcha })`: the passkey sign-in start (`sign_ins/passkey/begin`) with the sign-in captcha folded in. It sends `captcha_token` when the token source has one, and after a `CAPTCHA_REQUIRED` / `CAPTCHA_FAILED` refusal asks once for a fresh token and retries once.
|
|
14
|
+
|
|
3
15
|
## 0.15.0
|
|
4
16
|
|
|
5
17
|
### Added
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FapiClient } from './fapi';
|
|
2
|
+
import type { UsernameRule } from './environment';
|
|
3
|
+
/**
|
|
4
|
+
* Sign-up / sign-in form hints: whether a username is free (a live hint beside
|
|
5
|
+
* the field) and which method this browser last signed in with (the "Last used"
|
|
6
|
+
* badge). Both are hints only — the server enforces everything on submit.
|
|
7
|
+
*/
|
|
8
|
+
/** `POST /v1/client/usernames/availability`. */
|
|
9
|
+
export interface UsernameAvailability {
|
|
10
|
+
username: string;
|
|
11
|
+
/** Meets the instance's username rule. */
|
|
12
|
+
valid: boolean;
|
|
13
|
+
/** Valid and nobody holds it. */
|
|
14
|
+
available: boolean;
|
|
15
|
+
/** The rule it breaks, when not valid. */
|
|
16
|
+
message?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Ask whether a username is free. Null when the server cannot say (usernames
|
|
20
|
+
* off, rate-limited, unreachable) — a form then simply shows no hint.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkUsernameAvailability(client: FapiClient, username: string): Promise<UsernameAvailability | null>;
|
|
23
|
+
/** Check a username against the rule locally (before asking the server). */
|
|
24
|
+
export declare function usernameMeetsRule(username: string, rule: UsernameRule): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The method this browser last signed in with, as the server recorded it
|
|
27
|
+
* (`password`, `email_code`, `email_link`, `passkey`, `phone_code`,
|
|
28
|
+
* `oauth_google`, …). Null when none is remembered, the instance turned the
|
|
29
|
+
* hint off, or the server cannot be reached.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fetchLastSignInMethod(client: FapiClient): Promise<string | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a sign-in option is the one last used. `option` is a first factor
|
|
34
|
+
* (`password`, `email_code`, `passkey`, …) or a social provider id (`google`).
|
|
35
|
+
* Email code and email link count as one ("email"), as do the OAuth and the
|
|
36
|
+
* native flow of a provider.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isLastUsed(lastMethod: string | null | undefined, option: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The label a sign-in form shows for a first-party "Last used" method
|
|
41
|
+
* (`Last used: Password`), or null for social / enterprise methods (badged on
|
|
42
|
+
* their own buttons) and anything unrecognised. `t` is the form's translator.
|
|
43
|
+
*/
|
|
44
|
+
export declare function lastUsedMethodLabel(lastMethod: string | null | undefined, t: (key: string) => string): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Email OTP second factor: mail a code to the user's verified address for this
|
|
47
|
+
* sign-in attempt (on its `needs_second_factor` step). Resolves the masked
|
|
48
|
+
* address it went to; the code is then submitted like any second-factor code.
|
|
49
|
+
* Throws with the server's message when the factor is not offered.
|
|
50
|
+
*/
|
|
51
|
+
export declare function prepareEmailSecondFactor(client: FapiClient, attemptId: string): Promise<{
|
|
52
|
+
sentTo: string;
|
|
53
|
+
}>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkUsernameAvailability = checkUsernameAvailability;
|
|
4
|
+
exports.usernameMeetsRule = usernameMeetsRule;
|
|
5
|
+
exports.fetchLastSignInMethod = fetchLastSignInMethod;
|
|
6
|
+
exports.isLastUsed = isLastUsed;
|
|
7
|
+
exports.lastUsedMethodLabel = lastUsedMethodLabel;
|
|
8
|
+
exports.prepareEmailSecondFactor = prepareEmailSecondFactor;
|
|
9
|
+
/**
|
|
10
|
+
* Ask whether a username is free. Null when the server cannot say (usernames
|
|
11
|
+
* off, rate-limited, unreachable) — a form then simply shows no hint.
|
|
12
|
+
*/
|
|
13
|
+
async function checkUsernameAvailability(client, username) {
|
|
14
|
+
try {
|
|
15
|
+
const response = await client.post('/v1/client/usernames/availability', { username });
|
|
16
|
+
const d = response.data;
|
|
17
|
+
if (!response.ok || !d)
|
|
18
|
+
return null;
|
|
19
|
+
return {
|
|
20
|
+
username: typeof d.username === 'string' ? d.username : username.trim(),
|
|
21
|
+
valid: d.valid === true,
|
|
22
|
+
available: d.available === true,
|
|
23
|
+
...(typeof d.message === 'string' ? { message: d.message } : {}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const CHARSET_RE = {
|
|
31
|
+
default: /^[A-Za-z0-9._-]+$/,
|
|
32
|
+
alphanumeric: /^[A-Za-z0-9]+$/,
|
|
33
|
+
alphanumeric_underscore: /^[A-Za-z0-9_]+$/,
|
|
34
|
+
};
|
|
35
|
+
/** Check a username against the rule locally (before asking the server). */
|
|
36
|
+
function usernameMeetsRule(username, rule) {
|
|
37
|
+
const v = username.trim();
|
|
38
|
+
return v.length >= rule.minLength && v.length <= rule.maxLength && CHARSET_RE[rule.charset].test(v);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The method this browser last signed in with, as the server recorded it
|
|
42
|
+
* (`password`, `email_code`, `email_link`, `passkey`, `phone_code`,
|
|
43
|
+
* `oauth_google`, …). Null when none is remembered, the instance turned the
|
|
44
|
+
* hint off, or the server cannot be reached.
|
|
45
|
+
*/
|
|
46
|
+
async function fetchLastSignInMethod(client) {
|
|
47
|
+
try {
|
|
48
|
+
const response = await client.get('/v1/client/last_sign_in_method');
|
|
49
|
+
const m = response.ok ? response.data?.method : null;
|
|
50
|
+
return typeof m === 'string' && m ? m : null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whether a sign-in option is the one last used. `option` is a first factor
|
|
58
|
+
* (`password`, `email_code`, `passkey`, …) or a social provider id (`google`).
|
|
59
|
+
* Email code and email link count as one ("email"), as do the OAuth and the
|
|
60
|
+
* native flow of a provider.
|
|
61
|
+
*/
|
|
62
|
+
function isLastUsed(lastMethod, option) {
|
|
63
|
+
if (!lastMethod)
|
|
64
|
+
return false;
|
|
65
|
+
const norm = (m) => {
|
|
66
|
+
if (m.startsWith('oauth_'))
|
|
67
|
+
return `oauth:${m.slice(6)}`;
|
|
68
|
+
if (m.startsWith('id_token_'))
|
|
69
|
+
return `oauth:${m.slice(9)}`;
|
|
70
|
+
if (m === 'email_code' || m === 'email_link')
|
|
71
|
+
return 'email';
|
|
72
|
+
return m;
|
|
73
|
+
};
|
|
74
|
+
const last = norm(lastMethod);
|
|
75
|
+
return last === norm(option) || last === `oauth:${option}`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The label a sign-in form shows for a first-party "Last used" method
|
|
79
|
+
* (`Last used: Password`), or null for social / enterprise methods (badged on
|
|
80
|
+
* their own buttons) and anything unrecognised. `t` is the form's translator.
|
|
81
|
+
*/
|
|
82
|
+
function lastUsedMethodLabel(lastMethod, t) {
|
|
83
|
+
switch (lastMethod) {
|
|
84
|
+
case 'password':
|
|
85
|
+
return t('signIn.passwordLabel');
|
|
86
|
+
case 'email_code':
|
|
87
|
+
case 'email_link':
|
|
88
|
+
return t('signIn.identifierLabel');
|
|
89
|
+
case 'passkey':
|
|
90
|
+
return 'Passkey';
|
|
91
|
+
case 'phone_code':
|
|
92
|
+
return 'Phone';
|
|
93
|
+
default:
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Email OTP second factor: mail a code to the user's verified address for this
|
|
99
|
+
* sign-in attempt (on its `needs_second_factor` step). Resolves the masked
|
|
100
|
+
* address it went to; the code is then submitted like any second-factor code.
|
|
101
|
+
* Throws with the server's message when the factor is not offered.
|
|
102
|
+
*/
|
|
103
|
+
async function prepareEmailSecondFactor(client, attemptId) {
|
|
104
|
+
const response = await client.post(`/v1/client/sign_ins/${encodeURIComponent(attemptId)}/prepare_second_factor`, { strategy: 'email_code' });
|
|
105
|
+
if (!response.ok) {
|
|
106
|
+
const first = response.errors[0];
|
|
107
|
+
const error = new Error(first?.message ?? 'Could not send the code.');
|
|
108
|
+
if (first?.code)
|
|
109
|
+
error.code = first.code;
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
return { sentTo: typeof response.data?.sent_to === 'string' ? response.data.sent_to : '' };
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=account-hints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-hints.js","sourceRoot":"","sources":["../src/account-hints.ts"],"names":[],"mappings":";;AAwBA,8DAsBC;AASD,8CAGC;AAQD,sDAQC;AAQD,gCAUC;AAOD,kDAiBC;AAQD,4DAeC;AAvHD;;;GAGG;AACI,KAAK,UAAU,yBAAyB,CAC7C,MAAkB,EAClB,QAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAK/B,mCAAmC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACpC,OAAO;YACL,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE;YACvE,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI;YACvB,SAAS,EAAE,CAAC,CAAC,SAAS,KAAK,IAAI;YAC/B,GAA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CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,IAAI,0BAA0B,CAA8B,CAAC;QACnG,IAAI,KAAK,EAAE,IAAI;YAAE,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC7F,CAAC"}
|
package/dist/attempt.d.ts
CHANGED
|
@@ -54,11 +54,13 @@ export interface AttemptView {
|
|
|
54
54
|
*/
|
|
55
55
|
id: string | null;
|
|
56
56
|
/** The resource type the server stamps on every attempt view. */
|
|
57
|
-
object?: 'sign_in_attempt';
|
|
57
|
+
object?: 'sign_in_attempt' | 'sign_up_attempt';
|
|
58
58
|
status: string;
|
|
59
59
|
/** The identifier the attempt was started with; `null` before one is collected. */
|
|
60
60
|
identifier?: string | null;
|
|
61
61
|
supported_first_factors?: string[];
|
|
62
|
+
/** `passkey` on a passkey-only sign-up (see `awaitingPasskey`). */
|
|
63
|
+
strategy?: string;
|
|
62
64
|
created_session_id?: string | null;
|
|
63
65
|
/** Attempt expiry (epoch ms); `null` on the pre-attempt challenge marker. */
|
|
64
66
|
expires_at?: number | null;
|
package/dist/attempt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attempt.js","sourceRoot":"","sources":["../src/attempt.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;
|
|
1
|
+
{"version":3,"file":"attempt.js","sourceRoot":"","sources":["../src/attempt.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAoDH,4BAqDC;AAGD,gCAEC;AA6BD,kCAiBC;AAGD,8BAEC;AAGD,gCAEC;AAl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MAA6B;IACtD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type FieldError } from './attempt';
|
|
2
2
|
import { type FapiClient, type FlowState } from './fapi';
|
|
3
|
+
import type { WebAuthnHost } from './passkey';
|
|
3
4
|
import type { AtlasCaptchaLabels } from './atlas-captcha';
|
|
4
5
|
import { type FlowCaptcha } from './captcha-widget';
|
|
5
6
|
/**
|
|
@@ -103,3 +104,23 @@ export declare function createSignUp(client: FapiClient, values: Record<string,
|
|
|
103
104
|
captcha?: CaptchaController | null;
|
|
104
105
|
t: (key: string) => string;
|
|
105
106
|
}): Promise<FlowState>;
|
|
107
|
+
/**
|
|
108
|
+
* {@link createSignUp} for a passkey-only sign-up (`account.passkeySignUp`):
|
|
109
|
+
* POSTs `/v1/client/sign_ups/passkey` with the email (when the form collected
|
|
110
|
+
* one) and the configured sign-up fields — never a password. No account exists
|
|
111
|
+
* until {@link finishPasskeySignUp} registers the passkey.
|
|
112
|
+
*/
|
|
113
|
+
export declare function createPasskeySignUp(client: FapiClient, values: Record<string, string>, opts: {
|
|
114
|
+
consent: boolean;
|
|
115
|
+
captcha?: CaptchaController | null;
|
|
116
|
+
t: (key: string) => string;
|
|
117
|
+
}): Promise<FlowState>;
|
|
118
|
+
/**
|
|
119
|
+
* The passkey-only sign-up's last step, for a prebuilt form: run the browser
|
|
120
|
+
* ceremony, and the server creates the account when it verifies. A cancelled
|
|
121
|
+
* prompt reads `signUp.passkeyCancelled` from the form's catalog.
|
|
122
|
+
*/
|
|
123
|
+
export declare function finishPasskeySignUp(client: FapiClient, state: FlowState, opts: {
|
|
124
|
+
t: (key: string) => string;
|
|
125
|
+
host?: WebAuthnHost;
|
|
126
|
+
}): Promise<FlowState>;
|
|
@@ -5,9 +5,12 @@ exports.localizeCaptchaErrors = localizeCaptchaErrors;
|
|
|
5
5
|
exports.signInCaptchaOptions = signInCaptchaOptions;
|
|
6
6
|
exports.advanceWithCaptcha = advanceWithCaptcha;
|
|
7
7
|
exports.createSignUp = createSignUp;
|
|
8
|
+
exports.createPasskeySignUp = createPasskeySignUp;
|
|
9
|
+
exports.finishPasskeySignUp = finishPasskeySignUp;
|
|
8
10
|
const attempt_1 = require("./attempt");
|
|
9
11
|
const fapi_1 = require("./fapi");
|
|
10
12
|
const instance_settings_1 = require("./instance-settings");
|
|
13
|
+
const passkey_sign_up_1 = require("./passkey-sign-up");
|
|
11
14
|
const captcha_widget_1 = require("./captcha-widget");
|
|
12
15
|
function createCaptchaController(initial, settings = {}) {
|
|
13
16
|
let options = initial ?? { flow: undefined, active: false };
|
|
@@ -204,4 +207,36 @@ async function createSignUp(client, values, opts) {
|
|
|
204
207
|
opts.captcha.reset();
|
|
205
208
|
return next;
|
|
206
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* {@link createSignUp} for a passkey-only sign-up (`account.passkeySignUp`):
|
|
212
|
+
* POSTs `/v1/client/sign_ups/passkey` with the email (when the form collected
|
|
213
|
+
* one) and the configured sign-up fields — never a password. No account exists
|
|
214
|
+
* until {@link finishPasskeySignUp} registers the passkey.
|
|
215
|
+
*/
|
|
216
|
+
async function createPasskeySignUp(client, values, opts) {
|
|
217
|
+
const token = opts.captcha ? await opts.captcha.getToken() : null;
|
|
218
|
+
const { email, fields, consent } = (0, instance_settings_1.toSignUpInput)(values, opts.consent, token);
|
|
219
|
+
let next = await (0, passkey_sign_up_1.startPasskeySignUp)(client, {
|
|
220
|
+
...(email ? { email } : {}),
|
|
221
|
+
fields,
|
|
222
|
+
consent,
|
|
223
|
+
...(token ? { captchaToken: token } : {}),
|
|
224
|
+
});
|
|
225
|
+
next = { ...next, errors: localizeCaptchaErrors(next.errors, opts.t).errors };
|
|
226
|
+
if (next.errors.length > 0 && opts.captcha?.needed)
|
|
227
|
+
opts.captcha.reset();
|
|
228
|
+
return next;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The passkey-only sign-up's last step, for a prebuilt form: run the browser
|
|
232
|
+
* ceremony, and the server creates the account when it verifies. A cancelled
|
|
233
|
+
* prompt reads `signUp.passkeyCancelled` from the form's catalog.
|
|
234
|
+
*/
|
|
235
|
+
async function finishPasskeySignUp(client, state, opts) {
|
|
236
|
+
const next = await (0, passkey_sign_up_1.registerSignUpPasskey)(client, state, opts.host ? { host: opts.host } : {});
|
|
237
|
+
return {
|
|
238
|
+
...next,
|
|
239
|
+
errors: next.errors.map((e) => (e.code === 'PASSKEY_CANCELLED' ? { ...e, message: opts.t('signUp.passkeyCancelled') } : e)),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
207
242
|
//# sourceMappingURL=captcha-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captcha-controller.js","sourceRoot":"","sources":["../src/captcha-controller.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"captcha-controller.js","sourceRoot":"","sources":["../src/captcha-controller.ts"],"names":[],"mappings":";;AAqEA,0DA0FC;AAQD,sDAcC;AAUD,oDAYC;AAaD,gDA8CC;AAQD,oCAUC;AAQD,kDAgBC;AAOD,kDAUC;AAjUD,uCAAsD;AACtD,iCAA+E;AAC/E,2DAAoD;AACpD,uDAA8E;AAG9E,qDAO0B;AAwD1B,SAAgB,uBAAuB,CACrC,OAAkC,EAClC,WAAsC,EAAE;IAExC,IAAI,OAAO,GAA6B,OAAO,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACtF,IAAI,SAAS,GAAuB,IAAI,CAAC;IACzC,IAAI,MAAM,GAA+B,IAAI,CAAC;IAC9C,4EAA4E;IAC5E,wCAAwC;IACxC,IAAI,KAAK,GAA+B,IAAI,CAAC;IAC7C,2EAA2E;IAC3E,6BAA6B;IAC7B,IAAI,QAAQ,GAAkB,IAAI,CAAC;IAEnC,MAAM,MAAM,GAAG,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,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM;QAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CACvC,MAAkB,EAClB,KAAgB,EAChB,IAAyD;IAEzD,MAAM,IAAI,GAAG,MAAM,IAAA,uCAAqB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9F,OAAO;QACL,GAAG,IAAI;QACP,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5H,CAAC;AACJ,CAAC"}
|
package/dist/environment.d.ts
CHANGED
|
@@ -41,6 +41,53 @@ export declare function emailDeliveryFrom(body: unknown): EmailDelivery;
|
|
|
41
41
|
* `delivery` (not loaded yet) the list is returned unchanged.
|
|
42
42
|
*/
|
|
43
43
|
export declare function offeredFirstFactors(strategies: readonly string[], delivery: EmailDelivery | null | undefined): string[];
|
|
44
|
+
/** The username rule an instance enforces (from `account.username`). */
|
|
45
|
+
export interface UsernameRule {
|
|
46
|
+
minLength: number;
|
|
47
|
+
maxLength: number;
|
|
48
|
+
/** `default` = letters, digits and `. _ -`. */
|
|
49
|
+
charset: 'default' | 'alphanumeric' | 'alphanumeric_underscore';
|
|
50
|
+
requiredAtSignUp: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** How an emailed proof arrives: a code to type, a link to click, or either. */
|
|
53
|
+
export type EmailProofDelivery = 'code' | 'link' | 'both';
|
|
54
|
+
/** `account`: what a sign-in / sign-up form needs to draw itself. */
|
|
55
|
+
export interface AccountUx {
|
|
56
|
+
/** Null while usernames are off. */
|
|
57
|
+
username: UsernameRule | null;
|
|
58
|
+
/** Badge the method this browser last signed in with as "Last used". */
|
|
59
|
+
lastSignInMethod: boolean;
|
|
60
|
+
emailVerification: EmailProofDelivery;
|
|
61
|
+
passwordReset: EmailProofDelivery;
|
|
62
|
+
/** The second-factor step may offer "email me a code" ({@link prepareEmailSecondFactor}). */
|
|
63
|
+
emailSecondFactor: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Passkey-only sign-up ({@link startPasskeySignUp}), when the instance offers
|
|
66
|
+
* it: whether the form collects an email address. Null when not offered.
|
|
67
|
+
*/
|
|
68
|
+
passkeySignUp: {
|
|
69
|
+
email: 'off' | 'optional' | 'required';
|
|
70
|
+
} | null;
|
|
71
|
+
/**
|
|
72
|
+
* The second factors a sign-in may set up or use, when the server says
|
|
73
|
+
* (`account.mfa`): an authenticator app, texted codes (on AND the app can
|
|
74
|
+
* text), and how many authenticator codes enrolment asks for. Absent on a
|
|
75
|
+
* server that does not say: the MFA steps then offer the authenticator app
|
|
76
|
+
* only (see `mfaChoicesFrom`).
|
|
77
|
+
*/
|
|
78
|
+
mfa?: {
|
|
79
|
+
totp: boolean;
|
|
80
|
+
sms: boolean;
|
|
81
|
+
totpCodes: 1 | 2;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* What an older server (no `account`) is taken to mean: no usernames at
|
|
86
|
+
* sign-up, codes only, and no "Last used" hint (it has no endpoint for one).
|
|
87
|
+
*/
|
|
88
|
+
export declare const ACCOUNT_UX_DEFAULT: Readonly<AccountUx>;
|
|
89
|
+
/** Read `account` from a `/v1/client/environment` or `/v1/appearance` body. */
|
|
90
|
+
export declare function accountUxFrom(body: unknown): AccountUx;
|
|
44
91
|
/** One entry of the environment's `social_providers`. */
|
|
45
92
|
export interface EnvironmentSocialProvider {
|
|
46
93
|
provider: string;
|
|
@@ -72,6 +119,7 @@ export interface ClientEnvironment {
|
|
|
72
119
|
strategies: Record<string, unknown>;
|
|
73
120
|
emailDelivery: EmailDelivery;
|
|
74
121
|
socialProviders: EnvironmentSocialProvider[];
|
|
122
|
+
account: AccountUx;
|
|
75
123
|
}
|
|
76
124
|
/** Read a `/v1/client/environment` body. Defensive: malformed parts read as empty. */
|
|
77
125
|
export declare function clientEnvironmentFrom(body: unknown): ClientEnvironment;
|
package/dist/environment.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EMAIL_FIRST_FACTORS = exports.EMAIL_UNAVAILABLE_MESSAGE = exports.EMAIL_DELIVERY_UNKNOWN = void 0;
|
|
3
|
+
exports.ACCOUNT_UX_DEFAULT = exports.EMAIL_FIRST_FACTORS = exports.EMAIL_UNAVAILABLE_MESSAGE = exports.EMAIL_DELIVERY_UNKNOWN = void 0;
|
|
4
4
|
exports.emailDeliveryFrom = emailDeliveryFrom;
|
|
5
5
|
exports.offeredFirstFactors = offeredFirstFactors;
|
|
6
|
+
exports.accountUxFrom = accountUxFrom;
|
|
6
7
|
exports.clientEnvironmentFrom = clientEnvironmentFrom;
|
|
7
8
|
exports.fetchClientEnvironment = fetchClientEnvironment;
|
|
8
9
|
/**
|
|
@@ -47,6 +48,57 @@ function offeredFirstFactors(strategies, delivery) {
|
|
|
47
48
|
return [...strategies];
|
|
48
49
|
return strategies.filter((s) => !exports.EMAIL_FIRST_FACTORS.includes(s));
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* What an older server (no `account`) is taken to mean: no usernames at
|
|
53
|
+
* sign-up, codes only, and no "Last used" hint (it has no endpoint for one).
|
|
54
|
+
*/
|
|
55
|
+
exports.ACCOUNT_UX_DEFAULT = Object.freeze({
|
|
56
|
+
username: null,
|
|
57
|
+
lastSignInMethod: false,
|
|
58
|
+
emailVerification: 'code',
|
|
59
|
+
passwordReset: 'code',
|
|
60
|
+
emailSecondFactor: false,
|
|
61
|
+
passkeySignUp: null,
|
|
62
|
+
});
|
|
63
|
+
const proof = (v) => (v === 'link' || v === 'both' ? v : 'code');
|
|
64
|
+
/** Read `account` from a `/v1/client/environment` or `/v1/appearance` body. */
|
|
65
|
+
function accountUxFrom(body) {
|
|
66
|
+
const raw = isRecord(body) && isRecord(body.account) ? body.account : null;
|
|
67
|
+
if (!raw)
|
|
68
|
+
return { ...exports.ACCOUNT_UX_DEFAULT };
|
|
69
|
+
const u = isRecord(raw.username) ? raw.username : null;
|
|
70
|
+
const n = (v, d) => (typeof v === 'number' && Number.isInteger(v) ? v : d);
|
|
71
|
+
return {
|
|
72
|
+
username: u
|
|
73
|
+
? {
|
|
74
|
+
minLength: n(u.min_length, 3),
|
|
75
|
+
maxLength: n(u.max_length, 30),
|
|
76
|
+
charset: u.charset === 'alphanumeric' || u.charset === 'alphanumeric_underscore' ? u.charset : 'default',
|
|
77
|
+
requiredAtSignUp: u.required_at_sign_up === true,
|
|
78
|
+
}
|
|
79
|
+
: null,
|
|
80
|
+
lastSignInMethod: raw.last_sign_in_method === true,
|
|
81
|
+
emailVerification: proof(raw.email_verification),
|
|
82
|
+
passwordReset: proof(raw.password_reset),
|
|
83
|
+
emailSecondFactor: raw.email_second_factor === true,
|
|
84
|
+
...(isRecord(raw.mfa)
|
|
85
|
+
? {
|
|
86
|
+
mfa: {
|
|
87
|
+
totp: raw.mfa.totp !== false,
|
|
88
|
+
sms: raw.mfa.sms === true,
|
|
89
|
+
totpCodes: Number(raw.mfa.totp_codes ?? raw.mfa.totpCodes) >= 2 ? 2 : 1,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
: {}),
|
|
93
|
+
passkeySignUp: isRecord(raw.passkey_sign_up)
|
|
94
|
+
? {
|
|
95
|
+
email: raw.passkey_sign_up.email === 'off' || raw.passkey_sign_up.email === 'optional'
|
|
96
|
+
? raw.passkey_sign_up.email
|
|
97
|
+
: 'required',
|
|
98
|
+
}
|
|
99
|
+
: null,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
50
102
|
/** Read a `/v1/client/environment` body. Defensive: malformed parts read as empty. */
|
|
51
103
|
function clientEnvironmentFrom(body) {
|
|
52
104
|
const root = isRecord(body) ? body : {};
|
|
@@ -59,6 +111,7 @@ function clientEnvironmentFrom(body) {
|
|
|
59
111
|
socialProviders: Array.isArray(root.social_providers)
|
|
60
112
|
? root.social_providers.filter((p) => isRecord(p) && typeof p.provider === 'string')
|
|
61
113
|
: [],
|
|
114
|
+
account: accountUxFrom(root),
|
|
62
115
|
};
|
|
63
116
|
}
|
|
64
117
|
/** Fetch the client environment. Null when the server can't be reached or errors. */
|
package/dist/environment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":";;;AAiDA,8CAWC;AAQD,kDAMC;
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":";;;AAiDA,8CAWC;AAQD,kDAMC;AAuDD,sCAqCC;AAmCD,sDAeC;AAGD,wDAOC;AA1MD;;;GAGG;AACU,QAAA,sBAAsB,GAA4B,MAAM,CAAC,MAAM,CAAC;IAC3E,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH,iEAAiE;AACpD,QAAA,yBAAyB,GACpC,2FAA2F,CAAC;AAE9F,4DAA4D;AAC/C,QAAA,mBAAmB,GAAsB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAEnF,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CAC5D,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CA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AAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;YACtE,CAAC,CAAC,EAAE;QACN,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE;QACnE,aAAa,EAAE,iBAAiB,CAAC,IAAI,CAAC;QACtC,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC;YACnD,CAAC,CAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAC3B,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CACV;YAC9C,CAAC,CAAC,EAAE;QACN,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,qFAAqF;AAC9E,KAAK,UAAU,sBAAsB,CAAC,MAAkB;IAC7D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAU,wBAAwB,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/fapi.d.ts
CHANGED
|
@@ -66,6 +66,12 @@ export interface FapiResponse<T> {
|
|
|
66
66
|
data: T | null;
|
|
67
67
|
errors: FieldError[];
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The starts that can create an account, and so carry the SDK's stable device
|
|
71
|
+
* id for the accounts-per-device abuse limit. Password and passwordless
|
|
72
|
+
* sign-ins never create one and do not send it.
|
|
73
|
+
*/
|
|
74
|
+
export declare const DEVICE_ID_ROUTES: ReadonlySet<string>;
|
|
69
75
|
export declare class FapiClient {
|
|
70
76
|
private readonly options;
|
|
71
77
|
constructor(options: FapiClientOptions);
|
|
@@ -155,6 +161,14 @@ export interface FlowState {
|
|
|
155
161
|
* unknown, and for a sign-in completed on another device.
|
|
156
162
|
*/
|
|
157
163
|
sessionKept?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The one-time recovery codes a mid-sign-in MFA enrolment came with
|
|
166
|
+
* (`attempt_mfa_enrollment`'s `backup_codes`). Kept here, in memory only and
|
|
167
|
+
* never in `attempt` or any storage, until the user says they saved them
|
|
168
|
+
* (`pendingRecoveryCodes` / `acknowledgeRecoveryCodes`): the prebuilt
|
|
169
|
+
* components show them before exchanging the ticket.
|
|
170
|
+
*/
|
|
171
|
+
recoveryCodes?: string[] | null;
|
|
158
172
|
}
|
|
159
173
|
export declare const initialFlow: FlowState;
|
|
160
174
|
/**
|
|
@@ -195,7 +209,22 @@ export declare function startSignUp(client: FapiClient, input: {
|
|
|
195
209
|
fields?: Record<string, string>;
|
|
196
210
|
consent?: boolean;
|
|
197
211
|
captchaToken?: string;
|
|
212
|
+
/** The username to claim, when the instance offers usernames. */
|
|
213
|
+
username?: string;
|
|
198
214
|
}): Promise<FlowState>;
|
|
215
|
+
/**
|
|
216
|
+
* Resend a sign-up's emailed proof (a code, a link, or both — whatever the
|
|
217
|
+
* instance sends): `POST /v1/client/sign_ups/:id/prepare_verification`. The
|
|
218
|
+
* earlier code / link stops working. A refusal (a 429 with `retry_after`)
|
|
219
|
+
* comes back as `errors` with the attempt kept.
|
|
220
|
+
*/
|
|
221
|
+
export declare function resendSignUpVerification(client: FapiClient, state: FlowState): Promise<FlowState>;
|
|
222
|
+
/**
|
|
223
|
+
* Whether a sign-up attempt is waiting on an emailed LINK only (no code to
|
|
224
|
+
* type): the form says "check your email" and the tab polls. `emailVerification`
|
|
225
|
+
* is the instance's `account.emailVerification`.
|
|
226
|
+
*/
|
|
227
|
+
export declare function awaitingSignUpLink(attempt: AttemptView | null | undefined, emailVerification: string | null | undefined): boolean;
|
|
199
228
|
/** §5.3: ask the server to send a code or a magic link. */
|
|
200
229
|
export declare function prepareFactor(client: FapiClient, state: FlowState, strategy: 'email_code' | 'email_link'): Promise<FlowState>;
|
|
201
230
|
/**
|