@batijs/cli 0.0.164 → 0.0.165
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/compiled/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/eslint/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/express/files/$package.json.js +12 -4
- package/dist/boilerplates/@batijs/express/files/express-entry.ts +64 -7
- package/dist/boilerplates/@batijs/firebase-auth/files/$.env.js +15 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/$README.md.js +30 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +121 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/firebase/service-account-example.json +13 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/libs/firebaseAdmin.ts +14 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/libs/firebaseUI.ts +31 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/pages/+firebaseApp.ts +32 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/pages/login/+config.ts +6 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/pages/login/+guard.ts +11 -0
- package/dist/boilerplates/@batijs/firebase-auth/files/types.ts +25 -0
- package/dist/boilerplates/@batijs/firebase-auth/types/libs/firebaseAdmin.d.ts +4 -0
- package/dist/boilerplates/@batijs/firebase-auth/types/libs/firebaseUI.d.ts +5 -0
- package/dist/boilerplates/@batijs/firebase-auth/types/pages/+firebaseApp.d.ts +3 -0
- package/dist/boilerplates/@batijs/firebase-auth/types/pages/login/+config.d.ts +4 -0
- package/dist/boilerplates/@batijs/firebase-auth/types/pages/login/+guard.d.ts +3 -0
- package/dist/boilerplates/@batijs/firebase-auth/types/types.d.ts +18 -0
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +4 -2
- package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +87 -1
- package/dist/boilerplates/@batijs/h3/types/h3-entry.d.ts +6 -1
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/prettier/files/.prettierignore +3 -0
- package/dist/boilerplates/@batijs/react/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/react/files/pages/+config.ts +11 -0
- package/dist/boilerplates/@batijs/react/types/pages/+config.d.ts +8 -0
- package/dist/boilerplates/@batijs/react-firebase-auth/files/pages/login/+Page.tsx +52 -0
- package/dist/boilerplates/@batijs/react-firebase-auth/types/pages/login/+Page.d.ts +3 -0
- package/dist/boilerplates/@batijs/solid/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +11 -0
- package/dist/boilerplates/@batijs/solid/types/pages/+config.d.ts +8 -0
- package/dist/boilerplates/@batijs/solid-firebase-auth/files/pages/login/+Page.tsx +52 -0
- package/dist/boilerplates/@batijs/solid-firebase-auth/types/pages/login/+Page.d.ts +3 -0
- package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/trpc/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/trpc/types/trpc/client.d.ts +72 -38
- package/dist/boilerplates/@batijs/vercel/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/vue/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +11 -0
- package/dist/boilerplates/@batijs/vue/types/pages/+config.d.ts +8 -0
- package/dist/boilerplates/@batijs/vue-firebase-auth/files/pages/login/+Page.vue +51 -0
- package/dist/boilerplates/boilerplates.json +59 -0
- package/dist/index.js +3 -3
- package/package.json +7 -7
|
@@ -2,16 +2,24 @@ import { createServer, type IncomingMessage, type ServerResponse } from "node:ht
|
|
|
2
2
|
import { dirname } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import CredentialsProvider from "@auth/core/providers/credentials";
|
|
5
|
+
import { firebaseAdmin } from "@batijs/firebase-auth/libs/firebaseAdmin";
|
|
5
6
|
import { appRouter } from "@batijs/trpc/trpc/server";
|
|
6
7
|
import installCrypto from "@hattip/polyfills/crypto";
|
|
7
8
|
import installGetSetCookie from "@hattip/polyfills/get-set-cookie";
|
|
8
9
|
import installWhatwgNodeFetch from "@hattip/polyfills/whatwg-node";
|
|
9
10
|
import { nodeHTTPRequestHandler, type NodeHTTPCreateContextFnOptions } from "@trpc/server/adapters/node-http";
|
|
11
|
+
import { getAuth, type UserRecord } from "firebase-admin/auth";
|
|
10
12
|
import {
|
|
11
13
|
createApp,
|
|
12
14
|
createRouter,
|
|
15
|
+
deleteCookie,
|
|
13
16
|
eventHandler,
|
|
14
17
|
fromNodeMiddleware,
|
|
18
|
+
getCookie,
|
|
19
|
+
getResponseStatus,
|
|
20
|
+
getResponseStatusText,
|
|
21
|
+
readBody,
|
|
22
|
+
setCookie,
|
|
15
23
|
setResponseHeaders,
|
|
16
24
|
setResponseStatus,
|
|
17
25
|
toNodeListener,
|
|
@@ -31,6 +39,14 @@ const __dirname = dirname(__filename);
|
|
|
31
39
|
const isProduction = process.env.NODE_ENV === "production";
|
|
32
40
|
const root = __dirname;
|
|
33
41
|
|
|
42
|
+
/*{ @if (it.BATI.has("firebase-auth")) }*/
|
|
43
|
+
declare module "h3" {
|
|
44
|
+
interface H3EventContext {
|
|
45
|
+
user: UserRecord | null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/*{ /if }*/
|
|
49
|
+
|
|
34
50
|
startServer();
|
|
35
51
|
|
|
36
52
|
async function startServer() {
|
|
@@ -95,6 +111,71 @@ async function startServer() {
|
|
|
95
111
|
);
|
|
96
112
|
}
|
|
97
113
|
|
|
114
|
+
if (BATI.has("firebase-auth")) {
|
|
115
|
+
app.use(
|
|
116
|
+
eventHandler(async (event) => {
|
|
117
|
+
const sessionCookie = getCookie(event, "__session");
|
|
118
|
+
if (sessionCookie) {
|
|
119
|
+
try {
|
|
120
|
+
const auth = getAuth(firebaseAdmin);
|
|
121
|
+
const decodedIdToken = await auth.verifySessionCookie(sessionCookie);
|
|
122
|
+
const user = await auth.getUser(decodedIdToken.sub);
|
|
123
|
+
event.context.user = user;
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error("verifySessionCookie:", error);
|
|
126
|
+
event.context.user = null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
router.post(
|
|
133
|
+
"/api/sessionLogin",
|
|
134
|
+
eventHandler(async (event) => {
|
|
135
|
+
const body = await readBody(event);
|
|
136
|
+
const idToken: string = body.idToken || "";
|
|
137
|
+
|
|
138
|
+
let status: number;
|
|
139
|
+
let text: string;
|
|
140
|
+
|
|
141
|
+
const expiresIn = 60 * 60 * 24 * 5 * 1000; // 5 days
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
const auth = getAuth(firebaseAdmin);
|
|
145
|
+
const sessionCookie = await auth.createSessionCookie(idToken, { expiresIn });
|
|
146
|
+
setCookie(event, "__session", sessionCookie, {
|
|
147
|
+
maxAge: expiresIn,
|
|
148
|
+
httpOnly: true,
|
|
149
|
+
secure: true,
|
|
150
|
+
});
|
|
151
|
+
setResponseStatus(event, 200, "Success");
|
|
152
|
+
|
|
153
|
+
status = getResponseStatus(event);
|
|
154
|
+
text = getResponseStatusText(event);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error("createSessionCookie:", error);
|
|
157
|
+
setResponseStatus(event, 401, "Unauthorized Request");
|
|
158
|
+
status = getResponseStatus(event);
|
|
159
|
+
text = getResponseStatusText(event);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
status,
|
|
164
|
+
text,
|
|
165
|
+
};
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
router.post(
|
|
170
|
+
"/api/sessionLogout",
|
|
171
|
+
eventHandler((event) => {
|
|
172
|
+
deleteCookie(event, "__session");
|
|
173
|
+
setResponseStatus(event, 200, "Logged Out");
|
|
174
|
+
return "Logged Out";
|
|
175
|
+
}),
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
98
179
|
if (BATI.has("trpc")) {
|
|
99
180
|
/**
|
|
100
181
|
* tRPC route
|
|
@@ -153,7 +234,12 @@ async function startServer() {
|
|
|
153
234
|
router.use(
|
|
154
235
|
"/**",
|
|
155
236
|
eventHandler(async (event) => {
|
|
156
|
-
const pageContextInit =
|
|
237
|
+
const pageContextInit = BATI.has("firebase-auth")
|
|
238
|
+
? { urlOriginal: event.node.req.originalUrl || event.node.req.url! }
|
|
239
|
+
: {
|
|
240
|
+
urlOriginal: event.node.req.originalUrl || event.node.req.url!,
|
|
241
|
+
user: event.context.user,
|
|
242
|
+
};
|
|
157
243
|
const pageContext = await renderPage(pageContextInit);
|
|
158
244
|
const response = pageContext.httpResponse;
|
|
159
245
|
|
|
@@ -48,13 +48,13 @@ var require_package = __commonJS({
|
|
|
48
48
|
"@hattip/core": "^0.0.43",
|
|
49
49
|
"@hattip/router": "^0.0.43",
|
|
50
50
|
"@hattip/vite": "^0.0.43",
|
|
51
|
-
"@trpc/server": "^10.45.
|
|
51
|
+
"@trpc/server": "^10.45.2",
|
|
52
52
|
"@types/node": "^18.19.14",
|
|
53
53
|
hattip: "^0.0.33",
|
|
54
54
|
telefunc: "^0.1.71",
|
|
55
55
|
vike: "^0.4.165",
|
|
56
56
|
"vike-authjs": "^0.1.5",
|
|
57
|
-
vite: "^5.1.
|
|
57
|
+
vite: "^5.1.6"
|
|
58
58
|
},
|
|
59
59
|
dependencies: {
|
|
60
60
|
"@batijs/core": "workspace:*"
|
|
@@ -46,18 +46,18 @@ var require_package = __commonJS({
|
|
|
46
46
|
"@babel/plugin-transform-react-jsx": "^7.23.4",
|
|
47
47
|
"@batijs/compile": "workspace:*",
|
|
48
48
|
"@types/node": "^18.19.14",
|
|
49
|
-
"@types/react": "^18.2.
|
|
50
|
-
"@types/react-dom": "^18.2.
|
|
49
|
+
"@types/react": "^18.2.64",
|
|
50
|
+
"@types/react-dom": "^18.2.21",
|
|
51
51
|
"@vitejs/plugin-react": "^4.2.1",
|
|
52
52
|
"cross-fetch": "^4.0.0",
|
|
53
53
|
"eslint-plugin-react": "^7.34.0",
|
|
54
54
|
react: "^18.2.0",
|
|
55
55
|
"react-dom": "^18.2.0",
|
|
56
56
|
tailwindcss: "^3.4.1",
|
|
57
|
-
typescript: "^5.
|
|
57
|
+
typescript: "^5.4.2",
|
|
58
58
|
vike: "^0.4.165",
|
|
59
59
|
"vike-react": "^0.4.6",
|
|
60
|
-
vite: "^5.1.
|
|
60
|
+
vite: "^5.1.6"
|
|
61
61
|
},
|
|
62
62
|
dependencies: {
|
|
63
63
|
"@batijs/core": "workspace:*"
|
|
@@ -7,7 +7,18 @@ import Layout from "../layouts/LayoutDefault";
|
|
|
7
7
|
export default {
|
|
8
8
|
Layout,
|
|
9
9
|
Head,
|
|
10
|
+
/*{ @if (it.BATI.has("firebase-auth")) }*/
|
|
11
|
+
passToClient: ["user"],
|
|
12
|
+
/*{ /if }*/
|
|
10
13
|
// <title>
|
|
11
14
|
title: "My Vike App",
|
|
12
15
|
extends: vikeReact,
|
|
16
|
+
/*{ @if (it.BATI.has("firebase-auth")) }*/
|
|
17
|
+
meta: {
|
|
18
|
+
// Temporary workaround until +client.js is implemented: https://github.com/vikejs/vike/issues/1468
|
|
19
|
+
firebaseApp: {
|
|
20
|
+
env: { client: true },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
/*{ /if }*/
|
|
13
24
|
} satisfies Config;
|
|
@@ -3,6 +3,7 @@ import Layout from "../layouts/LayoutDefault";
|
|
|
3
3
|
declare const _default: {
|
|
4
4
|
Layout: typeof Layout;
|
|
5
5
|
Head: typeof Head;
|
|
6
|
+
passToClient: string[];
|
|
6
7
|
title: string;
|
|
7
8
|
extends: {
|
|
8
9
|
name: string;
|
|
@@ -71,5 +72,12 @@ declare const _default: {
|
|
|
71
72
|
};
|
|
72
73
|
};
|
|
73
74
|
};
|
|
75
|
+
meta: {
|
|
76
|
+
firebaseApp: {
|
|
77
|
+
env: {
|
|
78
|
+
client: true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
74
82
|
};
|
|
75
83
|
export default _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import "firebaseui/dist/firebaseui.css"
|
|
2
|
+
import React, { useEffect, useState } from 'react'
|
|
3
|
+
import { startFirebaseUI } from "@batijs/firebase-auth/libs/firebaseUI"
|
|
4
|
+
import * as firebaseui from "firebaseui"
|
|
5
|
+
import { getAuth, type UserCredential } from 'firebase/auth'
|
|
6
|
+
import { reload } from "vike/client/router"
|
|
7
|
+
|
|
8
|
+
export default Page
|
|
9
|
+
|
|
10
|
+
function Page() {
|
|
11
|
+
const [error, setError] = useState("")
|
|
12
|
+
|
|
13
|
+
async function sessionLogin(authResult: UserCredential) {
|
|
14
|
+
const idToken = await authResult.user.getIdToken() || ""
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch("/api/sessionLogin", {
|
|
17
|
+
method: "POST",
|
|
18
|
+
body: JSON.stringify({ idToken }),
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
if (response.ok) {
|
|
24
|
+
await reload()
|
|
25
|
+
} else {
|
|
26
|
+
setError(response.statusText)
|
|
27
|
+
}
|
|
28
|
+
await getAuth().signOut()
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.log('error :', err)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const ui = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(getAuth())
|
|
36
|
+
if (!error) {
|
|
37
|
+
startFirebaseUI(ui, sessionLogin)
|
|
38
|
+
}
|
|
39
|
+
}, [error])
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<div id="firebaseui-auth-container"></div>
|
|
44
|
+
{error && (
|
|
45
|
+
<>
|
|
46
|
+
<div style={{ color: "red" }}>There is an error occured : {error}</div>
|
|
47
|
+
<button onClick={() => setError("")}>Try Again</button>
|
|
48
|
+
</>
|
|
49
|
+
)}
|
|
50
|
+
</>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -47,10 +47,10 @@ var require_package = __commonJS({
|
|
|
47
47
|
"eslint-plugin-solid": "^0.13.1",
|
|
48
48
|
"solid-js": "^1.8.15",
|
|
49
49
|
tailwindcss: "^3.4.1",
|
|
50
|
-
typescript: "^5.
|
|
50
|
+
typescript: "^5.4.2",
|
|
51
51
|
vike: "^0.4.165",
|
|
52
52
|
"vike-solid": "^0.4.2",
|
|
53
|
-
vite: "^5.1.
|
|
53
|
+
vite: "^5.1.6",
|
|
54
54
|
"vite-plugin-solid": "^2.10.1"
|
|
55
55
|
},
|
|
56
56
|
dependencies: {
|
|
@@ -8,6 +8,17 @@ export default {
|
|
|
8
8
|
Layout,
|
|
9
9
|
Head,
|
|
10
10
|
// <title>
|
|
11
|
+
/*{ @if (it.BATI.has("firebase-auth")) }*/
|
|
12
|
+
passToClient: ["user"],
|
|
13
|
+
/*{ /if }*/
|
|
11
14
|
title: "My Vike App",
|
|
12
15
|
extends: vikeSolid,
|
|
16
|
+
/*{ @if (it.BATI.has("firebase-auth")) }*/
|
|
17
|
+
meta: {
|
|
18
|
+
// Temporary workaround until +client.js is implemented: https://github.com/vikejs/vike/issues/1468
|
|
19
|
+
firebaseApp: {
|
|
20
|
+
env: { client: true },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
/*{ /if }*/
|
|
13
24
|
} satisfies Config;
|
|
@@ -4,7 +4,15 @@ import Layout from "../layouts/LayoutDefault";
|
|
|
4
4
|
declare const _default: {
|
|
5
5
|
Layout: typeof Layout;
|
|
6
6
|
Head: typeof Head;
|
|
7
|
+
passToClient: string[];
|
|
7
8
|
title: string;
|
|
8
9
|
extends: typeof vikeSolid;
|
|
10
|
+
meta: {
|
|
11
|
+
firebaseApp: {
|
|
12
|
+
env: {
|
|
13
|
+
client: true;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
9
17
|
};
|
|
10
18
|
export default _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import "firebaseui/dist/firebaseui.css"
|
|
2
|
+
import { createEffect, createSignal } from "solid-js"
|
|
3
|
+
import { startFirebaseUI } from "@batijs/firebase-auth/libs/firebaseUI"
|
|
4
|
+
import * as firebaseui from "firebaseui"
|
|
5
|
+
import { getAuth, type UserCredential } from 'firebase/auth'
|
|
6
|
+
import { reload } from "vike/client/router"
|
|
7
|
+
|
|
8
|
+
export default Page
|
|
9
|
+
|
|
10
|
+
function Page() {
|
|
11
|
+
const [error, setError] = createSignal("")
|
|
12
|
+
|
|
13
|
+
async function sessionLogin(authResult: UserCredential) {
|
|
14
|
+
const idToken = await authResult.user.getIdToken() || ""
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch("/api/sessionLogin", {
|
|
17
|
+
method: "POST",
|
|
18
|
+
body: JSON.stringify({ idToken }),
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
if (response.ok) {
|
|
24
|
+
await reload()
|
|
25
|
+
} else {
|
|
26
|
+
setError(response.statusText)
|
|
27
|
+
}
|
|
28
|
+
await getAuth().signOut()
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.log('error :', err)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
createEffect(() => {
|
|
35
|
+
const ui = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(getAuth())
|
|
36
|
+
if (!error()) {
|
|
37
|
+
startFirebaseUI(ui, sessionLogin)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<div id="firebaseui-auth-container" />
|
|
44
|
+
{error() && (
|
|
45
|
+
<>
|
|
46
|
+
<div style={{ color: "red" }}>There is an error occured : {error()}</div>
|
|
47
|
+
<button onClick={() => setError("")}>Try Again</button>
|
|
48
|
+
</>
|
|
49
|
+
)}
|
|
50
|
+
</>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -44,11 +44,11 @@ var require_package = __commonJS({
|
|
|
44
44
|
"@batijs/compile": "workspace:*",
|
|
45
45
|
"@types/node": "^18.19.14",
|
|
46
46
|
autoprefixer: "^10.4.18",
|
|
47
|
-
daisyui: "^4.7.
|
|
47
|
+
daisyui: "^4.7.3",
|
|
48
48
|
postcss: "^8.4.35",
|
|
49
49
|
tailwindcss: "^3.4.1",
|
|
50
50
|
vike: "^0.4.165",
|
|
51
|
-
vite: "^5.1.
|
|
51
|
+
vite: "^5.1.6"
|
|
52
52
|
},
|
|
53
53
|
dependencies: {
|
|
54
54
|
"@batijs/core": "workspace:*"
|
|
@@ -43,10 +43,10 @@ var require_package = __commonJS({
|
|
|
43
43
|
devDependencies: {
|
|
44
44
|
"@batijs/compile": "workspace:*",
|
|
45
45
|
"@batijs/shared-db": "workspace:*",
|
|
46
|
-
"@trpc/client": "^10.45.
|
|
47
|
-
"@trpc/server": "^10.45.
|
|
46
|
+
"@trpc/client": "^10.45.2",
|
|
47
|
+
"@trpc/server": "^10.45.2",
|
|
48
48
|
"@types/node": "^18.19.14",
|
|
49
|
-
vite: "^5.1.
|
|
49
|
+
vite: "^5.1.6"
|
|
50
50
|
},
|
|
51
51
|
dependencies: {
|
|
52
52
|
"@batijs/core": "workspace:*"
|
|
@@ -1,38 +1,72 @@
|
|
|
1
|
-
export declare const trpc: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
1
|
+
export declare const trpc: import("@trpc/client").inferRouterProxyClient<import("@trpc/server/dist/core/router").CreateRouterInner<import("@trpc/server").RootConfig<{
|
|
2
|
+
ctx: object;
|
|
3
|
+
meta: object;
|
|
4
|
+
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
5
|
+
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
6
|
+
}>, {
|
|
7
|
+
demo: import("@trpc/server").BuildProcedure<"query", {
|
|
8
|
+
_config: import("@trpc/server").RootConfig<{
|
|
9
|
+
ctx: object;
|
|
10
|
+
meta: object;
|
|
11
|
+
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
12
|
+
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
13
|
+
}>;
|
|
14
|
+
_ctx_out: object;
|
|
15
|
+
_input_in: typeof import("@trpc/server").unsetMarker;
|
|
16
|
+
_input_out: typeof import("@trpc/server").unsetMarker;
|
|
17
|
+
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
18
|
+
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
19
|
+
_meta: object;
|
|
20
|
+
}, {
|
|
21
|
+
demo: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
onNewTodo: import("@trpc/server").BuildProcedure<"mutation", {
|
|
24
|
+
_config: import("@trpc/server").RootConfig<{
|
|
25
|
+
ctx: object;
|
|
26
|
+
meta: object;
|
|
27
|
+
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
28
|
+
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
29
|
+
}>;
|
|
30
|
+
_meta: object;
|
|
31
|
+
_ctx_out: object;
|
|
32
|
+
_input_in: string;
|
|
33
|
+
_input_out: string;
|
|
34
|
+
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
35
|
+
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
36
|
+
}, {
|
|
37
|
+
todoItems: import("@batijs/shared-db/database/todoItems").TodoItem[];
|
|
38
|
+
}>;
|
|
39
|
+
}>, {
|
|
40
|
+
demo: import("@trpc/server").BuildProcedure<"query", {
|
|
41
|
+
_config: import("@trpc/server").RootConfig<{
|
|
42
|
+
ctx: object;
|
|
43
|
+
meta: object;
|
|
44
|
+
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
45
|
+
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
46
|
+
}>;
|
|
47
|
+
_ctx_out: object;
|
|
48
|
+
_input_in: typeof import("@trpc/server").unsetMarker;
|
|
49
|
+
_input_out: typeof import("@trpc/server").unsetMarker;
|
|
50
|
+
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
51
|
+
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
52
|
+
_meta: object;
|
|
53
|
+
}, {
|
|
54
|
+
demo: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
onNewTodo: import("@trpc/server").BuildProcedure<"mutation", {
|
|
57
|
+
_config: import("@trpc/server").RootConfig<{
|
|
58
|
+
ctx: object;
|
|
59
|
+
meta: object;
|
|
60
|
+
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
61
|
+
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
62
|
+
}>;
|
|
63
|
+
_meta: object;
|
|
64
|
+
_ctx_out: object;
|
|
65
|
+
_input_in: string;
|
|
66
|
+
_input_out: string;
|
|
67
|
+
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
68
|
+
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
69
|
+
}, {
|
|
70
|
+
todoItems: import("@batijs/shared-db/database/todoItems").TodoItem[];
|
|
71
|
+
}>;
|
|
72
|
+
}>;
|
|
@@ -49,11 +49,11 @@ var require_package = __commonJS({
|
|
|
49
49
|
"cross-fetch": "^4.0.0",
|
|
50
50
|
"eslint-plugin-vue": "^9.22.0",
|
|
51
51
|
tailwindcss: "^3.4.1",
|
|
52
|
-
typescript: "^5.
|
|
52
|
+
typescript: "^5.4.2",
|
|
53
53
|
"unplugin-vue-markdown": "^0.26.0",
|
|
54
54
|
vike: "^0.4.165",
|
|
55
55
|
"vike-vue": "^0.6.3",
|
|
56
|
-
vite: "^5.1.
|
|
56
|
+
vite: "^5.1.6",
|
|
57
57
|
vue: "^3.4.21",
|
|
58
58
|
"vue-gtag": "^2.0.1"
|
|
59
59
|
},
|
|
@@ -8,6 +8,17 @@ export default {
|
|
|
8
8
|
Layout,
|
|
9
9
|
Head,
|
|
10
10
|
// <title>
|
|
11
|
+
/*{ @if (it.BATI.has("firebase-auth")) }*/
|
|
12
|
+
passToClient: ["user"],
|
|
13
|
+
/*{ /if }*/
|
|
11
14
|
title: "My Vike App",
|
|
12
15
|
extends: vikeVue,
|
|
16
|
+
/*{ @if (it.BATI.has("firebase-auth")) }*/
|
|
17
|
+
meta: {
|
|
18
|
+
// Temporary workaround until +client.js is implemented: https://github.com/vikejs/vike/issues/1468
|
|
19
|
+
firebaseApp: {
|
|
20
|
+
env: { client: true },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
/*{ /if }*/
|
|
13
24
|
} satisfies Config;
|
|
@@ -3,7 +3,15 @@ import Head from "../layouts/HeadDefault.vue";
|
|
|
3
3
|
declare const _default: {
|
|
4
4
|
Layout: typeof Head;
|
|
5
5
|
Head: typeof Head;
|
|
6
|
+
passToClient: string[];
|
|
6
7
|
title: string;
|
|
7
8
|
extends: typeof vikeVue;
|
|
9
|
+
meta: {
|
|
10
|
+
firebaseApp: {
|
|
11
|
+
env: {
|
|
12
|
+
client: true;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
8
16
|
};
|
|
9
17
|
export default _default;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="firebaseui-auth-container"></div>
|
|
3
|
+
<div v-if="error">
|
|
4
|
+
<div style="color:red">There is an error occured : {{ error }}</div>
|
|
5
|
+
<button @click="clearError">Try Again</button>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import "firebaseui/dist/firebaseui.css"
|
|
11
|
+
import { ref, onMounted, onUpdated } from "vue";
|
|
12
|
+
import * as firebaseui from "firebaseui"
|
|
13
|
+
import { getAuth, type UserCredential } from 'firebase/auth'
|
|
14
|
+
import { reload } from "vike/client/router"
|
|
15
|
+
import { startFirebaseUI } from "@batijs/firebase-auth/libs/firebaseUI"
|
|
16
|
+
|
|
17
|
+
const error = ref("")
|
|
18
|
+
const clearError = () => error.value = ""
|
|
19
|
+
const ui = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(getAuth())
|
|
20
|
+
|
|
21
|
+
async function sessionLogin(authResult: UserCredential) {
|
|
22
|
+
const idToken = await authResult.user.getIdToken() || ""
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch("/api/sessionLogin", {
|
|
25
|
+
method: "POST",
|
|
26
|
+
body: JSON.stringify({ idToken }),
|
|
27
|
+
headers: {
|
|
28
|
+
"Content-Type": "application/json",
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
if (response.ok) {
|
|
32
|
+
await reload()
|
|
33
|
+
} else {
|
|
34
|
+
error.value = response.statusText
|
|
35
|
+
}
|
|
36
|
+
await getAuth().signOut()
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.log('error :', err)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
onMounted(() => {
|
|
43
|
+
startFirebaseUI(ui, sessionLogin)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
onUpdated(() => {
|
|
47
|
+
if (!error.value) {
|
|
48
|
+
startFirebaseUI(ui, sessionLogin)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
</script>
|