0.11.0 • Published 1 year ago

@sphereon/ssi-sdk-vc-handler-ld-local v0.11.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

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
}
0.10.0

1 year ago

0.10.1-next.6

1 year ago

0.10.1-next.9

1 year ago

0.10.1-next.8

1 year ago

0.10.1-next.2

1 year ago

0.9.1-next.121

1 year ago

0.10.1-next.14

1 year ago

0.10.1-next.13

1 year ago

0.10.2-next.11

1 year ago

0.11.0

1 year ago

0.9.1-next.42

1 year ago

0.9.1-next.109

1 year ago

0.9.1-next.107

1 year ago

0.9.1-next.105

1 year ago

0.9.1-next.103

1 year ago

0.9.1-next.100

1 year ago

0.9.1-next.56

1 year ago

0.9.1-next.55

1 year ago

0.9.1-next.69

1 year ago

0.9.1-next.62

1 year ago

0.9.1-next.17

1 year ago

0.9.1-next.16

1 year ago

0.9.1-next.15

1 year ago

0.9.1-next.13

1 year ago

0.9.1-next.12

1 year ago

0.9.1-next.11

1 year ago

0.9.1-next.10

1 year ago

0.9.1-next.118

1 year ago

0.9.1-next.116

1 year ago

0.9.1-next.114

1 year ago

0.9.1-next.113

1 year ago

0.9.1-next.21

1 year ago

0.9.1-next.120

1 year ago

0.9.1-next.9

1 year ago

0.9.1-next.89

1 year ago

0.8.1-next.272

1 year ago

0.9.1-next.99

1 year ago

0.9.1-next.97

1 year ago

0.9.1-next.96

1 year ago

0.9.0

1 year ago

0.8.1-next.190

1 year ago

0.8.1-next.192

1 year ago

0.8.1-next.194

1 year ago

0.8.1-next.114

1 year ago

0.8.1-next.117

1 year ago

0.8.1-next.119

1 year ago

0.8.1-next.120

1 year ago

0.8.1-next.121

1 year ago

0.8.1-next.122

1 year ago

0.8.1-next.123

1 year ago

0.8.1-next.146

1 year ago

0.8.1-next.154

1 year ago

0.8.1-next.156

1 year ago

0.8.1-next.157

1 year ago

0.8.1-next.158

1 year ago

0.8.1-next.159

1 year ago

0.8.1-next.161

1 year ago

0.8.1-next.162

1 year ago

0.8.1-next.163

1 year ago

0.8.1-next.164

1 year ago

0.8.1-next.165

1 year ago

0.8.1-next.166

1 year ago

0.8.1-next.167

1 year ago

0.8.1-next.168

1 year ago

0.8.1-next.169

1 year ago

0.8.1-next.179

1 year ago

0.8.1-next.26

2 years ago

0.8.1-next.31

2 years ago

0.8.1-next.42

2 years ago

0.8.1-next.50

2 years ago

0.8.1-next.57

2 years ago

0.8.1-next.55

2 years ago

0.8.1-next.66

2 years ago

0.8.1-next.77

2 years ago

0.8.1-next.84

2 years ago

0.8.1-unstable.9

2 years ago

0.8.1-unstable.5

2 years ago

0.8.1-unstable.4

2 years ago

0.7.1-next.66

2 years ago

0.7.1-next.68

2 years ago

0.7.1-next.54

2 years ago

0.8.0

2 years ago

0.8.1-next.3

2 years ago

0.8.1-next.6

2 years ago

0.8.1-next.2

2 years ago

0.8.1-next.12

2 years ago

0.8.1-next.18

2 years ago

0.7.1-next.43

2 years ago

0.7.1-next.40

2 years ago

0.5.2-next.73

2 years ago

0.6.1-next.50

2 years ago

0.7.0

2 years ago

0.7.1-next.38

2 years ago

0.6.1-next.6

2 years ago

0.6.1-next.8

2 years ago

0.6.1-next.9

2 years ago

0.7.1-unstable.9

2 years ago

0.7.1-next.39

2 years ago

0.6.1-next.66

2 years ago

0.6.1-next.67

2 years ago

0.7.1-next.18

2 years ago

0.5.2-next.113

2 years ago

0.6.1-next.76

2 years ago

0.6.1-next.79

2 years ago

0.5.2-next.116

2 years ago

0.6.1-next.78

2 years ago

0.6.0

2 years ago

0.5.2-next.70

2 years ago

0.5.2-next.10

2 years ago

0.5.2-next.45

2 years ago

0.3.4-next.15

2 years ago

0.2.1-next.17

2 years ago

0.5.1-next.1

2 years ago

0.5.2-next.3

2 years ago

0.5.2-next.4

2 years ago

0.5.2-next.6

2 years ago

0.5.2-next.7

2 years ago

0.5.2-next.8

2 years ago

0.2.1-unstable.5

2 years ago

0.2.1-unstable.6

2 years ago

0.2.1-unstable.7

2 years ago

0.2.1-unstable.8

2 years ago

0.4.1-unstable.3

2 years ago

0.4.1-unstable.2

2 years ago

0.4.1-unstable.5

2 years ago

0.3.0

2 years ago

0.4.1-unstable.4

2 years ago

0.5.2-next.9

2 years ago

0.5.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.4.1-next.7

2 years ago

0.2.1-next.33

2 years ago

0.4.1-next.6

2 years ago

0.3.1-next.11

2 years ago

0.3.1-next.10

2 years ago

0.3.5-next.47

2 years ago

0.3.5-next.46

2 years ago

0.3.1-next.7

2 years ago

0.3.5-next.3

2 years ago

0.4.0

2 years ago

0.2.1-next.13

2 years ago

0.2.1-unstable.9

2 years ago

0.2.1-unstable.3

2 years ago

0.2.1-unstable.2

2 years ago

0.2.1-unstable.1

2 years ago

0.2.0

2 years ago

0.1.1-next.105

2 years ago

0.1.2-next.143

2 years ago

0.1.2-next.142

2 years ago