Skip to content

Latest commit

 

History

History
93 lines (55 loc) · 2.86 KB

FlattenedSign.md

File metadata and controls

93 lines (55 loc) · 2.86 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.

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

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

new FlattenedSign()

new FlattenedSign(payload): FlattenedSign

Parameters

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

Returns

FlattenedSign

Methods

setProtectedHeader()

setProtectedHeader(protectedHeader): this

Sets the JWS Protected Header on the FlattenedSign object.

Parameters

Parameter Type Description
protectedHeader JWSHeaderParameters JWS Protected Header.

Returns

this


setUnprotectedHeader()

setUnprotectedHeader(unprotectedHeader): this

Sets the JWS Unprotected Header on the FlattenedSign object.

Parameters

Parameter Type Description
unprotectedHeader JWSHeaderParameters JWS Unprotected Header.

Returns

this


sign()

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

Signs and resolves the value of the Flattened JWS object.

Parameters

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

Returns

Promise<FlattenedJWS>