Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jose-node-esm-runtime

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jose-node-esm-runtime - npm Package Compare versions

Comparing version 3.18.0 to 3.19.0

6

dist/node/esm/jwe/compact/decrypt.js

@@ -22,5 +22,9 @@ import decrypt from '../flattened/decrypt.js';

}, key, options);
return { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader };
const result = { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader };
if (typeof key === 'function') {
return { ...result, key: decrypted.key };
}
return result;
}
export { compactDecrypt };
export default compactDecrypt;

@@ -95,4 +95,6 @@ import { decode as base64url } from '../../runtime/base64url.js';

}
let resolvedKey = false;
if (typeof key === 'function') {
key = await key(parsedProt, jwe);
resolvedKey = true;
}

@@ -136,2 +138,5 @@ let cek;

}
if (resolvedKey) {
return { ...result, key };
}
return result;

@@ -138,0 +143,0 @@ }

4

dist/node/esm/jwk/embedded.js

@@ -1,2 +0,2 @@

import parseJwk from './parse.js';
import { importJWK } from '../key/import.js';
import isObject from '../lib/is_object.js';

@@ -12,3 +12,3 @@ import { JWSInvalid } from '../util/errors.js';

}
const key = await parseJwk(joseHeader.jwk, joseHeader.alg, true);
const key = (await importJWK({ ...joseHeader.jwk, ext: true }, joseHeader.alg, true));
if (key.type !== 'public') {

@@ -15,0 +15,0 @@ throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');

@@ -1,6 +0,6 @@

import asJWK from '../runtime/key_to_jwk.js';
import { exportJWK } from '../key/export.js';
async function fromKeyLike(key) {
return asJWK(key);
return exportJWK(key);
}
export { fromKeyLike };
export default fromKeyLike;

@@ -1,35 +0,6 @@

import { decode as base64url } from '../runtime/base64url.js';
import asKeyObject from '../runtime/jwk_to_key.js';
import { JOSENotSupported } from '../util/errors.js';
import isObject from '../lib/is_object.js';
import { importJWK } from '../key/import.js';
async function parseJwk(jwk, alg, octAsKeyObject) {
if (!isObject(jwk)) {
throw new TypeError('JWK must be an object');
}
alg || (alg = jwk.alg);
if (typeof alg !== 'string' || !alg) {
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
}
switch (jwk.kty) {
case 'oct':
if (typeof jwk.k !== 'string' || !jwk.k) {
throw new TypeError('missing "k" (Key Value) Parameter value');
}
octAsKeyObject !== null && octAsKeyObject !== void 0 ? octAsKeyObject : (octAsKeyObject = jwk.ext !== true);
if (octAsKeyObject) {
return asKeyObject({ ...jwk, alg, ext: false });
}
return base64url(jwk.k);
case 'RSA':
if (jwk.oth !== undefined) {
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
}
case 'EC':
case 'OKP':
return asKeyObject({ ...jwk, alg });
default:
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
}
return importJWK(jwk, alg, octAsKeyObject);
}
export { parseJwk };
export default parseJwk;

@@ -96,3 +96,3 @@ import fetchJwks from '../runtime/fetch_jwks.js';

if (cached[protectedHeader.alg] === undefined) {
const keyObject = await parseJWK({ ...jwk, alg: protectedHeader.alg });
const keyObject = (await parseJWK({ ...jwk, alg: protectedHeader.alg, ext: true }));
if (keyObject.type !== 'public') {

@@ -99,0 +99,0 @@ throw new JWKSInvalid('JSON Web Key Set members must be public keys');

@@ -20,5 +20,9 @@ import verify from '../flattened/verify.js';

}, key, options);
return { payload: verified.payload, protectedHeader: verified.protectedHeader };
const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };
if (typeof key === 'function') {
return { ...result, key: verified.key };
}
return result;
}
export { compactVerify };
export default compactVerify;

@@ -73,4 +73,6 @@ import { decode as base64url } from '../../runtime/base64url.js';

}
let resolvedKey = false;
if (typeof key === 'function') {
key = await key(parsedProt, jws);
resolvedKey = true;
}

@@ -101,2 +103,5 @@ checkKeyType(alg, key, 'verify');

}
if (resolvedKey) {
return { ...result, key };
}
return result;

@@ -103,0 +108,0 @@ }

@@ -18,5 +18,9 @@ import decrypt from '../jwe/compact/decrypt.js';

}
return { payload, protectedHeader };
const result = { payload, protectedHeader };
if (typeof key === 'function') {
return { ...result, key: decrypted.key };
}
return result;
}
export { jwtDecrypt };
export default jwtDecrypt;

@@ -11,5 +11,9 @@ import verify from '../jws/compact/verify.js';

const payload = jwtPayload(verified.protectedHeader, verified.payload, options);
return { payload, protectedHeader: verified.protectedHeader };
const result = { payload, protectedHeader: verified.protectedHeader };
if (typeof key === 'function') {
return { ...result, key: verified.key };
}
return result;
}
export { jwtVerify };
export default jwtVerify;
import { toSPKI as exportPublic } from '../runtime/asn1.js';
import { toPKCS8 as exportPrivate } from '../runtime/asn1.js';
import { fromKeyLike } from '../jwk/from_key_like.js';
import keyToJWK from '../runtime/key_to_jwk.js';
export async function exportSPKI(key) {

@@ -10,2 +10,4 @@ return exportPublic(key);

}
export const exportJWK = (...args) => fromKeyLike(...args);
export async function exportJWK(key) {
return keyToJWK(key);
}

@@ -1,6 +0,8 @@

import { encodeBase64, decodeBase64 } from '../runtime/base64url.js';
import { decode as decodeBase64URL, encodeBase64, decodeBase64 } from '../runtime/base64url.js';
import { fromSPKI as importPublic } from '../runtime/asn1.js';
import { fromPKCS8 as importPrivate } from '../runtime/asn1.js';
import asKeyObject from '../runtime/jwk_to_key.js';
import { JOSENotSupported } from '../util/errors.js';
import formatPEM from '../lib/format_pem.js';
import { parseJwk as importJwk } from '../jwk/parse.js';
import isObject from '../lib/is_object.js';
function getElement(seq) {

@@ -89,2 +91,30 @@ let result = [];

}
export const importJWK = (...args) => importJwk(...args);
export async function importJWK(jwk, alg, octAsKeyObject) {
if (!isObject(jwk)) {
throw new TypeError('JWK must be an object');
}
alg || (alg = jwk.alg);
if (typeof alg !== 'string' || !alg) {
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
}
switch (jwk.kty) {
case 'oct':
if (typeof jwk.k !== 'string' || !jwk.k) {
throw new TypeError('missing "k" (Key Value) Parameter value');
}
octAsKeyObject !== null && octAsKeyObject !== void 0 ? octAsKeyObject : (octAsKeyObject = jwk.ext !== true);
if (octAsKeyObject) {
return asKeyObject({ ...jwk, alg, ext: false });
}
return decodeBase64URL(jwk.k);
case 'RSA':
if (jwk.oth !== undefined) {
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
}
case 'EC':
case 'OKP':
return asKeyObject({ ...jwk, alg });
default:
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
}
}

@@ -9,3 +9,3 @@ import { unwrap as aesKw } from '../runtime/aeskw.js';

import { bitLengths as cekLengths } from '../lib/cek.js';
import { parseJwk } from '../jwk/parse.js';
import { importJWK } from '../key/import.js';
import checkKeyType from './check_key_type.js';

@@ -42,3 +42,3 @@ function assertEnryptedKey(encryptedKey) {

}
const epk = await parseJwk(joseHeader.epk, alg);
const epk = await importJWK(joseHeader.epk, alg);
let partyUInfo;

@@ -45,0 +45,0 @@ let partyVInfo;

@@ -1,7 +0,8 @@

import type { KeyLike, DecryptOptions, JWEHeaderParameters, GetKeyFunction, FlattenedJWE, CompactDecryptResult } from '../../types';
import type { KeyLike, DecryptOptions, JWEHeaderParameters, GetKeyFunction, FlattenedJWE, CompactDecryptResult, ResolvedKey } from '../../types';
export interface CompactDecryptGetKey extends GetKeyFunction<JWEHeaderParameters, FlattenedJWE> {
}
declare function compactDecrypt(jwe: string | Uint8Array, key: KeyLike | CompactDecryptGetKey, options?: DecryptOptions): Promise<CompactDecryptResult>;
declare function compactDecrypt(jwe: string | Uint8Array, key: KeyLike, options?: DecryptOptions): Promise<CompactDecryptResult>;
declare function compactDecrypt(jwe: string | Uint8Array, getKey: CompactDecryptGetKey, options?: DecryptOptions): Promise<CompactDecryptResult & ResolvedKey>;
export { compactDecrypt };
export default compactDecrypt;
export type { KeyLike, DecryptOptions, CompactDecryptResult };

@@ -1,7 +0,8 @@

import type { FlattenedDecryptResult, KeyLike, FlattenedJWE, JWEHeaderParameters, DecryptOptions, GetKeyFunction } from '../../types';
import type { FlattenedDecryptResult, KeyLike, FlattenedJWE, JWEHeaderParameters, DecryptOptions, GetKeyFunction, ResolvedKey } from '../../types';
export interface FlattenedDecryptGetKey extends GetKeyFunction<JWEHeaderParameters | undefined, FlattenedJWE> {
}
declare function flattenedDecrypt(jwe: FlattenedJWE, key: KeyLike | FlattenedDecryptGetKey, options?: DecryptOptions): Promise<FlattenedDecryptResult>;
declare function flattenedDecrypt(jwe: FlattenedJWE, key: KeyLike, options?: DecryptOptions): Promise<FlattenedDecryptResult>;
declare function flattenedDecrypt(jwe: FlattenedJWE, getKey: FlattenedDecryptGetKey, options?: DecryptOptions): Promise<FlattenedDecryptResult & ResolvedKey>;
export { flattenedDecrypt };
export default flattenedDecrypt;
export type { KeyLike, FlattenedJWE, JWEHeaderParameters, DecryptOptions, FlattenedDecryptResult };

@@ -1,7 +0,8 @@

import type { KeyLike, DecryptOptions, JWEHeaderParameters, GetKeyFunction, FlattenedJWE, GeneralJWE, GeneralDecryptResult } from '../../types';
import type { KeyLike, DecryptOptions, JWEHeaderParameters, GetKeyFunction, FlattenedJWE, GeneralJWE, GeneralDecryptResult, ResolvedKey } from '../../types';
export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters, FlattenedJWE> {
}
declare function generalDecrypt(jwe: GeneralJWE, key: KeyLike | GeneralDecryptGetKey, options?: DecryptOptions): Promise<GeneralDecryptResult>;
declare function generalDecrypt(jwe: GeneralJWE, key: KeyLike, options?: DecryptOptions): Promise<GeneralDecryptResult>;
declare function generalDecrypt(jwe: GeneralJWE, getKey: GeneralDecryptGetKey, options?: DecryptOptions): Promise<GeneralDecryptResult & ResolvedKey>;
export { generalDecrypt };
export default generalDecrypt;
export type { KeyLike, GeneralJWE, DecryptOptions, GeneralDecryptResult };

@@ -1,7 +0,8 @@

import type { CompactVerifyResult, FlattenedJWSInput, GetKeyFunction, JWSHeaderParameters, KeyLike, VerifyOptions } from '../../types';
import type { CompactVerifyResult, FlattenedJWSInput, GetKeyFunction, JWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types';
export interface CompactVerifyGetKey extends GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput> {
}
declare function compactVerify(jws: string | Uint8Array, key: KeyLike | CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult>;
declare function compactVerify(jws: string | Uint8Array, key: KeyLike, options?: VerifyOptions): Promise<CompactVerifyResult>;
declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey>;
export { compactVerify };
export default compactVerify;
export type { KeyLike, VerifyOptions, CompactVerifyResult };

@@ -1,7 +0,8 @@

import type { FlattenedVerifyResult, KeyLike, FlattenedJWSInput, JWSHeaderParameters, VerifyOptions, GetKeyFunction } from '../../types';
import type { FlattenedVerifyResult, KeyLike, FlattenedJWSInput, JWSHeaderParameters, VerifyOptions, GetKeyFunction, ResolvedKey } from '../../types';
export interface FlattenedVerifyGetKey extends GetKeyFunction<JWSHeaderParameters | undefined, FlattenedJWSInput> {
}
declare function flattenedVerify(jws: FlattenedJWSInput, key: KeyLike | FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult>;
declare function flattenedVerify(jws: FlattenedJWSInput, key: KeyLike, options?: VerifyOptions): Promise<FlattenedVerifyResult>;
declare function flattenedVerify(jws: FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult & ResolvedKey>;
export { flattenedVerify };
export default flattenedVerify;
export type { KeyLike, FlattenedJWSInput, GetKeyFunction, JWSHeaderParameters, VerifyOptions, FlattenedVerifyResult, };

@@ -1,7 +0,8 @@

import type { GeneralJWSInput, GeneralVerifyResult, FlattenedJWSInput, GetKeyFunction, JWSHeaderParameters, KeyLike, VerifyOptions } from '../../types';
import type { GeneralJWSInput, GeneralVerifyResult, FlattenedJWSInput, GetKeyFunction, JWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types';
export interface GeneralVerifyGetKey extends GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput> {
}
declare function generalVerify(jws: GeneralJWSInput, key: KeyLike | GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult>;
declare function generalVerify(jws: GeneralJWSInput, key: KeyLike, options?: VerifyOptions): Promise<GeneralVerifyResult>;
declare function generalVerify(jws: GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult & ResolvedKey>;
export { generalVerify };
export default generalVerify;
export type { KeyLike, GeneralJWSInput, VerifyOptions, GeneralVerifyResult };

@@ -1,2 +0,2 @@

import type { KeyLike, DecryptOptions, JWTPayload, JWTClaimVerificationOptions, GetKeyFunction, JWEHeaderParameters, FlattenedJWE, JWTDecryptResult } from '../types';
import type { KeyLike, DecryptOptions, JWTPayload, JWTClaimVerificationOptions, GetKeyFunction, JWEHeaderParameters, FlattenedJWE, JWTDecryptResult, ResolvedKey } from '../types';
interface JWTDecryptOptions extends DecryptOptions, JWTClaimVerificationOptions {

@@ -6,5 +6,6 @@ }

}
declare function jwtDecrypt(jwt: string | Uint8Array, key: KeyLike | JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult>;
declare function jwtDecrypt(jwt: string | Uint8Array, key: KeyLike, options?: JWTDecryptOptions): Promise<JWTDecryptResult>;
declare function jwtDecrypt(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult & ResolvedKey>;
export { jwtDecrypt };
export default jwtDecrypt;
export type { KeyLike, DecryptOptions, JWTPayload, JWTDecryptOptions, JWTDecryptResult };

@@ -1,2 +0,2 @@

import type { KeyLike, VerifyOptions, JWTPayload, JWTClaimVerificationOptions, JWSHeaderParameters, GetKeyFunction, FlattenedJWSInput, JWTVerifyResult } from '../types';
import type { KeyLike, VerifyOptions, JWTPayload, JWTClaimVerificationOptions, JWSHeaderParameters, GetKeyFunction, FlattenedJWSInput, JWTVerifyResult, ResolvedKey } from '../types';
interface JWTVerifyOptions extends VerifyOptions, JWTClaimVerificationOptions {

@@ -6,5 +6,6 @@ }

}
declare function jwtVerify(jwt: string | Uint8Array, key: KeyLike | JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult>;
declare function jwtVerify(jwt: string | Uint8Array, key: KeyLike, options?: JWTVerifyOptions): Promise<JWTVerifyResult>;
declare function jwtVerify(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult & ResolvedKey>;
export { jwtVerify };
export default jwtVerify;
export type { KeyLike, JWTPayload, JWTVerifyOptions, JWSHeaderParameters, GetKeyFunction, JWTVerifyResult, };

@@ -1,6 +0,5 @@

import { fromKeyLike } from '../jwk/from_key_like';
import type { KeyLike } from '../types';
import type { JWK, KeyLike } from '../types';
export declare function exportSPKI(key: Exclude<KeyLike, Uint8Array>): Promise<string>;
export declare function exportPKCS8(key: Exclude<KeyLike, Uint8Array>): Promise<string>;
export declare const exportJWK: typeof fromKeyLike;
export type { KeyLike };
export declare function exportJWK(key: KeyLike): Promise<JWK>;
export type { KeyLike, JWK };

@@ -1,3 +0,2 @@

import { parseJwk as importJwk } from '../jwk/parse';
import type { KeyLike } from '../types';
import type { JWK, KeyLike } from '../types';
export interface PEMImportOptions {

@@ -9,3 +8,3 @@ extractable?: boolean;

export declare function importPKCS8(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<Exclude<KeyLike, Uint8Array>>;
export declare const importJWK: typeof importJwk;
export type { KeyLike };
export declare function importJWK(jwk: JWK, alg?: string, octAsKeyObject?: boolean): Promise<KeyLike>;
export type { KeyLike, JWK };

@@ -172,1 +172,4 @@ /// <reference lib="dom"/>

}
export interface ResolvedKey {
key: KeyLike
}
{
"name": "jose-node-esm-runtime",
"version": "3.18.0",
"version": "3.19.0",
"description": "(Node.JS ESM Runtime) 'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK with no dependencies",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc