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)• new CompactSign(payload)
| Name | Type | Description |
|---|---|---|
payload |
Uint8Array |
Binary representation of the payload to sign. |
▸ setProtectedHeader(protectedHeader): CompactSign
Sets the JWS Protected Header on the Sign object.
| Name | Type | Description |
|---|---|---|
protectedHeader |
CompactJWSHeaderParameters |
JWS Protected Header. |
▸ sign(key, options?): Promise<string>
Signs and resolves the value of the Compact JWS string.
| Name | Type | Description |
|---|---|---|
key |
KeyLike | Uint8Array |
Private Key or Secret to sign the JWS with. |
options? |
SignOptions |
JWS Sign options. |
Promise<string>