@sparkvault/sdk-js 13.3.0 → 14.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.
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * SparkVault's first-party Notify surface: the metadata-only inbox of a user
5
5
  * signed in to SparkVault itself (a Core session JWT; an API key or an
6
- * identity-only token is refused), holding the notifications SparkVault
7
- * delivered to them `in_app`, plus this browser's Web Push registration. It is
6
+ * identity-only token is refused), holding the notifications SparkVault and the
7
+ * organization they signed in to delivered to them `in_app`, plus this browser's
8
+ * Web Push registration. It is
8
9
  * not a tenant's inbox for its own end users: a tenant reads its recipients'
9
10
  * feeds with `sv.products.notify.getInbox`. The recipient is ALWAYS derived
10
11
  * from the session on the server — no method takes a `recipient_id`, and any
@@ -147,4 +148,4 @@ export declare class NotifyModule {
147
148
  */
148
149
  unsubscribeWebPush(options: SubscribeWebPushOptions): Promise<boolean>;
149
150
  }
150
- export type { NotificationInboxState, NotificationMarkState, NotificationRow, ListNotificationsOptions, ListNotificationsResponse, UnreadCountResponse, MarkNotificationStateOptions, MarkNotificationStateResponse, NotificationBulkMarkState, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, WebPushKeyResponse, WebPushSubscriptionInput, RegisterWebPushResponse, UnsubscribeWebPushResponse, SubscribeWebPushStatus, SubscribeWebPushOptions, SubscribeWebPushResult, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, } from './types';
151
+ export type { NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, ListNotificationsOptions, ListNotificationsResponse, UnreadCountResponse, MarkNotificationStateOptions, MarkNotificationStateResponse, NotificationBulkMarkState, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, WebPushKeyResponse, WebPushSubscriptionInput, RegisterWebPushResponse, UnsubscribeWebPushResponse, SubscribeWebPushStatus, SubscribeWebPushOptions, SubscribeWebPushResult, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, } from './types';
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * Notify Module Types
3
3
  *
4
- * SparkVault's first-party inbox: the notifications SparkVault itself delivered
5
- * `in_app` to a signed-in SparkVault user. Unlike Entropy/Sparks, notification
4
+ * A signed-in SparkVault user's own feed: the notifications SparkVault itself
5
+ * delivered `in_app` to them and those their own organization's Notify did, as
6
+ * one feed, each row saying which (`from`). Unlike Entropy/Sparks, notification
6
7
  * ROWS are NOT remapped to camelCase: their fields mirror the wire, and a tenant's
7
- * sender-side feed (`sv.products.notify.getInbox`) returns the same row. A row carries
8
+ * sender-side feed (`sv.products.notify.getInbox`) returns the same row without
9
+ * `from`, since it reads one sending account's inbox. A row carries
8
10
  * its cleartext part (`title`, and for a cleartext send a short `body`) natively;
9
11
  * a SECURE send's content is never carried here — it lives behind the SparkLink
10
12
  * `sparklink_code`. Keeping the wire shape verbatim is the single source of truth
@@ -17,13 +19,27 @@ export type NotificationInboxState = 'all' | 'unseen' | 'unread' | 'archived';
17
19
  /** Terminal display states the recipient can apply to one of their rows. */
18
20
  export type NotificationMarkState = 'seen' | 'read' | 'archived';
19
21
  /**
20
- * An inbox row in the two-part notification model. The `title` (and, for a
21
- * cleartext send, the short `body`) is the NON-sensitive cleartext part, shown
22
- * natively. A SECURE send's content lives behind the SparkLink (`sparklink_code`)
23
- * and is never carried here — open the pointer to reveal it. Timestamps are epoch
24
- * SECONDS.
22
+ * Who a row of the person's own feed is from: SparkVault itself, or their own
23
+ * organization by its name. `name` is null when the organization has no name the
24
+ * feed can show (none, or one that reads as SparkVault's): label such a row
25
+ * generically, never as SparkVault's.
25
26
  */
26
- export interface NotificationRow {
27
+ export type NotificationSender = {
28
+ type: 'sparkvault';
29
+ } | {
30
+ type: 'organization';
31
+ name: string | null;
32
+ };
33
+ /**
34
+ * An inbox row in the two-part notification model, as one sending account's
35
+ * inbox read (`sv.products.notify.getInbox`) returns it: no `from`, since the
36
+ * sender reading its own inbox is who sent every row in it. The `title` (and,
37
+ * for a cleartext send, the short `body`) is the NON-sensitive cleartext part,
38
+ * shown natively. A SECURE send's content lives behind the SparkLink
39
+ * (`sparklink_code`) and is never carried here — open the pointer to reveal it.
40
+ * Timestamps are epoch SECONDS.
41
+ */
42
+ export interface NotifyInboxRow {
27
43
  notification_id: string;
28
44
  send_id: string;
29
45
  created_at: number;
@@ -70,6 +86,13 @@ export interface NotificationRow {
70
86
  */
71
87
  recalled: boolean;
72
88
  }
89
+ /**
90
+ * A row of the person's own feed: an inbox row, and who sent it. Show `from` on
91
+ * every row: an organization's title alone could read as SparkVault's own.
92
+ */
93
+ export interface NotificationRow extends NotifyInboxRow {
94
+ from: NotificationSender;
95
+ }
73
96
  export interface ListNotificationsOptions {
74
97
  state?: NotificationInboxState;
75
98
  /** Page size, 1-100 (server default 50). */
@@ -27,4 +27,4 @@ export declare class ProductsModule {
27
27
  export { IdentityModule } from './identity';
28
28
  export { NotifyProductModule, NOTIFY_PRESETS, buildNotifyPresetSend } from './notify';
29
29
  export type { SignInOptions, SignInResult, VerifyOptions, AttachOptions, VerifyResult, TokenClaims, } from './identity';
30
- 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 './notify';
30
+ 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, NotifyDestinationKind, NotifyDestinationState, NotifyDestinationSkipReason, NotifyDestinationFailureReason, NotifyDestinationReason, NotifySendStatusDestination, NotifySendSummaryDestination, NotifyWebhookDestination, NotifyWebhookDestinationRead, NotifySlackDestination, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyConfigDestinations, NotifyConfigDestinationsPatch, } from './notify';
@@ -311,14 +311,20 @@ export declare class NotifyProductModule {
311
311
  *
312
312
  * Delete a category by storing an explicit `null` TOMBSTONE — that is what keeps
313
313
  * a seeded default from re-appearing on the next merge. The reserved `security`
314
- * category can neither be removed nor made optional, and the promotional
314
+ * category can neither be removed nor made optional, the promotional
315
315
  * categories `marketing` and `product` can never be made required: their email
316
- * always carries an unsubscribe link.
316
+ * always carries an unsubscribe link, and `help_desk_alert` can be neither
317
+ * removed nor made required: each member decides on auth.sv, under it, whether
318
+ * the help desk's alerts reach them.
317
319
  *
318
320
  * The `events` section configures the outbound event webhook: `webhook_url`
319
321
  * must be https on a public host, and `secret` (16-256 chars) signs every event
320
- * body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. The
321
- * secret is WRITE-ONLY — reads report `events.secret_set`, never the value.
322
+ * body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. Both
323
+ * are WRITE-ONLY — reads report `events.webhook_url_set`,
324
+ * `events.webhook_url_host` and `events.secret_set`, never the values. A
325
+ * `webhook_url` on another host or port needs a new `secret` in the same
326
+ * patch (400 `VALIDATION_ERROR` naming `events.secret`), so a secret never
327
+ * follows its URL to a different host.
322
328
  *
323
329
  * The `email` section selects a domain of your own for your Notify email to go
324
330
  * out from. `security`, `events` and `email` are an org admin's to change: a
@@ -381,4 +387,4 @@ export declare class NotifyProductModule {
381
387
  } | null;
382
388
  }>;
383
389
  }
384
- 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';
390
+ 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, NotifyDestinationKind, NotifyDestinationState, NotifyDestinationSkipReason, NotifyDestinationFailureReason, NotifyDestinationReason, NotifySendStatusDestination, NotifySendSummaryDestination, NotifyWebhookDestination, NotifyWebhookDestinationRead, NotifySlackDestination, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyConfigDestinations, NotifyConfigDestinationsPatch, } from './types';
@@ -17,22 +17,73 @@
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, NotificationInboxState, NotificationMarkState, NotificationBulkMarkState } from '../../notify/types';
20
+ import type { ListNotificationsResponse, MarkNotificationStateResponse, NotificationInboxState, NotificationMarkState, NotificationBulkMarkState, NotifyInboxRow } from '../../notify/types';
21
21
  import type { UnsealedVault } from '../../vaults/types';
22
22
  /**
23
23
  * Every transport the dispatch seam can carry a notification on: what a send's
24
24
  * status, a stored ladder and a config read can name. An organization's own
25
- * send, and its config's ladders, may name only two of them:
25
+ * send, and its config's ladders, may name four of them:
26
26
  *
27
27
  * | Channel | An organization's send |
28
28
  * | --- | --- |
29
29
  * | `in_app` | Delivered by the notification's row in your Notify inbox, which your app reads through `getInbox`: the inbox lists a recipient's row when their `in_app` step runs, at once when it leads the ladder and only when that step comes due when it follows `email` (a stop that ends the ladder first, such as an unsubscribe on a non-critical send or a recall, leaves it unlisted), so a send naming `email` alone lists nothing there, and neither does one to a recipient who switched In-app off for your site on auth.sv (any send but a `security` one, which crosses that switch) |
30
30
  * | `email` | Goes out from your organization's own sender (`getEmailSender`) |
31
+ * | `push`, `web_push` | Reach the devices an active member of your organization, addressed by their SparkVault user id (`usr_*`), registered with SparkVault (its phone app and browser push), titled with your organization's name first; dropped from the ladder of a recipient with none |
31
32
  * | `sms`, `voice`, `whatsapp`, `rcs` | Refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`: Notify delivers no text, call or chat message |
32
- * | `push`, `web_push` | Refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`: SparkVault's own devices only |
33
- * | `webhook`, `slack`, `teams` | Refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`: SparkVault's own destinations only |
33
+ *
34
+ * A send's posts to your organization's own webhook, Slack channel or Teams
35
+ * workflow are no channel: they are its destinations (`NotifyConfig['destinations']`).
36
+ */
37
+ export type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs';
38
+ /**
39
+ * The kinds of send-level destination your organization's Notify config names,
40
+ * at most one of each, in the order every reader lists them: a webhook of your
41
+ * own, a Slack channel (through your organization's SparkVault Slack app) and a
42
+ * Microsoft Teams workflow. Each receives one post of every send whose category
43
+ * it lists, never one per recipient, and never a `security` send.
44
+ */
45
+ export type NotifyDestinationKind = 'webhook' | 'slack' | 'teams';
46
+ /**
47
+ * One of a send's destinations, as its status and its history summary report it.
48
+ *
49
+ * - `pending` — the post has not settled yet (it is queued, or waits to be tried again).
50
+ * - `delivered` — the destination accepted the post.
51
+ * - `skipped` — nothing was posted, and trying again would not post it.
52
+ * - `failed` — the post was given up on.
53
+ * - `recalled` — the whole send was recalled before the post settled.
54
+ * - `unknown` — the send's delivery record is gone (past its history horizon).
55
+ */
56
+ export type NotifyDestinationState = 'pending' | 'delivered' | 'skipped' | 'failed' | 'recalled' | 'unknown';
57
+ /**
58
+ * Why a destination's post was skipped: the sending account was suspended or
59
+ * is being deleted (`account_inactive`), the destination was removed
60
+ * (`destination_removed`) or stopped listing the send's category
61
+ * (`destination_unrouted`) before the post went out, its URL no longer
62
+ * resolves to a public host (`unsafe_url`) or answered with a redirect, which
63
+ * is never followed (`redirect_refused`), or Slack's own reasons: no
64
+ * SparkVault Slack app is installed (`slack_not_installed`), it needs an
65
+ * admin's Refresh Connection (`slack_reauthorization_required`), the channel
66
+ * is gone (`channel_not_found`) or archived (`is_archived`), the app was
67
+ * removed from it (`not_in_channel`: saving the destination again adds it back
68
+ * to a public channel), the notification has no visible title or sender name
69
+ * (`display_not_shown`), or Slack refused it with a code of no fixed form
70
+ * (`rejected_unrecognized`).
71
+ */
72
+ export type NotifyDestinationSkipReason = 'account_inactive' | 'destination_removed' | 'destination_unrouted' | 'unsafe_url' | 'redirect_refused' | 'slack_not_installed' | 'slack_reauthorization_required' | 'channel_not_found' | 'is_archived' | 'not_in_channel' | 'display_not_shown' | 'rejected_unrecognized';
73
+ /**
74
+ * Why a destination's post failed: it was sent and its answer was lost, so it
75
+ * may have landed and is never tried again, since that could post it twice
76
+ * (`possibly_delivered`), or every attempt met a fault that may clear, and
77
+ * none was left (`attempts_exhausted`).
78
+ */
79
+ export type NotifyDestinationFailureReason = 'possibly_delivered' | 'attempts_exhausted';
80
+ /**
81
+ * The `reason` beside a skipped or failed destination: a fixed reason, the
82
+ * HTTP status a webhook or Teams workflow refused the post with
83
+ * (`status_404`), or the error code Slack refused it with
84
+ * (`rejected_restricted_action`).
34
85
  */
35
- export type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
86
+ export type NotifyDestinationReason = NotifyDestinationSkipReason | NotifyDestinationFailureReason | `status_${number}` | `rejected_${string}`;
36
87
  /**
37
88
  * How a send's content reaches the recipient.
38
89
  * - `sealed` (default): content is sealed into a Spark behind a single-use
@@ -40,7 +91,7 @@ export type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | '
40
91
  * - `plaintext`: a short non-confidential body rendered INLINE in the channel
41
92
  * payload. Fail-closed — at most 50 recipients, never allowed on a
42
93
  * confidential category, and on the inline-capable channels alone, which
43
- * for an organization's send are both of its own (`in_app` and `email`).
94
+ * are all four of an organization's (`in_app`, `email`, `push`, `web_push`).
44
95
  */
45
96
  export type NotifyDeliveryMode = 'sealed' | 'plaintext';
46
97
  /**
@@ -81,11 +132,13 @@ export type NotifyCategory = NotifyPresetCategory | (string & Record<never, neve
81
132
  export type NotifyPresetName = 'alert' | 'secureMessage' | 'conversation' | 'approval' | 'signatureRequest';
82
133
  /**
83
134
  * A recipient addressed by the handles the SENDER knows them by. `id` is your
84
- * own key for them, or their Identity id (SVID, `ing_*`); `email` is where the
85
- * email channel delivers and the address a sealed send's recipient proves to
86
- * open it. A bare string is an email address or an SVID: a bare address is
87
- * also the address its recipient proves, while a bare SVID keys the person's
88
- * inbox row and carries no address to verify.
135
+ * own key for them, their Identity id (SVID, `ing_*`), or the SparkVault user
136
+ * id (`usr_*`) of an active member of your organization, which also reaches the
137
+ * devices they registered with SparkVault (`push`, `web_push`); `email` is
138
+ * where the email channel delivers and the address a sealed send's recipient
139
+ * proves to open it. A bare string is an email address or one of those
140
+ * SparkVault ids: a bare address is also the address its recipient proves,
141
+ * while a bare id keys the person's inbox row and carries no address to verify.
89
142
  *
90
143
  * The recipient's key is its `id`, else its `email`, trimmed, with an email
91
144
  * address lowercased the way Identity stores it: it names their row in your
@@ -97,13 +150,15 @@ export type NotifyPresetName = 'alert' | 'secureMessage' | 'conversation' | 'app
97
150
  * resolved to the person who holds it through Identity's directory.
98
151
  *
99
152
  * Refused with one 400 (`serviceCode` `VALIDATION_ERROR`) naming each such entry
100
- * by index: a SparkVault user id (`usr_*`), which only SparkVault's own
101
- * notifications address; a recipient with no email address that a phone number
102
- * would key (a bare number, `{ phone }`, or an `id` that is an E.164 number);
103
- * on a sealed send, one whose only handle is a phone (`{ id, phone }`); and, on
104
- * a sealed send at the default `identifier` level or at `passkey`, one with no
105
- * address to verify (a bare SVID, or an `id` alone): give it `{ id, email }`,
106
- * or send at `verificationLevel: 'none'`.
153
+ * by index: a SparkVault user id (`usr_*`) that is not an active member of your
154
+ * organization (another account's member, one still invited, or no member at
155
+ * all), and any id that only starts as one (`usr_`, `usr_x-1`), which names no
156
+ * member; a recipient with no email address that a phone number would key (a
157
+ * bare number, `{ phone }`, or an `id` that is an E.164 number); on a sealed
158
+ * send, one whose only handle is a phone (`{ id, phone }`); and, on a sealed
159
+ * send at the default `identifier` level or at `passkey`, one with no address
160
+ * to verify (a bare id, or an `id` alone): give it `{ id, email }`, or send at
161
+ * `verificationLevel: 'none'`.
107
162
  */
108
163
  export interface NotifyRecipientRef {
109
164
  /** At most 256 bytes of UTF-8 with no control characters: it keys the recipient's inbox. */
@@ -217,11 +272,11 @@ export interface CreateNotifySendOptions {
217
272
  policy?: NotifySendPolicy;
218
273
  /**
219
274
  * Channel ladder override, in escalation order; omit to resolve from the
220
- * account config per category. An organization's send names its own two
275
+ * account config per category. An organization's send names its own four
221
276
  * channels (see `NotifyChannel`): any other is refused 403, `serviceCode`
222
277
  * `NOTIFY_CHANNEL_NOT_AVAILABLE`, `details: { field: 'channels', channels }`.
223
278
  */
224
- channels?: Array<'in_app' | 'email'>;
279
+ channels?: Array<'in_app' | 'email' | 'push' | 'web_push'>;
225
280
  escalation?: NotifyEscalation;
226
281
  /**
227
282
  * Channel-agnostic display title (rides the email subject). Cut to 200
@@ -311,6 +366,10 @@ export interface ListNotifyInboxOptions {
311
366
  * under the key they were sent to: none is moved or aliased when the person
312
367
  * later gets an SVID, so a tenant that switches from email to SVID addressing
313
368
  * should also read the email-keyed inbox for its `history_ttl_days` window.
369
+ * A SparkVault user id (`usr_*`), or any id that only starts as one, names a
370
+ * member's own inbox, which only that member reads, signed in to SparkVault:
371
+ * it is refused 400 `VALIDATION_ERROR` before anything is read, here and on
372
+ * both marks.
314
373
  */
315
374
  recipientId: string;
316
375
  state?: NotifyInboxView;
@@ -318,13 +377,14 @@ export interface ListNotifyInboxOptions {
318
377
  limit?: number;
319
378
  cursor?: string;
320
379
  }
380
+ export type { NotifyInboxRow };
321
381
  /**
322
- * Both Notify inbox front doors run on one engine and return one row shape, so
323
- * the sender-side feed is typed as the recipient feed rather than duplicated.
382
+ * Both Notify inbox front doors run on one engine and page alike, so the
383
+ * sender-side page is typed as the recipient feed's, with the sender's rows.
324
384
  */
325
- export type ListNotifyInboxResponse = ListNotificationsResponse;
326
- /** The feed's row shape — one projection shared by both front doors. */
327
- export type NotifyInboxRow = NotificationRow;
385
+ export type ListNotifyInboxResponse = Omit<ListNotificationsResponse, 'notifications'> & {
386
+ notifications: NotifyInboxRow[];
387
+ };
328
388
  export interface MarkNotifyInboxStateOptions {
329
389
  recipientId: string;
330
390
  /** The row's own `created_at` (epoch seconds), round-tripped from the feed row. */
@@ -594,6 +654,27 @@ export interface NotifySendStatus {
594
654
  type: string | null;
595
655
  recipients: NotifySendStatusRecipient[];
596
656
  counts: NotifySendStatusCounts;
657
+ /**
658
+ * Each of your organization's destinations the send was routed to when it
659
+ * was accepted, in `NotifyDestinationKind` order; empty when none was.
660
+ * Reported beside the recipients, never part of them: `status` and `counts`
661
+ * are the recipients' alone.
662
+ */
663
+ destinations: NotifySendStatusDestination[];
664
+ }
665
+ /** One of a send status's `destinations`. */
666
+ export interface NotifySendStatusDestination {
667
+ kind: NotifyDestinationKind;
668
+ state: NotifyDestinationState;
669
+ /** Epoch seconds the state was recorded; null for a post no attempt has recorded anything for yet. */
670
+ at: number | null;
671
+ /** Beside a `skipped` or `failed` state; null otherwise. */
672
+ reason: NotifyDestinationReason | null;
673
+ /**
674
+ * Where the post went: the webhook's host, the Slack channel id, or the
675
+ * Teams workflow's host. Null when no attempt recorded one.
676
+ */
677
+ target: string | null;
597
678
  }
598
679
  /**
599
680
  * A send's delivery state, DERIVED from its counters — the send row itself is
@@ -666,6 +747,18 @@ export interface NotifySendSummary {
666
747
  */
667
748
  recalled_at: number | null;
668
749
  state: NotifySendState;
750
+ /**
751
+ * The state of each of your organization's destinations the send was routed
752
+ * to, in `NotifyDestinationKind` order (empty when none was), as
753
+ * `getSendStatus` reports it; null when the send's delivery record is gone
754
+ * (`state: 'unknown'`).
755
+ */
756
+ destinations: NotifySendSummaryDestination[] | null;
757
+ }
758
+ /** One of a send-history summary's `destinations`. */
759
+ export interface NotifySendSummaryDestination {
760
+ kind: NotifyDestinationKind;
761
+ state: NotifyDestinationState;
669
762
  }
670
763
  export interface ListNotifySendsOptions {
671
764
  /** Page size, 1-100 (server default 50). */
@@ -822,11 +915,12 @@ export interface NotifyConfigDelivery {
822
915
  escalation_enabled?: boolean;
823
916
  }
824
917
  /**
825
- * `delivery` as a patch writes it. Its ladders name an organization's own two
826
- * channels, `in_app` and `email` (see `NotifyChannel`): any other is refused
827
- * 403, `serviceCode` `NOTIFY_CHANNEL_NOT_AVAILABLE`, `details.field` naming the
828
- * ladder's field (and `details.category` the category, for a category's ladder
829
- * in `channel_priority`), and nothing is stored.
918
+ * `delivery` as a patch writes it. Its ladders name an organization's own four
919
+ * channels, `in_app`, `email`, `push` and `web_push` (see `NotifyChannel`): any
920
+ * other is refused 403, `serviceCode` `NOTIFY_CHANNEL_NOT_AVAILABLE`,
921
+ * `details.field` naming the ladder's field (and `details.category` the
922
+ * category, for a category's ladder in `channel_priority`), and nothing is
923
+ * stored.
830
924
  */
831
925
  export interface NotifyConfigDeliveryPatch extends Omit<NotifyConfigDelivery, 'channel_priority'> {
832
926
  /**
@@ -872,14 +966,22 @@ export interface NotifyConfigSecurity {
872
966
  *
873
967
  * Both fields are required before anything is sent: an unsigned event is not
874
968
  * offered. `webhook_url` must be https on a public host (loopback, private,
875
- * link-local, and CGNAT addresses are rejected server-side).
969
+ * link-local, and CGNAT addresses are rejected server-side). A patch names only
970
+ * what it changes, but a `webhook_url` on another host or port than the
971
+ * stored one needs a new `secret` in the same patch (400 `VALIDATION_ERROR`
972
+ * naming `events.secret`, `details.missing: ['secret']`): a secret never
973
+ * follows its URL to a different host.
876
974
  *
877
975
  * Delivery is BEST EFFORT — one retry, then the event is dropped. Polling
878
976
  * (`listSends`, `getSendStatus`, `listReceipts`) remains the source of truth;
879
977
  * the webhook exists to make that poll rare, not to replace it.
880
978
  */
881
979
  export interface NotifyConfigEvents {
882
- /** https only, ≤2048 chars. */
980
+ /**
981
+ * https only, ≤2048 chars. WRITE-ONLY: a config read reports
982
+ * `webhook_url_set` and `webhook_url_host` instead, since a catch hook's URL
983
+ * carries its own token.
984
+ */
883
985
  webhook_url?: string;
884
986
  /**
885
987
  * HMAC-SHA256 signing secret, 16-256 chars. Sent as the hex digest of the raw
@@ -888,12 +990,101 @@ export interface NotifyConfigEvents {
888
990
  */
889
991
  secret?: string;
890
992
  }
891
- /** `events` as it comes BACK from a read — the secret is never echoed. */
993
+ /** `events` as it comes BACK from a read — neither the URL nor the secret is ever echoed. */
892
994
  export interface NotifyConfigEventsRead {
893
- webhook_url?: string;
995
+ /** Whether an event webhook URL is stored. The URL itself is never returned. */
996
+ webhook_url_set?: boolean;
997
+ /** The stored event webhook URL's host, so an editor can say where events go. */
998
+ webhook_url_host?: string;
894
999
  /** Whether a signing secret is stored. The secret itself is never returned. */
895
1000
  secret_set?: boolean;
896
1001
  }
1002
+ /**
1003
+ * Your own HTTPS endpoint as a destination. Each routed send is POSTed to `url`
1004
+ * once as JSON, signed like the event webhook (the hex HMAC-SHA256 of the raw
1005
+ * body under `secret`, in `X-SparkVault-Signature`); a post that may not have
1006
+ * landed is tried again with the same `delivery_id`, so drop a repeat you
1007
+ * already received. A redirect is never followed.
1008
+ */
1009
+ export interface NotifyWebhookDestination {
1010
+ /**
1011
+ * https only on a public host, ≤2048 chars. WRITE-ONLY: a read reports
1012
+ * `url_set` and `url_host` instead, since a catch hook's URL carries its own
1013
+ * token.
1014
+ */
1015
+ url: string;
1016
+ /** Signing secret, 16-256 chars. WRITE-ONLY: a read reports `secret_set` instead. */
1017
+ secret: string;
1018
+ /**
1019
+ * The categories whose sends it receives one post of: 1-50, each once, each a
1020
+ * category a send can carry, never `security` (a person's security notices go
1021
+ * only to that person). A refused one is a 400 naming it in `details.category`.
1022
+ */
1023
+ categories: string[];
1024
+ }
1025
+ /** The webhook destination as a read returns it: neither its URL nor its secret is ever echoed. */
1026
+ export interface NotifyWebhookDestinationRead {
1027
+ /** Whether an endpoint URL is stored. The URL itself is never returned. */
1028
+ url_set: boolean;
1029
+ /** The stored endpoint URL's host, so an editor can say which endpoint it is. */
1030
+ url_host: string;
1031
+ /** Whether a signing secret is stored. The secret itself is never returned. */
1032
+ secret_set: boolean;
1033
+ categories: string[];
1034
+ }
1035
+ /**
1036
+ * A channel in your organization's Slack workspace as a destination, posted to
1037
+ * through its SparkVault Slack app installation. A save naming `channel_id`
1038
+ * (even the one already saved) prepares the channel first: the app reads it and
1039
+ * joins a public one it is not in, and a private channel needs the app invited
1040
+ * first. A channel the app cannot post in is refused 400 with `details.reason`
1041
+ * naming why, and nothing is stored.
1042
+ */
1043
+ export interface NotifySlackDestination {
1044
+ /** The channel's Slack id, as the console's channel picker lists it. */
1045
+ channel_id: string;
1046
+ /** As `NotifyWebhookDestination['categories']`. */
1047
+ categories: string[];
1048
+ }
1049
+ /** A Microsoft Teams workflow as a destination, posted to through its webhook URL. */
1050
+ export interface NotifyTeamsDestination {
1051
+ /**
1052
+ * https only on a public host, ≤2048 chars. The URL is itself the credential
1053
+ * that posts to the channel. WRITE-ONLY: a read reports `webhook_url_set`
1054
+ * and `webhook_url_host` instead.
1055
+ */
1056
+ webhook_url: string;
1057
+ /** As `NotifyWebhookDestination['categories']`. */
1058
+ categories: string[];
1059
+ }
1060
+ /** The Teams destination as a read returns it: the workflow URL is never echoed. */
1061
+ export interface NotifyTeamsDestinationRead {
1062
+ /** Whether a workflow URL is stored. */
1063
+ webhook_url_set: boolean;
1064
+ /** The stored workflow URL's host, so an editor can say which workflow it is. */
1065
+ webhook_url_host: string;
1066
+ categories: string[];
1067
+ }
1068
+ /** The destinations a config read returns, each present only once configured. */
1069
+ export interface NotifyConfigDestinations {
1070
+ webhook?: NotifyWebhookDestinationRead;
1071
+ slack?: NotifySlackDestination;
1072
+ teams?: NotifyTeamsDestinationRead;
1073
+ }
1074
+ /**
1075
+ * A patch of the destinations: null removes the destination of its kind; an
1076
+ * object creates it, naming every field, or patches the one stored, naming
1077
+ * only what it changes (a credential it leaves out stays as stored). A webhook
1078
+ * `url` on another host or port than the stored one needs a new `secret` in
1079
+ * the same patch (400 `VALIDATION_ERROR` naming
1080
+ * `destinations.webhook.secret`, `details.missing: ['secret']`): a secret
1081
+ * never follows its URL to a different host.
1082
+ */
1083
+ export interface NotifyConfigDestinationsPatch {
1084
+ webhook?: Partial<NotifyWebhookDestination> | null;
1085
+ slack?: Partial<NotifySlackDestination> | null;
1086
+ teams?: Partial<NotifyTeamsDestination> | null;
1087
+ }
897
1088
  /** The account's effective config: secure defaults deep-merged with its overrides. */
898
1089
  export interface NotifyConfig {
899
1090
  delivery: NotifyConfigDelivery;
@@ -911,6 +1102,8 @@ export interface NotifyConfig {
911
1102
  email: {
912
1103
  sending_domain: string | null;
913
1104
  };
1105
+ /** Your organization's send-level destinations; empty until an admin configures one. */
1106
+ destinations: NotifyConfigDestinations;
914
1107
  /** Tombstoned entries are already dropped — a deleted category is simply gone. */
915
1108
  categories: Record<string, NotifyConfigCategory>;
916
1109
  }
@@ -922,9 +1115,12 @@ export interface NotifyConfig {
922
1115
  * `marketing`) is stored as a tombstone, which keeps the default from
923
1116
  * re-appearing on the next merge; any other delete leaves no entry. Storing a
924
1117
  * normal object under the same key later re-creates it. The reserved `security`
925
- * category can neither be removed nor made optional, and the promotional
1118
+ * category can neither be removed nor made optional, the promotional
926
1119
  * categories `marketing` and `product` can never be made required: their email
927
- * always carries an unsubscribe link.
1120
+ * always carries an unsubscribe link, and `help_desk_alert` can be neither
1121
+ * removed nor made required: each member decides on auth.sv, under it, whether
1122
+ * the help desk's alerts reach them. Each refusal is a 400 `VALIDATION_ERROR`
1123
+ * naming the category in `details.category`.
928
1124
  */
929
1125
  export interface NotifyConfigPatch {
930
1126
  delivery?: NotifyConfigDeliveryPatch;
@@ -946,15 +1142,21 @@ export interface NotifyConfigPatch {
946
1142
  email?: {
947
1143
  sending_domain?: string | null;
948
1144
  };
1145
+ /** Admin only. */
1146
+ destinations?: NotifyConfigDestinationsPatch;
949
1147
  categories?: Record<string, NotifyConfigCategory | null>;
950
1148
  }
951
1149
  /**
952
1150
  * The stored override delta, seeded-category tombstones included, because that is
953
- * what a write merges onto. One value is held back: `events.secret` comes back as
954
- * `secret_set`, never the secret — a patch never has to resend it.
1151
+ * what a write merges onto. The credentials are held back: `events.secret` and
1152
+ * the webhook destination's `secret` come back as `secret_set`, the webhook
1153
+ * destination's `url` as `url_set` and `url_host`, and `events.webhook_url` and
1154
+ * the Teams destination's `webhook_url` as `webhook_url_set` and
1155
+ * `webhook_url_host` — a patch never has to resend them.
955
1156
  */
956
- export type NotifyConfigOverrides = Omit<NotifyConfigPatch, 'events'> & {
1157
+ export type NotifyConfigOverrides = Omit<NotifyConfigPatch, 'events' | 'destinations'> & {
957
1158
  events?: NotifyConfigEventsRead;
1159
+ destinations?: NotifyConfigDestinations;
958
1160
  };
959
1161
  export interface NotifyConfigResponse {
960
1162
  effective: NotifyConfig;