@finema/finework-layer 0.2.124 → 0.2.126
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/CHANGELOG.md +12 -0
- package/app/composables/useAuth.ts +24 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.126](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.125...0.2.126) (2026-02-04)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* update cookie domain handling to use baseURL instead of baseAPI ([f66632c](https://gitlab.finema.co/finema/finework/finework-frontend-layer/commit/f66632c49968471067ca98b02ffa41b9b0f3fbd0))
|
|
8
|
+
|
|
9
|
+
## [0.2.125](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.124...0.2.125) (2026-02-04)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add convertDomainToCookieDomain function for cookie domain handling ([7f321f4](https://gitlab.finema.co/finema/finework/finework-frontend-layer/commit/7f321f451b45a2d51453918858b13e5b7a77ceae))
|
|
14
|
+
|
|
3
15
|
## [0.2.124](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.123...0.2.124) (2026-02-03)
|
|
4
16
|
|
|
5
17
|
## [0.2.123](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.122...0.2.123) (2026-02-02)
|
|
@@ -123,6 +123,29 @@ export interface IUserAccessLevel {
|
|
|
123
123
|
purchase: Permission
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
export const convertDomainToCookieDomain = (domain: string) => {
|
|
127
|
+
let hostname = ''
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
const url = domain.startsWith('http://') || domain.startsWith('https://')
|
|
131
|
+
? new URL(domain)
|
|
132
|
+
: new URL(`https://${domain}`)
|
|
133
|
+
|
|
134
|
+
hostname = url.hostname
|
|
135
|
+
} catch {
|
|
136
|
+
return ''
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (hostname === 'localhost' || /^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname)) {
|
|
140
|
+
return hostname
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const parts = hostname.split('.')
|
|
144
|
+
const baseDomain = parts.length > 2 ? parts.slice(-2).join('.') : hostname
|
|
145
|
+
|
|
146
|
+
return baseDomain.startsWith('.') ? baseDomain : `.${baseDomain}`
|
|
147
|
+
}
|
|
148
|
+
|
|
126
149
|
export const useAuth = () => {
|
|
127
150
|
const {
|
|
128
151
|
auth,
|
|
@@ -131,6 +154,7 @@ export const useAuth = () => {
|
|
|
131
154
|
const token = useCookie('token', {
|
|
132
155
|
path: '/',
|
|
133
156
|
maxAge: 60 * 60 * 24 * 365,
|
|
157
|
+
domain: convertDomainToCookieDomain(useRuntimeConfig().public.baseURL as string),
|
|
134
158
|
})
|
|
135
159
|
|
|
136
160
|
const isAuthenticated = computed(() => !!token.value)
|