File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ README.md
44assets/
55
66src/webflow/oauth.py
7+ src/webflow/signature.py
Original file line number Diff line number Diff line change 1+ # If we can I'd like to move this to the webhooks client wrapper,
2+ # but I can't find the Fern generation.yml to extend the client
3+ # according to documentation included here:
4+ # https://buildwithfern.com/learn/sdks/capabilities/custom-code
5+ import hmac
6+ import hashlib
7+ from collections .abc import Mapping
8+
9+ def verify (headers : Mapping , body :str , secret : str ):
10+ # Normalize header format to account for different server implementations
11+ normalized_headers = {k .lower (): v for k , v in headers .items ()}
12+
13+ message = f"{ normalized_headers .get ('x-webflow-timestamp' , '' )} :{ body } " .encode ('utf-8' )
14+
15+ generated_signature = hmac .new (
16+ key = secret .encode ('utf-8' ),
17+ msg = message ,
18+ digestmod = hashlib .sha256
19+ ).hexdigest ()
20+
21+ return normalized_headers .get ("x-webflow-signature" , "" ) == generated_signature
You can’t perform that action at this time.
0 commit comments