@strands.gg/accui 2.17.41 → 2.17.43

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/index.es.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { _ as Be, S as lt, U as Ka, a as Ga, b as Ya, c as Wa, d as kt, M as Qa, e as At, f as Gt, g as wa, u as Da, C as $a, h as Ze, i as gt, j as Na, k as mt, l as Et } from "./StrandsUIPlugin-DuI6-C0h.es.js";
2
2
  import { m as ed } from "./StrandsUIPlugin-DuI6-C0h.es.js";
3
3
  import { defineComponent as Ve, computed as D, provide as Qt, onMounted as We, onUnmounted as xt, createElementBlock as s, openBlock as a, normalizeClass as we, createElementVNode as e, createBlock as Ce, renderSlot as Oe, Teleport as Ft, createCommentVNode as I, toDisplayString as R, ref as A, watch as Le, createTextVNode as Q, reactive as Ye, withModifiers as De, createStaticVNode as Xt, createVNode as d, withDirectives as Xe, withCtx as M, unref as n, vModelText as Je, nextTick as ht, Fragment as Ne, Transition as rt, createSlots as qt, normalizeStyle as Re, renderList as Ke, mergeProps as ba, useSlots as ma, inject as pa, resolveDynamicComponent as ot, onBeforeUnmount as Ba, withKeys as Ue, h as oe, isMemoSame as Xa, getCurrentInstance as Ja } from "vue";
4
- import { u as pt, p as Ta } from "./useStrandsConfig-C9TOTAfh.es.js";
5
- import { s as ad } from "./useStrandsConfig-C9TOTAfh.es.js";
6
- import { u as ft } from "./useStrandsAuth-DoFlH5a3.es.js";
4
+ import { u as pt, p as Ta } from "./useStrandsConfig-CKLyNlSd.es.js";
5
+ import { s as ad } from "./useStrandsConfig-CKLyNlSd.es.js";
6
+ import { u as ft } from "./useStrandsAuth-DDFF_fP4.es.js";
7
7
  import { u as es } from "./useDarkMode-CvinMR9O.es.js";
8
8
  const ts = { class: "app-content" }, as = {
9
9
  key: 0,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("nuxt/app"),a=require("../../../useStrandsAuth-BGeuqkcO.cjs.js"),u=()=>{const t=e.useRuntimeConfig().public.strandsAuth,n=a.useStrandsAuth();return{...n,initialize:async()=>{await n.initialize()},signIn:async s=>{const i=await n.signIn(s);return i&&t.onSignInUrl&&await e.navigateTo(t.onSignInUrl),i},signUp:async s=>await n.signUp({email:s.email,password:"",firstName:"",lastName:""}),signOut:async()=>{await n.signOut(),t.onSignOutUrl&&await e.navigateTo(t.onSignOutUrl)}}},r=()=>{const{user:t}=u();return{user:t}},o=()=>{const{isAuthenticated:t,isLoading:n}=u();return{isAuthenticated:t,isLoading:n}};exports.useAuthState=o;exports.useAuthUser=r;exports.useStrandsAuth=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("nuxt/app"),a=require("../../../useStrandsAuth-CzzMjqan.cjs.js"),u=()=>{const t=e.useRuntimeConfig().public.strandsAuth,n=a.useStrandsAuth();return{...n,initialize:async()=>{await n.initialize()},signIn:async s=>{const i=await n.signIn(s);return i&&t.onSignInUrl&&await e.navigateTo(t.onSignInUrl),i},signUp:async s=>await n.signUp({email:s.email,password:"",firstName:"",lastName:""}),signOut:async()=>{await n.signOut(),t.onSignOutUrl&&await e.navigateTo(t.onSignOutUrl)}}},r=()=>{const{user:t}=u();return{user:t}},o=()=>{const{isAuthenticated:t,isLoading:n}=u();return{isAuthenticated:t,isLoading:n}};exports.useAuthState=o;exports.useAuthUser=r;exports.useStrandsAuth=u;
@@ -1,5 +1,5 @@
1
1
  import { useRuntimeConfig as e, navigateTo as a } from "nuxt/app";
2
- import { u as r } from "../../../useStrandsAuth-DoFlH5a3.es.js";
2
+ import { u as r } from "../../../useStrandsAuth-DDFF_fP4.es.js";
3
3
  const u = () => {
4
4
  const n = e().public.strandsAuth, t = r();
5
5
  return {
@@ -1 +1 @@
1
- "use strict";const r=require("nuxt/app"),g=r.defineNuxtRouteMiddleware(a=>{const n=r.useRuntimeConfig().public.strandsAuth;return new Promise(c=>{Promise.resolve().then(()=>require("../composables/useStrandsAuth.cjs.js")).then(({useStrandsAuth:d})=>{const{isAuthenticated:i,isLoading:h}=d(),s=()=>{if(h.value){setTimeout(s,50);return}const e=a.path,l=n.protectedRoutes?.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(t+"/")),f=n.guestOnlyRoutes?.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(t+"/"));if(l&&!i.value){const t=n.authUrl||"/auth",o=t.includes("?")?`${t}&redirect=${encodeURIComponent(e)}`:`${t}?redirect=${encodeURIComponent(e)}`;try{return r.navigateTo(o)}catch(u){if(console.warn("[Strands Auth] navigateTo failed, using window.location:",u),typeof window<"u"){window.location.href=o;return}throw u}}if(f&&i.value)return r.navigateTo(n.onSignInUrl||"/dashboard");c()};s()})})});module.exports=g;
1
+ "use strict";const r=require("nuxt/app"),g=r.defineNuxtRouteMiddleware(c=>{const n=r.useRuntimeConfig().public.strandsAuth;return new Promise(a=>{Promise.resolve().then(()=>require("../composables/useStrandsAuth.cjs.js")).then(({useStrandsAuth:d})=>{const{isAuthenticated:i,isLoading:l}=d(),o=()=>{if(l.value){setTimeout(o,50);return}const e=c.path,h=n.protectedRoutes?.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(t+"/")),f=n.guestOnlyRoutes?.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(t+"/"));if(h&&!i.value&&n.authUrl){const t=n.authUrl,s=t.includes("?")?`${t}&redirect=${encodeURIComponent(e)}`:`${t}?redirect=${encodeURIComponent(e)}`;try{return r.navigateTo(s)}catch(u){if(console.warn("[Strands Auth] navigateTo failed, using window.location:",u),typeof window<"u"){window.location.href=s;return}throw u}}if(f&&i.value&&n.onSignInUrl)return r.navigateTo(n.onSignInUrl);a()};o()})})});module.exports=g;
@@ -1,5 +1,5 @@
1
- import { defineNuxtRouteMiddleware as m, useRuntimeConfig as g, navigateTo as a } from "nuxt/app";
2
- const w = m((u) => {
1
+ import { defineNuxtRouteMiddleware as m, useRuntimeConfig as g, navigateTo as u } from "nuxt/app";
2
+ const w = m((a) => {
3
3
  const n = g().public.strandsAuth;
4
4
  if (!import.meta.server)
5
5
  return new Promise((c) => {
@@ -9,11 +9,11 @@ const w = m((u) => {
9
9
  setTimeout(i, 50);
10
10
  return;
11
11
  }
12
- const e = u.path, h = n.protectedRoutes?.some((t) => t.endsWith("*") ? e.startsWith(t.slice(0, -1)) : e === t || e.startsWith(t + "/")), f = n.guestOnlyRoutes?.some((t) => t.endsWith("*") ? e.startsWith(t.slice(0, -1)) : e === t || e.startsWith(t + "/"));
13
- if (h && !r.value) {
14
- const t = n.authUrl || "/auth", o = t.includes("?") ? `${t}&redirect=${encodeURIComponent(e)}` : `${t}?redirect=${encodeURIComponent(e)}`;
12
+ const e = a.path, h = n.protectedRoutes?.some((t) => t.endsWith("*") ? e.startsWith(t.slice(0, -1)) : e === t || e.startsWith(t + "/")), f = n.guestOnlyRoutes?.some((t) => t.endsWith("*") ? e.startsWith(t.slice(0, -1)) : e === t || e.startsWith(t + "/"));
13
+ if (h && !r.value && n.authUrl) {
14
+ const t = n.authUrl, o = t.includes("?") ? `${t}&redirect=${encodeURIComponent(e)}` : `${t}?redirect=${encodeURIComponent(e)}`;
15
15
  try {
16
- return a(o);
16
+ return u(o);
17
17
  } catch (s) {
18
18
  if (console.warn("[Strands Auth] navigateTo failed, using window.location:", s), typeof window < "u") {
19
19
  window.location.href = o;
@@ -22,8 +22,8 @@ const w = m((u) => {
22
22
  throw s;
23
23
  }
24
24
  }
25
- if (f && r.value)
26
- return a(n.onSignInUrl || "/dashboard");
25
+ if (f && r.value && n.onSignInUrl)
26
+ return u(n.onSignInUrl);
27
27
  c();
28
28
  };
29
29
  i();
@@ -1 +1 @@
1
- "use strict";const n=require("nuxt/app"),t=require("../../useStrandsConfig-x5zDprqF.cjs.js"),d=require("../../useDarkMode-Cew-NWjS.cjs.js"),c=n.defineNuxtPlugin({name:"strands-auth-client",async setup(){const o=n.useRuntimeConfig().public.strandsAuth,e={...t.STRANDS_AUTH_DEFAULTS,...o};if(t.setStrandsConfig(e),typeof window<"u"&&(window.__STRANDS_CONFIG__=e),e?.accentColor&&typeof window<"u"&&document.documentElement.style.setProperty("--strands-accent",e.accentColor),typeof window<"u"){const r=e?.theme||"system";d.useGlobalDarkMode().setTheme(r)}const{useStrandsAuth:s}=await Promise.resolve().then(()=>require("./composables/useStrandsAuth.cjs.js")),{initialize:i}=s();await i()}});module.exports=c;
1
+ "use strict";const n=require("nuxt/app"),t=require("../../useStrandsConfig-nOR0oGdb.cjs.js"),d=require("../../useDarkMode-Cew-NWjS.cjs.js"),c=n.defineNuxtPlugin({name:"strands-auth-client",async setup(){const o=n.useRuntimeConfig().public.strandsAuth,e={...t.STRANDS_AUTH_DEFAULTS,...o};if(t.setStrandsConfig(e),typeof window<"u"&&(window.__STRANDS_CONFIG__=e),e?.accentColor&&typeof window<"u"&&document.documentElement.style.setProperty("--strands-accent",e.accentColor),typeof window<"u"){const r=e?.theme||"system";d.useGlobalDarkMode().setTheme(r)}const{useStrandsAuth:s}=await Promise.resolve().then(()=>require("./composables/useStrandsAuth.cjs.js")),{initialize:i}=s();await i()}});module.exports=c;
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtPlugin as s, useRuntimeConfig as a } from "nuxt/app";
2
- import { s as d, S as c } from "../../useStrandsConfig-C9TOTAfh.es.js";
2
+ import { s as d, S as c } from "../../useStrandsConfig-CKLyNlSd.es.js";
3
3
  import { u as r } from "../../useDarkMode-CvinMR9O.es.js";
4
4
  const g = s({
5
5
  name: "strands-auth-client",
@@ -1 +1 @@
1
- "use strict";const n=require("nuxt/app"),s=require("../../useStrandsConfig-x5zDprqF.cjs.js"),r=n.defineNuxtPlugin({name:"strands-auth-server",setup(){const e=n.useRuntimeConfig().public.strandsAuth,t={...s.STRANDS_AUTH_DEFAULTS,...e};s.setStrandsConfig(t)}});module.exports=r;
1
+ "use strict";const n=require("nuxt/app"),s=require("../../useStrandsConfig-nOR0oGdb.cjs.js"),r=n.defineNuxtPlugin({name:"strands-auth-server",setup(){const e=n.useRuntimeConfig().public.strandsAuth,t={...s.STRANDS_AUTH_DEFAULTS,...e};s.setStrandsConfig(t)}});module.exports=r;
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtPlugin as t, useRuntimeConfig as e } from "nuxt/app";
2
- import { s as o, S as r } from "../../useStrandsConfig-C9TOTAfh.es.js";
2
+ import { s as o, S as r } from "../../useStrandsConfig-CKLyNlSd.es.js";
3
3
  const u = t({
4
4
  name: "strands-auth-server",
5
5
  setup() {
@@ -1,2 +1,2 @@
1
1
  import type { StrandsAuthConfig } from '../types';
2
- export declare const STRANDS_AUTH_DEFAULTS: Required<Omit<StrandsAuthConfig, 'clientId' | 'supportEmail' | 'oauth2RedirectUrl'>>;
2
+ export declare const STRANDS_AUTH_DEFAULTS: Required<Omit<StrandsAuthConfig, 'clientId' | 'supportEmail' | 'oauth2RedirectUrl' | 'onSignOutUrl' | 'onSignInUrl' | 'redirectUrl' | 'authUrl'>>;
@@ -1 +1 @@
1
- "use strict";const u=require("vue"),we=require("./useStrandsConfig-x5zDprqF.cjs.js");class ye{cache=new Map;DEFAULT_TTL=300*1e3;async fetch(d,v,g=this.DEFAULT_TTL){const b=Date.now(),s=this.cache.get(d);if(s&&b-s.timestamp<s.ttl)return s.promise;this.cleanExpired();const o=v().finally(()=>{setTimeout(()=>{this.cache.delete(d)},g)});return this.cache.set(d,{promise:o,timestamp:b,ttl:g}),o}clear(){this.cache.clear()}invalidate(d){this.cache.delete(d)}cleanExpired(){const d=Date.now();for(const[v,g]of this.cache.entries())d-g.timestamp>g.ttl&&this.cache.delete(v)}getStats(){return{size:this.cache.size,entries:Array.from(this.cache.keys())}}}const m=new ye;function pe(){return{fetch:m.fetch.bind(m),clear:m.clear.bind(m),invalidate:m.invalidate.bind(m),getStats:m.getStats.bind(m)}}function Se(n,d){let v=null;return(...g)=>{v&&clearTimeout(v),v=setTimeout(()=>{n(...g)},d)}}const F=Se((n,d)=>{typeof window<"u"&&localStorage.setItem(n,d)},300),E=n=>({id:n.id,email:n.email,firstName:n.first_name||n.firstName||"",lastName:n.last_name||n.lastName||"",avatar:n.avatar_url||n.avatar,mfaEnabled:n.mfa_enabled??n.mfaEnabled??!1,emailVerified:n.email_verified??n.emailVerified??!1,passwordUpdatedAt:n.password_updated_at||n.passwordUpdatedAt,settings:n.settings||{},xp:n.xp||0,level:n.level||1,next_level_xp:n.next_level_xp||n.next_level_xp||4,username:n.username,usernameLastChangedAt:n.username_last_changed_at||n.usernameLastChangedAt,createdAt:n.created_at||n.createdAt,updatedAt:n.updated_at||n.updatedAt||new Date().toISOString()}),_e={currentUser:u.ref(null),currentSession:u.ref(null),loadingStates:u.ref({initializing:!0,signingIn:!1,signingUp:!1,signingOut:!1,refreshingToken:!1,sendingMfaEmail:!1,verifyingMfa:!1,loadingProfile:!1}),isInitialized:u.ref(!1),mfaRequired:u.ref(!1),mfaSessionId:u.ref(null),availableMfaMethods:u.ref([])};let k=null,y=null,x=null,A=null;function Te(){const{getUrl:n,config:d}=we.useStrandsConfig(),{fetch:v,clear:g,invalidate:b}=pe(),{currentUser:s,currentSession:o,loadingStates:i,isInitialized:w,mfaRequired:p,mfaSessionId:h,availableMfaMethods:S}=_e,_=()=>{if(s.value=null,o.value=null,p.value=!1,h.value=null,S.value=[],typeof window<"u"&&(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")),I(),$(),y=null,g(),typeof window<"u"&&d.value?.onSignOutUrl){const e=window.location.pathname+window.location.search,t=d.value.onSignOutUrl;e!==t&&(window.location.href=t)}},L=u.computed(()=>i.value.initializing),U=u.computed(()=>i.value.signingIn),R=u.computed(()=>i.value.signingUp),q=u.computed(()=>i.value.signingOut),B=u.computed(()=>i.value.refreshingToken),V=u.computed(()=>i.value.sendingMfaEmail),K=u.computed(()=>i.value.verifyingMfa);u.computed(()=>i.value.loadingProfile);const j=u.computed(()=>i.value.signingIn||i.value.signingUp||i.value.signingOut||i.value.refreshingToken||i.value.sendingMfaEmail||i.value.verifyingMfa||i.value.loadingProfile),W=u.computed(()=>i.value.initializing||j.value),G=u.computed(()=>{const e=i.value;return e.initializing?"Checking authentication...":e.signingIn?"Signing you in...":e.signingUp?"Creating your account...":e.signingOut?"Signing you out...":e.refreshingToken?"Refreshing session...":e.sendingMfaEmail?"Sending verification code...":e.verifyingMfa?"Verifying code...":e.loadingProfile?"Loading profile...":"Loading..."}),O=()=>{const e={};return o.value?.accessToken&&(e.Authorization=`Bearer ${o.value.accessToken}`),o.value?.refreshToken&&(e["x-refresh-token"]=o.value.refreshToken),e},H=async(e,t,a)=>{const r=await fetch(n("mfaHardwareCompleteRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({device_id:e,credential:t})});if(!r.ok){const c=await r.text();let l="Failed to complete hardware key registration";try{const f=JSON.parse(c);l=f.message||f.error||c}catch{l=c||"Failed to complete hardware key registration"}throw new Error(l)}return r.json()},Y=async(e,t,a="hardware")=>{const r=await fetch(n("mfaHardwareStartRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({device_name:e,device_type:a})});if(!r.ok){const c=await r.text();let l="Failed to start hardware key registration";try{const f=JSON.parse(c);l=f.message||f.error||c}catch{l=c||"Failed to start hardware key registration"}throw new Error(l)}return r.json()},Q=u.computed(()=>s.value!==null),X=async e=>{i.value.signingIn=!0;try{p.value=!1,h.value=null,S.value=[];const t={"Content-Type":"application/json"};typeof window<"u"&&window.location&&(t.Origin=window.location.origin);const a=await fetch(n("signIn"),{method:"POST",headers:t,body:JSON.stringify(e)});if(!a.ok)throw a.status===401?new Error("Invalid email or password"):a.status===403?new Error("Please verify your email address before signing in"):new Error(`Sign in failed: ${a.status} ${a.statusText}`);const r=await a.json();if(r.mfa_required){p.value=!0,h.value=r.mfa_session_id||null;const c=(r.available_mfa_methods||[]).map(l=>{let f=`${l.device_type.charAt(0).toUpperCase()+l.device_type.slice(1)} Authentication`;return l.device_type==="hardware"?f=l.device_name||"Security Key":l.device_type==="totp"?f=l.device_name||"Authenticator App":l.device_type==="email"&&(f=l.device_name||"Email Verification"),{id:l.device_id,device_type:l.device_type,device_name:l.device_name||f,is_active:!0,created_at:new Date().toISOString(),last_used_at:l.last_used_at,credential_id:l.credential_id,device_info:l.device_info}});return S.value=c,i.value.signingIn=!1,r}return await C(r),r}catch(t){throw t}finally{i.value.signingIn=!1}},Z=async e=>{i.value.signingUp=!0;try{throw new Error("Sign up not implemented - please integrate with auth SDK")}finally{i.value.signingUp=!1}},ee=async()=>{i.value.signingOut=!0;try{I(),$(),y=null,g(),s.value=null,o.value=null,p.value=!1,h.value=null,S.value=[],typeof window<"u"&&(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")),typeof window<"u"&&d.value?.onSignOutUrl&&(window.location.href=d.value.onSignOutUrl)}finally{i.value.signingOut=!1}},P=async()=>{if(!o.value?.refreshToken)return!1;if(y)return await y;y=(async()=>{i.value.refreshingToken=!0;try{const t=await fetch(n("refresh"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:o.value.refreshToken})});if(!t.ok){if(t.status===401)return _(),!1;throw new Error(`Token refresh failed: ${t.status} ${t.statusText}`)}const a=await t.json();a.user&&(s.value=E(a.user),s.value&&typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value)));const r={accessToken:a.access_token,refreshToken:a.refresh_token,expiresAt:new Date(Date.now()+300*1e3),userId:a.user?.id||s.value?.id};return o.value=r,typeof window<"u"&&localStorage.setItem("strands_auth_session",JSON.stringify(r)),T(),M(),b(`sessions:${o.value.accessToken.slice(0,20)}`),!0}catch{return _(),!1}finally{i.value.refreshingToken=!1}})();const e=await y;return y=null,e},te=async()=>{const e=`profile:${o.value.accessToken.slice(0,20)}`;i.value.loadingProfile=!0;try{return await v(e,async()=>{const t=await fetch(n("profile"),{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value?.accessToken}`}});if(!t.ok)throw t.status===401?new Error("Authentication expired. Please sign in again."):new Error(`Failed to fetch profile: ${t.status} ${t.statusText}`);const a=await t.json();return s.value=E(a),s.value&&typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value)),s.value})}finally{i.value.loadingProfile=!1}},ae=async e=>{i.value.loadingProfile=!0;try{const t=await fetch(n("profile"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({first_name:e.firstName,last_name:e.lastName})});if(!t.ok)throw t.status===401?new Error("Authentication expired. Please sign in again."):new Error(`Profile update failed: ${t.status} ${t.statusText}`);const a=await t.json();return s.value=E(a),s.value&&F("strands_auth_user",JSON.stringify(s.value)),s.value}finally{i.value.loadingProfile=!1}},ne=async e=>{i.value.loadingProfile=!0;try{const t=await fetch(n("settings"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({settings:e})});if(!t.ok)throw t.status===401?new Error("Authentication expired. Please sign in again."):new Error(`Settings update failed: ${t.status} ${t.statusText}`);const a=await t.json();return s.value=E(a),s.value&&F("strands_auth_user",JSON.stringify(s.value)),s.value}finally{i.value.loadingProfile=!1}},se=async(e,t)=>{i.value.loadingProfile=!0;try{const a=await fetch(n("changeEmail"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({new_email:e,password:t})});if(!a.ok){if(a.status===401)throw new Error("Authentication expired. Please sign in again.");{const c=await a.json().catch(()=>({}));throw new Error(c.message||`Email change failed: ${a.status} ${a.statusText}`)}}const r=await a.json();return s.value&&(s.value={...s.value,email:e,emailVerified:!1,updatedAt:new Date().toISOString()},typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value))),r}finally{i.value.loadingProfile=!1}},ie=async(e,t,a=!1)=>{if(!h.value)throw new Error("No MFA session available");i.value.verifyingMfa=!0;try{const r=n(a?"mfaBackupCodeVerify":"mfaSigninVerify"),c=a?{mfa_session_id:h.value,backup_code:t}:{mfa_session_id:h.value,device_id:e,code:t},l=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!l.ok){const z=await l.text();let D="MFA verification failed";try{const J=JSON.parse(z);D=J.message||J.error||z}catch{D=z||"MFA verification failed"}throw new Error(D)}const f=await l.json();return p.value=!1,h.value=null,S.value=[],await C(f),f}finally{i.value.verifyingMfa=!1}},re=async e=>{if(!h.value)throw new Error("No MFA session available");i.value.sendingMfaEmail=!0;try{const t=await fetch(n("mfaSigninSendEmail"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:h.value,device_id:e})});if(!t.ok){const r=await t.text();let c="Failed to send MFA email code";try{const l=JSON.parse(r);c=l.message||l.error||r}catch{c=r||"Failed to send MFA email code"}throw new Error(c)}return await t.json()}finally{i.value.sendingMfaEmail=!1}},oe=async e=>{if(!h.value)throw new Error("No MFA session available");const t=await fetch(n("mfaWebAuthnChallenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:h.value,device_id:e})});if(!t.ok){const a=await t.text();let r="Failed to get WebAuthn challenge";try{const c=JSON.parse(a);r=c.message||c.error||a}catch{r=a||r}throw new Error(r)}return t.json()},C=async e=>{try{e.user&&(s.value=E(e.user));const t={accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:new Date(Date.now()+300*1e3),userId:s.value?.id||e.user?.id};o.value=t,typeof window<"u"&&(localStorage.setItem("strands_auth_session",JSON.stringify(t)),s.value&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value))),T(),M()}catch{}},T=()=>{if(k&&clearTimeout(k),!o.value||typeof document<"u"&&document.visibilityState==="hidden")return;const e=new Date,a=o.value.expiresAt.getTime()-e.getTime()-60*1e3;if(a<=0){P();return}k=setTimeout(async()=>{(typeof document>"u"||document.visibilityState==="visible")&&await P()&&T()},a)},I=()=>{k&&(clearTimeout(k),k=null)},M=()=>{x||typeof window>"u"||(x=setInterval(()=>{s.value&&o.value&&(localStorage.getItem("strands_auth_session")||($(),_()))},2e3))},$=()=>{x&&(clearInterval(x),x=null)},N=async()=>{if(console.log("[useStrandsAuth] initialize() called, isInitialized:",w.value,"hasPromise:",!!A),w.value){console.log("[useStrandsAuth] Already initialized, setting initializing=false"),i.value.initializing=!1;return}return A?(console.log("[useStrandsAuth] Waiting for existing initialization..."),A):(console.log("[useStrandsAuth] Starting new initialization..."),A=(async()=>{i.value.initializing=!0;try{if(typeof window<"u"){const e=localStorage.getItem("strands_auth_session"),t=localStorage.getItem("strands_auth_user");if(e&&t)try{const a=JSON.parse(e),r=JSON.parse(t);a.expiresAt=new Date(a.expiresAt),a.expiresAt<=new Date&&a.refreshToken?(o.value=a,s.value=r,await Promise.race([P(),new Promise(f=>setTimeout(()=>f(!1),5e3))])||_()):a.expiresAt>new Date?(o.value=a,s.value=r,T(),M()):(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"))}catch{localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")}}w.value=!0,console.log("[useStrandsAuth] isInitialized set to true, currentUser:",!!s.value),await new Promise(e=>setTimeout(e,50))}catch(e){console.error("[useStrandsAuth] initialization error:",e)}finally{console.log("[useStrandsAuth] finally - setting initializing=false"),i.value.initializing=!1,A=null}})(),A)},le=async e=>{i.value.loadingProfile=!0;try{const t=await fetch(n("changeUsername"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({username:e})});if(!t.ok){const r=await t.json().catch(()=>({}));throw t.status===409?new Error("Username is already taken"):r.cooldown_end?new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(r.cooldown_end).toLocaleDateString()}`):new Error(r.message||`Username change failed: ${t.status} ${t.statusText}`)}const a=await t.json();return s.value&&(s.value={...s.value,username:e,usernameLastChangedAt:new Date().toISOString(),updatedAt:new Date().toISOString()},typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value))),a}finally{i.value.loadingProfile=!1}},ue=async()=>{const e=await fetch(n("usernameCooldown"),{method:"GET",headers:{Authorization:`Bearer ${o.value.accessToken}`}});if(!e.ok)throw new Error(`Failed to get username cooldown: ${e.status} ${e.statusText}`);return e.json()},ce=async e=>{const t=n("checkUsernameAvailability").replace("{username}",encodeURIComponent(e)),a=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok)throw new Error(`Failed to check username availability: ${a.status} ${a.statusText}`);return a.json()},de=async()=>{const e=`sessions:${o.value?.accessToken?.slice(0,20)||"no-token"}`;try{return await v(e,async()=>{const t=O(),a=await fetch(n("sessions"),{method:"GET",headers:t});if(!a.ok)throw await a.text(),new Error(`Failed to get user sessions: ${a.status} ${a.statusText}`);return a.json()},120*1e3)}catch(t){throw t}},fe=async()=>{const e=await fetch(n("sessionsStats"),{method:"GET",headers:O()});if(!e.ok)throw new Error(`Failed to get session stats: ${e.status} ${e.statusText}`);return e.json()},he=async e=>{const t=n("sessionRevoke").replace("{session_id}",encodeURIComponent(e)),a=await fetch(t,{method:"POST",headers:O()});if(!a.ok)throw new Error(`Failed to revoke session: ${a.status} ${a.statusText}`);return a.status===200},ge=async()=>{const e=await fetch(n("sessionsRevokeAll"),{method:"POST",headers:O()});if(!e.ok)throw new Error(`Failed to revoke all other sessions: ${e.status} ${e.statusText}`);return e.status===200};typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&o.value?(T(),ve()):document.visibilityState==="hidden"&&I()}),typeof window<"u"&&window.addEventListener("storage",e=>{(e.key==="strands_auth_session"||e.key==="strands_auth_user")&&!e.newValue&&s.value&&_()});const ve=()=>{if(!(typeof window>"u")&&s.value&&o.value){const e=localStorage.getItem("strands_auth_session"),t=localStorage.getItem("strands_auth_user");(!e||!t)&&_()}},me=()=>{I(),$(),g()};try{u.getCurrentInstance()&&u.onUnmounted(me)}catch{}return w.value||N(),{user:u.computed(()=>s.value),currentUser:u.computed(()=>s.value),currentSession:u.computed(()=>o.value),isAuthenticated:Q,isLoading:u.computed(()=>W.value||!w.value),loading:j,loadingMessage:G,isInitializing:L,isInitialized:u.computed(()=>w.value),isSigningIn:U,isSigningUp:R,isSigningOut:q,isRefreshingToken:B,isSendingMfaEmail:V,isVerifyingMfa:K,mfaRequired:u.computed(()=>p.value),mfaSessionId:u.computed(()=>h.value),availableMfaMethods:u.computed(()=>S.value),signIn:X,signUp:Z,signOut:ee,refreshToken:P,fetchProfile:te,updateProfile:ae,updateUserSettings:ne,changeEmail:se,changeUsername:le,getUsernameCooldown:ue,checkUsernameAvailability:ce,getUserSessions:de,getSessionStats:fe,revokeSession:he,revokeAllOtherSessions:ge,initialize:N,setAuthData:C,verifyMfa:ie,sendMfaEmailCode:re,getMfaWebAuthnChallenge:oe,registerHardwareKey:Y,completeHardwareKeyRegistration:H,startTokenRefreshTimer:T,stopTokenRefreshTimer:I,getAuthHeaders:O,forceReInit:()=>{w.value=!1,i.value.initializing=!0,N()}}}exports.useStrandsAuth=Te;
1
+ "use strict";const u=require("vue"),we=require("./useStrandsConfig-nOR0oGdb.cjs.js");class ye{cache=new Map;DEFAULT_TTL=300*1e3;async fetch(d,v,g=this.DEFAULT_TTL){const b=Date.now(),s=this.cache.get(d);if(s&&b-s.timestamp<s.ttl)return s.promise;this.cleanExpired();const o=v().finally(()=>{setTimeout(()=>{this.cache.delete(d)},g)});return this.cache.set(d,{promise:o,timestamp:b,ttl:g}),o}clear(){this.cache.clear()}invalidate(d){this.cache.delete(d)}cleanExpired(){const d=Date.now();for(const[v,g]of this.cache.entries())d-g.timestamp>g.ttl&&this.cache.delete(v)}getStats(){return{size:this.cache.size,entries:Array.from(this.cache.keys())}}}const m=new ye;function pe(){return{fetch:m.fetch.bind(m),clear:m.clear.bind(m),invalidate:m.invalidate.bind(m),getStats:m.getStats.bind(m)}}function Se(n,d){let v=null;return(...g)=>{v&&clearTimeout(v),v=setTimeout(()=>{n(...g)},d)}}const F=Se((n,d)=>{typeof window<"u"&&localStorage.setItem(n,d)},300),E=n=>({id:n.id,email:n.email,firstName:n.first_name||n.firstName||"",lastName:n.last_name||n.lastName||"",avatar:n.avatar_url||n.avatar,mfaEnabled:n.mfa_enabled??n.mfaEnabled??!1,emailVerified:n.email_verified??n.emailVerified??!1,passwordUpdatedAt:n.password_updated_at||n.passwordUpdatedAt,settings:n.settings||{},xp:n.xp||0,level:n.level||1,next_level_xp:n.next_level_xp||n.next_level_xp||4,username:n.username,usernameLastChangedAt:n.username_last_changed_at||n.usernameLastChangedAt,createdAt:n.created_at||n.createdAt,updatedAt:n.updated_at||n.updatedAt||new Date().toISOString()}),_e={currentUser:u.ref(null),currentSession:u.ref(null),loadingStates:u.ref({initializing:!0,signingIn:!1,signingUp:!1,signingOut:!1,refreshingToken:!1,sendingMfaEmail:!1,verifyingMfa:!1,loadingProfile:!1}),isInitialized:u.ref(!1),mfaRequired:u.ref(!1),mfaSessionId:u.ref(null),availableMfaMethods:u.ref([])};let k=null,y=null,x=null,A=null;function Te(){const{getUrl:n,config:d}=we.useStrandsConfig(),{fetch:v,clear:g,invalidate:b}=pe(),{currentUser:s,currentSession:o,loadingStates:i,isInitialized:w,mfaRequired:p,mfaSessionId:h,availableMfaMethods:S}=_e,_=()=>{if(s.value=null,o.value=null,p.value=!1,h.value=null,S.value=[],typeof window<"u"&&(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")),I(),$(),y=null,g(),typeof window<"u"&&d.value?.onSignOutUrl){const e=window.location.pathname+window.location.search,t=d.value.onSignOutUrl;e!==t&&(window.location.href=t)}},L=u.computed(()=>i.value.initializing),U=u.computed(()=>i.value.signingIn),R=u.computed(()=>i.value.signingUp),q=u.computed(()=>i.value.signingOut),B=u.computed(()=>i.value.refreshingToken),V=u.computed(()=>i.value.sendingMfaEmail),K=u.computed(()=>i.value.verifyingMfa);u.computed(()=>i.value.loadingProfile);const j=u.computed(()=>i.value.signingIn||i.value.signingUp||i.value.signingOut||i.value.refreshingToken||i.value.sendingMfaEmail||i.value.verifyingMfa||i.value.loadingProfile),W=u.computed(()=>i.value.initializing||j.value),G=u.computed(()=>{const e=i.value;return e.initializing?"Checking authentication...":e.signingIn?"Signing you in...":e.signingUp?"Creating your account...":e.signingOut?"Signing you out...":e.refreshingToken?"Refreshing session...":e.sendingMfaEmail?"Sending verification code...":e.verifyingMfa?"Verifying code...":e.loadingProfile?"Loading profile...":"Loading..."}),O=()=>{const e={};return o.value?.accessToken&&(e.Authorization=`Bearer ${o.value.accessToken}`),o.value?.refreshToken&&(e["x-refresh-token"]=o.value.refreshToken),e},H=async(e,t,a)=>{const r=await fetch(n("mfaHardwareCompleteRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({device_id:e,credential:t})});if(!r.ok){const c=await r.text();let l="Failed to complete hardware key registration";try{const f=JSON.parse(c);l=f.message||f.error||c}catch{l=c||"Failed to complete hardware key registration"}throw new Error(l)}return r.json()},Y=async(e,t,a="hardware")=>{const r=await fetch(n("mfaHardwareStartRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({device_name:e,device_type:a})});if(!r.ok){const c=await r.text();let l="Failed to start hardware key registration";try{const f=JSON.parse(c);l=f.message||f.error||c}catch{l=c||"Failed to start hardware key registration"}throw new Error(l)}return r.json()},Q=u.computed(()=>s.value!==null),X=async e=>{i.value.signingIn=!0;try{p.value=!1,h.value=null,S.value=[];const t={"Content-Type":"application/json"};typeof window<"u"&&window.location&&(t.Origin=window.location.origin);const a=await fetch(n("signIn"),{method:"POST",headers:t,body:JSON.stringify(e)});if(!a.ok)throw a.status===401?new Error("Invalid email or password"):a.status===403?new Error("Please verify your email address before signing in"):new Error(`Sign in failed: ${a.status} ${a.statusText}`);const r=await a.json();if(r.mfa_required){p.value=!0,h.value=r.mfa_session_id||null;const c=(r.available_mfa_methods||[]).map(l=>{let f=`${l.device_type.charAt(0).toUpperCase()+l.device_type.slice(1)} Authentication`;return l.device_type==="hardware"?f=l.device_name||"Security Key":l.device_type==="totp"?f=l.device_name||"Authenticator App":l.device_type==="email"&&(f=l.device_name||"Email Verification"),{id:l.device_id,device_type:l.device_type,device_name:l.device_name||f,is_active:!0,created_at:new Date().toISOString(),last_used_at:l.last_used_at,credential_id:l.credential_id,device_info:l.device_info}});return S.value=c,i.value.signingIn=!1,r}return await C(r),r}catch(t){throw t}finally{i.value.signingIn=!1}},Z=async e=>{i.value.signingUp=!0;try{throw new Error("Sign up not implemented - please integrate with auth SDK")}finally{i.value.signingUp=!1}},ee=async()=>{i.value.signingOut=!0;try{I(),$(),y=null,g(),s.value=null,o.value=null,p.value=!1,h.value=null,S.value=[],typeof window<"u"&&(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")),typeof window<"u"&&d.value?.onSignOutUrl&&(window.location.href=d.value.onSignOutUrl)}finally{i.value.signingOut=!1}},P=async()=>{if(!o.value?.refreshToken)return!1;if(y)return await y;y=(async()=>{i.value.refreshingToken=!0;try{const t=await fetch(n("refresh"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:o.value.refreshToken})});if(!t.ok){if(t.status===401)return _(),!1;throw new Error(`Token refresh failed: ${t.status} ${t.statusText}`)}const a=await t.json();a.user&&(s.value=E(a.user),s.value&&typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value)));const r={accessToken:a.access_token,refreshToken:a.refresh_token,expiresAt:new Date(Date.now()+300*1e3),userId:a.user?.id||s.value?.id};return o.value=r,typeof window<"u"&&localStorage.setItem("strands_auth_session",JSON.stringify(r)),T(),M(),b(`sessions:${o.value.accessToken.slice(0,20)}`),!0}catch{return _(),!1}finally{i.value.refreshingToken=!1}})();const e=await y;return y=null,e},te=async()=>{const e=`profile:${o.value.accessToken.slice(0,20)}`;i.value.loadingProfile=!0;try{return await v(e,async()=>{const t=await fetch(n("profile"),{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value?.accessToken}`}});if(!t.ok)throw t.status===401?new Error("Authentication expired. Please sign in again."):new Error(`Failed to fetch profile: ${t.status} ${t.statusText}`);const a=await t.json();return s.value=E(a),s.value&&typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value)),s.value})}finally{i.value.loadingProfile=!1}},ae=async e=>{i.value.loadingProfile=!0;try{const t=await fetch(n("profile"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({first_name:e.firstName,last_name:e.lastName})});if(!t.ok)throw t.status===401?new Error("Authentication expired. Please sign in again."):new Error(`Profile update failed: ${t.status} ${t.statusText}`);const a=await t.json();return s.value=E(a),s.value&&F("strands_auth_user",JSON.stringify(s.value)),s.value}finally{i.value.loadingProfile=!1}},ne=async e=>{i.value.loadingProfile=!0;try{const t=await fetch(n("settings"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({settings:e})});if(!t.ok)throw t.status===401?new Error("Authentication expired. Please sign in again."):new Error(`Settings update failed: ${t.status} ${t.statusText}`);const a=await t.json();return s.value=E(a),s.value&&F("strands_auth_user",JSON.stringify(s.value)),s.value}finally{i.value.loadingProfile=!1}},se=async(e,t)=>{i.value.loadingProfile=!0;try{const a=await fetch(n("changeEmail"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({new_email:e,password:t})});if(!a.ok){if(a.status===401)throw new Error("Authentication expired. Please sign in again.");{const c=await a.json().catch(()=>({}));throw new Error(c.message||`Email change failed: ${a.status} ${a.statusText}`)}}const r=await a.json();return s.value&&(s.value={...s.value,email:e,emailVerified:!1,updatedAt:new Date().toISOString()},typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value))),r}finally{i.value.loadingProfile=!1}},ie=async(e,t,a=!1)=>{if(!h.value)throw new Error("No MFA session available");i.value.verifyingMfa=!0;try{const r=n(a?"mfaBackupCodeVerify":"mfaSigninVerify"),c=a?{mfa_session_id:h.value,backup_code:t}:{mfa_session_id:h.value,device_id:e,code:t},l=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!l.ok){const z=await l.text();let D="MFA verification failed";try{const J=JSON.parse(z);D=J.message||J.error||z}catch{D=z||"MFA verification failed"}throw new Error(D)}const f=await l.json();return p.value=!1,h.value=null,S.value=[],await C(f),f}finally{i.value.verifyingMfa=!1}},re=async e=>{if(!h.value)throw new Error("No MFA session available");i.value.sendingMfaEmail=!0;try{const t=await fetch(n("mfaSigninSendEmail"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:h.value,device_id:e})});if(!t.ok){const r=await t.text();let c="Failed to send MFA email code";try{const l=JSON.parse(r);c=l.message||l.error||r}catch{c=r||"Failed to send MFA email code"}throw new Error(c)}return await t.json()}finally{i.value.sendingMfaEmail=!1}},oe=async e=>{if(!h.value)throw new Error("No MFA session available");const t=await fetch(n("mfaWebAuthnChallenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:h.value,device_id:e})});if(!t.ok){const a=await t.text();let r="Failed to get WebAuthn challenge";try{const c=JSON.parse(a);r=c.message||c.error||a}catch{r=a||r}throw new Error(r)}return t.json()},C=async e=>{try{e.user&&(s.value=E(e.user));const t={accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:new Date(Date.now()+300*1e3),userId:s.value?.id||e.user?.id};o.value=t,typeof window<"u"&&(localStorage.setItem("strands_auth_session",JSON.stringify(t)),s.value&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value))),T(),M()}catch{}},T=()=>{if(k&&clearTimeout(k),!o.value||typeof document<"u"&&document.visibilityState==="hidden")return;const e=new Date,a=o.value.expiresAt.getTime()-e.getTime()-60*1e3;if(a<=0){P();return}k=setTimeout(async()=>{(typeof document>"u"||document.visibilityState==="visible")&&await P()&&T()},a)},I=()=>{k&&(clearTimeout(k),k=null)},M=()=>{x||typeof window>"u"||(x=setInterval(()=>{s.value&&o.value&&(localStorage.getItem("strands_auth_session")||($(),_()))},2e3))},$=()=>{x&&(clearInterval(x),x=null)},N=async()=>{if(console.log("[useStrandsAuth] initialize() called, isInitialized:",w.value,"hasPromise:",!!A),w.value){console.log("[useStrandsAuth] Already initialized, setting initializing=false"),i.value.initializing=!1;return}return A?(console.log("[useStrandsAuth] Waiting for existing initialization..."),A):(console.log("[useStrandsAuth] Starting new initialization..."),A=(async()=>{i.value.initializing=!0;try{if(typeof window<"u"){const e=localStorage.getItem("strands_auth_session"),t=localStorage.getItem("strands_auth_user");if(e&&t)try{const a=JSON.parse(e),r=JSON.parse(t);a.expiresAt=new Date(a.expiresAt),a.expiresAt<=new Date&&a.refreshToken?(o.value=a,s.value=r,await Promise.race([P(),new Promise(f=>setTimeout(()=>f(!1),5e3))])||_()):a.expiresAt>new Date?(o.value=a,s.value=r,T(),M()):(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"))}catch{localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")}}w.value=!0,console.log("[useStrandsAuth] isInitialized set to true, currentUser:",!!s.value),await new Promise(e=>setTimeout(e,50))}catch(e){console.error("[useStrandsAuth] initialization error:",e)}finally{console.log("[useStrandsAuth] finally - setting initializing=false"),i.value.initializing=!1,A=null}})(),A)},le=async e=>{i.value.loadingProfile=!0;try{const t=await fetch(n("changeUsername"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value.accessToken}`},body:JSON.stringify({username:e})});if(!t.ok){const r=await t.json().catch(()=>({}));throw t.status===409?new Error("Username is already taken"):r.cooldown_end?new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(r.cooldown_end).toLocaleDateString()}`):new Error(r.message||`Username change failed: ${t.status} ${t.statusText}`)}const a=await t.json();return s.value&&(s.value={...s.value,username:e,usernameLastChangedAt:new Date().toISOString(),updatedAt:new Date().toISOString()},typeof window<"u"&&localStorage.setItem("strands_auth_user",JSON.stringify(s.value))),a}finally{i.value.loadingProfile=!1}},ue=async()=>{const e=await fetch(n("usernameCooldown"),{method:"GET",headers:{Authorization:`Bearer ${o.value.accessToken}`}});if(!e.ok)throw new Error(`Failed to get username cooldown: ${e.status} ${e.statusText}`);return e.json()},ce=async e=>{const t=n("checkUsernameAvailability").replace("{username}",encodeURIComponent(e)),a=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok)throw new Error(`Failed to check username availability: ${a.status} ${a.statusText}`);return a.json()},de=async()=>{const e=`sessions:${o.value?.accessToken?.slice(0,20)||"no-token"}`;try{return await v(e,async()=>{const t=O(),a=await fetch(n("sessions"),{method:"GET",headers:t});if(!a.ok)throw await a.text(),new Error(`Failed to get user sessions: ${a.status} ${a.statusText}`);return a.json()},120*1e3)}catch(t){throw t}},fe=async()=>{const e=await fetch(n("sessionsStats"),{method:"GET",headers:O()});if(!e.ok)throw new Error(`Failed to get session stats: ${e.status} ${e.statusText}`);return e.json()},he=async e=>{const t=n("sessionRevoke").replace("{session_id}",encodeURIComponent(e)),a=await fetch(t,{method:"POST",headers:O()});if(!a.ok)throw new Error(`Failed to revoke session: ${a.status} ${a.statusText}`);return a.status===200},ge=async()=>{const e=await fetch(n("sessionsRevokeAll"),{method:"POST",headers:O()});if(!e.ok)throw new Error(`Failed to revoke all other sessions: ${e.status} ${e.statusText}`);return e.status===200};typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&o.value?(T(),ve()):document.visibilityState==="hidden"&&I()}),typeof window<"u"&&window.addEventListener("storage",e=>{(e.key==="strands_auth_session"||e.key==="strands_auth_user")&&!e.newValue&&s.value&&_()});const ve=()=>{if(!(typeof window>"u")&&s.value&&o.value){const e=localStorage.getItem("strands_auth_session"),t=localStorage.getItem("strands_auth_user");(!e||!t)&&_()}},me=()=>{I(),$(),g()};try{u.getCurrentInstance()&&u.onUnmounted(me)}catch{}return w.value||N(),{user:u.computed(()=>s.value),currentUser:u.computed(()=>s.value),currentSession:u.computed(()=>o.value),isAuthenticated:Q,isLoading:u.computed(()=>W.value||!w.value),loading:j,loadingMessage:G,isInitializing:L,isInitialized:u.computed(()=>w.value),isSigningIn:U,isSigningUp:R,isSigningOut:q,isRefreshingToken:B,isSendingMfaEmail:V,isVerifyingMfa:K,mfaRequired:u.computed(()=>p.value),mfaSessionId:u.computed(()=>h.value),availableMfaMethods:u.computed(()=>S.value),signIn:X,signUp:Z,signOut:ee,refreshToken:P,fetchProfile:te,updateProfile:ae,updateUserSettings:ne,changeEmail:se,changeUsername:le,getUsernameCooldown:ue,checkUsernameAvailability:ce,getUserSessions:de,getSessionStats:fe,revokeSession:he,revokeAllOtherSessions:ge,initialize:N,setAuthData:C,verifyMfa:ie,sendMfaEmailCode:re,getMfaWebAuthnChallenge:oe,registerHardwareKey:Y,completeHardwareKeyRegistration:H,startTokenRefreshTimer:T,stopTokenRefreshTimer:I,getAuthHeaders:O,forceReInit:()=>{w.value=!1,i.value.initializing=!0,N()}}}exports.useStrandsAuth=Te;
@@ -1,5 +1,5 @@
1
1
  import { computed as c, ref as y, getCurrentInstance as ye, onUnmounted as pe } from "vue";
2
- import { u as Se } from "./useStrandsConfig-C9TOTAfh.es.js";
2
+ import { u as Se } from "./useStrandsConfig-CKLyNlSd.es.js";
3
3
  class _e {
4
4
  cache = /* @__PURE__ */ new Map();
5
5
  DEFAULT_TTL = 300 * 1e3;
@@ -2,10 +2,6 @@ import { ref as g, getCurrentInstance as h, inject as S, computed as f, provide
2
2
  const d = {
3
3
  baseUrl: "https://your-api.example.com",
4
4
  accentColor: "#EA00A8",
5
- redirectUrl: "/",
6
- onSignInUrl: "/dashboard",
7
- onSignOutUrl: "/",
8
- authUrl: "/auth",
9
5
  autoRefresh: !0,
10
6
  refreshInterval: 4,
11
7
  protectedRoutes: [],
@@ -196,7 +192,7 @@ function E(s) {
196
192
  document.documentElement.style.setProperty("--strands-allow-squircle", t ? "1" : "0"), s.accentColor && v(s.accentColor);
197
193
  }
198
194
  }
199
- const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
195
+ const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
200
196
  __proto__: null,
201
197
  provideStrandsConfig: w,
202
198
  setStrandsConfig: E,
@@ -204,7 +200,7 @@ const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
204
200
  }, Symbol.toStringTag, { value: "Module" }));
205
201
  export {
206
202
  d as S,
207
- k as a,
203
+ A as a,
208
204
  w as p,
209
205
  E as s,
210
206
  b as u
@@ -0,0 +1 @@
1
+ "use strict";const u=require("vue"),c={baseUrl:"https://your-api.example.com",accentColor:"#EA00A8",autoRefresh:!0,refreshInterval:4,protectedRoutes:[],guestOnlyRoutes:["/auth","/login","/register"],devMode:!1,styles:!0,endpoints:{},useSquircle:!0,theme:"system"},a={signIn:"/api/v1/auth/sign-in",signUp:"/api/v1/auth/sign-up",signOut:"/api/v1/auth/sign-out",refresh:"/api/v1/auth/refresh",passwordReset:"/api/v1/auth/password-reset",passwordResetConfirm:"/api/v1/auth/password-reset/confirm",completeRegistration:"/api/v1/auth/complete-registration",profile:"/api/v1/user/profile",verifyEmail:"/api/v1/auth/verify-email",oauthProviders:"/api/v1/oauth/providers",oauthProvider:"/api/v1/oauth/providers/{provider_id}",changeEmail:"/api/v1/user/change-email",avatar:"/api/v1/user/avatar",settings:"/api/v1/user/settings",changeUsername:"/api/v1/user/username",usernameCooldown:"/api/v1/user/username/cooldown",checkUsernameAvailability:"/api/v1/username/{username}/available",mfaDevices:"/api/v1/mfa/devices",mfaTotpSetup:"/api/v1/mfa/totp/setup",mfaTotpVerify:"/api/v1/mfa/totp/verify",mfaEmailSetup:"/api/v1/mfa/email/setup",mfaEmailSend:"/api/v1/mfa/email/send",mfaEmailVerify:"/api/v1/mfa/email/verify",mfaDeviceDisable:"/api/v1/mfa/device/disable",mfaBackupCodes:"/api/v1/mfa/backup-codes/regenerate",mfaHardwareStartRegistration:"/api/v1/mfa/hardware/start-registration",mfaHardwareCompleteRegistration:"/api/v1/mfa/hardware/complete-registration",mfaSigninSendEmail:"/api/v1/auth/mfa/email/send",mfaSigninVerify:"/api/v1/auth/mfa/verify",mfaBackupCodeVerify:"/api/v1/auth/mfa/backup-code/verify",mfaWebAuthnChallenge:"/api/v1/auth/mfa/webauthn/challenge",sessions:"/api/v1/sessions",sessionsStats:"/api/v1/sessions/stats",sessionRevoke:"/api/v1/sessions/{session_id}/revoke",sessionsRevokeAll:"/api/v1/sessions/revoke-all"},p=Symbol("strands-config"),m=u.ref(null);function v(s){if(typeof window>"u"||!document.documentElement)return;if(typeof CSS<"u"&&CSS.registerProperty)try{CSS.registerProperty({name:"--strands-accent",syntax:"<color>",inherits:!0,initialValue:s})}catch{}document.documentElement.style.setProperty("--strands-accent",s),document.documentElement.style.setProperty("--accui-strands-accent",s);const t={"--accui-strands-50":`color-mix(in srgb, ${s} 10%, white)`,"--accui-strands-100":`color-mix(in srgb, ${s} 20%, white)`,"--accui-strands-200":`color-mix(in srgb, ${s} 30%, white)`,"--accui-strands-300":`color-mix(in srgb, ${s} 40%, white)`,"--accui-strands-400":`color-mix(in srgb, ${s} 70%, white)`,"--accui-strands-500":s,"--accui-strands-600":`color-mix(in srgb, ${s} 85%, black)`,"--accui-strands-700":`color-mix(in srgb, ${s} 70%, black)`,"--accui-strands-800":`color-mix(in srgb, ${s} 55%, black)`,"--accui-strands-900":`color-mix(in srgb, ${s} 40%, black)`,"--accui-strands-950":`color-mix(in srgb, ${s} 25%, black)`};for(const[r,n]of Object.entries(t))document.documentElement.style.setProperty(r,n)}function g(s){if(m.value=s,typeof window<"u"&&document.documentElement){const t=s.useSquircle!==void 0?s.useSquircle:!0;document.documentElement.style.setProperty("--strands-allow-squircle",t?"1":"0"),s.accentColor&&v(s.accentColor)}try{u.provide(p,s)}catch(t){console.warn("[Strands Auth] Could not provide config via Vue provide/inject. Config available via global state only.",t)}}function h(s){let t=null;try{u.getCurrentInstance()&&(t=u.inject(p,null))}catch{t=null}let r=null;try{if(typeof window<"u"){if(window.__STRANDS_CONFIG__)r=window.__STRANDS_CONFIG__;else if(window.__NUXT__){const i=window.__NUXT__;r=i?.config?.public?.strandsAuth||i?.public?.strandsAuth||i?.strandsAuth}}}catch(i){console.error("[Strands Auth] Error accessing runtime configuration:",i)}const n=u.computed(()=>{const i={...c,...s||{},...t||{},...m.value||{},...r||{}};if(i.baseUrl===c.baseUrl&&typeof window>"u"&&console.warn("[Strands Auth] No baseUrl configured for SSR. Please provide a baseUrl in your strandsAuth configuration."),typeof window<"u"&&document.documentElement){const e=i.useSquircle!==void 0?i.useSquircle:!0;document.documentElement.style.setProperty("--strands-allow-squircle",e?"1":"0"),i.accentColor&&document.documentElement.style.setProperty("--strands-accent",i.accentColor)}return i}),l=u.computed(()=>{const e=n.value.endpoints||{};return{signIn:e.signIn||a.signIn,signUp:e.signUp||a.signUp,signOut:e.signOut||a.signOut,refresh:e.refresh||a.refresh,passwordReset:e.passwordReset||a.passwordReset,passwordResetConfirm:e.passwordResetConfirm||a.passwordResetConfirm,completeRegistration:e.completeRegistration||a.completeRegistration,profile:e.profile||a.profile,verifyEmail:e.verifyEmail||a.verifyEmail,oauthProviders:e.oauthProviders||a.oauthProviders,oauthProvider:e.oauthProvider||a.oauthProvider,changeEmail:e.changeEmail||a.changeEmail,avatar:e.avatar||a.avatar,settings:e.settings||a.settings,changeUsername:e.changeUsername||a.changeUsername,usernameCooldown:e.usernameCooldown||a.usernameCooldown,checkUsernameAvailability:e.checkUsernameAvailability||a.checkUsernameAvailability,mfaDevices:e.mfaDevices||a.mfaDevices,mfaTotpSetup:e.mfaTotpSetup||a.mfaTotpSetup,mfaTotpVerify:e.mfaTotpVerify||a.mfaTotpVerify,mfaEmailSetup:e.mfaEmailSetup||a.mfaEmailSetup,mfaEmailSend:e.mfaEmailSend||a.mfaEmailSend,mfaEmailVerify:e.mfaEmailVerify||a.mfaEmailVerify,mfaDeviceDisable:e.mfaDeviceDisable||a.mfaDeviceDisable,mfaBackupCodes:e.mfaBackupCodes||a.mfaBackupCodes,mfaHardwareStartRegistration:e.mfaHardwareStartRegistration||a.mfaHardwareStartRegistration,mfaHardwareCompleteRegistration:e.mfaHardwareCompleteRegistration||a.mfaHardwareCompleteRegistration,mfaSigninSendEmail:e.mfaSigninSendEmail||a.mfaSigninSendEmail,mfaSigninVerify:e.mfaSigninVerify||a.mfaSigninVerify,mfaBackupCodeVerify:e.mfaBackupCodeVerify||a.mfaBackupCodeVerify,mfaWebAuthnChallenge:e.mfaWebAuthnChallenge||a.mfaWebAuthnChallenge,sessions:e.sessions||a.sessions,sessionsStats:e.sessionsStats||a.sessionsStats,sessionRevoke:e.sessionRevoke||a.sessionRevoke,sessionsRevokeAll:e.sessionsRevokeAll||a.sessionsRevokeAll}});return{config:n,endpoints:l,getUrl:i=>{const e=n.value;if(!e.baseUrl)throw new Error("Base URL is required in configuration");let o;typeof i=="string"&&i in l.value?o=l.value[i]:typeof i=="string"?o=i:o=l.value[i];const f=e.baseUrl.replace(/\/$/,""),d=o.startsWith("/")?o:`/${o}`;return console.debug(`[Strands Auth] Constructing URL for endpoint "${i}": ${f}${d}`),`${f}${d}`},getSupportEmail:()=>n.value.supportEmail||null}}function S(s){if(m.value=s,typeof window<"u"&&document.documentElement){const t=s.useSquircle!==void 0?s.useSquircle:!0;document.documentElement.style.setProperty("--strands-allow-squircle",t?"1":"0"),s.accentColor&&v(s.accentColor)}}const y=Object.freeze(Object.defineProperty({__proto__:null,provideStrandsConfig:g,setStrandsConfig:S,useStrandsConfig:h},Symbol.toStringTag,{value:"Module"}));exports.STRANDS_AUTH_DEFAULTS=c;exports.provideStrandsConfig=g;exports.setStrandsConfig=S;exports.useStrandsConfig=h;exports.useStrandsConfig$1=y;
package/dist/vite.cjs.js CHANGED
@@ -26,4 +26,4 @@ if (typeof window !== 'undefined') {
26
26
  window.__STRANDS_INJECTED__ = true
27
27
  }
28
28
  `}
29
- ${s}`,map:null}:null}}}function d(i={}){return{install(a){Promise.resolve().then(()=>require("./StrandsUIPlugin-D6qvy6mu.cjs.js")).then(n=>n.StrandsUIPlugin$1).then(n=>{const r=n.default;a.use(r)}),Promise.resolve().then(()=>require("./useStrandsConfig-x5zDprqF.cjs.js")).then(n=>n.useStrandsConfig$1).then(n=>{const{setStrandsConfig:r}=n;r(i),typeof window<"u"&&(window.__STRANDS_CONFIG__=i)})}}}exports.StrandsAuth=e;exports.StrandsAuthVitePlugin=e;exports.createStrandsAuth=d;exports.default=e;exports.strandsAuth=e;
29
+ ${s}`,map:null}:null}}}function d(i={}){return{install(a){Promise.resolve().then(()=>require("./StrandsUIPlugin-D6qvy6mu.cjs.js")).then(n=>n.StrandsUIPlugin$1).then(n=>{const r=n.default;a.use(r)}),Promise.resolve().then(()=>require("./useStrandsConfig-nOR0oGdb.cjs.js")).then(n=>n.useStrandsConfig$1).then(n=>{const{setStrandsConfig:r}=n;r(i),typeof window<"u"&&(window.__STRANDS_CONFIG__=i)})}}}exports.StrandsAuth=e;exports.StrandsAuthVitePlugin=e;exports.createStrandsAuth=d;exports.default=e;exports.strandsAuth=e;
package/dist/vite.es.js CHANGED
@@ -76,7 +76,7 @@ function d(r = {}) {
76
76
  import("./StrandsUIPlugin-DuI6-C0h.es.js").then((n) => n.n).then((n) => {
77
77
  const i = n.default;
78
78
  a.use(i);
79
- }), import("./useStrandsConfig-C9TOTAfh.es.js").then((n) => n.a).then((n) => {
79
+ }), import("./useStrandsConfig-CKLyNlSd.es.js").then((n) => n.a).then((n) => {
80
80
  const { setStrandsConfig: i } = n;
81
81
  i(r), typeof window < "u" && (window.__STRANDS_CONFIG__ = r);
82
82
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strands.gg/accui",
3
- "version": "2.17.41",
3
+ "version": "2.17.43",
4
4
  "description": "Strands Authentication UI Components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
@@ -1 +0,0 @@
1
- "use strict";const u=require("vue"),c={baseUrl:"https://your-api.example.com",accentColor:"#EA00A8",redirectUrl:"/",onSignInUrl:"/dashboard",onSignOutUrl:"/",authUrl:"/auth",autoRefresh:!0,refreshInterval:4,protectedRoutes:[],guestOnlyRoutes:["/auth","/login","/register"],devMode:!1,styles:!0,endpoints:{},useSquircle:!0,theme:"system"},a={signIn:"/api/v1/auth/sign-in",signUp:"/api/v1/auth/sign-up",signOut:"/api/v1/auth/sign-out",refresh:"/api/v1/auth/refresh",passwordReset:"/api/v1/auth/password-reset",passwordResetConfirm:"/api/v1/auth/password-reset/confirm",completeRegistration:"/api/v1/auth/complete-registration",profile:"/api/v1/user/profile",verifyEmail:"/api/v1/auth/verify-email",oauthProviders:"/api/v1/oauth/providers",oauthProvider:"/api/v1/oauth/providers/{provider_id}",changeEmail:"/api/v1/user/change-email",avatar:"/api/v1/user/avatar",settings:"/api/v1/user/settings",changeUsername:"/api/v1/user/username",usernameCooldown:"/api/v1/user/username/cooldown",checkUsernameAvailability:"/api/v1/username/{username}/available",mfaDevices:"/api/v1/mfa/devices",mfaTotpSetup:"/api/v1/mfa/totp/setup",mfaTotpVerify:"/api/v1/mfa/totp/verify",mfaEmailSetup:"/api/v1/mfa/email/setup",mfaEmailSend:"/api/v1/mfa/email/send",mfaEmailVerify:"/api/v1/mfa/email/verify",mfaDeviceDisable:"/api/v1/mfa/device/disable",mfaBackupCodes:"/api/v1/mfa/backup-codes/regenerate",mfaHardwareStartRegistration:"/api/v1/mfa/hardware/start-registration",mfaHardwareCompleteRegistration:"/api/v1/mfa/hardware/complete-registration",mfaSigninSendEmail:"/api/v1/auth/mfa/email/send",mfaSigninVerify:"/api/v1/auth/mfa/verify",mfaBackupCodeVerify:"/api/v1/auth/mfa/backup-code/verify",mfaWebAuthnChallenge:"/api/v1/auth/mfa/webauthn/challenge",sessions:"/api/v1/sessions",sessionsStats:"/api/v1/sessions/stats",sessionRevoke:"/api/v1/sessions/{session_id}/revoke",sessionsRevokeAll:"/api/v1/sessions/revoke-all"},p=Symbol("strands-config"),m=u.ref(null);function v(s){if(typeof window>"u"||!document.documentElement)return;if(typeof CSS<"u"&&CSS.registerProperty)try{CSS.registerProperty({name:"--strands-accent",syntax:"<color>",inherits:!0,initialValue:s})}catch{}document.documentElement.style.setProperty("--strands-accent",s),document.documentElement.style.setProperty("--accui-strands-accent",s);const t={"--accui-strands-50":`color-mix(in srgb, ${s} 10%, white)`,"--accui-strands-100":`color-mix(in srgb, ${s} 20%, white)`,"--accui-strands-200":`color-mix(in srgb, ${s} 30%, white)`,"--accui-strands-300":`color-mix(in srgb, ${s} 40%, white)`,"--accui-strands-400":`color-mix(in srgb, ${s} 70%, white)`,"--accui-strands-500":s,"--accui-strands-600":`color-mix(in srgb, ${s} 85%, black)`,"--accui-strands-700":`color-mix(in srgb, ${s} 70%, black)`,"--accui-strands-800":`color-mix(in srgb, ${s} 55%, black)`,"--accui-strands-900":`color-mix(in srgb, ${s} 40%, black)`,"--accui-strands-950":`color-mix(in srgb, ${s} 25%, black)`};for(const[r,n]of Object.entries(t))document.documentElement.style.setProperty(r,n)}function g(s){if(m.value=s,typeof window<"u"&&document.documentElement){const t=s.useSquircle!==void 0?s.useSquircle:!0;document.documentElement.style.setProperty("--strands-allow-squircle",t?"1":"0"),s.accentColor&&v(s.accentColor)}try{u.provide(p,s)}catch(t){console.warn("[Strands Auth] Could not provide config via Vue provide/inject. Config available via global state only.",t)}}function h(s){let t=null;try{u.getCurrentInstance()&&(t=u.inject(p,null))}catch{t=null}let r=null;try{if(typeof window<"u"){if(window.__STRANDS_CONFIG__)r=window.__STRANDS_CONFIG__;else if(window.__NUXT__){const i=window.__NUXT__;r=i?.config?.public?.strandsAuth||i?.public?.strandsAuth||i?.strandsAuth}}}catch(i){console.error("[Strands Auth] Error accessing runtime configuration:",i)}const n=u.computed(()=>{const i={...c,...s||{},...t||{},...m.value||{},...r||{}};if(i.baseUrl===c.baseUrl&&typeof window>"u"&&console.warn("[Strands Auth] No baseUrl configured for SSR. Please provide a baseUrl in your strandsAuth configuration."),typeof window<"u"&&document.documentElement){const e=i.useSquircle!==void 0?i.useSquircle:!0;document.documentElement.style.setProperty("--strands-allow-squircle",e?"1":"0"),i.accentColor&&document.documentElement.style.setProperty("--strands-accent",i.accentColor)}return i}),l=u.computed(()=>{const e=n.value.endpoints||{};return{signIn:e.signIn||a.signIn,signUp:e.signUp||a.signUp,signOut:e.signOut||a.signOut,refresh:e.refresh||a.refresh,passwordReset:e.passwordReset||a.passwordReset,passwordResetConfirm:e.passwordResetConfirm||a.passwordResetConfirm,completeRegistration:e.completeRegistration||a.completeRegistration,profile:e.profile||a.profile,verifyEmail:e.verifyEmail||a.verifyEmail,oauthProviders:e.oauthProviders||a.oauthProviders,oauthProvider:e.oauthProvider||a.oauthProvider,changeEmail:e.changeEmail||a.changeEmail,avatar:e.avatar||a.avatar,settings:e.settings||a.settings,changeUsername:e.changeUsername||a.changeUsername,usernameCooldown:e.usernameCooldown||a.usernameCooldown,checkUsernameAvailability:e.checkUsernameAvailability||a.checkUsernameAvailability,mfaDevices:e.mfaDevices||a.mfaDevices,mfaTotpSetup:e.mfaTotpSetup||a.mfaTotpSetup,mfaTotpVerify:e.mfaTotpVerify||a.mfaTotpVerify,mfaEmailSetup:e.mfaEmailSetup||a.mfaEmailSetup,mfaEmailSend:e.mfaEmailSend||a.mfaEmailSend,mfaEmailVerify:e.mfaEmailVerify||a.mfaEmailVerify,mfaDeviceDisable:e.mfaDeviceDisable||a.mfaDeviceDisable,mfaBackupCodes:e.mfaBackupCodes||a.mfaBackupCodes,mfaHardwareStartRegistration:e.mfaHardwareStartRegistration||a.mfaHardwareStartRegistration,mfaHardwareCompleteRegistration:e.mfaHardwareCompleteRegistration||a.mfaHardwareCompleteRegistration,mfaSigninSendEmail:e.mfaSigninSendEmail||a.mfaSigninSendEmail,mfaSigninVerify:e.mfaSigninVerify||a.mfaSigninVerify,mfaBackupCodeVerify:e.mfaBackupCodeVerify||a.mfaBackupCodeVerify,mfaWebAuthnChallenge:e.mfaWebAuthnChallenge||a.mfaWebAuthnChallenge,sessions:e.sessions||a.sessions,sessionsStats:e.sessionsStats||a.sessionsStats,sessionRevoke:e.sessionRevoke||a.sessionRevoke,sessionsRevokeAll:e.sessionsRevokeAll||a.sessionsRevokeAll}});return{config:n,endpoints:l,getUrl:i=>{const e=n.value;if(!e.baseUrl)throw new Error("Base URL is required in configuration");let o;typeof i=="string"&&i in l.value?o=l.value[i]:typeof i=="string"?o=i:o=l.value[i];const f=e.baseUrl.replace(/\/$/,""),d=o.startsWith("/")?o:`/${o}`;return console.debug(`[Strands Auth] Constructing URL for endpoint "${i}": ${f}${d}`),`${f}${d}`},getSupportEmail:()=>n.value.supportEmail||null}}function S(s){if(m.value=s,typeof window<"u"&&document.documentElement){const t=s.useSquircle!==void 0?s.useSquircle:!0;document.documentElement.style.setProperty("--strands-allow-squircle",t?"1":"0"),s.accentColor&&v(s.accentColor)}}const y=Object.freeze(Object.defineProperty({__proto__:null,provideStrandsConfig:g,setStrandsConfig:S,useStrandsConfig:h},Symbol.toStringTag,{value:"Module"}));exports.STRANDS_AUTH_DEFAULTS=c;exports.provideStrandsConfig=g;exports.setStrandsConfig=S;exports.useStrandsConfig=h;exports.useStrandsConfig$1=y;