22
33from __future__ import annotations
44
5- import hashlib
6- import hmac
7- import json
8- import time
95from typing import TYPE_CHECKING , Any , Dict , List , Optional , Union
106
117if TYPE_CHECKING :
2016)
2117from .._pagination import AsyncPage , SyncPage
2218from .._types import RequestOptions
19+ import hashlib
20+ import hmac
21+ import json
22+ import time
2323
2424
2525class Webhooks :
@@ -249,7 +249,9 @@ def verify_header(
249249
250250 issued_timestamp = issued_timestamp [2 :]
251251 signature_hash = signature_hash [3 :]
252- max_seconds_since_issued = tolerance if tolerance is not None else self .DEFAULT_TOLERANCE
252+ max_seconds_since_issued = (
253+ tolerance if tolerance is not None else self .DEFAULT_TOLERANCE
254+ )
253255 current_time = time .time ()
254256 timestamp_in_seconds = int (issued_timestamp ) / 1000
255257 seconds_since_issued = current_time - timestamp_in_seconds
@@ -258,9 +260,7 @@ def verify_header(
258260 raise ValueError ("Timestamp outside the tolerance zone" )
259261
260262 body_str = (
261- event_body .decode ("utf-8" )
262- if isinstance (event_body , bytes )
263- else event_body
263+ event_body .decode ("utf-8" ) if isinstance (event_body , bytes ) else event_body
264264 )
265265 unhashed_string = f"{ issued_timestamp } .{ body_str } "
266266 expected_signature = hmac .new (
@@ -273,6 +273,7 @@ def verify_header(
273273 raise ValueError (
274274 "Signature hash does not match the expected signature hash for payload"
275275 )
276+
276277 # @oagen-ignore-end
277278
278279
0 commit comments