jsontokens
Advanced tools
Comparing version 4.0.0 to 4.0.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decodeToken = void 0; | ||
const base64url_1 = require("base64url"); | ||
const base64url = require("./base64Url"); | ||
function decodeToken(token) { | ||
@@ -9,4 +9,4 @@ if (typeof token === 'string') { | ||
const tokenParts = token.split('.'); | ||
const header = JSON.parse(base64url_1.default.decode(tokenParts[0])); | ||
const payload = JSON.parse(base64url_1.default.decode(tokenParts[1])); | ||
const header = JSON.parse(base64url.decode(tokenParts[0])); | ||
const payload = JSON.parse(base64url.decode(tokenParts[1])); | ||
const signature = tokenParts[2]; | ||
@@ -26,7 +26,7 @@ // return the token object | ||
if (token.payload[0] !== '{') { | ||
payload = base64url_1.default.decode(payload); | ||
payload = base64url.decode(payload); | ||
} | ||
const allHeaders = []; | ||
token.header.map((headerValue) => { | ||
const header = JSON.parse(base64url_1.default.decode(headerValue)); | ||
const header = JSON.parse(base64url.decode(headerValue)); | ||
allHeaders.push(header); | ||
@@ -33,0 +33,0 @@ }); |
@@ -20,2 +20,3 @@ "use strict"; | ||
const base64_js_1 = require("base64-js"); | ||
const base64Url_1 = require("./base64Url"); | ||
function getParamSize(keySize) { | ||
@@ -43,8 +44,2 @@ return ((keySize / 8) | 0) + (keySize % 8 === 0 ? 0 : 1); | ||
const ENCODED_TAG_INT = TAG_INT | (CLASS_UNIVERSAL << 6); | ||
function base64Url(base64) { | ||
return base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); | ||
} | ||
function base64Pad(base64) { | ||
return `${base64}${'='.repeat(base64.length % 3)}`; | ||
} | ||
function signatureAsBytes(signature) { | ||
@@ -55,3 +50,3 @@ if (signature instanceof Uint8Array) { | ||
else if ('string' === typeof signature) { | ||
return (0, base64_js_1.toByteArray)(base64Pad(signature)); | ||
return (0, base64_js_1.toByteArray)((0, base64Url_1.pad)(signature)); | ||
} | ||
@@ -117,3 +112,3 @@ throw new TypeError('ECDSA signature must be a Base64 string or a Uint8Array'); | ||
dst.set(signatureBytes.subarray(sOffset + Math.max(-sPadding, 0), sOffset + sLength), offset); | ||
return base64Url((0, base64_js_1.fromByteArray)(dst)); | ||
return (0, base64Url_1.escape)((0, base64_js_1.fromByteArray)(dst)); | ||
} | ||
@@ -120,0 +115,0 @@ exports.derToJose = derToJose; |
@@ -13,3 +13,3 @@ "use strict"; | ||
exports.TokenSigner = exports.createUnsecuredToken = void 0; | ||
const base64url_1 = require("base64url"); | ||
const base64url = require("./base64Url"); | ||
const cryptoClients_1 = require("./cryptoClients"); | ||
@@ -21,6 +21,6 @@ const errors_1 = require("./errors"); | ||
// add in the header | ||
const encodedHeader = base64url_1.default.encode(JSON.stringify(header)); | ||
const encodedHeader = base64url.encode(JSON.stringify(header)); | ||
tokenParts.push(encodedHeader); | ||
// add in the payload | ||
const encodedPayload = base64url_1.default.encode(JSON.stringify(payload)); | ||
const encodedPayload = base64url.encode(JSON.stringify(payload)); | ||
tokenParts.push(encodedPayload); | ||
@@ -80,3 +80,3 @@ // prepare the message | ||
const signedToken = { | ||
header: [base64url_1.default.encode(JSON.stringify(header))], | ||
header: [base64url.encode(JSON.stringify(header))], | ||
payload: JSON.stringify(payload), | ||
@@ -83,0 +83,0 @@ signature: [signature], |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TokenVerifier = void 0; | ||
const base64url_1 = require("base64url"); | ||
const base64url = require("./base64Url"); | ||
const cryptoClients_1 = require("./cryptoClients"); | ||
@@ -66,3 +66,3 @@ const errors_1 = require("./errors"); | ||
verifyExpanded(token, async) { | ||
const signingInput = [token['header'].join('.'), base64url_1.default.encode(token['payload'])].join('.'); | ||
const signingInput = [token['header'].join('.'), base64url.encode(token['payload'])].join('.'); | ||
let verified = true; | ||
@@ -69,0 +69,0 @@ const performVerify = (signingInputHash) => { |
{ | ||
"name": "jsontokens", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "node.js library for encoding, decoding, and verifying JSON Web Tokens (JWTs)", | ||
@@ -51,4 +51,3 @@ "main": "lib/index.js", | ||
"@noble/secp256k1": "^1.6.3", | ||
"base64-js": "^1.5.1", | ||
"base64url": "^3.0.1" | ||
"base64-js": "^1.5.1" | ||
}, | ||
@@ -55,0 +54,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
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
121879
3
35
658
- Removedbase64url@^3.0.1
- Removedbase64url@3.0.1(transitive)