@sparkvault/sdk-js 10.0.1 → 11.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.
Files changed (54) hide show
  1. package/README.md +9 -4
  2. package/dist/api-base.d.ts +46 -11
  3. package/dist/config.d.ts +5 -3
  4. package/dist/entropy/index.d.ts +0 -1
  5. package/dist/entropy/types.d.ts +1 -1
  6. package/dist/errors.d.ts +18 -2
  7. package/dist/folders/index.d.ts +3 -1
  8. package/dist/http.d.ts +11 -6
  9. package/dist/index.cjs +8207 -7265
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +510 -297
  12. package/dist/index.mjs +8206 -7266
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/ingots/fetch-download.d.ts +48 -0
  15. package/dist/ingots/index.d.ts +29 -14
  16. package/dist/ingots/types.d.ts +98 -43
  17. package/dist/notify/types.d.ts +7 -2
  18. package/dist/products/identity/api.d.ts +30 -14
  19. package/dist/products/identity/handlers/index.d.ts +1 -1
  20. package/dist/products/identity/handlers/passkey-handler.d.ts +4 -13
  21. package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -1
  22. package/dist/products/identity/index.d.ts +23 -6
  23. package/dist/products/identity/inline-container.d.ts +13 -26
  24. package/dist/products/identity/modal.d.ts +16 -42
  25. package/dist/products/identity/renderer.d.ts +31 -10
  26. package/dist/products/identity/types.d.ts +17 -5
  27. package/dist/products/identity/types.test-d.d.ts +21 -0
  28. package/dist/products/identity/utils.d.ts +9 -16
  29. package/dist/products/identity/views/base.d.ts +4 -21
  30. package/dist/products/identity/views/identity-input.d.ts +4 -2
  31. package/dist/products/index.d.ts +1 -1
  32. package/dist/products/notify/index.d.ts +29 -19
  33. package/dist/products/notify/types.d.ts +74 -37
  34. package/dist/products/notify/types.test-d.d.ts +1 -0
  35. package/dist/request-path.d.ts +44 -0
  36. package/dist/sparkvault.js +1 -1
  37. package/dist/sparkvault.js.map +1 -1
  38. package/dist/ui/chrome.d.ts +16 -0
  39. package/dist/ui/ds-tokens.d.ts +58 -0
  40. package/dist/ui/inline-shell.d.ts +19 -0
  41. package/dist/ui/modal-shell.d.ts +36 -0
  42. package/dist/ui/target.d.ts +6 -0
  43. package/dist/vaults/index.d.ts +11 -6
  44. package/dist/vaults/upload/api.d.ts +21 -9
  45. package/dist/vaults/upload/chrome.d.ts +8 -22
  46. package/dist/vaults/upload/container.d.ts +0 -8
  47. package/dist/vaults/upload/index.d.ts +1 -1
  48. package/dist/vaults/upload/inline-container.d.ts +13 -42
  49. package/dist/vaults/upload/modal.d.ts +14 -33
  50. package/dist/vaults/upload/renderer.d.ts +0 -1
  51. package/dist/vaults/upload/styles.d.ts +4 -2
  52. package/dist/vaults/upload/types.d.ts +2 -2
  53. package/package.json +2 -2
  54. package/dist/utils/base64url.d.ts +0 -52
@@ -17,9 +17,10 @@
17
17
  * rendered into recipient-facing preference URLs. Case-mapping the tree would
18
18
  * silently corrupt them, so the config travels exactly as the server defines it.
19
19
  */
20
- import type { NotificationRow, ListNotificationsResponse, MarkNotificationStateResponse } from '../../notify/types';
20
+ import type { NotificationRow, ListNotificationsResponse, MarkNotificationStateResponse, NotificationInboxState, NotificationMarkState, NotificationBulkMarkState } from '../../notify/types';
21
+ import type { UnsealedVault } from '../../vaults/types';
21
22
  /** Every transport the dispatch seam can carry a notification on. */
22
- export type NotifyChannel = 'in_app' | 'websocket' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
23
+ export type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
23
24
  /**
24
25
  * How a send's content reaches the recipient.
25
26
  * - `sealed` (default): content is sealed into a Spark behind a single-use
@@ -89,10 +90,29 @@ export interface NotifySendContent {
89
90
  * An EXISTING ingot to point the grant at instead of sealing new content. One
90
91
  * persistent asset carries a single grant, so an ingot send is 1:1 — it targets
91
92
  * exactly one recipient.
93
+ *
94
+ * The recipient opens the file in the SparkVault file viewer, which has no
95
+ * action bar, so an ingot send is view-only: a non-view `policy.interaction`
96
+ * (including the `conversation`, `approval` and `signatureRequest` presets) is
97
+ * rejected with 400 `VALIDATION_ERROR`. The vault must be the caller's with
98
+ * public file sharing enabled (404 / 412 `PRECONDITION_FAILED` otherwise), and
99
+ * the sender must hold a Full License (403 `LICENSE_REQUIRED`).
100
+ *
101
+ * Only a holder of the vault's key may publish its files, so the send carries
102
+ * the unsealed vault's read-write VAT as `X-Vault-Access-Token` — exactly what
103
+ * the vault's own sharing calls demand. A missing, unknown or revoked VAT is 401
104
+ * `AUTHENTICATION_ERROR`; an expired one 403 (`details.reason: 'VAT_EXPIRED'`,
105
+ * unseal again and retry), a read-only one 403 (`'VAT_READ_ONLY'`), and one for
106
+ * another vault 403 `FORBIDDEN`.
92
107
  */
93
108
  export interface NotifyIngotRef {
94
109
  ingotId: string;
95
- vaultId: string;
110
+ /**
111
+ * The ingot's vault, unsealed with the VMK or a read-write DVAK
112
+ * (`sv.vaults.unseal(vaultId, key)`). Its id addresses the ingot and its VAT
113
+ * proves key possession.
114
+ */
115
+ vault: UnsealedVault;
96
116
  }
97
117
  /** The access policy stamped onto each minted SparkLink grant. */
98
118
  export interface NotifySendPolicy {
@@ -104,7 +124,9 @@ export interface NotifySendPolicy {
104
124
  /**
105
125
  * Cumulative per-step delays in SECONDS from send time, one per channel step.
106
126
  * Step 0 always fires immediately (any `delays[0]` is ignored), and the sequence
107
- * is aligned non-decreasing. Omit to derive the schedule from the account config.
127
+ * is aligned non-decreasing. Each value is at most 86400 (24 hours, the longest a
128
+ * sealed grant lives); a later one is rejected with a 400. Omit to derive the
129
+ * schedule from the account config.
108
130
  */
109
131
  export interface NotifyEscalation {
110
132
  delays: number[];
@@ -149,6 +171,14 @@ export interface CreateNotifySendOptions {
149
171
  /** Inbox-row retention, default 30. A plaintext send is capped at 7. */
150
172
  historyTtlDays?: number;
151
173
  }
174
+ /**
175
+ * Options for a preset helper (`sendAlert`, `sendSecureMessage`, …): the one
176
+ * send contract, with `category` optional because the preset stamps its own
177
+ * when the caller names none.
178
+ */
179
+ export type NotifyPresetSendOptions = Omit<CreateNotifySendOptions, 'category'> & {
180
+ category?: NotifyCategory;
181
+ };
152
182
  export interface NotifySendResult {
153
183
  send_id: string;
154
184
  /** Number of recipients the send was accepted for. */
@@ -171,14 +201,14 @@ export interface NotifyPreset {
171
201
  };
172
202
  }
173
203
  /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
174
- export type NotifyInboxView = 'all' | 'unseen' | 'unread' | 'archived';
204
+ export type NotifyInboxView = NotificationInboxState;
175
205
  /** Terminal display states applicable to a single row. */
176
- export type NotifyInboxMarkState = 'seen' | 'read' | 'archived';
206
+ export type NotifyInboxMarkState = NotificationMarkState;
177
207
  /**
178
208
  * States a BULK drain can apply. `archived` is per-row only — it has no sparse
179
209
  * GSI, so bulk-archiving would require a full-partition scan.
180
210
  */
181
- export type NotifyInboxBulkMarkState = 'seen' | 'read';
211
+ export type NotifyInboxBulkMarkState = NotificationBulkMarkState;
182
212
  export interface ListNotifyInboxOptions {
183
213
  /**
184
214
  * The inbox owner, keyed EXACTLY as addressed on the send. Identity claim never
@@ -223,7 +253,9 @@ export interface MarkNotifyInboxAllResponse {
223
253
  * cannot drift from the facts it summarizes).
224
254
  *
225
255
  * - `pending` — still in flight, or not yet driven.
226
- * - `delivered` — a channel accepted it and no provider has repudiated that.
256
+ * - `delivered` — a channel accepted it and no provider has repudiated that, or
257
+ * the recipient opened the sealed content or marked it seen and a later
258
+ * escalation step recorded that before any recall.
227
259
  * - `undeliverable` — every channel attempted declined (no handle, bounced, not
228
260
  * implemented). The recipient cannot be reached as addressed.
229
261
  * - `failed` — a channel exhausted its retries. OUR transport gave up; the
@@ -233,7 +265,8 @@ export interface MarkNotifyInboxAllResponse {
233
265
  * - `rate_limited` — skipped by the per-recipient abuse ceiling for that minute.
234
266
  * - `recalled` — the sender took it back before a channel reached this recipient.
235
267
  * The reveal is revoked and no further delivery will be attempted. It ranks
236
- * BELOW `delivered`: a channel that already reached someone reached them, so a
268
+ * BELOW `delivered`: a channel that already reached someone reached them, and
269
+ * engagement an escalation step recorded before the recall stands too, so a
237
270
  * recall afterwards leaves them `delivered`. It covers recipients the recall
238
271
  * itself marked AND, on a whole-audience recall, everyone the fan-out was
239
272
  * stopped before ever writing a row for.
@@ -277,7 +310,11 @@ export interface NotifySendStatusRecipient {
277
310
  /** Escalation step index the outcome came from. */
278
311
  step: number | null;
279
312
  }>>;
280
- /** At least one channel accepted the notification for this recipient. */
313
+ /**
314
+ * At least one channel accepted the notification for this recipient. A
315
+ * transport fact only: `state` is `delivered` for a recipient who opened or
316
+ * saw it even when every channel declined.
317
+ */
281
318
  delivered: boolean;
282
319
  /**
283
320
  * Every channel attempted for this recipient declined (`skipped`,
@@ -307,7 +344,7 @@ export interface NotifySendStatusCounts {
307
344
  * and do not partition anything.)
308
345
  */
309
346
  pending: number;
310
- /** Recipients with at least one `delivered` channel outcome. */
347
+ /** Recipients whose `state` is `delivered`. */
311
348
  delivered: number;
312
349
  /** Recipients whose every attempted channel declined — the silent-failure count. */
313
350
  undeliverable: number;
@@ -338,7 +375,8 @@ export interface NotifySendStatus {
338
375
  * recipients" can be made.
339
376
  * - `pending` — accepted; nothing handed to delivery yet.
340
377
  * - `sending` — in flight.
341
- * - `delivered` — every recipient reached a channel that accepted.
378
+ * - `delivered` — every recipient settled delivered, whether a channel
379
+ * accepted it or their engagement was recorded (see the recipient `state`).
342
380
  * - `partial` — every recipient resolved; some delivered, some did not.
343
381
  * - `failed` — every recipient resolved and none delivered.
344
382
  *
@@ -363,8 +401,10 @@ export interface NotifySendStatus {
363
401
  * A send's delivery state, DERIVED from its counters — the send row itself is
364
402
  * write-once, so there is no stored lifecycle to read.
365
403
  *
366
- * `failed` counts recipients whose every attempted channel declined, so
367
- * `delivered + failed` is how many have reached a terminal answer; a recipient
404
+ * `failed` counts every recipient who reached a terminal answer without being
405
+ * delivered (declined, retries exhausted, opted out, rate limited, or a bounce
406
+ * that repudiated a delivery), so `delivered + failed` is how many have
407
+ * resolved; a recipient
368
408
  * still climbing the escalation ladder is in neither, which is why an in-flight
369
409
  * send reads `sending` rather than being scored early.
370
410
  *
@@ -390,8 +430,16 @@ export interface NotifySendSummary {
390
430
  /** Audience size at accept — the denominator of the counters below. */
391
431
  recipient_count: number | null;
392
432
  enqueued_count: number | null;
433
+ /**
434
+ * Recipients settled delivered, on the same evidence as the recipient
435
+ * `delivered` state: a channel accepted it, or they opened the sealed content
436
+ * or marked it seen and a later escalation step recorded that before any recall.
437
+ */
393
438
  delivered_count: number | null;
394
- /** Recipients whose every attempted channel declined. */
439
+ /**
440
+ * Recipients who reached a terminal answer without being delivered: every
441
+ * attempted channel declined or gave up, or they were suppressed or rate limited.
442
+ */
395
443
  failed_count: number | null;
396
444
  state: NotifySendState;
397
445
  }
@@ -450,6 +498,12 @@ export interface NotifyReceipt {
450
498
  asset_id: string | null;
451
499
  vault_id: string | null;
452
500
  link_code: string | null;
501
+ /**
502
+ * The correlation key a `receipt.recorded` webhook event quotes: 32 hex of the
503
+ * SHA-256 over the grant code, never the code itself. Null on a receipt
504
+ * recorded before the key existed.
505
+ */
506
+ link_code_hash: string | null;
453
507
  link_type: string | null;
454
508
  verification_level: NotifyVerificationLevel | null;
455
509
  action_hash: string | null;
@@ -460,16 +514,14 @@ export interface NotifyReceipt {
460
514
  /**
461
515
  * The send whose grant produced this receipt, stamped at mint time — so it is
462
516
  * present for grants a Notify send created, and null for a standalone
463
- * SparkLink or a receipt served from the legacy audit walk.
517
+ * SparkLink.
464
518
  */
465
519
  send_id: string | null;
466
520
  /** The send's display title, alongside `send_id` and under the same conditions. */
467
521
  title: string | null;
468
- /** The receipt row's own id. Null on the legacy source. */
522
+ /** The receipt's own id. Null on a per-send receipt (`getSendReceipts`). */
469
523
  receipt_id: string | null;
470
524
  }
471
- /** Which store answered a receipts listing (see `ListNotifyReceiptsResponse.source`). */
472
- export type NotifyReceiptSource = 'receipt_index' | 'legacy_scan';
473
525
  /** A receipt correlated to the recipient whose grant produced it. */
474
526
  export interface NotifySendReceipt extends NotifyReceipt {
475
527
  recipient_id: string;
@@ -485,25 +537,11 @@ export interface ListNotifyReceiptsResponse {
485
537
  receipts: NotifyReceipt[];
486
538
  /**
487
539
  * Next-page cursor, or null on the last page. A page can still come back SHORT
488
- * of `limit` while more rows follow — `interaction` narrows with a DynamoDB
489
- * filter applied after the key evaluation — so follow the cursor; never treat
540
+ * of `limit` (even empty) while more rows follow — `interaction` narrows with
541
+ * a filter applied after each page is read — so follow the cursor; never treat
490
542
  * a short page as the end.
491
543
  */
492
544
  cursor: string | null;
493
- /**
494
- * Which store answered.
495
- *
496
- * `receipt_index` is the normal path: one bounded query on the account's
497
- * receipt partition, with real pagination.
498
- *
499
- * `legacy_scan` appears only for an account whose receipts were all emitted
500
- * before the receipt index existed. It walks the account audit log with a
501
- * filter, so it can return EMPTY pages that are nowhere near the end of the
502
- * data — on that source, keep following the cursor until it is null before
503
- * concluding there are no receipts. The two sources are never merged into one
504
- * page; the cursor stays on whichever source started the walk.
505
- */
506
- source: NotifyReceiptSource;
507
545
  }
508
546
  export interface NotifySendReceiptsResponse {
509
547
  send_id: string;
@@ -528,6 +566,7 @@ export interface NotifyConfigCategory {
528
566
  description?: string;
529
567
  required?: boolean;
530
568
  }
569
+ /** Each value is an integer number of minutes from send time, 0..1440 (24 hours). */
531
570
  export interface NotifyConfigRealtimeFallbackDelay {
532
571
  email_minutes?: number;
533
572
  sms_minutes?: number;
@@ -600,8 +639,6 @@ export interface NotifyConfig {
600
639
  events?: NotifyConfigEventsRead;
601
640
  /** Tombstoned entries are already dropped — a deleted category is simply gone. */
602
641
  categories: Record<string, NotifyConfigCategory>;
603
- /** Owner-managed SSM references. Readable, never account-writable. */
604
- channel_credentials: Record<string, unknown>;
605
642
  }
606
643
  /**
607
644
  * A partial PATCH of the account's config overrides. Only the sections present are
@@ -28,6 +28,7 @@ export type NotifyWireContract = [
28
28
  Assert<Equals<NotificationRow['recalled'], boolean>>,
29
29
  Assert<Equals<NotificationRow['locked'], boolean>>,
30
30
  Assert<Equals<NotificationRow['sparklink_code'], string | undefined>>,
31
+ Assert<Equals<NotificationRow['pointer_url'], string | undefined>>,
31
32
  Assert<Equals<NotifyRecipientState, 'pending' | 'delivered' | 'undeliverable' | 'failed' | 'suppressed' | 'rate_limited' | 'recalled'>>,
32
33
  Assert<Equals<Pick<NotifySendStatusCounts, NotifyRecipientState>, Record<NotifyRecipientState, number>>>
33
34
  ];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Request paths: the one way a module names a SparkVault route.
3
+ *
4
+ * Every request the SDK sends carries the caller's credentials (a Bearer token
5
+ * or API key, plus a Vault Access Token on vault data), so a value that
6
+ * smuggled '/' or a dot-segment into a path would re-target that credentialed
7
+ * request at another route. `apiPath` closes that by construction: each
8
+ * interpolated value becomes exactly one percent-encoded segment, and a value
9
+ * that cannot be one segment is refused before any request leaves. The
10
+ * transports accept only an `ApiPath`, so no module can name a route any other
11
+ * way. Server-issued ids are also checked for their shape first
12
+ * (`requireResourceId`), so a malformed id fails with a ValidationError that
13
+ * names the argument instead of reaching the server as a 404.
14
+ *
15
+ * The rules are the platform's one copy in `@sparkvault/app-sdk/request-path`
16
+ * and, for ids, `@sparkvault/app-sdk/ids`, bundled into this SDK and mirrored
17
+ * into sdk-mobile; this module only types them and raises this SDK's error.
18
+ */
19
+ declare const API_PATH: unique symbol;
20
+ /** A route path whose every interpolated value is exactly one encoded segment. */
21
+ export type ApiPath = string & {
22
+ readonly [API_PATH]: true;
23
+ };
24
+ /** Query parameters; `undefined`, `null` and `''` are left out of the query. */
25
+ export type QueryParams = Record<string, string | number | boolean | null | undefined>;
26
+ /**
27
+ * Build a route path from a template: `apiPath\`/v1/vaults/${vaultId}\``.
28
+ *
29
+ * @throws ValidationError when an interpolated value cannot be exactly one
30
+ * path segment ('', '.', '..', a non-string, or malformed UTF-16).
31
+ */
32
+ export declare function apiPath(literals: TemplateStringsArray, ...values: string[]): ApiPath;
33
+ /**
34
+ * A server-issued resource id (`vlt_…`, `ing_…`, `fld_…`, `spk_…`, …), checked
35
+ * before it names a route.
36
+ *
37
+ * @param field - The argument's name, reported on the ValidationError.
38
+ */
39
+ export declare function requireResourceId(value: unknown, field: string): string;
40
+ /** The id of the unsealed vault a data-plane method was handed. */
41
+ export declare function requireVaultId(vault: {
42
+ readonly id?: unknown;
43
+ } | null | undefined): string;
44
+ export {};