@fedify/debugger 2.2.0-dev.610 → 2.2.0-dev.622
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/mod.cjs +47 -83
- package/dist/mod.d.cts +1 -7
- package/dist/mod.d.ts +1 -7
- package/dist/mod.js +24 -38
- package/package.json +4 -4
package/dist/mod.cjs
CHANGED
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
const __fedify_fedify_federation = __toESM(require("@fedify/fedify/federation"));
|
|
28
|
-
const __fedify_fedify_otel = __toESM(require("@fedify/fedify/otel"));
|
|
29
|
-
const __logtape_logtape = __toESM(require("@logtape/logtape"));
|
|
30
|
-
const __opentelemetry_api = __toESM(require("@opentelemetry/api"));
|
|
31
|
-
const __opentelemetry_context_async_hooks = __toESM(require("@opentelemetry/context-async-hooks"));
|
|
32
|
-
const __opentelemetry_core = __toESM(require("@opentelemetry/core"));
|
|
33
|
-
const __opentelemetry_sdk_trace_base = __toESM(require("@opentelemetry/sdk-trace-base"));
|
|
34
|
-
const node_async_hooks = __toESM(require("node:async_hooks"));
|
|
35
|
-
const hono = __toESM(require("hono"));
|
|
36
|
-
const hono_cookie = __toESM(require("hono/cookie"));
|
|
37
|
-
const node_crypto = __toESM(require("node:crypto"));
|
|
38
|
-
const hono_jsx_jsx_runtime = __toESM(require("hono/jsx/jsx-runtime"));
|
|
39
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let _fedify_fedify_federation = require("@fedify/fedify/federation");
|
|
4
|
+
let _fedify_fedify_otel = require("@fedify/fedify/otel");
|
|
5
|
+
let _logtape_logtape = require("@logtape/logtape");
|
|
6
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
7
|
+
let _opentelemetry_context_async_hooks = require("@opentelemetry/context-async-hooks");
|
|
8
|
+
let _opentelemetry_core = require("@opentelemetry/core");
|
|
9
|
+
let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
10
|
+
let node_async_hooks = require("node:async_hooks");
|
|
11
|
+
let hono = require("hono");
|
|
12
|
+
let hono_cookie = require("hono/cookie");
|
|
13
|
+
let node_crypto = require("node:crypto");
|
|
14
|
+
let hono_jsx_jsx_runtime = require("hono/jsx/jsx-runtime");
|
|
40
15
|
//#region src/log-store.ts
|
|
41
16
|
/**
|
|
42
17
|
* Persistent storage for log records grouped by trace ID, backed by a
|
|
@@ -92,7 +67,7 @@ function serializeLogRecord(record) {
|
|
|
92
67
|
for (const part of record.message) if (typeof part === "string") messageParts.push(part);
|
|
93
68
|
else if (part == null) messageParts.push("");
|
|
94
69
|
else messageParts.push(String(part));
|
|
95
|
-
const { traceId: _t, spanId: _s
|
|
70
|
+
const { traceId: _t, spanId: _s, ...properties } = record.properties;
|
|
96
71
|
return {
|
|
97
72
|
category: record.category,
|
|
98
73
|
level: record.level,
|
|
@@ -113,9 +88,13 @@ function createLogSink(store) {
|
|
|
113
88
|
store.add(traceId, serializeLogRecord(record));
|
|
114
89
|
};
|
|
115
90
|
}
|
|
116
|
-
|
|
117
91
|
//#endregion
|
|
118
92
|
//#region src/auth.ts
|
|
93
|
+
/**
|
|
94
|
+
* Authentication types and helpers for the debug dashboard.
|
|
95
|
+
*
|
|
96
|
+
* @module
|
|
97
|
+
*/
|
|
119
98
|
const SESSION_COOKIE_NAME = "__fedify_debug_session";
|
|
120
99
|
const SESSION_TOKEN = "authenticated";
|
|
121
100
|
async function generateHmacKey() {
|
|
@@ -134,8 +113,7 @@ function fromHex(hex) {
|
|
|
134
113
|
}
|
|
135
114
|
async function signSession(key) {
|
|
136
115
|
const encoder = new TextEncoder();
|
|
137
|
-
|
|
138
|
-
return toHex(signature);
|
|
116
|
+
return toHex(await crypto.subtle.sign("HMAC", key, encoder.encode(SESSION_TOKEN)));
|
|
139
117
|
}
|
|
140
118
|
async function verifySession(key, signature) {
|
|
141
119
|
try {
|
|
@@ -172,7 +150,6 @@ async function checkAuth(auth, formData) {
|
|
|
172
150
|
}
|
|
173
151
|
return false;
|
|
174
152
|
}
|
|
175
|
-
|
|
176
153
|
//#endregion
|
|
177
154
|
//#region src/views/logo.tsx
|
|
178
155
|
/**
|
|
@@ -347,7 +324,6 @@ const FedifyLogo = ({ size = 24 }) => {
|
|
|
347
324
|
]
|
|
348
325
|
});
|
|
349
326
|
};
|
|
350
|
-
|
|
351
327
|
//#endregion
|
|
352
328
|
//#region src/views/layout.tsx
|
|
353
329
|
/**
|
|
@@ -422,7 +398,6 @@ const Layout = ({ title, pathPrefix, children }) => {
|
|
|
422
398
|
children: [/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)(FedifyLogo, { size: 24 }), "Fedify Debug Dashboard"]
|
|
423
399
|
}) }) }), /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("main", { children })] })] });
|
|
424
400
|
};
|
|
425
|
-
|
|
426
401
|
//#endregion
|
|
427
402
|
//#region src/views/login.tsx
|
|
428
403
|
/**
|
|
@@ -548,7 +523,6 @@ const LoginPage = ({ pathPrefix, showUsername, error }) => {
|
|
|
548
523
|
]
|
|
549
524
|
});
|
|
550
525
|
};
|
|
551
|
-
|
|
552
526
|
//#endregion
|
|
553
527
|
//#region src/views/trace-detail.tsx
|
|
554
528
|
/**
|
|
@@ -675,7 +649,6 @@ function formatJson(json) {
|
|
|
675
649
|
return json;
|
|
676
650
|
}
|
|
677
651
|
}
|
|
678
|
-
|
|
679
652
|
//#endregion
|
|
680
653
|
//#region src/views/traces-list.tsx
|
|
681
654
|
/**
|
|
@@ -701,24 +674,24 @@ const TracesListPage = ({ traces, pathPrefix }) => {
|
|
|
701
674
|
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("th", { children: "Activity Types" }),
|
|
702
675
|
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("th", { children: "Activities" }),
|
|
703
676
|
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("th", { children: "Timestamp" })
|
|
704
|
-
] }) }), /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("tbody", { children: traces.map((trace
|
|
677
|
+
] }) }), /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("tbody", { children: traces.map((trace) => /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsxs)("tr", { children: [
|
|
705
678
|
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("a", {
|
|
706
|
-
href: `${pathPrefix}/traces/${trace
|
|
707
|
-
children: /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("code", { children: trace
|
|
679
|
+
href: `${pathPrefix}/traces/${trace.traceId}`,
|
|
680
|
+
children: /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("code", { children: trace.traceId.slice(0, 8) })
|
|
708
681
|
}) }),
|
|
709
|
-
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsxs)("td", { children: [trace
|
|
682
|
+
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsxs)("td", { children: [trace.activityTypes.map((t) => /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("span", {
|
|
710
683
|
class: "badge",
|
|
711
684
|
children: t
|
|
712
|
-
}, t)), trace
|
|
685
|
+
}, t)), trace.activityTypes.length === 0 && /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("span", {
|
|
713
686
|
class: "empty",
|
|
714
687
|
children: "none"
|
|
715
688
|
})] }),
|
|
716
|
-
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("td", { children: trace
|
|
689
|
+
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("td", { children: trace.activityCount }),
|
|
717
690
|
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("time", {
|
|
718
|
-
datetime: trace
|
|
719
|
-
children: trace
|
|
691
|
+
datetime: trace.timestamp,
|
|
692
|
+
children: trace.timestamp
|
|
720
693
|
}) })
|
|
721
|
-
] }, trace
|
|
694
|
+
] }, trace.traceId)) })] }),
|
|
722
695
|
/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)("script", { dangerouslySetInnerHTML: { __html: `
|
|
723
696
|
(function() {
|
|
724
697
|
var interval = setInterval(function() {
|
|
@@ -743,7 +716,6 @@ const TracesListPage = ({ traces, pathPrefix }) => {
|
|
|
743
716
|
]
|
|
744
717
|
});
|
|
745
718
|
};
|
|
746
|
-
|
|
747
719
|
//#endregion
|
|
748
720
|
//#region src/routes.tsx
|
|
749
721
|
function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
@@ -751,8 +723,7 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
751
723
|
let hmacKeyPromise;
|
|
752
724
|
if (auth != null && auth.type !== "request") hmacKeyPromise = generateHmacKey();
|
|
753
725
|
if (auth != null) if (auth.type === "request") app.use("*", async (c, next) => {
|
|
754
|
-
|
|
755
|
-
if (!allowed) return c.text("Forbidden", 403);
|
|
726
|
+
if (!await auth.authenticate(c.req.raw)) return c.text("Forbidden", 403);
|
|
756
727
|
await next();
|
|
757
728
|
});
|
|
758
729
|
else {
|
|
@@ -760,18 +731,15 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
760
731
|
app.post("/login", async (c) => {
|
|
761
732
|
const body = await c.req.parseBody();
|
|
762
733
|
const password = typeof body.password === "string" ? body.password : "";
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
username,
|
|
734
|
+
if (!await checkAuth(auth, {
|
|
735
|
+
username: typeof body.username === "string" ? body.username : void 0,
|
|
766
736
|
password
|
|
767
|
-
})
|
|
768
|
-
if (!ok) return c.html(/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)(LoginPage, {
|
|
737
|
+
})) return c.html(/* @__PURE__ */ (0, hono_jsx_jsx_runtime.jsx)(LoginPage, {
|
|
769
738
|
pathPrefix,
|
|
770
739
|
showUsername,
|
|
771
740
|
error: "Invalid credentials."
|
|
772
741
|
}), 401);
|
|
773
|
-
const
|
|
774
|
-
const sig = await signSession(key);
|
|
742
|
+
const sig = await signSession(await hmacKeyPromise);
|
|
775
743
|
const secure = new URL(c.req.url).protocol === "https:";
|
|
776
744
|
return new Response(null, {
|
|
777
745
|
status: 303,
|
|
@@ -801,9 +769,7 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
801
769
|
}
|
|
802
770
|
const sessionValue = (0, hono_cookie.getCookie)(c, SESSION_COOKIE_NAME);
|
|
803
771
|
if (sessionValue) {
|
|
804
|
-
|
|
805
|
-
const valid = await verifySession(key, sessionValue);
|
|
806
|
-
if (valid) {
|
|
772
|
+
if (await verifySession(await hmacKeyPromise, sessionValue)) {
|
|
807
773
|
await next();
|
|
808
774
|
return;
|
|
809
775
|
}
|
|
@@ -845,7 +811,6 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
845
811
|
});
|
|
846
812
|
return app;
|
|
847
813
|
}
|
|
848
|
-
|
|
849
814
|
//#endregion
|
|
850
815
|
//#region src/mod.tsx
|
|
851
816
|
/**
|
|
@@ -893,14 +858,14 @@ function createFederationDebugger(federation, options) {
|
|
|
893
858
|
exporter = _autoSetup.exporter;
|
|
894
859
|
logKv = _autoSetup.kv;
|
|
895
860
|
} else {
|
|
896
|
-
const kv = new
|
|
861
|
+
const kv = new _fedify_fedify_federation.MemoryKvStore();
|
|
897
862
|
logKv = kv;
|
|
898
|
-
exporter = new
|
|
899
|
-
const tracerProvider = new
|
|
900
|
-
|
|
901
|
-
const contextManager = new
|
|
902
|
-
|
|
903
|
-
|
|
863
|
+
exporter = new _fedify_fedify_otel.FedifySpanExporter(kv);
|
|
864
|
+
const tracerProvider = new _opentelemetry_sdk_trace_base.BasicTracerProvider({ spanProcessors: [new _opentelemetry_sdk_trace_base.SimpleSpanProcessor(exporter)] });
|
|
865
|
+
_opentelemetry_api.trace.setGlobalTracerProvider(tracerProvider);
|
|
866
|
+
const contextManager = new _opentelemetry_context_async_hooks.AsyncLocalStorageContextManager();
|
|
867
|
+
_opentelemetry_api.context.setGlobalContextManager(contextManager);
|
|
868
|
+
_opentelemetry_api.propagation.setGlobalPropagator(new _opentelemetry_core.W3CTraceContextPropagator());
|
|
904
869
|
_autoSetup = {
|
|
905
870
|
exporter,
|
|
906
871
|
kv
|
|
@@ -909,7 +874,7 @@ function createFederationDebugger(federation, options) {
|
|
|
909
874
|
const logStore = new LogStore(logKv);
|
|
910
875
|
const sink = createLogSink(logStore);
|
|
911
876
|
if (options == null || !("exporter" in options)) {
|
|
912
|
-
const existingConfig = (0,
|
|
877
|
+
const existingConfig = (0, _logtape_logtape.getConfig)();
|
|
913
878
|
if (existingConfig != null) {
|
|
914
879
|
const sinks = {
|
|
915
880
|
...existingConfig.sinks,
|
|
@@ -923,14 +888,14 @@ function createFederationDebugger(federation, options) {
|
|
|
923
888
|
category: [],
|
|
924
889
|
sinks: ["__fedify_debugger__"]
|
|
925
890
|
});
|
|
926
|
-
(0,
|
|
891
|
+
(0, _logtape_logtape.configureSync)({
|
|
927
892
|
...existingConfig,
|
|
928
893
|
contextLocalStorage: existingConfig.contextLocalStorage ?? new node_async_hooks.AsyncLocalStorage(),
|
|
929
894
|
reset: true,
|
|
930
895
|
sinks,
|
|
931
896
|
loggers
|
|
932
897
|
});
|
|
933
|
-
} else (0,
|
|
898
|
+
} else (0, _logtape_logtape.configureSync)({
|
|
934
899
|
sinks: { __fedify_debugger__: sink },
|
|
935
900
|
loggers: [{
|
|
936
901
|
category: [],
|
|
@@ -963,7 +928,6 @@ function createFederationDebugger(federation, options) {
|
|
|
963
928
|
}
|
|
964
929
|
});
|
|
965
930
|
}
|
|
966
|
-
|
|
967
931
|
//#endregion
|
|
968
932
|
exports.createFederationDebugger = createFederationDebugger;
|
|
969
|
-
exports.resetAutoSetup = resetAutoSetup;
|
|
933
|
+
exports.resetAutoSetup = resetAutoSetup;
|
package/dist/mod.d.cts
CHANGED
|
@@ -3,7 +3,6 @@ import { FedifySpanExporter } from "@fedify/fedify/otel";
|
|
|
3
3
|
import { Sink } from "@logtape/logtape";
|
|
4
4
|
|
|
5
5
|
//#region src/auth.d.ts
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Authentication configuration for the debug dashboard.
|
|
9
8
|
*
|
|
@@ -61,11 +60,6 @@ interface SerializedLogRecord {
|
|
|
61
60
|
*/
|
|
62
61
|
readonly properties: Record<string, unknown>;
|
|
63
62
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Persistent storage for log records grouped by trace ID, backed by a
|
|
66
|
-
* {@link KvStore}. When the same `KvStore` is shared across web and worker
|
|
67
|
-
* processes the dashboard can display logs produced by background tasks.
|
|
68
|
-
*/
|
|
69
63
|
//#endregion
|
|
70
64
|
//#region src/mod.d.ts
|
|
71
65
|
/**
|
|
@@ -185,4 +179,4 @@ declare function createFederationDebugger<TContextData>(federation: Federation<T
|
|
|
185
179
|
sink: Sink;
|
|
186
180
|
};
|
|
187
181
|
//#endregion
|
|
188
|
-
export { FederationDebuggerAuth, FederationDebuggerOptions, FederationDebuggerSimpleOptions, SerializedLogRecord, createFederationDebugger, resetAutoSetup };
|
|
182
|
+
export { type FederationDebuggerAuth, FederationDebuggerOptions, FederationDebuggerSimpleOptions, type SerializedLogRecord, createFederationDebugger, resetAutoSetup };
|
package/dist/mod.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { FedifySpanExporter } from "@fedify/fedify/otel";
|
|
|
4
4
|
import { Sink } from "@logtape/logtape";
|
|
5
5
|
|
|
6
6
|
//#region src/auth.d.ts
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Authentication configuration for the debug dashboard.
|
|
10
9
|
*
|
|
@@ -62,11 +61,6 @@ interface SerializedLogRecord {
|
|
|
62
61
|
*/
|
|
63
62
|
readonly properties: Record<string, unknown>;
|
|
64
63
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Persistent storage for log records grouped by trace ID, backed by a
|
|
67
|
-
* {@link KvStore}. When the same `KvStore` is shared across web and worker
|
|
68
|
-
* processes the dashboard can display logs produced by background tasks.
|
|
69
|
-
*/
|
|
70
64
|
//#endregion
|
|
71
65
|
//#region src/mod.d.ts
|
|
72
66
|
/**
|
|
@@ -186,4 +180,4 @@ declare function createFederationDebugger<TContextData>(federation: Federation<T
|
|
|
186
180
|
sink: Sink;
|
|
187
181
|
};
|
|
188
182
|
//#endregion
|
|
189
|
-
export { FederationDebuggerAuth, FederationDebuggerOptions, FederationDebuggerSimpleOptions, SerializedLogRecord, createFederationDebugger, resetAutoSetup };
|
|
183
|
+
export { type FederationDebuggerAuth, FederationDebuggerOptions, FederationDebuggerSimpleOptions, type SerializedLogRecord, createFederationDebugger, resetAutoSetup };
|
package/dist/mod.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { MemoryKvStore } from "@fedify/fedify/federation";
|
|
5
3
|
import { FedifySpanExporter } from "@fedify/fedify/otel";
|
|
6
4
|
import { configureSync, getConfig } from "@logtape/logtape";
|
|
@@ -13,7 +11,6 @@ import { Hono } from "hono";
|
|
|
13
11
|
import { getCookie } from "hono/cookie";
|
|
14
12
|
import { timingSafeEqual } from "node:crypto";
|
|
15
13
|
import { jsx, jsxs } from "hono/jsx/jsx-runtime";
|
|
16
|
-
|
|
17
14
|
//#region src/log-store.ts
|
|
18
15
|
/**
|
|
19
16
|
* Persistent storage for log records grouped by trace ID, backed by a
|
|
@@ -69,7 +66,7 @@ function serializeLogRecord(record) {
|
|
|
69
66
|
for (const part of record.message) if (typeof part === "string") messageParts.push(part);
|
|
70
67
|
else if (part == null) messageParts.push("");
|
|
71
68
|
else messageParts.push(String(part));
|
|
72
|
-
const { traceId: _t, spanId: _s
|
|
69
|
+
const { traceId: _t, spanId: _s, ...properties } = record.properties;
|
|
73
70
|
return {
|
|
74
71
|
category: record.category,
|
|
75
72
|
level: record.level,
|
|
@@ -90,9 +87,13 @@ function createLogSink(store) {
|
|
|
90
87
|
store.add(traceId, serializeLogRecord(record));
|
|
91
88
|
};
|
|
92
89
|
}
|
|
93
|
-
|
|
94
90
|
//#endregion
|
|
95
91
|
//#region src/auth.ts
|
|
92
|
+
/**
|
|
93
|
+
* Authentication types and helpers for the debug dashboard.
|
|
94
|
+
*
|
|
95
|
+
* @module
|
|
96
|
+
*/
|
|
96
97
|
const SESSION_COOKIE_NAME = "__fedify_debug_session";
|
|
97
98
|
const SESSION_TOKEN = "authenticated";
|
|
98
99
|
async function generateHmacKey() {
|
|
@@ -111,8 +112,7 @@ function fromHex(hex) {
|
|
|
111
112
|
}
|
|
112
113
|
async function signSession(key) {
|
|
113
114
|
const encoder = new TextEncoder();
|
|
114
|
-
|
|
115
|
-
return toHex(signature);
|
|
115
|
+
return toHex(await crypto.subtle.sign("HMAC", key, encoder.encode(SESSION_TOKEN)));
|
|
116
116
|
}
|
|
117
117
|
async function verifySession(key, signature) {
|
|
118
118
|
try {
|
|
@@ -149,7 +149,6 @@ async function checkAuth(auth, formData) {
|
|
|
149
149
|
}
|
|
150
150
|
return false;
|
|
151
151
|
}
|
|
152
|
-
|
|
153
152
|
//#endregion
|
|
154
153
|
//#region src/views/logo.tsx
|
|
155
154
|
/**
|
|
@@ -324,7 +323,6 @@ const FedifyLogo = ({ size = 24 }) => {
|
|
|
324
323
|
]
|
|
325
324
|
});
|
|
326
325
|
};
|
|
327
|
-
|
|
328
326
|
//#endregion
|
|
329
327
|
//#region src/views/layout.tsx
|
|
330
328
|
/**
|
|
@@ -399,7 +397,6 @@ const Layout = ({ title, pathPrefix, children }) => {
|
|
|
399
397
|
children: [/* @__PURE__ */ jsx(FedifyLogo, { size: 24 }), "Fedify Debug Dashboard"]
|
|
400
398
|
}) }) }), /* @__PURE__ */ jsx("main", { children })] })] });
|
|
401
399
|
};
|
|
402
|
-
|
|
403
400
|
//#endregion
|
|
404
401
|
//#region src/views/login.tsx
|
|
405
402
|
/**
|
|
@@ -525,7 +522,6 @@ const LoginPage = ({ pathPrefix, showUsername, error }) => {
|
|
|
525
522
|
]
|
|
526
523
|
});
|
|
527
524
|
};
|
|
528
|
-
|
|
529
525
|
//#endregion
|
|
530
526
|
//#region src/views/trace-detail.tsx
|
|
531
527
|
/**
|
|
@@ -652,7 +648,6 @@ function formatJson(json) {
|
|
|
652
648
|
return json;
|
|
653
649
|
}
|
|
654
650
|
}
|
|
655
|
-
|
|
656
651
|
//#endregion
|
|
657
652
|
//#region src/views/traces-list.tsx
|
|
658
653
|
/**
|
|
@@ -678,24 +673,24 @@ const TracesListPage = ({ traces, pathPrefix }) => {
|
|
|
678
673
|
/* @__PURE__ */ jsx("th", { children: "Activity Types" }),
|
|
679
674
|
/* @__PURE__ */ jsx("th", { children: "Activities" }),
|
|
680
675
|
/* @__PURE__ */ jsx("th", { children: "Timestamp" })
|
|
681
|
-
] }) }), /* @__PURE__ */ jsx("tbody", { children: traces.map((trace
|
|
676
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: traces.map((trace) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
682
677
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("a", {
|
|
683
|
-
href: `${pathPrefix}/traces/${trace
|
|
684
|
-
children: /* @__PURE__ */ jsx("code", { children: trace
|
|
678
|
+
href: `${pathPrefix}/traces/${trace.traceId}`,
|
|
679
|
+
children: /* @__PURE__ */ jsx("code", { children: trace.traceId.slice(0, 8) })
|
|
685
680
|
}) }),
|
|
686
|
-
/* @__PURE__ */ jsxs("td", { children: [trace
|
|
681
|
+
/* @__PURE__ */ jsxs("td", { children: [trace.activityTypes.map((t) => /* @__PURE__ */ jsx("span", {
|
|
687
682
|
class: "badge",
|
|
688
683
|
children: t
|
|
689
|
-
}, t)), trace
|
|
684
|
+
}, t)), trace.activityTypes.length === 0 && /* @__PURE__ */ jsx("span", {
|
|
690
685
|
class: "empty",
|
|
691
686
|
children: "none"
|
|
692
687
|
})] }),
|
|
693
|
-
/* @__PURE__ */ jsx("td", { children: trace
|
|
688
|
+
/* @__PURE__ */ jsx("td", { children: trace.activityCount }),
|
|
694
689
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("time", {
|
|
695
|
-
datetime: trace
|
|
696
|
-
children: trace
|
|
690
|
+
datetime: trace.timestamp,
|
|
691
|
+
children: trace.timestamp
|
|
697
692
|
}) })
|
|
698
|
-
] }, trace
|
|
693
|
+
] }, trace.traceId)) })] }),
|
|
699
694
|
/* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: `
|
|
700
695
|
(function() {
|
|
701
696
|
var interval = setInterval(function() {
|
|
@@ -720,7 +715,6 @@ const TracesListPage = ({ traces, pathPrefix }) => {
|
|
|
720
715
|
]
|
|
721
716
|
});
|
|
722
717
|
};
|
|
723
|
-
|
|
724
718
|
//#endregion
|
|
725
719
|
//#region src/routes.tsx
|
|
726
720
|
function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
@@ -728,8 +722,7 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
728
722
|
let hmacKeyPromise;
|
|
729
723
|
if (auth != null && auth.type !== "request") hmacKeyPromise = generateHmacKey();
|
|
730
724
|
if (auth != null) if (auth.type === "request") app.use("*", async (c, next) => {
|
|
731
|
-
|
|
732
|
-
if (!allowed) return c.text("Forbidden", 403);
|
|
725
|
+
if (!await auth.authenticate(c.req.raw)) return c.text("Forbidden", 403);
|
|
733
726
|
await next();
|
|
734
727
|
});
|
|
735
728
|
else {
|
|
@@ -737,18 +730,15 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
737
730
|
app.post("/login", async (c) => {
|
|
738
731
|
const body = await c.req.parseBody();
|
|
739
732
|
const password = typeof body.password === "string" ? body.password : "";
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
username,
|
|
733
|
+
if (!await checkAuth(auth, {
|
|
734
|
+
username: typeof body.username === "string" ? body.username : void 0,
|
|
743
735
|
password
|
|
744
|
-
})
|
|
745
|
-
if (!ok) return c.html(/* @__PURE__ */ jsx(LoginPage, {
|
|
736
|
+
})) return c.html(/* @__PURE__ */ jsx(LoginPage, {
|
|
746
737
|
pathPrefix,
|
|
747
738
|
showUsername,
|
|
748
739
|
error: "Invalid credentials."
|
|
749
740
|
}), 401);
|
|
750
|
-
const
|
|
751
|
-
const sig = await signSession(key);
|
|
741
|
+
const sig = await signSession(await hmacKeyPromise);
|
|
752
742
|
const secure = new URL(c.req.url).protocol === "https:";
|
|
753
743
|
return new Response(null, {
|
|
754
744
|
status: 303,
|
|
@@ -778,9 +768,7 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
778
768
|
}
|
|
779
769
|
const sessionValue = getCookie(c, SESSION_COOKIE_NAME);
|
|
780
770
|
if (sessionValue) {
|
|
781
|
-
|
|
782
|
-
const valid = await verifySession(key, sessionValue);
|
|
783
|
-
if (valid) {
|
|
771
|
+
if (await verifySession(await hmacKeyPromise, sessionValue)) {
|
|
784
772
|
await next();
|
|
785
773
|
return;
|
|
786
774
|
}
|
|
@@ -822,7 +810,6 @@ function createDebugApp(pathPrefix, exporter, logStore, auth) {
|
|
|
822
810
|
});
|
|
823
811
|
return app;
|
|
824
812
|
}
|
|
825
|
-
|
|
826
813
|
//#endregion
|
|
827
814
|
//#region src/mod.tsx
|
|
828
815
|
/**
|
|
@@ -940,6 +927,5 @@ function createFederationDebugger(federation, options) {
|
|
|
940
927
|
}
|
|
941
928
|
});
|
|
942
929
|
}
|
|
943
|
-
|
|
944
930
|
//#endregion
|
|
945
|
-
export { createFederationDebugger, resetAutoSetup };
|
|
931
|
+
export { createFederationDebugger, resetAutoSetup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/debugger",
|
|
3
|
-
"version": "2.2.0-dev.
|
|
3
|
+
"version": "2.2.0-dev.622+e54cb037",
|
|
4
4
|
"description": "Embedded ActivityPub debug dashboard for Fedify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/mod.cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"directory": "packages/debugger"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@fedify/fedify": "^2.2.0-dev.
|
|
32
|
+
"@fedify/fedify": "^2.2.0-dev.622+e54cb037"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@js-temporal/polyfill": "^0.5.1",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"hono": "^4.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"tsdown": "^0.
|
|
45
|
-
"typescript": "^5.9.
|
|
44
|
+
"tsdown": "^0.21.6",
|
|
45
|
+
"typescript": "^5.9.2"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build:self": "tsdown",
|