jose 4.3.4 → 4.3.8
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/dist/browser/jwks/remote.js +1 -1
- package/dist/browser/lib/aesgcmkw.js +2 -2
- package/dist/browser/lib/crypto_key.js +7 -7
- package/dist/browser/lib/decrypt_key_management.js +2 -2
- package/dist/browser/lib/encrypt_key_management.js +3 -3
- package/dist/browser/runtime/aeskw.js +1 -1
- package/dist/browser/runtime/asn1.js +21 -20
- package/dist/browser/runtime/decrypt.js +3 -3
- package/dist/browser/runtime/digest.js +1 -1
- package/dist/browser/runtime/ecdhes.js +8 -9
- package/dist/browser/runtime/encrypt.js +3 -3
- package/dist/browser/runtime/generate.js +7 -7
- package/dist/browser/runtime/get_sign_verify_key.js +1 -1
- package/dist/browser/runtime/jwk_to_key.js +4 -4
- package/dist/browser/runtime/pbes2kw.js +4 -4
- package/dist/browser/runtime/sign.js +1 -1
- package/dist/browser/runtime/subtle_dsa.js +7 -6
- package/dist/browser/runtime/verify.js +1 -1
- package/dist/node/cjs/jwks/remote.js +1 -1
- package/dist/node/cjs/lib/aesgcmkw.js +2 -2
- package/dist/node/cjs/lib/crypto_key.js +7 -7
- package/dist/node/cjs/lib/decrypt_key_management.js +2 -2
- package/dist/node/cjs/lib/encrypt_key_management.js +3 -3
- package/dist/node/cjs/runtime/aeskw.js +4 -5
- package/dist/node/cjs/runtime/check_cek_length.js +2 -2
- package/dist/node/cjs/runtime/decrypt.js +3 -3
- package/dist/node/cjs/runtime/ecdhes.js +7 -7
- package/dist/node/cjs/runtime/encrypt.js +3 -3
- package/dist/node/cjs/runtime/generate.js +2 -2
- package/dist/node/cjs/runtime/get_named_curve.js +2 -2
- package/dist/node/cjs/runtime/get_sign_verify_key.js +1 -2
- package/dist/node/cjs/runtime/jwk_to_key.js +1 -1
- package/dist/node/cjs/runtime/key_to_jwk.js +1 -1
- package/dist/node/cjs/runtime/node_key.js +4 -3
- package/dist/node/cjs/runtime/pbes2kw.js +6 -6
- package/dist/node/cjs/runtime/verify.js +1 -1
- package/dist/node/esm/jwks/remote.js +1 -1
- package/dist/node/esm/lib/aesgcmkw.js +2 -2
- package/dist/node/esm/lib/crypto_key.js +7 -7
- package/dist/node/esm/lib/decrypt_key_management.js +2 -2
- package/dist/node/esm/lib/encrypt_key_management.js +3 -3
- package/dist/node/esm/runtime/aeskw.js +5 -6
- package/dist/node/esm/runtime/check_cek_length.js +2 -2
- package/dist/node/esm/runtime/decrypt.js +3 -3
- package/dist/node/esm/runtime/ecdhes.js +7 -7
- package/dist/node/esm/runtime/encrypt.js +3 -3
- package/dist/node/esm/runtime/generate.js +2 -2
- package/dist/node/esm/runtime/get_named_curve.js +2 -2
- package/dist/node/esm/runtime/get_sign_verify_key.js +2 -3
- package/dist/node/esm/runtime/jwk_to_key.js +1 -1
- package/dist/node/esm/runtime/key_to_jwk.js +1 -1
- package/dist/node/esm/runtime/node_key.js +4 -3
- package/dist/node/esm/runtime/pbes2kw.js +6 -6
- package/dist/node/esm/runtime/verify.js +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/node/cjs/runtime/secret_key.js +0 -14
- package/dist/node/esm/runtime/secret_key.js +0 -11
|
@@ -3,10 +3,11 @@ import getNamedCurve from './get_named_curve.js';
|
|
|
3
3
|
import { JOSENotSupported } from '../util/errors.js';
|
|
4
4
|
import checkModulusLength from './check_modulus_length.js';
|
|
5
5
|
const [major, minor] = process.version
|
|
6
|
-
.
|
|
6
|
+
.slice(1)
|
|
7
7
|
.split('.')
|
|
8
8
|
.map((str) => parseInt(str, 10));
|
|
9
|
-
const
|
|
9
|
+
const electron = 'electron' in process.versions;
|
|
10
|
+
const rsaPssParams = !electron && (major >= 17 || (major === 16 && minor >= 9));
|
|
10
11
|
const PSS = {
|
|
11
12
|
padding: constants.RSA_PKCS1_PSS_PADDING,
|
|
12
13
|
saltLength: constants.RSA_PSS_SALTLEN_DIGEST,
|
|
@@ -37,7 +38,7 @@ export default function keyForCrypto(alg, key) {
|
|
|
37
38
|
case rsaPssParams && 'PS512':
|
|
38
39
|
if (key.asymmetricKeyType === 'rsa-pss') {
|
|
39
40
|
const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = key.asymmetricKeyDetails;
|
|
40
|
-
const length = parseInt(alg.
|
|
41
|
+
const length = parseInt(alg.slice(-3), 10);
|
|
41
42
|
if (hashAlgorithm !== undefined &&
|
|
42
43
|
(hashAlgorithm !== `sha${length}` || mgf1HashAlgorithm !== hashAlgorithm)) {
|
|
43
44
|
throw new TypeError(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${alg}`);
|
|
@@ -27,17 +27,17 @@ function getPassword(key, alg) {
|
|
|
27
27
|
export const encrypt = async (alg, key, cek, p2c = Math.floor(Math.random() * 2049) + 2048, p2s = random(new Uint8Array(16))) => {
|
|
28
28
|
checkP2s(p2s);
|
|
29
29
|
const salt = concatSalt(alg, p2s);
|
|
30
|
-
const keylen = parseInt(alg.
|
|
30
|
+
const keylen = parseInt(alg.slice(13, 16), 10) >> 3;
|
|
31
31
|
const password = getPassword(key, alg);
|
|
32
|
-
const derivedKey = await pbkdf2(password, salt, p2c, keylen, `sha${alg.
|
|
33
|
-
const encryptedKey = await wrap(alg.
|
|
32
|
+
const derivedKey = await pbkdf2(password, salt, p2c, keylen, `sha${alg.slice(8, 11)}`);
|
|
33
|
+
const encryptedKey = await wrap(alg.slice(-6), derivedKey, cek);
|
|
34
34
|
return { encryptedKey, p2c, p2s: base64url(p2s) };
|
|
35
35
|
};
|
|
36
36
|
export const decrypt = async (alg, key, encryptedKey, p2c, p2s) => {
|
|
37
37
|
checkP2s(p2s);
|
|
38
38
|
const salt = concatSalt(alg, p2s);
|
|
39
|
-
const keylen = parseInt(alg.
|
|
39
|
+
const keylen = parseInt(alg.slice(13, 16), 10) >> 3;
|
|
40
40
|
const password = getPassword(key, alg);
|
|
41
|
-
const derivedKey = await pbkdf2(password, salt, p2c, keylen, `sha${alg.
|
|
42
|
-
return unwrap(alg.
|
|
41
|
+
const derivedKey = await pbkdf2(password, salt, p2c, keylen, `sha${alg.slice(8, 11)}`);
|
|
42
|
+
return unwrap(alg.slice(-6), derivedKey, encryptedKey);
|
|
43
43
|
};
|
|
@@ -5,7 +5,7 @@ import nodeKey from './node_key.js';
|
|
|
5
5
|
import sign from './sign.js';
|
|
6
6
|
import getVerifyKey from './get_sign_verify_key.js';
|
|
7
7
|
const [major, minor] = process.version
|
|
8
|
-
.
|
|
8
|
+
.slice(1)
|
|
9
9
|
.split('.')
|
|
10
10
|
.map((str) => parseInt(str, 10));
|
|
11
11
|
const oneShotCallbackSupported = major >= 16 || (major === 15 && minor >= 13);
|
package/dist/types/types.d.ts
CHANGED
|
@@ -262,7 +262,7 @@ export interface CompactJWSHeaderParameters extends JWSHeaderParameters {
|
|
|
262
262
|
alg: string
|
|
263
263
|
}
|
|
264
264
|
export interface JWTHeaderParameters extends CompactJWSHeaderParameters {
|
|
265
|
-
b64
|
|
265
|
+
b64?: true
|
|
266
266
|
}
|
|
267
267
|
export interface CompactJWEHeaderParameters extends JWEHeaderParameters {
|
|
268
268
|
alg: string
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const crypto_1 = require("crypto");
|
|
4
|
-
function getSecretKey(key) {
|
|
5
|
-
let keyObject;
|
|
6
|
-
if (key instanceof Uint8Array) {
|
|
7
|
-
keyObject = (0, crypto_1.createSecretKey)(key);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
keyObject = key;
|
|
11
|
-
}
|
|
12
|
-
return keyObject;
|
|
13
|
-
}
|
|
14
|
-
exports.default = getSecretKey;
|