From 35ea1f6c29c92c3e70df8e4bf30428306e8c14be Mon Sep 17 00:00:00 2001 From: Dakota Brink Date: Tue, 26 Nov 2024 10:08:45 -0500 Subject: [PATCH] authorize with lib --- packages/frames-validator/package.json | 2 +- packages/frames-validator/src/validation.ts | 4 ++-- sdks/node-sdk/package.json | 4 ++-- sdks/node-sdk/src/Client.ts | 7 ++++++ yarn.lock | 26 ++++++++++++++++++--- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/packages/frames-validator/package.json b/packages/frames-validator/package.json index 68f61891..a8c47397 100644 --- a/packages/frames-validator/package.json +++ b/packages/frames-validator/package.json @@ -40,7 +40,7 @@ "dependencies": { "@noble/curves": "^1.3.0", "@noble/hashes": "^1.4.0", - "@xmtp/node-sdk": "^0.0.27", + "@xmtp/node-sdk": "workspace:^", "@xmtp/proto": "^3.72.3", "uint8array-extras": "^1.4.0", "viem": "^2.16.5" diff --git a/packages/frames-validator/src/validation.ts b/packages/frames-validator/src/validation.ts index d9713e7f..3aff65a6 100644 --- a/packages/frames-validator/src/validation.ts +++ b/packages/frames-validator/src/validation.ts @@ -48,8 +48,8 @@ export async function validateFramesPost( } } else { // make sure inbox IDs match - const addressInboxId = await getInboxIdForAddress(walletAddress, env); - if (inboxId !== addressInboxId) { + const authorized = Client.isAddressAuthorized(inboxId, walletAddress); + if (!authorized) { throw new Error("Invalid inbox ID"); } diff --git a/sdks/node-sdk/package.json b/sdks/node-sdk/package.json index aaea946d..35ad41fc 100644 --- a/sdks/node-sdk/package.json +++ b/sdks/node-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@xmtp/node-sdk", - "version": "0.0.27", + "version": "0.0.28", "description": "XMTP Node client SDK for interacting with XMTP networks", "keywords": [ "xmtp", @@ -53,7 +53,7 @@ "@xmtp/content-type-group-updated": "^1.0.1", "@xmtp/content-type-primitives": "^1.0.3", "@xmtp/content-type-text": "^1.0.1", - "@xmtp/node-bindings": "^0.0.22", + "@xmtp/node-bindings": "^0.0.23", "@xmtp/proto": "^3.72.3" }, "devDependencies": { diff --git a/sdks/node-sdk/src/Client.ts b/sdks/node-sdk/src/Client.ts index 2bd7eff0..eaea9149 100644 --- a/sdks/node-sdk/src/Client.ts +++ b/sdks/node-sdk/src/Client.ts @@ -172,6 +172,13 @@ export class Client { return this.#innerClient.isRegistered(); } + async isAddressAuthorized( + inboxId: string, + address: string, + ): Promise { + return this.#innerClient.isAddressAuthorized(inboxId, address); + } + async #createInboxSignatureText() { try { const signatureText = await this.#innerClient.createInboxSignatureText(); diff --git a/yarn.lock b/yarn.lock index 011b1f85..af9672c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5065,7 +5065,7 @@ __metadata: "@rollup/plugin-typescript": "npm:^12.1.1" "@types/bl": "npm:^5.1.4" "@xmtp/frames-client": "npm:^1.0.0" - "@xmtp/node-sdk": "npm:^0.0.27" + "@xmtp/node-sdk": "workspace:^" "@xmtp/proto": "npm:^3.72.3" "@xmtp/xmtp-js": "npm:^12.1.0" ethers: "npm:^6.10.0" @@ -5086,7 +5086,27 @@ __metadata: languageName: node linkType: hard -"@xmtp/node-sdk@npm:^0.0.27, @xmtp/node-sdk@workspace:sdks/node-sdk": +"@xmtp/node-bindings@npm:^0.0.23": + version: 0.0.23 + resolution: "@xmtp/node-bindings@npm:0.0.23" + checksum: 10/c7327d874c0ec05027bb40b9d51bcc436662aabb9a8d342fbf8ef96f03fe103a596785b312e760b76df68f8176fe8baf348019328f89ff63e4faed17219fbe61 + languageName: node + linkType: hard + +"@xmtp/node-sdk@npm:^0.0.27": + version: 0.0.27 + resolution: "@xmtp/node-sdk@npm:0.0.27" + dependencies: + "@xmtp/content-type-group-updated": "npm:^1.0.1" + "@xmtp/content-type-primitives": "npm:^1.0.3" + "@xmtp/content-type-text": "npm:^1.0.1" + "@xmtp/node-bindings": "npm:^0.0.22" + "@xmtp/proto": "npm:^3.72.3" + checksum: 10/9937c77d4bd3f3ed8df2f9938e940e2c21a7c8e8f06506d227bb97939f8294e0ae6ec6bc1498f528274257d61f9142e38639aa123c3ddf086a98d9cd041c0161 + languageName: node + linkType: hard + +"@xmtp/node-sdk@workspace:^, @xmtp/node-sdk@workspace:sdks/node-sdk": version: 0.0.0-use.local resolution: "@xmtp/node-sdk@workspace:sdks/node-sdk" dependencies: @@ -5097,7 +5117,7 @@ __metadata: "@xmtp/content-type-group-updated": "npm:^1.0.1" "@xmtp/content-type-primitives": "npm:^1.0.3" "@xmtp/content-type-text": "npm:^1.0.1" - "@xmtp/node-bindings": "npm:^0.0.22" + "@xmtp/node-bindings": "npm:^0.0.23" "@xmtp/proto": "npm:^3.72.3" "@xmtp/xmtp-js": "workspace:^" fast-glob: "npm:^3.3.2"