zudoku 0.78.0 → 0.78.2
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/cli/cli.js +602 -160
- package/dist/cli/worker.js +6 -4
- package/dist/declarations/app/adapter.d.ts +12 -0
- package/dist/declarations/app/adapters/cloudflare.d.ts +8 -0
- package/dist/declarations/app/adapters/lambda.d.ts +13 -0
- package/dist/declarations/app/adapters/node.d.ts +12 -0
- package/dist/declarations/app/adapters/vercel.d.ts +14 -0
- package/dist/declarations/app/entry.client.d.ts +2 -0
- package/dist/declarations/app/entry.server.d.ts +13 -0
- package/dist/declarations/app/protectChunks.d.ts +17 -0
- package/dist/declarations/app/wrapProtectedRoutes.d.ts +4 -0
- package/dist/declarations/config/validators/HeaderNavigationSchema.d.ts +216 -80
- package/dist/declarations/config/validators/ZudokuConfig.d.ts +81 -30
- package/dist/declarations/config/validators/icon-types.d.ts +1 -1
- package/dist/declarations/lib/authentication/authentication.d.ts +7 -0
- package/dist/declarations/lib/authentication/cookie-sync.d.ts +3 -0
- package/dist/declarations/lib/authentication/cookies.d.ts +10 -0
- package/dist/declarations/lib/authentication/providers/azureb2c.d.ts +6 -1
- package/dist/declarations/lib/authentication/providers/clerk.d.ts +1 -0
- package/dist/declarations/lib/authentication/providers/openid.d.ts +2 -1
- package/dist/declarations/lib/authentication/providers/supabase.d.ts +2 -0
- package/dist/declarations/lib/authentication/session-handler.d.ts +81 -0
- package/dist/declarations/lib/authentication/state.d.ts +7 -0
- package/dist/declarations/lib/authentication/verify-cache.d.ts +2 -0
- package/dist/declarations/lib/components/Bootstrap.d.ts +2 -2
- package/dist/declarations/lib/components/Heading.d.ts +1 -1
- package/dist/declarations/lib/components/context/RenderContext.d.ts +6 -0
- package/dist/declarations/lib/core/RouteGuard.d.ts +11 -0
- package/dist/declarations/lib/core/ZudokuContext.d.ts +5 -2
- package/dist/declarations/lib/manifest.d.ts +25 -0
- package/dist/declarations/lib/util/url.d.ts +2 -0
- package/dist/flat-config.d.ts +1 -1
- package/docs/configuration/protected-routes.md +21 -4
- package/docs/guides/server-side-content-protection.md +207 -0
- package/package.json +26 -4
- package/src/app/adapter.ts +16 -0
- package/src/app/adapters/cloudflare.ts +18 -0
- package/src/app/adapters/lambda.ts +36 -0
- package/src/app/adapters/node.ts +32 -0
- package/src/app/adapters/vercel.ts +39 -0
- package/src/app/demo.tsx +2 -2
- package/src/app/entry.client.tsx +19 -7
- package/src/app/entry.server.tsx +133 -9
- package/src/app/main.tsx +21 -3
- package/src/app/protectChunks.ts +64 -0
- package/src/app/standalone.tsx +2 -2
- package/src/app/wrapProtectedRoutes.ts +82 -0
- package/src/config/validators/icon-types.ts +17 -0
- package/src/lib/authentication/authentication.ts +15 -0
- package/src/lib/authentication/cookie-sync.ts +90 -0
- package/src/lib/authentication/cookies.ts +54 -0
- package/src/lib/authentication/hook.ts +13 -0
- package/src/lib/authentication/providers/azureb2c.tsx +70 -2
- package/src/lib/authentication/providers/clerk.tsx +49 -0
- package/src/lib/authentication/providers/openid.tsx +46 -0
- package/src/lib/authentication/providers/supabase.tsx +30 -2
- package/src/lib/authentication/session-handler.ts +164 -0
- package/src/lib/authentication/state.ts +36 -5
- package/src/lib/authentication/verify-cache.ts +32 -0
- package/src/lib/components/Bootstrap.tsx +20 -14
- package/src/lib/components/Header.tsx +56 -57
- package/src/lib/components/MobileTopNavigation.tsx +66 -67
- package/src/lib/components/Zudoku.tsx +14 -1
- package/src/lib/components/context/RenderContext.ts +8 -0
- package/src/lib/components/context/ZudokuContext.ts +2 -1
- package/src/lib/core/RouteGuard.tsx +50 -29
- package/src/lib/core/ZudokuContext.ts +39 -6
- package/src/lib/errors/RouterError.tsx +43 -1
- package/src/lib/manifest.ts +62 -0
- package/src/lib/oas/parser/dereference/index.ts +2 -1
- package/src/lib/oas/parser/dereference/resolveRef.ts +2 -1
- package/src/lib/oas/parser/index.ts +1 -1
- package/src/lib/plugins/openapi/client/createServer.ts +13 -4
- package/src/lib/plugins/search-pagefind/index.tsx +1 -4
- package/src/lib/util/os.ts +1 -0
- package/src/lib/util/url.ts +13 -0
- package/src/vite/build.ts +84 -24
- package/src/vite/config.ts +51 -5
- package/src/vite/dev-server.ts +61 -8
- package/src/vite/manifest.ts +15 -0
- package/src/vite/plugin-api.ts +3 -1
- package/src/vite/plugin-markdown-export.ts +3 -9
- package/src/vite/prerender/worker.ts +2 -4
- package/src/vite/protected/annotator.ts +136 -0
- package/src/vite/protected/build.ts +151 -0
- package/src/vite/protected/registry.ts +82 -0
- package/src/vite/ssr-templates/cloudflare.ts +5 -18
- package/src/vite/ssr-templates/lambda.ts +4 -0
- package/src/vite/ssr-templates/node.ts +7 -22
- package/src/vite/ssr-templates/vercel.ts +6 -20
- package/src/vite-env.d.ts +1 -0
package/dist/cli/worker.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import Piscina from "piscina";
|
|
5
|
-
import { matchPath } from "react-router";
|
|
6
5
|
|
|
7
6
|
// src/config/validators/ProtectedRoutesSchema.ts
|
|
8
7
|
import { z } from "zod/mini";
|
|
@@ -45,6 +44,11 @@ var joinUrl = (...parts) => {
|
|
|
45
44
|
return buildUrl(parsedParts);
|
|
46
45
|
};
|
|
47
46
|
|
|
47
|
+
// src/lib/util/url.ts
|
|
48
|
+
import { matchPath } from "react-router";
|
|
49
|
+
var matchesProtectedPattern = (pattern, path2) => matchPath({ path: pattern, end: true }, path2) != null;
|
|
50
|
+
var matchesAnyProtectedPattern = (patterns, path2) => patterns.some((p) => matchesProtectedPattern(p, path2));
|
|
51
|
+
|
|
48
52
|
// src/lib/core/transform-config.ts
|
|
49
53
|
import { isValidElement } from "react";
|
|
50
54
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
@@ -129,9 +133,7 @@ var renderPage = async ({ urlPath }) => {
|
|
|
129
133
|
const outputPath = path.join(distDir, filename);
|
|
130
134
|
const request = new Request(url);
|
|
131
135
|
const protectedRoutes = ProtectedRoutesSchema.parse(config.protectedRoutes);
|
|
132
|
-
const isProtectedRoute = protectedRoutes ? Object.keys(protectedRoutes)
|
|
133
|
-
(route) => matchPath({ path: route, end: true }, urlPath)
|
|
134
|
-
) : false;
|
|
136
|
+
const isProtectedRoute = protectedRoutes ? matchesAnyProtectedPattern(Object.keys(protectedRoutes), urlPath) : false;
|
|
135
137
|
const response = await server.handleRequest({
|
|
136
138
|
template,
|
|
137
139
|
request,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import type { ZudokuManifest } from "../lib/manifest.js";
|
|
3
|
+
import type { protectChunks } from "./protectChunks.js";
|
|
4
|
+
export type AdapterContext = {
|
|
5
|
+
basePath?: string;
|
|
6
|
+
manifest: ZudokuManifest;
|
|
7
|
+
protectChunks: typeof protectChunks;
|
|
8
|
+
};
|
|
9
|
+
export type Adapter<T = Hono> = {
|
|
10
|
+
setup?: (app: Hono, ctx: AdapterContext) => void;
|
|
11
|
+
finalize?: (app: Hono) => T;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { handle } from "hono/aws-lambda";
|
|
2
|
+
import type { Adapter } from "../adapter.js";
|
|
3
|
+
import type { protectChunks } from "../protectChunks.js";
|
|
4
|
+
type ProtectChunksOpts = Parameters<typeof protectChunks>[0];
|
|
5
|
+
type ServeStaticFactory = Extract<ProtectChunksOpts, {
|
|
6
|
+
serveStatic: unknown;
|
|
7
|
+
}>["serveStatic"];
|
|
8
|
+
export type LambdaAdapterOptions = {
|
|
9
|
+
serverDir?: string;
|
|
10
|
+
serveStatic?: ServeStaticFactory;
|
|
11
|
+
};
|
|
12
|
+
export declare const lambda: (opts?: LambdaAdapterOptions) => Adapter<ReturnType<typeof handle>>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Adapter } from "../adapter.js";
|
|
2
|
+
import type { protectChunks } from "../protectChunks.js";
|
|
3
|
+
type ProtectChunksOpts = Parameters<typeof protectChunks>[0];
|
|
4
|
+
type ServeStaticFactory = Extract<ProtectChunksOpts, {
|
|
5
|
+
serveStatic: unknown;
|
|
6
|
+
}>["serveStatic"];
|
|
7
|
+
export type NodeAdapterOptions = {
|
|
8
|
+
serverDir?: string;
|
|
9
|
+
serveStatic?: ServeStaticFactory;
|
|
10
|
+
};
|
|
11
|
+
export declare const node: (opts?: NodeAdapterOptions) => Adapter;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { handle } from "hono/vercel";
|
|
2
|
+
import type { Adapter } from "../adapter.js";
|
|
3
|
+
import type { protectChunks } from "../protectChunks.js";
|
|
4
|
+
type ProtectChunksOpts = Parameters<typeof protectChunks>[0];
|
|
5
|
+
type ServeStaticFactory = Extract<ProtectChunksOpts, {
|
|
6
|
+
serveStatic: unknown;
|
|
7
|
+
}>["serveStatic"];
|
|
8
|
+
export type VercelAdapterOptions = {
|
|
9
|
+
serverDir?: string;
|
|
10
|
+
staticDir?: string;
|
|
11
|
+
serveStatic?: ServeStaticFactory;
|
|
12
|
+
};
|
|
13
|
+
export declare const vercel: (opts?: VercelAdapterOptions) => Adapter<ReturnType<typeof handle>>;
|
|
14
|
+
export {};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
1
2
|
import { type RouteObject } from "react-router";
|
|
2
3
|
import "vite/modulepreload-polyfill";
|
|
4
|
+
import type { Adapter } from "./adapter.js";
|
|
3
5
|
import { getRoutesByConfig } from "./main.js";
|
|
6
|
+
import { protectChunks as rawProtectChunks } from "./protectChunks.js";
|
|
4
7
|
export { getRoutesByConfig };
|
|
8
|
+
export type { Adapter, AdapterContext } from "./adapter.js";
|
|
9
|
+
export declare const protectChunks: typeof rawProtectChunks;
|
|
5
10
|
export declare const handleRequest: ({ template, request, routes, basePath, bypassProtection, }: {
|
|
6
11
|
template: string;
|
|
7
12
|
request: Request;
|
|
@@ -9,3 +14,11 @@ export declare const handleRequest: ({ template, request, routes, basePath, bypa
|
|
|
9
14
|
basePath?: string;
|
|
10
15
|
bypassProtection?: boolean;
|
|
11
16
|
}) => Promise<Response>;
|
|
17
|
+
export declare const manifest: import("../lib/manifest.js").ZudokuManifest;
|
|
18
|
+
export declare const createApp: () => Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
19
|
+
export type MountOptions<T = Hono> = {
|
|
20
|
+
adapter?: Adapter<T>;
|
|
21
|
+
template?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const mount: <T = Hono>(app: Hono, options?: MountOptions<T>) => T;
|
|
24
|
+
export declare const createServer: <T = Hono>(options?: MountOptions<T>) => T;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from "hono";
|
|
2
|
+
type ServeStaticFactory = (opts: {
|
|
3
|
+
root: string;
|
|
4
|
+
rewriteRequestPath?: (p: string) => string;
|
|
5
|
+
}) => MiddlewareHandler;
|
|
6
|
+
type FilesystemServe = {
|
|
7
|
+
serverDir: string;
|
|
8
|
+
serveStatic: ServeStaticFactory;
|
|
9
|
+
};
|
|
10
|
+
type CustomServe = {
|
|
11
|
+
serve: MiddlewareHandler;
|
|
12
|
+
};
|
|
13
|
+
export declare const protectChunks: (opts: {
|
|
14
|
+
basePath?: string;
|
|
15
|
+
verifyAccessToken?: (token: string) => Promise<unknown>;
|
|
16
|
+
} & (FilesystemServe | CustomServe)) => MiddlewareHandler;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RouteObject } from "react-router";
|
|
2
|
+
import type { ProtectedRoutesInput } from "../config/validators/ProtectedRoutesSchema.js";
|
|
3
|
+
export declare const wrapProtectedRoutes: (routes: RouteObject[], protectedRoutes: ProtectedRoutesInput, isAuthenticated: boolean, basePath?: string) => RouteObject[];
|
|
4
|
+
export declare const warnInlineProtectedRoutes: (routes: RouteObject[], protectedRoutes: ProtectedRoutesInput, basePath?: string) => void;
|