Skip to main content

formsg@1.0.0

decryptSubmission(submissionData, options)
processWebhook(submissionData, signatureHeader)
verifyWebhook(signatureHeader)

Functions

decryptSubmission

decryptSubmission(submissionData, options) ⇒ Operation

Decrypt a FormSG submission

ParamTypeDescription
submissionDataDecryptParamsThe encrypted submission data from FormSG webhook
optionsDecryptOptionsOptions for decryption

This operation writes the following keys to state:

State KeyDescription
dataThe current data/response
configurationFormSG configuration
referencesArray 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)

ParamTypeDescription
submissionDataDecryptParamsThe encrypted submission data from FormSG webhook
signatureHeaderstringThe X-FormSG-Signature header value

This operation writes the following keys to state:

State KeyDescription
dataThe current data/response
configurationFormSG configuration
referencesArray of previous data objects

Example

processWebhook($.data, $.request.headers['x-formsg-signature'])

verifyWebhook

verifyWebhook(signatureHeader) ⇒ Operation

Verify a FormSG webhook signature

ParamTypeDescription
signatureHeaderstringThe X-FormSG-Signature header value

This operation writes the following keys to state:

State KeyDescription
dataThe current data/response
configurationFormSG configuration
referencesArray of previous data objects

Example

verifyWebhook($.request.headers['x-formsg-signature'])

Interfaces

DecryptOptions

Options for decrypting FormSG submissions

Properties

NameTypeDefaultDescription
[verifySignature]booleanfalseWhether to verify webhook signature
[signatureHeader]stringThe X-FormSG-Signature header value

FormSGConfiguration

Configuration for FormSG adaptor

Properties

NameTypeDefaultDescription
formSecretKeystringYour form's secret key from FormSG
[mode]PackageMode'development'SDK mode: 'production', 'staging', or 'development'
[webhookEndpoint]stringThe URI of your webhook endpoint

FormSGState

State object for FormSG operations

Properties

NameTypeDescription
dataObjectThe current data/response
configurationFormSGConfigurationFormSG configuration
referencesArrayArray of previous data objects