Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/oauth4webapi/build/index.d.ts>modifyAssertion

Low-Level OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
Latest
variable modifyAssertion
import { modifyAssertion } from "https://deno.land/x/oauth4webapi@v2.17.0/build/index.d.ts";

Use to mutate JWT header and payload before they are signed. Its intended use is working around non-conform server behaviours, such as modifying JWT "aud" (audience) claims, or otherwise changing fixed claims used by this library.

Examples

Changing Private Key JWT client assertion audience issued from an array to a string

import * as oauth from 'oauth4webapi'

// Prerequisites
let as!: oauth.AuthorizationServer
let client!: oauth.Client
let parameters!: URLSearchParams
let clientPrivateKey!: CryptoKey

const response = await oauth.pushedAuthorizationRequest(as, client, parameters, {
  clientPrivateKey: {
    key: clientPrivateKey,
    [oauth.modifyAssertion](header, payload) {
      payload.aud = as.issuer
    },
  },
})

Changing Request Object issued by issueRequestObject to have an expiration of 5 minutes

import * as oauth from 'oauth4webapi'

// Prerequisites
let as!: oauth.AuthorizationServer
let client!: oauth.Client
let parameters!: URLSearchParams
let jarPrivateKey!: CryptoKey

const request = await oauth.issueRequestObject(as, client, parameters, {
  key: jarPrivateKey,
  [oauth.modifyAssertion](header, payload) {
    payload.exp = <number>payload.iat + 300
  },
})

type

unique symbol