@xmtp/node-bindings 0.0.17 → 0.0.19
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 +47 -23
- package/dist/index.js +31 -25
- package/package.json +11 -10
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
|
|
@@ -12,6 +12,9 @@ export class Client {
|
|
|
12
12
|
sendConsentSyncRequest(): Promise<void>
|
|
13
13
|
findInboxIdByAddress(address: string): Promise<string | null>
|
|
14
14
|
addressesFromInboxId(refreshFromNetwork: boolean, inboxIds: Array<string>): Promise<Array<InboxState>>
|
|
15
|
+
signWithInstallationKey(text: string): Array<number>
|
|
16
|
+
verifySignedWithInstallationKey(signatureText: string, signatureBytes: Array<number>): void
|
|
17
|
+
verifySignedWithPublicKey(signatureText: string, signatureBytes: Array<number>, publicKey: Array<number>): void
|
|
15
18
|
setConsentStates(records: Array<Consent>): Promise<void>
|
|
16
19
|
getConsentState(entityType: ConsentEntityType, entity: string): Promise<ConsentState>
|
|
17
20
|
/**
|
|
@@ -27,10 +30,11 @@ export class Client {
|
|
|
27
30
|
revokeWalletSignatureText(walletAddress: string): Promise<string>
|
|
28
31
|
revokeInstallationsSignatureText(): Promise<string>
|
|
29
32
|
addSignature(signatureType: SignatureRequestType, signatureBytes: Uint8Array): Promise<void>
|
|
33
|
+
addScwSignature(signatureType: SignatureRequestType, signatureBytes: Uint8Array, chainId: bigint, blockNumber?: bigint | undefined | null): Promise<void>
|
|
30
34
|
applySignatureRequests(): Promise<void>
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
export class Conversation {
|
|
37
|
+
export declare class Conversation {
|
|
34
38
|
id(): string
|
|
35
39
|
send(encodedContent: EncodedContent): Promise<string>
|
|
36
40
|
sendOptimistic(encodedContent: EncodedContent): string
|
|
@@ -70,7 +74,7 @@ export class Conversation {
|
|
|
70
74
|
dmPeerInboxId(): string
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
export class Conversations {
|
|
77
|
+
export declare class Conversations {
|
|
74
78
|
createGroup(accountAddresses: Array<string>, options?: CreateGroupOptions | undefined | null): Promise<Conversation>
|
|
75
79
|
createDm(accountAddress: string): Promise<Conversation>
|
|
76
80
|
findGroupById(groupId: string): Conversation
|
|
@@ -78,6 +82,7 @@ export class Conversations {
|
|
|
78
82
|
findMessageById(messageId: string): Message
|
|
79
83
|
processStreamedWelcomeMessage(envelopeBytes: Uint8Array): Promise<Conversation>
|
|
80
84
|
sync(): Promise<void>
|
|
85
|
+
syncAllConversations(): Promise<bigint>
|
|
81
86
|
list(opts?: ListConversationsOptions | undefined | null): Promise<Array<Conversation>>
|
|
82
87
|
listGroups(opts?: ListConversationsOptions | undefined | null): Promise<Array<Conversation>>
|
|
83
88
|
listDms(opts?: ListConversationsOptions | undefined | null): Promise<Array<Conversation>>
|
|
@@ -89,7 +94,7 @@ export class Conversations {
|
|
|
89
94
|
streamAllDmMessages(callback: (err: null | Error, result: Message | undefined) => void): StreamCloser
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
export class GroupMember {
|
|
97
|
+
export declare class GroupMember {
|
|
93
98
|
inboxId: string
|
|
94
99
|
accountAddresses: Array<string>
|
|
95
100
|
installationIds: Array<string>
|
|
@@ -97,17 +102,17 @@ export class GroupMember {
|
|
|
97
102
|
consentState: ConsentState
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
export class GroupMetadata {
|
|
105
|
+
export declare class GroupMetadata {
|
|
101
106
|
creatorInboxId(): string
|
|
102
107
|
conversationType(): string
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
export class GroupPermissions {
|
|
110
|
+
export declare class GroupPermissions {
|
|
106
111
|
policyType(): GroupPermissionsOptions
|
|
107
112
|
policySet(): PermissionPolicySet
|
|
108
113
|
}
|
|
109
114
|
|
|
110
|
-
export class StreamCloser {
|
|
115
|
+
export declare class StreamCloser {
|
|
111
116
|
/**
|
|
112
117
|
* Signal the stream to end
|
|
113
118
|
* Does not wait for the stream to end.
|
|
@@ -129,13 +134,13 @@ export interface Consent {
|
|
|
129
134
|
entity: string
|
|
130
135
|
}
|
|
131
136
|
|
|
132
|
-
export const enum ConsentEntityType {
|
|
137
|
+
export declare const enum ConsentEntityType {
|
|
133
138
|
GroupId = 0,
|
|
134
139
|
InboxId = 1,
|
|
135
140
|
Address = 2
|
|
136
141
|
}
|
|
137
142
|
|
|
138
|
-
export const enum ConsentState {
|
|
143
|
+
export declare const enum ConsentState {
|
|
139
144
|
Unknown = 0,
|
|
140
145
|
Allowed = 1,
|
|
141
146
|
Denied = 2
|
|
@@ -148,7 +153,7 @@ export interface ContentTypeId {
|
|
|
148
153
|
versionMinor: number
|
|
149
154
|
}
|
|
150
155
|
|
|
151
|
-
export const enum ConversationType {
|
|
156
|
+
export declare const enum ConversationType {
|
|
152
157
|
Dm = 0,
|
|
153
158
|
Group = 1,
|
|
154
159
|
Sync = 2
|
|
@@ -161,7 +166,7 @@ export const enum ConversationType {
|
|
|
161
166
|
* It can be one of: `debug`, `info`, `warn`, `error` or 'off'.
|
|
162
167
|
* By default, logging is disabled.
|
|
163
168
|
*/
|
|
164
|
-
export declare function createClient(host: string, isSecure: boolean, dbPath: string, inboxId: string, accountAddress: string, encryptionKey?: Uint8Array | undefined | null, historySyncUrl?: string | undefined | null,
|
|
169
|
+
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
170
|
|
|
166
171
|
export interface CreateGroupOptions {
|
|
167
172
|
permissions?: GroupPermissionsOptions
|
|
@@ -171,7 +176,7 @@ export interface CreateGroupOptions {
|
|
|
171
176
|
groupPinnedFrameUrl?: string
|
|
172
177
|
}
|
|
173
178
|
|
|
174
|
-
export const enum DeliveryStatus {
|
|
179
|
+
export declare const enum DeliveryStatus {
|
|
175
180
|
Unpublished = 0,
|
|
176
181
|
Published = 1,
|
|
177
182
|
Failed = 2
|
|
@@ -185,22 +190,22 @@ export interface EncodedContent {
|
|
|
185
190
|
content: Uint8Array
|
|
186
191
|
}
|
|
187
192
|
|
|
188
|
-
export declare function generateInboxId(accountAddress: string): string
|
|
193
|
+
export declare export declare function generateInboxId(accountAddress: string): string
|
|
189
194
|
|
|
190
|
-
export declare function getInboxIdForAddress(host: string, isSecure: boolean, accountAddress: string): Promise<string | null>
|
|
195
|
+
export declare export declare function getInboxIdForAddress(host: string, isSecure: boolean, accountAddress: string): Promise<string | null>
|
|
191
196
|
|
|
192
|
-
export const enum GroupMembershipState {
|
|
197
|
+
export declare const enum GroupMembershipState {
|
|
193
198
|
Allowed = 0,
|
|
194
199
|
Rejected = 1,
|
|
195
200
|
Pending = 2
|
|
196
201
|
}
|
|
197
202
|
|
|
198
|
-
export const enum GroupMessageKind {
|
|
203
|
+
export declare const enum GroupMessageKind {
|
|
199
204
|
Application = 0,
|
|
200
205
|
MembershipChange = 1
|
|
201
206
|
}
|
|
202
207
|
|
|
203
|
-
export const enum GroupPermissionsOptions {
|
|
208
|
+
export declare const enum GroupPermissionsOptions {
|
|
204
209
|
AllMembers = 0,
|
|
205
210
|
AdminOnly = 1,
|
|
206
211
|
CustomPolicy = 2
|
|
@@ -234,6 +239,26 @@ export interface ListMessagesOptions {
|
|
|
234
239
|
direction?: SortDirection
|
|
235
240
|
}
|
|
236
241
|
|
|
242
|
+
export declare const enum LogLevel {
|
|
243
|
+
off = 'off',
|
|
244
|
+
error = 'error',
|
|
245
|
+
warn = 'warn',
|
|
246
|
+
info = 'info',
|
|
247
|
+
debug = 'debug',
|
|
248
|
+
trace = 'trace'
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Specify options for the logger */
|
|
252
|
+
export interface LogOptions {
|
|
253
|
+
/**
|
|
254
|
+
* enable structured JSON logging to stdout.Useful for third-party log viewers
|
|
255
|
+
* an option so that it does not require being specified in js object.
|
|
256
|
+
*/
|
|
257
|
+
structured?: boolean
|
|
258
|
+
/** Filter logs by level */
|
|
259
|
+
level?: LogLevel
|
|
260
|
+
}
|
|
261
|
+
|
|
237
262
|
export interface Message {
|
|
238
263
|
id: string
|
|
239
264
|
sentAtNs: number
|
|
@@ -244,13 +269,13 @@ export interface Message {
|
|
|
244
269
|
deliveryStatus: DeliveryStatus
|
|
245
270
|
}
|
|
246
271
|
|
|
247
|
-
export const enum PermissionLevel {
|
|
272
|
+
export declare const enum PermissionLevel {
|
|
248
273
|
Member = 0,
|
|
249
274
|
Admin = 1,
|
|
250
275
|
SuperAdmin = 2
|
|
251
276
|
}
|
|
252
277
|
|
|
253
|
-
export const enum PermissionPolicy {
|
|
278
|
+
export declare const enum PermissionPolicy {
|
|
254
279
|
Allow = 0,
|
|
255
280
|
Deny = 1,
|
|
256
281
|
Admin = 2,
|
|
@@ -270,7 +295,7 @@ export interface PermissionPolicySet {
|
|
|
270
295
|
updateGroupPinnedFrameUrlPolicy: PermissionPolicy
|
|
271
296
|
}
|
|
272
297
|
|
|
273
|
-
export const enum PermissionUpdateType {
|
|
298
|
+
export declare const enum PermissionUpdateType {
|
|
274
299
|
AddMember = 0,
|
|
275
300
|
RemoveMember = 1,
|
|
276
301
|
AddAdmin = 2,
|
|
@@ -278,15 +303,14 @@ export const enum PermissionUpdateType {
|
|
|
278
303
|
UpdateMetadata = 4
|
|
279
304
|
}
|
|
280
305
|
|
|
281
|
-
export const enum SignatureRequestType {
|
|
306
|
+
export declare const enum SignatureRequestType {
|
|
282
307
|
AddWallet = 0,
|
|
283
308
|
CreateInbox = 1,
|
|
284
309
|
RevokeWallet = 2,
|
|
285
310
|
RevokeInstallations = 3
|
|
286
311
|
}
|
|
287
312
|
|
|
288
|
-
export const enum SortDirection {
|
|
313
|
+
export declare const enum SortDirection {
|
|
289
314
|
Ascending = 0,
|
|
290
315
|
Descending = 1
|
|
291
316
|
}
|
|
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, LogLevel, 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 { LogLevel }
|
|
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.19",
|
|
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,17 +37,17 @@
|
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
|
|
39
|
-
"@napi-rs/cli": "^3.0.0-alpha.
|
|
40
|
-
"@types/node": "^
|
|
40
|
+
"@napi-rs/cli": "^3.0.0-alpha.64",
|
|
41
|
+
"@types/node": "^22.9.0",
|
|
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.
|
|
49
|
-
"vitest": "^2.1.
|
|
46
|
+
"uuid": "^11.0.3",
|
|
47
|
+
"viem": "^2.21.47",
|
|
48
|
+
"vite": "^5.4.11",
|
|
49
|
+
"vite-tsconfig-paths": "^5.1.2",
|
|
50
|
+
"vitest": "^2.1.5"
|
|
50
51
|
},
|
|
51
52
|
"packageManager": "yarn@4.5.1",
|
|
52
53
|
"engines": {
|