@sparkvault/sdk-js 17.0.1 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- 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 +255 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +153 -161
- package/dist/index.mjs +255 -229
- 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/help-desk/client.d.ts +0 -4
- package/dist/products/help-desk/kb-types.d.ts +1 -2
- package/dist/products/help-desk/types.d.ts +1 -5
- package/dist/products/help-desk/widget-identity.d.ts +2 -2
- 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.cjs
CHANGED
|
@@ -92,7 +92,7 @@ function givenUpUploadId({ created, uploadId }) {
|
|
|
92
92
|
* The codes Core's activation refuses an upload with, which Forge's refusal
|
|
93
93
|
* map reads (the status is Core's):
|
|
94
94
|
* - UPLOAD_CONTRACT_MISMATCH (409): a finalize or session from another
|
|
95
|
-
* publication contract than Core's, a mixed deployment that converges
|
|
95
|
+
* publication contract than Core's, a mixed deployment that converges, so the
|
|
96
96
|
* upload is kept and its finalize tried again.
|
|
97
97
|
* - UPLOAD_PROTOCOL_RETIRED (410): a session from a contract Core no longer
|
|
98
98
|
* publishes, which never can be.
|
|
@@ -838,7 +838,7 @@ class ValidationError extends SparkVaultError {
|
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
840
|
/**
|
|
841
|
-
* Plan required gate (402 PLAN_REQUIRED)
|
|
841
|
+
* Plan required gate (402 PLAN_REQUIRED): the account has no active
|
|
842
842
|
* subscription and attempted a billable/create action. Surface a subscribe CTA
|
|
843
843
|
* to admins, or "ask your account admin" to members.
|
|
844
844
|
*/
|
|
@@ -869,7 +869,7 @@ class UsageCreditFundingReviewError extends SparkVaultError {
|
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
871
|
/**
|
|
872
|
-
* Quota exceeded gate (402 QUOTA_EXCEEDED)
|
|
872
|
+
* Quota exceeded gate (402 QUOTA_EXCEEDED): a pooled-capacity limit is
|
|
873
873
|
* exhausted. `resource` identifies which pool so callers can point the CTA at
|
|
874
874
|
* the right capacity block.
|
|
875
875
|
*/
|
|
@@ -885,7 +885,7 @@ class QuotaExceededError extends SparkVaultError {
|
|
|
885
885
|
}
|
|
886
886
|
/**
|
|
887
887
|
* Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED or
|
|
888
|
-
* NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED)
|
|
888
|
+
* NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED): the account or selected project
|
|
889
889
|
* does not hold Notify and attempted a send that names no accepted send's
|
|
890
890
|
* `sendId` (a replay of an accepted send, the same request under its `sendId`,
|
|
891
891
|
* is answered with the stored send), or a config save that selects a new
|
|
@@ -1153,12 +1153,24 @@ const SPARKVAULT_FILES_HOST = 'files.sv';
|
|
|
1153
1153
|
/**
|
|
1154
1154
|
* The help-desk domain: each organization's help desk lives at a host under
|
|
1155
1155
|
* it, and every custom help-desk domain points its CNAME at it. The whole
|
|
1156
|
-
* subtree is reserved
|
|
1157
|
-
* domain
|
|
1156
|
+
* subtree is reserved (no organization claims a name in it as its own
|
|
1157
|
+
* domain), but none of its hosts is owned: a tenant's help-desk host is never
|
|
1158
1158
|
* trusted the way a platform host is (isSparkVaultOwnedHostname).
|
|
1159
1159
|
*/
|
|
1160
1160
|
const SPARKVAULT_HELP_DESK_DOMAIN = 'help.sv';
|
|
1161
1161
|
|
|
1162
|
+
/**
|
|
1163
|
+
* The Help Desk sign-in host (`https://signin.help.sv`): the one fixed host of
|
|
1164
|
+
* the window Help Desk's own sign-in opens (`/{desk_id}/{challenge_id}`) and
|
|
1165
|
+
* of the one redirect URI its Identity client registers (`/callback`). Its
|
|
1166
|
+
* label is a reserved organization handle (organization-handle.js), so no desk
|
|
1167
|
+
* can hold it, and the help.sv Worker serves the portal's shell on it as on
|
|
1168
|
+
* every host of the domain. Like every host under the help-desk domain it is
|
|
1169
|
+
* reserved and not owned (isSparkVaultOwnedHostname). Core takes the window's
|
|
1170
|
+
* steps only from exactly this origin.
|
|
1171
|
+
*/
|
|
1172
|
+
const SPARKVAULT_HELP_DESK_SIGN_IN_HOST = `signin.${SPARKVAULT_HELP_DESK_DOMAIN}`;
|
|
1173
|
+
|
|
1162
1174
|
/**
|
|
1163
1175
|
* Notify's mail domain: each organization's Notify mail goes from a host under
|
|
1164
1176
|
* it, as its help desk's goes from one under the help-desk domain. On the web
|
|
@@ -1374,7 +1386,7 @@ class SparkVaultApi {
|
|
|
1374
1386
|
constructor(timeoutMs = DEFAULT_TIMEOUT_MS$1) {
|
|
1375
1387
|
/**
|
|
1376
1388
|
* Abort controller for the current session. Replaced by resetSession()
|
|
1377
|
-
* at the start of every user-facing session
|
|
1389
|
+
* at the start of every user-facing session, so an aborted controller can
|
|
1378
1390
|
* never leak into the next session.
|
|
1379
1391
|
*/
|
|
1380
1392
|
this.closeController = new AbortController();
|
|
@@ -1388,7 +1400,7 @@ class SparkVaultApi {
|
|
|
1388
1400
|
isAborted() {
|
|
1389
1401
|
return this.closeController.signal.aborted;
|
|
1390
1402
|
}
|
|
1391
|
-
/** The current session's abort signal
|
|
1403
|
+
/** The current session's abort signal, for callers that need to wire it into XHR/etc. */
|
|
1392
1404
|
getAbortSignal() {
|
|
1393
1405
|
return this.closeController.signal;
|
|
1394
1406
|
}
|
|
@@ -1438,7 +1450,7 @@ class SparkVaultApi {
|
|
|
1438
1450
|
* transport shares.
|
|
1439
1451
|
*/
|
|
1440
1452
|
rawRequest(url, options) {
|
|
1441
|
-
// Only send Content-Type when there's actually a body
|
|
1453
|
+
// Only send Content-Type when there's actually a body; otherwise GETs
|
|
1442
1454
|
// with no payload would carry a misleading content-type header.
|
|
1443
1455
|
const headers = { Accept: 'application/json' };
|
|
1444
1456
|
if (options.body !== undefined)
|
|
@@ -1669,7 +1681,7 @@ class HttpClient {
|
|
|
1669
1681
|
* and every other answer is the base error under the service's own code.
|
|
1670
1682
|
* Each carries the service's code (`serviceCode`), which tells apart two
|
|
1671
1683
|
* refusals that share a typed class's `code`, and the answer's `Retry-After`
|
|
1672
|
-
* (`retryAfterMs`), the floor for whoever retries it
|
|
1684
|
+
* (`retryAfterMs`), the floor for whoever retries it: the SDK's own
|
|
1673
1685
|
* transfers when the answer is a download link's mint, and the host page
|
|
1674
1686
|
* otherwise.
|
|
1675
1687
|
*/
|
|
@@ -1695,7 +1707,7 @@ class HttpClient {
|
|
|
1695
1707
|
case 403:
|
|
1696
1708
|
// A Notify send, or a config save selecting a new sending domain, refused
|
|
1697
1709
|
// because the account does not hold Notify is a billing gate, not a
|
|
1698
|
-
// credential problem
|
|
1710
|
+
// credential problem; give it its own catchable type.
|
|
1699
1711
|
if (code === 'NOTIFY_SUBSCRIPTION_REQUIRED' || code === 'NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED') {
|
|
1700
1712
|
return new NotifySubscriptionRequiredError(message, details, retryAfterMs, code);
|
|
1701
1713
|
}
|
|
@@ -2709,9 +2721,9 @@ function identityTypesParam(types) {
|
|
|
2709
2721
|
return types ? { [SIGNIN_IDENTITY_TYPES.param]: formatSigninIdentityTypes(types) } : {};
|
|
2710
2722
|
}
|
|
2711
2723
|
/**
|
|
2712
|
-
* This page as a navigation return target: origin, path, and query
|
|
2713
|
-
* carries the page's own state
|
|
2714
|
-
* destination)
|
|
2724
|
+
* This page as a navigation return target: origin, path, and query (the query
|
|
2725
|
+
* carries the page's own state, whether app routing or the sign-in page's validated
|
|
2726
|
+
* destination), without the fragment, which is the channel a result returns
|
|
2715
2727
|
* in.
|
|
2716
2728
|
*/
|
|
2717
2729
|
function currentPageReturnUrl() {
|
|
@@ -2924,7 +2936,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
2924
2936
|
}
|
|
2925
2937
|
/**
|
|
2926
2938
|
* Check whether the SVID resolved from an email or phone has registered
|
|
2927
|
-
* passkeys (`has_passkey`; cross-tenant
|
|
2939
|
+
* passkeys (`has_passkey`; cross-tenant, single global RP), for a
|
|
2928
2940
|
* verification that admits passkeys.
|
|
2929
2941
|
*/
|
|
2930
2942
|
async checkPasskey(identity, identityType = 'email', authContext) {
|
|
@@ -2933,7 +2945,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
2933
2945
|
}
|
|
2934
2946
|
/**
|
|
2935
2947
|
* Redeem a one-time sign-in code (with its PKCE verifier) for the sign-in
|
|
2936
|
-
* result
|
|
2948
|
+
* result: the shared return leg for `flow: 'redirect'` and the silent SSO
|
|
2937
2949
|
* self-heal. The code arrives in the URL fragment after the hosted page
|
|
2938
2950
|
* navigates back; it is single-use, 60s-lived, and bound to this page's
|
|
2939
2951
|
* origin server-side.
|
|
@@ -3069,7 +3081,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
3069
3081
|
}
|
|
3070
3082
|
/**
|
|
3071
3083
|
* Skip a post-login recommendation, suppressing it server-side for 30 days.
|
|
3072
|
-
* Authorized by the login's verification token. Best-effort
|
|
3084
|
+
* Authorized by the login's verification token. Best-effort: a failure here
|
|
3073
3085
|
* must not block completing the login.
|
|
3074
3086
|
*/
|
|
3075
3087
|
async dismissRecommendation(params) {
|
|
@@ -3144,7 +3156,7 @@ class IdentityApi extends SparkVaultApi {
|
|
|
3144
3156
|
});
|
|
3145
3157
|
}
|
|
3146
3158
|
/**
|
|
3147
|
-
* Claim the SparkLink click's result by kindling
|
|
3159
|
+
* Claim the SparkLink click's result by kindling, the WebSocket-loss
|
|
3148
3160
|
* fallback. The SDK calls this when its socket was suspended with the tab and
|
|
3149
3161
|
* it refocuses. Returns what the click produced (a completed login, or its
|
|
3150
3162
|
* second-factor challenge), or null while still pending (not yet clicked) or
|
|
@@ -3180,7 +3192,7 @@ function signinRefParam(signinRef) {
|
|
|
3180
3192
|
* Read a SparkLink result event. The WebSocket push and the kindling reclaim
|
|
3181
3193
|
* carry the same server-built event, so this is the one reader for both.
|
|
3182
3194
|
* Returns null for anything that is not a usable result: a still-pending
|
|
3183
|
-
* reclaim, or an event missing what its type requires
|
|
3195
|
+
* reclaim, or an event missing what its type requires, such as a challenge without a
|
|
3184
3196
|
* ticket, or a completed login with neither a token (default flow) nor the
|
|
3185
3197
|
* redirect that continues it (OIDC hosted login).
|
|
3186
3198
|
*/
|
|
@@ -3270,7 +3282,7 @@ class IdentityApiError extends SparkVaultError {
|
|
|
3270
3282
|
* script, and the invisible formatting marks a contacts app wraps a number in.
|
|
3271
3283
|
* The separators and marks are dropped. Anything else is refused, never
|
|
3272
3284
|
* dropped: stripping it would fold part of the text into the number and deliver
|
|
3273
|
-
* to someone else's line
|
|
3285
|
+
* to someone else's line. A letter or a dial-control character (',' and ';'
|
|
3274
3286
|
* pause, '#' and '*' are keypad tones) carries an extension ("x2", ",89"), a
|
|
3275
3287
|
* digit of another script ('٧', '7') is a digit the ASCII read would silently
|
|
3276
3288
|
* lose, and a '+' after a digit declares nothing.
|
|
@@ -3284,7 +3296,7 @@ class IdentityApiError extends SparkVaultError {
|
|
|
3284
3296
|
/** A '+' before any digit: the caller declared the country code. */
|
|
3285
3297
|
const DECLARED_COUNTRY_CODE = /^\D*\+/;
|
|
3286
3298
|
|
|
3287
|
-
/** E.164 digits once a country code is declared: 8
|
|
3299
|
+
/** E.164 digits once a country code is declared: 8 to 15, never a leading 0. */
|
|
3288
3300
|
const E164_DIGITS = /^[1-9]\d{7,14}$/;
|
|
3289
3301
|
|
|
3290
3302
|
/** Invisible formatting marks (bidi embeddings, zero-width characters), in any number. */
|
|
@@ -3773,12 +3785,12 @@ class VerificationState {
|
|
|
3773
3785
|
* abandoned-window backstop, and a `window.closed` poll that surfaces a manual
|
|
3774
3786
|
* close as a cancellation.
|
|
3775
3787
|
*/
|
|
3776
|
-
/** Default popup dimensions
|
|
3788
|
+
/** Default popup dimensions: a centered login/ceremony window. */
|
|
3777
3789
|
const DEFAULT_WIDTH = 480;
|
|
3778
3790
|
const DEFAULT_HEIGHT = 640;
|
|
3779
3791
|
/**
|
|
3780
3792
|
* Default timeout for popup operations: 30 minutes. This is an
|
|
3781
|
-
* abandoned-window backstop
|
|
3793
|
+
* abandoned-window backstop, never a liveness gate. A person mid-login is
|
|
3782
3794
|
* often slow for legitimate reasons (waiting out an OTP resend backoff,
|
|
3783
3795
|
* fetching their phone for a cross-device passkey, hunting for an alternative
|
|
3784
3796
|
* method), and yanking the window away from them mid-flow is far worse than
|
|
@@ -3796,7 +3808,7 @@ const CLOSED_POLL_INTERVAL_MS = 500;
|
|
|
3796
3808
|
* (host page serves `Cross-Origin-Opener-Policy: same-origin`) flips to
|
|
3797
3809
|
* `closed` on the first poll while the real window stays open in front of the
|
|
3798
3810
|
* user; a human closing a window they asked for takes longer than this. A slow
|
|
3799
|
-
* network can only delay the ready ping
|
|
3811
|
+
* network can only delay the ready ping (it never makes `closed` true), so a
|
|
3800
3812
|
* legitimate popup on a slow connection cannot trip this.
|
|
3801
3813
|
*/
|
|
3802
3814
|
const SEVERED_DETECT_WINDOW_MS = 2500;
|
|
@@ -3816,7 +3828,7 @@ class PopupLauncher {
|
|
|
3816
3828
|
return new Promise((resolve, reject) => {
|
|
3817
3829
|
const left = Math.round((window.screen.width - width) / 2);
|
|
3818
3830
|
const top = Math.round((window.screen.height - height) / 2);
|
|
3819
|
-
// Synchronous open inside the caller's user gesture
|
|
3831
|
+
// Synchronous open inside the caller's user gesture: any await before
|
|
3820
3832
|
// this point would let the browser treat the popup as programmatic and
|
|
3821
3833
|
// block it.
|
|
3822
3834
|
const popup = window.open(options.url, options.windowName, `width=${width},height=${height},left=${left},top=${top},popup=1`);
|
|
@@ -3834,7 +3846,7 @@ class PopupLauncher {
|
|
|
3834
3846
|
clearInterval(pollClosedId);
|
|
3835
3847
|
};
|
|
3836
3848
|
const handleMessage = (event) => {
|
|
3837
|
-
// Only trust the server-validated Identity origin
|
|
3849
|
+
// Only trust the server-validated Identity origin, never the broader
|
|
3838
3850
|
// sparkvault.com family (XSS or subdomain-takeover relay).
|
|
3839
3851
|
if (event.origin !== options.trustedOrigin) {
|
|
3840
3852
|
return;
|
|
@@ -3872,7 +3884,7 @@ class PopupLauncher {
|
|
|
3872
3884
|
settled = true;
|
|
3873
3885
|
cleanup();
|
|
3874
3886
|
// `closed` going true right after open, before the page ever pinged,
|
|
3875
|
-
// is a dead handle (COOP severance
|
|
3887
|
+
// is a dead handle (COOP severance; see SEVERED_DETECT_WINDOW_MS),
|
|
3876
3888
|
// not a person closing the window: the real window is still open but
|
|
3877
3889
|
// can never postMessage back, so retrying the popup can never work.
|
|
3878
3890
|
if (!readyReceived && Date.now() - openedAt <= SEVERED_DETECT_WINDOW_MS) {
|
|
@@ -3904,7 +3916,7 @@ const POPUP_WIDTH = 450;
|
|
|
3904
3916
|
const POPUP_HEIGHT = 500;
|
|
3905
3917
|
/**
|
|
3906
3918
|
* Device-level hint the Identity API sets on every completed passkey login
|
|
3907
|
-
* (products/product-identity/src/utils/passkey-hint-cookie.js
|
|
3919
|
+
* (products/product-identity/src/utils/passkey-hint-cookie.js; the cookie
|
|
3908
3920
|
* NAME is the wire contract between the two). Host-locked to the Identity
|
|
3909
3921
|
* origin and deliberately JS-readable, it means "a passkey login has completed
|
|
3910
3922
|
* in this browser", which is what licenses auto-starting the discoverable
|
|
@@ -3971,7 +3983,7 @@ class PasskeyHandler {
|
|
|
3971
3983
|
* Verify user with an existing passkey.
|
|
3972
3984
|
*
|
|
3973
3985
|
* On the Identity origin (the hosted widget / hosted login) the ceremony runs
|
|
3974
|
-
* inline
|
|
3986
|
+
* inline: same-origin with the RP id, one tap, no popup. On a third-party
|
|
3975
3987
|
* origin the rpId would not match the document, so it falls back to the popup
|
|
3976
3988
|
* served from the Identity origin. (Verification, unlike registration, is
|
|
3977
3989
|
* supported in cross-origin iframes, so the embedded widget uses the inline
|
|
@@ -3985,7 +3997,7 @@ class PasskeyHandler {
|
|
|
3985
3997
|
}
|
|
3986
3998
|
/**
|
|
3987
3999
|
* True when the SDK is running ON the Identity origin and the browser exposes
|
|
3988
|
-
* WebAuthn
|
|
4000
|
+
* WebAuthn, the only place an inline ceremony's rpId matches the document.
|
|
3989
4001
|
*/
|
|
3990
4002
|
canRunCeremonyInline() {
|
|
3991
4003
|
return typeof window !== 'undefined'
|
|
@@ -3996,8 +4008,8 @@ class PasskeyHandler {
|
|
|
3996
4008
|
/**
|
|
3997
4009
|
* True when the discoverable ceremony may be fired WITHOUT a user gesture:
|
|
3998
4010
|
* the flow is running on the Identity origin (the inline ceremony needs no
|
|
3999
|
-
* popup, so no gesture) AND this browser carries the passkey-hint cookie
|
|
4000
|
-
* a passkey login has completed here before. First visits never see an
|
|
4011
|
+
* popup, so no gesture) AND this browser carries the passkey-hint cookie
|
|
4012
|
+
* (a passkey login has completed here before). First visits never see an
|
|
4001
4013
|
* unprompted system sheet.
|
|
4002
4014
|
*/
|
|
4003
4015
|
canAutoVerify() {
|
|
@@ -4335,7 +4347,7 @@ class OtpHandler {
|
|
|
4335
4347
|
signinRef: this.state.signinRef,
|
|
4336
4348
|
});
|
|
4337
4349
|
// Primary factor accepted, but the account requires a second factor.
|
|
4338
|
-
// Not a success and not a retry
|
|
4350
|
+
// Not a success and not a retry: hand the ticket up to drive the 2FA step.
|
|
4339
4351
|
if (response.second_factor_required && response.ticket) {
|
|
4340
4352
|
return {
|
|
4341
4353
|
success: false,
|
|
@@ -4870,7 +4882,7 @@ function methodIconGlyph(iconName) {
|
|
|
4870
4882
|
case 'users':
|
|
4871
4883
|
return createUsersIcon();
|
|
4872
4884
|
default:
|
|
4873
|
-
// Neutral placeholder
|
|
4885
|
+
// Neutral placeholder, deliberately NOT the email envelope, so an
|
|
4874
4886
|
// unmapped icon name surfaces the gap instead of impersonating email.
|
|
4875
4887
|
return createGenericMethodIcon();
|
|
4876
4888
|
}
|
|
@@ -4886,7 +4898,7 @@ function createEmailIcon() {
|
|
|
4886
4898
|
return svg;
|
|
4887
4899
|
}
|
|
4888
4900
|
function createSmsIcon() {
|
|
4889
|
-
// Chat bubble
|
|
4901
|
+
// Chat bubble: the text-message channel, distinct from the voice-call
|
|
4890
4902
|
// handset (createPhoneIcon) so SMS and voice OTP read differently.
|
|
4891
4903
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
4892
4904
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -4909,7 +4921,7 @@ function createPhoneIcon() {
|
|
|
4909
4921
|
return svg;
|
|
4910
4922
|
}
|
|
4911
4923
|
function createGenericMethodIcon() {
|
|
4912
|
-
// Neutral rounded badge with a center dot
|
|
4924
|
+
// Neutral rounded badge with a center dot: a placeholder for an unmapped
|
|
4913
4925
|
// icon name, deliberately unlike any real method glyph.
|
|
4914
4926
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
4915
4927
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -6081,7 +6093,7 @@ class PasskeyView {
|
|
|
6081
6093
|
*
|
|
6082
6094
|
* Shown behind the browser's passkey sheet while an auto-started discoverable
|
|
6083
6095
|
* ceremony runs (returning browsers carrying the passkey-hint cookie). The
|
|
6084
|
-
* ceremony was fired without a click, so this screen has no action button
|
|
6096
|
+
* ceremony was fired without a click, so this screen has no action button,
|
|
6085
6097
|
* only a live status and an escape hatch to the identifier form for anyone
|
|
6086
6098
|
* who wants a different method (or whose sheet hangs).
|
|
6087
6099
|
*/
|
|
@@ -6206,7 +6218,7 @@ class PasskeyPromptView {
|
|
|
6206
6218
|
* Includes a "Not now" skip that suppresses this method's prompt for 30 days
|
|
6207
6219
|
* (handled by the renderer).
|
|
6208
6220
|
*
|
|
6209
|
-
* Sibling of PasskeyPromptView
|
|
6221
|
+
* Sibling of PasskeyPromptView: same low-friction, skippable shape.
|
|
6210
6222
|
*/
|
|
6211
6223
|
class BackupVerifyView {
|
|
6212
6224
|
constructor(props) {
|
|
@@ -6530,7 +6542,7 @@ class SparkLinkWaitingView {
|
|
|
6530
6542
|
* Professional enterprise-quality error display with clear visual hierarchy.
|
|
6531
6543
|
*/
|
|
6532
6544
|
/**
|
|
6533
|
-
* Error codes that mean the site owner's Identity access is blocked
|
|
6545
|
+
* Error codes that mean the site owner's Identity access is blocked: the
|
|
6534
6546
|
* free trial was exhausted or expired, or a paid plan hit its capacity wall.
|
|
6535
6547
|
* The end user can do nothing about these, so the ErrorView renders a friendly,
|
|
6536
6548
|
* non-leaky interstitial (no "Try Again", no debug code badge) exactly like
|
|
@@ -6647,7 +6659,7 @@ class ErrorView {
|
|
|
6647
6659
|
contentSection.appendChild(title);
|
|
6648
6660
|
contentSection.appendChild(message);
|
|
6649
6661
|
if (isGenuine) {
|
|
6650
|
-
// Error code badge
|
|
6662
|
+
// Error code badge, useful for debugging genuine errors only.
|
|
6651
6663
|
const codeBadge = document.createElement('div');
|
|
6652
6664
|
codeBadge.className = 'sv-error-code-badge';
|
|
6653
6665
|
const codeLabel = document.createElement('span');
|
|
@@ -6758,7 +6770,7 @@ function withAlpha(hex, alpha) {
|
|
|
6758
6770
|
* Service Unavailable View
|
|
6759
6771
|
*
|
|
6760
6772
|
* Shown when the identity config endpoint is unreachable.
|
|
6761
|
-
* Clean, professional, branded
|
|
6773
|
+
* Clean, professional, branded, with no error codes or technical jargon.
|
|
6762
6774
|
*/
|
|
6763
6775
|
function createShieldIcon() {
|
|
6764
6776
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
@@ -6857,8 +6869,8 @@ class ServiceUnavailableView {
|
|
|
6857
6869
|
*
|
|
6858
6870
|
* Full-dialog terminal screen shown when the SparkVault Identity Product has
|
|
6859
6871
|
* not been configured for the account that the JS SDK is configured against. The
|
|
6860
|
-
* audience is the website owner / developer
|
|
6861
|
-
* surface, not an end-user error
|
|
6872
|
+
* audience is the website owner / developer: this is a misconfiguration
|
|
6873
|
+
* surface, not an end-user error, so the dialog drops customer branding and
|
|
6862
6874
|
* presents itself as an unmistakable SparkVault notice.
|
|
6863
6875
|
*/
|
|
6864
6876
|
const ACTIVATION_URL = 'https://app.sparkvault.com/products/identity';
|
|
@@ -7023,8 +7035,8 @@ class ProductNotConfiguredView {
|
|
|
7023
7035
|
*
|
|
7024
7036
|
* Full-dialog terminal screen shown when the embedding site's origin is not in
|
|
7025
7037
|
* the account's verified-domains allowlist. The audience is the website owner /
|
|
7026
|
-
* developer
|
|
7027
|
-
* is permanent (retrying never clears an origin block)
|
|
7038
|
+
* developer: this is a misconfiguration surface, not an end-user error, and it
|
|
7039
|
+
* is permanent (retrying never clears an origin block), so the dialog drops
|
|
7028
7040
|
* customer branding, offers no "Try Again", names the blocked origin, and
|
|
7029
7041
|
* points to the place that fixes it. Reuses the SparkVault-notice styling from
|
|
7030
7042
|
* the product-not-configured view.
|
|
@@ -7047,7 +7059,7 @@ function createBadge() {
|
|
|
7047
7059
|
surface.setAttribute('stroke', DS.slate200);
|
|
7048
7060
|
surface.setAttribute('stroke-width', '1');
|
|
7049
7061
|
svg.appendChild(surface);
|
|
7050
|
-
// Globe with a slash
|
|
7062
|
+
// Globe with a slash: an unrecognized domain.
|
|
7051
7063
|
const globe = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
7052
7064
|
globe.setAttribute('cx', '32');
|
|
7053
7065
|
globe.setAttribute('cy', '32');
|
|
@@ -7150,7 +7162,7 @@ class OriginNotAllowedView {
|
|
|
7150
7162
|
ownerLabel.textContent = 'Are you the site owner?';
|
|
7151
7163
|
const ownerHint = document.createElement('span');
|
|
7152
7164
|
ownerHint.className = 'sv-not-activated-owner-hint';
|
|
7153
|
-
// textContent (not innerHTML)
|
|
7165
|
+
// textContent (not innerHTML): the origin is server-reported but we never
|
|
7154
7166
|
// trust it into the DOM as markup.
|
|
7155
7167
|
ownerHint.textContent = this.props.origin
|
|
7156
7168
|
? `Add ${this.props.origin} to your verified domains in SparkVault, then reload this page.`
|
|
@@ -7244,7 +7256,7 @@ function progressHook() {
|
|
|
7244
7256
|
function progressStart() { progressHook()?.start(); }
|
|
7245
7257
|
function progressDone() { progressHook()?.done(); }
|
|
7246
7258
|
/**
|
|
7247
|
-
* End-user copy for a blocked Identity. Intentionally non-leaky
|
|
7259
|
+
* End-user copy for a blocked Identity. Intentionally non-leaky: it never names
|
|
7248
7260
|
* the trial, billing, usage, or any owner-facing internal. When the site's
|
|
7249
7261
|
* company name is known it is surfaced so the screen reads as the site's own and
|
|
7250
7262
|
* the visitor is pointed back to the site for help (never to SparkVault). The
|
|
@@ -7349,7 +7361,7 @@ class IdentityRenderer {
|
|
|
7349
7361
|
* Seed the verification identity from the render options, deriving the
|
|
7350
7362
|
* channel (email vs phone) from the value itself rather than trusting which
|
|
7351
7363
|
* option field carried it. The hosted login forwards a simple-mode identity
|
|
7352
|
-
* hint
|
|
7364
|
+
* hint (which may be a phone number) as `email`; keying off the value keeps
|
|
7353
7365
|
* the method list AND the OTP delivery target aligned with the real channel
|
|
7354
7366
|
* instead of falling back to the email methods. Normalizes to E.164 /
|
|
7355
7367
|
* lowercased email so the code goes to the canonical identifier.
|
|
@@ -7375,7 +7387,7 @@ class IdentityRenderer {
|
|
|
7375
7387
|
}
|
|
7376
7388
|
/**
|
|
7377
7389
|
* True when the identifier is fixed by the flow and the person must prove
|
|
7378
|
-
* that exact identity
|
|
7390
|
+
* that exact identity: the invite / simple-redirect case. There is no
|
|
7379
7391
|
* identifier-entry step to return to, so the picker must not offer a
|
|
7380
7392
|
* "change identity" back link that would let them verify a different
|
|
7381
7393
|
* identifier than the one they were invited as.
|
|
@@ -7422,7 +7434,7 @@ class IdentityRenderer {
|
|
|
7422
7434
|
if (this.api.isConfigPreloaded()) {
|
|
7423
7435
|
// Config fetch already started - race it against a 50ms timeout
|
|
7424
7436
|
// If config is ready (or almost ready), we skip the loading flash.
|
|
7425
|
-
// A rejected preload (e.g. product_not_configured) must not abort start()
|
|
7437
|
+
// A rejected preload (e.g. product_not_configured) must not abort start():
|
|
7426
7438
|
// swallow here and let the in-modal try/catch below route to the
|
|
7427
7439
|
// correct error view.
|
|
7428
7440
|
const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(null), 50));
|
|
@@ -7471,8 +7483,8 @@ class IdentityRenderer {
|
|
|
7471
7483
|
* would otherwise escape. In the default embedded/dialog mode that escape is
|
|
7472
7484
|
* exactly the "closes silently" failure: the host's `onError` runs, the
|
|
7473
7485
|
* embedding page tears the iframe down, and the user is left with no message.
|
|
7474
|
-
* Render the error in the SparkVault dialog
|
|
7475
|
-
* in-flow error already behaves
|
|
7486
|
+
* Render the error in the SparkVault dialog, consistent with how every
|
|
7487
|
+
* in-flow error already behaves, so the dialog stays open and the user can
|
|
7476
7488
|
* retry or close it (→ onCancel).
|
|
7477
7489
|
*/
|
|
7478
7490
|
showStartupError(error) {
|
|
@@ -7486,7 +7498,7 @@ class IdentityRenderer {
|
|
|
7486
7498
|
* Map a config-fetch error to the appropriate terminal view.
|
|
7487
7499
|
*
|
|
7488
7500
|
* Two failures are permanent developer-misconfigurations, not transient
|
|
7489
|
-
* outages, so they get dedicated terminal screens (no "Try Again"
|
|
7501
|
+
* outages, so they get dedicated terminal screens (no "Try Again", since retrying
|
|
7490
7502
|
* can never clear them) instead of the generic service-unavailable view:
|
|
7491
7503
|
* - `product_not_configured`: the account has not configured Identity.
|
|
7492
7504
|
* - `ORIGIN_NOT_ALLOWED`: this site's domain is not on the account's
|
|
@@ -7755,7 +7767,7 @@ class IdentityRenderer {
|
|
|
7755
7767
|
}
|
|
7756
7768
|
// Returning browser on the Identity origin (passkey-hint cookie present):
|
|
7757
7769
|
// auto-start the discoverable ceremony instead of asking for an identifier
|
|
7758
|
-
//
|
|
7770
|
+
// (the Google-style one-touch return). A cancel lands on the identifier
|
|
7759
7771
|
// form, which keeps a "Sign in with a passkey" way back in. A provider
|
|
7760
7772
|
// that starts on its own once the pending reference lands goes first, as
|
|
7761
7773
|
// with the reference held (startWithFederation), so the identifier form
|
|
@@ -7784,7 +7796,7 @@ class IdentityRenderer {
|
|
|
7784
7796
|
* Fired on open for returning browsers and from the identifier form's
|
|
7785
7797
|
* "Sign in with a passkey" shortcut. Anything short of a terminal outcome
|
|
7786
7798
|
* (dismissed sheet, no credential on the device, transient failure) falls
|
|
7787
|
-
* back to the identifier form with no error banner
|
|
7799
|
+
* back to the identifier form with no error banner: the person simply
|
|
7788
7800
|
* lands where a first-time visitor starts.
|
|
7789
7801
|
*/
|
|
7790
7802
|
async launchDiscoverableVerify() {
|
|
@@ -8089,7 +8101,7 @@ class IdentityRenderer {
|
|
|
8089
8101
|
// Leaving the SparkLink waiting view (e.g. "Choose another method") must
|
|
8090
8102
|
// tear down its WebSocket + refocus listeners and clear the kindling, or a
|
|
8091
8103
|
// later tab refocus would fire a stale claim for an abandoned flow.
|
|
8092
|
-
// Idempotent
|
|
8104
|
+
// Idempotent: a no-op when SparkLink was never armed.
|
|
8093
8105
|
this.cleanupSparkLink();
|
|
8094
8106
|
const autoRoute = options.autoRoute !== false;
|
|
8095
8107
|
if (!this.sdkConfig)
|
|
@@ -8154,7 +8166,7 @@ class IdentityRenderer {
|
|
|
8154
8166
|
}
|
|
8155
8167
|
// When a passkey is already registered for this identifier, jump
|
|
8156
8168
|
// straight to the WebAuthn ceremony instead of asking the user to
|
|
8157
|
-
// pick a method
|
|
8169
|
+
// pick a method: it is the safest, fastest option. The back arrow on
|
|
8158
8170
|
// the passkey view re-enters this method with autoRoute=false so the
|
|
8159
8171
|
// user lands on the full picker (passkey still listed) and can pick
|
|
8160
8172
|
// a code or SparkLink instead. A provider that starts on its own once the
|
|
@@ -8188,7 +8200,7 @@ class IdentityRenderer {
|
|
|
8188
8200
|
// - a list the provider is missing from only while the page's ask for the
|
|
8189
8201
|
// sign-in's reference is out (federationAwaitingReference): with the
|
|
8190
8202
|
// reference held the provider leads it, so it is never one method.
|
|
8191
|
-
// (Passkey auto-route above still applies
|
|
8203
|
+
// (Passkey auto-route above still applies: a biometric prompt costs
|
|
8192
8204
|
// nothing and can be dismissed.)
|
|
8193
8205
|
const sendsToSuppliedPhone = this.identityPrefilled && methods[0].identityType === 'phone';
|
|
8194
8206
|
const heldFederation = methods[0].type === 'federation' && !this.federationMayAutoStart;
|
|
@@ -8293,7 +8305,7 @@ class IdentityRenderer {
|
|
|
8293
8305
|
}
|
|
8294
8306
|
handleIdentitySubmit(result) {
|
|
8295
8307
|
this.verificationState.setIdentity(result.value, result.type);
|
|
8296
|
-
// The person typed this identifier, so it is theirs to change
|
|
8308
|
+
// The person typed this identifier, so it is theirs to change: a no-hint
|
|
8297
8309
|
// simple-mode session must keep the back link + single-method auto-proceed.
|
|
8298
8310
|
this.identityPrefilled = false;
|
|
8299
8311
|
this.showMethodSelect();
|
|
@@ -8389,7 +8401,7 @@ class IdentityRenderer {
|
|
|
8389
8401
|
if (!result.success) {
|
|
8390
8402
|
this.cleanupSparkLink();
|
|
8391
8403
|
// A blocked Identity (trial exhausted/expired, paid capacity) is
|
|
8392
|
-
// terminal
|
|
8404
|
+
// terminal: show the "sign-in unavailable" interstitial, not a
|
|
8393
8405
|
// retryable "Try Again" that invites retrying a permanently-blocked
|
|
8394
8406
|
// login. Mirrors the otp send path.
|
|
8395
8407
|
if (this.renderBlockedInterstitial(result.errorCode))
|
|
@@ -8477,7 +8489,7 @@ class IdentityRenderer {
|
|
|
8477
8489
|
else if (this.renderBlockedInterstitial(result.errorCode)) ;
|
|
8478
8490
|
else if (this.renderIdentityTypeRefusal(result.errorCode, result.error)) ;
|
|
8479
8491
|
else if (result.errorCode === 'identity_locked') {
|
|
8480
|
-
// The identity is locked down
|
|
8492
|
+
// The identity is locked down: a dedicated, actionable state, not a
|
|
8481
8493
|
// generic "invalid code" retry. The person must manage it at auth.sv.
|
|
8482
8494
|
this.setState({
|
|
8483
8495
|
view: 'error',
|
|
@@ -8548,7 +8560,7 @@ class IdentityRenderer {
|
|
|
8548
8560
|
if (error instanceof IdentityApiError && this.renderIdentityTypeRefusal(error.code, message))
|
|
8549
8561
|
return;
|
|
8550
8562
|
// The login ticket is not consumed on a wrong code, so the user can retry
|
|
8551
|
-
// against the same ticket
|
|
8563
|
+
// against the same ticket: re-render the view carrying the error.
|
|
8552
8564
|
this.setState({ view: 'two-factor', ticket, methods, error: message });
|
|
8553
8565
|
}
|
|
8554
8566
|
}
|
|
@@ -8605,14 +8617,14 @@ class IdentityRenderer {
|
|
|
8605
8617
|
return true;
|
|
8606
8618
|
}
|
|
8607
8619
|
if (this.renderBlockedInterstitial(result.errorCode)) {
|
|
8608
|
-
// Terminal interstitial already rendered
|
|
8620
|
+
// Terminal interstitial already rendered: the owner must subscribe.
|
|
8609
8621
|
return true;
|
|
8610
8622
|
}
|
|
8611
8623
|
if (this.renderIdentityTypeRefusal(result.errorCode, result.error)) {
|
|
8612
8624
|
return true;
|
|
8613
8625
|
}
|
|
8614
8626
|
if (result.errorCode === 'identity_locked') {
|
|
8615
|
-
// Dedicated state
|
|
8627
|
+
// Dedicated state: retrying cannot unlock the identity.
|
|
8616
8628
|
this.setState({
|
|
8617
8629
|
view: 'error',
|
|
8618
8630
|
code: 'identity_locked',
|
|
@@ -8636,7 +8648,7 @@ class IdentityRenderer {
|
|
|
8636
8648
|
void this.showMethodSelect({ autoRoute: false });
|
|
8637
8649
|
}
|
|
8638
8650
|
else if (result.errorType === 'not_found') {
|
|
8639
|
-
// No passkey yet
|
|
8651
|
+
// No passkey yet: pivot the same screen to registration.
|
|
8640
8652
|
this.setState({
|
|
8641
8653
|
view: 'passkey',
|
|
8642
8654
|
recipient: this.recipient,
|
|
@@ -8690,7 +8702,7 @@ class IdentityRenderer {
|
|
|
8690
8702
|
}
|
|
8691
8703
|
/**
|
|
8692
8704
|
* Leave for the social provider. The renderer runs on the Identity origin's
|
|
8693
|
-
* sign-in page, and the round trip returns to that same page
|
|
8705
|
+
* sign-in page, and the round trip returns to that same page, query intact,
|
|
8694
8706
|
* because the query carries the destination the page was opened for (the
|
|
8695
8707
|
* popup's `origin`, or the redirect mode's handoff parameters), which the
|
|
8696
8708
|
* page re-gates before releasing the result. The state stored here is what
|
|
@@ -8857,7 +8869,7 @@ class IdentityRenderer {
|
|
|
8857
8869
|
* The server returns an ordered `recommendations` list (passkey upsell,
|
|
8858
8870
|
* backup verification, …); this walks it, rendering the step views the SDK
|
|
8859
8871
|
* supports and finalizing when the queue drains. A redirect target skips the
|
|
8860
|
-
* pipeline. A future nudge is one new recommendation type + view case
|
|
8872
|
+
* pipeline. A future nudge is one new recommendation type + view case, no
|
|
8861
8873
|
* primary-login handler changes.
|
|
8862
8874
|
*/
|
|
8863
8875
|
runPostLogin(result) {
|
|
@@ -8890,7 +8902,7 @@ class IdentityRenderer {
|
|
|
8890
8902
|
this.setState({ view: 'backup-verify', missingType: next.missingType, pendingResult: result });
|
|
8891
8903
|
}
|
|
8892
8904
|
else {
|
|
8893
|
-
// A recommendation type this SDK build does not render
|
|
8905
|
+
// A recommendation type this SDK build does not render: skip it.
|
|
8894
8906
|
this.advancePostLogin();
|
|
8895
8907
|
}
|
|
8896
8908
|
}
|
|
@@ -9041,7 +9053,7 @@ class IdentityRenderer {
|
|
|
9041
9053
|
// Directly trigger passkey registration
|
|
9042
9054
|
const result = await this.passkeyHandler.register(pendingResult.token);
|
|
9043
9055
|
if (result.success && result.result) {
|
|
9044
|
-
// Passkey created
|
|
9056
|
+
// Passkey created: adopt its fresh token/session as the result to
|
|
9045
9057
|
// finalize with (and to authorize any later backup-attach step), then
|
|
9046
9058
|
// advance to the next recommendation.
|
|
9047
9059
|
this.postLoginResult = result.result;
|
|
@@ -9179,7 +9191,7 @@ class IdentityRenderer {
|
|
|
9179
9191
|
case 'sparklink_verified':
|
|
9180
9192
|
case 'sparklink_second_factor': {
|
|
9181
9193
|
const outcome = parseSparkLinkEvent(data);
|
|
9182
|
-
// A result the sign-in cannot use
|
|
9194
|
+
// A result the sign-in cannot use (e.g. "verified" with no token)
|
|
9183
9195
|
// can never complete it; say so rather than report a hollow success.
|
|
9184
9196
|
if (!outcome) {
|
|
9185
9197
|
this.failSparkLink();
|
|
@@ -9193,7 +9205,7 @@ class IdentityRenderer {
|
|
|
9193
9205
|
this.failSparkLink();
|
|
9194
9206
|
break;
|
|
9195
9207
|
case 'sparklink_resent':
|
|
9196
|
-
// Server auto-resent a new link
|
|
9208
|
+
// Server auto-resent a new link: update countdown timer
|
|
9197
9209
|
if (typeof data.expiresAt === 'number') {
|
|
9198
9210
|
this.setState({
|
|
9199
9211
|
view: 'sparklink-waiting',
|
|
@@ -9214,7 +9226,7 @@ class IdentityRenderer {
|
|
|
9214
9226
|
*
|
|
9215
9227
|
* A completed login runs the post-login pipeline, which hands the host the
|
|
9216
9228
|
* full result (including any redirect URL) before attempting top-level
|
|
9217
|
-
* navigation
|
|
9229
|
+
* navigation: the host page is the source of truth for what happens next;
|
|
9218
9230
|
* the SDK's window.location.href call is a fallback for hosts that delegate
|
|
9219
9231
|
* navigation entirely to the SDK. A login held at the second-factor gate
|
|
9220
9232
|
* opens the two-factor view, exactly as after an emailed code.
|
|
@@ -9257,7 +9269,7 @@ class IdentityRenderer {
|
|
|
9257
9269
|
* is suspended (mobile: the user leaves to the mail app). On refocus, if the
|
|
9258
9270
|
* socket is no longer open, reclaim the click's result once by kindling. A
|
|
9259
9271
|
* single ~2s retry covers returning before the server finished writing it.
|
|
9260
|
-
* Deliberately NOT a polling loop
|
|
9272
|
+
* Deliberately NOT a polling loop: it fires only on refocus, and only when
|
|
9261
9273
|
* the socket is actually gone.
|
|
9262
9274
|
*/
|
|
9263
9275
|
armSparkLinkRefocusClaim() {
|
|
@@ -9301,7 +9313,7 @@ class IdentityRenderer {
|
|
|
9301
9313
|
this.applySparkLinkOutcome(outcome);
|
|
9302
9314
|
return;
|
|
9303
9315
|
}
|
|
9304
|
-
// Pending
|
|
9316
|
+
// Pending: the click may still be processing server-side. One short retry,
|
|
9305
9317
|
// then stop. No ongoing polling. Tracked so cleanup can cancel it.
|
|
9306
9318
|
if (allowRetry && this.sparkLinkKindling === kindling) {
|
|
9307
9319
|
this.sparkLinkRetryTimer = setTimeout(() => {
|
|
@@ -9519,9 +9531,9 @@ function getStyles(options) {
|
|
|
9519
9531
|
textSecondary: isDark ? DS.darkTextMuted : DS.slate600,
|
|
9520
9532
|
textMuted: isDark ? withAlpha(DS.white, 0.45) : DS.slate500,
|
|
9521
9533
|
textOnPrimary: DS.white,
|
|
9522
|
-
// Focus
|
|
9534
|
+
// Focus, a two-tone ring: inner surface gap + accent-derived outer ring.
|
|
9523
9535
|
focusRing: `0 0 0 2px ${surface}, 0 0 0 4px ${focusRingColor}`,
|
|
9524
|
-
// Shadows
|
|
9536
|
+
// Shadows, DS-weight: lean on hairlines, keep elevation subtle.
|
|
9525
9537
|
shadowSm: isDark
|
|
9526
9538
|
? '0 1px 2px rgba(0, 0, 0, 0.4)'
|
|
9527
9539
|
: DS.shadowSm,
|
|
@@ -11563,7 +11575,7 @@ class DialogLauncher {
|
|
|
11563
11575
|
return;
|
|
11564
11576
|
}
|
|
11565
11577
|
if (message.error === 'cancelled') {
|
|
11566
|
-
// The person explicitly backed out inside the popup
|
|
11578
|
+
// The person explicitly backed out inside the popup: end the flow rather
|
|
11567
11579
|
// than offer to reopen to the same place.
|
|
11568
11580
|
this.finishCancel();
|
|
11569
11581
|
return;
|
|
@@ -11576,7 +11588,7 @@ class DialogLauncher {
|
|
|
11576
11588
|
return;
|
|
11577
11589
|
// Severed handle (COOP: same-origin on the host page): the popup is open in
|
|
11578
11590
|
// front of the person and working, but postMessage can never deliver and a
|
|
11579
|
-
// retry popup severs identically
|
|
11591
|
+
// retry popup severs identically. The ONLY flow that can complete is the
|
|
11580
11592
|
// redirect flow, so switch to it. When the owner can't arm the redirect
|
|
11581
11593
|
// return leg it resolves false and we degrade to the retry alert.
|
|
11582
11594
|
if (error instanceof PopupSeveredError && this.callbacks.onPopupSevered) {
|
|
@@ -11864,14 +11876,14 @@ function onBodyReady(callback) {
|
|
|
11864
11876
|
}
|
|
11865
11877
|
}
|
|
11866
11878
|
/**
|
|
11867
|
-
* Attach a click handler to every element matching `selector
|
|
11879
|
+
* Attach a click handler to every element matching `selector`: both elements
|
|
11868
11880
|
* present once the DOM is ready and elements added later (observed via
|
|
11869
11881
|
* MutationObserver).
|
|
11870
11882
|
*
|
|
11871
11883
|
* Each call is fully self-contained: the element bookkeeping lives in this
|
|
11872
11884
|
* closure, so the returned cleanup removes only the listeners this call
|
|
11873
|
-
* registered. Multiple attachments
|
|
11874
|
-
* element attached twice
|
|
11885
|
+
* registered. Multiple attachments (different selectors, or even the same
|
|
11886
|
+
* element attached twice) never interfere with one another.
|
|
11875
11887
|
*
|
|
11876
11888
|
* @param selector - CSS selector for elements to attach to
|
|
11877
11889
|
* @param onClick - Click handler to register on every matching element
|
|
@@ -12151,7 +12163,7 @@ const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
|
|
|
12151
12163
|
// algorithm-confused token cannot masquerade as valid.
|
|
12152
12164
|
const ACCEPTED_TOKEN_ALGS = ['EdDSA', 'RS256'];
|
|
12153
12165
|
/**
|
|
12154
|
-
* Whether `handleRedirectResult()` has anything to do on this load
|
|
12166
|
+
* Whether `handleRedirectResult()` has anything to do on this load: a returned
|
|
12155
12167
|
* sign-in fragment to consume, or a pending sign-in to self-heal. Public + side
|
|
12156
12168
|
* effect-free (peeks, never consumes) so a host that defers SDK init for
|
|
12157
12169
|
* performance can cheaply decide whether to boot the SDK on a given page load,
|
|
@@ -12230,7 +12242,7 @@ class IdentityModule {
|
|
|
12230
12242
|
ensurePreconnect(config.identityBaseUrl);
|
|
12231
12243
|
}
|
|
12232
12244
|
/**
|
|
12233
|
-
* Build a deep link into the person's auth.sv Identity portal
|
|
12245
|
+
* Build a deep link into the person's auth.sv Identity portal, where they
|
|
12234
12246
|
* manage their verified identity, passkeys, sessions, and connected sites
|
|
12235
12247
|
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
12236
12248
|
* self-serve;
|
|
@@ -12272,7 +12284,7 @@ class IdentityModule {
|
|
|
12272
12284
|
* SSO hub session on the Identity origin),
|
|
12273
12285
|
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
12274
12286
|
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
12275
|
-
* with FedCM support
|
|
12287
|
+
* with FedCM support: callers should feature-detect with
|
|
12276
12288
|
* `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
|
|
12277
12289
|
*
|
|
12278
12290
|
* @returns the verified result, or `null` when the browser has no FedCM
|
|
@@ -12304,7 +12316,7 @@ class IdentityModule {
|
|
|
12304
12316
|
}
|
|
12305
12317
|
const nonce = options.nonce ?? (await this.api.drawAuthorizationValues()).nonce;
|
|
12306
12318
|
// The FedCM IdP is the IDENTITY origin (where sign-in runs and the SSO hub
|
|
12307
|
-
// cookie lives)
|
|
12319
|
+
// cookie lives), not the auth.sv portal. The config, its endpoints, and
|
|
12308
12320
|
// the credentialed accounts fetch must all be same-origin with that cookie.
|
|
12309
12321
|
const configURL = `${this.config.identityBaseUrl}/${this.config.accountId}/fedcm/config.json`;
|
|
12310
12322
|
// A restriction rides the provider's `params`, which the browser hands the
|
|
@@ -12363,7 +12375,7 @@ class IdentityModule {
|
|
|
12363
12375
|
* This is the single programmatic entry point; `attach()` binds it to element
|
|
12364
12376
|
* clicks. The popup runs the flow top-level on the Identity origin (so
|
|
12365
12377
|
* login's `__Host-` hub cookie is a first-party write and cross-domain SSO
|
|
12366
|
-
* works) and posts the result back
|
|
12378
|
+
* works) and posts the result back; the promise resolves with it.
|
|
12367
12379
|
*
|
|
12368
12380
|
* Resilience: pair this with `handleRedirectResult()` on page load. If the
|
|
12369
12381
|
* popup's result is ever lost (a mobile browser discards the backgrounded
|
|
@@ -12423,7 +12435,7 @@ class IdentityModule {
|
|
|
12423
12435
|
backdropBlur: options.backdropBlur ?? this.config.backdropBlur,
|
|
12424
12436
|
};
|
|
12425
12437
|
// Inline rendering (target) and explicit local mode run the flow in this
|
|
12426
|
-
// document
|
|
12438
|
+
// document: that is how the SparkVault-hosted sign-in page itself runs
|
|
12427
12439
|
// the flow. Otherwise sign-in leaves this page: a top-level redirect to
|
|
12428
12440
|
// the sign-in page on the Identity origin (so login's first-party SSO
|
|
12429
12441
|
// cookie persists), returning via handleRedirectResult().
|
|
@@ -12602,8 +12614,8 @@ class IdentityModule {
|
|
|
12602
12614
|
throw new ValidationError('Invalid token header');
|
|
12603
12615
|
}
|
|
12604
12616
|
// Accept exactly the algorithms the Identity server signs with; reject
|
|
12605
|
-
// everything else
|
|
12606
|
-
// token, or an absent alg
|
|
12617
|
+
// everything else: `none` (unsigned), a symmetric or algorithm-confused
|
|
12618
|
+
// token, or an absent alg, none of which could pass the server-side JWKS
|
|
12607
12619
|
// verification the host performs before trusting the token.
|
|
12608
12620
|
const alg = header.alg;
|
|
12609
12621
|
if (typeof alg !== 'string' || !ACCEPTED_TOKEN_ALGS.includes(alg)) {
|
|
@@ -12627,17 +12639,17 @@ class IdentityModule {
|
|
|
12627
12639
|
return payload;
|
|
12628
12640
|
}
|
|
12629
12641
|
/**
|
|
12630
|
-
* Complete a sign-in on page load
|
|
12642
|
+
* Complete a sign-in on page load: the return leg of `signIn()`. Call once
|
|
12631
12643
|
* on every page load; it resolves `null` when there is nothing to do.
|
|
12632
12644
|
*
|
|
12633
12645
|
* It handles two cases:
|
|
12634
|
-
* 1. A one-time code is in the URL fragment (`#sv_code=…`)
|
|
12646
|
+
* 1. A one-time code is in the URL fragment (`#sv_code=…`): the popup's
|
|
12635
12647
|
* result was lost and self-heal navigated here, or `flow: 'redirect'`
|
|
12636
12648
|
* returned. Redeem it server-side and hand the full result to
|
|
12637
12649
|
* `onSuccess` (and resolve with it).
|
|
12638
12650
|
* 2. A sign-in was in flight but never delivered (a mobile browser
|
|
12639
12651
|
* discarded the backgrounded opener tab, killing the popup's
|
|
12640
|
-
* postMessage)
|
|
12652
|
+
* postMessage): silently re-mint from the SSO session the popup signed
|
|
12641
12653
|
* in or chose, by navigating this tab through the silent SSO endpoint
|
|
12642
12654
|
* and straight back with a code (case 1 on return). The bounce names
|
|
12643
12655
|
* the sign-in's reference, and the endpoint mints only when the
|
|
@@ -12645,7 +12657,7 @@ class IdentityModule {
|
|
|
12645
12657
|
* such session (a sign-in that opened none, such as one through the
|
|
12646
12658
|
* account's own identity provider) it comes back logged-out, no oracle.
|
|
12647
12659
|
*
|
|
12648
|
-
* The code is one-time, PKCE-bound, and origin-locked
|
|
12660
|
+
* The code is one-time, PKCE-bound, and origin-locked, never the token. The
|
|
12649
12661
|
* host must still verify `result.token` server-side via the Identity JWKS.
|
|
12650
12662
|
*
|
|
12651
12663
|
* @example Call on page load; sign-in clicks stay unchanged.
|
|
@@ -12663,7 +12675,7 @@ class IdentityModule {
|
|
|
12663
12675
|
}
|
|
12664
12676
|
// A silent-SSO recovery that found no live session returns `#sso=…`; strip
|
|
12665
12677
|
// it so the logged-out load is clean, retire the one-shot state/verifier the
|
|
12666
|
-
// outbound bounce staged (dead now
|
|
12678
|
+
// outbound bounce staged (dead now: no code came back), and do not re-bounce
|
|
12667
12679
|
// (handled below).
|
|
12668
12680
|
if (params.get('sso')) {
|
|
12669
12681
|
this.clearUrlFragment();
|
|
@@ -12682,7 +12694,7 @@ class IdentityModule {
|
|
|
12682
12694
|
const code = params.get('sv_code');
|
|
12683
12695
|
const errorCode = params.get('sv_error');
|
|
12684
12696
|
// A returned fragment means this sign-in resolved (redeem, cancel, or
|
|
12685
|
-
// error), so retire any pending marker
|
|
12697
|
+
// error), so retire any pending marker; otherwise it could fire one
|
|
12686
12698
|
// spurious silent bounce on a later load inside its TTL.
|
|
12687
12699
|
removePendingMarker();
|
|
12688
12700
|
// Consume exactly once: fragment and one-shot state/verifier are cleared
|
|
@@ -12717,8 +12729,8 @@ class IdentityModule {
|
|
|
12717
12729
|
// here: the code is PKCE- and origin-bound to this tab, and a recovery
|
|
12718
12730
|
// bounce only ever mints for the account its `login_hint` named (see
|
|
12719
12731
|
// startRecoveryBounce). The redeemed result exposes just that account's
|
|
12720
|
-
// PRIMARY identifier
|
|
12721
|
-
// with
|
|
12732
|
+
// PRIMARY identifier (not necessarily the one the caller signed in
|
|
12733
|
+
// with), so re-checking it here could only discard valid sign-ins.
|
|
12722
12734
|
const raw = await this.api.redeemHandoffCode(code, codeVerifier);
|
|
12723
12735
|
const result = {
|
|
12724
12736
|
token: raw.token,
|
|
@@ -12741,7 +12753,7 @@ class IdentityModule {
|
|
|
12741
12753
|
* Silently re-mint the sign-in result from the SSO session the popup signed
|
|
12742
12754
|
* in or chose. Navigates this tab through the silent SSO endpoint
|
|
12743
12755
|
* (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
|
|
12744
|
-
* PKCE-bound, returns a one-time code in the fragment
|
|
12756
|
+
* PKCE-bound, returns a one-time code in the fragment, handled by case 1 on
|
|
12745
12757
|
* return. No-op (stays put) if session storage or WebCrypto is unavailable,
|
|
12746
12758
|
* so a degraded environment simply never recovers rather than erroring. The
|
|
12747
12759
|
* bounce's PKCE verifier and state are a draw from the Identity origin
|
|
@@ -12757,7 +12769,7 @@ class IdentityModule {
|
|
|
12757
12769
|
const sso = new URL(`${this.config.identityBaseUrl}/${this.config.accountId}/sso`);
|
|
12758
12770
|
// With several hub sessions, login_hint names the account the interrupted
|
|
12759
12771
|
// sign-in was addressing: /sso mints silently ONLY for a hint that matched
|
|
12760
|
-
// exactly one hub session's verified identifiers
|
|
12772
|
+
// exactly one hub session's verified identifiers, and every unsatisfiable hint
|
|
12761
12773
|
// (a stranger's address, an ambiguous match, an account not eligible here)
|
|
12762
12774
|
// comes back with no result at all rather than a different account's.
|
|
12763
12775
|
if (pending.hint) {
|
|
@@ -12917,14 +12929,14 @@ class IdentityModule {
|
|
|
12917
12929
|
// nothing below can match.
|
|
12918
12930
|
}
|
|
12919
12931
|
// A `#token` is accepted only as the answer to a sign-in THIS browser
|
|
12920
|
-
// started
|
|
12932
|
+
// started: the renderer stores the state before leaving for the
|
|
12921
12933
|
// provider. Anyone can compose a URL carrying their own genuinely-signed
|
|
12922
12934
|
// token, so a fragment with no stored state, or a different one, is an
|
|
12923
12935
|
// unsolicited result (login CSRF) and is refused.
|
|
12924
12936
|
if (!expectedState || params.get(SIGNIN_RESULT_FRAGMENT.state) !== expectedState) {
|
|
12925
12937
|
throw new ValidationError('Invalid OAuth state');
|
|
12926
12938
|
}
|
|
12927
|
-
// Unverified client-side decode
|
|
12939
|
+
// Unverified client-side decode: surfaces the claims for the result
|
|
12928
12940
|
// shape and rejects an obviously-bad token (expiry/issuer/audience/alg).
|
|
12929
12941
|
// The host MUST still verify result.token server-side via the Identity
|
|
12930
12942
|
// JWKS before trusting any claim for an authorization decision.
|
|
@@ -12995,7 +13007,7 @@ class IdentityModule {
|
|
|
12995
13007
|
* Whether the preloaded config has already settled as a *permanent* failure
|
|
12996
13008
|
* the popup can't surface (origin not allowed, or product not configured).
|
|
12997
13009
|
* Used to skip the launcher and show the error dialog in-page immediately.
|
|
12998
|
-
* Returns false
|
|
13010
|
+
* Returns false (proceed to the launcher) when config is not preloaded,
|
|
12999
13011
|
* still in flight (raced against a short timeout so the common path is never
|
|
13000
13012
|
* delayed), resolved, or failed only transiently (the launcher surfaces a
|
|
13001
13013
|
* transient failure in its own dialog).
|
|
@@ -13009,7 +13021,7 @@ class IdentityModule {
|
|
|
13009
13021
|
this.api.getConfig(),
|
|
13010
13022
|
new Promise((resolve) => setTimeout(() => resolve(PENDING), 50)),
|
|
13011
13023
|
]);
|
|
13012
|
-
// Resolved with config, or still pending after the timeout
|
|
13024
|
+
// Resolved with config, or still pending after the timeout: either way,
|
|
13013
13025
|
// don't block the iframe path.
|
|
13014
13026
|
return false;
|
|
13015
13027
|
}
|
|
@@ -13041,7 +13053,7 @@ class IdentityModule {
|
|
|
13041
13053
|
*
|
|
13042
13054
|
* @internal Used only by the SparkVault-hosted sign-in popup and hosted login
|
|
13043
13055
|
* page (which own their chrome and pass `renderMode: 'local'`). Customer
|
|
13044
|
-
* integrations have no inline mode
|
|
13056
|
+
* integrations have no inline mode; use `signIn()` / `attach()`.
|
|
13045
13057
|
*/
|
|
13046
13058
|
async render(options) {
|
|
13047
13059
|
const returned = await this.consumeRedirectResult();
|
|
@@ -13067,8 +13079,8 @@ class IdentityModule {
|
|
|
13067
13079
|
|
|
13068
13080
|
/**
|
|
13069
13081
|
* The caller-supplied send idempotency key. It becomes part of the send's
|
|
13070
|
-
* storage key, so `#` (the key separator) is excluded
|
|
13071
|
-
* key-segment boundary into another tenant's namespace
|
|
13082
|
+
* storage key, so `#` (the key separator) is excluded (no caller id can forge a
|
|
13083
|
+
* key-segment boundary into another tenant's namespace), and the length bound
|
|
13072
13084
|
* keeps the key inside the store's key-size limit.
|
|
13073
13085
|
*/
|
|
13074
13086
|
const NOTIFY_SEND_ID_PATTERN = /^[A-Za-z0-9_.:-]+$/;
|
|
@@ -13330,14 +13342,14 @@ class NotifyProjectsModule {
|
|
|
13330
13342
|
}
|
|
13331
13343
|
|
|
13332
13344
|
/**
|
|
13333
|
-
* Notify Product Module
|
|
13345
|
+
* Notify Product Module: the TENANT (sender) surface.
|
|
13334
13346
|
*
|
|
13335
13347
|
* The counterpart to `sv.notify`: where that module is SparkVault's own
|
|
13336
13348
|
* first-party inbox, which a signed-in SparkVault user reads for the
|
|
13337
13349
|
* notifications SparkVault delivered to them `in_app`, this one is the
|
|
13338
|
-
* account-scoped product surface a tenant's BACKEND drives
|
|
13350
|
+
* account-scoped product surface a tenant's BACKEND drives (send, send
|
|
13339
13351
|
* history, recall, sender-side inbox reads and state, send status, receipts,
|
|
13340
|
-
* the account's Notify config, and who its email is from.
|
|
13352
|
+
* the account's Notify config, and who its email is from).
|
|
13341
13353
|
* A tenant reads its own recipients' feeds here (`getInbox`), never through
|
|
13342
13354
|
* `sv.notify`. Every method maps to
|
|
13343
13355
|
* `/v1/products/notify/*` and is authorized by the caller's account, so the
|
|
@@ -13352,7 +13364,7 @@ class NotifyProjectsModule {
|
|
|
13352
13364
|
* and metadata.
|
|
13353
13365
|
*/
|
|
13354
13366
|
/**
|
|
13355
|
-
* The caller-supplied idempotency key's accepted shape
|
|
13367
|
+
* The caller-supplied idempotency key's accepted shape: the server's own rule,
|
|
13356
13368
|
* so a malformed key fails locally instead of on the wire.
|
|
13357
13369
|
*/
|
|
13358
13370
|
function isSendId(value) {
|
|
@@ -13371,7 +13383,7 @@ const BULK_MARK_STATES$1 = NOTIFY_INBOX_BULK_MARK_STATES;
|
|
|
13371
13383
|
* The five secure-by-default preset bundles: the server's own table, in this
|
|
13372
13384
|
* SDK's camelCase shape.
|
|
13373
13385
|
*
|
|
13374
|
-
* There is no preset endpoint
|
|
13386
|
+
* There is no preset endpoint: presets are a merge over the one send contract,
|
|
13375
13387
|
* so they are applied client-side and produce an ordinary `send` request. Caller
|
|
13376
13388
|
* arguments win over a preset's defaults wherever they state a value;
|
|
13377
13389
|
* `channels` left unset lets the account config resolve the ladder per category.
|
|
@@ -13440,8 +13452,8 @@ class NotifyProductModule {
|
|
|
13440
13452
|
* recipient, and enqueue delivery across the resolved channel ladder.
|
|
13441
13453
|
*
|
|
13442
13454
|
* `sendId` is the idempotency key. Replaying an existing one with the same
|
|
13443
|
-
* request returns the stored send unchanged
|
|
13444
|
-
* re-delivered
|
|
13455
|
+
* request returns the stored send unchanged (never re-sealed, never
|
|
13456
|
+
* re-delivered), flagged `idempotent`; another request under it is refused 400
|
|
13445
13457
|
* (`sendId` on `CreateNotifySendOptions`).
|
|
13446
13458
|
*
|
|
13447
13459
|
* The send speaks in your organization's name, and one that would email
|
|
@@ -13455,12 +13467,12 @@ class NotifyProductModule {
|
|
|
13455
13467
|
* | Status | `serviceCode` | `details` | Next |
|
|
13456
13468
|
* | --- | --- | --- | --- |
|
|
13457
13469
|
* | 403 | `NOTIFY_CHANNEL_NOT_AVAILABLE` | `{ field, channels }` | Name only `in_app` and `email` |
|
|
13458
|
-
* | 409 | `NOTIFY_SENDER_NAME_REQUIRED` |
|
|
13470
|
+
* | 409 | `NOTIFY_SENDER_NAME_REQUIRED` | none | Name the organization in Settings |
|
|
13459
13471
|
* | 409 | `NOTIFY_SENDER_NAME_RESERVED` | `{ reason: 'reserved_name' }` | Rename the organization |
|
|
13460
13472
|
* | 409 | `HANDLE_REQUIRED` | `{ product: 'notify' }` | Choose the organization's handle in Company Settings |
|
|
13461
13473
|
* | 429 | `NOTIFY_EMAIL_ADMISSION_LIMIT` | `{ limit, window: 'hour', resets_at }` | Wait `retryAfterMs`, then send |
|
|
13462
|
-
* | 503 | `EMAIL_SETUP_BUSY` |
|
|
13463
|
-
* | 503 | `NOTIFY_EMAIL_CAPACITY_UNAVAILABLE` |
|
|
13474
|
+
* | 503 | `EMAIL_SETUP_BUSY` | none | Retry the same send after `retryAfterMs` |
|
|
13475
|
+
* | 503 | `NOTIFY_EMAIL_CAPACITY_UNAVAILABLE` | none | Retry the same send |
|
|
13464
13476
|
*
|
|
13465
13477
|
* A replay is answered from the stored send and meets none of them again.
|
|
13466
13478
|
*
|
|
@@ -13474,7 +13486,7 @@ class NotifyProductModule {
|
|
|
13474
13486
|
* category: 'transactional',
|
|
13475
13487
|
* });
|
|
13476
13488
|
*
|
|
13477
|
-
* @example Send a stored file
|
|
13489
|
+
* @example Send a stored file: the unsealed vault proves you hold its key
|
|
13478
13490
|
* const vault = await sv.vaults.unseal('vlt_abc', process.env.CONTRACTS_DVAK);
|
|
13479
13491
|
* await sv.products.notify.send({
|
|
13480
13492
|
* sendId: `contract:${contract.id}`,
|
|
@@ -13505,7 +13517,7 @@ class NotifyProductModule {
|
|
|
13505
13517
|
return response.data;
|
|
13506
13518
|
}
|
|
13507
13519
|
/**
|
|
13508
|
-
* Frictionless informational ping
|
|
13520
|
+
* Frictionless informational ping: no verification, view-only, delivered
|
|
13509
13521
|
* INLINE (plaintext) so it is read at a glance. Channels resolve from the
|
|
13510
13522
|
* account config, narrowed to the ones that render cleartext.
|
|
13511
13523
|
*
|
|
@@ -13580,7 +13592,7 @@ class NotifyProductModule {
|
|
|
13580
13592
|
* grant still opens, never the content; a plaintext row carries its body.
|
|
13581
13593
|
* Treat the answer as sensitive and keep it out of logs.
|
|
13582
13594
|
*
|
|
13583
|
-
* A page can come back SHORT of `limit` yet still carry a non-null cursor
|
|
13595
|
+
* A page can come back SHORT of `limit` yet still carry a non-null cursor:
|
|
13584
13596
|
* follow the cursor; never treat a short page as the end.
|
|
13585
13597
|
*
|
|
13586
13598
|
* @example
|
|
@@ -13603,7 +13615,7 @@ class NotifyProductModule {
|
|
|
13603
13615
|
}
|
|
13604
13616
|
/**
|
|
13605
13617
|
* Apply a terminal display state to one row (idempotent). `createdAt` MUST be
|
|
13606
|
-
* the row's own `created_at`, round-tripped from the feed row
|
|
13618
|
+
* the row's own `created_at`, round-tripped from the feed row; the id alone
|
|
13607
13619
|
* cannot address the row. Any mark (seen, read or archived) marks the row seen,
|
|
13608
13620
|
* which stops its escalation.
|
|
13609
13621
|
*
|
|
@@ -13659,7 +13671,7 @@ class NotifyProductModule {
|
|
|
13659
13671
|
}
|
|
13660
13672
|
// ── Send history & recall ───────────────────────────────────────────────────
|
|
13661
13673
|
/**
|
|
13662
|
-
* The account's send history, newest first
|
|
13674
|
+
* The account's send history, newest first: what you sent, to how many, and
|
|
13663
13675
|
* how it landed.
|
|
13664
13676
|
*
|
|
13665
13677
|
* Metadata only by construction: the history index does not project the
|
|
@@ -13692,13 +13704,13 @@ class NotifyProductModule {
|
|
|
13692
13704
|
*
|
|
13693
13705
|
* `mode: 'grant'` (the default) drops access and leaves the content intact.
|
|
13694
13706
|
* `mode: 'content'` hard-burns the sealed spark so it is unreadable for
|
|
13695
|
-
* everyone
|
|
13707
|
+
* everyone. Spark-backed sends only: an ingot send merely references the
|
|
13696
13708
|
* owner's durable vault content, so a content recall of one is a 400, refused
|
|
13697
13709
|
* before anything is revoked or stopped.
|
|
13698
13710
|
*
|
|
13699
13711
|
* Idempotent: a grant already revoked (or already consumed) counts as recalled,
|
|
13700
13712
|
* so a repeated call converges rather than accumulating failures. One
|
|
13701
|
-
* recipient's failure never stops the rest
|
|
13713
|
+
* recipient's failure never stops the rest; the response reports every one.
|
|
13702
13714
|
*
|
|
13703
13715
|
* PLAINTEXT SENDS CANNOT BE RECALLED (400): they delivered their body inline,
|
|
13704
13716
|
* in the clear, and minted no grant. There is nothing to revoke, and saying
|
|
@@ -13733,7 +13745,7 @@ class NotifyProductModule {
|
|
|
13733
13745
|
// ── Status & receipts ───────────────────────────────────────────────────────
|
|
13734
13746
|
/**
|
|
13735
13747
|
* The sender's per-recipient delivery rollup for one send: who it reached and
|
|
13736
|
-
* how far each recipient got. Metadata only
|
|
13748
|
+
* how far each recipient got. Metadata only: never the pointer, and no contact
|
|
13737
13749
|
* beyond the handle each recipient was addressed by (`recipient_id`).
|
|
13738
13750
|
*
|
|
13739
13751
|
* @example
|
|
@@ -13767,7 +13779,7 @@ class NotifyProductModule {
|
|
|
13767
13779
|
/**
|
|
13768
13780
|
* Every receipt for one send, each attached to the recipient who produced it.
|
|
13769
13781
|
* The walk reads the account's receipts back to the send's creation, and no
|
|
13770
|
-
* further. One call is bounded: when `truncated` is true it stopped first
|
|
13782
|
+
* further. One call is bounded: when `truncated` is true it stopped first;
|
|
13771
13783
|
* pass the returned `cursor` back in to resume exactly where it stopped.
|
|
13772
13784
|
*
|
|
13773
13785
|
* @example
|
|
@@ -13804,7 +13816,7 @@ class NotifyProductModule {
|
|
|
13804
13816
|
* Merge a partial patch onto the account's config overrides. Unknown keys are
|
|
13805
13817
|
* rejected before any write.
|
|
13806
13818
|
*
|
|
13807
|
-
* Delete a category by storing an explicit `null` TOMBSTONE
|
|
13819
|
+
* Delete a category by storing an explicit `null` TOMBSTONE: that is what keeps
|
|
13808
13820
|
* a seeded default from re-appearing on the next merge. The reserved `security`
|
|
13809
13821
|
* category can neither be removed nor made optional, the promotional
|
|
13810
13822
|
* categories `marketing` and `product` can never be made required: their email
|
|
@@ -13815,7 +13827,7 @@ class NotifyProductModule {
|
|
|
13815
13827
|
* The `events` section configures the outbound event webhook: `webhook_url`
|
|
13816
13828
|
* must be https on a public host, and `secret` (16-256 chars) signs every event
|
|
13817
13829
|
* body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. Both
|
|
13818
|
-
* are WRITE-ONLY
|
|
13830
|
+
* are WRITE-ONLY: reads report `events.webhook_url_set`,
|
|
13819
13831
|
* `events.webhook_url_host` and `events.secret_set`, never the values. A
|
|
13820
13832
|
* `webhook_url` on another host or port needs a new `secret` in the same
|
|
13821
13833
|
* patch (400 `VALIDATION_ERROR` naming `events.secret`), so a secret never
|
|
@@ -13835,7 +13847,7 @@ class NotifyProductModule {
|
|
|
13835
13847
|
* await sv.products.notify.updateConfig({
|
|
13836
13848
|
* categories: {
|
|
13837
13849
|
* weekly_newsletter: { label: 'Weekly newsletter', required: false },
|
|
13838
|
-
* marketing: null, // tombstone
|
|
13850
|
+
* marketing: null, // tombstone: remove the seeded default
|
|
13839
13851
|
* },
|
|
13840
13852
|
* events: {
|
|
13841
13853
|
* webhook_url: 'https://api.example.com/hooks/sparkvault',
|
|
@@ -14741,8 +14753,8 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
|
|
|
14741
14753
|
* presets, size limits, the operator display and desk mode choices, the
|
|
14742
14754
|
* operator queue's views and orders, the reply review list's views and
|
|
14743
14755
|
* states, the response-time histogram's bucket edges, the sections of a
|
|
14744
|
-
* desk's settings an address names, and the messages
|
|
14745
|
-
* sign-in posts between the website and its
|
|
14756
|
+
* desk's settings an address names, and the messages Help Desk's own
|
|
14757
|
+
* sign-in posts between the website and its sign-in window live here for
|
|
14746
14758
|
* the same reason. So does the one rule a typed or pasted sign-in code is
|
|
14747
14759
|
* read by (helpDeskPinDigits), which every sign-in form applies. So does the
|
|
14748
14760
|
* one way a client names a message it sends (newMessageId), which the
|
|
@@ -14770,14 +14782,15 @@ const HELP_DESK_CLOSE_REASONS = Object.freeze(['resolved', 'duplicate', 'spam'])
|
|
|
14770
14782
|
Object.freeze(HELP_DESK_CLOSE_REASONS.filter((reason) => reason !== 'duplicate'));
|
|
14771
14783
|
|
|
14772
14784
|
/**
|
|
14773
|
-
* The messages
|
|
14774
|
-
* window (the JS SDK's openWidgetIdentity) and the
|
|
14775
|
-
*
|
|
14776
|
-
*
|
|
14777
|
-
*
|
|
14778
|
-
* sign-in's code
|
|
14779
|
-
*
|
|
14780
|
-
*
|
|
14785
|
+
* The messages Help Desk's own sign-in exchanges between the website's
|
|
14786
|
+
* window (the JS SDK's openWidgetIdentity) and the sign-in window it opens on
|
|
14787
|
+
* the Help Desk sign-in host (the portal's sign-in window page): the window
|
|
14788
|
+
* asks its opener for the challenge's state (`ready`), the opener answers its
|
|
14789
|
+
* own popup alone, at the sign-in origin (`state`), and the window reports
|
|
14790
|
+
* the sign-in's code, only once the person confirms it, or its cancellation
|
|
14791
|
+
* (`result`) to the website's origin alone. Every message names its
|
|
14792
|
+
* challenge, and the state is never in the window's URL, so only the window
|
|
14793
|
+
* that started a challenge can complete it.
|
|
14781
14794
|
*/
|
|
14782
14795
|
const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
|
|
14783
14796
|
ready: 'sparkvault:help-desk:identity-ready',
|
|
@@ -14948,6 +14961,8 @@ const HELP_DESK_ROLES = Object.freeze(['manager', 'agent', 'trainee']);
|
|
|
14948
14961
|
* hold_tickets be assigned, mentioned, alerted and balanced-assigned
|
|
14949
14962
|
* configure_desk edit the desk's settings, queues, routing, alerts and knowledge base
|
|
14950
14963
|
* configure_chat the desk's chat intake and new-ticket chat notifications
|
|
14964
|
+
* activate_desk activate the desk on a company vault by presenting its key: the first
|
|
14965
|
+
* activation, a deactivated desk's, and a move to another vault
|
|
14951
14966
|
* assign_roles choose who holds which role on the desk
|
|
14952
14967
|
* view_analytics the desk's analytics, its CSV and the operator breakdown
|
|
14953
14968
|
* manage_requesters block or unblock a requester
|
|
@@ -14962,6 +14977,11 @@ const HELP_DESK_ROLES = Object.freeze(['manager', 'agent', 'trainee']);
|
|
|
14962
14977
|
* A Trainee keeps no saved replies: they use every one, and their reply is
|
|
14963
14978
|
* reviewed before it reaches a customer, so no text of theirs reaches one
|
|
14964
14979
|
* through another operator's reply unreviewed.
|
|
14980
|
+
*
|
|
14981
|
+
* A company admin alone activates a desk: presenting a company vault's key is
|
|
14982
|
+
* the company's consent to the help desk opening every file in that vault, so
|
|
14983
|
+
* no desk role gives it. Deactivating, which only withdraws that access, is
|
|
14984
|
+
* the desk's configurers' (`configure_desk`).
|
|
14965
14985
|
*/
|
|
14966
14986
|
const EVERY_ROLE = HELP_DESK_ROLES;
|
|
14967
14987
|
const capability = (roles, { admin = false, requiresAdmin = false } = {}) =>
|
|
@@ -14979,6 +14999,7 @@ Object.freeze({
|
|
|
14979
14999
|
hold_tickets: capability(EVERY_ROLE),
|
|
14980
15000
|
configure_desk: capability(['manager'], { admin: true }),
|
|
14981
15001
|
configure_chat: capability([], { admin: true }),
|
|
15002
|
+
activate_desk: capability([], { admin: true }),
|
|
14982
15003
|
assign_roles: capability(['manager'], { admin: true }),
|
|
14983
15004
|
view_analytics: capability(['manager']),
|
|
14984
15005
|
manage_requesters: capability(['manager']),
|
|
@@ -15375,14 +15396,14 @@ function refused(reason) {
|
|
|
15375
15396
|
*/
|
|
15376
15397
|
/**
|
|
15377
15398
|
* Time-to-first-byte bound: how long the download host may take to return
|
|
15378
|
-
* response headers. This bounds only the wait for a transfer to start
|
|
15399
|
+
* response headers. This bounds only the wait for a transfer to start: a
|
|
15379
15400
|
* signed link either begins serving promptly or is not going to.
|
|
15380
15401
|
*/
|
|
15381
15402
|
const DOWNLOAD_TTFB_TIMEOUT_MS = 30000;
|
|
15382
15403
|
/**
|
|
15383
15404
|
* Liveness bound on the response body: the longest tolerated gap between two
|
|
15384
15405
|
* chunks, rearmed on every chunk. Progress, not wall clock, bounds the
|
|
15385
|
-
* transfer
|
|
15406
|
+
* transfer: a large file over a slow link still completes, while a stalled
|
|
15386
15407
|
* connection fails promptly enough to retry.
|
|
15387
15408
|
*/
|
|
15388
15409
|
const DOWNLOAD_IDLE_TIMEOUT_MS = 60000;
|
|
@@ -16064,7 +16085,7 @@ function mapFolder(wire) {
|
|
|
16064
16085
|
*/
|
|
16065
16086
|
/**
|
|
16066
16087
|
* Error class for upload API errors. Inherits `code` and `statusCode` from
|
|
16067
|
-
* SparkVaultError
|
|
16088
|
+
* SparkVaultError, with no duplicate `httpStatus` field.
|
|
16068
16089
|
*
|
|
16069
16090
|
* A failed transfer request also carries what the transfer policy
|
|
16070
16091
|
* (`@sparkvault/app-sdk/transfer-retry`) makes of its answer, read where the
|
|
@@ -16144,15 +16165,15 @@ function parseLengthHeader(raw) {
|
|
|
16144
16165
|
/**
|
|
16145
16166
|
* Abort a stalled chunk PATCH after this long with no upload progress.
|
|
16146
16167
|
* XHR's own `timeout` measures total request duration, which would abort a
|
|
16147
|
-
* slow-but-progressing 50MB chunk
|
|
16168
|
+
* slow-but-progressing 50MB chunk, so a chunk fails only after the
|
|
16148
16169
|
* connection has been completely silent for the full window.
|
|
16149
16170
|
*/
|
|
16150
16171
|
const CHUNK_INACTIVITY_TIMEOUT_MS = 60000;
|
|
16151
16172
|
/**
|
|
16152
16173
|
* How many consecutive timeouts end the finalization receipt early.
|
|
16153
16174
|
*
|
|
16154
|
-
* A genuinely slow finalize shows up as ONE timeout
|
|
16155
|
-
* the re-drive
|
|
16175
|
+
* A genuinely slow finalize shows up as ONE timeout (the PATCH that started
|
|
16176
|
+
* the re-drive) followed by 409s from the writer that is working on it.
|
|
16156
16177
|
* Back-to-back timeouts mean nobody is answering at all, and spending the
|
|
16157
16178
|
* whole retry budget on a black-holed socket would freeze the widget at 100%
|
|
16158
16179
|
* for minutes with nothing for the user to act on.
|
|
@@ -16194,8 +16215,8 @@ function uploadRefusedError(coreCode, message, status, outcome) {
|
|
|
16194
16215
|
return new UploadApiError(message ?? REFUSAL_WORDING.get(coreCode) ?? REFUSED_MESSAGE, 'upload_refused', status, { status, coreCode }, outcome);
|
|
16195
16216
|
}
|
|
16196
16217
|
/**
|
|
16197
|
-
* Core's refusal of a request that stages an upload
|
|
16198
|
-
* replacement, the widget's initiation
|
|
16218
|
+
* Core's refusal of a request that stages an upload (a create, a
|
|
16219
|
+
* replacement, the widget's initiation) read as the upload's verdict: a final
|
|
16199
16220
|
* refusal of Core's (UPLOAD_FINAL_REFUSAL_CODES, the answer's own code: a
|
|
16200
16221
|
* later staging of the same file superseded it before its token was minted,
|
|
16201
16222
|
* 410 UPLOAD_SUPERSEDED) is the `upload_refused` a transfer answer naming it
|
|
@@ -16452,7 +16473,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16452
16473
|
* Vault upload info by vault id, memoized for the life of this client.
|
|
16453
16474
|
*
|
|
16454
16475
|
* The client is built once with the SDK and the map dies with the page, so
|
|
16455
|
-
* the memo cannot outlive the page it decorates
|
|
16476
|
+
* the memo cannot outlive the page it decorates, which is why there is no
|
|
16456
16477
|
* TTL and no invalidation API to get wrong. It deliberately survives
|
|
16457
16478
|
* `resetSession()`, alongside the other long-lived per-client state.
|
|
16458
16479
|
*/
|
|
@@ -16465,7 +16486,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16465
16486
|
* retries, a cancel aside; a refused API call it raises with its status is
|
|
16466
16487
|
* Core's verdict, never a transfer's, so of the policy's reading it carries
|
|
16467
16488
|
* only the floor Core named (`retryAfterMs`), for whoever acts on the
|
|
16468
|
-
* refusal
|
|
16489
|
+
* refusal, and Core's final refusal of the upload a call stages is that
|
|
16469
16490
|
* upload's `upload_refused` ({@link stagingRefusal}).
|
|
16470
16491
|
*/
|
|
16471
16492
|
makeError(message, code, statusCode, details, retryAfterMs = null) {
|
|
@@ -16509,13 +16530,13 @@ class UploadApi extends SparkVaultApi {
|
|
|
16509
16530
|
/**
|
|
16510
16531
|
* Get vault upload info (public endpoint), fetched at most once per vault.
|
|
16511
16532
|
*
|
|
16512
|
-
* Every widget interaction
|
|
16513
|
-
* an `attach()` handler serves
|
|
16533
|
+
* Every widget interaction (`upload()`, `pop()`, `render()`, and each click
|
|
16534
|
+
* an `attach()` handler serves) starts by asking for this, and the answer is
|
|
16514
16535
|
* pure display and geometry: the vault's name, its branding, and the size it
|
|
16515
16536
|
* advertises. It authorizes nothing. The server re-validates the vault, its
|
|
16516
16537
|
* upload source, the request origin, and the file size on the POST that
|
|
16517
16538
|
* actually creates the upload, and that re-validation is the correctness
|
|
16518
|
-
* backstop for this whole flow
|
|
16539
|
+
* backstop for this whole flow: a memoized answer can never widen what an
|
|
16519
16540
|
* upload is allowed to do, and the backstop must stay in place.
|
|
16520
16541
|
*
|
|
16521
16542
|
* Only a successful answer is kept: a rejection evicts its entry so the next
|
|
@@ -16588,7 +16609,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16588
16609
|
/**
|
|
16589
16610
|
* Upload a file to Forge over the TUS resumable protocol (v1.0.0).
|
|
16590
16611
|
*
|
|
16591
|
-
* The single canonical browser transfer path
|
|
16612
|
+
* The single canonical browser transfer path: the upload widget and the
|
|
16592
16613
|
* authenticated `ingots.upload` flow both go through here (one canonical
|
|
16593
16614
|
* transfer path). Creates the session, PATCHes chunks sized exactly by the
|
|
16594
16615
|
* server's `X-Chunk-Size` (Forge fixes the geometry at 50MB, which keeps
|
|
@@ -16599,7 +16620,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16599
16620
|
* Every answer is read through the transfer policy
|
|
16600
16621
|
* (`@sparkvault/app-sdk/transfer-retry`) and every retry spends one budget
|
|
16601
16622
|
* ({@link TusTransfer}). A chunk that fails in transit is resent only from
|
|
16602
|
-
* an offset the server just named
|
|
16623
|
+
* an offset the server just named: a 409's own `Upload-Offset` at once,
|
|
16603
16624
|
* otherwise a HEAD after the backoff ({@link offsetAfterFailure}); a session
|
|
16604
16625
|
* the server no longer holds throws `session_gone`, which only a new upload
|
|
16605
16626
|
* recovers from (any code of Core's the server named rides
|
|
@@ -16798,7 +16819,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16798
16819
|
await waitToRetry(transfer.budget, failure, transfer.uploadUrl, transfer.sessionSignal);
|
|
16799
16820
|
}
|
|
16800
16821
|
/**
|
|
16801
|
-
* Confirm the server finalized a fully received upload
|
|
16822
|
+
* Confirm the server finalized a fully received upload: the one receipt
|
|
16802
16823
|
* every transfer ends on.
|
|
16803
16824
|
*
|
|
16804
16825
|
* The server persists the session's final offset BEFORE it finalizes, so a
|
|
@@ -16806,7 +16827,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16806
16827
|
* size while finalization failed or is still running, and reporting that as
|
|
16807
16828
|
* success would hand the user a stored file whose ingot was never published.
|
|
16808
16829
|
* The zero-length PATCH at the final offset is the server's finalization
|
|
16809
|
-
* re-drive
|
|
16830
|
+
* re-drive: it short-circuits to 204 on an already-finalized session, and
|
|
16810
16831
|
* on a received-but-unfinalized one it answers only after publication.
|
|
16811
16832
|
*
|
|
16812
16833
|
* While another request finalizes the receipt answers 409 with
|
|
@@ -16838,7 +16859,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
16838
16859
|
}
|
|
16839
16860
|
catch (error) {
|
|
16840
16861
|
const failure = transferFailure(error);
|
|
16841
|
-
// Any answer at all
|
|
16862
|
+
// Any answer at all (a 409 above all) proves someone is on the other
|
|
16842
16863
|
// end, so the timeout tally starts over.
|
|
16843
16864
|
consecutiveTimeouts = failure.code === 'timeout' ? consecutiveTimeouts + 1 : 0;
|
|
16844
16865
|
if (consecutiveTimeouts >= FINALIZE_MAX_CONSECUTIVE_TIMEOUTS) {
|
|
@@ -16893,12 +16914,12 @@ class UploadApi extends SparkVaultApi {
|
|
|
16893
16914
|
return this.checkResumeOffset(await this.headUploadOffset(transfer.uploadUrl, RESUME_CHECK), transfer);
|
|
16894
16915
|
}
|
|
16895
16916
|
/**
|
|
16896
|
-
* Judge an offset the server named for the upload to resume from
|
|
16897
|
-
* or a 409's `Upload-Offset`
|
|
16917
|
+
* Judge an offset the server named for the upload to resume from (a HEAD's,
|
|
16918
|
+
* or a 409's `Upload-Offset`): the one place a server-reported resume point
|
|
16898
16919
|
* is judged.
|
|
16899
16920
|
*
|
|
16900
16921
|
* Forge commits a chunk before it answers, so a PATCH that died in transit
|
|
16901
|
-
* may have landed in full or not at all (never in part
|
|
16922
|
+
* may have landed in full or not at all (never in part: the chunk object
|
|
16902
16923
|
* is written atomically before the offset advances); only the session's own
|
|
16903
16924
|
* persisted offset knows which, and the client's arithmetic is worthless
|
|
16904
16925
|
* here.
|
|
@@ -17058,7 +17079,7 @@ class UploadApi extends SparkVaultApi {
|
|
|
17058
17079
|
});
|
|
17059
17080
|
}
|
|
17060
17081
|
/**
|
|
17061
|
-
* Read the server's persisted upload offset via a TUS HEAD request
|
|
17082
|
+
* Read the server's persisted upload offset via a TUS HEAD request: the one
|
|
17062
17083
|
* place the client asks Forge where a session really stands.
|
|
17063
17084
|
*
|
|
17064
17085
|
* @param check - Which caller this read serves; shapes the failure copy.
|
|
@@ -17144,7 +17165,7 @@ const NAME_CONFLICT_POLICIES = ['upsert', 'complete_pending', 'refuse', 'new_nam
|
|
|
17144
17165
|
*
|
|
17145
17166
|
* Uploads and downloads run over the single canonical Forge TUS transfer path
|
|
17146
17167
|
* (shared with the public upload widget), with server-side finalization and
|
|
17147
|
-
* download-host allowlisting enforced
|
|
17168
|
+
* download-host allowlisting enforced, with no per-size branching.
|
|
17148
17169
|
*/
|
|
17149
17170
|
class IngotsModule {
|
|
17150
17171
|
constructor(config, http) {
|
|
@@ -17252,16 +17273,16 @@ class IngotsModule {
|
|
|
17252
17273
|
}
|
|
17253
17274
|
}
|
|
17254
17275
|
/**
|
|
17255
|
-
* Send a file's bytes to an upload session
|
|
17256
|
-
* {@link createUpload} returned
|
|
17276
|
+
* Send a file's bytes to an upload session (the `uploadUrl` a
|
|
17277
|
+
* {@link createUpload} returned) over the resumable transfer every SDK
|
|
17257
17278
|
* upload uses. Resolves only once the server confirms the ingot is
|
|
17258
17279
|
* published, so a resolved promise never stands for a stored file whose
|
|
17259
17280
|
* ingot never went live.
|
|
17260
17281
|
*
|
|
17261
17282
|
* Transient failures are retried inside the transfer; a session the server
|
|
17262
17283
|
* no longer holds (it expired, was cancelled, or its ingot was removed)
|
|
17263
|
-
* rejects with code `session_gone`, and only a new upload session
|
|
17264
|
-
* {@link createUpload}, or {@link upload} again
|
|
17284
|
+
* rejects with code `session_gone`, and only a new upload session (a new
|
|
17285
|
+
* {@link createUpload}, or {@link upload} again) can store the file. An
|
|
17265
17286
|
* upload the server refused (the account's storage pool cannot take it, a
|
|
17266
17287
|
* later upload replaced it, or its vault is scheduled for deletion: a 409
|
|
17267
17288
|
* `VAULT_DELETION_SCHEDULED`, whose session the server keeps until the
|
|
@@ -17358,9 +17379,9 @@ class IngotsModule {
|
|
|
17358
17379
|
*
|
|
17359
17380
|
* Creates the upload session, streams the file to Forge over TUS, then
|
|
17360
17381
|
* confirms the server finalized the upload before resolving. A file the
|
|
17361
|
-
* server refused
|
|
17382
|
+
* server refused (another upload of it superseded this one, at its create
|
|
17362
17383
|
* or while it streamed, the storage pool cannot take it, or its vault is
|
|
17363
|
-
* scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`)
|
|
17384
|
+
* scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`)) rejects with
|
|
17364
17385
|
* code `upload_refused`, as {@link sendUpload} does. An upload that rejects
|
|
17365
17386
|
* any way but one the server received whole ({@link isReceivedUploadFailure}:
|
|
17366
17387
|
* the server publishes or ends that one on its own) is given up: the end of
|
|
@@ -17759,7 +17780,7 @@ class IngotsModule {
|
|
|
17759
17780
|
await this.http.delete(apiPath `/v1/vaults/${vaultId}/ingots/${id}/sharing/invite/${invite}`, { vat: vault.vatToken });
|
|
17760
17781
|
}
|
|
17761
17782
|
/**
|
|
17762
|
-
* Batch content-HMAC existence check
|
|
17783
|
+
* Batch content-HMAC existence check: the pre-upload dedup handshake.
|
|
17763
17784
|
* Returns which of the supplied vault-keyed HMACs already exist on active
|
|
17764
17785
|
* ingots in the vault, so callers can skip transferring those bytes.
|
|
17765
17786
|
*
|
|
@@ -17802,7 +17823,7 @@ class IngotsModule {
|
|
|
17802
17823
|
}
|
|
17803
17824
|
/**
|
|
17804
17825
|
* Request a Forge upload session for a new ingot.
|
|
17805
|
-
* Shared by createUpload and upload
|
|
17826
|
+
* Shared by createUpload and upload: the single ingot-create path.
|
|
17806
17827
|
*/
|
|
17807
17828
|
async requestUploadSession(vault, body) {
|
|
17808
17829
|
const payload = {
|
|
@@ -17840,7 +17861,7 @@ class IngotsModule {
|
|
|
17840
17861
|
* Run the canonical TUS transfer for a created/replaced ingot.
|
|
17841
17862
|
*
|
|
17842
17863
|
* The transfer resolves only once the server has confirmed finalization, so
|
|
17843
|
-
* the ingot this returns is always a published one
|
|
17864
|
+
* the ingot this returns is always a published one, never a stored file
|
|
17844
17865
|
* whose ingot never went active.
|
|
17845
17866
|
*/
|
|
17846
17867
|
async transferAndFinalize(session, minted, file, onProgress) {
|
|
@@ -17945,22 +17966,24 @@ function mapInvitation(wire) {
|
|
|
17945
17966
|
};
|
|
17946
17967
|
}
|
|
17947
17968
|
|
|
17948
|
-
/** The native support ceremony. Identity
|
|
17969
|
+
/** The native support ceremony. Identity's answer stays inside the Help Desk sign-in window. */
|
|
17949
17970
|
const VALUE = /^[A-Za-z0-9_-]{43}$/;
|
|
17971
|
+
/** The one origin the sign-in window runs on. Never read from the challenge's sign-in URL, which is checked against it. */
|
|
17972
|
+
const SIGN_IN_ORIGIN = `https://${SPARKVAULT_HELP_DESK_SIGN_IN_HOST}`;
|
|
17950
17973
|
/** The website's own opener policy cut the window off: no retry on this page can work, only its owner can fix it. */
|
|
17951
17974
|
const SEVERED_MESSAGE = 'This website stops the support sign-in window from reporting back, so sign-in cannot finish here. Let the website\'s owner know.';
|
|
17952
|
-
/** How often the sign-in window's handle is checked once it leaves for
|
|
17975
|
+
/** How often the sign-in window's handle is checked once it leaves for its start page. */
|
|
17953
17976
|
const HANDLE_CHECK_MS = 500;
|
|
17954
17977
|
/**
|
|
17955
17978
|
* What a sign-in window's handle reading `closed` before its page's ready
|
|
17956
17979
|
* message means. A website serving `Cross-Origin-Opener-Policy: same-origin`
|
|
17957
|
-
* severs the window the moment its
|
|
17980
|
+
* severs the window the moment its start page loads: the handle reads
|
|
17958
17981
|
* `closed` while the window stays open in front of the person, showing that
|
|
17959
17982
|
* page's own "not connected" notice. So:
|
|
17960
17983
|
* - the website's page holding focus again means the person closed the
|
|
17961
17984
|
* window and is back on it: a cancellation;
|
|
17962
17985
|
* - a handle that reads `closed` at the first check after the window left
|
|
17963
|
-
* for
|
|
17986
|
+
* for its start page, while the website's page still lacks focus, is a
|
|
17964
17987
|
* severance: the window is still in front of the person, for no person
|
|
17965
17988
|
* closes it that fast and then leaves the website;
|
|
17966
17989
|
* - anything else cannot be told apart (a severance on a slow load, or a
|
|
@@ -17977,6 +18000,19 @@ function closedBeforeReady(firstCheck) {
|
|
|
17977
18000
|
return new PopupSeveredError(SEVERED_MESSAGE);
|
|
17978
18001
|
return new SparkVaultError('Support sign-in did not start. Try again.', 'HELP_DESK_WIDGET_SIGN_IN_INTERRUPTED');
|
|
17979
18002
|
}
|
|
18003
|
+
/**
|
|
18004
|
+
* The challenge's start page, `https://signin.help.sv/{desk_id}/{challenge_id}`:
|
|
18005
|
+
* its sign-in URL when that is exactly the sign-in window's page for this
|
|
18006
|
+
* desk and this challenge, and the challenge's other values have their
|
|
18007
|
+
* shapes; else null.
|
|
18008
|
+
*/
|
|
18009
|
+
function startPage(value, deskId) {
|
|
18010
|
+
if (!value || ![value.challenge_id, value.verifier, value.state].every((part) => typeof part === 'string' && VALUE.test(part)) ||
|
|
18011
|
+
!Number.isSafeInteger(value.expires_at))
|
|
18012
|
+
return null;
|
|
18013
|
+
const expected = `${SIGN_IN_ORIGIN}/${deskId}/${value.challenge_id}`;
|
|
18014
|
+
return value.sign_in_url === expected ? expected : null;
|
|
18015
|
+
}
|
|
17980
18016
|
/**
|
|
17981
18017
|
* Open synchronously inside the user's gesture, before preparing the server
|
|
17982
18018
|
* challenge. A session redeemed after the sign-in already ended (cancelled,
|
|
@@ -17999,7 +18035,6 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
17999
18035
|
catch { /* The popup may already have navigated. */ }
|
|
18000
18036
|
return new Promise((resolve, reject) => {
|
|
18001
18037
|
let challenge = null;
|
|
18002
|
-
let firstPartyOrigin = null;
|
|
18003
18038
|
let settled = false;
|
|
18004
18039
|
let checking = false;
|
|
18005
18040
|
let interval;
|
|
@@ -18044,19 +18079,19 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18044
18079
|
finish(null, session);
|
|
18045
18080
|
};
|
|
18046
18081
|
const receive = (event) => {
|
|
18047
|
-
if (!challenge || event.source !== popup || event.origin !==
|
|
18082
|
+
if (!challenge || event.source !== popup || event.origin !== SIGN_IN_ORIGIN)
|
|
18048
18083
|
return;
|
|
18049
18084
|
const data = event.data;
|
|
18050
18085
|
if (!data || data.challenge_id !== challenge.challenge_id)
|
|
18051
18086
|
return;
|
|
18052
|
-
// The
|
|
18053
|
-
//
|
|
18054
|
-
//
|
|
18055
|
-
//
|
|
18087
|
+
// The sign-in window this page opened asks for the challenge's state,
|
|
18088
|
+
// without which Core takes none of its steps: only this popup, at the
|
|
18089
|
+
// sign-in origin, is ever answered, so a sign-in link opened in any
|
|
18090
|
+
// other window or browser completes nothing.
|
|
18056
18091
|
if (data.type === HELP_DESK_WIDGET_IDENTITY_MESSAGES.ready) {
|
|
18057
18092
|
if (watch)
|
|
18058
18093
|
clearInterval(watch);
|
|
18059
|
-
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state },
|
|
18094
|
+
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state }, SIGN_IN_ORIGIN);
|
|
18060
18095
|
return;
|
|
18061
18096
|
}
|
|
18062
18097
|
if (data.type !== HELP_DESK_WIDGET_IDENTITY_MESSAGES.result || data.state !== challenge.state)
|
|
@@ -18073,10 +18108,8 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18073
18108
|
void prepare().then((value) => {
|
|
18074
18109
|
if (settled)
|
|
18075
18110
|
return;
|
|
18076
|
-
const url =
|
|
18077
|
-
if (!
|
|
18078
|
-
url.protocol !== 'https:' || url.origin !== 'https://auth.sv' || url.username || url.password || url.search || url.hash ||
|
|
18079
|
-
url.pathname !== `/help-desk/${deskId}/${value.challenge_id}`)
|
|
18111
|
+
const url = startPage(value, deskId);
|
|
18112
|
+
if (!url)
|
|
18080
18113
|
throw new SparkVaultError('The support sign-in address is invalid.', 'HELP_DESK_INVALID_RESPONSE');
|
|
18081
18114
|
// The window still holds this page's own placeholder, which no opener
|
|
18082
18115
|
// policy severs: closed now, the person closed it.
|
|
@@ -18085,8 +18118,7 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18085
18118
|
return;
|
|
18086
18119
|
}
|
|
18087
18120
|
challenge = value;
|
|
18088
|
-
|
|
18089
|
-
popup.location.replace(url.href);
|
|
18121
|
+
popup.location.replace(url);
|
|
18090
18122
|
// A window whose handle dies before its page asks for the state can
|
|
18091
18123
|
// never be handed it, so the sign-in ends at once (closedBeforeReady)
|
|
18092
18124
|
// rather than polling until the challenge expires.
|
|
@@ -18097,8 +18129,8 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18097
18129
|
finish(closedBeforeReady(checks === 1));
|
|
18098
18130
|
}, HANDLE_CHECK_MS);
|
|
18099
18131
|
// Code delivery must survive a browser severing window.opener during
|
|
18100
|
-
// the
|
|
18101
|
-
// challenge and verifier; no Identity
|
|
18132
|
+
// the window's Identity round trip. Polling knows only the original
|
|
18133
|
+
// challenge and verifier; no Identity token ever reaches this page.
|
|
18102
18134
|
interval = setInterval(() => {
|
|
18103
18135
|
if (settled || checking || !challenge)
|
|
18104
18136
|
return;
|
|
@@ -18240,7 +18272,7 @@ class HelpDeskClient {
|
|
|
18240
18272
|
this.releasedTokens = new Map();
|
|
18241
18273
|
this.ownsSession = false;
|
|
18242
18274
|
// Frozen copies of the records this client reads, so a page changing the desk it handed in (`HelpDeskConnectOptions.desk`) changes nothing here.
|
|
18243
|
-
this.desk = Object.freeze({ ...desk, branding: Object.freeze({ ...desk.branding }),
|
|
18275
|
+
this.desk = Object.freeze({ ...desk, branding: Object.freeze({ ...desk.branding }),
|
|
18244
18276
|
external_identity: desk.external_identity ? Object.freeze({ ...desk.external_identity }) : undefined,
|
|
18245
18277
|
ticket_access_control: desk.ticket_access_control ? Object.freeze({ ...desk.ticket_access_control }) : undefined });
|
|
18246
18278
|
this.http = http;
|
|
@@ -18622,10 +18654,6 @@ class HelpDeskClient {
|
|
|
18622
18654
|
challenge_id: options.challengeId, binding_secret: options.bindingSecret, code: options.code,
|
|
18623
18655
|
});
|
|
18624
18656
|
}
|
|
18625
|
-
/** Identity completion still requires a server-approved desk portal origin. */
|
|
18626
|
-
completeIdentity(options) {
|
|
18627
|
-
return this.establish(apiPath `/v1/hd/desks/${this.desk.desk_id}/auth/identity/complete`, { token: options.token });
|
|
18628
|
-
}
|
|
18629
18657
|
/** Uninstalled result: the owning form/controller decides when the new requester becomes current. */
|
|
18630
18658
|
signInWidgetIdentity(options = {}) {
|
|
18631
18659
|
const revision = this.revision;
|
|
@@ -18644,8 +18672,8 @@ class HelpDeskClient {
|
|
|
18644
18672
|
const result = await this.send('POST', apiPath `/v1/hd/desks/${this.desk.desk_id}/auth/widget/redeem`, {
|
|
18645
18673
|
challenge_id: challenge.challenge_id, verifier: challenge.verifier, ...(code && { code }),
|
|
18646
18674
|
}, undefined, false);
|
|
18647
|
-
// A native sign-in opens a session at
|
|
18648
|
-
//
|
|
18675
|
+
// A native sign-in opens a session at SparkVault's Identity: an email sign-in's customer carries
|
|
18676
|
+
// the `identity` assurance; a sign-in by the organization's own identity provider carries
|
|
18649
18677
|
// the `federated` mark and the `federated` assurance together, never one without the other.
|
|
18650
18678
|
const customer = result?.customer;
|
|
18651
18679
|
const nativeIdentity = customer?.federated === true ? customer.assurance === 'federated' : customer?.assurance === 'identity';
|
|
@@ -19142,7 +19170,7 @@ function lastExtension(name) {
|
|
|
19142
19170
|
* server never reads the plaintext of an uploaded ingot, so the policy splits
|
|
19143
19171
|
* by where the bytes are: the NAME rule runs on the server at initiate and in
|
|
19144
19172
|
* the browser before an upload starts; the SNIFF rule runs wherever the bytes
|
|
19145
|
-
* are at hand
|
|
19173
|
+
* are at hand, in the browser over the file's first slice and on the server
|
|
19146
19174
|
* over an inbound email's parts. The type a ticket stores a file under, which
|
|
19147
19175
|
* the MIME registry decides, is server-only: ./attachment-policy-node.js.
|
|
19148
19176
|
*
|
|
@@ -21780,9 +21808,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21780
21808
|
return;
|
|
21781
21809
|
}
|
|
21782
21810
|
hosted.hidden = newRequestUrl === null;
|
|
21783
|
-
message(
|
|
21784
|
-
? 'This help desk cannot sign you in right now. Try again later.'
|
|
21785
|
-
: 'This help desk requires sign-in. Open it in a new tab to sign in and submit your request there.');
|
|
21811
|
+
message('This help desk requires sign-in. Open it in a new tab to sign in and submit your request there.');
|
|
21786
21812
|
}
|
|
21787
21813
|
async function submit() {
|
|
21788
21814
|
if (pending || completed || destroyed)
|
|
@@ -26793,7 +26819,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26793
26819
|
sourceArticleId = undefined;
|
|
26794
26820
|
}
|
|
26795
26821
|
/**
|
|
26796
|
-
* Switch account from the contact form:
|
|
26822
|
+
* Switch account from the contact form: the window's chooser opens in this
|
|
26797
26823
|
* gesture, the current session staying current until another account's is
|
|
26798
26824
|
* redeemed. A window that closes or fails rejects, nothing changed, for the
|
|
26799
26825
|
* form to say so; a redeemed session takes the old one's place.
|
|
@@ -27313,7 +27339,7 @@ function idempotencyHeaders(key) {
|
|
|
27313
27339
|
if (key === undefined)
|
|
27314
27340
|
return undefined;
|
|
27315
27341
|
if (typeof key !== 'string' || !/^[\x20-\x7E]{8,128}$/.test(key))
|
|
27316
|
-
throw new ValidationError('idempotencyKey must contain 8
|
|
27342
|
+
throw new ValidationError('idempotencyKey must contain 8 to 128 printable ASCII characters');
|
|
27317
27343
|
return { 'Idempotency-Key': key };
|
|
27318
27344
|
}
|
|
27319
27345
|
/** Empty pages are legitimate; a repeated cursor is never drained forever. */
|
|
@@ -28009,7 +28035,7 @@ function createSecuritySidebar(branding) {
|
|
|
28009
28035
|
const STYLE_ID = 'sparkvault-upload-styles';
|
|
28010
28036
|
/**
|
|
28011
28037
|
* Inject upload widget styles into the document head.
|
|
28012
|
-
* Idempotent: the stylesheet is static and shared by every widget instance
|
|
28038
|
+
* Idempotent: the stylesheet is static and shared by every widget instance;
|
|
28013
28039
|
* per-instance behavior (backdrop blur, dark mode) is driven by class toggles.
|
|
28014
28040
|
*/
|
|
28015
28041
|
function injectUploadStyles() {
|
|
@@ -29472,7 +29498,7 @@ class UploadRenderer {
|
|
|
29472
29498
|
this.hybridModalInitialized = false;
|
|
29473
29499
|
// Lifecycle flags: a closed renderer must never render or fire callbacks,
|
|
29474
29500
|
// and onCancel fires at most once per renderer (mutually exclusive with
|
|
29475
|
-
// onError
|
|
29501
|
+
// onError; see cancel()/handleApiError).
|
|
29476
29502
|
this.closed = false;
|
|
29477
29503
|
this.cancelled = false;
|
|
29478
29504
|
// Counts the uploads this renderer started; an upload whose number is no
|
|
@@ -29558,7 +29584,7 @@ class UploadRenderer {
|
|
|
29558
29584
|
}
|
|
29559
29585
|
/**
|
|
29560
29586
|
* Cancel the flow: tear everything down and fire the cancel contract
|
|
29561
|
-
* exactly once. onCancel and onError are mutually exclusive
|
|
29587
|
+
* exactly once. onCancel and onError are mutually exclusive: a deliberate
|
|
29562
29588
|
* cancellation (user close, programmatic close, or a new upload replacing
|
|
29563
29589
|
* this renderer) must never surface as an error to the host.
|
|
29564
29590
|
*/
|
|
@@ -29582,7 +29608,7 @@ class UploadRenderer {
|
|
|
29582
29608
|
this.cancel();
|
|
29583
29609
|
}
|
|
29584
29610
|
setState(state) {
|
|
29585
|
-
// A closed renderer never renders again
|
|
29611
|
+
// A closed renderer never renders again: a progress event racing the
|
|
29586
29612
|
// teardown must not resurrect the hybrid-mode modal or touch the DOM.
|
|
29587
29613
|
if (this.closed)
|
|
29588
29614
|
return;
|
|
@@ -29590,7 +29616,7 @@ class UploadRenderer {
|
|
|
29590
29616
|
this.viewState = state;
|
|
29591
29617
|
// Progress events fire many times per second for the whole transfer.
|
|
29592
29618
|
// While the uploading view is already on screen, mutate its progress
|
|
29593
|
-
// nodes in place instead of tearing down and rebuilding the subtree
|
|
29619
|
+
// nodes in place instead of tearing down and rebuilding the subtree:
|
|
29594
29620
|
// a full rebuild per event thrashes the DOM and restarts the progress
|
|
29595
29621
|
// bar's CSS transition and the stage-arrow animation on every tick. The
|
|
29596
29622
|
// view re-renders once, when every byte is sent and SparkVault is
|
|
@@ -30254,7 +30280,7 @@ class UploadRenderer {
|
|
|
30254
30280
|
const sent = { bytesUploaded: file.size, bytesTotal: file.size, percentage: 100 };
|
|
30255
30281
|
this.callbacks.onProgress?.({ ...sent, phase: 'ceremony' });
|
|
30256
30282
|
this.callbacks.onProgress?.({ ...sent, phase: 'complete' });
|
|
30257
|
-
// Silent mode: skip the success screen
|
|
30283
|
+
// Silent mode: skip the success screen, fire onSuccess and close so
|
|
30258
30284
|
// the host site can render its own post-upload UI.
|
|
30259
30285
|
if (this.options.hideSuccessScreen) {
|
|
30260
30286
|
this.callbacks.onSuccess(result);
|
|
@@ -30329,8 +30355,8 @@ class UploadRenderer {
|
|
|
30329
30355
|
handleApiError(error, action = null) {
|
|
30330
30356
|
// A closed renderer must not surface errors: cancelling mid-transfer
|
|
30331
30357
|
// aborts the in-flight request, whose 'cancelled' rejection races the
|
|
30332
|
-
// teardown. The host has already received onCancel
|
|
30333
|
-
// onError are mutually exclusive
|
|
30358
|
+
// teardown. The host has already received onCancel (onCancel and
|
|
30359
|
+
// onError are mutually exclusive) and the container is destroyed, so
|
|
30334
30360
|
// there is nothing left to render into.
|
|
30335
30361
|
if (this.closed || isCancellationError(error)) {
|
|
30336
30362
|
return;
|
|
@@ -30490,7 +30516,7 @@ class VaultUploadModule {
|
|
|
30490
30516
|
}
|
|
30491
30517
|
// Public-API aliases. The dashboard's vault-edit screen and the SDK docs
|
|
30492
30518
|
// document sv.vaults.upload.pop({ vaultId }) and
|
|
30493
|
-
// sv.vaults.upload.render({ vaultId, target })
|
|
30519
|
+
// sv.vaults.upload.render({ vaultId, target }); both defer to upload().
|
|
30494
30520
|
/** Open the upload widget as a popup. Equivalent to `upload(options)`. */
|
|
30495
30521
|
async pop(options) {
|
|
30496
30522
|
return this.upload(options);
|
|
@@ -30664,7 +30690,7 @@ class VaultsModule {
|
|
|
30664
30690
|
};
|
|
30665
30691
|
}
|
|
30666
30692
|
/**
|
|
30667
|
-
* Retain this many previous versions of each file or structured object (0
|
|
30693
|
+
* Retain this many previous versions of each file or structured object (0 to 50,
|
|
30668
30694
|
* default 0). Interactive company administrators only. Applies on each ingot's
|
|
30669
30695
|
* next successful content change; retained versions count toward storage usage.
|
|
30670
30696
|
*/
|
|
@@ -30722,7 +30748,7 @@ class VaultsModule {
|
|
|
30722
30748
|
* Requires the vault's exact name as confirmation, matched case-sensitively.
|
|
30723
30749
|
* The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
|
|
30724
30750
|
* named with any Unicode (emoji, CJK, the U+202F in macOS-style names) is
|
|
30725
|
-
* deletable
|
|
30751
|
+
* deletable: an HTTP header value cannot carry non-latin1 characters.
|
|
30726
30752
|
*
|
|
30727
30753
|
* @example
|
|
30728
30754
|
* await sv.vaults.delete('vlt_abc', 'My Vault');
|
|
@@ -31028,7 +31054,7 @@ class SparksModule {
|
|
|
31028
31054
|
};
|
|
31029
31055
|
}
|
|
31030
31056
|
/**
|
|
31031
|
-
* Read (and burn) a spark. Reading is destructive
|
|
31057
|
+
* Read (and burn) a spark. Reading is destructive: the spark can be read
|
|
31032
31058
|
* exactly once.
|
|
31033
31059
|
* Supply the source vault's VAT for a Structured Ingots field Spark.
|
|
31034
31060
|
*
|
|
@@ -31234,7 +31260,7 @@ class EntropyModule {
|
|
|
31234
31260
|
/**
|
|
31235
31261
|
* Generate `n` random bytes as a Uint8Array.
|
|
31236
31262
|
*
|
|
31237
|
-
* SECURITY: this returns raw *server* entropy
|
|
31263
|
+
* SECURITY: this returns raw *server* entropy; it is NOT finished key
|
|
31238
31264
|
* material. Client secret keys MUST hybrid-mix it: XOR the returned bytes with
|
|
31239
31265
|
* a local CSPRNG (`crypto.getRandomValues`) before use, so the server share
|
|
31240
31266
|
* alone can never determine the key.
|
|
@@ -31242,7 +31268,7 @@ class EntropyModule {
|
|
|
31242
31268
|
* @example
|
|
31243
31269
|
* const serverEntropy = await sv.entropy.generateBytes(32);
|
|
31244
31270
|
* const localEntropy = crypto.getRandomValues(new Uint8Array(32));
|
|
31245
|
-
* // Hybrid-mixed key material
|
|
31271
|
+
* // Hybrid-mixed key material, safe to use as a secret key.
|
|
31246
31272
|
* const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
|
|
31247
31273
|
*/
|
|
31248
31274
|
async generateBytes(n) {
|
|
@@ -31291,7 +31317,7 @@ function validateEntropyRequest(bytes, format) {
|
|
|
31291
31317
|
* Web Push registration. It is
|
|
31292
31318
|
* not a tenant's inbox for its own end users: a tenant reads its recipients'
|
|
31293
31319
|
* feeds with `sv.products.notify.getInbox`. The recipient is ALWAYS derived
|
|
31294
|
-
* from the session on the server
|
|
31320
|
+
* from the session on the server: no method takes a `recipient_id`, and any
|
|
31295
31321
|
* account/recipient a caller might try to supply is ignored. This mirrors
|
|
31296
31322
|
* `@sparkvault/sdk-mobile`'s notify client; device push registration is
|
|
31297
31323
|
* intentionally omitted (Expo-only on mobile).
|
|
@@ -31333,7 +31359,7 @@ class NotifyModule {
|
|
|
31333
31359
|
this.http = http;
|
|
31334
31360
|
}
|
|
31335
31361
|
/**
|
|
31336
|
-
* The caller's own inbox feed (newest first). Follow `cursor` to page
|
|
31362
|
+
* The caller's own inbox feed (newest first). Follow `cursor` to page: a
|
|
31337
31363
|
* page can come back short of `limit` yet still carry a non-null cursor.
|
|
31338
31364
|
*
|
|
31339
31365
|
* @example
|
|
@@ -31347,7 +31373,7 @@ class NotifyModule {
|
|
|
31347
31373
|
}
|
|
31348
31374
|
/**
|
|
31349
31375
|
* Bounded unseen badge count for the caller's own inbox. `capped` true means
|
|
31350
|
-
* the true count is at/beyond the ceiling
|
|
31376
|
+
* the true count is at/beyond the ceiling: render "N+".
|
|
31351
31377
|
*
|
|
31352
31378
|
* @example
|
|
31353
31379
|
* const { unread_count, capped } = await sv.notify.getUnreadCount();
|
|
@@ -31359,7 +31385,7 @@ class NotifyModule {
|
|
|
31359
31385
|
/**
|
|
31360
31386
|
* Apply a terminal display state to one of the caller's own rows (idempotent).
|
|
31361
31387
|
* `createdAt` MUST be the row's own `created_at` (round-tripped from the list
|
|
31362
|
-
* row)
|
|
31388
|
+
* row); the id alone cannot address the row.
|
|
31363
31389
|
*
|
|
31364
31390
|
* @example
|
|
31365
31391
|
* await sv.notify.markState('ntf_abc', { createdAt: row.created_at, state: 'read' });
|
|
@@ -31383,7 +31409,7 @@ class NotifyModule {
|
|
|
31383
31409
|
}
|
|
31384
31410
|
/**
|
|
31385
31411
|
* Bulk-mark ONE bounded page of the caller's inbox and return the server's
|
|
31386
|
-
* payload verbatim. `cursor` comes back non-null while rows remain
|
|
31412
|
+
* payload verbatim. `cursor` comes back non-null while rows remain: thread it
|
|
31387
31413
|
* into the next call. `archived` is per-row only (no GSI to page over), so the
|
|
31388
31414
|
* bulk states are `seen` and `read`.
|
|
31389
31415
|
*
|
|
@@ -31418,10 +31444,10 @@ class NotifyModule {
|
|
|
31418
31444
|
* clears the unseen marker too, so the badge zeroes with it. Idempotent.
|
|
31419
31445
|
*
|
|
31420
31446
|
* `complete` is false when the loop stopped at the page bound with rows still
|
|
31421
|
-
* unmarked
|
|
31447
|
+
* unmarked: an inbox deeper than the bound finishes on a second call. Without
|
|
31422
31448
|
* it a truncated drain looks exactly like a finished one.
|
|
31423
31449
|
*
|
|
31424
|
-
* An error mid-drain propagates
|
|
31450
|
+
* An error mid-drain propagates: the pages already marked stay marked, and a
|
|
31425
31451
|
* re-run picks up the remainder.
|
|
31426
31452
|
*
|
|
31427
31453
|
* @example
|
|
@@ -31453,7 +31479,7 @@ class NotifyModule {
|
|
|
31453
31479
|
}
|
|
31454
31480
|
/**
|
|
31455
31481
|
* The platform VAPID public key for `pushManager.subscribe()`. `configured`
|
|
31456
|
-
* is false until the server-side VAPID keypair is provisioned
|
|
31482
|
+
* is false until the server-side VAPID keypair is provisioned: hide the
|
|
31457
31483
|
* enable-notifications affordance while false.
|
|
31458
31484
|
*/
|
|
31459
31485
|
async getWebPushKey() {
|
|
@@ -31567,8 +31593,8 @@ class NotifyModule {
|
|
|
31567
31593
|
}
|
|
31568
31594
|
}
|
|
31569
31595
|
// A subscription made against the current key is reused: registering it
|
|
31570
|
-
// again refreshes its server TTL. One made against another key is dead
|
|
31571
|
-
// push service refuses every push signed with this one
|
|
31596
|
+
// again refreshes its server TTL. One made against another key is dead (its
|
|
31597
|
+
// push service refuses every push signed with this one), so it is replaced.
|
|
31572
31598
|
const held = await registration.pushManager.getSubscription();
|
|
31573
31599
|
const existing = held && isBoundToKey(held, applicationServerKey) ? held : null;
|
|
31574
31600
|
if (held && !existing) {
|
|
@@ -31740,7 +31766,7 @@ class SparkVault {
|
|
|
31740
31766
|
return new SparkVault(config);
|
|
31741
31767
|
}
|
|
31742
31768
|
/**
|
|
31743
|
-
* Whether a sign-in needs completing on this page load
|
|
31769
|
+
* Whether a sign-in needs completing on this page load: a returned handoff
|
|
31744
31770
|
* fragment, or a popup whose result was lost (a mobile opener-tab discard).
|
|
31745
31771
|
* Side effect-free and instance-free, so a host that defers SDK init for
|
|
31746
31772
|
* performance can cheaply decide whether to boot the SDK and call
|
|
@@ -31752,7 +31778,7 @@ class SparkVault {
|
|
|
31752
31778
|
}
|
|
31753
31779
|
/** Get the SDK version */
|
|
31754
31780
|
static get version() {
|
|
31755
|
-
return '
|
|
31781
|
+
return '18.0.0';
|
|
31756
31782
|
}
|
|
31757
31783
|
}
|
|
31758
31784
|
if (typeof window !== 'undefined') {
|