Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 1.67 KB

jws_compact_sign.CompactSign.md

File metadata and controls

76 lines (47 loc) · 1.67 KB

Class: CompactSign

The CompactSign class is a utility for creating Compact JWS strings.

example Usage

const jws = await new jose.CompactSign(
  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 CompactSign(payload)

Parameters

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

Methods

setProtectedHeader

setProtectedHeader(protectedHeader): CompactSign

Sets the JWS Protected Header on the Sign object.

Parameters

Name Type Description
protectedHeader CompactJWSHeaderParameters JWS Protected Header.

Returns

CompactSign


sign

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

Signs and resolves the value of the Compact JWS string.

Parameters

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

Returns

Promise<string>