Skip to content

Latest commit

 

History

History
107 lines (67 loc) · 2.58 KB

jws_flattened_sign.FlattenedSign.md

File metadata and controls

107 lines (67 loc) · 2.58 KB

Class: FlattenedSign

The FlattenedSign class is a utility for creating Flattened JWS objects.

example Usage

const encoder = new TextEncoder()

const jws = await new FlattenedSign(encoder.encode('It’s a dangerous business, Frodo, going out your door.'))
  .setProtectedHeader({ alg: 'ES256' })
  .sign(privateKey)
console.log(jws)

example ESM import

import { FlattenedSign } from 'jose'

example CJS import

const { FlattenedSign } = require('jose')

example Deno import

import { FlattenedSign } from 'https://deno.land/x/jose@v4.1.3/index.ts'

Table of contents

Constructors

Methods

Constructors

constructor

new FlattenedSign(payload)

Parameters

Name Type Description
payload Uint8Array Binary representation of the payload to sign.

Methods

setProtectedHeader

setProtectedHeader(protectedHeader): FlattenedSign

Sets the JWS Protected Header on the FlattenedSign object.

Parameters

Name Type Description
protectedHeader JWSHeaderParameters JWS Protected Header.

Returns

FlattenedSign


setUnprotectedHeader

setUnprotectedHeader(unprotectedHeader): FlattenedSign

Sets the JWS Unprotected Header on the FlattenedSign object.

Parameters

Name Type Description
unprotectedHeader JWSHeaderParameters JWS Unprotected Header.

Returns

FlattenedSign


sign

sign(key, options?): Promise<FlattenedJWS>

Signs and resolves the value of the Flattened JWS object.

Parameters

Name Type Description
key KeyLike | Uint8Array Private Key or Secret to sign the JWS with.
options? SignOptions JWS Sign options.

Returns

Promise<FlattenedJWS>