Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump jsonwebtoken from 8.5.1 to 9.0.0 #1062

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions __tests__/jwt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const verifyOptions = {
clientId: 'the_client_id'
};

const symmetricKey = 'shared secret';

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "shared secret" is used as [key](1).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used in tests, have dismissed the alert.


const createPrivateKey = () => {
const { privateKey } = generateKeyPairSync('rsa', {
modulusLength: 2048
Expand All @@ -27,8 +29,12 @@ const DEFAULT_PAYLOAD = <any>{
nonce: verifyOptions.nonce,
azp: verifyOptions.aud
};
const createJWT = (payload = DEFAULT_PAYLOAD, options = {}) => {
const key = createPrivateKey();
const createJWT = (
payload = DEFAULT_PAYLOAD,
options: Record<string, any> = {}
) => {
const key = options.algorithm === 'HS256' ? symmetricKey : createPrivateKey();

return jwt.sign(payload, key, {
algorithm: 'RS256',
audience: verifyOptions.aud,
Expand All @@ -43,6 +49,7 @@ const verifier = new IDTokenVerifier({
issuer: verifyOptions.iss,
audience: verifyOptions.aud
});

verifier.getRsaVerifier = (_, __, cb) => cb(null, { verify: () => true });

describe('jwt', () => {
Expand Down Expand Up @@ -171,10 +178,12 @@ describe('jwt', () => {
const id_token = await createJWT(DEFAULT_PAYLOAD, {
algorithm: 'HS256'
});

expect(() => verify({ ...verifyOptions, id_token })).toThrow(
`Signature algorithm of "HS256" is not supported. Expected the ID token to be signed with "RS256".`
);
});

it('validates issuer is present', async () => {
const id_token = await createJWT(DEFAULT_PAYLOAD, { issuer: '' });
expect(() => verify({ ...verifyOptions, id_token })).toThrow(
Expand Down
124 changes: 39 additions & 85 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"jest-fetch-mock": "^3.0.3",
"jest-junit": "^14.0.0",
"jest-localstorage-mock": "^2.4.22",
"jsonwebtoken": "^8.5.1",
"jsonwebtoken": "^9.0.0",
"node-fetch": "^3.2.10",
"oidc-provider": "^7.14.0",
"prettier": "^2.7.1",
Expand Down