@sparkvault/sdk-js 15.10.0 → 15.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Namespace for SparkVault first-party products. Each product is a
5
5
  * self-contained surface (UI + API) the account can enable independently.
6
- * Identity, Notify, and the customer-facing Help Desk attach here.
6
+ * Identity, Notify, customer-facing Help Desk, Structured Ingots, and the
7
+ * pre-launch Messaging business API attach here.
7
8
  */
8
9
  import type { ResolvedConfig } from '../config';
9
10
  import { HttpClient } from '../http';
@@ -11,6 +12,7 @@ import { IdentityModule } from './identity';
11
12
  import { NotifyProductModule } from './notify';
12
13
  import { HelpDeskModule } from './help-desk';
13
14
  import { StructuredIngotsModule } from './structured-ingots';
15
+ import { MessagingModule } from './messaging';
14
16
  export declare class ProductsModule {
15
17
  /** Identity verification product (passkey, OTP, SparkLink, social). */
16
18
  readonly identity: IdentityModule;
@@ -24,6 +26,8 @@ export declare class ProductsModule {
24
26
  readonly helpDesk: HelpDeskModule;
25
27
  /** Encrypted structured records, optional types, and retained object history. */
26
28
  readonly structuredIngots: StructuredIngotsModule;
29
+ /** Authenticated business API for pre-launch Messaging; no recipient widget. */
30
+ readonly messaging: MessagingModule;
27
31
  /**
28
32
  * `http` defaults to a client over the same resolved config so constructing
29
33
  * this module standalone stays a one-argument call.
@@ -34,6 +38,8 @@ export { IdentityModule } from './identity';
34
38
  export { NotifyProductModule, NotifyProjectsModule, NOTIFY_PRESETS, buildNotifyPresetSend } from './notify';
35
39
  export { HelpDeskModule, HelpDeskClient } from './help-desk';
36
40
  export { StructuredIngotsModule, StructuredIngotTypesModule } from './structured-ingots';
41
+ export { MessagingModule } from './messaging';
42
+ export type * from './messaging/types';
37
43
  export type * from './structured-ingots/types';
38
44
  export type * from './help-desk/types';
39
45
  export type * from './help-desk/form-types';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Business-side Messaging operations using the caller's Core JWT or API key.
3
+ * Core brokers the keys and returns plaintext reads; this is not end-to-end
4
+ * encryption. No recipient login, DOM widget, polling or message cache lives here.
5
+ */
6
+ import { HttpClient } from '../../http';
7
+ import type { CreateMessagingConversationOptions, InitiateMessagingAttachmentOptions, ListMessagingInboxOptions, MessagingAttachmentDownload, MessagingAttachmentUpload, MessagingConversation, MessagingConversationCreated, MessagingInboxPage, MessagingInviteResult, MessagingParticipant, MessagingParticipantInput, MessagingReadResult, MessagingReceiptToken, MessagingRecipientIdentity, MessagingSendResult, ReadMessagingConversationOptions, SendMessagingMessageOptions } from './types';
8
+ /** Stateless, authenticated business API for the pre-launch Messaging product. */
9
+ export declare class MessagingModule {
10
+ private readonly http;
11
+ constructor(http: HttpClient);
12
+ /** Follow cursor even when a page contains fewer than limit conversations. */
13
+ getInbox(options?: ListMessagingInboxOptions): Promise<MessagingInboxPage>;
14
+ /** Create with business members; invite account-less recipients separately. */
15
+ createConversation(options?: CreateMessagingConversationOptions): Promise<MessagingConversationCreated>;
16
+ getConversation(conversationId: string): Promise<MessagingConversation>;
17
+ /** Sends are never retried automatically: Core allocates a new id per send. */
18
+ send(conversationId: string, options: SendMessagingMessageOptions): Promise<MessagingSendResult>;
19
+ /** Fresh read each time, including recalls and newly resolved gaps at old ids. */
20
+ read(conversationId: string, options?: ReadMessagingConversationOptions): Promise<MessagingReadResult>;
21
+ markRead(conversationId: string, lastReadId: number): Promise<void>;
22
+ archive(conversationId: string, archived?: boolean): Promise<void>;
23
+ invite(conversationId: string, identity: MessagingRecipientIdentity): Promise<MessagingInviteResult>;
24
+ addParticipant(conversationId: string, input: MessagingParticipantInput): Promise<MessagingParticipant[]>;
25
+ removeParticipant(conversationId: string, svid: string): Promise<MessagingParticipant[]>;
26
+ recall(conversationId: string, messageId: number): Promise<void>;
27
+ getReceipt(conversationId: string, messageId: number): Promise<MessagingReceiptToken>;
28
+ /** Owner-only; a closed conversation refuses new sends. */
29
+ close(conversationId: string, closed?: boolean): Promise<void>;
30
+ /** Stores the caller's preference; Core currently does not gate sends on it. */
31
+ setOptOut(conversationId: string, optedOut: boolean): Promise<void>;
32
+ /** Owner-only; legal hold prevents recall, not account deletion. */
33
+ setLegalHold(conversationId: string, held: boolean): Promise<void>;
34
+ /** Returns transfer metadata only; no account credential is sent to Forge. */
35
+ initiateAttachmentUpload(conversationId: string, options: InitiateMessagingAttachmentOptions): Promise<MessagingAttachmentUpload>;
36
+ getAttachmentDownload(conversationId: string, ingotId: string): Promise<MessagingAttachmentDownload>;
37
+ }
38
+ export type * from './types';
@@ -0,0 +1,162 @@
1
+ /** The authenticated business API; account-less recipient sign-in is separate. */
2
+ export type MessagingIdentity = string | Record<string, unknown>;
3
+ export interface MessagingParticipant {
4
+ svid: string;
5
+ role: 'owner' | 'member';
6
+ addedAt: number;
7
+ /** Opaque display descriptor, preserved as stored (including user_id/email). */
8
+ identity?: MessagingIdentity;
9
+ optedOut?: boolean;
10
+ }
11
+ export interface MessagingParticipantInput {
12
+ /** Business member principal. Account-less recipients must join by invite. */
13
+ svid: string;
14
+ identity?: MessagingIdentity;
15
+ }
16
+ export interface MessagingConversationSettings {
17
+ /** Audit-row retention and receipt lifetime in seconds; 0 disables both. */
18
+ auditRetentionSeconds?: number;
19
+ }
20
+ export interface CreateMessagingConversationOptions {
21
+ participants?: MessagingParticipantInput[];
22
+ settings?: MessagingConversationSettings;
23
+ }
24
+ export interface MessagingConversationCreated {
25
+ conversationId: string;
26
+ vaultId: string;
27
+ participants: MessagingParticipant[];
28
+ createdAt: number;
29
+ }
30
+ export interface MessagingConversation {
31
+ conversationId: string;
32
+ participants: MessagingParticipant[];
33
+ /** Contiguous durable boundary, not a ceiling for reads. */
34
+ committedThrough: number;
35
+ compactedThrough: number;
36
+ settings: MessagingConversationSettings;
37
+ createdAt: number;
38
+ }
39
+ /** Opaque start key: pass the object from the preceding page back unchanged. */
40
+ export type MessagingInboxCursor = Record<string, string | number>;
41
+ export interface ListMessagingInboxOptions {
42
+ /** Server default 25, capped at 100. */
43
+ limit?: number;
44
+ cursor?: MessagingInboxCursor;
45
+ }
46
+ export interface MessagingInboxEntry {
47
+ conversationId: string;
48
+ accountId: string;
49
+ lastActivityTs: number;
50
+ lastMessageId: number;
51
+ unreadCount: number;
52
+ lastReadId?: number;
53
+ archived: boolean;
54
+ otherParticipants?: unknown;
55
+ }
56
+ export interface MessagingInboxPage {
57
+ conversations: MessagingInboxEntry[];
58
+ /** A short/empty page may still have a continuation. */
59
+ cursor?: MessagingInboxCursor;
60
+ }
61
+ export interface MessagingAttachment {
62
+ ingotId: string;
63
+ /** Display filename sealed in the message, not in the transfer URL. */
64
+ name: string;
65
+ }
66
+ export interface MessagingContentMessage {
67
+ messageId: number;
68
+ schemaVersion: number;
69
+ senderSvid: string;
70
+ senderIdentity: MessagingIdentity;
71
+ /** Epoch seconds. */
72
+ ts: number;
73
+ contentType: string;
74
+ content: string;
75
+ attachments: MessagingAttachment[];
76
+ recalled?: false;
77
+ unavailable?: false;
78
+ }
79
+ export interface MessagingRecalledMessage {
80
+ messageId: number;
81
+ recalled: true;
82
+ unavailable?: false;
83
+ }
84
+ export interface MessagingUnavailableMessage {
85
+ messageId: number;
86
+ unavailable: true;
87
+ recalled?: false;
88
+ }
89
+ /** A gap may become readable on a later read; a recall never carries content. */
90
+ export type MessagingMessage = MessagingContentMessage | MessagingRecalledMessage | MessagingUnavailableMessage;
91
+ export interface ReadMessagingConversationOptions {
92
+ /** Inclusive range; supply both fromId and toId to page through history. */
93
+ fromId?: number;
94
+ toId?: number;
95
+ /** Newest-page size when no range is supplied; server default 25, cap 50. */
96
+ limit?: number;
97
+ }
98
+ export interface MessagingReadResult {
99
+ messages: MessagingMessage[];
100
+ committedThrough: number;
101
+ compactedThrough: number;
102
+ }
103
+ export interface SendMessagingMessageOptions {
104
+ /** Non-empty text, at most 64 KiB UTF-8 (enforced by Core). */
105
+ content: string;
106
+ contentType?: 'text/plain';
107
+ /** Completed, live unsent uploads belonging to this sender/conversation. */
108
+ attachments?: MessagingAttachment[];
109
+ }
110
+ export interface MessagingMessageReceipt {
111
+ accountId: string;
112
+ conversationId: string;
113
+ messageId: number;
114
+ senderSvid: string;
115
+ contentHash: string;
116
+ ts: number;
117
+ }
118
+ export interface MessagingSendResult {
119
+ messageId: number;
120
+ conversationId: string;
121
+ ts: number;
122
+ ingotId: string;
123
+ contentHash: string;
124
+ committedThrough: number;
125
+ /** Pending means an earlier allocated id has not been resolved yet. */
126
+ status: 'committed' | 'pending';
127
+ receipt: MessagingMessageReceipt;
128
+ }
129
+ export interface MessagingReceiptToken {
130
+ receiptToken: string;
131
+ expiresAt: number;
132
+ receipt: Omit<MessagingMessageReceipt, 'ts'> & {
133
+ messageTs: number;
134
+ };
135
+ }
136
+ export interface MessagingRecipientIdentity {
137
+ type: 'email' | 'phone';
138
+ value: string;
139
+ }
140
+ export interface MessagingInviteResult {
141
+ svid: string;
142
+ accessUrl: string;
143
+ }
144
+ export interface InitiateMessagingAttachmentOptions {
145
+ sizeBytes: number;
146
+ contentType?: string;
147
+ }
148
+ export interface MessagingAttachmentUpload {
149
+ ingotId: string;
150
+ /** Client-direct upload URL; this method does not transfer bytes. */
151
+ forgeUrl: string;
152
+ expiresAt: number;
153
+ maxBytes: number;
154
+ }
155
+ export interface MessagingAttachmentDownload {
156
+ ingotId: string;
157
+ /** Client-direct download URL; the filename comes from the message. */
158
+ forgeUrl: string;
159
+ expiresAt: number;
160
+ sizeBytes: number;
161
+ contentType: string;
162
+ }