@batijs/cli 0.0.195 → 0.0.197
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/boilerplates/@batijs/auth0/files/$.env.js +5 -9
- package/dist/boilerplates/@batijs/auth0/files/$README.md.js +8 -17
- package/dist/boilerplates/@batijs/authjs/files/server/authjs-handler.ts +100 -0
- package/dist/boilerplates/@batijs/authjs/types/server/authjs-handler.d.ts +16 -0
- package/dist/boilerplates/@batijs/eslint/files/.eslintrc.json +15 -2
- package/dist/boilerplates/@batijs/express/files/$package.json.js +8 -9
- package/dist/boilerplates/@batijs/express/files/express-entry.ts +51 -144
- package/dist/boilerplates/@batijs/express/types/express-entry.d.ts +5 -0
- package/dist/boilerplates/@batijs/fastify/files/$package.json.js +6 -10
- package/dist/boilerplates/@batijs/fastify/files/fastify-entry.ts +63 -149
- package/dist/boilerplates/@batijs/fastify/types/fastify-entry.d.ts +6 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +8 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/libs/firebaseAdmin.ts +2 -1
- package/dist/boilerplates/@batijs/firebase-auth/files/server/firebase-auth-middleware.ts +72 -0
- package/dist/boilerplates/@batijs/firebase-auth/types/libs/firebaseAdmin.d.ts +2 -1
- package/dist/boilerplates/@batijs/firebase-auth/types/server/firebase-auth-middleware.d.ts +4 -0
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +4 -6
- package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +36 -175
- package/dist/boilerplates/@batijs/h3/types/h3-entry.d.ts +5 -0
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +7 -3
- package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +40 -60
- package/dist/boilerplates/@batijs/hattip/types/hattip-entry.d.ts +1 -0
- package/dist/boilerplates/@batijs/hono/files/$package.json.js +5 -3
- package/dist/boilerplates/@batijs/hono/files/hono-entry.ts +54 -116
- package/dist/boilerplates/@batijs/hono/types/hono-entry.d.ts +5 -0
- package/dist/boilerplates/@batijs/react/files/$.eslintrc.json.js +0 -4
- package/dist/boilerplates/@batijs/react/files/$README.md.js +9 -3
- package/dist/boilerplates/@batijs/shared/files/package.json +1 -0
- package/dist/boilerplates/@batijs/shared-server/files/server/vike-handler.ts +15 -0
- package/dist/boilerplates/@batijs/shared-server/types/server/vike-handler.d.ts +2 -0
- package/dist/boilerplates/@batijs/solid/files/$README.md.js +9 -3
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +12 -0
- package/dist/boilerplates/@batijs/telefunc/files/server/telefunc-handler.ts +20 -0
- package/dist/boilerplates/@batijs/telefunc/types/server/telefunc-handler.d.ts +2 -0
- package/dist/boilerplates/@batijs/vue/files/$README.md.js +9 -3
- package/dist/boilerplates/boilerplates.json +35 -0
- package/dist/index.js +2 -5
- package/package.json +5 -5
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
import "dotenv/config";
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
|
|
6
|
+
import {
|
|
7
|
+
firebaseAuthLoginHandler,
|
|
8
|
+
firebaseAuthLogoutHandler,
|
|
9
|
+
firebaseAuthMiddleware,
|
|
10
|
+
} from "@batijs/firebase-auth/server/firebase-auth-middleware";
|
|
11
|
+
import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
|
|
12
|
+
import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
|
|
7
13
|
import { appRouter, type AppRouter } from "@batijs/trpc/trpc/server";
|
|
8
|
-
import { createMiddleware } from "@hattip/adapter-node";
|
|
9
14
|
import {
|
|
10
15
|
fastifyTRPCPlugin,
|
|
11
16
|
type CreateFastifyContextOptions,
|
|
12
17
|
type FastifyTRPCPluginOptions,
|
|
13
18
|
} from "@trpc/server/adapters/fastify";
|
|
14
|
-
import
|
|
15
|
-
import { auth, type ConfigParams } from "express-openid-connect";
|
|
19
|
+
import { createRequestAdapter } from "@universal-middleware/express";
|
|
16
20
|
import Fastify from "fastify";
|
|
17
|
-
import {
|
|
18
|
-
import { telefunc } from "telefunc";
|
|
19
|
-
import { VikeAuth } from "vike-authjs";
|
|
20
|
-
import { renderPage } from "vike/server";
|
|
21
|
+
import type { RouteHandlerMethod } from "fastify/types/route";
|
|
21
22
|
|
|
22
23
|
const __filename = fileURLToPath(import.meta.url);
|
|
23
24
|
const __dirname = dirname(__filename);
|
|
@@ -26,11 +27,51 @@ const root = __dirname;
|
|
|
26
27
|
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
|
|
27
28
|
const hmrPort = process.env.HMR_PORT ? parseInt(process.env.HMR_PORT, 10) : 24678;
|
|
28
29
|
|
|
30
|
+
interface Middleware<Context extends Record<string | number | symbol, unknown>> {
|
|
31
|
+
(request: Request, context: Context): Response | void | Promise<Response> | Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function handlerAdapter<Context extends Record<string | number | symbol, unknown>>(
|
|
35
|
+
handler: Middleware<Context>,
|
|
36
|
+
) {
|
|
37
|
+
const requestAdapter = createRequestAdapter();
|
|
38
|
+
return (async (request, reply) => {
|
|
39
|
+
const config = request.routeOptions.config as unknown as Record<string, unknown>;
|
|
40
|
+
config.context ??= {};
|
|
41
|
+
const response = await handler(requestAdapter(request.raw)[0], config.context as Context);
|
|
42
|
+
|
|
43
|
+
if (response) {
|
|
44
|
+
if (!response.body) {
|
|
45
|
+
// Fastify currently doesn't send a response for body is null.
|
|
46
|
+
// To mimic express behavior, we convert the body to an empty ReadableStream.
|
|
47
|
+
Object.defineProperty(response, "body", {
|
|
48
|
+
value: new ReadableStream({
|
|
49
|
+
start(controller) {
|
|
50
|
+
controller.close();
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
writable: false,
|
|
54
|
+
configurable: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return reply.send(response);
|
|
59
|
+
}
|
|
60
|
+
}) satisfies RouteHandlerMethod;
|
|
61
|
+
}
|
|
62
|
+
|
|
29
63
|
startServer();
|
|
30
64
|
|
|
31
65
|
async function startServer() {
|
|
32
66
|
const app = Fastify();
|
|
33
67
|
|
|
68
|
+
// Avoid pre-parsing body, otherwise it will cause issue with universal handlers
|
|
69
|
+
// This will probably change in the future though, you can follow https://github.com/magne4000/universal-handler for updates
|
|
70
|
+
app.removeAllContentTypeParsers();
|
|
71
|
+
app.addContentTypeParser("*", function (_request, _payload, done) {
|
|
72
|
+
done(null, "");
|
|
73
|
+
});
|
|
74
|
+
|
|
34
75
|
await app.register(await import("@fastify/middie"));
|
|
35
76
|
|
|
36
77
|
if (isProduction) {
|
|
@@ -52,118 +93,23 @@ async function startServer() {
|
|
|
52
93
|
app.use(viteDevMiddleware);
|
|
53
94
|
}
|
|
54
95
|
|
|
55
|
-
if (BATI.has("authjs")) {
|
|
56
|
-
await app.register(await import("@fastify/formbody"));
|
|
96
|
+
if (BATI.has("authjs") || BATI.has("auth0")) {
|
|
57
97
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* TODO: Replace secret {@see https://authjs.dev/reference/core#secret}
|
|
61
|
-
* TODO: Choose and implement providers
|
|
62
|
-
*
|
|
63
|
-
* @link {@see https://authjs.dev/guides/providers/custom-provider}
|
|
98
|
+
* Append Auth.js session to context
|
|
64
99
|
**/
|
|
65
|
-
|
|
66
|
-
secret: "MY_SECRET",
|
|
67
|
-
providers: [
|
|
68
|
-
CredentialsProvider({
|
|
69
|
-
name: "Credentials",
|
|
70
|
-
credentials: {
|
|
71
|
-
username: { label: "Username", type: "text", placeholder: "jsmith" },
|
|
72
|
-
password: { label: "Password", type: "password" },
|
|
73
|
-
},
|
|
74
|
-
async authorize() {
|
|
75
|
-
// Add logic here to look up the user from the credentials supplied
|
|
76
|
-
const user = { id: "1", name: "J Smith", email: "jsmith@example.com" };
|
|
77
|
-
|
|
78
|
-
// Any object returned will be saved in `user` property of the JWT
|
|
79
|
-
// If you return null then an error will be displayed advising the user to check their details.
|
|
80
|
-
// You can also Reject this callback with an Error thus the user will be sent to the error page with the error message as a query parameter
|
|
81
|
-
return user ?? null;
|
|
82
|
-
},
|
|
83
|
-
}),
|
|
84
|
-
],
|
|
85
|
-
});
|
|
100
|
+
app.addHook("onRequest", handlerAdapter(authjsSessionMiddleware));
|
|
86
101
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
new Promise<void>((resolve) => {
|
|
93
|
-
vikeAuth(request.raw, reply.raw, () => resolve());
|
|
94
|
-
});
|
|
95
|
-
if (request.url.startsWith("/api/auth/")) {
|
|
96
|
-
await next();
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
});
|
|
102
|
+
/**
|
|
103
|
+
* Auth.js route
|
|
104
|
+
* @link {@see https://authjs.dev/getting-started/installation}
|
|
105
|
+
**/
|
|
106
|
+
app.all("/api/auth/*", handlerAdapter(authjsHandler));
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
if (BATI.has("firebase-auth")) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
app.
|
|
106
|
-
const sessionCookie = request.cookies.__session;
|
|
107
|
-
if (sessionCookie) {
|
|
108
|
-
try {
|
|
109
|
-
const auth = getAuth(firebaseAdmin);
|
|
110
|
-
const decodedIdToken = await auth.verifySessionCookie(sessionCookie);
|
|
111
|
-
const user = await auth.getUser(decodedIdToken.sub);
|
|
112
|
-
request.user = user;
|
|
113
|
-
} catch (error) {
|
|
114
|
-
console.debug("verifySessionCookie:", error);
|
|
115
|
-
request.user = null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
app.post<{ Body: { idToken: string } }>("/api/sessionLogin", async (request, reply) => {
|
|
121
|
-
const idToken = request.body.idToken || "";
|
|
122
|
-
|
|
123
|
-
const expiresIn = 60 * 60 * 24 * 5 * 1000; // 5 days
|
|
124
|
-
|
|
125
|
-
try {
|
|
126
|
-
const auth = getAuth(firebaseAdmin);
|
|
127
|
-
const sessionCookie = await auth.createSessionCookie(idToken, { expiresIn });
|
|
128
|
-
reply.setCookie("__session", sessionCookie, {
|
|
129
|
-
path: "/", // The path needs to be set manually; otherwise, it will default to "/api" in this case.
|
|
130
|
-
maxAge: expiresIn,
|
|
131
|
-
httpOnly: true,
|
|
132
|
-
secure: true,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
reply.code(200);
|
|
136
|
-
return reply.send({ status: "success" });
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.error("createSessionCookie failed :", error);
|
|
139
|
-
|
|
140
|
-
reply.code(401);
|
|
141
|
-
return reply.send({ status: "Unauthorized" });
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
app.post("/api/sessionLogout", (_, reply) => {
|
|
146
|
-
reply.clearCookie("__session");
|
|
147
|
-
reply.code(200);
|
|
148
|
-
return reply.send({ status: "Logged Out" });
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (BATI.has("auth0")) {
|
|
153
|
-
const config: ConfigParams = {
|
|
154
|
-
authRequired: false, // Controls whether authentication is required for all routes
|
|
155
|
-
auth0Logout: true, // Uses Auth0 logout feature
|
|
156
|
-
baseURL: process.env.BASE_URL?.startsWith("http") ? process.env.BASE_URL : `http://localhost:${port}`, // The URL where the application is served
|
|
157
|
-
routes: {
|
|
158
|
-
login: "/api/auth/login", // Custom login route, default is "/login"
|
|
159
|
-
logout: "/api/auth/logout", // Custom logout route, default is "/logout"
|
|
160
|
-
callback: "/api/auth/callback", // Custom callback route, default is "/callback"
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const expressApp = express();
|
|
165
|
-
|
|
166
|
-
app.use(expressApp.use(auth(config)));
|
|
110
|
+
app.addHook("onRequest", handlerAdapter(firebaseAuthMiddleware));
|
|
111
|
+
app.post("/api/sessionLogin", handlerAdapter(firebaseAuthLoginHandler));
|
|
112
|
+
app.post("/api/sessionLogout", handlerAdapter(firebaseAuthLogoutHandler));
|
|
167
113
|
}
|
|
168
114
|
|
|
169
115
|
if (BATI.has("trpc")) {
|
|
@@ -193,19 +139,7 @@ async function startServer() {
|
|
|
193
139
|
*
|
|
194
140
|
* @link {@see https://telefunc.com}
|
|
195
141
|
**/
|
|
196
|
-
app.post<{ Body: string }>("/_telefunc",
|
|
197
|
-
const httpResponse = await telefunc({
|
|
198
|
-
url: request.originalUrl || request.url,
|
|
199
|
-
method: request.method,
|
|
200
|
-
body: request.body,
|
|
201
|
-
context: request,
|
|
202
|
-
});
|
|
203
|
-
const { body, statusCode, contentType } = httpResponse;
|
|
204
|
-
|
|
205
|
-
reply.code(statusCode);
|
|
206
|
-
reply.type(contentType);
|
|
207
|
-
return reply.send(body);
|
|
208
|
-
});
|
|
142
|
+
app.post<{ Body: string }>("/_telefunc", handlerAdapter(telefuncHandler));
|
|
209
143
|
}
|
|
210
144
|
|
|
211
145
|
/**
|
|
@@ -213,27 +147,7 @@ async function startServer() {
|
|
|
213
147
|
*
|
|
214
148
|
* @link {@see https://vike.dev}
|
|
215
149
|
**/
|
|
216
|
-
app.all("/*",
|
|
217
|
-
const pageContextInit = BATI.has("auth0")
|
|
218
|
-
? { urlOriginal: request.originalUrl || request.url, user: request.raw.oidc.user }
|
|
219
|
-
: BATI.has("firebase-auth")
|
|
220
|
-
? { urlOriginal: request.originalUrl || request.url, user: request.user }
|
|
221
|
-
: { urlOriginal: request.originalUrl || request.url };
|
|
222
|
-
|
|
223
|
-
const pageContext = await renderPage(pageContextInit);
|
|
224
|
-
const { httpResponse } = pageContext;
|
|
225
|
-
|
|
226
|
-
if (!httpResponse) {
|
|
227
|
-
return;
|
|
228
|
-
} else {
|
|
229
|
-
const { statusCode, headers, body } = httpResponse;
|
|
230
|
-
|
|
231
|
-
headers.forEach(([name, value]) => reply.header(name, value));
|
|
232
|
-
reply.code(statusCode);
|
|
233
|
-
|
|
234
|
-
return reply.send(body);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
150
|
+
app.all("/*", handlerAdapter(vikeHandler));
|
|
237
151
|
|
|
238
152
|
app.listen(
|
|
239
153
|
{
|
|
@@ -1 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import "dotenv/config";
|
|
3
|
+
interface Middleware<Context extends Record<string | number | symbol, unknown>> {
|
|
4
|
+
(request: Request, context: Context): Response | void | Promise<Response> | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare function handlerAdapter<Context extends Record<string | number | symbol, unknown>>(handler: Middleware<Context>): (this: import("fastify").FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>, request: import("fastify").FastifyRequest<import("fastify").RouteGenericInterface, import("fastify").RawServerDefault, import("http").IncomingMessage, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown, import("fastify").FastifyBaseLogger, import("fastify/types/type-provider").ResolveFastifyRequestType<import("fastify").FastifyTypeProviderDefault, import("fastify").FastifySchema, import("fastify").RouteGenericInterface>>, reply: import("fastify").FastifyReply<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>) => Promise<undefined>;
|
|
7
|
+
export {};
|
|
@@ -42,7 +42,9 @@ var require_package = __commonJS({
|
|
|
42
42
|
license: "MIT",
|
|
43
43
|
devDependencies: {
|
|
44
44
|
"@batijs/compile": "workspace:*",
|
|
45
|
+
"@types/cookie": "^0.6.0",
|
|
45
46
|
"@types/node": "^18.19.14",
|
|
47
|
+
cookie: "^0.6.0",
|
|
46
48
|
dotenv: "^16.4.5",
|
|
47
49
|
firebase: "^10.12.1",
|
|
48
50
|
"firebase-admin": "^12.1.1",
|
|
@@ -76,6 +78,9 @@ var require_package = __commonJS({
|
|
|
76
78
|
},
|
|
77
79
|
"./pages/login/+guard": {
|
|
78
80
|
types: "./dist/types/pages/login/+guard.d.ts"
|
|
81
|
+
},
|
|
82
|
+
"./server/firebase-auth-middleware": {
|
|
83
|
+
types: "./dist/types/server/firebase-auth-middleware.d.ts"
|
|
79
84
|
}
|
|
80
85
|
},
|
|
81
86
|
typesVersions: {
|
|
@@ -94,6 +99,9 @@ var require_package = __commonJS({
|
|
|
94
99
|
],
|
|
95
100
|
"pages/login/+guard": [
|
|
96
101
|
"./dist/types/pages/login/+guard.d.ts"
|
|
102
|
+
],
|
|
103
|
+
"server/firebase-auth-middleware": [
|
|
104
|
+
"./dist/types/server/firebase-auth-middleware.d.ts"
|
|
97
105
|
]
|
|
98
106
|
}
|
|
99
107
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
import { applicationDefault, getApp, getApps, initializeApp, type App } from "firebase-admin/app";
|
|
3
|
+
import { getAuth } from "firebase-admin/auth";
|
|
3
4
|
|
|
4
5
|
let firebaseAdmin: App | undefined;
|
|
5
6
|
|
|
@@ -11,4 +12,4 @@ if (!getApps().length) {
|
|
|
11
12
|
firebaseAdmin = getApp();
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export { firebaseAdmin };
|
|
15
|
+
export { firebaseAdmin, getAuth };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { parse, serialize } from "cookie";
|
|
2
|
+
import { getAuth } from "firebase-admin/auth";
|
|
3
|
+
import { firebaseAdmin } from "../libs/firebaseAdmin";
|
|
4
|
+
|
|
5
|
+
export async function firebaseAuthMiddleware(
|
|
6
|
+
request: Request,
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
context: any,
|
|
9
|
+
): Promise<void> {
|
|
10
|
+
if (!request.headers.has("cookie")) return;
|
|
11
|
+
|
|
12
|
+
const cookies = parse(request.headers.get("cookie")!);
|
|
13
|
+
const sessionCookie: string = cookies.__session || "";
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const auth = getAuth(firebaseAdmin);
|
|
17
|
+
const decodedIdToken = await auth.verifySessionCookie(sessionCookie, true);
|
|
18
|
+
context.user = await auth.getUser(decodedIdToken.sub);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.debug("verifySessionCookie:", error);
|
|
21
|
+
context.user = null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function firebaseAuthLoginHandler<Context extends Record<string | number | symbol, unknown>>(
|
|
26
|
+
request: Request,
|
|
27
|
+
_context?: Context,
|
|
28
|
+
): Promise<Response> {
|
|
29
|
+
const body = await request.json();
|
|
30
|
+
const idToken: string = (body as { idToken?: string }).idToken || "";
|
|
31
|
+
|
|
32
|
+
const expiresIn = 60 * 60 * 24 * 5 * 1000; // 5 days
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const sessionCookie = await getAuth(firebaseAdmin).createSessionCookie(idToken, { expiresIn });
|
|
36
|
+
|
|
37
|
+
const options = { maxAge: expiresIn / 1000, httpOnly: true, secure: true };
|
|
38
|
+
|
|
39
|
+
return new Response(JSON.stringify({ status: "success" }), {
|
|
40
|
+
status: 200,
|
|
41
|
+
headers: {
|
|
42
|
+
"content-type": "application/json",
|
|
43
|
+
"set-cookie": serialize("__session", sessionCookie, options),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error("createSessionCookie:", error);
|
|
48
|
+
|
|
49
|
+
return new Response("Unauthorized Request", {
|
|
50
|
+
status: 401,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function firebaseAuthLogoutHandler<Context extends Record<string | number | symbol, unknown>>(
|
|
56
|
+
_request: Request,
|
|
57
|
+
_context?: Context,
|
|
58
|
+
): Promise<Response> {
|
|
59
|
+
return new Response(JSON.stringify({ status: "success" }), {
|
|
60
|
+
status: 200,
|
|
61
|
+
headers: {
|
|
62
|
+
"content-type": "application/json",
|
|
63
|
+
"set-cookie": serialize("__session", "", {
|
|
64
|
+
maxAge: 0,
|
|
65
|
+
httpOnly: true,
|
|
66
|
+
secure: true,
|
|
67
|
+
expires: new Date(1),
|
|
68
|
+
path: "/",
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function firebaseAuthMiddleware(request: Request, context: any): Promise<void>;
|
|
3
|
+
export declare function firebaseAuthLoginHandler<Context extends Record<string | number | symbol, unknown>>(request: Request, _context?: Context): Promise<Response>;
|
|
4
|
+
export declare function firebaseAuthLogoutHandler<Context extends Record<string | number | symbol, unknown>>(_request: Request, _context?: Context): Promise<Response>;
|
|
@@ -42,8 +42,11 @@ var require_package = __commonJS({
|
|
|
42
42
|
license: "MIT",
|
|
43
43
|
devDependencies: {
|
|
44
44
|
"@auth/core": "^0.31.0",
|
|
45
|
+
"@batijs/authjs": "workspace:*",
|
|
45
46
|
"@batijs/compile": "workspace:*",
|
|
46
47
|
"@batijs/firebase-auth": "workspace:*",
|
|
48
|
+
"@batijs/shared-server": "workspace:^",
|
|
49
|
+
"@batijs/telefunc": "workspace:^",
|
|
47
50
|
"@batijs/trpc": "workspace:^",
|
|
48
51
|
"@hattip/polyfills": "^0.0.45",
|
|
49
52
|
"@trpc/server": "^10.45.2",
|
|
@@ -51,15 +54,11 @@ var require_package = __commonJS({
|
|
|
51
54
|
"@types/node": "^18.19.14",
|
|
52
55
|
"@types/serve-static": "^1.15.7",
|
|
53
56
|
dotenv: "^16.4.5",
|
|
54
|
-
express: "^4.19.2",
|
|
55
|
-
"express-openid-connect": "^2.17.1",
|
|
56
|
-
"firebase-admin": "^12.1.1",
|
|
57
57
|
h3: "~1.11.1",
|
|
58
58
|
"serve-static": "^1.15.0",
|
|
59
59
|
telefunc: "^0.1.72",
|
|
60
60
|
tsx: "^4.11.0",
|
|
61
61
|
vike: "^0.4.172",
|
|
62
|
-
"vike-authjs": "^0.1.6",
|
|
63
62
|
vite: "^5.2.11"
|
|
64
63
|
},
|
|
65
64
|
dependencies: {
|
|
@@ -121,8 +120,7 @@ async function getPackageJson(props) {
|
|
|
121
120
|
"tsx",
|
|
122
121
|
"vike",
|
|
123
122
|
"vite",
|
|
124
|
-
...props.meta.BATI.has("authjs") ? ["@auth/core"
|
|
125
|
-
...props.meta.BATI.has("auth0") ? ["express", "express-openid-connect"] : []
|
|
123
|
+
...props.meta.BATI.has("authjs") || props.meta.BATI.has("auth0") ? ["@auth/core"] : []
|
|
126
124
|
]
|
|
127
125
|
});
|
|
128
126
|
}
|