zigrix 0.1.0-alpha.7 → 0.1.0-alpha.9
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/LICENSE +1 -1
- package/README.md +248 -112
- package/dist/agents/registry.js +5 -2
- package/dist/agents/roles.d.ts +10 -0
- package/dist/agents/roles.js +83 -0
- package/dist/config/defaults.d.ts +2 -1
- package/dist/config/defaults.js +2 -1
- package/dist/config/schema.d.ts +25 -3
- package/dist/config/schema.js +34 -2
- package/dist/configure.d.ts +1 -0
- package/dist/configure.js +14 -1
- package/dist/dashboard/.next/BUILD_ID +1 -1
- package/dist/dashboard/.next/app-build-manifest.json +10 -10
- package/dist/dashboard/.next/app-path-routes-manifest.json +4 -4
- package/dist/dashboard/.next/build-manifest.json +2 -2
- package/dist/dashboard/.next/server/app/_not-found.html +1 -1
- package/dist/dashboard/.next/server/app/_not-found.rsc +1 -1
- package/dist/dashboard/.next/server/app/api/auth/login/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/auth/logout/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/auth/session/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/auth/setup/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/overview/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/stream/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/tasks/[taskId]/cancel/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/tasks/[taskId]/conversation/route.js +1 -1
- package/dist/dashboard/.next/server/app/api/tasks/[taskId]/route.js +1 -1
- package/dist/dashboard/.next/server/app/login.html +1 -1
- package/dist/dashboard/.next/server/app/login.rsc +1 -1
- package/dist/dashboard/.next/server/app/setup.html +1 -1
- package/dist/dashboard/.next/server/app/setup.rsc +1 -1
- package/dist/dashboard/.next/server/app-paths-manifest.json +4 -4
- package/dist/dashboard/.next/server/functions-config-manifest.json +3 -3
- package/dist/dashboard/.next/server/middleware.js +1 -1
- package/dist/dashboard/.next/server/pages/404.html +1 -1
- package/dist/dashboard/.next/server/pages/500.html +1 -1
- package/dist/index.js +5 -1
- package/dist/onboard.d.ts +16 -2
- package/dist/onboard.js +128 -9
- package/dist/orchestration/dispatch.d.ts +2 -1
- package/dist/orchestration/dispatch.js +157 -41
- package/dist/orchestration/evidence.js +17 -3
- package/dist/orchestration/finalize.js +2 -2
- package/dist/orchestration/report.js +6 -1
- package/dist/orchestration/worker.d.ts +1 -1
- package/dist/orchestration/worker.js +17 -2
- package/dist/rules/templates.js +3 -6
- package/dist/state/tasks.d.ts +7 -0
- package/package.json +1 -1
- package/skills/zigrix-main-agent-guide/SKILL.md +118 -0
- /package/dist/dashboard/.next/static/{afoa9JVywKLyR6X4Cxspl → TlUj0t8APzTccK13DVZZW}/_buildManifest.js +0 -0
- /package/dist/dashboard/.next/static/{afoa9JVywKLyR6X4Cxspl → TlUj0t8APzTccK13DVZZW}/_ssgManifest.js +0 -0
package/dist/config/schema.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
import { STANDARD_AGENT_ROLES, normalizeAgentRole } from '../agents/roles.js';
|
|
3
3
|
const pathSchema = z.string().min(1);
|
|
4
|
+
const standardRoleSchema = z.enum(STANDARD_AGENT_ROLES);
|
|
5
|
+
const roleSchema = z.string().min(1).transform((value, ctx) => {
|
|
6
|
+
const normalized = normalizeAgentRole(value);
|
|
7
|
+
if (!normalized) {
|
|
8
|
+
ctx.addIssue({
|
|
9
|
+
code: z.ZodIssueCode.custom,
|
|
10
|
+
message: `role must be one of: ${STANDARD_AGENT_ROLES.join(', ')}`,
|
|
11
|
+
});
|
|
12
|
+
return z.NEVER;
|
|
13
|
+
}
|
|
14
|
+
return normalized;
|
|
15
|
+
}).pipe(standardRoleSchema);
|
|
4
16
|
const agentSchema = z.object({
|
|
5
17
|
label: z.string().min(1),
|
|
6
|
-
role:
|
|
18
|
+
role: roleSchema,
|
|
7
19
|
runtime: z.string().min(1),
|
|
8
20
|
enabled: z.boolean().default(true),
|
|
9
21
|
metadata: z.record(z.string(), z.unknown()).default({}),
|
|
@@ -33,6 +45,7 @@ export const zigrixConfigSchema = z.object({
|
|
|
33
45
|
orchestration: z.object({
|
|
34
46
|
participants: z.array(z.string()),
|
|
35
47
|
excluded: z.array(z.string()),
|
|
48
|
+
orchestratorId: z.string().min(1),
|
|
36
49
|
}),
|
|
37
50
|
}).superRefine((value, ctx) => {
|
|
38
51
|
const overlap = value.orchestration.participants.filter((item) => value.orchestration.excluded.includes(item));
|
|
@@ -62,6 +75,25 @@ export const zigrixConfigSchema = z.object({
|
|
|
62
75
|
});
|
|
63
76
|
}
|
|
64
77
|
}
|
|
78
|
+
// Only validate orchestratorId against registry when agents are registered
|
|
79
|
+
// During bootstrap (addAgent one-by-one), registry may not yet include the orchestrator
|
|
80
|
+
const orchestratorId = value.orchestration.orchestratorId;
|
|
81
|
+
const hasOrchestratorInRegistry = knownAgents.has(orchestratorId);
|
|
82
|
+
const hasAnyOrchestrator = Object.values(value.registry).some((agent) => agent.role === 'orchestrator');
|
|
83
|
+
if (hasAnyOrchestrator && !hasOrchestratorInRegistry) {
|
|
84
|
+
ctx.addIssue({
|
|
85
|
+
code: z.ZodIssueCode.custom,
|
|
86
|
+
message: `orchestratorId '${orchestratorId}' must exist in registry`,
|
|
87
|
+
path: ['orchestration', 'orchestratorId'],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (value.orchestration.excluded.includes(orchestratorId)) {
|
|
91
|
+
ctx.addIssue({
|
|
92
|
+
code: z.ZodIssueCode.custom,
|
|
93
|
+
message: `orchestratorId '${orchestratorId}' cannot be excluded`,
|
|
94
|
+
path: ['orchestration', 'orchestratorId'],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
65
97
|
}),
|
|
66
98
|
rules: z.object({
|
|
67
99
|
scales: z.record(z.string(), z.object({
|
package/dist/configure.d.ts
CHANGED
package/dist/configure.js
CHANGED
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { removeAgent } from './agents/registry.js';
|
|
5
5
|
import { loadConfig, writeConfigFile } from './config/load.js';
|
|
6
|
-
import { detectOpenClawHome, ensureZigrixInPath, filterAgents, loadOpenClawConfig, promptAgentSelection, registerAgents, registerSkills, seedRules, } from './onboard.js';
|
|
6
|
+
import { detectOpenClawHome, ensureZigrixInPath, filterAgents, loadOpenClawConfig, promptAgentSelection, ensureOrchestratorId, registerAgents, registerSkills, seedRules, } from './onboard.js';
|
|
7
7
|
import { resolvePaths } from './state/paths.js';
|
|
8
8
|
const ALL_SECTIONS = ['agents', 'rules', 'workspace', 'path', 'skills'];
|
|
9
9
|
// ─── Configure ────────────────────────────────────────────────────────────────
|
|
@@ -81,6 +81,19 @@ export async function runConfigure(options) {
|
|
|
81
81
|
log(`⚠️ ${warnings[warnings.length - 1]}`);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
// ─── orchestrator ────────────────────────────────────────────────────
|
|
85
|
+
if (sections.includes('agents') || options.orchestratorId) {
|
|
86
|
+
const orchResult = ensureOrchestratorId(config, options.orchestratorId);
|
|
87
|
+
config = orchResult.config;
|
|
88
|
+
if (orchResult.changed) {
|
|
89
|
+
configDirty = true;
|
|
90
|
+
log(`✅ Orchestrator set to: ${config.agents.orchestration.orchestratorId}`);
|
|
91
|
+
}
|
|
92
|
+
if (orchResult.warning) {
|
|
93
|
+
warnings.push(orchResult.warning);
|
|
94
|
+
log(`⚠️ ${orchResult.warning}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
84
97
|
// ─── workspace ────────────────────────────────────────────────────────
|
|
85
98
|
if (sections.includes('workspace') && options.projectsBaseDir) {
|
|
86
99
|
const resolved = path.resolve(options.projectsBaseDir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
TlUj0t8APzTccK13DVZZW
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"static/css/9f7ffdac282b0450.css",
|
|
16
16
|
"static/chunks/app/layout-96206a34ff37a783.js"
|
|
17
17
|
],
|
|
18
|
-
"/api/
|
|
18
|
+
"/api/overview/route": [
|
|
19
19
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
20
20
|
"static/chunks/4bd1b696-c023c6e3521b1417.js",
|
|
21
21
|
"static/chunks/255-ebd51be49873d76c.js",
|
|
22
22
|
"static/chunks/main-app-458501fc143f8dcb.js",
|
|
23
|
-
"static/chunks/app/api/
|
|
23
|
+
"static/chunks/app/api/overview/route-aaf047a494f0055f.js"
|
|
24
24
|
],
|
|
25
25
|
"/api/auth/session/route": [
|
|
26
26
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
@@ -29,26 +29,26 @@
|
|
|
29
29
|
"static/chunks/main-app-458501fc143f8dcb.js",
|
|
30
30
|
"static/chunks/app/api/auth/session/route-aaf047a494f0055f.js"
|
|
31
31
|
],
|
|
32
|
-
"/api/auth/
|
|
32
|
+
"/api/auth/login/route": [
|
|
33
33
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
34
34
|
"static/chunks/4bd1b696-c023c6e3521b1417.js",
|
|
35
35
|
"static/chunks/255-ebd51be49873d76c.js",
|
|
36
36
|
"static/chunks/main-app-458501fc143f8dcb.js",
|
|
37
|
-
"static/chunks/app/api/auth/
|
|
37
|
+
"static/chunks/app/api/auth/login/route-aaf047a494f0055f.js"
|
|
38
38
|
],
|
|
39
|
-
"/api/auth/
|
|
39
|
+
"/api/auth/logout/route": [
|
|
40
40
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
41
41
|
"static/chunks/4bd1b696-c023c6e3521b1417.js",
|
|
42
42
|
"static/chunks/255-ebd51be49873d76c.js",
|
|
43
43
|
"static/chunks/main-app-458501fc143f8dcb.js",
|
|
44
|
-
"static/chunks/app/api/auth/
|
|
44
|
+
"static/chunks/app/api/auth/logout/route-aaf047a494f0055f.js"
|
|
45
45
|
],
|
|
46
|
-
"/api/
|
|
46
|
+
"/api/tasks/[taskId]/route": [
|
|
47
47
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
48
48
|
"static/chunks/4bd1b696-c023c6e3521b1417.js",
|
|
49
49
|
"static/chunks/255-ebd51be49873d76c.js",
|
|
50
50
|
"static/chunks/main-app-458501fc143f8dcb.js",
|
|
51
|
-
"static/chunks/app/api/
|
|
51
|
+
"static/chunks/app/api/tasks/[taskId]/route-aaf047a494f0055f.js"
|
|
52
52
|
],
|
|
53
53
|
"/api/tasks/[taskId]/conversation/route": [
|
|
54
54
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"static/chunks/main-app-458501fc143f8dcb.js",
|
|
65
65
|
"static/chunks/app/api/tasks/[taskId]/cancel/route-aaf047a494f0055f.js"
|
|
66
66
|
],
|
|
67
|
-
"/api/
|
|
67
|
+
"/api/auth/setup/route": [
|
|
68
68
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
69
69
|
"static/chunks/4bd1b696-c023c6e3521b1417.js",
|
|
70
70
|
"static/chunks/255-ebd51be49873d76c.js",
|
|
71
71
|
"static/chunks/main-app-458501fc143f8dcb.js",
|
|
72
|
-
"static/chunks/app/api/
|
|
72
|
+
"static/chunks/app/api/auth/setup/route-aaf047a494f0055f.js"
|
|
73
73
|
],
|
|
74
74
|
"/api/stream/route": [
|
|
75
75
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"/_not-found/page": "/_not-found",
|
|
3
|
-
"/api/
|
|
3
|
+
"/api/overview/route": "/api/overview",
|
|
4
4
|
"/api/auth/session/route": "/api/auth/session",
|
|
5
|
-
"/api/auth/setup/route": "/api/auth/setup",
|
|
6
5
|
"/api/auth/login/route": "/api/auth/login",
|
|
7
|
-
"/api/
|
|
6
|
+
"/api/auth/logout/route": "/api/auth/logout",
|
|
7
|
+
"/api/tasks/[taskId]/route": "/api/tasks/[taskId]",
|
|
8
8
|
"/api/tasks/[taskId]/conversation/route": "/api/tasks/[taskId]/conversation",
|
|
9
9
|
"/api/tasks/[taskId]/cancel/route": "/api/tasks/[taskId]/cancel",
|
|
10
|
-
"/api/
|
|
10
|
+
"/api/auth/setup/route": "/api/auth/setup",
|
|
11
11
|
"/api/stream/route": "/api/stream",
|
|
12
12
|
"/login/page": "/login",
|
|
13
13
|
"/setup/page": "/setup",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"devFiles": [],
|
|
6
6
|
"ampDevFiles": [],
|
|
7
7
|
"lowPriorityFiles": [
|
|
8
|
-
"static/
|
|
9
|
-
"static/
|
|
8
|
+
"static/TlUj0t8APzTccK13DVZZW/_buildManifest.js",
|
|
9
|
+
"static/TlUj0t8APzTccK13DVZZW/_ssgManifest.js"
|
|
10
10
|
],
|
|
11
11
|
"rootMainFiles": [
|
|
12
12
|
"static/chunks/webpack-1c485544eee88ef7.js",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><!--
|
|
1
|
+
<!DOCTYPE html><!--TlUj0t8APzTccK13DVZZW--><html lang="ko"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/9f7ffdac282b0450.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-1c485544eee88ef7.js"/><script src="/_next/static/chunks/4bd1b696-c023c6e3521b1417.js" async=""></script><script src="/_next/static/chunks/255-ebd51be49873d76c.js" async=""></script><script src="/_next/static/chunks/main-app-458501fc143f8dcb.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><title>Zigrix Dashboard</title><meta name="description" content="Zigrix task orchestration dashboard"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-1c485544eee88ef7.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[9766,[],\"\"]\n3:I[8924,[],\"\"]\n4:I[4431,[],\"OutletBoundary\"]\n6:I[5278,[],\"AsyncMetadataOutlet\"]\n8:I[4431,[],\"ViewportBoundary\"]\na:I[4431,[],\"MetadataBoundary\"]\nb:\"$Sreact.suspense\"\nd:I[7150,[],\"\"]\n:HL[\"/_next/static/css/9f7ffdac282b0450.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"TlUj0t8APzTccK13DVZZW\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/9f7ffdac282b0450.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"ko\",\"children\":[\"$\",\"body\",null,{\"children\":[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L4\",null,{\"children\":[\"$L5\",[\"$\",\"$L6\",null,{\"promise\":\"$@7\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],null],[\"$\",\"$La\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$b\",null,{\"fallback\":null,\"children\":\"$Lc\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n5:null\n"])</script><script>self.__next_f.push([1,"7:{\"metadata\":[[\"$\",\"title\",\"0\",{\"children\":\"Zigrix Dashboard\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Zigrix task orchestration dashboard\"}]],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"c:\"$7:metadata\"\n"])</script></body></html>
|
|
@@ -8,7 +8,7 @@ a:I[4431,[],"MetadataBoundary"]
|
|
|
8
8
|
b:"$Sreact.suspense"
|
|
9
9
|
d:I[7150,[],""]
|
|
10
10
|
:HL["/_next/static/css/9f7ffdac282b0450.css","style"]
|
|
11
|
-
0:{"P":null,"b":"
|
|
11
|
+
0:{"P":null,"b":"TlUj0t8APzTccK13DVZZW","p":"","c":["","_not-found"],"i":false,"f":[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/9f7ffdac282b0450.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"ko","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":["/_not-found",["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],null,["$","$L4",null,{"children":["$L5",["$","$L6",null,{"promise":"$@7"}]]}]]}],{},null,false]},null,false]},null,false],["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],[["$","$L8",null,{"children":"$L9"}],null],["$","$La",null,{"children":["$","div",null,{"hidden":true,"children":["$","$b",null,{"fallback":null,"children":"$Lc"}]}]}]]}],false]],"m":"$undefined","G":["$d",[]],"s":false,"S":true}
|
|
12
12
|
9:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]
|
|
13
13
|
5:null
|
|
14
14
|
7:{"metadata":[["$","title","0",{"children":"Zigrix Dashboard"}],["$","meta","1",{"name":"description","content":"Zigrix task orchestration dashboard"}]],"error":null,"digest":"$undefined"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var a={};a.id=758,a.ids=[758],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};try{if(new URL(a.url).origin===b)return{allowedOrigin:b,origin:b}}catch{}return{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},57510:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>O,patchFetch:()=>N,routeModule:()=>J,serverHooks:()=>M,workAsyncStorage:()=>K,workUnitAsyncStorage:()=>L});var d={};c.r(d),c.d(d,{OPTIONS:()=>H,POST:()=>I,runtime:()=>G});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360);let w=new Map,x=new Map,y=0;function z(a){return(a||"unknown").trim().toLowerCase()}function A(a){return(a||"").trim().toLowerCase()}function B(a){if(!(a-y<6e4)){y=a;w.forEach((b,c)=>{a-b.lastSeenAtMs>36e4&&w.delete(c)}),x.forEach((b,c)=>{a-b.lastSeenAtMs>36e4&&x.delete(c)})}}function C(a,b,c){let d=a.get(b);if(!d)return null;let e=c-d.firstFailureAtMs>=6e4,f=d.lockedUntilMs<=c;return e&&f?(a.delete(b),null):d}function D(a,b){if(!(b-a.firstFailureAtMs<6e4))return a.lockedUntilMs>b?a.lockedUntilMs:null;let c=Math.max(a.failures>=5?a.firstFailureAtMs+6e4:0,a.lockedUntilMs>b?a.lockedUntilMs:0);return c>b?c:null}function E(a,b,c){let d=a.get(b),e=!d||c-d.firstFailureAtMs>=6e4?{failures:0,firstFailureAtMs:c,lockedUntilMs:0,lastSeenAtMs:c}:d;if(e.failures+=1,e.lastSeenAtMs=c,e.failures>=5){let a=e.failures-5,b=Math.min(3e5,15e3*2**a);e.lockedUntilMs=Math.max(e.lockedUntilMs,c+b)}return a.set(b,e),D(e,c)}var F=c(3563);let G="nodejs";function H(a){return(0,F.rp)(a,["POST","OPTIONS"])}async function I(a){let b,c=(0,F.wx)(a);if(c)return c;if((0,v.dV)())return(0,F.mN)(a,u.NextResponse.json({error:"Setup required"},{status:403}));let d=a.headers.get("x-forwarded-for")?.split(",")[0]?.trim()||a.headers.get("x-real-ip")||"unknown";try{b=await a.json()}catch{return(0,F.mN)(a,u.NextResponse.json({error:"Invalid JSON body"},{status:400}))}if(!b||"object"!=typeof b||Array.isArray(b))return(0,F.mN)(a,u.NextResponse.json({error:"Invalid request body"},{status:400}));let{username:e,password:f}=b;if("string"!=typeof e||!e.trim())return(0,F.mN)(a,u.NextResponse.json({error:"username is required"},{status:400}));if("string"!=typeof f)return(0,F.mN)(a,u.NextResponse.json({error:"password is required"},{status:400}));let g=e.trim(),h=function(a,b){let c=Date.now();B(c);let d=C(w,z(a),c),e=C(x,A(b),c),f=Math.max((d?D(d,c):null)??0,(e?D(e,c):null)??0);return f?{limited:!0,retryAfterSeconds:Math.max(1,Math.ceil((f-c)/1e3))}:{limited:!1,retryAfterSeconds:0}}(d,g);if(h.limited)return(0,F.mN)(a,u.NextResponse.json({error:"Too many attempts. Try again later."},{status:429,headers:{"Retry-After":String(h.retryAfterSeconds)}}));if(!await (0,v.BE)(g,f)){let b=Date.now();return B(b),E(w,z(d),b),E(x,A(g),b),(0,F.mN)(a,u.NextResponse.json({error:"Invalid credentials"},{status:401}))}w.delete(z(d)),x.delete(A(g));let i=await (0,v.jw)(g),j=u.NextResponse.json({ok:!0,username:g});return j.cookies.set(v.IX,i,{httpOnly:!0,secure:!0,sameSite:"lax",maxAge:v.gw,path:"/"}),(0,F.mN)(a,j)}let J=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/login/route",pathname:"/api/auth/login",filename:"route",bundlePath:"app/api/auth/login/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/login/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:K,workUnitAsyncStorage:L,serverHooks:M}=J;function N(){return(0,g.patchFetch)({workAsyncStorage:K,workUnitAsyncStorage:L})}async function O(a,b,c){var d;let e="/api/auth/login/route";"/index"===e&&(e="/");let g=await J.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,resolvedPathname:C}=g,D=(0,j.normalizeAppPath)(e),E=!!(y.dynamicRoutes[D]||y.routes[C]);if(E&&!x){let a=!!y.routes[C],b=y.dynamicRoutes[D];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let F=null;!E||J.isDev||x||(F="/index"===(F=C)?"/":F);let G=!0===J.isDev||!E,H=E&&!G,I=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:G,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:H,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>J.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>J.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${I} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${I} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&A&&B&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!E)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await J.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:H,isOnDemandRevalidate:A})},z),b}},l=await J.handleResponse({req:a,nextConfig:w,cacheKey:F,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,responseGenerator:k,waitUntil:c.waitUntil});if(!E)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",A?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&E||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${I} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":I,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await J.onRequestError(a,b,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:H,isOnDemandRevalidate:A})}),E)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=57510));module.exports=c})();
|
|
1
|
+
(()=>{var a={};a.id=758,a.ids=[758],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};let c=new Set;try{c.add(new URL(a.url).origin)}catch{}let d=a.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),f=a.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),g=a.headers.get("host")?.trim();return(d&&f&&c.add(`${f}://${d}`),g&&(c.add(`https://${g}`),c.add(`http://${g}`)),c.has(b))?{allowedOrigin:b,origin:b}:{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},57510:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>O,patchFetch:()=>N,routeModule:()=>J,serverHooks:()=>M,workAsyncStorage:()=>K,workUnitAsyncStorage:()=>L});var d={};c.r(d),c.d(d,{OPTIONS:()=>H,POST:()=>I,runtime:()=>G});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360);let w=new Map,x=new Map,y=0;function z(a){return(a||"unknown").trim().toLowerCase()}function A(a){return(a||"").trim().toLowerCase()}function B(a){if(!(a-y<6e4)){y=a;w.forEach((b,c)=>{a-b.lastSeenAtMs>36e4&&w.delete(c)}),x.forEach((b,c)=>{a-b.lastSeenAtMs>36e4&&x.delete(c)})}}function C(a,b,c){let d=a.get(b);if(!d)return null;let e=c-d.firstFailureAtMs>=6e4,f=d.lockedUntilMs<=c;return e&&f?(a.delete(b),null):d}function D(a,b){if(!(b-a.firstFailureAtMs<6e4))return a.lockedUntilMs>b?a.lockedUntilMs:null;let c=Math.max(a.failures>=5?a.firstFailureAtMs+6e4:0,a.lockedUntilMs>b?a.lockedUntilMs:0);return c>b?c:null}function E(a,b,c){let d=a.get(b),e=!d||c-d.firstFailureAtMs>=6e4?{failures:0,firstFailureAtMs:c,lockedUntilMs:0,lastSeenAtMs:c}:d;if(e.failures+=1,e.lastSeenAtMs=c,e.failures>=5){let a=e.failures-5,b=Math.min(3e5,15e3*2**a);e.lockedUntilMs=Math.max(e.lockedUntilMs,c+b)}return a.set(b,e),D(e,c)}var F=c(3563);let G="nodejs";function H(a){return(0,F.rp)(a,["POST","OPTIONS"])}async function I(a){let b,c=(0,F.wx)(a);if(c)return c;if((0,v.dV)())return(0,F.mN)(a,u.NextResponse.json({error:"Setup required"},{status:403}));let d=a.headers.get("x-forwarded-for")?.split(",")[0]?.trim()||a.headers.get("x-real-ip")||"unknown";try{b=await a.json()}catch{return(0,F.mN)(a,u.NextResponse.json({error:"Invalid JSON body"},{status:400}))}if(!b||"object"!=typeof b||Array.isArray(b))return(0,F.mN)(a,u.NextResponse.json({error:"Invalid request body"},{status:400}));let{username:e,password:f}=b;if("string"!=typeof e||!e.trim())return(0,F.mN)(a,u.NextResponse.json({error:"username is required"},{status:400}));if("string"!=typeof f)return(0,F.mN)(a,u.NextResponse.json({error:"password is required"},{status:400}));let g=e.trim(),h=function(a,b){let c=Date.now();B(c);let d=C(w,z(a),c),e=C(x,A(b),c),f=Math.max((d?D(d,c):null)??0,(e?D(e,c):null)??0);return f?{limited:!0,retryAfterSeconds:Math.max(1,Math.ceil((f-c)/1e3))}:{limited:!1,retryAfterSeconds:0}}(d,g);if(h.limited)return(0,F.mN)(a,u.NextResponse.json({error:"Too many attempts. Try again later."},{status:429,headers:{"Retry-After":String(h.retryAfterSeconds)}}));if(!await (0,v.BE)(g,f)){let b=Date.now();return B(b),E(w,z(d),b),E(x,A(g),b),(0,F.mN)(a,u.NextResponse.json({error:"Invalid credentials"},{status:401}))}w.delete(z(d)),x.delete(A(g));let i=await (0,v.jw)(g),j=u.NextResponse.json({ok:!0,username:g});return j.cookies.set(v.IX,i,{httpOnly:!0,secure:!0,sameSite:"lax",maxAge:v.gw,path:"/"}),(0,F.mN)(a,j)}let J=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/login/route",pathname:"/api/auth/login",filename:"route",bundlePath:"app/api/auth/login/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/login/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:K,workUnitAsyncStorage:L,serverHooks:M}=J;function N(){return(0,g.patchFetch)({workAsyncStorage:K,workUnitAsyncStorage:L})}async function O(a,b,c){var d;let e="/api/auth/login/route";"/index"===e&&(e="/");let g=await J.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,resolvedPathname:C}=g,D=(0,j.normalizeAppPath)(e),E=!!(y.dynamicRoutes[D]||y.routes[C]);if(E&&!x){let a=!!y.routes[C],b=y.dynamicRoutes[D];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let F=null;!E||J.isDev||x||(F="/index"===(F=C)?"/":F);let G=!0===J.isDev||!E,H=E&&!G,I=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:G,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:H,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>J.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>J.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${I} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${I} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&A&&B&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!E)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await J.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:H,isOnDemandRevalidate:A})},z),b}},l=await J.handleResponse({req:a,nextConfig:w,cacheKey:F,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,responseGenerator:k,waitUntil:c.waitUntil});if(!E)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",A?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&E||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${I} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":I,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await J.onRequestError(a,b,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:H,isOnDemandRevalidate:A})}),E)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=57510));module.exports=c})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var a={};a.id=489,a.ids=[489],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};try{if(new URL(a.url).origin===b)return{allowedOrigin:b,origin:b}}catch{}return{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10086:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>F,patchFetch:()=>E,routeModule:()=>A,serverHooks:()=>D,workAsyncStorage:()=>B,workUnitAsyncStorage:()=>C});var d={};c.r(d),c.d(d,{OPTIONS:()=>y,POST:()=>z,runtime:()=>x});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360),w=c(3563);let x="nodejs";function y(a){return(0,w.rp)(a,["POST","OPTIONS"])}async function z(a){let b=(0,w.wx)(a);if(b)return b;let c=u.NextResponse.json({ok:!0});return c.cookies.set(v.IX,"",{httpOnly:!0,secure:!0,sameSite:"lax",maxAge:0,path:"/"}),(0,w.mN)(a,c)}let A=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/logout/route",pathname:"/api/auth/logout",filename:"route",bundlePath:"app/api/auth/logout/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/logout/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:B,workUnitAsyncStorage:C,serverHooks:D}=A;function E(){return(0,g.patchFetch)({workAsyncStorage:B,workUnitAsyncStorage:C})}async function F(a,b,c){var d;let e="/api/auth/logout/route";"/index"===e&&(e="/");let g=await A.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,resolvedPathname:D}=g,E=(0,j.normalizeAppPath)(e),F=!!(y.dynamicRoutes[E]||y.routes[D]);if(F&&!x){let a=!!y.routes[D],b=y.dynamicRoutes[E];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let G=null;!F||A.isDev||x||(G="/index"===(G=D)?"/":G);let H=!0===A.isDev||!F,I=F&&!H,J=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:H,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:I,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>A.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>A.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${J} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${J} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&B&&C&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!F)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await A.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})},z),b}},l=await A.handleResponse({req:a,nextConfig:w,cacheKey:G,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,responseGenerator:k,waitUntil:c.waitUntil});if(!F)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",B?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&F||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${J} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":J,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await A.onRequestError(a,b,{routerKind:"App Router",routePath:E,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})}),F)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=10086));module.exports=c})();
|
|
1
|
+
(()=>{var a={};a.id=489,a.ids=[489],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};let c=new Set;try{c.add(new URL(a.url).origin)}catch{}let d=a.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),f=a.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),g=a.headers.get("host")?.trim();return(d&&f&&c.add(`${f}://${d}`),g&&(c.add(`https://${g}`),c.add(`http://${g}`)),c.has(b))?{allowedOrigin:b,origin:b}:{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10086:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>F,patchFetch:()=>E,routeModule:()=>A,serverHooks:()=>D,workAsyncStorage:()=>B,workUnitAsyncStorage:()=>C});var d={};c.r(d),c.d(d,{OPTIONS:()=>y,POST:()=>z,runtime:()=>x});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360),w=c(3563);let x="nodejs";function y(a){return(0,w.rp)(a,["POST","OPTIONS"])}async function z(a){let b=(0,w.wx)(a);if(b)return b;let c=u.NextResponse.json({ok:!0});return c.cookies.set(v.IX,"",{httpOnly:!0,secure:!0,sameSite:"lax",maxAge:0,path:"/"}),(0,w.mN)(a,c)}let A=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/logout/route",pathname:"/api/auth/logout",filename:"route",bundlePath:"app/api/auth/logout/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/logout/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:B,workUnitAsyncStorage:C,serverHooks:D}=A;function E(){return(0,g.patchFetch)({workAsyncStorage:B,workUnitAsyncStorage:C})}async function F(a,b,c){var d;let e="/api/auth/logout/route";"/index"===e&&(e="/");let g=await A.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,resolvedPathname:D}=g,E=(0,j.normalizeAppPath)(e),F=!!(y.dynamicRoutes[E]||y.routes[D]);if(F&&!x){let a=!!y.routes[D],b=y.dynamicRoutes[E];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let G=null;!F||A.isDev||x||(G="/index"===(G=D)?"/":G);let H=!0===A.isDev||!F,I=F&&!H,J=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:H,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:I,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>A.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>A.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${J} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${J} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&B&&C&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!F)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await A.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})},z),b}},l=await A.handleResponse({req:a,nextConfig:w,cacheKey:G,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,responseGenerator:k,waitUntil:c.waitUntil});if(!F)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",B?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&F||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${J} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":J,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await A.onRequestError(a,b,{routerKind:"App Router",routePath:E,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})}),F)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=10086));module.exports=c})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var a={};a.id=745,a.ids=[745],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};try{if(new URL(a.url).origin===b)return{allowedOrigin:b,origin:b}}catch{}return{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},85017:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>F,patchFetch:()=>E,routeModule:()=>A,serverHooks:()=>D,workAsyncStorage:()=>B,workUnitAsyncStorage:()=>C});var d={};c.r(d),c.d(d,{GET:()=>z,OPTIONS:()=>y,runtime:()=>x});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360),w=c(3563);let x="nodejs";function y(a){return(0,w.rp)(a,["GET","OPTIONS"])}async function z(a){let b=(0,w.wx)(a);if(b)return b;let c=a.cookies.get(v.IX)?.value,d=await (0,v.gV)(c);return d?(0,w.mN)(a,u.NextResponse.json({authenticated:!0,username:d.username,issuedAt:new Date(1e3*d.issuedAt).toISOString(),expiresAt:new Date(1e3*d.expiresAt).toISOString()})):(0,w.mN)(a,u.NextResponse.json({authenticated:!1},{status:401}))}let A=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/session/route",pathname:"/api/auth/session",filename:"route",bundlePath:"app/api/auth/session/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/session/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:B,workUnitAsyncStorage:C,serverHooks:D}=A;function E(){return(0,g.patchFetch)({workAsyncStorage:B,workUnitAsyncStorage:C})}async function F(a,b,c){var d;let e="/api/auth/session/route";"/index"===e&&(e="/");let g=await A.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,resolvedPathname:D}=g,E=(0,j.normalizeAppPath)(e),F=!!(y.dynamicRoutes[E]||y.routes[D]);if(F&&!x){let a=!!y.routes[D],b=y.dynamicRoutes[E];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let G=null;!F||A.isDev||x||(G="/index"===(G=D)?"/":G);let H=!0===A.isDev||!F,I=F&&!H,J=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:H,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:I,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>A.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>A.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${J} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${J} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&B&&C&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!F)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await A.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})},z),b}},l=await A.handleResponse({req:a,nextConfig:w,cacheKey:G,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,responseGenerator:k,waitUntil:c.waitUntil});if(!F)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",B?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&F||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${J} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":J,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await A.onRequestError(a,b,{routerKind:"App Router",routePath:E,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})}),F)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=85017));module.exports=c})();
|
|
1
|
+
(()=>{var a={};a.id=745,a.ids=[745],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};let c=new Set;try{c.add(new URL(a.url).origin)}catch{}let d=a.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),f=a.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),g=a.headers.get("host")?.trim();return(d&&f&&c.add(`${f}://${d}`),g&&(c.add(`https://${g}`),c.add(`http://${g}`)),c.has(b))?{allowedOrigin:b,origin:b}:{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},85017:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>F,patchFetch:()=>E,routeModule:()=>A,serverHooks:()=>D,workAsyncStorage:()=>B,workUnitAsyncStorage:()=>C});var d={};c.r(d),c.d(d,{GET:()=>z,OPTIONS:()=>y,runtime:()=>x});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360),w=c(3563);let x="nodejs";function y(a){return(0,w.rp)(a,["GET","OPTIONS"])}async function z(a){let b=(0,w.wx)(a);if(b)return b;let c=a.cookies.get(v.IX)?.value,d=await (0,v.gV)(c);return d?(0,w.mN)(a,u.NextResponse.json({authenticated:!0,username:d.username,issuedAt:new Date(1e3*d.issuedAt).toISOString(),expiresAt:new Date(1e3*d.expiresAt).toISOString()})):(0,w.mN)(a,u.NextResponse.json({authenticated:!1},{status:401}))}let A=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/session/route",pathname:"/api/auth/session",filename:"route",bundlePath:"app/api/auth/session/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/session/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:B,workUnitAsyncStorage:C,serverHooks:D}=A;function E(){return(0,g.patchFetch)({workAsyncStorage:B,workUnitAsyncStorage:C})}async function F(a,b,c){var d;let e="/api/auth/session/route";"/index"===e&&(e="/");let g=await A.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,resolvedPathname:D}=g,E=(0,j.normalizeAppPath)(e),F=!!(y.dynamicRoutes[E]||y.routes[D]);if(F&&!x){let a=!!y.routes[D],b=y.dynamicRoutes[E];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let G=null;!F||A.isDev||x||(G="/index"===(G=D)?"/":G);let H=!0===A.isDev||!F,I=F&&!H,J=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:H,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:I,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>A.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>A.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${J} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${J} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&B&&C&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!F)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await A.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})},z),b}},l=await A.handleResponse({req:a,nextConfig:w,cacheKey:G,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:B,revalidateOnlyGenerated:C,responseGenerator:k,waitUntil:c.waitUntil});if(!F)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",B?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&F||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${J} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":J,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await A.onRequestError(a,b,{routerKind:"App Router",routePath:E,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:B})}),F)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=85017));module.exports=c})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var a={};a.id=490,a.ids=[490],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};try{if(new URL(a.url).origin===b)return{allowedOrigin:b,origin:b}}catch{}return{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},47600:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>I,patchFetch:()=>H,routeModule:()=>D,serverHooks:()=>G,workAsyncStorage:()=>E,workUnitAsyncStorage:()=>F});var d={};c.r(d),c.d(d,{GET:()=>B,OPTIONS:()=>A,POST:()=>C,runtime:()=>z});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360),w=c(3563);let x=new Set(["localhost","127.0.0.1","::1","[::1]"]);function y(a){let b=function(a){let b=a.headers.get("x-forwarded-for");if(b){let a=b.split(",")[0]?.trim();if(a)return a}let c=a.headers.get("x-real-ip")?.trim();return c||null}(a);if(b){let a=b.trim().toLowerCase();return!!a&&("::1"===a||"[::1]"===a||a.startsWith("127.")||a.startsWith("::ffff:127."))}try{let b=new URL(a.url).hostname.toLowerCase();return x.has(b)}catch{return!1}}let z="nodejs";function A(a){return(0,w.rp)(a,["GET","POST","OPTIONS"])}async function B(a){let b=(0,w.wx)(a);return b||(y(a)?(0,v.dV)()?(0,w.mN)(a,u.NextResponse.json({setupRequired:!0})):(0,w.mN)(a,u.NextResponse.json({error:"Not found"},{status:404})):(0,w.mN)(a,u.NextResponse.json({error:"Setup is allowed only from local access"},{status:403})))}async function C(a){let b,c=(0,w.wx)(a);if(c)return c;if(!y(a))return(0,w.mN)(a,u.NextResponse.json({error:"Setup is allowed only from local access"},{status:403}));if(!(0,v.dV)())return(0,w.mN)(a,u.NextResponse.json({error:"Not found"},{status:404}));try{b=await a.json()}catch{return(0,w.mN)(a,u.NextResponse.json({error:"Invalid JSON body"},{status:400}))}if(!b||"object"!=typeof b||Array.isArray(b))return(0,w.mN)(a,u.NextResponse.json({error:"Invalid request body"},{status:400}));let{username:d,password:e}=b;if("string"!=typeof d||!d.trim())return(0,w.mN)(a,u.NextResponse.json({error:"username is required"},{status:400}));if("string"!=typeof e||e.length<8)return(0,w.mN)(a,u.NextResponse.json({error:"password must be at least 8 characters"},{status:400}));try{return await (0,v.xC)(d.trim(),e),(0,w.mN)(a,u.NextResponse.json({ok:!0}))}catch(b){return console.error("[setup] Failed to create admin:",b),(0,w.mN)(a,u.NextResponse.json({error:"Failed to create admin account"},{status:500}))}}let D=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/setup/route",pathname:"/api/auth/setup",filename:"route",bundlePath:"app/api/auth/setup/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/setup/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:E,workUnitAsyncStorage:F,serverHooks:G}=D;function H(){return(0,g.patchFetch)({workAsyncStorage:E,workUnitAsyncStorage:F})}async function I(a,b,c){var d;let e="/api/auth/setup/route";"/index"===e&&(e="/");let g=await D.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,resolvedPathname:C}=g,E=(0,j.normalizeAppPath)(e),F=!!(y.dynamicRoutes[E]||y.routes[C]);if(F&&!x){let a=!!y.routes[C],b=y.dynamicRoutes[E];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let G=null;!F||D.isDev||x||(G="/index"===(G=C)?"/":G);let H=!0===D.isDev||!F,I=F&&!H,J=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:H,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:I,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>D.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>D.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${J} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${J} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&A&&B&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!F)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await D.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:A})},z),b}},l=await D.handleResponse({req:a,nextConfig:w,cacheKey:G,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,responseGenerator:k,waitUntil:c.waitUntil});if(!F)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",A?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&F||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${J} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":J,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await D.onRequestError(a,b,{routerKind:"App Router",routePath:E,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:A})}),F)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},48161:a=>{"use strict";a.exports=require("node:os")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=47600));module.exports=c})();
|
|
1
|
+
(()=>{var a={};a.id=490,a.ids=[490],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3563:(a,b,c)=>{"use strict";c.d(b,{mN:()=>i,rp:()=>j,wx:()=>h});var d=c(10641),e=c(67360);function f(a){let b=a.headers.get("origin");if(!b)return{allowedOrigin:null,origin:null};let c=new Set;try{c.add(new URL(a.url).origin)}catch{}let d=a.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),f=a.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),g=a.headers.get("host")?.trim();return(d&&f&&c.add(`${f}://${d}`),g&&(c.add(`https://${g}`),c.add(`http://${g}`)),c.has(b))?{allowedOrigin:b,origin:b}:{allowedOrigin:(function(){let a=(0,e.TI)(),b=new Set;for(let c of a.corsOrigins){if("string"!=typeof c)continue;let a=c.trim();a&&"*"!==a&&b.add(a)}return Array.from(b)})().find(a=>a===b)||null,origin:b}}function g(a){let b=a.get("Vary");if(!b)return void a.set("Vary","Origin");let c=b.split(",").map(a=>a.trim()).filter(Boolean);c.includes("Origin")||(c.push("Origin"),a.set("Vary",c.join(", ")))}function h(a){let{allowedOrigin:b,origin:c}=f(a);if(!c||b)return null;let e=d.NextResponse.json({error:"Forbidden"},{status:403});return g(e.headers),e}function i(a,b){let c=new Headers(b.headers);g(c);let{allowedOrigin:d}=f(a);return d&&(c.set("Access-Control-Allow-Origin",d),c.set("Access-Control-Allow-Credentials","true")),new Response(b.body,{status:b.status,statusText:b.statusText,headers:c})}function j(a,b){let{allowedOrigin:c,origin:e}=f(a);if(e&&!c){let a=d.NextResponse.json({error:"Forbidden"},{status:403});return g(a.headers),a}let h=new d.NextResponse(null,{status:204});if(g(h.headers),!c)return h;let i=a.headers.get("access-control-request-headers");return h.headers.set("Access-Control-Allow-Origin",c),h.headers.set("Access-Control-Allow-Credentials","true"),h.headers.set("Access-Control-Allow-Methods",b.join(", ")),h.headers.set("Access-Control-Allow-Headers",i||"Content-Type, Authorization"),h.headers.set("Access-Control-Max-Age",String(600)),h}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},47600:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>M,patchFetch:()=>L,routeModule:()=>H,serverHooks:()=>K,workAsyncStorage:()=>I,workUnitAsyncStorage:()=>J});var d={};c.r(d),c.d(d,{GET:()=>F,OPTIONS:()=>E,POST:()=>G,runtime:()=>D});var e=c(95736),f=c(9117),g=c(4044),h=c(39326),i=c(32324),j=c(261),k=c(54290),l=c(85328),m=c(38928),n=c(46595),o=c(3421),p=c(17679),q=c(41681),r=c(63446),s=c(86439),t=c(51356),u=c(10641),v=c(67360),w=c(3563);let x=new Set(["localhost","127.0.0.1","::1","[::1]"]);function y(a){return a.trim().toLowerCase()}function z(a){return a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a}function A(a){let b=a.trim().toLowerCase();return z(b.includes(":")&&!b.startsWith("[")?b.split(":")[0]:b)}function B(a){return function(a){let b=z(y(a));return!!b&&("::1"===b||b.startsWith("127.")||b.startsWith("::ffff:127."))}(a)||function(a){let b=z(y(a)).match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(!b)return!1;let c=Number(b[1]),d=Number(b[2]);return![c,d].some(Number.isNaN)&&(10===c||172===c&&d>=16&&d<=31||192===c&&168===d||169===c&&254===d)}(a)||function(a){let b=z(y(a));return b.startsWith("fc")||b.startsWith("fd")||b.startsWith("fe80:")}(a)}function C(a){let b=function(a){let b=a.headers.get("x-forwarded-for");if(b){let a=b.split(",")[0]?.trim();if(a)return a}let c=a.headers.get("x-real-ip")?.trim();return c||null}(a);if(b)return B(b);let c=a.headers.get("x-forwarded-host");if(c){let a=A(c.split(",")[0]||c);if(x.has(a)||B(a)||a.endsWith(".local"))return!0}let d=a.headers.get("host");if(d){let a=A(d);if(x.has(a)||B(a)||a.endsWith(".local"))return!0}try{let b=A(new URL(a.url).hostname);return x.has(b)||B(b)||b.endsWith(".local")}catch{return!1}}let D="nodejs";function E(a){return(0,w.rp)(a,["GET","POST","OPTIONS"])}async function F(a){let b=(0,w.wx)(a);return b||(C(a)?(0,v.dV)()?(0,w.mN)(a,u.NextResponse.json({setupRequired:!0})):(0,w.mN)(a,u.NextResponse.json({error:"Not found"},{status:404})):(0,w.mN)(a,u.NextResponse.json({error:"Setup is allowed only from local/private network access"},{status:403})))}async function G(a){let b,c=(0,w.wx)(a);if(c)return c;if(!C(a))return(0,w.mN)(a,u.NextResponse.json({error:"Setup is allowed only from local/private network access"},{status:403}));if(!(0,v.dV)())return(0,w.mN)(a,u.NextResponse.json({error:"Not found"},{status:404}));try{b=await a.json()}catch{return(0,w.mN)(a,u.NextResponse.json({error:"Invalid JSON body"},{status:400}))}if(!b||"object"!=typeof b||Array.isArray(b))return(0,w.mN)(a,u.NextResponse.json({error:"Invalid request body"},{status:400}));let{username:d,password:e}=b;if("string"!=typeof d||!d.trim())return(0,w.mN)(a,u.NextResponse.json({error:"username is required"},{status:400}));if("string"!=typeof e||e.length<8)return(0,w.mN)(a,u.NextResponse.json({error:"password must be at least 8 characters"},{status:400}));try{return await (0,v.xC)(d.trim(),e),(0,w.mN)(a,u.NextResponse.json({ok:!0}))}catch(b){return console.error("[setup] Failed to create admin:",b),(0,w.mN)(a,u.NextResponse.json({error:"Failed to create admin account"},{status:500}))}}let H=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/auth/setup/route",pathname:"/api/auth/setup",filename:"route",bundlePath:"app/api/auth/setup/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/janos/.openclaw/workspace/projects/zigrix/dashboard/src/app/api/auth/setup/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:I,workUnitAsyncStorage:J,serverHooks:K}=H;function L(){return(0,g.patchFetch)({workAsyncStorage:I,workUnitAsyncStorage:J})}async function M(a,b,c){var d;let e="/api/auth/setup/route";"/index"===e&&(e="/");let g=await H.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,resolvedPathname:C}=g,D=(0,j.normalizeAppPath)(e),E=!!(y.dynamicRoutes[D]||y.routes[C]);if(E&&!x){let a=!!y.routes[C],b=y.dynamicRoutes[D];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let F=null;!E||H.isDev||x||(F="/index"===(F=C)?"/":F);let G=!0===H.isDev||!E,I=E&&!G,J=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:G,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:I,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>H.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>H.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${J} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${J} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&A&&B&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!E)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await H.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:A})},z),b}},l=await H.handleResponse({req:a,nextConfig:w,cacheKey:F,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,responseGenerator:k,waitUntil:c.waitUntil});if(!E)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",A?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&E||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${J} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":J,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await H.onRequestError(a,b,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:A})}),E)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},48161:a=>{"use strict";a.exports=require("node:os")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},67360:(a,b,c)=>{"use strict";c.d(b,{BE:()=>w,IX:()=>n,TI:()=>t,dV:()=>u,gV:()=>A,gw:()=>o,jw:()=>z,xC:()=>v});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(48161),i=c.n(h),j=c(77598),k=c.n(j),l=c(74729),m=c.n(l);let n="zigrix_session",o=43200,p=new TextEncoder,q=new TextDecoder;function r(){return process.env.ZIGRIX_HOME||g().join(i().homedir(),".zigrix")}function s(){return g().join(r(),"dashboard.json")}function t(){let a=s();try{let b=e().readFileSync(a,"utf-8"),c=JSON.parse(b);if(!c||"object"!=typeof c||Array.isArray(c))return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""};return{admins:Array.isArray(c.admins)?c.admins:[],sessionSecret:"string"==typeof c.sessionSecret?c.sessionSecret:"",corsOrigins:Array.isArray(c.corsOrigins)?c.corsOrigins:[],createdAt:"string"==typeof c.createdAt?c.createdAt:""}}catch{return{admins:[],sessionSecret:"",corsOrigins:[],createdAt:""}}}function u(){return 0===t().admins.length}async function v(a,b){let c={admins:[{username:a,passwordHash:await m().hash(b,12)}],sessionSecret:k().randomBytes(64).toString("hex"),corsOrigins:["http://localhost:3000"],createdAt:new Date().toISOString()},d=s(),f=r();e().existsSync(f)||e().mkdirSync(f,{recursive:!0}),e().writeFileSync(d,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384});try{e().chmodSync(d,384)}catch{}}async function w(a,b){let c=t().admins.find(b=>b.username===a);if(!c)return await m().hash(b,12),!1;if(!await m().compare(b,c.passwordHash))return!1;let d=p.encode(a),e=p.encode(c.username);return d.length===e.length&&k().timingSafeEqual(d,e)}function x(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function y(a,b){let c=await k().subtle.importKey("raw",p.encode(b),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return x(new Uint8Array(await k().subtle.sign("HMAC",c,p.encode(a))))}async function z(a){let b=t().sessionSecret;if(!b)throw Error("Session secret not configured. Run setup first.");let c=Math.floor(Date.now()/1e3),d=x(p.encode(JSON.stringify({sub:a,iat:c,exp:c+o}))),e=await y(d,b);return`${d}.${e}`}async function A(a){let b;if(!a)return null;let c=a.split(".");if(2!==c.length)return null;let[d,e]=c;if(!d||!e)return null;let f=t().sessionSecret;if(!f||!function(a,b){if(a.length!==b.length)return!1;let c=p.encode(a),d=p.encode(b);return k().timingSafeEqual(c,d)}(await y(d,f),e))return null;try{let a=q.decode(function(a){let b=a.replace(/-/g,"+").replace(/_/g,"/"),c=b.padEnd(4*Math.ceil(b.length/4),"=");return new Uint8Array(Buffer.from(c,"base64"))}(d));b=JSON.parse(a)}catch{return null}if("number"!=typeof b.exp||"number"!=typeof b.iat)return null;let g=Math.floor(Date.now()/1e3);return b.exp<=g||b.iat>g+60?null:{username:"string"==typeof b.sub?b.sub:"",issuedAt:b.iat,expiresAt:b.exp}}},73024:a=>{"use strict";a.exports=require("node:fs")},74729:a=>{"use strict";a.exports=require("bcryptjs")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[331,692],()=>b(b.s=47600));module.exports=c})();
|