@strands.gg/accui 1.8.0 → 1.9.0
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/dist/nuxt/runtime/composables/useStrandsAuth.cjs.js +1 -1
- package/dist/nuxt/runtime/composables/useStrandsAuth.es.js +1 -1
- package/dist/nuxt-v4/runtime/composables/useStrandsAuth.cjs.js +1 -1
- package/dist/nuxt-v4/runtime/composables/useStrandsAuth.es.js +1 -1
- package/dist/strands-auth-ui.cjs.js +1 -1
- package/dist/strands-auth-ui.es.js +1 -1
- package/dist/{useStrandsAuth-Beee__9G.js → useStrandsAuth-BA8qEUcp.js} +39 -58
- package/dist/useStrandsAuth-BA8qEUcp.js.map +1 -0
- package/dist/{useStrandsAuth-JfbGH2c-.cjs → useStrandsAuth-Co2lLH4X.cjs} +39 -58
- package/dist/useStrandsAuth-Co2lLH4X.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/useStrandsAuth-Beee__9G.js.map +0 -1
- package/dist/useStrandsAuth-JfbGH2c-.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const app = require("nuxt/app");
|
|
4
|
-
const useStrandsAuth$1 = require("../../../useStrandsAuth-
|
|
4
|
+
const useStrandsAuth$1 = require("../../../useStrandsAuth-Co2lLH4X.cjs");
|
|
5
5
|
const useStrandsAuth = () => {
|
|
6
6
|
const config = app.useRuntimeConfig().public["strandsAuth"];
|
|
7
7
|
const vueAuth = useStrandsAuth$1.useStrandsAuth();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRuntimeConfig, navigateTo } from "nuxt/app";
|
|
2
|
-
import { u as useStrandsAuth$1 } from "../../../useStrandsAuth-
|
|
2
|
+
import { u as useStrandsAuth$1 } from "../../../useStrandsAuth-BA8qEUcp.js";
|
|
3
3
|
const useStrandsAuth = () => {
|
|
4
4
|
const config = useRuntimeConfig().public["strandsAuth"];
|
|
5
5
|
const vueAuth = useStrandsAuth$1();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const app = require("nuxt/app");
|
|
4
|
-
const useStrandsAuth$1 = require("../../../useStrandsAuth-
|
|
4
|
+
const useStrandsAuth$1 = require("../../../useStrandsAuth-Co2lLH4X.cjs");
|
|
5
5
|
const useStrandsAuth = () => {
|
|
6
6
|
const config = app.useRuntimeConfig().public["strandsAuth"];
|
|
7
7
|
const vueAuth = useStrandsAuth$1.useStrandsAuth();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRuntimeConfig, navigateTo } from "nuxt/app";
|
|
2
|
-
import { u as useStrandsAuth$1 } from "../../../useStrandsAuth-
|
|
2
|
+
import { u as useStrandsAuth$1 } from "../../../useStrandsAuth-BA8qEUcp.js";
|
|
3
3
|
const useStrandsAuth = () => {
|
|
4
4
|
const config = useRuntimeConfig().public["strandsAuth"];
|
|
5
5
|
const vueAuth = useStrandsAuth$1();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const vue = require("vue");
|
|
4
4
|
const useStrandsConfig = require("./useStrandsConfig-Dms13Zd0.cjs");
|
|
5
|
-
const useStrandsAuth = require("./useStrandsAuth-
|
|
5
|
+
const useStrandsAuth = require("./useStrandsAuth-Co2lLH4X.cjs");
|
|
6
6
|
const _hoisted_1$v = { class: "accui-component-scope" };
|
|
7
7
|
const _hoisted_2$s = { class: "alert-content" };
|
|
8
8
|
const _hoisted_3$s = { class: "alert-icon-container" };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, computed, createElementBlock, openBlock, createElementVNode, normalizeClass, createCommentVNode, toDisplayString, renderSlot, createTextVNode, normalizeStyle, useSlots, ref, createBlock, resolveDynamicComponent, mergeProps, withCtx, onMounted, nextTick, toRefs, watch, Fragment, renderList, unref, reactive, withModifiers, createStaticVNode, withDirectives, vModelText, Teleport, onBeforeUnmount, createVNode, withKeys, Transition, resolveComponent, h, onUnmounted } from "vue";
|
|
2
2
|
import { u as useStrandsConfig, p as provideStrandsConfig } from "./useStrandsConfig-Cxb360Os.js";
|
|
3
3
|
import { s } from "./useStrandsConfig-Cxb360Os.js";
|
|
4
|
-
import { u as useStrandsAuth } from "./useStrandsAuth-
|
|
4
|
+
import { u as useStrandsAuth } from "./useStrandsAuth-BA8qEUcp.js";
|
|
5
5
|
const _hoisted_1$v = { class: "accui-component-scope" };
|
|
6
6
|
const _hoisted_2$s = { class: "alert-content" };
|
|
7
7
|
const _hoisted_3$s = { class: "alert-icon-container" };
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { ref, computed } from "vue";
|
|
2
2
|
import { u as useStrandsConfig } from "./useStrandsConfig-Cxb360Os.js";
|
|
3
|
+
const mapApiUserToFrontend = (apiUser) => {
|
|
4
|
+
return {
|
|
5
|
+
id: apiUser.id,
|
|
6
|
+
email: apiUser.email,
|
|
7
|
+
firstName: apiUser.first_name || apiUser.firstName || "",
|
|
8
|
+
lastName: apiUser.last_name || apiUser.lastName || "",
|
|
9
|
+
avatar: apiUser.avatar_url || apiUser.avatar,
|
|
10
|
+
mfaEnabled: apiUser.mfa_enabled ?? apiUser.mfaEnabled ?? false,
|
|
11
|
+
emailVerified: apiUser.email_verified ?? apiUser.emailVerified ?? false,
|
|
12
|
+
passwordUpdatedAt: apiUser.password_updated_at || apiUser.passwordUpdatedAt,
|
|
13
|
+
settings: apiUser.settings || {},
|
|
14
|
+
xp: apiUser.xp || 0,
|
|
15
|
+
level: apiUser.level || 1,
|
|
16
|
+
next_level_xp: apiUser.next_level_xp || apiUser.next_level_xp || 4,
|
|
17
|
+
username: apiUser.username,
|
|
18
|
+
usernameLastChangedAt: apiUser.username_last_changed_at || apiUser.usernameLastChangedAt,
|
|
19
|
+
createdAt: apiUser.created_at || apiUser.createdAt,
|
|
20
|
+
updatedAt: apiUser.updated_at || apiUser.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
21
|
+
};
|
|
22
|
+
};
|
|
3
23
|
const { getUrl } = useStrandsConfig();
|
|
4
24
|
const currentUser = ref(null);
|
|
5
25
|
const currentSession = ref(null);
|
|
@@ -149,7 +169,7 @@ function useStrandsAuth() {
|
|
|
149
169
|
isSigningIn.value = false;
|
|
150
170
|
return authData;
|
|
151
171
|
}
|
|
152
|
-
setAuthData(authData);
|
|
172
|
+
await setAuthData(authData);
|
|
153
173
|
return authData;
|
|
154
174
|
} catch (error) {
|
|
155
175
|
throw error;
|
|
@@ -205,12 +225,18 @@ function useStrandsAuth() {
|
|
|
205
225
|
throw new Error(`Token refresh failed: ${response.status} ${response.statusText}`);
|
|
206
226
|
}
|
|
207
227
|
const tokenData = await response.json();
|
|
228
|
+
if (tokenData.user) {
|
|
229
|
+
currentUser.value = mapApiUserToFrontend(tokenData.user);
|
|
230
|
+
if (typeof window !== "undefined") {
|
|
231
|
+
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
208
234
|
const newSession = {
|
|
209
235
|
accessToken: tokenData.access_token,
|
|
210
236
|
refreshToken: tokenData.refresh_token,
|
|
211
237
|
expiresAt: new Date(Date.now() + 5 * 60 * 1e3),
|
|
212
238
|
// 5 minutes from now
|
|
213
|
-
userId: currentUser.value?.id
|
|
239
|
+
userId: tokenData.user?.id || currentUser.value?.id
|
|
214
240
|
};
|
|
215
241
|
currentSession.value = newSession;
|
|
216
242
|
if (typeof window !== "undefined") {
|
|
@@ -244,24 +270,7 @@ function useStrandsAuth() {
|
|
|
244
270
|
}
|
|
245
271
|
}
|
|
246
272
|
const userData = await response.json();
|
|
247
|
-
currentUser.value =
|
|
248
|
-
id: userData.id,
|
|
249
|
-
email: userData.email,
|
|
250
|
-
firstName: userData.first_name,
|
|
251
|
-
lastName: userData.last_name,
|
|
252
|
-
avatar: userData.avatar_url,
|
|
253
|
-
mfaEnabled: userData.mfaEnabled || false,
|
|
254
|
-
emailVerified: userData.email_verified,
|
|
255
|
-
passwordUpdatedAt: userData.password_updated_at,
|
|
256
|
-
settings: userData.settings || {},
|
|
257
|
-
xp: userData.xp || 0,
|
|
258
|
-
level: userData.level || 1,
|
|
259
|
-
next_level_xp: userData.next_level_xp || 4,
|
|
260
|
-
username: userData.username,
|
|
261
|
-
usernameLastChangedAt: userData.username_last_changed_at,
|
|
262
|
-
createdAt: userData.created_at,
|
|
263
|
-
updatedAt: userData.updated_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
264
|
-
};
|
|
273
|
+
currentUser.value = mapApiUserToFrontend(userData);
|
|
265
274
|
if (typeof window !== "undefined") {
|
|
266
275
|
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
267
276
|
}
|
|
@@ -295,31 +304,9 @@ function useStrandsAuth() {
|
|
|
295
304
|
}
|
|
296
305
|
}
|
|
297
306
|
const updatedUserData = await response.json();
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
// Update with API response data, preserving the API field names
|
|
302
|
-
id: updatedUserData.id,
|
|
303
|
-
email: updatedUserData.email,
|
|
304
|
-
firstName: updatedUserData.first_name,
|
|
305
|
-
lastName: updatedUserData.last_name,
|
|
306
|
-
emailVerified: updatedUserData.email_verified,
|
|
307
|
-
avatar: updatedUserData.avatar_url,
|
|
308
|
-
mfaEnabled: updatedUserData.mfa_enabled,
|
|
309
|
-
xp: updatedUserData.xp,
|
|
310
|
-
level: updatedUserData.level,
|
|
311
|
-
next_level_xp: updatedUserData.next_level_xp,
|
|
312
|
-
username: updatedUserData.username,
|
|
313
|
-
// This was missing and causing the bug!
|
|
314
|
-
usernameLastChangedAt: updatedUserData.username_last_changed_at,
|
|
315
|
-
createdAt: updatedUserData.created_at,
|
|
316
|
-
updatedAt: updatedUserData.updated_at,
|
|
317
|
-
settings: updatedUserData.settings,
|
|
318
|
-
passwordUpdatedAt: updatedUserData.password_updated_at
|
|
319
|
-
};
|
|
320
|
-
if (typeof window !== "undefined") {
|
|
321
|
-
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
322
|
-
}
|
|
307
|
+
currentUser.value = mapApiUserToFrontend(updatedUserData);
|
|
308
|
+
if (typeof window !== "undefined") {
|
|
309
|
+
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
323
310
|
}
|
|
324
311
|
return currentUser.value;
|
|
325
312
|
} finally {
|
|
@@ -350,15 +337,9 @@ function useStrandsAuth() {
|
|
|
350
337
|
}
|
|
351
338
|
}
|
|
352
339
|
const updatedUserData = await response.json();
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
settings: updatedUserData.settings,
|
|
357
|
-
updatedAt: updatedUserData.updated_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
358
|
-
};
|
|
359
|
-
if (typeof window !== "undefined") {
|
|
360
|
-
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
361
|
-
}
|
|
340
|
+
currentUser.value = mapApiUserToFrontend(updatedUserData);
|
|
341
|
+
if (typeof window !== "undefined") {
|
|
342
|
+
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
362
343
|
}
|
|
363
344
|
return currentUser.value;
|
|
364
345
|
} finally {
|
|
@@ -436,7 +417,7 @@ function useStrandsAuth() {
|
|
|
436
417
|
mfaRequired.value = false;
|
|
437
418
|
mfaSessionId.value = null;
|
|
438
419
|
availableMfaMethods.value = [];
|
|
439
|
-
setAuthData(authData);
|
|
420
|
+
await setAuthData(authData);
|
|
440
421
|
return authData;
|
|
441
422
|
} finally {
|
|
442
423
|
isVerifyingMfa.value = false;
|
|
@@ -498,10 +479,10 @@ function useStrandsAuth() {
|
|
|
498
479
|
}
|
|
499
480
|
return response.json();
|
|
500
481
|
};
|
|
501
|
-
const setAuthData = (authResponse) => {
|
|
482
|
+
const setAuthData = async (authResponse) => {
|
|
502
483
|
try {
|
|
503
484
|
if (authResponse.user) {
|
|
504
|
-
currentUser.value = authResponse.user;
|
|
485
|
+
currentUser.value = mapApiUserToFrontend(authResponse.user);
|
|
505
486
|
}
|
|
506
487
|
const session = {
|
|
507
488
|
accessToken: authResponse.access_token,
|
|
@@ -753,4 +734,4 @@ function useStrandsAuth() {
|
|
|
753
734
|
export {
|
|
754
735
|
useStrandsAuth as u
|
|
755
736
|
};
|
|
756
|
-
//# sourceMappingURL=useStrandsAuth-
|
|
737
|
+
//# sourceMappingURL=useStrandsAuth-BA8qEUcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStrandsAuth-BA8qEUcp.js","sources":["../../../apps/accounts-ui/src/vue/composables/useStrandsAuth.ts"],"sourcesContent":["import { ref, computed } from 'vue'\nimport type { User, Session, SessionInfo, SessionStats, SignInCredentials, SignUpData, AuthResponse, MfaDevice, MfaErrorResponse } from '../../types'\nimport { useStrandsConfig } from './useStrandsConfig'\n\n// Utility function to map API user data to frontend format\nconst mapApiUserToFrontend = (apiUser: any): User => {\n return {\n id: apiUser.id,\n email: apiUser.email,\n firstName: apiUser.first_name || apiUser.firstName || '',\n lastName: apiUser.last_name || apiUser.lastName || '',\n avatar: apiUser.avatar_url || apiUser.avatar,\n mfaEnabled: apiUser.mfa_enabled ?? apiUser.mfaEnabled ?? false,\n emailVerified: apiUser.email_verified ?? apiUser.emailVerified ?? false,\n passwordUpdatedAt: apiUser.password_updated_at || apiUser.passwordUpdatedAt,\n settings: apiUser.settings || {},\n xp: apiUser.xp || 0,\n level: apiUser.level || 1,\n next_level_xp: apiUser.next_level_xp || apiUser.next_level_xp || 4,\n username: apiUser.username,\n usernameLastChangedAt: apiUser.username_last_changed_at || apiUser.usernameLastChangedAt,\n createdAt: apiUser.created_at || apiUser.createdAt,\n updatedAt: apiUser.updated_at || apiUser.updatedAt || new Date().toISOString(),\n }\n}\n\nconst { getUrl } = useStrandsConfig()\n\nconst currentUser = ref<User | null>(null)\nconst currentSession = ref<Session | null>(null)\n\n// Specific loading states\nconst isInitializing = ref(true)\nconst isSigningIn = ref(false)\nconst isSigningUp = ref(false)\nconst isSigningOut = ref(false)\nconst isRefreshingToken = ref(false)\nconst isSendingMfaEmail = ref(false)\nconst isVerifyingMfa = ref(false)\nconst isLoadingProfile = ref(false)\n\n// Legacy loading states for backward compatibility\nconst loading = computed(() => isSigningIn.value || isSigningUp.value || isSigningOut.value || isRefreshingToken.value || isSendingMfaEmail.value || isVerifyingMfa.value || isLoadingProfile.value)\nconst isLoading = computed(() => isInitializing.value || loading.value)\n\n// Loading messages for better UX\nconst loadingMessage = computed(() => {\n if (isInitializing.value) return 'Checking authentication...'\n if (isSigningIn.value) return 'Signing you in...'\n if (isSigningUp.value) return 'Creating your account...'\n if (isSigningOut.value) return 'Signing you out...'\n if (isRefreshingToken.value) return 'Refreshing session...'\n if (isSendingMfaEmail.value) return 'Sending verification code...'\n if (isVerifyingMfa.value) return 'Verifying code...'\n return 'Loading...' // Fallback\n})\n\nconst isInitialized = ref(false)\n\n// MFA state\nconst mfaRequired = ref(false)\nconst mfaSessionId = ref<string | null>(null)\nconst availableMfaMethods = ref<MfaDevice[]>([])\n\n// Token refresh timer\nlet refreshTimer: NodeJS.Timeout | null = null\n\nexport function useStrandsAuth() {\n // Helper function to get authenticated headers with refresh token\n const getAuthHeaders = () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n }\n \n // Include refresh token for session management\n if (currentSession.value?.refreshToken) {\n headers['x-refresh-token'] = currentSession.value.refreshToken\n }\n \n return headers\n }\n /**\n * Complete hardware key (WebAuthn) registration for MFA\n * Returns result with backup codes on success\n */\n const completeHardwareKeyRegistration = async (deviceId: string, credential: any, accessToken: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n\n const response = await fetch(getUrl('mfaHardwareCompleteRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`\n },\n body: JSON.stringify({\n device_id: deviceId,\n credential: credential\n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to complete hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to complete hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n /**\n * Register a hardware key (WebAuthn) for MFA\n * Returns { device_id, challenge } on success\n */\n const registerHardwareKey = async (deviceName: string, accessToken: string, deviceType: 'hardware' | 'passkey' = 'hardware') => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('mfaHardwareStartRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({ \n device_name: deviceName,\n device_type: deviceType \n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to start hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to start hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n\n const isAuthenticated = computed(() => currentUser.value !== null)\n\n const signIn = async (credentials: SignInCredentials) => {\n isSigningIn.value = true\n try {\n // Reset MFA state at start of new sign-in attempt\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Make API call to sign-in endpoint\n const response = await fetch(getUrl('signIn'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(credentials),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Invalid email or password')\n } else if (response.status === 403) {\n throw new Error('Please verify your email address before signing in')\n } else {\n throw new Error(`Sign in failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const authData: AuthResponse = await response.json()\n \n // Check if MFA is required\n if (authData.mfa_required) {\n mfaRequired.value = true\n mfaSessionId.value = authData.mfa_session_id || null\n \n // Convert API MFA methods to the expected format\n const methods = (authData.available_mfa_methods || []).map((method: any) => {\n // Create better fallback names for different device types\n let fallbackName = `${method.device_type.charAt(0).toUpperCase() + method.device_type.slice(1)} Authentication`\n \n if (method.device_type === 'hardware') {\n // Better names for hardware keys\n fallbackName = method.device_name || 'Security Key' // Could be YubiKey, FIDO2 Key, etc.\n } else if (method.device_type === 'totp') {\n fallbackName = method.device_name || 'Authenticator App'\n } else if (method.device_type === 'email') {\n fallbackName = method.device_name || 'Email Verification'\n }\n \n return {\n id: method.device_id,\n device_type: method.device_type,\n device_name: method.device_name || fallbackName,\n is_active: true,\n created_at: new Date().toISOString(),\n last_used_at: method.last_used_at,\n // Pass through additional metadata if available\n credential_id: method.credential_id,\n device_info: method.device_info\n }\n })\n availableMfaMethods.value = methods\n \n // Set signIn loading to false immediately so MFA modal can show\n isSigningIn.value = false\n \n return authData // Return without storing full auth data\n }\n \n // Store the authentication data if MFA not required\n await setAuthData(authData)\n \n return authData\n } catch (error) {\n throw error\n } finally {\n isSigningIn.value = false\n }\n }\n\n const signUp = async (userData: SignUpData) => {\n isSigningUp.value = true\n try {\n // Integration point: Replace with actual auth SDK call\n // Example: const result = await authSDK.signUp(userData)\n \n throw new Error('Sign up not implemented - please integrate with auth SDK')\n } finally {\n isSigningUp.value = false\n }\n }\n\n const signOut = async () => {\n isSigningOut.value = true\n try {\n // Stop token refresh timer\n stopTokenRefreshTimer()\n \n // Clear user and session state\n currentUser.value = null\n currentSession.value = null\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Clear stored tokens\n if (typeof window !== 'undefined') {\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } finally {\n isSigningOut.value = false\n }\n }\n\n const refreshToken = async () => {\n if (!currentSession.value?.refreshToken) {\n return false\n }\n \n \n isRefreshingToken.value = true\n try {\n const response = await fetch(getUrl('refresh'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n refresh_token: currentSession.value.refreshToken,\n }),\n })\n\n if (!response.ok) { \n if (response.status === 401) {\n // Refresh token is invalid/expired, sign out user\n await signOut()\n return false\n }\n throw new Error(`Token refresh failed: ${response.status} ${response.statusText}`)\n }\n\n const tokenData = await response.json()\n \n // Token refresh now returns full AuthResponse with user data\n if (tokenData.user) {\n // Update user data with fresh information from the server\n currentUser.value = mapApiUserToFrontend(tokenData.user)\n \n // Update localStorage with fresh user data\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n // Update session with fresh tokens\n const newSession: Session = {\n accessToken: tokenData.access_token,\n refreshToken: tokenData.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now\n userId: tokenData.user?.id || currentUser.value?.id,\n }\n \n currentSession.value = newSession\n \n // Update localStorage with new session\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(newSession))\n }\n \n // Restart token refresh timer\n startTokenRefreshTimer()\n \n return true\n } catch (error) {\n // On refresh failure, sign out the user\n await signOut()\n return false\n }\n }\n\n const fetchProfile = async (): Promise<User | null> => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Failed to fetch profile: ${response.status} ${response.statusText}`)\n }\n }\n\n const userData = await response.json()\n \n // Update the current user state using the mapping utility\n currentUser.value = mapApiUserToFrontend(userData)\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateProfile = async (profileData: Partial<User>) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n first_name: profileData.firstName,\n last_name: profileData.lastName,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Profile update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state using the mapping utility\n currentUser.value = mapApiUserToFrontend(updatedUserData)\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateUserSettings = async (settings: any) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('settings'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n settings: settings,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Settings update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state using the mapping utility\n currentUser.value = mapApiUserToFrontend(updatedUserData)\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const changeEmail = async (newEmail: string, password: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeEmail'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n new_email: newEmail,\n password: password,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `Email change failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const result = await response.json()\n \n // For email change, we need to manually update some fields since API might not return full user\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n email: newEmail,\n emailVerified: false, // Email needs to be verified again\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const verifyMfa = async (deviceId: string, code: string, isBackupCode = false) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isVerifyingMfa.value = true\n try {\n const endpoint = isBackupCode ? getUrl('mfaBackupCodeVerify') : getUrl('mfaSigninVerify')\n const body = isBackupCode \n ? { mfa_session_id: mfaSessionId.value, backup_code: code }\n : { mfa_session_id: mfaSessionId.value, device_id: deviceId, code }\n\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'MFA verification failed'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'MFA verification failed'\n }\n \n throw new Error(errorMessage)\n }\n\n const authData: AuthResponse = await response.json()\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Store the authentication data\n await setAuthData(authData)\n \n return authData\n } finally {\n isVerifyingMfa.value = false\n }\n }\n\n const sendMfaEmailCode = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isSendingMfaEmail.value = true\n try {\n const response = await fetch(getUrl('mfaSigninSendEmail'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId,\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to send MFA email code'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'Failed to send MFA email code'\n }\n \n throw new Error(errorMessage)\n }\n\n const result = await response.json()\n return result\n } finally {\n isSendingMfaEmail.value = false\n }\n }\n\n const getMfaWebAuthnChallenge = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n \n const response = await fetch(getUrl('mfaWebAuthnChallenge'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to get WebAuthn challenge'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || errorMessage\n }\n \n throw new Error(errorMessage)\n }\n\n return response.json()\n }\n\n const setAuthData = async (authResponse: AuthResponse) => {\n try {\n // Handle user data (only for sign-in/sign-up, not token refresh)\n if (authResponse.user) {\n currentUser.value = mapApiUserToFrontend(authResponse.user)\n }\n \n // Create session object\n const session: Session = {\n accessToken: authResponse.access_token,\n refreshToken: authResponse.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now (matching API token expiry)\n userId: currentUser.value?.id || authResponse.user?.id,\n }\n \n currentSession.value = session\n \n // Store in localStorage for persistence\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(session))\n if (currentUser.value) {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n // Start automatic token refresh\n startTokenRefreshTimer()\n } catch (error) {\n console.error('Error setting auth data:', error)\n // Silently handle auth data storage errors\n }\n }\n\n // Token refresh timer management\n const startTokenRefreshTimer = () => {\n // Clear existing timer\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n }\n \n if (!currentSession.value) return\n \n // Calculate time until token expires (refresh 1 minute before expiry)\n const now = new Date()\n const expiresAt = currentSession.value.expiresAt\n const timeUntilRefresh = expiresAt.getTime() - now.getTime() - (1 * 60 * 1000) // 1 minute before expiry\n \n // If token is already expired or expires very soon, refresh immediately\n if (timeUntilRefresh <= 0) {\n refreshToken()\n return\n }\n \n // Set timer to refresh token\n refreshTimer = setTimeout(async () => {\n const success = await refreshToken()\n \n if (success) {\n // Schedule next refresh\n startTokenRefreshTimer()\n }\n }, timeUntilRefresh)\n }\n\n const stopTokenRefreshTimer = () => {\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n refreshTimer = null\n }\n }\n\n const initialize = async () => {\n if (isInitialized.value) return\n \n isInitializing.value = true\n try {\n // Check for existing session/token in localStorage\n if (typeof window !== 'undefined') {\n const storedSession = localStorage.getItem('strands_auth_session')\n const storedUser = localStorage.getItem('strands_auth_user')\n \n if (storedSession && storedUser) {\n try {\n const session = JSON.parse(storedSession) as Session\n const user = JSON.parse(storedUser) as User\n \n // Convert expiresAt back to Date object\n session.expiresAt = new Date(session.expiresAt)\n \n // Check if session is still valid\n if (session.expiresAt > new Date()) {\n currentSession.value = session\n currentUser.value = user\n \n // Start token refresh timer for restored session\n startTokenRefreshTimer()\n } else {\n // Session expired, clear storage\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } catch (error) {\n // Clear corrupted data\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n }\n }\n \n isInitialized.value = true\n \n // Add a small delay to ensure state is fully settled before hiding loading\n await new Promise(resolve => setTimeout(resolve, 50))\n } catch (error) {\n // Silently handle initialization errors\n } finally {\n isInitializing.value = false\n }\n }\n\n const changeUsername = async (newUsername: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeUsername'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n username: newUsername,\n }),\n })\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n if (response.status === 409) {\n throw new Error('Username is already taken')\n } else if (errorData.cooldown_end) {\n throw new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(errorData.cooldown_end).toLocaleDateString()}`)\n }\n throw new Error(errorData.message || `Username change failed: ${response.status} ${response.statusText}`)\n }\n\n const result = await response.json()\n \n // For username change, we need to manually update some fields since API might not return full user\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n username: newUsername,\n usernameLastChangedAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const getUsernameCooldown = async () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('usernameCooldown'), {\n method: 'GET',\n headers: {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get username cooldown: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const checkUsernameAvailability = async (username: string) => {\n // Replace {username} in the URL\n const url = getUrl('checkUsernameAvailability').replace('{username}', encodeURIComponent(username))\n \n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to check username availability: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n // Session management functions\n const getUserSessions = async () => {\n const response = await fetch(getUrl('sessions'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get user sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const getSessionStats = async () => {\n const response = await fetch(getUrl('sessionsStats'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get session stats: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const revokeSession = async (sessionId: string) => {\n const url = getUrl('sessionRevoke').replace('{session_id}', encodeURIComponent(sessionId))\n \n const response = await fetch(url, {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke session: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n const revokeAllOtherSessions = async () => {\n const response = await fetch(getUrl('sessionsRevokeAll'), {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke all other sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n // Auto-initialize on first use\n if (!isInitialized.value) {\n initialize()\n }\n\n return {\n // State\n user: computed(() => currentUser.value),\n currentUser: computed(() => currentUser.value),\n currentSession: computed(() => currentSession.value),\n isAuthenticated,\n isLoading: computed(() => isLoading.value || !isInitialized.value),\n loading: computed(() => loading.value),\n loadingMessage,\n \n // Specific loading states\n isInitializing,\n isSigningIn,\n isSigningUp,\n isSigningOut,\n isRefreshingToken,\n isSendingMfaEmail,\n isVerifyingMfa,\n \n // MFA State\n mfaRequired: computed(() => mfaRequired.value),\n mfaSessionId: computed(() => mfaSessionId.value),\n availableMfaMethods: computed(() => availableMfaMethods.value),\n\n // Methods\n signIn,\n signUp,\n signOut,\n refreshToken,\n fetchProfile,\n updateProfile,\n updateUserSettings,\n changeEmail,\n changeUsername,\n getUsernameCooldown,\n checkUsernameAvailability,\n // Session management\n getUserSessions,\n getSessionStats,\n revokeSession,\n revokeAllOtherSessions,\n initialize,\n setAuthData,\n verifyMfa,\n sendMfaEmailCode,\n getMfaWebAuthnChallenge,\n registerHardwareKey,\n completeHardwareKeyRegistration,\n \n // Token management\n startTokenRefreshTimer,\n stopTokenRefreshTimer,\n \n // Force re-initialization (useful for testing or navigation)\n forceReInit: () => {\n isInitialized.value = false\n isInitializing.value = true\n initialize()\n },\n }\n}"],"names":[],"mappings":";;AAKA,MAAM,uBAAuB,CAAC,YAAuB;AACnD,SAAO;AAAA,IACL,IAAI,QAAQ;AAAA,IACZ,OAAO,QAAQ;AAAA,IACf,WAAW,QAAQ,cAAc,QAAQ,aAAa;AAAA,IACtD,UAAU,QAAQ,aAAa,QAAQ,YAAY;AAAA,IACnD,QAAQ,QAAQ,cAAc,QAAQ;AAAA,IACtC,YAAY,QAAQ,eAAe,QAAQ,cAAc;AAAA,IACzD,eAAe,QAAQ,kBAAkB,QAAQ,iBAAiB;AAAA,IAClE,mBAAmB,QAAQ,uBAAuB,QAAQ;AAAA,IAC1D,UAAU,QAAQ,YAAY,CAAA;AAAA,IAC9B,IAAI,QAAQ,MAAM;AAAA,IAClB,OAAO,QAAQ,SAAS;AAAA,IACxB,eAAe,QAAQ,iBAAiB,QAAQ,iBAAiB;AAAA,IACjE,UAAU,QAAQ;AAAA,IAClB,uBAAuB,QAAQ,4BAA4B,QAAQ;AAAA,IACnE,WAAW,QAAQ,cAAc,QAAQ;AAAA,IACzC,WAAW,QAAQ,cAAc,QAAQ,cAAa,oBAAI,KAAA,GAAO,YAAA;AAAA,EAAY;AAEjF;AAEA,MAAM,EAAE,OAAA,IAAW,iBAAA;AAEnB,MAAM,cAAc,IAAiB,IAAI;AACzC,MAAM,iBAAiB,IAAoB,IAAI;AAG/C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,IAGA,aAAa,SAAS,MAAM,YAAY,KAAK;AAAA,IAC7C,cAAc,SAAS,MAAM,aAAa,KAAK;AAAA,IAC/C,qBAAqB,SAAS,MAAM,oBAAoB,KAAK;AAAA;AAAA,IAG/D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGE;AAAA,IACA;AAAA;AAAA,IAGA,aAAa,MAAM;AACjB,oBAAc,QAAQ;AACtB,qBAAe,QAAQ;AACvB,iBAAA;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const vue = require("vue");
|
|
3
3
|
const useStrandsConfig = require("./useStrandsConfig-Dms13Zd0.cjs");
|
|
4
|
+
const mapApiUserToFrontend = (apiUser) => {
|
|
5
|
+
return {
|
|
6
|
+
id: apiUser.id,
|
|
7
|
+
email: apiUser.email,
|
|
8
|
+
firstName: apiUser.first_name || apiUser.firstName || "",
|
|
9
|
+
lastName: apiUser.last_name || apiUser.lastName || "",
|
|
10
|
+
avatar: apiUser.avatar_url || apiUser.avatar,
|
|
11
|
+
mfaEnabled: apiUser.mfa_enabled ?? apiUser.mfaEnabled ?? false,
|
|
12
|
+
emailVerified: apiUser.email_verified ?? apiUser.emailVerified ?? false,
|
|
13
|
+
passwordUpdatedAt: apiUser.password_updated_at || apiUser.passwordUpdatedAt,
|
|
14
|
+
settings: apiUser.settings || {},
|
|
15
|
+
xp: apiUser.xp || 0,
|
|
16
|
+
level: apiUser.level || 1,
|
|
17
|
+
next_level_xp: apiUser.next_level_xp || apiUser.next_level_xp || 4,
|
|
18
|
+
username: apiUser.username,
|
|
19
|
+
usernameLastChangedAt: apiUser.username_last_changed_at || apiUser.usernameLastChangedAt,
|
|
20
|
+
createdAt: apiUser.created_at || apiUser.createdAt,
|
|
21
|
+
updatedAt: apiUser.updated_at || apiUser.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
22
|
+
};
|
|
23
|
+
};
|
|
4
24
|
const { getUrl } = useStrandsConfig.useStrandsConfig();
|
|
5
25
|
const currentUser = vue.ref(null);
|
|
6
26
|
const currentSession = vue.ref(null);
|
|
@@ -150,7 +170,7 @@ function useStrandsAuth() {
|
|
|
150
170
|
isSigningIn.value = false;
|
|
151
171
|
return authData;
|
|
152
172
|
}
|
|
153
|
-
setAuthData(authData);
|
|
173
|
+
await setAuthData(authData);
|
|
154
174
|
return authData;
|
|
155
175
|
} catch (error) {
|
|
156
176
|
throw error;
|
|
@@ -206,12 +226,18 @@ function useStrandsAuth() {
|
|
|
206
226
|
throw new Error(`Token refresh failed: ${response.status} ${response.statusText}`);
|
|
207
227
|
}
|
|
208
228
|
const tokenData = await response.json();
|
|
229
|
+
if (tokenData.user) {
|
|
230
|
+
currentUser.value = mapApiUserToFrontend(tokenData.user);
|
|
231
|
+
if (typeof window !== "undefined") {
|
|
232
|
+
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
209
235
|
const newSession = {
|
|
210
236
|
accessToken: tokenData.access_token,
|
|
211
237
|
refreshToken: tokenData.refresh_token,
|
|
212
238
|
expiresAt: new Date(Date.now() + 5 * 60 * 1e3),
|
|
213
239
|
// 5 minutes from now
|
|
214
|
-
userId: currentUser.value?.id
|
|
240
|
+
userId: tokenData.user?.id || currentUser.value?.id
|
|
215
241
|
};
|
|
216
242
|
currentSession.value = newSession;
|
|
217
243
|
if (typeof window !== "undefined") {
|
|
@@ -245,24 +271,7 @@ function useStrandsAuth() {
|
|
|
245
271
|
}
|
|
246
272
|
}
|
|
247
273
|
const userData = await response.json();
|
|
248
|
-
currentUser.value =
|
|
249
|
-
id: userData.id,
|
|
250
|
-
email: userData.email,
|
|
251
|
-
firstName: userData.first_name,
|
|
252
|
-
lastName: userData.last_name,
|
|
253
|
-
avatar: userData.avatar_url,
|
|
254
|
-
mfaEnabled: userData.mfaEnabled || false,
|
|
255
|
-
emailVerified: userData.email_verified,
|
|
256
|
-
passwordUpdatedAt: userData.password_updated_at,
|
|
257
|
-
settings: userData.settings || {},
|
|
258
|
-
xp: userData.xp || 0,
|
|
259
|
-
level: userData.level || 1,
|
|
260
|
-
next_level_xp: userData.next_level_xp || 4,
|
|
261
|
-
username: userData.username,
|
|
262
|
-
usernameLastChangedAt: userData.username_last_changed_at,
|
|
263
|
-
createdAt: userData.created_at,
|
|
264
|
-
updatedAt: userData.updated_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
265
|
-
};
|
|
274
|
+
currentUser.value = mapApiUserToFrontend(userData);
|
|
266
275
|
if (typeof window !== "undefined") {
|
|
267
276
|
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
268
277
|
}
|
|
@@ -296,31 +305,9 @@ function useStrandsAuth() {
|
|
|
296
305
|
}
|
|
297
306
|
}
|
|
298
307
|
const updatedUserData = await response.json();
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
// Update with API response data, preserving the API field names
|
|
303
|
-
id: updatedUserData.id,
|
|
304
|
-
email: updatedUserData.email,
|
|
305
|
-
firstName: updatedUserData.first_name,
|
|
306
|
-
lastName: updatedUserData.last_name,
|
|
307
|
-
emailVerified: updatedUserData.email_verified,
|
|
308
|
-
avatar: updatedUserData.avatar_url,
|
|
309
|
-
mfaEnabled: updatedUserData.mfa_enabled,
|
|
310
|
-
xp: updatedUserData.xp,
|
|
311
|
-
level: updatedUserData.level,
|
|
312
|
-
next_level_xp: updatedUserData.next_level_xp,
|
|
313
|
-
username: updatedUserData.username,
|
|
314
|
-
// This was missing and causing the bug!
|
|
315
|
-
usernameLastChangedAt: updatedUserData.username_last_changed_at,
|
|
316
|
-
createdAt: updatedUserData.created_at,
|
|
317
|
-
updatedAt: updatedUserData.updated_at,
|
|
318
|
-
settings: updatedUserData.settings,
|
|
319
|
-
passwordUpdatedAt: updatedUserData.password_updated_at
|
|
320
|
-
};
|
|
321
|
-
if (typeof window !== "undefined") {
|
|
322
|
-
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
323
|
-
}
|
|
308
|
+
currentUser.value = mapApiUserToFrontend(updatedUserData);
|
|
309
|
+
if (typeof window !== "undefined") {
|
|
310
|
+
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
324
311
|
}
|
|
325
312
|
return currentUser.value;
|
|
326
313
|
} finally {
|
|
@@ -351,15 +338,9 @@ function useStrandsAuth() {
|
|
|
351
338
|
}
|
|
352
339
|
}
|
|
353
340
|
const updatedUserData = await response.json();
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
settings: updatedUserData.settings,
|
|
358
|
-
updatedAt: updatedUserData.updated_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
359
|
-
};
|
|
360
|
-
if (typeof window !== "undefined") {
|
|
361
|
-
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
362
|
-
}
|
|
341
|
+
currentUser.value = mapApiUserToFrontend(updatedUserData);
|
|
342
|
+
if (typeof window !== "undefined") {
|
|
343
|
+
localStorage.setItem("strands_auth_user", JSON.stringify(currentUser.value));
|
|
363
344
|
}
|
|
364
345
|
return currentUser.value;
|
|
365
346
|
} finally {
|
|
@@ -437,7 +418,7 @@ function useStrandsAuth() {
|
|
|
437
418
|
mfaRequired.value = false;
|
|
438
419
|
mfaSessionId.value = null;
|
|
439
420
|
availableMfaMethods.value = [];
|
|
440
|
-
setAuthData(authData);
|
|
421
|
+
await setAuthData(authData);
|
|
441
422
|
return authData;
|
|
442
423
|
} finally {
|
|
443
424
|
isVerifyingMfa.value = false;
|
|
@@ -499,10 +480,10 @@ function useStrandsAuth() {
|
|
|
499
480
|
}
|
|
500
481
|
return response.json();
|
|
501
482
|
};
|
|
502
|
-
const setAuthData = (authResponse) => {
|
|
483
|
+
const setAuthData = async (authResponse) => {
|
|
503
484
|
try {
|
|
504
485
|
if (authResponse.user) {
|
|
505
|
-
currentUser.value = authResponse.user;
|
|
486
|
+
currentUser.value = mapApiUserToFrontend(authResponse.user);
|
|
506
487
|
}
|
|
507
488
|
const session = {
|
|
508
489
|
accessToken: authResponse.access_token,
|
|
@@ -752,4 +733,4 @@ function useStrandsAuth() {
|
|
|
752
733
|
};
|
|
753
734
|
}
|
|
754
735
|
exports.useStrandsAuth = useStrandsAuth;
|
|
755
|
-
//# sourceMappingURL=useStrandsAuth-
|
|
736
|
+
//# sourceMappingURL=useStrandsAuth-Co2lLH4X.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStrandsAuth-Co2lLH4X.cjs","sources":["../../../apps/accounts-ui/src/vue/composables/useStrandsAuth.ts"],"sourcesContent":["import { ref, computed } from 'vue'\nimport type { User, Session, SessionInfo, SessionStats, SignInCredentials, SignUpData, AuthResponse, MfaDevice, MfaErrorResponse } from '../../types'\nimport { useStrandsConfig } from './useStrandsConfig'\n\n// Utility function to map API user data to frontend format\nconst mapApiUserToFrontend = (apiUser: any): User => {\n return {\n id: apiUser.id,\n email: apiUser.email,\n firstName: apiUser.first_name || apiUser.firstName || '',\n lastName: apiUser.last_name || apiUser.lastName || '',\n avatar: apiUser.avatar_url || apiUser.avatar,\n mfaEnabled: apiUser.mfa_enabled ?? apiUser.mfaEnabled ?? false,\n emailVerified: apiUser.email_verified ?? apiUser.emailVerified ?? false,\n passwordUpdatedAt: apiUser.password_updated_at || apiUser.passwordUpdatedAt,\n settings: apiUser.settings || {},\n xp: apiUser.xp || 0,\n level: apiUser.level || 1,\n next_level_xp: apiUser.next_level_xp || apiUser.next_level_xp || 4,\n username: apiUser.username,\n usernameLastChangedAt: apiUser.username_last_changed_at || apiUser.usernameLastChangedAt,\n createdAt: apiUser.created_at || apiUser.createdAt,\n updatedAt: apiUser.updated_at || apiUser.updatedAt || new Date().toISOString(),\n }\n}\n\nconst { getUrl } = useStrandsConfig()\n\nconst currentUser = ref<User | null>(null)\nconst currentSession = ref<Session | null>(null)\n\n// Specific loading states\nconst isInitializing = ref(true)\nconst isSigningIn = ref(false)\nconst isSigningUp = ref(false)\nconst isSigningOut = ref(false)\nconst isRefreshingToken = ref(false)\nconst isSendingMfaEmail = ref(false)\nconst isVerifyingMfa = ref(false)\nconst isLoadingProfile = ref(false)\n\n// Legacy loading states for backward compatibility\nconst loading = computed(() => isSigningIn.value || isSigningUp.value || isSigningOut.value || isRefreshingToken.value || isSendingMfaEmail.value || isVerifyingMfa.value || isLoadingProfile.value)\nconst isLoading = computed(() => isInitializing.value || loading.value)\n\n// Loading messages for better UX\nconst loadingMessage = computed(() => {\n if (isInitializing.value) return 'Checking authentication...'\n if (isSigningIn.value) return 'Signing you in...'\n if (isSigningUp.value) return 'Creating your account...'\n if (isSigningOut.value) return 'Signing you out...'\n if (isRefreshingToken.value) return 'Refreshing session...'\n if (isSendingMfaEmail.value) return 'Sending verification code...'\n if (isVerifyingMfa.value) return 'Verifying code...'\n return 'Loading...' // Fallback\n})\n\nconst isInitialized = ref(false)\n\n// MFA state\nconst mfaRequired = ref(false)\nconst mfaSessionId = ref<string | null>(null)\nconst availableMfaMethods = ref<MfaDevice[]>([])\n\n// Token refresh timer\nlet refreshTimer: NodeJS.Timeout | null = null\n\nexport function useStrandsAuth() {\n // Helper function to get authenticated headers with refresh token\n const getAuthHeaders = () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n }\n \n // Include refresh token for session management\n if (currentSession.value?.refreshToken) {\n headers['x-refresh-token'] = currentSession.value.refreshToken\n }\n \n return headers\n }\n /**\n * Complete hardware key (WebAuthn) registration for MFA\n * Returns result with backup codes on success\n */\n const completeHardwareKeyRegistration = async (deviceId: string, credential: any, accessToken: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n\n const response = await fetch(getUrl('mfaHardwareCompleteRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`\n },\n body: JSON.stringify({\n device_id: deviceId,\n credential: credential\n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to complete hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to complete hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n /**\n * Register a hardware key (WebAuthn) for MFA\n * Returns { device_id, challenge } on success\n */\n const registerHardwareKey = async (deviceName: string, accessToken: string, deviceType: 'hardware' | 'passkey' = 'hardware') => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('mfaHardwareStartRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({ \n device_name: deviceName,\n device_type: deviceType \n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to start hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to start hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n\n const isAuthenticated = computed(() => currentUser.value !== null)\n\n const signIn = async (credentials: SignInCredentials) => {\n isSigningIn.value = true\n try {\n // Reset MFA state at start of new sign-in attempt\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Make API call to sign-in endpoint\n const response = await fetch(getUrl('signIn'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(credentials),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Invalid email or password')\n } else if (response.status === 403) {\n throw new Error('Please verify your email address before signing in')\n } else {\n throw new Error(`Sign in failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const authData: AuthResponse = await response.json()\n \n // Check if MFA is required\n if (authData.mfa_required) {\n mfaRequired.value = true\n mfaSessionId.value = authData.mfa_session_id || null\n \n // Convert API MFA methods to the expected format\n const methods = (authData.available_mfa_methods || []).map((method: any) => {\n // Create better fallback names for different device types\n let fallbackName = `${method.device_type.charAt(0).toUpperCase() + method.device_type.slice(1)} Authentication`\n \n if (method.device_type === 'hardware') {\n // Better names for hardware keys\n fallbackName = method.device_name || 'Security Key' // Could be YubiKey, FIDO2 Key, etc.\n } else if (method.device_type === 'totp') {\n fallbackName = method.device_name || 'Authenticator App'\n } else if (method.device_type === 'email') {\n fallbackName = method.device_name || 'Email Verification'\n }\n \n return {\n id: method.device_id,\n device_type: method.device_type,\n device_name: method.device_name || fallbackName,\n is_active: true,\n created_at: new Date().toISOString(),\n last_used_at: method.last_used_at,\n // Pass through additional metadata if available\n credential_id: method.credential_id,\n device_info: method.device_info\n }\n })\n availableMfaMethods.value = methods\n \n // Set signIn loading to false immediately so MFA modal can show\n isSigningIn.value = false\n \n return authData // Return without storing full auth data\n }\n \n // Store the authentication data if MFA not required\n await setAuthData(authData)\n \n return authData\n } catch (error) {\n throw error\n } finally {\n isSigningIn.value = false\n }\n }\n\n const signUp = async (userData: SignUpData) => {\n isSigningUp.value = true\n try {\n // Integration point: Replace with actual auth SDK call\n // Example: const result = await authSDK.signUp(userData)\n \n throw new Error('Sign up not implemented - please integrate with auth SDK')\n } finally {\n isSigningUp.value = false\n }\n }\n\n const signOut = async () => {\n isSigningOut.value = true\n try {\n // Stop token refresh timer\n stopTokenRefreshTimer()\n \n // Clear user and session state\n currentUser.value = null\n currentSession.value = null\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Clear stored tokens\n if (typeof window !== 'undefined') {\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } finally {\n isSigningOut.value = false\n }\n }\n\n const refreshToken = async () => {\n if (!currentSession.value?.refreshToken) {\n return false\n }\n \n \n isRefreshingToken.value = true\n try {\n const response = await fetch(getUrl('refresh'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n refresh_token: currentSession.value.refreshToken,\n }),\n })\n\n if (!response.ok) { \n if (response.status === 401) {\n // Refresh token is invalid/expired, sign out user\n await signOut()\n return false\n }\n throw new Error(`Token refresh failed: ${response.status} ${response.statusText}`)\n }\n\n const tokenData = await response.json()\n \n // Token refresh now returns full AuthResponse with user data\n if (tokenData.user) {\n // Update user data with fresh information from the server\n currentUser.value = mapApiUserToFrontend(tokenData.user)\n \n // Update localStorage with fresh user data\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n // Update session with fresh tokens\n const newSession: Session = {\n accessToken: tokenData.access_token,\n refreshToken: tokenData.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now\n userId: tokenData.user?.id || currentUser.value?.id,\n }\n \n currentSession.value = newSession\n \n // Update localStorage with new session\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(newSession))\n }\n \n // Restart token refresh timer\n startTokenRefreshTimer()\n \n return true\n } catch (error) {\n // On refresh failure, sign out the user\n await signOut()\n return false\n }\n }\n\n const fetchProfile = async (): Promise<User | null> => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Failed to fetch profile: ${response.status} ${response.statusText}`)\n }\n }\n\n const userData = await response.json()\n \n // Update the current user state using the mapping utility\n currentUser.value = mapApiUserToFrontend(userData)\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateProfile = async (profileData: Partial<User>) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n first_name: profileData.firstName,\n last_name: profileData.lastName,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Profile update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state using the mapping utility\n currentUser.value = mapApiUserToFrontend(updatedUserData)\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateUserSettings = async (settings: any) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('settings'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n settings: settings,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Settings update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state using the mapping utility\n currentUser.value = mapApiUserToFrontend(updatedUserData)\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const changeEmail = async (newEmail: string, password: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeEmail'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n new_email: newEmail,\n password: password,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `Email change failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const result = await response.json()\n \n // For email change, we need to manually update some fields since API might not return full user\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n email: newEmail,\n emailVerified: false, // Email needs to be verified again\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const verifyMfa = async (deviceId: string, code: string, isBackupCode = false) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isVerifyingMfa.value = true\n try {\n const endpoint = isBackupCode ? getUrl('mfaBackupCodeVerify') : getUrl('mfaSigninVerify')\n const body = isBackupCode \n ? { mfa_session_id: mfaSessionId.value, backup_code: code }\n : { mfa_session_id: mfaSessionId.value, device_id: deviceId, code }\n\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'MFA verification failed'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'MFA verification failed'\n }\n \n throw new Error(errorMessage)\n }\n\n const authData: AuthResponse = await response.json()\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Store the authentication data\n await setAuthData(authData)\n \n return authData\n } finally {\n isVerifyingMfa.value = false\n }\n }\n\n const sendMfaEmailCode = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isSendingMfaEmail.value = true\n try {\n const response = await fetch(getUrl('mfaSigninSendEmail'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId,\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to send MFA email code'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'Failed to send MFA email code'\n }\n \n throw new Error(errorMessage)\n }\n\n const result = await response.json()\n return result\n } finally {\n isSendingMfaEmail.value = false\n }\n }\n\n const getMfaWebAuthnChallenge = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n \n const response = await fetch(getUrl('mfaWebAuthnChallenge'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to get WebAuthn challenge'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || errorMessage\n }\n \n throw new Error(errorMessage)\n }\n\n return response.json()\n }\n\n const setAuthData = async (authResponse: AuthResponse) => {\n try {\n // Handle user data (only for sign-in/sign-up, not token refresh)\n if (authResponse.user) {\n currentUser.value = mapApiUserToFrontend(authResponse.user)\n }\n \n // Create session object\n const session: Session = {\n accessToken: authResponse.access_token,\n refreshToken: authResponse.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now (matching API token expiry)\n userId: currentUser.value?.id || authResponse.user?.id,\n }\n \n currentSession.value = session\n \n // Store in localStorage for persistence\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(session))\n if (currentUser.value) {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n // Start automatic token refresh\n startTokenRefreshTimer()\n } catch (error) {\n console.error('Error setting auth data:', error)\n // Silently handle auth data storage errors\n }\n }\n\n // Token refresh timer management\n const startTokenRefreshTimer = () => {\n // Clear existing timer\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n }\n \n if (!currentSession.value) return\n \n // Calculate time until token expires (refresh 1 minute before expiry)\n const now = new Date()\n const expiresAt = currentSession.value.expiresAt\n const timeUntilRefresh = expiresAt.getTime() - now.getTime() - (1 * 60 * 1000) // 1 minute before expiry\n \n // If token is already expired or expires very soon, refresh immediately\n if (timeUntilRefresh <= 0) {\n refreshToken()\n return\n }\n \n // Set timer to refresh token\n refreshTimer = setTimeout(async () => {\n const success = await refreshToken()\n \n if (success) {\n // Schedule next refresh\n startTokenRefreshTimer()\n }\n }, timeUntilRefresh)\n }\n\n const stopTokenRefreshTimer = () => {\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n refreshTimer = null\n }\n }\n\n const initialize = async () => {\n if (isInitialized.value) return\n \n isInitializing.value = true\n try {\n // Check for existing session/token in localStorage\n if (typeof window !== 'undefined') {\n const storedSession = localStorage.getItem('strands_auth_session')\n const storedUser = localStorage.getItem('strands_auth_user')\n \n if (storedSession && storedUser) {\n try {\n const session = JSON.parse(storedSession) as Session\n const user = JSON.parse(storedUser) as User\n \n // Convert expiresAt back to Date object\n session.expiresAt = new Date(session.expiresAt)\n \n // Check if session is still valid\n if (session.expiresAt > new Date()) {\n currentSession.value = session\n currentUser.value = user\n \n // Start token refresh timer for restored session\n startTokenRefreshTimer()\n } else {\n // Session expired, clear storage\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } catch (error) {\n // Clear corrupted data\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n }\n }\n \n isInitialized.value = true\n \n // Add a small delay to ensure state is fully settled before hiding loading\n await new Promise(resolve => setTimeout(resolve, 50))\n } catch (error) {\n // Silently handle initialization errors\n } finally {\n isInitializing.value = false\n }\n }\n\n const changeUsername = async (newUsername: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeUsername'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n username: newUsername,\n }),\n })\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n if (response.status === 409) {\n throw new Error('Username is already taken')\n } else if (errorData.cooldown_end) {\n throw new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(errorData.cooldown_end).toLocaleDateString()}`)\n }\n throw new Error(errorData.message || `Username change failed: ${response.status} ${response.statusText}`)\n }\n\n const result = await response.json()\n \n // For username change, we need to manually update some fields since API might not return full user\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n username: newUsername,\n usernameLastChangedAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const getUsernameCooldown = async () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('usernameCooldown'), {\n method: 'GET',\n headers: {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get username cooldown: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const checkUsernameAvailability = async (username: string) => {\n // Replace {username} in the URL\n const url = getUrl('checkUsernameAvailability').replace('{username}', encodeURIComponent(username))\n \n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to check username availability: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n // Session management functions\n const getUserSessions = async () => {\n const response = await fetch(getUrl('sessions'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get user sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const getSessionStats = async () => {\n const response = await fetch(getUrl('sessionsStats'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get session stats: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const revokeSession = async (sessionId: string) => {\n const url = getUrl('sessionRevoke').replace('{session_id}', encodeURIComponent(sessionId))\n \n const response = await fetch(url, {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke session: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n const revokeAllOtherSessions = async () => {\n const response = await fetch(getUrl('sessionsRevokeAll'), {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke all other sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n // Auto-initialize on first use\n if (!isInitialized.value) {\n initialize()\n }\n\n return {\n // State\n user: computed(() => currentUser.value),\n currentUser: computed(() => currentUser.value),\n currentSession: computed(() => currentSession.value),\n isAuthenticated,\n isLoading: computed(() => isLoading.value || !isInitialized.value),\n loading: computed(() => loading.value),\n loadingMessage,\n \n // Specific loading states\n isInitializing,\n isSigningIn,\n isSigningUp,\n isSigningOut,\n isRefreshingToken,\n isSendingMfaEmail,\n isVerifyingMfa,\n \n // MFA State\n mfaRequired: computed(() => mfaRequired.value),\n mfaSessionId: computed(() => mfaSessionId.value),\n availableMfaMethods: computed(() => availableMfaMethods.value),\n\n // Methods\n signIn,\n signUp,\n signOut,\n refreshToken,\n fetchProfile,\n updateProfile,\n updateUserSettings,\n changeEmail,\n changeUsername,\n getUsernameCooldown,\n checkUsernameAvailability,\n // Session management\n getUserSessions,\n getSessionStats,\n revokeSession,\n revokeAllOtherSessions,\n initialize,\n setAuthData,\n verifyMfa,\n sendMfaEmailCode,\n getMfaWebAuthnChallenge,\n registerHardwareKey,\n completeHardwareKeyRegistration,\n \n // Token management\n startTokenRefreshTimer,\n stopTokenRefreshTimer,\n \n // Force re-initialization (useful for testing or navigation)\n forceReInit: () => {\n isInitialized.value = false\n isInitializing.value = true\n initialize()\n },\n }\n}"],"names":["useStrandsConfig","ref","computed"],"mappings":";;;AAKA,MAAM,uBAAuB,CAAC,YAAuB;AACnD,SAAO;AAAA,IACL,IAAI,QAAQ;AAAA,IACZ,OAAO,QAAQ;AAAA,IACf,WAAW,QAAQ,cAAc,QAAQ,aAAa;AAAA,IACtD,UAAU,QAAQ,aAAa,QAAQ,YAAY;AAAA,IACnD,QAAQ,QAAQ,cAAc,QAAQ;AAAA,IACtC,YAAY,QAAQ,eAAe,QAAQ,cAAc;AAAA,IACzD,eAAe,QAAQ,kBAAkB,QAAQ,iBAAiB;AAAA,IAClE,mBAAmB,QAAQ,uBAAuB,QAAQ;AAAA,IAC1D,UAAU,QAAQ,YAAY,CAAA;AAAA,IAC9B,IAAI,QAAQ,MAAM;AAAA,IAClB,OAAO,QAAQ,SAAS;AAAA,IACxB,eAAe,QAAQ,iBAAiB,QAAQ,iBAAiB;AAAA,IACjE,UAAU,QAAQ;AAAA,IAClB,uBAAuB,QAAQ,4BAA4B,QAAQ;AAAA,IACnE,WAAW,QAAQ,cAAc,QAAQ;AAAA,IACzC,WAAW,QAAQ,cAAc,QAAQ,cAAa,oBAAI,KAAA,GAAO,YAAA;AAAA,EAAY;AA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MAAM,YAAY,KAAK;AAAA,IAC7C,gBAAgBA,IAAAA,SAAS,MAAM,eAAe,KAAK;AAAA,IACnD;AAAA,IACA,WAAWA,IAAAA,SAAS,MAAM,UAAU,SAAS,CAAC,cAAc,KAAK;AAAA,IACjE,SAASA,IAAAA,SAAS,MAAM,QAAQ,KAAK;AAAA,IACrC;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA,aAAaA,IAAAA,SAAS,MAAM,YAAY,KAAK;AAAA,IAC7C,cAAcA,IAAAA,SAAS,MAAM,aAAa,KAAK;AAAA,IAC/C,qBAAqBA,IAAAA,SAAS,MAAM,oBAAoB,KAAK;AAAA;AAAA,IAG/D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGE;AAAA,IACA;AAAA;AAAA,IAGA,aAAa,MAAM;AACjB,oBAAc,QAAQ;AACtB,qBAAe,QAAQ;AACvB,iBAAA;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStrandsAuth-Beee__9G.js","sources":["../../../apps/accounts-ui/src/vue/composables/useStrandsAuth.ts"],"sourcesContent":["import { ref, computed } from 'vue'\nimport type { User, Session, SessionInfo, SessionStats, SignInCredentials, SignUpData, AuthResponse, MfaDevice, MfaErrorResponse } from '../../types'\nimport { useStrandsConfig } from './useStrandsConfig'\n\nconst { getUrl } = useStrandsConfig()\n\nconst currentUser = ref<User | null>(null)\nconst currentSession = ref<Session | null>(null)\n\n// Specific loading states\nconst isInitializing = ref(true)\nconst isSigningIn = ref(false)\nconst isSigningUp = ref(false)\nconst isSigningOut = ref(false)\nconst isRefreshingToken = ref(false)\nconst isSendingMfaEmail = ref(false)\nconst isVerifyingMfa = ref(false)\nconst isLoadingProfile = ref(false)\n\n// Legacy loading states for backward compatibility\nconst loading = computed(() => isSigningIn.value || isSigningUp.value || isSigningOut.value || isRefreshingToken.value || isSendingMfaEmail.value || isVerifyingMfa.value || isLoadingProfile.value)\nconst isLoading = computed(() => isInitializing.value || loading.value)\n\n// Loading messages for better UX\nconst loadingMessage = computed(() => {\n if (isInitializing.value) return 'Checking authentication...'\n if (isSigningIn.value) return 'Signing you in...'\n if (isSigningUp.value) return 'Creating your account...'\n if (isSigningOut.value) return 'Signing you out...'\n if (isRefreshingToken.value) return 'Refreshing session...'\n if (isSendingMfaEmail.value) return 'Sending verification code...'\n if (isVerifyingMfa.value) return 'Verifying code...'\n return 'Loading...' // Fallback\n})\n\nconst isInitialized = ref(false)\n\n// MFA state\nconst mfaRequired = ref(false)\nconst mfaSessionId = ref<string | null>(null)\nconst availableMfaMethods = ref<MfaDevice[]>([])\n\n// Token refresh timer\nlet refreshTimer: NodeJS.Timeout | null = null\n\nexport function useStrandsAuth() {\n // Helper function to get authenticated headers with refresh token\n const getAuthHeaders = () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n }\n \n // Include refresh token for session management\n if (currentSession.value?.refreshToken) {\n headers['x-refresh-token'] = currentSession.value.refreshToken\n }\n \n return headers\n }\n /**\n * Complete hardware key (WebAuthn) registration for MFA\n * Returns result with backup codes on success\n */\n const completeHardwareKeyRegistration = async (deviceId: string, credential: any, accessToken: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n\n const response = await fetch(getUrl('mfaHardwareCompleteRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`\n },\n body: JSON.stringify({\n device_id: deviceId,\n credential: credential\n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to complete hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to complete hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n /**\n * Register a hardware key (WebAuthn) for MFA\n * Returns { device_id, challenge } on success\n */\n const registerHardwareKey = async (deviceName: string, accessToken: string, deviceType: 'hardware' | 'passkey' = 'hardware') => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('mfaHardwareStartRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({ \n device_name: deviceName,\n device_type: deviceType \n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to start hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to start hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n\n const isAuthenticated = computed(() => currentUser.value !== null)\n\n const signIn = async (credentials: SignInCredentials) => {\n isSigningIn.value = true\n try {\n // Reset MFA state at start of new sign-in attempt\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Make API call to sign-in endpoint\n const response = await fetch(getUrl('signIn'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(credentials),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Invalid email or password')\n } else if (response.status === 403) {\n throw new Error('Please verify your email address before signing in')\n } else {\n throw new Error(`Sign in failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const authData: AuthResponse = await response.json()\n \n // Check if MFA is required\n if (authData.mfa_required) {\n mfaRequired.value = true\n mfaSessionId.value = authData.mfa_session_id || null\n \n // Convert API MFA methods to the expected format\n const methods = (authData.available_mfa_methods || []).map((method: any) => {\n // Create better fallback names for different device types\n let fallbackName = `${method.device_type.charAt(0).toUpperCase() + method.device_type.slice(1)} Authentication`\n \n if (method.device_type === 'hardware') {\n // Better names for hardware keys\n fallbackName = method.device_name || 'Security Key' // Could be YubiKey, FIDO2 Key, etc.\n } else if (method.device_type === 'totp') {\n fallbackName = method.device_name || 'Authenticator App'\n } else if (method.device_type === 'email') {\n fallbackName = method.device_name || 'Email Verification'\n }\n \n return {\n id: method.device_id,\n device_type: method.device_type,\n device_name: method.device_name || fallbackName,\n is_active: true,\n created_at: new Date().toISOString(),\n last_used_at: method.last_used_at,\n // Pass through additional metadata if available\n credential_id: method.credential_id,\n device_info: method.device_info\n }\n })\n availableMfaMethods.value = methods\n \n // Set signIn loading to false immediately so MFA modal can show\n isSigningIn.value = false\n \n return authData // Return without storing full auth data\n }\n \n // Store the authentication data if MFA not required\n setAuthData(authData)\n \n return authData\n } catch (error) {\n throw error\n } finally {\n isSigningIn.value = false\n }\n }\n\n const signUp = async (userData: SignUpData) => {\n isSigningUp.value = true\n try {\n // Integration point: Replace with actual auth SDK call\n // Example: const result = await authSDK.signUp(userData)\n \n throw new Error('Sign up not implemented - please integrate with auth SDK')\n } finally {\n isSigningUp.value = false\n }\n }\n\n const signOut = async () => {\n isSigningOut.value = true\n try {\n // Stop token refresh timer\n stopTokenRefreshTimer()\n \n // Clear user and session state\n currentUser.value = null\n currentSession.value = null\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Clear stored tokens\n if (typeof window !== 'undefined') {\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } finally {\n isSigningOut.value = false\n }\n }\n\n const refreshToken = async () => {\n if (!currentSession.value?.refreshToken) {\n return false\n }\n \n \n isRefreshingToken.value = true\n try {\n const response = await fetch(getUrl('refresh'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n refresh_token: currentSession.value.refreshToken,\n }),\n })\n\n if (!response.ok) { \n if (response.status === 401) {\n // Refresh token is invalid/expired, sign out user\n await signOut()\n return false\n }\n throw new Error(`Token refresh failed: ${response.status} ${response.statusText}`)\n }\n\n const tokenData = await response.json()\n \n // For token refresh, only update tokens - don't change user data\n const newSession: Session = {\n accessToken: tokenData.access_token,\n refreshToken: tokenData.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now\n userId: currentUser.value?.id,\n }\n \n currentSession.value = newSession\n \n // Update localStorage with new session\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(newSession))\n }\n \n // Restart token refresh timer\n startTokenRefreshTimer()\n \n return true\n } catch (error) {\n // On refresh failure, sign out the user\n await signOut()\n return false\n }\n }\n\n const fetchProfile = async (): Promise<User | null> => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Failed to fetch profile: ${response.status} ${response.statusText}`)\n }\n }\n\n const userData = await response.json()\n \n // Update the current user state\n currentUser.value = {\n id: userData.id,\n email: userData.email,\n firstName: userData.first_name,\n lastName: userData.last_name,\n avatar: userData.avatar_url,\n mfaEnabled: userData.mfaEnabled || false,\n emailVerified: userData.email_verified,\n passwordUpdatedAt: userData.password_updated_at,\n settings: userData.settings || {},\n xp: userData.xp || 0,\n level: userData.level || 1,\n next_level_xp: userData.next_level_xp || 4,\n username: userData.username,\n usernameLastChangedAt: userData.username_last_changed_at,\n createdAt: userData.created_at,\n updatedAt: userData.updated_at || new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateProfile = async (profileData: Partial<User>) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n first_name: profileData.firstName,\n last_name: profileData.lastName,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Profile update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state with API response data\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n // Update with API response data, preserving the API field names\n id: updatedUserData.id,\n email: updatedUserData.email,\n firstName: updatedUserData.first_name,\n lastName: updatedUserData.last_name,\n emailVerified: updatedUserData.email_verified,\n avatar: updatedUserData.avatar_url,\n mfaEnabled: updatedUserData.mfa_enabled,\n xp: updatedUserData.xp,\n level: updatedUserData.level,\n next_level_xp: updatedUserData.next_level_xp,\n username: updatedUserData.username, // This was missing and causing the bug!\n usernameLastChangedAt: updatedUserData.username_last_changed_at,\n createdAt: updatedUserData.created_at,\n updatedAt: updatedUserData.updated_at,\n settings: updatedUserData.settings,\n passwordUpdatedAt: updatedUserData.password_updated_at,\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateUserSettings = async (settings: any) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('settings'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n settings: settings,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Settings update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n settings: updatedUserData.settings,\n updatedAt: updatedUserData.updated_at || new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const changeEmail = async (newEmail: string, password: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeEmail'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n new_email: newEmail,\n password: password,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `Email change failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const result = await response.json()\n \n // Update the current user state with new email\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n email: newEmail,\n emailVerified: false, // Email needs to be verified again\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const verifyMfa = async (deviceId: string, code: string, isBackupCode = false) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isVerifyingMfa.value = true\n try {\n const endpoint = isBackupCode ? getUrl('mfaBackupCodeVerify') : getUrl('mfaSigninVerify')\n const body = isBackupCode \n ? { mfa_session_id: mfaSessionId.value, backup_code: code }\n : { mfa_session_id: mfaSessionId.value, device_id: deviceId, code }\n\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'MFA verification failed'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'MFA verification failed'\n }\n \n throw new Error(errorMessage)\n }\n\n const authData: AuthResponse = await response.json()\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Store the authentication data\n setAuthData(authData)\n \n return authData\n } finally {\n isVerifyingMfa.value = false\n }\n }\n\n const sendMfaEmailCode = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isSendingMfaEmail.value = true\n try {\n const response = await fetch(getUrl('mfaSigninSendEmail'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId,\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to send MFA email code'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'Failed to send MFA email code'\n }\n \n throw new Error(errorMessage)\n }\n\n const result = await response.json()\n return result\n } finally {\n isSendingMfaEmail.value = false\n }\n }\n\n const getMfaWebAuthnChallenge = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n \n const response = await fetch(getUrl('mfaWebAuthnChallenge'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to get WebAuthn challenge'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || errorMessage\n }\n \n throw new Error(errorMessage)\n }\n\n return response.json()\n }\n\n const setAuthData = (authResponse: AuthResponse) => {\n try {\n // Handle user data (only for sign-in/sign-up, not token refresh)\n if (authResponse.user) {\n currentUser.value = authResponse.user\n }\n \n // Create session object\n const session: Session = {\n accessToken: authResponse.access_token,\n refreshToken: authResponse.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now (matching API token expiry)\n userId: currentUser.value?.id || authResponse.user?.id,\n }\n \n currentSession.value = session\n \n // Store in localStorage for persistence\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(session))\n if (currentUser.value) {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n // Start automatic token refresh\n startTokenRefreshTimer()\n } catch (error) {\n console.error('Error setting auth data:', error)\n // Silently handle auth data storage errors\n }\n }\n\n // Token refresh timer management\n const startTokenRefreshTimer = () => {\n // Clear existing timer\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n }\n \n if (!currentSession.value) return\n \n // Calculate time until token expires (refresh 1 minute before expiry)\n const now = new Date()\n const expiresAt = currentSession.value.expiresAt\n const timeUntilRefresh = expiresAt.getTime() - now.getTime() - (1 * 60 * 1000) // 1 minute before expiry\n \n // If token is already expired or expires very soon, refresh immediately\n if (timeUntilRefresh <= 0) {\n refreshToken()\n return\n }\n \n // Set timer to refresh token\n refreshTimer = setTimeout(async () => {\n const success = await refreshToken()\n \n if (success) {\n // Schedule next refresh\n startTokenRefreshTimer()\n }\n }, timeUntilRefresh)\n }\n\n const stopTokenRefreshTimer = () => {\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n refreshTimer = null\n }\n }\n\n const initialize = async () => {\n if (isInitialized.value) return\n \n isInitializing.value = true\n try {\n // Check for existing session/token in localStorage\n if (typeof window !== 'undefined') {\n const storedSession = localStorage.getItem('strands_auth_session')\n const storedUser = localStorage.getItem('strands_auth_user')\n \n if (storedSession && storedUser) {\n try {\n const session = JSON.parse(storedSession) as Session\n const user = JSON.parse(storedUser) as User\n \n // Convert expiresAt back to Date object\n session.expiresAt = new Date(session.expiresAt)\n \n // Check if session is still valid\n if (session.expiresAt > new Date()) {\n currentSession.value = session\n currentUser.value = user\n \n // Start token refresh timer for restored session\n startTokenRefreshTimer()\n } else {\n // Session expired, clear storage\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } catch (error) {\n // Clear corrupted data\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n }\n }\n \n isInitialized.value = true\n \n // Add a small delay to ensure state is fully settled before hiding loading\n await new Promise(resolve => setTimeout(resolve, 50))\n } catch (error) {\n // Silently handle initialization errors\n } finally {\n isInitializing.value = false\n }\n }\n\n const changeUsername = async (newUsername: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeUsername'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n username: newUsername,\n }),\n })\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n if (response.status === 409) {\n throw new Error('Username is already taken')\n } else if (errorData.cooldown_end) {\n throw new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(errorData.cooldown_end).toLocaleDateString()}`)\n }\n throw new Error(errorData.message || `Username change failed: ${response.status} ${response.statusText}`)\n }\n\n const result = await response.json()\n \n // Update the current user state with new username\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n username: newUsername,\n usernameLastChangedAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const getUsernameCooldown = async () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('usernameCooldown'), {\n method: 'GET',\n headers: {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get username cooldown: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const checkUsernameAvailability = async (username: string) => {\n // Replace {username} in the URL\n const url = getUrl('checkUsernameAvailability').replace('{username}', encodeURIComponent(username))\n \n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to check username availability: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n // Session management functions\n const getUserSessions = async () => {\n const response = await fetch(getUrl('sessions'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get user sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const getSessionStats = async () => {\n const response = await fetch(getUrl('sessionsStats'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get session stats: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const revokeSession = async (sessionId: string) => {\n const url = getUrl('sessionRevoke').replace('{session_id}', encodeURIComponent(sessionId))\n \n const response = await fetch(url, {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke session: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n const revokeAllOtherSessions = async () => {\n const response = await fetch(getUrl('sessionsRevokeAll'), {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke all other sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n // Auto-initialize on first use\n if (!isInitialized.value) {\n initialize()\n }\n\n return {\n // State\n user: computed(() => currentUser.value),\n currentUser: computed(() => currentUser.value),\n currentSession: computed(() => currentSession.value),\n isAuthenticated,\n isLoading: computed(() => isLoading.value || !isInitialized.value),\n loading: computed(() => loading.value),\n loadingMessage,\n \n // Specific loading states\n isInitializing,\n isSigningIn,\n isSigningUp,\n isSigningOut,\n isRefreshingToken,\n isSendingMfaEmail,\n isVerifyingMfa,\n \n // MFA State\n mfaRequired: computed(() => mfaRequired.value),\n mfaSessionId: computed(() => mfaSessionId.value),\n availableMfaMethods: computed(() => availableMfaMethods.value),\n\n // Methods\n signIn,\n signUp,\n signOut,\n refreshToken,\n fetchProfile,\n updateProfile,\n updateUserSettings,\n changeEmail,\n changeUsername,\n getUsernameCooldown,\n checkUsernameAvailability,\n // Session management\n getUserSessions,\n getSessionStats,\n revokeSession,\n revokeAllOtherSessions,\n initialize,\n setAuthData,\n verifyMfa,\n sendMfaEmailCode,\n getMfaWebAuthnChallenge,\n registerHardwareKey,\n completeHardwareKeyRegistration,\n \n // Token management\n startTokenRefreshTimer,\n stopTokenRefreshTimer,\n \n // Force re-initialization (useful for testing or navigation)\n forceReInit: () => {\n isInitialized.value = false\n isInitializing.value = true\n initialize()\n },\n }\n}"],"names":[],"mappings":";;AAIA,MAAM,EAAE,OAAA,IAAW,iBAAA;AAEnB,MAAM,cAAc,IAAiB,IAAI;AACzC,MAAM,iBAAiB,IAAoB,IAAI;AAG/C,MAAM,iBAAiB,IAAI,IAAI;AAC/B,MAAM,cAAc,IAAI,KAAK;AAC7B,MAAM,cAAc,IAAI,KAAK;AAC7B,MAAM,eAAe,IAAI,KAAK;AAC9B,MAAM,oBAAoB,IAAI,KAAK;AACnC,MAAM,oBAAoB,IAAI,KAAK;AACnC,MAAM,iBAAiB,IAAI,KAAK;AAChC,MAAM,mBAAmB,IAAI,KAAK;AAGlC,MAAM,UAAU,SAAS,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src/vue/composables/useStrandsAuth.ts"],"sourcesContent":["import { ref, computed } from 'vue'\nimport type { User, Session, SessionInfo, SessionStats, SignInCredentials, SignUpData, AuthResponse, MfaDevice, MfaErrorResponse } from '../../types'\nimport { useStrandsConfig } from './useStrandsConfig'\n\nconst { getUrl } = useStrandsConfig()\n\nconst currentUser = ref<User | null>(null)\nconst currentSession = ref<Session | null>(null)\n\n// Specific loading states\nconst isInitializing = ref(true)\nconst isSigningIn = ref(false)\nconst isSigningUp = ref(false)\nconst isSigningOut = ref(false)\nconst isRefreshingToken = ref(false)\nconst isSendingMfaEmail = ref(false)\nconst isVerifyingMfa = ref(false)\nconst isLoadingProfile = ref(false)\n\n// Legacy loading states for backward compatibility\nconst loading = computed(() => isSigningIn.value || isSigningUp.value || isSigningOut.value || isRefreshingToken.value || isSendingMfaEmail.value || isVerifyingMfa.value || isLoadingProfile.value)\nconst isLoading = computed(() => isInitializing.value || loading.value)\n\n// Loading messages for better UX\nconst loadingMessage = computed(() => {\n if (isInitializing.value) return 'Checking authentication...'\n if (isSigningIn.value) return 'Signing you in...'\n if (isSigningUp.value) return 'Creating your account...'\n if (isSigningOut.value) return 'Signing you out...'\n if (isRefreshingToken.value) return 'Refreshing session...'\n if (isSendingMfaEmail.value) return 'Sending verification code...'\n if (isVerifyingMfa.value) return 'Verifying code...'\n return 'Loading...' // Fallback\n})\n\nconst isInitialized = ref(false)\n\n// MFA state\nconst mfaRequired = ref(false)\nconst mfaSessionId = ref<string | null>(null)\nconst availableMfaMethods = ref<MfaDevice[]>([])\n\n// Token refresh timer\nlet refreshTimer: NodeJS.Timeout | null = null\n\nexport function useStrandsAuth() {\n // Helper function to get authenticated headers with refresh token\n const getAuthHeaders = () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n }\n \n // Include refresh token for session management\n if (currentSession.value?.refreshToken) {\n headers['x-refresh-token'] = currentSession.value.refreshToken\n }\n \n return headers\n }\n /**\n * Complete hardware key (WebAuthn) registration for MFA\n * Returns result with backup codes on success\n */\n const completeHardwareKeyRegistration = async (deviceId: string, credential: any, accessToken: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n\n const response = await fetch(getUrl('mfaHardwareCompleteRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`\n },\n body: JSON.stringify({\n device_id: deviceId,\n credential: credential\n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to complete hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to complete hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n /**\n * Register a hardware key (WebAuthn) for MFA\n * Returns { device_id, challenge } on success\n */\n const registerHardwareKey = async (deviceName: string, accessToken: string, deviceType: 'hardware' | 'passkey' = 'hardware') => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('mfaHardwareStartRegistration'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({ \n device_name: deviceName,\n device_type: deviceType \n })\n })\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to start hardware key registration'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || 'Failed to start hardware key registration'\n }\n \n throw new Error(errorMessage)\n }\n return response.json()\n }\n\n const isAuthenticated = computed(() => currentUser.value !== null)\n\n const signIn = async (credentials: SignInCredentials) => {\n isSigningIn.value = true\n try {\n // Reset MFA state at start of new sign-in attempt\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Make API call to sign-in endpoint\n const response = await fetch(getUrl('signIn'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(credentials),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Invalid email or password')\n } else if (response.status === 403) {\n throw new Error('Please verify your email address before signing in')\n } else {\n throw new Error(`Sign in failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const authData: AuthResponse = await response.json()\n \n // Check if MFA is required\n if (authData.mfa_required) {\n mfaRequired.value = true\n mfaSessionId.value = authData.mfa_session_id || null\n \n // Convert API MFA methods to the expected format\n const methods = (authData.available_mfa_methods || []).map((method: any) => {\n // Create better fallback names for different device types\n let fallbackName = `${method.device_type.charAt(0).toUpperCase() + method.device_type.slice(1)} Authentication`\n \n if (method.device_type === 'hardware') {\n // Better names for hardware keys\n fallbackName = method.device_name || 'Security Key' // Could be YubiKey, FIDO2 Key, etc.\n } else if (method.device_type === 'totp') {\n fallbackName = method.device_name || 'Authenticator App'\n } else if (method.device_type === 'email') {\n fallbackName = method.device_name || 'Email Verification'\n }\n \n return {\n id: method.device_id,\n device_type: method.device_type,\n device_name: method.device_name || fallbackName,\n is_active: true,\n created_at: new Date().toISOString(),\n last_used_at: method.last_used_at,\n // Pass through additional metadata if available\n credential_id: method.credential_id,\n device_info: method.device_info\n }\n })\n availableMfaMethods.value = methods\n \n // Set signIn loading to false immediately so MFA modal can show\n isSigningIn.value = false\n \n return authData // Return without storing full auth data\n }\n \n // Store the authentication data if MFA not required\n setAuthData(authData)\n \n return authData\n } catch (error) {\n throw error\n } finally {\n isSigningIn.value = false\n }\n }\n\n const signUp = async (userData: SignUpData) => {\n isSigningUp.value = true\n try {\n // Integration point: Replace with actual auth SDK call\n // Example: const result = await authSDK.signUp(userData)\n \n throw new Error('Sign up not implemented - please integrate with auth SDK')\n } finally {\n isSigningUp.value = false\n }\n }\n\n const signOut = async () => {\n isSigningOut.value = true\n try {\n // Stop token refresh timer\n stopTokenRefreshTimer()\n \n // Clear user and session state\n currentUser.value = null\n currentSession.value = null\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Clear stored tokens\n if (typeof window !== 'undefined') {\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } finally {\n isSigningOut.value = false\n }\n }\n\n const refreshToken = async () => {\n if (!currentSession.value?.refreshToken) {\n return false\n }\n \n \n isRefreshingToken.value = true\n try {\n const response = await fetch(getUrl('refresh'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n refresh_token: currentSession.value.refreshToken,\n }),\n })\n\n if (!response.ok) { \n if (response.status === 401) {\n // Refresh token is invalid/expired, sign out user\n await signOut()\n return false\n }\n throw new Error(`Token refresh failed: ${response.status} ${response.statusText}`)\n }\n\n const tokenData = await response.json()\n \n // For token refresh, only update tokens - don't change user data\n const newSession: Session = {\n accessToken: tokenData.access_token,\n refreshToken: tokenData.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now\n userId: currentUser.value?.id,\n }\n \n currentSession.value = newSession\n \n // Update localStorage with new session\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(newSession))\n }\n \n // Restart token refresh timer\n startTokenRefreshTimer()\n \n return true\n } catch (error) {\n // On refresh failure, sign out the user\n await signOut()\n return false\n }\n }\n\n const fetchProfile = async (): Promise<User | null> => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Failed to fetch profile: ${response.status} ${response.statusText}`)\n }\n }\n\n const userData = await response.json()\n \n // Update the current user state\n currentUser.value = {\n id: userData.id,\n email: userData.email,\n firstName: userData.first_name,\n lastName: userData.last_name,\n avatar: userData.avatar_url,\n mfaEnabled: userData.mfaEnabled || false,\n emailVerified: userData.email_verified,\n passwordUpdatedAt: userData.password_updated_at,\n settings: userData.settings || {},\n xp: userData.xp || 0,\n level: userData.level || 1,\n next_level_xp: userData.next_level_xp || 4,\n username: userData.username,\n usernameLastChangedAt: userData.username_last_changed_at,\n createdAt: userData.created_at,\n updatedAt: userData.updated_at || new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateProfile = async (profileData: Partial<User>) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('profile'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n first_name: profileData.firstName,\n last_name: profileData.lastName,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Profile update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state with API response data\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n // Update with API response data, preserving the API field names\n id: updatedUserData.id,\n email: updatedUserData.email,\n firstName: updatedUserData.first_name,\n lastName: updatedUserData.last_name,\n emailVerified: updatedUserData.email_verified,\n avatar: updatedUserData.avatar_url,\n mfaEnabled: updatedUserData.mfa_enabled,\n xp: updatedUserData.xp,\n level: updatedUserData.level,\n next_level_xp: updatedUserData.next_level_xp,\n username: updatedUserData.username, // This was missing and causing the bug!\n usernameLastChangedAt: updatedUserData.username_last_changed_at,\n createdAt: updatedUserData.created_at,\n updatedAt: updatedUserData.updated_at,\n settings: updatedUserData.settings,\n passwordUpdatedAt: updatedUserData.password_updated_at,\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const updateUserSettings = async (settings: any) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('settings'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n settings: settings,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n throw new Error(`Settings update failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const updatedUserData = await response.json()\n \n // Update the current user state\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n settings: updatedUserData.settings,\n updatedAt: updatedUserData.updated_at || new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return currentUser.value\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const changeEmail = async (newEmail: string, password: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeEmail'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n new_email: newEmail,\n password: password,\n }),\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error('Authentication expired. Please sign in again.')\n } else {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `Email change failed: ${response.status} ${response.statusText}`)\n }\n }\n\n const result = await response.json()\n \n // Update the current user state with new email\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n email: newEmail,\n emailVerified: false, // Email needs to be verified again\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const verifyMfa = async (deviceId: string, code: string, isBackupCode = false) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isVerifyingMfa.value = true\n try {\n const endpoint = isBackupCode ? getUrl('mfaBackupCodeVerify') : getUrl('mfaSigninVerify')\n const body = isBackupCode \n ? { mfa_session_id: mfaSessionId.value, backup_code: code }\n : { mfa_session_id: mfaSessionId.value, device_id: deviceId, code }\n\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'MFA verification failed'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'MFA verification failed'\n }\n \n throw new Error(errorMessage)\n }\n\n const authData: AuthResponse = await response.json()\n \n // Clear MFA state\n mfaRequired.value = false\n mfaSessionId.value = null\n availableMfaMethods.value = []\n \n // Store the authentication data\n setAuthData(authData)\n \n return authData\n } finally {\n isVerifyingMfa.value = false\n }\n }\n\n const sendMfaEmailCode = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n\n isSendingMfaEmail.value = true\n try {\n const response = await fetch(getUrl('mfaSigninSendEmail'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId,\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to send MFA email code'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n // If parsing fails, use the raw text but clean it up\n errorMessage = errorText || 'Failed to send MFA email code'\n }\n \n throw new Error(errorMessage)\n }\n\n const result = await response.json()\n return result\n } finally {\n isSendingMfaEmail.value = false\n }\n }\n\n const getMfaWebAuthnChallenge = async (deviceId: string) => {\n if (!mfaSessionId.value) {\n throw new Error('No MFA session available')\n }\n \n const response = await fetch(getUrl('mfaWebAuthnChallenge'), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n mfa_session_id: mfaSessionId.value,\n device_id: deviceId\n }),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n let errorMessage = 'Failed to get WebAuthn challenge'\n \n try {\n const errorData = JSON.parse(errorText)\n errorMessage = errorData.message || errorData.error || errorText\n } catch {\n errorMessage = errorText || errorMessage\n }\n \n throw new Error(errorMessage)\n }\n\n return response.json()\n }\n\n const setAuthData = (authResponse: AuthResponse) => {\n try {\n // Handle user data (only for sign-in/sign-up, not token refresh)\n if (authResponse.user) {\n currentUser.value = authResponse.user\n }\n \n // Create session object\n const session: Session = {\n accessToken: authResponse.access_token,\n refreshToken: authResponse.refresh_token,\n expiresAt: new Date(Date.now() + 5 * 60 * 1000), // 5 minutes from now (matching API token expiry)\n userId: currentUser.value?.id || authResponse.user?.id,\n }\n \n currentSession.value = session\n \n // Store in localStorage for persistence\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_session', JSON.stringify(session))\n if (currentUser.value) {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n // Start automatic token refresh\n startTokenRefreshTimer()\n } catch (error) {\n console.error('Error setting auth data:', error)\n // Silently handle auth data storage errors\n }\n }\n\n // Token refresh timer management\n const startTokenRefreshTimer = () => {\n // Clear existing timer\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n }\n \n if (!currentSession.value) return\n \n // Calculate time until token expires (refresh 1 minute before expiry)\n const now = new Date()\n const expiresAt = currentSession.value.expiresAt\n const timeUntilRefresh = expiresAt.getTime() - now.getTime() - (1 * 60 * 1000) // 1 minute before expiry\n \n // If token is already expired or expires very soon, refresh immediately\n if (timeUntilRefresh <= 0) {\n refreshToken()\n return\n }\n \n // Set timer to refresh token\n refreshTimer = setTimeout(async () => {\n const success = await refreshToken()\n \n if (success) {\n // Schedule next refresh\n startTokenRefreshTimer()\n }\n }, timeUntilRefresh)\n }\n\n const stopTokenRefreshTimer = () => {\n if (refreshTimer) {\n clearTimeout(refreshTimer)\n refreshTimer = null\n }\n }\n\n const initialize = async () => {\n if (isInitialized.value) return\n \n isInitializing.value = true\n try {\n // Check for existing session/token in localStorage\n if (typeof window !== 'undefined') {\n const storedSession = localStorage.getItem('strands_auth_session')\n const storedUser = localStorage.getItem('strands_auth_user')\n \n if (storedSession && storedUser) {\n try {\n const session = JSON.parse(storedSession) as Session\n const user = JSON.parse(storedUser) as User\n \n // Convert expiresAt back to Date object\n session.expiresAt = new Date(session.expiresAt)\n \n // Check if session is still valid\n if (session.expiresAt > new Date()) {\n currentSession.value = session\n currentUser.value = user\n \n // Start token refresh timer for restored session\n startTokenRefreshTimer()\n } else {\n // Session expired, clear storage\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n } catch (error) {\n // Clear corrupted data\n localStorage.removeItem('strands_auth_session')\n localStorage.removeItem('strands_auth_user')\n }\n }\n }\n \n isInitialized.value = true\n \n // Add a small delay to ensure state is fully settled before hiding loading\n await new Promise(resolve => setTimeout(resolve, 50))\n } catch (error) {\n // Silently handle initialization errors\n } finally {\n isInitializing.value = false\n }\n }\n\n const changeUsername = async (newUsername: string) => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n isLoadingProfile.value = true\n try {\n const response = await fetch(getUrl('changeUsername'), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n body: JSON.stringify({\n username: newUsername,\n }),\n })\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n if (response.status === 409) {\n throw new Error('Username is already taken')\n } else if (errorData.cooldown_end) {\n throw new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(errorData.cooldown_end).toLocaleDateString()}`)\n }\n throw new Error(errorData.message || `Username change failed: ${response.status} ${response.statusText}`)\n }\n\n const result = await response.json()\n \n // Update the current user state with new username\n if (currentUser.value) {\n currentUser.value = {\n ...currentUser.value,\n username: newUsername,\n usernameLastChangedAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n }\n \n // Update localStorage\n if (typeof window !== 'undefined') {\n localStorage.setItem('strands_auth_user', JSON.stringify(currentUser.value))\n }\n }\n \n return result\n } finally {\n isLoadingProfile.value = false\n }\n }\n\n const getUsernameCooldown = async () => {\n if (!currentSession.value?.accessToken) {\n throw new Error('No access token available')\n }\n \n const response = await fetch(getUrl('usernameCooldown'), {\n method: 'GET',\n headers: {\n 'Authorization': `Bearer ${currentSession.value.accessToken}`,\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get username cooldown: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const checkUsernameAvailability = async (username: string) => {\n // Replace {username} in the URL\n const url = getUrl('checkUsernameAvailability').replace('{username}', encodeURIComponent(username))\n \n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (!response.ok) {\n throw new Error(`Failed to check username availability: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n // Session management functions\n const getUserSessions = async () => {\n const response = await fetch(getUrl('sessions'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get user sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const getSessionStats = async () => {\n const response = await fetch(getUrl('sessionsStats'), {\n method: 'GET',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to get session stats: ${response.status} ${response.statusText}`)\n }\n\n return response.json()\n }\n\n const revokeSession = async (sessionId: string) => {\n const url = getUrl('sessionRevoke').replace('{session_id}', encodeURIComponent(sessionId))\n \n const response = await fetch(url, {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke session: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n const revokeAllOtherSessions = async () => {\n const response = await fetch(getUrl('sessionsRevokeAll'), {\n method: 'POST',\n headers: getAuthHeaders(),\n })\n\n if (!response.ok) {\n throw new Error(`Failed to revoke all other sessions: ${response.status} ${response.statusText}`)\n }\n\n return response.status === 200\n }\n\n // Auto-initialize on first use\n if (!isInitialized.value) {\n initialize()\n }\n\n return {\n // State\n user: computed(() => currentUser.value),\n currentUser: computed(() => currentUser.value),\n currentSession: computed(() => currentSession.value),\n isAuthenticated,\n isLoading: computed(() => isLoading.value || !isInitialized.value),\n loading: computed(() => loading.value),\n loadingMessage,\n \n // Specific loading states\n isInitializing,\n isSigningIn,\n isSigningUp,\n isSigningOut,\n isRefreshingToken,\n isSendingMfaEmail,\n isVerifyingMfa,\n \n // MFA State\n mfaRequired: computed(() => mfaRequired.value),\n mfaSessionId: computed(() => mfaSessionId.value),\n availableMfaMethods: computed(() => availableMfaMethods.value),\n\n // Methods\n signIn,\n signUp,\n signOut,\n refreshToken,\n fetchProfile,\n updateProfile,\n updateUserSettings,\n changeEmail,\n changeUsername,\n getUsernameCooldown,\n checkUsernameAvailability,\n // Session management\n getUserSessions,\n getSessionStats,\n revokeSession,\n revokeAllOtherSessions,\n initialize,\n setAuthData,\n verifyMfa,\n sendMfaEmailCode,\n getMfaWebAuthnChallenge,\n registerHardwareKey,\n completeHardwareKeyRegistration,\n \n // Token management\n startTokenRefreshTimer,\n stopTokenRefreshTimer,\n \n // Force re-initialization (useful for testing or navigation)\n forceReInit: () => {\n isInitialized.value = false\n isInitializing.value = true\n initialize()\n },\n }\n}"],"names":["useStrandsConfig","ref","computed"],"mappings":";;;AAIA,MAAM,EAAE,OAAA,IAAWA,kCAAA;AAEnB,MAAM,cAAcC,IAAAA,IAAiB,IAAI;AACzC,MAAM,iBAAiBA,IAA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