@dev.smartpricing/platform-layer 0.0.6 → 0.0.7
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/app/utils/auth.utils.ts +26 -0
- package/nuxt.config.ts +4 -1
- package/package.json +2 -2
package/app/utils/auth.utils.ts
CHANGED
|
@@ -16,3 +16,29 @@ export function isPublicAuthRoute(pathname: string): boolean {
|
|
|
16
16
|
if (!pathname.startsWith('/auth/')) return false
|
|
17
17
|
return !AUTHENTICATED_AUTH_PATHS.some(p => pathname.startsWith(p))
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Reads a cookie value by name from `document.cookie`. Returns `undefined` when
|
|
22
|
+
* the cookie is absent or `document` is unavailable (SSR/build). Mirrors the
|
|
23
|
+
* reader in `apps/frontend/app/composables/useRest.ts`.
|
|
24
|
+
*/
|
|
25
|
+
export function readCookie(name: string): string | undefined {
|
|
26
|
+
if (typeof document === 'undefined') return undefined
|
|
27
|
+
const prefix = `${name}=`
|
|
28
|
+
for (const part of document.cookie.split('; ')) {
|
|
29
|
+
if (part.startsWith(prefix)) return decodeURIComponent(part.slice(prefix.length))
|
|
30
|
+
}
|
|
31
|
+
return undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the environment-scoped CSRF cookie name: prod keeps the bare base
|
|
36
|
+
* name, every other environment gets a `_<env>` suffix so sessions from
|
|
37
|
+
* different environments don't collide on the shared `.smartness.com` domain.
|
|
38
|
+
*
|
|
39
|
+
* Must stay in sync with the backend's `envScopedCookieName`
|
|
40
|
+
* (`apps/backend/src/utils/env.ts`).
|
|
41
|
+
*/
|
|
42
|
+
export function envScopedCsrfCookieName(baseName: string, environment: string): string {
|
|
43
|
+
return environment === 'prod' ? baseName : `${baseName}_${environment}`
|
|
44
|
+
}
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev.smartpricing/platform-layer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"nuxt": "^4.4.2",
|
|
22
|
-
"nuxt-ui-layer": "github:smartpricing/smartness-nuxt-ui#v1.7.
|
|
22
|
+
"nuxt-ui-layer": "github:smartpricing/smartness-nuxt-ui#v1.7.2",
|
|
23
23
|
"vue": "latest"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|