0.0.6 • Published 2 years ago

vc-sdk v0.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Lit Verifiable Credentials SDK

Installation:

yarn add lit-vc-sdk

npm install lit-vc-sdk

Usage

The lit-vc-sdk uses Ceramic to store conditions. By default, the SDK connects to the Ceramic Clay Testnet. This can be changed by adding CERAMIC_NETWORK="<your desired network address>" to the .env

Planned functions and status (Sept 2022)

Issuer Functions

FunctionDescriptionStatus
issueCredentialissue and sign a verifiable credential (VC) to a receiverbeta
revokeCredentialrevoke previously issues credentialnot done

Receiver/User Functions

FunctionDescriptionStatus
verifyCredentialverify an issued credentialbeta
generatePresentationgenerate a verifiable presentation (VP) for a selected VCbeta
acceptCredentialaccept a credential issued to a the usernot done
burnCredentialremove a previously issued credentialnot done
requestCredentialrequest a credential from an issuernot done
transferCredentialtransfer a credential to another PKPnot done

Verifier Functions

FunctionDescriptionStatus
verifyPresentationverify an issued VPbeta
requestDecryptionrequest decryption rights over a VPnot done

Functions


issueCredential

issues a verifiable credential to a receiver

issueCredential(credential: Credential, proof: Proof, recipient: string): Promise<IssueCredentialResponse>

Parameters

credential (Credential): credential object

receiver (string): PKP Public key of VC receiving party

Returns

Promise\: A promise containing the Ceramic stream ID of the stored VC


verifyCredential

verifies a previously issued credential

verifyCredential(vcId: string, issuer: string): Promise<any>

Parameters

vcId(string): the Ceramic stream ID of the credential to verify

issuer(string): the PKP public key of the VC owner

Returns

Promise\<VerifyCredentialResponse>: A promise containing an object that includes a boolean verified property, as well as the verified credential obj.


generatePresentation

generates a VP for a given VC

generatePresentation(presentation: Presentation, credential: Credential[], issuer: string): Promise<any>

Parameters

presentation (Presentation): the presentation object

credential (Credential[]): an array of the credentials to include in the VP

issuer (string): the PKP public key of the party issuing the VP

Returns

Promise\<GeneratePresentationResponse>: A promise containing the Ceramic stream ID of the stored VP


verifyPresentation

verifies a previously issued presentation and the contained credentials

verifyPresentation(vcId: string, issuer: string): Promise<VerifyPresentationResponse>

Parameters

vcId(string): the Ceramic stream ID of the presentation to verify

issuer(string): the PKP public key of the VC owner

Returns

Promise\<VerifyPresentationResponse>: A promise containing an object that includes a boolean verified property, as well as the verified presentation obj.


Types


Credential

interface Credential {
  "@context": string[],
  id: string,
  type: string[],
  issuer: string,
  issuanceDate: string,
  credentialSubject: CredentialSubject,
  proof?: Proof
}

Presentation

interface Presentation {
  "@context": string[],
  type: string,
  proof?: Proof,
  issuer?: string
  verifiableCredential?: Credential[]
}

Proof

interface Proof {
  type: string,
  created: string,
  proofPurpose: string,
  verificationMethod: string,
  jws: string
}

VerifyCredentialResponse

interface VerifyCredentialResponse {
  recoveredCredential: Credential
  verified: boolean
}

GeneratePresentationResponse

interface GeneratePresentationResponse {
  docId: string,
  presentation: Presentation
}

VerifyPresentationResponse

interface VerifyPresentationResponse {
  recoveredPresentation: Presentation
  verified: boolean
}