Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 2.48 KB

jwt_decrypt.jwtDecrypt.md

File metadata and controls

69 lines (47 loc) · 2.48 KB

Function: jwtDecrypt

jwt/decrypt.jwtDecrypt

jwtDecrypt(jwt, key, options?): Promise<JWTDecryptResult>

Verifies the JWT format (to be a JWE Compact format), decrypts the ciphertext, validates the JWT Claims Set.

example ESM import

import { jwtDecrypt } from 'jose/jwt/decrypt'

example CJS import

const { jwtDecrypt } = require('jose/jwt/decrypt')

example Deno import

import { jwtDecrypt } from 'https://deno.land/x/jose@v3.19.0/jwt/decrypt.ts'

example Usage

const jwt = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..KVcNLqK-3-8ZkYIC.xSwF4VxO0kUMUD2W-cifsNUxnr-swyBq-nADBptyt6y9n79-iNc5b0AALJpRwc0wwDkJw8hNOMjApNUTMsK9b-asToZ3DXFMvwfJ6n1aWefvd7RsoZ2LInWFfVAuttJDzoGB.uuexQoWHwrLMEYRElT8pBQ'

const { payload, protectedHeader } = await jwtDecrypt(jwt, secretKey, {
  issuer: 'urn:example:issuer',
  audience: 'urn:example:audience'
})

console.log(protectedHeader)
console.log(payload)

Parameters

Name Type Description
jwt string | Uint8Array JSON Web Token value (encoded as JWE).
key KeyLike Private Key or Secret to decrypt and verify the JWT with.
options? JWTDecryptOptions JWT Decryption and JWT Claims Set validation options.

Returns

Promise<JWTDecryptResult>

Defined in

jwt/decrypt.ts:62

jwtDecrypt(jwt, getKey, options?): Promise<JWTDecryptResult & ResolvedKey>

Parameters

Name Type Description
jwt string | Uint8Array JSON Web Token value (encoded as JWE).
getKey JWTDecryptGetKey Function resolving Private Key or Secret to decrypt and verify the JWT with.
options? JWTDecryptOptions JWT Decryption and JWT Claims Set validation options.

Returns

Promise<JWTDecryptResult & ResolvedKey>

Defined in

jwt/decrypt.ts:72