The @zcloak/login-verify module offers functionalities for verifying zkID Login information using either Decentralized Identifiers (DID) or Verifiable Credentials (VCs).
yarn add @zcloak/login-verifyimport { verifyDidLogin } from '@zcloak/login-verify';
...
The method:
verifyDidLogin(params)
export async function verifyDidLogin<T extends 'did_login' | 'did_login$Kilt' = 'did_login'>(
message: HexString | Uint8Array | string,
data: RequestRpcs<T>[T][1],
resolver?: DidResolver
): Promise<boolean> {
//......
}
didLogin(params) function in the Provider, verifyDidLogin(params) function helps verify whether the User is actually the Owner of the DID.message - the message which the User signed on (this should be the same with the massage in didLogin(params))signature - the signature on that message, started with '0x'publicKey - the publicKey of User's AuthenticationKey, which is contains in the DID info (can be obtained by getCurrentDid() function in the Provider.Boolean - Whether the signature is actually signed by the User (in other word -- Whether developers should allow the User to login)Key methods include:
verifyCredentialDigest(params)
export async function verifyCredentialDigest<
T extends
| 'did_requestCredentialDigest'
| 'did_requestCredentialDigest$Kilt' = 'did_requestCredentialDigest'
>(
credentialDigest: RequestRpcs<T>[T][1],
challenge: string,
owner: T extends 'did_requestCredentialDigest' ? DidUrl : DidUri,
resolver?: DidResolver
): Promise<boolean> {
//......
}
verifyCredentialDigest method provided in our SDK can be used to check whether the Digest Disclosure is valid, whether the User is the Credential’s Owner.credentialDigest - the RequestCredentialDigestReponse of login-rpc, can be obtained use did_requestCredentialDigest methodchallenge - a random string, the same with the challenge in the did_requestCredentialDigest methodowner - the credential owner