Skip to content

Instantly share code, notes, and snippets.

@polluterofminds
Last active April 5, 2022 17:30
Show Gist options
  • Save polluterofminds/a03110e485f0e74e407fdb10aa550239 to your computer and use it in GitHub Desktop.
Save polluterofminds/a03110e485f0e74e407fdb10aa550239 to your computer and use it in GitHub Desktop.
Members Only Step 5
async authorize(credentials) {
try {
const siwe = new SiweMessage(JSON.parse(credentials?.message || "{}"))
const domain = process.env.DOMAIN
if (siwe.domain !== domain) {
return null
}
if (siwe.nonce !== (await getCsrfToken({ req }))) {
return null
}
await siwe.validate(credentials?.signature || "");
const ownsNFT = await validateNFTOwnership(siwe.address);
if(!ownsNFT) {
return null
}
return {
id: siwe.address
}
} catch (e) {
return null
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment