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()
• new GeneralSign(payload
)
Name | Type | Description |
---|---|---|
payload |
Uint8Array |
Binary representation of the payload to sign. |
▸ addSignature(key
, options?
): Signature
Name | Type |
---|---|
key |
KeyLike |
options? |
SignOptions |
▸ sign(): Promise
<GeneralJWS
>
Signs and resolves the value of the General JWS object.
Promise
<GeneralJWS
>