jose-node-esm-runtime
Advanced tools
Comparing version 5.5.0 to 5.6.0
@@ -13,3 +13,3 @@ import fetchJwks from '../runtime/fetch_jwks.js'; | ||
const NAME = 'jose'; | ||
const VERSION = 'v5.5.0'; | ||
const VERSION = 'v5.6.0'; | ||
USER_AGENT = `${NAME}/${VERSION}`; | ||
@@ -16,0 +16,0 @@ } |
import { withAlg as invalidKeyInput } from './invalid_key_input.js'; | ||
import isKeyLike, { types } from '../runtime/is_key_like.js'; | ||
const tag = (key) => key?.[Symbol.toStringTag]; | ||
const symmetricTypeCheck = (alg, key) => { | ||
@@ -10,3 +11,3 @@ if (key instanceof Uint8Array) | ||
if (key.type !== 'secret') { | ||
throw new TypeError(`${types.join(' or ')} instances for symmetric algorithms must be of type "secret"`); | ||
throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`); | ||
} | ||
@@ -19,15 +20,15 @@ }; | ||
if (key.type === 'secret') { | ||
throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithms must not be of type "secret"`); | ||
throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`); | ||
} | ||
if (usage === 'sign' && key.type === 'public') { | ||
throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm signing must be of type "private"`); | ||
throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`); | ||
} | ||
if (usage === 'decrypt' && key.type === 'public') { | ||
throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm decryption must be of type "private"`); | ||
throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`); | ||
} | ||
if (key.algorithm && usage === 'verify' && key.type === 'private') { | ||
throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm verifying must be of type "public"`); | ||
throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`); | ||
} | ||
if (key.algorithm && usage === 'encrypt' && key.type === 'private') { | ||
throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm encryption must be of type "public"`); | ||
throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`); | ||
} | ||
@@ -34,0 +35,0 @@ }; |
@@ -6,2 +6,3 @@ import { unwrap as aesKw } from '../runtime/aeskw.js'; | ||
import { decode as base64url } from '../runtime/base64url.js'; | ||
import * as normalize from '../runtime/normalize_key.js'; | ||
import { JOSENotSupported, JWEInvalid } from '../util/errors.js'; | ||
@@ -14,2 +15,5 @@ import { bitLength as cekLength } from '../lib/cek.js'; | ||
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) { | ||
if (normalize.normalizePrivateKey) { | ||
key = await normalize.normalizePrivateKey(key, alg); | ||
} | ||
checkKeyType(alg, key, 'decrypt'); | ||
@@ -16,0 +20,0 @@ switch (alg) { |
@@ -6,2 +6,3 @@ import { wrap as aesKw } from '../runtime/aeskw.js'; | ||
import { encode as base64url } from '../runtime/base64url.js'; | ||
import * as normalize from '../runtime/normalize_key.js'; | ||
import generateCek, { bitLength as cekLength } from '../lib/cek.js'; | ||
@@ -16,2 +17,5 @@ import { JOSENotSupported } from '../util/errors.js'; | ||
let cek; | ||
if (normalize.normalizePublicKey) { | ||
key = await normalize.normalizePublicKey(key, alg); | ||
} | ||
checkKeyType(alg, key, 'encrypt'); | ||
@@ -18,0 +22,0 @@ switch (alg) { |
{ | ||
"name": "jose-node-esm-runtime", | ||
"version": "5.5.0", | ||
"version": "5.6.0", | ||
"homepage": "https://github.com/panva/jose", | ||
@@ -5,0 +5,0 @@ "repository": "panva/jose", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212791
116
5336