@open-mercato/webhooks 0.6.7-develop.6862.1.c11a64ce0a → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.js +0 -15
  3. package/dist/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.js.map +2 -2
  4. package/dist/modules/webhooks/api/inbound/[endpointId]/route.js +7 -152
  5. package/dist/modules/webhooks/api/inbound/[endpointId]/route.js.map +3 -3
  6. package/dist/modules/webhooks/backend/webhooks/[id]/page.js +1 -2
  7. package/dist/modules/webhooks/backend/webhooks/[id]/page.js.map +2 -2
  8. package/dist/modules/webhooks/backend/webhooks/page.js +1 -2
  9. package/dist/modules/webhooks/backend/webhooks/page.js.map +2 -2
  10. package/dist/modules/webhooks/data/entities.js +1 -101
  11. package/dist/modules/webhooks/data/entities.js.map +2 -2
  12. package/dist/modules/webhooks/encryption.js +0 -7
  13. package/dist/modules/webhooks/encryption.js.map +2 -2
  14. package/dist/modules/webhooks/events.js +0 -2
  15. package/dist/modules/webhooks/events.js.map +2 -2
  16. package/dist/modules/webhooks/lib/queue.js +0 -47
  17. package/dist/modules/webhooks/lib/queue.js.map +2 -2
  18. package/dist/modules/webhooks/widgets/injection/integration-deliveries/widget.client.js +1 -2
  19. package/dist/modules/webhooks/widgets/injection/integration-deliveries/widget.client.js.map +2 -2
  20. package/generated/entities.ids.generated.ts +1 -3
  21. package/generated/entity-fields-registry.ts +0 -28
  22. package/package.json +11 -12
  23. package/src/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.ts +0 -16
  24. package/src/modules/webhooks/api/inbound/[endpointId]/__tests__/route.test.ts +1 -99
  25. package/src/modules/webhooks/api/inbound/[endpointId]/route.ts +7 -178
  26. package/src/modules/webhooks/backend/webhooks/[id]/page.tsx +1 -2
  27. package/src/modules/webhooks/backend/webhooks/page.tsx +1 -2
  28. package/src/modules/webhooks/data/entities.ts +0 -84
  29. package/src/modules/webhooks/encryption.ts +0 -7
  30. package/src/modules/webhooks/events.ts +0 -2
  31. package/src/modules/webhooks/i18n/de.json +1 -1
  32. package/src/modules/webhooks/i18n/en.json +1 -1
  33. package/src/modules/webhooks/i18n/es.json +1 -1
  34. package/src/modules/webhooks/i18n/pl.json +1 -1
  35. package/src/modules/webhooks/lib/queue.ts +0 -60
  36. package/src/modules/webhooks/migrations/.snapshot-open-mercato.json +339 -908
  37. package/src/modules/webhooks/widgets/injection/integration-deliveries/widget.client.tsx +1 -2
  38. package/dist/modules/webhooks/extension-points.js +0 -15
  39. package/dist/modules/webhooks/extension-points.js.map +0 -7
  40. package/dist/modules/webhooks/generators.js +0 -57
  41. package/dist/modules/webhooks/generators.js.map +0 -7
  42. package/dist/modules/webhooks/lib/inbound-dispatch.js +0 -105
  43. package/dist/modules/webhooks/lib/inbound-dispatch.js.map +0 -7
  44. package/dist/modules/webhooks/lib/inbound-registry.js +0 -76
  45. package/dist/modules/webhooks/lib/inbound-registry.js.map +0 -7
  46. package/dist/modules/webhooks/lib/module-webhook-registry.js +0 -12
  47. package/dist/modules/webhooks/lib/module-webhook-registry.js.map +0 -7
  48. package/dist/modules/webhooks/migrations/Migration20260617141327_webhooks.js +0 -16
  49. package/dist/modules/webhooks/migrations/Migration20260617141327_webhooks.js.map +0 -7
  50. package/dist/modules/webhooks/workers/inbound-dispatch.js +0 -29
  51. package/dist/modules/webhooks/workers/inbound-dispatch.js.map +0 -7
  52. package/generated/entities/inbound_endpoint_config_entity/index.ts +0 -8
  53. package/generated/entities/webhook_ingestion_entity/index.ts +0 -16
  54. package/src/modules/webhooks/api/inbound/[endpointId]/__tests__/route.unify.test.ts +0 -149
  55. package/src/modules/webhooks/extension-points.ts +0 -12
  56. package/src/modules/webhooks/generators.ts +0 -57
  57. package/src/modules/webhooks/i18n/ko.json +0 -161
  58. package/src/modules/webhooks/lib/__tests__/inbound-dispatch.test.ts +0 -186
  59. package/src/modules/webhooks/lib/__tests__/inbound-registry.test.ts +0 -102
  60. package/src/modules/webhooks/lib/__tests__/module-webhook-registry.test.ts +0 -53
  61. package/src/modules/webhooks/lib/inbound-dispatch.ts +0 -147
  62. package/src/modules/webhooks/lib/inbound-registry.ts +0 -92
  63. package/src/modules/webhooks/lib/module-webhook-registry.ts +0 -33
  64. package/src/modules/webhooks/migrations/Migration20260617141327_webhooks.ts +0 -16
  65. package/src/modules/webhooks/workers/inbound-dispatch.ts +0 -31
@@ -1,16 +1,6 @@
1
1
  // AUTO-GENERATED by mercato generate entity-ids
2
2
  // Static registry for entity fields - eliminates dynamic imports for Turbopack compatibility
3
3
  export const entityFieldsRegistry: Record<string, Record<string, string>> = {
4
- "inbound_endpoint_config_entity": {
5
- "id": "id",
6
- "source_key": "source_key",
7
- "is_active": "is_active",
8
- "integration_id": "integration_id",
9
- "organization_id": "organization_id",
10
- "tenant_id": "tenant_id",
11
- "created_at": "created_at",
12
- "updated_at": "updated_at"
13
- },
14
4
  "webhook_delivery_entity": {
15
5
  "id": "id",
16
6
  "webhook_id": "webhook_id",
@@ -72,24 +62,6 @@ export const entityFieldsRegistry: Record<string, Record<string, string>> = {
72
62
  "organization_id": "organization_id",
73
63
  "tenant_id": "tenant_id",
74
64
  "created_at": "created_at"
75
- },
76
- "webhook_ingestion_entity": {
77
- "id": "id",
78
- "source_key": "source_key",
79
- "event_type": "event_type",
80
- "external_message_id": "external_message_id",
81
- "payload": "payload",
82
- "headers": "headers",
83
- "status": "status",
84
- "error_message": "error_message",
85
- "processed_at": "processed_at",
86
- "handler_count": "handler_count",
87
- "handler_results": "handler_results",
88
- "duration_ms": "duration_ms",
89
- "organization_id": "organization_id",
90
- "tenant_id": "tenant_id",
91
- "created_at": "created_at",
92
- "updated_at": "updated_at"
93
65
  }
94
66
  };
95
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/webhooks",
3
- "version": "0.6.7-develop.6862.1.c11a64ce0a",
3
+ "version": "0.6.7",
4
4
  "license": "MIT",
5
5
  "description": "Webhooks module for Open Mercato — Standard Webhooks compliant outbound/inbound delivery",
6
6
  "type": "module",
@@ -70,28 +70,28 @@
70
70
  }
71
71
  },
72
72
  "dependencies": {
73
- "@open-mercato/core": "0.6.7-develop.6862.1.c11a64ce0a",
74
- "@open-mercato/queue": "0.6.7-develop.6862.1.c11a64ce0a",
75
- "@open-mercato/ui": "0.6.7-develop.6862.1.c11a64ce0a",
76
- "svix": "^1.99.1"
73
+ "@open-mercato/core": "0.6.7",
74
+ "@open-mercato/queue": "0.6.7",
75
+ "@open-mercato/ui": "0.6.7",
76
+ "svix": "^1.96.1"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "@mikro-orm/postgresql": "^7.0.14",
80
- "@open-mercato/shared": "0.6.7-develop.6862.1.c11a64ce0a",
80
+ "@open-mercato/shared": "0.6.7",
81
81
  "react": "^19.0.0",
82
82
  "react-dom": "^19.0.0"
83
83
  },
84
84
  "devDependencies": {
85
- "@open-mercato/shared": "0.6.7-develop.6862.1.c11a64ce0a",
85
+ "@open-mercato/shared": "0.6.7",
86
86
  "@types/jest": "^30.0.0",
87
87
  "@types/react": "^19.2.17",
88
88
  "@types/react-dom": "^19.2.3",
89
89
  "esbuild": "^0.28.1",
90
90
  "glob": "^13.0.6",
91
91
  "jest": "^30.4.2",
92
- "react": "19.2.8",
93
- "react-dom": "19.2.8",
94
- "ts-jest": "^29.4.12",
92
+ "react": "19.2.7",
93
+ "react-dom": "19.2.7",
94
+ "ts-jest": "^29.4.11",
95
95
  "typescript": "7.0.2"
96
96
  },
97
97
  "publishConfig": {
@@ -101,6 +101,5 @@
101
101
  "type": "git",
102
102
  "url": "https://github.com/open-mercato/open-mercato",
103
103
  "directory": "packages/webhooks"
104
- },
105
- "stableVersion": "0.6.6"
104
+ }
106
105
  }
@@ -83,22 +83,6 @@ test.describe('TC-WEBHOOK-003: Inbound webhook receiver', () => {
83
83
  expect(replayWithoutMessageIdDuplicateResponse.status()).toBe(200);
84
84
  await expect(replayWithoutMessageIdDuplicateResponse.json()).resolves.toEqual({ ok: true, duplicate: true });
85
85
 
86
- const staleTimestampResponse = await request.fetch(`${BASE_URL}/api/webhooks/inbound/mock_inbound`, {
87
- method: 'POST',
88
- headers: {
89
- 'content-type': 'application/json',
90
- 'x-mock-webhook-signature': validSignature,
91
- 'webhook-id': `stale-${Date.now()}`,
92
- 'webhook-timestamp': String(Math.floor(Date.now() / 1000) - 10 * 60),
93
- 'webhook-signature': 'v1,mock',
94
- },
95
- data: rawBody,
96
- });
97
- expect(staleTimestampResponse.status()).toBe(400);
98
- await expect(staleTimestampResponse.json()).resolves.toEqual({
99
- error: 'Webhook timestamp is outside the allowed replay window',
100
- });
101
-
102
86
  const invalidSignatureResponse = await request.fetch(`${BASE_URL}/api/webhooks/inbound/mock_inbound`, {
103
87
  method: 'POST',
104
88
  headers: {
@@ -62,13 +62,12 @@ import { POST, buildInboundRateLimitKey, resolveInboundReceiptMessageId } from '
62
62
 
63
63
  const routeContext = { params: Promise.resolve({ endpointId: 'mock_inbound' }) }
64
64
 
65
- function createRequest(body: string = '{"ok":true}', headers: Record<string, string> = {}) {
65
+ function createRequest(body: string = '{"ok":true}') {
66
66
  return new Request('http://localhost/api/webhooks/inbound/mock_inbound', {
67
67
  method: 'POST',
68
68
  headers: {
69
69
  'content-type': 'application/json',
70
70
  'webhook-id': 'msg-1',
71
- ...headers,
72
71
  },
73
72
  body,
74
73
  })
@@ -96,103 +95,6 @@ describe('POST', () => {
96
95
  translate: (_key: string, fallback?: string) => fallback ?? '',
97
96
  })
98
97
  mockIsWebhookIntegrationEnabled.mockResolvedValue(true)
99
- mockGetWebhookEndpointAdapter.mockReturnValue(createAdapter(
100
- {
101
- eventType: 'mock.inbound.received',
102
- payload: { ok: true },
103
- },
104
- { allowUnscopedInbound: true },
105
- ))
106
- })
107
-
108
- it('rejects stale Standard Webhooks timestamps before persisting a fresh message id', async () => {
109
- const staleTimestamp = String(Math.floor(Date.now() / 1000) - 10 * 60)
110
-
111
- const response = await POST(createRequest('{"ok":true}', {
112
- 'webhook-id': 'fresh-message-id',
113
- 'webhook-timestamp': staleTimestamp,
114
- 'webhook-signature': 'v1,mock',
115
- }), routeContext)
116
-
117
- expect(response.status).toBe(400)
118
- await expect(response.json()).resolves.toEqual({ error: 'Webhook timestamp is outside the allowed replay window' })
119
- expect(mockRouteEm.persist).not.toHaveBeenCalled()
120
- expect(mockRouteEm.flush).not.toHaveBeenCalled()
121
- expect(mockEmitWebhooksEvent).not.toHaveBeenCalled()
122
- })
123
-
124
- it('rejects when any present Standard or Svix timestamp header is stale', async () => {
125
- const now = Math.floor(Date.now() / 1000)
126
-
127
- const response = await POST(createRequest('{"ok":true}', {
128
- 'webhook-id': 'fresh-message-id',
129
- 'webhook-timestamp': String(now),
130
- 'webhook-signature': 'v1,mock',
131
- 'svix-timestamp': String(now - 10 * 60),
132
- }), routeContext)
133
-
134
- expect(response.status).toBe(400)
135
- await expect(response.json()).resolves.toEqual({ error: 'Webhook timestamp is outside the allowed replay window' })
136
- expect(mockRouteEm.persist).not.toHaveBeenCalled()
137
- expect(mockRouteEm.flush).not.toHaveBeenCalled()
138
- expect(mockEmitWebhooksEvent).not.toHaveBeenCalled()
139
- })
140
-
141
- it.each(['', 'not-a-number'])('rejects malformed Standard Webhooks timestamps: %j', async (timestamp) => {
142
- const response = await POST(createRequest('{"ok":true}', {
143
- 'webhook-id': 'fresh-message-id',
144
- 'webhook-timestamp': timestamp,
145
- 'webhook-signature': 'v1,mock',
146
- }), routeContext)
147
-
148
- expect(response.status).toBe(400)
149
- await expect(response.json()).resolves.toEqual({ error: 'Webhook timestamp is outside the allowed replay window' })
150
- expect(mockRouteEm.persist).not.toHaveBeenCalled()
151
- expect(mockRouteEm.flush).not.toHaveBeenCalled()
152
- expect(mockEmitWebhooksEvent).not.toHaveBeenCalled()
153
- })
154
-
155
- it('accepts fresh Standard Webhooks timestamps', async () => {
156
- mockGetWebhookEndpointAdapter.mockReturnValue(createAdapter(
157
- {
158
- eventType: 'mock.inbound.received',
159
- payload: { ok: true },
160
- },
161
- { allowUnscopedInbound: true },
162
- ))
163
- const freshTimestamp = String(Math.floor(Date.now() / 1000))
164
-
165
- const response = await POST(createRequest('{"ok":true}', {
166
- 'webhook-id': 'fresh-message-id',
167
- 'webhook-timestamp': freshTimestamp,
168
- 'webhook-signature': 'v1,mock',
169
- }), routeContext)
170
-
171
- expect(response.status).toBe(200)
172
- await expect(response.json()).resolves.toEqual({ ok: true })
173
- expect(mockRouteEm.persist).toHaveBeenCalledTimes(1)
174
- expect(mockRouteEm.flush).toHaveBeenCalledTimes(1)
175
- expect(mockEmitWebhooksEvent).toHaveBeenCalledTimes(1)
176
- })
177
-
178
- it('rejects an oversized declared body before adapter verification', async () => {
179
- const adapter = createAdapter({
180
- eventType: 'mock.inbound.received',
181
- payload: { ok: true },
182
- tenantId: 'tenant-1',
183
- organizationId: 'org-1',
184
- })
185
- mockGetWebhookEndpointAdapter.mockReturnValue(adapter)
186
- const request = new Request('http://localhost/api/webhooks/inbound/mock_inbound', {
187
- method: 'POST',
188
- headers: { 'content-length': String(1024 * 1024 + 1) },
189
- body: '{}',
190
- })
191
-
192
- const response = await POST(request, routeContext)
193
-
194
- expect(response.status).toBe(413)
195
- expect(adapter.verifyWebhook).not.toHaveBeenCalled()
196
98
  })
197
99
 
198
100
  it('rejects verified inbound webhooks without tenant and organization scope before side effects', async () => {
@@ -4,40 +4,13 @@ import type { EntityManager } from '@mikro-orm/postgresql'
4
4
  import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
5
5
  import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
6
6
  import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
7
- import { parseNumberWithDefault } from '@open-mercato/shared/lib/number'
8
7
  import { checkRateLimit, getClientIp, RATE_LIMIT_ERROR_FALLBACK, RATE_LIMIT_ERROR_KEY } from '@open-mercato/shared/lib/ratelimit/helpers'
9
8
  import type { RateLimiterService } from '@open-mercato/shared/lib/ratelimit/service'
10
- import { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'
11
- import {
12
- isWebhookTimestampWithinTolerance,
13
- readBoundedRequestBody,
14
- WEBHOOK_SIGNATURE_TOLERANCE_SECONDS,
15
- WebhookBodyTooLargeError,
16
- type InboundWebhookRequest,
17
- } from '@open-mercato/shared/lib/webhooks'
18
9
  import { emitWebhooksEvent } from '../../../events'
19
10
  import { getWebhookEndpointAdapter } from '../../../lib/adapter-registry'
20
- import { getWebhookSource } from '../../../lib/inbound-registry'
21
- import { enqueueInboundDispatch } from '../../../lib/queue'
22
11
  import { isWebhookIntegrationEnabled, WEBHOOK_INTEGRATION_DISABLED_MESSAGE } from '../../../lib/integration-state'
23
12
  import { json } from '../../helpers'
24
- import { InboundEndpointConfigEntity, WebhookIngestionEntity, WebhookInboundReceiptEntity } from '../../../data/entities'
25
-
26
- type IntegrationCredentialsService = {
27
- resolve: (
28
- integrationId: string,
29
- scope: { organizationId: string; tenantId: string },
30
- ) => Promise<Record<string, unknown> | null>
31
- }
32
-
33
- function toStringCredentials(credentials: Record<string, unknown> | null): Record<string, string> {
34
- const result: Record<string, string> = {}
35
- if (!credentials) return result
36
- for (const [key, value] of Object.entries(credentials)) {
37
- if (typeof value === 'string') result[key] = value
38
- }
39
- return result
40
- }
13
+ import { WebhookInboundReceiptEntity } from '../../../data/entities'
41
14
 
42
15
  export const metadata = {
43
16
  POST: { requireAuth: false },
@@ -53,16 +26,13 @@ const inboundResponseSchema = z.object({
53
26
  })
54
27
 
55
28
  const errorSchema = z.object({ error: z.string() })
56
- const INBOUND_TIMESTAMP_TOLERANCE_ENV = 'OM_WEBHOOKS_INBOUND_TIMESTAMP_TOLERANCE_SECONDS'
57
- const STALE_TIMESTAMP_ERROR = 'Webhook timestamp is outside the allowed replay window'
58
29
 
59
30
  export async function POST(request: Request, context: RouteContext): Promise<Response> {
60
31
  const params = await context.params
61
- const source = getWebhookSource(params.endpointId)
62
- const adapter = source ? undefined : getWebhookEndpointAdapter(params.endpointId)
32
+ const adapter = getWebhookEndpointAdapter(params.endpointId)
63
33
  const { translate } = await resolveTranslations()
64
34
 
65
- if (!source && !adapter) {
35
+ if (!adapter) {
66
36
  return json({ error: 'Webhook endpoint not found' }, { status: 404 })
67
37
  }
68
38
 
@@ -81,127 +51,8 @@ export async function POST(request: Request, context: RouteContext): Promise<Res
81
51
  if (rateLimitResponse) return rateLimitResponse
82
52
  }
83
53
 
84
- let body: string
85
- try {
86
- body = await readBoundedRequestBody(request)
87
- } catch (error) {
88
- if (error instanceof WebhookBodyTooLargeError) {
89
- return json({ error: 'Webhook payload too large' }, { status: 413 })
90
- }
91
- throw error
92
- }
54
+ const body = await request.text()
93
55
  const headers = Object.fromEntries(request.headers.entries())
94
- if (!isInboundWebhookTimestampFresh(headers)) {
95
- return json({ error: STALE_TIMESTAMP_ERROR }, { status: 400 })
96
- }
97
-
98
- if (source) {
99
- let parsedBody: Record<string, unknown> = {}
100
- try {
101
- const parsed = JSON.parse(body)
102
- if (parsed && typeof parsed === 'object') parsedBody = parsed as Record<string, unknown>
103
- } catch {
104
- parsedBody = {}
105
- }
106
- const inboundRequest: InboundWebhookRequest = { body, headers, parsedBody }
107
-
108
- const credentialsService = tryResolve<IntegrationCredentialsService>(container, 'integrationCredentialsService')
109
- const configs = await findWithDecryption(
110
- em,
111
- InboundEndpointConfigEntity,
112
- { sourceKey: params.endpointId, isActive: true },
113
- {},
114
- )
115
-
116
- let verifiedScope: { organizationId: string; tenantId: string } | null = null
117
- for (const config of configs) {
118
- const scope = { organizationId: config.organizationId, tenantId: config.tenantId }
119
- const credentials = credentialsService
120
- ? await credentialsService.resolve(`webhook_source_${params.endpointId}`, scope)
121
- : null
122
- let valid = false
123
- try {
124
- valid = await source.verifier(inboundRequest, toStringCredentials(credentials))
125
- } catch {
126
- valid = false
127
- }
128
- if (valid) {
129
- verifiedScope = scope
130
- break
131
- }
132
- }
133
-
134
- if (!verifiedScope) {
135
- return json({ error: 'Signature verification failed' }, { status: 401 })
136
- }
137
-
138
- const eventType = source.eventTypeExtractor(parsedBody, headers)
139
- const messageId = source.messageIdExtractor?.(parsedBody, headers)
140
- ?? resolveInboundReceiptMessageId({
141
- endpointId: params.endpointId,
142
- providerKey: params.endpointId,
143
- headers,
144
- body,
145
- })
146
-
147
- try {
148
- em.persist(em.create(WebhookInboundReceiptEntity, {
149
- endpointId: params.endpointId,
150
- messageId,
151
- providerKey: params.endpointId,
152
- eventType,
153
- tenantId: verifiedScope.tenantId,
154
- organizationId: verifiedScope.organizationId,
155
- createdAt: new Date(),
156
- }))
157
- await em.flush()
158
- } catch (error) {
159
- if (isUniqueViolation(error)) {
160
- return json({ ok: true, duplicate: true })
161
- }
162
- throw error
163
- }
164
-
165
- const ingestion = em.create(WebhookIngestionEntity, {
166
- sourceKey: params.endpointId,
167
- eventType,
168
- externalMessageId: messageId,
169
- payload: parsedBody,
170
- headers,
171
- status: 'received',
172
- handlerCount: 0,
173
- organizationId: verifiedScope.organizationId,
174
- tenantId: verifiedScope.tenantId,
175
- createdAt: new Date(),
176
- updatedAt: new Date(),
177
- })
178
- em.persist(ingestion)
179
- await em.flush()
180
-
181
- await enqueueInboundDispatch({
182
- ingestionId: ingestion.id,
183
- sourceKey: params.endpointId,
184
- eventType,
185
- tenantId: verifiedScope.tenantId,
186
- organizationId: verifiedScope.organizationId,
187
- })
188
-
189
- await emitWebhooksEvent('webhooks.inbound.received', {
190
- providerKey: params.endpointId,
191
- endpointId: params.endpointId,
192
- messageId,
193
- eventType,
194
- payload: parsedBody,
195
- tenantId: verifiedScope.tenantId,
196
- organizationId: verifiedScope.organizationId,
197
- }, { persistent: true })
198
-
199
- return json({ ok: true })
200
- }
201
-
202
- if (!adapter) {
203
- return json({ error: 'Webhook endpoint not found' }, { status: 404 })
204
- }
205
56
  let verified: Awaited<ReturnType<typeof adapter.verifyWebhook>>
206
57
  try {
207
58
  verified = await adapter.verifyWebhook({
@@ -275,15 +126,11 @@ export const openApi: OpenApiRouteDoc = {
275
126
  methods: {
276
127
  POST: {
277
128
  summary: 'Receive inbound webhook',
278
- description: 'The endpoint id resolves to a registered webhook source first (module-level handler dispatch), otherwise to a legacy adapter provider key.',
129
+ description: 'Endpoint ids currently resolve to registered adapter provider keys.',
279
130
  pathParams: z.object({ endpointId: z.string().min(1) }),
280
- responses: [
281
- { status: 200, description: 'Inbound webhook accepted', schema: inboundResponseSchema },
282
- { status: 413, description: 'Webhook payload too large', schema: errorSchema },
283
- ],
131
+ responses: [{ status: 200, description: 'Inbound webhook accepted', schema: inboundResponseSchema }],
284
132
  errors: [
285
- { status: 400, description: 'Verification failed or stale webhook timestamp', schema: errorSchema },
286
- { status: 401, description: 'Signature verification failed (source flow)', schema: errorSchema },
133
+ { status: 400, description: 'Verification failed', schema: errorSchema },
287
134
  { status: 404, description: 'Endpoint not found', schema: errorSchema },
288
135
  { status: 429, description: 'Rate limit exceeded', schema: errorSchema },
289
136
  { status: 503, description: 'Webhook integration disabled', schema: errorSchema },
@@ -308,24 +155,6 @@ function isUniqueViolation(error: unknown): boolean {
308
155
  return (maybeError.cause as { code?: string }).code === '23505'
309
156
  }
310
157
 
311
- function isInboundWebhookTimestampFresh(headers: Record<string, string>): boolean {
312
- const timestamps = [
313
- headers['webhook-timestamp'],
314
- headers['svix-timestamp'],
315
- ].filter((timestamp): timestamp is string => typeof timestamp === 'string')
316
-
317
- if (timestamps.length === 0) {
318
- return true
319
- }
320
-
321
- const toleranceSeconds = parseNumberWithDefault(
322
- process.env[INBOUND_TIMESTAMP_TOLERANCE_ENV],
323
- WEBHOOK_SIGNATURE_TOLERANCE_SECONDS,
324
- { integer: true, min: 0 },
325
- )
326
- return timestamps.every((timestamp) => isWebhookTimestampWithinTolerance(timestamp.trim(), toleranceSeconds))
327
- }
328
-
329
158
  type ResolveInboundReceiptMessageIdInput = {
330
159
  endpointId: string
331
160
  providerKey: string
@@ -1,6 +1,5 @@
1
1
  "use client"
2
2
  import * as React from 'react'
3
- import { extensionPoints } from '@open-mercato/webhooks/modules/webhooks/extension-points'
4
3
  import { useParams, usePathname, useRouter } from 'next/navigation'
5
4
  import { RotateCw } from 'lucide-react'
6
5
  import { Page, PageBody } from '@open-mercato/ui/backend/Page'
@@ -680,7 +679,7 @@ export default function WebhookDetailPage() {
680
679
 
681
680
  return <RowActions items={items} />
682
681
  }}
683
- perspective={{ tableId: extensionPoints.hosts.deliveriesTable.tableId }}
682
+ perspective={{ tableId: 'webhooks.deliveries' }}
684
683
  pagination={{
685
684
  page: deliveryPage,
686
685
  pageSize: 20,
@@ -1,6 +1,5 @@
1
1
  "use client"
2
2
  import * as React from 'react'
3
- import { extensionPoints } from '@open-mercato/webhooks/modules/webhooks/extension-points'
4
3
  import Link from 'next/link'
5
4
  import { useRouter } from 'next/navigation'
6
5
  import { Page, PageBody } from '@open-mercato/ui/backend/Page'
@@ -257,7 +256,7 @@ export default function WebhooksListPage() {
257
256
  setFilterValues({})
258
257
  setPage(1)
259
258
  }}
260
- perspective={{ tableId: extensionPoints.hosts.webhooksTable.tableId }}
259
+ perspective={{ tableId: 'webhooks.list' }}
261
260
  rowActions={(row) => {
262
261
  const items = [
263
262
  {
@@ -1,5 +1,4 @@
1
1
  import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
2
- import type { WebhookHandlerResult, WebhookIngestionStatus } from '@open-mercato/shared/lib/webhooks'
3
2
 
4
3
  @Entity({ tableName: 'webhooks' })
5
4
  @Index({ properties: ['organizationId', 'tenantId', 'isActive'] })
@@ -185,86 +184,3 @@ export class WebhookInboundReceiptEntity {
185
184
  @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
186
185
  createdAt: Date = new Date()
187
186
  }
188
-
189
- @Entity({ tableName: 'webhook_ingestions' })
190
- @Index({ properties: ['sourceKey', 'status', 'createdAt'] })
191
- @Index({ properties: ['organizationId', 'tenantId', 'createdAt'] })
192
- @Index({ properties: ['externalMessageId'] })
193
- export class WebhookIngestionEntity {
194
- @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
195
- id!: string
196
-
197
- @Property({ name: 'source_key', type: 'text' })
198
- sourceKey!: string
199
-
200
- @Property({ name: 'event_type', type: 'text' })
201
- eventType!: string
202
-
203
- @Property({ name: 'external_message_id', type: 'text', nullable: true })
204
- externalMessageId?: string | null
205
-
206
- @Property({ name: 'payload', type: 'json' })
207
- payload!: Record<string, unknown>
208
-
209
- @Property({ name: 'headers', type: 'json', nullable: true })
210
- headers?: Record<string, string> | null
211
-
212
- @Property({ name: 'status', type: 'text', default: 'received' })
213
- status: WebhookIngestionStatus = 'received'
214
-
215
- @Property({ name: 'error_message', type: 'text', nullable: true })
216
- errorMessage?: string | null
217
-
218
- @Property({ name: 'processed_at', type: Date, nullable: true })
219
- processedAt?: Date | null
220
-
221
- @Property({ name: 'handler_count', type: 'int', default: 0 })
222
- handlerCount: number = 0
223
-
224
- @Property({ name: 'handler_results', type: 'json', nullable: true })
225
- handlerResults?: WebhookHandlerResult[] | null
226
-
227
- @Property({ name: 'duration_ms', type: 'int', nullable: true })
228
- durationMs?: number | null
229
-
230
- @Property({ name: 'organization_id', type: 'uuid' })
231
- organizationId!: string
232
-
233
- @Property({ name: 'tenant_id', type: 'uuid' })
234
- tenantId!: string
235
-
236
- @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
237
- createdAt: Date = new Date()
238
-
239
- @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
240
- updatedAt: Date = new Date()
241
- }
242
-
243
- @Entity({ tableName: 'webhook_inbound_configs' })
244
- @Unique({ name: 'webhook_inbound_configs_source_scope_unique', properties: ['sourceKey', 'organizationId', 'tenantId'] })
245
- @Index({ properties: ['sourceKey', 'isActive'] })
246
- export class InboundEndpointConfigEntity {
247
- @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
248
- id!: string
249
-
250
- @Property({ name: 'source_key', type: 'text' })
251
- sourceKey!: string
252
-
253
- @Property({ name: 'is_active', type: 'boolean', default: true })
254
- isActive: boolean = true
255
-
256
- @Property({ name: 'integration_id', type: 'text', nullable: true })
257
- integrationId?: string | null
258
-
259
- @Property({ name: 'organization_id', type: 'uuid' })
260
- organizationId!: string
261
-
262
- @Property({ name: 'tenant_id', type: 'uuid' })
263
- tenantId!: string
264
-
265
- @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
266
- createdAt: Date = new Date()
267
-
268
- @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
269
- updatedAt: Date = new Date()
270
- }
@@ -8,13 +8,6 @@ export const defaultEncryptionMaps: ModuleEncryptionMap[] = [
8
8
  { field: 'previous_secret' },
9
9
  ],
10
10
  },
11
- {
12
- entityId: 'webhooks:webhook_ingestion_entity',
13
- fields: [
14
- { field: 'payload' },
15
- { field: 'headers' },
16
- ],
17
- },
18
11
  ]
19
12
 
20
13
  export default defaultEncryptionMaps
@@ -10,8 +10,6 @@ const events = [
10
10
  { id: 'webhooks.delivery.exhausted', label: 'Webhook Delivery Retries Exhausted', entity: 'delivery', category: 'lifecycle' as const, clientBroadcast: true },
11
11
  { id: 'webhooks.webhook.disabled', label: 'Webhook Auto-Disabled', entity: 'webhook', category: 'lifecycle' as const, clientBroadcast: true },
12
12
  { id: 'webhooks.inbound.received', label: 'Inbound Webhook Received', entity: 'inbound', category: 'custom' as const },
13
- { id: 'webhooks.inbound.processed', label: 'Inbound Webhook Processed', entity: 'inbound', category: 'lifecycle' as const },
14
- { id: 'webhooks.inbound.handler_failed', label: 'Inbound Handler Failed', entity: 'inbound', category: 'lifecycle' as const, clientBroadcast: true },
15
13
  { id: 'webhooks.secret.rotated', label: 'Webhook Secret Rotated', entity: 'webhook', category: 'lifecycle' as const },
16
14
  ] as const
17
15
 
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Name",
81
81
  "webhooks.form.namePlaceholder": "My Webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Rate Limit Per Minute",
83
- "webhooks.form.rateLimitPerMinuteHint": "Maximale Anzahl von Zustellungen pro Minute für diesen Endpunkt (0 bedeutet unbegrenzt). Der Wert wird gespeichert, aber vom Zustellungs-Worker noch nicht durchgesetzt.",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited).",
84
84
  "webhooks.form.secret": "Signing Secret",
85
85
  "webhooks.form.secretCopied": "Secret copied to clipboard.",
86
86
  "webhooks.form.secretCopy": "Copy Secret",
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Name",
81
81
  "webhooks.form.namePlaceholder": "My Webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Rate Limit Per Minute",
83
- "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited). Stored for future use — the delivery worker does not enforce it yet.",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited).",
84
84
  "webhooks.form.secret": "Signing Secret",
85
85
  "webhooks.form.secretCopied": "Secret copied to clipboard.",
86
86
  "webhooks.form.secretCopy": "Copy Secret",
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Name",
81
81
  "webhooks.form.namePlaceholder": "My Webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Rate Limit Per Minute",
83
- "webhooks.form.rateLimitPerMinuteHint": "Máximo de entregas por minuto para este endpoint (0 significa sin límite). El valor se guarda, pero el worker de entrega aún no lo aplica.",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Maximum deliveries per minute for this endpoint (0 means unlimited).",
84
84
  "webhooks.form.secret": "Signing Secret",
85
85
  "webhooks.form.secretCopied": "Secret copied to clipboard.",
86
86
  "webhooks.form.secretCopy": "Copy Secret",
@@ -80,7 +80,7 @@
80
80
  "webhooks.form.name": "Nazwa",
81
81
  "webhooks.form.namePlaceholder": "Mój webhook",
82
82
  "webhooks.form.rateLimitPerMinute": "Limit na minutę",
83
- "webhooks.form.rateLimitPerMinuteHint": "Maksymalna liczba dostaw na minutę dla tego endpointu (0 oznacza brak limitu). Wartość jest zapisywana, ale nie jest jeszcze wymuszana przy dostarczaniu.",
83
+ "webhooks.form.rateLimitPerMinuteHint": "Maksymalna liczba dostaw na minutę dla tego endpointu (0 oznacza brak limitu).",
84
84
  "webhooks.form.secret": "Sekret podpisujący",
85
85
  "webhooks.form.secretCopied": "Skopiowano sekret do schowka.",
86
86
  "webhooks.form.secretCopy": "Kopiuj sekret",