@block65/kms-jsonwebtoken
Advanced tools
+8
-14
@@ -7,12 +7,2 @@ "use strict"; | ||
| const error_1 = require("./error"); | ||
| function toBase64Url(buff) { | ||
| return Buffer.from(buff) | ||
| .toString('base64') | ||
| .replace(/\+/g, '-') | ||
| .replace(/\//g, '_') | ||
| .replace(/=/g, ''); | ||
| } | ||
| function fromBase64Url(encoded) { | ||
| return Buffer.from(encoded.replace(/-/g, '+').replace(/_/g, '/'), 'base64'); | ||
| } | ||
| async function sign(payload, signatureFunction, options) { | ||
@@ -28,3 +18,3 @@ if (!options.keyid) { | ||
| algorithm: 'none', | ||
| jwtid: options.jwtid || toBase64Url(crypto.randomBytes(12)), | ||
| jwtid: options.jwtid || crypto.randomBytes(12).toString('base64url'), | ||
| }, (err, result) => { | ||
@@ -41,7 +31,11 @@ if (err) { | ||
| const [encodedAlgNoneHeader, encodedPayload] = token.split('.'); | ||
| const header = JSON.parse(fromBase64Url(encodedAlgNoneHeader).toString()); | ||
| const encodedRs256Header = toBase64Url(Buffer.from(JSON.stringify({ ...header, alg: 'RS256' }))); | ||
| const header = JSON.parse(Buffer.from(encodedAlgNoneHeader, 'base64url').toString()); | ||
| const encodedRs256Header = Buffer.from(JSON.stringify({ ...header, alg: 'RS256' })).toString('base64url'); | ||
| const signature = await signatureFunction(Buffer.from(`${encodedRs256Header}.${encodedPayload}`), options); | ||
| return [encodedRs256Header, encodedPayload, toBase64Url(signature)].join('.'); | ||
| return [ | ||
| encodedRs256Header, | ||
| encodedPayload, | ||
| signature.toString('base64url'), | ||
| ].join('.'); | ||
| } | ||
| exports.sign = sign; |
+14
-11
| { | ||
| "name": "@block65/kms-jsonwebtoken", | ||
| "version": "3.0.0", | ||
| "version": "4.0.1", | ||
| "private": false, | ||
@@ -26,13 +26,13 @@ "license": "UNLICENSED", | ||
| "devDependencies": { | ||
| "@aws-sdk/client-kms": "^3.13.0", | ||
| "@aws-sdk/client-kms": "^3.14.0", | ||
| "@block65/eslint-config": "4.0.0", | ||
| "@google-cloud/kms": "^2.3.1", | ||
| "@types/jest": "^26.0.22", | ||
| "@types/jest": "^26.0.23", | ||
| "@types/jsonwebtoken": "^8.5.1", | ||
| "@types/node": "^14.14.41", | ||
| "@typescript-eslint/eslint-plugin": "^4.22.0", | ||
| "@typescript-eslint/parser": "^4.22.0", | ||
| "aws-sdk-client-mock": "^0.3.0", | ||
| "eslint": "^7.24.0", | ||
| "eslint-plugin-formatjs": "^2.14.7", | ||
| "@types/node": "^15.0.2", | ||
| "@typescript-eslint/eslint-plugin": "^4.22.1", | ||
| "@typescript-eslint/parser": "^4.22.1", | ||
| "aws-sdk-client-mock": "^0.4.0", | ||
| "eslint": "^7.26.0", | ||
| "eslint-plugin-formatjs": "^2.14.10", | ||
| "eslint-plugin-import": "^2.22.1", | ||
@@ -45,9 +45,12 @@ "eslint-plugin-prettier": "^3.4.0", | ||
| "rimraf": "^3.0.2", | ||
| "ts-jest": "^26.5.5", | ||
| "ts-jest": "^26.5.6", | ||
| "typescript": "^4.2.4" | ||
| }, | ||
| "peerDependencies": { | ||
| "@aws-sdk/client-kms": "^3.13.0", | ||
| "@aws-sdk/client-kms": "^3.14.0", | ||
| "@google-cloud/kms": "^2.3.1" | ||
| }, | ||
| "engines": { | ||
| "node": ">=15.7.0" | ||
| } | ||
| } |
| /// <reference types="node" /> | ||
| declare function toBase64Url(buff: Buffer): string; | ||
| declare function fromBase64Url(encoded: string): Buffer; |
| "use strict"; | ||
| function toBase64Url(buff) { | ||
| return Buffer.from(buff) | ||
| .toString('base64') | ||
| .replace(/\+/g, '-') | ||
| .replace(/\//g, '_') | ||
| .replace(/=/g, ''); | ||
| } | ||
| function fromBase64Url(encoded) { | ||
| return Buffer.from(encoded.replace(/-/g, '+').replace(/_/g, '/'), 'base64'); | ||
| } |
Explicitly Unlicensed Item
LicenseSomething was found which is explicitly marked as unlicensed.
Found 1 instance in 1 package
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Explicitly Unlicensed Item
LicenseSomething was found which is explicitly marked as unlicensed.
Found 1 instance in 1 package
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
14027
-4.27%18
-10%277
-6.73%