third-audience-mdx 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +41 -0
- package/INSTALLATION.md +367 -0
- package/README.md +303 -0
- package/WORKLOG.md +162 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +208 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +185 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/dashboard/auth.d.mts +16 -0
- package/dist/dashboard/auth.d.ts +16 -0
- package/dist/dashboard/auth.js +123 -0
- package/dist/dashboard/auth.js.map +1 -0
- package/dist/dashboard/auth.mjs +87 -0
- package/dist/dashboard/auth.mjs.map +1 -0
- package/dist/dashboard/routes/analytics-api-route.d.mts +6 -0
- package/dist/dashboard/routes/analytics-api-route.d.ts +6 -0
- package/dist/dashboard/routes/analytics-api-route.js +180 -0
- package/dist/dashboard/routes/analytics-api-route.js.map +1 -0
- package/dist/dashboard/routes/analytics-api-route.mjs +145 -0
- package/dist/dashboard/routes/analytics-api-route.mjs.map +1 -0
- package/dist/dashboard/routes/api-key-route.d.mts +8 -0
- package/dist/dashboard/routes/api-key-route.d.ts +8 -0
- package/dist/dashboard/routes/api-key-route.js +173 -0
- package/dist/dashboard/routes/api-key-route.js.map +1 -0
- package/dist/dashboard/routes/api-key-route.mjs +137 -0
- package/dist/dashboard/routes/api-key-route.mjs.map +1 -0
- package/dist/dashboard/routes/citation-route.d.mts +14 -0
- package/dist/dashboard/routes/citation-route.d.ts +14 -0
- package/dist/dashboard/routes/citation-route.js +202 -0
- package/dist/dashboard/routes/citation-route.js.map +1 -0
- package/dist/dashboard/routes/citation-route.mjs +166 -0
- package/dist/dashboard/routes/citation-route.mjs.map +1 -0
- package/dist/dashboard/routes/llms-txt-route.d.mts +6 -0
- package/dist/dashboard/routes/llms-txt-route.d.ts +6 -0
- package/dist/dashboard/routes/llms-txt-route.js +119 -0
- package/dist/dashboard/routes/llms-txt-route.js.map +1 -0
- package/dist/dashboard/routes/llms-txt-route.mjs +84 -0
- package/dist/dashboard/routes/llms-txt-route.mjs.map +1 -0
- package/dist/dashboard/routes/login-route.d.mts +6 -0
- package/dist/dashboard/routes/login-route.d.ts +6 -0
- package/dist/dashboard/routes/login-route.js +313 -0
- package/dist/dashboard/routes/login-route.js.map +1 -0
- package/dist/dashboard/routes/login-route.mjs +284 -0
- package/dist/dashboard/routes/login-route.mjs.map +1 -0
- package/dist/dashboard/routes/markdown-route.d.mts +15 -0
- package/dist/dashboard/routes/markdown-route.d.ts +15 -0
- package/dist/dashboard/routes/markdown-route.js +239 -0
- package/dist/dashboard/routes/markdown-route.js.map +1 -0
- package/dist/dashboard/routes/markdown-route.mjs +204 -0
- package/dist/dashboard/routes/markdown-route.mjs.map +1 -0
- package/dist/dashboard/routes/okf-route.d.mts +13 -0
- package/dist/dashboard/routes/okf-route.d.ts +13 -0
- package/dist/dashboard/routes/okf-route.js +184 -0
- package/dist/dashboard/routes/okf-route.js.map +1 -0
- package/dist/dashboard/routes/okf-route.mjs +149 -0
- package/dist/dashboard/routes/okf-route.mjs.map +1 -0
- package/dist/dashboard/routes/sitemap-ai-route.d.mts +6 -0
- package/dist/dashboard/routes/sitemap-ai-route.d.ts +6 -0
- package/dist/dashboard/routes/sitemap-ai-route.js +134 -0
- package/dist/dashboard/routes/sitemap-ai-route.js.map +1 -0
- package/dist/dashboard/routes/sitemap-ai-route.mjs +99 -0
- package/dist/dashboard/routes/sitemap-ai-route.mjs.map +1 -0
- package/dist/dashboard/ui/components/Sidebar.d.mts +5 -0
- package/dist/dashboard/ui/components/Sidebar.d.ts +5 -0
- package/dist/dashboard/ui/components/Sidebar.js +102 -0
- package/dist/dashboard/ui/components/Sidebar.js.map +1 -0
- package/dist/dashboard/ui/components/Sidebar.mjs +68 -0
- package/dist/dashboard/ui/components/Sidebar.mjs.map +1 -0
- package/dist/dashboard/ui/globals.css +175 -0
- package/dist/dashboard/ui/pages/BotAnalyticsPage.d.mts +5 -0
- package/dist/dashboard/ui/pages/BotAnalyticsPage.d.ts +5 -0
- package/dist/dashboard/ui/pages/BotAnalyticsPage.js +269 -0
- package/dist/dashboard/ui/pages/BotAnalyticsPage.js.map +1 -0
- package/dist/dashboard/ui/pages/BotAnalyticsPage.mjs +232 -0
- package/dist/dashboard/ui/pages/BotAnalyticsPage.mjs.map +1 -0
- package/dist/dashboard/ui/pages/BotManagementPage.d.mts +13 -0
- package/dist/dashboard/ui/pages/BotManagementPage.d.ts +13 -0
- package/dist/dashboard/ui/pages/BotManagementPage.js +177 -0
- package/dist/dashboard/ui/pages/BotManagementPage.js.map +1 -0
- package/dist/dashboard/ui/pages/BotManagementPage.mjs +153 -0
- package/dist/dashboard/ui/pages/BotManagementPage.mjs.map +1 -0
- package/dist/dashboard/ui/pages/LlmTrafficPage.d.mts +5 -0
- package/dist/dashboard/ui/pages/LlmTrafficPage.d.ts +5 -0
- package/dist/dashboard/ui/pages/LlmTrafficPage.js +203 -0
- package/dist/dashboard/ui/pages/LlmTrafficPage.js.map +1 -0
- package/dist/dashboard/ui/pages/LlmTrafficPage.mjs +168 -0
- package/dist/dashboard/ui/pages/LlmTrafficPage.mjs.map +1 -0
- package/dist/dashboard/ui/pages/SettingsPage.d.mts +8 -0
- package/dist/dashboard/ui/pages/SettingsPage.d.ts +8 -0
- package/dist/dashboard/ui/pages/SettingsPage.js +181 -0
- package/dist/dashboard/ui/pages/SettingsPage.js.map +1 -0
- package/dist/dashboard/ui/pages/SettingsPage.mjs +157 -0
- package/dist/dashboard/ui/pages/SettingsPage.mjs.map +1 -0
- package/dist/dashboard/ui/pages/SystemHealthPage.d.mts +5 -0
- package/dist/dashboard/ui/pages/SystemHealthPage.d.ts +5 -0
- package/dist/dashboard/ui/pages/SystemHealthPage.js +183 -0
- package/dist/dashboard/ui/pages/SystemHealthPage.js.map +1 -0
- package/dist/dashboard/ui/pages/SystemHealthPage.mjs +148 -0
- package/dist/dashboard/ui/pages/SystemHealthPage.mjs.map +1 -0
- package/dist/index.d.mts +84 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +372 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +346 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/dashboard/routes/llms-txt-route.ts
|
|
31
|
+
var llms_txt_route_exports = {};
|
|
32
|
+
__export(llms_txt_route_exports, {
|
|
33
|
+
GET: () => GET
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(llms_txt_route_exports);
|
|
36
|
+
var import_server = require("next/server");
|
|
37
|
+
var import_path2 = __toESM(require("path"));
|
|
38
|
+
|
|
39
|
+
// src/core/mdx-reader.ts
|
|
40
|
+
var import_fs = __toESM(require("fs"));
|
|
41
|
+
var import_path = __toESM(require("path"));
|
|
42
|
+
var import_gray_matter = __toESM(require("gray-matter"));
|
|
43
|
+
var MdxReader = class {
|
|
44
|
+
constructor(options) {
|
|
45
|
+
this.contentDir = options.contentDir;
|
|
46
|
+
}
|
|
47
|
+
/** Read a single MDX file by slug. Returns null if not found. */
|
|
48
|
+
read(slug) {
|
|
49
|
+
const candidates = [
|
|
50
|
+
import_path.default.join(this.contentDir, `${slug}.mdx`),
|
|
51
|
+
import_path.default.join(this.contentDir, `${slug}.md`),
|
|
52
|
+
import_path.default.join(this.contentDir, slug, "index.mdx"),
|
|
53
|
+
import_path.default.join(this.contentDir, slug, "index.md")
|
|
54
|
+
];
|
|
55
|
+
for (const filePath of candidates) {
|
|
56
|
+
if (import_fs.default.existsSync(filePath)) {
|
|
57
|
+
return this.parseFile(slug, filePath);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** Read all MDX files recursively. */
|
|
63
|
+
readAll() {
|
|
64
|
+
if (!import_fs.default.existsSync(this.contentDir)) return [];
|
|
65
|
+
return this.walkDir(this.contentDir, this.contentDir);
|
|
66
|
+
}
|
|
67
|
+
walkDir(dir, root) {
|
|
68
|
+
const results = [];
|
|
69
|
+
for (const entry of import_fs.default.readdirSync(dir, { withFileTypes: true })) {
|
|
70
|
+
const fullPath = import_path.default.join(dir, entry.name);
|
|
71
|
+
if (entry.isDirectory()) {
|
|
72
|
+
results.push(...this.walkDir(fullPath, root));
|
|
73
|
+
} else if (entry.name.endsWith(".mdx") || entry.name.endsWith(".md")) {
|
|
74
|
+
const relative = import_path.default.relative(root, fullPath);
|
|
75
|
+
const slug = relative.replace(/\.(mdx|md)$/, "").replace(/\/index$/, "");
|
|
76
|
+
results.push(this.parseFile(slug, fullPath));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return results;
|
|
80
|
+
}
|
|
81
|
+
parseFile(slug, filePath) {
|
|
82
|
+
const raw = import_fs.default.readFileSync(filePath, "utf-8");
|
|
83
|
+
const { data: frontmatter, content: rawContent } = (0, import_gray_matter.default)(raw);
|
|
84
|
+
return { slug, filePath, frontmatter, rawContent };
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/discovery/llms-txt.ts
|
|
89
|
+
function generateLlmsTxt(files, baseUrl) {
|
|
90
|
+
const lines = [
|
|
91
|
+
"# LLMs.txt \u2014 AI-readable content index",
|
|
92
|
+
`# Generated by third-audience-mdx`,
|
|
93
|
+
""
|
|
94
|
+
];
|
|
95
|
+
for (const file of files) {
|
|
96
|
+
const fm = file.frontmatter;
|
|
97
|
+
const url = `${baseUrl.replace(/\/$/, "")}/${file.slug}`;
|
|
98
|
+
const title = String(fm.title ?? file.slug);
|
|
99
|
+
const desc = fm.description ? ` \u2014 ${String(fm.description)}` : "";
|
|
100
|
+
lines.push(`- [${title}](${url})${desc}`);
|
|
101
|
+
}
|
|
102
|
+
return lines.join("\n") + "\n";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/dashboard/routes/llms-txt-route.ts
|
|
106
|
+
var reader = new MdxReader({ contentDir: import_path2.default.join(process.cwd(), process.env.TA_CONTENT_DIR ?? "content") });
|
|
107
|
+
async function GET(req) {
|
|
108
|
+
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL ?? `${req.nextUrl.protocol}//${req.nextUrl.host}`;
|
|
109
|
+
const files = reader.readAll();
|
|
110
|
+
const content = generateLlmsTxt(files, baseUrl);
|
|
111
|
+
return new import_server.NextResponse(content, {
|
|
112
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
GET
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=llms-txt-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dashboard/routes/llms-txt-route.ts","../../../src/core/mdx-reader.ts","../../../src/discovery/llms-txt.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server'\nimport path from 'path'\nimport { MdxReader } from '../../core/mdx-reader.js'\nimport { generateLlmsTxt } from '../../discovery/llms-txt.js'\n\nconst reader = new MdxReader({ contentDir: path.join(process.cwd(), process.env.TA_CONTENT_DIR ?? 'content') })\n\n/** Handler for GET /llms.txt → rewired to /api/third-audience/llms-txt */\nexport async function GET(req: NextRequest) {\n const baseUrl = process.env.NEXT_PUBLIC_SITE_URL\n ?? `${req.nextUrl.protocol}//${req.nextUrl.host}`\n\n const files = reader.readAll()\n const content = generateLlmsTxt(files, baseUrl)\n\n return new NextResponse(content, {\n headers: { 'Content-Type': 'text/plain; charset=utf-8' },\n })\n}\n","import fs from 'fs'\nimport path from 'path'\nimport matter from 'gray-matter'\n\nexport interface MdxFile {\n slug: string // relative path without extension, e.g. 'blog/my-post'\n filePath: string // absolute path to .mdx file\n frontmatter: Record<string, unknown>\n rawContent: string // body after frontmatter\n}\n\nexport interface MdxReaderOptions {\n contentDir: string // absolute path to content directory\n}\n\nexport class MdxReader {\n private contentDir: string\n\n constructor(options: MdxReaderOptions) {\n this.contentDir = options.contentDir\n }\n\n /** Read a single MDX file by slug. Returns null if not found. */\n read(slug: string): MdxFile | null {\n const candidates = [\n path.join(this.contentDir, `${slug}.mdx`),\n path.join(this.contentDir, `${slug}.md`),\n path.join(this.contentDir, slug, 'index.mdx'),\n path.join(this.contentDir, slug, 'index.md'),\n ]\n\n for (const filePath of candidates) {\n if (fs.existsSync(filePath)) {\n return this.parseFile(slug, filePath)\n }\n }\n\n return null\n }\n\n /** Read all MDX files recursively. */\n readAll(): MdxFile[] {\n if (!fs.existsSync(this.contentDir)) return []\n return this.walkDir(this.contentDir, this.contentDir)\n }\n\n private walkDir(dir: string, root: string): MdxFile[] {\n const results: MdxFile[] = []\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const fullPath = path.join(dir, entry.name)\n if (entry.isDirectory()) {\n results.push(...this.walkDir(fullPath, root))\n } else if (entry.name.endsWith('.mdx') || entry.name.endsWith('.md')) {\n const relative = path.relative(root, fullPath)\n const slug = relative.replace(/\\.(mdx|md)$/, '').replace(/\\/index$/, '')\n results.push(this.parseFile(slug, fullPath))\n }\n }\n return results\n }\n\n private parseFile(slug: string, filePath: string): MdxFile {\n const raw = fs.readFileSync(filePath, 'utf-8')\n const { data: frontmatter, content: rawContent } = matter(raw)\n return { slug, filePath, frontmatter, rawContent }\n }\n}\n","import type { MdxFile } from '../core/mdx-reader.js'\n\n/**\n * Generates /llms.txt content from MDX frontmatter.\n * Format: one entry per line — URL, title, description.\n */\nexport function generateLlmsTxt(files: MdxFile[], baseUrl: string): string {\n const lines: string[] = [\n '# LLMs.txt — AI-readable content index',\n `# Generated by third-audience-mdx`,\n '',\n ]\n\n for (const file of files) {\n const fm = file.frontmatter\n const url = `${baseUrl.replace(/\\/$/, '')}/${file.slug}`\n const title = String(fm.title ?? file.slug)\n const desc = fm.description ? ` — ${String(fm.description)}` : ''\n lines.push(`- [${title}](${url})${desc}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,IAAAA,eAAiB;;;ACDjB,gBAAe;AACf,kBAAiB;AACjB,yBAAm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{ NextResponse } from "next/server";
|
|
3
|
+
import path2 from "path";
|
|
4
|
+
|
|
5
|
+
// src/core/mdx-reader.ts
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import matter from "gray-matter";
|
|
9
|
+
var MdxReader = class {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.contentDir = options.contentDir;
|
|
12
|
+
}
|
|
13
|
+
/** Read a single MDX file by slug. Returns null if not found. */
|
|
14
|
+
read(slug) {
|
|
15
|
+
const candidates = [
|
|
16
|
+
path.join(this.contentDir, `${slug}.mdx`),
|
|
17
|
+
path.join(this.contentDir, `${slug}.md`),
|
|
18
|
+
path.join(this.contentDir, slug, "index.mdx"),
|
|
19
|
+
path.join(this.contentDir, slug, "index.md")
|
|
20
|
+
];
|
|
21
|
+
for (const filePath of candidates) {
|
|
22
|
+
if (fs.existsSync(filePath)) {
|
|
23
|
+
return this.parseFile(slug, filePath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/** Read all MDX files recursively. */
|
|
29
|
+
readAll() {
|
|
30
|
+
if (!fs.existsSync(this.contentDir)) return [];
|
|
31
|
+
return this.walkDir(this.contentDir, this.contentDir);
|
|
32
|
+
}
|
|
33
|
+
walkDir(dir, root) {
|
|
34
|
+
const results = [];
|
|
35
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
36
|
+
const fullPath = path.join(dir, entry.name);
|
|
37
|
+
if (entry.isDirectory()) {
|
|
38
|
+
results.push(...this.walkDir(fullPath, root));
|
|
39
|
+
} else if (entry.name.endsWith(".mdx") || entry.name.endsWith(".md")) {
|
|
40
|
+
const relative = path.relative(root, fullPath);
|
|
41
|
+
const slug = relative.replace(/\.(mdx|md)$/, "").replace(/\/index$/, "");
|
|
42
|
+
results.push(this.parseFile(slug, fullPath));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return results;
|
|
46
|
+
}
|
|
47
|
+
parseFile(slug, filePath) {
|
|
48
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
49
|
+
const { data: frontmatter, content: rawContent } = matter(raw);
|
|
50
|
+
return { slug, filePath, frontmatter, rawContent };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/discovery/llms-txt.ts
|
|
55
|
+
function generateLlmsTxt(files, baseUrl) {
|
|
56
|
+
const lines = [
|
|
57
|
+
"# LLMs.txt \u2014 AI-readable content index",
|
|
58
|
+
`# Generated by third-audience-mdx`,
|
|
59
|
+
""
|
|
60
|
+
];
|
|
61
|
+
for (const file of files) {
|
|
62
|
+
const fm = file.frontmatter;
|
|
63
|
+
const url = `${baseUrl.replace(/\/$/, "")}/${file.slug}`;
|
|
64
|
+
const title = String(fm.title ?? file.slug);
|
|
65
|
+
const desc = fm.description ? ` \u2014 ${String(fm.description)}` : "";
|
|
66
|
+
lines.push(`- [${title}](${url})${desc}`);
|
|
67
|
+
}
|
|
68
|
+
return lines.join("\n") + "\n";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/dashboard/routes/llms-txt-route.ts
|
|
72
|
+
var reader = new MdxReader({ contentDir: path2.join(process.cwd(), process.env.TA_CONTENT_DIR ?? "content") });
|
|
73
|
+
async function GET(req) {
|
|
74
|
+
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL ?? `${req.nextUrl.protocol}//${req.nextUrl.host}`;
|
|
75
|
+
const files = reader.readAll();
|
|
76
|
+
const content = generateLlmsTxt(files, baseUrl);
|
|
77
|
+
return new NextResponse(content, {
|
|
78
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
GET
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=llms-txt-route.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dashboard/routes/llms-txt-route.ts","../../../src/core/mdx-reader.ts","../../../src/discovery/llms-txt.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server'\nimport path from 'path'\nimport { MdxReader } from '../../core/mdx-reader.js'\nimport { generateLlmsTxt } from '../../discovery/llms-txt.js'\n\nconst reader = new MdxReader({ contentDir: path.join(process.cwd(), process.env.TA_CONTENT_DIR ?? 'content') })\n\n/** Handler for GET /llms.txt → rewired to /api/third-audience/llms-txt */\nexport async function GET(req: NextRequest) {\n const baseUrl = process.env.NEXT_PUBLIC_SITE_URL\n ?? `${req.nextUrl.protocol}//${req.nextUrl.host}`\n\n const files = reader.readAll()\n const content = generateLlmsTxt(files, baseUrl)\n\n return new NextResponse(content, {\n headers: { 'Content-Type': 'text/plain; charset=utf-8' },\n })\n}\n","import fs from 'fs'\nimport path from 'path'\nimport matter from 'gray-matter'\n\nexport interface MdxFile {\n slug: string // relative path without extension, e.g. 'blog/my-post'\n filePath: string // absolute path to .mdx file\n frontmatter: Record<string, unknown>\n rawContent: string // body after frontmatter\n}\n\nexport interface MdxReaderOptions {\n contentDir: string // absolute path to content directory\n}\n\nexport class MdxReader {\n private contentDir: string\n\n constructor(options: MdxReaderOptions) {\n this.contentDir = options.contentDir\n }\n\n /** Read a single MDX file by slug. Returns null if not found. */\n read(slug: string): MdxFile | null {\n const candidates = [\n path.join(this.contentDir, `${slug}.mdx`),\n path.join(this.contentDir, `${slug}.md`),\n path.join(this.contentDir, slug, 'index.mdx'),\n path.join(this.contentDir, slug, 'index.md'),\n ]\n\n for (const filePath of candidates) {\n if (fs.existsSync(filePath)) {\n return this.parseFile(slug, filePath)\n }\n }\n\n return null\n }\n\n /** Read all MDX files recursively. */\n readAll(): MdxFile[] {\n if (!fs.existsSync(this.contentDir)) return []\n return this.walkDir(this.contentDir, this.contentDir)\n }\n\n private walkDir(dir: string, root: string): MdxFile[] {\n const results: MdxFile[] = []\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const fullPath = path.join(dir, entry.name)\n if (entry.isDirectory()) {\n results.push(...this.walkDir(fullPath, root))\n } else if (entry.name.endsWith('.mdx') || entry.name.endsWith('.md')) {\n const relative = path.relative(root, fullPath)\n const slug = relative.replace(/\\.(mdx|md)$/, '').replace(/\\/index$/, '')\n results.push(this.parseFile(slug, fullPath))\n }\n }\n return results\n }\n\n private parseFile(slug: string, filePath: string): MdxFile {\n const raw = fs.readFileSync(filePath, 'utf-8')\n const { data: frontmatter, content: rawContent } = matter(raw)\n return { slug, filePath, frontmatter, rawContent }\n }\n}\n","import type { MdxFile } from '../core/mdx-reader.js'\n\n/**\n * Generates /llms.txt content from MDX frontmatter.\n * Format: one entry per line — URL, title, description.\n */\nexport function generateLlmsTxt(files: MdxFile[], baseUrl: string): string {\n const lines: string[] = [\n '# LLMs.txt — AI-readable content index',\n `# Generated by third-audience-mdx`,\n '',\n ]\n\n for (const file of files) {\n const fm = file.frontmatter\n const url = `${baseUrl.replace(/\\/$/, '')}/${file.slug}`\n const title = String(fm.title ?? file.slug)\n const desc = fm.description ? ` — ${String(fm.description)}` : ''\n lines.push(`- [${title}](${url})${desc}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n"],"mappings":";AAAA,SAAS,oBAAsC;AAC/C,OAAOA,WAAU;;;ACDjB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,YAAY;AAaZ,IAAM,YAAN,MAAgB;AAAA,EAGrB,YAAY,SAA2B;AACrC,SAAK,aAAa,QAAQ;AAAA,EAC5B;AAAA;AAAA,EAGA,KAAK,MAA8B;AACjC,UAAM,aAAa;AAAA,MACjB,KAAK,KAAK,KAAK,YAAY,GAAG,IAAI,MAAM;AAAA,MACxC,KAAK,KAAK,KAAK,YAAY,GAAG,IAAI,KAAK;AAAA,MACvC,KAAK,KAAK,KAAK,YAAY,MAAM,WAAW;AAAA,MAC5C,KAAK,KAAK,KAAK,YAAY,MAAM,UAAU;AAAA,IAC7C;AAEA,eAAW,YAAY,YAAY;AACjC,UAAI,GAAG,WAAW,QAAQ,GAAG;A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GAAG,SAAS,KAAK,IAAI;AAC1C,UAAM,OAAO,GAAG,cAAc,WAAM,OAAO,GAAG,WAAW,CAAC,KAAK;AAC/D,UAAM,KAAK,MAAM,KAAK,KAAK,GAAG,IAAI,IAAI,EAAE;AAAA,EAC1C;AAEA,SAAO,MAAM,KAAK,IAAI,IAAI;AAC5B;;;AFjBA,IAAM,SAAS,IAAI,UAAU,EAAE,YAAYC,MAAK,KAAK,QAAQ,IAAI,GAAG,QAAQ,IAAI,kBAAkB,SAAS,EAAE,CAAC;AAG9G,eAAsB,IAAI,KAAkB;AAC1C,QAAM,UAAU,QAAQ,IAAI,wBACvB,GAAG,IAAI,QAAQ,QAAQ,KAAK,IAAI,QAAQ,IAAI;AAEjD,QAAM,QAAQ,OAAO,QAAQ;AAC7B,QAAM,UAAU,gBAAgB,OAAO,OAAO;AAE9C,SAAO,IAAI,aAAa,SAAS;AAAA,IAC/B,SAAS,EAAE,gBAAgB,4BAA4B;AAAA,EACzD,CAAC;AACH;","names":["path","path"]}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/dashboard/admin-store.ts
|
|
34
|
+
var admin_store_exports = {};
|
|
35
|
+
__export(admin_store_exports, {
|
|
36
|
+
DEFAULT_PASSWORD: () => DEFAULT_PASSWORD,
|
|
37
|
+
generateApiKey: () => generateApiKey,
|
|
38
|
+
generateDefaultPassword: () => generateDefaultPassword,
|
|
39
|
+
getApiKey: () => getApiKey,
|
|
40
|
+
hashPassword: () => hashPassword,
|
|
41
|
+
initAdmin: () => initAdmin,
|
|
42
|
+
loadAdmin: () => loadAdmin,
|
|
43
|
+
recordLogin: () => recordLogin,
|
|
44
|
+
rotateApiKey: () => rotateApiKey,
|
|
45
|
+
saveAdmin: () => saveAdmin,
|
|
46
|
+
signSession: () => signSession,
|
|
47
|
+
updatePassword: () => updatePassword,
|
|
48
|
+
verifyApiKey: () => verifyApiKey,
|
|
49
|
+
verifyPassword: () => verifyPassword,
|
|
50
|
+
verifySession: () => verifySession
|
|
51
|
+
});
|
|
52
|
+
function adminFilePath() {
|
|
53
|
+
const dataDir = process.env.TA_DATA_DIR ?? "data";
|
|
54
|
+
return import_path.default.join(process.cwd(), dataDir, "ta-admin.json");
|
|
55
|
+
}
|
|
56
|
+
function generateDefaultPassword() {
|
|
57
|
+
return import_crypto.default.randomBytes(6).toString("hex");
|
|
58
|
+
}
|
|
59
|
+
function hashPassword(password) {
|
|
60
|
+
const secret = process.env.THIRD_AUDIENCE_SECRET ?? "ta-salt";
|
|
61
|
+
return import_crypto.default.createHash("sha256").update(secret + password).digest("hex");
|
|
62
|
+
}
|
|
63
|
+
function loadAdmin() {
|
|
64
|
+
const filePath = adminFilePath();
|
|
65
|
+
if (!import_fs.default.existsSync(filePath)) return null;
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(import_fs.default.readFileSync(filePath, "utf-8"));
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function saveAdmin(record) {
|
|
73
|
+
const filePath = adminFilePath();
|
|
74
|
+
const dir = import_path.default.dirname(filePath);
|
|
75
|
+
if (!import_fs.default.existsSync(dir)) import_fs.default.mkdirSync(dir, { recursive: true });
|
|
76
|
+
import_fs.default.writeFileSync(filePath, JSON.stringify(record, null, 2), "utf-8");
|
|
77
|
+
}
|
|
78
|
+
function initAdmin() {
|
|
79
|
+
const existing = loadAdmin();
|
|
80
|
+
if (existing) return { password: "", apiKey: "", isNew: false };
|
|
81
|
+
const apiKey = generateApiKey();
|
|
82
|
+
saveAdmin({
|
|
83
|
+
passwordHash: hashPassword(DEFAULT_PASSWORD),
|
|
84
|
+
isDefaultPassword: true,
|
|
85
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
86
|
+
lastLoginAt: null,
|
|
87
|
+
apiKey: encryptApiKey(apiKey)
|
|
88
|
+
});
|
|
89
|
+
return { password: DEFAULT_PASSWORD, apiKey, isNew: true };
|
|
90
|
+
}
|
|
91
|
+
function verifyPassword(password) {
|
|
92
|
+
const record = loadAdmin();
|
|
93
|
+
if (!record) return false;
|
|
94
|
+
return record.passwordHash === hashPassword(password);
|
|
95
|
+
}
|
|
96
|
+
function updatePassword(newPassword) {
|
|
97
|
+
const record = loadAdmin();
|
|
98
|
+
if (!record) return;
|
|
99
|
+
saveAdmin({
|
|
100
|
+
...record,
|
|
101
|
+
passwordHash: hashPassword(newPassword),
|
|
102
|
+
isDefaultPassword: false
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function recordLogin() {
|
|
106
|
+
const record = loadAdmin();
|
|
107
|
+
if (!record) return;
|
|
108
|
+
saveAdmin({ ...record, lastLoginAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
109
|
+
}
|
|
110
|
+
function getEncryptionKey() {
|
|
111
|
+
const secret = process.env.THIRD_AUDIENCE_SECRET ?? "ta-fallback-key-change-me";
|
|
112
|
+
return import_crypto.default.createHash("sha256").update(secret).digest();
|
|
113
|
+
}
|
|
114
|
+
function encryptApiKey(plaintext) {
|
|
115
|
+
const iv = import_crypto.default.randomBytes(12);
|
|
116
|
+
const key = getEncryptionKey();
|
|
117
|
+
const cipher = import_crypto.default.createCipheriv(CIPHER, key, iv);
|
|
118
|
+
const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
119
|
+
const tag = cipher.getAuthTag();
|
|
120
|
+
return iv.toString("hex") + tag.toString("hex") + encrypted.toString("hex");
|
|
121
|
+
}
|
|
122
|
+
function decryptApiKey(encoded) {
|
|
123
|
+
try {
|
|
124
|
+
const iv = Buffer.from(encoded.slice(0, 24), "hex");
|
|
125
|
+
const tag = Buffer.from(encoded.slice(24, 56), "hex");
|
|
126
|
+
const encrypted = Buffer.from(encoded.slice(56), "hex");
|
|
127
|
+
const key = getEncryptionKey();
|
|
128
|
+
const decipher = import_crypto.default.createDecipheriv(CIPHER, key, iv);
|
|
129
|
+
decipher.setAuthTag(tag);
|
|
130
|
+
return decipher.update(encrypted) + decipher.final("utf8");
|
|
131
|
+
} catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function generateApiKey() {
|
|
136
|
+
return "ta_" + import_crypto.default.randomBytes(24).toString("hex");
|
|
137
|
+
}
|
|
138
|
+
function getApiKey() {
|
|
139
|
+
const record = loadAdmin();
|
|
140
|
+
if (!record?.apiKey) return null;
|
|
141
|
+
return decryptApiKey(record.apiKey);
|
|
142
|
+
}
|
|
143
|
+
function rotateApiKey() {
|
|
144
|
+
const record = loadAdmin();
|
|
145
|
+
if (!record) throw new Error("Admin store not initialised");
|
|
146
|
+
const newKey = generateApiKey();
|
|
147
|
+
saveAdmin({ ...record, apiKey: encryptApiKey(newKey) });
|
|
148
|
+
return newKey;
|
|
149
|
+
}
|
|
150
|
+
function verifyApiKey(key) {
|
|
151
|
+
const stored = getApiKey();
|
|
152
|
+
if (!stored) return false;
|
|
153
|
+
if (key.length !== stored.length) return false;
|
|
154
|
+
return import_crypto.default.timingSafeEqual(Buffer.from(key), Buffer.from(stored));
|
|
155
|
+
}
|
|
156
|
+
function signSession(payload) {
|
|
157
|
+
const secret = process.env.THIRD_AUDIENCE_SECRET ?? "ta-salt";
|
|
158
|
+
const sig = import_crypto.default.createHmac("sha256", secret).update(payload).digest("hex");
|
|
159
|
+
return `${payload}.${sig}`;
|
|
160
|
+
}
|
|
161
|
+
function verifySession(token) {
|
|
162
|
+
const lastDot = token.lastIndexOf(".");
|
|
163
|
+
if (lastDot === -1) return false;
|
|
164
|
+
const payload = token.slice(0, lastDot);
|
|
165
|
+
const sig = token.slice(lastDot + 1);
|
|
166
|
+
const expected = import_crypto.default.createHmac("sha256", process.env.THIRD_AUDIENCE_SECRET ?? "ta-salt").update(payload).digest("hex");
|
|
167
|
+
if (sig.length !== expected.length) return false;
|
|
168
|
+
return import_crypto.default.timingSafeEqual(Buffer.from(sig, "hex"), Buffer.from(expected, "hex"));
|
|
169
|
+
}
|
|
170
|
+
var import_fs, import_path, import_crypto, DEFAULT_PASSWORD, CIPHER;
|
|
171
|
+
var init_admin_store = __esm({
|
|
172
|
+
"src/dashboard/admin-store.ts"() {
|
|
173
|
+
"use strict";
|
|
174
|
+
import_fs = __toESM(require("fs"));
|
|
175
|
+
import_path = __toESM(require("path"));
|
|
176
|
+
import_crypto = __toESM(require("crypto"));
|
|
177
|
+
DEFAULT_PASSWORD = "Chang3M3Now!";
|
|
178
|
+
CIPHER = "aes-256-gcm";
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// src/dashboard/routes/login-route.ts
|
|
183
|
+
var login_route_exports = {};
|
|
184
|
+
__export(login_route_exports, {
|
|
185
|
+
GET: () => GET,
|
|
186
|
+
POST: () => POST
|
|
187
|
+
});
|
|
188
|
+
module.exports = __toCommonJS(login_route_exports);
|
|
189
|
+
var import_server = require("next/server");
|
|
190
|
+
init_admin_store();
|
|
191
|
+
var COOKIE_NAME = "ta_session";
|
|
192
|
+
var COOKIE_MAX_AGE = 60 * 60 * 8;
|
|
193
|
+
var LOGIN_HTML = (error, reset) => `<!DOCTYPE html>
|
|
194
|
+
<html lang="en">
|
|
195
|
+
<head>
|
|
196
|
+
<meta charset="UTF-8">
|
|
197
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
198
|
+
<title>${reset ? "Reset Password" : "Third Audience \u2014 Login"}</title>
|
|
199
|
+
<style>
|
|
200
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
201
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f7; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
|
|
202
|
+
.card { background: #fff; border-radius: 18px; box-shadow: 0 4px 24px rgba(0,0,0,.08); padding: 40px 48px; width: 100%; max-width: 380px; }
|
|
203
|
+
.logo { font-size: 22px; font-weight: 700; color: #1d1d1f; margin-bottom: 8px; }
|
|
204
|
+
.subtitle { font-size: 14px; color: #6e6e73; margin-bottom: 32px; }
|
|
205
|
+
label { display: block; font-size: 13px; font-weight: 500; color: #1d1d1f; margin-bottom: 6px; }
|
|
206
|
+
input[type=password] { width: 100%; padding: 10px 14px; border: 1.5px solid #d2d2d7; border-radius: 10px; font-size: 15px; outline: none; transition: border-color .15s; }
|
|
207
|
+
input[type=password]:focus { border-color: #007aff; }
|
|
208
|
+
.error { background: #fff2f2; border: 1px solid #ffbaba; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #c0392b; margin-bottom: 20px; }
|
|
209
|
+
.btn { width: 100%; background: #007aff; color: #fff; border: none; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 20px; transition: background .15s; }
|
|
210
|
+
.btn:hover { background: #0062cc; }
|
|
211
|
+
.hint { font-size: 12px; color: #6e6e73; text-align: center; margin-top: 16px; }
|
|
212
|
+
</style>
|
|
213
|
+
</head>
|
|
214
|
+
<body>
|
|
215
|
+
<div class="card">
|
|
216
|
+
<div class="logo">Third Audience</div>
|
|
217
|
+
<div class="subtitle">${reset ? "Choose a new password to continue" : "Sign in to your dashboard"}</div>
|
|
218
|
+
${error ? `<div class="error">${error}</div>` : ""}
|
|
219
|
+
<form method="POST">
|
|
220
|
+
${reset ? `
|
|
221
|
+
<div style="margin-bottom:16px">
|
|
222
|
+
<label for="password">New password</label>
|
|
223
|
+
<input id="password" name="password" type="password" autocomplete="new-password" required minlength="8" placeholder="At least 8 characters">
|
|
224
|
+
</div>
|
|
225
|
+
<div>
|
|
226
|
+
<label for="confirm">Confirm password</label>
|
|
227
|
+
<input id="confirm" name="confirm" type="password" autocomplete="new-password" required placeholder="Repeat password">
|
|
228
|
+
</div>
|
|
229
|
+
<input type="hidden" name="action" value="reset">
|
|
230
|
+
<button class="btn" type="submit">Set password</button>
|
|
231
|
+
` : `
|
|
232
|
+
<div>
|
|
233
|
+
<label for="password">Password</label>
|
|
234
|
+
<input id="password" name="password" type="password" autocomplete="current-password" required placeholder="Enter your password">
|
|
235
|
+
</div>
|
|
236
|
+
<button class="btn" type="submit">Sign in</button>
|
|
237
|
+
`}
|
|
238
|
+
<p class="hint">Third Audience Dashboard</p>
|
|
239
|
+
</form>
|
|
240
|
+
</div>
|
|
241
|
+
</body>
|
|
242
|
+
</html>`;
|
|
243
|
+
async function GET(req) {
|
|
244
|
+
const reset = req.nextUrl.searchParams.get("reset") === "1";
|
|
245
|
+
return new import_server.NextResponse(LOGIN_HTML(void 0, reset), {
|
|
246
|
+
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async function POST(req) {
|
|
250
|
+
const body = await req.formData();
|
|
251
|
+
const action = body.get("action");
|
|
252
|
+
const password = body.get("password");
|
|
253
|
+
const confirm = body.get("confirm");
|
|
254
|
+
if (action === "reset") {
|
|
255
|
+
if (!password || password.length < 8) {
|
|
256
|
+
return new import_server.NextResponse(LOGIN_HTML("Password must be at least 8 characters.", true), {
|
|
257
|
+
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
if (password !== confirm) {
|
|
261
|
+
return new import_server.NextResponse(LOGIN_HTML("Passwords do not match.", true), {
|
|
262
|
+
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
const { updatePassword: updatePassword2 } = await Promise.resolve().then(() => (init_admin_store(), admin_store_exports));
|
|
266
|
+
updatePassword2(password);
|
|
267
|
+
const token2 = signSession("admin:" + Date.now());
|
|
268
|
+
const res2 = import_server.NextResponse.redirect(new URL("/third-audience/", req.nextUrl));
|
|
269
|
+
res2.cookies.set(COOKIE_NAME, token2, {
|
|
270
|
+
httpOnly: true,
|
|
271
|
+
sameSite: "strict",
|
|
272
|
+
secure: process.env.NODE_ENV === "production",
|
|
273
|
+
maxAge: COOKIE_MAX_AGE,
|
|
274
|
+
path: "/"
|
|
275
|
+
});
|
|
276
|
+
return res2;
|
|
277
|
+
}
|
|
278
|
+
if (!password || !verifyPassword(password)) {
|
|
279
|
+
return new import_server.NextResponse(LOGIN_HTML("Incorrect password."), {
|
|
280
|
+
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
recordLogin();
|
|
284
|
+
const admin = loadAdmin();
|
|
285
|
+
const token = signSession("admin:" + Date.now());
|
|
286
|
+
if (admin?.isDefaultPassword) {
|
|
287
|
+
const res2 = import_server.NextResponse.redirect(new URL("/third-audience/login?reset=1", req.nextUrl));
|
|
288
|
+
res2.cookies.set(COOKIE_NAME + "_reset", token, {
|
|
289
|
+
httpOnly: true,
|
|
290
|
+
sameSite: "strict",
|
|
291
|
+
secure: process.env.NODE_ENV === "production",
|
|
292
|
+
maxAge: 300,
|
|
293
|
+
// 5 min to complete reset
|
|
294
|
+
path: "/third-audience/login"
|
|
295
|
+
});
|
|
296
|
+
return res2;
|
|
297
|
+
}
|
|
298
|
+
const res = import_server.NextResponse.redirect(new URL("/third-audience/", req.nextUrl));
|
|
299
|
+
res.cookies.set(COOKIE_NAME, token, {
|
|
300
|
+
httpOnly: true,
|
|
301
|
+
sameSite: "strict",
|
|
302
|
+
secure: process.env.NODE_ENV === "production",
|
|
303
|
+
maxAge: COOKIE_MAX_AGE,
|
|
304
|
+
path: "/"
|
|
305
|
+
});
|
|
306
|
+
return res;
|
|
307
|
+
}
|
|
308
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
309
|
+
0 && (module.exports = {
|
|
310
|
+
GET,
|
|
311
|
+
POST
|
|
312
|
+
});
|
|
313
|
+
//# sourceMappingURL=login-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dashboard/admin-store.ts","../../../src/dashboard/routes/login-route.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport crypto from 'crypto'\n\nexport interface AdminRecord {\n passwordHash: string // sha256(secret + password)\n isDefaultPassword: boolean\n createdAt: string\n lastLoginAt: string | null\n apiKey?: string // AES-256-GCM encrypted, for headless/external API callers\n}\n\nfunction adminFilePath(): string {\n const dataDir = process.env.TA_DATA_DIR ?? 'data'\n return path.join(process.cwd(), dataDir, 'ta-admin.json')\n}\n\nexport function generateDefaultPassword(): string {\n return crypto.randomBytes(6).toString('hex') // 12-char hex, easy to type\n}\n\nexport function hashPassword(password: string): string {\n const secret = process.env.THIRD_AUDIENCE_SECRET ?? 'ta-salt'\n return crypto.createHash('sha256').update(secret + password).digest('hex')\n}\n\nexport function loadAdmin(): AdminRecord | null {\n const filePath = adminFilePath()\n if (!fs.existsSync(filePath)) return null\n try {\n return JSON.parse(fs.readFileSync(filePath, 'utf-8')) as AdminRecord\n } catch {\n return null\n }\n}\n\nexport function saveAdmin(record: AdminRecord): void {\n const filePath = adminFilePath()\n const dir = path.dirname(filePath)\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })\n fs.writeFileSync(filePath, JSON.stringify(record, null, 2), 'utf-8')\n}\n\nexport const DEFAULT_PASSWORD = 'Chang3M3Now!'\n\nexport function initAdmin(): { password: string; apiKey: string; isNew: boolean } {\n const existing = loadAdmin()\n if (existing) return { password: '', apiKey: '', isNew: false }\n\n const apiKey = generateApiKey()\n saveAdmin({\n passwordHash: hashPassword(DEFAULT_PASSWORD),\n isDefaultPassword: true,\n createdAt: new Date().toISOString(),\n lastLoginAt: null,\n apiKey: encryptApiKey(apiKey),\n })\n return { password: DEFAULT_PASSWORD, apiKey, isNew: true }\n}\n\nexport function verifyPassword(password: string): boolean {\n const record = loadAdmin()\n if (!record) return false\n return record.passwordHash === hashPassword(password)\n}\n\nexport function updatePassword(newPassword: string): void {\n const record = loadAdmin()\n if (!record) return\n saveAdmin({\n ...record,\n passwordHash: hashPassword(newPassword),\n isDefaultPassword: false,\n })\n}\n\nexport function recordLogin(): void {\n const record = loadAdmin()\n if (!record) return\n saveAdmin({ ...record, lastLoginAt: new Date().toISOString() })\n}\n\n// ---------------------------------------------------------------------------\n// API key — AES-256-GCM encrypted at rest, mirroring WP's SECURE_AUTH_KEY approach\n// ---------------------------------------------------------------------------\n\nconst CIPHER = 'aes-256-gcm'\n\nfunction getEncryptionKey(): Buffer {\n const secret = process.env.THIRD_AUDIENCE_SECRET ?? 'ta-fallback-key-change-me'\n // Derive a 32-byte key from the secret using SHA-256\n return crypto.createHash('sha256').update(secret).digest()\n}\n\nfunction encryptApiKey(plaintext: string): string {\n const iv = crypto.randomBytes(12)\n const key = getEncryptionKey()\n const cipher = crypto.createCipheriv(CIPHER, key, iv) as crypto.CipherGCM\n const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()])\n const tag = cipher.getAuthTag()\n // Format: iv(24 hex) + tag(32 hex) + encrypted(hex)\n return iv.toString('hex') + tag.toString('hex') + encrypted.toString('hex')\n}\n\nfunction decryptApiKey(encoded: string): string | null {\n try {\n const iv = Buffer.from(encoded.slice(0, 24), 'hex')\n const tag = Buffer.from(encoded.slice(24, 56), 'hex')\n const encrypted = Buffer.from(encoded.slice(56), 'hex')\n const key = getEncryptionKey()\n const decipher = crypto.createDecipheriv(CIPHER, key, iv) as crypto.DecipherGCM\n decipher.setAuthTag(tag)\n return decipher.update(encrypted) + decipher.final('utf8')\n } catch {\n return null\n }\n}\n\nexport function generateApiKey(): string {\n return 'ta_' + crypto.randomBytes(24).toString('hex') // 51-char key\n}\n\nexport function getApiKey(): string | null {\n const record = loadAdmin()\n if (!record?.apiKey) return null\n return decryptApiKey(record.apiKey)\n}\n\nexport function rotateApiKey(): string {\n const record = loadAdmin()\n if (!record) throw new Error('Admin store not initialised')\n const newKey = generateApiKey()\n saveAdmin({ ...record, apiKey: encryptApiKey(newKey) })\n return newKey\n}\n\nexport function verifyApiKey(key: string): boolean {\n const stored = getApiKey()\n if (!stored) return false\n if (key.length !== stored.length) return false\n return crypto.timingSafeEqual(Buffer.from(key), Buffer.from(stored))\n}\n\n// ---------------------------------------------------------------------------\n// Session cookie: HMAC-SHA256(secret, userId + timestamp) — stateless, no DB\n// ---------------------------------------------------------------------------\nexport function signSession(payload: string): string {\n const secret = process.env.THIRD_AUDIENCE_SECRET ?? 'ta-salt'\n const sig = crypto.createHmac('sha256', secret).update(payload).digest('hex')\n return `${payload}.${sig}`\n}\n\nexport function verifySession(token: string): boolean {\n const lastDot = token.lastIndexOf('.')\n if (lastDot === -1) return false\n const payload = token.slice(0, lastDot)\n const sig = token.slice(lastDot + 1)\n const expected = crypto.createHmac('sha256', process.env.THIRD_AUDIENCE_SECRET ?? 'ta-salt')\n .update(payload).digest('hex')\n // Constant-time comparison\n if (sig.length !== expected.length) return false\n return crypto.timingSafeEqual(Buffer.from(sig, 'hex'), Buffer.from(expected, 'hex'))\n}\n","import { NextResponse, type NextRequest } from 'next/server'\nimport { verifyPassword, signSession, recordLogin, loadAdmin } from '../admin-store.js'\n\nconst COOKIE_NAME = 'ta_session'\nconst COOKIE_MAX_AGE = 60 * 60 * 8 // 8 hours\n\nconst LOGIN_HTML = (error?: string, reset?: boolean) => `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>${reset ? 'Reset Password' : 'Third Audience — Login'}</title>\n <style>\n *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }\n body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f7; min-height: 100vh; display: flex; align-items: center; justify-content: center; }\n .card { background: #fff; border-radius: 18px; box-shadow: 0 4px 24px rgba(0,0,0,.08); padding: 40px 48px; width: 100%; max-width: 380px; }\n .logo { font-size: 22px; font-weight: 700; color: #1d1d1f; margin-bottom: 8px; }\n .subtitle { font-size: 14px; color: #6e6e73; margin-bottom: 32px; }\n label { display: block; font-size: 13px; font-weight: 500; color: #1d1d1f; margin-bottom: 6px; }\n input[type=password] { width: 100%; padding: 10px 14px; border: 1.5px solid #d2d2d7; border-radius: 10px; font-size: 15px; outline: none; transition: border-color .15s; }\n input[type=password]:focus { border-color: #007aff; }\n .error { background: #fff2f2; border: 1px solid #ffbaba; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #c0392b; margin-bottom: 20px; }\n .btn { width: 100%; background: #007aff; color: #fff; border: none; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 20px; transition: background .15s; }\n .btn:hover { background: #0062cc; }\n .hint { font-size: 12px; color: #6e6e73; text-align: center; margin-top: 16px; }\n </style>\n</head>\n<body>\n <div class=\"card\">\n <div class=\"logo\">Third Audience</div>\n <div class=\"subtitle\">${reset ? 'Choose a new password to continue' : 'Sign in to your dashboard'}</div>\n ${error ? `<div class=\"error\">${error}</div>` : ''}\n <form method=\"POST\">\n ${reset ? `\n <div style=\"margin-bottom:16px\">\n <label for=\"password\">New password</label>\n <input id=\"password\" name=\"password\" type=\"password\" autocomplete=\"new-password\" required minlength=\"8\" placeholder=\"At least 8 characters\">\n </div>\n <div>\n <label for=\"confirm\">Confirm password</label>\n <input id=\"confirm\" name=\"confirm\" type=\"password\" autocomplete=\"new-password\" required placeholder=\"Repeat password\">\n </div>\n <input type=\"hidden\" name=\"action\" value=\"reset\">\n <button class=\"btn\" type=\"submit\">Set password</button>\n ` : `\n <div>\n <label for=\"password\">Password</label>\n <input id=\"password\" name=\"password\" type=\"password\" autocomplete=\"current-password\" required placeholder=\"Enter your password\">\n </div>\n <button class=\"btn\" type=\"submit\">Sign in</button>\n `}\n <p class=\"hint\">Third Audience Dashboard</p>\n </form>\n </div>\n</body>\n</html>`\n\nexport async function GET(req: NextRequest): Promise<NextResponse> {\n const reset = req.nextUrl.searchParams.get('reset') === '1'\n return new NextResponse(LOGIN_HTML(undefined, reset), {\n headers: { 'Content-Type': 'text/html; charset=utf-8' },\n })\n}\n\nexport async function POST(req: NextRequest): Promise<NextResponse> {\n const body = await req.formData()\n const action = body.get('action') as string | null\n const password = body.get('password') as string | null\n const confirm = body.get('confirm') as string | null\n\n if (action === 'reset') {\n if (!password || password.length < 8) {\n return new NextResponse(LOGIN_HTML('Password must be at least 8 characters.', true), {\n headers: { 'Content-Type': 'text/html; charset=utf-8' },\n })\n }\n if (password !== confirm) {\n return new NextResponse(LOGIN_HTML('Passwords do not match.', true), {\n headers: { 'Content-Type': 'text/html; charset=utf-8' },\n })\n }\n const { updatePassword } = await import('../admin-store.js')\n updatePassword(password)\n // Issue new session after reset\n const token = signSession('admin:' + Date.now())\n const res = NextResponse.redirect(new URL('/third-audience/', req.nextUrl))\n res.cookies.set(COOKIE_NAME, token, {\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n maxAge: COOKIE_MAX_AGE,\n path: '/',\n })\n return res\n }\n\n // Normal login\n if (!password || !verifyPassword(password)) {\n return new NextResponse(LOGIN_HTML('Incorrect password.'), {\n headers: { 'Content-Type': 'text/html; charset=utf-8' },\n })\n }\n\n recordLogin()\n\n const admin = loadAdmin()\n const token = signSession('admin:' + Date.now())\n\n // If this was the default password, force reset before entering dashboard\n if (admin?.isDefaultPassword) {\n const res = NextResponse.redirect(new URL('/third-audience/login?reset=1', req.nextUrl))\n // Set a temporary cookie so reset page knows we're authenticated\n res.cookies.set(COOKIE_NAME + '_reset', token, {\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n maxAge: 300, // 5 min to complete reset\n path: '/third-audience/login',\n })\n return res\n }\n\n const res = NextResponse.redirect(new URL('/third-audience/', req.nextUrl))\n res.cookies.set(COOKIE_NAME, token, {\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n maxAge: COOKIE_MAX_AGE,\n path: '/',\n })\n return res\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,SAAS,gBAAwB;AAC/B,QAAM,UAAU,QAAQ,IAAI,eAAe;AAC3C,SAAO,YAAAA,QAAK,KAAK,QAAQ,IAAI,GAAG,SAAS,eAAe;AA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