@sparkvault/sdk-js 8.15.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 +11 -5
- package/dist/config.d.ts +6 -4
- package/dist/{sparkvault.cjs.js → index.cjs} +112 -18
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +320 -30
- package/dist/{sparkvault.esm.js → index.mjs} +112 -18
- package/dist/index.mjs.map +1 -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
|
};
|
|
@@ -971,11 +973,15 @@ class IdentityApi extends SparkVaultApi {
|
|
|
971
973
|
* If preload fails, getConfig() will clear the cache and retry.
|
|
972
974
|
*/
|
|
973
975
|
preloadConfig() {
|
|
974
|
-
if (
|
|
975
|
-
|
|
976
|
-
// If this fails, getConfig() clears the cache and retries.
|
|
977
|
-
this.configCache = this.request('GET', '/config');
|
|
976
|
+
if (this.configCache) {
|
|
977
|
+
return;
|
|
978
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(() => { });
|
|
979
985
|
}
|
|
980
986
|
/**
|
|
981
987
|
* Check if config has been preloaded and is ready.
|
|
@@ -9421,8 +9427,9 @@ class IdentityModule {
|
|
|
9421
9427
|
*
|
|
9422
9428
|
* The counterpart to `sv.notify`: where that module is session-scoped and reads
|
|
9423
9429
|
* only the signed-in person's OWN inbox, this one is the account-scoped product
|
|
9424
|
-
* surface a tenant's BACKEND drives — send, sender-side
|
|
9425
|
-
* 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
|
|
9426
9433
|
* `/v1/products/notify/*` and is authorized by the caller's account, so the
|
|
9427
9434
|
* recipient is supplied explicitly rather than derived from a session.
|
|
9428
9435
|
*
|
|
@@ -9474,15 +9481,22 @@ const NOTIFY_PRESETS = Object.freeze({
|
|
|
9474
9481
|
channels: ['in_app', 'push', 'web_push', 'email'],
|
|
9475
9482
|
policy: { verificationLevel: 'identifier', interaction: 'reply' },
|
|
9476
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.
|
|
9477
9491
|
approval: {
|
|
9478
9492
|
category: 'approval',
|
|
9479
9493
|
channels: ['in_app', 'push', 'web_push', 'email'],
|
|
9480
|
-
policy: { verificationLevel: '
|
|
9494
|
+
policy: { verificationLevel: 'identifier', interaction: 'approve' },
|
|
9481
9495
|
},
|
|
9482
9496
|
signatureRequest: {
|
|
9483
9497
|
category: 'signature',
|
|
9484
9498
|
channels: ['in_app', 'push', 'web_push', 'email'],
|
|
9485
|
-
policy: { verificationLevel: '
|
|
9499
|
+
policy: { verificationLevel: 'identifier', interaction: 'sign' },
|
|
9486
9500
|
},
|
|
9487
9501
|
});
|
|
9488
9502
|
/**
|
|
@@ -9572,11 +9586,11 @@ class NotifyProductModule {
|
|
|
9572
9586
|
async sendConversation(options) {
|
|
9573
9587
|
return this.send(buildNotifyPresetSend('conversation', options));
|
|
9574
9588
|
}
|
|
9575
|
-
/** High-stakes approve/deny —
|
|
9589
|
+
/** High-stakes approve/deny — identifier-verified, with `action_hash` binding. */
|
|
9576
9590
|
async sendApproval(options) {
|
|
9577
9591
|
return this.send(buildNotifyPresetSend('approval', options));
|
|
9578
9592
|
}
|
|
9579
|
-
/** Signature-on-delivery —
|
|
9593
|
+
/** Signature-on-delivery — identifier-verified, with `action_hash` binding. */
|
|
9580
9594
|
async sendSignatureRequest(options) {
|
|
9581
9595
|
return this.send(buildNotifyPresetSend('signatureRequest', options));
|
|
9582
9596
|
}
|
|
@@ -9662,6 +9676,76 @@ class NotifyProductModule {
|
|
|
9662
9676
|
});
|
|
9663
9677
|
return response.data;
|
|
9664
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
|
+
}
|
|
9665
9749
|
// ── Status & receipts ───────────────────────────────────────────────────────
|
|
9666
9750
|
/**
|
|
9667
9751
|
* The sender's per-recipient delivery rollup for one send: who it reached and
|
|
@@ -9679,13 +9763,14 @@ class NotifyProductModule {
|
|
|
9679
9763
|
* The account's verified-interaction receipts (portable, JWKS-verifiable
|
|
9680
9764
|
* proofs), newest first. Follow `cursor` to page.
|
|
9681
9765
|
*
|
|
9682
|
-
*
|
|
9683
|
-
*
|
|
9684
|
-
*
|
|
9685
|
-
*
|
|
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.
|
|
9686
9771
|
*
|
|
9687
9772
|
* @example
|
|
9688
|
-
* const { receipts, cursor } = await sv.products.notify.listReceipts({ interaction: 'approve' });
|
|
9773
|
+
* const { receipts, cursor, source } = await sv.products.notify.listReceipts({ interaction: 'approve' });
|
|
9689
9774
|
*/
|
|
9690
9775
|
async listReceipts(options = {}) {
|
|
9691
9776
|
const query = buildQuery$3({
|
|
@@ -9738,12 +9823,21 @@ class NotifyProductModule {
|
|
|
9738
9823
|
* a seeded default from re-appearing on the next merge. The reserved `security`
|
|
9739
9824
|
* category can neither be removed nor made optional.
|
|
9740
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
|
+
*
|
|
9741
9831
|
* @example
|
|
9742
9832
|
* await sv.products.notify.updateConfig({
|
|
9743
9833
|
* categories: {
|
|
9744
9834
|
* weekly_newsletter: { label: 'Weekly newsletter', required: false },
|
|
9745
9835
|
* marketing: null, // tombstone — remove the seeded default
|
|
9746
9836
|
* },
|
|
9837
|
+
* events: {
|
|
9838
|
+
* webhook_url: 'https://api.example.com/hooks/sparkvault',
|
|
9839
|
+
* secret: process.env.SPARKVAULT_EVENT_SECRET,
|
|
9840
|
+
* },
|
|
9747
9841
|
* });
|
|
9748
9842
|
*/
|
|
9749
9843
|
async updateConfig(patch) {
|
|
@@ -14699,7 +14793,7 @@ class SparkVault {
|
|
|
14699
14793
|
}
|
|
14700
14794
|
/** Get the SDK version */
|
|
14701
14795
|
static get version() {
|
|
14702
|
-
return '
|
|
14796
|
+
return '9.0.0';
|
|
14703
14797
|
}
|
|
14704
14798
|
}
|
|
14705
14799
|
if (typeof window !== 'undefined') {
|
|
@@ -14710,4 +14804,4 @@ if (typeof window !== 'undefined') {
|
|
|
14710
14804
|
}
|
|
14711
14805
|
|
|
14712
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 };
|
|
14713
|
-
//# sourceMappingURL=
|
|
14807
|
+
//# sourceMappingURL=index.mjs.map
|