Socket
Socket
Sign inDemoInstall

jose

Package Overview
Dependencies
0
Maintainers
1
Versions
201
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.11.2 to 4.11.3

dist/deno/README.md

10

dist/browser/lib/crypto_key.js

@@ -74,9 +74,9 @@ import { isCloudflareWorkers } from '../runtime/env.js';

}
case isCloudflareWorkers() && 'EdDSA': {
if (!isAlgorithm(key.algorithm, 'NODE-ED25519'))
throw unusable('NODE-ED25519');
break;
}
case 'EdDSA': {
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
if (isCloudflareWorkers()) {
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
break;
throw unusable('Ed25519, Ed448, or NODE-ED25519');
}
throw unusable('Ed25519 or Ed448');

@@ -83,0 +83,0 @@ }

@@ -60,3 +60,3 @@ import { isCloudflareWorkers } from './env.js';

const genericImport = async (replace, keyFormat, pem, alg, options) => {
var _a;
var _a, _b;
let algorithm;

@@ -112,8 +112,2 @@ let keyUsages;

}
case isCloudflareWorkers() && 'EdDSA': {
const namedCurve = getNamedCurve(keyData).toUpperCase();
algorithm = { name: `NODE-${namedCurve}`, namedCurve: `NODE-${namedCurve}` };
keyUsages = isPublic ? ['verify'] : ['sign'];
break;
}
case 'EdDSA':

@@ -126,3 +120,14 @@ algorithm = { name: getNamedCurve(keyData) };

}
return crypto.subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
try {
return await crypto.subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
}
catch (err) {
if (algorithm.name === 'Ed25519' &&
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
isCloudflareWorkers()) {
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
return await crypto.subtle.importKey(keyFormat, keyData, algorithm, (_b = options === null || options === void 0 ? void 0 : options.extractable) !== null && _b !== void 0 ? _b : false, keyUsages);
}
throw err;
}
};

@@ -129,0 +134,0 @@ export const fromPKCS8 = (pem, alg, options) => {

@@ -54,3 +54,3 @@ import { isCloudflareWorkers } from './env.js';

export async function generateKeyPair(alg, options) {
var _a, _b, _c;
var _a, _b, _c, _d;
let algorithm;

@@ -105,13 +105,2 @@ let keyUsages;

break;
case isCloudflareWorkers() && '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;
default:
throw new JOSENotSupported('Invalid or unsupported crv option provided');
}
break;
case 'EdDSA':

@@ -154,3 +143,14 @@ keyUsages = ['sign', 'verify'];

}
return (crypto.subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
try {
return (await crypto.subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
}
catch (err) {
if (algorithm.name === 'Ed25519' &&
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
isCloudflareWorkers()) {
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
return (await crypto.subtle.generateKey(algorithm, (_d = options === null || options === void 0 ? void 0 : options.extractable) !== null && _d !== void 0 ? _d : false, keyUsages));
}
throw err;
}
}

@@ -102,15 +102,2 @@ import { isCloudflareWorkers } from './env.js';

}
case isCloudflareWorkers() && '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;
default:
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}
break;
case 'OKP': {

@@ -153,4 +140,15 @@ switch (jwk.alg) {

delete keyData.use;
return crypto.subtle.importKey('jwk', keyData, ...rest);
try {
return await crypto.subtle.importKey('jwk', keyData, ...rest);
}
catch (err) {
if (algorithm.name === 'Ed25519' &&
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
isCloudflareWorkers()) {
rest[0] = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
return await crypto.subtle.importKey('jwk', keyData, ...rest);
}
throw err;
}
};
export default parse;

@@ -22,6 +22,6 @@ import { isCloudflareWorkers } from './env.js';

return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
case isCloudflareWorkers() && 'EdDSA':
const { namedCurve } = algorithm;
return { name: namedCurve, namedCurve };
case 'EdDSA':
if (isCloudflareWorkers() && algorithm.name === 'NODE-ED25519') {
return { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
}
return { name: algorithm.name };

@@ -28,0 +28,0 @@ default:

@@ -77,9 +77,9 @@ "use strict";

}
case (0, env_js_1.isCloudflareWorkers)() && 'EdDSA': {
if (!isAlgorithm(key.algorithm, 'NODE-ED25519'))
throw unusable('NODE-ED25519');
break;
}
case 'EdDSA': {
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
if ((0, env_js_1.isCloudflareWorkers)()) {
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
break;
throw unusable('Ed25519, Ed448, or NODE-ED25519');
}
throw unusable('Ed25519 or Ed448');

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

@@ -74,9 +74,9 @@ import { isCloudflareWorkers } from '../runtime/env.js';

}
case isCloudflareWorkers() && 'EdDSA': {
if (!isAlgorithm(key.algorithm, 'NODE-ED25519'))
throw unusable('NODE-ED25519');
break;
}
case 'EdDSA': {
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
if (isCloudflareWorkers()) {
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
break;
throw unusable('Ed25519, Ed448, or NODE-ED25519');
}
throw unusable('Ed25519 or Ed448');

@@ -83,0 +83,0 @@ }

{
"name": "jose",
"version": "4.11.2",
"version": "4.11.3",
"description": "'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",

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

@@ -41,3 +41,3 @@ # jose

```js
import * as jose from 'https://deno.land/x/jose@v4.11.2/index.ts'
import * as jose from 'https://deno.land/x/jose@v4.11.3/index.ts'
```

@@ -44,0 +44,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc