From 2ad6ee42d1765c9a2cf3d47a63b79a59c7dc74fb Mon Sep 17 00:00:00 2001 From: Geiner Grandez Valle Date: Thu, 10 Oct 2024 14:30:18 -0500 Subject: [PATCH] docs: update README --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e401a89..1e5853a 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,58 @@ const vcPayload: JwtCredentialPayload = { const privateKey = ""; const AMOY_CHAIN_ID = 80002; const issuer = createDidEthrFromPrivateKey(privateKey, {chainNameOrId: AMOY_CHAIN_ID}) -const proofTypeCredential = new ProofTypeJWT({issuer}) +const proofTypeJwtCredential = new ProofTypeJWT({issuer}) -const vcJwt = await proofTypeCredential.generateProof(vcPayload) +const vcJwt = await proofTypeJwtCredential.generateProof(vcPayload) console.log(vcJwt) // eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQi...0CQmqB14NnN5XxD0d_glLRs1Myc_LBJjnuNwE +``` + +## Verifying JWTs +```ts +import { ResolverOrOptions, ProofTypeJWT } from '@kaytrust/prooftypes' +const RPC_AMOY = ""; +const AMOY_CHAIN_ID = 80002; +const resolver:ResolverOrOptions = {registry: '0xBC56d0883ef228b2B16420E9002Ece0A46c893F8', rpcUrl: RPC_AMOY, chainId: AMOY_CHAIN_ID} +const proofTypeJwtCredential = new ProofTypeJWT({resolver}) + +const verifiedVC = await proofTypeJwtCredential.verifyProof(vcJwt) +console.log(verifiedVC) +/* +{ + "payload": { + // the original payload of the signed credential + }, + "doc": { + // the DID document of the credential issuer (as returned by the `resolver`) + }, + "issuer": "did:ethr:0xf1232f840f3ad7d23fcdaa84d6c66dac24efb198", //the credential issuer + "signer": { + //the publicKey entry of the `doc` that has signed the credential + }, + "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE1NjY...Sx3Y2IdWaUpatJQA", // the original credential + + //parsed payload aligned to the W3C data model + "verifiableCredential": { + "@context": [Array], + "type": [ "VerifiableCredential", "UniversityDegreeCredential" ], + "issuer": { + "id": "did:ethr:0xf1232f840f3ad7d23fcdaa84d6c66dac24efb198" + }, + "issuanceDate": "2019-07-12T16:51:22.000Z", + "credentialSubject": { + "id": "did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4" + "degree": { + "type": "BachelorDegree", + "name": "Baccalauréat en musiques numériques" + }, + }, + "proof": { + // proof type for internal use, NOT a registered vc-data-model type + "type": "JwtProof2020", + "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE1NjY...Sx3Y2IdWaUpatJQA" + } + } +} +*/ ``` \ No newline at end of file