Skip to main content

Python SDK for FormSG

Project description

Please note that this is an SDK for webhooks integration, and not the FormSG system.

FormSG Python3 SDK

This SDK provides convenient utilities for verifying FormSG webhooks and decrypting submissions in JavaScript and Node.js.

Installation

Install the package with

pip install formsg-sdk

Usage

Webhook Authentication and Decrypting form responses

End-to-end Encryption

FormSG uses end-to-end encryption with elliptic curve cryptography to protect submission data and ensure only intended recipients are able to view form submissions. As such, FormSG servers are unable to access the data.

The underlying cryptosystem is x25519-xsalsa20-poly1305. This codebase is the python implementation of the NaCl library. Official webhook SDK by the FormSG team only supports javascript.

Format of Submission Response

Key Type Description
formId string Unique form identifier.
submissionId string Unique response identifier, displayed as 'Response ID' to form respondents
encryptedContent string The encrypted submission in base64.
created string Creation timestamp.
attachmentDownloadUrls Record<string, string> (Optional) Records containing field IDs and URLs where encrypted uploaded attachments can be downloaded.

Format of Decrypted Submissions

decrypt_responses(request, formSecretKey, securehttp=True) takes in a http request, formsecretkey (b64 encoded) and returns a dictionary with the following structure

{
'data': 
    {
    'formId': str
    'submissionId': str
    'version': str
    'created': str
    'attachmentDownloadUrls': dict
    'decryptedContent': [   
                        {
                        '_id': str
                        'question': str
                        'answer': str
                        'fieldtype': str
                            },
                            {
                        '_id': str
                        'question': str
                        'answer': str
                        'fieldtype': str
                        },
                            ...
                        ]
    }
}

Signature verification

Under the hood, signatures are verified upon decryption, using steps found here - Verifying Signatures Manually

TODO

Attachment decryption.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

formsg_sdk-0.1.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

formsg_sdk-0.1.3-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file formsg_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: formsg_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for formsg_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2f76c1abd349bb4912a183d2b89d0a2252bc69366f9284e98e71f6c04f5e55b0
MD5 0ebb28441786f37d9eeeffd9e9715f68
BLAKE2b-256 25dcae25725608c313eccac9b35a561a991c07be048ea4cf4526dbb18ac27d71

See more details on using hashes here.

File details

Details for the file formsg_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: formsg_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for formsg_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 01c6027fedf097e55d04bf977ce5d77c09e38f3e643fe793cb570c787224e901
MD5 94de01a8293a96df5b36489b8871ffba
BLAKE2b-256 821dd1457c8ef4758be0faf99a8838871727064424e94f769d2f41f901d29bf7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page