formsg@1.0.2
- decryptSubmission(submissionData, options)
- processWebhook(submissionData, signatureHeader)
- verifyWebhook(signatureHeader)
Functions
decryptSubmission
decryptSubmission(submissionData, options) ⇒ Operation
Decrypt a FormSG submission
| Param | Type | Description |
|---|---|---|
| submissionData | DecryptParams | The encrypted submission data from FormSG webhook |
| options | DecryptOptions | Options for decryption |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | The current data/response |
| configuration | FormSG configuration |
| references | Array of previous data objects |
Example
decryptSubmission($.data)
Example
decryptSubmission($.data, {
verifySignature: true,
signatureHeader: $.request.headers['x-formsg-signature']
})
processWebhook
processWebhook(submissionData, signatureHeader) ⇒ Operation
Process a FormSG webhook (verify and decrypt in one step)
| Param | Type | Description |
|---|---|---|
| submissionData | DecryptParams | The encrypted submission data from FormSG webhook |
| signatureHeader | string | The X-FormSG-Signature header value |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | The current data/response |
| configuration | FormSG configuration |
| references | Array of previous data objects |
Example
processWebhook($.data, $.request.headers['x-formsg-signature'])
verifyWebhook
verifyWebhook(signatureHeader) ⇒ Operation
Verify a FormSG webhook signature
| Param | Type | Description |
|---|---|---|
| signatureHeader | string | The X-FormSG-Signature header value |
This operation writes the following keys to state:
| State Key | Description |
|---|---|
| data | The current data/response |
| configuration | FormSG configuration |
| references | Array of previous data objects |
Example
verifyWebhook($.request.headers['x-formsg-signature'])
Interfaces
DecryptOptions
Options for decrypting FormSG submissions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [verifySignature] | boolean | false | Whether to verify webhook signature |
| [signatureHeader] | string | The X-FormSG-Signature header value |
FormSGConfiguration
Configuration for FormSG adaptor
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| formSecretKey | string | Your form's secret key from FormSG | |
| [mode] | PackageMode | 'development' | SDK mode: 'production', 'staging', or 'development' |
| [webhookEndpoint] | string | The URI of your webhook endpoint |
FormSGState
State object for FormSG operations
Properties
| Name | Type | Description |
|---|---|---|
| data | Object | The current data/response |
| configuration | FormSGConfiguration | FormSG configuration |
| references | Array | Array of previous data objects |