@sparkvault/sdk-js 8.14.0 → 9.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 +13 -5
- package/dist/config.d.ts +6 -4
- package/dist/{sparkvault.cjs.js → index.cjs} +245 -35
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +341 -32
- package/dist/{sparkvault.esm.js → index.mjs} +245 -35
- package/dist/index.mjs.map +1 -0
- package/dist/products/identity/index.d.ts +13 -2
- package/dist/products/identity/types.d.ts +8 -0
- package/dist/products/index.d.ts +1 -1
- package/dist/products/notify/index.d.ts +72 -11
- package/dist/products/notify/types.d.ts +243 -16
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +17 -6
- package/dist/sparkvault.cjs.js.map +0 -1
- package/dist/sparkvault.esm.js.map +0 -1
|
@@ -192,7 +192,9 @@ function resolveConfig(config) {
|
|
|
192
192
|
getAccessToken: config.getAccessToken,
|
|
193
193
|
apiKey: config.apiKey,
|
|
194
194
|
clientId: config.clientId,
|
|
195
|
-
|
|
195
|
+
// Preloading warms a dialog that only a browser can open; default it off
|
|
196
|
+
// where there is no DOM so server hosts make no init-time network call.
|
|
197
|
+
preloadConfig: config.preloadConfig ?? typeof window !== 'undefined',
|
|
196
198
|
backdropBlur: config.backdropBlur !== false, // Default: true
|
|
197
199
|
allowedDownloadHostPatterns: config.allowedDownloadHostPatterns ?? DEFAULT_ALLOWED_DOWNLOAD_HOST_PATTERNS,
|
|
198
200
|
};
|
|
@@ -862,6 +864,12 @@ function buildSigninUrl(config, options, extras) {
|
|
|
862
864
|
params.set('mode', 'simple');
|
|
863
865
|
params.set('session', authContext.simpleMode.sessionId);
|
|
864
866
|
}
|
|
867
|
+
// `prompt` is validated here, the single serialization point: only the exact
|
|
868
|
+
// literal reaches the sign-in page; anything else is silently dropped, so a
|
|
869
|
+
// plain-JS caller passing junk degrades to the default behavior.
|
|
870
|
+
if (options.prompt === 'select_account') {
|
|
871
|
+
params.set('prompt', 'select_account');
|
|
872
|
+
}
|
|
865
873
|
if (extras) {
|
|
866
874
|
params.set('redirect_uri', extras.redirectUri);
|
|
867
875
|
params.set('state', extras.state);
|
|
@@ -965,11 +973,15 @@ class IdentityApi extends SparkVaultApi {
|
|
|
965
973
|
* If preload fails, getConfig() will clear the cache and retry.
|
|
966
974
|
*/
|
|
967
975
|
preloadConfig() {
|
|
968
|
-
if (
|
|
969
|
-
|
|
970
|
-
// If this fails, getConfig() clears the cache and retries.
|
|
971
|
-
this.configCache = this.request('GET', '/config');
|
|
976
|
+
if (this.configCache) {
|
|
977
|
+
return;
|
|
972
978
|
}
|
|
979
|
+
const pending = this.request('GET', '/config');
|
|
980
|
+
this.configCache = pending;
|
|
981
|
+
// Nobody awaits a background preload, and an unawaited rejection aborts the
|
|
982
|
+
// whole Node process. Attach a terminal handler so the failure stays parked
|
|
983
|
+
// on the cached promise, which getConfig() re-raises to its caller on demand.
|
|
984
|
+
pending.catch(() => { });
|
|
973
985
|
}
|
|
974
986
|
/**
|
|
975
987
|
* Check if config has been preloaded and is ready.
|
|
@@ -8562,17 +8574,67 @@ const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
|
|
|
8562
8574
|
// listener but not sessionStorage) is what lets the next load self-heal.
|
|
8563
8575
|
const PENDING_KEY = 'sv_signin_pending';
|
|
8564
8576
|
const PENDING_TTL_MS = 10 * 60 * 1000;
|
|
8565
|
-
|
|
8566
|
-
|
|
8577
|
+
// One-shot: the identifier the recovery bounce is re-minting for. Written only
|
|
8578
|
+
// by the recovery bounce; the return leg consumes it to verify the redeemed
|
|
8579
|
+
// result is for that same account (see consumeHandoffFragment).
|
|
8580
|
+
const RECOVERY_HINT_KEY = 'sv_recovery_hint';
|
|
8581
|
+
/**
|
|
8582
|
+
* Normalize an identifier for equality, mirroring the server: trim, and
|
|
8583
|
+
* lowercase emails (a value containing '@'). Phones compare trimmed-exact.
|
|
8584
|
+
*/
|
|
8585
|
+
function normalizeIdentity(value) {
|
|
8586
|
+
const trimmed = value.trim();
|
|
8587
|
+
return trimmed.includes('@') ? trimmed.toLowerCase() : trimmed;
|
|
8588
|
+
}
|
|
8589
|
+
/**
|
|
8590
|
+
* Read and parse the pending marker — JSON `{ at, hint }`, where `hint` is the
|
|
8591
|
+
* email or phone the sign-in was started with (null when the flow collects the
|
|
8592
|
+
* identifier itself). A bare-timestamp value is accepted as `{ at, hint: null }`:
|
|
8593
|
+
* markers live at most 10 minutes in sessionStorage, so any such value
|
|
8594
|
+
* disappears within one deploy window of this parser going live — the fallback
|
|
8595
|
+
* is bounded and never grows. Anything unreadable yields null.
|
|
8596
|
+
*/
|
|
8597
|
+
function readPendingMarker() {
|
|
8567
8598
|
let raw = null;
|
|
8568
8599
|
try {
|
|
8569
8600
|
raw = sessionStorage.getItem(PENDING_KEY);
|
|
8570
8601
|
}
|
|
8571
8602
|
catch {
|
|
8572
|
-
return
|
|
8603
|
+
return null;
|
|
8604
|
+
}
|
|
8605
|
+
if (!raw) {
|
|
8606
|
+
return null;
|
|
8607
|
+
}
|
|
8608
|
+
let at = NaN;
|
|
8609
|
+
let hint = null;
|
|
8610
|
+
try {
|
|
8611
|
+
const parsed = JSON.parse(raw);
|
|
8612
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
8613
|
+
const marker = parsed;
|
|
8614
|
+
if (typeof marker.at === 'number') {
|
|
8615
|
+
at = marker.at;
|
|
8616
|
+
}
|
|
8617
|
+
if (typeof marker.hint === 'string' && marker.hint) {
|
|
8618
|
+
hint = marker.hint;
|
|
8619
|
+
}
|
|
8620
|
+
}
|
|
8621
|
+
else if (typeof parsed === 'number') {
|
|
8622
|
+
// A bare timestamp parses as a JSON number.
|
|
8623
|
+
at = parsed;
|
|
8624
|
+
}
|
|
8573
8625
|
}
|
|
8574
|
-
|
|
8575
|
-
|
|
8626
|
+
catch {
|
|
8627
|
+
at = Number(raw);
|
|
8628
|
+
}
|
|
8629
|
+
return Number.isFinite(at) ? { at, hint } : null;
|
|
8630
|
+
}
|
|
8631
|
+
/** True while a marker is within the self-heal TTL. */
|
|
8632
|
+
function isFreshPendingMarker(marker) {
|
|
8633
|
+
return marker !== null && Date.now() - marker.at < PENDING_TTL_MS;
|
|
8634
|
+
}
|
|
8635
|
+
/** True when the pending marker is present and still within its TTL. */
|
|
8636
|
+
function hasFreshPendingMarker() {
|
|
8637
|
+
return isFreshPendingMarker(readPendingMarker());
|
|
8576
8638
|
}
|
|
8577
8639
|
/**
|
|
8578
8640
|
* Whether `handleRedirectResult()` has anything to do on this load — a returned
|
|
@@ -8842,7 +8904,8 @@ class IdentityModule {
|
|
|
8842
8904
|
// the backgrounded opener tab, killing the postMessage listener),
|
|
8843
8905
|
// handleRedirectResult() can silently self-heal on the next load from
|
|
8844
8906
|
// the SSO session the popup login established.
|
|
8845
|
-
|
|
8907
|
+
const pendingHint = mergedOptions.email || mergedOptions.phone || null;
|
|
8908
|
+
this.markSignInPending(pendingHint);
|
|
8846
8909
|
this.launcher = new DialogLauncher(this.config, this.api, mergedOptions, {
|
|
8847
8910
|
onSuccess: (result) => { this.clearSignInPending(); hostCallbacks.onSuccess(result); },
|
|
8848
8911
|
onError: (error) => { this.clearSignInPending(); hostCallbacks.onError(error); },
|
|
@@ -8851,7 +8914,7 @@ class IdentityModule {
|
|
|
8851
8914
|
// no-result end retires the marker (no spurious bounce on a reload
|
|
8852
8915
|
// while the retry alert is up); "Try again" re-arms it.
|
|
8853
8916
|
onPopupClosedUnresolved: () => this.clearSignInPending(),
|
|
8854
|
-
onPopupReopened: () => this.markSignInPending(),
|
|
8917
|
+
onPopupReopened: () => this.markSignInPending(pendingHint),
|
|
8855
8918
|
// COOP-severed popup: postMessage can never deliver, so switch this tab
|
|
8856
8919
|
// to the redirect flow (returns via handleRedirectResult). The pending
|
|
8857
8920
|
// marker stays armed — the returned #sv_code fragment retires it.
|
|
@@ -8889,6 +8952,7 @@ class IdentityModule {
|
|
|
8889
8952
|
email: options.email,
|
|
8890
8953
|
phone: options.phone,
|
|
8891
8954
|
authContext: options.authContext,
|
|
8955
|
+
prompt: options.prompt,
|
|
8892
8956
|
onSuccess: options.onSuccess,
|
|
8893
8957
|
onError: options.onError,
|
|
8894
8958
|
onCancel: options.onCancel,
|
|
@@ -9004,8 +9068,9 @@ class IdentityModule {
|
|
|
9004
9068
|
}
|
|
9005
9069
|
// No returned result. If a sign-in was in flight and its result never
|
|
9006
9070
|
// arrived, self-heal once from the SSO session (mobile opener-tab discard).
|
|
9007
|
-
|
|
9008
|
-
|
|
9071
|
+
const pending = this.consumeSignInPending();
|
|
9072
|
+
if (pending.fresh) {
|
|
9073
|
+
await this.startRecoveryBounce(pending.hint);
|
|
9009
9074
|
}
|
|
9010
9075
|
return null;
|
|
9011
9076
|
}
|
|
@@ -9022,9 +9087,11 @@ class IdentityModule {
|
|
|
9022
9087
|
// (and a StrictMode double-invocation finds an empty hash and no-ops).
|
|
9023
9088
|
let expectedState = null;
|
|
9024
9089
|
let codeVerifier = null;
|
|
9090
|
+
let expectedRecoveryIdentity = null;
|
|
9025
9091
|
try {
|
|
9026
9092
|
expectedState = sessionStorage.getItem('sv_oauth_state');
|
|
9027
9093
|
codeVerifier = sessionStorage.getItem('sv_pkce_verifier');
|
|
9094
|
+
expectedRecoveryIdentity = sessionStorage.getItem(RECOVERY_HINT_KEY);
|
|
9028
9095
|
this.clearOneShotAuthState();
|
|
9029
9096
|
}
|
|
9030
9097
|
catch {
|
|
@@ -9054,6 +9121,18 @@ class IdentityModule {
|
|
|
9054
9121
|
sessionId: raw.session_id ?? undefined,
|
|
9055
9122
|
refreshToken: raw.refresh_token ?? undefined,
|
|
9056
9123
|
};
|
|
9124
|
+
// A recovery bounce carries the identifier the interrupted sign-in was
|
|
9125
|
+
// addressing, but /sso treats a hint matching no hub session like no hint
|
|
9126
|
+
// at all (anti-oracle) — so the bounce can come back holding a DIFFERENT
|
|
9127
|
+
// single-eligible account. The client is the one place that knows which
|
|
9128
|
+
// account the person was signing in to: a mismatched result is discarded,
|
|
9129
|
+
// never handed to the host (a wrong-account handoff). Silent — no
|
|
9130
|
+
// onError — falling through to interactive sign-in, matching the recovery
|
|
9131
|
+
// flow's non-oracle posture.
|
|
9132
|
+
if (expectedRecoveryIdentity &&
|
|
9133
|
+
normalizeIdentity(expectedRecoveryIdentity) !== normalizeIdentity(result.identity)) {
|
|
9134
|
+
return null;
|
|
9135
|
+
}
|
|
9057
9136
|
options.onSuccess?.(result);
|
|
9058
9137
|
return result;
|
|
9059
9138
|
}
|
|
@@ -9072,11 +9151,41 @@ class IdentityModule {
|
|
|
9072
9151
|
* so a hostile/degraded environment simply never recovers rather than
|
|
9073
9152
|
* erroring.
|
|
9074
9153
|
*/
|
|
9075
|
-
async startRecoveryBounce() {
|
|
9076
|
-
const
|
|
9154
|
+
async startRecoveryBounce(loginHint) {
|
|
9155
|
+
const sso = new URL(`${this.config.identityBaseUrl}/${this.config.accountId}/sso`);
|
|
9156
|
+
// With several hub sessions, login_hint tells /sso which account the
|
|
9157
|
+
// interrupted sign-in was addressing, so recovery never re-mints another.
|
|
9158
|
+
// Also stash it one-shot: a hint matching no hub session deliberately
|
|
9159
|
+
// behaves server-side like no hint at all (anti-oracle), so the return leg
|
|
9160
|
+
// must verify the redeemed identity is the one this sign-in was for.
|
|
9161
|
+
try {
|
|
9162
|
+
if (loginHint) {
|
|
9163
|
+
sessionStorage.setItem(RECOVERY_HINT_KEY, loginHint);
|
|
9164
|
+
}
|
|
9165
|
+
else {
|
|
9166
|
+
sessionStorage.removeItem(RECOVERY_HINT_KEY);
|
|
9167
|
+
}
|
|
9168
|
+
}
|
|
9169
|
+
catch {
|
|
9170
|
+
// No storage → prepareHandoffNavigation bails below; nothing to verify.
|
|
9171
|
+
}
|
|
9172
|
+
if (loginHint) {
|
|
9173
|
+
sso.searchParams.set('login_hint', loginHint);
|
|
9174
|
+
}
|
|
9175
|
+
const nav = await this.prepareHandoffNavigation(sso.toString());
|
|
9077
9176
|
if (nav) {
|
|
9078
9177
|
window.location.assign(nav);
|
|
9079
9178
|
}
|
|
9179
|
+
else {
|
|
9180
|
+
// The bounce never left (no storage or WebCrypto) — retire the stash so
|
|
9181
|
+
// it cannot linger into an unrelated later return leg.
|
|
9182
|
+
try {
|
|
9183
|
+
sessionStorage.removeItem(RECOVERY_HINT_KEY);
|
|
9184
|
+
}
|
|
9185
|
+
catch {
|
|
9186
|
+
// Storage disabled: nothing was persisted, nothing to clear.
|
|
9187
|
+
}
|
|
9188
|
+
}
|
|
9080
9189
|
}
|
|
9081
9190
|
/**
|
|
9082
9191
|
* Explicit `flow: 'redirect'` — navigate this tab to the interactive sign-in
|
|
@@ -9136,9 +9245,16 @@ class IdentityModule {
|
|
|
9136
9245
|
url.searchParams.set('code_challenge', codeChallenge);
|
|
9137
9246
|
return url.toString();
|
|
9138
9247
|
}
|
|
9139
|
-
|
|
9248
|
+
/**
|
|
9249
|
+
* Arm the self-heal marker for an in-flight sign-in. `hint` is the identifier
|
|
9250
|
+
* (email or phone) the sign-in was started with, when the caller supplied
|
|
9251
|
+
* one — the recovery bounce forwards it as the /sso `login_hint`, so with
|
|
9252
|
+
* several hub sessions recovery re-mints the account this sign-in was for,
|
|
9253
|
+
* never a different one.
|
|
9254
|
+
*/
|
|
9255
|
+
markSignInPending(hint) {
|
|
9140
9256
|
try {
|
|
9141
|
-
sessionStorage.setItem(PENDING_KEY,
|
|
9257
|
+
sessionStorage.setItem(PENDING_KEY, JSON.stringify({ at: Date.now(), hint }));
|
|
9142
9258
|
}
|
|
9143
9259
|
catch {
|
|
9144
9260
|
// No storage → no self-heal; the popup still delivers when it can.
|
|
@@ -9152,11 +9268,16 @@ class IdentityModule {
|
|
|
9152
9268
|
// Nothing to clear.
|
|
9153
9269
|
}
|
|
9154
9270
|
}
|
|
9155
|
-
/**
|
|
9271
|
+
/**
|
|
9272
|
+
* Consume the pending marker: `fresh` is true once (then cleared) if a recent
|
|
9273
|
+
* sign-in is still awaiting its result; `hint` is the identifier that sign-in
|
|
9274
|
+
* carried, for the recovery bounce's `login_hint`.
|
|
9275
|
+
*/
|
|
9156
9276
|
consumeSignInPending() {
|
|
9157
|
-
const
|
|
9277
|
+
const marker = readPendingMarker();
|
|
9278
|
+
const fresh = isFreshPendingMarker(marker);
|
|
9158
9279
|
this.clearSignInPending();
|
|
9159
|
-
return fresh;
|
|
9280
|
+
return { fresh, hint: fresh ? marker.hint : null };
|
|
9160
9281
|
}
|
|
9161
9282
|
/** Remove the result fragment from the URL bar (and history entry). */
|
|
9162
9283
|
clearUrlFragment() {
|
|
@@ -9164,11 +9285,12 @@ class IdentityModule {
|
|
|
9164
9285
|
window.history.replaceState(window.history.state, document.title, `${window.location.pathname}${window.location.search}`);
|
|
9165
9286
|
}
|
|
9166
9287
|
}
|
|
9167
|
-
/** Drop the one-shot PKCE state/verifier a
|
|
9288
|
+
/** Drop the one-shot PKCE state/verifier (+ recovery hint) a bounce staged. */
|
|
9168
9289
|
clearOneShotAuthState() {
|
|
9169
9290
|
try {
|
|
9170
9291
|
sessionStorage.removeItem('sv_oauth_state');
|
|
9171
9292
|
sessionStorage.removeItem('sv_pkce_verifier');
|
|
9293
|
+
sessionStorage.removeItem(RECOVERY_HINT_KEY);
|
|
9172
9294
|
}
|
|
9173
9295
|
catch {
|
|
9174
9296
|
// Storage disabled: nothing was persisted, nothing to clear.
|
|
@@ -9305,8 +9427,9 @@ class IdentityModule {
|
|
|
9305
9427
|
*
|
|
9306
9428
|
* The counterpart to `sv.notify`: where that module is session-scoped and reads
|
|
9307
9429
|
* only the signed-in person's OWN inbox, this one is the account-scoped product
|
|
9308
|
-
* surface a tenant's BACKEND drives — send, sender-side
|
|
9309
|
-
* send status, receipts, and the account's Notify config.
|
|
9430
|
+
* surface a tenant's BACKEND drives — send, send history, recall, sender-side
|
|
9431
|
+
* inbox reads and state, send status, receipts, and the account's Notify config.
|
|
9432
|
+
* Every method maps to
|
|
9310
9433
|
* `/v1/products/notify/*` and is authorized by the caller's account, so the
|
|
9311
9434
|
* recipient is supplied explicitly rather than derived from a session.
|
|
9312
9435
|
*
|
|
@@ -9358,15 +9481,22 @@ const NOTIFY_PRESETS = Object.freeze({
|
|
|
9358
9481
|
channels: ['in_app', 'push', 'web_push', 'email'],
|
|
9359
9482
|
policy: { verificationLevel: 'identifier', interaction: 'reply' },
|
|
9360
9483
|
},
|
|
9484
|
+
// `approval` and `signatureRequest` verify at `identifier`, not `passkey`: a
|
|
9485
|
+
// passkey-level grant is only satisfiable by a recipient who ALREADY has a
|
|
9486
|
+
// passkey registered with SparkVault, and the recipient ceremony cannot enrol
|
|
9487
|
+
// one mid-flight — a passkey default strands every first-time raw-email
|
|
9488
|
+
// recipient on a request they can never answer. Pass
|
|
9489
|
+
// `policy: { verificationLevel: 'passkey' }` explicitly when the audience is
|
|
9490
|
+
// known to be enrolled.
|
|
9361
9491
|
approval: {
|
|
9362
9492
|
category: 'approval',
|
|
9363
9493
|
channels: ['in_app', 'push', 'web_push', 'email'],
|
|
9364
|
-
policy: { verificationLevel: '
|
|
9494
|
+
policy: { verificationLevel: 'identifier', interaction: 'approve' },
|
|
9365
9495
|
},
|
|
9366
9496
|
signatureRequest: {
|
|
9367
9497
|
category: 'signature',
|
|
9368
9498
|
channels: ['in_app', 'push', 'web_push', 'email'],
|
|
9369
|
-
policy: { verificationLevel: '
|
|
9499
|
+
policy: { verificationLevel: 'identifier', interaction: 'sign' },
|
|
9370
9500
|
},
|
|
9371
9501
|
});
|
|
9372
9502
|
/**
|
|
@@ -9456,11 +9586,11 @@ class NotifyProductModule {
|
|
|
9456
9586
|
async sendConversation(options) {
|
|
9457
9587
|
return this.send(buildNotifyPresetSend('conversation', options));
|
|
9458
9588
|
}
|
|
9459
|
-
/** High-stakes approve/deny —
|
|
9589
|
+
/** High-stakes approve/deny — identifier-verified, with `action_hash` binding. */
|
|
9460
9590
|
async sendApproval(options) {
|
|
9461
9591
|
return this.send(buildNotifyPresetSend('approval', options));
|
|
9462
9592
|
}
|
|
9463
|
-
/** Signature-on-delivery —
|
|
9593
|
+
/** Signature-on-delivery — identifier-verified, with `action_hash` binding. */
|
|
9464
9594
|
async sendSignatureRequest(options) {
|
|
9465
9595
|
return this.send(buildNotifyPresetSend('signatureRequest', options));
|
|
9466
9596
|
}
|
|
@@ -9546,6 +9676,76 @@ class NotifyProductModule {
|
|
|
9546
9676
|
});
|
|
9547
9677
|
return response.data;
|
|
9548
9678
|
}
|
|
9679
|
+
// ── Send history & recall ───────────────────────────────────────────────────
|
|
9680
|
+
/**
|
|
9681
|
+
* The account's send history, newest first — what you sent, to how many, and
|
|
9682
|
+
* how it landed.
|
|
9683
|
+
*
|
|
9684
|
+
* Metadata only by construction: the history index does not project the
|
|
9685
|
+
* audience, so no recipient contact or SparkLink pointer can travel here. Take
|
|
9686
|
+
* `getSendStatus(sendId)` for the per-recipient detail.
|
|
9687
|
+
*
|
|
9688
|
+
* Real pagination: a null `cursor` means the end of the account's history.
|
|
9689
|
+
*
|
|
9690
|
+
* @example
|
|
9691
|
+
* let cursor: string | undefined;
|
|
9692
|
+
* do {
|
|
9693
|
+
* const page = await sv.products.notify.listSends({ cursor, limit: 50 });
|
|
9694
|
+
* for (const send of page.sends) {
|
|
9695
|
+
* console.log(send.created_at, send.title, send.state,
|
|
9696
|
+
* `${send.delivered_count ?? '?'} / ${send.recipient_count ?? '?'}`);
|
|
9697
|
+
* }
|
|
9698
|
+
* cursor = page.cursor ?? undefined;
|
|
9699
|
+
* } while (cursor);
|
|
9700
|
+
*/
|
|
9701
|
+
async listSends(options = {}) {
|
|
9702
|
+
const query = buildQuery$3({ limit: options.limit, cursor: options.cursor });
|
|
9703
|
+
const response = await this.http.get(`${BASE_PATH}/sends${query}`);
|
|
9704
|
+
return response.data;
|
|
9705
|
+
}
|
|
9706
|
+
/**
|
|
9707
|
+
* Recall a sealed send: revoke the single-use SparkLink grants it minted, so
|
|
9708
|
+
* the content can no longer be revealed.
|
|
9709
|
+
*
|
|
9710
|
+
* `mode: 'grant'` (the default) drops access and leaves the content intact.
|
|
9711
|
+
* `mode: 'content'` hard-burns the sealed spark so it is unreadable for
|
|
9712
|
+
* everyone — spark-backed sends only, since an ingot send merely references the
|
|
9713
|
+
* owner's durable vault content.
|
|
9714
|
+
*
|
|
9715
|
+
* Idempotent: a grant already revoked (or already consumed) counts as recalled,
|
|
9716
|
+
* so a repeated call converges rather than accumulating failures. One
|
|
9717
|
+
* recipient's failure never stops the rest — the response reports every one.
|
|
9718
|
+
*
|
|
9719
|
+
* PLAINTEXT SENDS CANNOT BE RECALLED (400): they delivered their body inline,
|
|
9720
|
+
* in the clear, and minted no grant. There is nothing to revoke, and saying
|
|
9721
|
+
* otherwise would be a lie about the one thing you are asking.
|
|
9722
|
+
*
|
|
9723
|
+
* @example
|
|
9724
|
+
* // Whole audience, access only
|
|
9725
|
+
* await sv.products.notify.recallSend(send.send_id);
|
|
9726
|
+
*
|
|
9727
|
+
* // One recipient, burn the content for everyone
|
|
9728
|
+
* const { recalled, failed } = await sv.products.notify.recallSend(send.send_id, {
|
|
9729
|
+
* recipientIds: [user.svid],
|
|
9730
|
+
* mode: 'content',
|
|
9731
|
+
* });
|
|
9732
|
+
*/
|
|
9733
|
+
async recallSend(sendId, options = {}) {
|
|
9734
|
+
requireSendId(sendId);
|
|
9735
|
+
if (options.recipientIds !== undefined) {
|
|
9736
|
+
if (!Array.isArray(options.recipientIds) || options.recipientIds.length === 0) {
|
|
9737
|
+
throw new ValidationError('recipientIds must be a non-empty array; omit it entirely to recall the whole audience', { field: 'recipientIds', received: options.recipientIds });
|
|
9738
|
+
}
|
|
9739
|
+
}
|
|
9740
|
+
if (options.mode !== undefined && options.mode !== 'grant' && options.mode !== 'content') {
|
|
9741
|
+
throw new ValidationError("mode must be 'grant' or 'content'", {
|
|
9742
|
+
field: 'mode',
|
|
9743
|
+
received: options.mode,
|
|
9744
|
+
});
|
|
9745
|
+
}
|
|
9746
|
+
const response = await this.http.post(`${BASE_PATH}/sends/${encodeURIComponent(sendId)}/recall`, { recipient_ids: options.recipientIds, mode: options.mode });
|
|
9747
|
+
return response.data;
|
|
9748
|
+
}
|
|
9549
9749
|
// ── Status & receipts ───────────────────────────────────────────────────────
|
|
9550
9750
|
/**
|
|
9551
9751
|
* The sender's per-recipient delivery rollup for one send: who it reached and
|
|
@@ -9563,13 +9763,14 @@ class NotifyProductModule {
|
|
|
9563
9763
|
* The account's verified-interaction receipts (portable, JWKS-verifiable
|
|
9564
9764
|
* proofs), newest first. Follow `cursor` to page.
|
|
9565
9765
|
*
|
|
9566
|
-
*
|
|
9567
|
-
*
|
|
9568
|
-
*
|
|
9569
|
-
*
|
|
9766
|
+
* `source` says which store answered. `receipt_index` is the normal path — a
|
|
9767
|
+
* bounded query with real pagination. `legacy_scan` appears only for an account
|
|
9768
|
+
* whose receipts all predate that index; it filters the account audit log, so
|
|
9769
|
+
* it can hand back EMPTY pages that are nowhere near the end. On EITHER source,
|
|
9770
|
+
* follow the cursor until it is null before concluding there are none.
|
|
9570
9771
|
*
|
|
9571
9772
|
* @example
|
|
9572
|
-
* const { receipts, cursor } = await sv.products.notify.listReceipts({ interaction: 'approve' });
|
|
9773
|
+
* const { receipts, cursor, source } = await sv.products.notify.listReceipts({ interaction: 'approve' });
|
|
9573
9774
|
*/
|
|
9574
9775
|
async listReceipts(options = {}) {
|
|
9575
9776
|
const query = buildQuery$3({
|
|
@@ -9622,12 +9823,21 @@ class NotifyProductModule {
|
|
|
9622
9823
|
* a seeded default from re-appearing on the next merge. The reserved `security`
|
|
9623
9824
|
* category can neither be removed nor made optional.
|
|
9624
9825
|
*
|
|
9826
|
+
* The `events` section configures the outbound event webhook: `webhook_url`
|
|
9827
|
+
* must be https on a public host, and `secret` (16-256 chars) signs every event
|
|
9828
|
+
* body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. The
|
|
9829
|
+
* secret is WRITE-ONLY — reads report `events.secret_set`, never the value.
|
|
9830
|
+
*
|
|
9625
9831
|
* @example
|
|
9626
9832
|
* await sv.products.notify.updateConfig({
|
|
9627
9833
|
* categories: {
|
|
9628
9834
|
* weekly_newsletter: { label: 'Weekly newsletter', required: false },
|
|
9629
9835
|
* marketing: null, // tombstone — remove the seeded default
|
|
9630
9836
|
* },
|
|
9837
|
+
* events: {
|
|
9838
|
+
* webhook_url: 'https://api.example.com/hooks/sparkvault',
|
|
9839
|
+
* secret: process.env.SPARKVAULT_EVENT_SECRET,
|
|
9840
|
+
* },
|
|
9631
9841
|
* });
|
|
9632
9842
|
*/
|
|
9633
9843
|
async updateConfig(patch) {
|
|
@@ -14583,7 +14793,7 @@ class SparkVault {
|
|
|
14583
14793
|
}
|
|
14584
14794
|
/** Get the SDK version */
|
|
14585
14795
|
static get version() {
|
|
14586
|
-
return '
|
|
14796
|
+
return '9.0.0';
|
|
14587
14797
|
}
|
|
14588
14798
|
}
|
|
14589
14799
|
if (typeof window !== 'undefined') {
|
|
@@ -14594,4 +14804,4 @@ if (typeof window !== 'undefined') {
|
|
|
14594
14804
|
}
|
|
14595
14805
|
|
|
14596
14806
|
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, logger, setDebugMode };
|
|
14597
|
-
//# sourceMappingURL=
|
|
14807
|
+
//# sourceMappingURL=index.mjs.map
|