Skip to content

Commit

Permalink
update the validator
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Nov 28, 2024
1 parent 0eae3f6 commit 844e312
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions packages/frames-validator/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,21 @@ export async function validateFramesPost(
throw new Error("Invalid wallet address");
}
} else {
const randomWallet = Wallet.createRandom();
const encryptionKey = getRandomValues(new Uint8Array(32));
const client = await Client.create(
{
getAddress: () => randomWallet.address,
signMessage: async (message: string) =>
getBytes(await randomWallet.signMessage(message)),
},
encryptionKey,
);

// make sure inbox IDs match
const authorized = await client.isInstallationAuthorized(
const authorized = await Client.isInstallationAuthorized(
{ env },
inboxId,
installationId,
);
if (!authorized) {
throw new Error("Installation not a member of association state");
}

const isMember = await client.isAddressAuthorized(inboxId, walletAddress);
const isMember = await Client.isAddressAuthorized(
{ env },
inboxId,
walletAddress,
);

if (!isMember) {
throw new Error("Unable to associate wallet address with inbox");
Expand Down
2 changes: 1 addition & 1 deletion sdks/node-sdk/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export class Client {
return await isAddressAuthorizedBinding(host, inboxId, address);
}

static async isInstallationAuthori(
static async isInstallationAuthorized(
networkOptions: NetworkOptions,
inboxId: string,
installation: Uint8Array,
Expand Down

0 comments on commit 844e312

Please sign in to comment.