Back to Jose

Class: FlattenedSign

docs/jws/flattened/sign/classes/FlattenedSign.md

6.2.122.6 KB
Original Source

Class: FlattenedSign

πŸ’— Help the project

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.

Builds and signs Flattened 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/flattened/sign'.

Example

js
const jws = await new jose.FlattenedSign(
  new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
)
  .setProtectedHeader({ alg: 'ES256' })
  .sign(privateKey)

console.log(jws)

Constructors

Constructor

β–Έ new FlattenedSign(payload): FlattenedSign

Creates a Flattened JWS signer.

Parameters

ParameterTypeDescription
payloadUint8ArrayBinary representation of the payload to sign.

Returns

FlattenedSign

Methods

setProtectedHeader()

β–Έ setProtectedHeader(protectedHeader): this

Sets the JWS Protected Header. May only be called once.

Parameters

ParameterTypeDescription
protectedHeaderJWSHeaderParametersJWS Protected Header.

Returns

this


setUnprotectedHeader()

β–Έ setUnprotectedHeader(unprotectedHeader): this

Sets the JWS Unprotected Header. May only be called once.

Parameters

ParameterTypeDescription
unprotectedHeaderJWSHeaderParametersJWS Unprotected Header.

Returns

this


sign()

β–Έ sign(key, options?): Promise<FlattenedJWS>

Signs the payload as a Flattened JWS.

Parameters

ParameterTypeDescription
keyKeyInputPrivate key or shared secret. See Algorithm Key Requirements.
options?SignOptionsJWS Sign options.

Returns

Promise<FlattenedJWS>