@swarm-tips/client 0.2.4 → 0.2.6
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/README.md +2 -0
- package/SBOM.spdx.json +5 -5
- package/dist/inbox/client.d.ts +79 -0
- package/dist/inbox/client.js +32 -0
- package/dist/inbox/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,3 +22,5 @@ tools. Browser entrypoints do not depend on Node built-ins or a global Buffer.
|
|
|
22
22
|
|
|
23
23
|
The `/evm` subpath expects the optional `viem` and `wagmi` peers. Install them
|
|
24
24
|
in applications that use EVM wallet helpers; other subpaths do not pull them in.
|
|
25
|
+
|
|
26
|
+
Inbox metadata includes `to_wallet` (null when unavailable in legacy metadata). `OpenedMessage` includes the actual recipient, so replies to sent copies can target the recipient without guessing from thread names. Opening and replying never acknowledge messages.
|
package/SBOM.spdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"spdxVersion": "SPDX-2.3",
|
|
3
3
|
"dataLicense": "CC0-1.0",
|
|
4
4
|
"SPDXID": "SPDXRef-DOCUMENT",
|
|
5
|
-
"name": "@swarm-tips/client-0.2.
|
|
6
|
-
"documentNamespace": "https://swarm.tips/sbom/client/0.2.
|
|
5
|
+
"name": "@swarm-tips/client-0.2.6",
|
|
6
|
+
"documentNamespace": "https://swarm.tips/sbom/client/0.2.6",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-09-
|
|
8
|
+
"created": "2026-09-10T13:43:36.045Z",
|
|
9
9
|
"creators": [
|
|
10
10
|
"Tool: sdk/client/scripts/generate-sbom.mjs",
|
|
11
11
|
"Organization: Swarm Tips"
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
{
|
|
16
16
|
"name": "@swarm-tips/client",
|
|
17
17
|
"SPDXID": "SPDXRef-Package",
|
|
18
|
-
"versionInfo": "0.2.
|
|
19
|
-
"downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.2.
|
|
18
|
+
"versionInfo": "0.2.6",
|
|
19
|
+
"downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.2.6",
|
|
20
20
|
"filesAnalyzed": false,
|
|
21
21
|
"licenseConcluded": "MIT",
|
|
22
22
|
"licenseDeclared": "MIT"
|
package/dist/inbox/client.d.ts
CHANGED
|
@@ -46,6 +46,75 @@ export interface InboxMessage {
|
|
|
46
46
|
* inbound-only reads (treat as "received"). */
|
|
47
47
|
direction?: "received" | "sent";
|
|
48
48
|
}
|
|
49
|
+
export interface MessageReference {
|
|
50
|
+
msg_id: string;
|
|
51
|
+
direction?: "received" | "sent";
|
|
52
|
+
}
|
|
53
|
+
export interface MessageEnvelope {
|
|
54
|
+
/** Stored recipient; null for legacy metadata without a recipient. */
|
|
55
|
+
to_wallet: string | null;
|
|
56
|
+
msg_id: string;
|
|
57
|
+
direction: "received" | "sent";
|
|
58
|
+
from_wallet: string;
|
|
59
|
+
sent_at: string;
|
|
60
|
+
/** Inbox messages do not expire. */
|
|
61
|
+
expires_at: null;
|
|
62
|
+
body_bytes: number;
|
|
63
|
+
intent: "game_invite" | "task_offer" | "task_clarification" | null;
|
|
64
|
+
/** Stable mailbox-local grouping label, not a threadId filter. */
|
|
65
|
+
thread_ref: string;
|
|
66
|
+
acknowledged: boolean | null;
|
|
67
|
+
/** Untrusted excerpt; absent unless explicitly requested. */
|
|
68
|
+
preview?: string;
|
|
69
|
+
preview_truncated?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface InboxListOptions {
|
|
72
|
+
cursor?: string;
|
|
73
|
+
limit?: number;
|
|
74
|
+
threadId?: string;
|
|
75
|
+
minTrust?: number;
|
|
76
|
+
status?: "pending" | "all";
|
|
77
|
+
includeSent?: boolean;
|
|
78
|
+
preview?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface InboxListPage {
|
|
81
|
+
messages: MessageEnvelope[];
|
|
82
|
+
count: number;
|
|
83
|
+
/** Continue even when messages is empty. */
|
|
84
|
+
next_cursor: string | null;
|
|
85
|
+
filtered_acknowledged: number;
|
|
86
|
+
filtered_muted: number;
|
|
87
|
+
filtered_below_min_trust: number;
|
|
88
|
+
}
|
|
89
|
+
export type OpenedMessage = InboxMessage & Omit<MessageEnvelope, "acknowledged" | "to_wallet"> & {
|
|
90
|
+
/** Actual recipient of this message, including sent mirror copies. */
|
|
91
|
+
to_wallet: string;
|
|
92
|
+
};
|
|
93
|
+
export type OpenMessageResult = {
|
|
94
|
+
msg_id: string;
|
|
95
|
+
direction: "received" | "sent";
|
|
96
|
+
status: "opened";
|
|
97
|
+
message: OpenedMessage;
|
|
98
|
+
} | {
|
|
99
|
+
msg_id: string;
|
|
100
|
+
direction: "received" | "sent";
|
|
101
|
+
status: "unavailable";
|
|
102
|
+
} | {
|
|
103
|
+
msg_id: string;
|
|
104
|
+
direction: "received" | "sent";
|
|
105
|
+
status: "error";
|
|
106
|
+
error: "storage_error";
|
|
107
|
+
};
|
|
108
|
+
export type AckMessageResult = {
|
|
109
|
+
msg_id: string;
|
|
110
|
+
direction: "received";
|
|
111
|
+
status: "acknowledged" | "unavailable";
|
|
112
|
+
} | {
|
|
113
|
+
msg_id: string;
|
|
114
|
+
direction: "received";
|
|
115
|
+
status: "error";
|
|
116
|
+
error: "storage_error";
|
|
117
|
+
};
|
|
49
118
|
export interface MessagePage {
|
|
50
119
|
messages: InboxMessage[];
|
|
51
120
|
next_cursor: string | null;
|
|
@@ -145,6 +214,16 @@ export declare class InboxClient {
|
|
|
145
214
|
* `direction:"sent"`. */
|
|
146
215
|
includeSent?: boolean;
|
|
147
216
|
}): Promise<MessagePage>;
|
|
217
|
+
/** Metadata first; listing never acknowledges. Old bulk status is independent. */
|
|
218
|
+
listMessages(opts?: InboxListOptions): Promise<InboxListPage>;
|
|
219
|
+
/** Load only selected bodies. This never acknowledges or follows message links. */
|
|
220
|
+
openMessages(messages: MessageReference[]): Promise<{
|
|
221
|
+
results: OpenMessageResult[];
|
|
222
|
+
}>;
|
|
223
|
+
/** Mark only these received IDs handled/dismissed. Per-ID errors can be retried. */
|
|
224
|
+
ackMessageIds(messageIds: string[]): Promise<{
|
|
225
|
+
results: AckMessageResult[];
|
|
226
|
+
}>;
|
|
148
227
|
/** Read one thread (e.g. `task:{task_id}` / `game:{id}`), newest first. Pass
|
|
149
228
|
* `includeSent` to fold in the connected wallet's own replies (full
|
|
150
229
|
* two-way conversation). */
|
package/dist/inbox/client.js
CHANGED
|
@@ -145,6 +145,32 @@ export class InboxClient {
|
|
|
145
145
|
next_cursor: page.next_cursor ?? null,
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
+
/** Metadata first; listing never acknowledges. Old bulk status is independent. */
|
|
149
|
+
async listMessages(opts = {}) {
|
|
150
|
+
if (opts.includeSent && opts.status !== "all")
|
|
151
|
+
throw new InboxApiError(0, "includeSent requires status=all");
|
|
152
|
+
if (opts.limit !== undefined && (!Number.isInteger(opts.limit) || opts.limit < 1 || opts.limit > 50))
|
|
153
|
+
throw new InboxApiError(0, "limit must be in 1..50");
|
|
154
|
+
if (opts.minTrust !== undefined && (!Number.isFinite(opts.minTrust) || opts.minTrust < 0 || opts.minTrust > 1))
|
|
155
|
+
throw new InboxApiError(0, "minTrust must be in [0,1]");
|
|
156
|
+
const query = new URLSearchParams();
|
|
157
|
+
for (const [key, value] of Object.entries({ cursor: opts.cursor, limit: opts.limit, thread_id: opts.threadId, min_trust: opts.minTrust, status: opts.status, include_sent: opts.includeSent, preview: opts.preview })) {
|
|
158
|
+
if (value !== undefined)
|
|
159
|
+
query.set(key, String(value));
|
|
160
|
+
}
|
|
161
|
+
const suffix = query.toString();
|
|
162
|
+
return this.authed(`/internal/inbox/list${suffix ? `?${suffix}` : ""}`, { method: "GET" });
|
|
163
|
+
}
|
|
164
|
+
/** Load only selected bodies. This never acknowledges or follows message links. */
|
|
165
|
+
async openMessages(messages) {
|
|
166
|
+
validateSelectedIds(messages.map(m => m.msg_id));
|
|
167
|
+
return this.authed("/internal/inbox/open", { method: "POST", body: JSON.stringify({ messages }) });
|
|
168
|
+
}
|
|
169
|
+
/** Mark only these received IDs handled/dismissed. Per-ID errors can be retried. */
|
|
170
|
+
async ackMessageIds(messageIds) {
|
|
171
|
+
validateSelectedIds(messageIds);
|
|
172
|
+
return this.authed("/internal/inbox/ack-ids", { method: "POST", body: JSON.stringify({ message_ids: messageIds }) });
|
|
173
|
+
}
|
|
148
174
|
/** Read one thread (e.g. `task:{task_id}` / `game:{id}`), newest first. Pass
|
|
149
175
|
* `includeSent` to fold in the connected wallet's own replies (full
|
|
150
176
|
* two-way conversation). */
|
|
@@ -332,3 +358,9 @@ export class InboxClient {
|
|
|
332
358
|
}
|
|
333
359
|
}
|
|
334
360
|
}
|
|
361
|
+
function validateSelectedIds(ids) {
|
|
362
|
+
if (ids.length < 1 || ids.length > 50)
|
|
363
|
+
throw new InboxApiError(0, "select 1..50 message IDs");
|
|
364
|
+
if (ids.some(id => !/^\d{20}_[0-9a-fA-F]{8}$/.test(id)))
|
|
365
|
+
throw new InboxApiError(0, "msg_id must be a server-issued message ID");
|
|
366
|
+
}
|
package/dist/inbox/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { InboxClient, InboxApiError, type InboxClientOpts, type InboxMessage, type InboxSession, type MessagePage, type NonceSigner, type SendReceipt, type TopicId, type TopicPost, type TopicPage, type PublishReceipt, type ReportReceipt, } from "./client.js";
|
|
1
|
+
export { InboxClient, InboxApiError, type InboxClientOpts, type InboxMessage, type MessageReference, type MessageEnvelope, type InboxListOptions, type InboxListPage, type OpenMessageResult, type OpenedMessage, type AckMessageResult, type InboxSession, type MessagePage, type NonceSigner, type SendReceipt, type TopicId, type TopicPost, type TopicPage, type PublishReceipt, type ReportReceipt, } from "./client.js";
|
|
2
2
|
export { solanaNonceSigner } from "./solana.js";
|