mirror of
https://github.com/danbulant/jose
synced 2026-05-24 20:41:46 +00:00
2.1 KiB
2.1 KiB
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
Methods
addSignature
▸ addSignature(key, options?): Signature
Parameters
| Name | Type |
|---|---|
key |
KeyLike |
options? |
SignOptions |
Returns
Defined in
sign
▸ sign(): Promise<GeneralJWS>
Signs and resolves the value of the General JWS object.
Returns
Promise<GeneralJWS>