@sparkvault/sdk-js 8.13.1 → 8.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -72,6 +72,74 @@ declare class HealthModule {
72
72
  private readStatus;
73
73
  }
74
74
 
75
+ /**
76
+ * SparkVault SDK HTTP Client
77
+ */
78
+
79
+ interface RequestOptions {
80
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
81
+ headers?: Record<string, string>;
82
+ body?: unknown;
83
+ timeout?: number;
84
+ }
85
+ /** Capacity state for a pool, driving low-capacity nudges in the UI. */
86
+ type PoolState = 'ok' | 'notice' | 'warning' | 'exhausted';
87
+ /** Shared storage-pool capacity snapshot carried on `meta.pools`. */
88
+ interface StoragePool {
89
+ used_gb: number;
90
+ limit_gb: number;
91
+ pct: number;
92
+ state: PoolState;
93
+ }
94
+ /** Shared bandwidth-pool capacity snapshot carried on `meta.pools`. */
95
+ interface BandwidthPool {
96
+ used_gb: number;
97
+ limit_gb: number;
98
+ pct: number;
99
+ state: PoolState;
100
+ /** ISO timestamp when the bandwidth cycle resets. */
101
+ cycle_resets_at: string;
102
+ }
103
+ /** Pooled-capacity snapshot that rides on every response's `meta`. */
104
+ interface PoolsMeta {
105
+ storage: StoragePool;
106
+ bandwidth: BandwidthPool;
107
+ }
108
+ /**
109
+ * Response envelope metadata. `pools` rides on responses so clients can render
110
+ * low-capacity nudges without a separate fetch. Unknown fields are preserved.
111
+ */
112
+ interface ResponseMeta {
113
+ pools?: PoolsMeta;
114
+ [key: string]: unknown;
115
+ }
116
+ interface ApiResponse<T = unknown> {
117
+ data: T;
118
+ meta?: ResponseMeta;
119
+ status: number;
120
+ headers: Headers;
121
+ }
122
+ declare class HttpClient {
123
+ private readonly config;
124
+ constructor(config: ResolvedConfig);
125
+ private getDefaultHeaders;
126
+ private getAccessToken;
127
+ request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
128
+ private parseResponse;
129
+ private createErrorFromResponse;
130
+ private unwrapApiResponse;
131
+ /**
132
+ * Pull the `meta` envelope (carrying `pools` capacity snapshots) off a
133
+ * standard `{ data, meta }` response. Returns undefined for bare responses.
134
+ */
135
+ private extractResponseMeta;
136
+ get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
137
+ post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
138
+ put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
139
+ patch<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
140
+ delete<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
141
+ }
142
+
75
143
  /**
76
144
  * Identity Module Types
77
145
  */
@@ -125,6 +193,12 @@ interface VerifyOptions {
125
193
  * hosts that prefer a full-page redirect over a popup on mobile.
126
194
  */
127
195
  flow?: 'auto' | 'popup' | 'redirect';
196
+ /**
197
+ * `'select_account'` always shows the sign-in page's account chooser instead
198
+ * of silently continuing as the current account — even when only one saved
199
+ * account exists. Any other value is dropped at URL serialization.
200
+ */
201
+ prompt?: 'select_account';
128
202
  /**
129
203
  * Rendering strategy (internal). `'local'` renders the flow directly in this
130
204
  * document — used inside the popup that runs the flow, and forced for inline
@@ -147,6 +221,8 @@ interface AttachOptions {
147
221
  phone?: string;
148
222
  /** Auth context for OIDC/simple mode flows */
149
223
  authContext?: AuthContext;
224
+ /** `'select_account'` always shows the account chooser (see `VerifyOptions.prompt`) */
225
+ prompt?: 'select_account';
150
226
  /** Called when user cancels */
151
227
  onCancel?: () => void;
152
228
  /** Called when verification completes */
@@ -290,6 +366,15 @@ declare class QuotaExceededError extends SparkVaultError {
290
366
  readonly resource?: QuotaResource;
291
367
  constructor(message: string, details?: Record<string, unknown>);
292
368
  }
369
+ /**
370
+ * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED) — the account has
371
+ * no active Notify subscription and attempted a send. Distinct from a generic
372
+ * authorization failure: the credential is fine and re-authenticating changes
373
+ * nothing, so surface a subscribe CTA rather than a sign-in prompt.
374
+ */
375
+ declare class NotifySubscriptionRequiredError extends SparkVaultError {
376
+ constructor(message: string, details?: Record<string, unknown>);
377
+ }
293
378
  declare class NetworkError extends SparkVaultError {
294
379
  constructor(message: string, details?: Record<string, unknown>);
295
380
  }
@@ -463,58 +548,796 @@ declare class IdentityModule {
463
548
  * returns via the fragment code; OIDC/simple modes navigate bare (their
464
549
  * server-rendered pages drive the server-validated redirect back).
465
550
  *
466
- * @returns false when the return leg cannot be armed (no session storage or
467
- * WebCrypto) — the caller surfaces an actionable error instead of a
468
- * silent dead-end.
551
+ * @returns false when the return leg cannot be armed (no session storage or
552
+ * WebCrypto) — the caller surfaces an actionable error instead of a
553
+ * silent dead-end.
554
+ */
555
+ private startRedirectFlow;
556
+ /**
557
+ * Arm the PKCE + state return leg for a handoff navigation and return the URL
558
+ * to navigate to (redirect_uri = this exact page; query preserved for app
559
+ * state, fragment dropped since it is the result channel). Returns null when
560
+ * session storage or WebCrypto is unavailable so callers can degrade.
561
+ */
562
+ private prepareHandoffNavigation;
563
+ /**
564
+ * Arm the self-heal marker for an in-flight sign-in. `hint` is the identifier
565
+ * (email or phone) the sign-in was started with, when the caller supplied
566
+ * one — the recovery bounce forwards it as the /sso `login_hint`, so with
567
+ * several hub sessions recovery re-mints the account this sign-in was for,
568
+ * never a different one.
569
+ */
570
+ private markSignInPending;
571
+ private clearSignInPending;
572
+ /**
573
+ * Consume the pending marker: `fresh` is true once (then cleared) if a recent
574
+ * sign-in is still awaiting its result; `hint` is the identifier that sign-in
575
+ * carried, for the recovery bounce's `login_hint`.
576
+ */
577
+ private consumeSignInPending;
578
+ /** Remove the result fragment from the URL bar (and history entry). */
579
+ private clearUrlFragment;
580
+ /** Drop the one-shot PKCE state/verifier (+ recovery hint) a bounce staged. */
581
+ private clearOneShotAuthState;
582
+ private consumeRedirectResult;
583
+ /**
584
+ * Close the identity dialog/inline UI if open.
585
+ *
586
+ * Tears down whichever surface is active: the dialog launcher (default dialog
587
+ * mode) or the local renderer (inline / local mode).
588
+ */
589
+ close(): void;
590
+ /**
591
+ * Whether the preloaded config has already settled as a *permanent* failure
592
+ * the popup can't surface (origin not allowed, or product not configured).
593
+ * Used to skip the launcher and show the error dialog in-page immediately.
594
+ * Returns false — proceed to the launcher — when config is not preloaded,
595
+ * still in flight (raced against a short timeout so the common path is never
596
+ * delayed), resolved, or failed only transiently (the launcher surfaces a
597
+ * transient failure in its own dialog).
598
+ */
599
+ private preloadedConfigPermanentlyFailed;
600
+ /**
601
+ * Resolve target to an HTMLElement.
602
+ */
603
+ private createInlineContainer;
604
+ /**
605
+ * Render the flow into a page element instead of a popup.
606
+ *
607
+ * @internal Used only by the SparkVault-hosted sign-in popup and hosted login
608
+ * page (which own their chrome and pass `renderMode: 'local'`). Customer
609
+ * integrations have no inline mode — use `signIn()` / `attach()`.
610
+ */
611
+ render(options: VerifyOptions & {
612
+ target: string | HTMLElement;
613
+ }): Promise<VerifyResult>;
614
+ }
615
+
616
+ /**
617
+ * Notify Module Types
618
+ *
619
+ * The signed-in user's first-party inbox. Unlike Entropy/Sparks, notification
620
+ * ROWS are NOT remapped to camelCase: their fields mirror the wire. A row carries
621
+ * its cleartext part (`title`, and for a cleartext send a short `body`) natively;
622
+ * a SECURE send's content is never carried here — it lives behind the SparkLink
623
+ * `sparklink_code`. Keeping the wire shape verbatim is the single source of truth
624
+ * shared with `@sparkvault/sdk-mobile` and the first-party console, so do not
625
+ * "camelCase" these rows. Only the input option `createdAt` is camelCase for call
626
+ * ergonomics (mapped to `created_at` on the wire).
627
+ */
628
+ /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
629
+ type NotificationInboxState = 'all' | 'unseen' | 'unread' | 'archived';
630
+ /** Terminal display states the recipient can apply to one of their rows. */
631
+ type NotificationMarkState = 'seen' | 'read' | 'archived';
632
+ /**
633
+ * An inbox row in the two-part notification model. The `title` (and, for a
634
+ * cleartext send, the short `body`) is the NON-sensitive cleartext part, shown
635
+ * natively. A SECURE send's content lives behind the SparkLink (`sparklink_code`)
636
+ * and is never carried here — open the pointer to reveal it. Timestamps are epoch
637
+ * SECONDS.
638
+ */
639
+ interface NotificationRow {
640
+ notification_id: string;
641
+ send_id: string;
642
+ created_at: number;
643
+ title: string;
644
+ /**
645
+ * The short cleartext body of a plaintext send, shown natively. Absent on a
646
+ * sealed row (its content lives behind the pointer).
647
+ */
648
+ body?: string;
649
+ category: string;
650
+ type: string;
651
+ seen_at: number | null;
652
+ read_at: number | null;
653
+ archived_at: number | null;
654
+ /**
655
+ * The grant to open. Present only for a SEALED (secure) send — a cleartext send
656
+ * delivers its content inline in the channel and mints no grant, so its row has
657
+ * no pointer. Guard before building a URL from it.
658
+ */
659
+ sparklink_code?: string;
660
+ /** True only when there is a secure part to reveal (i.e. `sparklink_code` is set). */
661
+ locked: boolean;
662
+ thread_id?: string;
663
+ }
664
+ interface ListNotificationsOptions {
665
+ state?: NotificationInboxState;
666
+ /** Page size, 1-100 (server default 50). */
667
+ limit?: number;
668
+ /** Opaque cursor from a prior response. */
669
+ cursor?: string;
670
+ }
671
+ interface ListNotificationsResponse {
672
+ notifications: NotificationRow[];
673
+ /**
674
+ * Next-page cursor, or null on the last page. A page can be SHORT of `limit`
675
+ * yet still carry a non-null cursor (the state/sender filter is applied after
676
+ * the key query) — follow the cursor; never treat a short page as the end.
677
+ */
678
+ cursor: string | null;
679
+ }
680
+ interface UnreadCountResponse {
681
+ unread_count: number;
682
+ /** True when the true count is at/beyond the badge ceiling (render "N+"). */
683
+ capped: boolean;
684
+ }
685
+ interface MarkNotificationStateOptions {
686
+ /** The row's `created_at` (epoch seconds), round-tripped from the list row. Required. */
687
+ createdAt: number;
688
+ state: NotificationMarkState;
689
+ }
690
+ interface MarkNotificationStateResponse {
691
+ notification_id: string;
692
+ state: NotificationMarkState;
693
+ updated_at: number;
694
+ }
695
+ /**
696
+ * States a BULK drain can apply. `archived` is per-row only — it has no GSI for
697
+ * the server to page over, so the bulk endpoint rejects it.
698
+ */
699
+ type NotificationBulkMarkState = 'seen' | 'read';
700
+ interface MarkAllNotificationsStateOptions {
701
+ state: NotificationBulkMarkState;
702
+ /** Cursor from the prior page's response; omit to start at the newest page. */
703
+ cursor?: string;
704
+ }
705
+ interface MarkAllNotificationsStateResponse {
706
+ /** Rows marked by THIS page — the server marks one bounded page per call. */
707
+ updated: number;
708
+ /** Cursor for the next page, or null once the inbox is drained. */
709
+ cursor: string | null;
710
+ }
711
+ /** Total across a full `markAllRead()` drain. */
712
+ interface MarkAllReadResult {
713
+ updated: number;
714
+ /**
715
+ * True when the drain reached the end of the inbox (the server returned a null
716
+ * cursor). False when it stopped at the page bound with rows still unmarked —
717
+ * call again to continue. Without this a truncated drain is indistinguishable
718
+ * from a completed one.
719
+ */
720
+ complete: boolean;
721
+ }
722
+ /** The platform VAPID public key needed for pushManager.subscribe(). */
723
+ interface WebPushKeyResponse {
724
+ /** False until the VAPID keypair is provisioned server-side — hide the UI. */
725
+ configured: boolean;
726
+ /** base64url VAPID application server key, or null when not configured. */
727
+ vapid_public_key: string | null;
728
+ /** The VAPID `sub` contact (mailto:/https), or null when not configured. */
729
+ subject: string | null;
730
+ }
731
+ /** RFC 8030 subscription shape sent to the server (a PushSubscription's JSON). */
732
+ interface WebPushSubscriptionInput {
733
+ endpoint: string;
734
+ keys: {
735
+ p256dh: string;
736
+ auth: string;
737
+ };
738
+ }
739
+ interface RegisterWebPushResponse {
740
+ success: boolean;
741
+ created: boolean;
742
+ refreshed: boolean;
743
+ }
744
+ interface UnsubscribeWebPushResponse {
745
+ success: boolean;
746
+ deleted: boolean;
747
+ }
748
+ /** Terminal outcomes of the end-to-end subscribeWebPush ceremony. */
749
+ type SubscribeWebPushStatus = 'subscribed' | 'already_subscribed' | 'not_supported' | 'not_configured' | 'permission_denied';
750
+ interface SubscribeWebPushOptions {
751
+ /**
752
+ * The caller's service-worker registration (the app owns the worker file and
753
+ * its lifecycle). Web Push requires a service worker to receive push events.
754
+ */
755
+ serviceWorkerRegistration: ServiceWorkerRegistration;
756
+ }
757
+ interface SubscribeWebPushResult {
758
+ status: SubscribeWebPushStatus;
759
+ /** The live PushSubscription on 'subscribed'/'already_subscribed'. */
760
+ subscription?: PushSubscription;
761
+ }
762
+
763
+ /**
764
+ * Notify Product Types — the TENANT (sender) surface of `/v1/products/notify/*`.
765
+ *
766
+ * Wire-shape convention, split deliberately and consistently:
767
+ *
768
+ * - **Option bags are camelCase** and mapped to the snake_case body, matching
769
+ * every other data-plane module (`sparks`, `ingots`, and the recipient
770
+ * `notify` module's `createdAt`). Call ergonomics belong to the caller's
771
+ * language.
772
+ * - **Responses mirror the wire verbatim** (snake_case), for the same reason the
773
+ * recipient module documents: inbox rows and receipts are one shape shared
774
+ * with `@sparkvault/sdk-mobile` and the first-party console. Do not remap them.
775
+ * - **The config patch is the ONE exception on the input side**: it stays
776
+ * snake_case verbatim. It is a partial PATCH against a server-validated schema
777
+ * whose `categories` map is OPEN-KEYED — a tenant names its own topics
778
+ * (`weekly_newsletter`) and those keys are addressed in send payloads and
779
+ * rendered into recipient-facing preference URLs. Case-mapping the tree would
780
+ * silently corrupt them, so the config travels exactly as the server defines it.
781
+ */
782
+
783
+ /** Every transport the dispatch seam can carry a notification on. */
784
+ type NotifyChannel = 'in_app' | 'websocket' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
785
+ /**
786
+ * How a send's content reaches the recipient.
787
+ * - `sealed` (default): content is sealed into a Spark behind a single-use
788
+ * SparkLink; channels carry only the pointer ("tap to view").
789
+ * - `plaintext`: a short non-confidential body rendered INLINE in the channel
790
+ * payload. Fail-closed — restricted to inline-capable channels
791
+ * (`in_app`/`push`/`web_push`/`email`), at most 50 recipients, and never
792
+ * allowed on a confidential category.
793
+ */
794
+ type NotifyDeliveryMode = 'sealed' | 'plaintext';
795
+ /** What a recipient must prove before the SparkLink reveals its content. */
796
+ type NotifyVerificationLevel = 'none' | 'identifier' | 'passkey' | 'out_of_band' | 'dual_control';
797
+ /** What the recipient does at the reveal — the interaction the receipt attests to. */
798
+ type NotifyInteraction = 'view' | 'acknowledge' | 'sign' | 'approve' | 'reply';
799
+ /**
800
+ * The fixed categories the five presets classify their sends as. These are
801
+ * interaction bundles, not account topics — they are independent of
802
+ * `config.categories`.
803
+ */
804
+ type NotifyPresetCategory = 'alert' | 'secure' | 'conversation' | 'approval' | 'signature';
805
+ /**
806
+ * A send's display category. The server accepts either a key configured in the
807
+ * account's open-keyed `config.categories` map or one of the five preset
808
+ * categories, so this is a string that offers the preset values as hints rather
809
+ * than a closed union the account's own topics could not satisfy.
810
+ */
811
+ type NotifyCategory = NotifyPresetCategory | (string & Record<never, never>);
812
+ /** The five secure-by-default preset bundles. */
813
+ type NotifyPresetName = 'alert' | 'secureMessage' | 'conversation' | 'approval' | 'signatureRequest';
814
+ /**
815
+ * A recipient addressed by the handles the SENDER knows them by. `id` is the
816
+ * stable inbox partition key (an SVID `ing_*`, a console user id `usr_*`, or the
817
+ * tenant's own key); `email` / `phone` are the deliverable handles. A bare string
818
+ * is an identifier that is its own invite.
819
+ *
820
+ * Recipient preferences and device-channel capability are resolved from the id,
821
+ * so addressing by SVID is what makes per-person preferences apply.
822
+ */
823
+ interface NotifyRecipientRef {
824
+ id?: string;
825
+ email?: string;
826
+ phone?: string;
827
+ }
828
+ type NotifyRecipient = string | NotifyRecipientRef;
829
+ /** Content to seal into a fresh Spark, one per recipient. */
830
+ interface NotifySendContent {
831
+ payload: string;
832
+ /** Defaults to `text/plain`. A plaintext send accepts only `text/plain` or `text/html`. */
833
+ contentType?: string;
834
+ filename?: string;
835
+ /** Sealed-content lifetime; the grant never outlives the content it points at. */
836
+ ttlMinutes?: number;
837
+ }
838
+ /**
839
+ * An EXISTING ingot to point the grant at instead of sealing new content. One
840
+ * persistent asset carries a single grant, so an ingot send is 1:1 — it targets
841
+ * exactly one recipient.
842
+ */
843
+ interface NotifyIngotRef {
844
+ ingotId: string;
845
+ vaultId: string;
846
+ }
847
+ /** The access policy stamped onto each minted SparkLink grant. */
848
+ interface NotifySendPolicy {
849
+ verificationLevel?: NotifyVerificationLevel;
850
+ interaction?: NotifyInteraction;
851
+ /** Require the recipient to have verified within N minutes of revealing. */
852
+ revealFreshnessMinutes?: number;
853
+ }
854
+ /**
855
+ * Cumulative per-step delays in SECONDS from send time, one per channel step.
856
+ * Step 0 always fires immediately (any `delays[0]` is ignored), and the sequence
857
+ * is aligned non-decreasing. Omit to derive the schedule from the account config.
858
+ */
859
+ interface NotifyEscalation {
860
+ delays: number[];
861
+ }
862
+ interface CreateNotifySendOptions {
863
+ /**
864
+ * Idempotency key, `^[A-Za-z0-9_.:-]{1,128}$`. Replaying an existing id returns
865
+ * the stored send unchanged — never re-sealed, never re-delivered — with
866
+ * `idempotent: true`. Generated (`ntsnd_*`) when absent.
867
+ */
868
+ sendId?: string;
869
+ /** 1-500 recipients. An ingot send accepts exactly one. */
870
+ recipients: NotifyRecipient[];
871
+ /** Provide exactly one content source: `content` OR `ingot`. */
872
+ content?: NotifySendContent;
873
+ /** Provide exactly one content source: `content` OR `ingot`. */
874
+ ingot?: NotifyIngotRef;
875
+ /** Defaults to `sealed`. */
876
+ delivery?: NotifyDeliveryMode;
877
+ policy?: NotifySendPolicy;
878
+ /** Channel ladder override; omit to resolve from the account config per category. */
879
+ channels?: NotifyChannel[];
880
+ escalation?: NotifyEscalation;
881
+ /** Channel-agnostic display title (rides the email subject). Truncated at 200 chars, never rejected. */
882
+ title?: string;
883
+ category?: NotifyCategory;
884
+ /** Free-form display type the tenant uses to classify the send. */
885
+ type?: string;
886
+ /**
887
+ * NON-SECRET display text (≤500 chars) shown alongside a sealed send — e.g.
888
+ * "verify with your passkey to open". It is never the sealed content.
889
+ */
890
+ instructions?: string;
891
+ /** Inbox-row retention, default 30. A plaintext send is capped at 7. */
892
+ historyTtlDays?: number;
893
+ }
894
+ interface NotifySendResult {
895
+ send_id: string;
896
+ /** Number of recipients the send was accepted for. */
897
+ recipients: number;
898
+ status: string;
899
+ /**
900
+ * Present (and `true`) ONLY on an idempotent replay of an existing `send_id`.
901
+ * The first accept OMITS the field entirely — it is never `false`.
902
+ */
903
+ idempotent?: boolean;
904
+ }
905
+ /** One preset's fixed bundle, merged UNDER the caller's own arguments. */
906
+ interface NotifyPreset {
907
+ category: NotifyPresetCategory;
908
+ delivery?: NotifyDeliveryMode;
909
+ channels?: NotifyChannel[];
910
+ policy: {
911
+ verificationLevel: NotifyVerificationLevel;
912
+ interaction: NotifyInteraction;
913
+ };
914
+ }
915
+ /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
916
+ type NotifyInboxView = 'all' | 'unseen' | 'unread' | 'archived';
917
+ /** Terminal display states applicable to a single row. */
918
+ type NotifyInboxMarkState = 'seen' | 'read' | 'archived';
919
+ /**
920
+ * States a BULK drain can apply. `archived` is per-row only — it has no sparse
921
+ * GSI, so bulk-archiving would require a full-partition scan.
922
+ */
923
+ type NotifyInboxBulkMarkState = 'seen' | 'read';
924
+ interface ListNotifyInboxOptions {
925
+ /**
926
+ * The inbox owner, keyed EXACTLY as addressed on the send. Identity claim never
927
+ * migrates or aliases prior email/phone-keyed rows, so a tenant that switches to
928
+ * SVID addressing should also read the prior identifier partition for its
929
+ * `history_ttl_days` window.
930
+ */
931
+ recipientId: string;
932
+ state?: NotifyInboxView;
933
+ /** Page size, 1-100 (server default 50). */
934
+ limit?: number;
935
+ cursor?: string;
936
+ }
937
+ /**
938
+ * Both Notify inbox front doors run on one engine and return one row shape, so
939
+ * the sender-side feed is typed as the recipient feed rather than duplicated.
940
+ */
941
+ type ListNotifyInboxResponse = ListNotificationsResponse;
942
+ /** The feed's row shape — one projection shared by both front doors. */
943
+ type NotifyInboxRow = NotificationRow;
944
+ interface MarkNotifyInboxStateOptions {
945
+ recipientId: string;
946
+ /** The row's own `created_at` (epoch seconds), round-tripped from the feed row. */
947
+ createdAt: number;
948
+ state: NotifyInboxMarkState;
949
+ }
950
+ type MarkNotifyInboxStateResponse = MarkNotificationStateResponse;
951
+ interface MarkNotifyInboxAllOptions {
952
+ recipientId: string;
953
+ state: NotifyInboxBulkMarkState;
954
+ /** Continuation cursor from a prior call; loop until the response cursor is null. */
955
+ cursor?: string;
956
+ }
957
+ interface MarkNotifyInboxAllResponse {
958
+ /** Rows marked in THIS bounded page. */
959
+ updated: number;
960
+ /** Next page, or null when the drain is complete. */
961
+ cursor: string | null;
962
+ }
963
+ interface NotifySendStatusRecipient {
964
+ recipient_id: string;
965
+ /** True once the recipient's first delivery step was enqueued. */
966
+ enqueued: boolean;
967
+ seen_at: number | null;
968
+ read_at: number | null;
969
+ archived_at: number | null;
970
+ /**
971
+ * The latest dispatch outcome per attempted channel — the difference between a
972
+ * notification that actually left the building and one whose every channel
973
+ * declined. `{}` until the first dispatch is recorded. The adapter `detail`
974
+ * string is deliberately NOT carried here: it can echo a provider response body
975
+ * (and with it the recipient's raw contact), which this rollup never exposes.
976
+ */
977
+ channel_outcomes: Partial<Record<NotifyChannel, {
978
+ outcome: 'delivered' | 'skipped' | 'not_implemented' | 'retryable';
979
+ /** Epoch seconds the outcome was recorded. */
980
+ at: number | null;
981
+ /** Escalation step index the outcome came from. */
982
+ step: number | null;
983
+ }>>;
984
+ /** At least one channel accepted the notification for this recipient. */
985
+ delivered: boolean;
986
+ /**
987
+ * Every channel attempted for this recipient declined (`skipped` /
988
+ * `not_implemented`) and none delivered — a silent non-delivery. False while
989
+ * nothing has been attempted yet and while a `retryable` attempt is still in
990
+ * flight.
991
+ */
992
+ undeliverable: boolean;
993
+ }
994
+ interface NotifySendStatusCounts {
995
+ total: number;
996
+ enqueued: number;
997
+ seen: number;
998
+ read: number;
999
+ archived: number;
1000
+ /** Recipients with at least one `delivered` channel outcome. */
1001
+ delivered: number;
1002
+ /** Recipients whose every attempted channel declined — the silent-failure count. */
1003
+ undeliverable: number;
1004
+ }
1005
+ /**
1006
+ * The sender's per-recipient delivery rollup. Metadata only by construction: it
1007
+ * never carries the SparkLink pointer, the recipient's raw contact, or policy
1008
+ * internals.
1009
+ */
1010
+ interface NotifySendStatus {
1011
+ send_id: string;
1012
+ status: string;
1013
+ channels: NotifyChannel[];
1014
+ created_at: number;
1015
+ title: string | null;
1016
+ category: string | null;
1017
+ type: string | null;
1018
+ recipients: NotifySendStatusRecipient[];
1019
+ counts: NotifySendStatusCounts;
1020
+ }
1021
+ /** The five verified-interaction receipt subtypes (SparkLink lifecycle events are not receipts). */
1022
+ type NotifyReceiptEventType = 'sparklink_accessed' | 'sparklink_signed' | 'sparklink_approved' | 'sparklink_denied' | 'sparklink_replied';
1023
+ /**
1024
+ * A portable, JWKS-verifiable proof of a verified interaction. `signed_token` is
1025
+ * the Identity-signed EdDSA token; `action_hash` binds it to the approved/signed
1026
+ * action. `link_code` is masked (`abc123***`) exactly as stored.
1027
+ */
1028
+ interface NotifyReceipt {
1029
+ event_type: NotifyReceiptEventType;
1030
+ occurred_at: number | null;
1031
+ interaction: NotifyInteraction | null;
1032
+ identity: string | null;
1033
+ asset_id: string | null;
1034
+ vault_id: string | null;
1035
+ link_code: string | null;
1036
+ link_type: string | null;
1037
+ verification_level: NotifyVerificationLevel | null;
1038
+ action_hash: string | null;
1039
+ signed_token: string | null;
1040
+ decision: string | null;
1041
+ thread_id: string | null;
1042
+ reply_spark_id: string | null;
1043
+ }
1044
+ /** A receipt correlated to the recipient whose grant produced it. */
1045
+ interface NotifySendReceipt extends NotifyReceipt {
1046
+ recipient_id: string;
1047
+ }
1048
+ interface ListNotifyReceiptsOptions {
1049
+ /** Page size, 1-100 (server default 50). */
1050
+ limit?: number;
1051
+ cursor?: string;
1052
+ /** Narrow to a single interaction mode. */
1053
+ interaction?: NotifyInteraction;
1054
+ }
1055
+ interface ListNotifyReceiptsResponse {
1056
+ receipts: NotifyReceipt[];
1057
+ /**
1058
+ * Next-page cursor, or null on the last page. A page can be SHORT of `limit` —
1059
+ * even EMPTY — yet still carry a non-null cursor (the receipt-subtype and
1060
+ * `interaction` filters are applied after the key query) — follow the cursor;
1061
+ * never treat a short or empty page as the end.
1062
+ */
1063
+ cursor: string | null;
1064
+ }
1065
+ interface NotifySendReceiptsResponse {
1066
+ send_id: string;
1067
+ receipts: NotifySendReceipt[];
1068
+ /**
1069
+ * True when the bounded correlation scan ended with grants still unmatched — the
1070
+ * result is bounded, not authoritative-complete. Absent on servers that do not
1071
+ * report it.
1072
+ */
1073
+ truncated?: boolean;
1074
+ /**
1075
+ * Continuation cursor for the correlation scan when it was truncated; null or
1076
+ * absent when the scan completed.
1077
+ */
1078
+ cursor?: string | null;
1079
+ }
1080
+ /** One notification topic. `required: true` is the compliance floor — unmutable by the recipient. */
1081
+ interface NotifyConfigCategory {
1082
+ /** ≤60 chars. */
1083
+ label?: string;
1084
+ /** ≤200 chars. */
1085
+ description?: string;
1086
+ required?: boolean;
1087
+ }
1088
+ interface NotifyConfigRealtimeFallbackDelay {
1089
+ email_minutes?: number;
1090
+ sms_minutes?: number;
1091
+ voice_minutes?: number;
1092
+ }
1093
+ interface NotifyConfigDelivery {
1094
+ default_channels?: NotifyChannel[];
1095
+ /** Per-category channel order, keyed by category. */
1096
+ channel_priority?: Record<string, NotifyChannel[]>;
1097
+ realtime_fallback_delay?: NotifyConfigRealtimeFallbackDelay;
1098
+ escalation_enabled?: boolean;
1099
+ }
1100
+ interface NotifyConfigReliability {
1101
+ /**
1102
+ * Per `(account, recipient)` minute bucket, 1-600. An abuse/bug backstop the
1103
+ * tenant cannot switch off — 0 is rejected.
1104
+ */
1105
+ rate_limit_per_recipient_per_minute?: number;
1106
+ }
1107
+ interface NotifyConfigHistory {
1108
+ history_ttl_days?: number;
1109
+ receipt_retention_days?: number;
1110
+ }
1111
+ interface NotifyConfigSecurity {
1112
+ verification_level?: NotifyVerificationLevel;
1113
+ /** 0 = off. */
1114
+ reveal_freshness_minutes?: number;
1115
+ /**
1116
+ * Categories that must seal, ADDED to the hardcoded confidential baseline
1117
+ * (`secure`/`conversation`/`approval`/`signature`). Expand-only: the baseline can
1118
+ * never be removed here.
1119
+ */
1120
+ mandatory_seal_categories?: string[];
1121
+ }
1122
+ /** The account's effective config: secure defaults deep-merged with its overrides. */
1123
+ interface NotifyConfig {
1124
+ delivery: NotifyConfigDelivery;
1125
+ reliability: NotifyConfigReliability;
1126
+ history: NotifyConfigHistory;
1127
+ security: NotifyConfigSecurity;
1128
+ /** Tombstoned entries are already dropped — a deleted category is simply gone. */
1129
+ categories: Record<string, NotifyConfigCategory>;
1130
+ /** Owner-managed SSM references. Readable, never account-writable. */
1131
+ channel_credentials: Record<string, unknown>;
1132
+ }
1133
+ /**
1134
+ * A partial PATCH of the account's config overrides. Only the sections present are
1135
+ * touched, and every field is validated server-side before any write.
1136
+ *
1137
+ * `categories.<key>: null` is a DELETE TOMBSTONE — it is what keeps a seeded
1138
+ * default (say `marketing`) from re-appearing on the next merge. Storing a normal
1139
+ * object under the same key later re-creates it. The reserved `security` category
1140
+ * can neither be removed nor made optional.
1141
+ */
1142
+ interface NotifyConfigPatch {
1143
+ delivery?: NotifyConfigDelivery;
1144
+ reliability?: NotifyConfigReliability;
1145
+ history?: NotifyConfigHistory;
1146
+ security?: NotifyConfigSecurity;
1147
+ categories?: Record<string, NotifyConfigCategory | null>;
1148
+ }
1149
+ /** The stored override delta, verbatim — tombstones included, because that is what a write merges onto. */
1150
+ type NotifyConfigOverrides = NotifyConfigPatch;
1151
+ interface NotifyConfigResponse {
1152
+ effective: NotifyConfig;
1153
+ overrides: NotifyConfigOverrides;
1154
+ }
1155
+
1156
+ /**
1157
+ * Notify Product Module — the TENANT (sender) surface.
1158
+ *
1159
+ * The counterpart to `sv.notify`: where that module is session-scoped and reads
1160
+ * only the signed-in person's OWN inbox, this one is the account-scoped product
1161
+ * surface a tenant's BACKEND drives — send, sender-side inbox reads and state,
1162
+ * send status, receipts, and the account's Notify config. Every method maps to
1163
+ * `/v1/products/notify/*` and is authorized by the caller's account, so the
1164
+ * recipient is supplied explicitly rather than derived from a session.
1165
+ *
1166
+ * Intended for server-side use with an `apiKey` (sent as `X-API-Key`); a Core JWT
1167
+ * works identically. Note the API prefers a Bearer JWT when both credentials are
1168
+ * configured, so a server integration should set `apiKey` alone.
1169
+ *
1170
+ * Notify never touches crypto here: `send` seals content and mints one single-use
1171
+ * SparkLink per recipient server-side, and the client only ever carries pointers
1172
+ * and metadata.
1173
+ */
1174
+
1175
+ /**
1176
+ * The five secure-by-default preset bundles, mirroring the server's table.
1177
+ *
1178
+ * There is no preset endpoint — presets are a merge over the one send contract,
1179
+ * so they are applied client-side and produce an ordinary `send` request. Caller
1180
+ * arguments always win over a preset's defaults; `channels` left unset lets the
1181
+ * account config resolve the ladder per category.
1182
+ *
1183
+ * `alert` is the only plaintext preset: a non-confidential ping is read at a
1184
+ * glance rather than behind a tap-to-view link. The other four seal.
1185
+ */
1186
+ declare const NOTIFY_PRESETS: Readonly<Record<NotifyPresetName, NotifyPreset>>;
1187
+ /**
1188
+ * Merge a preset's bundle UNDER the caller's arguments, yielding ordinary send
1189
+ * options. Exported so a caller can inspect (or further adjust) what a preset
1190
+ * would send before sending it.
1191
+ */
1192
+ declare function buildNotifyPresetSend(preset: NotifyPresetName, options: CreateNotifySendOptions): CreateNotifySendOptions;
1193
+ declare class NotifyProductModule {
1194
+ private readonly http;
1195
+ constructor(http: HttpClient);
1196
+ /**
1197
+ * Send a notification: seal the content, mint one single-use SparkLink per
1198
+ * recipient, and enqueue delivery across the resolved channel ladder.
1199
+ *
1200
+ * `sendId` is the idempotency key. Replaying an existing one returns the stored
1201
+ * send unchanged — never re-sealed, never re-delivered — flagged `idempotent`.
1202
+ *
1203
+ * @example
1204
+ * const send = await sv.products.notify.send({
1205
+ * sendId: `invoice:${invoice.id}`,
1206
+ * recipients: [{ id: user.svid, email: user.email }],
1207
+ * content: { payload: 'Your invoice is ready.' },
1208
+ * policy: { verificationLevel: 'identifier', interaction: 'view' },
1209
+ * title: 'Invoice ready',
1210
+ * category: 'transactional',
1211
+ * });
1212
+ */
1213
+ send(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1214
+ /**
1215
+ * Frictionless informational ping — no verification, view-only, delivered
1216
+ * INLINE (plaintext) so it is read at a glance. Channels resolve from the
1217
+ * account config; plaintext requires an inline-capable channel.
1218
+ *
1219
+ * @example
1220
+ * await sv.products.notify.sendAlert({
1221
+ * recipients: [{ id: user.svid }],
1222
+ * content: { payload: 'Your export finished.' },
1223
+ * title: 'Export complete',
1224
+ * });
1225
+ */
1226
+ sendAlert(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1227
+ /** Confidential content revealed after the recipient proves their identifier. */
1228
+ sendSecureMessage(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1229
+ /** Two-way thread: identifier-verified reveal plus an encrypted reply. */
1230
+ sendConversation(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1231
+ /** High-stakes approve/deny — passkey-verified, with `action_hash` binding. */
1232
+ sendApproval(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1233
+ /** Signature-on-delivery — passkey-verified, with `action_hash` binding. */
1234
+ sendSignatureRequest(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1235
+ /**
1236
+ * Read one recipient's metadata-only feed, newest first. Rows are pointers: a
1237
+ * sealed row carries only `sparklink_code`, never the content.
1238
+ *
1239
+ * A page can come back SHORT of `limit` yet still carry a non-null cursor —
1240
+ * follow the cursor; never treat a short page as the end.
1241
+ *
1242
+ * @example
1243
+ * const { notifications, cursor } = await sv.products.notify.getInbox({
1244
+ * recipientId: user.svid,
1245
+ * state: 'unread',
1246
+ * });
1247
+ */
1248
+ getInbox(options: ListNotifyInboxOptions): Promise<ListNotifyInboxResponse>;
1249
+ /**
1250
+ * Apply a terminal display state to one row (idempotent). `createdAt` MUST be
1251
+ * the row's own `created_at`, round-tripped from the feed or the webhook/push
1252
+ * payload — the id alone cannot address the row.
1253
+ *
1254
+ * @example
1255
+ * await sv.products.notify.markInboxState(row.notification_id, {
1256
+ * recipientId: user.svid,
1257
+ * createdAt: row.created_at,
1258
+ * state: 'read',
1259
+ * });
1260
+ */
1261
+ markInboxState(notificationId: string, options: MarkNotifyInboxStateOptions): Promise<MarkNotifyInboxStateResponse>;
1262
+ /**
1263
+ * Bulk-mark one bounded page of a recipient's inbox `seen` or `read`. Loop on
1264
+ * the returned cursor until it is null. `archived` is per-row only.
1265
+ *
1266
+ * @example
1267
+ * let cursor: string | undefined;
1268
+ * do {
1269
+ * const page = await sv.products.notify.markInboxAll({
1270
+ * recipientId: user.svid, state: 'read', cursor,
1271
+ * });
1272
+ * cursor = page.cursor ?? undefined;
1273
+ * } while (cursor);
469
1274
  */
470
- private startRedirectFlow;
1275
+ markInboxAll(options: MarkNotifyInboxAllOptions): Promise<MarkNotifyInboxAllResponse>;
471
1276
  /**
472
- * Arm the PKCE + state return leg for a handoff navigation and return the URL
473
- * to navigate to (redirect_uri = this exact page; query preserved for app
474
- * state, fragment dropped since it is the result channel). Returns null when
475
- * session storage or WebCrypto is unavailable so callers can degrade.
1277
+ * The sender's per-recipient delivery rollup for one send: who it reached and
1278
+ * how far each recipient got. Metadata only — never the pointer or contacts.
1279
+ *
1280
+ * @example
1281
+ * const { counts } = await sv.products.notify.getSendStatus(send.send_id);
476
1282
  */
477
- private prepareHandoffNavigation;
478
- private markSignInPending;
479
- private clearSignInPending;
480
- /** True once (then cleared) if a recent sign-in is still awaiting its result. */
481
- private consumeSignInPending;
482
- /** Remove the result fragment from the URL bar (and history entry). */
483
- private clearUrlFragment;
484
- /** Drop the one-shot PKCE state/verifier a redirect bounce staged. */
485
- private clearOneShotAuthState;
486
- private consumeRedirectResult;
1283
+ getSendStatus(sendId: string): Promise<NotifySendStatus>;
487
1284
  /**
488
- * Close the identity dialog/inline UI if open.
1285
+ * The account's verified-interaction receipts (portable, JWKS-verifiable
1286
+ * proofs), newest first. Follow `cursor` to page.
489
1287
  *
490
- * Tears down whichever surface is active: the dialog launcher (default dialog
491
- * mode) or the local renderer (inline / local mode).
1288
+ * A page can come back SHORT of `limit` — even EMPTY — yet still carry a
1289
+ * non-null cursor: the receipt-subtype and `interaction` filters are applied
1290
+ * after the key query, so a page of non-matching rows yields no receipts and a
1291
+ * live cursor. Follow the cursor; never treat a short or empty page as the end.
1292
+ *
1293
+ * @example
1294
+ * const { receipts, cursor } = await sv.products.notify.listReceipts({ interaction: 'approve' });
492
1295
  */
493
- close(): void;
1296
+ listReceipts(options?: ListNotifyReceiptsOptions): Promise<ListNotifyReceiptsResponse>;
494
1297
  /**
495
- * Whether the preloaded config has already settled as a *permanent* failure
496
- * the popup can't surface (origin not allowed, or product not configured).
497
- * Used to skip the launcher and show the error dialog in-page immediately.
498
- * Returns false — proceed to the launcher — when config is not preloaded,
499
- * still in flight (raced against a short timeout so the common path is never
500
- * delayed), resolved, or failed only transiently (the launcher surfaces a
501
- * transient failure in its own dialog).
1298
+ * Every receipt for one send, each attached to the recipient who produced it.
1299
+ * The correlation scan is bounded: when `truncated` is true, some older
1300
+ * receipts fall outside the scanned window — pass the returned `cursor` back in
1301
+ * to resume the scan exactly where it stopped.
1302
+ *
1303
+ * @example
1304
+ * const all: NotifySendReceipt[] = [];
1305
+ * let cursor: string | undefined;
1306
+ * do {
1307
+ * const page = await sv.products.notify.getSendReceipts(send.send_id, { cursor });
1308
+ * all.push(...page.receipts);
1309
+ * cursor = page.truncated ? page.cursor ?? undefined : undefined;
1310
+ * } while (cursor);
502
1311
  */
503
- private preloadedConfigPermanentlyFailed;
1312
+ getSendReceipts(sendId: string, options?: {
1313
+ cursor?: string;
1314
+ }): Promise<NotifySendReceiptsResponse>;
504
1315
  /**
505
- * Resolve target to an HTMLElement.
1316
+ * The account's effective Notify config (secure defaults deep-merged with its
1317
+ * overrides) plus the raw override delta, so an editor can show what is
1318
+ * customized versus default.
1319
+ *
1320
+ * @example
1321
+ * const { effective, overrides } = await sv.products.notify.getConfig();
506
1322
  */
507
- private createInlineContainer;
1323
+ getConfig(): Promise<NotifyConfigResponse>;
508
1324
  /**
509
- * Render the flow into a page element instead of a popup.
1325
+ * Merge a partial patch onto the account's config overrides. Owner-gated
1326
+ * (`channel_credentials`) and unknown keys are rejected before any write.
510
1327
  *
511
- * @internal Used only by the SparkVault-hosted sign-in popup and hosted login
512
- * page (which own their chrome and pass `renderMode: 'local'`). Customer
513
- * integrations have no inline mode — use `signIn()` / `attach()`.
1328
+ * Delete a category by storing an explicit `null` TOMBSTONE — that is what keeps
1329
+ * a seeded default from re-appearing on the next merge. The reserved `security`
1330
+ * category can neither be removed nor made optional.
1331
+ *
1332
+ * @example
1333
+ * await sv.products.notify.updateConfig({
1334
+ * categories: {
1335
+ * weekly_newsletter: { label: 'Weekly newsletter', required: false },
1336
+ * marketing: null, // tombstone — remove the seeded default
1337
+ * },
1338
+ * });
514
1339
  */
515
- render(options: VerifyOptions & {
516
- target: string | HTMLElement;
517
- }): Promise<VerifyResult>;
1340
+ updateConfig(patch: NotifyConfigPatch): Promise<NotifyConfigResponse>;
518
1341
  }
519
1342
 
520
1343
  /**
@@ -528,75 +1351,17 @@ declare class IdentityModule {
528
1351
  declare class ProductsModule {
529
1352
  /** Identity verification product (passkey, OTP, SparkLink, social). */
530
1353
  readonly identity: IdentityModule;
531
- constructor(config: ResolvedConfig);
532
- }
533
-
534
- /**
535
- * SparkVault SDK HTTP Client
536
- */
537
-
538
- interface RequestOptions {
539
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
540
- headers?: Record<string, string>;
541
- body?: unknown;
542
- timeout?: number;
543
- }
544
- /** Capacity state for a pool, driving low-capacity nudges in the UI. */
545
- type PoolState = 'ok' | 'notice' | 'warning' | 'exhausted';
546
- /** Shared storage-pool capacity snapshot carried on `meta.pools`. */
547
- interface StoragePool {
548
- used_gb: number;
549
- limit_gb: number;
550
- pct: number;
551
- state: PoolState;
552
- }
553
- /** Shared bandwidth-pool capacity snapshot carried on `meta.pools`. */
554
- interface BandwidthPool {
555
- used_gb: number;
556
- limit_gb: number;
557
- pct: number;
558
- state: PoolState;
559
- /** ISO timestamp when the bandwidth cycle resets. */
560
- cycle_resets_at: string;
561
- }
562
- /** Pooled-capacity snapshot that rides on every response's `meta`. */
563
- interface PoolsMeta {
564
- storage: StoragePool;
565
- bandwidth: BandwidthPool;
566
- }
567
- /**
568
- * Response envelope metadata. `pools` rides on responses so clients can render
569
- * low-capacity nudges without a separate fetch. Unknown fields are preserved.
570
- */
571
- interface ResponseMeta {
572
- pools?: PoolsMeta;
573
- [key: string]: unknown;
574
- }
575
- interface ApiResponse<T = unknown> {
576
- data: T;
577
- meta?: ResponseMeta;
578
- status: number;
579
- headers: Headers;
580
- }
581
- declare class HttpClient {
582
- private readonly config;
583
- constructor(config: ResolvedConfig);
584
- private getDefaultHeaders;
585
- private getAccessToken;
586
- request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
587
- private parseResponse;
588
- private createErrorFromResponse;
589
- private unwrapApiResponse;
590
1354
  /**
591
- * Pull the `meta` envelope (carrying `pools` capacity snapshots) off a
592
- * standard `{ data, meta }` response. Returns undefined for bare responses.
1355
+ * Notify product — the tenant/sender surface (send, sender-side inbox, status,
1356
+ * receipts, config). Distinct from `sv.notify`, which is the signed-in
1357
+ * recipient's own inbox.
593
1358
  */
594
- private extractResponseMeta;
595
- get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
596
- post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
597
- put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
598
- patch<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
599
- delete<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
1359
+ readonly notify: NotifyProductModule;
1360
+ /**
1361
+ * `http` defaults to a client over the same resolved config so constructing
1362
+ * this module standalone stays a one-argument call.
1363
+ */
1364
+ constructor(config: ResolvedConfig, http?: HttpClient);
600
1365
  }
601
1366
 
602
1367
  /**
@@ -1878,126 +2643,6 @@ declare class EntropyModule {
1878
2643
  private validateByteCount;
1879
2644
  }
1880
2645
 
1881
- /**
1882
- * Notify Module Types
1883
- *
1884
- * The signed-in user's first-party inbox. Unlike Entropy/Sparks, notification
1885
- * ROWS are NOT remapped to camelCase: their fields mirror the wire. A row carries
1886
- * its cleartext part (`title`, and for a cleartext send a short `body`) natively;
1887
- * a SECURE send's content is never carried here — it lives behind the SparkLink
1888
- * `sparklink_code`. Keeping the wire shape verbatim is the single source of truth
1889
- * shared with `@sparkvault/sdk-mobile` and the first-party console, so do not
1890
- * "camelCase" these rows. Only the input option `createdAt` is camelCase for call
1891
- * ergonomics (mapped to `created_at` on the wire).
1892
- */
1893
- /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
1894
- type NotificationInboxState = 'all' | 'unseen' | 'unread' | 'archived';
1895
- /** Terminal display states the recipient can apply to one of their rows. */
1896
- type NotificationMarkState = 'seen' | 'read' | 'archived';
1897
- /**
1898
- * An inbox row in the two-part notification model. The `title` (and, for a
1899
- * cleartext send, the short `body`) is the NON-sensitive cleartext part, shown
1900
- * natively. A SECURE send's content lives behind the SparkLink (`sparklink_code`)
1901
- * and is never carried here — open the pointer to reveal it. Timestamps are epoch
1902
- * SECONDS.
1903
- */
1904
- interface NotificationRow {
1905
- notification_id: string;
1906
- send_id: string;
1907
- created_at: number;
1908
- title: string;
1909
- /**
1910
- * The short cleartext body of a plaintext send, shown natively. Absent on a
1911
- * sealed row (its content lives behind the pointer).
1912
- */
1913
- body?: string;
1914
- category: string;
1915
- type: string;
1916
- seen_at: number | null;
1917
- read_at: number | null;
1918
- archived_at: number | null;
1919
- /**
1920
- * The grant to open. Present only for a SEALED (secure) send — a cleartext send
1921
- * delivers its content inline in the channel and mints no grant, so its row has
1922
- * no pointer. Guard before building a URL from it.
1923
- */
1924
- sparklink_code?: string;
1925
- /** True only when there is a secure part to reveal (i.e. `sparklink_code` is set). */
1926
- locked: boolean;
1927
- thread_id?: string;
1928
- }
1929
- interface ListNotificationsOptions {
1930
- state?: NotificationInboxState;
1931
- /** Page size, 1-100 (server default 50). */
1932
- limit?: number;
1933
- /** Opaque cursor from a prior response. */
1934
- cursor?: string;
1935
- }
1936
- interface ListNotificationsResponse {
1937
- notifications: NotificationRow[];
1938
- /**
1939
- * Next-page cursor, or null on the last page. A page can be SHORT of `limit`
1940
- * yet still carry a non-null cursor (the state/sender filter is applied after
1941
- * the key query) — follow the cursor; never treat a short page as the end.
1942
- */
1943
- cursor: string | null;
1944
- }
1945
- interface UnreadCountResponse {
1946
- unread_count: number;
1947
- /** True when the true count is at/beyond the badge ceiling (render "N+"). */
1948
- capped: boolean;
1949
- }
1950
- interface MarkNotificationStateOptions {
1951
- /** The row's `created_at` (epoch seconds), round-tripped from the list row. Required. */
1952
- createdAt: number;
1953
- state: NotificationMarkState;
1954
- }
1955
- interface MarkNotificationStateResponse {
1956
- notification_id: string;
1957
- state: NotificationMarkState;
1958
- updated_at: number;
1959
- }
1960
- /** The platform VAPID public key needed for pushManager.subscribe(). */
1961
- interface WebPushKeyResponse {
1962
- /** False until the VAPID keypair is provisioned server-side — hide the UI. */
1963
- configured: boolean;
1964
- /** base64url VAPID application server key, or null when not configured. */
1965
- vapid_public_key: string | null;
1966
- /** The VAPID `sub` contact (mailto:/https), or null when not configured. */
1967
- subject: string | null;
1968
- }
1969
- /** RFC 8030 subscription shape sent to the server (a PushSubscription's JSON). */
1970
- interface WebPushSubscriptionInput {
1971
- endpoint: string;
1972
- keys: {
1973
- p256dh: string;
1974
- auth: string;
1975
- };
1976
- }
1977
- interface RegisterWebPushResponse {
1978
- success: boolean;
1979
- created: boolean;
1980
- refreshed: boolean;
1981
- }
1982
- interface UnsubscribeWebPushResponse {
1983
- success: boolean;
1984
- deleted: boolean;
1985
- }
1986
- /** Terminal outcomes of the end-to-end subscribeWebPush ceremony. */
1987
- type SubscribeWebPushStatus = 'subscribed' | 'already_subscribed' | 'not_supported' | 'not_configured' | 'permission_denied';
1988
- interface SubscribeWebPushOptions {
1989
- /**
1990
- * The caller's service-worker registration (the app owns the worker file and
1991
- * its lifecycle). Web Push requires a service worker to receive push events.
1992
- */
1993
- serviceWorkerRegistration: ServiceWorkerRegistration;
1994
- }
1995
- interface SubscribeWebPushResult {
1996
- status: SubscribeWebPushStatus;
1997
- /** The live PushSubscription on 'subscribed'/'already_subscribed'. */
1998
- subscription?: PushSubscription;
1999
- }
2000
-
2001
2646
  /**
2002
2647
  * Notify Module
2003
2648
  *
@@ -2036,6 +2681,36 @@ declare class NotifyModule {
2036
2681
  * await sv.notify.markState('ntf_abc', { createdAt: row.created_at, state: 'read' });
2037
2682
  */
2038
2683
  markState(notificationId: string, options: MarkNotificationStateOptions): Promise<MarkNotificationStateResponse>;
2684
+ /**
2685
+ * Bulk-mark ONE bounded page of the caller's inbox and return the server's
2686
+ * payload verbatim. `cursor` comes back non-null while rows remain — thread it
2687
+ * into the next call. `archived` is per-row only (no GSI to page over), so the
2688
+ * bulk states are `seen` and `read`.
2689
+ *
2690
+ * Prefer `markAllRead()` unless the caller needs to own the paging.
2691
+ *
2692
+ * @example
2693
+ * let page = await sv.notify.markAllState({ state: 'seen' });
2694
+ * while (page.cursor) page = await sv.notify.markAllState({ state: 'seen', cursor: page.cursor });
2695
+ */
2696
+ markAllState(options: MarkAllNotificationsStateOptions): Promise<MarkAllNotificationsStateResponse>;
2697
+ /**
2698
+ * Drain the caller's whole inbox to read: loop `markAllState` on the returned
2699
+ * cursor until it comes back null, and return the total marked. Marking read
2700
+ * clears the unseen marker too, so the badge zeroes with it. Idempotent.
2701
+ *
2702
+ * `complete` is false when the loop stopped at the page bound with rows still
2703
+ * unmarked — an inbox deeper than the bound finishes on a second call. Without
2704
+ * it a truncated drain looks exactly like a finished one.
2705
+ *
2706
+ * An error mid-drain propagates — the pages already marked stay marked, and a
2707
+ * re-run picks up the remainder.
2708
+ *
2709
+ * @example
2710
+ * let { updated, complete } = await sv.notify.markAllRead();
2711
+ * while (!complete) ({ complete } = await sv.notify.markAllRead());
2712
+ */
2713
+ markAllRead(): Promise<MarkAllReadResult>;
2039
2714
  /**
2040
2715
  * Whether this environment can do Web Push (service worker + Push API +
2041
2716
  * Notifications). Feature-detect before showing an enable-notifications UI.
@@ -2196,5 +2871,5 @@ declare global {
2196
2871
  }
2197
2872
  }
2198
2873
 
2199
- export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NetworkError, NotifyModule, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, SparkVault as default, logger, setDebugMode };
2200
- export type { AccessLogRetention, AccessLogsOptions, ApiResponse, AuthMethod, BandwidthPool, CreateFolderOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, Folder, FolderBreadcrumbItem, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListSparksOptions, MarkNotificationStateOptions, MarkNotificationStateResponse, NotificationInboxState, NotificationMarkState, NotificationRow, PoolState, PoolsMeta, QuotaResource, RegisterWebPushResponse, ReplaceIngotOptions, ResponseMeta, SearchIngotsOptions, ShareSparkOptions, Spark, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StoragePool, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, Theme, TokenClaims, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultDetail, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushSubscriptionInput };
2874
+ export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, logger, setDebugMode };
2875
+ export type { AccessLogRetention, AccessLogsOptions, ApiResponse, AuthMethod, BandwidthPool, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, Folder, FolderBreadcrumbItem, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusRecipient, NotifyVerificationLevel, PoolState, PoolsMeta, QuotaResource, RegisterWebPushResponse, ReplaceIngotOptions, ResponseMeta, SearchIngotsOptions, ShareSparkOptions, Spark, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StoragePool, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, Theme, TokenClaims, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultDetail, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushSubscriptionInput };