Comparing version 5.1.0 to 5.1.1
@@ -0,1 +1,8 @@ | ||
## [5.1.1](https://github.com/decentralized-identity/did-jwt/compare/5.1.0...5.1.1) (2021-03-25) | ||
### Bug Fixes | ||
* simplify expected Resolver type in verify methods ([#159](https://github.com/decentralized-identity/did-jwt/issues/159)) ([969de89](https://github.com/decentralized-identity/did-jwt/commit/969de8942c95ed8e82d092685ac3586c18c19d25)), closes [#158](https://github.com/decentralized-identity/did-jwt/issues/158) | ||
# [5.1.0](https://github.com/decentralized-identity/did-jwt/compare/5.0.2...5.1.0) (2021-03-24) | ||
@@ -2,0 +9,0 @@ |
@@ -14,2 +14,5 @@ import { EcdsaSignature } from './util'; | ||
} | ||
export declare type Public<T> = { | ||
[P in keyof T]: T[P]; | ||
}; | ||
export interface JWTVerifyOptions { | ||
@@ -20,3 +23,3 @@ /** @deprecated Please use `proofPurpose: 'authentication' instead` */ | ||
callbackUrl?: string; | ||
resolver?: Resolver; | ||
resolver?: Public<Resolver>; | ||
skewTime?: number; | ||
@@ -164,3 +167,3 @@ /** See https://www.w3.org/TR/did-spec-registries/#verification-relationships */ | ||
*/ | ||
export declare function resolveAuthenticator(resolver: Resolver, alg: string, issuer: string, proofPurpose?: string): Promise<DIDAuthenticator>; | ||
export declare function resolveAuthenticator(resolver: Public<Resolver>, alg: string, issuer: string, proofPurpose?: string): Promise<DIDAuthenticator>; | ||
//# sourceMappingURL=JWT.d.ts.map |
import { Encrypter, Decrypter } from './JWE'; | ||
import type { Resolver } from 'did-resolver'; | ||
import { Public } from './JWT'; | ||
export declare function xc20pDirEncrypter(key: Uint8Array): Encrypter; | ||
export declare function xc20pDirDecrypter(key: Uint8Array): Decrypter; | ||
export declare function x25519Encrypter(publicKey: Uint8Array, kid?: string): Encrypter; | ||
export declare function resolveX25519Encrypters(dids: string[], resolver: Resolver): Promise<Encrypter[]>; | ||
export declare function resolveX25519Encrypters(dids: string[], resolver: Public<Resolver>): Promise<Encrypter[]>; | ||
export declare function x25519Decrypter(secretKey: Uint8Array): Decrypter; | ||
//# sourceMappingURL=xc20pEncryption.d.ts.map |
{ | ||
"name": "did-jwt", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Library for Signing and Verifying JWTs compatible uPort and DID standards", | ||
@@ -50,3 +50,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@babel/preset-typescript": "7.13.0", | ||
"@semantic-release/changelog": "5.0.1", | ||
@@ -53,0 +53,0 @@ "@semantic-release/git": "9.0.0", |
@@ -25,3 +25,3 @@ import VerifierAlgorithm from '../VerifierAlgorithm' | ||
expect.assertions(1) | ||
const resolver = ({ | ||
const resolver = { | ||
resolve: async () => ({ | ||
@@ -44,3 +44,3 @@ didResolutionMetadata: {}, | ||
}) | ||
} as unknown) as Resolver | ||
} | ||
const jwt = | ||
@@ -47,0 +47,0 @@ 'eyJhbGciOiJFZERTQSJ9.eyJleHAiOjE3NjQ4Nzg5MDgsImlzcyI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNIiwibmJmIjoxNjA3MTEyNTA4LCJzdWIiOiJkaWQ6a2V5Ono2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSIsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIiwiaHR0cHM6Ly9pZGVudGl0eS5mb3VuZGF0aW9uLy53ZWxsLWtub3duL2RpZC1jb25maWd1cmF0aW9uL3YxIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7ImlkIjoiZGlkOmtleTp6Nk1rb1RIc2dOTnJieThKekNOUTFpUkx5VzVRUTZSOFh1dTZBQThpZ0dyTVZQVU0iLCJvcmlnaW4iOiJpZGVudGl0eS5mb3VuZGF0aW9uIn0sImV4cGlyYXRpb25EYXRlIjoiMjAyNS0xMi0wNFQxNDowODoyOC0wNjowMCIsImlzc3VhbmNlRGF0ZSI6IjIwMjAtMTItMDRUMTQ6MDg6MjgtMDY6MDAiLCJpc3N1ZXIiOiJkaWQ6a2V5Ono2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSIsInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJEb21haW5MaW5rYWdlQ3JlZGVudGlhbCJdfX0.6ovgQ-T_rmYueviySqXhzMzgqJMAizOGUKAObQr2iikoRNsb8DHfna4rh1puwWqYwgT3QJVpzdO_xZARAYM9Dw' |
@@ -184,3 +184,3 @@ import { createJWT, verifyJWT, decodeJWT, createJWS, verifyJWS, resolveAuthenticator, NBF_SKEW } from '../JWT' | ||
describe('verifyJWT()', () => { | ||
const resolver = ({ resolve: jest.fn().mockReturnValue(didDoc) } as unknown) as Resolver | ||
const resolver = { resolve: jest.fn().mockReturnValue(didDoc) } | ||
@@ -253,3 +253,3 @@ describe('pregenerated JWT', () => { | ||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJpYXQiOjE0ODUzMjExMzMsImlzcyI6ImRpZDpldGhyOjB4OTBlNDVkNzViZDEyNDZlMDkyNDg3MjAxODY0N2RiYTk5NmE4ZTdiOSIsInJlcXVlc3RlZCI6WyJuYW1lIiwicGhvbmUiXX0.KIG2zUO8Quf3ucb9jIncZ1CmH0v-fAZlsKvesfsd9x4RzU0qrvinVd9d30DOeZOwdwEdXkET_wuPoOECwU0IKA' | ||
const legacyResolver = ({ resolve: jest.fn().mockReturnValue(didDocLegacy) } as unknown) as Resolver | ||
const legacyResolver = { resolve: jest.fn().mockReturnValue(didDocLegacy) } | ||
@@ -375,3 +375,3 @@ it('verifies the JWT and return correct payload', async () => { | ||
expect.assertions(1) | ||
const ethResolver = ({ | ||
const ethResolver = { | ||
resolve: jest.fn().mockReturnValue({ | ||
@@ -390,3 +390,3 @@ didDocument: { | ||
}) | ||
} as unknown) as Resolver | ||
} | ||
const jwt = await createJWT({ hello: 'world' }, { issuer: aud, signer, alg: 'ES256K' }) | ||
@@ -399,3 +399,3 @@ const { payload } = await verifyJWT(jwt, { resolver: ethResolver }) | ||
expect.assertions(1) | ||
const ethResolver = ({ | ||
const ethResolver = { | ||
resolve: jest.fn().mockReturnValue({ | ||
@@ -414,3 +414,3 @@ didDocument: { | ||
}) | ||
} as unknown) as Resolver | ||
} | ||
const jwt = await createJWT({ hello: 'world' }, { issuer: aud, signer, alg: 'ES256K' }) | ||
@@ -673,7 +673,3 @@ const { payload } = await verifyJWT(jwt, { resolver: ethResolver }) | ||
expect.assertions(1) | ||
const authenticators = await resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(singleKey) } as unknown) as Resolver, | ||
alg, | ||
did | ||
) | ||
const authenticators = await resolveAuthenticator({ resolve: jest.fn().mockReturnValue(singleKey) }, alg, did) | ||
return expect(authenticators).toEqual({ | ||
@@ -689,3 +685,3 @@ authenticators: [ecKey1], | ||
const authenticators = await resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) } as unknown) as Resolver, | ||
{ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) }, | ||
alg, | ||
@@ -704,3 +700,3 @@ did | ||
const authenticators = await resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) } as unknown) as Resolver, | ||
{ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) }, | ||
alg, | ||
@@ -720,3 +716,3 @@ did, | ||
const authenticators = await resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(multipleAuthTypes) } as unknown) as Resolver, | ||
{ resolve: jest.fn().mockReturnValue(multipleAuthTypes) }, | ||
alg, | ||
@@ -736,7 +732,3 @@ did, | ||
return await expect( | ||
resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(unsupportedFormat) } as unknown) as Resolver, | ||
alg, | ||
did | ||
) | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(unsupportedFormat) }, alg, did) | ||
).rejects.toThrowError(`DID document for ${did} does not have public keys for ${alg}`) | ||
@@ -751,3 +743,3 @@ }) | ||
const authenticators = await resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) } as unknown) as Resolver, | ||
{ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) }, | ||
alg, | ||
@@ -766,3 +758,3 @@ did | ||
const authenticators = await resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) } as unknown) as Resolver, | ||
{ resolve: jest.fn().mockReturnValue(multipleKeysLegacy) }, | ||
alg, | ||
@@ -782,3 +774,3 @@ did, | ||
const authenticators = await resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(multipleAuthTypes) } as unknown) as Resolver, | ||
{ resolve: jest.fn().mockReturnValue(multipleAuthTypes) }, | ||
alg, | ||
@@ -798,7 +790,3 @@ did, | ||
return await expect( | ||
resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(unsupportedFormat) } as unknown) as Resolver, | ||
alg, | ||
did | ||
) | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(unsupportedFormat) }, alg, did) | ||
).rejects.toThrowError(`DID document for ${did} does not have public keys for ${alg}`) | ||
@@ -811,8 +799,3 @@ }) | ||
return await expect( | ||
resolveAuthenticator( | ||
({ resolve: jest.fn().mockReturnValue(singleKey) } as unknown) as Resolver, | ||
alg, | ||
did, | ||
'authentication' | ||
) | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(singleKey) }, alg, did, 'authentication') | ||
).rejects.toThrowError( | ||
@@ -826,3 +809,3 @@ `DID document for ${did} does not have public keys suitable for ES256K with authentication purpose` | ||
return await expect( | ||
resolveAuthenticator(({ resolve: jest.fn().mockReturnValue(noPublicKey) } as unknown) as Resolver, alg, did) | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(noPublicKey) }, alg, did) | ||
).rejects.toThrowError(`DID document for ${did} does not have public keys for ${alg}`) | ||
@@ -835,3 +818,3 @@ }) | ||
resolveAuthenticator( | ||
({ | ||
{ | ||
resolve: jest.fn().mockReturnValue({ | ||
@@ -841,3 +824,3 @@ didResolutionMetadata: { error: 'notFound' }, | ||
}) | ||
} as unknown) as Resolver, | ||
}, | ||
alg, | ||
@@ -852,3 +835,3 @@ did | ||
return await expect( | ||
resolveAuthenticator(({ resolve: jest.fn().mockReturnValue(singleKey) } as unknown) as Resolver, 'ESBAD', did) | ||
resolveAuthenticator({ resolve: jest.fn().mockReturnValue(singleKey) }, 'ESBAD', did) | ||
).rejects.toThrowError('No supported signature types for algorithm ESBAD') | ||
@@ -855,0 +838,0 @@ }) |
@@ -19,2 +19,4 @@ import VerifierAlgorithm from './VerifierAlgorithm' | ||
export type Public<T> = { [P in keyof T]: T[P] } | ||
export interface JWTVerifyOptions { | ||
@@ -25,3 +27,3 @@ /** @deprecated Please use `proofPurpose: 'authentication' instead` */ | ||
callbackUrl?: string | ||
resolver?: Resolver | ||
resolver?: Public<Resolver> | ||
skewTime?: number | ||
@@ -353,3 +355,3 @@ /** See https://www.w3.org/TR/did-spec-registries/#verification-relationships */ | ||
export async function resolveAuthenticator( | ||
resolver: Resolver, | ||
resolver: Public<Resolver>, | ||
alg: string, | ||
@@ -356,0 +358,0 @@ issuer: string, |
@@ -8,2 +8,3 @@ import { XChaCha20Poly1305 } from '@stablelib/xchacha20poly1305' | ||
import type { VerificationMethod, Resolver } from 'did-resolver' | ||
import { Public } from './JWT' | ||
@@ -82,3 +83,3 @@ function xc20pEncrypter(key: Uint8Array): (cleartext: Uint8Array, aad?: Uint8Array) => EncryptionResult { | ||
export async function resolveX25519Encrypters(dids: string[], resolver: Resolver): Promise<Encrypter[]> { | ||
export async function resolveX25519Encrypters(dids: string[], resolver: Public<Resolver>): Promise<Encrypter[]> { | ||
return Promise.all( | ||
@@ -85,0 +86,0 @@ dids.map(async (did) => { |
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 not supported yet
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 not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
722164
0
3574