jose-browser-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': |
@@ -19,3 +19,3 @@ import { JWEInvalid, JOSENotSupported } from '../util/errors.js'; | ||
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`); | ||
} | ||
@@ -22,0 +22,0 @@ if (cek instanceof Uint8Array) { |
import crypto from './webcrypto.js'; | ||
import { JOSENotSupported } from '../util/errors.js'; | ||
import random from './random.js'; | ||
export async function generateSecret(alg) { | ||
export async function generateSecret(alg, options) { | ||
var _a; | ||
let length; | ||
@@ -41,3 +42,3 @@ let algorithm; | ||
} | ||
return crypto.subtle.generateKey(algorithm, false, keyUsages); | ||
return (crypto.subtle.generateKey(algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages)); | ||
} | ||
@@ -53,3 +54,3 @@ function getModulusLengthOption(options) { | ||
export async function generateKeyPair(alg, options) { | ||
var _a; | ||
var _a, _b; | ||
let algorithm; | ||
@@ -114,3 +115,3 @@ let keyUsages; | ||
} | ||
return crypto.subtle.generateKey(algorithm, false, keyUsages); | ||
return (crypto.subtle.generateKey(algorithm, (_b = options === null || options === void 0 ? void 0 : options.extractable) !== null && _b !== void 0 ? _b : false, keyUsages)); | ||
} |
@@ -7,3 +7,3 @@ import crypto, { isCryptoKey } from './webcrypto.js'; | ||
if (!key.extractable) { | ||
throw new TypeError('non-extractable key cannot be extracted as a JWK'); | ||
throw new TypeError('non-extractable CryptoKey cannot be exported as a JWK'); | ||
} | ||
@@ -10,0 +10,0 @@ const { ext, key_ops, alg, use, ...jwk } = await crypto.subtle.exportKey('jwk', key); |
@@ -41,4 +41,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`); | ||
} | ||
} |
@@ -10,4 +10,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`); | ||
} | ||
} |
import globalThis from './global.js'; | ||
export default globalThis.crypto; | ||
export function isCryptoKey(key) { | ||
return key instanceof globalThis.CryptoKey; | ||
if (typeof globalThis.CryptoKey === 'undefined') { | ||
return false; | ||
} | ||
return key != null && key instanceof globalThis.CryptoKey; | ||
} |
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-browser-runtime", | ||
"version": "3.11.6", | ||
"version": "3.12.0", | ||
"description": "(Browser 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
124656
3130