@finema/finework-layer 0.2.124 → 0.2.125

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.125](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.124...0.2.125) (2026-02-04)
4
+
5
+ ### Features
6
+
7
+ * add convertDomainToCookieDomain function for cookie domain handling ([7f321f4](https://gitlab.finema.co/finema/finework/finework-frontend-layer/commit/7f321f451b45a2d51453918858b13e5b7a77ceae))
8
+
3
9
  ## [0.2.124](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.123...0.2.124) (2026-02-03)
4
10
 
5
11
  ## [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.baseAPI as string),
134
158
  })
135
159
 
136
160
  const isAuthenticated = computed(() => !!token.value)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@finema/finework-layer",
3
3
  "type": "module",
4
- "version": "0.2.124",
4
+ "version": "0.2.125",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground -o",