Skip to main content

@panva/jose@6.0.10
Built and signed on GitHub Actions

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

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
3 weeks ago (6.0.10)
function generalVerify
generalVerify(
jws: types.GeneralJWSInput,
key:
types.CryptoKey
| types.KeyObject
| types.JWK
| Uint8Array
,
options?: types.VerifyOptions,
): Promise<types.GeneralVerifyResult>

Verifies the signature and format of and afterwards decodes the General JWS.

This function is exported (as a named export) from the main 'jose' module entry point as well as from its subpath export 'jose/jws/general/verify'.

Examples

Example 1

const jws = {
  payload: 'SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4',
  signatures: [
    {
      signature:
        'FVVOXwj6kD3DqdfD9yYqfT2W9jv-Nop4kOehp_DeDGNB5dQNSPRvntBY6xH3uxlCxE8na9d_kyhYOcanpDJ0EA',
      protected: 'eyJhbGciOiJFUzI1NiJ9',
    },
  ],
}

const { payload, protectedHeader } = await jose.generalVerify(jws, publicKey)

console.log(protectedHeader)
console.log(new TextDecoder().decode(payload))

Parameters

jws: types.GeneralJWSInput

General JWS.

key:
types.CryptoKey
| types.KeyObject
| types.JWK
| Uint8Array

Key to verify the JWS with. See Algorithm Key Requirements.

optional
options: types.VerifyOptions

JWS Verify options.

Return Type

Promise<types.GeneralVerifyResult>
generalVerify(
jws: types.GeneralJWSInput,
options?: types.VerifyOptions,
): Promise<types.GeneralVerifyResult & types.ResolvedKey>

Parameters

jws: types.GeneralJWSInput

General JWS.

Function resolving a key to verify the JWS with. See Algorithm Key Requirements.

optional
options: types.VerifyOptions

JWS Verify options.

Return Type

Promise<types.GeneralVerifyResult & types.ResolvedKey>

Add Package

deno add jsr:@panva/jose

Import symbol

import { generalVerify } from "@panva/jose/jws/general/verify";

---- OR ----

Import directly with a jsr specifier

import { generalVerify } from "jsr:@panva/jose/jws/general/verify";

Add Package

npx jsr add @panva/jose

Import symbol

import { generalVerify } from "@panva/jose/jws/general/verify";

Add Package

yarn dlx jsr add @panva/jose

Import symbol

import { generalVerify } from "@panva/jose/jws/general/verify";

Add Package

pnpm dlx jsr add @panva/jose

Import symbol

import { generalVerify } from "@panva/jose/jws/general/verify";

Add Package

bunx jsr add @panva/jose

Import symbol

import { generalVerify } from "@panva/jose/jws/general/verify";