@xmtp/node-bindings 0.0.17 → 0.0.18
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 +7 -9
- package/dist/bindings_node.darwin-arm64.node +0 -0
- package/dist/bindings_node.darwin-x64.node +0 -0
- package/dist/bindings_node.linux-arm64-gnu.node +0 -0
- package/dist/bindings_node.linux-arm64-musl.node +0 -0
- package/dist/bindings_node.linux-x64-gnu.node +0 -0
- package/dist/bindings_node.linux-x64-musl.node +0 -0
- package/dist/bindings_node.win32-x64-msvc.node +0 -0
- package/dist/index.d.ts +43 -23
- package/dist/index.js +31 -25
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
# Node bindings for the
|
|
1
|
+
# Node bindings for the libXMTP rust library
|
|
2
2
|
|
|
3
|
-
>
|
|
4
|
-
> These bindings are currently in
|
|
3
|
+
> [!CAUTION]
|
|
4
|
+
> These bindings are currently in alpha and under heavy development. The API is subject to change and it is not yet recommended for production use.
|
|
5
5
|
|
|
6
6
|
## Useful commands
|
|
7
7
|
|
|
8
8
|
- `yarn`: Installs all dependencies (required before building)
|
|
9
|
-
- `yarn build
|
|
9
|
+
- `yarn build`: Build a release version of the Node bindings for the current platform
|
|
10
|
+
- `yarn lint`: Run cargo clippy and fmt checks
|
|
11
|
+
- `yarn test`: Run the test suite on Node
|
|
10
12
|
|
|
11
13
|
## Testing
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Test users are available as exports in `users.mjs`. To register all users on the network, run the `setup.mjs` script.
|
|
16
|
-
|
|
17
|
-
Before running any of the test scripts, a local XMTP node must be running. This can be achieved by running `./dev/up` at the root of this repository.
|
|
15
|
+
Before running the test suite, a local XMTP node must be running. This can be achieved by running `./dev/up` at the root of this repository. Docker is required.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export class Client {
|
|
3
|
+
export declare class Client {
|
|
4
4
|
accountAddress: string
|
|
5
5
|
inboxId(): string
|
|
6
6
|
isRegistered(): boolean
|
|
@@ -27,10 +27,11 @@ export class Client {
|
|
|
27
27
|
revokeWalletSignatureText(walletAddress: string): Promise<string>
|
|
28
28
|
revokeInstallationsSignatureText(): Promise<string>
|
|
29
29
|
addSignature(signatureType: SignatureRequestType, signatureBytes: Uint8Array): Promise<void>
|
|
30
|
+
addScwSignature(signatureType: SignatureRequestType, signatureBytes: Uint8Array, chainId: bigint, blockNumber?: bigint | undefined | null): Promise<void>
|
|
30
31
|
applySignatureRequests(): Promise<void>
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export class Conversation {
|
|
34
|
+
export declare class Conversation {
|
|
34
35
|
id(): string
|
|
35
36
|
send(encodedContent: EncodedContent): Promise<string>
|
|
36
37
|
sendOptimistic(encodedContent: EncodedContent): string
|
|
@@ -70,7 +71,7 @@ export class Conversation {
|
|
|
70
71
|
dmPeerInboxId(): string
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
export class Conversations {
|
|
74
|
+
export declare class Conversations {
|
|
74
75
|
createGroup(accountAddresses: Array<string>, options?: CreateGroupOptions | undefined | null): Promise<Conversation>
|
|
75
76
|
createDm(accountAddress: string): Promise<Conversation>
|
|
76
77
|
findGroupById(groupId: string): Conversation
|
|
@@ -89,7 +90,7 @@ export class Conversations {
|
|
|
89
90
|
streamAllDmMessages(callback: (err: null | Error, result: Message | undefined) => void): StreamCloser
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
export class GroupMember {
|
|
93
|
+
export declare class GroupMember {
|
|
93
94
|
inboxId: string
|
|
94
95
|
accountAddresses: Array<string>
|
|
95
96
|
installationIds: Array<string>
|
|
@@ -97,17 +98,17 @@ export class GroupMember {
|
|
|
97
98
|
consentState: ConsentState
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
export class GroupMetadata {
|
|
101
|
+
export declare class GroupMetadata {
|
|
101
102
|
creatorInboxId(): string
|
|
102
103
|
conversationType(): string
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
export class GroupPermissions {
|
|
106
|
+
export declare class GroupPermissions {
|
|
106
107
|
policyType(): GroupPermissionsOptions
|
|
107
108
|
policySet(): PermissionPolicySet
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
export class StreamCloser {
|
|
111
|
+
export declare class StreamCloser {
|
|
111
112
|
/**
|
|
112
113
|
* Signal the stream to end
|
|
113
114
|
* Does not wait for the stream to end.
|
|
@@ -129,13 +130,13 @@ export interface Consent {
|
|
|
129
130
|
entity: string
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
export const enum ConsentEntityType {
|
|
133
|
+
export declare const enum ConsentEntityType {
|
|
133
134
|
GroupId = 0,
|
|
134
135
|
InboxId = 1,
|
|
135
136
|
Address = 2
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
export const enum ConsentState {
|
|
139
|
+
export declare const enum ConsentState {
|
|
139
140
|
Unknown = 0,
|
|
140
141
|
Allowed = 1,
|
|
141
142
|
Denied = 2
|
|
@@ -148,7 +149,7 @@ export interface ContentTypeId {
|
|
|
148
149
|
versionMinor: number
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
export const enum ConversationType {
|
|
152
|
+
export declare const enum ConversationType {
|
|
152
153
|
Dm = 0,
|
|
153
154
|
Group = 1,
|
|
154
155
|
Sync = 2
|
|
@@ -161,7 +162,7 @@ export const enum ConversationType {
|
|
|
161
162
|
* It can be one of: `debug`, `info`, `warn`, `error` or 'off'.
|
|
162
163
|
* By default, logging is disabled.
|
|
163
164
|
*/
|
|
164
|
-
export declare function createClient(host: string, isSecure: boolean, dbPath: string, inboxId: string, accountAddress: string, encryptionKey?: Uint8Array | undefined | null, historySyncUrl?: string | undefined | null,
|
|
165
|
+
export declare export declare function createClient(host: string, isSecure: boolean, dbPath: string, inboxId: string, accountAddress: string, encryptionKey?: Uint8Array | undefined | null, historySyncUrl?: string | undefined | null, logOptions?: LogOptions | undefined | null): Promise<Client>
|
|
165
166
|
|
|
166
167
|
export interface CreateGroupOptions {
|
|
167
168
|
permissions?: GroupPermissionsOptions
|
|
@@ -171,7 +172,7 @@ export interface CreateGroupOptions {
|
|
|
171
172
|
groupPinnedFrameUrl?: string
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
export const enum DeliveryStatus {
|
|
175
|
+
export declare const enum DeliveryStatus {
|
|
175
176
|
Unpublished = 0,
|
|
176
177
|
Published = 1,
|
|
177
178
|
Failed = 2
|
|
@@ -185,22 +186,22 @@ export interface EncodedContent {
|
|
|
185
186
|
content: Uint8Array
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
export declare function generateInboxId(accountAddress: string): string
|
|
189
|
+
export declare export declare function generateInboxId(accountAddress: string): string
|
|
189
190
|
|
|
190
|
-
export declare function getInboxIdForAddress(host: string, isSecure: boolean, accountAddress: string): Promise<string | null>
|
|
191
|
+
export declare export declare function getInboxIdForAddress(host: string, isSecure: boolean, accountAddress: string): Promise<string | null>
|
|
191
192
|
|
|
192
|
-
export const enum GroupMembershipState {
|
|
193
|
+
export declare const enum GroupMembershipState {
|
|
193
194
|
Allowed = 0,
|
|
194
195
|
Rejected = 1,
|
|
195
196
|
Pending = 2
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
export const enum GroupMessageKind {
|
|
199
|
+
export declare const enum GroupMessageKind {
|
|
199
200
|
Application = 0,
|
|
200
201
|
MembershipChange = 1
|
|
201
202
|
}
|
|
202
203
|
|
|
203
|
-
export const enum GroupPermissionsOptions {
|
|
204
|
+
export declare const enum GroupPermissionsOptions {
|
|
204
205
|
AllMembers = 0,
|
|
205
206
|
AdminOnly = 1,
|
|
206
207
|
CustomPolicy = 2
|
|
@@ -218,6 +219,15 @@ export interface Installation {
|
|
|
218
219
|
clientTimestampNs?: bigint
|
|
219
220
|
}
|
|
220
221
|
|
|
222
|
+
export declare const enum Level {
|
|
223
|
+
off = 'off',
|
|
224
|
+
error = 'error',
|
|
225
|
+
warn = 'warn',
|
|
226
|
+
info = 'info',
|
|
227
|
+
debug = 'debug',
|
|
228
|
+
trace = 'trace'
|
|
229
|
+
}
|
|
230
|
+
|
|
221
231
|
export interface ListConversationsOptions {
|
|
222
232
|
allowedStates?: Array<GroupMembershipState>
|
|
223
233
|
createdAfterNs?: number
|
|
@@ -234,6 +244,17 @@ export interface ListMessagesOptions {
|
|
|
234
244
|
direction?: SortDirection
|
|
235
245
|
}
|
|
236
246
|
|
|
247
|
+
/** Specify options for the logger */
|
|
248
|
+
export interface LogOptions {
|
|
249
|
+
/**
|
|
250
|
+
* enable structured JSON logging to stdout.Useful for third-party log viewers
|
|
251
|
+
* an option so that it does not require being specified in js object.
|
|
252
|
+
*/
|
|
253
|
+
structured?: boolean
|
|
254
|
+
/** Filter logs by level */
|
|
255
|
+
level?: Level
|
|
256
|
+
}
|
|
257
|
+
|
|
237
258
|
export interface Message {
|
|
238
259
|
id: string
|
|
239
260
|
sentAtNs: number
|
|
@@ -244,13 +265,13 @@ export interface Message {
|
|
|
244
265
|
deliveryStatus: DeliveryStatus
|
|
245
266
|
}
|
|
246
267
|
|
|
247
|
-
export const enum PermissionLevel {
|
|
268
|
+
export declare const enum PermissionLevel {
|
|
248
269
|
Member = 0,
|
|
249
270
|
Admin = 1,
|
|
250
271
|
SuperAdmin = 2
|
|
251
272
|
}
|
|
252
273
|
|
|
253
|
-
export const enum PermissionPolicy {
|
|
274
|
+
export declare const enum PermissionPolicy {
|
|
254
275
|
Allow = 0,
|
|
255
276
|
Deny = 1,
|
|
256
277
|
Admin = 2,
|
|
@@ -270,7 +291,7 @@ export interface PermissionPolicySet {
|
|
|
270
291
|
updateGroupPinnedFrameUrlPolicy: PermissionPolicy
|
|
271
292
|
}
|
|
272
293
|
|
|
273
|
-
export const enum PermissionUpdateType {
|
|
294
|
+
export declare const enum PermissionUpdateType {
|
|
274
295
|
AddMember = 0,
|
|
275
296
|
RemoveMember = 1,
|
|
276
297
|
AddAdmin = 2,
|
|
@@ -278,15 +299,14 @@ export const enum PermissionUpdateType {
|
|
|
278
299
|
UpdateMetadata = 4
|
|
279
300
|
}
|
|
280
301
|
|
|
281
|
-
export const enum SignatureRequestType {
|
|
302
|
+
export declare const enum SignatureRequestType {
|
|
282
303
|
AddWallet = 0,
|
|
283
304
|
CreateInbox = 1,
|
|
284
305
|
RevokeWallet = 2,
|
|
285
306
|
RevokeInstallations = 3
|
|
286
307
|
}
|
|
287
308
|
|
|
288
|
-
export const enum SortDirection {
|
|
309
|
+
export declare const enum SortDirection {
|
|
289
310
|
Ascending = 0,
|
|
290
311
|
Descending = 1
|
|
291
312
|
}
|
|
292
|
-
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// prettier-ignore
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
3
4
|
/* auto-generated by NAPI-RS */
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
import { createRequire } from 'node:module'
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
const __dirname = new URL('.', import.meta.url).pathname
|
|
6
9
|
|
|
10
|
+
const { readFileSync } = require('node:fs')
|
|
7
11
|
let nativeBinding = null
|
|
8
12
|
const loadErrors = []
|
|
9
13
|
|
|
@@ -336,7 +340,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
336
340
|
nativeBinding = require('./bindings_node.wasi.cjs')
|
|
337
341
|
} catch (err) {
|
|
338
342
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
339
|
-
|
|
343
|
+
loadErrors.push(err)
|
|
340
344
|
}
|
|
341
345
|
}
|
|
342
346
|
if (!nativeBinding) {
|
|
@@ -344,7 +348,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
344
348
|
nativeBinding = require('@xmtp/node-bindings-wasm32-wasi')
|
|
345
349
|
} catch (err) {
|
|
346
350
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
347
|
-
|
|
351
|
+
loadErrors.push(err)
|
|
348
352
|
}
|
|
349
353
|
}
|
|
350
354
|
}
|
|
@@ -361,25 +365,27 @@ if (!nativeBinding) {
|
|
|
361
365
|
throw new Error(`Failed to load native binding`)
|
|
362
366
|
}
|
|
363
367
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
368
|
+
const { Client, Conversation, Conversations, GroupMember, GroupMetadata, GroupPermissions, StreamCloser, ConsentEntityType, ConsentState, ConversationType, createClient, DeliveryStatus, generateInboxId, getInboxIdForAddress, GroupMembershipState, GroupMessageKind, GroupPermissionsOptions, Level, PermissionLevel, PermissionPolicy, PermissionUpdateType, SignatureRequestType, SortDirection } = nativeBinding
|
|
369
|
+
export { Client }
|
|
370
|
+
export { Conversation }
|
|
371
|
+
export { Conversations }
|
|
372
|
+
export { GroupMember }
|
|
373
|
+
export { GroupMetadata }
|
|
374
|
+
export { GroupPermissions }
|
|
375
|
+
export { StreamCloser }
|
|
376
|
+
export { ConsentEntityType }
|
|
377
|
+
export { ConsentState }
|
|
378
|
+
export { ConversationType }
|
|
379
|
+
export { createClient }
|
|
380
|
+
export { DeliveryStatus }
|
|
381
|
+
export { generateInboxId }
|
|
382
|
+
export { getInboxIdForAddress }
|
|
383
|
+
export { GroupMembershipState }
|
|
384
|
+
export { GroupMessageKind }
|
|
385
|
+
export { GroupPermissionsOptions }
|
|
386
|
+
export { Level }
|
|
387
|
+
export { PermissionLevel }
|
|
388
|
+
export { PermissionPolicy }
|
|
389
|
+
export { PermissionUpdateType }
|
|
390
|
+
export { SignatureRequestType }
|
|
391
|
+
export { SortDirection }
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmtp/node-bindings",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://git@github.com/xmtp/libxmtp.git",
|
|
7
7
|
"directory": "bindings_node"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
13
|
"types": "./dist/index.d.ts",
|
|
@@ -22,9 +23,9 @@
|
|
|
22
23
|
"artifacts": "napi artifacts",
|
|
23
24
|
"build": "yarn build:clean && yarn build:release && yarn build:finish",
|
|
24
25
|
"build:clean": "rm -rf dist",
|
|
25
|
-
"build:debug": "napi build --platform",
|
|
26
|
+
"build:debug": "napi build --platform --esm",
|
|
26
27
|
"build:finish": "mkdir dist && mv index.js dist && mv index.d.ts dist && mv *.node dist",
|
|
27
|
-
"build:release": "napi build --platform --release",
|
|
28
|
+
"build:release": "napi build --platform --release --esm",
|
|
28
29
|
"clean": "yarn build:clean && yarn test:clean",
|
|
29
30
|
"format": "prettier -w .",
|
|
30
31
|
"format:check": "prettier -c .",
|
|
@@ -36,16 +37,16 @@
|
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
|
|
39
|
-
"@napi-rs/cli": "^3.0.0-alpha.
|
|
40
|
+
"@napi-rs/cli": "^3.0.0-alpha.64",
|
|
40
41
|
"@types/node": "^20.17.6",
|
|
41
42
|
"@types/uuid": "^10.0.0",
|
|
42
43
|
"prettier": "^3.3.3",
|
|
43
44
|
"prettier-plugin-packagejson": "^2.5.3",
|
|
44
45
|
"typescript": "^5.6.3",
|
|
45
|
-
"uuid": "^11.0.
|
|
46
|
-
"viem": "^2.21.
|
|
47
|
-
"vite": "^5.4.
|
|
48
|
-
"vite-tsconfig-paths": "^5.1.
|
|
46
|
+
"uuid": "^11.0.3",
|
|
47
|
+
"viem": "^2.21.44",
|
|
48
|
+
"vite": "^5.4.11",
|
|
49
|
+
"vite-tsconfig-paths": "^5.1.2",
|
|
49
50
|
"vitest": "^2.1.4"
|
|
50
51
|
},
|
|
51
52
|
"packageManager": "yarn@4.5.1",
|