mirror of
https://github.com/hanzoai/jose.git
synced 2026-09-24 17:00:01 +00:00
Thread resolver return types through verify and decrypt results. Add overloads so wrappers can forward either keys or resolvers. Infer importJWK and generateSecret results from their inputs. Keep JWT payload generics unconstrained while rejecting known non-object shapes. Signed-off-by: Filip Skokan <[email protected]>
2.2 KiB
2.2 KiB
Class: CompactSign
💗 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.
The CompactSign class is used to build and sign Compact JWS strings.
This class is exported (as a named export) from the main 'jose' module entry point as well as
from its subpath export 'jose/jws/compact/sign'.
Example
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)
Constructors
Constructor
â–¸ new CompactSign(payload): CompactSign
CompactSign constructor
Parameters
| Parameter | Type | Description |
|---|---|---|
payload |
Uint8Array |
Binary representation of the payload to sign. |
Returns
CompactSign
Methods
setProtectedHeader()
â–¸ setProtectedHeader(protectedHeader): this
Sets the JWS Protected Header on the CompactSign object.
Parameters
| Parameter | Type | Description |
|---|---|---|
protectedHeader |
CompactJWSHeaderParameters |
JWS Protected Header. |
Returns
this
sign()
â–¸ sign(key, options?): Promise<string>
Signs and resolves the value of the Compact JWS string.
Parameters
| Parameter | Type | Description |
|---|---|---|
key |
KeyInput |
Private Key or Secret to sign the JWS with. See Algorithm Key Requirements. |
options? |
SignOptions |
JWS Sign options. |
Returns
Promise<string>