Skip to content

Latest commit

 

History

History
96 lines (58 loc) · 2.05 KB

jws_general_sign.generalsign.md

File metadata and controls

96 lines (58 loc) · 2.05 KB

Class: GeneralSign

jws/general/sign.GeneralSign

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

example ESM import

import { GeneralSign } from 'jose/jws/general/sign'

example CJS import

const { GeneralSign } = require('jose/jws/general/sign')

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()

Table of contents

Constructors

Methods

Constructors

constructor

new GeneralSign(payload)

Parameters

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

Defined in

jws/general/sign.ts:99

Methods

addSignature

addSignature(key, options?): Signature

Parameters

Name Type
key KeyLike
options? SignOptions

Returns

Signature

Defined in

jws/general/sign.ts:108


sign

sign(): Promise<GeneralJWS>

Signs and resolves the value of the General JWS object.

Returns

Promise<GeneralJWS>

Defined in

jws/general/sign.ts:118