Skip to content

Commit 3eec751

Browse files
committed
feat(warn): doc to docs
1 parent 078c3ac commit 3eec751

9 files changed

+28
-99
lines changed

packages/nuxt/playground/preset/nitro.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,17 @@ export default {
1616
// }
1717
// }
1818
// }
19+
20+
interface FirebaseUserAppConfig {
21+
firebase?: {
22+
functions?: {
23+
runtimeOptions?: RuntimeOptions
24+
httpsOptions?: HttpsOptions
25+
}
26+
}
27+
}
28+
29+
declare module '@nuxt/schema' {
30+
// interface AppConfig extends FirebaseUserAppConfig {}
31+
interface RuntimeConfig extends FirebaseUserAppConfig {}
32+
}

packages/nuxt/src/firebaseAliases.ts

-31
This file was deleted.

packages/nuxt/src/module.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
} from 'firebase-admin/app'
1818
import { markRaw } from 'vue'
1919
import type { NuxtVueFireAppCheckOptions } from './runtime/app-check'
20-
import { addMissingAlias } from './firebaseAliases'
2120
import { log } from './runtime/logging'
2221

2322
export interface VueFireNuxtModuleOptions {
@@ -89,7 +88,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
8988
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
9089
const templatesDir = fileURLToPath(new URL('../templates', import.meta.url))
9190

92-
// to handle TimeStamp objects
91+
// to handle TimeStamp and GeoPoints objects
9392
addPlugin(resolve(runtimeDir, 'payload-plugin'))
9493

9594
// TODO: I don't think the appConfig is the right place to store these as it makes things reactive
@@ -129,7 +128,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
129128
if (nuxt.options.ssr && !hasServiceAccount) {
130129
log(
131130
'warn',
132-
'You activated both SSR and auth but you are not providing an admin config. If you render or prerender any page using auth, you will get an error. In that case, provide an admin config to the nuxt-vuefire module.'
131+
'You activated both SSR and auth but you are not providing a service account for the admin SDK. See https://vuefire.vuejs.org/nuxt/getting-started.html#configuring-the-admin-sdk.'
133132
)
134133
}
135134

@@ -141,8 +140,7 @@ export default defineNuxtModule<VueFireNuxtModuleOptions>({
141140
} else if (nuxt.options.ssr) {
142141
log(
143142
'warn',
144-
'You activated both SSR and app-check but you are not providing an admin config. If you render or prerender any page using app-check, you will get an error. In that case, provide an admin config to the nuxt-vuefire module.'
145-
// TODO: link about how to provide admin credentials
143+
'You activated both SSR and app-check but you are not providing a service account for the admin SDK. See https://vuefire.vuejs.org/nuxt/getting-started.html#configuring-the-admin-sdk.'
146144
)
147145
}
148146
}

packages/nuxt/src/runtime/app/plugin.server.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { deleteApp, type FirebaseApp, initializeApp } from 'firebase/app'
2-
import { getAuth, signInWithCustomToken, type User } from 'firebase/auth'
3-
import { type App as AdminApp } from 'firebase-admin/app'
4-
import { DecodedIdToken, getAuth as getAdminAuth } from 'firebase-admin/auth'
2+
import { type User } from 'firebase/auth'
3+
import { DecodedIdToken } from 'firebase-admin/auth'
54
import { LRUCache } from 'lru-cache'
65
import { log } from '../logging'
7-
import { DECODED_ID_TOKEN_SYMBOL, UserSymbol } from '../constants'
8-
import { defineNuxtPlugin, useAppConfig, useRequestEvent } from '#app'
6+
import { DECODED_ID_TOKEN_SYMBOL } from '../constants'
7+
import { defineNuxtPlugin, useAppConfig } from '#app'
98

109
// TODO: allow customizing
1110
// TODO: find sensible defaults. Should they change depending on the platform?
@@ -25,7 +24,7 @@ const appCache = new LRUCache<string, FirebaseApp>({
2524
/**
2625
* Initializes the app and provides it to others.
2726
*/
28-
export default defineNuxtPlugin(async (nuxtApp) => {
27+
export default defineNuxtPlugin((nuxtApp) => {
2928
const appConfig = useAppConfig()
3029

3130
const decodedToken = nuxtApp[
@@ -35,11 +34,6 @@ export default defineNuxtPlugin(async (nuxtApp) => {
3534

3635
const uid = decodedToken?.uid
3736

38-
// // expose the user to code
39-
// event.context.user = user
40-
// // for SSR
41-
// nuxtApp.payload.vuefireUser = user?.toJSON()
42-
4337
let firebaseApp: FirebaseApp | undefined
4438

4539
// log('debug', 'initializing app with', appConfig.firebaseConfig)
@@ -56,9 +50,10 @@ export default defineNuxtPlugin(async (nuxtApp) => {
5650
firebaseApp = appCache.get(uid)!
5751
// console.time('token')
5852
} else {
59-
log('debug', '👤 reusing authenticated app', uid)
53+
log('debug', '👤 reusing authenticated app', firebaseApp.name)
6054
}
6155
} else {
56+
// TODO: is this safe? should we create a new one everytime
6257
if (!appCache.has('')) {
6358
appCache.set('', initializeApp(appConfig.firebaseConfig))
6459
}

packages/nuxt/src/runtime/auth/api.session-verification.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
} from 'h3'
1010
import { log } from '../logging'
1111

12-
// This version is used at https://github.com/FirebaseExtended/firebase-framework-tools/blob/e69f5bdd44695274ad88dbb4e21aac778ba60cc8/src/firebase-aware.ts#L39 but doesn't work locally. Should it maybe be used in production only? Seems unlikely.
13-
1412
/**
1513
* Setups an API endpoint to be used by the client to mint a cookie based auth session.
1614
*/
@@ -36,7 +34,7 @@ export default defineEventHandler(async (event) => {
3634
log('error', 'Error minting the cookie -', e.message)
3735
})
3836
if (cookie) {
39-
log('debug', `minted a session cookie for user ${verifiedIdToken.uid}`)
37+
// log('debug', `minted a session cookie for user ${verifiedIdToken.uid}`)
4038
setCookie(event, AUTH_COOKIE_NAME, cookie, {
4139
maxAge: AUTH_COOKIE_MAX_AGE,
4240
secure: true,
@@ -53,7 +51,7 @@ export default defineEventHandler(async (event) => {
5351
}
5452
}
5553
} else {
56-
log('debug', 'deleting the session cookie')
54+
// log('debug', 'deleting the session cookie')
5755
deleteCookie(event, AUTH_COOKIE_NAME)
5856
event.node.res.statusCode = 204
5957
}

packages/nuxt/src/runtime/auth/api.session.ts

-41
This file was deleted.

packages/nuxt/src/runtime/auth/plugin-user-token.server.ts

-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ import { getCookie } from 'h3'
44
import { DECODED_ID_TOKEN_SYMBOL } from '../constants'
55
import { defineNuxtPlugin, useRequestEvent } from '#app'
66

7-
// TODO: move this to auth and adapt the module to load it in the right order
8-
97
/**
108
* Decodes the user token if any. Should only be added on the server and before the firebase/app
119
*/
1210
export default defineNuxtPlugin(async (nuxtApp) => {
1311
const event = useRequestEvent()
1412
const adminApp = nuxtApp.$firebaseAdminApp as AdminApp
1513

16-
// log('debug', '🔥 Plugin auth user server')
17-
1814
const decodedToken = await decodeUserToken(
1915
getCookie(event, AUTH_COOKIE_NAME),
2016
adminApp

packages/nuxt/src/runtime/auth/plugin.server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getAuth, signInWithCustomToken, type User } from 'firebase/auth'
1+
import { getAuth, signInWithCustomToken } from 'firebase/auth'
22
import { DecodedIdToken, getAuth as getAdminAuth } from 'firebase-admin/auth'
33
import type { FirebaseApp } from 'firebase/app'
44
import type { App as AdminApp } from 'firebase-admin/app'

src/auth/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FirebaseApp } from 'firebase/app'
2-
import { getAuth, type User } from 'firebase/auth'
2+
import { getAuth, initializeAuth, type User } from 'firebase/auth'
33
import { App, ref } from 'vue-demi'
44
import { useFirebaseApp } from '../app'
55
import { getGlobalScope } from '../globals'

0 commit comments

Comments
 (0)