Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@digitalbazaar/vc

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digitalbazaar/vc - npm Package Compare versions

Comparing version 6.1.0 to 6.2.0

4

lib/index.js

@@ -657,6 +657,6 @@ /**

if('credentialStatus' in credential) {
if(!credential.credentialStatus.id) {
if(Array.isArray(credential.credentialStatus) ? credential.credentialStatus.some(cs => !cs.id) : !credential.credentialStatus.id) {
throw new Error('"credentialStatus" must include an id.');
}
if(!credential.credentialStatus.type) {
if(Array.isArray(credential.credentialStatus) ? credential.credentialStatus.some(cs => !cs.type) : !credential.credentialStatus.type) {
throw new Error('"credentialStatus" must include a type.');

@@ -663,0 +663,0 @@ }

{
"name": "@digitalbazaar/vc",
"version": "6.1.0",
"version": "6.2.0",
"description": "Verifiable Credentials JavaScript library.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/digitalbazaar/vc",

@@ -119,8 +119,71 @@ # Verifiable Credentials JS Library _(@digitalbazaar/vc)_

### Issuing a Selective Disclosure Verifiable Credential
Pre-requisites:
* You have a private key (with id and controller) and corresponding suite
* You have are using a cryptosuite that supports selective disclosure, such
as `ecdsa-sd-2023`
* If you're using a custom `@context`, make sure it's resolvable
* (Recommended) You have a strategy for where to publish your Controller
Document and Public Key
```js
import * as vc from '@digitalbazaar/vc';
import * as ecdsaSd2023Cryptosuite from
'@digitalbazaar/ecdsa-sd-2023-cryptosuite';
import {DataIntegrityProof} from '@digitalbazaar/data-integrity';
const ecdsaKeyPair = await EcdsaMultikey.generate({
curve: 'P-256',
id: 'https://example.edu/issuers/keys/2',
controller: 'https://example.edu/issuers/565049'
});
// sample unsigned credential
const credential = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "https://example.com/credentials/1872",
"type": ["VerifiableCredential", "AlumniCredential"],
"issuer": "https://example.edu/issuers/565049",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"alumniOf": "Example University"
}
};
// setup ecdsa-sd-2023 suite for signing selective disclosure VCs
const suite = new DataIntegrityProof({
signer: ecdsaKeyPair.signer(),
cryptosuite: createSignCryptosuite({
// require the `issuer` and `issuanceDate` fields to always be disclosed
// by the holder (presenter)
mandatoryPointers: [
'/issuanceDate',
'/issuer'
]
})
});
// use a proof ID to enable it to be found and transformed into a disclosure
// proof by the holder later
const proofId = `urn:uuid:${uuid()}`;
suite.proof = {id: proofId};
const signedVC = await vc.issue({credential, suite, documentLoader});
console.log(JSON.stringify(signedVC, null, 2));
```
### Deriving a Selective Disclosure Verifiable Credential
Note: This step is performed as a holder of a verifiable credential, not as
an issuer.
Pre-requisites:
* You have a verifiable credential that was issued using a cryptosuite that
support selective disclosure, such as `ecdsa-sd-2023`
supports selective disclosure, such as `ecdsa-sd-2023`
* If you're using a custom `@context`, make sure it's resolvable

@@ -140,3 +203,3 @@

// Sample signed credential
// sample signed credential
const credential = {

@@ -172,3 +235,3 @@ "@context": [

// derived from the base proof already provided by the issuer
const ecdsaSdDeriveSuite = new DataIntegrityProof({
const suite = new DataIntegrityProof({
cryptosuite: createDiscloseCryptosuite({

@@ -187,3 +250,5 @@ // the ID of the base proof to convert to a disclosure proof

const derivedVC = await vc.derive({credential, suite, documentLoader});
const derivedVC = await vc.derive({
verifiableCredential, suite, documentLoader
});
console.log(JSON.stringify(derivedVC, null, 2));

@@ -190,0 +255,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc