@seip/bluebird-js 0.1.7 → 0.2.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/AGENTS.md +726 -620
- package/README.md +615 -607
- package/app/models/user.js +19 -0
- package/app/resources/html/home.html +137 -0
- package/app/resources/html/layouts/main.html +54 -0
- package/app/resources/html/notFound.html +14 -0
- package/app/resources/html/terms.html +46 -0
- package/app/resources/index.html +27 -0
- package/app/resources/layouts/AppLayout.jsx +89 -0
- package/app/resources/main.jsx +18 -0
- package/app/resources/pages/Dashboard.jsx +98 -0
- package/app/resources/pages/Home.jsx +140 -0
- package/app/resources/pages/Login.jsx +35 -0
- package/app/resources/pages/NotFound.jsx +16 -0
- package/app/resources/pages/Register.jsx +55 -0
- package/app/resources/routes.jsx +54 -0
- package/app/resources/spa.js +67 -0
- package/app/resources/styles.css +9 -0
- package/app/routes/api.js +85 -50
- package/app/routes/auth.js +209 -0
- package/app/routes/web.js +59 -47
- package/core/ai.js +30 -10
- package/core/app.d.ts +2 -18
- package/core/app.js +987 -801
- package/core/auth.d.ts +2 -13
- package/core/auth.js +444 -326
- package/core/cli/build.js +37 -0
- package/core/cli/dev.js +155 -0
- package/core/cli/doctor.js +37 -2
- package/core/cli/export.js +191 -0
- package/core/cli/init.js +91 -322
- package/core/cli/nginx.js +1 -1
- package/core/cli/templates.js +139 -0
- package/core/cli/view.js +98 -161
- package/core/config.js +44 -2
- package/core/csrf.js +156 -24
- package/core/database.js +1184 -1131
- package/core/debug.js +1 -1
- package/core/html.js +8 -1
- package/core/index.d.ts +126 -310
- package/core/paths.js +55 -0
- package/core/ratelimit.js +10 -1
- package/core/react/client/api.js +237 -0
- package/core/react/client/auth.js +236 -0
- package/core/react/client/components.js +1321 -0
- package/core/react/client/i18n.js +338 -0
- package/core/react/client/index.d.ts +249 -0
- package/core/react/client/index.js +49 -0
- package/core/react/client/router.js +26 -0
- package/core/react/client/theme.css +512 -0
- package/core/render-cache.js +250 -212
- package/core/render.d.ts +25 -21
- package/core/render.js +738 -736
- package/core/router.d.ts +2 -3
- package/core/router.js +171 -171
- package/core/seo.js +10 -0
- package/core/spa.js +599 -0
- package/core/view-loader.js +155 -613
- package/core/vite-plugin.d.ts +18 -0
- package/core/vite-plugin.js +162 -0
- package/core/vite.js +250 -145
- package/index.js +22 -18
- package/jsconfig.json +5 -3
- package/package.json +114 -92
- package/production.md +8 -3
- package/public/js/bluebird.js +1160 -0
- package/templates/_auth/app/database.js +19 -0
- package/templates/_auth/app/models/user.js +22 -0
- package/templates/_auth/app/routes/auth-router.js +304 -0
- package/templates/_base/app/resources/html/layouts/main.html +55 -0
- package/templates/_base/app/resources/html/notFound.html +14 -0
- package/templates/_base/app/resources/index.html +27 -0
- package/templates/_base/app/resources/styles.css +9 -0
- package/templates/api/app/models/note.js +18 -0
- package/templates/api/app/routes/api.js +82 -0
- package/templates/api/app/routes/auth.js +11 -0
- package/templates/api/index.js +19 -0
- package/templates/api/template.json +13 -0
- package/templates/auth/app/mail.js +11 -0
- package/templates/auth/app/models/password_reset.js +18 -0
- package/templates/auth/app/resources/html/home.html +21 -0
- package/templates/auth/app/resources/html/partials/nav.html +2 -0
- package/templates/auth/app/resources/layouts/AppLayout.jsx +60 -0
- package/templates/auth/app/resources/main.jsx +18 -0
- package/templates/auth/app/resources/pages/Dashboard.jsx +51 -0
- package/templates/auth/app/resources/pages/ForgotPassword.jsx +34 -0
- package/templates/auth/app/resources/pages/Login.jsx +36 -0
- package/templates/auth/app/resources/pages/NotFound.jsx +16 -0
- package/templates/auth/app/resources/pages/Profile.jsx +99 -0
- package/templates/auth/app/resources/pages/Register.jsx +50 -0
- package/templates/auth/app/resources/pages/ResetPassword.jsx +50 -0
- package/templates/auth/app/resources/routes.jsx +54 -0
- package/templates/auth/app/resources/spa.js +29 -0
- package/templates/auth/app/routes/api.js +17 -0
- package/templates/auth/app/routes/auth.js +13 -0
- package/templates/auth/app/routes/web.js +21 -0
- package/templates/auth/index.js +19 -0
- package/templates/auth/template.json +15 -0
- package/templates/blank/app/models/.gitkeep +0 -0
- package/templates/blank/app/resources/html/home.html +27 -0
- package/templates/blank/app/resources/html/partials/nav.html +1 -0
- package/templates/blank/app/resources/main.jsx +16 -0
- package/templates/blank/app/resources/pages/Home.jsx +42 -0
- package/templates/blank/app/resources/pages/NotFound.jsx +27 -0
- package/templates/blank/app/resources/routes.jsx +15 -0
- package/templates/blank/app/resources/spa.js +24 -0
- package/templates/blank/app/routes/api.js +11 -0
- package/templates/blank/app/routes/web.js +21 -0
- package/templates/blank/index.js +13 -0
- package/templates/blank/template.json +12 -0
- package/templates/blog/app/lib/blog.js +149 -0
- package/templates/blog/app/models/post.js +22 -0
- package/templates/blog/app/resources/html/home.html +28 -0
- package/templates/blog/app/resources/html/not-found.html +5 -0
- package/templates/blog/app/resources/html/partials/nav.html +2 -0
- package/templates/blog/app/resources/html/partials/post-card.html +9 -0
- package/templates/blog/app/resources/html/post.html +8 -0
- package/templates/blog/app/resources/layouts/AdminLayout.jsx +54 -0
- package/templates/blog/app/resources/main.jsx +18 -0
- package/templates/blog/app/resources/pages/Login.jsx +31 -0
- package/templates/blog/app/resources/pages/NotFound.jsx +16 -0
- package/templates/blog/app/resources/pages/PostEditor.jsx +51 -0
- package/templates/blog/app/resources/pages/Posts.jsx +83 -0
- package/templates/blog/app/resources/pages/Register.jsx +43 -0
- package/templates/blog/app/resources/routes.jsx +51 -0
- package/templates/blog/app/resources/spa.js +25 -0
- package/templates/blog/app/resources/styles.css +40 -0
- package/templates/blog/app/routes/api.js +77 -0
- package/templates/blog/app/routes/auth.js +10 -0
- package/templates/blog/app/routes/web.js +114 -0
- package/templates/blog/index.js +21 -0
- package/templates/blog/template.json +14 -0
- package/vite.config.js +11 -0
- package/app/views/components/Header.jsx +0 -42
- package/app/views/components/LiveCounter.jsx +0 -67
- package/app/views/layouts/main/view.jsx +0 -201
- package/app/views/legal/terms.html +0 -29
- package/app/views/pages/about.jsx +0 -98
- package/app/views/pages/dashboard.jsx +0 -278
- package/app/views/pages/index.jsx +0 -123
- package/app/views/pages/login.jsx +0 -141
- package/core/actions.d.ts +0 -4
- package/core/actions.js +0 -355
- package/core/jsx.d.ts +0 -38
- package/core/jsx.js +0 -1597
- package/core/vite.d.ts +0 -3
- package/public/js/bluebird-client.js +0 -3265
- package/public/js/tailwind.js +0 -8
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
export const route = "/";
|
|
2
|
-
export const cache = 300;
|
|
3
|
-
export const layout = "main";
|
|
4
|
-
export const seo = true;
|
|
5
|
-
|
|
6
|
-
export const head = () => ({
|
|
7
|
-
title: "Blue Bird Framework — High Performance Web Framework",
|
|
8
|
-
description: "Fast, structured, and opinionated Express.js framework with React JSX SSR and multi-tier caching.",
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Home page React JSX view module.
|
|
13
|
-
*/
|
|
14
|
-
export default function IndexView() {
|
|
15
|
-
return (
|
|
16
|
-
<>
|
|
17
|
-
<section className="py-10 md:py-14 border-b border-slate-800/80">
|
|
18
|
-
<h1 className="mt-3 text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 via-blue-500 to-indigo-400 bg-clip-text text-transparent">
|
|
19
|
-
Hello, Developer!
|
|
20
|
-
</h1>
|
|
21
|
-
<p className="mt-4 text-base md:text-lg text-slate-300 max-w-2xl leading-relaxed">
|
|
22
|
-
Blue Bird is a fast, structured, and opinionated Express.js framework for developers who want
|
|
23
|
-
visual elegance and performance with native React JSX SSR, Partial Rendering, and modern JavaScript.
|
|
24
|
-
</p>
|
|
25
|
-
<div className="flex items-center gap-4 mt-6">
|
|
26
|
-
<a
|
|
27
|
-
href="/about"
|
|
28
|
-
className="px-4 py-2.5 rounded-xl bg-sky-500 hover:bg-sky-400 text-slate-950 font-semibold text-sm transition-colors shadow-lg shadow-sky-500/20"
|
|
29
|
-
>
|
|
30
|
-
About Us →
|
|
31
|
-
</a>
|
|
32
|
-
<a
|
|
33
|
-
href="https://github.com/seip25/bluebird-js"
|
|
34
|
-
target="_blank"
|
|
35
|
-
className="px-4 py-2.5 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 text-slate-200 text-sm font-semibold transition-colors"
|
|
36
|
-
>
|
|
37
|
-
GitHub
|
|
38
|
-
</a>
|
|
39
|
-
</div>
|
|
40
|
-
</section>
|
|
41
|
-
|
|
42
|
-
<div className="mt-8">
|
|
43
|
-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">
|
|
44
|
-
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 hover:border-sky-500/40 hover:shadow-lg hover:shadow-sky-500/5 transition-all">
|
|
45
|
-
<header>
|
|
46
|
-
<span className="inline-block px-2.5 py-1 rounded-md bg-sky-500/15 text-sky-400 border border-sky-500/30 text-xs font-semibold uppercase tracking-wider mb-3">
|
|
47
|
-
Rendering
|
|
48
|
-
</span>
|
|
49
|
-
<h3 className="text-lg font-bold text-slate-100">Zero-Build React JSX SSR</h3>
|
|
50
|
-
</header>
|
|
51
|
-
<p className="text-sm text-slate-400 mt-2 leading-relaxed">
|
|
52
|
-
Native <code>.jsx</code> views compiled in memory with automatic XSS escaping, shared layouts,{" "}
|
|
53
|
-
<code><Client /></code> islands with anti-CLS skeletons, and partial SPA transitions.
|
|
54
|
-
</p>
|
|
55
|
-
</article>
|
|
56
|
-
|
|
57
|
-
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 hover:border-sky-500/40 hover:shadow-lg hover:shadow-sky-500/5 transition-all">
|
|
58
|
-
<header>
|
|
59
|
-
<span className="inline-block px-2.5 py-1 rounded-md bg-sky-500/15 text-sky-400 border border-sky-500/30 text-xs font-semibold uppercase tracking-wider mb-3">
|
|
60
|
-
Performance
|
|
61
|
-
</span>
|
|
62
|
-
<h3 className="text-lg font-bold text-slate-100">Declarative Auto-Routes & Cache</h3>
|
|
63
|
-
</header>
|
|
64
|
-
<p className="text-sm text-slate-400 mt-2 leading-relaxed">
|
|
65
|
-
Export <code>const cache = 300</code> and <code>const middlewares = [...]</code> directly from your{" "}
|
|
66
|
-
<code>app/views/*.jsx</code> files for instant route mounting and L1 RAM / Redis caching.
|
|
67
|
-
</p>
|
|
68
|
-
</article>
|
|
69
|
-
|
|
70
|
-
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 hover:border-sky-500/40 hover:shadow-lg hover:shadow-sky-500/5 transition-all">
|
|
71
|
-
<header>
|
|
72
|
-
<span className="inline-block px-2.5 py-1 rounded-md bg-sky-500/15 text-sky-400 border border-sky-500/30 text-xs font-semibold uppercase tracking-wider mb-3">
|
|
73
|
-
Security
|
|
74
|
-
</span>
|
|
75
|
-
<h3 className="text-lg font-bold text-slate-100">JWT & Route Security</h3>
|
|
76
|
-
</header>
|
|
77
|
-
<p className="text-sm text-slate-400 mt-2 leading-relaxed">
|
|
78
|
-
Secure cookie management, GCM-encrypted JWT tokens, custom security headers, and route rate limiting built-in.
|
|
79
|
-
</p>
|
|
80
|
-
</article>
|
|
81
|
-
|
|
82
|
-
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 hover:border-sky-500/40 hover:shadow-lg hover:shadow-sky-500/5 transition-all">
|
|
83
|
-
<header>
|
|
84
|
-
<span className="inline-block px-2.5 py-1 rounded-md bg-sky-500/15 text-sky-400 border border-sky-500/30 text-xs font-semibold uppercase tracking-wider mb-3">
|
|
85
|
-
Database
|
|
86
|
-
</span>
|
|
87
|
-
<h3 className="text-lg font-bold text-slate-100">Unified DB Layer</h3>
|
|
88
|
-
</header>
|
|
89
|
-
<p className="text-sm text-slate-400 mt-2 leading-relaxed">
|
|
90
|
-
Built-in support for SQLite (native node:sqlite with WAL), MySQL, and PostgreSQL with connection pooling and caching.
|
|
91
|
-
</p>
|
|
92
|
-
</article>
|
|
93
|
-
|
|
94
|
-
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 hover:border-sky-500/40 hover:shadow-lg hover:shadow-sky-500/5 transition-all">
|
|
95
|
-
<header>
|
|
96
|
-
<span className="inline-block px-2.5 py-1 rounded-md bg-sky-500/15 text-sky-400 border border-sky-500/30 text-xs font-semibold uppercase tracking-wider mb-3">
|
|
97
|
-
DevOps
|
|
98
|
-
</span>
|
|
99
|
-
<h3 className="text-lg font-bold text-slate-100">Production Ready</h3>
|
|
100
|
-
</header>
|
|
101
|
-
<p className="text-sm text-slate-400 mt-2 leading-relaxed">
|
|
102
|
-
Production cluster orchestration with PM2, native health checks, and smooth View Transitions SPA navigation.
|
|
103
|
-
</p>
|
|
104
|
-
</article>
|
|
105
|
-
|
|
106
|
-
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 hover:border-sky-500/40 hover:shadow-lg hover:shadow-sky-500/5 transition-all">
|
|
107
|
-
<header>
|
|
108
|
-
<span className="inline-block px-2.5 py-1 rounded-md bg-sky-500/15 text-sky-400 border border-sky-500/30 text-xs font-semibold uppercase tracking-wider mb-3">
|
|
109
|
-
Design
|
|
110
|
-
</span>
|
|
111
|
-
<h3 className="text-lg font-bold text-slate-100">Tailwind CSS Built-In</h3>
|
|
112
|
-
</header>
|
|
113
|
-
<p className="text-sm text-slate-400 mt-2 leading-relaxed">
|
|
114
|
-
Modern utility classes styled by <strong>Tailwind CSS v4</strong> (
|
|
115
|
-
<code className="text-sky-400 font-mono text-xs">/js/tailwind.js</code>) and Google Fonts Inter with zero build steps.
|
|
116
|
-
</p>
|
|
117
|
-
</article>
|
|
118
|
-
</div>
|
|
119
|
-
</div>
|
|
120
|
-
</>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { script } from "@seip/bluebird-js/core/html.js";
|
|
2
|
-
|
|
3
|
-
export const route = "/login";
|
|
4
|
-
export const layout = "main";
|
|
5
|
-
export const seo = true;
|
|
6
|
-
|
|
7
|
-
export const head = () => ({
|
|
8
|
-
title: "Sign In — Blue Bird Framework",
|
|
9
|
-
description: "Test native JWT authentication, encrypted cookies, and protected routes.",
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Login page React JSX view module.
|
|
14
|
-
*/
|
|
15
|
-
export default function LoginView() {
|
|
16
|
-
return (
|
|
17
|
-
<>
|
|
18
|
-
<section className="py-10 md:py-14 border-b border-slate-800/80">
|
|
19
|
-
<h1 className="mt-3 text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 via-blue-500 to-indigo-400 bg-clip-text text-transparent">
|
|
20
|
-
Authentication Demo
|
|
21
|
-
</h1>
|
|
22
|
-
<p className="mt-4 text-base md:text-lg text-slate-300 max-w-2xl leading-relaxed">
|
|
23
|
-
Test native AES-256-GCM JWT auth cookies, Auth.protect middleware, and seamless View Transitions.
|
|
24
|
-
</p>
|
|
25
|
-
</section>
|
|
26
|
-
|
|
27
|
-
<div className="mt-8 max-w-2xl">
|
|
28
|
-
<div className="rounded-xl border border-sky-500/30 bg-sky-500/10 p-4 text-sky-200 mb-6">
|
|
29
|
-
<strong className="font-semibold block text-sky-400 mb-1">Interactive Auth Testing</strong>
|
|
30
|
-
<p className="text-sm leading-relaxed text-slate-300">
|
|
31
|
-
Submit credentials below to generate an encrypted JWT session cookie with{" "}
|
|
32
|
-
<code className="text-sky-300 font-mono text-xs px-1.5 py-0.5 rounded bg-slate-900 border border-slate-800">
|
|
33
|
-
Auth.login(res, user)
|
|
34
|
-
</code>
|
|
35
|
-
. Try visiting <strong className="text-white">/dashboard</strong> directly before and after logging in to verify the{" "}
|
|
36
|
-
<code className="text-sky-300 font-mono text-xs px-1.5 py-0.5 rounded bg-slate-900 border border-slate-800">
|
|
37
|
-
Auth.protect({'{'} redirect: "/login" {'}'})
|
|
38
|
-
</code>{" "}
|
|
39
|
-
middleware!
|
|
40
|
-
</p>
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 md:p-8">
|
|
44
|
-
<header className="mb-6">
|
|
45
|
-
<h3 className="text-xl font-bold text-slate-100">Sign In</h3>
|
|
46
|
-
<p className="text-sm text-slate-400 mt-1">
|
|
47
|
-
Enter your test credentials below to start a secure session.
|
|
48
|
-
</p>
|
|
49
|
-
</header>
|
|
50
|
-
|
|
51
|
-
<form action="/login" method="POST" id="loginForm" className="space-y-4">
|
|
52
|
-
<div>
|
|
53
|
-
<label
|
|
54
|
-
htmlFor="email"
|
|
55
|
-
className="block text-xs font-semibold uppercase tracking-wider text-slate-400 mb-1.5"
|
|
56
|
-
>
|
|
57
|
-
Email Address
|
|
58
|
-
</label>
|
|
59
|
-
<input
|
|
60
|
-
type="email"
|
|
61
|
-
id="email"
|
|
62
|
-
name="email"
|
|
63
|
-
value="alex@example.com"
|
|
64
|
-
placeholder="alex@example.com"
|
|
65
|
-
required
|
|
66
|
-
className="w-full rounded-lg border border-slate-700 bg-slate-950 px-3.5 py-2.5 text-sm text-slate-100 placeholder-slate-500 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500/20"
|
|
67
|
-
/>
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<div>
|
|
71
|
-
<label
|
|
72
|
-
htmlFor="password"
|
|
73
|
-
className="block text-xs font-semibold uppercase tracking-wider text-slate-400 mb-1.5"
|
|
74
|
-
>
|
|
75
|
-
Password
|
|
76
|
-
</label>
|
|
77
|
-
<input
|
|
78
|
-
type="password"
|
|
79
|
-
id="password"
|
|
80
|
-
name="password"
|
|
81
|
-
value="password123"
|
|
82
|
-
placeholder="••••••••"
|
|
83
|
-
required
|
|
84
|
-
className="w-full rounded-lg border border-slate-700 bg-slate-950 px-3.5 py-2.5 text-sm text-slate-100 placeholder-slate-500 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500/20"
|
|
85
|
-
/>
|
|
86
|
-
</div>
|
|
87
|
-
|
|
88
|
-
<div className="flex items-center justify-between gap-4 pt-4">
|
|
89
|
-
<button
|
|
90
|
-
type="submit"
|
|
91
|
-
id="submitBtn"
|
|
92
|
-
className="bg-sky-500 hover:bg-sky-400 text-slate-950 font-semibold px-5 py-2.5 rounded-lg text-sm transition-colors shadow-lg shadow-sky-500/20"
|
|
93
|
-
>
|
|
94
|
-
Sign In →
|
|
95
|
-
</button>
|
|
96
|
-
<a
|
|
97
|
-
href="/dashboard"
|
|
98
|
-
className="px-4 py-2.5 rounded-lg border border-slate-700 bg-slate-900/80 hover:bg-slate-800 text-slate-300 text-sm font-medium transition-colors"
|
|
99
|
-
>
|
|
100
|
-
Try /dashboard (Protected)
|
|
101
|
-
</a>
|
|
102
|
-
</div>
|
|
103
|
-
</form>
|
|
104
|
-
</article>
|
|
105
|
-
|
|
106
|
-
<article className="mt-8 rounded-2xl border border-slate-800 bg-slate-900/40 p-6">
|
|
107
|
-
<header>
|
|
108
|
-
<h4 className="font-bold text-slate-200">What is being tested here?</h4>
|
|
109
|
-
</header>
|
|
110
|
-
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
|
|
111
|
-
<div className="rounded-xl border border-slate-800/80 bg-slate-950/60 p-4">
|
|
112
|
-
<h5 className="font-bold text-sm text-slate-200 mb-1">1. Auth.protect Middleware</h5>
|
|
113
|
-
<p className="text-xs text-slate-400 leading-relaxed">
|
|
114
|
-
When an unauthenticated client requests <code className="text-sky-300 font-mono">/dashboard</code>, the server issues a 302 redirect to{" "}
|
|
115
|
-
<code className="text-sky-300 font-mono">/login</code>. The client router automatically follows the transition smoothly.
|
|
116
|
-
</p>
|
|
117
|
-
</div>
|
|
118
|
-
<div className="rounded-xl border border-slate-800/80 bg-slate-950/60 p-4">
|
|
119
|
-
<h5 className="font-bold text-sm text-slate-200 mb-1">2. Encrypted JWT Cookies</h5>
|
|
120
|
-
<p className="text-xs text-slate-400 leading-relaxed">
|
|
121
|
-
Session cookies are encrypted with AES-256-GCM and marked HttpOnly and SameSite=Lax to protect against token exfiltration.
|
|
122
|
-
</p>
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
</article>
|
|
126
|
-
</div>
|
|
127
|
-
|
|
128
|
-
{script(() => {
|
|
129
|
-
const form = document.getElementById("loginForm");
|
|
130
|
-
const btn = document.getElementById("submitBtn");
|
|
131
|
-
form?.addEventListener("submit", () => {
|
|
132
|
-
if (btn) {
|
|
133
|
-
btn.textContent = "Signing In...";
|
|
134
|
-
btn.setAttribute("disabled", "true");
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
})}
|
|
138
|
-
</>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
package/core/actions.d.ts
DELETED
package/core/actions.js
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
import Csrf from "./csrf.js";
|
|
2
|
-
import Validator from "./validate.js";
|
|
3
|
-
import Render from "./render.js";
|
|
4
|
-
|
|
5
|
-
const DEFAULT_MAX_BYTES = 64 * 1024;
|
|
6
|
-
const DEFAULT_MAX_DEPTH = 6;
|
|
7
|
-
const DEFAULT_MAX_KEYS = 100;
|
|
8
|
-
const BANNED_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Recursively sanitizes and validates an incoming action payload object to prevent
|
|
12
|
-
* prototype pollution (`__proto__`, `constructor`, `prototype`), excessive nesting depth,
|
|
13
|
-
* and key-flooding memory attacks.
|
|
14
|
-
*
|
|
15
|
-
* @param {any} input
|
|
16
|
-
* @param {number} [maxDepth=DEFAULT_MAX_DEPTH]
|
|
17
|
-
* @param {number} [maxKeys=DEFAULT_MAX_KEYS]
|
|
18
|
-
* @param {number} [currentDepth=0]
|
|
19
|
-
* @param {{ count: number }} [keyCounter={ count: 0 }]
|
|
20
|
-
* @returns {any}
|
|
21
|
-
*/
|
|
22
|
-
export function sanitizeActionPayload(
|
|
23
|
-
input,
|
|
24
|
-
maxDepth = DEFAULT_MAX_DEPTH,
|
|
25
|
-
maxKeys = DEFAULT_MAX_KEYS,
|
|
26
|
-
currentDepth = 0,
|
|
27
|
-
keyCounter = { count: 0 }
|
|
28
|
-
) {
|
|
29
|
-
if (input === null || input === undefined) return input;
|
|
30
|
-
if (typeof input !== "object") return input;
|
|
31
|
-
|
|
32
|
-
if (currentDepth > maxDepth) {
|
|
33
|
-
const err = new Error("Payload nesting depth limit exceeded.");
|
|
34
|
-
err.statusCode = 413;
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (Array.isArray(input)) {
|
|
39
|
-
if (input.length > maxKeys) {
|
|
40
|
-
const err = new Error(`Payload array length exceeds maximum allowed (${maxKeys}).`);
|
|
41
|
-
err.statusCode = 413;
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
return input.map((item) =>
|
|
45
|
-
sanitizeActionPayload(item, maxDepth, maxKeys, currentDepth + 1, keyCounter)
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const clean = Object.create(null);
|
|
50
|
-
const entries = Object.entries(input);
|
|
51
|
-
for (const [k, v] of entries) {
|
|
52
|
-
if (BANNED_KEYS.has(k)) continue;
|
|
53
|
-
keyCounter.count++;
|
|
54
|
-
if (keyCounter.count > maxKeys) {
|
|
55
|
-
const err = new Error(`Payload key count exceeds maximum allowed (${maxKeys}).`);
|
|
56
|
-
err.statusCode = 413;
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
59
|
-
clean[k] = sanitizeActionPayload(v, maxDepth, maxKeys, currentDepth + 1, keyCounter);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return { ...clean };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Parses byte size strings like "64kb", "1mb", or numbers into integer bytes.
|
|
67
|
-
* @param {number|string} [limit]
|
|
68
|
-
* @returns {number}
|
|
69
|
-
*/
|
|
70
|
-
export function parseByteLimit(limit) {
|
|
71
|
-
if (typeof limit === "number" && limit > 0) return limit;
|
|
72
|
-
if (typeof limit === "string") {
|
|
73
|
-
const match = limit.trim().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb)?$/i);
|
|
74
|
-
if (match) {
|
|
75
|
-
const num = parseFloat(match[1]);
|
|
76
|
-
const unit = (match[2] || "b").toLowerCase();
|
|
77
|
-
if (unit === "mb") return Math.floor(num * 1024 * 1024);
|
|
78
|
-
if (unit === "kb") return Math.floor(num * 1024);
|
|
79
|
-
return Math.floor(num);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return DEFAULT_MAX_BYTES;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Native Server Actions manager for Bluebird.js.
|
|
87
|
-
* Wraps server mutation handlers with automatic CSRF verification, strict payload size/depth/key
|
|
88
|
-
* guards, optional schema validation, and reactive partial SSR re-rendering.
|
|
89
|
-
*/
|
|
90
|
-
/**
|
|
91
|
-
* Shorthand helper to mark any async function as a Server Action.
|
|
92
|
-
* Supports (fn) or (options, fn) signatures.
|
|
93
|
-
*
|
|
94
|
-
* @param {Object|Function} optionsOrFn
|
|
95
|
-
* @param {Function} [maybeFn]
|
|
96
|
-
* @returns {Function}
|
|
97
|
-
*/
|
|
98
|
-
export function action(optionsOrFn, maybeFn) {
|
|
99
|
-
const handler = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
100
|
-
const options = typeof optionsOrFn === "function" ? {} : (optionsOrFn || {});
|
|
101
|
-
|
|
102
|
-
const fn = function bluebirdServerAction(...args) {
|
|
103
|
-
if (typeof handler === "function") {
|
|
104
|
-
return handler(...args);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
fn.__bb_action__ = true;
|
|
109
|
-
fn.__isBluebirdAction = true;
|
|
110
|
-
fn.options = options;
|
|
111
|
-
fn.handler = handler;
|
|
112
|
-
if (handler && handler.name && handler.name !== "anonymous" && handler.name !== "handlerFn") {
|
|
113
|
-
fn.__actionName = handler.name;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return fn;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export class Actions {
|
|
120
|
-
/**
|
|
121
|
-
* Defines a single server action or a map of server actions with security and validation options.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* // Single action with schema validation and 32KB max payload
|
|
125
|
-
* export const actions = {
|
|
126
|
-
* updateProfile: Actions.define(
|
|
127
|
-
* {
|
|
128
|
-
* schema: { name: { required: true, min: 2 } },
|
|
129
|
-
* maxBytes: "32kb",
|
|
130
|
-
* },
|
|
131
|
-
* async ({ body, req, user }) => {
|
|
132
|
-
* await User.update(user.id, body, { only: ["name"] });
|
|
133
|
-
* return { updated: true };
|
|
134
|
-
* }
|
|
135
|
-
* ),
|
|
136
|
-
* };
|
|
137
|
-
*
|
|
138
|
-
* @param {Object|Function} optionsOrMap - Options object, action map, or handler function.
|
|
139
|
-
* @param {Function} [handlerFn] - Action handler function when first argument is options.
|
|
140
|
-
* @returns {Object}
|
|
141
|
-
*/
|
|
142
|
-
static define(optionsOrMap, handlerFn) {
|
|
143
|
-
if (typeof optionsOrMap === "function") {
|
|
144
|
-
return action({}, optionsOrMap);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (typeof handlerFn === "function") {
|
|
148
|
-
return action(optionsOrMap || {}, handlerFn);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (optionsOrMap && typeof optionsOrMap === "object") {
|
|
152
|
-
const out = {};
|
|
153
|
-
for (const [key, val] of Object.entries(optionsOrMap)) {
|
|
154
|
-
if (typeof val === "function") {
|
|
155
|
-
out[key] = action({}, val);
|
|
156
|
-
out[key].__actionName = key;
|
|
157
|
-
} else if (val && typeof val === "object" && typeof val.handler === "function") {
|
|
158
|
-
out[key] = action(val.options || val, val.handler);
|
|
159
|
-
out[key].__actionName = key;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return out;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return {};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Express route handler that dispatches incoming POST requests to the matching Server Action
|
|
170
|
-
* exported by a view module (`export const actions = { ... }`).
|
|
171
|
-
*
|
|
172
|
-
* Security checks performed automatically before invoking the action:
|
|
173
|
-
* 1. CSRF verification (header `x-csrf-token` or body `_csrf` matched against signed `_csrf` cookie).
|
|
174
|
-
* 2. Payload byte size guard (`Content-Length` and serialized body byte length, default 64KB).
|
|
175
|
-
* 3. Prototype pollution & deep-nesting guard (`__proto__`, `constructor`, `prototype`, maxDepth, maxKeys).
|
|
176
|
-
* 4. Optional `Validator` schema check if `schema` is configured on the action.
|
|
177
|
-
*
|
|
178
|
-
* @param {string} viewName - View name associated with the route.
|
|
179
|
-
* @param {Record<string, any>} actionsMap - Exported `actions` object from the view module.
|
|
180
|
-
* @returns {Function} Express route handler.
|
|
181
|
-
*/
|
|
182
|
-
static createDispatcher(viewName, actionsMap) {
|
|
183
|
-
return async (req, res) => {
|
|
184
|
-
const actionName =
|
|
185
|
-
req.headers["x-bluebird-action"] ||
|
|
186
|
-
req.body?._action ||
|
|
187
|
-
req.query?._action ||
|
|
188
|
-
"default";
|
|
189
|
-
|
|
190
|
-
const rawAction =
|
|
191
|
-
actionsMap[actionName] ||
|
|
192
|
-
(actionName === "default" && typeof actionsMap === "function" ? actionsMap : null);
|
|
193
|
-
|
|
194
|
-
if (!rawAction) {
|
|
195
|
-
return res.status(404).json({
|
|
196
|
-
status: "error",
|
|
197
|
-
message: `Action '${String(actionName)}' not found on view '${viewName}'.`,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const actionDef =
|
|
202
|
-
typeof rawAction === "function" && !rawAction.__bb_action__
|
|
203
|
-
? { options: {}, handler: rawAction }
|
|
204
|
-
: rawAction;
|
|
205
|
-
const opts = actionDef.options || {};
|
|
206
|
-
const handler = actionDef.handler || (typeof rawAction === "function" ? rawAction : null);
|
|
207
|
-
|
|
208
|
-
if (typeof handler !== "function") {
|
|
209
|
-
return res.status(404).json({
|
|
210
|
-
status: "error",
|
|
211
|
-
message: `Invalid handler for action '${String(actionName)}'.`,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const maxBytes = parseByteLimit(opts.maxBytes ?? opts.limit ?? DEFAULT_MAX_BYTES);
|
|
216
|
-
const maxDepth = opts.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
217
|
-
const maxKeys = opts.maxKeys ?? DEFAULT_MAX_KEYS;
|
|
218
|
-
|
|
219
|
-
const contentLength = parseInt(req.headers["content-length"] || "0", 10);
|
|
220
|
-
if (contentLength > maxBytes) {
|
|
221
|
-
return res.status(413).json({
|
|
222
|
-
status: "error",
|
|
223
|
-
message: `Action payload too large (exceeds ${maxBytes} bytes).`,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const rawBodyStr = JSON.stringify(req.body || {});
|
|
228
|
-
if (Buffer.byteLength(rawBodyStr, "utf-8") > maxBytes) {
|
|
229
|
-
return res.status(413).json({
|
|
230
|
-
status: "error",
|
|
231
|
-
message: `Action payload size exceeds maximum allowed (${maxBytes} bytes).`,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (opts.csrf !== false) {
|
|
236
|
-
const cookieToken = req.cookies?.["_csrf"];
|
|
237
|
-
const headerToken =
|
|
238
|
-
req.headers["x-csrf-token"] ||
|
|
239
|
-
req.body?._csrf ||
|
|
240
|
-
req.query?._csrf;
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
!cookieToken ||
|
|
244
|
-
!headerToken ||
|
|
245
|
-
cookieToken !== headerToken ||
|
|
246
|
-
!Csrf.verifyToken(headerToken)
|
|
247
|
-
) {
|
|
248
|
-
return res.status(403).json({
|
|
249
|
-
status: "error",
|
|
250
|
-
message: "Invalid or missing CSRF token for server action.",
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
let safeBody = {};
|
|
256
|
-
try {
|
|
257
|
-
safeBody = sanitizeActionPayload(req.body || {}, maxDepth, maxKeys);
|
|
258
|
-
delete safeBody._csrf;
|
|
259
|
-
delete safeBody._action;
|
|
260
|
-
} catch (err) {
|
|
261
|
-
return res.status(err.statusCode || 400).json({
|
|
262
|
-
status: "error",
|
|
263
|
-
message: err.message || "Invalid action payload.",
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (opts.schema) {
|
|
268
|
-
const validator =
|
|
269
|
-
opts.schema instanceof Validator
|
|
270
|
-
? opts.schema
|
|
271
|
-
: new Validator(opts.schema, req.lang || "en");
|
|
272
|
-
const validation = await validator.validate(safeBody);
|
|
273
|
-
if (!validation.success) {
|
|
274
|
-
return res.status(400).json({
|
|
275
|
-
status: "error",
|
|
276
|
-
message: validation.message?.[0] || "Validation failed.",
|
|
277
|
-
errors: validation.errors,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const ctx = Object.assign(
|
|
283
|
-
{},
|
|
284
|
-
safeBody,
|
|
285
|
-
{
|
|
286
|
-
req,
|
|
287
|
-
res,
|
|
288
|
-
user: req.user,
|
|
289
|
-
body: safeBody,
|
|
290
|
-
payload: safeBody,
|
|
291
|
-
params: req.params || {},
|
|
292
|
-
query: req.query || {},
|
|
293
|
-
action: String(actionName),
|
|
294
|
-
}
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const result = await handler(ctx, ctx);
|
|
298
|
-
if (res.headersSent) return;
|
|
299
|
-
|
|
300
|
-
if (result && typeof result === "object" && typeof result.redirect === "string") {
|
|
301
|
-
return Render.redirect(req, res, result.redirect);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const wantsPartial =
|
|
305
|
-
req.headers["x-bluebird-partial"] === "1" ||
|
|
306
|
-
req.query?._partial === "1" ||
|
|
307
|
-
(result && typeof result === "object" && result.reRender === true);
|
|
308
|
-
|
|
309
|
-
if (wantsPartial) {
|
|
310
|
-
const extraProps =
|
|
311
|
-
result && typeof result === "object" && !Array.isArray(result)
|
|
312
|
-
? result.props || result
|
|
313
|
-
: {};
|
|
314
|
-
return Render.send(res, viewName, {
|
|
315
|
-
user: req.user,
|
|
316
|
-
params: req.params,
|
|
317
|
-
query: req.query,
|
|
318
|
-
actionResult: result,
|
|
319
|
-
...extraProps,
|
|
320
|
-
_layout: false,
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const expectsJson =
|
|
325
|
-
req.headers["x-bluebird-action"] ||
|
|
326
|
-
req.headers["x-requested-with"] === "XMLHttpRequest" ||
|
|
327
|
-
req.headers.accept?.includes("application/json");
|
|
328
|
-
|
|
329
|
-
if (expectsJson) {
|
|
330
|
-
return res.status(200).json({
|
|
331
|
-
status: "success",
|
|
332
|
-
action: String(actionName),
|
|
333
|
-
data: result ?? null,
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const extraProps =
|
|
338
|
-
result && typeof result === "object" && !Array.isArray(result)
|
|
339
|
-
? result.props || result
|
|
340
|
-
: {};
|
|
341
|
-
return Render.send(res, viewName, {
|
|
342
|
-
user: req.user,
|
|
343
|
-
params: req.params,
|
|
344
|
-
query: req.query,
|
|
345
|
-
actionResult: result,
|
|
346
|
-
...extraProps,
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
Actions.action = action;
|
|
353
|
-
Actions.fn = action;
|
|
354
|
-
|
|
355
|
-
export default Actions;
|
package/core/jsx.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
h,
|
|
3
|
-
createElement,
|
|
4
|
-
jsx,
|
|
5
|
-
jsxs,
|
|
6
|
-
Fragment,
|
|
7
|
-
Island,
|
|
8
|
-
Client,
|
|
9
|
-
IslandComponentProps,
|
|
10
|
-
isJsxElement,
|
|
11
|
-
renderJsxToString,
|
|
12
|
-
compileJsx,
|
|
13
|
-
registerJsxLoader,
|
|
14
|
-
useState,
|
|
15
|
-
useEffect,
|
|
16
|
-
useRef,
|
|
17
|
-
useMemo,
|
|
18
|
-
useCallback,
|
|
19
|
-
} from "./index.js";
|
|
20
|
-
export {
|
|
21
|
-
h,
|
|
22
|
-
createElement,
|
|
23
|
-
jsx,
|
|
24
|
-
jsxs,
|
|
25
|
-
Fragment,
|
|
26
|
-
Island,
|
|
27
|
-
Client,
|
|
28
|
-
IslandComponentProps,
|
|
29
|
-
isJsxElement,
|
|
30
|
-
renderJsxToString,
|
|
31
|
-
compileJsx,
|
|
32
|
-
registerJsxLoader,
|
|
33
|
-
useState,
|
|
34
|
-
useEffect,
|
|
35
|
-
useRef,
|
|
36
|
-
useMemo,
|
|
37
|
-
useCallback,
|
|
38
|
-
};
|