jose-node-esm-runtime
Advanced tools
Comparing version 3.20.2 to 3.20.3
import { decode as base64url } from '../../runtime/base64url.js'; | ||
import decrypt from '../../runtime/decrypt.js'; | ||
import { inflate } from '../../runtime/zlib.js'; | ||
import random from '../../runtime/random.js'; | ||
import { JOSEAlgNotAllowed, JOSENotSupported, JWEInvalid } from '../../util/errors.js'; | ||
@@ -10,9 +9,5 @@ import isDisjoint from '../../lib/is_disjoint.js'; | ||
import { encoder, decoder, concat } from '../../lib/buffer_utils.js'; | ||
import cekFactory from '../../lib/cek.js'; | ||
import generateCek from '../../lib/cek.js'; | ||
import validateCrit from '../../lib/validate_crit.js'; | ||
import validateAlgorithms from '../../lib/validate_algorithms.js'; | ||
const generateCek = cekFactory(random); | ||
const checkExtensions = validateCrit.bind(undefined, JWEInvalid, new Map()); | ||
const checkAlgOption = validateAlgorithms.bind(undefined, 'keyManagementAlgorithms'); | ||
const checkEncOption = validateAlgorithms.bind(undefined, 'contentEncryptionAlgorithms'); | ||
async function flattenedDecrypt(jwe, key, options) { | ||
@@ -68,3 +63,3 @@ var _a; | ||
}; | ||
checkExtensions(options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader); | ||
validateCrit(JWEInvalid, new Map(), options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader); | ||
if (joseHeader.zip !== undefined) { | ||
@@ -85,4 +80,5 @@ if (!parsedProt || !parsedProt.zip) { | ||
} | ||
const keyManagementAlgorithms = options && checkAlgOption(options.keyManagementAlgorithms); | ||
const contentEncryptionAlgorithms = options && checkEncOption(options.contentEncryptionAlgorithms); | ||
const keyManagementAlgorithms = options && validateAlgorithms('keyManagementAlgorithms', options.keyManagementAlgorithms); | ||
const contentEncryptionAlgorithms = options && | ||
validateAlgorithms('contentEncryptionAlgorithms', options.contentEncryptionAlgorithms); | ||
if (keyManagementAlgorithms && !keyManagementAlgorithms.has(alg)) { | ||
@@ -89,0 +85,0 @@ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter not allowed'); |
import { encode as base64url } from '../../runtime/base64url.js'; | ||
import random from '../../runtime/random.js'; | ||
import encrypt from '../../runtime/encrypt.js'; | ||
import { deflate } from '../../runtime/zlib.js'; | ||
import ivFactory from '../../lib/iv.js'; | ||
import generateIv from '../../lib/iv.js'; | ||
import encryptKeyManagement from '../../lib/encrypt_key_management.js'; | ||
@@ -11,4 +10,2 @@ import { JOSENotSupported, JWEInvalid } from '../../util/errors.js'; | ||
import validateCrit from '../../lib/validate_crit.js'; | ||
const generateIv = ivFactory(random); | ||
const checkExtensions = validateCrit.bind(undefined, JWEInvalid, new Map()); | ||
class FlattenedEncrypt { | ||
@@ -79,3 +76,3 @@ constructor(plaintext) { | ||
}; | ||
checkExtensions(options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader); | ||
validateCrit(JWEInvalid, new Map(), options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader); | ||
if (joseHeader.zip !== undefined) { | ||
@@ -82,0 +79,0 @@ if (!this._protectedHeader || !this._protectedHeader.zip) { |
@@ -8,3 +8,2 @@ import { encode as base64url } from '../../runtime/base64url.js'; | ||
import validateCrit from '../../lib/validate_crit.js'; | ||
const checkExtensions = validateCrit.bind(undefined, JWSInvalid, new Map([['b64', true]])); | ||
class FlattenedSign { | ||
@@ -42,3 +41,3 @@ constructor(payload) { | ||
}; | ||
const extensions = checkExtensions(options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader); | ||
const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader); | ||
let b64 = true; | ||
@@ -45,0 +44,0 @@ if (extensions.has('b64')) { |
@@ -10,4 +10,2 @@ import { decode as base64url } from '../../runtime/base64url.js'; | ||
import validateAlgorithms from '../../lib/validate_algorithms.js'; | ||
const checkExtensions = validateCrit.bind(undefined, JWSInvalid, new Map([['b64', true]])); | ||
const checkAlgOption = validateAlgorithms.bind(undefined, 'algorithms'); | ||
async function flattenedVerify(jws, key, options) { | ||
@@ -50,3 +48,3 @@ var _a; | ||
}; | ||
const extensions = checkExtensions(options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader); | ||
const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader); | ||
let b64 = true; | ||
@@ -63,3 +61,3 @@ if (extensions.has('b64')) { | ||
} | ||
const algorithms = options && checkAlgOption(options.algorithms); | ||
const algorithms = options && validateAlgorithms('algorithms', options.algorithms); | ||
if (algorithms && !algorithms.has(alg)) { | ||
@@ -66,0 +64,0 @@ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter not allowed'); |
import { JOSENotSupported } from '../util/errors.js'; | ||
import random from '../runtime/random.js'; | ||
const bitLengths = new Map([ | ||
@@ -10,3 +11,3 @@ ['A128CBC-HS256', 256], | ||
]); | ||
const factory = (random) => (alg) => { | ||
const generateCek = (alg) => { | ||
const bitLength = bitLengths.get(alg); | ||
@@ -18,3 +19,3 @@ if (!bitLength) { | ||
}; | ||
export default factory; | ||
export default generateCek; | ||
export { bitLengths }; |
@@ -1,2 +0,1 @@ | ||
import random from '../runtime/random.js'; | ||
import { wrap as aesKw } from '../runtime/aeskw.js'; | ||
@@ -8,7 +7,6 @@ import * as ECDH from '../runtime/ecdhes.js'; | ||
import { encode as base64url } from '../runtime/base64url.js'; | ||
import cekFactory, { bitLengths as cekLengths } from '../lib/cek.js'; | ||
import generateCek, { bitLengths as cekLengths } from '../lib/cek.js'; | ||
import { JOSENotSupported } from '../util/errors.js'; | ||
import { exportJWK } from '../key/export.js'; | ||
import checkKeyType from './check_key_type.js'; | ||
const generateCek = cekFactory(random); | ||
async function encryptKeyManagement(alg, enc, key, providedCek, providedParameters = {}) { | ||
@@ -15,0 +13,0 @@ let encryptedKey; |
import { JOSENotSupported } from '../util/errors.js'; | ||
import random from '../runtime/random.js'; | ||
const bitLengths = new Map([ | ||
@@ -13,3 +14,3 @@ ['A128CBC-HS256', 128], | ||
]); | ||
const factory = (random) => (alg) => { | ||
const generateIv = (alg) => { | ||
const bitLength = bitLengths.get(alg); | ||
@@ -21,3 +22,3 @@ if (!bitLength) { | ||
}; | ||
export default factory; | ||
export default generateIv; | ||
export { bitLengths }; |
import encrypt from './encrypt.js'; | ||
import decrypt from './decrypt.js'; | ||
import ivFactory from '../lib/iv.js'; | ||
import random from './random.js'; | ||
import generateIv from '../lib/iv.js'; | ||
import { encode as base64url } from './base64url.js'; | ||
const generateIv = ivFactory(random); | ||
export const wrap = async (alg, key, cek, iv) => { | ||
@@ -8,0 +6,0 @@ const jweAlgorithm = alg.substr(0, 7); |
@@ -24,2 +24,13 @@ export class JOSEError extends Error { | ||
} | ||
export class JWTExpired extends JOSEError { | ||
constructor(message, claim = 'unspecified', reason = 'unspecified') { | ||
super(message); | ||
this.code = 'ERR_JWT_EXPIRED'; | ||
this.claim = claim; | ||
this.reason = reason; | ||
} | ||
static get code() { | ||
return 'ERR_JWT_EXPIRED'; | ||
} | ||
} | ||
export class JOSEAlgNotAllowed extends JOSEError { | ||
@@ -138,10 +149,1 @@ constructor() { | ||
} | ||
export class JWTExpired extends JWTClaimValidationFailed { | ||
constructor() { | ||
super(...arguments); | ||
this.code = 'ERR_JWT_EXPIRED'; | ||
} | ||
static get code() { | ||
return 'ERR_JWT_EXPIRED'; | ||
} | ||
} |
@@ -13,2 +13,9 @@ export declare class JOSEError extends Error { | ||
} | ||
export declare class JWTExpired extends JOSEError implements JWTClaimValidationFailed { | ||
static get code(): 'ERR_JWT_EXPIRED'; | ||
code: string; | ||
claim: string; | ||
reason: string; | ||
constructor(message: string, claim?: string, reason?: string); | ||
} | ||
export declare class JOSEAlgNotAllowed extends JOSEError { | ||
@@ -67,5 +74,1 @@ static get code(): 'ERR_JOSE_ALG_NOT_ALLOWED'; | ||
} | ||
export declare class JWTExpired extends JWTClaimValidationFailed { | ||
static get code(): 'ERR_JWT_EXPIRED'; | ||
code: string; | ||
} |
{ | ||
"name": "jose-node-esm-runtime", | ||
"version": "3.20.2", | ||
"version": "3.20.3", | ||
"description": "(Node.JS ESM Runtime) 'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK with no dependencies", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
169009
4269