@sparkvault/sdk-js 8.13.1 → 8.14.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
  */
@@ -290,6 +358,15 @@ declare class QuotaExceededError extends SparkVaultError {
290
358
  readonly resource?: QuotaResource;
291
359
  constructor(message: string, details?: Record<string, unknown>);
292
360
  }
361
+ /**
362
+ * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED) — the account has
363
+ * no active Notify subscription and attempted a send. Distinct from a generic
364
+ * authorization failure: the credential is fine and re-authenticating changes
365
+ * nothing, so surface a subscribe CTA rather than a sign-in prompt.
366
+ */
367
+ declare class NotifySubscriptionRequiredError extends SparkVaultError {
368
+ constructor(message: string, details?: Record<string, unknown>);
369
+ }
293
370
  declare class NetworkError extends SparkVaultError {
294
371
  constructor(message: string, details?: Record<string, unknown>);
295
372
  }
@@ -467,54 +544,781 @@ declare class IdentityModule {
467
544
  * WebCrypto) — the caller surfaces an actionable error instead of a
468
545
  * silent dead-end.
469
546
  */
470
- private startRedirectFlow;
547
+ private startRedirectFlow;
548
+ /**
549
+ * Arm the PKCE + state return leg for a handoff navigation and return the URL
550
+ * to navigate to (redirect_uri = this exact page; query preserved for app
551
+ * state, fragment dropped since it is the result channel). Returns null when
552
+ * session storage or WebCrypto is unavailable so callers can degrade.
553
+ */
554
+ private prepareHandoffNavigation;
555
+ private markSignInPending;
556
+ private clearSignInPending;
557
+ /** True once (then cleared) if a recent sign-in is still awaiting its result. */
558
+ private consumeSignInPending;
559
+ /** Remove the result fragment from the URL bar (and history entry). */
560
+ private clearUrlFragment;
561
+ /** Drop the one-shot PKCE state/verifier a redirect bounce staged. */
562
+ private clearOneShotAuthState;
563
+ private consumeRedirectResult;
564
+ /**
565
+ * Close the identity dialog/inline UI if open.
566
+ *
567
+ * Tears down whichever surface is active: the dialog launcher (default dialog
568
+ * mode) or the local renderer (inline / local mode).
569
+ */
570
+ close(): void;
571
+ /**
572
+ * Whether the preloaded config has already settled as a *permanent* failure
573
+ * the popup can't surface (origin not allowed, or product not configured).
574
+ * Used to skip the launcher and show the error dialog in-page immediately.
575
+ * Returns false — proceed to the launcher — when config is not preloaded,
576
+ * still in flight (raced against a short timeout so the common path is never
577
+ * delayed), resolved, or failed only transiently (the launcher surfaces a
578
+ * transient failure in its own dialog).
579
+ */
580
+ private preloadedConfigPermanentlyFailed;
581
+ /**
582
+ * Resolve target to an HTMLElement.
583
+ */
584
+ private createInlineContainer;
585
+ /**
586
+ * Render the flow into a page element instead of a popup.
587
+ *
588
+ * @internal Used only by the SparkVault-hosted sign-in popup and hosted login
589
+ * page (which own their chrome and pass `renderMode: 'local'`). Customer
590
+ * integrations have no inline mode — use `signIn()` / `attach()`.
591
+ */
592
+ render(options: VerifyOptions & {
593
+ target: string | HTMLElement;
594
+ }): Promise<VerifyResult>;
595
+ }
596
+
597
+ /**
598
+ * Notify Module Types
599
+ *
600
+ * The signed-in user's first-party inbox. Unlike Entropy/Sparks, notification
601
+ * ROWS are NOT remapped to camelCase: their fields mirror the wire. A row carries
602
+ * its cleartext part (`title`, and for a cleartext send a short `body`) natively;
603
+ * a SECURE send's content is never carried here — it lives behind the SparkLink
604
+ * `sparklink_code`. Keeping the wire shape verbatim is the single source of truth
605
+ * shared with `@sparkvault/sdk-mobile` and the first-party console, so do not
606
+ * "camelCase" these rows. Only the input option `createdAt` is camelCase for call
607
+ * ergonomics (mapped to `created_at` on the wire).
608
+ */
609
+ /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
610
+ type NotificationInboxState = 'all' | 'unseen' | 'unread' | 'archived';
611
+ /** Terminal display states the recipient can apply to one of their rows. */
612
+ type NotificationMarkState = 'seen' | 'read' | 'archived';
613
+ /**
614
+ * An inbox row in the two-part notification model. The `title` (and, for a
615
+ * cleartext send, the short `body`) is the NON-sensitive cleartext part, shown
616
+ * natively. A SECURE send's content lives behind the SparkLink (`sparklink_code`)
617
+ * and is never carried here — open the pointer to reveal it. Timestamps are epoch
618
+ * SECONDS.
619
+ */
620
+ interface NotificationRow {
621
+ notification_id: string;
622
+ send_id: string;
623
+ created_at: number;
624
+ title: string;
625
+ /**
626
+ * The short cleartext body of a plaintext send, shown natively. Absent on a
627
+ * sealed row (its content lives behind the pointer).
628
+ */
629
+ body?: string;
630
+ category: string;
631
+ type: string;
632
+ seen_at: number | null;
633
+ read_at: number | null;
634
+ archived_at: number | null;
635
+ /**
636
+ * The grant to open. Present only for a SEALED (secure) send — a cleartext send
637
+ * delivers its content inline in the channel and mints no grant, so its row has
638
+ * no pointer. Guard before building a URL from it.
639
+ */
640
+ sparklink_code?: string;
641
+ /** True only when there is a secure part to reveal (i.e. `sparklink_code` is set). */
642
+ locked: boolean;
643
+ thread_id?: string;
644
+ }
645
+ interface ListNotificationsOptions {
646
+ state?: NotificationInboxState;
647
+ /** Page size, 1-100 (server default 50). */
648
+ limit?: number;
649
+ /** Opaque cursor from a prior response. */
650
+ cursor?: string;
651
+ }
652
+ interface ListNotificationsResponse {
653
+ notifications: NotificationRow[];
654
+ /**
655
+ * Next-page cursor, or null on the last page. A page can be SHORT of `limit`
656
+ * yet still carry a non-null cursor (the state/sender filter is applied after
657
+ * the key query) — follow the cursor; never treat a short page as the end.
658
+ */
659
+ cursor: string | null;
660
+ }
661
+ interface UnreadCountResponse {
662
+ unread_count: number;
663
+ /** True when the true count is at/beyond the badge ceiling (render "N+"). */
664
+ capped: boolean;
665
+ }
666
+ interface MarkNotificationStateOptions {
667
+ /** The row's `created_at` (epoch seconds), round-tripped from the list row. Required. */
668
+ createdAt: number;
669
+ state: NotificationMarkState;
670
+ }
671
+ interface MarkNotificationStateResponse {
672
+ notification_id: string;
673
+ state: NotificationMarkState;
674
+ updated_at: number;
675
+ }
676
+ /**
677
+ * States a BULK drain can apply. `archived` is per-row only — it has no GSI for
678
+ * the server to page over, so the bulk endpoint rejects it.
679
+ */
680
+ type NotificationBulkMarkState = 'seen' | 'read';
681
+ interface MarkAllNotificationsStateOptions {
682
+ state: NotificationBulkMarkState;
683
+ /** Cursor from the prior page's response; omit to start at the newest page. */
684
+ cursor?: string;
685
+ }
686
+ interface MarkAllNotificationsStateResponse {
687
+ /** Rows marked by THIS page — the server marks one bounded page per call. */
688
+ updated: number;
689
+ /** Cursor for the next page, or null once the inbox is drained. */
690
+ cursor: string | null;
691
+ }
692
+ /** Total across a full `markAllRead()` drain. */
693
+ interface MarkAllReadResult {
694
+ updated: number;
695
+ /**
696
+ * True when the drain reached the end of the inbox (the server returned a null
697
+ * cursor). False when it stopped at the page bound with rows still unmarked —
698
+ * call again to continue. Without this a truncated drain is indistinguishable
699
+ * from a completed one.
700
+ */
701
+ complete: boolean;
702
+ }
703
+ /** The platform VAPID public key needed for pushManager.subscribe(). */
704
+ interface WebPushKeyResponse {
705
+ /** False until the VAPID keypair is provisioned server-side — hide the UI. */
706
+ configured: boolean;
707
+ /** base64url VAPID application server key, or null when not configured. */
708
+ vapid_public_key: string | null;
709
+ /** The VAPID `sub` contact (mailto:/https), or null when not configured. */
710
+ subject: string | null;
711
+ }
712
+ /** RFC 8030 subscription shape sent to the server (a PushSubscription's JSON). */
713
+ interface WebPushSubscriptionInput {
714
+ endpoint: string;
715
+ keys: {
716
+ p256dh: string;
717
+ auth: string;
718
+ };
719
+ }
720
+ interface RegisterWebPushResponse {
721
+ success: boolean;
722
+ created: boolean;
723
+ refreshed: boolean;
724
+ }
725
+ interface UnsubscribeWebPushResponse {
726
+ success: boolean;
727
+ deleted: boolean;
728
+ }
729
+ /** Terminal outcomes of the end-to-end subscribeWebPush ceremony. */
730
+ type SubscribeWebPushStatus = 'subscribed' | 'already_subscribed' | 'not_supported' | 'not_configured' | 'permission_denied';
731
+ interface SubscribeWebPushOptions {
732
+ /**
733
+ * The caller's service-worker registration (the app owns the worker file and
734
+ * its lifecycle). Web Push requires a service worker to receive push events.
735
+ */
736
+ serviceWorkerRegistration: ServiceWorkerRegistration;
737
+ }
738
+ interface SubscribeWebPushResult {
739
+ status: SubscribeWebPushStatus;
740
+ /** The live PushSubscription on 'subscribed'/'already_subscribed'. */
741
+ subscription?: PushSubscription;
742
+ }
743
+
744
+ /**
745
+ * Notify Product Types — the TENANT (sender) surface of `/v1/products/notify/*`.
746
+ *
747
+ * Wire-shape convention, split deliberately and consistently:
748
+ *
749
+ * - **Option bags are camelCase** and mapped to the snake_case body, matching
750
+ * every other data-plane module (`sparks`, `ingots`, and the recipient
751
+ * `notify` module's `createdAt`). Call ergonomics belong to the caller's
752
+ * language.
753
+ * - **Responses mirror the wire verbatim** (snake_case), for the same reason the
754
+ * recipient module documents: inbox rows and receipts are one shape shared
755
+ * with `@sparkvault/sdk-mobile` and the first-party console. Do not remap them.
756
+ * - **The config patch is the ONE exception on the input side**: it stays
757
+ * snake_case verbatim. It is a partial PATCH against a server-validated schema
758
+ * whose `categories` map is OPEN-KEYED — a tenant names its own topics
759
+ * (`weekly_newsletter`) and those keys are addressed in send payloads and
760
+ * rendered into recipient-facing preference URLs. Case-mapping the tree would
761
+ * silently corrupt them, so the config travels exactly as the server defines it.
762
+ */
763
+
764
+ /** Every transport the dispatch seam can carry a notification on. */
765
+ type NotifyChannel = 'in_app' | 'websocket' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
766
+ /**
767
+ * How a send's content reaches the recipient.
768
+ * - `sealed` (default): content is sealed into a Spark behind a single-use
769
+ * SparkLink; channels carry only the pointer ("tap to view").
770
+ * - `plaintext`: a short non-confidential body rendered INLINE in the channel
771
+ * payload. Fail-closed — restricted to inline-capable channels
772
+ * (`in_app`/`push`/`web_push`/`email`), at most 50 recipients, and never
773
+ * allowed on a confidential category.
774
+ */
775
+ type NotifyDeliveryMode = 'sealed' | 'plaintext';
776
+ /** What a recipient must prove before the SparkLink reveals its content. */
777
+ type NotifyVerificationLevel = 'none' | 'identifier' | 'passkey' | 'out_of_band' | 'dual_control';
778
+ /** What the recipient does at the reveal — the interaction the receipt attests to. */
779
+ type NotifyInteraction = 'view' | 'acknowledge' | 'sign' | 'approve' | 'reply';
780
+ /**
781
+ * The fixed categories the five presets classify their sends as. These are
782
+ * interaction bundles, not account topics — they are independent of
783
+ * `config.categories`.
784
+ */
785
+ type NotifyPresetCategory = 'alert' | 'secure' | 'conversation' | 'approval' | 'signature';
786
+ /**
787
+ * A send's display category. The server accepts either a key configured in the
788
+ * account's open-keyed `config.categories` map or one of the five preset
789
+ * categories, so this is a string that offers the preset values as hints rather
790
+ * than a closed union the account's own topics could not satisfy.
791
+ */
792
+ type NotifyCategory = NotifyPresetCategory | (string & Record<never, never>);
793
+ /** The five secure-by-default preset bundles. */
794
+ type NotifyPresetName = 'alert' | 'secureMessage' | 'conversation' | 'approval' | 'signatureRequest';
795
+ /**
796
+ * A recipient addressed by the handles the SENDER knows them by. `id` is the
797
+ * stable inbox partition key (an SVID `ing_*`, a console user id `usr_*`, or the
798
+ * tenant's own key); `email` / `phone` are the deliverable handles. A bare string
799
+ * is an identifier that is its own invite.
800
+ *
801
+ * Recipient preferences and device-channel capability are resolved from the id,
802
+ * so addressing by SVID is what makes per-person preferences apply.
803
+ */
804
+ interface NotifyRecipientRef {
805
+ id?: string;
806
+ email?: string;
807
+ phone?: string;
808
+ }
809
+ type NotifyRecipient = string | NotifyRecipientRef;
810
+ /** Content to seal into a fresh Spark, one per recipient. */
811
+ interface NotifySendContent {
812
+ payload: string;
813
+ /** Defaults to `text/plain`. A plaintext send accepts only `text/plain` or `text/html`. */
814
+ contentType?: string;
815
+ filename?: string;
816
+ /** Sealed-content lifetime; the grant never outlives the content it points at. */
817
+ ttlMinutes?: number;
818
+ }
819
+ /**
820
+ * An EXISTING ingot to point the grant at instead of sealing new content. One
821
+ * persistent asset carries a single grant, so an ingot send is 1:1 — it targets
822
+ * exactly one recipient.
823
+ */
824
+ interface NotifyIngotRef {
825
+ ingotId: string;
826
+ vaultId: string;
827
+ }
828
+ /** The access policy stamped onto each minted SparkLink grant. */
829
+ interface NotifySendPolicy {
830
+ verificationLevel?: NotifyVerificationLevel;
831
+ interaction?: NotifyInteraction;
832
+ /** Require the recipient to have verified within N minutes of revealing. */
833
+ revealFreshnessMinutes?: number;
834
+ }
835
+ /**
836
+ * Cumulative per-step delays in SECONDS from send time, one per channel step.
837
+ * Step 0 always fires immediately (any `delays[0]` is ignored), and the sequence
838
+ * is aligned non-decreasing. Omit to derive the schedule from the account config.
839
+ */
840
+ interface NotifyEscalation {
841
+ delays: number[];
842
+ }
843
+ interface CreateNotifySendOptions {
844
+ /**
845
+ * Idempotency key, `^[A-Za-z0-9_.:-]{1,128}$`. Replaying an existing id returns
846
+ * the stored send unchanged — never re-sealed, never re-delivered — with
847
+ * `idempotent: true`. Generated (`ntsnd_*`) when absent.
848
+ */
849
+ sendId?: string;
850
+ /** 1-500 recipients. An ingot send accepts exactly one. */
851
+ recipients: NotifyRecipient[];
852
+ /** Provide exactly one content source: `content` OR `ingot`. */
853
+ content?: NotifySendContent;
854
+ /** Provide exactly one content source: `content` OR `ingot`. */
855
+ ingot?: NotifyIngotRef;
856
+ /** Defaults to `sealed`. */
857
+ delivery?: NotifyDeliveryMode;
858
+ policy?: NotifySendPolicy;
859
+ /** Channel ladder override; omit to resolve from the account config per category. */
860
+ channels?: NotifyChannel[];
861
+ escalation?: NotifyEscalation;
862
+ /** Channel-agnostic display title (rides the email subject). Truncated at 200 chars, never rejected. */
863
+ title?: string;
864
+ category?: NotifyCategory;
865
+ /** Free-form display type the tenant uses to classify the send. */
866
+ type?: string;
867
+ /**
868
+ * NON-SECRET display text (≤500 chars) shown alongside a sealed send — e.g.
869
+ * "verify with your passkey to open". It is never the sealed content.
870
+ */
871
+ instructions?: string;
872
+ /** Inbox-row retention, default 30. A plaintext send is capped at 7. */
873
+ historyTtlDays?: number;
874
+ }
875
+ interface NotifySendResult {
876
+ send_id: string;
877
+ /** Number of recipients the send was accepted for. */
878
+ recipients: number;
879
+ status: string;
880
+ /**
881
+ * Present (and `true`) ONLY on an idempotent replay of an existing `send_id`.
882
+ * The first accept OMITS the field entirely — it is never `false`.
883
+ */
884
+ idempotent?: boolean;
885
+ }
886
+ /** One preset's fixed bundle, merged UNDER the caller's own arguments. */
887
+ interface NotifyPreset {
888
+ category: NotifyPresetCategory;
889
+ delivery?: NotifyDeliveryMode;
890
+ channels?: NotifyChannel[];
891
+ policy: {
892
+ verificationLevel: NotifyVerificationLevel;
893
+ interaction: NotifyInteraction;
894
+ };
895
+ }
896
+ /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
897
+ type NotifyInboxView = 'all' | 'unseen' | 'unread' | 'archived';
898
+ /** Terminal display states applicable to a single row. */
899
+ type NotifyInboxMarkState = 'seen' | 'read' | 'archived';
900
+ /**
901
+ * States a BULK drain can apply. `archived` is per-row only — it has no sparse
902
+ * GSI, so bulk-archiving would require a full-partition scan.
903
+ */
904
+ type NotifyInboxBulkMarkState = 'seen' | 'read';
905
+ interface ListNotifyInboxOptions {
906
+ /**
907
+ * The inbox owner, keyed EXACTLY as addressed on the send. Identity claim never
908
+ * migrates or aliases prior email/phone-keyed rows, so a tenant that switches to
909
+ * SVID addressing should also read the prior identifier partition for its
910
+ * `history_ttl_days` window.
911
+ */
912
+ recipientId: string;
913
+ state?: NotifyInboxView;
914
+ /** Page size, 1-100 (server default 50). */
915
+ limit?: number;
916
+ cursor?: string;
917
+ }
918
+ /**
919
+ * Both Notify inbox front doors run on one engine and return one row shape, so
920
+ * the sender-side feed is typed as the recipient feed rather than duplicated.
921
+ */
922
+ type ListNotifyInboxResponse = ListNotificationsResponse;
923
+ /** The feed's row shape — one projection shared by both front doors. */
924
+ type NotifyInboxRow = NotificationRow;
925
+ interface MarkNotifyInboxStateOptions {
926
+ recipientId: string;
927
+ /** The row's own `created_at` (epoch seconds), round-tripped from the feed row. */
928
+ createdAt: number;
929
+ state: NotifyInboxMarkState;
930
+ }
931
+ type MarkNotifyInboxStateResponse = MarkNotificationStateResponse;
932
+ interface MarkNotifyInboxAllOptions {
933
+ recipientId: string;
934
+ state: NotifyInboxBulkMarkState;
935
+ /** Continuation cursor from a prior call; loop until the response cursor is null. */
936
+ cursor?: string;
937
+ }
938
+ interface MarkNotifyInboxAllResponse {
939
+ /** Rows marked in THIS bounded page. */
940
+ updated: number;
941
+ /** Next page, or null when the drain is complete. */
942
+ cursor: string | null;
943
+ }
944
+ interface NotifySendStatusRecipient {
945
+ recipient_id: string;
946
+ /** True once the recipient's first delivery step was enqueued. */
947
+ enqueued: boolean;
948
+ seen_at: number | null;
949
+ read_at: number | null;
950
+ archived_at: number | null;
951
+ /**
952
+ * The latest dispatch outcome per attempted channel — the difference between a
953
+ * notification that actually left the building and one whose every channel
954
+ * declined. `{}` until the first dispatch is recorded. The adapter `detail`
955
+ * string is deliberately NOT carried here: it can echo a provider response body
956
+ * (and with it the recipient's raw contact), which this rollup never exposes.
957
+ */
958
+ channel_outcomes: Partial<Record<NotifyChannel, {
959
+ outcome: 'delivered' | 'skipped' | 'not_implemented' | 'retryable';
960
+ /** Epoch seconds the outcome was recorded. */
961
+ at: number | null;
962
+ /** Escalation step index the outcome came from. */
963
+ step: number | null;
964
+ }>>;
965
+ /** At least one channel accepted the notification for this recipient. */
966
+ delivered: boolean;
967
+ /**
968
+ * Every channel attempted for this recipient declined (`skipped` /
969
+ * `not_implemented`) and none delivered — a silent non-delivery. False while
970
+ * nothing has been attempted yet and while a `retryable` attempt is still in
971
+ * flight.
972
+ */
973
+ undeliverable: boolean;
974
+ }
975
+ interface NotifySendStatusCounts {
976
+ total: number;
977
+ enqueued: number;
978
+ seen: number;
979
+ read: number;
980
+ archived: number;
981
+ /** Recipients with at least one `delivered` channel outcome. */
982
+ delivered: number;
983
+ /** Recipients whose every attempted channel declined — the silent-failure count. */
984
+ undeliverable: number;
985
+ }
986
+ /**
987
+ * The sender's per-recipient delivery rollup. Metadata only by construction: it
988
+ * never carries the SparkLink pointer, the recipient's raw contact, or policy
989
+ * internals.
990
+ */
991
+ interface NotifySendStatus {
992
+ send_id: string;
993
+ status: string;
994
+ channels: NotifyChannel[];
995
+ created_at: number;
996
+ title: string | null;
997
+ category: string | null;
998
+ type: string | null;
999
+ recipients: NotifySendStatusRecipient[];
1000
+ counts: NotifySendStatusCounts;
1001
+ }
1002
+ /** The five verified-interaction receipt subtypes (SparkLink lifecycle events are not receipts). */
1003
+ type NotifyReceiptEventType = 'sparklink_accessed' | 'sparklink_signed' | 'sparklink_approved' | 'sparklink_denied' | 'sparklink_replied';
1004
+ /**
1005
+ * A portable, JWKS-verifiable proof of a verified interaction. `signed_token` is
1006
+ * the Identity-signed EdDSA token; `action_hash` binds it to the approved/signed
1007
+ * action. `link_code` is masked (`abc123***`) exactly as stored.
1008
+ */
1009
+ interface NotifyReceipt {
1010
+ event_type: NotifyReceiptEventType;
1011
+ occurred_at: number | null;
1012
+ interaction: NotifyInteraction | null;
1013
+ identity: string | null;
1014
+ asset_id: string | null;
1015
+ vault_id: string | null;
1016
+ link_code: string | null;
1017
+ link_type: string | null;
1018
+ verification_level: NotifyVerificationLevel | null;
1019
+ action_hash: string | null;
1020
+ signed_token: string | null;
1021
+ decision: string | null;
1022
+ thread_id: string | null;
1023
+ reply_spark_id: string | null;
1024
+ }
1025
+ /** A receipt correlated to the recipient whose grant produced it. */
1026
+ interface NotifySendReceipt extends NotifyReceipt {
1027
+ recipient_id: string;
1028
+ }
1029
+ interface ListNotifyReceiptsOptions {
1030
+ /** Page size, 1-100 (server default 50). */
1031
+ limit?: number;
1032
+ cursor?: string;
1033
+ /** Narrow to a single interaction mode. */
1034
+ interaction?: NotifyInteraction;
1035
+ }
1036
+ interface ListNotifyReceiptsResponse {
1037
+ receipts: NotifyReceipt[];
1038
+ /**
1039
+ * Next-page cursor, or null on the last page. A page can be SHORT of `limit` —
1040
+ * even EMPTY — yet still carry a non-null cursor (the receipt-subtype and
1041
+ * `interaction` filters are applied after the key query) — follow the cursor;
1042
+ * never treat a short or empty page as the end.
1043
+ */
1044
+ cursor: string | null;
1045
+ }
1046
+ interface NotifySendReceiptsResponse {
1047
+ send_id: string;
1048
+ receipts: NotifySendReceipt[];
1049
+ /**
1050
+ * True when the bounded correlation scan ended with grants still unmatched — the
1051
+ * result is bounded, not authoritative-complete. Absent on servers that do not
1052
+ * report it.
1053
+ */
1054
+ truncated?: boolean;
1055
+ /**
1056
+ * Continuation cursor for the correlation scan when it was truncated; null or
1057
+ * absent when the scan completed.
1058
+ */
1059
+ cursor?: string | null;
1060
+ }
1061
+ /** One notification topic. `required: true` is the compliance floor — unmutable by the recipient. */
1062
+ interface NotifyConfigCategory {
1063
+ /** ≤60 chars. */
1064
+ label?: string;
1065
+ /** ≤200 chars. */
1066
+ description?: string;
1067
+ required?: boolean;
1068
+ }
1069
+ interface NotifyConfigRealtimeFallbackDelay {
1070
+ email_minutes?: number;
1071
+ sms_minutes?: number;
1072
+ voice_minutes?: number;
1073
+ }
1074
+ interface NotifyConfigDelivery {
1075
+ default_channels?: NotifyChannel[];
1076
+ /** Per-category channel order, keyed by category. */
1077
+ channel_priority?: Record<string, NotifyChannel[]>;
1078
+ realtime_fallback_delay?: NotifyConfigRealtimeFallbackDelay;
1079
+ escalation_enabled?: boolean;
1080
+ }
1081
+ interface NotifyConfigReliability {
1082
+ /**
1083
+ * Per `(account, recipient)` minute bucket, 1-600. An abuse/bug backstop the
1084
+ * tenant cannot switch off — 0 is rejected.
1085
+ */
1086
+ rate_limit_per_recipient_per_minute?: number;
1087
+ }
1088
+ interface NotifyConfigHistory {
1089
+ history_ttl_days?: number;
1090
+ receipt_retention_days?: number;
1091
+ }
1092
+ interface NotifyConfigSecurity {
1093
+ verification_level?: NotifyVerificationLevel;
1094
+ /** 0 = off. */
1095
+ reveal_freshness_minutes?: number;
1096
+ /**
1097
+ * Categories that must seal, ADDED to the hardcoded confidential baseline
1098
+ * (`secure`/`conversation`/`approval`/`signature`). Expand-only: the baseline can
1099
+ * never be removed here.
1100
+ */
1101
+ mandatory_seal_categories?: string[];
1102
+ }
1103
+ /** The account's effective config: secure defaults deep-merged with its overrides. */
1104
+ interface NotifyConfig {
1105
+ delivery: NotifyConfigDelivery;
1106
+ reliability: NotifyConfigReliability;
1107
+ history: NotifyConfigHistory;
1108
+ security: NotifyConfigSecurity;
1109
+ /** Tombstoned entries are already dropped — a deleted category is simply gone. */
1110
+ categories: Record<string, NotifyConfigCategory>;
1111
+ /** Owner-managed SSM references. Readable, never account-writable. */
1112
+ channel_credentials: Record<string, unknown>;
1113
+ }
1114
+ /**
1115
+ * A partial PATCH of the account's config overrides. Only the sections present are
1116
+ * touched, and every field is validated server-side before any write.
1117
+ *
1118
+ * `categories.<key>: null` is a DELETE TOMBSTONE — it is what keeps a seeded
1119
+ * default (say `marketing`) from re-appearing on the next merge. Storing a normal
1120
+ * object under the same key later re-creates it. The reserved `security` category
1121
+ * can neither be removed nor made optional.
1122
+ */
1123
+ interface NotifyConfigPatch {
1124
+ delivery?: NotifyConfigDelivery;
1125
+ reliability?: NotifyConfigReliability;
1126
+ history?: NotifyConfigHistory;
1127
+ security?: NotifyConfigSecurity;
1128
+ categories?: Record<string, NotifyConfigCategory | null>;
1129
+ }
1130
+ /** The stored override delta, verbatim — tombstones included, because that is what a write merges onto. */
1131
+ type NotifyConfigOverrides = NotifyConfigPatch;
1132
+ interface NotifyConfigResponse {
1133
+ effective: NotifyConfig;
1134
+ overrides: NotifyConfigOverrides;
1135
+ }
1136
+
1137
+ /**
1138
+ * Notify Product Module — the TENANT (sender) surface.
1139
+ *
1140
+ * The counterpart to `sv.notify`: where that module is session-scoped and reads
1141
+ * only the signed-in person's OWN inbox, this one is the account-scoped product
1142
+ * surface a tenant's BACKEND drives — send, sender-side inbox reads and state,
1143
+ * send status, receipts, and the account's Notify config. Every method maps to
1144
+ * `/v1/products/notify/*` and is authorized by the caller's account, so the
1145
+ * recipient is supplied explicitly rather than derived from a session.
1146
+ *
1147
+ * Intended for server-side use with an `apiKey` (sent as `X-API-Key`); a Core JWT
1148
+ * works identically. Note the API prefers a Bearer JWT when both credentials are
1149
+ * configured, so a server integration should set `apiKey` alone.
1150
+ *
1151
+ * Notify never touches crypto here: `send` seals content and mints one single-use
1152
+ * SparkLink per recipient server-side, and the client only ever carries pointers
1153
+ * and metadata.
1154
+ */
1155
+
1156
+ /**
1157
+ * The five secure-by-default preset bundles, mirroring the server's table.
1158
+ *
1159
+ * There is no preset endpoint — presets are a merge over the one send contract,
1160
+ * so they are applied client-side and produce an ordinary `send` request. Caller
1161
+ * arguments always win over a preset's defaults; `channels` left unset lets the
1162
+ * account config resolve the ladder per category.
1163
+ *
1164
+ * `alert` is the only plaintext preset: a non-confidential ping is read at a
1165
+ * glance rather than behind a tap-to-view link. The other four seal.
1166
+ */
1167
+ declare const NOTIFY_PRESETS: Readonly<Record<NotifyPresetName, NotifyPreset>>;
1168
+ /**
1169
+ * Merge a preset's bundle UNDER the caller's arguments, yielding ordinary send
1170
+ * options. Exported so a caller can inspect (or further adjust) what a preset
1171
+ * would send before sending it.
1172
+ */
1173
+ declare function buildNotifyPresetSend(preset: NotifyPresetName, options: CreateNotifySendOptions): CreateNotifySendOptions;
1174
+ declare class NotifyProductModule {
1175
+ private readonly http;
1176
+ constructor(http: HttpClient);
1177
+ /**
1178
+ * Send a notification: seal the content, mint one single-use SparkLink per
1179
+ * recipient, and enqueue delivery across the resolved channel ladder.
1180
+ *
1181
+ * `sendId` is the idempotency key. Replaying an existing one returns the stored
1182
+ * send unchanged — never re-sealed, never re-delivered — flagged `idempotent`.
1183
+ *
1184
+ * @example
1185
+ * const send = await sv.products.notify.send({
1186
+ * sendId: `invoice:${invoice.id}`,
1187
+ * recipients: [{ id: user.svid, email: user.email }],
1188
+ * content: { payload: 'Your invoice is ready.' },
1189
+ * policy: { verificationLevel: 'identifier', interaction: 'view' },
1190
+ * title: 'Invoice ready',
1191
+ * category: 'transactional',
1192
+ * });
1193
+ */
1194
+ send(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1195
+ /**
1196
+ * Frictionless informational ping — no verification, view-only, delivered
1197
+ * INLINE (plaintext) so it is read at a glance. Channels resolve from the
1198
+ * account config; plaintext requires an inline-capable channel.
1199
+ *
1200
+ * @example
1201
+ * await sv.products.notify.sendAlert({
1202
+ * recipients: [{ id: user.svid }],
1203
+ * content: { payload: 'Your export finished.' },
1204
+ * title: 'Export complete',
1205
+ * });
1206
+ */
1207
+ sendAlert(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1208
+ /** Confidential content revealed after the recipient proves their identifier. */
1209
+ sendSecureMessage(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1210
+ /** Two-way thread: identifier-verified reveal plus an encrypted reply. */
1211
+ sendConversation(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1212
+ /** High-stakes approve/deny — passkey-verified, with `action_hash` binding. */
1213
+ sendApproval(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1214
+ /** Signature-on-delivery — passkey-verified, with `action_hash` binding. */
1215
+ sendSignatureRequest(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1216
+ /**
1217
+ * Read one recipient's metadata-only feed, newest first. Rows are pointers: a
1218
+ * sealed row carries only `sparklink_code`, never the content.
1219
+ *
1220
+ * A page can come back SHORT of `limit` yet still carry a non-null cursor —
1221
+ * follow the cursor; never treat a short page as the end.
1222
+ *
1223
+ * @example
1224
+ * const { notifications, cursor } = await sv.products.notify.getInbox({
1225
+ * recipientId: user.svid,
1226
+ * state: 'unread',
1227
+ * });
1228
+ */
1229
+ getInbox(options: ListNotifyInboxOptions): Promise<ListNotifyInboxResponse>;
1230
+ /**
1231
+ * Apply a terminal display state to one row (idempotent). `createdAt` MUST be
1232
+ * the row's own `created_at`, round-tripped from the feed or the webhook/push
1233
+ * payload — the id alone cannot address the row.
1234
+ *
1235
+ * @example
1236
+ * await sv.products.notify.markInboxState(row.notification_id, {
1237
+ * recipientId: user.svid,
1238
+ * createdAt: row.created_at,
1239
+ * state: 'read',
1240
+ * });
1241
+ */
1242
+ markInboxState(notificationId: string, options: MarkNotifyInboxStateOptions): Promise<MarkNotifyInboxStateResponse>;
1243
+ /**
1244
+ * Bulk-mark one bounded page of a recipient's inbox `seen` or `read`. Loop on
1245
+ * the returned cursor until it is null. `archived` is per-row only.
1246
+ *
1247
+ * @example
1248
+ * let cursor: string | undefined;
1249
+ * do {
1250
+ * const page = await sv.products.notify.markInboxAll({
1251
+ * recipientId: user.svid, state: 'read', cursor,
1252
+ * });
1253
+ * cursor = page.cursor ?? undefined;
1254
+ * } while (cursor);
1255
+ */
1256
+ markInboxAll(options: MarkNotifyInboxAllOptions): Promise<MarkNotifyInboxAllResponse>;
471
1257
  /**
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.
1258
+ * The sender's per-recipient delivery rollup for one send: who it reached and
1259
+ * how far each recipient got. Metadata only — never the pointer or contacts.
1260
+ *
1261
+ * @example
1262
+ * const { counts } = await sv.products.notify.getSendStatus(send.send_id);
476
1263
  */
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;
1264
+ getSendStatus(sendId: string): Promise<NotifySendStatus>;
487
1265
  /**
488
- * Close the identity dialog/inline UI if open.
1266
+ * The account's verified-interaction receipts (portable, JWKS-verifiable
1267
+ * proofs), newest first. Follow `cursor` to page.
489
1268
  *
490
- * Tears down whichever surface is active: the dialog launcher (default dialog
491
- * mode) or the local renderer (inline / local mode).
1269
+ * A page can come back SHORT of `limit` — even EMPTY — yet still carry a
1270
+ * non-null cursor: the receipt-subtype and `interaction` filters are applied
1271
+ * after the key query, so a page of non-matching rows yields no receipts and a
1272
+ * live cursor. Follow the cursor; never treat a short or empty page as the end.
1273
+ *
1274
+ * @example
1275
+ * const { receipts, cursor } = await sv.products.notify.listReceipts({ interaction: 'approve' });
492
1276
  */
493
- close(): void;
1277
+ listReceipts(options?: ListNotifyReceiptsOptions): Promise<ListNotifyReceiptsResponse>;
494
1278
  /**
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).
1279
+ * Every receipt for one send, each attached to the recipient who produced it.
1280
+ * The correlation scan is bounded: when `truncated` is true, some older
1281
+ * receipts fall outside the scanned window — pass the returned `cursor` back in
1282
+ * to resume the scan exactly where it stopped.
1283
+ *
1284
+ * @example
1285
+ * const all: NotifySendReceipt[] = [];
1286
+ * let cursor: string | undefined;
1287
+ * do {
1288
+ * const page = await sv.products.notify.getSendReceipts(send.send_id, { cursor });
1289
+ * all.push(...page.receipts);
1290
+ * cursor = page.truncated ? page.cursor ?? undefined : undefined;
1291
+ * } while (cursor);
502
1292
  */
503
- private preloadedConfigPermanentlyFailed;
1293
+ getSendReceipts(sendId: string, options?: {
1294
+ cursor?: string;
1295
+ }): Promise<NotifySendReceiptsResponse>;
504
1296
  /**
505
- * Resolve target to an HTMLElement.
1297
+ * The account's effective Notify config (secure defaults deep-merged with its
1298
+ * overrides) plus the raw override delta, so an editor can show what is
1299
+ * customized versus default.
1300
+ *
1301
+ * @example
1302
+ * const { effective, overrides } = await sv.products.notify.getConfig();
506
1303
  */
507
- private createInlineContainer;
1304
+ getConfig(): Promise<NotifyConfigResponse>;
508
1305
  /**
509
- * Render the flow into a page element instead of a popup.
1306
+ * Merge a partial patch onto the account's config overrides. Owner-gated
1307
+ * (`channel_credentials`) and unknown keys are rejected before any write.
510
1308
  *
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()`.
1309
+ * Delete a category by storing an explicit `null` TOMBSTONE — that is what keeps
1310
+ * a seeded default from re-appearing on the next merge. The reserved `security`
1311
+ * category can neither be removed nor made optional.
1312
+ *
1313
+ * @example
1314
+ * await sv.products.notify.updateConfig({
1315
+ * categories: {
1316
+ * weekly_newsletter: { label: 'Weekly newsletter', required: false },
1317
+ * marketing: null, // tombstone — remove the seeded default
1318
+ * },
1319
+ * });
514
1320
  */
515
- render(options: VerifyOptions & {
516
- target: string | HTMLElement;
517
- }): Promise<VerifyResult>;
1321
+ updateConfig(patch: NotifyConfigPatch): Promise<NotifyConfigResponse>;
518
1322
  }
519
1323
 
520
1324
  /**
@@ -528,75 +1332,17 @@ declare class IdentityModule {
528
1332
  declare class ProductsModule {
529
1333
  /** Identity verification product (passkey, OTP, SparkLink, social). */
530
1334
  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
1335
  /**
591
- * Pull the `meta` envelope (carrying `pools` capacity snapshots) off a
592
- * standard `{ data, meta }` response. Returns undefined for bare responses.
1336
+ * Notify product — the tenant/sender surface (send, sender-side inbox, status,
1337
+ * receipts, config). Distinct from `sv.notify`, which is the signed-in
1338
+ * recipient's own inbox.
593
1339
  */
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>>;
1340
+ readonly notify: NotifyProductModule;
1341
+ /**
1342
+ * `http` defaults to a client over the same resolved config so constructing
1343
+ * this module standalone stays a one-argument call.
1344
+ */
1345
+ constructor(config: ResolvedConfig, http?: HttpClient);
600
1346
  }
601
1347
 
602
1348
  /**
@@ -1878,126 +2624,6 @@ declare class EntropyModule {
1878
2624
  private validateByteCount;
1879
2625
  }
1880
2626
 
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
2627
  /**
2002
2628
  * Notify Module
2003
2629
  *
@@ -2036,6 +2662,36 @@ declare class NotifyModule {
2036
2662
  * await sv.notify.markState('ntf_abc', { createdAt: row.created_at, state: 'read' });
2037
2663
  */
2038
2664
  markState(notificationId: string, options: MarkNotificationStateOptions): Promise<MarkNotificationStateResponse>;
2665
+ /**
2666
+ * Bulk-mark ONE bounded page of the caller's inbox and return the server's
2667
+ * payload verbatim. `cursor` comes back non-null while rows remain — thread it
2668
+ * into the next call. `archived` is per-row only (no GSI to page over), so the
2669
+ * bulk states are `seen` and `read`.
2670
+ *
2671
+ * Prefer `markAllRead()` unless the caller needs to own the paging.
2672
+ *
2673
+ * @example
2674
+ * let page = await sv.notify.markAllState({ state: 'seen' });
2675
+ * while (page.cursor) page = await sv.notify.markAllState({ state: 'seen', cursor: page.cursor });
2676
+ */
2677
+ markAllState(options: MarkAllNotificationsStateOptions): Promise<MarkAllNotificationsStateResponse>;
2678
+ /**
2679
+ * Drain the caller's whole inbox to read: loop `markAllState` on the returned
2680
+ * cursor until it comes back null, and return the total marked. Marking read
2681
+ * clears the unseen marker too, so the badge zeroes with it. Idempotent.
2682
+ *
2683
+ * `complete` is false when the loop stopped at the page bound with rows still
2684
+ * unmarked — an inbox deeper than the bound finishes on a second call. Without
2685
+ * it a truncated drain looks exactly like a finished one.
2686
+ *
2687
+ * An error mid-drain propagates — the pages already marked stay marked, and a
2688
+ * re-run picks up the remainder.
2689
+ *
2690
+ * @example
2691
+ * let { updated, complete } = await sv.notify.markAllRead();
2692
+ * while (!complete) ({ complete } = await sv.notify.markAllRead());
2693
+ */
2694
+ markAllRead(): Promise<MarkAllReadResult>;
2039
2695
  /**
2040
2696
  * Whether this environment can do Web Push (service worker + Push API +
2041
2697
  * Notifications). Feature-detect before showing an enable-notifications UI.
@@ -2196,5 +2852,5 @@ declare global {
2196
2852
  }
2197
2853
  }
2198
2854
 
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 };
2855
+ 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 };
2856
+ 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 };