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

did-jwt

Package Overview
Dependencies
Maintainers
6
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

did-jwt - npm Package Compare versions

Comparing version 6.6.1 to 6.7.0

1

lib/SignerAlgorithm.d.ts
import { SignerAlgorithm } from './JWT';
export declare function ES256SignerAlg(): SignerAlgorithm;
export declare function ES256KSignerAlg(recoverable?: boolean): SignerAlgorithm;

@@ -3,0 +4,0 @@ export declare function Ed25519SignerAlg(): SignerAlgorithm;

2

package.json
{
"name": "did-jwt",
"version": "6.6.1",
"version": "6.7.0",
"description": "Library for Signing and Verifying JWTs that use DIDs as issuers and JWEs that use DIDs as recipients",

@@ -5,0 +5,0 @@ "type": "module",

@@ -19,3 +19,49 @@ import SignerAlgorithm from '../SignerAlgorithm'

// Add tests specific to new ES256 signer for curve secp256r1 / P-256
const secp256r1 = new EC('p256')
import { ES256Signer } from '../signers/ES256Signer'
import { hexToBytes } from '../util'
const p256privateKey = '736f625c9dda78a94bb16840c82779bb7bc18014b8ede52f0f03429902fc4ba8'
const p256kp = secp256r1.keyFromPrivate(p256privateKey)
const p256signer = ES256Signer(hexToBytes(p256privateKey))
describe('SignerAlgorithm', () => {
it('supports ES256', () => {
expect(typeof SignerAlgorithm('ES256')).toEqual('function')
})
})
describe('ES256', () => {
const jwtSigner = SignerAlgorithm('ES256')
it('returns correct signature', async () => {
expect.assertions(1)
return await expect(jwtSigner('hello', p256signer)).resolves.toEqual(
'Zks0QO1ma5pHHtNbpb0qDap0VJSvQvA775N0GZsAp3PQjmDGbsfyKlUVcU9PFueIXksioSTsPXiOCgAHIOe4WA'
)
})
it('returns signature of 64 bytes', async () => {
expect.assertions(1)
const signature = await jwtSigner('hello', p256signer)
expect(base64ToBytes(signature).length).toEqual(64)
})
it('contains only r and s of signature', async () => {
expect.assertions(1)
const signature = await jwtSigner('hello', p256signer)
expect(toSignatureObject(signature)).toEqual({
r: '664b3440ed666b9a471ed35ba5bd2a0daa745494af42f03bef9374199b00a773',
s: 'd08e60c66ec7f22a5515714f4f16e7885e4b22a124ec3d788e0a000720e7b858',
})
})
it('can verify the signature', async () => {
expect.assertions(1)
const signature = await jwtSigner('hello', p256signer)
expect(p256kp.verify(sha256('hello'), toSignatureObject(signature))).toBeTruthy()
})
})
// end of tests added for P-256
describe('SignerAlgorithm', () => {
it('supports ES256K', () => {

@@ -22,0 +68,0 @@ expect(typeof SignerAlgorithm('ES256K')).toEqual('function')

@@ -9,2 +9,13 @@ import { Signer, SignerAlgorithm } from './JWT'

export function ES256SignerAlg(): SignerAlgorithm {
return async function sign(payload: string, signer: Signer): Promise<string> {
const signature: EcdsaSignature | string = await signer(payload)
if (instanceOfEcdsaSignature(signature)) {
return toJose(signature)
} else {
return signature
}
}
}
export function ES256KSignerAlg(recoverable?: boolean): SignerAlgorithm {

@@ -40,2 +51,3 @@ return async function sign(payload: string, signer: Signer): Promise<string> {

const algorithms: SignerAlgorithms = {
ES256: ES256SignerAlg(),
ES256K: ES256KSignerAlg(),

@@ -42,0 +54,0 @@ // This is a non-standard algorithm but retained for backwards compatibility

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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