@xmtp/node-bindings 0.0.15 → 0.0.17

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.
Binary file
package/dist/index.d.ts CHANGED
@@ -1,57 +1,44 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
- export class NapiClient {
3
+ export class Client {
4
4
  accountAddress: string
5
5
  inboxId(): string
6
6
  isRegistered(): boolean
7
7
  installationId(): string
8
8
  canMessage(accountAddresses: Array<string>): Promise<Record<string, boolean>>
9
9
  registerIdentity(): Promise<void>
10
- createInboxSignatureText(): Promise<string | null>
11
- conversations(): NapiConversations
12
- requestHistorySync(): Promise<void>
10
+ conversations(): Conversations
11
+ sendHistorySyncRequest(): Promise<void>
12
+ sendConsentSyncRequest(): Promise<void>
13
13
  findInboxIdByAddress(address: string): Promise<string | null>
14
+ addressesFromInboxId(refreshFromNetwork: boolean, inboxIds: Array<string>): Promise<Array<InboxState>>
15
+ setConsentStates(records: Array<Consent>): Promise<void>
16
+ getConsentState(entityType: ConsentEntityType, entity: string): Promise<ConsentState>
14
17
  /**
15
18
  * Get the client's inbox state.
16
19
  *
17
20
  * If `refresh_from_network` is true, the client will go to the network first to refresh the state.
18
21
  * Otherwise, the state will be read from the local database.
19
22
  */
20
- inboxState(refreshFromNetwork: boolean): Promise<NapiInboxState>
21
- addressesFromInboxId(refreshFromNetwork: boolean, inboxIds: Array<string>): Promise<Array<NapiInboxState>>
22
- getLatestInboxState(inboxId: string): Promise<NapiInboxState>
23
+ inboxState(refreshFromNetwork: boolean): Promise<InboxState>
24
+ getLatestInboxState(inboxId: string): Promise<InboxState>
25
+ createInboxSignatureText(): Promise<string | null>
23
26
  addWalletSignatureText(existingWalletAddress: string, newWalletAddress: string): Promise<string>
24
27
  revokeWalletSignatureText(walletAddress: string): Promise<string>
25
28
  revokeInstallationsSignatureText(): Promise<string>
26
- addSignature(signatureType: NapiSignatureRequestType, signatureBytes: Uint8Array): Promise<void>
29
+ addSignature(signatureType: SignatureRequestType, signatureBytes: Uint8Array): Promise<void>
27
30
  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
- findDmByTargetInboxId(targetInboxId: string): NapiGroup
36
- findMessageById(messageId: string): NapiMessage
37
- processStreamedWelcomeMessage(envelopeBytes: Uint8Array): Promise<NapiGroup>
38
- sync(): Promise<void>
39
- list(opts?: NapiListConversationsOptions | undefined | null): Promise<Array<NapiGroup>>
40
- stream(callback: (err: null | Error, result: NapiGroup) => void): NapiStreamCloser
41
- streamAllMessages(callback: (err: null | Error, result: NapiMessage) => void): NapiStreamCloser
42
31
  }
43
32
 
44
- export class NapiGroup {
33
+ export class Conversation {
45
34
  id(): string
46
- send(encodedContent: NapiEncodedContent): Promise<string>
47
- /** send a message without immediately publishing to the delivery service. */
48
- sendOptimistic(encodedContent: NapiEncodedContent): string
49
- /** Publish all unpublished messages */
35
+ send(encodedContent: EncodedContent): Promise<string>
36
+ sendOptimistic(encodedContent: EncodedContent): string
50
37
  publishMessages(): Promise<void>
51
38
  sync(): Promise<void>
52
- findMessages(opts?: NapiListMessagesOptions | undefined | null): Array<NapiMessage>
53
- processStreamedGroupMessage(envelopeBytes: Uint8Array): Promise<NapiMessage>
54
- listMembers(): Promise<Array<NapiGroupMember>>
39
+ findMessages(opts?: ListMessagesOptions | undefined | null): Array<Message>
40
+ processStreamedGroupMessage(envelopeBytes: Uint8Array): Promise<Message>
41
+ listMembers(): Promise<Array<GroupMember>>
55
42
  adminList(): Array<string>
56
43
  superAdminList(): Array<string>
57
44
  isAdmin(inboxId: string): boolean
@@ -61,7 +48,7 @@ export class NapiGroup {
61
48
  removeAdmin(inboxId: string): Promise<void>
62
49
  addSuperAdmin(inboxId: string): Promise<void>
63
50
  removeSuperAdmin(inboxId: string): Promise<void>
64
- groupPermissions(): NapiGroupPermissions
51
+ groupPermissions(): GroupPermissions
65
52
  addMembersByInboxId(inboxIds: Array<string>): Promise<void>
66
53
  removeMembers(accountAddresses: Array<string>): Promise<void>
67
54
  removeMembersByInboxId(inboxIds: Array<string>): Promise<void>
@@ -73,44 +60,54 @@ export class NapiGroup {
73
60
  groupDescription(): string
74
61
  updateGroupPinnedFrameUrl(pinnedFrameUrl: string): Promise<void>
75
62
  groupPinnedFrameUrl(): string
76
- stream(callback: (err: null | Error, result: NapiMessage) => void): NapiStreamCloser
63
+ stream(callback: (err: null | Error, result: Message | undefined) => void): StreamCloser
77
64
  createdAtNs(): number
78
65
  isActive(): boolean
79
66
  addedByInboxId(): string
80
- groupMetadata(): NapiGroupMetadata
81
- consentState(): NapiConsentState
82
- updateConsentState(state: NapiConsentState): void
67
+ groupMetadata(): GroupMetadata
68
+ consentState(): ConsentState
69
+ updateConsentState(state: ConsentState): void
70
+ dmPeerInboxId(): string
83
71
  }
84
72
 
85
- export class NapiGroupMember {
73
+ export class Conversations {
74
+ createGroup(accountAddresses: Array<string>, options?: CreateGroupOptions | undefined | null): Promise<Conversation>
75
+ createDm(accountAddress: string): Promise<Conversation>
76
+ findGroupById(groupId: string): Conversation
77
+ findDmByTargetInboxId(targetInboxId: string): Conversation
78
+ findMessageById(messageId: string): Message
79
+ processStreamedWelcomeMessage(envelopeBytes: Uint8Array): Promise<Conversation>
80
+ sync(): Promise<void>
81
+ list(opts?: ListConversationsOptions | undefined | null): Promise<Array<Conversation>>
82
+ listGroups(opts?: ListConversationsOptions | undefined | null): Promise<Array<Conversation>>
83
+ listDms(opts?: ListConversationsOptions | undefined | null): Promise<Array<Conversation>>
84
+ stream(callback: (err: null | Error, result: Conversation | undefined) => void): StreamCloser
85
+ streamGroups(callback: (err: null | Error, result: Conversation | undefined) => void): StreamCloser
86
+ streamDms(callback: (err: null | Error, result: Conversation | undefined) => void): StreamCloser
87
+ streamAllMessages(callback: (err: null | Error, result: Message | undefined) => void): StreamCloser
88
+ streamAllGroupMessages(callback: (err: null | Error, result: Message | undefined) => void): StreamCloser
89
+ streamAllDmMessages(callback: (err: null | Error, result: Message | undefined) => void): StreamCloser
90
+ }
91
+
92
+ export class GroupMember {
86
93
  inboxId: string
87
94
  accountAddresses: Array<string>
88
95
  installationIds: Array<string>
89
- permissionLevel: NapiPermissionLevel
90
- consentState: NapiConsentState
96
+ permissionLevel: PermissionLevel
97
+ consentState: ConsentState
91
98
  }
92
99
 
93
- export class NapiGroupMetadata {
100
+ export class GroupMetadata {
94
101
  creatorInboxId(): string
95
102
  conversationType(): string
96
103
  }
97
104
 
98
- export class NapiGroupPermissions {
99
- policyType(): NapiGroupPermissionsOptions
100
- policySet(): NapiPermissionPolicySet
101
- }
102
-
103
- export class NapiMessage {
104
- id: string
105
- sentAtNs: number
106
- convoId: string
107
- senderInboxId: string
108
- content: NapiEncodedContent
109
- kind: NapiGroupMessageKind
110
- deliveryStatus: NapiDeliveryStatus
105
+ export class GroupPermissions {
106
+ policyType(): GroupPermissionsOptions
107
+ policySet(): PermissionPolicySet
111
108
  }
112
109
 
113
- export class NapiStreamCloser {
110
+ export class StreamCloser {
114
111
  /**
115
112
  * Signal the stream to end
116
113
  * Does not wait for the stream to end.
@@ -126,108 +123,134 @@ export class NapiStreamCloser {
126
123
  isClosed(): boolean
127
124
  }
128
125
 
129
- /**
130
- * Create an MLS client
131
- * Optionally specify a filter for the log level as a string.
132
- * It can be one of: `debug`, `info`, `warn`, `error` or 'off'.
133
- * By default, logging is set to `info`. `off` completely disables logging.
134
- */
135
- export declare 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>
136
-
137
- export declare function generateInboxId(accountAddress: string): string
138
-
139
- export declare function getInboxIdForAddress(host: string, isSecure: boolean, accountAddress: string): Promise<string | null>
140
-
141
- export interface NapiConsent {
142
- entityType: NapiConsentEntityType
143
- state: NapiConsentState
126
+ export interface Consent {
127
+ entityType: ConsentEntityType
128
+ state: ConsentState
144
129
  entity: string
145
130
  }
146
131
 
147
- export const enum NapiConsentEntityType {
132
+ export const enum ConsentEntityType {
148
133
  GroupId = 0,
149
134
  InboxId = 1,
150
135
  Address = 2
151
136
  }
152
137
 
153
- export const enum NapiConsentState {
138
+ export const enum ConsentState {
154
139
  Unknown = 0,
155
140
  Allowed = 1,
156
141
  Denied = 2
157
142
  }
158
143
 
159
- export interface NapiContentTypeId {
144
+ export interface ContentTypeId {
160
145
  authorityId: string
161
146
  typeId: string
162
147
  versionMajor: number
163
148
  versionMinor: number
164
149
  }
165
150
 
166
- export interface NapiCreateGroupOptions {
167
- permissions?: NapiGroupPermissionsOptions
151
+ export const enum ConversationType {
152
+ Dm = 0,
153
+ Group = 1,
154
+ Sync = 2
155
+ }
156
+
157
+ /**
158
+ * Create a client
159
+ *
160
+ * Optionally specify a filter for the log level as a string.
161
+ * It can be one of: `debug`, `info`, `warn`, `error` or 'off'.
162
+ * By default, logging is disabled.
163
+ */
164
+ export declare function createClient(host: string, isSecure: boolean, dbPath: string, inboxId: string, accountAddress: string, encryptionKey?: Uint8Array | undefined | null, historySyncUrl?: string | undefined | null, envFilter?: "debug" | "info" | "warn" | "error" | "off" | undefined | null): Promise<Client>
165
+
166
+ export interface CreateGroupOptions {
167
+ permissions?: GroupPermissionsOptions
168
168
  groupName?: string
169
169
  groupImageUrlSquare?: string
170
170
  groupDescription?: string
171
171
  groupPinnedFrameUrl?: string
172
172
  }
173
173
 
174
- export const enum NapiDeliveryStatus {
174
+ export const enum DeliveryStatus {
175
175
  Unpublished = 0,
176
176
  Published = 1,
177
177
  Failed = 2
178
178
  }
179
179
 
180
- export interface NapiEncodedContent {
181
- type?: NapiContentTypeId
180
+ export interface EncodedContent {
181
+ type?: ContentTypeId
182
182
  parameters: Record<string, string>
183
183
  fallback?: string
184
184
  compression?: number
185
185
  content: Uint8Array
186
186
  }
187
187
 
188
- export const enum NapiGroupMessageKind {
188
+ export declare function generateInboxId(accountAddress: string): string
189
+
190
+ export declare function getInboxIdForAddress(host: string, isSecure: boolean, accountAddress: string): Promise<string | null>
191
+
192
+ export const enum GroupMembershipState {
193
+ Allowed = 0,
194
+ Rejected = 1,
195
+ Pending = 2
196
+ }
197
+
198
+ export const enum GroupMessageKind {
189
199
  Application = 0,
190
200
  MembershipChange = 1
191
201
  }
192
202
 
193
- export const enum NapiGroupPermissionsOptions {
203
+ export const enum GroupPermissionsOptions {
194
204
  AllMembers = 0,
195
205
  AdminOnly = 1,
196
206
  CustomPolicy = 2
197
207
  }
198
208
 
199
- export interface NapiInboxState {
209
+ export interface InboxState {
200
210
  inboxId: string
201
211
  recoveryAddress: string
202
- installations: Array<NapiInstallation>
212
+ installations: Array<Installation>
203
213
  accountAddresses: Array<string>
204
214
  }
205
215
 
206
- export interface NapiInstallation {
216
+ export interface Installation {
207
217
  id: string
208
218
  clientTimestampNs?: bigint
209
219
  }
210
220
 
211
- export interface NapiListConversationsOptions {
221
+ export interface ListConversationsOptions {
222
+ allowedStates?: Array<GroupMembershipState>
212
223
  createdAfterNs?: number
213
224
  createdBeforeNs?: number
214
225
  limit?: number
226
+ conversationType?: ConversationType
215
227
  }
216
228
 
217
- export interface NapiListMessagesOptions {
229
+ export interface ListMessagesOptions {
218
230
  sentBeforeNs?: number
219
231
  sentAfterNs?: number
220
232
  limit?: number
221
- deliveryStatus?: NapiDeliveryStatus
233
+ deliveryStatus?: DeliveryStatus
234
+ direction?: SortDirection
222
235
  }
223
236
 
224
- export const enum NapiPermissionLevel {
237
+ export interface Message {
238
+ id: string
239
+ sentAtNs: number
240
+ convoId: string
241
+ senderInboxId: string
242
+ content: EncodedContent
243
+ kind: GroupMessageKind
244
+ deliveryStatus: DeliveryStatus
245
+ }
246
+
247
+ export const enum PermissionLevel {
225
248
  Member = 0,
226
249
  Admin = 1,
227
250
  SuperAdmin = 2
228
251
  }
229
252
 
230
- export const enum NapiPermissionPolicy {
253
+ export const enum PermissionPolicy {
231
254
  Allow = 0,
232
255
  Deny = 1,
233
256
  Admin = 2,
@@ -236,18 +259,18 @@ export const enum NapiPermissionPolicy {
236
259
  Other = 5
237
260
  }
238
261
 
239
- export interface NapiPermissionPolicySet {
240
- addMemberPolicy: NapiPermissionPolicy
241
- removeMemberPolicy: NapiPermissionPolicy
242
- addAdminPolicy: NapiPermissionPolicy
243
- removeAdminPolicy: NapiPermissionPolicy
244
- updateGroupNamePolicy: NapiPermissionPolicy
245
- updateGroupDescriptionPolicy: NapiPermissionPolicy
246
- updateGroupImageUrlSquarePolicy: NapiPermissionPolicy
247
- updateGroupPinnedFrameUrlPolicy: NapiPermissionPolicy
262
+ export interface PermissionPolicySet {
263
+ addMemberPolicy: PermissionPolicy
264
+ removeMemberPolicy: PermissionPolicy
265
+ addAdminPolicy: PermissionPolicy
266
+ removeAdminPolicy: PermissionPolicy
267
+ updateGroupNamePolicy: PermissionPolicy
268
+ updateGroupDescriptionPolicy: PermissionPolicy
269
+ updateGroupImageUrlSquarePolicy: PermissionPolicy
270
+ updateGroupPinnedFrameUrlPolicy: PermissionPolicy
248
271
  }
249
272
 
250
- export const enum NapiPermissionUpdateType {
273
+ export const enum PermissionUpdateType {
251
274
  AddMember = 0,
252
275
  RemoveMember = 1,
253
276
  AddAdmin = 2,
@@ -255,10 +278,15 @@ export const enum NapiPermissionUpdateType {
255
278
  UpdateMetadata = 4
256
279
  }
257
280
 
258
- export const enum NapiSignatureRequestType {
281
+ export const enum SignatureRequestType {
259
282
  AddWallet = 0,
260
283
  CreateInbox = 1,
261
284
  RevokeWallet = 2,
262
285
  RevokeInstallations = 3
263
286
  }
264
287
 
288
+ export const enum SortDirection {
289
+ Ascending = 0,
290
+ Descending = 1
291
+ }
292
+
package/dist/index.js CHANGED
@@ -361,23 +361,25 @@ if (!nativeBinding) {
361
361
  throw new Error(`Failed to load native binding`)
362
362
  }
363
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
364
+ module.exports.Client = nativeBinding.Client
365
+ module.exports.Conversation = nativeBinding.Conversation
366
+ module.exports.Conversations = nativeBinding.Conversations
367
+ module.exports.GroupMember = nativeBinding.GroupMember
368
+ module.exports.GroupMetadata = nativeBinding.GroupMetadata
369
+ module.exports.GroupPermissions = nativeBinding.GroupPermissions
370
+ module.exports.StreamCloser = nativeBinding.StreamCloser
371
+ module.exports.ConsentEntityType = nativeBinding.ConsentEntityType
372
+ module.exports.ConsentState = nativeBinding.ConsentState
373
+ module.exports.ConversationType = nativeBinding.ConversationType
372
374
  module.exports.createClient = nativeBinding.createClient
375
+ module.exports.DeliveryStatus = nativeBinding.DeliveryStatus
373
376
  module.exports.generateInboxId = nativeBinding.generateInboxId
374
377
  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
378
+ module.exports.GroupMembershipState = nativeBinding.GroupMembershipState
379
+ module.exports.GroupMessageKind = nativeBinding.GroupMessageKind
380
+ module.exports.GroupPermissionsOptions = nativeBinding.GroupPermissionsOptions
381
+ module.exports.PermissionLevel = nativeBinding.PermissionLevel
382
+ module.exports.PermissionPolicy = nativeBinding.PermissionPolicy
383
+ module.exports.PermissionUpdateType = nativeBinding.PermissionUpdateType
384
+ module.exports.SignatureRequestType = nativeBinding.SignatureRequestType
385
+ module.exports.SortDirection = nativeBinding.SortDirection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmtp/node-bindings",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://git@github.com/xmtp/libxmtp.git",
@@ -20,32 +20,35 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "artifacts": "napi artifacts",
23
- "build": "napi build --platform --release",
23
+ "build": "yarn build:clean && yarn build:release && yarn build:finish",
24
24
  "build:clean": "rm -rf dist",
25
25
  "build:debug": "napi build --platform",
26
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",
27
+ "build:release": "napi build --platform --release",
28
28
  "clean": "yarn build:clean && yarn test:clean",
29
29
  "format": "prettier -w .",
30
30
  "format:check": "prettier -c .",
31
+ "lint": "yarn lint:clippy && yarn lint:fmt",
32
+ "lint:clippy": "cargo clippy --all-features --all-targets --no-deps -- -Dwarnings",
33
+ "lint:fmt": "cargo fmt --check",
31
34
  "test": "vitest run",
32
35
  "test:clean": "rm -rf test/*.db3*"
33
36
  },
34
37
  "devDependencies": {
35
- "@ianvs/prettier-plugin-sort-imports": "^4.2.1",
38
+ "@ianvs/prettier-plugin-sort-imports": "^4.4.0",
36
39
  "@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"
40
+ "@types/node": "^20.17.6",
41
+ "@types/uuid": "^10.0.0",
42
+ "prettier": "^3.3.3",
43
+ "prettier-plugin-packagejson": "^2.5.3",
44
+ "typescript": "^5.6.3",
45
+ "uuid": "^11.0.2",
46
+ "viem": "^2.21.41",
47
+ "vite": "^5.4.10",
48
+ "vite-tsconfig-paths": "^5.1.0",
49
+ "vitest": "^2.1.4"
47
50
  },
48
- "packageManager": "yarn@4.2.2",
51
+ "packageManager": "yarn@4.5.1",
49
52
  "engines": {
50
53
  "node": ">=18"
51
54
  },