Comparing version 4.3.0 to 4.3.1
{ | ||
"name": "did-jwt", | ||
"version": "4.3.0", | ||
"version": "4.3.1", | ||
"description": "Library for Signing and Verifying JWTs compatible uPort and DID standards", | ||
@@ -60,2 +60,4 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"@types/elliptic": "^6.4.6", | ||
@@ -78,2 +80,3 @@ "@types/jest": "^24.0.12", | ||
"regenerator-runtime": "^0.11.1", | ||
"semantic-release": "^17.0.7", | ||
"sinon": "^4.0.1", | ||
@@ -80,0 +83,0 @@ "standard": "^12.0.1", |
@@ -123,3 +123,3 @@ import { createJWT, verifyJWT, decodeJWT, resolveAuthenticator, NBF_SKEW } from '../JWT' | ||
it('throws an error if unsupported algorithm is passed in', async () => { | ||
expect(createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer, alg: 'BADALGO' })).rejects.toThrow( | ||
await expect(createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer, alg: 'BADALGO' })).rejects.toThrow( | ||
'Unsupported algorithm BADALGO' | ||
@@ -138,3 +138,3 @@ ) | ||
const jwt = await createJWT({ requested: ['name', 'phone'] }, { alg, issuer: did, signer }) | ||
return expect(naclVerifyJWT(jwt)).toBeTruthy() | ||
return await expect(naclVerifyJWT(jwt)).toBeTruthy() | ||
}) | ||
@@ -205,3 +205,3 @@ | ||
// const jwt = await createJWT({nbf: PAST}, {issuer:did, signer}) | ||
expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
await expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
}) | ||
@@ -213,3 +213,3 @@ it('passes when nbf is in the past and iat is in the future', async () => { | ||
// const jwt = await createJWT({nbf:PAST,iat:FUTURE},{issuer:did,signer}) | ||
expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
await expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
}) | ||
@@ -221,3 +221,3 @@ it('fails when nbf is in the future', async () => { | ||
// const jwt = await createJWT({nbf:FUTURE},{issuer:did,signer}) | ||
expect(verifyJWT(jwt, { resolver })).rejects.toThrow() | ||
await expect(verifyJWT(jwt, { resolver })).rejects.toThrow() | ||
}) | ||
@@ -229,3 +229,3 @@ it('fails when nbf is in the future and iat is in the past', async () => { | ||
// const jwt = await createJWT({nbf:FUTURE,iat:PAST},{issuer:did,signer}) | ||
expect(verifyJWT(jwt, { resolver })).rejects.toThrow() | ||
await expect(verifyJWT(jwt, { resolver })).rejects.toThrow() | ||
}) | ||
@@ -237,3 +237,3 @@ it('passes when nbf is missing and iat is in the past', async () => { | ||
// const jwt = await createJWT({iat:PAST},{issuer:did,signer}) | ||
expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
await expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
}) | ||
@@ -245,3 +245,3 @@ it('fails when nbf is missing and iat is in the future', async () => { | ||
// const jwt = await createJWT({iat:FUTURE},{issuer:did,signer}) | ||
expect(verifyJWT(jwt, { resolver })).rejects.toThrow() | ||
await expect(verifyJWT(jwt, { resolver })).rejects.toThrow() | ||
}) | ||
@@ -253,3 +253,3 @@ it('passes when nbf and iat are both missing', async () => { | ||
// const jwt = await createJWT({iat:undefined},{issuer:did,signer}) | ||
expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
await expect(verifyJWT(jwt, { resolver })).resolves.not.toThrow() | ||
}) | ||
@@ -285,3 +285,3 @@ }) | ||
const jwt = await createJWT({ exp: NOW - NBF_SKEW - 1 }, { issuer: did, signer }) | ||
expect(verifyJWT(jwt, { resolver })).rejects.toThrow(/JWT has expired/) | ||
await expect(verifyJWT(jwt, { resolver })).rejects.toThrow(/JWT has expired/) | ||
}) | ||
@@ -303,3 +303,3 @@ | ||
const jwt = await createJWT({ aud: [did, did] }, { issuer: did, signer }) | ||
expect(verifyJWT(jwt, { resolver, audience: aud })).rejects.toThrow(/JWT audience does not match your DID/) | ||
await expect(verifyJWT(jwt, { resolver, audience: aud })).rejects.toThrow(/JWT audience does not match your DID/) | ||
}) | ||
@@ -318,3 +318,3 @@ | ||
const jwt = await createJWT({ aud }, { issuer: did, signer }) | ||
expect(verifyJWT(jwt, { resolver, audience: did })).rejects.toThrow(/JWT audience does not match your DID/) | ||
await expect(verifyJWT(jwt, { resolver, audience: did })).rejects.toThrow(/JWT audience does not match your DID or callback url/) | ||
}) | ||
@@ -324,3 +324,3 @@ | ||
const jwt = await createJWT({ aud: 'http://pututu.uport.me/unique' }, { issuer: did, signer }) | ||
expect( | ||
await expect( | ||
verifyJWT(jwt, { | ||
@@ -335,4 +335,4 @@ resolver, | ||
const jwt = await createJWT({ aud: 'http://pututu.uport.me/unique' }, { issuer: did, signer }) | ||
expect(verifyJWT(jwt, { resolver })).rejects.toThrow( | ||
"JWT audience matching your callback url is required but one wasn't passed in" | ||
await expect(verifyJWT(jwt, { resolver })).rejects.toThrow( | ||
"JWT audience is required but your app address has not been configured" | ||
) | ||
@@ -343,3 +343,3 @@ }) | ||
const jwt = await createJWT({ aud }, { issuer: did, signer }) | ||
expect(verifyJWT(jwt, { resolver })).rejects.toThrow(/JWT audience does not match your DID or callback url/) | ||
await expect(verifyJWT(jwt, { resolver })).rejects.toThrow(/JWT audience is required but your app address has not been configured/) | ||
}) | ||
@@ -471,3 +471,3 @@ }) | ||
it('errors if no suitable public keys exist', async () => { | ||
return expect( | ||
return await expect( | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(unsupportedFormat) }, alg, did) | ||
@@ -508,3 +508,3 @@ ).rejects.toEqual(new Error(`DID document for ${did} does not have public keys for ${alg}`)) | ||
it('errors if no suitable public keys exist', async () => { | ||
return expect( | ||
return await expect( | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(unsupportedFormat) }, alg, did) | ||
@@ -516,3 +516,3 @@ ).rejects.toEqual(new Error(`DID document for ${did} does not have public keys for ${alg}`)) | ||
it('errors if no suitable public keys exist for authentication', async () => { | ||
return expect( | ||
return await expect( | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(singleKey) }, alg, did, true) | ||
@@ -525,3 +525,3 @@ ).rejects.toEqual( | ||
it('errors if no public keys exist', async () => { | ||
return expect( | ||
return await expect( | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(noPublicKey) }, alg, did) | ||
@@ -532,3 +532,3 @@ ).rejects.toEqual(new Error(`DID document for ${did} does not have public keys for ${alg}`)) | ||
it('errors if no DID document exists', async () => { | ||
return expect(resolveAuthenticator({ resolve: jest.fn().mockReturnValue(null) }, alg, did)).rejects.toEqual( | ||
return await expect(resolveAuthenticator({ resolve: jest.fn().mockReturnValue(null) }, alg, did)).rejects.toEqual( | ||
new Error(`Unable to resolve DID document for ${did}`) | ||
@@ -539,3 +539,3 @@ ) | ||
it('errors if no supported signature types exist', async () => { | ||
return expect( | ||
return await expect( | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(singleKey) }, 'ESBAD', did) | ||
@@ -542,0 +542,0 @@ ).rejects.toEqual(new Error('No supported signature types for algorithm ESBAD')) |
@@ -41,3 +41,3 @@ import SignerAlgorithm from '../SignerAlgorithm' | ||
it('returns correct signature', async () => { | ||
return expect(jwtSigner('hello', signer)).resolves.toEqual( | ||
return await expect(jwtSigner('hello', signer)).resolves.toEqual( | ||
'MaCPcIypS76TnvKSbhbPMG01BJvjQ6ouITV-mVt7_bfTZfGkEdwooSqbzPBHAlZXGzYYvrTnH4M9lF3OZMdpRQ' | ||
@@ -69,3 +69,3 @@ ) | ||
it('returns correct signature', async () => { | ||
return expect(jwtSigner('hello', signer)).resolves.toEqual( | ||
return await expect(jwtSigner('hello', signer)).resolves.toEqual( | ||
'MaCPcIypS76TnvKSbhbPMG01BJvjQ6ouITV-mVt7_bfTZfGkEdwooSqbzPBHAlZXGzYYvrTnH4M9lF3OZMdpRQE' | ||
@@ -98,3 +98,3 @@ ) | ||
it('returns correct signature', async () => { | ||
return expect(jwtSigner('hello', edSigner)).resolves.toEqual( | ||
return await expect(jwtSigner('hello', edSigner)).resolves.toEqual( | ||
'lLY_SeplJc_4tgMP1BHmjfxS0UEi-Xvonzbss4GT7yuFz--H28uCwsRjlIwXL4I0ugCrM-zQoA2gW2JdnFRkDQ' | ||
@@ -101,0 +101,0 @@ ) |
@@ -7,3 +7,3 @@ import SimpleSigner from '../SimpleSigner' | ||
const plaintext = 'thequickbrownfoxjumpedoverthelazyprogrammer' | ||
return expect(signer(plaintext)).resolves.toMatchSnapshot() | ||
return await expect(signer(plaintext)).resolves.toMatchSnapshot() | ||
}) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
419189
42
29
1955