Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jose-browser-runtime

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jose-browser-runtime - npm Package Compare versions

Comparing version 3.16.1 to 3.17.0

10

dist/browser/jwe/flattened/decrypt.js

@@ -0,11 +1,11 @@

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';
import isDisjoint from '../../lib/is_disjoint.js';
import isObject from '../../lib/is_object.js';
import { decode as base64url } from '../../runtime/base64url.js';
import decrypt from '../../runtime/decrypt.js';
import { inflate } from '../../runtime/zlib.js';
import decryptKeyManagement from '../../lib/decrypt_key_management.js';
import { encoder, decoder, concat } from '../../lib/buffer_utils.js';
import cekFactory from '../../lib/cek.js';
import random from '../../runtime/random.js';
import validateCrit from '../../lib/validate_crit.js';

@@ -73,3 +73,3 @@ import validateAlgorithms from '../../lib/validate_algorithms.js';

if (joseHeader.zip !== 'DEF') {
throw new JOSENotSupported('unsupported JWE "zip" (Compression Algorithm) Header Parameter value');
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value');
}

@@ -76,0 +76,0 @@ }

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

import ivFactory from '../../lib/iv.js';
import { encode as base64url } from '../../runtime/base64url.js';

@@ -6,2 +5,3 @@ import random from '../../runtime/random.js';

import { deflate } from '../../runtime/zlib.js';
import ivFactory from '../../lib/iv.js';
import encryptKeyManagement from '../../lib/encrypt_key_management.js';

@@ -85,3 +85,3 @@ import { JOSENotSupported, JWEInvalid } from '../../util/errors.js';

if (joseHeader.zip !== 'DEF') {
throw new JOSENotSupported('unsupported JWE "zip" (Compression Algorithm) Header Parameter value');
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value');
}

@@ -88,0 +88,0 @@ }

@@ -31,3 +31,3 @@ import { decode as base64url } from '../runtime/base64url.js';

default:
throw new JOSENotSupported('unsupported "kty" (Key Type) Parameter value');
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
}

@@ -34,0 +34,0 @@ }

@@ -1,4 +0,4 @@

import { JOSENotSupported, JWKInvalid } from '../util/errors.js';
import digest from '../runtime/digest.js';
import { encode as base64url } from '../runtime/base64url.js';
import { JOSENotSupported, JWKInvalid } from '../util/errors.js';
import { encoder } from '../lib/buffer_utils.js';

@@ -5,0 +5,0 @@ import isObject from '../lib/is_object.js';

@@ -0,4 +1,4 @@

import fetchJwks from '../runtime/fetch_jwks.js';
import parseJWK from '../jwk/parse.js';
import { JWKSInvalid, JOSENotSupported, JWKSNoMatchingKey, JWKSMultipleMatchingKeys, } from '../util/errors.js';
import fetchJwks from '../runtime/fetch_jwks.js';
import isObject from '../lib/is_object.js';

@@ -5,0 +5,0 @@ function getKtyFromAlg(alg) {

@@ -0,6 +1,6 @@

import { encode as base64url } from '../../runtime/base64url.js';
import sign from '../../runtime/sign.js';
import isDisjoint from '../../lib/is_disjoint.js';
import { JWSInvalid } from '../../util/errors.js';
import { encoder, decoder, concat } from '../../lib/buffer_utils.js';
import { encode as base64url } from '../../runtime/base64url.js';
import sign from '../../runtime/sign.js';
import checkKeyType from '../../lib/check_key_type.js';

@@ -7,0 +7,0 @@ import validateCrit from '../../lib/validate_crit.js';

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

import { decode as base64url } from '../../runtime/base64url.js';
import verify from '../../runtime/verify.js';
import { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';

@@ -6,4 +8,2 @@ import { concat, encoder, decoder } from '../../lib/buffer_utils.js';

import checkKeyType from '../../lib/check_key_type.js';
import { decode as base64url } from '../../runtime/base64url.js';
import verify from '../../runtime/verify.js';
import validateCrit from '../../lib/validate_crit.js';

@@ -10,0 +10,0 @@ import validateAlgorithms from '../../lib/validate_algorithms.js';

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

import * as base64url from '../runtime/base64url.js';
import { decoder } from '../lib/buffer_utils.js';
import * as base64url from '../runtime/base64url.js';
import { JWTInvalid } from '../util/errors.js';

@@ -4,0 +4,0 @@ import jwtPayload from '../lib/jwt_claims_set.js';

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

import { JOSENotSupported, JWEInvalid } from '../util/errors.js';
import { unwrap as aesKw } from '../runtime/aeskw.js';

@@ -8,2 +7,3 @@ import * as ECDH from '../runtime/ecdhes.js';

import { decode as base64url } from '../runtime/base64url.js';
import { JOSENotSupported, JWEInvalid } from '../util/errors.js';
import { bitLengths as cekLengths } from '../lib/cek.js';

@@ -92,3 +92,3 @@ import { parseJwk } from '../jwk/parse.js';

default: {
throw new JOSENotSupported('unsupported or invalid "alg" (JWE Algorithm) header value');
throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value');
}

@@ -95,0 +95,0 @@ }

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

import cekFactory, { bitLengths as cekLengths } from '../lib/cek.js';
import { JOSENotSupported } from '../util/errors.js';
import random from '../runtime/random.js';

@@ -10,2 +8,4 @@ import { wrap as aesKw } from '../runtime/aeskw.js';

import { encode as base64url } from '../runtime/base64url.js';
import cekFactory, { bitLengths as cekLengths } from '../lib/cek.js';
import { JOSENotSupported } from '../util/errors.js';
import { fromKeyLike } from '../jwk/from_key_like.js';

@@ -83,3 +83,3 @@ import checkKeyType from './check_key_type.js';

default: {
throw new JOSENotSupported('unsupported or invalid "alg" (JWE Algorithm) header value');
throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value');
}

@@ -86,0 +86,0 @@ }

@@ -6,3 +6,3 @@ import bogusWebCrypto from './bogus.js';

if (key.algorithm.length !== parseInt(alg.substr(1, 3), 10)) {
throw new TypeError(`invalid key size for alg: ${alg}`);
throw new TypeError(`Invalid key size for alg: ${alg}`);
}

@@ -9,0 +9,0 @@ }

@@ -69,5 +69,5 @@ import { concat, uint64be } from '../lib/buffer_utils.js';

default:
throw new JOSENotSupported('unsupported JWE Content Encryption Algorithm');
throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');
}
};
export default decrypt;

@@ -52,5 +52,5 @@ import { concat, uint64be } from '../lib/buffer_utils.js';

default:
throw new JOSENotSupported('unsupported JWE Content Encryption Algorithm');
throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');
}
};
export default encrypt;

@@ -13,3 +13,3 @@ import { JOSEError } from '../util/errors.js';

method: 'GET',
...(typeof globalThis.WebSocketPair === 'undefined'
...(globalThis.WebSocketPair === undefined
? {

@@ -16,0 +16,0 @@ referrerPolicy: 'no-referrer',

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

import { isCloudflareWorkers, isNodeJs } from './global.js';
import crypto from './webcrypto.js';

@@ -40,3 +41,3 @@ import { JOSENotSupported } from '../util/errors.js';

default:
throw new JOSENotSupported('unsupported or invalid JWK "alg" (Algorithm) Parameter value');
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}

@@ -104,2 +105,17 @@ return crypto.subtle.generateKey(algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);

break;
case (isCloudflareWorkers() || isNodeJs()) && 'EdDSA':
switch (options === null || options === void 0 ? void 0 : options.crv) {
case undefined:
case 'Ed25519':
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
keyUsages = ['sign', 'verify'];
break;
case isNodeJs() && 'Ed448':
algorithm = { name: 'NODE-ED448', namedCurve: 'NODE-ED448' };
keyUsages = ['sign', 'verify'];
break;
default:
throw new JOSENotSupported('Invalid or unsupported crv option provided, supported values are Ed25519 and Ed448');
}
break;
case 'ECDH-ES':

@@ -113,5 +129,5 @@ case 'ECDH-ES+A128KW':

default:
throw new JOSENotSupported('unsupported or invalid JWK "alg" (Algorithm) Parameter value');
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}
return (crypto.subtle.generateKey(algorithm, (_b = options === null || options === void 0 ? void 0 : options.extractable) !== null && _b !== void 0 ? _b : false, keyUsages));
}

@@ -11,1 +11,18 @@ function getGlobal() {

export default getGlobal();
export function isCloudflareWorkers() {
try {
return getGlobal().WebSocketPair !== undefined;
}
catch (_a) {
return false;
}
}
export function isNodeJs() {
var _a, _b;
try {
return ((_b = (_a = getGlobal().process) === null || _a === void 0 ? void 0 : _a.versions) === null || _b === void 0 ? void 0 : _b.node) !== undefined;
}
catch (_c) {
return false;
}
}

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

import { isCloudflareWorkers, isNodeJs } from './global.js';
import crypto from './webcrypto.js';

@@ -42,3 +43,3 @@ import { JOSENotSupported } from '../util/errors.js';

default:
throw new JOSENotSupported('unsupported or invalid JWK "alg" (Algorithm) Parameter value');
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}

@@ -72,3 +73,3 @@ break;

default:
throw new JOSENotSupported('unsupported or invalid JWK "alg" (Algorithm) Parameter value');
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}

@@ -80,5 +81,11 @@ break;

case 'ES256':
algorithm = { name: 'ECDSA', namedCurve: 'P-256' };
keyUsages = jwk.d ? ['sign'] : ['verify'];
break;
case 'ES384':
algorithm = { name: 'ECDSA', namedCurve: 'P-384' };
keyUsages = jwk.d ? ['sign'] : ['verify'];
break;
case 'ES512':
algorithm = { name: 'ECDSA', namedCurve: jwk.crv };
algorithm = { name: 'ECDSA', namedCurve: 'P-521' };
keyUsages = jwk.d ? ['sign'] : ['verify'];

@@ -94,8 +101,25 @@ break;

default:
throw new JOSENotSupported('unsupported or invalid JWK "alg" (Algorithm) Parameter value');
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}
break;
}
case (isCloudflareWorkers() || isNodeJs()) && 'OKP':
if (jwk.alg !== 'EdDSA') {
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}
switch (jwk.crv) {
case 'Ed25519':
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
keyUsages = jwk.d ? ['sign'] : ['verify'];
break;
case isNodeJs() && 'Ed448':
algorithm = { name: 'NODE-ED448', namedCurve: 'NODE-ED448' };
keyUsages = jwk.d ? ['sign'] : ['verify'];
break;
default:
throw new JOSENotSupported('Invalid or unsupported JWK "crv" (Subtype of Key Pair) Parameter value');
}
break;
default:
throw new JOSENotSupported('unsupported or invalid JWK "kty" (Key Type) Parameter value');
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
}

@@ -102,0 +126,0 @@ return { algorithm, keyUsages };

@@ -8,5 +8,5 @@ import subtleAlgorithm from './subtle_dsa.js';

checkKeyLength(alg, cryptoKey);
const signature = await crypto.subtle.sign(subtleAlgorithm(alg), cryptoKey, data);
const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm.namedCurve), cryptoKey, data);
return new Uint8Array(signature);
};
export default sign;

@@ -0,3 +1,4 @@

import { isCloudflareWorkers, isNodeJs } from './global.js';
import { JOSENotSupported } from '../util/errors.js';
export default function subtleDsa(alg) {
export default function subtleDsa(alg, crv) {
switch (alg) {

@@ -40,2 +41,4 @@ case 'HS256':

return { hash: { name: 'SHA-512' }, name: 'ECDSA', namedCurve: 'P-521' };
case (isCloudflareWorkers() || isNodeJs()) && 'EdDSA':
return { name: crv, namedCurve: crv };
default:

@@ -42,0 +45,0 @@ throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);

@@ -8,3 +8,3 @@ import subtleAlgorithm from './subtle_dsa.js';

checkKeyLength(alg, cryptoKey);
const algorithm = subtleAlgorithm(alg);
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm.namedCurve);
try {

@@ -11,0 +11,0 @@ return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);

{
"name": "jose-browser-runtime",
"version": "3.16.1",
"version": "3.17.0",
"description": "(Browser Runtime) 'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK with no dependencies",

@@ -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