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

did-jwt-vc

Package Overview
Dependencies
Maintainers
6
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

did-jwt-vc - npm Package Compare versions

Comparing version 2.1.8 to 2.1.9

41

package.json
{
"name": "did-jwt-vc",
"version": "2.1.8",
"version": "2.1.9",
"description": "Create and verify W3C Verifiable Credentials and Presentations in JWT format",

@@ -30,4 +30,4 @@ "source": "src/index.ts",

"dependencies": {
"did-jwt": "^5.7.0",
"did-resolver": "^3.1.0"
"did-jwt": "^5.12.3",
"did-resolver": "^3.1.5"
},

@@ -52,24 +52,25 @@ "repository": {

"devDependencies": {
"@babel/core": "7.16.0",
"@babel/preset-env": "7.16.0",
"@babel/preset-typescript": "7.16.0",
"@babel/core": "7.16.7",
"@babel/preset-env": "7.16.8",
"@babel/preset-typescript": "7.16.7",
"@semantic-release/changelog": "6.0.1",
"@semantic-release/git": "10.0.1",
"@types/elliptic": "6.4.14",
"@types/faker": "5.5.9",
"@types/jest": "27.0.2",
"@types/node": "15.12.4",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"codecov": "3.8.2",
"eslint": "7.32.0",
"@types/jest": "27.4.0",
"@types/node": "16.11.19",
"@typescript-eslint/eslint-plugin": "5.9.1",
"@typescript-eslint/parser": "5.9.1",
"codecov": "3.8.3",
"eslint": "8.6.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-jest": "24.7.0",
"eslint-plugin-jest": "25.3.4",
"eslint-plugin-prettier": "4.0.0",
"ethr-did": "2.1.4",
"faker": "5.5.3",
"jest": "27.3.1",
"microbundle": "0.13.3",
"prettier": "2.4.1",
"semantic-release": "18.0.0",
"typescript": "4.4.4"
"ethr-did": "2.1.5",
"faker": "6.6.6",
"jest": "27.4.7",
"microbundle": "0.14.2",
"prettier": "2.5.1",
"semantic-release": "18.0.1",
"typescript": "4.5.4"
},

@@ -76,0 +77,0 @@ "engines": {

@@ -24,9 +24,9 @@ [![npm](https://img.shields.io/npm/dt/did-jwt-vc.svg)](https://www.npmjs.com/package/did-jwt-vc)

```typescript
import * as EthrDID from 'ethr-did'
import { EthrDID } from 'ethr-did'
import { Issuer } from 'did-jwt-vc'
const issuer: Issuer = new EthrDID({
const issuer = new EthrDID({
identifier: '0xf1232f840f3ad7d23fcdaa84d6c66dac24efb198',
privateKey: 'd8b595680851765f38ea5405129244ba3cbad84467d190859f4c8b20c1ff6c75'
})
}) as Issuer
```

@@ -33,0 +33,0 @@

import { EthrDID } from 'ethr-did'
import {
createVerifiableCredentialJwt,
createVerifiablePresentationJwt,
Issuer,
JwtCredentialPayload,
verifyCredential,
verifyPresentation,
createVerifiablePresentationJwt,
Issuer,
verifyPresentationPayloadOptions,
} from '../index'
import { decodeJWT } from 'did-jwt'
import { decodeJWT, ES256KSigner } from 'did-jwt'
import { Resolvable } from 'did-resolver'
import { DEFAULT_VC_TYPE, DEFAULT_VP_TYPE, DEFAULT_CONTEXT } from '../types'
import {
CreatePresentationOptions,
DEFAULT_CONTEXT,
DEFAULT_VC_TYPE,
DEFAULT_VP_TYPE,
VerifyPresentationOptions,
} from '../types'
import {
validateContext,
validateCredentialSubject,
validateJwtFormat,

@@ -19,6 +27,8 @@ validateTimestamp,

validateVpType,
validateCredentialSubject,
} from '../validators'
import { CreatePresentationOptions, VerifyPresentationOptions } from '../types'
import elliptic from 'elliptic'
import * as u8a from 'uint8arrays'
const secp256k1 = new elliptic.ec('secp256k1')
jest.mock('../validators')

@@ -34,3 +44,2 @@

const DID_A = 'did:ethr:0xf1232f840f3ad7d23fcdaa84d6c66dac24efb198'
const DID_B = 'did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4'

@@ -424,1 +433,62 @@ const EXTRA_CONTEXT_A = 'https://www.w3.org/2018/credentials/examples/v1'

})
describe('github #98', () => {
it('verifies a JWT issued by a DID with publicKeyJwk', async () => {
const did = `did:ion:long-form-mock`
const privateKeyHex = '278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f'
const pubKey = secp256k1.keyFromPrivate(privateKeyHex, 'hex').getPublic()
const publicKeyJwk = {
kty: 'EC',
crv: 'secp256k1',
x: u8a.toString(pubKey.getX().toBuffer(), 'base64url'),
y: u8a.toString(pubKey.getY().toBuffer(), 'base64url'),
}
const localResolver: Resolvable = {
resolve: (did: string) =>
Promise.resolve({
'@context': 'https://w3id.org/did-resolution/v1',
didDocument: {
id: did,
'@context': ['https://www.w3.org/ns/did/v1'],
verificationMethod: [
{
id: '#key-1',
controller: '',
type: 'EcdsaSecp256k1VerificationKey2019',
publicKeyJwk,
},
],
authentication: ['#key-1'],
},
didDocumentMetadata: {},
didResolutionMetadata: {},
}),
}
const issuer: Issuer = {
did,
signer: ES256KSigner(privateKeyHex, false),
alg: 'ES256K',
}
const vcPayload: JwtCredentialPayload = {
nbf: 1562950282,
vc: {
'@context': ['https://www.w3.org/2018/credentials/v1'],
type: ['VerifiableCredential'],
credentialSubject: {
degree: {
type: 'Stemgerechtigd',
name: 'Je mag stemmen',
},
},
},
}
const vcJwt = await createVerifiableCredentialJwt(vcPayload, issuer, { header: { alg: 'ES256K' } })
const verifiedVC = await verifyCredential(vcJwt, localResolver, { header: { alg: 'ES256K' } })
expect(verifiedVC.issuer).toEqual('did:ion:long-form-mock')
})
})
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