jose 4.14.3 → 4.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser/jwks/remote.js +5 -1
- package/dist/browser/lib/crypto_key.js +0 -6
- package/dist/browser/runtime/asn1.js +2 -14
- package/dist/browser/runtime/generate.js +2 -14
- package/dist/browser/runtime/jwk_to_key.js +1 -13
- package/dist/browser/runtime/subtle_dsa.js +0 -4
- package/dist/node/cjs/jwks/remote.js +6 -2
- package/dist/node/cjs/lib/crypto_key.js +0 -6
- package/dist/node/esm/jwks/remote.js +5 -1
- package/dist/node/esm/lib/crypto_key.js +0 -6
- package/package.json +2 -3
- package/dist/browser/runtime/env.js +0 -5
- package/dist/node/cjs/runtime/env.js +0 -7
- package/dist/node/esm/runtime/env.js +0 -3
package/README.md
CHANGED
|
@@ -129,4 +129,4 @@ Please note that certain algorithms may not be available depending on the runtim
|
|
|
129
129
|
| Version | Security Fixes 🔑 | Other Bug Fixes 🐞 | New Features ⭐ |
|
|
130
130
|
| ------- | --------- | -------- | -------- |
|
|
131
131
|
| [v4.x](https://github.com/panva/jose/tree/v4.x) | ✅ | ✅ | ✅ |
|
|
132
|
-
| [
|
|
132
|
+
| [v2.x](https://github.com/panva/jose/tree/v2.x) | ✅ | ❌ | ❌ |
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import fetchJwks from '../runtime/fetch_jwks.js';
|
|
2
|
-
import { isCloudflareWorkers } from '../runtime/env.js';
|
|
3
2
|
import { JWKSInvalid, JWKSNoMatchingKey } from '../util/errors.js';
|
|
4
3
|
import { isJWKSLike, LocalJWKSet } from './local.js';
|
|
4
|
+
function isCloudflareWorkers() {
|
|
5
|
+
return (typeof WebSocketPair !== 'undefined' ||
|
|
6
|
+
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
7
|
+
(typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
|
|
8
|
+
}
|
|
5
9
|
class RemoteJWKSet extends LocalJWKSet {
|
|
6
10
|
constructor(url, options) {
|
|
7
11
|
super({ keys: [] });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isCloudflareWorkers } from '../runtime/env.js';
|
|
2
1
|
function unusable(name, prop = 'algorithm.name') {
|
|
3
2
|
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
4
3
|
}
|
|
@@ -73,11 +72,6 @@ export function checkSigCryptoKey(key, alg, ...usages) {
|
|
|
73
72
|
}
|
|
74
73
|
case 'EdDSA': {
|
|
75
74
|
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
|
|
76
|
-
if (isCloudflareWorkers()) {
|
|
77
|
-
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
|
|
78
|
-
break;
|
|
79
|
-
throw unusable('Ed25519, Ed448, or NODE-ED25519');
|
|
80
|
-
}
|
|
81
75
|
throw unusable('Ed25519 or Ed448');
|
|
82
76
|
}
|
|
83
77
|
break;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isCloudflareWorkers } from './env.js';
|
|
2
1
|
import crypto, { isCryptoKey } from './webcrypto.js';
|
|
3
2
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
4
3
|
import { encodeBase64, decodeBase64 } from './base64url.js';
|
|
@@ -57,7 +56,7 @@ const getNamedCurve = (keyData) => {
|
|
|
57
56
|
}
|
|
58
57
|
};
|
|
59
58
|
const genericImport = async (replace, keyFormat, pem, alg, options) => {
|
|
60
|
-
var _a
|
|
59
|
+
var _a;
|
|
61
60
|
let algorithm;
|
|
62
61
|
let keyUsages;
|
|
63
62
|
const keyData = new Uint8Array(atob(pem.replace(replace, ''))
|
|
@@ -115,18 +114,7 @@ const genericImport = async (replace, keyFormat, pem, alg, options) => {
|
|
|
115
114
|
default:
|
|
116
115
|
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
117
116
|
}
|
|
118
|
-
|
|
119
|
-
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);
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
if (algorithm.name === 'Ed25519' &&
|
|
123
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
124
|
-
isCloudflareWorkers()) {
|
|
125
|
-
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
126
|
-
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);
|
|
127
|
-
}
|
|
128
|
-
throw err;
|
|
129
|
-
}
|
|
117
|
+
return crypto.subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
|
|
130
118
|
};
|
|
131
119
|
export const fromPKCS8 = (pem, alg, options) => {
|
|
132
120
|
return genericImport(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, 'pkcs8', pem, alg, options);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isCloudflareWorkers } from './env.js';
|
|
2
1
|
import crypto from './webcrypto.js';
|
|
3
2
|
import { JOSENotSupported } from '../util/errors.js';
|
|
4
3
|
import random from './random.js';
|
|
@@ -51,7 +50,7 @@ function getModulusLengthOption(options) {
|
|
|
51
50
|
return modulusLength;
|
|
52
51
|
}
|
|
53
52
|
export async function generateKeyPair(alg, options) {
|
|
54
|
-
var _a, _b, _c
|
|
53
|
+
var _a, _b, _c;
|
|
55
54
|
let algorithm;
|
|
56
55
|
let keyUsages;
|
|
57
56
|
switch (alg) {
|
|
@@ -138,16 +137,5 @@ export async function generateKeyPair(alg, options) {
|
|
|
138
137
|
default:
|
|
139
138
|
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
140
139
|
}
|
|
141
|
-
|
|
142
|
-
return (await crypto.subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
|
|
143
|
-
}
|
|
144
|
-
catch (err) {
|
|
145
|
-
if (algorithm.name === 'Ed25519' &&
|
|
146
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
147
|
-
isCloudflareWorkers()) {
|
|
148
|
-
algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
149
|
-
return (await crypto.subtle.generateKey(algorithm, (_d = options === null || options === void 0 ? void 0 : options.extractable) !== null && _d !== void 0 ? _d : false, keyUsages));
|
|
150
|
-
}
|
|
151
|
-
throw err;
|
|
152
|
-
}
|
|
140
|
+
return (crypto.subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
|
|
153
141
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isCloudflareWorkers } from './env.js';
|
|
2
1
|
import crypto from './webcrypto.js';
|
|
3
2
|
import { JOSENotSupported } from '../util/errors.js';
|
|
4
3
|
import { decode as base64url } from './base64url.js';
|
|
@@ -139,17 +138,6 @@ const parse = async (jwk) => {
|
|
|
139
138
|
const keyData = { ...jwk };
|
|
140
139
|
delete keyData.alg;
|
|
141
140
|
delete keyData.use;
|
|
142
|
-
|
|
143
|
-
return await crypto.subtle.importKey('jwk', keyData, ...rest);
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
if (algorithm.name === 'Ed25519' &&
|
|
147
|
-
(err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
|
|
148
|
-
isCloudflareWorkers()) {
|
|
149
|
-
rest[0] = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
150
|
-
return await crypto.subtle.importKey('jwk', keyData, ...rest);
|
|
151
|
-
}
|
|
152
|
-
throw err;
|
|
153
|
-
}
|
|
141
|
+
return crypto.subtle.importKey('jwk', keyData, ...rest);
|
|
154
142
|
};
|
|
155
143
|
export default parse;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isCloudflareWorkers } from './env.js';
|
|
2
1
|
import { JOSENotSupported } from '../util/errors.js';
|
|
3
2
|
export default function subtleDsa(alg, algorithm) {
|
|
4
3
|
const hash = `SHA-${alg.slice(-3)}`;
|
|
@@ -20,9 +19,6 @@ export default function subtleDsa(alg, algorithm) {
|
|
|
20
19
|
case 'ES512':
|
|
21
20
|
return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
|
|
22
21
|
case 'EdDSA':
|
|
23
|
-
if (isCloudflareWorkers() && algorithm.name === 'NODE-ED25519') {
|
|
24
|
-
return { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
|
|
25
|
-
}
|
|
26
22
|
return { name: algorithm.name };
|
|
27
23
|
default:
|
|
28
24
|
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRemoteJWKSet = void 0;
|
|
4
4
|
const fetch_jwks_js_1 = require("../runtime/fetch_jwks.js");
|
|
5
|
-
const env_js_1 = require("../runtime/env.js");
|
|
6
5
|
const errors_js_1 = require("../util/errors.js");
|
|
7
6
|
const local_js_1 = require("./local.js");
|
|
7
|
+
function isCloudflareWorkers() {
|
|
8
|
+
return (typeof WebSocketPair !== 'undefined' ||
|
|
9
|
+
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
10
|
+
(typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
|
|
11
|
+
}
|
|
8
12
|
class RemoteJWKSet extends local_js_1.LocalJWKSet {
|
|
9
13
|
constructor(url, options) {
|
|
10
14
|
super({ keys: [] });
|
|
@@ -48,7 +52,7 @@ class RemoteJWKSet extends local_js_1.LocalJWKSet {
|
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
async reload() {
|
|
51
|
-
if (this._pendingFetch &&
|
|
55
|
+
if (this._pendingFetch && isCloudflareWorkers()) {
|
|
52
56
|
this._pendingFetch = undefined;
|
|
53
57
|
}
|
|
54
58
|
this._pendingFetch || (this._pendingFetch = (0, fetch_jwks_js_1.default)(this._url, this._timeoutDuration, this._options)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkEncCryptoKey = exports.checkSigCryptoKey = void 0;
|
|
4
|
-
const env_js_1 = require("../runtime/env.js");
|
|
5
4
|
function unusable(name, prop = 'algorithm.name') {
|
|
6
5
|
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
7
6
|
}
|
|
@@ -76,11 +75,6 @@ function checkSigCryptoKey(key, alg, ...usages) {
|
|
|
76
75
|
}
|
|
77
76
|
case 'EdDSA': {
|
|
78
77
|
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
|
|
79
|
-
if ((0, env_js_1.isCloudflareWorkers)()) {
|
|
80
|
-
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
|
|
81
|
-
break;
|
|
82
|
-
throw unusable('Ed25519, Ed448, or NODE-ED25519');
|
|
83
|
-
}
|
|
84
78
|
throw unusable('Ed25519 or Ed448');
|
|
85
79
|
}
|
|
86
80
|
break;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import fetchJwks from '../runtime/fetch_jwks.js';
|
|
2
|
-
import { isCloudflareWorkers } from '../runtime/env.js';
|
|
3
2
|
import { JWKSInvalid, JWKSNoMatchingKey } from '../util/errors.js';
|
|
4
3
|
import { isJWKSLike, LocalJWKSet } from './local.js';
|
|
4
|
+
function isCloudflareWorkers() {
|
|
5
|
+
return (typeof WebSocketPair !== 'undefined' ||
|
|
6
|
+
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
7
|
+
(typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));
|
|
8
|
+
}
|
|
5
9
|
class RemoteJWKSet extends LocalJWKSet {
|
|
6
10
|
constructor(url, options) {
|
|
7
11
|
super({ keys: [] });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isCloudflareWorkers } from '../runtime/env.js';
|
|
2
1
|
function unusable(name, prop = 'algorithm.name') {
|
|
3
2
|
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
4
3
|
}
|
|
@@ -73,11 +72,6 @@ export function checkSigCryptoKey(key, alg, ...usages) {
|
|
|
73
72
|
}
|
|
74
73
|
case 'EdDSA': {
|
|
75
74
|
if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
|
|
76
|
-
if (isCloudflareWorkers()) {
|
|
77
|
-
if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
|
|
78
|
-
break;
|
|
79
|
-
throw unusable('Ed25519, Ed448, or NODE-ED25519');
|
|
80
|
-
}
|
|
81
75
|
throw unusable('Ed25519 or Ed448');
|
|
82
76
|
}
|
|
83
77
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jose",
|
|
3
|
-
"version": "4.14.
|
|
3
|
+
"version": "4.14.4",
|
|
4
4
|
"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
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"encrypt",
|
|
21
21
|
"flattened",
|
|
22
22
|
"general",
|
|
23
|
-
"isomorphic",
|
|
24
23
|
"jose",
|
|
25
24
|
"json web token",
|
|
26
25
|
"jsonwebtoken",
|
|
@@ -43,11 +42,11 @@
|
|
|
43
42
|
"sign",
|
|
44
43
|
"signature",
|
|
45
44
|
"spki",
|
|
46
|
-
"universal",
|
|
47
45
|
"validate",
|
|
48
46
|
"vercel",
|
|
49
47
|
"verify",
|
|
50
48
|
"webcrypto",
|
|
49
|
+
"workerd",
|
|
51
50
|
"workers",
|
|
52
51
|
"x509"
|
|
53
52
|
],
|