File tree Expand file tree Collapse file tree 4 files changed +17
-11
lines changed
packages/nuxt/src/runtime Expand file tree Collapse file tree 4 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { getCookie } from 'h3'
5
5
// FirebaseError is an interface here but is a class in firebase/app
6
6
import type { FirebaseError } from 'firebase-admin'
7
7
import { log } from '../logging'
8
- import { AUTH_COOKIE_NAME , UserSymbol } from '../constants'
8
+ import { UserSymbol } from '../constants'
9
9
import { defineNuxtPlugin , useRequestEvent } from '#app'
10
10
11
11
/**
@@ -51,3 +51,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
51
51
function isFirebaseError ( err : any ) : err is FirebaseError {
52
52
return err != null && 'code' in err
53
53
}
54
+
55
+ // MUST be named session to be kept
56
+ // https://firebase.google.com/docs/hosting/manage-cache#using_cookies
57
+ const AUTH_COOKIE_NAME = '__session'
Original file line number Diff line number Diff line change 8
8
deleteCookie ,
9
9
} from 'h3'
10
10
import { log } from '../logging'
11
- import { AUTH_COOKIE_MAX_AGE , AUTH_COOKIE_NAME } from '../constants'
12
11
13
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.
14
13
@@ -66,4 +65,9 @@ export default defineEventHandler(async (event) => {
66
65
return ''
67
66
} )
68
67
69
- export const ID_TOKEN_MAX_AGE = 5 * 60
68
+ // these must be within this file because the handler gets inlined in dev mode
69
+ const ID_TOKEN_MAX_AGE = 5 * 60
70
+ const AUTH_COOKIE_MAX_AGE = 60 * 60 * 24 * 5 * 1_000
71
+ // MUST be named session to be kept
72
+ // https://firebase.google.com/docs/hosting/manage-cache#using_cookies
73
+ const AUTH_COOKIE_NAME = '__session'
Original file line number Diff line number Diff line change 5
5
defineEventHandler ,
6
6
deleteCookie ,
7
7
} from 'h3'
8
- import { AUTH_COOKIE_NAME , AUTH_COOKIE_MAX_AGE } from '../constants'
9
8
10
9
/**
11
10
* Setups an API endpoint to be used by the client to mint a cookie based auth session.
@@ -34,3 +33,9 @@ export default defineEventHandler(async (event) => {
34
33
event . node . res . statusCode = 204
35
34
return ''
36
35
} )
36
+
37
+ // these must be within this file because the handler gets inlined in dev mode
38
+ const AUTH_COOKIE_MAX_AGE = 60 * 60 * 24 * 5 * 1_000
39
+ // MUST be named session to be kept
40
+ // https://firebase.google.com/docs/hosting/manage-cache#using_cookies
41
+ const AUTH_COOKIE_NAME = '__session'
Original file line number Diff line number Diff line change 2
2
* @internal Gets access to the user within the application. This is a symbol to keep it private for the moment.
3
3
*/
4
4
export const UserSymbol = Symbol ( 'user' )
5
-
6
- // TODO: customizable defaults
7
- export const AUTH_COOKIE_MAX_AGE = 60 * 60 * 24 * 5 * 1_000
8
-
9
- // MUST be named session to be kept
10
- // https://firebase.google.com/docs/hosting/manage-cache#using_cookies
11
- export const AUTH_COOKIE_NAME = '__session'
You can’t perform that action at this time.
0 commit comments