From 1834621e224d07c9a2aab4942bd2cc5ddf644264 Mon Sep 17 00:00:00 2001 From: nickreynolds Date: Wed, 15 Mar 2023 13:29:07 -0400 Subject: [PATCH 1/2] chore: remove dev dependency did-key-creator --- package.json | 1 - src/__tests__/JWT.test.ts | 291 +++++++++++++++++++------------------- yarn.lock | 79 ++--------- 3 files changed, 158 insertions(+), 213 deletions(-) diff --git a/package.json b/package.json index 1f6ea0a4..5283af45 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,6 @@ "@typescript-eslint/eslint-plugin": "5.52.0", "@typescript-eslint/parser": "5.52.0", "codecov": "3.8.3", - "did-key-creator": "^0.3.2", "eslint": "8.34.0", "eslint-config-prettier": "8.6.0", "eslint-plugin-jest": "26.9.0", diff --git a/src/__tests__/JWT.test.ts b/src/__tests__/JWT.test.ts index 00e1f435..cadd10ca 100644 --- a/src/__tests__/JWT.test.ts +++ b/src/__tests__/JWT.test.ts @@ -24,7 +24,6 @@ import { ES256Signer } from '../signers/ES256Signer' import * as jwt from 'jsonwebtoken' import * as u8a from 'uint8arrays' import * as jwkToPem from 'jwk-to-pem' -import { encodeDIDfromHexString } from 'did-key-creator' const NOW = 1485321133 MockDate.set(NOW * 1000 + 123) @@ -121,151 +120,156 @@ const audDidDoc = { describe('createJWT()', () => { describe('ES256', () => { - const alg = 'ES256' - const privateKey = '736f625c9dda78a94bb16840c82779bb7bc18014b8ede52f0f03429902fc4ba8' - const publicKey = '0314c58e581c7656ba153195669fe4ce53ff78dd5ede60a4039771a90c58cb41de' - const publicKey_x = '14c58e581c7656ba153195669fe4ce53ff78dd5ede60a4039771a90c58cb41de' - const publicKey_y = 'ec41869995bd661849414c523c7dff9a96f1c8dbc2e5e78172118f91c7199869' - // construct did:key for secp256r1 (unlike did for secp256k1 which is for an Ethereum Address) - const multicodecName = 'p256-pub'; - const did = encodeDIDfromHexString(multicodecName,publicKey) - - const signer = ES256Signer(hexToBytes(privateKey)) - - interface privateJsonWebKey extends JsonWebKey { - d?: string - } - - // verifyTokenFormAndValidity - function verifyTokenFormAndValidity(token: string, pemPublic: string): boolean { - let result = null - try { - jwt.verify(token, pemPublic) - result = true - } catch (e) { - console.error(e.name + ': ' + e.message) - result = false - } - return result - } - - // input public key in hex, and export pem - function publicToJWK( - publicPointHex_x: string, - publicPointHex_y: string, - kty_value: string, - crv_value: string - ): JsonWebKey { - if (publicPointHex_x.length % 2 != 0) { - publicPointHex_x = '0' + publicPointHex_x - } - if (publicPointHex_y.length % 2 != 0) { - publicPointHex_y = '0' + publicPointHex_y - } - const publicPointUint8_x = u8a.fromString(publicPointHex_x, 'hex') - const publicPointBase64URL_x = u8a.toString(publicPointUint8_x, 'base64url') - const publicPointUint8_y = u8a.fromString(publicPointHex_y, 'hex') - const publicPointBase64URL_y = u8a.toString(publicPointUint8_y, 'base64url') - return { - kty: kty_value, - crv: crv_value, - x: publicPointBase64URL_x, - y: publicPointBase64URL_y, - } - } + const alg = 'ES256' + const privateKey = '736f625c9dda78a94bb16840c82779bb7bc18014b8ede52f0f03429902fc4ba8' + const publicKey_x = '14c58e581c7656ba153195669fe4ce53ff78dd5ede60a4039771a90c58cb41de' + const publicKey_y = 'ec41869995bd661849414c523c7dff9a96f1c8dbc2e5e78172118f91c7199869' + - // input private key in hex, and export pem - function privateToJWK(privatePointHex: string, kty_value: string, crv_value: string): privateJsonWebKey { - if (privatePointHex.length % 2 != 0) { - privatePointHex = '0' + privatePointHex - } - const privatePointUint8 = u8a.fromString(privatePointHex, 'hex') - const privatePointBase64URL = u8a.toString(privatePointUint8, 'base64url') - return { - kty: kty_value, - crv: crv_value, - d: privatePointBase64URL, - } + // construct did:key for secp256r1 (unlike did for secp256k1 which is for an Ethereum Address) + // This originally was constructed by `encodeDIDfromHextString` imported from `did-key-creator` + // package, but that dependency was removed, so now `did` is just hardcoded + // const multicodecName = 'p256-pub'; + // const publicKey = '0314c58e581c7656ba153195669fe4ce53ff78dd5ede60a4039771a90c58cb41de' + // const did = encodeDIDfromHexString(multicodecName,publicKey) + const did = 'did:key:zDnaej4NHntda4rNW4FBUJgFzdcgEAXKGRVGE8LuVfRbuMuc1' + + const signer = ES256Signer(hexToBytes(privateKey)) + + interface privateJsonWebKey extends JsonWebKey { + d?: string + } + + // verifyTokenFormAndValidity + function verifyTokenFormAndValidity(token: string, pemPublic: string): boolean { + let result = null + try { + jwt.verify(token, pemPublic) + result = true + } catch (e) { + console.error(e.name + ': ' + e.message) + result = false } + return result + } - it('creates a valid JWT', async () => { - expect.assertions(1) - const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer },{alg: 'ES256'}) - const pemPublic = jwkToPem.default(publicToJWK(publicKey_x,publicKey_y,'EC','P-256')) - expect(verifyTokenFormAndValidity(jwt,pemPublic)).toBe(true) - }) + // input public key in hex, and export pem + function publicToJWK( + publicPointHex_x: string, + publicPointHex_y: string, + kty_value: string, + crv_value: string + ): JsonWebKey { + if (publicPointHex_x.length % 2 != 0) { + publicPointHex_x = '0' + publicPointHex_x + } + if (publicPointHex_y.length % 2 != 0) { + publicPointHex_y = '0' + publicPointHex_y + } + const publicPointUint8_x = u8a.fromString(publicPointHex_x, 'hex') + const publicPointBase64URL_x = u8a.toString(publicPointUint8_x, 'base64url') + const publicPointUint8_y = u8a.fromString(publicPointHex_y, 'hex') + const publicPointBase64URL_y = u8a.toString(publicPointUint8_y, 'base64url') + return { + kty: kty_value, + crv: crv_value, + x: publicPointBase64URL_x, + y: publicPointBase64URL_y, + } + } - it('creates a valid JWT using a MNID', async () => { - expect.assertions(1) - const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: address, signer },{alg: 'ES256'}) - const pemPublic = jwkToPem.default(publicToJWK(publicKey_x,publicKey_y,'EC','P-256')) - expect(verifyTokenFormAndValidity(jwt,pemPublic)).toBe(true) - }) - - it('creates a JWT with correct format', async () => { - expect.assertions(1) - const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer },{alg: 'ES256'}) - return expect(decodeJWT(jwt)).toMatchSnapshot() - }) - - it('creates a JWT with correct legacy format', async () => { - expect.assertions(1) - const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: address, signer },{alg: 'ES256'}) - return expect(decodeJWT(jwt)).toMatchSnapshot() - }) - - it('creates a JWT with expiry in 10000 seconds', async () => { - expect.assertions(1) - const jwt = await createJWT( - { - requested: ['name', 'phone'], - nbf: Math.floor(new Date().getTime() / 1000), - }, - { issuer: did, signer, expiresIn: 10000 }, - {alg: 'ES256'} + // input private key in hex, and export pem + function privateToJWK(privatePointHex: string, kty_value: string, crv_value: string): privateJsonWebKey { + if (privatePointHex.length % 2 != 0) { + privatePointHex = '0' + privatePointHex + } + const privatePointUint8 = u8a.fromString(privatePointHex, 'hex') + const privatePointBase64URL = u8a.toString(privatePointUint8, 'base64url') + return { + kty: kty_value, + crv: crv_value, + d: privatePointBase64URL, + } + } + + it('creates a valid JWT', async () => { + expect.assertions(1) + const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer },{alg: 'ES256'}) + const pemPublic = jwkToPem.default(publicToJWK(publicKey_x,publicKey_y,'EC','P-256')) + expect(verifyTokenFormAndValidity(jwt,pemPublic)).toBe(true) + }) + + it('creates a valid JWT using a MNID', async () => { + expect.assertions(1) + const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: address, signer },{alg: 'ES256'}) + const pemPublic = jwkToPem.default(publicToJWK(publicKey_x,publicKey_y,'EC','P-256')) + expect(verifyTokenFormAndValidity(jwt,pemPublic)).toBe(true) + }) + + it('creates a JWT with correct format', async () => { + expect.assertions(1) + const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer },{alg: 'ES256'}) + return expect(decodeJWT(jwt)).toMatchSnapshot() + }) + + it('creates a JWT with correct legacy format', async () => { + expect.assertions(1) + const jwt = await createJWT({ requested: ['name', 'phone'] }, { issuer: address, signer },{alg: 'ES256'}) + return expect(decodeJWT(jwt)).toMatchSnapshot() + }) + + it('creates a JWT with expiry in 10000 seconds', async () => { + expect.assertions(1) + const jwt = await createJWT( + { + requested: ['name', 'phone'], + nbf: Math.floor(new Date().getTime() / 1000), + }, + { issuer: did, signer, expiresIn: 10000 }, + {alg: 'ES256'} + ) + const { payload } = decodeJWT(jwt) + return expect(payload.exp).toEqual(payload.nbf + 10000) + }) + + it('Uses iat if nbf is not defined but expiresIn is included', async () => { + expect.assertions(1) + const { payload } = decodeJWT( + await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer, expiresIn: 10000 },{alg: 'ES256'}) ) - const { payload } = decodeJWT(jwt) - return expect(payload.exp).toEqual(payload.nbf + 10000) - }) - - it('Uses iat if nbf is not defined but expiresIn is included', async () => { - expect.assertions(1) - const { payload } = decodeJWT( - await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer, expiresIn: 10000 },{alg: 'ES256'}) - ) - return expect(payload.exp).toEqual(payload.iat + 10000) - }) - - it('sets iat to the current time by default', async () => { - expect.assertions(1) - const timestamp = Math.floor(Date.now() / 1000) - const { payload } = decodeJWT(await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer },{alg: 'ES256'})) - return expect(payload.iat).toEqual(timestamp) - }) - - it('sets iat to the value passed in payload', async () => { - expect.assertions(1) - const timestamp = 2000000 - const { payload } = decodeJWT( - await createJWT({ requested: ['name', 'phone'], iat: timestamp }, { issuer: did, signer },{alg: 'ES256'}) - ) - return expect(payload.iat).toEqual(timestamp) - }) - - it('does not set iat if value in payload is undefined', async () => { - expect.assertions(1) - const { payload } = decodeJWT( - await createJWT({ requested: ['name', 'phone'], iat: undefined }, { issuer: did, signer },{alg: 'ES256'}) - ) - return expect(payload.iat).toBeUndefined() - }) - - it('throws an error if unsupported algorithm is passed in', async () => { - expect.assertions(1) - await expect( - createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer, alg: 'BADALGO' }) - ).rejects.toThrowError('Unsupported algorithm BADALGO') - }) + return expect(payload.exp).toEqual(payload.iat + 10000) + }) + + it('sets iat to the current time by default', async () => { + expect.assertions(1) + const timestamp = Math.floor(Date.now() / 1000) + const { payload } = decodeJWT(await createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer },{alg: 'ES256'})) + return expect(payload.iat).toEqual(timestamp) + }) + + it('sets iat to the value passed in payload', async () => { + expect.assertions(1) + const timestamp = 2000000 + const { payload } = decodeJWT( + await createJWT({ requested: ['name', 'phone'], iat: timestamp }, { issuer: did, signer },{alg: 'ES256'}) + ) + return expect(payload.iat).toEqual(timestamp) + }) + + it('does not set iat if value in payload is undefined', async () => { + expect.assertions(1) + const { payload } = decodeJWT( + await createJWT({ requested: ['name', 'phone'], iat: undefined }, { issuer: did, signer },{alg: 'ES256'}) + ) + return expect(payload.iat).toBeUndefined() + }) + + it('throws an error if unsupported algorithm is passed in', async () => { + expect.assertions(1) + await expect( + createJWT({ requested: ['name', 'phone'] }, { issuer: did, signer, alg: 'BADALGO' }) + ).rejects.toThrowError('Unsupported algorithm BADALGO') + }) }) }) @@ -441,8 +445,9 @@ describe('verifyJWT() for ES256', () => { const publicKey_x = '14c58e581c7656ba153195669fe4ce53ff78dd5ede60a4039771a90c58cb41de' const publicKey_y = 'ec41869995bd661849414c523c7dff9a96f1c8dbc2e5e78172118f91c7199869' // construct did:key for secp256r1 (unlike did for secp256k1 which is for an Ethereum Address) - const multicodecName = 'p256-pub'; - const did = encodeDIDfromHexString(multicodecName,publicKey) + // const multicodecName = 'p256-pub'; + // const did = encodeDIDfromHexString(multicodecName,publicKey) + const did = 'did:key:zDnaej4NHntda4rNW4FBUJgFzdcgEAXKGRVGE8LuVfRbuMuc1' const didDoc = { didDocument: { diff --git a/yarn.lock b/yarn.lock index a6a2514e..7d6b52e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3341,13 +3341,6 @@ browserslist@^4.21.4: node-releases "^2.0.8" update-browserslist-db "^1.0.10" -bs-logger@0.x: - version "0.2.6" - resolved "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz" - integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== - dependencies: - fast-json-stable-stringify "2.x" - bser@2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz" @@ -4007,16 +4000,6 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" -did-key-creator@^0.3.2: - version "0.3.2" - resolved "https://registry.npmjs.org/did-key-creator/-/did-key-creator-0.3.2.tgz" - integrity sha512-FZui+uHKTXjSUjT3H/3vmoSixtlpXLf+DZR036PXgfnK3iJDuJBbgNKyEJJ1M458qnlsmsliK8kWOC/EQhcflg== - dependencies: - multicodec "^3.0.1" - multiformats "^9.6.5" - ts-jest "^28.0.5" - uint8arrays "^2.1.4" - did-resolver@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/did-resolver/-/did-resolver-4.0.0.tgz" @@ -4506,7 +4489,7 @@ fast-glob@^3.2.9: merge2 "^1.3.0" micromatch "^4.0.4" -fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: +fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== @@ -5759,7 +5742,7 @@ jest-snapshot@^28.1.3: pretty-format "^28.1.3" semver "^7.3.5" -jest-util@^28.0.0, jest-util@^28.1.3: +jest-util@^28.1.3: version "28.1.3" resolved "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz" integrity sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ== @@ -6249,7 +6232,7 @@ lodash.isstring@^4.0.1: resolved "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz" integrity sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw== -lodash.memoize@4.x, lodash.memoize@^4.1.2: +lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= @@ -6312,11 +6295,6 @@ make-dir@^3.0.0, make-dir@^3.0.2: dependencies: semver "^6.0.0" -make-error@1.x: - version "1.3.6" - resolved "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - make-fetch-happen@^10.0.3, make-fetch-happen@^10.0.6, make-fetch-happen@^10.2.0: version "10.2.1" resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-10.2.1.tgz#f5e3835c5e9817b617f2770870d9492d28678164" @@ -6637,14 +6615,6 @@ ms@^2.0.0, ms@^2.1.2: resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -multicodec@^3.0.1: - version "3.2.1" - resolved "https://registry.npmjs.org/multicodec/-/multicodec-3.2.1.tgz" - integrity sha512-+expTPftro8VAW8kfvcuNNNBgb9gPeNYV9dn+z1kJRWF2vih+/S79f2RVeIwmrJBUJ6NT9IUPWnZDQvegEh5pw== - dependencies: - uint8arrays "^3.0.0" - varint "^6.0.0" - multiformats@^9.4.2, multiformats@^9.6.5: version "9.7.1" resolved "https://registry.npmjs.org/multiformats/-/multiformats-9.7.1.tgz" @@ -6895,7 +6865,6 @@ npm@^8.3.0: "@npmcli/fs" "^2.1.0" "@npmcli/map-workspaces" "^2.0.3" "@npmcli/package-json" "^2.0.0" - "@npmcli/promise-spawn" "*" "@npmcli/run-script" "^4.2.1" abbrev "~1.1.1" archy "~1.0.0" @@ -6906,7 +6875,6 @@ npm@^8.3.0: cli-table3 "^0.6.2" columnify "^1.6.0" fastest-levenshtein "^1.0.12" - fs-minipass "*" glob "^8.0.1" graceful-fs "^4.2.10" hosted-git-info "^5.1.0" @@ -6926,7 +6894,6 @@ npm@^8.3.0: libnpmteam "^4.0.4" libnpmversion "^3.0.7" make-fetch-happen "^10.2.0" - minimatch "*" minipass "^3.1.6" minipass-pipeline "^1.2.4" mkdirp "^1.0.4" @@ -8154,18 +8121,18 @@ semver@7.0.0: resolved "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz" integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== -semver@7.x, semver@^7.0.0, semver@^7.1.1, semver@^7.1.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7: +semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: + version "6.3.0" + resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + +semver@^7.0.0, semver@^7.1.1, semver@^7.1.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7: version "7.3.7" resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz" integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== dependencies: lru-cache "^6.0.0" -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - semver@^7.3.2: version "7.3.5" resolved "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz" @@ -8731,20 +8698,6 @@ trim-newlines@^3.0.0: resolved "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz" integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw== -ts-jest@^28.0.5: - version "28.0.8" - resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-28.0.8.tgz" - integrity sha512-5FaG0lXmRPzApix8oFG8RKjAz4ehtm8yMKOTy5HX3fY6W8kmvOrmcY0hKDElW52FJov+clhUbrKAqofnj4mXTg== - dependencies: - bs-logger "0.x" - fast-json-stable-stringify "2.x" - jest-util "^28.0.0" - json5 "^2.2.1" - lodash.memoize "4.x" - make-error "1.x" - semver "7.x" - yargs-parser "^21.0.1" - tslib@^1.8.1: version "1.14.1" resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" @@ -8829,13 +8782,6 @@ uglify-js@^3.1.4: resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.0.tgz" integrity sha512-aTeNPVmgIMPpm1cxXr2Q/nEbvkmV8yq66F3om7X3P/cvOXQ0TMQ64Wk63iyT1gPlmdmGzjGpyLh1f3y8MZWXGg== -uint8arrays@^2.1.4: - version "2.1.10" - resolved "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.10.tgz" - integrity sha512-Q9/hhJa2836nQfEJSZTmr+pg9+cDJS9XEAp7N2Vg5MzL3bK/mkMVfjscRGYruP9jNda6MAdf4QD/y78gSzkp6A== - dependencies: - multiformats "^9.4.2" - uint8arrays@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.0.0.tgz" @@ -8981,11 +8927,6 @@ validate-npm-package-name@^4.0.0: dependencies: builtins "^5.0.0" -varint@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz" - integrity sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg== - walk-up-path@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/walk-up-path/-/walk-up-path-1.0.0.tgz" @@ -9179,7 +9120,7 @@ yargs-parser@^20.2.2, yargs-parser@^20.2.3: resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs-parser@^21.0.0, yargs-parser@^21.0.1: +yargs-parser@^21.0.0: version "21.1.1" resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== From 9d8a450851e4e1ebd7b76db0a7ccc6d6b04db3ec Mon Sep 17 00:00:00 2001 From: nickreynolds Date: Wed, 15 Mar 2023 13:31:19 -0400 Subject: [PATCH 2/2] chore: fix whitespace --- src/__tests__/JWT.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/__tests__/JWT.test.ts b/src/__tests__/JWT.test.ts index cadd10ca..40454f4d 100644 --- a/src/__tests__/JWT.test.ts +++ b/src/__tests__/JWT.test.ts @@ -155,10 +155,10 @@ describe('createJWT()', () => { // input public key in hex, and export pem function publicToJWK( - publicPointHex_x: string, - publicPointHex_y: string, - kty_value: string, - crv_value: string + publicPointHex_x: string, + publicPointHex_y: string, + kty_value: string, + crv_value: string ): JsonWebKey { if (publicPointHex_x.length % 2 != 0) { publicPointHex_x = '0' + publicPointHex_x @@ -227,7 +227,7 @@ describe('createJWT()', () => { }, { issuer: did, signer, expiresIn: 10000 }, {alg: 'ES256'} - ) + ) const { payload } = decodeJWT(jwt) return expect(payload.exp).toEqual(payload.nbf + 10000) })