diff --git a/packages/frames-validator/src/validation.ts b/packages/frames-validator/src/validation.ts index 0185cd16..12e9bdde 100644 --- a/packages/frames-validator/src/validation.ts +++ b/packages/frames-validator/src/validation.ts @@ -1,8 +1,8 @@ -import { getRandomValues } from "crypto"; +import { getRandomValues, randomBytes } from "crypto"; import { sha256 } from "@noble/hashes/sha256"; import { Client, type XmtpEnv } from "@xmtp/node-sdk"; import { fetcher, frames, type publicKey, type signature } from "@xmtp/proto"; -import { getBytes, Wallet } from "ethers"; +import { getBytes, LangEn, Mnemonic, Wallet } from "ethers"; import { uint8ArrayToHex } from "uint8array-extras"; import type { UntrustedData, @@ -13,6 +13,8 @@ import { verifyIdentityKeySignature, verifyWalletSignature } from "./utils.js"; export type * from "./types.js"; +// let seed = Mnemonic.fromEntropy(randomBytes(16), "", LangEn.wordlist()).computeSeed(); + const { b64Decode } = fetcher; export async function validateFramesPost( @@ -49,7 +51,7 @@ export async function validateFramesPost( throw new Error("Invalid wallet address"); } } else { - let randomWallet = Wallet.createRandom(); + const randomWallet = Wallet.createRandom(); const encryptionKey = getRandomValues(new Uint8Array(32)); const client = await Client.create( { diff --git a/sdks/node-sdk/package.json b/sdks/node-sdk/package.json index 85669228..326e55bb 100644 --- a/sdks/node-sdk/package.json +++ b/sdks/node-sdk/package.json @@ -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.25", + "@xmtp/node-bindings": "^0.0.26", "@xmtp/proto": "^3.72.3" }, "devDependencies": { diff --git a/sdks/node-sdk/src/Client.ts b/sdks/node-sdk/src/Client.ts index c8f7e8ab..45845af2 100644 --- a/sdks/node-sdk/src/Client.ts +++ b/sdks/node-sdk/src/Client.ts @@ -15,6 +15,8 @@ import { generateInboxId, getInboxIdForAddress, GroupMessageKind, + isAddressAuthorized as isAddressAuthorizedBinding, + isInstallationAuthorized as isInstallationAuthorizedBinding, LogLevel, SignatureRequestType, verifySignedWithPublicKey as verifySignedWithPublicKeyBinding, @@ -452,4 +454,22 @@ export class Client { return false; } } + + static async isAddressAuthorized( + networkOptions: NetworkOptions, + inboxId: string, + address: string, + ): Promise { + const host = networkOptions.apiUrl || ApiUrls[networkOptions.env || "dev"]; + return await isAddressAuthorizedBinding(host, inboxId, address); + } + + static async isInstallationAuthori( + networkOptions: NetworkOptions, + inboxId: string, + installation: Uint8Array, + ): Promise { + const host = networkOptions.apiUrl || ApiUrls[networkOptions.env || "dev"]; + return await isInstallationAuthorizedBinding(host, inboxId, installation); + } } diff --git a/yarn.lock b/yarn.lock index 986bb607..0a4dd4eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5079,10 +5079,10 @@ __metadata: languageName: unknown linkType: soft -"@xmtp/node-bindings@npm:^0.0.25": - version: 0.0.25 - resolution: "@xmtp/node-bindings@npm:0.0.25" - checksum: 10/336f9b2a4a8b2781f6c53a7dd444428893f5e04a927350c82fcb79e37e0cc69abcb86406ffedeaa28115f1b57801890309546a10c9e806e3ed81b18b9d8f1431 +"@xmtp/node-bindings@npm:^0.0.26": + version: 0.0.26 + resolution: "@xmtp/node-bindings@npm:0.0.26" + checksum: 10/a5b97f6619f84aa8d9d27e695598a39769659039e6d1ee4637baae63ceefb796e9a1c05af1f681228c644ea701e64bdb590aec3dda2b59a768bae6734c2f9503 languageName: node linkType: hard @@ -5097,7 +5097,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.25" + "@xmtp/node-bindings": "npm:^0.0.26" "@xmtp/proto": "npm:^3.72.3" "@xmtp/xmtp-js": "workspace:^" fast-glob: "npm:^3.3.2"