@hookflo/tern 3.0.15-beta → 4.0.0
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.
- package/dist/index.js +1 -1
- package/dist/upstash/controls.js +12 -7
- package/dist/upstash/queue.js +4 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -134,7 +134,7 @@ class WebhookVerificationService {
|
|
|
134
134
|
}
|
|
135
135
|
static resolveCanonicalEventId(platform, metadata) {
|
|
136
136
|
const rawId = this.resolveRawEventId(platform, metadata);
|
|
137
|
-
return `${platform}
|
|
137
|
+
return `${platform}_${rawId}`;
|
|
138
138
|
}
|
|
139
139
|
static resolveRawEventId(platform, metadata) {
|
|
140
140
|
const candidate = metadata?.id || metadata?.delivery || metadata?.requestId || metadata?.timestamp;
|
package/dist/upstash/controls.js
CHANGED
|
@@ -13,23 +13,28 @@ function parseBody(body) {
|
|
|
13
13
|
return JSON.parse(body);
|
|
14
14
|
}
|
|
15
15
|
catch {
|
|
16
|
-
|
|
16
|
+
try {
|
|
17
|
+
const decoded = Buffer.from(body, 'base64').toString('utf8');
|
|
18
|
+
return JSON.parse(decoded);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
24
|
}
|
|
19
25
|
return undefined;
|
|
20
26
|
}
|
|
21
27
|
function resolvePlatform(message) {
|
|
28
|
+
const headers = message.headers;
|
|
29
|
+
const headerPlatform = headers?.['x-tern-platform'] ?? headers?.['X-Tern-Platform'];
|
|
30
|
+
if (typeof headerPlatform === 'string' && headerPlatform.trim().length > 0) {
|
|
31
|
+
return headerPlatform;
|
|
32
|
+
}
|
|
22
33
|
const body = parseBody(message.body);
|
|
23
34
|
const bodyPlatform = body?.platform;
|
|
24
35
|
if (typeof bodyPlatform === 'string' && bodyPlatform.trim().length > 0) {
|
|
25
36
|
return bodyPlatform;
|
|
26
37
|
}
|
|
27
|
-
const urlGroup = message.urlGroup;
|
|
28
|
-
const endpoint = typeof urlGroup?.endpoint === 'string' ? urlGroup.endpoint : '';
|
|
29
|
-
const routePlatform = endpoint.split('/').filter(Boolean).pop();
|
|
30
|
-
if (routePlatform && routePlatform !== 'webhooks') {
|
|
31
|
-
return routePlatform;
|
|
32
|
-
}
|
|
33
38
|
return 'unknown';
|
|
34
39
|
}
|
|
35
40
|
function createHeaders(token) {
|
package/dist/upstash/queue.js
CHANGED
|
@@ -183,13 +183,16 @@ async function handleReceive(request, platform, secret, queueConfig, toleranceIn
|
|
|
183
183
|
metadata: verificationResult.metadata || {},
|
|
184
184
|
};
|
|
185
185
|
const deduplicationId = await resolveDeduplicationId(request, verificationResult);
|
|
186
|
-
if (process.env.NODE_ENV
|
|
186
|
+
if (process.env.NODE_ENV == 'production') {
|
|
187
187
|
console.log(`[tern] deduplication-id: ${deduplicationId} (platform: ${platform})`);
|
|
188
188
|
}
|
|
189
189
|
const publishPayload = {
|
|
190
190
|
url: request.url,
|
|
191
191
|
body: queuedMessage,
|
|
192
192
|
deduplicationId,
|
|
193
|
+
headers: {
|
|
194
|
+
'x-tern-platform': platform,
|
|
195
|
+
},
|
|
193
196
|
};
|
|
194
197
|
if (queueConfig.retries !== undefined) {
|
|
195
198
|
publishPayload.retries = queueConfig.retries;
|
package/package.json
CHANGED