Skip to content

Commit 0f091cb

Browse files
committed
Fix return type for decrypt_attachment
1 parent 5976e68 commit 0f091cb

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ pip install formsg
1818

1919
The SDK provides two main utility functions for handling FormSG webhook:
2020

21-
- [`webhook_uri: str, signature_header: str, signature_expiry_seconds: float = 60)`](formsg/utils.py) verifies that the incoming webhook's signature is valid based on the FormSG production public key.
21+
- [`webhook_uri: str, signature_header: str, signature_expiry_seconds: float = 60) -> Mapping[str, Any]`](formsg/utils.py) verifies that the incoming webhook's signature is valid based on the FormSG production public key.
2222
It raises a `nacl.exceptions.BadSignatureError` if the signature is invalid.
2323
The signature header is usually found in the `X-FormSG-Signature` header.
2424
Details on how the signature is constructed can be found [here](https://github.com/opengovsg/formsg-javascript-sdk/#verifying-signatures-manually).
2525

26-
- [`decrypt_content(body: Mapping[str, Any], secret_key: str)`](formsg/utils.py) will decrypt the encrypted content using the given Base-64 encoded secret key.
26+
- [`decrypt_content(body: Mapping[str, Any], secret_key: str) -> Mapping[str, Any]`](formsg/utils.py) will decrypt the encrypted content using the given Base-64 encoded secret key.
2727
`body` is expected to be a dictionary-like object.
2828

29-
- [`decrypt_attachment(body: Mapping[str, Any], field_id: str, secret_key: str)`](formsg/utils.py) will decrypt the encrypted content using the given Base-64 encoded secret key.
30-
`body` is expected to be a dictionary-like object.
29+
- [`decrypt_attachment(body: Mapping[str, Any], field_id: str, secret_key: str) -> bytes`](formsg/utils.py) will download and decrypt the encrypted attachment for a `field` and using the given Base-64 encoded secret key. `body` is expected to be a dictionary-like object.
3130

3231
For convenience, the SDK implements a [`decrypt_django_request`](formsg/django.py) and [`decrypt_flask_request`](formsg/flask.py) which returns the decrypted FormSG content from a Django/Flask request object directly.
3332

formsg/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def decrypt_attachment(
7979
body: Mapping[str, Any],
8080
field_id: str,
8181
secret_key: str, # Base64 encoded secret key
82-
):
82+
) -> bytes:
8383
body = body.get('data', body) # Some FormSG submissions are in a data field while others are not.
8484
url = body['attachmentDownloadUrls'][field_id]
8585
r = requests.get(url)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='formsg',
9-
version='0.1.3',
9+
version='0.1.4',
1010
packages=['formsg'],
1111
description='A Python SDK for handling FormSG webhooks.',
1212
long_description=README,

0 commit comments

Comments
 (0)