ezlogs-nextjs 0.4.3 → 0.4.6
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/README.md +217 -86
- package/THIRD_PARTY_LICENSES.md +27 -0
- package/dist/actors/index.d.cts +1 -1
- package/dist/actors/index.d.ts +1 -1
- package/dist/{chunk-Z2TM3LGG.js → chunk-2NFJOT6Q.js} +1 -1
- package/dist/{chunk-R6IWVTX3.cjs → chunk-65HRY3PW.cjs} +31 -21
- package/dist/{chunk-YXZZNZG6.cjs → chunk-B3WST6ES.cjs} +9 -9
- package/dist/{chunk-MMLQXSSD.cjs → chunk-B5ZUQULZ.cjs} +18 -11
- package/dist/{chunk-NX4EL7BY.cjs → chunk-DM2EAOSF.cjs} +4 -4
- package/dist/chunk-DRE2VXFX.js +19 -0
- package/dist/chunk-H3FC5HMW.cjs +16 -0
- package/dist/{chunk-GI6BM4MR.js → chunk-IBSNHBUC.js} +18 -12
- package/dist/chunk-JWJKFZBW.js +52 -0
- package/dist/{chunk-MHBS5FEP.js → chunk-M3VBQ5KT.js} +27 -4
- package/dist/chunk-NFZ5OKF3.cjs +22 -0
- package/dist/{chunk-GMHOUAKD.cjs → chunk-O7SFYXJC.cjs} +37 -13
- package/dist/{chunk-U22T7QYY.js → chunk-PK2Z2ABL.js} +13 -3
- package/dist/{chunk-YMIGZYFH.js → chunk-RD47JECJ.js} +1 -1
- package/dist/chunk-RMKGMIV2.js +13 -0
- package/dist/{chunk-NINIAL7M.js → chunk-U3IJV5EJ.js} +1 -1
- package/dist/chunk-VJR4VB4B.cjs +56 -0
- package/dist/{chunk-PS4U2GFJ.cjs → chunk-YO6E763S.cjs} +5 -5
- package/dist/{configuration-CJ5yKVlP.d.cts → configuration-b9pImwFB.d.cts} +2 -2
- package/dist/{configuration-CJ5yKVlP.d.ts → configuration-b9pImwFB.d.ts} +2 -2
- package/dist/db/drizzle.cjs +3 -3
- package/dist/db/drizzle.js +2 -2
- package/dist/db/postgres-js.cjs +4 -4
- package/dist/db/postgres-js.js +2 -2
- package/dist/db/prisma.cjs +12 -12
- package/dist/db/prisma.js +2 -2
- package/dist/db/supabase.cjs +42 -17
- package/dist/db/supabase.d.cts +11 -5
- package/dist/db/supabase.d.ts +11 -5
- package/dist/db/supabase.js +33 -9
- package/dist/index.cjs +288 -142
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +198 -52
- package/dist/jobs/bullmq.cjs +44 -16
- package/dist/jobs/bullmq.d.cts +7 -1
- package/dist/jobs/bullmq.d.ts +7 -1
- package/dist/jobs/bullmq.js +33 -6
- package/dist/jobs/inngest.cjs +36 -17
- package/dist/jobs/inngest.d.cts +7 -1
- package/dist/jobs/inngest.d.ts +7 -1
- package/dist/jobs/inngest.js +23 -5
- package/dist/jobs/supabase-queues.cjs +9 -9
- package/dist/jobs/supabase-queues.js +4 -4
- package/dist/jobs/trigger.cjs +7 -7
- package/dist/jobs/trigger.js +4 -4
- package/dist/jobs/upstash-workflow.cjs +139 -23
- package/dist/jobs/upstash-workflow.d.cts +20 -2
- package/dist/jobs/upstash-workflow.d.ts +20 -2
- package/dist/jobs/upstash-workflow.js +129 -14
- package/dist/nextjs-plugin/index.cjs +46 -29
- package/dist/nextjs-plugin/index.js +46 -29
- package/dist/nextjs-plugin/loader.cjs +70 -60
- package/dist/nextjs-plugin/loader.d.cts +18 -1
- package/dist/nextjs-plugin/loader.d.ts +18 -1
- package/dist/nextjs-plugin/loader.js +70 -61
- package/dist/triggers/index.cjs +22 -16
- package/dist/triggers/index.d.cts +0 -10
- package/dist/triggers/index.d.ts +0 -10
- package/dist/triggers/index.js +11 -5
- package/package.json +6 -5
- package/sql/postgres/00_install.sql +20 -3
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkDM2EAOSF_cjs = require('./chunk-DM2EAOSF.cjs');
|
|
4
|
+
var chunkH3FC5HMW_cjs = require('./chunk-H3FC5HMW.cjs');
|
|
5
|
+
var chunkO7SFYXJC_cjs = require('./chunk-O7SFYXJC.cjs');
|
|
6
|
+
var chunkB3WST6ES_cjs = require('./chunk-B3WST6ES.cjs');
|
|
7
|
+
var chunkB5ZUQULZ_cjs = require('./chunk-B5ZUQULZ.cjs');
|
|
7
8
|
var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
|
|
8
9
|
require('./chunk-ZDSQYCYV.cjs');
|
|
9
10
|
|
|
@@ -12,7 +13,7 @@ var REQUEST_TIMEOUT_MS = 1e4;
|
|
|
12
13
|
var transport = {
|
|
13
14
|
async send(events) {
|
|
14
15
|
if (!events || events.length === 0) return "success";
|
|
15
|
-
const config =
|
|
16
|
+
const config = chunkB5ZUQULZ_cjs.configuration();
|
|
16
17
|
const serverUrl = config.serverUrl;
|
|
17
18
|
if (!serverUrl) {
|
|
18
19
|
chunkTWTG5ILJ_cjs.logger.error("Transport: serverUrl not configured");
|
|
@@ -104,7 +105,7 @@ function applyJitter(base) {
|
|
|
104
105
|
}
|
|
105
106
|
function retryAttempts() {
|
|
106
107
|
try {
|
|
107
|
-
const value =
|
|
108
|
+
const value = chunkB5ZUQULZ_cjs.configuration().retryAttempts;
|
|
108
109
|
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
109
110
|
return 3;
|
|
110
111
|
}
|
|
@@ -142,6 +143,7 @@ var flushScheduler = {
|
|
|
142
143
|
},
|
|
143
144
|
async stop() {
|
|
144
145
|
const s = state();
|
|
146
|
+
await chunkO7SFYXJC_cjs.settleAuditFlushes();
|
|
145
147
|
if (s.timer === null) return;
|
|
146
148
|
clearInterval(s.timer);
|
|
147
149
|
s.timer = null;
|
|
@@ -160,17 +162,20 @@ var flushScheduler = {
|
|
|
160
162
|
* builds a queue.
|
|
161
163
|
*/
|
|
162
164
|
flushNow() {
|
|
163
|
-
|
|
164
|
-
if (!s.inFlight || !s.current) return tick();
|
|
165
|
-
if (!s.followUp) {
|
|
166
|
-
s.followUp = s.current.then(() => {
|
|
167
|
-
s.followUp = null;
|
|
168
|
-
return tick();
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
return s.followUp;
|
|
165
|
+
return chunkO7SFYXJC_cjs.settleAuditFlushes().then(() => sendNow());
|
|
172
166
|
}
|
|
173
167
|
};
|
|
168
|
+
function sendNow() {
|
|
169
|
+
const s = state();
|
|
170
|
+
if (!s.inFlight || !s.current) return tick();
|
|
171
|
+
if (!s.followUp) {
|
|
172
|
+
s.followUp = s.current.then(() => {
|
|
173
|
+
s.followUp = null;
|
|
174
|
+
return tick();
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return s.followUp;
|
|
178
|
+
}
|
|
174
179
|
function tick() {
|
|
175
180
|
const s = state();
|
|
176
181
|
if (s.inFlight && s.current) return s.current;
|
|
@@ -183,12 +188,12 @@ function tick() {
|
|
|
183
188
|
}
|
|
184
189
|
async function runTick() {
|
|
185
190
|
try {
|
|
186
|
-
const events =
|
|
191
|
+
const events = chunkB3WST6ES_cjs.drainEvents();
|
|
187
192
|
if (events.length > 0) await retrySender.send(events);
|
|
188
|
-
const reader =
|
|
193
|
+
const reader = chunkB5ZUQULZ_cjs.configuration().databaseReader;
|
|
189
194
|
if (!reader) return;
|
|
190
|
-
await
|
|
191
|
-
const swept =
|
|
195
|
+
await chunkO7SFYXJC_cjs.maintainAuditLogAfterRequests(reader);
|
|
196
|
+
const swept = chunkB3WST6ES_cjs.drainEvents();
|
|
192
197
|
if (swept.length > 0) await retrySender.send(swept);
|
|
193
198
|
} catch (error) {
|
|
194
199
|
chunkTWTG5ILJ_cjs.logger.error(`FlushScheduler tick failed: ${describeError3(error)}`);
|
|
@@ -196,7 +201,7 @@ async function runTick() {
|
|
|
196
201
|
}
|
|
197
202
|
function sendInterval() {
|
|
198
203
|
try {
|
|
199
|
-
const value =
|
|
204
|
+
const value = chunkB5ZUQULZ_cjs.configuration().sendInterval;
|
|
200
205
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
201
206
|
return 5e3;
|
|
202
207
|
}
|
|
@@ -219,7 +224,7 @@ function patchGlobalFetch() {
|
|
|
219
224
|
if (typeof globalThis.fetch !== "function") return;
|
|
220
225
|
originalFetch = globalThis.fetch;
|
|
221
226
|
const wrapped = (input, init) => {
|
|
222
|
-
const id =
|
|
227
|
+
const id = chunkB5ZUQULZ_cjs.current();
|
|
223
228
|
if (!id) return originalFetch.call(globalThis, input, init);
|
|
224
229
|
try {
|
|
225
230
|
const enriched = injectHeader(input, init, id);
|
|
@@ -231,12 +236,50 @@ function patchGlobalFetch() {
|
|
|
231
236
|
};
|
|
232
237
|
globalThis.fetch = wrapped;
|
|
233
238
|
patched = true;
|
|
239
|
+
subscribeUndiciRequests();
|
|
240
|
+
}
|
|
241
|
+
var subscribed = false;
|
|
242
|
+
function subscribeUndiciRequests() {
|
|
243
|
+
if (subscribed) return;
|
|
244
|
+
const channel = loadDiagnosticsChannel();
|
|
245
|
+
if (!channel) return;
|
|
246
|
+
channel.subscribe("undici:request:create", onUndiciRequest);
|
|
247
|
+
subscribed = true;
|
|
248
|
+
}
|
|
249
|
+
function onUndiciRequest(message) {
|
|
250
|
+
try {
|
|
251
|
+
const request = message?.request;
|
|
252
|
+
if (!request || typeof request.addHeader !== "function") return;
|
|
253
|
+
const id = chunkB5ZUQULZ_cjs.current();
|
|
254
|
+
if (!id || hasCorrelationHeader(request.headers)) return;
|
|
255
|
+
request.addHeader(HEADER, id);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
chunkTWTG5ILJ_cjs.logger.debug(`outgoing request header injection failed: ${describeError4(error)}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function hasCorrelationHeader(headers) {
|
|
261
|
+
if (Array.isArray(headers)) {
|
|
262
|
+
for (let i = 0; i < headers.length; i += 2) {
|
|
263
|
+
if (String(headers[i]).toLowerCase() === HEADER) return true;
|
|
264
|
+
}
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
if (typeof headers === "string") return headers.toLowerCase().includes(`${HEADER}:`);
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
function loadDiagnosticsChannel() {
|
|
271
|
+
const mod = chunkB5ZUQULZ_cjs.loadNodeBuiltin(["diagnostics", "channel"].join("_"));
|
|
272
|
+
return typeof mod?.subscribe === "function" ? mod : null;
|
|
234
273
|
}
|
|
235
274
|
function unpatchGlobalFetch() {
|
|
236
275
|
if (!patched || originalFetch === null) return;
|
|
237
276
|
globalThis.fetch = originalFetch;
|
|
238
277
|
originalFetch = null;
|
|
239
278
|
patched = false;
|
|
279
|
+
if (subscribed) {
|
|
280
|
+
loadDiagnosticsChannel()?.unsubscribe("undici:request:create", onUndiciRequest);
|
|
281
|
+
subscribed = false;
|
|
282
|
+
}
|
|
240
283
|
}
|
|
241
284
|
function injectHeader(input, init, correlationId) {
|
|
242
285
|
if (input instanceof Request && !init) {
|
|
@@ -355,7 +398,7 @@ function buildHttpSourceData(input) {
|
|
|
355
398
|
source.graphql_variables = input.graphql.graphql_variables;
|
|
356
399
|
}
|
|
357
400
|
} else {
|
|
358
|
-
const params =
|
|
401
|
+
const params = chunkB3WST6ES_cjs.sanitizeRequestParams(input.rawParams, input.excludedVariableKeys);
|
|
359
402
|
if (params !== null) source.request_params = params;
|
|
360
403
|
}
|
|
361
404
|
return compact(source);
|
|
@@ -455,11 +498,38 @@ function parseServerActionName(name) {
|
|
|
455
498
|
}
|
|
456
499
|
const canonical = KNOWN_VERBS.get(leading);
|
|
457
500
|
if (!canonical) return { verb: null, entity: null };
|
|
458
|
-
|
|
501
|
+
let rest = tokens.slice(entityStart);
|
|
502
|
+
const isConnector = (t) => CONNECTORS.has(t.toLowerCase());
|
|
503
|
+
if (rest.length > 0 && COMPOUND.has(rest[0].toLowerCase())) {
|
|
504
|
+
rest = rest.slice(2);
|
|
505
|
+
if (rest.length > 0 && isConnector(rest[0])) {
|
|
506
|
+
rest = rest.slice(rest.map(isConnector).lastIndexOf(true) + 1);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const firstConnector = rest.findIndex(isConnector);
|
|
510
|
+
const entityTokens = firstConnector === -1 ? rest : rest.slice(0, firstConnector);
|
|
459
511
|
if (entityTokens.length === 0) return { verb: canonical, entity: null };
|
|
460
512
|
const entity = entityTokens.join("");
|
|
461
513
|
return { verb: canonical, entity: stripTrailingS(entity) || entity };
|
|
462
514
|
}
|
|
515
|
+
var COMPOUND = /* @__PURE__ */ new Set(["and", "or", "then"]);
|
|
516
|
+
var CONNECTORS = /* @__PURE__ */ new Set([
|
|
517
|
+
...COMPOUND,
|
|
518
|
+
"to",
|
|
519
|
+
"with",
|
|
520
|
+
"without",
|
|
521
|
+
"for",
|
|
522
|
+
"from",
|
|
523
|
+
"by",
|
|
524
|
+
"in",
|
|
525
|
+
"into",
|
|
526
|
+
"on",
|
|
527
|
+
"of",
|
|
528
|
+
"via",
|
|
529
|
+
"using",
|
|
530
|
+
"as",
|
|
531
|
+
"at"
|
|
532
|
+
]);
|
|
463
533
|
function stripTrailingS(entity) {
|
|
464
534
|
if (entity.length <= 1) return entity;
|
|
465
535
|
if (entity.endsWith("ies")) return `${entity.slice(0, -3)}y`;
|
|
@@ -505,7 +575,7 @@ function determineOutcome(statusCode, exception, graphqlResponseErrors, response
|
|
|
505
575
|
}
|
|
506
576
|
var MAX_SPECIFIC_ERROR_LENGTH = 200;
|
|
507
577
|
function capErrorText(text) {
|
|
508
|
-
const out =
|
|
578
|
+
const out = chunkB3WST6ES_cjs.scrubSecretsInText(text, { emails: true });
|
|
509
579
|
return out.length <= MAX_SPECIFIC_ERROR_LENGTH ? out : `${out.slice(0, MAX_SPECIFIC_ERROR_LENGTH - 1)}\u2026`;
|
|
510
580
|
}
|
|
511
581
|
var GENERIC_ERROR_TEXT = /^(?:validation(?: error| failed)?|invalid (?:input|request|data|body|payload|params|parameters|arguments)|bad request|unprocessable(?: entity| content)?|error|failed|request failed)[.!]?$/i;
|
|
@@ -543,9 +613,9 @@ function fieldMessage(path, message, userPatterns) {
|
|
|
543
613
|
const text = message?.replace(/\s+/g, " ").trim().replace(/received\s+("[^"]*"|'[^']*'|`[^`]*`)/gi, "received [FILTERED]");
|
|
544
614
|
if (!text) return null;
|
|
545
615
|
const keys = path.filter((k) => k !== null && k !== "");
|
|
546
|
-
if (keys.some((k) =>
|
|
616
|
+
if (keys.some((k) => chunkB3WST6ES_cjs.isSensitiveKey(k, userPatterns))) return null;
|
|
547
617
|
if (keys.length > 0) return `${keys.join(".")}: ${text}`;
|
|
548
|
-
return text.split(/[^A-Za-z0-9_]+/).some((w) => w !== "" &&
|
|
618
|
+
return text.split(/[^A-Za-z0-9_]+/).some((w) => w !== "" && chunkB3WST6ES_cjs.isSensitiveKey(w, userPatterns)) ? null : text;
|
|
549
619
|
}
|
|
550
620
|
function pathKey(segment) {
|
|
551
621
|
if (typeof segment === "string") return segment;
|
|
@@ -726,7 +796,7 @@ function parseGraphqlBody(body, excludedOperations, excludedVariableKeys) {
|
|
|
726
796
|
return { metadata: "skip" };
|
|
727
797
|
}
|
|
728
798
|
const operationType = inferOperationTypeFromQuery(queryString) ?? inferOperationTypeFromName(operationName);
|
|
729
|
-
const sanitizedVariables =
|
|
799
|
+
const sanitizedVariables = chunkB3WST6ES_cjs.sanitizeRequestParams(obj.variables, excludedVariableKeys);
|
|
730
800
|
return {
|
|
731
801
|
metadata: {
|
|
732
802
|
graphql_operation: operationName ?? "anonymous",
|
|
@@ -784,7 +854,7 @@ function captureRoute(handler, context = {}) {
|
|
|
784
854
|
return handler(...invokeArgs);
|
|
785
855
|
};
|
|
786
856
|
try {
|
|
787
|
-
if (!
|
|
857
|
+
if (!chunkB5ZUQULZ_cjs.configuration().captureHttp) {
|
|
788
858
|
return Promise.resolve(runHandler(...args));
|
|
789
859
|
}
|
|
790
860
|
const request = args[0];
|
|
@@ -794,10 +864,11 @@ function captureRoute(handler, context = {}) {
|
|
|
794
864
|
const snapshot = await snapshotRequest(request);
|
|
795
865
|
if (snapshot === null) return Promise.resolve(runHandler(...args));
|
|
796
866
|
snapshot.rawParams = mergeRouteParams(snapshot.rawParams, await readRouteParams(args[1]));
|
|
797
|
-
const correlationId =
|
|
798
|
-
|
|
867
|
+
const correlationId = chunkB5ZUQULZ_cjs.resolveCorrelation(request.headers ?? null);
|
|
868
|
+
const delivery = { jobDelivery: false };
|
|
869
|
+
return await chunkB5ZUQULZ_cjs.runWithCorrelation(
|
|
799
870
|
correlationId,
|
|
800
|
-
() => runWithActorAndAuditScope(async () => {
|
|
871
|
+
() => chunkH3FC5HMW_cjs.runWithDeliverySlot(delivery, () => runWithActorAndAuditScope(async () => {
|
|
801
872
|
await maybeRunActorHook(request);
|
|
802
873
|
const startMs = Date.now();
|
|
803
874
|
let statusCode = null;
|
|
@@ -808,7 +879,7 @@ function captureRoute(handler, context = {}) {
|
|
|
808
879
|
let followed = false;
|
|
809
880
|
let handlerMs = null;
|
|
810
881
|
const finish = async () => {
|
|
811
|
-
await
|
|
882
|
+
await chunkB5ZUQULZ_cjs.maybeExtractSupabaseActor();
|
|
812
883
|
await emitEvent({
|
|
813
884
|
snapshot,
|
|
814
885
|
context,
|
|
@@ -817,10 +888,11 @@ function captureRoute(handler, context = {}) {
|
|
|
817
888
|
graphqlErrorMessage,
|
|
818
889
|
responseErrorMessage,
|
|
819
890
|
durationMs: handlerMs ?? Date.now() - startMs,
|
|
820
|
-
startedAt: new Date(startMs)
|
|
891
|
+
startedAt: new Date(startMs),
|
|
892
|
+
jobDelivery: delivery.jobDelivery
|
|
821
893
|
});
|
|
822
894
|
await flushOnServerless();
|
|
823
|
-
|
|
895
|
+
chunkB5ZUQULZ_cjs.endCorrelationScope();
|
|
824
896
|
};
|
|
825
897
|
try {
|
|
826
898
|
response = await Promise.resolve(runHandler(...args));
|
|
@@ -830,8 +902,8 @@ function captureRoute(handler, context = {}) {
|
|
|
830
902
|
graphqlErrorMessage = await readGraphqlErrors(response);
|
|
831
903
|
}
|
|
832
904
|
const trpcRoute = isTrpcRoute(snapshot.rawParams, context.routeModulePath ?? null);
|
|
833
|
-
responseErrorMessage = await readResponseErrorMessage(response, trpcRoute);
|
|
834
|
-
const trpcStream = responseErrorMessage === null && trpcRoute ? trpcStreamErrorScanner(
|
|
905
|
+
responseErrorMessage = await readResponseErrorMessage(response, trpcRoute) ?? authRedirectError(snapshot.url, response.status, response.headers.get("location"));
|
|
906
|
+
const trpcStream = responseErrorMessage === null && trpcRoute ? trpcStreamErrorScanner(chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys) : null;
|
|
835
907
|
const followedResponse = followBody(
|
|
836
908
|
response,
|
|
837
909
|
snapshot.method,
|
|
@@ -857,9 +929,12 @@ function captureRoute(handler, context = {}) {
|
|
|
857
929
|
statusCode = 500;
|
|
858
930
|
throw e;
|
|
859
931
|
} finally {
|
|
860
|
-
if (!followed)
|
|
932
|
+
if (!followed) {
|
|
933
|
+
await chunkB5ZUQULZ_cjs.maybeExtractSupabaseActor();
|
|
934
|
+
await offTheResponse(finish);
|
|
935
|
+
}
|
|
861
936
|
}
|
|
862
|
-
})
|
|
937
|
+
}))
|
|
863
938
|
);
|
|
864
939
|
} catch (preCaptureError) {
|
|
865
940
|
if (handlerInvoked) throw preCaptureError;
|
|
@@ -879,12 +954,12 @@ function withMiddlewareCapture(middleware) {
|
|
|
879
954
|
return middleware(req, ...mRest);
|
|
880
955
|
};
|
|
881
956
|
try {
|
|
882
|
-
const correlationId =
|
|
957
|
+
const correlationId = chunkB5ZUQULZ_cjs.resolveCorrelation(request.headers);
|
|
883
958
|
try {
|
|
884
959
|
request.headers.set(CORRELATION_HEADER, correlationId);
|
|
885
960
|
} catch {
|
|
886
961
|
}
|
|
887
|
-
return await
|
|
962
|
+
return await chunkB5ZUQULZ_cjs.runWithCorrelation(
|
|
888
963
|
correlationId,
|
|
889
964
|
() => runWithActorAndAuditScope(async () => {
|
|
890
965
|
const startMs = Date.now();
|
|
@@ -898,20 +973,27 @@ function withMiddlewareCapture(middleware) {
|
|
|
898
973
|
}
|
|
899
974
|
try {
|
|
900
975
|
if (shouldEmitPageNavigation(request)) {
|
|
976
|
+
const durationMs = Date.now() - startMs;
|
|
901
977
|
await maybeRunActorHook(request);
|
|
902
|
-
await
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
978
|
+
await chunkB5ZUQULZ_cjs.maybeExtractSupabaseActor();
|
|
979
|
+
const event = rest[0];
|
|
980
|
+
await offTheResponse(
|
|
981
|
+
async () => {
|
|
982
|
+
await emitPageNavigationEvent({
|
|
983
|
+
request,
|
|
984
|
+
statusCode: typeof response?.status === "number" ? response.status : null,
|
|
985
|
+
durationMs,
|
|
986
|
+
startedAt
|
|
987
|
+
});
|
|
988
|
+
},
|
|
989
|
+
typeof event?.waitUntil === "function" ? event.waitUntil.bind(event) : null
|
|
990
|
+
);
|
|
909
991
|
}
|
|
910
992
|
} catch (error) {
|
|
911
993
|
chunkTWTG5ILJ_cjs.logger.debug(`page navigation capture failed: ${describeError5(error)}`);
|
|
912
994
|
}
|
|
913
995
|
return response;
|
|
914
|
-
}).finally(
|
|
996
|
+
}).finally(chunkB5ZUQULZ_cjs.endCorrelationScope)
|
|
915
997
|
);
|
|
916
998
|
} catch (preCaptureError) {
|
|
917
999
|
if (middlewareInvoked) throw preCaptureError;
|
|
@@ -972,25 +1054,25 @@ async function emitPageNavigationEvent(input) {
|
|
|
972
1054
|
userAgent,
|
|
973
1055
|
remoteIp,
|
|
974
1056
|
contentType: null,
|
|
975
|
-
excludedVariableKeys:
|
|
1057
|
+
excludedVariableKeys: chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys
|
|
976
1058
|
});
|
|
977
1059
|
const { outcome, error_message } = determineOutcome(
|
|
978
1060
|
input.statusCode,
|
|
979
1061
|
null,
|
|
980
1062
|
null
|
|
981
1063
|
);
|
|
982
|
-
const event =
|
|
1064
|
+
const event = chunkB3WST6ES_cjs.build({
|
|
983
1065
|
source_type: "http_request",
|
|
984
1066
|
source_data: sourceData,
|
|
985
1067
|
outcome,
|
|
986
|
-
correlation_id:
|
|
1068
|
+
correlation_id: chunkB5ZUQULZ_cjs.current(),
|
|
987
1069
|
resource_ids: [],
|
|
988
|
-
context:
|
|
1070
|
+
context: chunkB5ZUQULZ_cjs.getCurrentActor() ? { actor: chunkB5ZUQULZ_cjs.getCurrentActor() } : null,
|
|
989
1071
|
duration_ms: input.durationMs,
|
|
990
1072
|
error_message,
|
|
991
1073
|
timestamp: input.startedAt
|
|
992
1074
|
});
|
|
993
|
-
|
|
1075
|
+
chunkB3WST6ES_cjs.pushEvent(event);
|
|
994
1076
|
} catch (error) {
|
|
995
1077
|
chunkTWTG5ILJ_cjs.logger.error(`page navigation emit failed: ${describeError5(error)}`);
|
|
996
1078
|
}
|
|
@@ -1015,7 +1097,7 @@ function capturePagesApi(handler, context = {}) {
|
|
|
1015
1097
|
return handler(...invokeArgs);
|
|
1016
1098
|
};
|
|
1017
1099
|
try {
|
|
1018
|
-
if (!
|
|
1100
|
+
if (!chunkB5ZUQULZ_cjs.configuration().captureHttp) {
|
|
1019
1101
|
return Promise.resolve(runHandler(...args));
|
|
1020
1102
|
}
|
|
1021
1103
|
const req = args[0];
|
|
@@ -1023,12 +1105,13 @@ function capturePagesApi(handler, context = {}) {
|
|
|
1023
1105
|
if (!req || !res) return Promise.resolve(runHandler(...args));
|
|
1024
1106
|
const snapshot = snapshotPagesRequest(req);
|
|
1025
1107
|
if (snapshot === null) return Promise.resolve(runHandler(...args));
|
|
1026
|
-
const correlationId =
|
|
1108
|
+
const correlationId = chunkB5ZUQULZ_cjs.resolveCorrelation({
|
|
1027
1109
|
get: (name) => readPagesHeader(req, name)
|
|
1028
1110
|
});
|
|
1029
|
-
|
|
1111
|
+
const delivery = { jobDelivery: false };
|
|
1112
|
+
return await chunkB5ZUQULZ_cjs.runWithCorrelation(
|
|
1030
1113
|
correlationId,
|
|
1031
|
-
() => runWithActorAndAuditScope(async () => {
|
|
1114
|
+
() => chunkH3FC5HMW_cjs.runWithDeliverySlot(delivery, () => runWithActorAndAuditScope(async () => {
|
|
1032
1115
|
await maybeRunActorHookFromPages(req);
|
|
1033
1116
|
const startMs = Date.now();
|
|
1034
1117
|
let exception = null;
|
|
@@ -1039,20 +1122,29 @@ function capturePagesApi(handler, context = {}) {
|
|
|
1039
1122
|
exception = e instanceof Error ? e : new Error(String(e));
|
|
1040
1123
|
throw e;
|
|
1041
1124
|
} finally {
|
|
1042
|
-
await
|
|
1125
|
+
await chunkB5ZUQULZ_cjs.maybeExtractSupabaseActor();
|
|
1126
|
+
const status = typeof res.statusCode === "number" ? res.statusCode : null;
|
|
1127
|
+
const getHeader = res.getHeader;
|
|
1043
1128
|
await emitEvent({
|
|
1044
1129
|
snapshot,
|
|
1045
1130
|
context,
|
|
1046
|
-
statusCode:
|
|
1131
|
+
statusCode: status,
|
|
1047
1132
|
exception,
|
|
1048
1133
|
graphqlErrorMessage: null,
|
|
1134
|
+
// NextAuth v4 under pages/api/auth: a failed sign-in redirects to ?error=.
|
|
1135
|
+
responseErrorMessage: authRedirectError(
|
|
1136
|
+
snapshot.url,
|
|
1137
|
+
status,
|
|
1138
|
+
typeof getHeader === "function" ? getHeader.call(res, "location") : null
|
|
1139
|
+
),
|
|
1049
1140
|
durationMs: Date.now() - startMs,
|
|
1050
|
-
startedAt: new Date(startMs)
|
|
1141
|
+
startedAt: new Date(startMs),
|
|
1142
|
+
jobDelivery: delivery.jobDelivery
|
|
1051
1143
|
});
|
|
1052
1144
|
await flushOnServerless();
|
|
1053
|
-
|
|
1145
|
+
chunkB5ZUQULZ_cjs.endCorrelationScope();
|
|
1054
1146
|
}
|
|
1055
|
-
})
|
|
1147
|
+
}))
|
|
1056
1148
|
);
|
|
1057
1149
|
} catch (preCaptureError) {
|
|
1058
1150
|
if (handlerInvoked) throw preCaptureError;
|
|
@@ -1071,39 +1163,33 @@ function captureServerAction(action, actionName) {
|
|
|
1071
1163
|
return action(...invokeArgs);
|
|
1072
1164
|
};
|
|
1073
1165
|
try {
|
|
1074
|
-
if (!
|
|
1166
|
+
if (!chunkB5ZUQULZ_cjs.configuration().captureHttp) {
|
|
1075
1167
|
return Promise.resolve(runAction(...args));
|
|
1076
1168
|
}
|
|
1077
1169
|
const headersAdapter = await readNextHeadersAsAdapter();
|
|
1078
|
-
const correlationId =
|
|
1079
|
-
return await
|
|
1170
|
+
const correlationId = chunkB5ZUQULZ_cjs.resolveCorrelation(headersAdapter);
|
|
1171
|
+
return await chunkB5ZUQULZ_cjs.runWithCorrelation(
|
|
1080
1172
|
correlationId,
|
|
1081
1173
|
() => runWithActorAndAuditScope(async () => {
|
|
1082
1174
|
const startMs = Date.now();
|
|
1083
1175
|
const startedAt = new Date(startMs);
|
|
1084
1176
|
let exception = null;
|
|
1085
1177
|
await maybeRunActorHookFromServerAction();
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
await
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
// A returned failure (`{ success: false, error }`) is a
|
|
1093
|
-
// handled refusal, not a crash: no HTTP status is
|
|
1094
|
-
// invented; outcome + error_message carry it.
|
|
1095
|
-
statusCode: failure ? null : 200,
|
|
1096
|
-
exception: failure ? new Error(failure.errorMessage) : null,
|
|
1097
|
-
durationMs: Date.now() - startMs,
|
|
1098
|
-
startedAt,
|
|
1099
|
-
args
|
|
1178
|
+
const record = async (input) => {
|
|
1179
|
+
await chunkB5ZUQULZ_cjs.maybeExtractSupabaseActor();
|
|
1180
|
+
await offTheResponse(async () => {
|
|
1181
|
+
await emitServerActionEvent(input);
|
|
1182
|
+
await flushOnServerless();
|
|
1183
|
+
chunkB5ZUQULZ_cjs.endCorrelationScope();
|
|
1100
1184
|
});
|
|
1101
|
-
|
|
1185
|
+
};
|
|
1186
|
+
let result;
|
|
1187
|
+
try {
|
|
1188
|
+
result = await Promise.resolve(runAction(...args));
|
|
1102
1189
|
} catch (e) {
|
|
1103
1190
|
if (isNextControlFlowError(e)) {
|
|
1104
|
-
await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
|
|
1105
1191
|
const controlStatus = nextControlFlowStatus(e) ?? 200;
|
|
1106
|
-
await
|
|
1192
|
+
await record({
|
|
1107
1193
|
actionName,
|
|
1108
1194
|
// redirect() is a success; notFound() / forbidden()
|
|
1109
1195
|
// keep their 4xx.
|
|
@@ -1117,8 +1203,7 @@ function captureServerAction(action, actionName) {
|
|
|
1117
1203
|
throw e;
|
|
1118
1204
|
}
|
|
1119
1205
|
exception = e instanceof Error ? e : new Error(String(e));
|
|
1120
|
-
await
|
|
1121
|
-
await emitServerActionEvent({
|
|
1206
|
+
await record({
|
|
1122
1207
|
actionName,
|
|
1123
1208
|
statusCode: 500,
|
|
1124
1209
|
exception,
|
|
@@ -1127,10 +1212,25 @@ function captureServerAction(action, actionName) {
|
|
|
1127
1212
|
args
|
|
1128
1213
|
});
|
|
1129
1214
|
throw e;
|
|
1130
|
-
} finally {
|
|
1131
|
-
await flushOnServerless();
|
|
1132
|
-
chunkMMLQXSSD_cjs.endCorrelationScope();
|
|
1133
1215
|
}
|
|
1216
|
+
let failure = null;
|
|
1217
|
+
try {
|
|
1218
|
+
failure = classifyServerActionResult(result);
|
|
1219
|
+
} catch (e) {
|
|
1220
|
+
chunkTWTG5ILJ_cjs.logger.debug(`server action result classification failed: ${describeError5(e)}`);
|
|
1221
|
+
}
|
|
1222
|
+
await record({
|
|
1223
|
+
actionName,
|
|
1224
|
+
// A returned failure (`{ success: false, error }`) is a
|
|
1225
|
+
// handled refusal, not a crash: no HTTP status is
|
|
1226
|
+
// invented; outcome + error_message carry it.
|
|
1227
|
+
statusCode: failure ? null : 200,
|
|
1228
|
+
exception: failure ? new Error(failure.errorMessage) : null,
|
|
1229
|
+
durationMs: Date.now() - startMs,
|
|
1230
|
+
startedAt,
|
|
1231
|
+
args
|
|
1232
|
+
});
|
|
1233
|
+
return result;
|
|
1134
1234
|
})
|
|
1135
1235
|
);
|
|
1136
1236
|
} catch (preCaptureError) {
|
|
@@ -1157,7 +1257,7 @@ async function __ezlogs_run_inline_server_action(actionName, body) {
|
|
|
1157
1257
|
return wrapped();
|
|
1158
1258
|
}
|
|
1159
1259
|
function classifyServerActionResult(result) {
|
|
1160
|
-
const classifier =
|
|
1260
|
+
const classifier = chunkB5ZUQULZ_cjs.configuration().isServerActionError;
|
|
1161
1261
|
if (classifier) {
|
|
1162
1262
|
try {
|
|
1163
1263
|
const verdict = classifier(result);
|
|
@@ -1233,7 +1333,7 @@ function hasErrorEntries(errors, depth = 0) {
|
|
|
1233
1333
|
return Object.values(errors).some((v) => hasErrorEntries(v, depth + 1));
|
|
1234
1334
|
}
|
|
1235
1335
|
function formStateErrorMessage(r) {
|
|
1236
|
-
const patterns =
|
|
1336
|
+
const patterns = chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys;
|
|
1237
1337
|
const specific = Array.isArray(r.errors) ? specificErrorMessage({ errors: r.errors }, patterns) ?? specificErrorMessage({ formErrors: r.errors }, patterns) : specificErrorMessage({ fieldErrors: r.errors }, patterns);
|
|
1238
1338
|
if (specific) return capErrorText(specific);
|
|
1239
1339
|
if (typeof r.message === "string" && r.message.trim().length > 0) {
|
|
@@ -1261,7 +1361,7 @@ function defaultErrorMessage(result) {
|
|
|
1261
1361
|
}
|
|
1262
1362
|
var MAX_ERROR_MESSAGE_LENGTH = 200;
|
|
1263
1363
|
function specificOrOwn(result, error) {
|
|
1264
|
-
const specific = isGenericErrorText(error) ? specificErrorMessage(result,
|
|
1364
|
+
const specific = isGenericErrorText(error) ? specificErrorMessage(result, chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys) : null;
|
|
1265
1365
|
return capErrorText(specific ?? error);
|
|
1266
1366
|
}
|
|
1267
1367
|
function truncate(value) {
|
|
@@ -1279,7 +1379,7 @@ function isZodErrorLike(value) {
|
|
|
1279
1379
|
return Array.isArray(issues) && issues.length > 0;
|
|
1280
1380
|
}
|
|
1281
1381
|
function formatZodIssues(issues) {
|
|
1282
|
-
const patterns =
|
|
1382
|
+
const patterns = chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys;
|
|
1283
1383
|
const messages = [];
|
|
1284
1384
|
for (const issue of issues) {
|
|
1285
1385
|
const m = issueMessage(issue, patterns);
|
|
@@ -1368,7 +1468,7 @@ function redirectPath(target, requestHost) {
|
|
|
1368
1468
|
const url = new URL(target, "http://ezlogs.internal");
|
|
1369
1469
|
if (absolute && (!requestHost || url.host.toLowerCase() !== requestHost.toLowerCase())) return null;
|
|
1370
1470
|
const path = url.pathname.split("/").map((seg) => /^[A-Za-z0-9_-]{20,}$/.test(seg) && !UUID.test(seg) ? "[FILTERED]" : seg).join("/");
|
|
1371
|
-
return path ?
|
|
1471
|
+
return path ? chunkB3WST6ES_cjs.scrubSecretsInText(path, { emails: true }) : null;
|
|
1372
1472
|
} catch {
|
|
1373
1473
|
return null;
|
|
1374
1474
|
}
|
|
@@ -1382,9 +1482,9 @@ async function emitServerActionEvent(input) {
|
|
|
1382
1482
|
const fromPage = referer ?? nextUrl ?? null;
|
|
1383
1483
|
const argParams = extractServerActionArgs(input.args, input.actionName);
|
|
1384
1484
|
const combined = argParams !== null || fromPage !== null ? { ...argParams ?? {}, ...fromPage !== null ? { from_page: fromPage } : {} } : null;
|
|
1385
|
-
const requestParams =
|
|
1485
|
+
const requestParams = chunkB3WST6ES_cjs.maskAuthParams(
|
|
1386
1486
|
combined,
|
|
1387
|
-
|
|
1487
|
+
chunkB3WST6ES_cjs.isAuthActionName(input.actionName) || chunkB3WST6ES_cjs.isAuthPath(pathOf(fromPage))
|
|
1388
1488
|
);
|
|
1389
1489
|
const syntheticUrl = new URL(
|
|
1390
1490
|
`http://localhost/__server-action/${encodeURIComponent(input.actionName)}`
|
|
@@ -1399,7 +1499,7 @@ async function emitServerActionEvent(input) {
|
|
|
1399
1499
|
userAgent,
|
|
1400
1500
|
remoteIp: extractRemoteIp(await readNextHeadersAsAdapter()),
|
|
1401
1501
|
contentType: null,
|
|
1402
|
-
excludedVariableKeys:
|
|
1502
|
+
excludedVariableKeys: chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys
|
|
1403
1503
|
});
|
|
1404
1504
|
if (input.redirectTo) {
|
|
1405
1505
|
const host = await readNextHeader("x-forwarded-host") ?? await readNextHeader("host");
|
|
@@ -1411,18 +1511,18 @@ async function emitServerActionEvent(input) {
|
|
|
1411
1511
|
input.exception,
|
|
1412
1512
|
null
|
|
1413
1513
|
);
|
|
1414
|
-
const event =
|
|
1514
|
+
const event = chunkB3WST6ES_cjs.build({
|
|
1415
1515
|
source_type: "http_request",
|
|
1416
1516
|
source_data: sourceData,
|
|
1417
1517
|
outcome,
|
|
1418
|
-
correlation_id:
|
|
1518
|
+
correlation_id: chunkB5ZUQULZ_cjs.current(),
|
|
1419
1519
|
resource_ids: [],
|
|
1420
|
-
context:
|
|
1520
|
+
context: chunkB5ZUQULZ_cjs.getCurrentActor() ? { actor: chunkB5ZUQULZ_cjs.getCurrentActor() } : null,
|
|
1421
1521
|
duration_ms: input.durationMs,
|
|
1422
1522
|
error_message,
|
|
1423
1523
|
timestamp: input.startedAt
|
|
1424
1524
|
});
|
|
1425
|
-
|
|
1525
|
+
chunkB3WST6ES_cjs.pushEvent(event);
|
|
1426
1526
|
} catch (error) {
|
|
1427
1527
|
chunkTWTG5ILJ_cjs.logger.error(`server-action capture emit failed: ${describeError5(error)}`);
|
|
1428
1528
|
}
|
|
@@ -1505,7 +1605,7 @@ function actionWords(name) {
|
|
|
1505
1605
|
return name.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([a-zA-Z])(\d)/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
1506
1606
|
}
|
|
1507
1607
|
function looksLikeCardNumber(digits, paymentAction) {
|
|
1508
|
-
if (digits.length < 13 || digits.length > 19 || !
|
|
1608
|
+
if (digits.length < 13 || digits.length > 19 || !chunkB3WST6ES_cjs.passesLuhn(digits)) return false;
|
|
1509
1609
|
return paymentAction || digits.length === 15 || digits.length === 16;
|
|
1510
1610
|
}
|
|
1511
1611
|
function maskPositional(value, flags) {
|
|
@@ -1593,7 +1693,7 @@ function serializeArgValue(value) {
|
|
|
1593
1693
|
return void 0;
|
|
1594
1694
|
}
|
|
1595
1695
|
async function captureHttpEvent(input) {
|
|
1596
|
-
if (!
|
|
1696
|
+
if (!chunkB5ZUQULZ_cjs.configuration().captureHttp) return;
|
|
1597
1697
|
const snapshot = await snapshotRequest(input.request);
|
|
1598
1698
|
if (snapshot === null) return;
|
|
1599
1699
|
let graphqlErrorMessage = null;
|
|
@@ -1659,7 +1759,7 @@ async function snapshotRequest(request) {
|
|
|
1659
1759
|
return { method, url, userAgent, remoteIp, contentType, rawParams, graphqlBody, serverActionId };
|
|
1660
1760
|
}
|
|
1661
1761
|
async function maybeRunActorHook(request) {
|
|
1662
|
-
const hook =
|
|
1762
|
+
const hook = chunkB5ZUQULZ_cjs.configuration().actorFromRequest;
|
|
1663
1763
|
let hookResult = null;
|
|
1664
1764
|
if (hook) {
|
|
1665
1765
|
try {
|
|
@@ -1672,7 +1772,7 @@ async function maybeRunActorHook(request) {
|
|
|
1672
1772
|
applyActorFromHookAndUa(hookResult, userAgent);
|
|
1673
1773
|
}
|
|
1674
1774
|
async function maybeRunActorHookFromPages(req) {
|
|
1675
|
-
const hook =
|
|
1775
|
+
const hook = chunkB5ZUQULZ_cjs.configuration().actorFromRequest;
|
|
1676
1776
|
let hookResult = null;
|
|
1677
1777
|
if (hook) {
|
|
1678
1778
|
try {
|
|
@@ -1686,7 +1786,7 @@ async function maybeRunActorHookFromPages(req) {
|
|
|
1686
1786
|
applyActorFromHookAndUa(hookResult, userAgent);
|
|
1687
1787
|
}
|
|
1688
1788
|
async function maybeRunActorHookFromServerAction() {
|
|
1689
|
-
const hook =
|
|
1789
|
+
const hook = chunkB5ZUQULZ_cjs.configuration().actorFromRequest;
|
|
1690
1790
|
const headers = await loadNextHeaders();
|
|
1691
1791
|
if (!hook && !headers) {
|
|
1692
1792
|
chunkTWTG5ILJ_cjs.logger.debug("actorFromRequest (server action): no hook + no next/headers");
|
|
@@ -1831,7 +1931,8 @@ function readPagesHeader(req, name) {
|
|
|
1831
1931
|
async function emitEvent(input) {
|
|
1832
1932
|
try {
|
|
1833
1933
|
await flushTriggerAuditLog();
|
|
1834
|
-
|
|
1934
|
+
if (input.jobDelivery) return;
|
|
1935
|
+
const config = chunkB5ZUQULZ_cjs.configuration();
|
|
1835
1936
|
let graphql = null;
|
|
1836
1937
|
if (input.snapshot.graphqlBody !== null) {
|
|
1837
1938
|
const parsed = parseGraphqlBody(
|
|
@@ -1847,9 +1948,9 @@ async function emitEvent(input) {
|
|
|
1847
1948
|
method: input.snapshot.method,
|
|
1848
1949
|
url: input.snapshot.url,
|
|
1849
1950
|
statusCode: input.statusCode,
|
|
1850
|
-
rawParams:
|
|
1951
|
+
rawParams: chunkB3WST6ES_cjs.maskAuthParams(
|
|
1851
1952
|
unwrapTrpcParams(input.snapshot.rawParams, input.snapshot.url, input.context.routeModulePath ?? null),
|
|
1852
|
-
|
|
1953
|
+
chunkB3WST6ES_cjs.isAuthPath(input.snapshot.url.pathname)
|
|
1853
1954
|
),
|
|
1854
1955
|
routeModulePath: input.context.routeModulePath ?? null,
|
|
1855
1956
|
serverActionName,
|
|
@@ -1867,20 +1968,20 @@ async function emitEvent(input) {
|
|
|
1867
1968
|
input.responseErrorMessage ?? null
|
|
1868
1969
|
);
|
|
1869
1970
|
const contextValue = buildContext();
|
|
1870
|
-
const event =
|
|
1971
|
+
const event = chunkB3WST6ES_cjs.build({
|
|
1871
1972
|
source_type: "http_request",
|
|
1872
1973
|
source_data: sourceData,
|
|
1873
1974
|
outcome,
|
|
1874
|
-
correlation_id:
|
|
1975
|
+
correlation_id: chunkB5ZUQULZ_cjs.current(),
|
|
1875
1976
|
resource_ids: [],
|
|
1876
1977
|
context: contextValue,
|
|
1877
1978
|
duration_ms: input.durationMs,
|
|
1878
1979
|
error_message,
|
|
1879
1980
|
timestamp: input.startedAt
|
|
1880
1981
|
});
|
|
1881
|
-
|
|
1982
|
+
chunkB3WST6ES_cjs.pushEvent(event);
|
|
1882
1983
|
} catch (error) {
|
|
1883
|
-
const cid =
|
|
1984
|
+
const cid = chunkB5ZUQULZ_cjs.current();
|
|
1884
1985
|
const cidLabel = cid ? ` (correlation_id=${cid})` : "";
|
|
1885
1986
|
chunkTWTG5ILJ_cjs.logger.error(`http capture emit failed${cidLabel}: ${describeError5(error)}`);
|
|
1886
1987
|
}
|
|
@@ -1888,7 +1989,7 @@ async function emitEvent(input) {
|
|
|
1888
1989
|
function followBody(response, method, onDone, onChunk) {
|
|
1889
1990
|
try {
|
|
1890
1991
|
if (!response.body || method === "HEAD" || response.bodyUsed) return null;
|
|
1891
|
-
const capture =
|
|
1992
|
+
const capture = chunkB5ZUQULZ_cjs.makeAsyncContextCapture();
|
|
1892
1993
|
if (!capture) return null;
|
|
1893
1994
|
const keepAlive = isServerless() ? platformWaitUntil() : null;
|
|
1894
1995
|
if (isServerless() && !keepAlive) return null;
|
|
@@ -1942,6 +2043,26 @@ function followBody(response, method, onDone, onChunk) {
|
|
|
1942
2043
|
return null;
|
|
1943
2044
|
}
|
|
1944
2045
|
}
|
|
2046
|
+
async function offTheResponse(work, waitUntil = null) {
|
|
2047
|
+
const done = work().catch((e) => chunkTWTG5ILJ_cjs.logger.debug(`capture failed: ${describeError5(e)}`));
|
|
2048
|
+
if (!isServerless()) return;
|
|
2049
|
+
try {
|
|
2050
|
+
const keepAlive = waitUntil ?? platformWaitUntil();
|
|
2051
|
+
if (keepAlive) {
|
|
2052
|
+
keepAlive(done);
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
} catch (e) {
|
|
2056
|
+
chunkTWTG5ILJ_cjs.logger.debug(`waitUntil unavailable, recording inline: ${describeError5(e)}`);
|
|
2057
|
+
}
|
|
2058
|
+
let timer;
|
|
2059
|
+
await Promise.race([
|
|
2060
|
+
done,
|
|
2061
|
+
new Promise((resolve) => {
|
|
2062
|
+
timer = setTimeout(resolve, SERVERLESS_INLINE_FLUSH_MS);
|
|
2063
|
+
})
|
|
2064
|
+
]).finally(() => clearTimeout(timer));
|
|
2065
|
+
}
|
|
1945
2066
|
var SERVERLESS_INLINE_FLUSH_MS = 2e3;
|
|
1946
2067
|
async function flushOnServerless() {
|
|
1947
2068
|
if (!isServerless()) return;
|
|
@@ -1979,23 +2100,38 @@ function platformWaitUntil() {
|
|
|
1979
2100
|
return null;
|
|
1980
2101
|
}
|
|
1981
2102
|
function buildContext() {
|
|
1982
|
-
const currentActor =
|
|
2103
|
+
const currentActor = chunkB5ZUQULZ_cjs.getCurrentActor();
|
|
1983
2104
|
if (!currentActor) return null;
|
|
1984
2105
|
return { actor: currentActor };
|
|
1985
2106
|
}
|
|
1986
2107
|
async function flushTriggerAuditLog() {
|
|
1987
|
-
const reader =
|
|
2108
|
+
const reader = chunkB5ZUQULZ_cjs.configuration().databaseReader;
|
|
1988
2109
|
if (!reader) return;
|
|
1989
|
-
|
|
2110
|
+
const work = chunkO7SFYXJC_cjs.flushAuditLog(reader).catch(
|
|
2111
|
+
(e) => chunkTWTG5ILJ_cjs.logger.debug(`trigger audit flush failed: ${describeError5(e)}`)
|
|
2112
|
+
);
|
|
2113
|
+
if (!isServerless()) return;
|
|
2114
|
+
const waitUntil = platformWaitUntil();
|
|
2115
|
+
if (waitUntil) {
|
|
2116
|
+
waitUntil(work.then(() => flushScheduler.flushNow()));
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
let timer;
|
|
2120
|
+
await Promise.race([
|
|
2121
|
+
work,
|
|
2122
|
+
new Promise((resolve) => {
|
|
2123
|
+
timer = setTimeout(resolve, SERVERLESS_INLINE_FLUSH_MS);
|
|
2124
|
+
})
|
|
2125
|
+
]).finally(() => clearTimeout(timer));
|
|
1990
2126
|
}
|
|
1991
2127
|
function runWithActorAndAuditScope(callback) {
|
|
1992
|
-
if (
|
|
1993
|
-
return
|
|
2128
|
+
if (chunkB5ZUQULZ_cjs.configuration().databaseReader == null) {
|
|
2129
|
+
return chunkB5ZUQULZ_cjs.runWithActorScope(callback);
|
|
1994
2130
|
}
|
|
1995
|
-
return
|
|
2131
|
+
return chunkB5ZUQULZ_cjs.runWithActorScope(() => chunkO7SFYXJC_cjs.runWithEmittedAuditIdsScope(callback));
|
|
1996
2132
|
}
|
|
1997
2133
|
function isExcludedPath(path, method) {
|
|
1998
|
-
const config =
|
|
2134
|
+
const config = chunkB5ZUQULZ_cjs.configuration();
|
|
1999
2135
|
const normalizedMethod = (method ?? "").toUpperCase();
|
|
2000
2136
|
for (const pattern of config.allExcludedPaths()) {
|
|
2001
2137
|
if (typeof pattern === "string") {
|
|
@@ -2007,7 +2143,7 @@ function isExcludedPath(path, method) {
|
|
|
2007
2143
|
return true;
|
|
2008
2144
|
}
|
|
2009
2145
|
}
|
|
2010
|
-
if (hasExcludedExtension(path,
|
|
2146
|
+
if (hasExcludedExtension(path, chunkB5ZUQULZ_cjs.DEFAULT_EXCLUDED_EXTENSIONS)) return true;
|
|
2011
2147
|
return false;
|
|
2012
2148
|
}
|
|
2013
2149
|
function extractRemoteIp(headers) {
|
|
@@ -2045,6 +2181,16 @@ function mergeRouteParams(rawParams, routeParams) {
|
|
|
2045
2181
|
return { ...routeParams, ...rawParams };
|
|
2046
2182
|
}
|
|
2047
2183
|
var MAX_ERROR_BODY_LENGTH = 16384;
|
|
2184
|
+
function authRedirectError(url, status, location) {
|
|
2185
|
+
try {
|
|
2186
|
+
if (typeof status !== "number" || status < 300 || status >= 400 || !chunkB3WST6ES_cjs.isAuthPath(url.pathname)) return null;
|
|
2187
|
+
if (typeof location !== "string" || !location) return null;
|
|
2188
|
+
const reason = new URL(location, url).searchParams.get("error");
|
|
2189
|
+
return reason ? capErrorText(reason) : null;
|
|
2190
|
+
} catch {
|
|
2191
|
+
return null;
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2048
2194
|
async function readResponseErrorMessage(response, trpcRoute = false) {
|
|
2049
2195
|
try {
|
|
2050
2196
|
if (response.status < 400 && response.status !== 207) return null;
|
|
@@ -2053,7 +2199,7 @@ async function readResponseErrorMessage(response, trpcRoute = false) {
|
|
|
2053
2199
|
const text = await response.clone().text();
|
|
2054
2200
|
if (!text || text.length > MAX_ERROR_BODY_LENGTH) return null;
|
|
2055
2201
|
const parsed = safeJsonParse2(text);
|
|
2056
|
-
const trpc = trpcErrorMessage(parsed,
|
|
2202
|
+
const trpc = trpcErrorMessage(parsed, chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys);
|
|
2057
2203
|
if (trpc) return trpc;
|
|
2058
2204
|
if (response.status === 207) return null;
|
|
2059
2205
|
const body = parsed;
|
|
@@ -2062,9 +2208,9 @@ async function readResponseErrorMessage(response, trpcRoute = false) {
|
|
|
2062
2208
|
const raw = [body.error, body.message, nested?.message].find(
|
|
2063
2209
|
(v) => typeof v === "string" && v.trim().length > 0
|
|
2064
2210
|
);
|
|
2065
|
-
const specific = !raw || isGenericErrorText(raw) ? specificErrorMessage(body,
|
|
2211
|
+
const specific = !raw || isGenericErrorText(raw) ? specificErrorMessage(body, chunkB5ZUQULZ_cjs.configuration().excludedGraphqlVariableKeys) : null;
|
|
2066
2212
|
if (specific) return capErrorText(specific);
|
|
2067
|
-
return raw ? truncate(
|
|
2213
|
+
return raw ? truncate(chunkB3WST6ES_cjs.scrubSecretsInText(raw.trim(), { emails: true })) : null;
|
|
2068
2214
|
} catch {
|
|
2069
2215
|
return null;
|
|
2070
2216
|
}
|
|
@@ -2088,23 +2234,23 @@ function applyActorFromHookAndUa(hookResult, userAgent) {
|
|
|
2088
2234
|
const uaMatch = classifyUserAgent(userAgent);
|
|
2089
2235
|
if (hookResult != null && typeof hookResult === "object" && !Array.isArray(hookResult)) {
|
|
2090
2236
|
if (uaMatch === null) {
|
|
2091
|
-
|
|
2237
|
+
chunkB5ZUQULZ_cjs.setActor(hookResult);
|
|
2092
2238
|
return;
|
|
2093
2239
|
}
|
|
2094
2240
|
const hookObj = hookResult;
|
|
2095
2241
|
const existingKind = hookObj.kind;
|
|
2096
2242
|
if (typeof existingKind === "string" && existingKind.length > 0) {
|
|
2097
|
-
|
|
2243
|
+
chunkB5ZUQULZ_cjs.setActor(hookObj);
|
|
2098
2244
|
return;
|
|
2099
2245
|
}
|
|
2100
|
-
|
|
2246
|
+
chunkB5ZUQULZ_cjs.setActor({ ...hookObj, kind: uaMatch.kind });
|
|
2101
2247
|
return;
|
|
2102
2248
|
}
|
|
2103
2249
|
if (uaMatch !== null) {
|
|
2104
|
-
|
|
2250
|
+
chunkB5ZUQULZ_cjs.setActor(synthesizeAgentActor(uaMatch));
|
|
2105
2251
|
return;
|
|
2106
2252
|
}
|
|
2107
|
-
|
|
2253
|
+
chunkB5ZUQULZ_cjs.setActor(null);
|
|
2108
2254
|
}
|
|
2109
2255
|
function synthesizeAgentActor(detection) {
|
|
2110
2256
|
return {
|
|
@@ -2152,7 +2298,7 @@ function _resetStartupAnnouncementForTests() {
|
|
|
2152
2298
|
}
|
|
2153
2299
|
var ezlogs = {
|
|
2154
2300
|
init(options) {
|
|
2155
|
-
const config =
|
|
2301
|
+
const config = chunkB5ZUQULZ_cjs.configuration();
|
|
2156
2302
|
config.apply(options);
|
|
2157
2303
|
if (options.logLevel) chunkTWTG5ILJ_cjs.setLogLevel(options.logLevel);
|
|
2158
2304
|
warnIfInsecureServerUrl(config.serverUrl, config.allowInsecureTransport);
|
|
@@ -2171,7 +2317,7 @@ var ezlogs = {
|
|
|
2171
2317
|
}
|
|
2172
2318
|
});
|
|
2173
2319
|
} else if (options.patchDatabaseClient) {
|
|
2174
|
-
|
|
2320
|
+
chunkDM2EAOSF_cjs.patchPgClient(
|
|
2175
2321
|
options.patchDatabaseClient
|
|
2176
2322
|
);
|
|
2177
2323
|
}
|
|
@@ -2218,7 +2364,7 @@ function detectDatabaseUrlFromEnv() {
|
|
|
2218
2364
|
return null;
|
|
2219
2365
|
}
|
|
2220
2366
|
async function autoWireTriggerPathFromDatabaseUrl(options) {
|
|
2221
|
-
const config =
|
|
2367
|
+
const config = chunkB5ZUQULZ_cjs.configuration();
|
|
2222
2368
|
let pg;
|
|
2223
2369
|
try {
|
|
2224
2370
|
const dynImport = new Function(
|
|
@@ -2237,7 +2383,7 @@ async function autoWireTriggerPathFromDatabaseUrl(options) {
|
|
|
2237
2383
|
max: 4
|
|
2238
2384
|
});
|
|
2239
2385
|
const reader = (sql, params) => pool.query(sql, params);
|
|
2240
|
-
if (await
|
|
2386
|
+
if (await chunkO7SFYXJC_cjs.auditLogInstalled(reader) === false) {
|
|
2241
2387
|
warnAuditLogMissing();
|
|
2242
2388
|
void pool.end?.().catch(() => {
|
|
2243
2389
|
});
|
|
@@ -2246,21 +2392,21 @@ async function autoWireTriggerPathFromDatabaseUrl(options) {
|
|
|
2246
2392
|
if (config.databaseReader === null) {
|
|
2247
2393
|
config.databaseReader = reader;
|
|
2248
2394
|
}
|
|
2249
|
-
|
|
2250
|
-
void
|
|
2395
|
+
chunkDM2EAOSF_cjs.patchPgClient(pg);
|
|
2396
|
+
void chunkO7SFYXJC_cjs.checkAuditLogAccess(reader);
|
|
2251
2397
|
runTriggerTrackedTablesDetection();
|
|
2252
2398
|
}
|
|
2253
2399
|
function applyDatabaseReaderDefaults() {
|
|
2254
|
-
const config =
|
|
2400
|
+
const config = chunkB5ZUQULZ_cjs.configuration();
|
|
2255
2401
|
const reader = config.databaseReader;
|
|
2256
2402
|
if (!reader) return;
|
|
2257
|
-
|
|
2403
|
+
chunkO7SFYXJC_cjs.auditLogInstalled(reader).then((installed) => {
|
|
2258
2404
|
if (installed === false && config.databaseReader === reader) {
|
|
2259
2405
|
config.databaseReader = null;
|
|
2260
2406
|
warnAuditLogMissing();
|
|
2261
2407
|
return;
|
|
2262
2408
|
}
|
|
2263
|
-
if (installed === true) void
|
|
2409
|
+
if (installed === true) void chunkO7SFYXJC_cjs.checkAuditLogAccess(reader);
|
|
2264
2410
|
runTriggerTrackedTablesDetection();
|
|
2265
2411
|
}).catch(() => {
|
|
2266
2412
|
});
|
|
@@ -2271,10 +2417,10 @@ function warnAuditLogMissing() {
|
|
|
2271
2417
|
);
|
|
2272
2418
|
}
|
|
2273
2419
|
function runTriggerTrackedTablesDetection() {
|
|
2274
|
-
const config =
|
|
2420
|
+
const config = chunkB5ZUQULZ_cjs.configuration();
|
|
2275
2421
|
if (!config.databaseReader) return;
|
|
2276
2422
|
if (config.triggerTrackedTables !== null) return;
|
|
2277
|
-
|
|
2423
|
+
chunkO7SFYXJC_cjs.detectTriggerTrackedTables(config.databaseReader).then((tables) => {
|
|
2278
2424
|
if (tables === null) {
|
|
2279
2425
|
chunkTWTG5ILJ_cjs.logger.debug(
|
|
2280
2426
|
"trigger-tracked-table detection failed; falling back to suppress-all on `databaseReader` paths. Untracked tables will not appear in the dashboard until detection succeeds or the table is added with `SELECT ezlogs_track('table_name')`."
|
|
@@ -2314,16 +2460,16 @@ function warnIfInsecureServerUrl(serverUrl, allowInsecure) {
|
|
|
2314
2460
|
);
|
|
2315
2461
|
}
|
|
2316
2462
|
function _internalsForTests() {
|
|
2317
|
-
return { buffer:
|
|
2463
|
+
return { buffer: chunkB3WST6ES_cjs.buffer_exports, flushScheduler };
|
|
2318
2464
|
}
|
|
2319
2465
|
|
|
2320
2466
|
Object.defineProperty(exports, "ArgError", {
|
|
2321
2467
|
enumerable: true,
|
|
2322
|
-
get: function () { return
|
|
2468
|
+
get: function () { return chunkB3WST6ES_cjs.ArgError; }
|
|
2323
2469
|
});
|
|
2324
2470
|
Object.defineProperty(exports, "buildEvent", {
|
|
2325
2471
|
enumerable: true,
|
|
2326
|
-
get: function () { return
|
|
2472
|
+
get: function () { return chunkB3WST6ES_cjs.build; }
|
|
2327
2473
|
});
|
|
2328
2474
|
exports.__ezlogs_run_inline_server_action = __ezlogs_run_inline_server_action;
|
|
2329
2475
|
exports._detectDatabaseUrlFromEnvForTests = _detectDatabaseUrlFromEnvForTests;
|