doccupine 0.0.133 → 0.0.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +274 -19
- package/dist/lib/config-manager.d.ts +8 -1
- package/dist/lib/config-manager.js +98 -4
- package/dist/lib/openapi-types.d.ts +120 -0
- package/dist/lib/openapi-types.js +14 -0
- package/dist/lib/openapi.d.ts +52 -0
- package/dist/lib/openapi.js +603 -0
- package/dist/lib/structures.js +28 -2
- package/dist/lib/types.d.ts +22 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +14 -0
- package/dist/templates/app/api/playground/route.d.ts +1 -0
- package/dist/templates/app/api/playground/route.js +199 -0
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +11 -2
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +10 -0
- package/dist/templates/components/layout/Accordion.d.ts +1 -1
- package/dist/templates/components/layout/Accordion.js +3 -2
- package/dist/templates/components/layout/ActionBar.d.ts +1 -1
- package/dist/templates/components/layout/ActionBar.js +21 -14
- package/dist/templates/components/layout/ApiPlayground.d.ts +1 -0
- package/dist/templates/components/layout/ApiPlayground.js +1083 -0
- package/dist/templates/components/layout/ApiPlaygroundDemo.d.ts +1 -0
- package/dist/templates/components/layout/ApiPlaygroundDemo.js +81 -0
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +10 -22
- package/dist/templates/components/layout/CopyButton.d.ts +1 -0
- package/dist/templates/components/layout/CopyButton.js +68 -0
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +39 -0
- package/dist/templates/components/layout/Mermaid.d.ts +1 -1
- package/dist/templates/components/layout/Mermaid.js +21 -3
- package/dist/templates/components/layout/SharedStyles.d.ts +1 -1
- package/dist/templates/components/layout/SharedStyles.js +0 -4
- package/dist/templates/components/layout/Steps.d.ts +1 -1
- package/dist/templates/components/layout/Steps.js +0 -1
- package/dist/templates/components/layout/Update.d.ts +1 -1
- package/dist/templates/components/layout/Update.js +2 -1
- package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
- package/dist/templates/mdx/accordion.mdx.js +19 -1
- package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/ai-assistant.mdx.js +3 -2
- package/dist/templates/mdx/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/analytics.mdx.js +2 -2
- package/dist/templates/mdx/api-playground.mdx.d.ts +1 -0
- package/dist/templates/mdx/api-playground.mdx.js +158 -0
- package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
- package/dist/templates/mdx/authentication.mdx.js +3 -3
- package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
- package/dist/templates/mdx/buttons.mdx.js +1 -1
- package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
- package/dist/templates/mdx/callouts.mdx.js +1 -1
- package/dist/templates/mdx/cards.mdx.d.ts +1 -1
- package/dist/templates/mdx/cards.mdx.js +1 -1
- package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
- package/dist/templates/mdx/color-swatches.mdx.js +1 -1
- package/dist/templates/mdx/commands.mdx.d.ts +1 -1
- package/dist/templates/mdx/commands.mdx.js +3 -2
- package/dist/templates/mdx/components.mdx.d.ts +1 -1
- package/dist/templates/mdx/components.mdx.js +12 -9
- package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
- package/dist/templates/mdx/deployment-and-hosting.mdx.js +4 -3
- package/dist/templates/mdx/fields.mdx.d.ts +1 -1
- package/dist/templates/mdx/fields.mdx.js +1 -1
- package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
- package/dist/templates/mdx/fonts.mdx.js +2 -2
- package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
- package/dist/templates/mdx/footer-links.mdx.js +1 -1
- package/dist/templates/mdx/frames.mdx.d.ts +1 -1
- package/dist/templates/mdx/frames.mdx.js +1 -1
- package/dist/templates/mdx/globals.mdx.d.ts +1 -1
- package/dist/templates/mdx/globals.mdx.js +1 -1
- package/dist/templates/mdx/icons.mdx.d.ts +1 -1
- package/dist/templates/mdx/icons.mdx.js +1 -1
- package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
- package/dist/templates/mdx/image-and-embeds.mdx.js +1 -1
- package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
- package/dist/templates/mdx/media-and-assets.mdx.js +2 -2
- package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
- package/dist/templates/mdx/mermaid.mdx.js +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.js +2 -2
- package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
- package/dist/templates/mdx/navigation.mdx.js +22 -11
- package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.js +4 -3
- package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/analytics.mdx.js +2 -2
- package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/api-playground.mdx.js +62 -0
- package/dist/templates/mdx/platform/billing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/billing.mdx.js +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.js +1 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.js +12 -2
- package/dist/templates/mdx/platform/custom-domains.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/custom-domains.mdx.js +1 -1
- package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/fonts-settings.mdx.js +1 -1
- package/dist/templates/mdx/platform/footer-links.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/footer-links.mdx.js +47 -0
- package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/import-from-github.mdx.js +91 -0
- package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/mcp.mdx.js +3 -3
- package/dist/templates/mdx/platform/project-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/project-settings.mdx.js +1 -1
- package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/self-updating-docs.mdx.js +113 -0
- package/dist/templates/mdx/platform/team-members.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/team-members.mdx.js +1 -1
- package/dist/templates/mdx/sections.mdx.d.ts +1 -1
- package/dist/templates/mdx/sections.mdx.js +1 -1
- package/dist/templates/mdx/steps.mdx.d.ts +1 -1
- package/dist/templates/mdx/steps.mdx.js +1 -1
- package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
- package/dist/templates/mdx/tabs.mdx.js +1 -1
- package/dist/templates/mdx/theme.mdx.d.ts +1 -1
- package/dist/templates/mdx/theme.mdx.js +1 -1
- package/dist/templates/mdx/update.mdx.d.ts +1 -1
- package/dist/templates/mdx/update.mdx.js +1 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
- package/dist/templates/package.js +6 -6
- package/dist/templates/services/openapi/playgroundAllowlistStub.d.ts +1 -0
- package/dist/templates/services/openapi/playgroundAllowlistStub.js +4 -0
- package/dist/templates/types/openapi.d.ts +1 -0
- package/dist/templates/types/openapi.js +93 -0
- package/dist/templates/utils/apiAnchors.d.ts +1 -0
- package/dist/templates/utils/apiAnchors.js +39 -0
- package/dist/templates/utils/apiSnippets.d.ts +1 -0
- package/dist/templates/utils/apiSnippets.js +94 -0
- package/dist/templates/utils/orderNavItems.d.ts +1 -1
- package/dist/templates/utils/orderNavItems.js +3 -0
- package/dist/templates/utils/playgroundAllowlist.d.ts +1 -0
- package/dist/templates/utils/playgroundAllowlist.js +70 -0
- package/dist/templates/utils/ssrfGuard.d.ts +1 -0
- package/dist/templates/utils/ssrfGuard.js +217 -0
- package/package.json +3 -2
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export const ssrfGuardTemplate = `// SERVER-ONLY. Imported solely by app/api/playground/route.ts (a route handler,
|
|
2
|
+
// which never ships to the client). Performs SSRF-safe outbound requests for
|
|
3
|
+
// the API playground proxy: it resolves the target host, rejects any address in
|
|
4
|
+
// a private/loopback/link-local/metadata range, and pins the connection to the
|
|
5
|
+
// pre-validated IPs so DNS rebinding between check and connect cannot redirect
|
|
6
|
+
// the socket to an internal address.
|
|
7
|
+
|
|
8
|
+
import dns from "node:dns/promises";
|
|
9
|
+
import net from "node:net";
|
|
10
|
+
import http from "node:http";
|
|
11
|
+
import https from "node:https";
|
|
12
|
+
import type { LookupAddress } from "node:dns";
|
|
13
|
+
import type { LookupFunction } from "node:net";
|
|
14
|
+
import type { AllowlistEntry } from "@/utils/playgroundAllowlist";
|
|
15
|
+
|
|
16
|
+
export class BlockedError extends Error {
|
|
17
|
+
constructor(public reason: string) {
|
|
18
|
+
super(reason);
|
|
19
|
+
this.name = "BlockedError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface GuardedInit {
|
|
24
|
+
method: string;
|
|
25
|
+
headers: Record<string, string>;
|
|
26
|
+
body?: Buffer;
|
|
27
|
+
timeoutMs: number;
|
|
28
|
+
maxBytes: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface GuardedResult {
|
|
32
|
+
status: number;
|
|
33
|
+
statusText: string;
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
body: Buffer;
|
|
36
|
+
truncated: boolean;
|
|
37
|
+
durationMs: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isBlockedIpv4(ip: string): boolean {
|
|
41
|
+
const parts = ip.split(".");
|
|
42
|
+
if (parts.length !== 4) return true;
|
|
43
|
+
const nums = parts.map((p) => Number(p));
|
|
44
|
+
if (nums.some((n) => !Number.isInteger(n) || n < 0 || n > 255)) return true;
|
|
45
|
+
const a = nums[0];
|
|
46
|
+
const b = nums[1];
|
|
47
|
+
const c = nums[2];
|
|
48
|
+
if (a === 0 || a === 10 || a === 127) return true;
|
|
49
|
+
if (a === 169 && b === 254) return true; // link-local incl. metadata
|
|
50
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
51
|
+
if (a === 192 && b === 168) return true;
|
|
52
|
+
if (a === 192 && b === 0 && c === 0) return true;
|
|
53
|
+
if (a === 100 && b >= 64 && b <= 127) return true; // CGNAT
|
|
54
|
+
if (a === 198 && (b === 18 || b === 19)) return true; // benchmarking
|
|
55
|
+
if (a >= 224) return true; // multicast + reserved + broadcast
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isBlockedIpv6(ip: string): boolean {
|
|
60
|
+
const clean = ip.toLowerCase().split("%")[0];
|
|
61
|
+
if (clean === "::" || clean === "::1") return true;
|
|
62
|
+
if (clean.startsWith("::ffff:")) {
|
|
63
|
+
const rest = clean.slice("::ffff:".length);
|
|
64
|
+
if (rest.includes(".")) return isBlockedIpv4(rest);
|
|
65
|
+
const segs = rest.split(":");
|
|
66
|
+
if (segs.length === 2) {
|
|
67
|
+
const hi = parseInt(segs[0], 16);
|
|
68
|
+
const lo = parseInt(segs[1], 16);
|
|
69
|
+
if (Number.isInteger(hi) && Number.isInteger(lo)) {
|
|
70
|
+
const v4 = [(hi >> 8) & 255, hi & 255, (lo >> 8) & 255, lo & 255].join(
|
|
71
|
+
".",
|
|
72
|
+
);
|
|
73
|
+
return isBlockedIpv4(v4);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const head = clean.split(":")[0];
|
|
78
|
+
if (
|
|
79
|
+
head.startsWith("fe8") ||
|
|
80
|
+
head.startsWith("fe9") ||
|
|
81
|
+
head.startsWith("fea") ||
|
|
82
|
+
head.startsWith("feb")
|
|
83
|
+
) {
|
|
84
|
+
return true; // link-local fe80::/10
|
|
85
|
+
}
|
|
86
|
+
if (head.startsWith("fc") || head.startsWith("fd")) return true; // unique-local
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isBlockedIp(ip: string): boolean {
|
|
91
|
+
const type = net.isIP(ip);
|
|
92
|
+
if (type === 4) return isBlockedIpv4(ip);
|
|
93
|
+
if (type === 6) return isBlockedIpv6(ip);
|
|
94
|
+
return true; // not a parseable IP -> fail closed
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function flattenHeaders(
|
|
98
|
+
headers: http.IncomingHttpHeaders,
|
|
99
|
+
): Record<string, string> {
|
|
100
|
+
const out: Record<string, string> = {};
|
|
101
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
102
|
+
if (value === undefined) continue;
|
|
103
|
+
out[key.toLowerCase()] = Array.isArray(value) ? value.join(", ") : value;
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function guardedFetch(
|
|
109
|
+
targetUrl: string,
|
|
110
|
+
entry: AllowlistEntry,
|
|
111
|
+
init: GuardedInit,
|
|
112
|
+
): Promise<GuardedResult> {
|
|
113
|
+
const url = new URL(targetUrl);
|
|
114
|
+
let host = url.hostname.toLowerCase();
|
|
115
|
+
if (host.endsWith(".")) host = host.slice(0, -1);
|
|
116
|
+
|
|
117
|
+
const literalType = net.isIP(host);
|
|
118
|
+
let validated: LookupAddress[];
|
|
119
|
+
|
|
120
|
+
if (literalType !== 0) {
|
|
121
|
+
// Raw-IP target: only allowed if the spec itself declared this host, and
|
|
122
|
+
// only into a private range when it opted in via allowPrivate.
|
|
123
|
+
if (isBlockedIp(host) && !entry.allowPrivate) {
|
|
124
|
+
throw new BlockedError("blocked: private IP-literal target");
|
|
125
|
+
}
|
|
126
|
+
validated = [{ address: host, family: literalType }];
|
|
127
|
+
} else {
|
|
128
|
+
let records: LookupAddress[];
|
|
129
|
+
try {
|
|
130
|
+
records = await dns.lookup(host, { all: true, verbatim: true });
|
|
131
|
+
} catch {
|
|
132
|
+
throw new BlockedError("blocked: DNS resolution failed");
|
|
133
|
+
}
|
|
134
|
+
if (records.length === 0) throw new BlockedError("blocked: no DNS records");
|
|
135
|
+
if (!entry.allowPrivate) {
|
|
136
|
+
for (const record of records) {
|
|
137
|
+
if (isBlockedIp(record.address)) {
|
|
138
|
+
throw new BlockedError("blocked: private IP");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
validated = records;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const isHttps = url.protocol === "https:";
|
|
146
|
+
const transport = isHttps ? https : http;
|
|
147
|
+
|
|
148
|
+
// Pin resolution to the addresses we just validated so a re-resolution
|
|
149
|
+
// between check and connect (DNS rebinding) cannot swap in a private IP.
|
|
150
|
+
const lookup: LookupFunction = (_hostname, options, callback) => {
|
|
151
|
+
if (options && options.all) {
|
|
152
|
+
callback(null, validated);
|
|
153
|
+
} else {
|
|
154
|
+
callback(null, validated[0].address, validated[0].family);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const requestOptions: https.RequestOptions = {
|
|
159
|
+
method: init.method,
|
|
160
|
+
headers: init.headers,
|
|
161
|
+
lookup,
|
|
162
|
+
timeout: init.timeoutMs,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
return await new Promise<GuardedResult>((resolve, reject) => {
|
|
166
|
+
const start = Date.now();
|
|
167
|
+
let settled = false;
|
|
168
|
+
const done = (fn: () => void) => {
|
|
169
|
+
if (settled) return;
|
|
170
|
+
settled = true;
|
|
171
|
+
fn();
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const req = transport.request(url, requestOptions, (res) => {
|
|
175
|
+
const chunks: Buffer[] = [];
|
|
176
|
+
let received = 0;
|
|
177
|
+
let truncated = false;
|
|
178
|
+
|
|
179
|
+
res.on("data", (chunk: Buffer) => {
|
|
180
|
+
received += chunk.length;
|
|
181
|
+
if (received > init.maxBytes) {
|
|
182
|
+
truncated = true;
|
|
183
|
+
res.destroy();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
chunks.push(chunk);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const finish = () =>
|
|
190
|
+
done(() =>
|
|
191
|
+
resolve({
|
|
192
|
+
status: res.statusCode ?? 0,
|
|
193
|
+
statusText: res.statusMessage ?? "",
|
|
194
|
+
headers: flattenHeaders(res.headers),
|
|
195
|
+
body: Buffer.concat(chunks),
|
|
196
|
+
truncated,
|
|
197
|
+
durationMs: Date.now() - start,
|
|
198
|
+
}),
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
res.on("end", finish);
|
|
202
|
+
res.on("close", finish);
|
|
203
|
+
res.on("error", () => done(() => reject(new Error("stream error"))));
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
req.on("timeout", () => {
|
|
207
|
+
req.destroy(new Error("timeout"));
|
|
208
|
+
});
|
|
209
|
+
req.on("error", (err) => done(() => reject(err)));
|
|
210
|
+
|
|
211
|
+
if (init.body && init.method !== "GET" && init.method !== "HEAD") {
|
|
212
|
+
req.write(init.body);
|
|
213
|
+
}
|
|
214
|
+
req.end();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doccupine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.134",
|
|
4
4
|
"description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -34,12 +34,13 @@
|
|
|
34
34
|
"author": "Luan Gjokaj",
|
|
35
35
|
"license": "SEE LICENSE IN LICENSE",
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@readme/openapi-parser": "^6.3.0",
|
|
37
38
|
"chalk": "^5.6.2",
|
|
38
39
|
"chokidar": "^5.0.0",
|
|
39
40
|
"commander": "^15.0.0",
|
|
40
41
|
"fs-extra": "^11.4.0",
|
|
41
42
|
"gray-matter": "^4.0.3",
|
|
42
|
-
"next": "^16.2.
|
|
43
|
+
"next": "^16.2.12",
|
|
43
44
|
"prompts": "^2.4.2",
|
|
44
45
|
"react": "^19.2.8",
|
|
45
46
|
"react-dom": "^19.2.8"
|