# @sphereon/ssi-sdk-vc-handler-ld-local

> JSON-LD VC Handler Local (Typescript

Latest version **0.11.0** (published 2023-05-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @sphereon/ssi-sdk-vc-handler-ld-local
pnpm add @sphereon/ssi-sdk-vc-handler-ld-local
yarn add @sphereon/ssi-sdk-vc-handler-ld-local
bun add @sphereon/ssi-sdk-vc-handler-ld-local
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.11.0 |
| Published | 2023-05-07 |
| First published | 2021-11-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 30 |
| Unpacked size | 578.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 75 |
| Author | Sphereon |
| Maintainers | nklomp78, nklomp, spostma, bramtencate |
| Keywords | Sphereon, SSI, Veramo, W3C, Verifiable Credentials, Verifiable Presentations, JsonLd |

## Links

- npm: https://www.npmjs.com/package/@sphereon/ssi-sdk-vc-handler-ld-local
- Repository: https://github.com/Sphereon-Opensource/SSI-SDK
- Homepage: https://github.com/Sphereon-Opensource/SSI-SDK#readme
- Issues: https://github.com/Sphereon-Opensource/SSI-SDK/issues
- npm.io page: https://npm.io/package/@sphereon/ssi-sdk-vc-handler-ld-local

## Dependencies (30)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [jsonld](https://npm.io/package/jsonld.md) ^4.0.1
- [crypto-ld](https://npm.io/package/crypto-ld.md) ^6.0.0
- [did-context](https://npm.io/package/did-context.md) ^3.1.1
- [@veramo/core](https://npm.io/package/@veramo/core.md) 4.2.0
- [@veramo/utils](https://npm.io/package/@veramo/utils.md) 4.2.0
- [@transmute/jsonld](https://npm.io/package/@transmute/jsonld.md) ^0.0.4
- [jsonld-signatures](https://npm.io/package/jsonld-signatures.md) ^7.0.0
- [@transmute/jose-ld](https://npm.io/package/@transmute/jose-ld.md) 0.7.0-unstable.80
- [credentials-context](https://npm.io/package/credentials-context.md) ^2.0.0
- [@digitalcredentials/vc](https://npm.io/package/@digitalcredentials/vc.md) ^5.0.0
- [@sphereon/ssi-sdk-core](https://npm.io/package/@sphereon/ssi-sdk-core.md) ^0.11.0
- [@digitalcredentials/jsonld](https://npm.io/package/@digitalcredentials/jsonld.md) ^5.2.1
- [@sphereon/ssi-sdk-did-utils](https://npm.io/package/@sphereon/ssi-sdk-did-utils.md) ^0.11.0
- [@transmute/ed25519-key-pair](https://npm.io/package/@transmute/ed25519-key-pair.md) 0.7.0-unstable.80
- [@transmute/security-context](https://npm.io/package/@transmute/security-context.md) 0.7.0-unstable.80
- [@transmute/vc-status-rl-2020](https://npm.io/package/@transmute/vc-status-rl-2020.md) 0.7.0-unstable.80
- [@transmute/secp256k1-key-pair](https://npm.io/package/@transmute/secp256k1-key-pair.md) 0.7.0-unstable.80
- [@sphereon/isomorphic-webcrypto](https://npm.io/package/@sphereon/isomorphic-webcrypto.md) ^2.4.0-unstable.4
- [@transmute/web-crypto-key-pair](https://npm.io/package/@transmute/web-crypto-key-pair.md) 0.7.0-unstable.80
- [ed25519-signature-2018-context](https://npm.io/package/ed25519-signature-2018-context.md) ^1.1.0
- [ed25519-signature-2020-context](https://npm.io/package/ed25519-signature-2020-context.md) ^1.1.0
- [@digitalcredentials/rdf-canonize](https://npm.io/package/@digitalcredentials/rdf-canonize.md) ^1.0.0
- [@sphereon/ed25519-signature-2018](https://npm.io/package/@sphereon/ed25519-signature-2018.md) 0.7.0-unstable.6
- [@transmute/jsonld-document-loader](https://npm.io/package/@transmute/jsonld-document-loader.md) ^0.7.0-unstable.80
- [@mattrglobal/jsonld-signatures-bbs](https://npm.io/package/@mattrglobal/jsonld-signatures-bbs.md) ^1.1.1
- [@digitalcredentials/jsonld-signatures](https://npm.io/package/@digitalcredentials/jsonld-signatures.md) ^9.3.1
- [@digitalcredentials/ed25519-signature-2020](https://npm.io/package/@digitalcredentials/ed25519-signature-2020.md) ~3.0.2
- [@digitalcredentials/ed25519-verification-key-2020](https://npm.io/package/@digitalcredentials/ed25519-verification-key-2020.md) 3.2.2
- [@digitalcredentials/x25519-key-agreement-2020-context](https://npm.io/package/@digitalcredentials/x25519-key-agreement-2020-context.md) ^1.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.11.0 (latest) — 2023-05-07
- 0.10.2-unstable.72 (unstable) — 2023-05-07
- 0.10.2-next.11 (next) — 2023-05-07
- 0.10.1-unstable.73 — 2023-05-07
- 0.10.1-next.14 — 2023-05-06
- 0.10.1-next.13 — 2023-05-06
- 0.10.1-next.9 — 2023-05-05
- 0.10.1-next.8 — 2023-05-05
- 0.10.1-next.6 — 2023-05-04
- 0.10.1-unstable.52 — 2023-05-03
- 0.10.1-unstable.50 — 2023-05-03
- 0.10.1-unstable.49 — 2023-05-03
- 0.10.1-next.2 — 2023-05-01
- 0.10.0 — 2023-04-30
- 0.9.1-next.121 — 2023-04-30
- … 320 more at https://npm.io/package/@sphereon/ssi-sdk-vc-handler-ld-local/versions

## README

<!--suppress HtmlDeprecatedAttribute -->
<h1 align="center">
  <br>
  <a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
  <br>JSON-LD VC Handler Local (Typescript + React-Native) 
  <br>
</h1>

---

**Warning: This package still is in every early development. Breaking changes without notice will happen at this point!**

---

# vc-handler-ld-local

A Veramo plugin to issue and verify JSON-LD based credentials and presentations using a react-native capable port of Digital Bazaars VC library.

### Installation

```shell
yarn add @sphereon/ssi-sdk-vc-handler-ld-local
```

### Build

```shell
yarn build
```

### Test

The test command runs:

- `prettier`
- `jest`
- `coverage`

You can also run only a single section of these tests, using for example `yarn test:unit`.

```shell
yarn test
```

### Utility scripts

There are other utility scripts that help with development.

- `yarn fix` - runs `eslint --fix` as well as `prettier` to fix code style.

### Agent setup

```typescript
constructor(connection: Promise<Connection>) {
    const privateKeyStore = new PrivateKeyStore(connection, new SecretBox(KMS_SECRET_KEY))
    this._agent = createAgent<
      ICredentialHandlerLDLocal & IDIDManager & IKeyManager & IDataStore & IDataStoreORM & IResolver
    >({
      plugins: [
        new BlsKeyManager({
          store: new KeyStore(connection),
          kms: {
            local: new BlsKeyManagementSystem(privateKeyStore),
          },
        }),
        new DIDManager({
          store: new DIDStore(connection),
          defaultProvider: 'did:key',
          providers: {
            'did:key': new BlsKeyDidProvider({
              defaultKms: 'local',
            }),
          },
        }),
        new CredentialIssuer(),
        new CredentialHandlerLDLocal({
          contextMaps: [LdDefaultContexts],
          suites: [new SphereonEd25519Signature2018(), new SphereonEd25519Signature2020(), new SphereonBbsBlsSignature2020()],
          keyStore: privateKeyStore
        }),
        new DIDResolverPlugin({
          resolver: new Resolver({
            ...keyDidResolver()
          }),
        }),
      ],
    });
  }
```

- To support BLS+, the @sphereon/bls-\* plugins must be used, otherwise only Ed25519 plugins will be supported.

### Issue Verifiable Credentials using the Veramo agent:

Ed25519

```typescript
agent.createVerifiableCredentialLDLocal({
  credential: {
    issuer: 'did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt',
    credentialSubject: {
      id: 'did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt',
    },
  },
})
```

BBS+

```typescript
agent.createVerifiableCredentialLDLocal({
  credential: {
    issuer:
      'did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic',
    credentialSubject: {
      id: 'did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic',
    },
    '@context': ['https://w3id.org/security/bbs/v1'],
  },
  keyRef:
    'ad80e96c1f45ab12acc3064de578a5fe9737cd09459257b8abb56058199ef06ca04455ed3714ec30b9f50c186a7cfcb502d3469ae9458e2d3d1a0bf8a58215b0e23ad9620b9a961d0a0cd5484b8539efdce49d018508addbf099cf63f96bdd5d',
})
```

### Verify a Verifiable Credential using Veramo agent:

Ed25519

```typescript
agent.verifyCredentialLDLocal({
  credential: {
    issuer: 'did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt',
    credentialSubject: {
      id: 'did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt',
    },
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    type: ['VerifiableCredential'],
    issuanceDate: '2022-08-23T13:26:14.712Z',
    proof: {
      type: 'Ed25519Signature2018',
      created: '2022-08-23T13:26:14Z',
      verificationMethod: 'did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt#z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt',
      proofPurpose: 'assertionMethod',
      jws: 'eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..o9mN0c6Ax-YmAIPz6_kQb2IA_HtKkfFn1H1LFHfexsoznFmIeEL0azh3oo8iYVrAa674dgLSvlHn8Q6iXAi_DA',
    },
  },
  fetchRemoteContexts: true,
})
```

BBS+

```typescript
agent.verifyCredentialLDLocal({
  credential: {
    issuer:
      'did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic',
    credentialSubject: {
      id: 'did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic',
    },
    '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/security/bbs/v1'],
    type: ['VerifiableCredential'],
    issuanceDate: '2022-08-23T09:59:03.522Z',
    proof: {
      type: 'BbsBlsSignature2020',
      created: '2022-08-23T09:59:03Z',
      proofPurpose: 'assertionMethod',
      proofValue:
        'uLSsfDEFXea0yybm6i28/TrnDaoUc4hwweLqjwe4dbtvSZk+WlsKIyJoXZa2d8doD7cw8zOe8wTnwvZje4LxlNISsdfT6TWQy2O7toRWWXxqC3L2qrrtc/TY1Pfgu8DvTpMahjH4bv9q+AUR/Mm6Tg==',
      verificationMethod:
        'did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic#zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic',
    },
  },
  fetchRemoteContexts: true,
})
```

### Request examples (Veramo REST API):

#### Issue Verifiable Credential

Ed25519:

```shell
POST http://localhost:7071/api/vdx-ivcs/v1/createVerifiableCredentialLDLocal

Content-Type: application/json

{
  "credential": {
    "issuer": "did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt",
    "credentialSubject": {
      "id": "did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt"
    }
  }
}
```

BBS+:

```shell
POST http://localhost:7071/api/vdx-ivcs/v1/createVerifiableCredentialLDLocal

Content-Type: application/json

{
  "credential": {
    "issuer": "did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic",
    "credentialSubject": {
      "id": "did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic"
    },
    "@context": ["https://w3id.org/security/bbs/v1"]
  },
  "keyRef": "ad80e96c1f45ab12acc3064de578a5fe9737cd09459257b8abb56058199ef06ca04455ed3714ec30b9f50c186a7cfcb502d3469ae9458e2d3d1a0bf8a58215b0e23ad9620b9a961d0a0cd5484b8539efdce49d018508addbf099cf63f96bdd5d"
}
```

- To generate a BBS+ VCs the [@context]("https://w3id.org/security/bbs/v1") and keyRef (kid) properties are needed

#### Verify a Verifiable Credential

Ed25519:

```shell
POST http://localhost:7071/api/vdx-ivcs/v1/verifyCredentialLDLocal

Content-Type: application/json
Accept: application/json

{
  "credential": {
    "issuer": "did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt",
    "credentialSubject": {
      "id": "did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt"
    },
    "@context": [
      "https://www.w3.org/2018/credentials/v1"
    ],
    "type": [
      "VerifiableCredential"
    ],
    "issuanceDate": "2022-08-23T13:26:14.712Z",
    "proof": {
      "type": "Ed25519Signature2018",
      "created": "2022-08-23T13:26:14Z",
      "verificationMethod": "did:key:z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt#z6MkkDYR2LLa6tDBXVEuxcU4pqvHggz36oQESE9fc9jK6mAt",
      "proofPurpose": "assertionMethod",
      "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..o9mN0c6Ax-YmAIPz6_kQb2IA_HtKkfFn1H1LFHfexsoznFmIeEL0azh3oo8iYVrAa674dgLSvlHn8Q6iXAi_DA"
    }
  },
  "fetchRemoteContexts": true
}
```

BBS+

```shell
POST http://localhost:7071/api/vdx-ivcs/v1/verifyCredentialLDLocal

Content-Type: application/json
Accept: application/json

{
  "credential": {
    "issuer": "did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic",
    "credentialSubject": {
      "id": "did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic"
    },
    "@context": [
      "https://www.w3.org/2018/credentials/v1",
      "https://w3id.org/security/bbs/v1"
    ],
    "type": [
      "VerifiableCredential"
    ],
    "issuanceDate": "2022-08-23T09:59:03.522Z",
    "proof": {
      "type": "BbsBlsSignature2020",
      "created": "2022-08-23T09:59:03Z",
      "proofPurpose": "assertionMethod",
      "proofValue": "uLSsfDEFXea0yybm6i28/TrnDaoUc4hwweLqjwe4dbtvSZk+WlsKIyJoXZa2d8doD7cw8zOe8wTnwvZje4LxlNISsdfT6TWQy2O7toRWWXxqC3L2qrrtc/TY1Pfgu8DvTpMahjH4bv9q+AUR/Mm6Tg==",
      "verificationMethod": "did:key:zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic#zUC7Gc59EawPuAbe1gcbmpTtYeyRvRLUsCfkmHwmNaiQyQtQp9f4G4KHurpHaa6QUvm1mL1rZvKXQWpfRcTBfLsstL2kmMN3rkFSzYuzbxwD4LespdY8NKdsghxeiRNtNSbzKic"
    }
  },
  "fetchRemoteContexts": true
}
```

---
_Source: https://npm.io/package/@sphereon/ssi-sdk-vc-handler-ld-local · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
