UNPKG

jose

Version:

JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes

32 lines (31 loc) • 2.05 kB
import type * as t from '../../types.d.ts'; /** Resolves a key for General JWS verification from unverified headers and token data. */ export interface GeneralVerifyGetKey<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array> extends t.GetKeyFunction<t.JWSHeaderParameters, t.FlattenedJWSInput, KeyType | t.KeyObject | t.JWK> { } /** * Validates a JWS Signature (digital signature or MAC) from a general JWS JSON Serialization and * decodes its JWS Payload. * * > Note: Returns payload and headers from the first signature that verifies successfully. Other entries' * > headers may be inspected to reject inconsistent use of the JWS Unencoded Payload Option, but are * > not included in the result. Rely only on the returned data. * * @param key Public key or shared secret. See * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}. */ export declare function generalVerify(jws: t.GeneralJWSInput, key: t.KeyInput, options?: t.VerifyOptions): Promise<t.GeneralVerifyResult>; /** * Validates a JWS Signature (digital signature or MAC) from a general JWS JSON Serialization and * decodes its JWS Payload with a dynamically resolved key, included in the result. * * @param getKey Resolves a public key or shared secret from unverified token data. */ export declare function generalVerify<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array>(jws: t.GeneralJWSInput, getKey: GeneralVerifyGetKey<KeyType>, options?: t.VerifyOptions): Promise<t.GeneralVerifyResult & t.ResolvedKey<KeyType>>; /** * Validates a JWS Signature (digital signature or MAC) from a general JWS JSON Serialization and * decodes its JWS Payload using a key or key resolver. The result includes `key` only when a * resolver is used. * * @param key Public key or shared secret, or a function resolving one. */ export declare function generalVerify(jws: t.GeneralJWSInput, key: t.KeyInput | GeneralVerifyGetKey, options?: t.VerifyOptions): Promise<t.GeneralVerifyResult & Partial<t.ResolvedKey>>;