@xmtp/node-bindings 0.0.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 XMTP (xmtp.org)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Node bindings for the MLS client
2
+
3
+ > **Important**
4
+ > These bindings are currently in **Alpha** status. Do not use in production as the API is not final and certain functionality may not work as intended.
5
+
6
+ ## Useful commands
7
+
8
+ - `yarn`: Installs all dependencies (required before building)
9
+ - `yarn build:release`: Build a release version of the Node bindings for the current platform
10
+
11
+ ## Testing
12
+
13
+ There are several test scripts written in Node located in the `/scripts` folder.
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.
@@ -0,0 +1,263 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export class NapiClient {
4
+ accountAddress: string
5
+ inboxId(): string
6
+ isRegistered(): boolean
7
+ installationId(): string
8
+ canMessage(accountAddresses: Array<string>): Promise<Record<string, boolean>>
9
+ registerIdentity(): Promise<void>
10
+ createInboxSignatureText(): Promise<string | null>
11
+ conversations(): NapiConversations
12
+ requestHistorySync(): Promise<void>
13
+ findInboxIdByAddress(address: string): Promise<string | null>
14
+ /**
15
+ * Get the client's inbox state.
16
+ *
17
+ * If `refresh_from_network` is true, the client will go to the network first to refresh the state.
18
+ * Otherwise, the state will be read from the local database.
19
+ */
20
+ inboxState(refreshFromNetwork: boolean): Promise<NapiInboxState>
21
+ addressesFromInboxId(refreshFromNetwork: boolean, inboxIds: Array<string>): Promise<Array<NapiInboxState>>
22
+ getLatestInboxState(inboxId: string): Promise<NapiInboxState>
23
+ addWalletSignatureText(existingWalletAddress: string, newWalletAddress: string): Promise<string>
24
+ revokeWalletSignatureText(walletAddress: string): Promise<string>
25
+ revokeInstallationsSignatureText(): Promise<string>
26
+ addSignature(signatureType: NapiSignatureRequestType, signatureBytes: Uint8Array): Promise<void>
27
+ applySignatureRequests(): Promise<void>
28
+ setConsentStates(records: Array<NapiConsent>): Promise<void>
29
+ getConsentState(entityType: NapiConsentEntityType, entity: string): Promise<NapiConsentState>
30
+ }
31
+
32
+ export class NapiConversations {
33
+ createGroup(accountAddresses: Array<string>, options?: NapiCreateGroupOptions | undefined | null): Promise<NapiGroup>
34
+ findGroupById(groupId: string): NapiGroup
35
+ findMessageById(messageId: string): NapiMessage
36
+ processStreamedWelcomeMessage(envelopeBytes: Uint8Array): Promise<NapiGroup>
37
+ sync(): Promise<void>
38
+ list(opts?: NapiListConversationsOptions | undefined | null): Promise<Array<NapiGroup>>
39
+ stream(callback: (err: null | Error, result: NapiGroup) => void): NapiStreamCloser
40
+ streamAllMessages(callback: (err: null | Error, result: NapiMessage) => void): NapiStreamCloser
41
+ }
42
+
43
+ export class NapiGroup {
44
+ id(): string
45
+ send(encodedContent: NapiEncodedContent): Promise<string>
46
+ /** send a message without immediately publishing to the delivery service. */
47
+ sendOptimistic(encodedContent: NapiEncodedContent): string
48
+ /** Publish all unpublished messages */
49
+ publishMessages(): Promise<void>
50
+ sync(): Promise<void>
51
+ findMessages(opts?: NapiListMessagesOptions | undefined | null): Array<NapiMessage>
52
+ processStreamedGroupMessage(envelopeBytes: Uint8Array): Promise<NapiMessage>
53
+ listMembers(): Promise<Array<NapiGroupMember>>
54
+ adminList(): Array<string>
55
+ superAdminList(): Array<string>
56
+ isAdmin(inboxId: string): boolean
57
+ isSuperAdmin(inboxId: string): boolean
58
+ addMembers(accountAddresses: Array<string>): Promise<void>
59
+ addAdmin(inboxId: string): Promise<void>
60
+ removeAdmin(inboxId: string): Promise<void>
61
+ addSuperAdmin(inboxId: string): Promise<void>
62
+ removeSuperAdmin(inboxId: string): Promise<void>
63
+ groupPermissions(): NapiGroupPermissions
64
+ addMembersByInboxId(inboxIds: Array<string>): Promise<void>
65
+ removeMembers(accountAddresses: Array<string>): Promise<void>
66
+ removeMembersByInboxId(inboxIds: Array<string>): Promise<void>
67
+ updateGroupName(groupName: string): Promise<void>
68
+ groupName(): string
69
+ updateGroupImageUrlSquare(groupImageUrlSquare: string): Promise<void>
70
+ groupImageUrlSquare(): string
71
+ updateGroupDescription(groupDescription: string): Promise<void>
72
+ groupDescription(): string
73
+ updateGroupPinnedFrameUrl(pinnedFrameUrl: string): Promise<void>
74
+ groupPinnedFrameUrl(): string
75
+ stream(callback: (err: null | Error, result: NapiMessage) => void): NapiStreamCloser
76
+ createdAtNs(): number
77
+ isActive(): boolean
78
+ addedByInboxId(): string
79
+ groupMetadata(): NapiGroupMetadata
80
+ consentState(): NapiConsentState
81
+ updateConsentState(state: NapiConsentState): void
82
+ }
83
+
84
+ export class NapiGroupMember {
85
+ inboxId: string
86
+ accountAddresses: Array<string>
87
+ installationIds: Array<string>
88
+ permissionLevel: NapiPermissionLevel
89
+ consentState: NapiConsentState
90
+ }
91
+
92
+ export class NapiGroupMetadata {
93
+ creatorInboxId(): string
94
+ conversationType(): string
95
+ }
96
+
97
+ export class NapiGroupPermissions {
98
+ policyType(): NapiGroupPermissionsOptions
99
+ policySet(): NapiPermissionPolicySet
100
+ }
101
+
102
+ export class NapiMessage {
103
+ id: string
104
+ sentAtNs: number
105
+ convoId: string
106
+ senderInboxId: string
107
+ content: NapiEncodedContent
108
+ kind: NapiGroupMessageKind
109
+ deliveryStatus: NapiDeliveryStatus
110
+ }
111
+
112
+ export class NapiStreamCloser {
113
+ /**
114
+ * Signal the stream to end
115
+ * Does not wait for the stream to end.
116
+ */
117
+ end(): void
118
+ /**
119
+ * End the stream and `await` for it to shutdown
120
+ * Returns the `Result` of the task.
121
+ * End the stream and asyncronously wait for it to shutdown
122
+ */
123
+ endAndWait(): Promise<void>
124
+ /** Checks if this stream is closed */
125
+ isClosed(): boolean
126
+ }
127
+
128
+ /**
129
+ * Create an MLS client
130
+ * Optionally specify a filter for the log level as a string.
131
+ * It can be one of: `debug`, `info`, `warn`, `error` or 'off'.
132
+ * By default, logging is set to `info`. `off` completely disables logging.
133
+ */
134
+ export function createClient(host: string, isSecure: boolean, dbPath: string, inboxId: string, accountAddress: string, encryptionKey?: Uint8Array | undefined | null, historySyncUrl?: string | undefined | null, envFilter?: string | undefined | null): Promise<NapiClient>
135
+
136
+ export function generateInboxId(accountAddress: string): string
137
+
138
+ export function getInboxIdForAddress(host: string, isSecure: boolean, accountAddress: string): Promise<string | null>
139
+
140
+ export interface NapiConsent {
141
+ entityType: NapiConsentEntityType
142
+ state: NapiConsentState
143
+ entity: string
144
+ }
145
+
146
+ export const enum NapiConsentEntityType {
147
+ GroupId = 0,
148
+ InboxId = 1,
149
+ Address = 2
150
+ }
151
+
152
+ export const enum NapiConsentState {
153
+ Unknown = 0,
154
+ Allowed = 1,
155
+ Denied = 2
156
+ }
157
+
158
+ export interface NapiContentTypeId {
159
+ authorityId: string
160
+ typeId: string
161
+ versionMajor: number
162
+ versionMinor: number
163
+ }
164
+
165
+ export interface NapiCreateGroupOptions {
166
+ permissions?: NapiGroupPermissionsOptions
167
+ groupName?: string
168
+ groupImageUrlSquare?: string
169
+ groupDescription?: string
170
+ groupPinnedFrameUrl?: string
171
+ }
172
+
173
+ export const enum NapiDeliveryStatus {
174
+ Unpublished = 0,
175
+ Published = 1,
176
+ Failed = 2
177
+ }
178
+
179
+ export interface NapiEncodedContent {
180
+ type?: NapiContentTypeId
181
+ parameters: Record<string, string>
182
+ fallback?: string
183
+ compression?: number
184
+ content: Uint8Array
185
+ }
186
+
187
+ export const enum NapiGroupMessageKind {
188
+ Application = 0,
189
+ MembershipChange = 1
190
+ }
191
+
192
+ export const enum NapiGroupPermissionsOptions {
193
+ AllMembers = 0,
194
+ AdminOnly = 1,
195
+ CustomPolicy = 2
196
+ }
197
+
198
+ export interface NapiInboxState {
199
+ inboxId: string
200
+ recoveryAddress: string
201
+ installations: Array<NapiInstallation>
202
+ accountAddresses: Array<string>
203
+ }
204
+
205
+ export interface NapiInstallation {
206
+ id: string
207
+ clientTimestampNs?: bigint
208
+ }
209
+
210
+ export interface NapiListConversationsOptions {
211
+ createdAfterNs?: number
212
+ createdBeforeNs?: number
213
+ limit?: number
214
+ }
215
+
216
+ export interface NapiListMessagesOptions {
217
+ sentBeforeNs?: number
218
+ sentAfterNs?: number
219
+ limit?: number
220
+ deliveryStatus?: NapiDeliveryStatus
221
+ }
222
+
223
+ export const enum NapiPermissionLevel {
224
+ Member = 0,
225
+ Admin = 1,
226
+ SuperAdmin = 2
227
+ }
228
+
229
+ export const enum NapiPermissionPolicy {
230
+ Allow = 0,
231
+ Deny = 1,
232
+ Admin = 2,
233
+ SuperAdmin = 3,
234
+ DoesNotExist = 4,
235
+ Other = 5
236
+ }
237
+
238
+ export interface NapiPermissionPolicySet {
239
+ addMemberPolicy: NapiPermissionPolicy
240
+ removeMemberPolicy: NapiPermissionPolicy
241
+ addAdminPolicy: NapiPermissionPolicy
242
+ removeAdminPolicy: NapiPermissionPolicy
243
+ updateGroupNamePolicy: NapiPermissionPolicy
244
+ updateGroupDescriptionPolicy: NapiPermissionPolicy
245
+ updateGroupImageUrlSquarePolicy: NapiPermissionPolicy
246
+ updateGroupPinnedFrameUrlPolicy: NapiPermissionPolicy
247
+ }
248
+
249
+ export const enum NapiPermissionUpdateType {
250
+ AddMember = 0,
251
+ RemoveMember = 1,
252
+ AddAdmin = 2,
253
+ RemoveAdmin = 3,
254
+ UpdateMetadata = 4
255
+ }
256
+
257
+ export const enum NapiSignatureRequestType {
258
+ AddWallet = 0,
259
+ CreateInbox = 1,
260
+ RevokeWallet = 2,
261
+ RevokeInstallations = 3
262
+ }
263
+
package/dist/index.js ADDED
@@ -0,0 +1,383 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ /* auto-generated by NAPI-RS */
4
+
5
+ const { readFileSync } = require('fs')
6
+
7
+ let nativeBinding = null
8
+ const loadErrors = []
9
+
10
+ const isMusl = () => {
11
+ let musl = false
12
+ if (process.platform === 'linux') {
13
+ musl = isMuslFromFilesystem()
14
+ if (musl === null) {
15
+ musl = isMuslFromReport()
16
+ }
17
+ if (musl === null) {
18
+ musl = isMuslFromChildProcess()
19
+ }
20
+ }
21
+ return musl
22
+ }
23
+
24
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
25
+
26
+ const isMuslFromFilesystem = () => {
27
+ try {
28
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
29
+ } catch {
30
+ return null
31
+ }
32
+ }
33
+
34
+ const isMuslFromReport = () => {
35
+ const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
36
+ if (!report) {
37
+ return null
38
+ }
39
+ if (report.header && report.header.glibcVersionRuntime) {
40
+ return false
41
+ }
42
+ if (Array.isArray(report.sharedObjects)) {
43
+ if (report.sharedObjects.some(isFileMusl)) {
44
+ return true
45
+ }
46
+ }
47
+ return false
48
+ }
49
+
50
+ const isMuslFromChildProcess = () => {
51
+ try {
52
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
53
+ } catch (e) {
54
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
55
+ return false
56
+ }
57
+ }
58
+
59
+ function requireNative() {
60
+ if (process.platform === 'android') {
61
+ if (process.arch === 'arm64') {
62
+ try {
63
+ return require('./bindings_node.android-arm64.node')
64
+ } catch (e) {
65
+ loadErrors.push(e)
66
+ }
67
+ try {
68
+ return require('@xmtp/node-bindings-android-arm64')
69
+ } catch (e) {
70
+ loadErrors.push(e)
71
+ }
72
+
73
+ } else if (process.arch === 'arm') {
74
+ try {
75
+ return require('./bindings_node.android-arm-eabi.node')
76
+ } catch (e) {
77
+ loadErrors.push(e)
78
+ }
79
+ try {
80
+ return require('@xmtp/node-bindings-android-arm-eabi')
81
+ } catch (e) {
82
+ loadErrors.push(e)
83
+ }
84
+
85
+ } else {
86
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
87
+ }
88
+ } else if (process.platform === 'win32') {
89
+ if (process.arch === 'x64') {
90
+ try {
91
+ return require('./bindings_node.win32-x64-msvc.node')
92
+ } catch (e) {
93
+ loadErrors.push(e)
94
+ }
95
+ try {
96
+ return require('@xmtp/node-bindings-win32-x64-msvc')
97
+ } catch (e) {
98
+ loadErrors.push(e)
99
+ }
100
+
101
+ } else if (process.arch === 'ia32') {
102
+ try {
103
+ return require('./bindings_node.win32-ia32-msvc.node')
104
+ } catch (e) {
105
+ loadErrors.push(e)
106
+ }
107
+ try {
108
+ return require('@xmtp/node-bindings-win32-ia32-msvc')
109
+ } catch (e) {
110
+ loadErrors.push(e)
111
+ }
112
+
113
+ } else if (process.arch === 'arm64') {
114
+ try {
115
+ return require('./bindings_node.win32-arm64-msvc.node')
116
+ } catch (e) {
117
+ loadErrors.push(e)
118
+ }
119
+ try {
120
+ return require('@xmtp/node-bindings-win32-arm64-msvc')
121
+ } catch (e) {
122
+ loadErrors.push(e)
123
+ }
124
+
125
+ } else {
126
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
127
+ }
128
+ } else if (process.platform === 'darwin') {
129
+ try {
130
+ return require('./bindings_node.darwin-universal.node')
131
+ } catch (e) {
132
+ loadErrors.push(e)
133
+ }
134
+ try {
135
+ return require('@xmtp/node-bindings-darwin-universal')
136
+ } catch (e) {
137
+ loadErrors.push(e)
138
+ }
139
+
140
+ if (process.arch === 'x64') {
141
+ try {
142
+ return require('./bindings_node.darwin-x64.node')
143
+ } catch (e) {
144
+ loadErrors.push(e)
145
+ }
146
+ try {
147
+ return require('@xmtp/node-bindings-darwin-x64')
148
+ } catch (e) {
149
+ loadErrors.push(e)
150
+ }
151
+
152
+ } else if (process.arch === 'arm64') {
153
+ try {
154
+ return require('./bindings_node.darwin-arm64.node')
155
+ } catch (e) {
156
+ loadErrors.push(e)
157
+ }
158
+ try {
159
+ return require('@xmtp/node-bindings-darwin-arm64')
160
+ } catch (e) {
161
+ loadErrors.push(e)
162
+ }
163
+
164
+ } else {
165
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
166
+ }
167
+ } else if (process.platform === 'freebsd') {
168
+ if (process.arch === 'x64') {
169
+ try {
170
+ return require('./bindings_node.freebsd-x64.node')
171
+ } catch (e) {
172
+ loadErrors.push(e)
173
+ }
174
+ try {
175
+ return require('@xmtp/node-bindings-freebsd-x64')
176
+ } catch (e) {
177
+ loadErrors.push(e)
178
+ }
179
+
180
+ } else if (process.arch === 'arm64') {
181
+ try {
182
+ return require('./bindings_node.freebsd-arm64.node')
183
+ } catch (e) {
184
+ loadErrors.push(e)
185
+ }
186
+ try {
187
+ return require('@xmtp/node-bindings-freebsd-arm64')
188
+ } catch (e) {
189
+ loadErrors.push(e)
190
+ }
191
+
192
+ } else {
193
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
194
+ }
195
+ } else if (process.platform === 'linux') {
196
+ if (process.arch === 'x64') {
197
+ if (isMusl()) {
198
+ try {
199
+ return require('./bindings_node.linux-x64-musl.node')
200
+ } catch (e) {
201
+ loadErrors.push(e)
202
+ }
203
+ try {
204
+ return require('@xmtp/node-bindings-linux-x64-musl')
205
+ } catch (e) {
206
+ loadErrors.push(e)
207
+ }
208
+
209
+ } else {
210
+ try {
211
+ return require('./bindings_node.linux-x64-gnu.node')
212
+ } catch (e) {
213
+ loadErrors.push(e)
214
+ }
215
+ try {
216
+ return require('@xmtp/node-bindings-linux-x64-gnu')
217
+ } catch (e) {
218
+ loadErrors.push(e)
219
+ }
220
+
221
+ }
222
+ } else if (process.arch === 'arm64') {
223
+ if (isMusl()) {
224
+ try {
225
+ return require('./bindings_node.linux-arm64-musl.node')
226
+ } catch (e) {
227
+ loadErrors.push(e)
228
+ }
229
+ try {
230
+ return require('@xmtp/node-bindings-linux-arm64-musl')
231
+ } catch (e) {
232
+ loadErrors.push(e)
233
+ }
234
+
235
+ } else {
236
+ try {
237
+ return require('./bindings_node.linux-arm64-gnu.node')
238
+ } catch (e) {
239
+ loadErrors.push(e)
240
+ }
241
+ try {
242
+ return require('@xmtp/node-bindings-linux-arm64-gnu')
243
+ } catch (e) {
244
+ loadErrors.push(e)
245
+ }
246
+
247
+ }
248
+ } else if (process.arch === 'arm') {
249
+ if (isMusl()) {
250
+ try {
251
+ return require('./bindings_node.linux-arm-musleabihf.node')
252
+ } catch (e) {
253
+ loadErrors.push(e)
254
+ }
255
+ try {
256
+ return require('@xmtp/node-bindings-linux-arm-musleabihf')
257
+ } catch (e) {
258
+ loadErrors.push(e)
259
+ }
260
+
261
+ } else {
262
+ try {
263
+ return require('./bindings_node.linux-arm-gnueabihf.node')
264
+ } catch (e) {
265
+ loadErrors.push(e)
266
+ }
267
+ try {
268
+ return require('@xmtp/node-bindings-linux-arm-gnueabihf')
269
+ } catch (e) {
270
+ loadErrors.push(e)
271
+ }
272
+
273
+ }
274
+ } else if (process.arch === 'riscv64') {
275
+ if (isMusl()) {
276
+ try {
277
+ return require('./bindings_node.linux-riscv64-musl.node')
278
+ } catch (e) {
279
+ loadErrors.push(e)
280
+ }
281
+ try {
282
+ return require('@xmtp/node-bindings-linux-riscv64-musl')
283
+ } catch (e) {
284
+ loadErrors.push(e)
285
+ }
286
+
287
+ } else {
288
+ try {
289
+ return require('./bindings_node.linux-riscv64-gnu.node')
290
+ } catch (e) {
291
+ loadErrors.push(e)
292
+ }
293
+ try {
294
+ return require('@xmtp/node-bindings-linux-riscv64-gnu')
295
+ } catch (e) {
296
+ loadErrors.push(e)
297
+ }
298
+
299
+ }
300
+ } else if (process.arch === 'ppc64') {
301
+ try {
302
+ return require('./bindings_node.linux-ppc64-gnu.node')
303
+ } catch (e) {
304
+ loadErrors.push(e)
305
+ }
306
+ try {
307
+ return require('@xmtp/node-bindings-linux-ppc64-gnu')
308
+ } catch (e) {
309
+ loadErrors.push(e)
310
+ }
311
+
312
+ } else if (process.arch === 's390x') {
313
+ try {
314
+ return require('./bindings_node.linux-s390x-gnu.node')
315
+ } catch (e) {
316
+ loadErrors.push(e)
317
+ }
318
+ try {
319
+ return require('@xmtp/node-bindings-linux-s390x-gnu')
320
+ } catch (e) {
321
+ loadErrors.push(e)
322
+ }
323
+
324
+ } else {
325
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
326
+ }
327
+ } else {
328
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
329
+ }
330
+ }
331
+
332
+ nativeBinding = requireNative()
333
+
334
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
335
+ try {
336
+ nativeBinding = require('./bindings_node.wasi.cjs')
337
+ } catch (err) {
338
+ if (process.env.NAPI_RS_FORCE_WASI) {
339
+ console.error(err)
340
+ }
341
+ }
342
+ if (!nativeBinding) {
343
+ try {
344
+ nativeBinding = require('@xmtp/node-bindings-wasm32-wasi')
345
+ } catch (err) {
346
+ if (process.env.NAPI_RS_FORCE_WASI) {
347
+ console.error(err)
348
+ }
349
+ }
350
+ }
351
+ }
352
+
353
+ if (!nativeBinding) {
354
+ if (loadErrors.length > 0) {
355
+ // TODO Link to documentation with potential fixes
356
+ // - The package owner could build/publish bindings for this arch
357
+ // - The user may need to bundle the correct files
358
+ // - The user may need to re-install node_modules to get new packages
359
+ throw new Error('Failed to load native binding', { cause: loadErrors })
360
+ }
361
+ throw new Error(`Failed to load native binding`)
362
+ }
363
+
364
+ module.exports.NapiClient = nativeBinding.NapiClient
365
+ module.exports.NapiConversations = nativeBinding.NapiConversations
366
+ module.exports.NapiGroup = nativeBinding.NapiGroup
367
+ module.exports.NapiGroupMember = nativeBinding.NapiGroupMember
368
+ module.exports.NapiGroupMetadata = nativeBinding.NapiGroupMetadata
369
+ module.exports.NapiGroupPermissions = nativeBinding.NapiGroupPermissions
370
+ module.exports.NapiMessage = nativeBinding.NapiMessage
371
+ module.exports.NapiStreamCloser = nativeBinding.NapiStreamCloser
372
+ module.exports.createClient = nativeBinding.createClient
373
+ module.exports.generateInboxId = nativeBinding.generateInboxId
374
+ module.exports.getInboxIdForAddress = nativeBinding.getInboxIdForAddress
375
+ module.exports.NapiConsentEntityType = nativeBinding.NapiConsentEntityType
376
+ module.exports.NapiConsentState = nativeBinding.NapiConsentState
377
+ module.exports.NapiDeliveryStatus = nativeBinding.NapiDeliveryStatus
378
+ module.exports.NapiGroupMessageKind = nativeBinding.NapiGroupMessageKind
379
+ module.exports.NapiGroupPermissionsOptions = nativeBinding.NapiGroupPermissionsOptions
380
+ module.exports.NapiPermissionLevel = nativeBinding.NapiPermissionLevel
381
+ module.exports.NapiPermissionPolicy = nativeBinding.NapiPermissionPolicy
382
+ module.exports.NapiPermissionUpdateType = nativeBinding.NapiPermissionUpdateType
383
+ module.exports.NapiSignatureRequestType = nativeBinding.NapiSignatureRequestType
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@xmtp/node-bindings",
3
+ "version": "0.0.13",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://git@github.com/xmtp/libxmtp.git",
7
+ "directory": "bindings_node"
8
+ },
9
+ "license": "MIT",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "artifacts": "napi artifacts",
23
+ "build": "napi build --platform --release",
24
+ "build:clean": "rm -rf dist",
25
+ "build:debug": "napi build --platform",
26
+ "build:finish": "mkdir dist && mv index.js dist && mv index.d.ts dist && mv *.node dist",
27
+ "build:release": "yarn build:clean && yarn build && yarn build:finish",
28
+ "clean": "yarn build:clean && yarn test:clean",
29
+ "format": "prettier -w .",
30
+ "format:check": "prettier -c .",
31
+ "test": "vitest run",
32
+ "test:clean": "rm -rf test/*.db3*"
33
+ },
34
+ "devDependencies": {
35
+ "@ianvs/prettier-plugin-sort-imports": "^4.2.1",
36
+ "@napi-rs/cli": "^3.0.0-alpha.55",
37
+ "@types/node": "^20.14.2",
38
+ "@types/uuid": "^10",
39
+ "prettier": "^3.3.2",
40
+ "prettier-plugin-packagejson": "^2.5.0",
41
+ "typescript": "^5.4.5",
42
+ "uuid": "^10.0.0",
43
+ "viem": "^2.11.1",
44
+ "vite": "^5.2.13",
45
+ "vite-tsconfig-paths": "^4.3.2",
46
+ "vitest": "^1.6.0"
47
+ },
48
+ "packageManager": "yarn@4.2.2",
49
+ "engines": {
50
+ "node": ">=18"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public",
54
+ "provenance": true,
55
+ "registry": "https://registry.npmjs.org/"
56
+ },
57
+ "napi": {
58
+ "binaryName": "bindings_node"
59
+ }
60
+ }