@sparkvault/sdk-js 8.3.0 → 8.5.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/README.md +2 -2
- package/dist/products/identity/renderer.d.ts +10 -0
- package/dist/sparkvault.cjs.js +73 -9
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +73 -9
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +2 -2
package/dist/sparkvault.esm.js
CHANGED
|
@@ -6035,6 +6035,7 @@ class IdentityRenderer {
|
|
|
6035
6035
|
// View management
|
|
6036
6036
|
this.currentView = null;
|
|
6037
6037
|
this.focusTimeoutId = null;
|
|
6038
|
+
this.morphTimer = null;
|
|
6038
6039
|
// Post-login recommendation pipeline: the verified result to finalize with,
|
|
6039
6040
|
// and the remaining server-recommended steps to walk before finalizing.
|
|
6040
6041
|
this.postLoginResult = null;
|
|
@@ -6250,6 +6251,10 @@ class IdentityRenderer {
|
|
|
6250
6251
|
clearTimeout(this.focusTimeoutId);
|
|
6251
6252
|
this.focusTimeoutId = null;
|
|
6252
6253
|
}
|
|
6254
|
+
if (this.morphTimer !== null) {
|
|
6255
|
+
clearTimeout(this.morphTimer);
|
|
6256
|
+
this.morphTimer = null;
|
|
6257
|
+
}
|
|
6253
6258
|
this.cleanupSparkLink();
|
|
6254
6259
|
this.destroyCurrentView();
|
|
6255
6260
|
this.container.destroy();
|
|
@@ -6284,14 +6289,13 @@ class IdentityRenderer {
|
|
|
6284
6289
|
this.container.setMinimalChrome(minimalChromeViews.includes(this.viewState.view));
|
|
6285
6290
|
const view = this.createViewForState(this.viewState);
|
|
6286
6291
|
this.currentView = view;
|
|
6287
|
-
clearChildren(body);
|
|
6288
6292
|
const rendered = view.render();
|
|
6289
6293
|
// Each step enters with a calm fade + rise (see .sv-step-enter). The brand
|
|
6290
6294
|
// lockup and footer live outside `body`, so only the flow content moves.
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
+
rendered.classList.add('sv-step-enter');
|
|
6296
|
+
// Swap with a Google-style height morph so the popup reads as one object
|
|
6297
|
+
// reshaping between steps (falls back to an instant swap in jsdom).
|
|
6298
|
+
this.morphSwap(body, rendered);
|
|
6295
6299
|
// Drive the top progress bar (owned by login-popup.js as
|
|
6296
6300
|
// `window.__sparkvaultProgress`) off the view: a transient `loading` view
|
|
6297
6301
|
// means a network step is in flight, so keep the bar trickling; any real
|
|
@@ -6322,6 +6326,55 @@ class IdentityRenderer {
|
|
|
6322
6326
|
}
|
|
6323
6327
|
this.currentView = null;
|
|
6324
6328
|
}
|
|
6329
|
+
/**
|
|
6330
|
+
* Replace the mounted view with a Google-style height morph: the flow region
|
|
6331
|
+
* animates its height from the outgoing content to the incoming content while
|
|
6332
|
+
* the new step fades + rises in (`.sv-step-enter`), so the popup reads as one
|
|
6333
|
+
* object reshaping rather than separate screens swapping. Falls back to an
|
|
6334
|
+
* instant swap when layout metrics are unavailable (jsdom, where heights read
|
|
6335
|
+
* 0) or the person prefers reduced motion.
|
|
6336
|
+
*/
|
|
6337
|
+
morphSwap(body, next) {
|
|
6338
|
+
const h0 = body.getBoundingClientRect().height;
|
|
6339
|
+
clearChildren(body);
|
|
6340
|
+
body.appendChild(next);
|
|
6341
|
+
const reduced = typeof window !== 'undefined'
|
|
6342
|
+
&& typeof window.matchMedia === 'function'
|
|
6343
|
+
&& window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
6344
|
+
const h1 = body.getBoundingClientRect().height;
|
|
6345
|
+
if (reduced || h0 < 1 || h1 < 1 || Math.abs(h1 - h0) < 1) {
|
|
6346
|
+
return; // instant swap
|
|
6347
|
+
}
|
|
6348
|
+
const restore = () => {
|
|
6349
|
+
if (this.morphTimer !== null) {
|
|
6350
|
+
clearTimeout(this.morphTimer);
|
|
6351
|
+
this.morphTimer = null;
|
|
6352
|
+
}
|
|
6353
|
+
body.removeEventListener('transitionend', onEnd);
|
|
6354
|
+
body.style.height = '';
|
|
6355
|
+
body.style.overflow = '';
|
|
6356
|
+
body.style.transition = '';
|
|
6357
|
+
body.style.boxSizing = '';
|
|
6358
|
+
};
|
|
6359
|
+
const onEnd = (event) => {
|
|
6360
|
+
// Ignore transitions bubbling up from child elements (e.g. input focus
|
|
6361
|
+
// rings); only the body's own height transition ends the morph.
|
|
6362
|
+
const propertyName = event.propertyName;
|
|
6363
|
+
if (event.target === body && propertyName === 'height') {
|
|
6364
|
+
restore();
|
|
6365
|
+
}
|
|
6366
|
+
};
|
|
6367
|
+
body.style.boxSizing = 'border-box';
|
|
6368
|
+
body.style.overflow = 'hidden';
|
|
6369
|
+
body.style.height = `${h0}px`;
|
|
6370
|
+
void body.offsetHeight; // commit the start height before transitioning
|
|
6371
|
+
body.style.transition = 'height var(--sv-dur-slow) var(--sv-ease-out)';
|
|
6372
|
+
body.style.height = `${h1}px`;
|
|
6373
|
+
body.addEventListener('transitionend', onEnd);
|
|
6374
|
+
if (this.morphTimer !== null)
|
|
6375
|
+
clearTimeout(this.morphTimer);
|
|
6376
|
+
this.morphTimer = setTimeout(restore, 550);
|
|
6377
|
+
}
|
|
6325
6378
|
createViewForState(state) {
|
|
6326
6379
|
switch (state.view) {
|
|
6327
6380
|
case 'loading':
|
|
@@ -6521,7 +6574,12 @@ class IdentityRenderer {
|
|
|
6521
6574
|
&& this.verificationState.passkey.hasPasskey === true
|
|
6522
6575
|
&& !this.verificationState.passkey.isFallbackMode
|
|
6523
6576
|
&& methods.some((m) => m.type === 'passkey')) {
|
|
6524
|
-
|
|
6577
|
+
// The person already has a passkey: now that sign-in runs in its own
|
|
6578
|
+
// top-level window, skip the intermediate "Continue with passkey" screen
|
|
6579
|
+
// and fire the WebAuthn ceremony immediately. A cancel or failure falls
|
|
6580
|
+
// back to the full method list (passkey still listed) instead of a
|
|
6581
|
+
// passkey retry screen, so the person can pick a code or SparkLink.
|
|
6582
|
+
void this.launchPasskeyVerify(true);
|
|
6525
6583
|
return;
|
|
6526
6584
|
}
|
|
6527
6585
|
if (methods.length === 1) {
|
|
@@ -6804,17 +6862,17 @@ class IdentityRenderer {
|
|
|
6804
6862
|
* loading state while the ceremony runs. window.open inside verify() fires
|
|
6805
6863
|
* synchronously (before the first await), so it stays within the gesture.
|
|
6806
6864
|
*/
|
|
6807
|
-
async launchPasskeyVerify() {
|
|
6865
|
+
async launchPasskeyVerify(fallbackToList = false) {
|
|
6808
6866
|
this.setState({ view: 'loading' });
|
|
6809
6867
|
const result = await this.passkeyHandler.verify();
|
|
6810
|
-
this.applyPasskeyResult(result, 'verify');
|
|
6868
|
+
this.applyPasskeyResult(result, 'verify', fallbackToList);
|
|
6811
6869
|
}
|
|
6812
6870
|
/**
|
|
6813
6871
|
* Apply a passkey ceremony result: complete on success, or route to the
|
|
6814
6872
|
* matching recovery state. Shared by the passkey view and the direct
|
|
6815
6873
|
* picker launch so both behave identically.
|
|
6816
6874
|
*/
|
|
6817
|
-
applyPasskeyResult(result, currentMode) {
|
|
6875
|
+
applyPasskeyResult(result, currentMode, fallbackToList = false) {
|
|
6818
6876
|
if (result.success && result.result) {
|
|
6819
6877
|
this.close();
|
|
6820
6878
|
this.safeOnSuccess(result.result);
|
|
@@ -6831,6 +6889,12 @@ class IdentityRenderer {
|
|
|
6831
6889
|
message: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
|
|
6832
6890
|
});
|
|
6833
6891
|
}
|
|
6892
|
+
else if (fallbackToList && this.passkeyFallbackMethodsAvailable()) {
|
|
6893
|
+
// Auto-launched passkey that the person cancelled or that failed: drop to
|
|
6894
|
+
// the full method list (passkey still listed) rather than a passkey-only
|
|
6895
|
+
// retry screen, so a code or SparkLink is one tap away.
|
|
6896
|
+
void this.showMethodSelect({ autoRoute: false });
|
|
6897
|
+
}
|
|
6834
6898
|
else if (result.errorType === 'not_found') {
|
|
6835
6899
|
// No passkey yet — pivot the same screen to registration.
|
|
6836
6900
|
this.setState({
|