@sparkvault/sdk-js 12.0.5 → 13.0.1

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.
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * Notify Product Module — the TENANT (sender) surface.
3
3
  *
4
- * The counterpart to `sv.notify`: where that module is session-scoped and reads
5
- * only the signed-in person's OWN inbox, this one is the account-scoped product
6
- * surface a tenant's BACKEND drives — send, send history, recall, sender-side
7
- * inbox reads and state, send status, receipts, and the account's Notify config.
8
- * Every method maps to
4
+ * The counterpart to `sv.notify`: where that module is SparkVault's own
5
+ * first-party inbox, which a signed-in SparkVault user reads for the
6
+ * notifications SparkVault delivered to them `in_app`, this one is the
7
+ * account-scoped product surface a tenant's BACKEND drives — send, send
8
+ * history, recall, sender-side inbox reads and state, send status, receipts,
9
+ * the account's Notify config, and who its email is from.
10
+ * A tenant reads its own recipients' feeds here (`getInbox`), never through
11
+ * `sv.notify`. Every method maps to
9
12
  * `/v1/products/notify/*` and is authorized by the caller's account, so the
10
13
  * recipient is supplied explicitly rather than derived from a session.
11
14
  *
@@ -25,20 +28,28 @@ import type { CreateNotifySendOptions, NotifySendResult, NotifyPreset, NotifyPre
25
28
  *
26
29
  * There is no preset endpoint — presets are a merge over the one send contract,
27
30
  * so they are applied client-side and produce an ordinary `send` request. Caller
28
- * arguments always win over a preset's defaults; `channels` left unset lets the
29
- * account config resolve the ladder per category.
31
+ * arguments win over a preset's defaults wherever they state a value;
32
+ * `channels` left unset lets the account config resolve the ladder per category.
30
33
  *
31
34
  * `alert` is the only plaintext preset: a non-confidential ping is read at a
32
- * glance rather than behind a tap-to-view link. The other four seal.
35
+ * glance rather than behind a tap-to-view link, on the account's ladder. The
36
+ * other four seal, on the channels every organization's recipients are reached
37
+ * on: `secureMessage` by email alone, `conversation`, `approval` and
38
+ * `signatureRequest` in your Notify inbox (`in_app`) and then by email.
33
39
  * `approval` and `signatureRequest` verify at `identifier`: pass
34
40
  * `policy: { verificationLevel: 'passkey' }` explicitly when the audience is
35
41
  * known to be enrolled.
42
+ *
43
+ * Every send in the process reads this one table, so it is frozen all the way
44
+ * down; `buildNotifyPresetSend` hands back options of the caller's own.
36
45
  */
37
46
  export declare const NOTIFY_PRESETS: Readonly<Record<NotifyPresetName, NotifyPreset>>;
38
47
  /**
39
48
  * Merge a preset's bundle UNDER the caller's arguments, yielding ordinary send
40
- * options. Exported so a caller can inspect (or further adjust) what a preset
41
- * would send before sending it.
49
+ * options: the Core API's own merge (`mergePresetSend`), so a preset sends the
50
+ * same through either. Exported so a caller can inspect (or further adjust)
51
+ * what a preset would send before sending it: the options are the caller's own,
52
+ * so adjusting them never reaches the preset table or any other send.
42
53
  */
43
54
  export declare function buildNotifyPresetSend(preset: NotifyPresetName, options: NotifyPresetSendOptions): CreateNotifySendOptions;
44
55
  export declare class NotifyProductModule {
@@ -48,8 +59,28 @@ export declare class NotifyProductModule {
48
59
  * Send a notification: seal the content, mint one single-use SparkLink per
49
60
  * recipient, and enqueue delivery across the resolved channel ladder.
50
61
  *
51
- * `sendId` is the idempotency key. Replaying an existing one returns the stored
52
- * send unchanged — never re-sealed, never re-delivered — flagged `idempotent`.
62
+ * `sendId` is the idempotency key. Replaying an existing one with the same
63
+ * request returns the stored send unchanged — never re-sealed, never
64
+ * re-delivered — flagged `idempotent`; another request under it is refused 400
65
+ * (`sendId` on `CreateNotifySendOptions`).
66
+ *
67
+ * The send speaks in your organization's name, and one that would email
68
+ * someone goes out from your organization's own sender (`getEmailSender`) and
69
+ * is admitted against your hourly share of sending capacity. Each refusal is
70
+ * a thrown `SparkVaultError` whose `serviceCode` names it, made before
71
+ * anything is sealed, charged or stored:
72
+ *
73
+ * | Status | `serviceCode` | `details` | Next |
74
+ * | --- | --- | --- | --- |
75
+ * | 403 | `NOTIFY_CHANNEL_NOT_AVAILABLE` | `{ field, channels }` | Name only `in_app` and `email` |
76
+ * | 409 | `NOTIFY_SENDER_NAME_REQUIRED` | — | Name the organization in Settings |
77
+ * | 409 | `NOTIFY_SENDER_NAME_RESERVED` | `{ reason: 'reserved_name' }` | Rename the organization |
78
+ * | 409 | `HANDLE_REQUIRED` | `{ product: 'notify' }` | Choose the organization's handle in Company Settings |
79
+ * | 429 | `NOTIFY_EMAIL_ADMISSION_LIMIT` | `{ limit, window: 'hour', resets_at }` | Wait `retryAfterMs`, then send |
80
+ * | 503 | `EMAIL_SETUP_BUSY` | — | Retry the same send after `retryAfterMs` |
81
+ * | 503 | `NOTIFY_EMAIL_CAPACITY_UNAVAILABLE` | — | Retry the same send |
82
+ *
83
+ * A replay is answered from the stored send and meets none of them again.
53
84
  *
54
85
  * @example
55
86
  * const send = await sv.products.notify.send({
@@ -75,7 +106,7 @@ export declare class NotifyProductModule {
75
106
  /**
76
107
  * Frictionless informational ping — no verification, view-only, delivered
77
108
  * INLINE (plaintext) so it is read at a glance. Channels resolve from the
78
- * account config; plaintext requires an inline-capable channel.
109
+ * account config, narrowed to the ones that render cleartext.
79
110
  *
80
111
  * @example
81
112
  * await sv.products.notify.sendAlert({
@@ -89,13 +120,53 @@ export declare class NotifyProductModule {
89
120
  sendSecureMessage(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
90
121
  /** Two-way thread: identifier-verified reveal plus an encrypted reply. */
91
122
  sendConversation(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
92
- /** High-stakes approve/deny — identifier-verified, with `action_hash` binding. */
123
+ /**
124
+ * High-stakes approve/deny, identifier-verified. Pass `policy.actionHash`, the
125
+ * SHA-256 of the thing being approved, so the signed receipt attests to THAT:
126
+ * without it the receipt binds a digest of the grant, which no hash of your
127
+ * own copy can match.
128
+ *
129
+ * @example
130
+ * const actionHash = createHash('sha256').update(canonicalWire).digest('hex');
131
+ * await sv.products.notify.sendApproval({
132
+ * sendId: `wire-approval-${wire.id}`,
133
+ * recipients: [{ id: approver.svid, email: approver.email }],
134
+ * content: { payload: `Approve ${wire.amount} to ${wire.payee}?` },
135
+ * policy: { actionHash },
136
+ * });
137
+ */
93
138
  sendApproval(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
94
- /** Signature-on-delivery — identifier-verified, with `action_hash` binding. */
139
+ /**
140
+ * Signature-on-delivery, identifier-verified. Pass `policy.actionHash`, the
141
+ * SHA-256 of the document being signed, so the signed receipt attests to THAT
142
+ * document.
143
+ *
144
+ * @example
145
+ * await sv.products.notify.sendSignatureRequest({
146
+ * sendId: `contract-${contract.id}`,
147
+ * recipients: [{ email: signer.email }],
148
+ * content: { payload: contractPdfBase64, contentType: 'application/pdf' },
149
+ * policy: { actionHash: createHash('sha256').update(contractPdfBytes).digest('hex') },
150
+ * });
151
+ */
95
152
  sendSignatureRequest(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
96
153
  /**
97
- * Read one recipient's metadata-only feed, newest first. Rows are pointers: a
98
- * sealed row carries only `sparklink_code`, never the content.
154
+ * Read one recipient's feed in your Notify inbox, newest first: exactly the
155
+ * notifications delivered to them `in_app`. The row IS the `in_app`
156
+ * delivery: its ladder carries `in_app`, because the send named it or your
157
+ * config resolved it and the recipient left In-app on for your site (a
158
+ * `security` send crosses that switch), and it is listed when that step
159
+ * runs: as the send fans out when `in_app` leads the ladder, and only when
160
+ * the step comes due when it follows `email`. A notification whose ladder
161
+ * carries no `in_app` (a send naming `email` alone, a recipient who switched
162
+ * In-app off for your site on auth.sv on any send but a `security` one, one
163
+ * their own preferences or block refused, one no channel reaches), one whose
164
+ * `in_app` step has not delivered it (and never will once a stop ended its
165
+ * ladder first), and the per-recipient ceiling's skip are status records
166
+ * only: in no view, and a mark of one is refused as not found. A sealed row carries
167
+ * the recipient's own pointer (`sparklink_code`, `pointer_url`) while its
168
+ * grant still opens, never the content; a plaintext row carries its body.
169
+ * Treat the answer as sensitive and keep it out of logs.
99
170
  *
100
171
  * A page can come back SHORT of `limit` yet still carry a non-null cursor —
101
172
  * follow the cursor; never treat a short page as the end.
@@ -109,8 +180,9 @@ export declare class NotifyProductModule {
109
180
  getInbox(options: ListNotifyInboxOptions): Promise<ListNotifyInboxResponse>;
110
181
  /**
111
182
  * Apply a terminal display state to one row (idempotent). `createdAt` MUST be
112
- * the row's own `created_at`, round-tripped from the feed or the webhook/push
113
- * payload — the id alone cannot address the row.
183
+ * the row's own `created_at`, round-tripped from the feed row — the id alone
184
+ * cannot address the row. Any mark (seen, read or archived) marks the row seen,
185
+ * which stops its escalation.
114
186
  *
115
187
  * @example
116
188
  * await sv.products.notify.markInboxState(row.notification_id, {
@@ -143,6 +215,7 @@ export declare class NotifyProductModule {
143
215
  * `getSendStatus(sendId)` for the per-recipient detail.
144
216
  *
145
217
  * Real pagination: a null `cursor` means the end of the account's history.
218
+ * A delivery counter is null until its first increment, so it reads 0 there.
146
219
  *
147
220
  * @example
148
221
  * let cursor: string | undefined;
@@ -150,7 +223,7 @@ export declare class NotifyProductModule {
150
223
  * const page = await sv.products.notify.listSends({ cursor, limit: 50 });
151
224
  * for (const send of page.sends) {
152
225
  * console.log(send.created_at, send.title, send.state,
153
- * `${send.delivered_count ?? '?'} / ${send.recipient_count ?? '?'}`);
226
+ * `${send.delivered_count ?? 0} / ${send.recipient_count ?? '?'}`);
154
227
  * }
155
228
  * cursor = page.cursor ?? undefined;
156
229
  * } while (cursor);
@@ -162,8 +235,9 @@ export declare class NotifyProductModule {
162
235
  *
163
236
  * `mode: 'grant'` (the default) drops access and leaves the content intact.
164
237
  * `mode: 'content'` hard-burns the sealed spark so it is unreadable for
165
- * everyone — spark-backed sends only, since an ingot send merely references the
166
- * owner's durable vault content.
238
+ * everyone — spark-backed sends only: an ingot send merely references the
239
+ * owner's durable vault content, so a content recall of one is a 400, refused
240
+ * before anything is revoked or stopped.
167
241
  *
168
242
  * Idempotent: a grant already revoked (or already consumed) counts as recalled,
169
243
  * so a repeated call converges rather than accumulating failures. One
@@ -186,17 +260,19 @@ export declare class NotifyProductModule {
186
260
  recallSend(sendId: string, options?: RecallNotifySendOptions): Promise<RecallNotifySendResponse>;
187
261
  /**
188
262
  * The sender's per-recipient delivery rollup for one send: who it reached and
189
- * how far each recipient got. Metadata only — never the pointer or contacts.
263
+ * how far each recipient got. Metadata only — never the pointer, and no contact
264
+ * beyond the handle each recipient was addressed by (`recipient_id`).
190
265
  *
191
266
  * @example
192
267
  * const { counts } = await sv.products.notify.getSendStatus(send.send_id);
193
268
  */
194
269
  getSendStatus(sendId: string): Promise<NotifySendStatus>;
195
270
  /**
196
- * The account's verified-interaction receipts (portable, JWKS-verifiable
197
- * proofs), newest first, with real pagination. An `interaction` filter can
198
- * hand back a short or empty page while more follow, so follow `cursor` until
199
- * it is null before concluding there are none.
271
+ * The account's verified-interaction receipts (a ceremony's carries portable,
272
+ * JWKS-verifiable proof; an open's is an unsigned access record), newest
273
+ * first, with real pagination. An `interaction` filter can hand back a short
274
+ * or empty page while more follow, so follow `cursor` until it is null before
275
+ * concluding there are none.
200
276
  *
201
277
  * @example
202
278
  * const { receipts, cursor } = await sv.products.notify.listReceipts({ interaction: 'approve' });
@@ -204,9 +280,9 @@ export declare class NotifyProductModule {
204
280
  listReceipts(options?: ListNotifyReceiptsOptions): Promise<ListNotifyReceiptsResponse>;
205
281
  /**
206
282
  * Every receipt for one send, each attached to the recipient who produced it.
207
- * The correlation scan is bounded: when `truncated` is true, some older
208
- * receipts fall outside the scanned window — pass the returned `cursor` back in
209
- * to resume the scan exactly where it stopped.
283
+ * The walk reads the account's receipts back to the send's creation, and no
284
+ * further. One call is bounded: when `truncated` is true it stopped first —
285
+ * pass the returned `cursor` back in to resume exactly where it stopped.
210
286
  *
211
287
  * @example
212
288
  * const all: NotifySendReceipt[] = [];
@@ -242,6 +318,14 @@ export declare class NotifyProductModule {
242
318
  * body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. The
243
319
  * secret is WRITE-ONLY — reads report `events.secret_set`, never the value.
244
320
  *
321
+ * The `email` section selects a domain of your own for your Notify email to go
322
+ * out from. `security`, `events` and `email` are an org admin's to change: a
323
+ * patch from anyone else naming one is refused whole, 403 `FORBIDDEN`
324
+ * (`details: { sections, required_role: 'admin' }`). A ladder naming a channel
325
+ * other than `in_app` and `email` is refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`
326
+ * (`details: { field, channels }`); a save that overlapping saves kept
327
+ * outracing is refused 409 `CONFLICT`: reload and patch again.
328
+ *
245
329
  * @example
246
330
  * await sv.products.notify.updateConfig({
247
331
  * categories: {
@@ -255,5 +339,44 @@ export declare class NotifyProductModule {
255
339
  * });
256
340
  */
257
341
  updateConfig(patch: NotifyConfigPatch): Promise<NotifyConfigResponse>;
342
+ /**
343
+ * Who your organization's Notify email is from, as the API answers it
344
+ * (verbatim snake_case): `"{organization name}" <from_address>`, with a
345
+ * notice naming SparkVault Notify. A reply reaches no one when the email goes
346
+ * out from the handle host, or from a domain of your own that is set up as a
347
+ * help-desk web host or receives the help desk's email; from a domain that
348
+ * only sends, a reply goes wherever that domain's own MX records route it.
349
+ *
350
+ * - `ready`: the email goes out from `from_address`, on `sending_host`: the
351
+ * domain `email.sending_domain` selects while it serves sending (its
352
+ * ownership verified and its sending ready), else the organization's handle
353
+ * host under send.sv, `handle_host`, which it falls back to the moment the
354
+ * domain stops serving.
355
+ * - `handle_required`: the organization has not chosen its handle, so a send
356
+ * that would email someone is refused 409 `HANDLE_REQUIRED` until it does.
357
+ * - `platform_sender`: SparkVault's own account, whose Notify email is
358
+ * platform mail.
359
+ *
360
+ * `domain_readiness` is the selected domain's readiness flags, null with no
361
+ * selection or while the organization does not hold the domain's claim.
362
+ *
363
+ * @example
364
+ * const sender = await sv.products.notify.getEmailSender();
365
+ * if (sender.state === 'handle_required') promptForHandle();
366
+ */
367
+ getEmailSender(): Promise<{
368
+ state: 'ready' | 'handle_required' | 'platform_sender';
369
+ from_address: string | null;
370
+ handle_host: string | null;
371
+ sending_domain: string | null;
372
+ sending_host: string | null;
373
+ domain_readiness: {
374
+ email_sending_ready: boolean;
375
+ email_receiving_ready: boolean;
376
+ web_ready: boolean;
377
+ help_desk_selectable: boolean;
378
+ notify_selectable: boolean;
379
+ } | null;
380
+ }>;
258
381
  }
259
- export type { NotifyChannel, NotifyDeliveryMode, NotifyVerificationLevel, NotifyInteraction, NotifyPresetCategory, NotifyCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyPreset, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifyIngotRef, NotifySendPolicy, NotifyEscalation, CreateNotifySendOptions, NotifySendResult, NotifyInboxView, NotifyInboxMarkState, NotifyInboxBulkMarkState, NotifyInboxRow, ListNotifyInboxOptions, ListNotifyInboxResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, NotifySendStatus, NotifySendStatusRecipient, NotifySendStatusCounts, NotifySendState, NotifySendSummary, ListNotifySendsOptions, ListNotifySendsResponse, NotifyRecallMode, RecallNotifySendOptions, RecallNotifySendResponse, NotifyReceipt, NotifyReceiptEventType, NotifySendReceipt, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, NotifySendReceiptsResponse, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigHistory, NotifyConfigSecurity, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigPatch, NotifyConfigOverrides, NotifyConfigResponse, } from './types';
382
+ export type { NotifyChannel, NotifyDeliveryMode, NotifyVerificationLevel, NotifyInteraction, NotifyPresetCategory, NotifyCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyPreset, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifyIngotRef, NotifySendPolicy, NotifyEscalation, CreateNotifySendOptions, NotifySendResult, NotifyInboxView, NotifyInboxMarkState, NotifyInboxBulkMarkState, NotifyInboxRow, ListNotifyInboxOptions, ListNotifyInboxResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, NotifySendStatus, NotifySendStatusRecipient, NotifyRecipientState, NotifySuppressionReason, NotifySendStatusCounts, NotifySendState, NotifySendSummary, ListNotifySendsOptions, ListNotifySendsResponse, NotifyRecallMode, RecallNotifySendOptions, RecallNotifySendResponse, NotifyReceipt, NotifyReportableVerificationLevel, NotifyReceiptEventType, NotifySendReceipt, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, NotifySendReceiptsResponse, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigHistory, NotifyConfigSecurity, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigPatch, NotifyConfigOverrides, NotifyConfigResponse, } from './types';