웹훅
폴링 대신, 어떤 작업에든 callbackUrl (및 webhookSecret) 을 전달하세요. 작업이 끝나면 PicoBerry 가 서명된 이벤트를 POST 합니다.
전달
전달
POST <your callbackUrl>
X-PB-Delivery-Id: 7f3a… # dedupe on this
X-PB-Signature: t=1720252800,v1=<hex>
{ "event": "asset.succeeded", "deliveryId": "7f3a…",
"data": { /* same shape as GET /v1/assets/{id} */ } }서명 검증
v1 은 시크릿을 키로 사용한 "<t>.<raw-body>" 의 HMAC-SHA256 입니다. 상수 시간으로 비교하고, X-PB-Delivery-Id 로 중복을 제거하세요.
검증
const [t, v1] = header.split(",").map(p => p.split("=")[1]);
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
if (!crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected))) reject();t, v1 = dict(p.split("=") for p in header.split(",")).values()
expected = hmac.new(secret, f"{t}.{raw_body}".encode(), hashlib.sha256).hexdigest()
if not hmac.compare_digest(v1, expected): reject()// identical to the Node example on the curl tab