Skip to content

Commit

Permalink
chore(deps): updates
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Jul 14, 2022
1 parent da5135b commit ef4967a
Show file tree
Hide file tree
Showing 11 changed files with 2,611 additions and 1,933 deletions.
16 changes: 12 additions & 4 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ parser: '@typescript-eslint/parser'

parserOptions:
ecmaVersion: 2020
project: './tsconfig.eslint.json'
project: './**/tsconfig.*'

overrides:
- files: '*.ts'
Expand All @@ -46,7 +46,7 @@ overrides:
- prettier
parserOptions:
ecmaVersion: 2020
project: './tsconfig.eslint.json'
project: './**/tsconfig.*'
rules:
'@typescript-eslint/naming-convention':
[
Expand Down Expand Up @@ -78,6 +78,16 @@ overrides:
]
'@typescript-eslint/restrict-template-expressions': off
'@typescript-eslint/no-shadow': warn
'@typescript-eslint/no-unused-vars':
[
warn,
{
args: after-used,
ignoreRestSiblings: true,
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
]

rules:
notice/notice:
Expand All @@ -101,10 +111,8 @@ rules:
*/
onNonMatchingHeader: append
nonMatchingTolerance: 0.7
unicorn/prefer-node-protocol: off
sonarjs/no-duplicate-string: [warn, 5]
sonarjs/cognitive-complexity: warn
eslint-comments/no-unused-disable: off
import/extensions: off
node/no-unpublished-import: off
spaced-comment: [error, always, markers: [/, //]]
Expand Down
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.2.0.cjs
yarnPath: .yarn/releases/yarn-3.2.1.cjs
24 changes: 24 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2022 Open Ag Data Alliance
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable import/no-commonjs */

const config = {
extends: ['@commitlint/config-conventional'],
};

module.exports = config;
62 changes: 32 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jwt-bearer-client-auth",
"version": "2.0.1",
"version": "2.0.2",
"description": "Create and verify JWT bearer client assertions from the OAuth-JWT-bearer RFC",
"main": "dist/index.js",
"files": [
Expand Down Expand Up @@ -77,40 +77,42 @@
},
"homepage": "https://github.com/OADA/jwt-bearer-client-auth",
"dependencies": {
"@oada/certs": "^4.1.0",
"@oada/certs": "^4.1.1",
"jsonwebtoken": "^8.5.1",
"pem-jwk": "^2.0.0",
"tslib": "^2.3.1"
"tslib": "^2.4.0"
},
"devDependencies": {
"@tsconfig/node12": "^1.0.9",
"@types/chai": "^4.3.0",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@tsconfig/node12": "^1.0.11",
"@types/chai": "^4.3.1",
"@types/chai-as-promised": "^7.1.5",
"@types/events": "^3.0.0",
"@types/jsonwebtoken": "^8.5.8",
"@types/jws": "^3.2.4",
"@types/karma-chrome-launcher": "^3.1.1",
"@types/mocha": "^9.1.0",
"@types/node": "12.20.47",
"@types/mocha": "^9.1.1",
"@types/node": "12.20.55",
"@types/node-jose": "^1.1.10",
"@types/pem-jwk": "^2.0.0",
"@types/prettier": "^2.4.4",
"@types/prettier": "^2.6.3",
"@types/source-map-support": "^0.5.4",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"@yarnpkg/sdks": "^2.6.0",
"@typescript-eslint/eslint-plugin": "^5.30.6",
"@typescript-eslint/parser": "^5.30.6",
"@yarnpkg/sdks": "^3.0.0-rc.12",
"assert": "^2.0.0",
"brfs": "^2.0.2",
"browserify": "^17.0.0",
"buffer": "^6.0.3",
"c8": "^7.11.0",
"c8": "^7.11.3",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"crypto-browserify": "^3.12.0",
"eslint": "^8.12.0",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-xo": "^0.40.0",
"eslint-config-xo-typescript": "^0.50.0",
"eslint-config-xo": "^0.41.0",
"eslint-config-xo-typescript": "^0.51.1",
"eslint-formatter-pretty": "^4.1.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-plugin-array-func": "^3.1.7",
Expand All @@ -119,45 +121,45 @@
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-github": "^4.3.6",
"eslint-plugin-i18n-text": "^1.0.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-no-constructor-bind": "^2.0.4",
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-no-secrets": "^0.8.9",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-optimize-regex": "^1.2.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-regexp": "^1.6.0",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-regexp": "^1.7.0",
"eslint-plugin-security": "^1.5.0",
"eslint-plugin-sonarjs": "^0.13.0",
"eslint-plugin-unicorn": "^42.0.0",
"eslint-plugin-unicorn": "^43.0.1",
"events": "^3.3.0",
"jws": "^4.0.0",
"karma": "^6.3.17",
"karma": "^6.4.0",
"karma-browserify": "^8.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-vivaldi-launcher": "^0.0.1",
"karma-webpack": "^5.0.0",
"mocha": "^9.2.2",
"mocha": "^10.0.0",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"prettier": "^2.6.1",
"prettier": "^2.7.1",
"process": "^0.11.10",
"puppeteer": "^13.5.2",
"puppeteer": "^15.4.0",
"stream-browserify": "^3.0.0",
"string_decoder": "^1.3.0",
"superagent": "^7.1.2",
"superagent": "^8.0.0",
"transform-loader": "^0.2.4",
"ts-loader": "^9.2.8",
"ts-node": "^10.7.0",
"typescript": "^4.6.3",
"ts-loader": "^9.3.1",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
"url": "^0.11.0",
"util": "^0.12.4",
"webpack": "^5.71.0"
"webpack": "^5.73.0"
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].1"
}
3 changes: 1 addition & 2 deletions src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { RSA_JWK, jwk2pem } from 'pem-jwk';
import { SignOptions, sign } from 'jsonwebtoken';

import type { JWKpem } from '@oada/certs/dist/jwks-utils';
import { jwksUtils as jwks } from '@oada/certs';

/**
Expand Down Expand Up @@ -89,7 +88,7 @@ export async function generate({
},
};

const pem = key.kty === 'PEM' ? (key as JWKpem).pem : jwk2pem(key as RSA_JWK);
const pem = key.kty === 'PEM' ? key.pem : jwk2pem(key as RSA_JWK);

return sign(payload, pem, jwtOptions);
}
3 changes: 1 addition & 2 deletions src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { RSA_JWK, jwk2pem } from 'pem-jwk';
import { verify as jwtVerify } from 'jsonwebtoken';

import type { JWKpem } from '@oada/certs/dist/jwks-utils';
import { jwksUtils as jwks } from '@oada/certs';

export interface VerifyOptions {
Expand All @@ -38,7 +37,7 @@ export async function verify({
payload,
}: VerifyOptions) {
const jwk = await jwks.jwkForSignature(token, hint);
const key = jwk.kty === 'PEM' ? (jwk as JWKpem).pem : jwk2pem(jwk as RSA_JWK);
const key = jwk.kty === 'PEM' ? jwk.pem : jwk2pem(jwk as RSA_JWK);

const verifyOptions = {
issuer,
Expand Down
5 changes: 4 additions & 1 deletion test/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { decode } from 'jws';
import { pem2jwk } from 'pem-jwk';
import { verify } from 'jsonwebtoken';

import type { JWK } from '@oada/certs/dist/jwks-utils';

import { generate } from '../dist';

chai.use(chaiAsPromised);
Expand All @@ -41,7 +43,8 @@ describe('generate', () => {
// eslint-disable-next-line prefer-template, security/detect-non-literal-fs-filename
pem: fs.readFileSync(__dirname + '/keys/abc123.private.pem').toString(),
} as const;
const privateJwk = { ...pem2jwk(privatePem.pem), kid: 'abc123' };
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const privateJwk = { ...pem2jwk(privatePem.pem), kid: 'abc123' } as JWK;
const publicPem = {
kid: 'abc123',
kty: 'PEM',
Expand Down
6 changes: 5 additions & 1 deletion test/verify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import chaiAsPromised from 'chai-as-promised';
import { pem2jwk } from 'pem-jwk';
import { sign } from 'jsonwebtoken';

import type { JWK } from '@oada/certs/dist/jwks-utils';

import { verify } from '../';

chai.use(chaiAsPromised);
Expand All @@ -46,7 +48,8 @@ describe('verify', () => {
// eslint-disable-next-line prefer-template, security/detect-non-literal-fs-filename
pem: fs.readFileSync(__dirname + '/keys/abc123.public.pem').toString(),
} as const;
const publicJwk = { ...pem2jwk(publicPem.pem), kid: 'abc123' };
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const publicJwk = { ...pem2jwk(publicPem.pem), kid: 'abc123' } as JWK;
const alg = 'RS256';
const options = {
algorithm: alg,
Expand Down Expand Up @@ -219,6 +222,7 @@ describe('verify', () => {
it('should fail if key type not supported', () => {
const token = sign({}, privatePem.pem, options);

// @ts-expect-error type intentionally wrong
publicJwk.kty = '[Unknown]';
const valid = verify({
token,
Expand Down
Loading

0 comments on commit ef4967a

Please sign in to comment.