Socket
Socket
Sign inDemoInstall

jose

Package Overview
Dependencies
Maintainers
1
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jose - npm Package Compare versions

Comparing version 4.9.2 to 4.9.3

14

dist/browser/lib/check_key_type.js

@@ -1,8 +0,8 @@

import invalidKeyInput from './invalid_key_input.js';
import { withAlg as invalidKeyInput } from './invalid_key_input.js';
import isKeyLike, { types } from '../runtime/is_key_like.js';
const symmetricTypeCheck = (key) => {
const symmetricTypeCheck = (alg, key) => {
if (key instanceof Uint8Array)
return;
if (!isKeyLike(key)) {
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));
throw new TypeError(invalidKeyInput(alg, key, ...types, 'Uint8Array'));
}

@@ -13,5 +13,5 @@ if (key.type !== 'secret') {

};
const asymmetricTypeCheck = (key, usage) => {
const asymmetricTypeCheck = (alg, key, usage) => {
if (!isKeyLike(key)) {
throw new TypeError(invalidKeyInput(key, ...types));
throw new TypeError(invalidKeyInput(alg, key, ...types));
}

@@ -40,8 +40,8 @@ if (key.type === 'secret') {

if (symmetric) {
symmetricTypeCheck(key);
symmetricTypeCheck(alg, key);
}
else {
asymmetricTypeCheck(key, usage);
asymmetricTypeCheck(alg, key, usage);
}
};
export default checkKeyType;

@@ -1,3 +0,2 @@

export default (actual, ...types) => {
let msg = 'Key must be ';
function message(msg, actual, ...types) {
if (types.length > 2) {

@@ -25,2 +24,8 @@ const last = types.pop();

return msg;
}
export default (actual, ...types) => {
return message('Key must be ', actual, ...types);
};
export function withAlg(alg, actual, ...types) {
return message(`Key for the ${alg} algorithm must be `, actual, ...types);
}
import { JWEInvalid } from '../util/errors.js';
const checkCekLength = (cek, expected) => {
if (cek.length << 3 !== expected) {
throw new JWEInvalid('Invalid Content Encryption Key length');
const actual = cek.byteLength << 3;
if (actual !== expected) {
throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
}
};
export default checkCekLength;

@@ -5,7 +5,7 @@ "use strict";

const is_key_like_js_1 = require("../runtime/is_key_like.js");
const symmetricTypeCheck = (key) => {
const symmetricTypeCheck = (alg, key) => {
if (key instanceof Uint8Array)
return;
if (!(0, is_key_like_js_1.default)(key)) {
throw new TypeError((0, invalid_key_input_js_1.default)(key, ...is_key_like_js_1.types, 'Uint8Array'));
throw new TypeError((0, invalid_key_input_js_1.withAlg)(alg, key, ...is_key_like_js_1.types, 'Uint8Array'));
}

@@ -16,5 +16,5 @@ if (key.type !== 'secret') {

};
const asymmetricTypeCheck = (key, usage) => {
const asymmetricTypeCheck = (alg, key, usage) => {
if (!(0, is_key_like_js_1.default)(key)) {
throw new TypeError((0, invalid_key_input_js_1.default)(key, ...is_key_like_js_1.types));
throw new TypeError((0, invalid_key_input_js_1.withAlg)(alg, key, ...is_key_like_js_1.types));
}

@@ -43,8 +43,8 @@ if (key.type === 'secret') {

if (symmetric) {
symmetricTypeCheck(key);
symmetricTypeCheck(alg, key);
}
else {
asymmetricTypeCheck(key, usage);
asymmetricTypeCheck(alg, key, usage);
}
};
exports.default = checkKeyType;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (actual, ...types) => {
let msg = 'Key must be ';
exports.withAlg = void 0;
function message(msg, actual, ...types) {
if (types.length > 2) {

@@ -27,2 +27,9 @@ const last = types.pop();

return msg;
}
exports.default = (actual, ...types) => {
return message('Key must be ', actual, ...types);
};
function withAlg(alg, actual, ...types) {
return message(`Key for the ${alg} algorithm must be `, actual, ...types);
}
exports.withAlg = withAlg;

@@ -22,4 +22,5 @@ "use strict";

if (cek instanceof Uint8Array) {
if (cek.length << 3 !== expected) {
throw new errors_js_1.JWEInvalid('Invalid Content Encryption Key length');
const actual = cek.byteLength << 3;
if (actual !== expected) {
throw new errors_js_1.JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
}

@@ -29,4 +30,5 @@ return;

if ((0, is_key_object_js_1.default)(cek) && cek.type === 'secret') {
if (cek.symmetricKeySize << 3 !== expected) {
throw new errors_js_1.JWEInvalid('Invalid Content Encryption Key length');
const actual = cek.symmetricKeySize << 3;
if (actual !== expected) {
throw new errors_js_1.JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
}

@@ -33,0 +35,0 @@ return;

@@ -1,8 +0,8 @@

import invalidKeyInput from './invalid_key_input.js';
import { withAlg as invalidKeyInput } from './invalid_key_input.js';
import isKeyLike, { types } from '../runtime/is_key_like.js';
const symmetricTypeCheck = (key) => {
const symmetricTypeCheck = (alg, key) => {
if (key instanceof Uint8Array)
return;
if (!isKeyLike(key)) {
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));
throw new TypeError(invalidKeyInput(alg, key, ...types, 'Uint8Array'));
}

@@ -13,5 +13,5 @@ if (key.type !== 'secret') {

};
const asymmetricTypeCheck = (key, usage) => {
const asymmetricTypeCheck = (alg, key, usage) => {
if (!isKeyLike(key)) {
throw new TypeError(invalidKeyInput(key, ...types));
throw new TypeError(invalidKeyInput(alg, key, ...types));
}

@@ -40,8 +40,8 @@ if (key.type === 'secret') {

if (symmetric) {
symmetricTypeCheck(key);
symmetricTypeCheck(alg, key);
}
else {
asymmetricTypeCheck(key, usage);
asymmetricTypeCheck(alg, key, usage);
}
};
export default checkKeyType;

@@ -1,3 +0,2 @@

export default (actual, ...types) => {
let msg = 'Key must be ';
function message(msg, actual, ...types) {
if (types.length > 2) {

@@ -25,2 +24,8 @@ const last = types.pop();

return msg;
}
export default (actual, ...types) => {
return message('Key must be ', actual, ...types);
};
export function withAlg(alg, actual, ...types) {
return message(`Key for the ${alg} algorithm must be `, actual, ...types);
}

@@ -20,4 +20,5 @@ import { JWEInvalid, JOSENotSupported } from '../util/errors.js';

if (cek instanceof Uint8Array) {
if (cek.length << 3 !== expected) {
throw new JWEInvalid('Invalid Content Encryption Key length');
const actual = cek.byteLength << 3;
if (actual !== expected) {
throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
}

@@ -27,4 +28,5 @@ return;

if (isKeyObject(cek) && cek.type === 'secret') {
if (cek.symmetricKeySize << 3 !== expected) {
throw new JWEInvalid('Invalid Content Encryption Key length');
const actual = cek.symmetricKeySize << 3;
if (actual !== expected) {
throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
}

@@ -31,0 +33,0 @@ return;

@@ -23,4 +23,4 @@ /**

* [CryptoKey](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey) is a representation of a
* key/secret available in the Browser and Deno runtimes. In addition to the import functions of
* this library you may use the
* key/secret available in the Browser and Web-interoperable runtimes. In addition to the import
* functions of this library you may use the
* [SubtleCrypto.importKey](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey)

@@ -27,0 +27,0 @@ * API to obtain a CryptoKey from your existing key material.

{
"name": "jose",
"version": "4.9.2",
"version": "4.9.3",
"description": "'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK, JWKS with no dependencies using runtime's native crypto",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc