Skip to content

Commit

Permalink
webhook wip
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Nov 14, 2023
1 parent c4b8df5 commit af3aec5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ wheel
setuptools
twine
auditwheel; sys_platform == 'linux'
cibuildwheel
cibuildwheel

pytest
21 changes: 21 additions & 0 deletions livekit-api/livekit/api/webhooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from .access_token import TokenVerifier
from livekit.protocol import webhook as proto_webhook
from google.protobuf.json_format import Parse
import hashlib
import base64


class WebhookReceiver:
def __init__(token_verifier: TokenVerifier):
self.token_verifier = token_verifier

Check failure on line 10 in livekit-api/livekit/api/webhooks.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F821)

livekit-api/livekit/api/webhooks.py:10:9: F821 Undefined name `self`

def receive(self, body: str, auth_token: str):
claims = self.token_verifier.verify(auth_token)

body_hash = hashlib.sha256(body).digest()
claims_hash = base64.b64decode(claims.sha256)

if body_hash != claims_hash:
raise Exception("hash mismatch")

Parse(body, proto_webhook.WebhookEvent())

0 comments on commit af3aec5

Please sign in to comment.