@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/README.md
CHANGED
|
@@ -825,8 +825,8 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
825
825
|
|
|
826
826
|
## Links
|
|
827
827
|
|
|
828
|
-
- [SparkVault Documentation](https://
|
|
829
|
-
- [SDK API Reference](https://
|
|
828
|
+
- [SparkVault Documentation](https://sparkvault.com/api/docs/)
|
|
829
|
+
- [SDK API Reference](https://sparkvault.com/api/docs/sdk-js/)
|
|
830
830
|
- [GitHub Repository](https://github.com/Spark-Vault/platform)
|
|
831
831
|
- [npm Package](https://www.npmjs.com/package/@sparkvault/sdk-js)
|
|
832
832
|
- [Report Issues](https://github.com/Spark-Vault/platform/issues)
|
|
@@ -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
|
/**
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -6039,6 +6039,7 @@ class IdentityRenderer {
|
|
|
6039
6039
|
// View management
|
|
6040
6040
|
this.currentView = null;
|
|
6041
6041
|
this.focusTimeoutId = null;
|
|
6042
|
+
this.morphTimer = null;
|
|
6042
6043
|
// Post-login recommendation pipeline: the verified result to finalize with,
|
|
6043
6044
|
// and the remaining server-recommended steps to walk before finalizing.
|
|
6044
6045
|
this.postLoginResult = null;
|
|
@@ -6254,6 +6255,10 @@ class IdentityRenderer {
|
|
|
6254
6255
|
clearTimeout(this.focusTimeoutId);
|
|
6255
6256
|
this.focusTimeoutId = null;
|
|
6256
6257
|
}
|
|
6258
|
+
if (this.morphTimer !== null) {
|
|
6259
|
+
clearTimeout(this.morphTimer);
|
|
6260
|
+
this.morphTimer = null;
|
|
6261
|
+
}
|
|
6257
6262
|
this.cleanupSparkLink();
|
|
6258
6263
|
this.destroyCurrentView();
|
|
6259
6264
|
this.container.destroy();
|
|
@@ -6288,14 +6293,13 @@ class IdentityRenderer {
|
|
|
6288
6293
|
this.container.setMinimalChrome(minimalChromeViews.includes(this.viewState.view));
|
|
6289
6294
|
const view = this.createViewForState(this.viewState);
|
|
6290
6295
|
this.currentView = view;
|
|
6291
|
-
clearChildren(body);
|
|
6292
6296
|
const rendered = view.render();
|
|
6293
6297
|
// Each step enters with a calm fade + rise (see .sv-step-enter). The brand
|
|
6294
6298
|
// lockup and footer live outside `body`, so only the flow content moves.
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
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);
|
|
6299
6303
|
// Drive the top progress bar (owned by login-popup.js as
|
|
6300
6304
|
// `window.__sparkvaultProgress`) off the view: a transient `loading` view
|
|
6301
6305
|
// means a network step is in flight, so keep the bar trickling; any real
|
|
@@ -6326,6 +6330,55 @@ class IdentityRenderer {
|
|
|
6326
6330
|
}
|
|
6327
6331
|
this.currentView = null;
|
|
6328
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
|
+
}
|
|
6329
6382
|
createViewForState(state) {
|
|
6330
6383
|
switch (state.view) {
|
|
6331
6384
|
case 'loading':
|
|
@@ -6525,7 +6578,12 @@ class IdentityRenderer {
|
|
|
6525
6578
|
&& this.verificationState.passkey.hasPasskey === true
|
|
6526
6579
|
&& !this.verificationState.passkey.isFallbackMode
|
|
6527
6580
|
&& methods.some((m) => m.type === 'passkey')) {
|
|
6528
|
-
|
|
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);
|
|
6529
6587
|
return;
|
|
6530
6588
|
}
|
|
6531
6589
|
if (methods.length === 1) {
|
|
@@ -6808,17 +6866,17 @@ class IdentityRenderer {
|
|
|
6808
6866
|
* loading state while the ceremony runs. window.open inside verify() fires
|
|
6809
6867
|
* synchronously (before the first await), so it stays within the gesture.
|
|
6810
6868
|
*/
|
|
6811
|
-
async launchPasskeyVerify() {
|
|
6869
|
+
async launchPasskeyVerify(fallbackToList = false) {
|
|
6812
6870
|
this.setState({ view: 'loading' });
|
|
6813
6871
|
const result = await this.passkeyHandler.verify();
|
|
6814
|
-
this.applyPasskeyResult(result, 'verify');
|
|
6872
|
+
this.applyPasskeyResult(result, 'verify', fallbackToList);
|
|
6815
6873
|
}
|
|
6816
6874
|
/**
|
|
6817
6875
|
* Apply a passkey ceremony result: complete on success, or route to the
|
|
6818
6876
|
* matching recovery state. Shared by the passkey view and the direct
|
|
6819
6877
|
* picker launch so both behave identically.
|
|
6820
6878
|
*/
|
|
6821
|
-
applyPasskeyResult(result, currentMode) {
|
|
6879
|
+
applyPasskeyResult(result, currentMode, fallbackToList = false) {
|
|
6822
6880
|
if (result.success && result.result) {
|
|
6823
6881
|
this.close();
|
|
6824
6882
|
this.safeOnSuccess(result.result);
|
|
@@ -6835,6 +6893,12 @@ class IdentityRenderer {
|
|
|
6835
6893
|
message: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
|
|
6836
6894
|
});
|
|
6837
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
|
+
}
|
|
6838
6902
|
else if (result.errorType === 'not_found') {
|
|
6839
6903
|
// No passkey yet — pivot the same screen to registration.
|
|
6840
6904
|
this.setState({
|