@sparkvault/sdk-js 13.2.1 → 13.4.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). */
@@ -311,9 +311,11 @@ 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
@@ -17,19 +17,19 @@
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
33
  * | `webhook`, `slack`, `teams` | Refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`: SparkVault's own destinations only |
34
34
  */
35
35
  export type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
@@ -40,7 +40,7 @@ export type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | '
40
40
  * - `plaintext`: a short non-confidential body rendered INLINE in the channel
41
41
  * payload. Fail-closed — at most 50 recipients, never allowed on a
42
42
  * 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`).
43
+ * are all four of an organization's (`in_app`, `email`, `push`, `web_push`).
44
44
  */
45
45
  export type NotifyDeliveryMode = 'sealed' | 'plaintext';
46
46
  /**
@@ -81,11 +81,13 @@ export type NotifyCategory = NotifyPresetCategory | (string & Record<never, neve
81
81
  export type NotifyPresetName = 'alert' | 'secureMessage' | 'conversation' | 'approval' | 'signatureRequest';
82
82
  /**
83
83
  * 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.
84
+ * own key for them, their Identity id (SVID, `ing_*`), or the SparkVault user
85
+ * id (`usr_*`) of an active member of your organization, which also reaches the
86
+ * devices they registered with SparkVault (`push`, `web_push`); `email` is
87
+ * where the email channel delivers and the address a sealed send's recipient
88
+ * proves to open it. A bare string is an email address or one of those
89
+ * SparkVault ids: a bare address is also the address its recipient proves,
90
+ * while a bare id keys the person's inbox row and carries no address to verify.
89
91
  *
90
92
  * The recipient's key is its `id`, else its `email`, trimmed, with an email
91
93
  * address lowercased the way Identity stores it: it names their row in your
@@ -97,13 +99,15 @@ export type NotifyPresetName = 'alert' | 'secureMessage' | 'conversation' | 'app
97
99
  * resolved to the person who holds it through Identity's directory.
98
100
  *
99
101
  * 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'`.
102
+ * by index: a SparkVault user id (`usr_*`) that is not an active member of your
103
+ * organization (another account's member, one still invited, or no member at
104
+ * all), and any id that only starts as one (`usr_`, `usr_x-1`), which names no
105
+ * member; a recipient with no email address that a phone number would key (a
106
+ * bare number, `{ phone }`, or an `id` that is an E.164 number); on a sealed
107
+ * send, one whose only handle is a phone (`{ id, phone }`); and, on a sealed
108
+ * send at the default `identifier` level or at `passkey`, one with no address
109
+ * to verify (a bare id, or an `id` alone): give it `{ id, email }`, or send at
110
+ * `verificationLevel: 'none'`.
107
111
  */
108
112
  export interface NotifyRecipientRef {
109
113
  /** At most 256 bytes of UTF-8 with no control characters: it keys the recipient's inbox. */
@@ -217,11 +221,11 @@ export interface CreateNotifySendOptions {
217
221
  policy?: NotifySendPolicy;
218
222
  /**
219
223
  * Channel ladder override, in escalation order; omit to resolve from the
220
- * account config per category. An organization's send names its own two
224
+ * account config per category. An organization's send names its own four
221
225
  * channels (see `NotifyChannel`): any other is refused 403, `serviceCode`
222
226
  * `NOTIFY_CHANNEL_NOT_AVAILABLE`, `details: { field: 'channels', channels }`.
223
227
  */
224
- channels?: Array<'in_app' | 'email'>;
228
+ channels?: Array<'in_app' | 'email' | 'push' | 'web_push'>;
225
229
  escalation?: NotifyEscalation;
226
230
  /**
227
231
  * Channel-agnostic display title (rides the email subject). Cut to 200
@@ -311,6 +315,10 @@ export interface ListNotifyInboxOptions {
311
315
  * under the key they were sent to: none is moved or aliased when the person
312
316
  * later gets an SVID, so a tenant that switches from email to SVID addressing
313
317
  * should also read the email-keyed inbox for its `history_ttl_days` window.
318
+ * A SparkVault user id (`usr_*`), or any id that only starts as one, names a
319
+ * member's own inbox, which only that member reads, signed in to SparkVault:
320
+ * it is refused 400 `VALIDATION_ERROR` before anything is read, here and on
321
+ * both marks.
314
322
  */
315
323
  recipientId: string;
316
324
  state?: NotifyInboxView;
@@ -318,13 +326,14 @@ export interface ListNotifyInboxOptions {
318
326
  limit?: number;
319
327
  cursor?: string;
320
328
  }
329
+ export type { NotifyInboxRow };
321
330
  /**
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.
331
+ * Both Notify inbox front doors run on one engine and page alike, so the
332
+ * sender-side page is typed as the recipient feed's, with the sender's rows.
324
333
  */
325
- export type ListNotifyInboxResponse = ListNotificationsResponse;
326
- /** The feed's row shape — one projection shared by both front doors. */
327
- export type NotifyInboxRow = NotificationRow;
334
+ export type ListNotifyInboxResponse = Omit<ListNotificationsResponse, 'notifications'> & {
335
+ notifications: NotifyInboxRow[];
336
+ };
328
337
  export interface MarkNotifyInboxStateOptions {
329
338
  recipientId: string;
330
339
  /** The row's own `created_at` (epoch seconds), round-tripped from the feed row. */
@@ -822,11 +831,12 @@ export interface NotifyConfigDelivery {
822
831
  escalation_enabled?: boolean;
823
832
  }
824
833
  /**
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.
834
+ * `delivery` as a patch writes it. Its ladders name an organization's own four
835
+ * channels, `in_app`, `email`, `push` and `web_push` (see `NotifyChannel`): any
836
+ * other is refused 403, `serviceCode` `NOTIFY_CHANNEL_NOT_AVAILABLE`,
837
+ * `details.field` naming the ladder's field (and `details.category` the
838
+ * category, for a category's ladder in `channel_priority`), and nothing is
839
+ * stored.
830
840
  */
831
841
  export interface NotifyConfigDeliveryPatch extends Omit<NotifyConfigDelivery, 'channel_priority'> {
832
842
  /**
@@ -922,9 +932,12 @@ export interface NotifyConfig {
922
932
  * `marketing`) is stored as a tombstone, which keeps the default from
923
933
  * re-appearing on the next merge; any other delete leaves no entry. Storing a
924
934
  * 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
935
+ * category can neither be removed nor made optional, the promotional
926
936
  * categories `marketing` and `product` can never be made required: their email
927
- * always carries an unsubscribe link.
937
+ * always carries an unsubscribe link, and `help_desk_alert` can be neither
938
+ * removed nor made required: each member decides on auth.sv, under it, whether
939
+ * the help desk's alerts reach them. Each refusal is a 400 `VALIDATION_ERROR`
940
+ * naming the category in `details.category`.
928
941
  */
929
942
  export interface NotifyConfigPatch {
930
943
  delivery?: NotifyConfigDeliveryPatch;