diff --git a/.changeset/new-steaks-pull.md b/.changeset/new-steaks-pull.md new file mode 100644 index 00000000..7d59ad92 --- /dev/null +++ b/.changeset/new-steaks-pull.md @@ -0,0 +1,5 @@ +--- +"@xmtp/node-sdk": patch +--- + +Upgrade Node SDK diff --git a/.github/workflows/mls-client.yml b/.github/workflows/mls-client.yml index a6164e7a..30ca2b9a 100644 --- a/.github/workflows/mls-client.yml +++ b/.github/workflows/mls-client.yml @@ -7,8 +7,8 @@ on: pull_request: paths: - - "sdks/mls-client/**" - - ".github/workflows/mls-client.yml" + - "sdks/node-sdk/**" + - ".github/workflows/node-sdk.yml" - "dev/**" - ".node-version" - ".nvmrc" @@ -33,7 +33,7 @@ jobs: - name: Install dependencies run: yarn - name: Typecheck - run: yarn turbo run typecheck --filter='./sdks/mls-client' + run: yarn turbo run typecheck --filter='./sdks/node-sdk' lint: name: Lint @@ -51,7 +51,7 @@ jobs: - name: Install dependencies run: yarn - name: Lint - run: yarn turbo run lint --filter='./sdks/mls-client' + run: yarn turbo run lint --filter='./sdks/node-sdk' test: name: Test @@ -73,7 +73,7 @@ jobs: - name: Sleep for 5 seconds run: sleep 5s - name: Run tests - run: yarn turbo run test --filter='./sdks/mls-client' + run: yarn turbo run test --filter='./sdks/node-sdk' build: name: Build @@ -91,4 +91,4 @@ jobs: - name: Install dependencies run: yarn - name: Build - run: yarn turbo run build --filter='./sdks/mls-client' + run: yarn turbo run build --filter='./sdks/node-sdk' diff --git a/.github/workflows/noop.yml b/.github/workflows/noop.yml index 4e0d4892..221c4cfe 100644 --- a/.github/workflows/noop.yml +++ b/.github/workflows/noop.yml @@ -10,7 +10,7 @@ on: - ".changeset/config.json" - ".github/**" - "!.github/workflows/js-sdk.yml" - - "!.github/workflows/mls-client.yml" + - "!.github/workflows/node-sdk.yml" - "!.github/workflows/content-types.yml" - ".vscode/**" - ".yarn/**" diff --git a/sdks/mls-client/.eslintrc.cjs b/sdks/node-sdk/.eslintrc.cjs similarity index 100% rename from sdks/mls-client/.eslintrc.cjs rename to sdks/node-sdk/.eslintrc.cjs diff --git a/sdks/mls-client/CHANGELOG.md b/sdks/node-sdk/CHANGELOG.md similarity index 99% rename from sdks/mls-client/CHANGELOG.md rename to sdks/node-sdk/CHANGELOG.md index 9f5a3b79..6be30cbf 100644 --- a/sdks/mls-client/CHANGELOG.md +++ b/sdks/node-sdk/CHANGELOG.md @@ -1,4 +1,4 @@ -# @xmtp/mls-client +# @xmtp/node-sdk ## 0.0.16 diff --git a/sdks/mls-client/LICENSE b/sdks/node-sdk/LICENSE similarity index 100% rename from sdks/mls-client/LICENSE rename to sdks/node-sdk/LICENSE diff --git a/sdks/mls-client/README.md b/sdks/node-sdk/README.md similarity index 100% rename from sdks/mls-client/README.md rename to sdks/node-sdk/README.md diff --git a/sdks/mls-client/package.json b/sdks/node-sdk/package.json similarity index 92% rename from sdks/mls-client/package.json rename to sdks/node-sdk/package.json index b7fdfbc6..331356f3 100644 --- a/sdks/mls-client/package.json +++ b/sdks/node-sdk/package.json @@ -1,7 +1,7 @@ { - "name": "@xmtp/mls-client", + "name": "@xmtp/node-sdk", "version": "0.0.16", - "description": "XMTP MLS client for interacting with XMTP networks", + "description": "XMTP Node client SDK for interacting with XMTP networks", "keywords": [ "xmtp", "messaging", @@ -18,7 +18,7 @@ "repository": { "type": "git", "url": "git+https://git@github.com/xmtp/xmtp-js.git", - "directory": "packages/mls-client" + "directory": "packages/node-sdk" }, "license": "MIT", "author": "XMTP Labs ", @@ -51,7 +51,7 @@ "dependencies": { "@xmtp/content-type-primitives": "^1.0.1", "@xmtp/content-type-text": "^1.0.0", - "@xmtp/mls-client-bindings-node": "^0.0.12", + "@xmtp/node-bindings": "^0.0.13", "@xmtp/proto": "^3.62.1" }, "devDependencies": { diff --git a/sdks/mls-client/rollup.config.js b/sdks/node-sdk/rollup.config.js similarity index 96% rename from sdks/mls-client/rollup.config.js rename to sdks/node-sdk/rollup.config.js index 0ab934c8..39aff655 100644 --- a/sdks/mls-client/rollup.config.js +++ b/sdks/node-sdk/rollup.config.js @@ -10,7 +10,7 @@ const external = [ "node:process", "@xmtp/content-type-text", "@xmtp/content-type-primitives", - "@xmtp/mls-client-bindings-node", + "@xmtp/node-bindings", "@xmtp/proto", "@xmtp/xmtp-js", ]; diff --git a/sdks/mls-client/src/AsyncStream.ts b/sdks/node-sdk/src/AsyncStream.ts similarity index 100% rename from sdks/mls-client/src/AsyncStream.ts rename to sdks/node-sdk/src/AsyncStream.ts diff --git a/sdks/mls-client/src/Client.ts b/sdks/node-sdk/src/Client.ts similarity index 89% rename from sdks/mls-client/src/Client.ts rename to sdks/node-sdk/src/Client.ts index c88582f1..9699be56 100644 --- a/sdks/mls-client/src/Client.ts +++ b/sdks/node-sdk/src/Client.ts @@ -14,7 +14,7 @@ import { NapiSignatureRequestType, type NapiClient, type NapiMessage, -} from "@xmtp/mls-client-bindings-node"; +} from "@xmtp/node-bindings"; import { ContentTypeGroupUpdated, GroupUpdatedCodec, @@ -45,19 +45,13 @@ export type NetworkOptions = { }; /** - * Encryption options + * Storage options */ -export type EncryptionOptions = { +export type StorageOptions = { /** * Encryption key to use for the local DB */ encryptionKey?: Uint8Array | null; -}; - -/** - * Storage options - */ -export type StorageOptions = { /** * Path to the local DB */ @@ -71,10 +65,21 @@ export type ContentOptions = { codecs?: ContentCodec[]; }; +export type OtherOptions = { + /** + * Optionally set the request history sync URL + */ + requestHistorySync?: string; + /** + * Optionally set the logging level (default: 'off') + */ + logging?: "debug" | "info" | "warn" | "error" | "off"; +}; + export type ClientOptions = NetworkOptions & - EncryptionOptions & StorageOptions & - ContentOptions; + ContentOptions & + OtherOptions; export class Client { #innerClient: NapiClient; @@ -107,6 +112,8 @@ export class Client { inboxId, accountAddress, options?.encryptionKey, + options?.requestHistorySync, + options?.logging ?? "off", ), [new GroupUpdatedCodec(), new TextCodec(), ...(options?.codecs ?? [])], ); @@ -201,4 +208,14 @@ export class Client { async inboxState(refreshFromNetwork: boolean = false) { return this.#innerClient.inboxState(refreshFromNetwork); } + + async inboxStateFromInboxIds( + inboxIds: string[], + refreshFromNetwork?: boolean, + ) { + return this.#innerClient.addressesFromInboxId( + refreshFromNetwork ?? false, + inboxIds, + ); + } } diff --git a/sdks/mls-client/src/Conversation.ts b/sdks/node-sdk/src/Conversation.ts similarity index 98% rename from sdks/mls-client/src/Conversation.ts rename to sdks/node-sdk/src/Conversation.ts index f778b2ae..acfc47d2 100644 --- a/sdks/mls-client/src/Conversation.ts +++ b/sdks/node-sdk/src/Conversation.ts @@ -1,9 +1,6 @@ import type { ContentTypeId } from "@xmtp/content-type-primitives"; import { ContentTypeText } from "@xmtp/content-type-text"; -import type { - NapiGroup, - NapiListMessagesOptions, -} from "@xmtp/mls-client-bindings-node"; +import type { NapiGroup, NapiListMessagesOptions } from "@xmtp/node-bindings"; import { AsyncStream, type StreamCallback } from "@/AsyncStream"; import type { Client } from "@/Client"; import { DecodedMessage } from "@/DecodedMessage"; diff --git a/sdks/mls-client/src/Conversations.ts b/sdks/node-sdk/src/Conversations.ts similarity index 98% rename from sdks/mls-client/src/Conversations.ts rename to sdks/node-sdk/src/Conversations.ts index c1bdcb65..9df05cf4 100644 --- a/sdks/mls-client/src/Conversations.ts +++ b/sdks/node-sdk/src/Conversations.ts @@ -2,7 +2,7 @@ import type { NapiConversations, NapiCreateGroupOptions, NapiListMessagesOptions, -} from "@xmtp/mls-client-bindings-node"; +} from "@xmtp/node-bindings"; import { AsyncStream, type StreamCallback } from "@/AsyncStream"; import type { Client } from "@/Client"; import { Conversation } from "@/Conversation"; diff --git a/sdks/mls-client/src/DecodedMessage.ts b/sdks/node-sdk/src/DecodedMessage.ts similarity index 97% rename from sdks/mls-client/src/DecodedMessage.ts rename to sdks/node-sdk/src/DecodedMessage.ts index e46f54e3..dd0e8744 100644 --- a/sdks/mls-client/src/DecodedMessage.ts +++ b/sdks/node-sdk/src/DecodedMessage.ts @@ -3,7 +3,7 @@ import { NapiDeliveryStatus, NapiGroupMessageKind, type NapiMessage, -} from "@xmtp/mls-client-bindings-node"; +} from "@xmtp/node-bindings"; import type { Client } from "@/Client"; import { nsToDate } from "@/helpers/date"; diff --git a/sdks/mls-client/src/codecs/GroupUpdatedCodec.ts b/sdks/node-sdk/src/codecs/GroupUpdatedCodec.ts similarity index 100% rename from sdks/mls-client/src/codecs/GroupUpdatedCodec.ts rename to sdks/node-sdk/src/codecs/GroupUpdatedCodec.ts diff --git a/sdks/mls-client/src/helpers/date.ts b/sdks/node-sdk/src/helpers/date.ts similarity index 100% rename from sdks/mls-client/src/helpers/date.ts rename to sdks/node-sdk/src/helpers/date.ts diff --git a/sdks/mls-client/src/index.ts b/sdks/node-sdk/src/index.ts similarity index 85% rename from sdks/mls-client/src/index.ts rename to sdks/node-sdk/src/index.ts index 6cd9e5c2..1093c0bf 100644 --- a/sdks/mls-client/src/index.ts +++ b/sdks/node-sdk/src/index.ts @@ -1,6 +1,6 @@ export type { ClientOptions, - EncryptionOptions, + OtherOptions, NetworkOptions, StorageOptions, XmtpEnv, @@ -14,4 +14,4 @@ export { GroupUpdatedCodec, } from "./codecs/GroupUpdatedCodec"; export type { StreamCallback } from "./AsyncStream"; -export type * from "@xmtp/mls-client-bindings-node"; +export type * from "@xmtp/node-bindings"; diff --git a/sdks/mls-client/test/Client.test.ts b/sdks/node-sdk/test/Client.test.ts similarity index 73% rename from sdks/mls-client/test/Client.test.ts rename to sdks/node-sdk/test/Client.test.ts index 8eb61b85..9a7be644 100644 --- a/sdks/mls-client/test/Client.test.ts +++ b/sdks/node-sdk/test/Client.test.ts @@ -47,4 +47,21 @@ describe("Client", () => { ]); expect(inboxState.recoveryAddress).toBe(user.account.address.toLowerCase()); }); + + it("should get inbox states from inbox IDs", async () => { + const user = createUser(); + const client = await createRegisteredClient(user); + const inboxStates = await client.inboxStateFromInboxIds([client.inboxId]); + expect(inboxStates.length).toBe(1); + expect(inboxStates[0].inboxId).toBe(client.inboxId); + expect(inboxStates[0].installations.map((install) => install.id)).toEqual([ + client.installationId, + ]); + expect(inboxStates[0].accountAddresses).toEqual([ + user.account.address.toLowerCase(), + ]); + expect(inboxStates[0].recoveryAddress).toBe( + user.account.address.toLowerCase(), + ); + }); }); diff --git a/sdks/mls-client/test/Conversation.test.ts b/sdks/node-sdk/test/Conversation.test.ts similarity index 100% rename from sdks/mls-client/test/Conversation.test.ts rename to sdks/node-sdk/test/Conversation.test.ts diff --git a/sdks/mls-client/test/Conversations.test.ts b/sdks/node-sdk/test/Conversations.test.ts similarity index 99% rename from sdks/mls-client/test/Conversations.test.ts rename to sdks/node-sdk/test/Conversations.test.ts index 388a0d74..29bd5803 100644 --- a/sdks/mls-client/test/Conversations.test.ts +++ b/sdks/node-sdk/test/Conversations.test.ts @@ -1,4 +1,4 @@ -import { NapiGroupPermissionsOptions } from "@xmtp/mls-client-bindings-node"; +import { NapiGroupPermissionsOptions } from "@xmtp/node-bindings"; import { describe, expect, it } from "vitest"; import { createRegisteredClient, createUser } from "@test/helpers"; diff --git a/sdks/mls-client/test/helpers.ts b/sdks/node-sdk/test/helpers.ts similarity index 100% rename from sdks/mls-client/test/helpers.ts rename to sdks/node-sdk/test/helpers.ts diff --git a/sdks/mls-client/tsconfig.json b/sdks/node-sdk/tsconfig.json similarity index 100% rename from sdks/mls-client/tsconfig.json rename to sdks/node-sdk/tsconfig.json diff --git a/sdks/mls-client/vitest.config.ts b/sdks/node-sdk/vitest.config.ts similarity index 100% rename from sdks/mls-client/vitest.config.ts rename to sdks/node-sdk/vitest.config.ts diff --git a/sdks/mls-client/vitest.setup.ts b/sdks/node-sdk/vitest.setup.ts similarity index 100% rename from sdks/mls-client/vitest.setup.ts rename to sdks/node-sdk/vitest.setup.ts diff --git a/yarn.lock b/yarn.lock index baf49cd7..5e894e11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2697,16 +2697,16 @@ __metadata: languageName: unknown linkType: soft -"@xmtp/mls-client-bindings-node@npm:^0.0.12": - version: 0.0.12 - resolution: "@xmtp/mls-client-bindings-node@npm:0.0.12" - checksum: 10/90d48198dc7419c3365a55a0227d6aafbe70580e7a5a5c240a40f500fbcbb939c88bc4280c2ec85e9ef046064507f2818ef124f0fa3449c82bedbd0fc308214e +"@xmtp/node-bindings@npm:^0.0.13": + version: 0.0.13 + resolution: "@xmtp/node-bindings@npm:0.0.13" + checksum: 10/98c8a26cdc56c9b0dab794ca933a0be002bdf8d7e7ebdf1ad7ed33c015eeb7ffa5773185b077dd68e6f53509b12e30971a3963e611a8f42693fd11493fe4d802 languageName: node linkType: hard -"@xmtp/mls-client@workspace:sdks/mls-client": +"@xmtp/node-sdk@workspace:sdks/node-sdk": version: 0.0.0-use.local - resolution: "@xmtp/mls-client@workspace:sdks/mls-client" + resolution: "@xmtp/node-sdk@workspace:sdks/node-sdk" dependencies: "@rollup/plugin-json": "npm:^6.1.0" "@rollup/plugin-typescript": "npm:^12.1.0" @@ -2716,7 +2716,7 @@ __metadata: "@vitest/coverage-v8": "npm:^2.1.2" "@xmtp/content-type-primitives": "npm:^1.0.1" "@xmtp/content-type-text": "npm:^1.0.0" - "@xmtp/mls-client-bindings-node": "npm:^0.0.12" + "@xmtp/node-bindings": "npm:^0.0.13" "@xmtp/proto": "npm:^3.62.1" "@xmtp/xmtp-js": "workspace:^" eslint: "npm:^8.57.0"