Skip to content

Latest commit

 

History

History
100 lines (59 loc) · 3.03 KB

jws_flattened_sign.FlattenedSign.md

File metadata and controls

100 lines (59 loc) · 3.03 KB

Class: FlattenedSign

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 FlattenedSign class is used to build and sign Flattened JWS objects.

Example

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)

Table of contents

Constructors

Methods

Constructors

constructor

new FlattenedSign(payload)

Parameters

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

Methods

setProtectedHeader

setProtectedHeader(protectedHeader): FlattenedSign

Sets the JWS Protected Header on the FlattenedSign object.

Parameters

Name Type Description
protectedHeader JWSHeaderParameters JWS Protected Header.

Returns

FlattenedSign


setUnprotectedHeader

setUnprotectedHeader(unprotectedHeader): FlattenedSign

Sets the JWS Unprotected Header on the FlattenedSign object.

Parameters

Name Type Description
unprotectedHeader JWSHeaderParameters JWS Unprotected Header.

Returns

FlattenedSign


sign

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

Signs and resolves the value of the Flattened JWS object.

Parameters

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

Returns

Promise<FlattenedJWS>