verifySignature
Verify a signature against a message and a public key.
Types
function verifySignature (data: SignMessageResponseData): Promise<boolean>
interface SignMessageResponseData {
// The public key of the authenticated user
pubkey: string
/**
* The challenge that was requested to be signed
*/
challenge: string
/**
* The message that was signed by the authenticator,
* Note that the message may not be the original raw message,
* but is combined with client data and authenticator data
* according to [WebAuthn Spec](https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion).
*/
message: string
/**
* The signature of the message that was signed by the authenticator
*/
signature: string
/**
* key type of the authenticated user
*/
keyType: 'main_key' | 'sub_key' | 'main_session_key' | 'sub_session_key'
/**
* Custom state that will be returned to your app after signing
*/
state?: any
/**
* The algorithm of the signature.
* corresponds to the `value` field of the [COSE](https://www.iana.org/assignments/cose/cose.xhtml#algorithms) structure
*/
alg: number
/**
* The attestation of the signature,
* only available when keyType is `main_session_key` or `sub_session_key`
*/
attestation?: string
}
Example
import { signWithPopup, verifySignature } from '@joyid/core'
const { error, data } = await signWithPopup(request)
if (error == null) {
const result = await verifySignature(data)
alert(result) // true or false
}
Details
- See also: Guide - Verify Signature with a live demo