remotion-lambda 4.0.535__tar.gz → 4.0.536__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/PKG-INFO +1 -1
  2. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda/__init__.py +1 -0
  3. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda/version.py +1 -1
  4. remotion_lambda-4.0.536/remotion_lambda/webhook.py +62 -0
  5. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda.egg-info/PKG-INFO +1 -1
  6. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda.egg-info/SOURCES.txt +1 -0
  7. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/LICENSE +0 -0
  8. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/README.md +0 -0
  9. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda/asyncremotionclient.py +0 -0
  10. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda/exception.py +0 -0
  11. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda/models.py +0 -0
  12. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda/remotionclient.py +0 -0
  13. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda.egg-info/dependency_links.txt +0 -0
  14. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda.egg-info/requires.txt +0 -0
  15. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/remotion_lambda.egg-info/top_level.txt +0 -0
  16. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/setup.cfg +0 -0
  17. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/setup.py +0 -0
  18. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/__init__.py +0 -0
  19. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/conftest.py +0 -0
  20. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/constants.py +0 -0
  21. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/test_get_render_progress_client.py +0 -0
  22. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/test_large_payload_compression.py +0 -0
  23. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/test_remotion_client.py +0 -0
  24. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/test_render_client_render_media.py +0 -0
  25. {remotion_lambda-4.0.535 → remotion_lambda-4.0.536}/tests/test_render_client_render_still.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotion_lambda
3
- Version: 4.0.535
3
+ Version: 4.0.536
4
4
  Summary: Remotion Lambda client
5
5
  Home-page: https://github.com/remotion-dev/remotion/tree/main/packages/lambda-python
6
6
  Author: Jonny Burger
@@ -25,3 +25,4 @@ from .models import (
25
25
  from .remotionclient import RemotionClient
26
26
  from .asyncremotionclient import AsyncRemotionClient
27
27
  from .version import VERSION
28
+ from .webhook import validate_webhook_signature
@@ -1,2 +1,2 @@
1
1
  # pylint: disable=missing-module-docstring, missing-final-newline
2
- VERSION = "4.0.535"
2
+ VERSION = "4.0.536"
@@ -0,0 +1,62 @@
1
+ # pylint: disable=missing-module-docstring
2
+ import hashlib
3
+ import hmac
4
+ from typing import Union
5
+
6
+ from .exception import RemotionException, RemotionInvalidArgumentException
7
+
8
+
9
+ def validate_webhook_signature(
10
+ secret: str,
11
+ body: Union[str, bytes],
12
+ signature_header: str,
13
+ ) -> None:
14
+ """
15
+ Validate that an incoming webhook request was sent by Remotion and that its
16
+ body was not modified in transit.
17
+
18
+ Pass the webhook secret that was configured when the render was started, the
19
+ raw request body exactly as it was received, and the value of the
20
+ ``X-Remotion-Signature`` header. The function raises an exception if the
21
+ request cannot be verified and returns ``None`` if it is authentic.
22
+
23
+ The signature covers the raw JSON bytes, so pass the body as it arrived
24
+ (``request.get_data()`` in Flask, ``request.body`` in Django) and decode it
25
+ only after this function returns. Decoding and re-encoding first can change
26
+ key order and whitespace, which would break the comparison even for a
27
+ genuine request.
28
+
29
+ This mirrors ``validateWebhookSignature()`` from ``@remotion/lambda/client``
30
+ and uses the same scheme: ``"sha512="`` followed by the hex digest of an
31
+ HMAC-SHA512 over the request body, keyed with the webhook secret.
32
+ """
33
+ if not secret:
34
+ raise RemotionInvalidArgumentException(
35
+ "No 'secret' was provided to validate_webhook_signature()."
36
+ )
37
+
38
+ if body is None or body == '' or body == b'':
39
+ raise RemotionInvalidArgumentException(
40
+ "No 'body' was provided to validate_webhook_signature()."
41
+ )
42
+
43
+ if not signature_header or signature_header == 'NO_SECRET_PROVIDED':
44
+ raise RemotionException('No webhook signature was provided')
45
+
46
+ body_bytes = body.encode('utf-8') if isinstance(body, str) else body
47
+
48
+ expected = (
49
+ 'sha512='
50
+ + hmac.new(
51
+ secret.encode('utf-8'), body_bytes, hashlib.sha512
52
+ ).hexdigest()
53
+ )
54
+
55
+ # Compare as bytes: `compare_digest()` rejects two `str` values when either
56
+ # side contains non-ASCII characters, and the signature header is
57
+ # attacker-controlled, so a non-ASCII value must fail the check with a
58
+ # `RemotionException` instead of raising an uncaught `TypeError`.
59
+ if not hmac.compare_digest(
60
+ expected.encode('utf-8'), signature_header.encode('utf-8')
61
+ ):
62
+ raise RemotionException('Signatures do not match')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotion-lambda
3
- Version: 4.0.535
3
+ Version: 4.0.536
4
4
  Summary: Remotion Lambda client
5
5
  Home-page: https://github.com/remotion-dev/remotion/tree/main/packages/lambda-python
6
6
  Author: Jonny Burger
@@ -7,6 +7,7 @@ remotion_lambda/exception.py
7
7
  remotion_lambda/models.py
8
8
  remotion_lambda/remotionclient.py
9
9
  remotion_lambda/version.py
10
+ remotion_lambda/webhook.py
10
11
  remotion_lambda.egg-info/PKG-INFO
11
12
  remotion_lambda.egg-info/SOURCES.txt
12
13
  remotion_lambda.egg-info/dependency_links.txt