@atlasauth/svelte 0.13.0 → 0.15.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlasauth/svelte changelog
2
2
 
3
+ ## 0.15.0 — 2026-11-05
4
+
5
+ - `<SignUp>` second-factor, enrolment and recovery-code steps; new `signInUrl`.
6
+
7
+ ## 0.14.0 — 2026-11-05
8
+
9
+ ### Added
10
+
11
+ - Sign-in offers the emailed proof when a password is on hold, even with email code sign-in off, and shows the password field with a confirmation once it is proven.
12
+
13
+ ### Also
14
+
15
+ - The existing-account notice after a sign-up reaches an account on hold (`FlowState.existingAccount`), and the `account_deleted` error reason.
16
+
3
17
  ## 0.13.0 — 2026-10-30
4
18
 
5
19
  - `<SignIn>` offers "Sign in with a passkey" and passkey autofill on the identifier field when the instance enables passkeys.
@@ -142,6 +142,8 @@ export interface FlowController {
142
142
  * for this before exchanging the ticket and finishing the sign-in.
143
143
  */
144
144
  saveRecoveryCodes(): void;
145
+ /** With `holdExistingAccountNotice`: the user read `pendingExistingAccountNotice($state)`; finish the sign-up. */
146
+ continueAfterExistingAccount(): void;
145
147
  /** Resend a sign-up's emailed code / link (the earlier one stops working). Resolves whether it was sent. */
146
148
  resendSignUp(): Promise<boolean>;
147
149
  /**
@@ -198,4 +200,6 @@ export declare function signIn(): FlowController;
198
200
  * `create(values)` posts `/v1/client/sign_ups` (the account is created there),
199
201
  * then `submit({ code })` verifies the emailed code and completes the session.
200
202
  */
201
- export declare function signUp(): FlowController;
203
+ export declare function signUp(options?: {
204
+ holdExistingAccountNotice?: boolean;
205
+ }): FlowController;
package/dist/accessors.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { derived, get, readable, writable } from 'svelte/store';
2
- import { FapiClient, advanceWithCaptcha, atlasCaptchaLabels, createCaptchaController, createPasskeySignInController, createPasskeySignUp, createSignUp, finishPasskeySignUp, fetchInstanceSettings, fetchLastSignInMethod, startSignInWithAtlas, flowNeedsCaptcha, signInCaptchaOptions, flowFromPending, pollAttempt, prepareFactor, shouldKeepPolling, createOrganizationAuditLog, createMfaEnrollment, acknowledgeRecoveryCodes, pendingRecoveryCodes, mfaChoicesFrom, prepareSecondFactorCode, resendSignUpVerification, PolicyAcceptanceController, loadPolicies as loadPolicyList, initialFlow as emptyFlow, } from '@atlasauth/js';
2
+ import { FapiClient, advanceWithCaptcha, atlasCaptchaLabels, attemptPasswordHoldProof, preparePasswordHoldProof, createCaptchaController, createPasskeySignInController, createPasskeySignUp, createSignUp, finishPasskeySignUp, fetchInstanceSettings, fetchLastSignInMethod, startSignInWithAtlas, flowNeedsCaptcha, signInCaptchaOptions, flowFromPending, pollAttempt, prepareFactor, shouldKeepPolling, createOrganizationAuditLog, createMfaEnrollment, acknowledgeExistingAccount, acknowledgeRecoveryCodes, pendingExistingAccountNotice, pendingRecoveryCodes, mfaChoicesFrom, prepareSecondFactorCode, resendSignUpVerification, PolicyAcceptanceController, loadPolicies as loadPolicyList, initialFlow as emptyFlow, } from '@atlasauth/js';
3
3
  import { useAtlas } from './context';
4
4
  import { translate } from './i18n';
5
5
  import { evaluate } from './protect';
@@ -89,7 +89,7 @@ export function getToken() {
89
89
  export function signOut(options) {
90
90
  return useAtlas().signOut(options);
91
91
  }
92
- function createFlow() {
92
+ function createFlow(options = {}) {
93
93
  const atlas = useAtlas();
94
94
  const client = new FapiClient({
95
95
  publishableKey: atlas.publishableKey,
@@ -163,7 +163,13 @@ function createFlow() {
163
163
  async function finish(next) {
164
164
  // An enrolment's recovery codes are shown first; `saveRecoveryCodes` finishes.
165
165
  if (pendingRecoveryCodes(next)) {
166
- state.set({ ...next, busy: false });
166
+ // The ticket dies in 60 seconds and saving the codes can take longer: redeem it now,
167
+ // and `saveRecoveryCodes` finishes. A refused exchange keeps the ticket, so the save reports it.
168
+ state.set({ ...next, busy: true });
169
+ const res = next.ticket
170
+ ? await client.post('/v1/client/tickets/exchange', { attempt_id: next.attempt.id, ticket: next.ticket })
171
+ : null;
172
+ state.set({ ...next, busy: false, ticket: res?.ok ? null : next.ticket });
167
173
  return;
168
174
  }
169
175
  if (next.attempt?.status === 'complete') {
@@ -176,6 +182,10 @@ function createFlow() {
176
182
  });
177
183
  exchanged = res.ok;
178
184
  }
185
+ if (exchanged && options.holdExistingAccountNotice && pendingExistingAccountNotice(next)) {
186
+ state.set({ ...next, ticket: null, busy: false });
187
+ return;
188
+ }
179
189
  const kept = exchanged && (await atlas.reload());
180
190
  state.set({ ...next, busy: false, sessionKept: kept });
181
191
  return;
@@ -183,9 +193,23 @@ function createFlow() {
183
193
  state.set(next);
184
194
  maybeStartPolling();
185
195
  }
196
+ // What lifts a password hold on this instance: the emailed code, or a link where it verifies by link only.
197
+ const holdProof = () => get(settings)?.account.emailVerification === 'link' ? 'email_link' : 'email_code';
186
198
  function submit(values) {
187
199
  void (async () => {
188
200
  state.update((current) => ({ ...current, busy: true, errors: [] }));
201
+ const { attempt, passwordHold, prepared } = get(state);
202
+ // A code that lifts a password hold goes to its own attempt, not this sign-in.
203
+ // `values.code`: "Use your password instead" leaves `prepared` set.
204
+ if (attempt?.status === 'needs_first_factor' &&
205
+ passwordHold &&
206
+ !passwordHold.released &&
207
+ prepared === 'email_code' &&
208
+ holdProof() === 'email_code' &&
209
+ values.code !== undefined) {
210
+ state.set(await attemptPasswordHoldProof(client, get(state), values.code));
211
+ return;
212
+ }
189
213
  const out = await advanceWithCaptcha(client, get(state), values, { captcha, identifier, t });
190
214
  identifier = out.identifier;
191
215
  await finish(out.state);
@@ -242,6 +266,9 @@ function createFlow() {
242
266
  function saveRecoveryCodes() {
243
267
  void finish(acknowledgeRecoveryCodes(get(state)));
244
268
  }
269
+ function continueAfterExistingAccount() {
270
+ void finish(acknowledgeExistingAccount(get(state)));
271
+ }
245
272
  async function resendSignUp() {
246
273
  state.update((current) => ({ ...current, busy: true, errors: [] }));
247
274
  const next = await resendSignUpVerification(client, get(state));
@@ -256,7 +283,11 @@ function createFlow() {
256
283
  }
257
284
  async function prepare(strategy) {
258
285
  state.update((current) => ({ ...current, busy: true, errors: [] }));
259
- const next = await prepareFactor(client, get(state), strategy);
286
+ const hold = get(state).passwordHold;
287
+ const proof = holdProof();
288
+ const next = hold && !hold.released && strategy === proof
289
+ ? await preparePasswordHoldProof(client, get(state), proof)
290
+ : await prepareFactor(client, get(state), strategy);
260
291
  state.set({ ...next, busy: false });
261
292
  maybeStartPolling();
262
293
  return next.errors.length === 0;
@@ -299,6 +330,7 @@ function createFlow() {
299
330
  enrollment,
300
331
  enrollmentState: { subscribe: enrollmentState.subscribe },
301
332
  saveRecoveryCodes,
333
+ continueAfterExistingAccount,
302
334
  resendSignUp,
303
335
  prepare,
304
336
  settings: { subscribe: settings.subscribe },
@@ -322,6 +354,6 @@ export function signIn() {
322
354
  * `create(values)` posts `/v1/client/sign_ups` (the account is created there),
323
355
  * then `submit({ code })` verifies the emailed code and completes the session.
324
356
  */
325
- export function signUp() {
326
- return createFlow();
357
+ export function signUp(options = {}) {
358
+ return createFlow(options);
327
359
  }
@@ -28,6 +28,7 @@ export let enrollmentState = null;
28
28
  export let emailVerification = "code";
29
29
  export let onResend = null;
30
30
  export let onPolicyDecline = null;
31
+ export let passwordHold = null;
31
32
  const atlas = useAtlas();
32
33
  const cls = (key, base) => classFor(key, atlas.appearance, base);
33
34
  const t = (key, vars) => translate(atlas.catalog, key, vars);
@@ -36,10 +37,21 @@ let values = {};
36
37
  $: step = attempt ? nextStep(attempt) : { kind: "collect_identifier" };
37
38
  const strategyName = (s) => typeof s === "string" ? s : String(s?.strategy ?? "");
38
39
  $: offered = step.kind === "collect_first_factor" ? offeredFirstFactors(step.strategies.map(strategyName), emailDelivery) : [];
39
- $: emailOptions = onPrepare ? offered.filter((s) => s === "email_code" || s === "email_link") : [];
40
+ let holdOption = null;
41
+ $: holdOption = passwordHold && !passwordHold.released && emailDelivery?.available !== false ? emailVerification === "link" ? "email_link" : "email_code" : null;
42
+ let emailOptions = [];
43
+ $: {
44
+ const listed = offered.filter((s) => s === "email_code" || s === "email_link");
45
+ emailOptions = !onPrepare ? [] : holdOption && !listed.includes(holdOption) ? [...listed, holdOption] : listed;
46
+ }
40
47
  $: plan = planFirstFactor(offered);
41
48
  $: showPassword = offered.includes("password") || emailOptions.length === 0;
42
49
  let prepared = null;
50
+ $: released = passwordHold?.released === true;
51
+ $: if (released) {
52
+ prepared = null;
53
+ values = {};
54
+ }
43
55
  $: sent = prepared && prepared.attemptId === (attempt?.id ?? null) ? prepared.strategy : null;
44
56
  async function prepare(strategy) {
45
57
  if (!onPrepare) return;
@@ -52,7 +64,7 @@ $: if (step.kind === "collect_first_factor" && onPrepare && plan.autoSend && att
52
64
  void prepare(plan.autoSend);
53
65
  }
54
66
  $: sending = step.kind === "collect_first_factor" && sent === null && !!onPrepare && !plan.password && emailOptions.length > 0;
55
- $: identifier = attempt?.identifier ?? "";
67
+ $: identifier = passwordHold?.email ?? attempt?.identifier ?? "";
56
68
  let emailed = null;
57
69
  $: emailedNow = emailed && emailed.attemptId === (attempt?.id ?? null) ? emailed : null;
58
70
  async function emailSecondFactor() {
@@ -185,6 +197,9 @@ function handleSubmit(event) {
185
197
  {#if sending}
186
198
  <p class="atlas-text" aria-live="polite">{t('signIn.sending')}</p>
187
199
  {/if}
200
+ {#if step.kind === 'collect_first_factor' && released && sent === null}
201
+ <p class="atlas-text" data-atlas-password-released="">{t('signIn.passwordHoldReleased')}</p>
202
+ {/if}
188
203
  {#if linkOnly}
189
204
  <p class="atlas-text" data-atlas-link-sent aria-live="polite">{t('signUp.linkSentTo', { email: identifier })}</p>
190
205
  {#if onResend}
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type AttemptView, type CaptchaController, type EmailDelivery, type FieldError, type MfaEnrollmentController, type MfaEnrollmentState } from '@atlasauth/js';
2
+ import { type AttemptView, type CaptchaController, type EmailDelivery, type FieldError, type FlowState, type MfaEnrollmentController, type MfaEnrollmentState } from '@atlasauth/js';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  /**
@@ -55,6 +55,7 @@ declare const __propDef: {
55
55
  */ emailVerification?: string;
56
56
  onResend?: (() => Promise<boolean>) | null;
57
57
  /** The user declined a policy the sign-in was waiting on (`needs_policy_acceptance`): cancel the attempt. */ onPolicyDecline?: ((title: string) => void) | null;
58
+ /** `FlowState.passwordHold`: offers the emailed proof, whichever factors the instance signs in with. */ passwordHold?: FlowState["passwordHold"];
58
59
  };
59
60
  events: {
60
61
  [evt: string]: CustomEvent<any>;
@@ -85,6 +85,8 @@ function submitIdentifier(values) {
85
85
  titleKey="signIn.title"
86
86
  onSubmit={submitIdentifier}
87
87
  onPrepare={flow.prepare}
88
+ passwordHold={$flowState.passwordHold ?? null}
89
+ emailVerification={$settings?.account.emailVerification ?? 'code'}
88
90
  onEmailSecondFactor={$settings?.account.emailSecondFactor ? flow.sendEmailSecondFactor : null}
89
91
  onSmsSecondFactor={$settings && flow.mfaChoices().sms ? flow.sendSmsSecondFactor : null}
90
92
  enrollment={flow.enrollment}
@@ -1,13 +1,23 @@
1
1
  <script>import { onDestroy, onMount } from "svelte";
2
- import { awaitingPasskey, passkeysSupported } from "@atlasauth/js";
2
+ import { awaitingPasskey, existingAccountResetUrl, passkeysSupported, pendingExistingAccountNotice, pendingRecoveryCodes, signInAfterProofUrl, signUpProvedByLink } from "@atlasauth/js";
3
3
  import { signUp } from "../accessors";
4
+ import { classFor } from "../appearance";
5
+ import { useAtlas } from "../context";
6
+ import { translate } from "../i18n";
4
7
  import AttemptFlow from "./AttemptFlow.svelte";
5
8
  import PasskeySignUpStep from "./PasskeySignUpStep.svelte";
9
+ import RecoveryCodes from "./RecoveryCodes.svelte";
6
10
  import SignUpForm from "./SignUpForm.svelte";
7
11
  export let afterUrl = void 0;
8
- const flow = signUp();
12
+ export let resetPasswordUrl = void 0;
13
+ export let signInUrl = void 0;
14
+ const atlas = useAtlas();
15
+ const cls = (key, base) => classFor(key, atlas.appearance, base);
16
+ const t = (key) => translate(atlas.catalog, key);
17
+ const flow = signUp({ holdExistingAccountNotice: true });
9
18
  const flowState = flow.state;
10
19
  const settings = flow.settings;
20
+ const enrollmentState = flow.enrollmentState;
11
21
  onDestroy(() => flow.destroy());
12
22
  onMount(() => {
13
23
  void flow.loadPolicies();
@@ -18,13 +28,38 @@ let mode = "password";
18
28
  $: offer = $settings?.account.passkeySignUp ?? null;
19
29
  $: canPasskey = !!offer && passkeysSupported();
20
30
  $: usingPasskey = mode === "passkey" && canPasskey;
31
+ $: recoveryCodes = pendingRecoveryCodes($flowState);
21
32
  function switchMode() {
22
33
  mode = usingPasskey ? "password" : "passkey";
23
34
  }
24
35
  </script>
25
36
 
26
- {#if $flowState.attempt && awaitingPasskey($flowState.attempt)}
37
+ {#if recoveryCodes}
38
+ <RecoveryCodes codes={recoveryCodes} busy={$flowState.busy} onSaved={flow.saveRecoveryCodes} />
39
+ {:else if pendingExistingAccountNotice($flowState)}
40
+ {@const resetHref = existingAccountResetUrl({ url: resetPasswordUrl, frontendApi: atlas.frontendApi, redirectUrl: afterUrl })}
41
+ <div class={cls('card', 'atlas-card')} data-atlas-existing-account="">
42
+ <h1 class={cls('headerTitle', 'atlas-title')}>{t('signUp.title')}</h1>
43
+ <p class="atlas-text">{t('signUp.existingAccount')}</p>
44
+ {#if resetHref}
45
+ <p class="atlas-text"><a class="atlas-link" href={resetHref}>{t('signIn.forgotPassword')}</a></p>
46
+ {/if}
47
+ <button class={cls('formButtonPrimary', 'atlas-button')} type="button" disabled={$flowState.busy} on:click={() => flow.continueAfterExistingAccount()}>
48
+ {t('signUp.submit')}
49
+ </button>
50
+ </div>
51
+ {:else if $flowState.attempt && awaitingPasskey($flowState.attempt)}
27
52
  <PasskeySignUpStep busy={$flowState.busy} errors={$flowState.errors} onCreate={flow.createPasskey} />
53
+ {:else if signUpProvedByLink($flowState.attempt)}
54
+ <!-- A link confirmed the address and made no session here. Says the same for any address. -->
55
+ {@const signInHref = signInAfterProofUrl({ url: signInUrl, frontendApi: atlas.frontendApi, redirectUrl: afterUrl })}
56
+ <div class={cls('card', 'atlas-card')} data-atlas-email-confirmed="">
57
+ <h1 class={cls('headerTitle', 'atlas-title')}>{t('signUp.title')}</h1>
58
+ <p class="atlas-text" role="status">{t('signUp.emailConfirmed')}</p>
59
+ {#if signInHref}
60
+ <a class={cls('formButtonPrimary', 'atlas-button')} href={signInHref}>{t('signIn.title')}</a>
61
+ {/if}
62
+ </div>
28
63
  {:else if $flowState.attempt}
29
64
  <AttemptFlow
30
65
  attempt={$flowState.attempt}
@@ -35,6 +70,11 @@ function switchMode() {
35
70
  onSubmit={flow.submit}
36
71
  emailVerification={$settings?.account.emailVerification ?? 'code'}
37
72
  onResend={flow.resendSignUp}
73
+ onEmailSecondFactor={$settings?.account.emailSecondFactor ? flow.sendEmailSecondFactor : null}
74
+ onSmsSecondFactor={$settings && flow.mfaChoices().sms ? flow.sendSmsSecondFactor : null}
75
+ enrollment={flow.enrollment}
76
+ enrollmentState={$enrollmentState}
77
+ onPolicyDecline={flow.declinePolicy}
38
78
  />
39
79
  {:else}
40
80
  <SignUpForm
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  * `/v1/client/sign_ups`; from there the flow is server-driven exactly like
9
9
  * `<SignIn/>` (the emailed-code step, then the ticket exchange).
10
10
  */ afterUrl?: string | undefined;
11
+ /** Where the existing-account notice's "Forgot password?" goes. Default: the hosted sign-in page; `null` hides it. */ resetPasswordUrl?: string | null | undefined;
12
+ /** Where "Sign in" goes once an emailed link confirmed the address and made no session here. Default: the hosted sign-in page; `null` hides it. */ signInUrl?: string | null | undefined;
11
13
  };
12
14
  events: {
13
15
  [evt: string]: CustomEvent<any>;
package/dist/i18n.js CHANGED
@@ -33,6 +33,9 @@ export const EN_US = {
33
33
  'signIn.resendCode': 'Resend code',
34
34
  'signIn.resendLink': 'Resend link',
35
35
  'signIn.passwordOption': 'Use your password instead',
36
+ 'signIn.passwordHoldReleased': 'Your email is verified. Enter your password to sign in.',
37
+ 'signUp.existingAccount': 'You already had an account. Your existing password still applies.',
38
+ 'signUp.emailConfirmed': 'Your email is confirmed. Sign in to continue.',
36
39
  'signIn.passkeyButton': 'Sign in with a passkey',
37
40
  'signIn.passkeyCancelled': "Passkey sign-in didn't finish. Try again, or use another way to sign in.",
38
41
  'signIn.signedIn': 'You\'re signed in.',
@@ -187,6 +190,9 @@ export const EN_US = {
187
190
  'error.email_delivery_unavailable': "This app can't send email right now. Try another sign-in method or contact the app owner.",
188
191
  'error.strategy_disabled': 'This sign-in method is not available for this app.',
189
192
  'error.sign_up_restricted': 'Sign-up on this app is by invitation only.',
193
+ 'error.sign_up_denied': 'Sign-up is not available for this account.',
194
+ 'error.password_not_yet_usable': 'Verify your email address before signing in with this password.',
195
+ 'error.account_deleted': 'The account for this address was deleted, so it can’t be used to sign up again.',
190
196
  'error.waitlisted': "You're on the waitlist. We'll email you when a place opens up.",
191
197
  'error.identifier_not_allowed': 'This email or phone number is not allowed on this app.',
192
198
  'error.disposable_email_blocked': 'Sign-up with a disposable or temporary email address is not allowed.',
@@ -195,6 +201,7 @@ export const EN_US = {
195
201
  'error.sign_ups_disabled': 'Sign-ups are temporarily disabled.',
196
202
  'error.high_risk_blocked': 'This sign-in was blocked because it looked unusual.',
197
203
  'error.sms_region_blocked': 'Text messages are not available for this phone number.',
204
+ 'error.github_team_required': 'Your GitHub account is not a member of a GitHub organization or team allowed to sign in here.',
198
205
  };
199
206
  /**
200
207
  * Look up a key and interpolate `{placeholders}`.
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { AtlasSdkInfo } from '@atlasauth/js';
2
2
  /** This package's version, sent as `X-Atlas-SDK` (kept in step with package.json by a test). */
3
- export declare const ATLAS_SVELTE_VERSION = "0.13.0";
3
+ export declare const ATLAS_SVELTE_VERSION = "0.15.0";
4
4
  export declare const ATLAS_SVELTE_SDK: AtlasSdkInfo;
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /** This package's version, sent as `X-Atlas-SDK` (kept in step with package.json by a test). */
2
- export const ATLAS_SVELTE_VERSION = '0.13.0';
2
+ export const ATLAS_SVELTE_VERSION = '0.15.0';
3
3
  export const ATLAS_SVELTE_SDK = { name: '@atlasauth/svelte', version: ATLAS_SVELTE_VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasauth/svelte",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "svelte": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@atlasauth/design": "0.3.0",
26
- "@atlasauth/js": "0.27.0",
26
+ "@atlasauth/js": "0.33.0",
27
27
  "@atlasauth/authz": "0.3.0",
28
- "@atlasauth/backend": "0.28.0"
28
+ "@atlasauth/backend": "0.39.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "svelte": ">=4",