Skip to content

Latest commit

 

History

History
87 lines (55 loc) · 1.74 KB

jws_general_sign.GeneralSign.md

File metadata and controls

87 lines (55 loc) · 1.74 KB

Class: GeneralSign

The GeneralSign class is a utility for creating General JWS objects.

example Usage

const encoder = new TextEncoder()

const sign = new GeneralSign(encoder.encode('It’s a dangerous business, Frodo, going out your door.'))

sign
  .addSignature(ecPrivateKey)
  .setProtectedHeader({ alg: 'ES256' })

sign
  .addSignature(rsaPrivateKey)
  .setProtectedHeader({ alg: 'PS256' })

const jws = await sign.sign()

example ESM import

import { GeneralSign } from 'jose'

example CJS import

const { GeneralSign } = require('jose')

example Deno import

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

Table of contents

Constructors

Methods

Constructors

constructor

new GeneralSign(payload)

Parameters

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

Methods

addSignature

addSignature(key, options?): Signature

Parameters

Name Type
key KeyLike | Uint8Array
options? SignOptions

Returns

Signature


sign

sign(): Promise<GeneralJWS>

Signs and resolves the value of the General JWS object.

Returns

Promise<GeneralJWS>