Skip to content

Commit

Permalink
new bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Nov 28, 2024
1 parent 2cf9051 commit 0eae3f6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
8 changes: 5 additions & 3 deletions packages/frames-validator/src/validation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getRandomValues } from "crypto";
import { getRandomValues, randomBytes } from "crypto";

Check failure on line 1 in packages/frames-validator/src/validation.ts

View workflow job for this annotation

GitHub Actions / Lint

'randomBytes' is defined but never used. Allowed unused vars must match /^_/u
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";

Check failure on line 5 in packages/frames-validator/src/validation.ts

View workflow job for this annotation

GitHub Actions / Lint

'LangEn' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 5 in packages/frames-validator/src/validation.ts

View workflow job for this annotation

GitHub Actions / Lint

'Mnemonic' is defined but never used. Allowed unused vars must match /^_/u
import { uint8ArrayToHex } from "uint8array-extras";
import type {
UntrustedData,
Expand All @@ -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(
Expand Down Expand Up @@ -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(
{
Expand Down
2 changes: 1 addition & 1 deletion sdks/node-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
20 changes: 20 additions & 0 deletions sdks/node-sdk/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
generateInboxId,
getInboxIdForAddress,
GroupMessageKind,
isAddressAuthorized as isAddressAuthorizedBinding,
isInstallationAuthorized as isInstallationAuthorizedBinding,
LogLevel,
SignatureRequestType,
verifySignedWithPublicKey as verifySignedWithPublicKeyBinding,
Expand Down Expand Up @@ -452,4 +454,22 @@ export class Client {
return false;
}
}

static async isAddressAuthorized(
networkOptions: NetworkOptions,
inboxId: string,
address: string,
): Promise<boolean> {
const host = networkOptions.apiUrl || ApiUrls[networkOptions.env || "dev"];
return await isAddressAuthorizedBinding(host, inboxId, address);
}

static async isInstallationAuthori(
networkOptions: NetworkOptions,
inboxId: string,
installation: Uint8Array,
): Promise<boolean> {
const host = networkOptions.apiUrl || ApiUrls[networkOptions.env || "dev"];
return await isInstallationAuthorizedBinding(host, inboxId, installation);
}
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down

0 comments on commit 0eae3f6

Please sign in to comment.