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.0.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.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: formsg_sdk-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2cf153bacfa2e18c6b7f93d2faa3d88311180dc58515da324af55a5dabbb3878
MD5 db79a9d26dc64f0b9d5de11380dc8053
BLAKE2b-256 f3421fc47860264c3d7cd9cbd69464f2afe856780eb20401fa5400d545081b02

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formsg_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cb7988c7afb76f580079611044c4d847aa3752a83ddf27b4b15bd374a4d1ee1
MD5 8f3067c80f6a66023b9ec9de03ea0b56
BLAKE2b-256 5aec6b57ae098a79d4158f61b20c6e149cfb8007baa9bf342e3bfd5da72ad317

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