Skip to content

Commit

Permalink
feat: check load address
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Nov 25, 2024
1 parent feeebe6 commit 8d609a6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/internal/accountDelegation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,17 @@ export async function load<chain extends Chain | undefined>(
})
raw = rest.raw

// if `address` and `credentialId` were passed (to remove first signature),
// check to make sure `address` matches the key used for the second signature.
if (parameters.address && parameters.credentialId) {
const response = rest.raw.response as AuthenticatorAssertionResponse
const userHandle = Bytes.toHex(new Uint8Array(response.userHandle!))
if (address !== userHandle)
throw new Error(
`supplied address "${address}" does not match signature address "${userHandle}"`,
)
}

const wrappedSignature = wrapSignature({
metadata: getWebAuthnMetadata(metadata),
signature,
Expand Down

0 comments on commit 8d609a6

Please sign in to comment.