Skip to content

Commit

Permalink
Add README.md for each packages (openwallet-foundation-labs#102)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas <[email protected]>
Signed-off-by: Lukas.J.Han <[email protected]>
Signed-off-by: Mirko Mollik <[email protected]>
  • Loading branch information
lukasjhan authored and cre8 committed Mar 8, 2024
1 parent 847b1c4 commit 7ed15c5
Show file tree
Hide file tree
Showing 18 changed files with 398 additions and 60 deletions.
75 changes: 17 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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<typeof claims> = {
_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/[email protected]`, you should use `@sd-jwt/[email protected]`, `@sd-jwt/[email protected]` 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

Expand All @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SD JWT - TypeScript JWT Library</title>
<meta name="description" content="SD JWT is a TypeScript library implementing the IETF SD-JWT specification for selective disclosure of JWT claims, enhancing privacy and security in digital communications." />
<meta name="keywords" content="SD JWT, TypeScript, JWT, JSON Web Token, selective disclosure, IETF, authentication, Node.js, React Native, security, privacy, data transmission" />
<meta name="author" content="OpenWallet Foundation" />
<meta property="og:title" content="SD JWT - TypeScript JWT Library" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://sdjwt.js.org" />
<meta property="og:image" content="https://avatars.githubusercontent.com/u/114502864?s=200&v=4" />
<meta property="og:description" content="SD JWT is a TypeScript library implementing the IETF SD-JWT specification for selective disclosure of JWT claims, enhancing privacy and security in digital communications." />
<meta property="og:site_name" content="SD JWT - TypeScript JWT Library" />
<meta property="og:locale" content="en_US" />
<link rel="canonical" href="https://sdjwt.js.org" />
<title>SD JWT - TypeScript SD JWT Library</title>
<link
href="https://unpkg.com/tailwindcss@^2.0/dist/tailwind.min.css"
rel="stylesheet"
Expand Down
11 changes: 11 additions & 0 deletions docs/sdjwt.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="SD JWT is a TypeScript library implementing the IETF SD-JWT specification for selective disclosure of JWT claims, enhancing privacy and security in digital communications." />
<meta name="keywords" content="SD JWT, TypeScript, JWT, JSON Web Token, selective disclosure, IETF, authentication, Node.js, React Native, security, privacy, data transmission" />
<meta name="author" content="OpenWallet Foundation" />
<meta property="og:title" content="SD JWT - TypeScript JWT Library" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://sdjwt.js.org" />
<meta property="og:image" content="https://avatars.githubusercontent.com/u/114502864?s=200&v=4" />
<meta property="og:description" content="SD JWT is a TypeScript library implementing the IETF SD-JWT specification for selective disclosure of JWT claims, enhancing privacy and security in digital communications." />
<meta property="og:site_name" content="SD JWT - TypeScript JWT Library" />
<meta property="og:locale" content="en_US" />
<link rel="canonical" href="https://sdjwt.js.org" />
<title>What is SD JWT?</title>
<link
href="https://unpkg.com/tailwindcss@^2.0/dist/tailwind.min.css"
Expand Down
39 changes: 39 additions & 0 deletions packages/browser-crypto/README.md
Original file line number Diff line number Diff line change
@@ -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-browser)
![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 Crypto

### About

Browser 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-browser

# using yarn
yarn add @sd-jwt/crypto-browser

# using pnpm
pnpm install @sd-jwt/crypto-browser
```

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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
![License](https://img.shields.io/github/license/openwallet-foundation-labs/sd-jwt-js.svg)
![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)

# SD-JWT Implementation in JavaScript (TypeScript)

## SD-JWT Core

### About

Core library for selective disclosure JWTs

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/core

# using yarn
yarn add @sd-jwt/core

# using pnpm
pnpm install @sd-jwt/core
```

Ensure you have Node.js installed as a prerequisite.

### Usage

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

```jsx
import { DisclosureFrame } from '@sd-jwt/core';

// 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(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
40 changes: 40 additions & 0 deletions packages/decode/README.md
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions packages/hash/README.md
Original file line number Diff line number Diff line change
@@ -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)
39 changes: 39 additions & 0 deletions packages/node-crypto/README.md
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 7ed15c5

Please sign in to comment.