jose-node-esm-runtime
Advanced tools
Comparing version 4.12.2 to 4.13.0
@@ -7,3 +7,3 @@ import { importJWK } from '../key/import.js'; | ||
...protectedHeader, | ||
...token.header, | ||
...token === null || token === void 0 ? void 0 : token.header, | ||
}; | ||
@@ -10,0 +10,0 @@ if (!isObject(joseHeader.jwk)) { |
@@ -103,7 +103,7 @@ import { importJWK } from '../key/import.js'; | ||
if (cached[alg] === undefined) { | ||
const keyObject = await importJWK({ ...jwk, ext: true }, alg); | ||
if (keyObject.type !== 'public') { | ||
const key = await importJWK({ ...jwk, ext: true }, alg); | ||
if (key instanceof Uint8Array || key.type !== 'public') { | ||
throw new JWKSInvalid('JSON Web Key Set members must be public keys'); | ||
} | ||
cached[alg] = keyObject; | ||
cached[alg] = key; | ||
} | ||
@@ -113,3 +113,6 @@ return cached[alg]; | ||
export function createLocalJWKSet(jwks) { | ||
return LocalJWKSet.prototype.getKey.bind(new LocalJWKSet(jwks)); | ||
const set = new LocalJWKSet(jwks); | ||
return async function (protectedHeader, token) { | ||
return set.getKey(protectedHeader, token); | ||
}; | ||
} |
@@ -80,3 +80,6 @@ import fetchJwks from '../runtime/fetch_jwks.js'; | ||
export function createRemoteJWKSet(url, options) { | ||
return RemoteJWKSet.prototype.getKey.bind(new RemoteJWKSet(url, options)); | ||
const set = new RemoteJWKSet(url, options); | ||
return async function (protectedHeader, token) { | ||
return set.getKey(protectedHeader, token); | ||
}; | ||
} |
@@ -33,2 +33,2 @@ import type { KeyLike, DecryptOptions, CompactJWEHeaderParameters, GetKeyFunction, FlattenedJWE, CompactDecryptResult, ResolvedKey } from '../../types'; | ||
*/ | ||
export declare function compactDecrypt(jwe: string | Uint8Array, getKey: CompactDecryptGetKey, options?: DecryptOptions): Promise<CompactDecryptResult & ResolvedKey>; | ||
export declare function compactDecrypt<T extends KeyLike = KeyLike>(jwe: string | Uint8Array, getKey: CompactDecryptGetKey, options?: DecryptOptions): Promise<CompactDecryptResult & ResolvedKey<T>>; |
@@ -43,2 +43,2 @@ import type { FlattenedDecryptResult, KeyLike, FlattenedJWE, JWEHeaderParameters, DecryptOptions, GetKeyFunction, ResolvedKey } from '../../types'; | ||
*/ | ||
export declare function flattenedDecrypt(jwe: FlattenedJWE, getKey: FlattenedDecryptGetKey, options?: DecryptOptions): Promise<FlattenedDecryptResult & ResolvedKey>; | ||
export declare function flattenedDecrypt<T extends KeyLike = KeyLike>(jwe: FlattenedJWE, getKey: FlattenedDecryptGetKey, options?: DecryptOptions): Promise<FlattenedDecryptResult & ResolvedKey<T>>; |
@@ -47,2 +47,2 @@ import type { KeyLike, DecryptOptions, JWEHeaderParameters, GetKeyFunction, FlattenedJWE, GeneralJWE, GeneralDecryptResult, ResolvedKey } from '../../types'; | ||
*/ | ||
export declare function generalDecrypt(jwe: GeneralJWE, getKey: GeneralDecryptGetKey, options?: DecryptOptions): Promise<GeneralDecryptResult & ResolvedKey>; | ||
export declare function generalDecrypt<T extends KeyLike = KeyLike>(jwe: GeneralJWE, getKey: GeneralDecryptGetKey, options?: DecryptOptions): Promise<GeneralDecryptResult & ResolvedKey<T>>; |
@@ -23,2 +23,2 @@ import type { KeyLike, FlattenedJWSInput, JWSHeaderParameters } from '../types'; | ||
*/ | ||
export declare function EmbeddedJWK(protectedHeader: JWSHeaderParameters, token: FlattenedJWSInput): Promise<KeyLike>; | ||
export declare function EmbeddedJWK<T extends KeyLike = KeyLike>(protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput): Promise<T>; |
@@ -5,7 +5,7 @@ import type { KeyLike, JWSHeaderParameters, JSONWebKeySet, FlattenedJWSInput } from '../types'; | ||
/** @private */ | ||
export declare class LocalJWKSet { | ||
export declare class LocalJWKSet<T extends KeyLike = KeyLike> { | ||
protected _jwks?: JSONWebKeySet; | ||
private _cached; | ||
constructor(jwks: unknown); | ||
getKey(protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput): Promise<KeyLike>; | ||
getKey(protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput): Promise<T>; | ||
} | ||
@@ -86,2 +86,2 @@ /** | ||
*/ | ||
export declare function createLocalJWKSet(jwks: JSONWebKeySet): (protectedHeader?: JWSHeaderParameters | undefined, token?: FlattenedJWSInput | undefined) => Promise<KeyLike>; | ||
export declare function createLocalJWKSet<T extends KeyLike = KeyLike>(jwks: JSONWebKeySet): (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<T>; |
@@ -92,2 +92,2 @@ import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput } from '../types'; | ||
*/ | ||
export declare function createRemoteJWKSet(url: URL, options?: RemoteJWKSetOptions): (protectedHeader?: JWSHeaderParameters | undefined, token?: FlattenedJWSInput | undefined) => Promise<KeyLike>; | ||
export declare function createRemoteJWKSet<T extends KeyLike = KeyLike>(url: URL, options?: RemoteJWKSetOptions): (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<T>; |
@@ -37,2 +37,2 @@ import type { CompactVerifyResult, FlattenedJWSInput, GetKeyFunction, CompactJWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types'; | ||
*/ | ||
export declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey>; | ||
export declare function compactVerify<T extends KeyLike = KeyLike>(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey<T>>; |
@@ -42,2 +42,2 @@ import type { FlattenedVerifyResult, KeyLike, FlattenedJWSInput, JWSHeaderParameters, VerifyOptions, GetKeyFunction, ResolvedKey } from '../../types'; | ||
*/ | ||
export declare function flattenedVerify(jws: FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult & ResolvedKey>; | ||
export declare function flattenedVerify<T extends KeyLike = KeyLike>(jws: FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult & ResolvedKey<T>>; |
@@ -45,2 +45,2 @@ import type { GeneralJWSInput, GeneralVerifyResult, FlattenedJWSInput, GetKeyFunction, JWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types'; | ||
*/ | ||
export declare function generalVerify(jws: GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult & ResolvedKey>; | ||
export declare function generalVerify<T extends KeyLike = KeyLike>(jws: GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult & ResolvedKey<T>>; |
@@ -41,2 +41,2 @@ import type { KeyLike, DecryptOptions, JWTClaimVerificationOptions, GetKeyFunction, CompactJWEHeaderParameters, FlattenedJWE, JWTDecryptResult, ResolvedKey } from '../types'; | ||
*/ | ||
export declare function jwtDecrypt(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult & ResolvedKey>; | ||
export declare function jwtDecrypt<T extends KeyLike = KeyLike>(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult & ResolvedKey<T>>; |
@@ -108,2 +108,2 @@ import type { KeyLike, VerifyOptions, JWTClaimVerificationOptions, JWTHeaderParameters, GetKeyFunction, FlattenedJWSInput, JWTVerifyResult, ResolvedKey } from '../types'; | ||
*/ | ||
export declare function jwtVerify(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult & ResolvedKey>; | ||
export declare function jwtVerify<T extends KeyLike = KeyLike>(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult & ResolvedKey<T>>; |
import type { KeyLike } from '../types'; | ||
export interface GenerateKeyPairResult { | ||
export interface GenerateKeyPairResult<T extends KeyLike = KeyLike> { | ||
/** The generated Private Key. */ | ||
privateKey: KeyLike; | ||
privateKey: T; | ||
/** Public Key corresponding to the generated Private Key. */ | ||
publicKey: KeyLike; | ||
publicKey: T; | ||
} | ||
@@ -44,2 +44,2 @@ export interface GenerateKeyPairOptions { | ||
*/ | ||
export declare function generateKeyPair(alg: string, options?: GenerateKeyPairOptions): Promise<GenerateKeyPairResult>; | ||
export declare function generateKeyPair<T extends KeyLike = KeyLike>(alg: string, options?: GenerateKeyPairOptions): Promise<GenerateKeyPairResult<T>>; |
@@ -26,2 +26,2 @@ import type { KeyLike } from '../types'; | ||
*/ | ||
export declare function generateSecret(alg: string, options?: GenerateSecretOptions): Promise<KeyLike | Uint8Array>; | ||
export declare function generateSecret<T extends KeyLike = KeyLike>(alg: string, options?: GenerateSecretOptions): Promise<T | Uint8Array>; |
@@ -30,3 +30,3 @@ import type { JWK, KeyLike } from '../types'; | ||
*/ | ||
export declare function importSPKI(spki: string, alg: string, options?: PEMImportOptions): Promise<KeyLike>; | ||
export declare function importSPKI<T extends KeyLike = KeyLike>(spki: string, alg: string, options?: PEMImportOptions): Promise<T>; | ||
/** | ||
@@ -59,3 +59,3 @@ * Imports the SPKI from an X.509 string certificate as a runtime-specific public key representation | ||
*/ | ||
export declare function importX509(x509: string, alg: string, options?: PEMImportOptions): Promise<KeyLike>; | ||
export declare function importX509<T extends KeyLike = KeyLike>(x509: string, alg: string, options?: PEMImportOptions): Promise<T>; | ||
/** | ||
@@ -82,3 +82,3 @@ * Imports a PEM-encoded PKCS#8 string as a runtime-specific private key representation (KeyObject | ||
*/ | ||
export declare function importPKCS8(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<KeyLike>; | ||
export declare function importPKCS8<T extends KeyLike = KeyLike>(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<T>; | ||
/** | ||
@@ -122,2 +122,2 @@ * Imports a JWK to a runtime-specific key representation (KeyLike). Either JWK "alg" (Algorithm) | ||
*/ | ||
export declare function importJWK(jwk: JWK, alg?: string, octAsKeyObject?: boolean): Promise<KeyLike | Uint8Array>; | ||
export declare function importJWK<T extends KeyLike = KeyLike>(jwk: JWK, alg?: string, octAsKeyObject?: boolean): Promise<T | Uint8Array>; |
@@ -604,5 +604,5 @@ /** | ||
export interface ResolvedKey { | ||
export interface ResolvedKey<T extends KeyLike = KeyLike> { | ||
/** Key resolved from the key resolver function. */ | ||
key: KeyLike | Uint8Array | ||
key: T | Uint8Array | ||
} | ||
@@ -609,0 +609,0 @@ |
{ | ||
"name": "jose-node-esm-runtime", | ||
"version": "4.12.2", | ||
"version": "4.13.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
243471
6148