新增企业微信、微博、WhatsApp、Workplace 四个渠道扩展。 企业微信渠道扩展主要模块:config, gateway, webhook, webhook_bot, outbound, streaming, pairing, security, crypto, dedupe, persistent_dedupe, card, directory, events, externalcontact, media, mentions, menu, message, oauth, status 微博渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, passive_reply, broadcast, message, menu, media, subscription, template, status WhatsApp 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, actions, monitor, status Workplace 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, actions, challenge, groups, media, mentions, menu, monitor, persona, quick_reply, signature, subscriptions, template, threading, users, status
18 lines
446 B
Python
18 lines
446 B
Python
import hashlib
|
|
import hmac
|
|
|
|
|
|
def verify_signature(payload: bytes, signature: str, app_secret: str) -> bool:
|
|
if not signature or not app_secret:
|
|
return False
|
|
expected = hmac.new(
|
|
app_secret.encode("utf-8"),
|
|
payload,
|
|
hashlib.sha256,
|
|
).hexdigest()
|
|
expected_header = f"sha256={expected}"
|
|
return hmac.compare_digest(
|
|
expected_header.encode("utf-8"),
|
|
signature.encode("utf-8"),
|
|
)
|