パッケージの詳細

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

Sphereon-Opensource419Apache-2.00.11.0


Sphereon
JSON-LD VC Handler Local (Typescript

Sphereon, SSI, Veramo, W3C

readme


Sphereon
JSON-LD VC Handler Local (Typescript + React-Native)


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

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

Build

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.

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

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

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

BBS+

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

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+

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:

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

Content-Type: application/json

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

BBS+:

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 and keyRef (kid) properties are needed

Verify a Verifiable Credential

Ed25519:

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+

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
}

更新履歴

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.11.0 (2023-05-07)

Bug Fixes

  • make credential mapper a bit more resilient (36c420e)
  • make credential mapper a bit more resilient (ce5b487)
  • make credential mapper a bit more resilient (7248fae)

Features

  • Create new agent-config module to replace the deps on Veramo cli, which pulls in everything (6ac4ec0)
  • Create new agent-config module to replace the deps on Veramo cli, which pulls in everything (673856f)
  • instead of returning a boolean value, return an object with more information about verification of LD creds/VPs (7df0e64)

0.10.1 (2023-05-01)

Note: Version bump only for package SSI-SDK-workspace

0.10.0 (2023-04-30)

Bug Fixes

  • bbs+ fixes and updates (84c08f1)
  • bbs+ fixes and updates (fc228a2)
  • bbs+ fixes and updates (efcbf2c)
  • bbs+ fixes and updates (871cf66)
  • bbs+ fixes and updates (ae9e903)
  • cleanup package.json files (aca017b)
  • cleanup package.json files (0cc08b6)
  • decoded JWT VPs/VCs did not contain everything (612b082)
  • decoded JWT VPs/VCs did not contain everything (fd7ff68)

Features

  • Add better internal handling of JWT proof values used in JsonLD converted credentials (90004c5)
  • added holder role to contact types (728c8e1)
  • More support for definition Formats when creating VPs from SIOP (61c4120)
  • Update to v2 PEX and v0.3 SIOP packages (80398e3)

0.9.0 (2023-03-09)

Bug Fixes

  • credential mapper for jtw (f04345b)
  • default contexts are not using node fs/path anymore (5a87aa3)
  • default contexts are not using node fs/path anymore (8f1b17a)
  • default contexts are not using node fs/path anymore (51fd687)
  • deps (ec062f8)
  • Disable factom tests (099a303)
  • Fix DID handling in OP session (926e358)
  • fix private key hex from Pem (0204094)
  • Incorrect verification method id returned when signing credentials in some cases (bdbf4ef)
  • Incorrect verification method id returned when signing credentials in some cases (c508507)
  • JWT claims would overwrite the issuer object in the credential. Disable Factom tests (f41cf64)
  • make sure cross-fetch is used to fetch (7033a2e)
  • Make sure we follow JWS detached signing for JsonWebSignature2020 (3da5bad)
  • missing awaits for signing presentations (518b8fc)
  • Move parseDid method to ssi-types (0b28de3)
  • QR code testing. Remove enzyme as it is not compatible with React 18 (62debd9)
  • Remove non dev dep on veramo-core (8cb8efe)
  • Remove workaround for verifier missing with ed25519 key (2e97af6)
  • RSA fixes for suite (b163872)
  • RSA fixes for suite (d6f57b8)
  • RSA fixes for suite (9eb47d1)
  • RSA fixes for suite (834642a)
  • RSA fixes for suite (3df79ab)
  • testing unimodules-core removal (ffdc606)
  • Tests to allow multiple subjects for credentials (5e407ac)
  • Tests to allow multiple subjects for credentials (52b1662)
  • Tests to allow multiple subjects for credentials (110d78e)

Features

  • add Alg support to DID:JWK. Although optional in reality several external systems expect it to be present (12dae72)
  • Add jsonwebsignature2020 context to presentations if missing (1f3f6b5)
  • Add jwt as signature when decoding JWT VCs/VPs (f089ac1)
  • Add RSA support to JsonWebKey/Signature2020 (94c0e73)
  • Add support for ES256/Secp256r1 DID JWKs (1e447a6)
  • allow existing did document for mapping (5f183ce)
  • allow existing did document for mapping (4d82518)
  • Allow multiple subjects for credentials (6300ccc)
  • Allow supplying signer/verifier (00892e2)
  • Allow supplying signer/verifier (625ea6f)
  • Allow supplying signer/verifier (b010d7a)
  • Allow to relax JWT timing checks, where the JWT claim is slightly different from the VC claim. Used for issuance and expiration dates (85bff6d)
  • Create VP in OP Authenticator and allow for callbacks (0ed86d8)
  • did utils package (d98b358)
  • Jsonweb2020 sig support (43a3adf)
  • make sure the vc-handler-ld-local can deal with keys in JWK format (26cff51)
  • Make sure VP type corresponds with PEX definition (129b663)
  • Make sure VP type corresponds with PEX definition (3dafa3f)
  • New QR code provider plugin. Can generate both SIOPv2 and DIDCommv2 OOB QRs. Support for text generation and React QR codes as SVG (d40ba75)
  • Update SIOP OP to be in line wiht latest SIOP and also supporting late binding of identifiers (2beea04)

Reverts

  • Revert "fix: make sure to explicitly depend on @digitalcredentials VC packages" (dae695d)
  • Revert "fix: make sure to explicitly depend on @digitalcredentials VC packages" (e2be77a)
  • Revert "fix: deps" (5b0df98)

0.8.0 (2022-09-03)

Bug Fixes

  • Remove most deps from ssi-sdk-core to prevent circular deps (b4151a9)

Features

  • Add support for update and recovery keys (85bcf7e)
  • Create common SSI types package (0fdc372)

0.7.0 (2022-08-05)

Bug Fixes

  • Update ion deps to remove problematic did-key p384 from transmute which depended on webcypto-asl which is not compatible with node >=14. (386efc7)

Features

  • add Microsoft Request Service API support (251ed60)
  • Add migration support to mnemonic seed manager plugin. Fix some entity props in the process (f7641f4)

Reverts

  • Revert "MYC-184 Update main Version change 0.5.1 -> 0.5.2" (b1b8cc6)
  • Revert "MYC-184 uncommitted changes are added" (fb4f878)

0.6.0 (2022-07-01)

Bug Fixes

  • Fix unit tests for VC API (f3c5eea)
  • fixed and refactored some pr notes (2ff95b9)
  • tests are now using env variables (9cb6ec2)

Features

  • Add custom DID resolver support (45cea11)
  • Add default DID resolver support (eebce18)
  • Add did resolver and method support per OpSession (9378b45)
  • Add did resolver and method support per OpSession (a9f7afc)
  • Add supported DID methods (df74ccd)
  • Add supported DID methods (7322265)
  • added piiLoggingEnabled and logLevel to optional params for clientCredential authentication (584fb7b)
  • added region to optional params for clientcredential authentication (e21bd70)
  • changed the structure of the module to be more like the ssi-core module of ours. Plus, changed some documents (4480b3f)

0.5.1 (2022-02-23)

Note: Version bump only for package SSI-SDK-workspace

0.5.0 (2022-02-23)

Features

  • Update waci pex implementation as it was serializing a SIOP Auth request including all options like private keys, not conforming to WACI-PEX (90a1cba)

0.4.0 (2022-02-11)

Bug Fixes

  • ensure we set jsx to react (c2a5e6f)

Features

  • Add WACI PEx QR generator for React (7850e34)

0.3.4 (2022-02-11)

Bug Fixes

0.3.3 (2022-02-10)

Bug Fixes

  • building of vc-handler-ld-local containing ts files + not copying files (cdbfcab)
  • we imported a ts file from another package in the monorepo instead of using the module (5d647df)

0.3.2 (2022-02-04)

Bug Fixes

  • building of vc-handler-ld-local containing ts files + not copying files (cdbfcab)
  • we imported a ts file from another package in the monorepo instead of using the module (5d647df)

0.3.1 (2022-01-28)

Note: Version bump only for package SSI-SDK-workspace

0.3.0 (2022-01-16)

Bug Fixes

  • Add missing suites exports (4a3b8ce)
  • Be a bit more relaxed when deleting an LTO DID, eventhough onchain support is not present (7347914)
  • Update test timeout for Factom (9a934cf)

Features

  • Add debug logging when creating VC, can be enabled by DEBUG=sphereon:ssi-sdk:ld-credential-module-local (c0df2ce)

0.2.0 (2021-12-16)

Bug Fixes

  • LTO DIDs use #sign for keys (11daa98)
  • move to ES6 import for cross-fetch (b855273)
  • Multibase encoding didn't include the prefix char (1be44b7)
  • update test to search for kid using #sign instead of #key as the LTO indexer impl changed (fa0fae4)
  • workaround for bug in VeramoEd25519Signature2018 implementation (13442eb)

Features

  • Add JSON-LD Credential and Presentation handling/sign support that is compatible with React-Native (b4e8453)
  • Add JSON-LD Credential and Presentation handling/sign support that is compatible with React-Native (995f55e)
  • Add local default contexts (da29f02)
  • Add Local JSON-LD VC and VP issuance and verification plugin (aa1b45c)
  • Add Mnemonic seed generation, verificaiton and secure storage (d9a410a)
  • Add new ed25519 2018 signature and spec implementation using transmute's TS implementation (ffbe876)
  • Add proof purposes to issuance and verification methods. Add support to resolve verification methods from DID doc (c8e7392)
  • Add Self-Issued OpenID Connect and OpenID Connect for Verifiable Presentations support (1ec1d1c)
  • Add suite lookup based on verification method type next to veramo key type (5c18dc2)
  • Allow remote context loading (742d3cc)

0.1.0 (2021-11-26)

Bug Fixes

  • add missing env var for workflow for PRs (c3198ca)
  • fix workflow env (3acf669)
  • fix workflow for PRs (eddad66)
  • open handles and logging after test completes (8cca899)
  • sync main into develop (143927c)

Features

  • Add factom-did module (e6e3cfb)
  • Add lto-did module (236ca01)
  • Add ssi-sdk core module (42a5b65)
  • Add workspace/lerna files and structures (2c2b112)