@blaaiz/docs-core 0.2.0 → 0.3.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/dist/{chunk-3ZX4WIE3.js → chunk-ICDBGTIJ.js} +89 -3
- package/dist/chunk-ICDBGTIJ.js.map +1 -0
- package/dist/generator.js +1 -1
- package/dist/index.cjs +87 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -1
- package/dist/index.d.ts +74 -1
- package/dist/index.js +1 -1
- package/dist/ui.cjs +1 -1
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.js +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/skills/SKILL.md +59 -45
- package/dist/chunk-3ZX4WIE3.js.map +0 -1
|
@@ -2526,6 +2526,92 @@ function createSignOut(options = {}) {
|
|
|
2526
2526
|
};
|
|
2527
2527
|
}
|
|
2528
2528
|
|
|
2529
|
+
// src/core/auth/site-auth.ts
|
|
2530
|
+
var notConfigured = () => new Response("This sign-in method is not configured for this site.", { status: 501 });
|
|
2531
|
+
var PUBLIC_SITE = {
|
|
2532
|
+
enabled: false,
|
|
2533
|
+
signInPath: "/signin",
|
|
2534
|
+
secretEnabled: false,
|
|
2535
|
+
googleEnabled: false,
|
|
2536
|
+
emailSignIn: () => Promise.resolve(notConfigured()),
|
|
2537
|
+
secretSignIn: () => Promise.resolve(notConfigured()),
|
|
2538
|
+
google: {
|
|
2539
|
+
start: () => notConfigured(),
|
|
2540
|
+
callback: () => Promise.resolve(notConfigured())
|
|
2541
|
+
}
|
|
2542
|
+
};
|
|
2543
|
+
function createSiteAuth(auth, options = {}) {
|
|
2544
|
+
if (auth === "public") {
|
|
2545
|
+
return {
|
|
2546
|
+
...PUBLIC_SITE,
|
|
2547
|
+
gate: () => Promise.resolve(null),
|
|
2548
|
+
signOut: createSignOut()
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
return workspaceSiteAuth(auth, options);
|
|
2552
|
+
}
|
|
2553
|
+
function workspaceSiteAuth(auth, options) {
|
|
2554
|
+
const env = options.env ?? ((name) => process.env[name]);
|
|
2555
|
+
const signInPath = auth.signInPath ?? "/signin";
|
|
2556
|
+
const secure = auth.secureCookies ?? true;
|
|
2557
|
+
const ttlSeconds = auth.sessionTtlSeconds;
|
|
2558
|
+
const sessionSecretEnv = auth.sessionSecretEnv ?? "DOCS_SESSION_SECRET";
|
|
2559
|
+
const secret = env(sessionSecretEnv) ?? "";
|
|
2560
|
+
if (secret === "") {
|
|
2561
|
+
throw new DocsConfigError(
|
|
2562
|
+
`auth.mode is 'workspace': set the ${sessionSecretEnv} environment variable to a long random value (for example: openssl rand -hex 32).`
|
|
2563
|
+
);
|
|
2564
|
+
}
|
|
2565
|
+
const shared = {
|
|
2566
|
+
secret,
|
|
2567
|
+
allowedDomains: auth.allowedDomains,
|
|
2568
|
+
secureCookies: secure,
|
|
2569
|
+
signInPath,
|
|
2570
|
+
...ttlSeconds === void 0 ? {} : { ttlSeconds }
|
|
2571
|
+
};
|
|
2572
|
+
const emailEnabled = auth.providers.email === true;
|
|
2573
|
+
const accessSecret = auth.providers.secret ? env(auth.providers.secret.secretEnv ?? "DOCS_ACCESS_SECRET") ?? "" : "";
|
|
2574
|
+
const secretEnabled = accessSecret !== "";
|
|
2575
|
+
const googleConfig = auth.providers.google;
|
|
2576
|
+
const clientId = googleConfig ? env(googleConfig.clientIdEnv ?? "GOOGLE_CLIENT_ID") : void 0;
|
|
2577
|
+
const clientSecret = googleConfig ? env(googleConfig.clientSecretEnv ?? "GOOGLE_CLIENT_SECRET") : void 0;
|
|
2578
|
+
const googleEnabled = Boolean(googleConfig && clientId && clientSecret);
|
|
2579
|
+
const emailSignIn = emailEnabled ? createEmailSignIn(shared) : null;
|
|
2580
|
+
const secretSignIn = secretEnabled ? createSecretSignIn({ ...shared, accessSecret }) : null;
|
|
2581
|
+
const googleFor = (request) => {
|
|
2582
|
+
if (!googleEnabled || !googleConfig || !clientId || !clientSecret) {
|
|
2583
|
+
return null;
|
|
2584
|
+
}
|
|
2585
|
+
const origin = new URL(request.url).origin;
|
|
2586
|
+
const redirectPath = googleConfig.redirectPath ?? "/api/auth/google/callback";
|
|
2587
|
+
return createGoogleAuth({
|
|
2588
|
+
...shared,
|
|
2589
|
+
clientId,
|
|
2590
|
+
clientSecret,
|
|
2591
|
+
redirectUri: `${origin}${redirectPath}`
|
|
2592
|
+
});
|
|
2593
|
+
};
|
|
2594
|
+
return {
|
|
2595
|
+
enabled: true,
|
|
2596
|
+
signInPath,
|
|
2597
|
+
secretEnabled,
|
|
2598
|
+
googleEnabled,
|
|
2599
|
+
gate: createAuthGate({
|
|
2600
|
+
secret,
|
|
2601
|
+
allowedDomains: auth.allowedDomains,
|
|
2602
|
+
signInPath,
|
|
2603
|
+
publicPaths: [...options.publicPaths ?? ["/api/proxy"]]
|
|
2604
|
+
}),
|
|
2605
|
+
emailSignIn: (request) => emailSignIn?.(request) ?? Promise.resolve(notConfigured()),
|
|
2606
|
+
secretSignIn: (request) => secretSignIn?.(request) ?? Promise.resolve(notConfigured()),
|
|
2607
|
+
google: {
|
|
2608
|
+
start: (request) => googleFor(request)?.start(request) ?? notConfigured(),
|
|
2609
|
+
callback: (request) => googleFor(request)?.callback(request) ?? Promise.resolve(notConfigured())
|
|
2610
|
+
},
|
|
2611
|
+
signOut: createSignOut({ secureCookies: secure, redirectTo: signInPath })
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2529
2615
|
// src/core/proxy.ts
|
|
2530
2616
|
var DEFAULT_RATE_LIMIT_PER_MINUTE2 = 60;
|
|
2531
2617
|
var ProxyTargetError = class extends Error {
|
|
@@ -2979,6 +3065,6 @@ function mergeOpenApiDocuments(inputs, options) {
|
|
|
2979
3065
|
};
|
|
2980
3066
|
}
|
|
2981
3067
|
|
|
2982
|
-
export { AI_PROVIDER_MODELS, AI_PROVIDER_NAMES, AiConfigError, DocsConfigError, InvalidNavigationError, OpenApiMergeError, ProxyTargetError, SESSION_COOKIE, assertAllowedTarget, buildMetadata, buildRobots, buildSearchIndex, buildSessionCookie, buildSitemap, buildThemeCss, clearSessionCookie, createAskAiRoute, createAuthGate, createEmailSignIn, createGoogleAuth, createMarkdownRoute, createSecretSignIn, createSignOut, createTryItProxy, createTryItProxyRoute, defineDocsConfig, isAllowedEmail, mdxToMarkdown, mergeOpenApiDocuments, openApiOperationToMarkdown, parseNavigation, planDocsTree, readCookie, resolveAiConfig, searchIndex, signSession, unwrapProxyTarget, validateDocsConfig, verifySession };
|
|
2983
|
-
//# sourceMappingURL=chunk-
|
|
2984
|
-
//# sourceMappingURL=chunk-
|
|
3068
|
+
export { AI_PROVIDER_MODELS, AI_PROVIDER_NAMES, AiConfigError, DocsConfigError, InvalidNavigationError, OpenApiMergeError, ProxyTargetError, SESSION_COOKIE, assertAllowedTarget, buildMetadata, buildRobots, buildSearchIndex, buildSessionCookie, buildSitemap, buildThemeCss, clearSessionCookie, createAskAiRoute, createAuthGate, createEmailSignIn, createGoogleAuth, createMarkdownRoute, createSecretSignIn, createSignOut, createSiteAuth, createTryItProxy, createTryItProxyRoute, defineDocsConfig, isAllowedEmail, mdxToMarkdown, mergeOpenApiDocuments, openApiOperationToMarkdown, parseNavigation, planDocsTree, readCookie, resolveAiConfig, searchIndex, signSession, unwrapProxyTarget, validateDocsConfig, verifySession };
|
|
3069
|
+
//# sourceMappingURL=chunk-ICDBGTIJ.js.map
|
|
3070
|
+
//# sourceMappingURL=chunk-ICDBGTIJ.js.map
|