@sparkvault/sdk-js 8.2.0 → 8.4.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.
@@ -23,6 +23,7 @@ export declare class IdentityRenderer {
23
23
  private readonly sparkLinkHandler;
24
24
  private currentView;
25
25
  private focusTimeoutId;
26
+ private morphTimer;
26
27
  private postLoginResult;
27
28
  private postLoginQueue;
28
29
  private sparkLinkWs;
@@ -95,6 +96,15 @@ export declare class IdentityRenderer {
95
96
  private showInitialAuthStep;
96
97
  private render;
97
98
  private destroyCurrentView;
99
+ /**
100
+ * Replace the mounted view with a Google-style height morph: the flow region
101
+ * animates its height from the outgoing content to the incoming content while
102
+ * the new step fades + rises in (`.sv-step-enter`), so the popup reads as one
103
+ * object reshaping rather than separate screens swapping. Falls back to an
104
+ * instant swap when layout metrics are unavailable (jsdom, where heights read
105
+ * 0) or the person prefers reduced motion.
106
+ */
107
+ private morphSwap;
98
108
  private createViewForState;
99
109
  private showIdentityInput;
100
110
  /**
@@ -2023,6 +2023,38 @@ function getStyles(options) {
2023
2023
  : '0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04)',
2024
2024
  };
2025
2025
  return `
2026
+ /* ========================================
2027
+ MOTION SYSTEM — shared duration/easing tokens so every transition in
2028
+ the flow is consistent. Enters decelerate (ease-out-expo), exits
2029
+ accelerate, spring is reserved for the success moment.
2030
+ ======================================== */
2031
+ :root {
2032
+ --sv-dur-instant: 80ms;
2033
+ --sv-dur-fast: 140ms;
2034
+ --sv-dur-base: 220ms;
2035
+ --sv-dur-slow: 320ms;
2036
+ --sv-dur-slower: 480ms;
2037
+ --sv-ease-standard: cubic-bezier(0.2, 0, 0, 1);
2038
+ --sv-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
2039
+ --sv-ease-accelerate: cubic-bezier(0.3, 0, 1, 1);
2040
+ --sv-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
2041
+ }
2042
+
2043
+ /* Each mounted view enters with a calm fade + rise. Applied by the renderer
2044
+ on every step change; the brand lockup and footer never move. */
2045
+ @keyframes sv-step-in {
2046
+ from { opacity: 0; transform: translateY(8px); }
2047
+ to { opacity: 1; transform: none; }
2048
+ }
2049
+ .sv-step-enter { animation: sv-step-in var(--sv-dur-base) var(--sv-ease-out) both; }
2050
+
2051
+ /* The top progress bar itself is owned and styled by the sign-in page
2052
+ (login-popup.js); the renderer only drives it via window.__sparkvaultProgress. */
2053
+
2054
+ @media (prefers-reduced-motion: reduce) {
2055
+ .sv-step-enter { animation-duration: 1ms; }
2056
+ }
2057
+
2026
2058
  /* ========================================
2027
2059
  OVERLAY & MODAL CONTAINER
2028
2060
  ======================================== */
@@ -2143,11 +2175,11 @@ function getStyles(options) {
2143
2175
  ======================================== */
2144
2176
 
2145
2177
  .sv-title {
2146
- font-size: 18px;
2178
+ font-size: 21px;
2147
2179
  font-weight: 600;
2148
- letter-spacing: -0.02em;
2149
- line-height: 1.3;
2150
- margin: 0 0 6px 0;
2180
+ letter-spacing: -0.021em;
2181
+ line-height: 1.22;
2182
+ margin: 0 0 7px 0;
2151
2183
  text-align: center;
2152
2184
  color: ${tokens.textPrimary};
2153
2185
  }
@@ -2186,16 +2218,17 @@ function getStyles(options) {
2186
2218
 
2187
2219
  .sv-input {
2188
2220
  width: 100%;
2189
- padding: 10px 12px;
2221
+ padding: 13px 14px;
2190
2222
  font-size: 15px;
2191
2223
  font-weight: 400;
2192
2224
  line-height: 1.4;
2193
- border: 1px solid ${tokens.border};
2194
- border-radius: 8px;
2225
+ border: 1px solid ${tokens.borderHover};
2226
+ border-radius: 10px;
2195
2227
  background: ${tokens.bgInput};
2196
2228
  color: ${tokens.textPrimary};
2197
2229
  box-sizing: border-box;
2198
- transition: border-color 0.15s ease, box-shadow 0.15s ease;
2230
+ box-shadow: 0 1px 1px ${isDark ? 'rgba(0,0,0,0.3)' : 'rgba(10,10,10,0.04)'};
2231
+ transition: border-color var(--sv-dur-fast) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard);
2199
2232
  }
2200
2233
 
2201
2234
  .sv-input:hover:not(:focus):not(:disabled) {
@@ -2237,15 +2270,15 @@ function getStyles(options) {
2237
2270
  justify-content: center;
2238
2271
  gap: 8px;
2239
2272
  width: 100%;
2240
- padding: 10px 16px;
2241
- font-size: 14px;
2242
- font-weight: 500;
2243
- letter-spacing: -0.005em;
2244
- line-height: 1.4;
2273
+ padding: 14px 16px;
2274
+ font-size: 15px;
2275
+ font-weight: 600;
2276
+ letter-spacing: -0.006em;
2277
+ line-height: 1.35;
2245
2278
  border: none;
2246
- border-radius: 8px;
2279
+ border-radius: 10px;
2247
2280
  cursor: pointer;
2248
- transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
2281
+ transition: background var(--sv-dur-fast) var(--sv-ease-standard), transform var(--sv-dur-instant) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard);
2249
2282
  box-sizing: border-box;
2250
2283
  }
2251
2284
 
@@ -2288,14 +2321,17 @@ function getStyles(options) {
2288
2321
  border-color: ${tokens.borderHover};
2289
2322
  }
2290
2323
 
2291
- /* Method Button */
2324
+ /* Method Button — a full-width row that lifts on hover with a nudging
2325
+ chevron affordance (added via ::after so no DOM change is needed). */
2292
2326
  .sv-btn-method {
2327
+ position: relative;
2293
2328
  background: ${tokens.bg};
2294
- border: 1px solid ${tokens.border};
2329
+ border: 1px solid ${tokens.borderHover};
2330
+ border-radius: 12px;
2295
2331
  color: ${tokens.textPrimary};
2296
2332
  text-align: left;
2297
- padding: 12px 14px;
2298
- margin-bottom: 8px;
2333
+ padding: 15px 40px 15px 14px;
2334
+ margin-bottom: 9px;
2299
2335
  /* Inset 2px on either side so the focus outline (drawn outside the
2300
2336
  border-box) has room to render without clipping against the
2301
2337
  dialog's container edges. width:auto pairs with this to prevent
@@ -2303,6 +2339,25 @@ function getStyles(options) {
2303
2339
  margin-left: 2px;
2304
2340
  margin-right: 2px;
2305
2341
  width: calc(100% - 4px);
2342
+ transition: transform var(--sv-dur-base) var(--sv-ease-out), background var(--sv-dur-fast) var(--sv-ease-standard), border-color var(--sv-dur-fast) var(--sv-ease-standard);
2343
+ }
2344
+
2345
+ .sv-btn-method::after {
2346
+ content: "";
2347
+ position: absolute;
2348
+ right: 16px;
2349
+ top: 50%;
2350
+ width: 8px;
2351
+ height: 8px;
2352
+ border-right: 1.6px solid ${tokens.textMuted};
2353
+ border-top: 1.6px solid ${tokens.textMuted};
2354
+ transform: translateY(-50%) rotate(45deg);
2355
+ transition: transform var(--sv-dur-base) var(--sv-ease-out), border-color var(--sv-dur-fast) var(--sv-ease-standard);
2356
+ }
2357
+
2358
+ .sv-btn-method:hover:not(:disabled)::after {
2359
+ transform: translateY(-50%) translateX(3px) rotate(45deg);
2360
+ border-color: ${tokens.textSecondary};
2306
2361
  }
2307
2362
 
2308
2363
  /* The shared .sv-btn focus rule sets outline-offset:2px which sits
@@ -2315,7 +2370,8 @@ function getStyles(options) {
2315
2370
 
2316
2371
  .sv-btn-method:hover:not(:disabled) {
2317
2372
  background: ${tokens.bgSubtle};
2318
- border-color: ${tokens.borderHover};
2373
+ border-color: ${tokens.border};
2374
+ transform: translateY(-2px);
2319
2375
  }
2320
2376
 
2321
2377
  .sv-btn-method:last-child {
@@ -2356,18 +2412,25 @@ function getStyles(options) {
2356
2412
  }
2357
2413
 
2358
2414
  .sv-method-icon {
2359
- width: 20px;
2360
- height: 20px;
2415
+ width: 36px;
2416
+ height: 36px;
2361
2417
  flex-shrink: 0;
2362
2418
  display: flex;
2363
2419
  align-items: center;
2364
2420
  justify-content: center;
2421
+ border-radius: 9px;
2422
+ background: ${tokens.bgSubtle};
2365
2423
  color: ${tokens.textSecondary};
2424
+ transition: background var(--sv-dur-fast) var(--sv-ease-standard);
2425
+ }
2426
+
2427
+ .sv-btn-method:hover:not(:disabled) .sv-method-icon {
2428
+ background: ${tokens.bg};
2366
2429
  }
2367
2430
 
2368
2431
  .sv-method-icon svg {
2369
- width: 20px;
2370
- height: 20px;
2432
+ width: 19px;
2433
+ height: 19px;
2371
2434
  }
2372
2435
 
2373
2436
  .sv-method-text {
@@ -2399,18 +2462,20 @@ function getStyles(options) {
2399
2462
  }
2400
2463
 
2401
2464
  .sv-otp-digit {
2402
- width: 44px;
2403
- height: 52px;
2465
+ width: 46px;
2466
+ height: 56px;
2404
2467
  text-align: center;
2405
- font-size: 20px;
2468
+ font-size: 22px;
2406
2469
  font-weight: 600;
2407
2470
  letter-spacing: 0;
2408
- border: 1px solid ${tokens.border};
2409
- border-radius: 8px;
2471
+ font-variant-numeric: tabular-nums;
2472
+ caret-color: transparent;
2473
+ border: 1px solid ${tokens.borderHover};
2474
+ border-radius: 11px;
2410
2475
  background: ${tokens.bgInput};
2411
2476
  color: ${tokens.textPrimary};
2412
2477
  box-sizing: border-box;
2413
- transition: border-color 0.15s ease, box-shadow 0.15s ease;
2478
+ transition: border-color var(--sv-dur-fast) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard), transform var(--sv-dur-fast) var(--sv-ease-spring);
2414
2479
  }
2415
2480
 
2416
2481
  .sv-otp-digit:hover:not(:focus):not(:disabled) {
@@ -2421,6 +2486,7 @@ function getStyles(options) {
2421
2486
  outline: none;
2422
2487
  border-color: ${tokens.borderFocus};
2423
2488
  box-shadow: 0 0 0 3px ${tokens.primaryLight};
2489
+ transform: translateY(-2px);
2424
2490
  }
2425
2491
 
2426
2492
  .sv-otp-digit:disabled {
@@ -5938,6 +6004,14 @@ class OriginNotAllowedView {
5938
6004
  * Orchestrates view state and rendering for identity verification flows.
5939
6005
  * Uses extracted handlers for OTP and Passkey operations.
5940
6006
  */
6007
+ function progressHook() {
6008
+ if (typeof window === 'undefined')
6009
+ return null;
6010
+ const hook = window.__sparkvaultProgress;
6011
+ return hook && typeof hook.start === 'function' ? hook : null;
6012
+ }
6013
+ function progressStart() { progressHook()?.start(); }
6014
+ function progressDone() { progressHook()?.done(); }
5941
6015
  /**
5942
6016
  * End-user copy for a blocked Identity. Intentionally non-leaky — it never names
5943
6017
  * the trial, billing, usage, or any owner-facing internal. When the site's
@@ -5965,6 +6039,7 @@ class IdentityRenderer {
5965
6039
  // View management
5966
6040
  this.currentView = null;
5967
6041
  this.focusTimeoutId = null;
6042
+ this.morphTimer = null;
5968
6043
  // Post-login recommendation pipeline: the verified result to finalize with,
5969
6044
  // and the remaining server-recommended steps to walk before finalizing.
5970
6045
  this.postLoginResult = null;
@@ -6180,6 +6255,10 @@ class IdentityRenderer {
6180
6255
  clearTimeout(this.focusTimeoutId);
6181
6256
  this.focusTimeoutId = null;
6182
6257
  }
6258
+ if (this.morphTimer !== null) {
6259
+ clearTimeout(this.morphTimer);
6260
+ this.morphTimer = null;
6261
+ }
6183
6262
  this.cleanupSparkLink();
6184
6263
  this.destroyCurrentView();
6185
6264
  this.container.destroy();
@@ -6214,8 +6293,24 @@ class IdentityRenderer {
6214
6293
  this.container.setMinimalChrome(minimalChromeViews.includes(this.viewState.view));
6215
6294
  const view = this.createViewForState(this.viewState);
6216
6295
  this.currentView = view;
6217
- clearChildren(body);
6218
- body.appendChild(view.render());
6296
+ const rendered = view.render();
6297
+ // Each step enters with a calm fade + rise (see .sv-step-enter). The brand
6298
+ // lockup and footer live outside `body`, so only the flow content moves.
6299
+ rendered.classList.add('sv-step-enter');
6300
+ // Swap with a Google-style height morph so the popup reads as one object
6301
+ // reshaping between steps (falls back to an instant swap in jsdom).
6302
+ this.morphSwap(body, rendered);
6303
+ // Drive the top progress bar (owned by login-popup.js as
6304
+ // `window.__sparkvaultProgress`) off the view: a transient `loading` view
6305
+ // means a network step is in flight, so keep the bar trickling; any real
6306
+ // view completes it. The controller is idempotent, so overlapping calls are
6307
+ // safe, and it is a no-op when the hook is absent (any non-popup host).
6308
+ if (this.viewState.view === 'loading') {
6309
+ progressStart();
6310
+ }
6311
+ else {
6312
+ progressDone();
6313
+ }
6219
6314
  // Auto-focus: prefer inputs first, then primary/method buttons (skip back links)
6220
6315
  const focusable = body.querySelector('input:not([disabled]), ' +
6221
6316
  'button.sv-btn-primary:not([disabled]), ' +
@@ -6235,6 +6330,55 @@ class IdentityRenderer {
6235
6330
  }
6236
6331
  this.currentView = null;
6237
6332
  }
6333
+ /**
6334
+ * Replace the mounted view with a Google-style height morph: the flow region
6335
+ * animates its height from the outgoing content to the incoming content while
6336
+ * the new step fades + rises in (`.sv-step-enter`), so the popup reads as one
6337
+ * object reshaping rather than separate screens swapping. Falls back to an
6338
+ * instant swap when layout metrics are unavailable (jsdom, where heights read
6339
+ * 0) or the person prefers reduced motion.
6340
+ */
6341
+ morphSwap(body, next) {
6342
+ const h0 = body.getBoundingClientRect().height;
6343
+ clearChildren(body);
6344
+ body.appendChild(next);
6345
+ const reduced = typeof window !== 'undefined'
6346
+ && typeof window.matchMedia === 'function'
6347
+ && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
6348
+ const h1 = body.getBoundingClientRect().height;
6349
+ if (reduced || h0 < 1 || h1 < 1 || Math.abs(h1 - h0) < 1) {
6350
+ return; // instant swap
6351
+ }
6352
+ const restore = () => {
6353
+ if (this.morphTimer !== null) {
6354
+ clearTimeout(this.morphTimer);
6355
+ this.morphTimer = null;
6356
+ }
6357
+ body.removeEventListener('transitionend', onEnd);
6358
+ body.style.height = '';
6359
+ body.style.overflow = '';
6360
+ body.style.transition = '';
6361
+ body.style.boxSizing = '';
6362
+ };
6363
+ const onEnd = (event) => {
6364
+ // Ignore transitions bubbling up from child elements (e.g. input focus
6365
+ // rings); only the body's own height transition ends the morph.
6366
+ const propertyName = event.propertyName;
6367
+ if (event.target === body && propertyName === 'height') {
6368
+ restore();
6369
+ }
6370
+ };
6371
+ body.style.boxSizing = 'border-box';
6372
+ body.style.overflow = 'hidden';
6373
+ body.style.height = `${h0}px`;
6374
+ void body.offsetHeight; // commit the start height before transitioning
6375
+ body.style.transition = 'height var(--sv-dur-slow) var(--sv-ease-out)';
6376
+ body.style.height = `${h1}px`;
6377
+ body.addEventListener('transitionend', onEnd);
6378
+ if (this.morphTimer !== null)
6379
+ clearTimeout(this.morphTimer);
6380
+ this.morphTimer = setTimeout(restore, 550);
6381
+ }
6238
6382
  createViewForState(state) {
6239
6383
  switch (state.view) {
6240
6384
  case 'loading':
@@ -6434,7 +6578,12 @@ class IdentityRenderer {
6434
6578
  && this.verificationState.passkey.hasPasskey === true
6435
6579
  && !this.verificationState.passkey.isFallbackMode
6436
6580
  && methods.some((m) => m.type === 'passkey')) {
6437
- this.setState({ view: 'passkey', recipient: this.recipient, mode: 'verify' });
6581
+ // The person already has a passkey: now that sign-in runs in its own
6582
+ // top-level window, skip the intermediate "Continue with passkey" screen
6583
+ // and fire the WebAuthn ceremony immediately. A cancel or failure falls
6584
+ // back to the full method list (passkey still listed) instead of a
6585
+ // passkey retry screen, so the person can pick a code or SparkLink.
6586
+ void this.launchPasskeyVerify(true);
6438
6587
  return;
6439
6588
  }
6440
6589
  if (methods.length === 1) {
@@ -6597,6 +6746,7 @@ class IdentityRenderer {
6597
6746
  if (this.viewState.view !== 'otp-verify')
6598
6747
  return;
6599
6748
  const currentMethod = this.verificationState.otp.method ?? 'email';
6749
+ progressStart();
6600
6750
  const result = await this.otpHandler.verify(code);
6601
6751
  if (result.secondFactor) {
6602
6752
  this.setState({
@@ -6716,17 +6866,17 @@ class IdentityRenderer {
6716
6866
  * loading state while the ceremony runs. window.open inside verify() fires
6717
6867
  * synchronously (before the first await), so it stays within the gesture.
6718
6868
  */
6719
- async launchPasskeyVerify() {
6869
+ async launchPasskeyVerify(fallbackToList = false) {
6720
6870
  this.setState({ view: 'loading' });
6721
6871
  const result = await this.passkeyHandler.verify();
6722
- this.applyPasskeyResult(result, 'verify');
6872
+ this.applyPasskeyResult(result, 'verify', fallbackToList);
6723
6873
  }
6724
6874
  /**
6725
6875
  * Apply a passkey ceremony result: complete on success, or route to the
6726
6876
  * matching recovery state. Shared by the passkey view and the direct
6727
6877
  * picker launch so both behave identically.
6728
6878
  */
6729
- applyPasskeyResult(result, currentMode) {
6879
+ applyPasskeyResult(result, currentMode, fallbackToList = false) {
6730
6880
  if (result.success && result.result) {
6731
6881
  this.close();
6732
6882
  this.safeOnSuccess(result.result);
@@ -6743,6 +6893,12 @@ class IdentityRenderer {
6743
6893
  message: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
6744
6894
  });
6745
6895
  }
6896
+ else if (fallbackToList && this.passkeyFallbackMethodsAvailable()) {
6897
+ // Auto-launched passkey that the person cancelled or that failed: drop to
6898
+ // the full method list (passkey still listed) rather than a passkey-only
6899
+ // retry screen, so a code or SparkLink is one tap away.
6900
+ void this.showMethodSelect({ autoRoute: false });
6901
+ }
6746
6902
  else if (result.errorType === 'not_found') {
6747
6903
  // No passkey yet — pivot the same screen to registration.
6748
6904
  this.setState({