# @eengineer1/veramo-credential-sd-jwt

> This repository contains a plugin for the [Veramo](https://github.com/decentralized-identity/veramo) verifiable data framework that leverages the following specification compliant [SD-JWT (Selective Disclosure JSON Web Token) library](https://github.com/E

Latest version **1.0.1** (published 2023-12-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @eengineer1/veramo-credential-sd-jwt
pnpm add @eengineer1/veramo-credential-sd-jwt
yarn add @eengineer1/veramo-credential-sd-jwt
bun add @eengineer1/veramo-credential-sd-jwt
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-12-31 |
| First published | 2023-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.17.0 |
| Dependencies | 12 |
| Unpacked size | 87.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | eengineer1 |

## Links

- npm: https://www.npmjs.com/package/@eengineer1/veramo-credential-sd-jwt
- npm.io page: https://npm.io/package/@eengineer1/veramo-credential-sd-jwt

## Dependencies (12)

- [did-jwt](https://npm.io/package/did-jwt.md) ^7.4.7
- [did-jwt-vc](https://npm.io/package/did-jwt-vc.md) ^3.2.15
- [uint8arrays](https://npm.io/package/uint8arrays.md) ^5.0.1
- [@veramo/core](https://npm.io/package/@veramo/core.md) ^5.5.3
- [did-resolver](https://npm.io/package/did-resolver.md) ^4.1.0
- [@veramo/utils](https://npm.io/package/@veramo/utils.md) ^5.5.3
- [json-canonicalize](https://npm.io/package/json-canonicalize.md) ^1.0.6
- [@veramo/core-types](https://npm.io/package/@veramo/core-types.md) ^5.5.3
- [@veramo/did-manager](https://npm.io/package/@veramo/did-manager.md) ^5.5.3
- [@veramo/key-manager](https://npm.io/package/@veramo/key-manager.md) ^5.5.3
- [@veramo/credential-w3c](https://npm.io/package/@veramo/credential-w3c.md) ^5.5.3
- [@eengineer1/sd-jwt-ts-node](https://npm.io/package/@eengineer1/sd-jwt-ts-node.md) ^1.0.1

## Recent versions

- 1.0.1 (latest) — 2023-12-31
- 1.0.1-develop.1 (beta) — 2023-12-31
- 1.0.0 — 2023-12-30
- 1.0.0-develop.1 — 2023-12-30

## README

# Veramo SD-JWT Plugin

This repository contains a plugin for the [Veramo](https://github.com/decentralized-identity/veramo) verifiable data framework that leverages the following specification compliant [SD-JWT (Selective Disclosure JSON Web Token) library](https://github.com/Eengineer1/sd-jwt-ts).

[![Apache 2.0 License](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://choosealicense.com/licenses/mit/)

> ⚠️ This plugin is strictly an ESM module and requires Node.js >= 18.17.0.

## Overview

The Veramo SD-JWT plugin allows for privacy-preserving data sharing by enabling selective disclosure of data fields in a JWT credential payload. This is achieved by using the SD-JWT aforementioned library, which allows each field in the JWT payload to be individually disclosed.

## Installation

To install the Veramo SD-JWT plugin, use the following command:

```bash
npm install @eengineer1/veramo-credential-sd-jwt
```

## Usage

After installation, you can use the plugin in your Veramo agent as follows:

```typescript
import { createAgent, ... } from '@veramo/core'
import { CredentialSDJwt } from '@eengineer1/veramo-credential-sd-jwt'

const agent = new Agent({
    plugins: [
        ..., // other required plugins
        new CredentialSDJwt()
    ]
})
```

With the agent instantiated, you can now use the plugin to issue and / or verify SD-JWT credentials and presentations as follows:

```typescript
import { type CredentialPayload } from '@veramo/core-types'
import { type JSONObject } from '@eengineer1/sd-jwt-ts-node'

// original claimset
const claimset = {
    id: '7aea4ed3-9b02-4f64-8f05-aeb59899c8a2',
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    type: ['VerifiableCredential'],
    issuer: 'did:cheqd:testnet:09b20561-7339-40ea-a377-05ea35a0e82a',
    credentialSubject: {
        id: 'did:jwk:eyJhbGciOiJFUzI1NksiLCJjcnYiOiJzZWNwMjU2azEiLCJrdHkiOiJFQyIsInVzZSI6InNpZyIsIngiOiJmMmF2aHdTcTlNVGg4c0x0ZnBDZU1udnllSzdzVjIyRUtNZ2IzS1hOWXJZIiwieSI6ImFUUEY0OFZ5d0tKOFpJeEYzU0NweEtkNUhPeUt2cUZPWUcxQWc2Sm1qeVEifQ',
        nestedSimple: 'information',
        nestedObject: {
            nested: 'information',
        },
        nestedArray: ['information1', 'information2'],
    },
}

// non-selectively disclosable claimset
const undisclosedClaimset = {
    '@context': claimset['@context'],
    type: claimset.type,
    issuanceDate: 'anything-truthy',
    credentialSubject: {
        id: claimset.credentialSubject.id,
        nestedSimple: claimset.credentialSubject.nestedSimple,
    },
} satisfies JSONObject

// create + sign SD-JWT credential
const { sdJwt, normalisedCredential } = await agent.createVerifiableCredentialSDJwt({
    credential: claimset,
    undisclosedFields: undisclosedClaimset,
    removeOriginalFields: true,
    returnNormalisedCredential: true,
})

// verify SD-JWT credential
const { verified, message } = await agent.verifyVerifiableCredentialSDJwt({
    credential: sdJwt.jwt,
})

// create + sign SD-JWT presentation
const { sdJwtPresentation, normalisedPresentation } = await agent.createVerifiablePresentationSDJwt({
    presentation: {
    verifiableCredential: [sdJwt.jwt],
        holder: holder.didDocument.id,
    },
    removeOriginalFields: true,
    returnNormalisedPresentation: true,
})

// verify SD-JWT presentation
const { verified, message } = await agent.verifyVerifiablePresentationSDJwt({
    presentation: sdJwtPresentation,
})
```

## License

This project is licensed under the Apache 2.0 License. See the [LICENSE](./LICENSE) file for details.

---
_Source: https://npm.io/package/@eengineer1/veramo-credential-sd-jwt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
