@sparkvault/sdk-js 17.0.1 → 17.0.2
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 +3 -3
- package/dist/api-base.d.ts +2 -2
- package/dist/config.d.ts +1 -1
- package/dist/entropy/index.d.ts +2 -2
- package/dist/entropy/types.d.ts +1 -1
- package/dist/errors.d.ts +3 -3
- package/dist/http.d.ts +1 -1
- package/dist/index.cjs +197 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +150 -150
- package/dist/index.mjs +197 -189
- package/dist/index.mjs.map +1 -1
- package/dist/ingots/index.d.ts +10 -10
- package/dist/ingots/types.d.ts +3 -3
- package/dist/notify/index.d.ts +8 -8
- package/dist/notify/types.d.ts +10 -10
- package/dist/products/identity/api.d.ts +5 -5
- package/dist/products/identity/dialog-launcher.d.ts +2 -2
- package/dist/products/identity/handlers/otp-handler.d.ts +1 -1
- package/dist/products/identity/handlers/passkey-handler.d.ts +4 -4
- package/dist/products/identity/index.d.ts +11 -11
- package/dist/products/identity/renderer.d.ts +10 -10
- package/dist/products/identity/types.d.ts +10 -10
- package/dist/products/identity/utils.d.ts +3 -3
- package/dist/products/identity/views/backup-verify.d.ts +3 -3
- package/dist/products/identity/views/error.d.ts +1 -1
- package/dist/products/identity/views/identity-input.d.ts +1 -1
- package/dist/products/identity/views/method-select.d.ts +1 -1
- package/dist/products/identity/views/origin-not-allowed.d.ts +2 -2
- package/dist/products/identity/views/passkey-auto.d.ts +1 -1
- package/dist/products/identity/views/product-not-configured.d.ts +2 -2
- package/dist/products/identity/views/service-unavailable.d.ts +1 -1
- package/dist/products/index.d.ts +1 -1
- package/dist/products/notify/index.d.ts +21 -21
- package/dist/products/notify/types.d.ts +65 -65
- package/dist/products/structured-ingots/types.d.ts +2 -2
- package/dist/sparks/index.d.ts +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/utils/dom.d.ts +3 -3
- package/dist/vaults/index.d.ts +2 -2
- package/dist/vaults/types.d.ts +2 -2
- package/dist/vaults/upload/api.d.ts +14 -14
- package/dist/vaults/upload/renderer.d.ts +1 -1
- package/dist/vaults/upload/styles.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -88,7 +88,7 @@ function givenUpUploadId({ created, uploadId }) {
|
|
|
88
88
|
* The codes Core's activation refuses an upload with, which Forge's refusal
|
|
89
89
|
* map reads (the status is Core's):
|
|
90
90
|
* - UPLOAD_CONTRACT_MISMATCH (409): a finalize or session from another
|
|
91
|
-
* publication contract than Core's, a mixed deployment that converges
|
|
91
|
+
* publication contract than Core's, a mixed deployment that converges, so the
|
|
92
92
|
* upload is kept and its finalize tried again.
|
|
93
93
|
* - UPLOAD_PROTOCOL_RETIRED (410): a session from a contract Core no longer
|
|
94
94
|
* publishes, which never can be.
|
|
@@ -834,7 +834,7 @@ class ValidationError extends SparkVaultError {
|
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
836
|
/**
|
|
837
|
-
* Plan required gate (402 PLAN_REQUIRED)
|
|
837
|
+
* Plan required gate (402 PLAN_REQUIRED): the account has no active
|
|
838
838
|
* subscription and attempted a billable/create action. Surface a subscribe CTA
|
|
839
839
|
* to admins, or "ask your account admin" to members.
|
|
840
840
|
*/
|
|
@@ -865,7 +865,7 @@ class UsageCreditFundingReviewError extends SparkVaultError {
|
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
867
|
/**
|
|
868
|
-
* Quota exceeded gate (402 QUOTA_EXCEEDED)
|
|
868
|
+
* Quota exceeded gate (402 QUOTA_EXCEEDED): a pooled-capacity limit is
|
|
869
869
|
* exhausted. `resource` identifies which pool so callers can point the CTA at
|
|
870
870
|
* the right capacity block.
|
|
871
871
|
*/
|
|
@@ -881,7 +881,7 @@ class QuotaExceededError extends SparkVaultError {
|
|
|
881
881
|
}
|
|
882
882
|
/**
|
|
883
883
|
* Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED or
|
|
884
|
-
* NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED)
|
|
884
|
+
* NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED): the account or selected project
|
|
885
885
|
* does not hold Notify and attempted a send that names no accepted send's
|
|
886
886
|
* `sendId` (a replay of an accepted send, the same request under its `sendId`,
|
|
887
887
|
* is answered with the stored send), or a config save that selects a new
|
|
@@ -1149,8 +1149,8 @@ const SPARKVAULT_FILES_HOST = 'files.sv';
|
|
|
1149
1149
|
/**
|
|
1150
1150
|
* The help-desk domain: each organization's help desk lives at a host under
|
|
1151
1151
|
* it, and every custom help-desk domain points its CNAME at it. The whole
|
|
1152
|
-
* subtree is reserved
|
|
1153
|
-
* domain
|
|
1152
|
+
* subtree is reserved (no organization claims a name in it as its own
|
|
1153
|
+
* domain), but none of its hosts is owned: a tenant's help-desk host is never
|
|
1154
1154
|
* trusted the way a platform host is (isSparkVaultOwnedHostname).
|
|
1155
1155
|
*/
|
|
1156
1156
|
const SPARKVAULT_HELP_DESK_DOMAIN = 'help.sv';
|
|
@@ -1370,7 +1370,7 @@ class SparkVaultApi {
|
|
|
1370
1370
|
constructor(timeoutMs = DEFAULT_TIMEOUT_MS$1) {
|
|
1371
1371
|
/**
|
|
1372
1372
|
* Abort controller for the current session. Replaced by resetSession()
|
|
1373
|
-
* at the start of every user-facing session
|
|
1373
|
+
* at the start of every user-facing session, so an aborted controller can
|
|
1374
1374
|
* never leak into the next session.
|
|
1375
1375
|
*/
|
|
1376
1376
|
this.closeController = new AbortController();
|
|
@@ -1384,7 +1384,7 @@ class SparkVaultApi {
|
|
|
1384
1384
|
isAborted() {
|
|
1385
1385
|
return this.closeController.signal.aborted;
|
|
1386
1386
|
}
|
|
1387
|
-
/** The current session's abort signal
|
|
1387
|
+
/** The current session's abort signal, for callers that need to wire it into XHR/etc. */
|
|
1388
1388
|
getAbortSignal() {
|
|
1389
1389
|
return this.closeController.signal;
|
|
1390
1390
|
}
|
|
@@ -1434,7 +1434,7 @@ class SparkVaultApi {
|
|
|
1434
1434
|
* transport shares.
|
|
1435
1435
|
*/
|
|
1436
1436
|
rawRequest(url, options) {
|
|
1437
|
-
// Only send Content-Type when there's actually a body
|
|
1437
|
+
// Only send Content-Type when there's actually a body; otherwise GETs
|
|
1438
1438
|
// with no payload would carry a misleading content-type header.
|
|
1439
1439
|
const headers = { Accept: 'application/json' };
|
|
1440
1440
|
if (options.body !== undefined)
|
|
@@ -1665,7 +1665,7 @@ class HttpClient {
|
|
|
1665
1665
|
* and every other answer is the base error under the service's own code.
|
|
1666
1666
|
* Each carries the service's code (`serviceCode`), which tells apart two
|
|
1667
1667
|
* refusals that share a typed class's `code`, and the answer's `Retry-After`
|
|
1668
|
-
* (`retryAfterMs`), the floor for whoever retries it
|
|
1668
|
+
* (`retryAfterMs`), the floor for whoever retries it: the SDK's own
|
|
1669
1669
|
* transfers when the answer is a download link's mint, and the host page
|
|
1670
1670
|
* otherwise.
|
|
1671
1671
|
*/
|
|
@@ -1691,7 +1691,7 @@ class HttpClient {
|
|
|
1691
1691
|
case 403:
|
|
1692
1692
|
// A Notify send, or a config save selecting a new sending domain, refused
|
|
1693
1693
|
// because the account does not hold Notify is a billing gate, not a
|
|
1694
|
-
// credential problem
|
|
1694
|
+
// credential problem; give it its own catchable type.
|
|
1695
1695
|
if (code === 'NOTIFY_SUBSCRIPTION_REQUIRED' || code === 'NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED') {
|
|
1696
1696
|
return new NotifySubscriptionRequiredError(message, details, retryAfterMs, code);
|
|
1697
1697
|
}
|
|
@@ -2705,9 +2705,9 @@ function identityTypesParam(types) {
|
|
|
2705
2705
|
return types ? { [SIGNIN_IDENTITY_TYPES.param]: formatSigninIdentityTypes(types) } : {};
|
|
2706
2706
|
}
|
|
2707
2707
|
/**
|
|
2708
|
-
* This page as a navigation return target: origin, path, and query
|
|
2709
|
-
* carries the page's own state
|
|
2710
|
-
* destination)
|
|
2708
|
+
* This page as a navigation return target: origin, path, and query (the query
|
|
2709
|
+
* carries the page's own state, whether app routing or the sign-in page's validated
|
|
2710
|
+
* destination), without the fragment, which is the channel a result returns
|
|
2711
2711
|
* in.
|
|
2712
2712
|
*/
|
|
2713
2713
|
function currentPageReturnUrl() {
|
|
@@ -2920,7 +2920,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
2920
2920
|
}
|
|
2921
2921
|
/**
|
|
2922
2922
|
* Check whether the SVID resolved from an email or phone has registered
|
|
2923
|
-
* passkeys (`has_passkey`; cross-tenant
|
|
2923
|
+
* passkeys (`has_passkey`; cross-tenant, single global RP), for a
|
|
2924
2924
|
* verification that admits passkeys.
|
|
2925
2925
|
*/
|
|
2926
2926
|
async checkPasskey(identity, identityType = 'email', authContext) {
|
|
@@ -2929,7 +2929,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
2929
2929
|
}
|
|
2930
2930
|
/**
|
|
2931
2931
|
* Redeem a one-time sign-in code (with its PKCE verifier) for the sign-in
|
|
2932
|
-
* result
|
|
2932
|
+
* result: the shared return leg for `flow: 'redirect'` and the silent SSO
|
|
2933
2933
|
* self-heal. The code arrives in the URL fragment after the hosted page
|
|
2934
2934
|
* navigates back; it is single-use, 60s-lived, and bound to this page's
|
|
2935
2935
|
* origin server-side.
|
|
@@ -3065,7 +3065,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
3065
3065
|
}
|
|
3066
3066
|
/**
|
|
3067
3067
|
* Skip a post-login recommendation, suppressing it server-side for 30 days.
|
|
3068
|
-
* Authorized by the login's verification token. Best-effort
|
|
3068
|
+
* Authorized by the login's verification token. Best-effort: a failure here
|
|
3069
3069
|
* must not block completing the login.
|
|
3070
3070
|
*/
|
|
3071
3071
|
async dismissRecommendation(params) {
|
|
@@ -3140,7 +3140,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
3140
3140
|
});
|
|
3141
3141
|
}
|
|
3142
3142
|
/**
|
|
3143
|
-
* Claim the SparkLink click's result by kindling
|
|
3143
|
+
* Claim the SparkLink click's result by kindling, the WebSocket-loss
|
|
3144
3144
|
* fallback. The SDK calls this when its socket was suspended with the tab and
|
|
3145
3145
|
* it refocuses. Returns what the click produced (a completed login, or its
|
|
3146
3146
|
* second-factor challenge), or null while still pending (not yet clicked) or
|
|
@@ -3176,7 +3176,7 @@ function signinRefParam(signinRef) {
|
|
|
3176
3176
|
* Read a SparkLink result event. The WebSocket push and the kindling reclaim
|
|
3177
3177
|
* carry the same server-built event, so this is the one reader for both.
|
|
3178
3178
|
* Returns null for anything that is not a usable result: a still-pending
|
|
3179
|
-
* reclaim, or an event missing what its type requires
|
|
3179
|
+
* reclaim, or an event missing what its type requires, such as a challenge without a
|
|
3180
3180
|
* ticket, or a completed login with neither a token (default flow) nor the
|
|
3181
3181
|
* redirect that continues it (OIDC hosted login).
|
|
3182
3182
|
*/
|
|
@@ -3266,7 +3266,7 @@ class IdentityApiError extends SparkVaultError {
|
|
|
3266
3266
|
* script, and the invisible formatting marks a contacts app wraps a number in.
|
|
3267
3267
|
* The separators and marks are dropped. Anything else is refused, never
|
|
3268
3268
|
* dropped: stripping it would fold part of the text into the number and deliver
|
|
3269
|
-
* to someone else's line
|
|
3269
|
+
* to someone else's line. A letter or a dial-control character (',' and ';'
|
|
3270
3270
|
* pause, '#' and '*' are keypad tones) carries an extension ("x2", ",89"), a
|
|
3271
3271
|
* digit of another script ('٧', '7') is a digit the ASCII read would silently
|
|
3272
3272
|
* lose, and a '+' after a digit declares nothing.
|
|
@@ -3280,7 +3280,7 @@ class IdentityApiError extends SparkVaultError {
|
|
|
3280
3280
|
/** A '+' before any digit: the caller declared the country code. */
|
|
3281
3281
|
const DECLARED_COUNTRY_CODE = /^\D*\+/;
|
|
3282
3282
|
|
|
3283
|
-
/** E.164 digits once a country code is declared: 8
|
|
3283
|
+
/** E.164 digits once a country code is declared: 8 to 15, never a leading 0. */
|
|
3284
3284
|
const E164_DIGITS = /^[1-9]\d{7,14}$/;
|
|
3285
3285
|
|
|
3286
3286
|
/** Invisible formatting marks (bidi embeddings, zero-width characters), in any number. */
|
|
@@ -3769,12 +3769,12 @@ class VerificationState {
|
|
|
3769
3769
|
* abandoned-window backstop, and a `window.closed` poll that surfaces a manual
|
|
3770
3770
|
* close as a cancellation.
|
|
3771
3771
|
*/
|
|
3772
|
-
/** Default popup dimensions
|
|
3772
|
+
/** Default popup dimensions: a centered login/ceremony window. */
|
|
3773
3773
|
const DEFAULT_WIDTH = 480;
|
|
3774
3774
|
const DEFAULT_HEIGHT = 640;
|
|
3775
3775
|
/**
|
|
3776
3776
|
* Default timeout for popup operations: 30 minutes. This is an
|
|
3777
|
-
* abandoned-window backstop
|
|
3777
|
+
* abandoned-window backstop, never a liveness gate. A person mid-login is
|
|
3778
3778
|
* often slow for legitimate reasons (waiting out an OTP resend backoff,
|
|
3779
3779
|
* fetching their phone for a cross-device passkey, hunting for an alternative
|
|
3780
3780
|
* method), and yanking the window away from them mid-flow is far worse than
|
|
@@ -3792,7 +3792,7 @@ const CLOSED_POLL_INTERVAL_MS = 500;
|
|
|
3792
3792
|
* (host page serves `Cross-Origin-Opener-Policy: same-origin`) flips to
|
|
3793
3793
|
* `closed` on the first poll while the real window stays open in front of the
|
|
3794
3794
|
* user; a human closing a window they asked for takes longer than this. A slow
|
|
3795
|
-
* network can only delay the ready ping
|
|
3795
|
+
* network can only delay the ready ping (it never makes `closed` true), so a
|
|
3796
3796
|
* legitimate popup on a slow connection cannot trip this.
|
|
3797
3797
|
*/
|
|
3798
3798
|
const SEVERED_DETECT_WINDOW_MS = 2500;
|
|
@@ -3812,7 +3812,7 @@ class PopupLauncher {
|
|
|
3812
3812
|
return new Promise((resolve, reject) => {
|
|
3813
3813
|
const left = Math.round((window.screen.width - width) / 2);
|
|
3814
3814
|
const top = Math.round((window.screen.height - height) / 2);
|
|
3815
|
-
// Synchronous open inside the caller's user gesture
|
|
3815
|
+
// Synchronous open inside the caller's user gesture: any await before
|
|
3816
3816
|
// this point would let the browser treat the popup as programmatic and
|
|
3817
3817
|
// block it.
|
|
3818
3818
|
const popup = window.open(options.url, options.windowName, `width=${width},height=${height},left=${left},top=${top},popup=1`);
|
|
@@ -3830,7 +3830,7 @@ class PopupLauncher {
|
|
|
3830
3830
|
clearInterval(pollClosedId);
|
|
3831
3831
|
};
|
|
3832
3832
|
const handleMessage = (event) => {
|
|
3833
|
-
// Only trust the server-validated Identity origin
|
|
3833
|
+
// Only trust the server-validated Identity origin, never the broader
|
|
3834
3834
|
// sparkvault.com family (XSS or subdomain-takeover relay).
|
|
3835
3835
|
if (event.origin !== options.trustedOrigin) {
|
|
3836
3836
|
return;
|
|
@@ -3868,7 +3868,7 @@ class PopupLauncher {
|
|
|
3868
3868
|
settled = true;
|
|
3869
3869
|
cleanup();
|
|
3870
3870
|
// `closed` going true right after open, before the page ever pinged,
|
|
3871
|
-
// is a dead handle (COOP severance
|
|
3871
|
+
// is a dead handle (COOP severance; see SEVERED_DETECT_WINDOW_MS),
|
|
3872
3872
|
// not a person closing the window: the real window is still open but
|
|
3873
3873
|
// can never postMessage back, so retrying the popup can never work.
|
|
3874
3874
|
if (!readyReceived && Date.now() - openedAt <= SEVERED_DETECT_WINDOW_MS) {
|
|
@@ -3900,7 +3900,7 @@ const POPUP_WIDTH = 450;
|
|
|
3900
3900
|
const POPUP_HEIGHT = 500;
|
|
3901
3901
|
/**
|
|
3902
3902
|
* Device-level hint the Identity API sets on every completed passkey login
|
|
3903
|
-
* (products/product-identity/src/utils/passkey-hint-cookie.js
|
|
3903
|
+
* (products/product-identity/src/utils/passkey-hint-cookie.js; the cookie
|
|
3904
3904
|
* NAME is the wire contract between the two). Host-locked to the Identity
|
|
3905
3905
|
* origin and deliberately JS-readable, it means "a passkey login has completed
|
|
3906
3906
|
* in this browser", which is what licenses auto-starting the discoverable
|
|
@@ -3967,7 +3967,7 @@ class PasskeyHandler {
|
|
|
3967
3967
|
* Verify user with an existing passkey.
|
|
3968
3968
|
*
|
|
3969
3969
|
* On the Identity origin (the hosted widget / hosted login) the ceremony runs
|
|
3970
|
-
* inline
|
|
3970
|
+
* inline: same-origin with the RP id, one tap, no popup. On a third-party
|
|
3971
3971
|
* origin the rpId would not match the document, so it falls back to the popup
|
|
3972
3972
|
* served from the Identity origin. (Verification, unlike registration, is
|
|
3973
3973
|
* supported in cross-origin iframes, so the embedded widget uses the inline
|
|
@@ -3981,7 +3981,7 @@ class PasskeyHandler {
|
|
|
3981
3981
|
}
|
|
3982
3982
|
/**
|
|
3983
3983
|
* True when the SDK is running ON the Identity origin and the browser exposes
|
|
3984
|
-
* WebAuthn
|
|
3984
|
+
* WebAuthn, the only place an inline ceremony's rpId matches the document.
|
|
3985
3985
|
*/
|
|
3986
3986
|
canRunCeremonyInline() {
|
|
3987
3987
|
return typeof window !== 'undefined'
|
|
@@ -3992,8 +3992,8 @@ class PasskeyHandler {
|
|
|
3992
3992
|
/**
|
|
3993
3993
|
* True when the discoverable ceremony may be fired WITHOUT a user gesture:
|
|
3994
3994
|
* the flow is running on the Identity origin (the inline ceremony needs no
|
|
3995
|
-
* popup, so no gesture) AND this browser carries the passkey-hint cookie
|
|
3996
|
-
* a passkey login has completed here before. First visits never see an
|
|
3995
|
+
* popup, so no gesture) AND this browser carries the passkey-hint cookie
|
|
3996
|
+
* (a passkey login has completed here before). First visits never see an
|
|
3997
3997
|
* unprompted system sheet.
|
|
3998
3998
|
*/
|
|
3999
3999
|
canAutoVerify() {
|
|
@@ -4331,7 +4331,7 @@ class OtpHandler {
|
|
|
4331
4331
|
signinRef: this.state.signinRef,
|
|
4332
4332
|
});
|
|
4333
4333
|
// Primary factor accepted, but the account requires a second factor.
|
|
4334
|
-
// Not a success and not a retry
|
|
4334
|
+
// Not a success and not a retry: hand the ticket up to drive the 2FA step.
|
|
4335
4335
|
if (response.second_factor_required && response.ticket) {
|
|
4336
4336
|
return {
|
|
4337
4337
|
success: false,
|
|
@@ -4866,7 +4866,7 @@ function methodIconGlyph(iconName) {
|
|
|
4866
4866
|
case 'users':
|
|
4867
4867
|
return createUsersIcon();
|
|
4868
4868
|
default:
|
|
4869
|
-
// Neutral placeholder
|
|
4869
|
+
// Neutral placeholder, deliberately NOT the email envelope, so an
|
|
4870
4870
|
// unmapped icon name surfaces the gap instead of impersonating email.
|
|
4871
4871
|
return createGenericMethodIcon();
|
|
4872
4872
|
}
|
|
@@ -4882,7 +4882,7 @@ function createEmailIcon() {
|
|
|
4882
4882
|
return svg;
|
|
4883
4883
|
}
|
|
4884
4884
|
function createSmsIcon() {
|
|
4885
|
-
// Chat bubble
|
|
4885
|
+
// Chat bubble: the text-message channel, distinct from the voice-call
|
|
4886
4886
|
// handset (createPhoneIcon) so SMS and voice OTP read differently.
|
|
4887
4887
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
4888
4888
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -4905,7 +4905,7 @@ function createPhoneIcon() {
|
|
|
4905
4905
|
return svg;
|
|
4906
4906
|
}
|
|
4907
4907
|
function createGenericMethodIcon() {
|
|
4908
|
-
// Neutral rounded badge with a center dot
|
|
4908
|
+
// Neutral rounded badge with a center dot: a placeholder for an unmapped
|
|
4909
4909
|
// icon name, deliberately unlike any real method glyph.
|
|
4910
4910
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
4911
4911
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -6077,7 +6077,7 @@ class PasskeyView {
|
|
|
6077
6077
|
*
|
|
6078
6078
|
* Shown behind the browser's passkey sheet while an auto-started discoverable
|
|
6079
6079
|
* ceremony runs (returning browsers carrying the passkey-hint cookie). The
|
|
6080
|
-
* ceremony was fired without a click, so this screen has no action button
|
|
6080
|
+
* ceremony was fired without a click, so this screen has no action button,
|
|
6081
6081
|
* only a live status and an escape hatch to the identifier form for anyone
|
|
6082
6082
|
* who wants a different method (or whose sheet hangs).
|
|
6083
6083
|
*/
|
|
@@ -6202,7 +6202,7 @@ class PasskeyPromptView {
|
|
|
6202
6202
|
* Includes a "Not now" skip that suppresses this method's prompt for 30 days
|
|
6203
6203
|
* (handled by the renderer).
|
|
6204
6204
|
*
|
|
6205
|
-
* Sibling of PasskeyPromptView
|
|
6205
|
+
* Sibling of PasskeyPromptView: same low-friction, skippable shape.
|
|
6206
6206
|
*/
|
|
6207
6207
|
class BackupVerifyView {
|
|
6208
6208
|
constructor(props) {
|
|
@@ -6526,7 +6526,7 @@ class SparkLinkWaitingView {
|
|
|
6526
6526
|
* Professional enterprise-quality error display with clear visual hierarchy.
|
|
6527
6527
|
*/
|
|
6528
6528
|
/**
|
|
6529
|
-
* Error codes that mean the site owner's Identity access is blocked
|
|
6529
|
+
* Error codes that mean the site owner's Identity access is blocked: the
|
|
6530
6530
|
* free trial was exhausted or expired, or a paid plan hit its capacity wall.
|
|
6531
6531
|
* The end user can do nothing about these, so the ErrorView renders a friendly,
|
|
6532
6532
|
* non-leaky interstitial (no "Try Again", no debug code badge) exactly like
|
|
@@ -6643,7 +6643,7 @@ class ErrorView {
|
|
|
6643
6643
|
contentSection.appendChild(title);
|
|
6644
6644
|
contentSection.appendChild(message);
|
|
6645
6645
|
if (isGenuine) {
|
|
6646
|
-
// Error code badge
|
|
6646
|
+
// Error code badge, useful for debugging genuine errors only.
|
|
6647
6647
|
const codeBadge = document.createElement('div');
|
|
6648
6648
|
codeBadge.className = 'sv-error-code-badge';
|
|
6649
6649
|
const codeLabel = document.createElement('span');
|
|
@@ -6754,7 +6754,7 @@ function withAlpha(hex, alpha) {
|
|
|
6754
6754
|
* Service Unavailable View
|
|
6755
6755
|
*
|
|
6756
6756
|
* Shown when the identity config endpoint is unreachable.
|
|
6757
|
-
* Clean, professional, branded
|
|
6757
|
+
* Clean, professional, branded, with no error codes or technical jargon.
|
|
6758
6758
|
*/
|
|
6759
6759
|
function createShieldIcon() {
|
|
6760
6760
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
@@ -6853,8 +6853,8 @@ class ServiceUnavailableView {
|
|
|
6853
6853
|
*
|
|
6854
6854
|
* Full-dialog terminal screen shown when the SparkVault Identity Product has
|
|
6855
6855
|
* not been configured for the account that the JS SDK is configured against. The
|
|
6856
|
-
* audience is the website owner / developer
|
|
6857
|
-
* surface, not an end-user error
|
|
6856
|
+
* audience is the website owner / developer: this is a misconfiguration
|
|
6857
|
+
* surface, not an end-user error, so the dialog drops customer branding and
|
|
6858
6858
|
* presents itself as an unmistakable SparkVault notice.
|
|
6859
6859
|
*/
|
|
6860
6860
|
const ACTIVATION_URL = 'https://app.sparkvault.com/products/identity';
|
|
@@ -7019,8 +7019,8 @@ class ProductNotConfiguredView {
|
|
|
7019
7019
|
*
|
|
7020
7020
|
* Full-dialog terminal screen shown when the embedding site's origin is not in
|
|
7021
7021
|
* the account's verified-domains allowlist. The audience is the website owner /
|
|
7022
|
-
* developer
|
|
7023
|
-
* is permanent (retrying never clears an origin block)
|
|
7022
|
+
* developer: this is a misconfiguration surface, not an end-user error, and it
|
|
7023
|
+
* is permanent (retrying never clears an origin block), so the dialog drops
|
|
7024
7024
|
* customer branding, offers no "Try Again", names the blocked origin, and
|
|
7025
7025
|
* points to the place that fixes it. Reuses the SparkVault-notice styling from
|
|
7026
7026
|
* the product-not-configured view.
|
|
@@ -7043,7 +7043,7 @@ function createBadge() {
|
|
|
7043
7043
|
surface.setAttribute('stroke', DS.slate200);
|
|
7044
7044
|
surface.setAttribute('stroke-width', '1');
|
|
7045
7045
|
svg.appendChild(surface);
|
|
7046
|
-
// Globe with a slash
|
|
7046
|
+
// Globe with a slash: an unrecognized domain.
|
|
7047
7047
|
const globe = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
7048
7048
|
globe.setAttribute('cx', '32');
|
|
7049
7049
|
globe.setAttribute('cy', '32');
|
|
@@ -7146,7 +7146,7 @@ class OriginNotAllowedView {
|
|
|
7146
7146
|
ownerLabel.textContent = 'Are you the site owner?';
|
|
7147
7147
|
const ownerHint = document.createElement('span');
|
|
7148
7148
|
ownerHint.className = 'sv-not-activated-owner-hint';
|
|
7149
|
-
// textContent (not innerHTML)
|
|
7149
|
+
// textContent (not innerHTML): the origin is server-reported but we never
|
|
7150
7150
|
// trust it into the DOM as markup.
|
|
7151
7151
|
ownerHint.textContent = this.props.origin
|
|
7152
7152
|
? `Add ${this.props.origin} to your verified domains in SparkVault, then reload this page.`
|
|
@@ -7240,7 +7240,7 @@ function progressHook() {
|
|
|
7240
7240
|
function progressStart() { progressHook()?.start(); }
|
|
7241
7241
|
function progressDone() { progressHook()?.done(); }
|
|
7242
7242
|
/**
|
|
7243
|
-
* End-user copy for a blocked Identity. Intentionally non-leaky
|
|
7243
|
+
* End-user copy for a blocked Identity. Intentionally non-leaky: it never names
|
|
7244
7244
|
* the trial, billing, usage, or any owner-facing internal. When the site's
|
|
7245
7245
|
* company name is known it is surfaced so the screen reads as the site's own and
|
|
7246
7246
|
* the visitor is pointed back to the site for help (never to SparkVault). The
|
|
@@ -7345,7 +7345,7 @@ class IdentityRenderer {
|
|
|
7345
7345
|
* Seed the verification identity from the render options, deriving the
|
|
7346
7346
|
* channel (email vs phone) from the value itself rather than trusting which
|
|
7347
7347
|
* option field carried it. The hosted login forwards a simple-mode identity
|
|
7348
|
-
* hint
|
|
7348
|
+
* hint (which may be a phone number) as `email`; keying off the value keeps
|
|
7349
7349
|
* the method list AND the OTP delivery target aligned with the real channel
|
|
7350
7350
|
* instead of falling back to the email methods. Normalizes to E.164 /
|
|
7351
7351
|
* lowercased email so the code goes to the canonical identifier.
|
|
@@ -7371,7 +7371,7 @@ class IdentityRenderer {
|
|
|
7371
7371
|
}
|
|
7372
7372
|
/**
|
|
7373
7373
|
* True when the identifier is fixed by the flow and the person must prove
|
|
7374
|
-
* that exact identity
|
|
7374
|
+
* that exact identity: the invite / simple-redirect case. There is no
|
|
7375
7375
|
* identifier-entry step to return to, so the picker must not offer a
|
|
7376
7376
|
* "change identity" back link that would let them verify a different
|
|
7377
7377
|
* identifier than the one they were invited as.
|
|
@@ -7418,7 +7418,7 @@ class IdentityRenderer {
|
|
|
7418
7418
|
if (this.api.isConfigPreloaded()) {
|
|
7419
7419
|
// Config fetch already started - race it against a 50ms timeout
|
|
7420
7420
|
// If config is ready (or almost ready), we skip the loading flash.
|
|
7421
|
-
// A rejected preload (e.g. product_not_configured) must not abort start()
|
|
7421
|
+
// A rejected preload (e.g. product_not_configured) must not abort start():
|
|
7422
7422
|
// swallow here and let the in-modal try/catch below route to the
|
|
7423
7423
|
// correct error view.
|
|
7424
7424
|
const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(null), 50));
|
|
@@ -7467,8 +7467,8 @@ class IdentityRenderer {
|
|
|
7467
7467
|
* would otherwise escape. In the default embedded/dialog mode that escape is
|
|
7468
7468
|
* exactly the "closes silently" failure: the host's `onError` runs, the
|
|
7469
7469
|
* embedding page tears the iframe down, and the user is left with no message.
|
|
7470
|
-
* Render the error in the SparkVault dialog
|
|
7471
|
-
* in-flow error already behaves
|
|
7470
|
+
* Render the error in the SparkVault dialog, consistent with how every
|
|
7471
|
+
* in-flow error already behaves, so the dialog stays open and the user can
|
|
7472
7472
|
* retry or close it (→ onCancel).
|
|
7473
7473
|
*/
|
|
7474
7474
|
showStartupError(error) {
|
|
@@ -7482,7 +7482,7 @@ class IdentityRenderer {
|
|
|
7482
7482
|
* Map a config-fetch error to the appropriate terminal view.
|
|
7483
7483
|
*
|
|
7484
7484
|
* Two failures are permanent developer-misconfigurations, not transient
|
|
7485
|
-
* outages, so they get dedicated terminal screens (no "Try Again"
|
|
7485
|
+
* outages, so they get dedicated terminal screens (no "Try Again", since retrying
|
|
7486
7486
|
* can never clear them) instead of the generic service-unavailable view:
|
|
7487
7487
|
* - `product_not_configured`: the account has not configured Identity.
|
|
7488
7488
|
* - `ORIGIN_NOT_ALLOWED`: this site's domain is not on the account's
|
|
@@ -7751,7 +7751,7 @@ class IdentityRenderer {
|
|
|
7751
7751
|
}
|
|
7752
7752
|
// Returning browser on the Identity origin (passkey-hint cookie present):
|
|
7753
7753
|
// auto-start the discoverable ceremony instead of asking for an identifier
|
|
7754
|
-
//
|
|
7754
|
+
// (the Google-style one-touch return). A cancel lands on the identifier
|
|
7755
7755
|
// form, which keeps a "Sign in with a passkey" way back in. A provider
|
|
7756
7756
|
// that starts on its own once the pending reference lands goes first, as
|
|
7757
7757
|
// with the reference held (startWithFederation), so the identifier form
|
|
@@ -7780,7 +7780,7 @@ class IdentityRenderer {
|
|
|
7780
7780
|
* Fired on open for returning browsers and from the identifier form's
|
|
7781
7781
|
* "Sign in with a passkey" shortcut. Anything short of a terminal outcome
|
|
7782
7782
|
* (dismissed sheet, no credential on the device, transient failure) falls
|
|
7783
|
-
* back to the identifier form with no error banner
|
|
7783
|
+
* back to the identifier form with no error banner: the person simply
|
|
7784
7784
|
* lands where a first-time visitor starts.
|
|
7785
7785
|
*/
|
|
7786
7786
|
async launchDiscoverableVerify() {
|
|
@@ -8085,7 +8085,7 @@ class IdentityRenderer {
|
|
|
8085
8085
|
// Leaving the SparkLink waiting view (e.g. "Choose another method") must
|
|
8086
8086
|
// tear down its WebSocket + refocus listeners and clear the kindling, or a
|
|
8087
8087
|
// later tab refocus would fire a stale claim for an abandoned flow.
|
|
8088
|
-
// Idempotent
|
|
8088
|
+
// Idempotent: a no-op when SparkLink was never armed.
|
|
8089
8089
|
this.cleanupSparkLink();
|
|
8090
8090
|
const autoRoute = options.autoRoute !== false;
|
|
8091
8091
|
if (!this.sdkConfig)
|
|
@@ -8150,7 +8150,7 @@ class IdentityRenderer {
|
|
|
8150
8150
|
}
|
|
8151
8151
|
// When a passkey is already registered for this identifier, jump
|
|
8152
8152
|
// straight to the WebAuthn ceremony instead of asking the user to
|
|
8153
|
-
// pick a method
|
|
8153
|
+
// pick a method: it is the safest, fastest option. The back arrow on
|
|
8154
8154
|
// the passkey view re-enters this method with autoRoute=false so the
|
|
8155
8155
|
// user lands on the full picker (passkey still listed) and can pick
|
|
8156
8156
|
// a code or SparkLink instead. A provider that starts on its own once the
|
|
@@ -8184,7 +8184,7 @@ class IdentityRenderer {
|
|
|
8184
8184
|
// - a list the provider is missing from only while the page's ask for the
|
|
8185
8185
|
// sign-in's reference is out (federationAwaitingReference): with the
|
|
8186
8186
|
// reference held the provider leads it, so it is never one method.
|
|
8187
|
-
// (Passkey auto-route above still applies
|
|
8187
|
+
// (Passkey auto-route above still applies: a biometric prompt costs
|
|
8188
8188
|
// nothing and can be dismissed.)
|
|
8189
8189
|
const sendsToSuppliedPhone = this.identityPrefilled && methods[0].identityType === 'phone';
|
|
8190
8190
|
const heldFederation = methods[0].type === 'federation' && !this.federationMayAutoStart;
|
|
@@ -8289,7 +8289,7 @@ class IdentityRenderer {
|
|
|
8289
8289
|
}
|
|
8290
8290
|
handleIdentitySubmit(result) {
|
|
8291
8291
|
this.verificationState.setIdentity(result.value, result.type);
|
|
8292
|
-
// The person typed this identifier, so it is theirs to change
|
|
8292
|
+
// The person typed this identifier, so it is theirs to change: a no-hint
|
|
8293
8293
|
// simple-mode session must keep the back link + single-method auto-proceed.
|
|
8294
8294
|
this.identityPrefilled = false;
|
|
8295
8295
|
this.showMethodSelect();
|
|
@@ -8385,7 +8385,7 @@ class IdentityRenderer {
|
|
|
8385
8385
|
if (!result.success) {
|
|
8386
8386
|
this.cleanupSparkLink();
|
|
8387
8387
|
// A blocked Identity (trial exhausted/expired, paid capacity) is
|
|
8388
|
-
// terminal
|
|
8388
|
+
// terminal: show the "sign-in unavailable" interstitial, not a
|
|
8389
8389
|
// retryable "Try Again" that invites retrying a permanently-blocked
|
|
8390
8390
|
// login. Mirrors the otp send path.
|
|
8391
8391
|
if (this.renderBlockedInterstitial(result.errorCode))
|
|
@@ -8473,7 +8473,7 @@ class IdentityRenderer {
|
|
|
8473
8473
|
else if (this.renderBlockedInterstitial(result.errorCode)) ;
|
|
8474
8474
|
else if (this.renderIdentityTypeRefusal(result.errorCode, result.error)) ;
|
|
8475
8475
|
else if (result.errorCode === 'identity_locked') {
|
|
8476
|
-
// The identity is locked down
|
|
8476
|
+
// The identity is locked down: a dedicated, actionable state, not a
|
|
8477
8477
|
// generic "invalid code" retry. The person must manage it at auth.sv.
|
|
8478
8478
|
this.setState({
|
|
8479
8479
|
view: 'error',
|
|
@@ -8544,7 +8544,7 @@ class IdentityRenderer {
|
|
|
8544
8544
|
if (error instanceof IdentityApiError && this.renderIdentityTypeRefusal(error.code, message))
|
|
8545
8545
|
return;
|
|
8546
8546
|
// The login ticket is not consumed on a wrong code, so the user can retry
|
|
8547
|
-
// against the same ticket
|
|
8547
|
+
// against the same ticket: re-render the view carrying the error.
|
|
8548
8548
|
this.setState({ view: 'two-factor', ticket, methods, error: message });
|
|
8549
8549
|
}
|
|
8550
8550
|
}
|
|
@@ -8601,14 +8601,14 @@ class IdentityRenderer {
|
|
|
8601
8601
|
return true;
|
|
8602
8602
|
}
|
|
8603
8603
|
if (this.renderBlockedInterstitial(result.errorCode)) {
|
|
8604
|
-
// Terminal interstitial already rendered
|
|
8604
|
+
// Terminal interstitial already rendered: the owner must subscribe.
|
|
8605
8605
|
return true;
|
|
8606
8606
|
}
|
|
8607
8607
|
if (this.renderIdentityTypeRefusal(result.errorCode, result.error)) {
|
|
8608
8608
|
return true;
|
|
8609
8609
|
}
|
|
8610
8610
|
if (result.errorCode === 'identity_locked') {
|
|
8611
|
-
// Dedicated state
|
|
8611
|
+
// Dedicated state: retrying cannot unlock the identity.
|
|
8612
8612
|
this.setState({
|
|
8613
8613
|
view: 'error',
|
|
8614
8614
|
code: 'identity_locked',
|
|
@@ -8632,7 +8632,7 @@ class IdentityRenderer {
|
|
|
8632
8632
|
void this.showMethodSelect({ autoRoute: false });
|
|
8633
8633
|
}
|
|
8634
8634
|
else if (result.errorType === 'not_found') {
|
|
8635
|
-
// No passkey yet
|
|
8635
|
+
// No passkey yet: pivot the same screen to registration.
|
|
8636
8636
|
this.setState({
|
|
8637
8637
|
view: 'passkey',
|
|
8638
8638
|
recipient: this.recipient,
|
|
@@ -8686,7 +8686,7 @@ class IdentityRenderer {
|
|
|
8686
8686
|
}
|
|
8687
8687
|
/**
|
|
8688
8688
|
* Leave for the social provider. The renderer runs on the Identity origin's
|
|
8689
|
-
* sign-in page, and the round trip returns to that same page
|
|
8689
|
+
* sign-in page, and the round trip returns to that same page, query intact,
|
|
8690
8690
|
* because the query carries the destination the page was opened for (the
|
|
8691
8691
|
* popup's `origin`, or the redirect mode's handoff parameters), which the
|
|
8692
8692
|
* page re-gates before releasing the result. The state stored here is what
|
|
@@ -8853,7 +8853,7 @@ class IdentityRenderer {
|
|
|
8853
8853
|
* The server returns an ordered `recommendations` list (passkey upsell,
|
|
8854
8854
|
* backup verification, …); this walks it, rendering the step views the SDK
|
|
8855
8855
|
* supports and finalizing when the queue drains. A redirect target skips the
|
|
8856
|
-
* pipeline. A future nudge is one new recommendation type + view case
|
|
8856
|
+
* pipeline. A future nudge is one new recommendation type + view case, no
|
|
8857
8857
|
* primary-login handler changes.
|
|
8858
8858
|
*/
|
|
8859
8859
|
runPostLogin(result) {
|
|
@@ -8886,7 +8886,7 @@ class IdentityRenderer {
|
|
|
8886
8886
|
this.setState({ view: 'backup-verify', missingType: next.missingType, pendingResult: result });
|
|
8887
8887
|
}
|
|
8888
8888
|
else {
|
|
8889
|
-
// A recommendation type this SDK build does not render
|
|
8889
|
+
// A recommendation type this SDK build does not render: skip it.
|
|
8890
8890
|
this.advancePostLogin();
|
|
8891
8891
|
}
|
|
8892
8892
|
}
|
|
@@ -9037,7 +9037,7 @@ class IdentityRenderer {
|
|
|
9037
9037
|
// Directly trigger passkey registration
|
|
9038
9038
|
const result = await this.passkeyHandler.register(pendingResult.token);
|
|
9039
9039
|
if (result.success && result.result) {
|
|
9040
|
-
// Passkey created
|
|
9040
|
+
// Passkey created: adopt its fresh token/session as the result to
|
|
9041
9041
|
// finalize with (and to authorize any later backup-attach step), then
|
|
9042
9042
|
// advance to the next recommendation.
|
|
9043
9043
|
this.postLoginResult = result.result;
|
|
@@ -9175,7 +9175,7 @@ class IdentityRenderer {
|
|
|
9175
9175
|
case 'sparklink_verified':
|
|
9176
9176
|
case 'sparklink_second_factor': {
|
|
9177
9177
|
const outcome = parseSparkLinkEvent(data);
|
|
9178
|
-
// A result the sign-in cannot use
|
|
9178
|
+
// A result the sign-in cannot use (e.g. "verified" with no token)
|
|
9179
9179
|
// can never complete it; say so rather than report a hollow success.
|
|
9180
9180
|
if (!outcome) {
|
|
9181
9181
|
this.failSparkLink();
|
|
@@ -9189,7 +9189,7 @@ class IdentityRenderer {
|
|
|
9189
9189
|
this.failSparkLink();
|
|
9190
9190
|
break;
|
|
9191
9191
|
case 'sparklink_resent':
|
|
9192
|
-
// Server auto-resent a new link
|
|
9192
|
+
// Server auto-resent a new link: update countdown timer
|
|
9193
9193
|
if (typeof data.expiresAt === 'number') {
|
|
9194
9194
|
this.setState({
|
|
9195
9195
|
view: 'sparklink-waiting',
|
|
@@ -9210,7 +9210,7 @@ class IdentityRenderer {
|
|
|
9210
9210
|
*
|
|
9211
9211
|
* A completed login runs the post-login pipeline, which hands the host the
|
|
9212
9212
|
* full result (including any redirect URL) before attempting top-level
|
|
9213
|
-
* navigation
|
|
9213
|
+
* navigation: the host page is the source of truth for what happens next;
|
|
9214
9214
|
* the SDK's window.location.href call is a fallback for hosts that delegate
|
|
9215
9215
|
* navigation entirely to the SDK. A login held at the second-factor gate
|
|
9216
9216
|
* opens the two-factor view, exactly as after an emailed code.
|
|
@@ -9253,7 +9253,7 @@ class IdentityRenderer {
|
|
|
9253
9253
|
* is suspended (mobile: the user leaves to the mail app). On refocus, if the
|
|
9254
9254
|
* socket is no longer open, reclaim the click's result once by kindling. A
|
|
9255
9255
|
* single ~2s retry covers returning before the server finished writing it.
|
|
9256
|
-
* Deliberately NOT a polling loop
|
|
9256
|
+
* Deliberately NOT a polling loop: it fires only on refocus, and only when
|
|
9257
9257
|
* the socket is actually gone.
|
|
9258
9258
|
*/
|
|
9259
9259
|
armSparkLinkRefocusClaim() {
|
|
@@ -9297,7 +9297,7 @@ class IdentityRenderer {
|
|
|
9297
9297
|
this.applySparkLinkOutcome(outcome);
|
|
9298
9298
|
return;
|
|
9299
9299
|
}
|
|
9300
|
-
// Pending
|
|
9300
|
+
// Pending: the click may still be processing server-side. One short retry,
|
|
9301
9301
|
// then stop. No ongoing polling. Tracked so cleanup can cancel it.
|
|
9302
9302
|
if (allowRetry && this.sparkLinkKindling === kindling) {
|
|
9303
9303
|
this.sparkLinkRetryTimer = setTimeout(() => {
|
|
@@ -9515,9 +9515,9 @@ function getStyles(options) {
|
|
|
9515
9515
|
textSecondary: isDark ? DS.darkTextMuted : DS.slate600,
|
|
9516
9516
|
textMuted: isDark ? withAlpha(DS.white, 0.45) : DS.slate500,
|
|
9517
9517
|
textOnPrimary: DS.white,
|
|
9518
|
-
// Focus
|
|
9518
|
+
// Focus, a two-tone ring: inner surface gap + accent-derived outer ring.
|
|
9519
9519
|
focusRing: `0 0 0 2px ${surface}, 0 0 0 4px ${focusRingColor}`,
|
|
9520
|
-
// Shadows
|
|
9520
|
+
// Shadows, DS-weight: lean on hairlines, keep elevation subtle.
|
|
9521
9521
|
shadowSm: isDark
|
|
9522
9522
|
? '0 1px 2px rgba(0, 0, 0, 0.4)'
|
|
9523
9523
|
: DS.shadowSm,
|
|
@@ -11559,7 +11559,7 @@ class DialogLauncher {
|
|
|
11559
11559
|
return;
|
|
11560
11560
|
}
|
|
11561
11561
|
if (message.error === 'cancelled') {
|
|
11562
|
-
// The person explicitly backed out inside the popup
|
|
11562
|
+
// The person explicitly backed out inside the popup: end the flow rather
|
|
11563
11563
|
// than offer to reopen to the same place.
|
|
11564
11564
|
this.finishCancel();
|
|
11565
11565
|
return;
|
|
@@ -11572,7 +11572,7 @@ class DialogLauncher {
|
|
|
11572
11572
|
return;
|
|
11573
11573
|
// Severed handle (COOP: same-origin on the host page): the popup is open in
|
|
11574
11574
|
// front of the person and working, but postMessage can never deliver and a
|
|
11575
|
-
// retry popup severs identically
|
|
11575
|
+
// retry popup severs identically. The ONLY flow that can complete is the
|
|
11576
11576
|
// redirect flow, so switch to it. When the owner can't arm the redirect
|
|
11577
11577
|
// return leg it resolves false and we degrade to the retry alert.
|
|
11578
11578
|
if (error instanceof PopupSeveredError && this.callbacks.onPopupSevered) {
|
|
@@ -11860,14 +11860,14 @@ function onBodyReady(callback) {
|
|
|
11860
11860
|
}
|
|
11861
11861
|
}
|
|
11862
11862
|
/**
|
|
11863
|
-
* Attach a click handler to every element matching `selector
|
|
11863
|
+
* Attach a click handler to every element matching `selector`: both elements
|
|
11864
11864
|
* present once the DOM is ready and elements added later (observed via
|
|
11865
11865
|
* MutationObserver).
|
|
11866
11866
|
*
|
|
11867
11867
|
* Each call is fully self-contained: the element bookkeeping lives in this
|
|
11868
11868
|
* closure, so the returned cleanup removes only the listeners this call
|
|
11869
|
-
* registered. Multiple attachments
|
|
11870
|
-
* element attached twice
|
|
11869
|
+
* registered. Multiple attachments (different selectors, or even the same
|
|
11870
|
+
* element attached twice) never interfere with one another.
|
|
11871
11871
|
*
|
|
11872
11872
|
* @param selector - CSS selector for elements to attach to
|
|
11873
11873
|
* @param onClick - Click handler to register on every matching element
|
|
@@ -12147,7 +12147,7 @@ const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
|
|
|
12147
12147
|
// algorithm-confused token cannot masquerade as valid.
|
|
12148
12148
|
const ACCEPTED_TOKEN_ALGS = ['EdDSA', 'RS256'];
|
|
12149
12149
|
/**
|
|
12150
|
-
* Whether `handleRedirectResult()` has anything to do on this load
|
|
12150
|
+
* Whether `handleRedirectResult()` has anything to do on this load: a returned
|
|
12151
12151
|
* sign-in fragment to consume, or a pending sign-in to self-heal. Public + side
|
|
12152
12152
|
* effect-free (peeks, never consumes) so a host that defers SDK init for
|
|
12153
12153
|
* performance can cheaply decide whether to boot the SDK on a given page load,
|
|
@@ -12226,7 +12226,7 @@ class IdentityModule {
|
|
|
12226
12226
|
ensurePreconnect(config.identityBaseUrl);
|
|
12227
12227
|
}
|
|
12228
12228
|
/**
|
|
12229
|
-
* Build a deep link into the person's auth.sv Identity portal
|
|
12229
|
+
* Build a deep link into the person's auth.sv Identity portal, where they
|
|
12230
12230
|
* manage their verified identity, passkeys, sessions, and connected sites
|
|
12231
12231
|
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
12232
12232
|
* self-serve;
|
|
@@ -12268,7 +12268,7 @@ class IdentityModule {
|
|
|
12268
12268
|
* SSO hub session on the Identity origin),
|
|
12269
12269
|
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
12270
12270
|
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
12271
|
-
* with FedCM support
|
|
12271
|
+
* with FedCM support: callers should feature-detect with
|
|
12272
12272
|
* `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
|
|
12273
12273
|
*
|
|
12274
12274
|
* @returns the verified result, or `null` when the browser has no FedCM
|
|
@@ -12300,7 +12300,7 @@ class IdentityModule {
|
|
|
12300
12300
|
}
|
|
12301
12301
|
const nonce = options.nonce ?? (await this.api.drawAuthorizationValues()).nonce;
|
|
12302
12302
|
// The FedCM IdP is the IDENTITY origin (where sign-in runs and the SSO hub
|
|
12303
|
-
// cookie lives)
|
|
12303
|
+
// cookie lives), not the auth.sv portal. The config, its endpoints, and
|
|
12304
12304
|
// the credentialed accounts fetch must all be same-origin with that cookie.
|
|
12305
12305
|
const configURL = `${this.config.identityBaseUrl}/${this.config.accountId}/fedcm/config.json`;
|
|
12306
12306
|
// A restriction rides the provider's `params`, which the browser hands the
|
|
@@ -12359,7 +12359,7 @@ class IdentityModule {
|
|
|
12359
12359
|
* This is the single programmatic entry point; `attach()` binds it to element
|
|
12360
12360
|
* clicks. The popup runs the flow top-level on the Identity origin (so
|
|
12361
12361
|
* login's `__Host-` hub cookie is a first-party write and cross-domain SSO
|
|
12362
|
-
* works) and posts the result back
|
|
12362
|
+
* works) and posts the result back; the promise resolves with it.
|
|
12363
12363
|
*
|
|
12364
12364
|
* Resilience: pair this with `handleRedirectResult()` on page load. If the
|
|
12365
12365
|
* popup's result is ever lost (a mobile browser discards the backgrounded
|
|
@@ -12419,7 +12419,7 @@ class IdentityModule {
|
|
|
12419
12419
|
backdropBlur: options.backdropBlur ?? this.config.backdropBlur,
|
|
12420
12420
|
};
|
|
12421
12421
|
// Inline rendering (target) and explicit local mode run the flow in this
|
|
12422
|
-
// document
|
|
12422
|
+
// document: that is how the SparkVault-hosted sign-in page itself runs
|
|
12423
12423
|
// the flow. Otherwise sign-in leaves this page: a top-level redirect to
|
|
12424
12424
|
// the sign-in page on the Identity origin (so login's first-party SSO
|
|
12425
12425
|
// cookie persists), returning via handleRedirectResult().
|
|
@@ -12598,8 +12598,8 @@ class IdentityModule {
|
|
|
12598
12598
|
throw new ValidationError('Invalid token header');
|
|
12599
12599
|
}
|
|
12600
12600
|
// Accept exactly the algorithms the Identity server signs with; reject
|
|
12601
|
-
// everything else
|
|
12602
|
-
// token, or an absent alg
|
|
12601
|
+
// everything else: `none` (unsigned), a symmetric or algorithm-confused
|
|
12602
|
+
// token, or an absent alg, none of which could pass the server-side JWKS
|
|
12603
12603
|
// verification the host performs before trusting the token.
|
|
12604
12604
|
const alg = header.alg;
|
|
12605
12605
|
if (typeof alg !== 'string' || !ACCEPTED_TOKEN_ALGS.includes(alg)) {
|
|
@@ -12623,17 +12623,17 @@ class IdentityModule {
|
|
|
12623
12623
|
return payload;
|
|
12624
12624
|
}
|
|
12625
12625
|
/**
|
|
12626
|
-
* Complete a sign-in on page load
|
|
12626
|
+
* Complete a sign-in on page load: the return leg of `signIn()`. Call once
|
|
12627
12627
|
* on every page load; it resolves `null` when there is nothing to do.
|
|
12628
12628
|
*
|
|
12629
12629
|
* It handles two cases:
|
|
12630
|
-
* 1. A one-time code is in the URL fragment (`#sv_code=…`)
|
|
12630
|
+
* 1. A one-time code is in the URL fragment (`#sv_code=…`): the popup's
|
|
12631
12631
|
* result was lost and self-heal navigated here, or `flow: 'redirect'`
|
|
12632
12632
|
* returned. Redeem it server-side and hand the full result to
|
|
12633
12633
|
* `onSuccess` (and resolve with it).
|
|
12634
12634
|
* 2. A sign-in was in flight but never delivered (a mobile browser
|
|
12635
12635
|
* discarded the backgrounded opener tab, killing the popup's
|
|
12636
|
-
* postMessage)
|
|
12636
|
+
* postMessage): silently re-mint from the SSO session the popup signed
|
|
12637
12637
|
* in or chose, by navigating this tab through the silent SSO endpoint
|
|
12638
12638
|
* and straight back with a code (case 1 on return). The bounce names
|
|
12639
12639
|
* the sign-in's reference, and the endpoint mints only when the
|
|
@@ -12641,7 +12641,7 @@ class IdentityModule {
|
|
|
12641
12641
|
* such session (a sign-in that opened none, such as one through the
|
|
12642
12642
|
* account's own identity provider) it comes back logged-out, no oracle.
|
|
12643
12643
|
*
|
|
12644
|
-
* The code is one-time, PKCE-bound, and origin-locked
|
|
12644
|
+
* The code is one-time, PKCE-bound, and origin-locked, never the token. The
|
|
12645
12645
|
* host must still verify `result.token` server-side via the Identity JWKS.
|
|
12646
12646
|
*
|
|
12647
12647
|
* @example Call on page load; sign-in clicks stay unchanged.
|
|
@@ -12659,7 +12659,7 @@ class IdentityModule {
|
|
|
12659
12659
|
}
|
|
12660
12660
|
// A silent-SSO recovery that found no live session returns `#sso=…`; strip
|
|
12661
12661
|
// it so the logged-out load is clean, retire the one-shot state/verifier the
|
|
12662
|
-
// outbound bounce staged (dead now
|
|
12662
|
+
// outbound bounce staged (dead now: no code came back), and do not re-bounce
|
|
12663
12663
|
// (handled below).
|
|
12664
12664
|
if (params.get('sso')) {
|
|
12665
12665
|
this.clearUrlFragment();
|
|
@@ -12678,7 +12678,7 @@ class IdentityModule {
|
|
|
12678
12678
|
const code = params.get('sv_code');
|
|
12679
12679
|
const errorCode = params.get('sv_error');
|
|
12680
12680
|
// A returned fragment means this sign-in resolved (redeem, cancel, or
|
|
12681
|
-
// error), so retire any pending marker
|
|
12681
|
+
// error), so retire any pending marker; otherwise it could fire one
|
|
12682
12682
|
// spurious silent bounce on a later load inside its TTL.
|
|
12683
12683
|
removePendingMarker();
|
|
12684
12684
|
// Consume exactly once: fragment and one-shot state/verifier are cleared
|
|
@@ -12713,8 +12713,8 @@ class IdentityModule {
|
|
|
12713
12713
|
// here: the code is PKCE- and origin-bound to this tab, and a recovery
|
|
12714
12714
|
// bounce only ever mints for the account its `login_hint` named (see
|
|
12715
12715
|
// startRecoveryBounce). The redeemed result exposes just that account's
|
|
12716
|
-
// PRIMARY identifier
|
|
12717
|
-
// with
|
|
12716
|
+
// PRIMARY identifier (not necessarily the one the caller signed in
|
|
12717
|
+
// with), so re-checking it here could only discard valid sign-ins.
|
|
12718
12718
|
const raw = await this.api.redeemHandoffCode(code, codeVerifier);
|
|
12719
12719
|
const result = {
|
|
12720
12720
|
token: raw.token,
|
|
@@ -12737,7 +12737,7 @@ class IdentityModule {
|
|
|
12737
12737
|
* Silently re-mint the sign-in result from the SSO session the popup signed
|
|
12738
12738
|
* in or chose. Navigates this tab through the silent SSO endpoint
|
|
12739
12739
|
* (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
|
|
12740
|
-
* PKCE-bound, returns a one-time code in the fragment
|
|
12740
|
+
* PKCE-bound, returns a one-time code in the fragment, handled by case 1 on
|
|
12741
12741
|
* return. No-op (stays put) if session storage or WebCrypto is unavailable,
|
|
12742
12742
|
* so a degraded environment simply never recovers rather than erroring. The
|
|
12743
12743
|
* bounce's PKCE verifier and state are a draw from the Identity origin
|
|
@@ -12753,7 +12753,7 @@ class IdentityModule {
|
|
|
12753
12753
|
const sso = new URL(`${this.config.identityBaseUrl}/${this.config.accountId}/sso`);
|
|
12754
12754
|
// With several hub sessions, login_hint names the account the interrupted
|
|
12755
12755
|
// sign-in was addressing: /sso mints silently ONLY for a hint that matched
|
|
12756
|
-
// exactly one hub session's verified identifiers
|
|
12756
|
+
// exactly one hub session's verified identifiers, and every unsatisfiable hint
|
|
12757
12757
|
// (a stranger's address, an ambiguous match, an account not eligible here)
|
|
12758
12758
|
// comes back with no result at all rather than a different account's.
|
|
12759
12759
|
if (pending.hint) {
|
|
@@ -12913,14 +12913,14 @@ class IdentityModule {
|
|
|
12913
12913
|
// nothing below can match.
|
|
12914
12914
|
}
|
|
12915
12915
|
// A `#token` is accepted only as the answer to a sign-in THIS browser
|
|
12916
|
-
// started
|
|
12916
|
+
// started: the renderer stores the state before leaving for the
|
|
12917
12917
|
// provider. Anyone can compose a URL carrying their own genuinely-signed
|
|
12918
12918
|
// token, so a fragment with no stored state, or a different one, is an
|
|
12919
12919
|
// unsolicited result (login CSRF) and is refused.
|
|
12920
12920
|
if (!expectedState || params.get(SIGNIN_RESULT_FRAGMENT.state) !== expectedState) {
|
|
12921
12921
|
throw new ValidationError('Invalid OAuth state');
|
|
12922
12922
|
}
|
|
12923
|
-
// Unverified client-side decode
|
|
12923
|
+
// Unverified client-side decode: surfaces the claims for the result
|
|
12924
12924
|
// shape and rejects an obviously-bad token (expiry/issuer/audience/alg).
|
|
12925
12925
|
// The host MUST still verify result.token server-side via the Identity
|
|
12926
12926
|
// JWKS before trusting any claim for an authorization decision.
|
|
@@ -12991,7 +12991,7 @@ class IdentityModule {
|
|
|
12991
12991
|
* Whether the preloaded config has already settled as a *permanent* failure
|
|
12992
12992
|
* the popup can't surface (origin not allowed, or product not configured).
|
|
12993
12993
|
* Used to skip the launcher and show the error dialog in-page immediately.
|
|
12994
|
-
* Returns false
|
|
12994
|
+
* Returns false (proceed to the launcher) when config is not preloaded,
|
|
12995
12995
|
* still in flight (raced against a short timeout so the common path is never
|
|
12996
12996
|
* delayed), resolved, or failed only transiently (the launcher surfaces a
|
|
12997
12997
|
* transient failure in its own dialog).
|
|
@@ -13005,7 +13005,7 @@ class IdentityModule {
|
|
|
13005
13005
|
this.api.getConfig(),
|
|
13006
13006
|
new Promise((resolve) => setTimeout(() => resolve(PENDING), 50)),
|
|
13007
13007
|
]);
|
|
13008
|
-
// Resolved with config, or still pending after the timeout
|
|
13008
|
+
// Resolved with config, or still pending after the timeout: either way,
|
|
13009
13009
|
// don't block the iframe path.
|
|
13010
13010
|
return false;
|
|
13011
13011
|
}
|
|
@@ -13037,7 +13037,7 @@ class IdentityModule {
|
|
|
13037
13037
|
*
|
|
13038
13038
|
* @internal Used only by the SparkVault-hosted sign-in popup and hosted login
|
|
13039
13039
|
* page (which own their chrome and pass `renderMode: 'local'`). Customer
|
|
13040
|
-
* integrations have no inline mode
|
|
13040
|
+
* integrations have no inline mode; use `signIn()` / `attach()`.
|
|
13041
13041
|
*/
|
|
13042
13042
|
async render(options) {
|
|
13043
13043
|
const returned = await this.consumeRedirectResult();
|
|
@@ -13063,8 +13063,8 @@ class IdentityModule {
|
|
|
13063
13063
|
|
|
13064
13064
|
/**
|
|
13065
13065
|
* The caller-supplied send idempotency key. It becomes part of the send's
|
|
13066
|
-
* storage key, so `#` (the key separator) is excluded
|
|
13067
|
-
* key-segment boundary into another tenant's namespace
|
|
13066
|
+
* storage key, so `#` (the key separator) is excluded (no caller id can forge a
|
|
13067
|
+
* key-segment boundary into another tenant's namespace), and the length bound
|
|
13068
13068
|
* keeps the key inside the store's key-size limit.
|
|
13069
13069
|
*/
|
|
13070
13070
|
const NOTIFY_SEND_ID_PATTERN = /^[A-Za-z0-9_.:-]+$/;
|
|
@@ -13326,14 +13326,14 @@ class NotifyProjectsModule {
|
|
|
13326
13326
|
}
|
|
13327
13327
|
|
|
13328
13328
|
/**
|
|
13329
|
-
* Notify Product Module
|
|
13329
|
+
* Notify Product Module: the TENANT (sender) surface.
|
|
13330
13330
|
*
|
|
13331
13331
|
* The counterpart to `sv.notify`: where that module is SparkVault's own
|
|
13332
13332
|
* first-party inbox, which a signed-in SparkVault user reads for the
|
|
13333
13333
|
* notifications SparkVault delivered to them `in_app`, this one is the
|
|
13334
|
-
* account-scoped product surface a tenant's BACKEND drives
|
|
13334
|
+
* account-scoped product surface a tenant's BACKEND drives (send, send
|
|
13335
13335
|
* history, recall, sender-side inbox reads and state, send status, receipts,
|
|
13336
|
-
* the account's Notify config, and who its email is from.
|
|
13336
|
+
* the account's Notify config, and who its email is from).
|
|
13337
13337
|
* A tenant reads its own recipients' feeds here (`getInbox`), never through
|
|
13338
13338
|
* `sv.notify`. Every method maps to
|
|
13339
13339
|
* `/v1/products/notify/*` and is authorized by the caller's account, so the
|
|
@@ -13348,7 +13348,7 @@ class NotifyProjectsModule {
|
|
|
13348
13348
|
* and metadata.
|
|
13349
13349
|
*/
|
|
13350
13350
|
/**
|
|
13351
|
-
* The caller-supplied idempotency key's accepted shape
|
|
13351
|
+
* The caller-supplied idempotency key's accepted shape: the server's own rule,
|
|
13352
13352
|
* so a malformed key fails locally instead of on the wire.
|
|
13353
13353
|
*/
|
|
13354
13354
|
function isSendId(value) {
|
|
@@ -13367,7 +13367,7 @@ const BULK_MARK_STATES$1 = NOTIFY_INBOX_BULK_MARK_STATES;
|
|
|
13367
13367
|
* The five secure-by-default preset bundles: the server's own table, in this
|
|
13368
13368
|
* SDK's camelCase shape.
|
|
13369
13369
|
*
|
|
13370
|
-
* There is no preset endpoint
|
|
13370
|
+
* There is no preset endpoint: presets are a merge over the one send contract,
|
|
13371
13371
|
* so they are applied client-side and produce an ordinary `send` request. Caller
|
|
13372
13372
|
* arguments win over a preset's defaults wherever they state a value;
|
|
13373
13373
|
* `channels` left unset lets the account config resolve the ladder per category.
|
|
@@ -13436,8 +13436,8 @@ class NotifyProductModule {
|
|
|
13436
13436
|
* recipient, and enqueue delivery across the resolved channel ladder.
|
|
13437
13437
|
*
|
|
13438
13438
|
* `sendId` is the idempotency key. Replaying an existing one with the same
|
|
13439
|
-
* request returns the stored send unchanged
|
|
13440
|
-
* re-delivered
|
|
13439
|
+
* request returns the stored send unchanged (never re-sealed, never
|
|
13440
|
+
* re-delivered), flagged `idempotent`; another request under it is refused 400
|
|
13441
13441
|
* (`sendId` on `CreateNotifySendOptions`).
|
|
13442
13442
|
*
|
|
13443
13443
|
* The send speaks in your organization's name, and one that would email
|
|
@@ -13451,12 +13451,12 @@ class NotifyProductModule {
|
|
|
13451
13451
|
* | Status | `serviceCode` | `details` | Next |
|
|
13452
13452
|
* | --- | --- | --- | --- |
|
|
13453
13453
|
* | 403 | `NOTIFY_CHANNEL_NOT_AVAILABLE` | `{ field, channels }` | Name only `in_app` and `email` |
|
|
13454
|
-
* | 409 | `NOTIFY_SENDER_NAME_REQUIRED` |
|
|
13454
|
+
* | 409 | `NOTIFY_SENDER_NAME_REQUIRED` | none | Name the organization in Settings |
|
|
13455
13455
|
* | 409 | `NOTIFY_SENDER_NAME_RESERVED` | `{ reason: 'reserved_name' }` | Rename the organization |
|
|
13456
13456
|
* | 409 | `HANDLE_REQUIRED` | `{ product: 'notify' }` | Choose the organization's handle in Company Settings |
|
|
13457
13457
|
* | 429 | `NOTIFY_EMAIL_ADMISSION_LIMIT` | `{ limit, window: 'hour', resets_at }` | Wait `retryAfterMs`, then send |
|
|
13458
|
-
* | 503 | `EMAIL_SETUP_BUSY` |
|
|
13459
|
-
* | 503 | `NOTIFY_EMAIL_CAPACITY_UNAVAILABLE` |
|
|
13458
|
+
* | 503 | `EMAIL_SETUP_BUSY` | none | Retry the same send after `retryAfterMs` |
|
|
13459
|
+
* | 503 | `NOTIFY_EMAIL_CAPACITY_UNAVAILABLE` | none | Retry the same send |
|
|
13460
13460
|
*
|
|
13461
13461
|
* A replay is answered from the stored send and meets none of them again.
|
|
13462
13462
|
*
|
|
@@ -13470,7 +13470,7 @@ class NotifyProductModule {
|
|
|
13470
13470
|
* category: 'transactional',
|
|
13471
13471
|
* });
|
|
13472
13472
|
*
|
|
13473
|
-
* @example Send a stored file
|
|
13473
|
+
* @example Send a stored file: the unsealed vault proves you hold its key
|
|
13474
13474
|
* const vault = await sv.vaults.unseal('vlt_abc', process.env.CONTRACTS_DVAK);
|
|
13475
13475
|
* await sv.products.notify.send({
|
|
13476
13476
|
* sendId: `contract:${contract.id}`,
|
|
@@ -13501,7 +13501,7 @@ class NotifyProductModule {
|
|
|
13501
13501
|
return response.data;
|
|
13502
13502
|
}
|
|
13503
13503
|
/**
|
|
13504
|
-
* Frictionless informational ping
|
|
13504
|
+
* Frictionless informational ping: no verification, view-only, delivered
|
|
13505
13505
|
* INLINE (plaintext) so it is read at a glance. Channels resolve from the
|
|
13506
13506
|
* account config, narrowed to the ones that render cleartext.
|
|
13507
13507
|
*
|
|
@@ -13576,7 +13576,7 @@ class NotifyProductModule {
|
|
|
13576
13576
|
* grant still opens, never the content; a plaintext row carries its body.
|
|
13577
13577
|
* Treat the answer as sensitive and keep it out of logs.
|
|
13578
13578
|
*
|
|
13579
|
-
* A page can come back SHORT of `limit` yet still carry a non-null cursor
|
|
13579
|
+
* A page can come back SHORT of `limit` yet still carry a non-null cursor:
|
|
13580
13580
|
* follow the cursor; never treat a short page as the end.
|
|
13581
13581
|
*
|
|
13582
13582
|
* @example
|
|
@@ -13599,7 +13599,7 @@ class NotifyProductModule {
|
|
|
13599
13599
|
}
|
|
13600
13600
|
/**
|
|
13601
13601
|
* Apply a terminal display state to one row (idempotent). `createdAt` MUST be
|
|
13602
|
-
* the row's own `created_at`, round-tripped from the feed row
|
|
13602
|
+
* the row's own `created_at`, round-tripped from the feed row; the id alone
|
|
13603
13603
|
* cannot address the row. Any mark (seen, read or archived) marks the row seen,
|
|
13604
13604
|
* which stops its escalation.
|
|
13605
13605
|
*
|
|
@@ -13655,7 +13655,7 @@ class NotifyProductModule {
|
|
|
13655
13655
|
}
|
|
13656
13656
|
// ── Send history & recall ───────────────────────────────────────────────────
|
|
13657
13657
|
/**
|
|
13658
|
-
* The account's send history, newest first
|
|
13658
|
+
* The account's send history, newest first: what you sent, to how many, and
|
|
13659
13659
|
* how it landed.
|
|
13660
13660
|
*
|
|
13661
13661
|
* Metadata only by construction: the history index does not project the
|
|
@@ -13688,13 +13688,13 @@ class NotifyProductModule {
|
|
|
13688
13688
|
*
|
|
13689
13689
|
* `mode: 'grant'` (the default) drops access and leaves the content intact.
|
|
13690
13690
|
* `mode: 'content'` hard-burns the sealed spark so it is unreadable for
|
|
13691
|
-
* everyone
|
|
13691
|
+
* everyone. Spark-backed sends only: an ingot send merely references the
|
|
13692
13692
|
* owner's durable vault content, so a content recall of one is a 400, refused
|
|
13693
13693
|
* before anything is revoked or stopped.
|
|
13694
13694
|
*
|
|
13695
13695
|
* Idempotent: a grant already revoked (or already consumed) counts as recalled,
|
|
13696
13696
|
* so a repeated call converges rather than accumulating failures. One
|
|
13697
|
-
* recipient's failure never stops the rest
|
|
13697
|
+
* recipient's failure never stops the rest; the response reports every one.
|
|
13698
13698
|
*
|
|
13699
13699
|
* PLAINTEXT SENDS CANNOT BE RECALLED (400): they delivered their body inline,
|
|
13700
13700
|
* in the clear, and minted no grant. There is nothing to revoke, and saying
|
|
@@ -13729,7 +13729,7 @@ class NotifyProductModule {
|
|
|
13729
13729
|
// ── Status & receipts ───────────────────────────────────────────────────────
|
|
13730
13730
|
/**
|
|
13731
13731
|
* The sender's per-recipient delivery rollup for one send: who it reached and
|
|
13732
|
-
* how far each recipient got. Metadata only
|
|
13732
|
+
* how far each recipient got. Metadata only: never the pointer, and no contact
|
|
13733
13733
|
* beyond the handle each recipient was addressed by (`recipient_id`).
|
|
13734
13734
|
*
|
|
13735
13735
|
* @example
|
|
@@ -13763,7 +13763,7 @@ class NotifyProductModule {
|
|
|
13763
13763
|
/**
|
|
13764
13764
|
* Every receipt for one send, each attached to the recipient who produced it.
|
|
13765
13765
|
* The walk reads the account's receipts back to the send's creation, and no
|
|
13766
|
-
* further. One call is bounded: when `truncated` is true it stopped first
|
|
13766
|
+
* further. One call is bounded: when `truncated` is true it stopped first;
|
|
13767
13767
|
* pass the returned `cursor` back in to resume exactly where it stopped.
|
|
13768
13768
|
*
|
|
13769
13769
|
* @example
|
|
@@ -13800,7 +13800,7 @@ class NotifyProductModule {
|
|
|
13800
13800
|
* Merge a partial patch onto the account's config overrides. Unknown keys are
|
|
13801
13801
|
* rejected before any write.
|
|
13802
13802
|
*
|
|
13803
|
-
* Delete a category by storing an explicit `null` TOMBSTONE
|
|
13803
|
+
* Delete a category by storing an explicit `null` TOMBSTONE: that is what keeps
|
|
13804
13804
|
* a seeded default from re-appearing on the next merge. The reserved `security`
|
|
13805
13805
|
* category can neither be removed nor made optional, the promotional
|
|
13806
13806
|
* categories `marketing` and `product` can never be made required: their email
|
|
@@ -13811,7 +13811,7 @@ class NotifyProductModule {
|
|
|
13811
13811
|
* The `events` section configures the outbound event webhook: `webhook_url`
|
|
13812
13812
|
* must be https on a public host, and `secret` (16-256 chars) signs every event
|
|
13813
13813
|
* body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. Both
|
|
13814
|
-
* are WRITE-ONLY
|
|
13814
|
+
* are WRITE-ONLY: reads report `events.webhook_url_set`,
|
|
13815
13815
|
* `events.webhook_url_host` and `events.secret_set`, never the values. A
|
|
13816
13816
|
* `webhook_url` on another host or port needs a new `secret` in the same
|
|
13817
13817
|
* patch (400 `VALIDATION_ERROR` naming `events.secret`), so a secret never
|
|
@@ -13831,7 +13831,7 @@ class NotifyProductModule {
|
|
|
13831
13831
|
* await sv.products.notify.updateConfig({
|
|
13832
13832
|
* categories: {
|
|
13833
13833
|
* weekly_newsletter: { label: 'Weekly newsletter', required: false },
|
|
13834
|
-
* marketing: null, // tombstone
|
|
13834
|
+
* marketing: null, // tombstone: remove the seeded default
|
|
13835
13835
|
* },
|
|
13836
13836
|
* events: {
|
|
13837
13837
|
* webhook_url: 'https://api.example.com/hooks/sparkvault',
|
|
@@ -14944,6 +14944,8 @@ const HELP_DESK_ROLES = Object.freeze(['manager', 'agent', 'trainee']);
|
|
|
14944
14944
|
* hold_tickets be assigned, mentioned, alerted and balanced-assigned
|
|
14945
14945
|
* configure_desk edit the desk's settings, queues, routing, alerts and knowledge base
|
|
14946
14946
|
* configure_chat the desk's chat intake and new-ticket chat notifications
|
|
14947
|
+
* activate_desk activate the desk on a company vault by presenting its key: the first
|
|
14948
|
+
* activation, a deactivated desk's, and a move to another vault
|
|
14947
14949
|
* assign_roles choose who holds which role on the desk
|
|
14948
14950
|
* view_analytics the desk's analytics, its CSV and the operator breakdown
|
|
14949
14951
|
* manage_requesters block or unblock a requester
|
|
@@ -14958,6 +14960,11 @@ const HELP_DESK_ROLES = Object.freeze(['manager', 'agent', 'trainee']);
|
|
|
14958
14960
|
* A Trainee keeps no saved replies: they use every one, and their reply is
|
|
14959
14961
|
* reviewed before it reaches a customer, so no text of theirs reaches one
|
|
14960
14962
|
* through another operator's reply unreviewed.
|
|
14963
|
+
*
|
|
14964
|
+
* A company admin alone activates a desk: presenting a company vault's key is
|
|
14965
|
+
* the company's consent to the help desk opening every file in that vault, so
|
|
14966
|
+
* no desk role gives it. Deactivating, which only withdraws that access, is
|
|
14967
|
+
* the desk's configurers' (`configure_desk`).
|
|
14961
14968
|
*/
|
|
14962
14969
|
const EVERY_ROLE = HELP_DESK_ROLES;
|
|
14963
14970
|
const capability = (roles, { admin = false, requiresAdmin = false } = {}) =>
|
|
@@ -14975,6 +14982,7 @@ Object.freeze({
|
|
|
14975
14982
|
hold_tickets: capability(EVERY_ROLE),
|
|
14976
14983
|
configure_desk: capability(['manager'], { admin: true }),
|
|
14977
14984
|
configure_chat: capability([], { admin: true }),
|
|
14985
|
+
activate_desk: capability([], { admin: true }),
|
|
14978
14986
|
assign_roles: capability(['manager'], { admin: true }),
|
|
14979
14987
|
view_analytics: capability(['manager']),
|
|
14980
14988
|
manage_requesters: capability(['manager']),
|
|
@@ -15371,14 +15379,14 @@ function refused(reason) {
|
|
|
15371
15379
|
*/
|
|
15372
15380
|
/**
|
|
15373
15381
|
* Time-to-first-byte bound: how long the download host may take to return
|
|
15374
|
-
* response headers. This bounds only the wait for a transfer to start
|
|
15382
|
+
* response headers. This bounds only the wait for a transfer to start: a
|
|
15375
15383
|
* signed link either begins serving promptly or is not going to.
|
|
15376
15384
|
*/
|
|
15377
15385
|
const DOWNLOAD_TTFB_TIMEOUT_MS = 30000;
|
|
15378
15386
|
/**
|
|
15379
15387
|
* Liveness bound on the response body: the longest tolerated gap between two
|
|
15380
15388
|
* chunks, rearmed on every chunk. Progress, not wall clock, bounds the
|
|
15381
|
-
* transfer
|
|
15389
|
+
* transfer: a large file over a slow link still completes, while a stalled
|
|
15382
15390
|
* connection fails promptly enough to retry.
|
|
15383
15391
|
*/
|
|
15384
15392
|
const DOWNLOAD_IDLE_TIMEOUT_MS = 60000;
|
|
@@ -16060,7 +16068,7 @@ function mapFolder(wire) {
|
|
|
16060
16068
|
*/
|
|
16061
16069
|
/**
|
|
16062
16070
|
* Error class for upload API errors. Inherits `code` and `statusCode` from
|
|
16063
|
-
* SparkVaultError
|
|
16071
|
+
* SparkVaultError, with no duplicate `httpStatus` field.
|
|
16064
16072
|
*
|
|
16065
16073
|
* A failed transfer request also carries what the transfer policy
|
|
16066
16074
|
* (`@sparkvault/app-sdk/transfer-retry`) makes of its answer, read where the
|
|
@@ -16140,15 +16148,15 @@ function parseLengthHeader(raw) {
|
|
|
16140
16148
|
/**
|
|
16141
16149
|
* Abort a stalled chunk PATCH after this long with no upload progress.
|
|
16142
16150
|
* XHR's own `timeout` measures total request duration, which would abort a
|
|
16143
|
-
* slow-but-progressing 50MB chunk
|
|
16151
|
+
* slow-but-progressing 50MB chunk, so a chunk fails only after the
|
|
16144
16152
|
* connection has been completely silent for the full window.
|
|
16145
16153
|
*/
|
|
16146
16154
|
const CHUNK_INACTIVITY_TIMEOUT_MS = 60000;
|
|
16147
16155
|
/**
|
|
16148
16156
|
* How many consecutive timeouts end the finalization receipt early.
|
|
16149
16157
|
*
|
|
16150
|
-
* A genuinely slow finalize shows up as ONE timeout
|
|
16151
|
-
* the re-drive
|
|
16158
|
+
* A genuinely slow finalize shows up as ONE timeout (the PATCH that started
|
|
16159
|
+
* the re-drive) followed by 409s from the writer that is working on it.
|
|
16152
16160
|
* Back-to-back timeouts mean nobody is answering at all, and spending the
|
|
16153
16161
|
* whole retry budget on a black-holed socket would freeze the widget at 100%
|
|
16154
16162
|
* for minutes with nothing for the user to act on.
|
|
@@ -16190,8 +16198,8 @@ function uploadRefusedError(coreCode, message, status, outcome) {
|
|
|
16190
16198
|
return new UploadApiError(message ?? REFUSAL_WORDING.get(coreCode) ?? REFUSED_MESSAGE, 'upload_refused', status, { status, coreCode }, outcome);
|
|
16191
16199
|
}
|
|
16192
16200
|
/**
|
|
16193
|
-
* Core's refusal of a request that stages an upload
|
|
16194
|
-
* replacement, the widget's initiation
|
|
16201
|
+
* Core's refusal of a request that stages an upload (a create, a
|
|
16202
|
+
* replacement, the widget's initiation) read as the upload's verdict: a final
|
|
16195
16203
|
* refusal of Core's (UPLOAD_FINAL_REFUSAL_CODES, the answer's own code: a
|
|
16196
16204
|
* later staging of the same file superseded it before its token was minted,
|
|
16197
16205
|
* 410 UPLOAD_SUPERSEDED) is the `upload_refused` a transfer answer naming it
|
|
@@ -16448,7 +16456,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16448
16456
|
* Vault upload info by vault id, memoized for the life of this client.
|
|
16449
16457
|
*
|
|
16450
16458
|
* The client is built once with the SDK and the map dies with the page, so
|
|
16451
|
-
* the memo cannot outlive the page it decorates
|
|
16459
|
+
* the memo cannot outlive the page it decorates, which is why there is no
|
|
16452
16460
|
* TTL and no invalidation API to get wrong. It deliberately survives
|
|
16453
16461
|
* `resetSession()`, alongside the other long-lived per-client state.
|
|
16454
16462
|
*/
|
|
@@ -16461,7 +16469,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16461
16469
|
* retries, a cancel aside; a refused API call it raises with its status is
|
|
16462
16470
|
* Core's verdict, never a transfer's, so of the policy's reading it carries
|
|
16463
16471
|
* only the floor Core named (`retryAfterMs`), for whoever acts on the
|
|
16464
|
-
* refusal
|
|
16472
|
+
* refusal, and Core's final refusal of the upload a call stages is that
|
|
16465
16473
|
* upload's `upload_refused` ({@link stagingRefusal}).
|
|
16466
16474
|
*/
|
|
16467
16475
|
makeError(message, code, statusCode, details, retryAfterMs = null) {
|
|
@@ -16505,13 +16513,13 @@ class UploadApi extends SparkVaultApi {
|
|
|
16505
16513
|
/**
|
|
16506
16514
|
* Get vault upload info (public endpoint), fetched at most once per vault.
|
|
16507
16515
|
*
|
|
16508
|
-
* Every widget interaction
|
|
16509
|
-
* an `attach()` handler serves
|
|
16516
|
+
* Every widget interaction (`upload()`, `pop()`, `render()`, and each click
|
|
16517
|
+
* an `attach()` handler serves) starts by asking for this, and the answer is
|
|
16510
16518
|
* pure display and geometry: the vault's name, its branding, and the size it
|
|
16511
16519
|
* advertises. It authorizes nothing. The server re-validates the vault, its
|
|
16512
16520
|
* upload source, the request origin, and the file size on the POST that
|
|
16513
16521
|
* actually creates the upload, and that re-validation is the correctness
|
|
16514
|
-
* backstop for this whole flow
|
|
16522
|
+
* backstop for this whole flow: a memoized answer can never widen what an
|
|
16515
16523
|
* upload is allowed to do, and the backstop must stay in place.
|
|
16516
16524
|
*
|
|
16517
16525
|
* Only a successful answer is kept: a rejection evicts its entry so the next
|
|
@@ -16584,7 +16592,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16584
16592
|
/**
|
|
16585
16593
|
* Upload a file to Forge over the TUS resumable protocol (v1.0.0).
|
|
16586
16594
|
*
|
|
16587
|
-
* The single canonical browser transfer path
|
|
16595
|
+
* The single canonical browser transfer path: the upload widget and the
|
|
16588
16596
|
* authenticated `ingots.upload` flow both go through here (one canonical
|
|
16589
16597
|
* transfer path). Creates the session, PATCHes chunks sized exactly by the
|
|
16590
16598
|
* server's `X-Chunk-Size` (Forge fixes the geometry at 50MB, which keeps
|
|
@@ -16595,7 +16603,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16595
16603
|
* Every answer is read through the transfer policy
|
|
16596
16604
|
* (`@sparkvault/app-sdk/transfer-retry`) and every retry spends one budget
|
|
16597
16605
|
* ({@link TusTransfer}). A chunk that fails in transit is resent only from
|
|
16598
|
-
* an offset the server just named
|
|
16606
|
+
* an offset the server just named: a 409's own `Upload-Offset` at once,
|
|
16599
16607
|
* otherwise a HEAD after the backoff ({@link offsetAfterFailure}); a session
|
|
16600
16608
|
* the server no longer holds throws `session_gone`, which only a new upload
|
|
16601
16609
|
* recovers from (any code of Core's the server named rides
|
|
@@ -16794,7 +16802,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16794
16802
|
await waitToRetry(transfer.budget, failure, transfer.uploadUrl, transfer.sessionSignal);
|
|
16795
16803
|
}
|
|
16796
16804
|
/**
|
|
16797
|
-
* Confirm the server finalized a fully received upload
|
|
16805
|
+
* Confirm the server finalized a fully received upload: the one receipt
|
|
16798
16806
|
* every transfer ends on.
|
|
16799
16807
|
*
|
|
16800
16808
|
* The server persists the session's final offset BEFORE it finalizes, so a
|
|
@@ -16802,7 +16810,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16802
16810
|
* size while finalization failed or is still running, and reporting that as
|
|
16803
16811
|
* success would hand the user a stored file whose ingot was never published.
|
|
16804
16812
|
* The zero-length PATCH at the final offset is the server's finalization
|
|
16805
|
-
* re-drive
|
|
16813
|
+
* re-drive: it short-circuits to 204 on an already-finalized session, and
|
|
16806
16814
|
* on a received-but-unfinalized one it answers only after publication.
|
|
16807
16815
|
*
|
|
16808
16816
|
* While another request finalizes the receipt answers 409 with
|
|
@@ -16834,7 +16842,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16834
16842
|
}
|
|
16835
16843
|
catch (error) {
|
|
16836
16844
|
const failure = transferFailure(error);
|
|
16837
|
-
// Any answer at all
|
|
16845
|
+
// Any answer at all (a 409 above all) proves someone is on the other
|
|
16838
16846
|
// end, so the timeout tally starts over.
|
|
16839
16847
|
consecutiveTimeouts = failure.code === 'timeout' ? consecutiveTimeouts + 1 : 0;
|
|
16840
16848
|
if (consecutiveTimeouts >= FINALIZE_MAX_CONSECUTIVE_TIMEOUTS) {
|
|
@@ -16889,12 +16897,12 @@ class UploadApi extends SparkVaultApi {
|
|
|
16889
16897
|
return this.checkResumeOffset(await this.headUploadOffset(transfer.uploadUrl, RESUME_CHECK), transfer);
|
|
16890
16898
|
}
|
|
16891
16899
|
/**
|
|
16892
|
-
* Judge an offset the server named for the upload to resume from
|
|
16893
|
-
* or a 409's `Upload-Offset`
|
|
16900
|
+
* Judge an offset the server named for the upload to resume from (a HEAD's,
|
|
16901
|
+
* or a 409's `Upload-Offset`): the one place a server-reported resume point
|
|
16894
16902
|
* is judged.
|
|
16895
16903
|
*
|
|
16896
16904
|
* Forge commits a chunk before it answers, so a PATCH that died in transit
|
|
16897
|
-
* may have landed in full or not at all (never in part
|
|
16905
|
+
* may have landed in full or not at all (never in part: the chunk object
|
|
16898
16906
|
* is written atomically before the offset advances); only the session's own
|
|
16899
16907
|
* persisted offset knows which, and the client's arithmetic is worthless
|
|
16900
16908
|
* here.
|
|
@@ -17054,7 +17062,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
17054
17062
|
});
|
|
17055
17063
|
}
|
|
17056
17064
|
/**
|
|
17057
|
-
* Read the server's persisted upload offset via a TUS HEAD request
|
|
17065
|
+
* Read the server's persisted upload offset via a TUS HEAD request: the one
|
|
17058
17066
|
* place the client asks Forge where a session really stands.
|
|
17059
17067
|
*
|
|
17060
17068
|
* @param check - Which caller this read serves; shapes the failure copy.
|
|
@@ -17140,7 +17148,7 @@ const NAME_CONFLICT_POLICIES = ['upsert', 'complete_pending', 'refuse', 'new_nam
|
|
|
17140
17148
|
*
|
|
17141
17149
|
* Uploads and downloads run over the single canonical Forge TUS transfer path
|
|
17142
17150
|
* (shared with the public upload widget), with server-side finalization and
|
|
17143
|
-
* download-host allowlisting enforced
|
|
17151
|
+
* download-host allowlisting enforced, with no per-size branching.
|
|
17144
17152
|
*/
|
|
17145
17153
|
class IngotsModule {
|
|
17146
17154
|
constructor(config, http) {
|
|
@@ -17248,16 +17256,16 @@ class IngotsModule {
|
|
|
17248
17256
|
}
|
|
17249
17257
|
}
|
|
17250
17258
|
/**
|
|
17251
|
-
* Send a file's bytes to an upload session
|
|
17252
|
-
* {@link createUpload} returned
|
|
17259
|
+
* Send a file's bytes to an upload session (the `uploadUrl` a
|
|
17260
|
+
* {@link createUpload} returned) over the resumable transfer every SDK
|
|
17253
17261
|
* upload uses. Resolves only once the server confirms the ingot is
|
|
17254
17262
|
* published, so a resolved promise never stands for a stored file whose
|
|
17255
17263
|
* ingot never went live.
|
|
17256
17264
|
*
|
|
17257
17265
|
* Transient failures are retried inside the transfer; a session the server
|
|
17258
17266
|
* no longer holds (it expired, was cancelled, or its ingot was removed)
|
|
17259
|
-
* rejects with code `session_gone`, and only a new upload session
|
|
17260
|
-
* {@link createUpload}, or {@link upload} again
|
|
17267
|
+
* rejects with code `session_gone`, and only a new upload session (a new
|
|
17268
|
+
* {@link createUpload}, or {@link upload} again) can store the file. An
|
|
17261
17269
|
* upload the server refused (the account's storage pool cannot take it, a
|
|
17262
17270
|
* later upload replaced it, or its vault is scheduled for deletion: a 409
|
|
17263
17271
|
* `VAULT_DELETION_SCHEDULED`, whose session the server keeps until the
|
|
@@ -17354,9 +17362,9 @@ class IngotsModule {
|
|
|
17354
17362
|
*
|
|
17355
17363
|
* Creates the upload session, streams the file to Forge over TUS, then
|
|
17356
17364
|
* confirms the server finalized the upload before resolving. A file the
|
|
17357
|
-
* server refused
|
|
17365
|
+
* server refused (another upload of it superseded this one, at its create
|
|
17358
17366
|
* or while it streamed, the storage pool cannot take it, or its vault is
|
|
17359
|
-
* scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`)
|
|
17367
|
+
* scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`)) rejects with
|
|
17360
17368
|
* code `upload_refused`, as {@link sendUpload} does. An upload that rejects
|
|
17361
17369
|
* any way but one the server received whole ({@link isReceivedUploadFailure}:
|
|
17362
17370
|
* the server publishes or ends that one on its own) is given up: the end of
|
|
@@ -17755,7 +17763,7 @@ class IngotsModule {
|
|
|
17755
17763
|
await this.http.delete(apiPath `/v1/vaults/${vaultId}/ingots/${id}/sharing/invite/${invite}`, { vat: vault.vatToken });
|
|
17756
17764
|
}
|
|
17757
17765
|
/**
|
|
17758
|
-
* Batch content-HMAC existence check
|
|
17766
|
+
* Batch content-HMAC existence check: the pre-upload dedup handshake.
|
|
17759
17767
|
* Returns which of the supplied vault-keyed HMACs already exist on active
|
|
17760
17768
|
* ingots in the vault, so callers can skip transferring those bytes.
|
|
17761
17769
|
*
|
|
@@ -17798,7 +17806,7 @@ class IngotsModule {
|
|
|
17798
17806
|
}
|
|
17799
17807
|
/**
|
|
17800
17808
|
* Request a Forge upload session for a new ingot.
|
|
17801
|
-
* Shared by createUpload and upload
|
|
17809
|
+
* Shared by createUpload and upload: the single ingot-create path.
|
|
17802
17810
|
*/
|
|
17803
17811
|
async requestUploadSession(vault, body) {
|
|
17804
17812
|
const payload = {
|
|
@@ -17836,7 +17844,7 @@ class IngotsModule {
|
|
|
17836
17844
|
* Run the canonical TUS transfer for a created/replaced ingot.
|
|
17837
17845
|
*
|
|
17838
17846
|
* The transfer resolves only once the server has confirmed finalization, so
|
|
17839
|
-
* the ingot this returns is always a published one
|
|
17847
|
+
* the ingot this returns is always a published one, never a stored file
|
|
17840
17848
|
* whose ingot never went active.
|
|
17841
17849
|
*/
|
|
17842
17850
|
async transferAndFinalize(session, minted, file, onProgress) {
|
|
@@ -19138,7 +19146,7 @@ function lastExtension(name) {
|
|
|
19138
19146
|
* server never reads the plaintext of an uploaded ingot, so the policy splits
|
|
19139
19147
|
* by where the bytes are: the NAME rule runs on the server at initiate and in
|
|
19140
19148
|
* the browser before an upload starts; the SNIFF rule runs wherever the bytes
|
|
19141
|
-
* are at hand
|
|
19149
|
+
* are at hand, in the browser over the file's first slice and on the server
|
|
19142
19150
|
* over an inbound email's parts. The type a ticket stores a file under, which
|
|
19143
19151
|
* the MIME registry decides, is server-only: ./attachment-policy-node.js.
|
|
19144
19152
|
*
|
|
@@ -27309,7 +27317,7 @@ function idempotencyHeaders(key) {
|
|
|
27309
27317
|
if (key === undefined)
|
|
27310
27318
|
return undefined;
|
|
27311
27319
|
if (typeof key !== 'string' || !/^[\x20-\x7E]{8,128}$/.test(key))
|
|
27312
|
-
throw new ValidationError('idempotencyKey must contain 8
|
|
27320
|
+
throw new ValidationError('idempotencyKey must contain 8 to 128 printable ASCII characters');
|
|
27313
27321
|
return { 'Idempotency-Key': key };
|
|
27314
27322
|
}
|
|
27315
27323
|
/** Empty pages are legitimate; a repeated cursor is never drained forever. */
|
|
@@ -28005,7 +28013,7 @@ function createSecuritySidebar(branding) {
|
|
|
28005
28013
|
const STYLE_ID = 'sparkvault-upload-styles';
|
|
28006
28014
|
/**
|
|
28007
28015
|
* Inject upload widget styles into the document head.
|
|
28008
|
-
* Idempotent: the stylesheet is static and shared by every widget instance
|
|
28016
|
+
* Idempotent: the stylesheet is static and shared by every widget instance;
|
|
28009
28017
|
* per-instance behavior (backdrop blur, dark mode) is driven by class toggles.
|
|
28010
28018
|
*/
|
|
28011
28019
|
function injectUploadStyles() {
|
|
@@ -29468,7 +29476,7 @@ class UploadRenderer {
|
|
|
29468
29476
|
this.hybridModalInitialized = false;
|
|
29469
29477
|
// Lifecycle flags: a closed renderer must never render or fire callbacks,
|
|
29470
29478
|
// and onCancel fires at most once per renderer (mutually exclusive with
|
|
29471
|
-
// onError
|
|
29479
|
+
// onError; see cancel()/handleApiError).
|
|
29472
29480
|
this.closed = false;
|
|
29473
29481
|
this.cancelled = false;
|
|
29474
29482
|
// Counts the uploads this renderer started; an upload whose number is no
|
|
@@ -29554,7 +29562,7 @@ class UploadRenderer {
|
|
|
29554
29562
|
}
|
|
29555
29563
|
/**
|
|
29556
29564
|
* Cancel the flow: tear everything down and fire the cancel contract
|
|
29557
|
-
* exactly once. onCancel and onError are mutually exclusive
|
|
29565
|
+
* exactly once. onCancel and onError are mutually exclusive: a deliberate
|
|
29558
29566
|
* cancellation (user close, programmatic close, or a new upload replacing
|
|
29559
29567
|
* this renderer) must never surface as an error to the host.
|
|
29560
29568
|
*/
|
|
@@ -29578,7 +29586,7 @@ class UploadRenderer {
|
|
|
29578
29586
|
this.cancel();
|
|
29579
29587
|
}
|
|
29580
29588
|
setState(state) {
|
|
29581
|
-
// A closed renderer never renders again
|
|
29589
|
+
// A closed renderer never renders again: a progress event racing the
|
|
29582
29590
|
// teardown must not resurrect the hybrid-mode modal or touch the DOM.
|
|
29583
29591
|
if (this.closed)
|
|
29584
29592
|
return;
|
|
@@ -29586,7 +29594,7 @@ class UploadRenderer {
|
|
|
29586
29594
|
this.viewState = state;
|
|
29587
29595
|
// Progress events fire many times per second for the whole transfer.
|
|
29588
29596
|
// While the uploading view is already on screen, mutate its progress
|
|
29589
|
-
// nodes in place instead of tearing down and rebuilding the subtree
|
|
29597
|
+
// nodes in place instead of tearing down and rebuilding the subtree:
|
|
29590
29598
|
// a full rebuild per event thrashes the DOM and restarts the progress
|
|
29591
29599
|
// bar's CSS transition and the stage-arrow animation on every tick. The
|
|
29592
29600
|
// view re-renders once, when every byte is sent and SparkVault is
|
|
@@ -30250,7 +30258,7 @@ class UploadRenderer {
|
|
|
30250
30258
|
const sent = { bytesUploaded: file.size, bytesTotal: file.size, percentage: 100 };
|
|
30251
30259
|
this.callbacks.onProgress?.({ ...sent, phase: 'ceremony' });
|
|
30252
30260
|
this.callbacks.onProgress?.({ ...sent, phase: 'complete' });
|
|
30253
|
-
// Silent mode: skip the success screen
|
|
30261
|
+
// Silent mode: skip the success screen, fire onSuccess and close so
|
|
30254
30262
|
// the host site can render its own post-upload UI.
|
|
30255
30263
|
if (this.options.hideSuccessScreen) {
|
|
30256
30264
|
this.callbacks.onSuccess(result);
|
|
@@ -30325,8 +30333,8 @@ class UploadRenderer {
|
|
|
30325
30333
|
handleApiError(error, action = null) {
|
|
30326
30334
|
// A closed renderer must not surface errors: cancelling mid-transfer
|
|
30327
30335
|
// aborts the in-flight request, whose 'cancelled' rejection races the
|
|
30328
|
-
// teardown. The host has already received onCancel
|
|
30329
|
-
// onError are mutually exclusive
|
|
30336
|
+
// teardown. The host has already received onCancel (onCancel and
|
|
30337
|
+
// onError are mutually exclusive) and the container is destroyed, so
|
|
30330
30338
|
// there is nothing left to render into.
|
|
30331
30339
|
if (this.closed || isCancellationError(error)) {
|
|
30332
30340
|
return;
|
|
@@ -30486,7 +30494,7 @@ class VaultUploadModule {
|
|
|
30486
30494
|
}
|
|
30487
30495
|
// Public-API aliases. The dashboard's vault-edit screen and the SDK docs
|
|
30488
30496
|
// document sv.vaults.upload.pop({ vaultId }) and
|
|
30489
|
-
// sv.vaults.upload.render({ vaultId, target })
|
|
30497
|
+
// sv.vaults.upload.render({ vaultId, target }); both defer to upload().
|
|
30490
30498
|
/** Open the upload widget as a popup. Equivalent to `upload(options)`. */
|
|
30491
30499
|
async pop(options) {
|
|
30492
30500
|
return this.upload(options);
|
|
@@ -30660,7 +30668,7 @@ class VaultsModule {
|
|
|
30660
30668
|
};
|
|
30661
30669
|
}
|
|
30662
30670
|
/**
|
|
30663
|
-
* Retain this many previous versions of each file or structured object (0
|
|
30671
|
+
* Retain this many previous versions of each file or structured object (0 to 50,
|
|
30664
30672
|
* default 0). Interactive company administrators only. Applies on each ingot's
|
|
30665
30673
|
* next successful content change; retained versions count toward storage usage.
|
|
30666
30674
|
*/
|
|
@@ -30718,7 +30726,7 @@ class VaultsModule {
|
|
|
30718
30726
|
* Requires the vault's exact name as confirmation, matched case-sensitively.
|
|
30719
30727
|
* The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
|
|
30720
30728
|
* named with any Unicode (emoji, CJK, the U+202F in macOS-style names) is
|
|
30721
|
-
* deletable
|
|
30729
|
+
* deletable: an HTTP header value cannot carry non-latin1 characters.
|
|
30722
30730
|
*
|
|
30723
30731
|
* @example
|
|
30724
30732
|
* await sv.vaults.delete('vlt_abc', 'My Vault');
|
|
@@ -31024,7 +31032,7 @@ class SparksModule {
|
|
|
31024
31032
|
};
|
|
31025
31033
|
}
|
|
31026
31034
|
/**
|
|
31027
|
-
* Read (and burn) a spark. Reading is destructive
|
|
31035
|
+
* Read (and burn) a spark. Reading is destructive: the spark can be read
|
|
31028
31036
|
* exactly once.
|
|
31029
31037
|
* Supply the source vault's VAT for a Structured Ingots field Spark.
|
|
31030
31038
|
*
|
|
@@ -31230,7 +31238,7 @@ class EntropyModule {
|
|
|
31230
31238
|
/**
|
|
31231
31239
|
* Generate `n` random bytes as a Uint8Array.
|
|
31232
31240
|
*
|
|
31233
|
-
* SECURITY: this returns raw *server* entropy
|
|
31241
|
+
* SECURITY: this returns raw *server* entropy; it is NOT finished key
|
|
31234
31242
|
* material. Client secret keys MUST hybrid-mix it: XOR the returned bytes with
|
|
31235
31243
|
* a local CSPRNG (`crypto.getRandomValues`) before use, so the server share
|
|
31236
31244
|
* alone can never determine the key.
|
|
@@ -31238,7 +31246,7 @@ class EntropyModule {
|
|
|
31238
31246
|
* @example
|
|
31239
31247
|
* const serverEntropy = await sv.entropy.generateBytes(32);
|
|
31240
31248
|
* const localEntropy = crypto.getRandomValues(new Uint8Array(32));
|
|
31241
|
-
* // Hybrid-mixed key material
|
|
31249
|
+
* // Hybrid-mixed key material, safe to use as a secret key.
|
|
31242
31250
|
* const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
|
|
31243
31251
|
*/
|
|
31244
31252
|
async generateBytes(n) {
|
|
@@ -31287,7 +31295,7 @@ function validateEntropyRequest(bytes, format) {
|
|
|
31287
31295
|
* Web Push registration. It is
|
|
31288
31296
|
* not a tenant's inbox for its own end users: a tenant reads its recipients'
|
|
31289
31297
|
* feeds with `sv.products.notify.getInbox`. The recipient is ALWAYS derived
|
|
31290
|
-
* from the session on the server
|
|
31298
|
+
* from the session on the server: no method takes a `recipient_id`, and any
|
|
31291
31299
|
* account/recipient a caller might try to supply is ignored. This mirrors
|
|
31292
31300
|
* `@sparkvault/sdk-mobile`'s notify client; device push registration is
|
|
31293
31301
|
* intentionally omitted (Expo-only on mobile).
|
|
@@ -31329,7 +31337,7 @@ class NotifyModule {
|
|
|
31329
31337
|
this.http = http;
|
|
31330
31338
|
}
|
|
31331
31339
|
/**
|
|
31332
|
-
* The caller's own inbox feed (newest first). Follow `cursor` to page
|
|
31340
|
+
* The caller's own inbox feed (newest first). Follow `cursor` to page: a
|
|
31333
31341
|
* page can come back short of `limit` yet still carry a non-null cursor.
|
|
31334
31342
|
*
|
|
31335
31343
|
* @example
|
|
@@ -31343,7 +31351,7 @@ class NotifyModule {
|
|
|
31343
31351
|
}
|
|
31344
31352
|
/**
|
|
31345
31353
|
* Bounded unseen badge count for the caller's own inbox. `capped` true means
|
|
31346
|
-
* the true count is at/beyond the ceiling
|
|
31354
|
+
* the true count is at/beyond the ceiling: render "N+".
|
|
31347
31355
|
*
|
|
31348
31356
|
* @example
|
|
31349
31357
|
* const { unread_count, capped } = await sv.notify.getUnreadCount();
|
|
@@ -31355,7 +31363,7 @@ class NotifyModule {
|
|
|
31355
31363
|
/**
|
|
31356
31364
|
* Apply a terminal display state to one of the caller's own rows (idempotent).
|
|
31357
31365
|
* `createdAt` MUST be the row's own `created_at` (round-tripped from the list
|
|
31358
|
-
* row)
|
|
31366
|
+
* row); the id alone cannot address the row.
|
|
31359
31367
|
*
|
|
31360
31368
|
* @example
|
|
31361
31369
|
* await sv.notify.markState('ntf_abc', { createdAt: row.created_at, state: 'read' });
|
|
@@ -31379,7 +31387,7 @@ class NotifyModule {
|
|
|
31379
31387
|
}
|
|
31380
31388
|
/**
|
|
31381
31389
|
* Bulk-mark ONE bounded page of the caller's inbox and return the server's
|
|
31382
|
-
* payload verbatim. `cursor` comes back non-null while rows remain
|
|
31390
|
+
* payload verbatim. `cursor` comes back non-null while rows remain: thread it
|
|
31383
31391
|
* into the next call. `archived` is per-row only (no GSI to page over), so the
|
|
31384
31392
|
* bulk states are `seen` and `read`.
|
|
31385
31393
|
*
|
|
@@ -31414,10 +31422,10 @@ class NotifyModule {
|
|
|
31414
31422
|
* clears the unseen marker too, so the badge zeroes with it. Idempotent.
|
|
31415
31423
|
*
|
|
31416
31424
|
* `complete` is false when the loop stopped at the page bound with rows still
|
|
31417
|
-
* unmarked
|
|
31425
|
+
* unmarked: an inbox deeper than the bound finishes on a second call. Without
|
|
31418
31426
|
* it a truncated drain looks exactly like a finished one.
|
|
31419
31427
|
*
|
|
31420
|
-
* An error mid-drain propagates
|
|
31428
|
+
* An error mid-drain propagates: the pages already marked stay marked, and a
|
|
31421
31429
|
* re-run picks up the remainder.
|
|
31422
31430
|
*
|
|
31423
31431
|
* @example
|
|
@@ -31449,7 +31457,7 @@ class NotifyModule {
|
|
|
31449
31457
|
}
|
|
31450
31458
|
/**
|
|
31451
31459
|
* The platform VAPID public key for `pushManager.subscribe()`. `configured`
|
|
31452
|
-
* is false until the server-side VAPID keypair is provisioned
|
|
31460
|
+
* is false until the server-side VAPID keypair is provisioned: hide the
|
|
31453
31461
|
* enable-notifications affordance while false.
|
|
31454
31462
|
*/
|
|
31455
31463
|
async getWebPushKey() {
|
|
@@ -31563,8 +31571,8 @@ class NotifyModule {
|
|
|
31563
31571
|
}
|
|
31564
31572
|
}
|
|
31565
31573
|
// A subscription made against the current key is reused: registering it
|
|
31566
|
-
// again refreshes its server TTL. One made against another key is dead
|
|
31567
|
-
// push service refuses every push signed with this one
|
|
31574
|
+
// again refreshes its server TTL. One made against another key is dead (its
|
|
31575
|
+
// push service refuses every push signed with this one), so it is replaced.
|
|
31568
31576
|
const held = await registration.pushManager.getSubscription();
|
|
31569
31577
|
const existing = held && isBoundToKey(held, applicationServerKey) ? held : null;
|
|
31570
31578
|
if (held && !existing) {
|
|
@@ -31736,7 +31744,7 @@ class SparkVault {
|
|
|
31736
31744
|
return new SparkVault(config);
|
|
31737
31745
|
}
|
|
31738
31746
|
/**
|
|
31739
|
-
* Whether a sign-in needs completing on this page load
|
|
31747
|
+
* Whether a sign-in needs completing on this page load: a returned handoff
|
|
31740
31748
|
* fragment, or a popup whose result was lost (a mobile opener-tab discard).
|
|
31741
31749
|
* Side effect-free and instance-free, so a host that defers SDK init for
|
|
31742
31750
|
* performance can cheaply decide whether to boot the SDK and call
|
|
@@ -31748,7 +31756,7 @@ class SparkVault {
|
|
|
31748
31756
|
}
|
|
31749
31757
|
/** Get the SDK version */
|
|
31750
31758
|
static get version() {
|
|
31751
|
-
return '17.0.
|
|
31759
|
+
return '17.0.2';
|
|
31752
31760
|
}
|
|
31753
31761
|
}
|
|
31754
31762
|
if (typeof window !== 'undefined') {
|