@sd-jwt/sd-jwt-vc
TypeScript icon, indicating that this package has built-in type declarations

0.7.2 • Public • Published

License NPM Release Stars

SD-JWT Implementation in JavaScript (TypeScript)

SD-JWT-VC

About

SD-JWT-VC format based on the core functions

Check the detail description in our github repo.

Installation

To install this project, run the following command:

# using npm
npm install @sd-jwt/sd-jwt-vc

# using yarn
yarn add @sd-jwt/sd-jwt-vc

# using pnpm
pnpm install @sd-jwt/sd-jwt-vc

Ensure you have Node.js installed as a prerequisite.

Usage

Here's a basic example of how to use this library:

import { DisclosureFrame } from '@sd-jwt/sd-jwt-vc';

// identifier of the issuer
const iss = 'University';

// issuance time
const iat = new Date().getTime() / 1000;

//unique identifier of the schema
const vct = 'University-Degree';

// Issuer defines the claims object with the user's information
const claims = {
  firstname: 'John',
  lastname: 'Doe',
  ssn: '123-45-6789',
  id: '1234',
};

// Issuer defines the disclosure frame to specify which claims can be disclosed/undisclosed
const disclosureFrame: DisclosureFrame<typeof claims> = {
  _sd: ['firstname', 'lastname', 'ssn'],
};

// Issuer issues a signed JWT credential with the specified claims and disclosure frame
// returns an encoded JWT
const credential = await sdjwt.issue(
  { iss, iat, vct, ...claims },
  disclosureFrame,
);

// Holder may validate the credential from the issuer
const valid = await sdjwt.validate(credential);

// Holder defines the presentation frame to specify which claims should be presented
// The list of presented claims must be a subset of the disclosed claims
const presentationFrame = ['firstname', 'ssn'];

// Holder creates a presentation using the issued credential and the presentation frame
// returns an encoded SD JWT.
const presentation = await sdjwt.present(credential, presentationFrame);

// Verifier can verify the presentation using the Issuer's public key
const verified = await sdjwt.verify(presentation);

Check out more details in our documentation or examples

Revocation

To add revocation capabilities, you can use the @sd-jwt/jwt-status-list library to create a JWT Status List and include it in the SD-JWT-VC.

Dependencies

  • @sd-jwt/core
  • @sd-jwt/types
  • @sd-jwt/utils
  • @sd-jwt/jwt-status-list

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.7.24,705latest
0.7.2-next.1341next

Version History

VersionDownloads (Last 7 Days)Published
0.7.2-next.1341
0.7.2-next.1242
0.7.2-next.117
0.7.2-next.105
0.7.2-next.91
0.7.2-next.81
0.7.2-next.71
0.7.2-next.61
0.7.2-next.51
0.7.2-next.41
0.7.24,705
0.7.2-next.21
0.7.2-next.11
0.7.2-next.01
0.7.1363
0.7.1-next.21
0.7.1-next.11
0.7.1-next.01
0.7.048
0.6.2-next.271
0.6.2-next.261
0.6.2-next.191
0.6.2-next.181
0.6.2-next.171
0.6.2-next.161
0.6.2-next.151
0.6.2-next.141
0.6.2-next.131
0.6.2-next.121
0.6.2-next.111
0.6.2-next.101
0.6.2-next.91
0.6.2-next.81
0.6.2-next.71
0.6.2-next.61
0.6.2-next.51
0.6.2-next.41
0.6.2-next.31
0.6.2-next.21
0.6.2-next.11
0.6.1147
0.6.1-next.71
0.6.1-next.61
0.6.1-next.51
0.5.1-next.141
0.6.01
0.5.1-next.121
0.4.1-next.131
0.4.1-next.121
0.5.01
0.4.1-next.81
0.4.1-next.21
0.4.1-next.91
0.4.1-next.71
0.4.1-next.61
0.4.1-next.51
0.4.1-next.31
0.4.01
0.3.2-next.1141
0.3.2-next.1131
0.3.2-next.1121
0.3.2-next.1111
0.3.2-next.1101
0.3.2-next.1091
0.3.2-next.1081
0.3.2-next.1071
0.3.2-next.1061
0.3.2-next.1051
0.3.2-next.1041
0.3.2-next.1031
0.3.2-next.1025
0.3.2-next.1011
0.3.2-next.1001
0.3.2-next.991
0.3.2-next.981
0.3.2-next.971
0.3.2-next.961
0.3.2-next.951
0.3.2-next.941

Package Sidebar

Install

npm i @sd-jwt/sd-jwt-vc

Weekly Downloads

5,433

Version

0.7.2

License

Apache-2.0

Unpacked Size

64.8 kB

Total Files

34

Last publish

Collaborators

  • openwalletfoundation
  • blu3beri