refactor(integrations): verify resend webhooks with the shared standard webhooks check

Đang mở
#528 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend, testing

Hướng nghiên cứu

Start by reading src/lib/webhooks/standard-webhooks.ts and the Resend verifier in src/lib/adapters/resend/index.ts; this issue is blocked until #515 and #525 are on main. Then review the existing Resend tests and move scheme-level cases to src/lib/webhooks/standard-webhooks.test.ts, keeping Resend header and documented Svix example coverage. Done when Resend delegates verification to the shared check and its unit tests, Playwright spec, lint, and typecheck pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: integrations enhancement impact: low priority: P2 size: XS

Context

Raised by the Fable review of #525 (Polar webhooks, #429), comment 4591332936.

#525 adds src/lib/webhooks/standard-webhooks.ts (verifyStandardWebhook, standardWebhookKey, standardWebhookSignature), the Standard Webhooks check Polar signs with. Resend signs the same way through Svix, only under the svix-id, svix-timestamp, and svix-signature header names. #515 (Resend webhooks, #427) carries its own copy in src/lib/adapters/resend/index.ts (signingKey, svixSignature, verifyWebhook): the same key decoding, signature, and compare-every-entry loop. Once both merge there are two copies of one signature check, which can drift.

The Resend worker asked that the move wait until #515 merges, so this is its own issue rather than part of #525.

Blocked by #515 and #525 (both must be on main).

Plan

  1. In src/lib/adapters/resend/index.ts, verify with verifyStandardWebhook(request, key === null ? [] : [key], RESEND_WEBHOOK_HEADERS, now), with key from standardWebhookKey(secret).
  2. Replace signingKey and svixSignature with standardWebhookKey and standardWebhookSignature in resendWebhookSignature and createWebhook. Keep RESEND_WEBHOOK_HEADERS as Resend's header names, typed StandardWebhookHeaders.
  3. Delete what becomes unused. Keep RESEND_WEBHOOK_TOLERANCE_SECONDS only if a caller still needs it, otherwise use STANDARD_WEBHOOK_TOLERANCE_SECONDS.
  4. Move any scheme-level tests left in resend/index.test.ts to src/lib/webhooks/standard-webhooks.test.ts. Keep Resend's own: its header names and the Svix documented example.

Acceptance criteria

  • Resend's verify calls verifyStandardWebhook; no second HMAC or compare loop remains in resend/index.ts.
  • Every existing Resend webhook unit test passes unchanged in outcome.
  • Playwright: e2e/webhook-setup-resend.spec.ts passes unchanged. No new e2e is needed, because behavior does not change.

Files and areas

  • src/lib/adapters/resend/index.ts, src/lib/adapters/resend/index.test.ts, src/lib/webhooks/standard-webhooks.test.ts.
  • Non-goals: changing Resend's subscriptions, mapping, tolerance, or setup.

Verification

  • npx vitest run src/lib/adapters/resend src/lib/webhooks
  • npm run lint, npm run typecheck

Branch: <issue-number>-resend-shared-verifier
Closes with a Closes #<issue-number> footer on the commit or pull request.

Model: anthropic/claude-opus-5-5 | Reasoning effort: not reported by the harness

Ngôn ngữ chính
TypeScript
Star
13
Fork
2
Merge trung bình
5 giờ 20 phút
Pull request đã merge (30 ngày)
287

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của eddiejaoude/StackDash

Tất cả issue của eddiejaoude/StackDash

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.