3.4.0 • Published 9 months ago

@litentry/vc-sdk v3.4.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
-
Last release
9 months ago

@litentry/vc-sdk

This SDK provides the common functionality to help dApps parse and validate Litentry issued Verifiable Credentials.

A live example of this SDK's consumer application is identity-hub (https://idhub.litentry.io) where users request and generate their VCs and reveal their obtained VCs and share the relevant VCs should they consent to 3rd party applications.

Install

npm install @litentry/parachain-api @litentry/sidechain-api @litentry/vc-sdk

Examples

You can find more elaborated examples about the usage of this package on https://github.com/litentry/client-sdk-examples.

Below you will find some code snippets to guide you through the main functionalities.

Validate Verifiable Credential (VC)

Interaction with the Litentry parachain and TEE to validate whether the VC is an active VC issued by the Litentry.

What the validateVc function do

  • The validateVc function can only verify that the VC was issued by Litentry.
  • The VC's credentialSubject can be Substrate or EVM account that is support by Litentry.

What the validateVc function can't do

  • The validateVc function cannot validate that the VC's credentialSubject is the current wallet account. It's SDK's consumer's responsibility to validate the id of VC's credentialSubject is equal to the wallet address.

Example

import { WsProvider, ApiPromise } from '@polkadot/api';
import { validateVc } from '@litentry/vc-sdk';

const api: ApiPromise = await ApiPromise.create({
  provider: new WsProvider('wss://tee-prod.litentry.io'),
});
// vc json string
const vcJson =
  '{"@context": "https://www.w3.org/2018/credentials/v1", "type": "VerifiableCredential", "issuer": "https://example.com/issuer", "subject": "did:example:123", "credentialStatus": "https://example.com/status"}';
const result = await validateVc(api, vcJson);

// isValid is false if any field value of the result.detail is not true
if (!result.isValid) {
  // true or error message
  console.log('vcSignature: ', result.detail.vcSignature);
  // true or error message
  console.log('enclaveRegistry: ', result.detail.enclaveRegistry);
}

Note for simplicity, in above example it's assumed that SDK consumer application has to provide the api instance of ApiPromise and manage its lifecycle as well.

3.4.0

9 months ago

3.3.0-next.0

9 months ago

1.3.3

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.3.2

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

2.0.2

11 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.6.0-next.8

12 months ago

3.3.0

10 months ago

1.6.0-next.7

12 months ago

3.2.0

11 months ago

1.6.0-next.6

12 months ago

3.1.0

11 months ago

1.6.0-next.5

12 months ago

1.6.0-next.4

12 months ago

1.6.0-next.3

12 months ago

1.6.0-next.2

12 months ago

1.6.0-next.1

12 months ago

1.6.0-next.0

12 months ago

3.0.0

11 months ago

1.2.0

1 year ago

1.2.0-next.1

1 year ago

1.2.0-next.0

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago