Skip to content

Latest commit

 

History

History
72 lines (44 loc) · 2.39 KB

GeneralSign.md

File metadata and controls

72 lines (44 loc) · 2.39 KB

Class: GeneralSign

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by becoming a sponsor.

The GeneralSign class is used to build and sign General JWS objects.

This class is exported (as a named export) from the main 'jose' module entry point as well as from its subpath export 'jose/jws/general/sign'.

Example

const jws = await new jose.GeneralSign(
  new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
)
  .addSignature(ecPrivateKey)
  .setProtectedHeader({ alg: 'ES256' })
  .addSignature(rsaPrivateKey)
  .setProtectedHeader({ alg: 'PS256' })
  .sign()

console.log(jws)

Constructors

new GeneralSign()

new GeneralSign(payload): GeneralSign

Parameters

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

Returns

GeneralSign

Methods

addSignature()

addSignature(key, options?): Signature

Adds an additional signature for the General JWS object.

Parameters

Parameter Type Description
key Uint8Array | KeyLike | JWK Private Key or Secret to sign the individual JWS signature with. See Algorithm Key Requirements.
options? SignOptions JWS Sign options.

Returns

Signature


sign()

sign(): Promise<GeneralJWS>

Signs and resolves the value of the General JWS object.

Returns

Promise<GeneralJWS>