diff --git a/README.md b/README.md index 39933f5..b283adc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -![Coverage](https://img.shields.io/badge/coverage-93%25-green) +![Coverage](https://img.shields.io/codecov/c/github/openwallet-foundation-labs/sd-jwt-js) ![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg) -![NPM](https://img.shields.io/npm/v/%40hopae%2Fsd-jwt) +![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Fcore) ![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js) ![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js) @@ -38,63 +38,24 @@ By adhering to these design principles, "Selective Disclosure for JWT" aims to s # How to use -## Installation +## Packages -To install this project, run the following command: +- **[@sd-jwt/core](./packages/core/README.md)**: Core library for selective disclosure JWTs +- **[@sd-jwt/decode](./packages/decode/README.md)**: Decode SD JWT into objects +- **[@sd-jwt/present](./packages/present/README.md)**: Present SD JWT +- **[@sd-jwt/utils](./packages/utils/README.md)**: Utility functions for SD JWT +- **[@sd-jwt/types](./packages/types/README.md)**: Types for SD JWT +- **[@sd-jwt/hash](./packages/hash/README.md)**: SHA-256 support for SD JWT +- **[@sd-jwt/crypto-nodejs](./packages/node-crypto/README.md)**: Nodejs Crypto support for SD JWT +- **[@sd-jwt/crypto-browser](./packages/browser-crypto/README.md)**: Browser Crypto support for SD JWT -```bash -npm install @hopae/sd-jwt -``` - -Ensure you have Node.js installed as a prerequisite. - -## Usage - -Here's a basic example of how to use this library: - -```jsx -import sdjwt, { DisclosureFrame } from '@hopae/sd-jwt'; - -// 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 = { - _sd: ['firstname', 'lastname', 'ssn'], -}; +## Version -// Issuer issues a signed JWT credential with the specified claims and disclosure frame -// returns an encoded JWT -const credential = await sdjwt.issue(claims, privateKey, disclosureFrame); +We keep all the versions of our packages in sync. -// Holder may validate the credential from the issuer -const valid = await sdjwt.validate(credential, publicKey); +It means for example, that if you are using `@sd-jwt/core@1.0.0`, you should use `@sd-jwt/decode@1.0.0`, `@sd-jwt/present@1.0.0` and so on. -// 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, publicKey); -``` - -Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/wiki) or [examples](./examples/) - -## Dependencies - -- "@noble/hashes": "1.0.0", - - pure js hash algorithm implementation with security audit (v1.0.0) -- "js-base64": "^3.7.6" - - pure js base64 implementation +# Development ## Build @@ -111,15 +72,13 @@ pnpm run build To run the test suite, execute: ```bash -# Unit tests pnpm test - -# E2E tests -pnpm test:e2e ``` We use [Vitest](https://vitest.dev/) for our testing framework. Ensure you have written tests for all new features. +We also use [CodeCov](https://app.codecov.io/gh/openwallet-foundation-labs/sd-jwt-js) for our testing coverage. You can check the details of coverage of each package + ## Security - [x] [Mandatory Signing of the Issuer-signed JWT](https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-06.html#name-mandatory-signing-of-the-is) diff --git a/docs/index.html b/docs/index.html index 8fd413e..d942b90 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3,7 +3,18 @@ - SD JWT - TypeScript JWT Library + + + + + + + + + + + + SD JWT - TypeScript SD JWT Library + + + + + + + + + + + What is SD JWT? = { + _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(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](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/examples) + +### Dependencies + +- @sd-jwt/decode +- @sd-jwt/types +- @sd-jwt/utils diff --git a/packages/decode/README.md b/packages/decode/README.md new file mode 100644 index 0000000..7be6ad1 --- /dev/null +++ b/packages/decode/README.md @@ -0,0 +1,40 @@ +![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg) +![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Fdecode) +![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js) +![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js) + +# SD-JWT Implementation in JavaScript (TypeScript) + +## SD-JWT Decode + +### About + +Decode SD JWT into objects + +Check the detail description in our github [repo](https://github.com/openwallet-foundation-labs/sd-jwt-js). + +### Installation + +To install this project, run the following command: + +```bash +# using npm +npm install @sd-jwt/decode + +# using yarn +yarn add @sd-jwt/decode + +# using pnpm +pnpm install @sd-jwt/decode +``` + +Ensure you have Node.js installed as a prerequisite. + +### Usage + +Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/examples) + +### Dependencies + +- @sd-jwt/types +- @sd-jwt/utils diff --git a/packages/hash/README.md b/packages/hash/README.md new file mode 100644 index 0000000..07b2419 --- /dev/null +++ b/packages/hash/README.md @@ -0,0 +1,40 @@ +![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg) +![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Fhash) +![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js) +![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js) + +# SD-JWT Implementation in JavaScript (TypeScript) + +## SD-JWT Hash + +### About + +SHA-256 support for SD JWT + +Check the detail description in our github [repo](https://github.com/openwallet-foundation-labs/sd-jwt-js). + +### Installation + +To install this project, run the following command: + +```bash +# using npm +npm install @sd-jwt/hash + +# using yarn +yarn add @sd-jwt/hash + +# using pnpm +pnpm install @sd-jwt/hash +``` + +Ensure you have Node.js installed as a prerequisite. + +### Usage + +Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/examples) + +### Dependencies + +- "@noble/hashes": "1.0.0", + - pure js hash algorithm implementation with security audit (v1.0.0) diff --git a/packages/node-crypto/README.md b/packages/node-crypto/README.md new file mode 100644 index 0000000..5cea669 --- /dev/null +++ b/packages/node-crypto/README.md @@ -0,0 +1,39 @@ +![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg) +![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Fcrypto-nodejs) +![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js) +![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js) + +# SD-JWT Implementation in JavaScript (TypeScript) + +## SD-JWT Nodejs Crypto + +### About + +Nodejs Crypto support for SD JWT + +Check the detail description in our github [repo](https://github.com/openwallet-foundation-labs/sd-jwt-js). + +### Installation + +To install this project, run the following command: + +```bash +# using npm +npm install @sd-jwt/crypto-nodejs + +# using yarn +yarn add @sd-jwt/crypto-nodejs + +# using pnpm +pnpm install @sd-jwt/crypto-nodejs +``` + +Ensure you have Node.js installed as a prerequisite. + +### Usage + +Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/examples) + +### Dependencies + +None diff --git a/packages/present/README.md b/packages/present/README.md new file mode 100644 index 0000000..509b91c --- /dev/null +++ b/packages/present/README.md @@ -0,0 +1,41 @@ +![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg) +![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Fpresent) +![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js) +![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js) + +# SD-JWT Implementation in JavaScript (TypeScript) + +## SD-JWT Present + +### About + +Present SD JWT + +Check the detail description in our github [repo](https://github.com/openwallet-foundation-labs/sd-jwt-js). + +### Installation + +To install this project, run the following command: + +```bash +# using npm +npm install @sd-jwt/present + +# using yarn +yarn add @sd-jwt/present + +# using pnpm +pnpm install @sd-jwt/present +``` + +Ensure you have Node.js installed as a prerequisite. + +### Usage + +Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/examples) + +### Dependencies + +- @sd-jwt/decode +- @sd-jwt/types +- @sd-jwt/utils diff --git a/packages/types/README.md b/packages/types/README.md new file mode 100644 index 0000000..b35f2fb --- /dev/null +++ b/packages/types/README.md @@ -0,0 +1,39 @@ +![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg) +![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Ftypes) +![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js) +![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js) + +# SD-JWT Implementation in JavaScript (TypeScript) + +## SD-JWT Browser Types + +### About + +Types for SD JWT + +Check the detail description in our github [repo](https://github.com/openwallet-foundation-labs/sd-jwt-js). + +### Installation + +To install this project, run the following command: + +```bash +# using npm +npm install @sd-jwt/types + +# using yarn +yarn add @sd-jwt/types + +# using pnpm +pnpm install @sd-jwt/types +``` + +Ensure you have Node.js installed as a prerequisite. + +### Usage + +Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/examples) + +### Dependencies + +None diff --git a/packages/utils/README.md b/packages/utils/README.md new file mode 100644 index 0000000..87e568e --- /dev/null +++ b/packages/utils/README.md @@ -0,0 +1,41 @@ +![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg) +![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Futils) +![Release](https://img.shields.io/github/v/release/openwallet-foundation-labs/sd-jwt-js) +![Stars](https://img.shields.io/github/stars/openwallet-foundation-labs/sd-jwt-js) + +# SD-JWT Implementation in JavaScript (TypeScript) + +## SD-JWT Utils + +### About + +Utility functions for SD JWT + +Check the detail description in our github [repo](https://github.com/openwallet-foundation-labs/sd-jwt-js). + +### Installation + +To install this project, run the following command: + +```bash +# using npm +npm install @sd-jwt/utils + +# using yarn +yarn add @sd-jwt/utils + +# using pnpm +pnpm install @sd-jwt/utils +``` + +Ensure you have Node.js installed as a prerequisite. + +### Usage + +Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/next/examples) + +### Dependencies + +- @sd-jwt/types +- "js-base64": "^3.7.6" + - pure js base64 implementation diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a6ba6ba..491f0af 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -105,7 +105,7 @@ importers: specifier: ^5.3.3 version: 5.3.3 - packages/broswer-crypto: {} + packages/browser-crypto: {} packages/core: dependencies: