jose-node-esm-runtime
Advanced tools
Comparing version 3.11.6 to 3.12.0
@@ -11,3 +11,3 @@ import decrypt from '../flattened/decrypt.js'; | ||
} | ||
const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag, length } = jwe.split('.'); | ||
const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag, length, } = jwe.split('.'); | ||
if (length !== 5) { | ||
@@ -14,0 +14,0 @@ throw new JWEInvalid('Invalid Compact JWE'); |
@@ -25,3 +25,3 @@ import { decode as base64url } from '../runtime/base64url.js'; | ||
if (jwk.oth !== undefined) { | ||
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is unsupported'); | ||
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported'); | ||
} | ||
@@ -28,0 +28,0 @@ case 'EC': |
@@ -1,2 +0,2 @@ | ||
import { KeyObject, createDecipheriv, createCipheriv, getCiphers } from 'crypto'; | ||
import { createDecipheriv, createCipheriv, getCiphers } from 'crypto'; | ||
import { JOSENotSupported } from '../util/errors.js'; | ||
@@ -6,2 +6,3 @@ import { concat } from '../lib/buffer_utils.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
function checkKeySize(key, alg) { | ||
@@ -13,3 +14,3 @@ if (key.symmetricKeySize << 3 !== parseInt(alg.substr(1, 3), 10)) { | ||
function ensureKeyObject(key, alg, usage) { | ||
if (key instanceof KeyObject) { | ||
if (isKeyObject(key)) { | ||
return key; | ||
@@ -29,3 +30,3 @@ } | ||
if (!getCiphers().includes(algorithm)) { | ||
throw new JOSENotSupported(`alg ${alg} is unsupported either by JOSE or your javascript runtime`); | ||
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`); | ||
} | ||
@@ -41,3 +42,3 @@ const keyObject = ensureKeyObject(key, alg, 'wrapKey'); | ||
if (!getCiphers().includes(algorithm)) { | ||
throw new JOSENotSupported(`alg ${alg} is unsupported either by JOSE or your javascript runtime`); | ||
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`); | ||
} | ||
@@ -44,0 +45,0 @@ const keyObject = ensureKeyObject(key, alg, 'unwrapKey'); |
@@ -1,3 +0,3 @@ | ||
import { KeyObject } from 'crypto'; | ||
import { JWEInvalid, JOSENotSupported } from '../util/errors.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
const checkCekLength = (enc, cek) => { | ||
@@ -17,3 +17,3 @@ let expected; | ||
default: | ||
throw new JOSENotSupported(`Content Encryption Algorithm ${enc} is unsupported either by JOSE or your javascript runtime`); | ||
throw new JOSENotSupported(`Content Encryption Algorithm ${enc} is not supported either by JOSE or your javascript runtime`); | ||
} | ||
@@ -26,3 +26,3 @@ if (cek instanceof Uint8Array) { | ||
} | ||
if (cek instanceof KeyObject && cek.type === 'secret') { | ||
if (isKeyObject(cek) && cek.type === 'secret') { | ||
if (cek.symmetricKeySize << 3 !== expected) { | ||
@@ -29,0 +29,0 @@ throw new JWEInvalid('Invalid Content Encryption Key length'); |
@@ -1,2 +0,2 @@ | ||
import { getCiphers, KeyObject, createDecipheriv } from 'crypto'; | ||
import { getCiphers, createDecipheriv } from 'crypto'; | ||
import checkIvLength from '../lib/check_iv_length.js'; | ||
@@ -9,5 +9,6 @@ import checkCekLength from './check_cek_length.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
async function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) { | ||
const keySize = parseInt(enc.substr(1, 3), 10); | ||
if (cek instanceof KeyObject) { | ||
if (isKeyObject(cek)) { | ||
cek = cek.export(); | ||
@@ -20,3 +21,3 @@ } | ||
if (!getCiphers().includes(algorithm)) { | ||
throw new JOSENotSupported(`alg ${enc} is unsupported either by your javascript runtime`); | ||
throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`); | ||
} | ||
@@ -49,3 +50,3 @@ const expectedTag = cbcTag(aad, iv, ciphertext, macSize, macKey, keySize); | ||
if (!getCiphers().includes(algorithm)) { | ||
throw new JOSENotSupported(`alg ${enc} is unsupported either by your javascript runtime`); | ||
throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`); | ||
} | ||
@@ -69,3 +70,3 @@ try { | ||
} | ||
else if (cek instanceof Uint8Array || cek instanceof KeyObject) { | ||
else if (cek instanceof Uint8Array || isKeyObject(cek)) { | ||
key = cek; | ||
@@ -72,0 +73,0 @@ } |
@@ -20,4 +20,4 @@ import { JOSENotSupported } from '../util/errors.js'; | ||
default: | ||
throw new JOSENotSupported(`alg ${alg} is unsupported either by JOSE or your javascript runtime`); | ||
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { KeyObject, diffieHellman, generateKeyPair as generateKeyPairCb } from 'crypto'; | ||
import { diffieHellman, generateKeyPair as generateKeyPairCb } from 'crypto'; | ||
import { promisify } from 'util'; | ||
@@ -8,2 +8,3 @@ import getNamedCurve from './get_named_curve.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
const generateKeyPair = promisify(generateKeyPairCb); | ||
@@ -15,3 +16,3 @@ export const deriveKey = async (publicKey, privateKey, algorithm, keyLength, apu = new Uint8Array(0), apv = new Uint8Array(0)) => { | ||
} | ||
if (!(publicKey instanceof KeyObject)) { | ||
if (!isKeyObject(publicKey)) { | ||
throw new TypeError('invalid key input'); | ||
@@ -22,3 +23,3 @@ } | ||
} | ||
if (!(privateKey instanceof KeyObject)) { | ||
if (!isKeyObject(privateKey)) { | ||
throw new TypeError('invalid key input'); | ||
@@ -33,3 +34,3 @@ } | ||
} | ||
if (!(key instanceof KeyObject)) { | ||
if (!isKeyObject(key)) { | ||
throw new TypeError('invalid key input'); | ||
@@ -36,0 +37,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { KeyObject, createCipheriv } from 'crypto'; | ||
import { createCipheriv } from 'crypto'; | ||
import checkIvLength from '../lib/check_iv_length.js'; | ||
@@ -7,5 +7,6 @@ import checkCekLength from './check_cek_length.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
async function cbcEncrypt(enc, plaintext, cek, iv, aad) { | ||
const keySize = parseInt(enc.substr(1, 3), 10); | ||
if (cek instanceof KeyObject) { | ||
if (isKeyObject(cek)) { | ||
cek = cek.export(); | ||
@@ -38,3 +39,3 @@ } | ||
} | ||
else if (cek instanceof Uint8Array || cek instanceof KeyObject) { | ||
else if (cek instanceof Uint8Array || isKeyObject(cek)) { | ||
key = cek; | ||
@@ -41,0 +42,0 @@ } |
@@ -7,3 +7,3 @@ import { createSecretKey, generateKeyPair as generateKeyPairCb } from 'crypto'; | ||
const generate = promisify(generateKeyPairCb); | ||
export async function generateSecret(alg) { | ||
export async function generateSecret(alg, options) { | ||
let length; | ||
@@ -10,0 +10,0 @@ switch (alg) { |
@@ -1,4 +0,5 @@ | ||
import { KeyObject, createPublicKey } from 'crypto'; | ||
import { createPublicKey } from 'crypto'; | ||
import { JOSENotSupported } from '../util/errors.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
const p256 = Buffer.from([42, 134, 72, 206, 61, 3, 1, 7]); | ||
@@ -28,3 +29,3 @@ const p384 = Buffer.from([43, 129, 4, 0, 34]); | ||
} | ||
if (!(key instanceof KeyObject)) { | ||
if (!isKeyObject(key)) { | ||
throw new TypeError('invalid key input'); | ||
@@ -31,0 +32,0 @@ } |
@@ -11,4 +11,4 @@ import { JOSENotSupported } from '../util/errors.js'; | ||
default: | ||
throw new JOSENotSupported(`alg ${alg} is unsupported either by JOSE or your javascript runtime`); | ||
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { KeyObject, createPublicKey } from 'crypto'; | ||
import { createPublicKey } from 'crypto'; | ||
import { encode as base64url } from './base64url.js'; | ||
@@ -7,2 +7,3 @@ import Asn1SequenceDecoder from './asn1_sequence_decoder.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
const [major, minor] = process.version | ||
@@ -21,3 +22,3 @@ .substr(1) | ||
} | ||
else if (key instanceof KeyObject) { | ||
else if (isKeyObject(key)) { | ||
keyObject = key; | ||
@@ -24,0 +25,0 @@ } |
@@ -50,4 +50,4 @@ import { constants } from 'crypto'; | ||
default: | ||
throw new JOSENotSupported(`alg ${alg} is unsupported either by JOSE or your javascript runtime`); | ||
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`); | ||
} | ||
} |
import { promisify } from 'util'; | ||
import { KeyObject, pbkdf2 as pbkdf2cb } from 'crypto'; | ||
import { pbkdf2 as pbkdf2cb } from 'crypto'; | ||
import random from './random.js'; | ||
@@ -9,5 +9,6 @@ import { p2s as concatSalt } from '../lib/buffer_utils.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
const pbkdf2 = promisify(pbkdf2cb); | ||
function getPassword(key, alg) { | ||
if (key instanceof KeyObject) { | ||
if (isKeyObject(key)) { | ||
return key.export(); | ||
@@ -14,0 +15,0 @@ } |
@@ -1,4 +0,5 @@ | ||
import { KeyObject, publicEncrypt, constants, privateDecrypt } from 'crypto'; | ||
import { publicEncrypt, constants, privateDecrypt } from 'crypto'; | ||
import checkModulusLength from './check_modulus_length.js'; | ||
import { isCryptoKey, getKeyObject } from './webcrypto.js'; | ||
import isKeyObject from './is_key_object.js'; | ||
const checkKey = (key, alg) => { | ||
@@ -38,3 +39,3 @@ if (key.type === 'secret' || key.asymmetricKeyType !== 'rsa') { | ||
function ensureKeyObject(key, alg, ...usages) { | ||
if (key instanceof KeyObject) { | ||
if (isKeyObject(key)) { | ||
return key; | ||
@@ -41,0 +42,0 @@ } |
@@ -6,3 +6,3 @@ import * as crypto from 'crypto'; | ||
if (webcrypto !== undefined) { | ||
return key instanceof webcrypto.CryptoKey; | ||
return key != null && key instanceof webcrypto.CryptoKey; | ||
} | ||
@@ -9,0 +9,0 @@ return false; |
import { generateSecret as generate } from '../runtime/generate.js'; | ||
async function generateSecret(alg) { | ||
return generate(alg); | ||
async function generateSecret(alg, options) { | ||
return generate(alg, options); | ||
} | ||
export { generateSecret }; | ||
export default generateSecret; |
@@ -5,2 +5,3 @@ import type { KeyLike } from '../types.js'; | ||
modulusLength?: number; | ||
extractable?: boolean; | ||
} | ||
@@ -7,0 +8,0 @@ declare function generateKeyPair(alg: string, options?: GenerateKeyPairOptions): Promise<{ |
import type { KeyLike } from '../types.d'; | ||
declare function generateSecret(alg: string): Promise<KeyLike>; | ||
export interface GenerateSecretOptions { | ||
extractable?: boolean; | ||
} | ||
declare function generateSecret(alg: string, options?: GenerateSecretOptions): Promise<KeyLike>; | ||
export { generateSecret }; | ||
export default generateSecret; |
{ | ||
"name": "jose-node-esm-runtime", | ||
"version": "3.11.6", | ||
"version": "3.12.0", | ||
"description": "(Node.JS ESM Runtime) 'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK with no dependencies", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
145192
106
3707