1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
# Class: GeneralSign
[💗 Help the project](https://github.com/sponsors/panva)
The GeneralSign class is a utility for creating General JWS objects.
**`example`** Usage
```js
const jws = await new jose.GeneralSign(
new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
)
.addSignature(ecPrivateKey)
.setProtectedHeader({ alg: 'ES256' })
.addSignature(rsaPrivateKey)
.setProtectedHeader({ alg: 'PS256' })
.sign()
console.log(jws)
```
## Table of contents
### Constructors
- [constructor](jws_general_sign.GeneralSign.md#constructor)
### Methods
- [addSignature](jws_general_sign.GeneralSign.md#addsignature)
- [sign](jws_general_sign.GeneralSign.md#sign)
## Constructors
### constructor
• **new GeneralSign**(`payload`)
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `payload` | `Uint8Array` | Binary representation of the payload to sign. |
## Methods
### addSignature
â–¸ **addSignature**(`key`, `options?`): [`Signature`](../interfaces/jws_general_sign.Signature.md)
Adds an additional signature for the General JWS object.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `key` | `Uint8Array` \| [`KeyLike`](../types/types.KeyLike.md) | Private Key or Secret to sign the individual JWS signature with. |
| `options?` | [`SignOptions`](../interfaces/types.SignOptions.md) | JWS Sign options. |
#### Returns
[`Signature`](../interfaces/jws_general_sign.Signature.md)
___
### sign
â–¸ **sign**(): `Promise`<[`GeneralJWS`](../interfaces/types.GeneralJWS.md)\>
Signs and resolves the value of the General JWS object.
#### Returns
`Promise`<[`GeneralJWS`](../interfaces/types.GeneralJWS.md)\>
|