@strands.gg/accui 2.15.16 → 2.17.9

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.
Files changed (35) hide show
  1. package/dist/StrandsUIPlugin-Bwc7jBcb.cjs.js +143 -0
  2. package/dist/StrandsUIPlugin-RTFzvRED.es.js +20536 -0
  3. package/dist/accui.css +1 -1
  4. package/dist/index.cjs.js +5 -1
  5. package/dist/index.es.js +8805 -12557
  6. package/dist/nuxt/module.cjs.js +23 -1
  7. package/dist/nuxt/module.es.js +58 -82
  8. package/dist/nuxt/runtime/composables/useAuthenticatedFetch.cjs.js +1 -1
  9. package/dist/nuxt/runtime/composables/useAuthenticatedFetch.es.js +82 -111
  10. package/dist/nuxt/runtime/composables/useStrandsAuth.cjs.js +1 -1
  11. package/dist/nuxt/runtime/composables/useStrandsAuth.es.js +30 -46
  12. package/dist/nuxt/runtime/middleware/auth.global.cjs.js +1 -1
  13. package/dist/nuxt/runtime/middleware/auth.global.es.js +28 -44
  14. package/dist/nuxt/runtime/plugin.client.cjs.js +1 -1
  15. package/dist/nuxt/runtime/plugin.client.es.js +10 -19
  16. package/dist/nuxt/runtime/plugin.server.cjs.js +1 -1
  17. package/dist/nuxt/runtime/plugin.server.es.js +8 -10
  18. package/dist/nuxt/runtime/plugins/auth-interceptor.client.cjs.js +1 -1
  19. package/dist/nuxt/runtime/plugins/auth-interceptor.client.es.js +27 -48
  20. package/dist/nuxt.cjs.js +1 -1
  21. package/dist/nuxt.es.js +9 -9
  22. package/dist/useStrandsAuth-BVqpuhrO.cjs.js +1 -0
  23. package/dist/useStrandsAuth-Bv61_QkS.es.js +653 -0
  24. package/dist/useStrandsConfig-Cd22bj_E.es.js +209 -0
  25. package/dist/useStrandsConfig-D7a0QXz3.cjs.js +1 -0
  26. package/dist/vite.cjs.js +29 -1
  27. package/dist/vite.es.js +58 -75
  28. package/dist/vue/utils/modalStack.d.ts +3 -0
  29. package/package.json +2 -2
  30. package/dist/StrandsUIPlugin-BRGzLy44.cjs.js +0 -1
  31. package/dist/StrandsUIPlugin-DtGqMkbS.es.js +0 -26371
  32. package/dist/useStrandsAuth-BCnUxo-R.es.js +0 -915
  33. package/dist/useStrandsAuth-DoJxpNLb.cjs.js +0 -1
  34. package/dist/useStrandsConfig-Sr6NG90B.cjs.js +0 -1
  35. package/dist/useStrandsConfig-fRu-OG08.es.js +0 -248
@@ -1 +1,23 @@
1
- "use strict";const t=require("@nuxt/kit");var e="undefined"!=typeof document?document.currentScript:null;const s=t.defineNuxtModule({meta:{name:"@strands.gg/accui/nuxt",configKey:"strandsAuth",compatibility:{nuxt:"^3.0.0 || ^4.0.0"}},defaults:{baseUrl:"https://your-api.example.com",accentColor:"#EA00A8",redirectUrl:"/",onSignInUrl:"/dashboard",onSignOutUrl:"/",autoRefresh:1,refreshInterval:4,protectedRoutes:[],guestOnlyRoutes:["/auth","/login","/register"],devMode:0,styles:1,supportEmail:"",oauth2RedirectUrl:""},async setup(s,n){const r=t.createResolver("undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("nuxt/module.cjs.js",document.baseURI).href);n.options.runtimeConfig.public=n.options.runtimeConfig.public||{};const o={...s,styles:0!=s.styles};if(n.options.runtimeConfig.public.strandsAuth=o,n.options.appConfig&&(n.options.appConfig.strandsAuth=o),0!=s.styles&&n.options.css.push("@strands.gg/accui/style.css"),s.accentColor&&"#EA00A8"!==s.accentColor){const t=s.accentColor,e=`\n :root {\n --strands-custom-accent: ${t};\n --strands-custom-50: color-mix(in srgb, ${t} 10%, white);\n --strands-custom-100: color-mix(in srgb, ${t} 20%, white);\n --strands-custom-200: color-mix(in srgb, ${t} 30%, white);\n --strands-custom-300: color-mix(in srgb, ${t} 40%, white);\n --strands-custom-400: color-mix(in srgb, ${t} 70%, white);\n --strands-custom-500: ${t};\n --strands-custom-600: color-mix(in srgb, ${t} 85%, black);\n --strands-custom-700: color-mix(in srgb, ${t} 70%, black);\n --strands-custom-800: color-mix(in srgb, ${t} 55%, black);\n --strands-custom-900: color-mix(in srgb, ${t} 40%, black);\n --strands-custom-950: color-mix(in srgb, ${t} 25%, black);\n }\n `;n.options.app.head=n.options.app.head||{},n.options.app.head.style=n.options.app.head.style||[],n.options.app.head.style.unshift({innerHTML:e,key:"strands-accent-override"})}const a="es.js",i=r.resolve(`./runtime/plugin.client.${a}`),u=r.resolve(`./runtime/plugin.server.${a}`),d=r.resolve(`./runtime/middleware/auth.global.${a}`),c=r.resolve(`./runtime/plugins/auth-interceptor.client.${a}`);t.addPlugin({src:i,mode:"client"}),t.addPlugin({src:u,mode:"server"}),t.addPlugin({src:c,mode:"client"}),t.addRouteMiddleware({name:"auth",path:d,global:1}),n.hook("pages:extend",()=>{}),t.addImports([{name:"useStrandsAuth",as:"useStrandsAuth",from:r.resolve(`./runtime/composables/useStrandsAuth.${a}`)},{name:"useAuthUser",as:"useAuthUser",from:r.resolve(`./runtime/composables/useStrandsAuth.${a}`)},{name:"useAuthState",as:"useAuthState",from:r.resolve(`./runtime/composables/useStrandsAuth.${a}`)},{name:"useAuthenticatedFetch",as:"useAuthenticatedFetch",from:r.resolve(`./runtime/composables/useAuthenticatedFetch.${a}`)}]);const l=["StrandsAuth","StrandsSignIn","StrandsSignUp","StrandsCompleteSignUp","StrandsUserProfile","StrandsUserButton","StrandsPasswordReset","StrandsMFASetup","StrandsMfaVerification","StrandsMfaModal","StrandsBackupCodesModal","StrandsConfirmModal","StrandsEmailMfaSetupModal","StrandsHardwareKeySetupModal","StrandsSessionsModal","StrandsSettingsModal","StrandsTotpSetupModal","StrandsConfigProvider","SignedIn","StrandsLogo","StrandsSecuredFooter","StrandsNav","StrandsNavItem","UiAlert","UiApp","UiAvatarEditor","UiButton","UiCard","UiCheckboxGroup","UiColorPicker","UiDateTimePicker","UiDivider","UiHero","UiInput","UiLevelProgress","UiLink","UiLoader","UiModal","UiPill","UiRadioGroup","UiSlider","UiTable","UiTabs","UiThemeToggle","UiToggle","UiTooltip","VirtualList","SvgIcon","IconGithub","IconGoogle"];for(const e of l)t.addComponent({name:e,export:e,filePath:"@strands.gg/accui"});n.hook("prepare:types",t=>{t.references.push({types:"@strands.gg/auth-nuxt"}),t.declarations&&t.declarations.push(`\n declare global {\n const useStrandsAuth: typeof import('${r.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useStrandsAuth']\n const useAuthUser: typeof import('${r.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthUser']\n const useAuthState: typeof import('${r.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthState']\n const useAuthenticatedFetch: typeof import('${r.resolve("./runtime/composables/useAuthenticatedFetch.d.ts")}')['useAuthenticatedFetch']\n }\n `)})}});module.exports=s;
1
+ "use strict";const r=require("@nuxt/kit");var n=typeof document<"u"?document.currentScript:null;const h={baseUrl:"https://your-api.example.com",accentColor:"#EA00A8",redirectUrl:"/",onSignInUrl:"/dashboard",onSignOutUrl:"/",autoRefresh:!0,refreshInterval:4,protectedRoutes:[],guestOnlyRoutes:["/auth","/login","/register"],devMode:!1,styles:!0,supportEmail:"",oauth2RedirectUrl:""},g=r.defineNuxtModule({meta:{name:"@strands.gg/accui/nuxt",configKey:"strandsAuth",compatibility:{nuxt:"^3.0.0 || ^4.0.0"}},defaults:h,async setup(a,t){const s=r.createResolver(typeof document>"u"?require("url").pathToFileURL(__filename).href:n&&n.tagName.toUpperCase()==="SCRIPT"&&n.src||new URL("nuxt/module.cjs.js",document.baseURI).href);t.options.runtimeConfig.public=t.options.runtimeConfig.public||{};const i={...a,styles:a.styles!==!1};if(t.options.runtimeConfig.public.strandsAuth=i,t.options.appConfig&&(t.options.appConfig.strandsAuth=i),a.styles!==!1&&t.options.css.push("@strands.gg/accui/style.css"),a.accentColor&&a.accentColor!=="#EA00A8"){const e=a.accentColor,p=`
2
+ :root {
3
+ --strands-custom-accent: ${e};
4
+ --strands-custom-50: color-mix(in srgb, ${e} 10%, white);
5
+ --strands-custom-100: color-mix(in srgb, ${e} 20%, white);
6
+ --strands-custom-200: color-mix(in srgb, ${e} 30%, white);
7
+ --strands-custom-300: color-mix(in srgb, ${e} 40%, white);
8
+ --strands-custom-400: color-mix(in srgb, ${e} 70%, white);
9
+ --strands-custom-500: ${e};
10
+ --strands-custom-600: color-mix(in srgb, ${e} 85%, black);
11
+ --strands-custom-700: color-mix(in srgb, ${e} 70%, black);
12
+ --strands-custom-800: color-mix(in srgb, ${e} 55%, black);
13
+ --strands-custom-900: color-mix(in srgb, ${e} 40%, black);
14
+ --strands-custom-950: color-mix(in srgb, ${e} 25%, black);
15
+ }
16
+ `;t.options.app.head=t.options.app.head||{},t.options.app.head.style=t.options.app.head.style||[],t.options.app.head.style.unshift({innerHTML:p,key:"strands-accent-override"})}const o="es.js",u=s.resolve(`./runtime/plugin.client.${o}`),d=s.resolve(`./runtime/plugin.server.${o}`),c=s.resolve(`./runtime/middleware/auth.global.${o}`),l=s.resolve(`./runtime/plugins/auth-interceptor.client.${o}`);r.addPlugin({src:u,mode:"client"}),r.addPlugin({src:d,mode:"server"}),r.addPlugin({src:l,mode:"client"}),r.addRouteMiddleware({name:"auth",path:c,global:!0}),t.hook("pages:extend",()=>{}),r.addImports([{name:"useStrandsAuth",as:"useStrandsAuth",from:s.resolve(`./runtime/composables/useStrandsAuth.${o}`)},{name:"useAuthUser",as:"useAuthUser",from:s.resolve(`./runtime/composables/useStrandsAuth.${o}`)},{name:"useAuthState",as:"useAuthState",from:s.resolve(`./runtime/composables/useStrandsAuth.${o}`)},{name:"useAuthenticatedFetch",as:"useAuthenticatedFetch",from:s.resolve(`./runtime/composables/useAuthenticatedFetch.${o}`)}]);const m=["StrandsAuth","StrandsSignIn","StrandsSignUp","StrandsCompleteSignUp","StrandsUserProfile","StrandsUserButton","StrandsPasswordReset","StrandsMFASetup","StrandsMfaVerification","StrandsMfaModal","StrandsBackupCodesModal","StrandsConfirmModal","StrandsEmailMfaSetupModal","StrandsHardwareKeySetupModal","StrandsSessionsModal","StrandsSettingsModal","StrandsTotpSetupModal","StrandsConfigProvider","SignedIn","StrandsLogo","StrandsSecuredFooter","StrandsNav","StrandsNavItem","UiAlert","UiApp","UiAvatarEditor","UiButton","UiCard","UiCheckboxGroup","UiColorPicker","UiDateTimePicker","UiDivider","UiHero","UiInput","UiLevelProgress","UiLink","UiLoader","UiModal","UiPill","UiRadioGroup","UiSlider","UiTable","UiTabs","UiThemeToggle","UiToggle","UiTooltip","VirtualList","SvgIcon","IconGithub","IconGoogle"];for(const e of m)r.addComponent({name:e,export:e,filePath:"@strands.gg/accui"});t.hook("prepare:types",e=>{e.references.push({types:"@strands.gg/auth-nuxt"}),e.declarations&&e.declarations.push(`
17
+ declare global {
18
+ const useStrandsAuth: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useStrandsAuth']
19
+ const useAuthUser: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthUser']
20
+ const useAuthState: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthState']
21
+ const useAuthenticatedFetch: typeof import('${s.resolve("./runtime/composables/useAuthenticatedFetch.d.ts")}')['useAuthenticatedFetch']
22
+ }
23
+ `)})}});module.exports=g;
@@ -1,20 +1,19 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addRouteMiddleware, addImports, addComponent } from "@nuxt/kit";
2
- const moduleDefaults = {
1
+ import { defineNuxtModule as p, createResolver as h, addPlugin as a, addRouteMiddleware as g, addImports as S, addComponent as f } from "@nuxt/kit";
2
+ const b = {
3
3
  baseUrl: "https://your-api.example.com",
4
4
  accentColor: "#EA00A8",
5
5
  redirectUrl: "/",
6
6
  onSignInUrl: "/dashboard",
7
7
  onSignOutUrl: "/",
8
- autoRefresh: true,
8
+ autoRefresh: !0,
9
9
  refreshInterval: 4,
10
10
  protectedRoutes: [],
11
11
  guestOnlyRoutes: ["/auth", "/login", "/register"],
12
- devMode: false,
13
- styles: true,
12
+ devMode: !1,
13
+ styles: !0,
14
14
  supportEmail: "",
15
15
  oauth2RedirectUrl: ""
16
- };
17
- const module = defineNuxtModule({
16
+ }, U = p({
18
17
  meta: {
19
18
  name: "@strands.gg/accui/nuxt",
20
19
  configKey: "strandsAuth",
@@ -22,93 +21,74 @@ const module = defineNuxtModule({
22
21
  nuxt: "^3.0.0 || ^4.0.0"
23
22
  }
24
23
  },
25
- defaults: moduleDefaults,
26
- async setup(options, nuxt) {
27
- const resolver = createResolver(import.meta.url);
28
- nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
29
- const runtimeConfig = {
30
- ...options,
31
- styles: options.styles !== false
24
+ defaults: b,
25
+ async setup(r, t) {
26
+ const s = h(import.meta.url);
27
+ t.options.runtimeConfig.public = t.options.runtimeConfig.public || {};
28
+ const n = {
29
+ ...r,
30
+ styles: r.styles !== !1
32
31
  };
33
- nuxt.options.runtimeConfig.public.strandsAuth = runtimeConfig;
34
- if (nuxt.options.appConfig) {
35
- nuxt.options.appConfig.strandsAuth = runtimeConfig;
36
- }
37
- if (options.styles !== false) {
38
- nuxt.options.css.push("@strands.gg/accui/style.css");
39
- }
40
- if (options.accentColor && options.accentColor !== "#EA00A8") {
41
- const accentColor = options.accentColor;
42
- const cssVariables = `
32
+ if (t.options.runtimeConfig.public.strandsAuth = n, t.options.appConfig && (t.options.appConfig.strandsAuth = n), r.styles !== !1 && t.options.css.push("@strands.gg/accui/style.css"), r.accentColor && r.accentColor !== "#EA00A8") {
33
+ const e = r.accentColor, m = `
43
34
  :root {
44
- --strands-custom-accent: ${accentColor};
45
- --strands-custom-50: color-mix(in srgb, ${accentColor} 10%, white);
46
- --strands-custom-100: color-mix(in srgb, ${accentColor} 20%, white);
47
- --strands-custom-200: color-mix(in srgb, ${accentColor} 30%, white);
48
- --strands-custom-300: color-mix(in srgb, ${accentColor} 40%, white);
49
- --strands-custom-400: color-mix(in srgb, ${accentColor} 70%, white);
50
- --strands-custom-500: ${accentColor};
51
- --strands-custom-600: color-mix(in srgb, ${accentColor} 85%, black);
52
- --strands-custom-700: color-mix(in srgb, ${accentColor} 70%, black);
53
- --strands-custom-800: color-mix(in srgb, ${accentColor} 55%, black);
54
- --strands-custom-900: color-mix(in srgb, ${accentColor} 40%, black);
55
- --strands-custom-950: color-mix(in srgb, ${accentColor} 25%, black);
35
+ --strands-custom-accent: ${e};
36
+ --strands-custom-50: color-mix(in srgb, ${e} 10%, white);
37
+ --strands-custom-100: color-mix(in srgb, ${e} 20%, white);
38
+ --strands-custom-200: color-mix(in srgb, ${e} 30%, white);
39
+ --strands-custom-300: color-mix(in srgb, ${e} 40%, white);
40
+ --strands-custom-400: color-mix(in srgb, ${e} 70%, white);
41
+ --strands-custom-500: ${e};
42
+ --strands-custom-600: color-mix(in srgb, ${e} 85%, black);
43
+ --strands-custom-700: color-mix(in srgb, ${e} 70%, black);
44
+ --strands-custom-800: color-mix(in srgb, ${e} 55%, black);
45
+ --strands-custom-900: color-mix(in srgb, ${e} 40%, black);
46
+ --strands-custom-950: color-mix(in srgb, ${e} 25%, black);
56
47
  }
57
48
  `;
58
- nuxt.options.app.head = nuxt.options.app.head || {};
59
- nuxt.options.app.head.style = nuxt.options.app.head.style || [];
60
- nuxt.options.app.head.style.unshift({
61
- innerHTML: cssVariables,
49
+ t.options.app.head = t.options.app.head || {}, t.options.app.head.style = t.options.app.head.style || [], t.options.app.head.style.unshift({
50
+ innerHTML: m,
62
51
  key: "strands-accent-override"
63
52
  });
64
53
  }
65
- const ext = "es.js";
66
- const clientPluginPath = resolver.resolve(`./runtime/plugin.client.${ext}`);
67
- const serverPluginPath = resolver.resolve(`./runtime/plugin.server.${ext}`);
68
- const middlewarePath = resolver.resolve(`./runtime/middleware/auth.global.${ext}`);
69
- const authInterceptorPath = resolver.resolve(`./runtime/plugins/auth-interceptor.client.${ext}`);
70
- addPlugin({
71
- src: clientPluginPath,
54
+ const o = "es.js", i = s.resolve(`./runtime/plugin.client.${o}`), u = s.resolve(`./runtime/plugin.server.${o}`), c = s.resolve(`./runtime/middleware/auth.global.${o}`), d = s.resolve(`./runtime/plugins/auth-interceptor.client.${o}`);
55
+ a({
56
+ src: i,
72
57
  mode: "client"
73
- });
74
- addPlugin({
75
- src: serverPluginPath,
58
+ }), a({
59
+ src: u,
76
60
  mode: "server"
77
- });
78
- addPlugin({
79
- src: authInterceptorPath,
61
+ }), a({
62
+ src: d,
80
63
  mode: "client"
81
- });
82
- addRouteMiddleware({
64
+ }), g({
83
65
  name: "auth",
84
- path: middlewarePath,
85
- global: true
86
- });
87
- nuxt.hook("pages:extend", () => {
88
- });
89
- addImports([
66
+ path: c,
67
+ global: !0
68
+ }), t.hook("pages:extend", () => {
69
+ }), S([
90
70
  {
91
71
  name: "useStrandsAuth",
92
72
  as: "useStrandsAuth",
93
- from: resolver.resolve(`./runtime/composables/useStrandsAuth.${ext}`)
73
+ from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
94
74
  },
95
75
  {
96
76
  name: "useAuthUser",
97
77
  as: "useAuthUser",
98
- from: resolver.resolve(`./runtime/composables/useStrandsAuth.${ext}`)
78
+ from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
99
79
  },
100
80
  {
101
81
  name: "useAuthState",
102
82
  as: "useAuthState",
103
- from: resolver.resolve(`./runtime/composables/useStrandsAuth.${ext}`)
83
+ from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
104
84
  },
105
85
  {
106
86
  name: "useAuthenticatedFetch",
107
87
  as: "useAuthenticatedFetch",
108
- from: resolver.resolve(`./runtime/composables/useAuthenticatedFetch.${ext}`)
88
+ from: s.resolve(`./runtime/composables/useAuthenticatedFetch.${o}`)
109
89
  }
110
90
  ]);
111
- const components = [
91
+ const l = [
112
92
  // Strands Auth Components
113
93
  "StrandsAuth",
114
94
  "StrandsSignIn",
@@ -164,30 +144,26 @@ const module = defineNuxtModule({
164
144
  "IconGithub",
165
145
  "IconGoogle"
166
146
  ];
167
- for (const component of components) {
168
- addComponent({
169
- name: component,
170
- export: component,
147
+ for (const e of l)
148
+ f({
149
+ name: e,
150
+ export: e,
171
151
  filePath: "@strands.gg/accui"
172
152
  });
173
- }
174
- nuxt.hook("prepare:types", (opts) => {
175
- opts.references.push({
153
+ t.hook("prepare:types", (e) => {
154
+ e.references.push({
176
155
  types: "@strands.gg/auth-nuxt"
177
- });
178
- if (opts.declarations) {
179
- opts.declarations.push(`
156
+ }), e.declarations && e.declarations.push(`
180
157
  declare global {
181
- const useStrandsAuth: typeof import('${resolver.resolve(`./runtime/composables/useStrandsAuth.d.ts`)}')['useStrandsAuth']
182
- const useAuthUser: typeof import('${resolver.resolve(`./runtime/composables/useStrandsAuth.d.ts`)}')['useAuthUser']
183
- const useAuthState: typeof import('${resolver.resolve(`./runtime/composables/useStrandsAuth.d.ts`)}')['useAuthState']
184
- const useAuthenticatedFetch: typeof import('${resolver.resolve(`./runtime/composables/useAuthenticatedFetch.d.ts`)}')['useAuthenticatedFetch']
158
+ const useStrandsAuth: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useStrandsAuth']
159
+ const useAuthUser: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthUser']
160
+ const useAuthState: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthState']
161
+ const useAuthenticatedFetch: typeof import('${s.resolve("./runtime/composables/useAuthenticatedFetch.d.ts")}')['useAuthenticatedFetch']
185
162
  }
186
163
  `);
187
- }
188
164
  });
189
165
  }
190
166
  });
191
167
  export {
192
- module as default
168
+ U as default
193
169
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("nuxt/app"),e=require("./useStrandsAuth.cjs.js");function n(){const n=t.useRuntimeConfig().public.strandsAuth,{currentSession:o,refreshToken:s,getAuthHeaders:r}=e.useStrandsAuth(),c=async(t,e={})=>{const{autoRefresh:c=1,requireAuth:a=1,baseURL:p,...u}=e;if(a&&!o.value?.accessToken)throw new Error("User is not authenticated");let h=t;const d=p||n.baseUrl;d&&"string"==typeof t&&!t.startsWith("http")&&(h=new URL(t,d).toString());const y=new Headers(u.headers);if(o.value?.accessToken)try{const t=r();Object.entries(t).forEach(([t,e])=>{y.set(t,e)})}catch(b){if(a)throw b}const i={...u,headers:y};let f=await fetch(h,i);if(401===f.status&&c&&o.value?.refreshToken)try{if(await s()&&o.value?.accessToken){const t=r();Object.entries(t).forEach(([t,e])=>{y.set(t,e)}),f=await fetch(h,{...i,headers:y})}}catch(j){}return f};return{authenticatedFetch:c,get:(t,e)=>c(t,{...e,method:"GET"}),post:(t,e,n)=>{const o=new Headers(n?.headers);return e&&"object"==typeof e&&!o.has("Content-Type")&&o.set("Content-Type","application/json"),c(t,{...n,method:"POST",headers:o,body:"object"==typeof e?JSON.stringify(e):e})},put:(t,e,n)=>{const o=new Headers(n?.headers);return e&&"object"==typeof e&&!o.has("Content-Type")&&o.set("Content-Type","application/json"),c(t,{...n,method:"PUT",headers:o,body:"object"==typeof e?JSON.stringify(e):e})},delete:(t,e)=>c(t,{...e,method:"DELETE"}),patch:(t,e,n)=>{const o=new Headers(n?.headers);return e&&"object"==typeof e&&!o.has("Content-Type")&&o.set("Content-Type","application/json"),c(t,{...n,method:"PATCH",headers:o,body:"object"==typeof e?JSON.stringify(e):e})}}}const o={get:async(t,e)=>{const{get:o}=n();return o(t,e)},post:async(t,e,o)=>{const{post:s}=n();return s(t,e,o)},put:async(t,e,o)=>{const{put:s}=n();return s(t,e,o)},delete:async(t,e)=>{const{delete:o}=n();return o(t,e)},patch:async(t,e,o)=>{const{patch:s}=n();return s(t,e,o)}};exports.$authFetch=o,exports.useAuthenticatedFetch=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("nuxt/app"),m=require("./useStrandsAuth.cjs.js");function i(){const r=A.useRuntimeConfig().public.strandsAuth,{currentSession:t,refreshToken:a,getAuthHeaders:o}=m.useStrandsAuth(),u=async(s,e={})=>{const{autoRefresh:c=!0,requireAuth:n=!0,baseURL:j,...y}=e;if(n&&!t.value?.accessToken)throw new Error("User is not authenticated");let p=s;const g=j||r.baseUrl;g&&typeof s=="string"&&!s.startsWith("http")&&(p=new URL(s,g).toString());const f=new Headers(y.headers);if(t.value?.accessToken)try{const h=o();Object.entries(h).forEach(([l,T])=>{f.set(l,T)})}catch(h){if(console.warn("[Strands Auth] Failed to get auth headers:",h),n)throw h}const w={...y,headers:f};let d=await fetch(p,w);if(d.status===401&&c&&t.value?.refreshToken)try{if(await a()&&t.value?.accessToken){const l=o();Object.entries(l).forEach(([T,S])=>{f.set(T,S)}),d=await fetch(p,{...w,headers:f})}}catch(h){console.error("[Strands Auth] Token refresh failed:",h)}return d};return{authenticatedFetch:u,get:(s,e)=>u(s,{...e,method:"GET"}),post:(s,e,c)=>{const n=new Headers(c?.headers);return e&&typeof e=="object"&&!n.has("Content-Type")&&n.set("Content-Type","application/json"),u(s,{...c,method:"POST",headers:n,body:typeof e=="object"?JSON.stringify(e):e})},put:(s,e,c)=>{const n=new Headers(c?.headers);return e&&typeof e=="object"&&!n.has("Content-Type")&&n.set("Content-Type","application/json"),u(s,{...c,method:"PUT",headers:n,body:typeof e=="object"?JSON.stringify(e):e})},delete:(s,e)=>u(s,{...e,method:"DELETE"}),patch:(s,e,c)=>{const n=new Headers(c?.headers);return e&&typeof e=="object"&&!n.has("Content-Type")&&n.set("Content-Type","application/json"),u(s,{...c,method:"PATCH",headers:n,body:typeof e=="object"?JSON.stringify(e):e})}}}const O={get:async(r,t)=>{const{get:a}=i();return a(r,t)},post:async(r,t,a)=>{const{post:o}=i();return o(r,t,a)},put:async(r,t,a)=>{const{put:o}=i();return o(r,t,a)},delete:async(r,t)=>{const{delete:a}=i();return a(r,t)},patch:async(r,t,a)=>{const{patch:o}=i();return o(r,t,a)}};exports.$authFetch=O;exports.useAuthenticatedFetch=i;
@@ -1,132 +1,103 @@
1
- import { useRuntimeConfig } from "nuxt/app";
2
- import { useStrandsAuth } from "./useStrandsAuth.es.js";
3
- function useAuthenticatedFetch() {
4
- const config = useRuntimeConfig().public["strandsAuth"];
5
- const { currentSession, refreshToken, getAuthHeaders } = useStrandsAuth();
6
- const authenticatedFetch = async (url, options = {}) => {
1
+ import { useRuntimeConfig as A } from "nuxt/app";
2
+ import { useStrandsAuth as S } from "./useStrandsAuth.es.js";
3
+ function u() {
4
+ const r = A().public.strandsAuth, { currentSession: t, refreshToken: o, getAuthHeaders: c } = S(), i = async (s, e = {}) => {
7
5
  const {
8
- autoRefresh = true,
9
- requireAuth = true,
10
- baseURL,
11
- ...fetchOptions
12
- } = options;
13
- if (requireAuth && !currentSession.value?.accessToken) {
6
+ autoRefresh: a = !0,
7
+ requireAuth: n = !0,
8
+ baseURL: j,
9
+ ...y
10
+ } = e;
11
+ if (n && !t.value?.accessToken)
14
12
  throw new Error("User is not authenticated");
15
- }
16
- let fullUrl = url;
17
- const resolvedBaseURL = baseURL || config.baseUrl;
18
- if (resolvedBaseURL && typeof url === "string" && !url.startsWith("http")) {
19
- fullUrl = new URL(url, resolvedBaseURL).toString();
20
- }
21
- const headers = new Headers(fetchOptions.headers);
22
- if (currentSession.value?.accessToken) {
13
+ let p = s;
14
+ const g = j || r.baseUrl;
15
+ g && typeof s == "string" && !s.startsWith("http") && (p = new URL(s, g).toString());
16
+ const f = new Headers(y.headers);
17
+ if (t.value?.accessToken)
23
18
  try {
24
- const authHeaders = getAuthHeaders();
25
- Object.entries(authHeaders).forEach(([key, value]) => {
26
- headers.set(key, value);
19
+ const h = c();
20
+ Object.entries(h).forEach(([l, T]) => {
21
+ f.set(l, T);
27
22
  });
28
- } catch (error) {
29
- console.warn("[Strands Auth] Failed to get auth headers:", error);
30
- if (requireAuth) {
31
- throw error;
32
- }
23
+ } catch (h) {
24
+ if (console.warn("[Strands Auth] Failed to get auth headers:", h), n)
25
+ throw h;
33
26
  }
34
- }
35
- const enhancedOptions = {
36
- ...fetchOptions,
37
- headers
27
+ const w = {
28
+ ...y,
29
+ headers: f
38
30
  };
39
- let response = await fetch(fullUrl, enhancedOptions);
40
- if (response.status === 401 && autoRefresh && currentSession.value?.refreshToken) {
31
+ let d = await fetch(p, w);
32
+ if (d.status === 401 && a && t.value?.refreshToken)
41
33
  try {
42
- const refreshed = await refreshToken();
43
- if (refreshed && currentSession.value?.accessToken) {
44
- const newAuthHeaders = getAuthHeaders();
45
- Object.entries(newAuthHeaders).forEach(([key, value]) => {
46
- headers.set(key, value);
47
- });
48
- response = await fetch(fullUrl, { ...enhancedOptions, headers });
34
+ if (await o() && t.value?.accessToken) {
35
+ const l = c();
36
+ Object.entries(l).forEach(([T, m]) => {
37
+ f.set(T, m);
38
+ }), d = await fetch(p, { ...w, headers: f });
49
39
  }
50
- } catch (refreshError) {
51
- console.error("[Strands Auth] Token refresh failed:", refreshError);
40
+ } catch (h) {
41
+ console.error("[Strands Auth] Token refresh failed:", h);
52
42
  }
53
- }
54
- return response;
55
- };
56
- const get = (url, options) => {
57
- return authenticatedFetch(url, { ...options, method: "GET" });
58
- };
59
- const post = (url, body, options) => {
60
- const headers = new Headers(options?.headers);
61
- if (body && typeof body === "object" && !headers.has("Content-Type")) {
62
- headers.set("Content-Type", "application/json");
63
- }
64
- return authenticatedFetch(url, {
65
- ...options,
66
- method: "POST",
67
- headers,
68
- body: typeof body === "object" ? JSON.stringify(body) : body
69
- });
70
- };
71
- const put = (url, body, options) => {
72
- const headers = new Headers(options?.headers);
73
- if (body && typeof body === "object" && !headers.has("Content-Type")) {
74
- headers.set("Content-Type", "application/json");
75
- }
76
- return authenticatedFetch(url, {
77
- ...options,
78
- method: "PUT",
79
- headers,
80
- body: typeof body === "object" ? JSON.stringify(body) : body
81
- });
82
- };
83
- const del = (url, options) => {
84
- return authenticatedFetch(url, { ...options, method: "DELETE" });
85
- };
86
- const patch = (url, body, options) => {
87
- const headers = new Headers(options?.headers);
88
- if (body && typeof body === "object" && !headers.has("Content-Type")) {
89
- headers.set("Content-Type", "application/json");
90
- }
91
- return authenticatedFetch(url, {
92
- ...options,
93
- method: "PATCH",
94
- headers,
95
- body: typeof body === "object" ? JSON.stringify(body) : body
96
- });
43
+ return d;
97
44
  };
98
45
  return {
99
- authenticatedFetch,
100
- get,
101
- post,
102
- put,
103
- delete: del,
104
- patch
46
+ authenticatedFetch: i,
47
+ get: (s, e) => i(s, { ...e, method: "GET" }),
48
+ post: (s, e, a) => {
49
+ const n = new Headers(a?.headers);
50
+ return e && typeof e == "object" && !n.has("Content-Type") && n.set("Content-Type", "application/json"), i(s, {
51
+ ...a,
52
+ method: "POST",
53
+ headers: n,
54
+ body: typeof e == "object" ? JSON.stringify(e) : e
55
+ });
56
+ },
57
+ put: (s, e, a) => {
58
+ const n = new Headers(a?.headers);
59
+ return e && typeof e == "object" && !n.has("Content-Type") && n.set("Content-Type", "application/json"), i(s, {
60
+ ...a,
61
+ method: "PUT",
62
+ headers: n,
63
+ body: typeof e == "object" ? JSON.stringify(e) : e
64
+ });
65
+ },
66
+ delete: (s, e) => i(s, { ...e, method: "DELETE" }),
67
+ patch: (s, e, a) => {
68
+ const n = new Headers(a?.headers);
69
+ return e && typeof e == "object" && !n.has("Content-Type") && n.set("Content-Type", "application/json"), i(s, {
70
+ ...a,
71
+ method: "PATCH",
72
+ headers: n,
73
+ body: typeof e == "object" ? JSON.stringify(e) : e
74
+ });
75
+ }
105
76
  };
106
77
  }
107
- const $authFetch = {
108
- get: async (url, options) => {
109
- const { get } = useAuthenticatedFetch();
110
- return get(url, options);
78
+ const R = {
79
+ get: async (r, t) => {
80
+ const { get: o } = u();
81
+ return o(r, t);
111
82
  },
112
- post: async (url, body, options) => {
113
- const { post } = useAuthenticatedFetch();
114
- return post(url, body, options);
83
+ post: async (r, t, o) => {
84
+ const { post: c } = u();
85
+ return c(r, t, o);
115
86
  },
116
- put: async (url, body, options) => {
117
- const { put } = useAuthenticatedFetch();
118
- return put(url, body, options);
87
+ put: async (r, t, o) => {
88
+ const { put: c } = u();
89
+ return c(r, t, o);
119
90
  },
120
- delete: async (url, options) => {
121
- const { delete: del } = useAuthenticatedFetch();
122
- return del(url, options);
91
+ delete: async (r, t) => {
92
+ const { delete: o } = u();
93
+ return o(r, t);
123
94
  },
124
- patch: async (url, body, options) => {
125
- const { patch } = useAuthenticatedFetch();
126
- return patch(url, body, options);
95
+ patch: async (r, t, o) => {
96
+ const { patch: c } = u();
97
+ return c(r, t, o);
127
98
  }
128
99
  };
129
100
  export {
130
- $authFetch,
131
- useAuthenticatedFetch
101
+ R as $authFetch,
102
+ u as useAuthenticatedFetch
132
103
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("nuxt/app"),s=require("../../../useStrandsAuth-DoJxpNLb.cjs.js"),a=()=>{const a=t.useRuntimeConfig().public.strandsAuth,e=s.useStrandsAuth();return{...e,initialize:async()=>{await e.initialize()},signIn:async s=>{const i=await e.signIn(s);return i&&a.onSignInUrl&&await t.navigateTo(a.onSignInUrl),i},signUp:async t=>await e.signUp({email:t.email,password:"",firstName:"",lastName:""}),signOut:async()=>{await e.signOut(),a.onSignOutUrl&&await t.navigateTo(a.onSignOutUrl)}}};exports.useAuthState=()=>{const{isAuthenticated:t,isLoading:s}=a();return{isAuthenticated:t,isLoading:s}},exports.useAuthUser=()=>{const{user:t}=a();return{user:t}},exports.useStrandsAuth=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("nuxt/app"),a=require("../../../useStrandsAuth-BVqpuhrO.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,56 +1,40 @@
1
- import { useRuntimeConfig, navigateTo } from "nuxt/app";
2
- import { u as useStrandsAuth$1 } from "../../../useStrandsAuth-BCnUxo-R.es.js";
3
- const useStrandsAuth = () => {
4
- const config = useRuntimeConfig().public["strandsAuth"];
5
- const vueAuth = useStrandsAuth$1();
6
- const initialize = async () => {
7
- await vueAuth.initialize();
8
- };
9
- const signIn = async (credentials) => {
10
- const result = await vueAuth.signIn(credentials);
11
- if (result && config.onSignInUrl) {
12
- await navigateTo(config.onSignInUrl);
13
- }
14
- return result;
15
- };
16
- const signUp = async (userData) => {
17
- const result = await vueAuth.signUp({
18
- email: userData.email,
1
+ import { useRuntimeConfig as e, navigateTo as a } from "nuxt/app";
2
+ import { u as r } from "../../../useStrandsAuth-Bv61_QkS.es.js";
3
+ const u = () => {
4
+ const n = e().public.strandsAuth, t = r();
5
+ return {
6
+ // Re-export Vue composable state and methods
7
+ ...t,
8
+ // Add initialize function
9
+ initialize: async () => {
10
+ await t.initialize();
11
+ },
12
+ // Override methods with Nuxt-specific navigation
13
+ signIn: async (i) => {
14
+ const s = await t.signIn(i);
15
+ return s && n.onSignInUrl && await a(n.onSignInUrl), s;
16
+ },
17
+ signUp: async (i) => await t.signUp({
18
+ email: i.email,
19
19
  password: "",
20
20
  // Empty password for magic link
21
21
  firstName: "",
22
22
  // Will be filled later in the magic link flow
23
23
  lastName: ""
24
- });
25
- return result;
26
- };
27
- const signOut = async () => {
28
- await vueAuth.signOut();
29
- if (config.onSignOutUrl) {
30
- await navigateTo(config.onSignOutUrl);
24
+ }),
25
+ signOut: async () => {
26
+ await t.signOut(), n.onSignOutUrl && await a(n.onSignOutUrl);
31
27
  }
32
28
  };
33
- return {
34
- // Re-export Vue composable state and methods
35
- ...vueAuth,
36
- // Add initialize function
37
- initialize,
38
- // Override methods with Nuxt-specific navigation
39
- signIn,
40
- signUp,
41
- signOut
42
- };
43
- };
44
- const useAuthUser = () => {
45
- const { user } = useStrandsAuth();
46
- return { user };
47
- };
48
- const useAuthState = () => {
49
- const { isAuthenticated, isLoading } = useStrandsAuth();
50
- return { isAuthenticated, isLoading };
29
+ }, U = () => {
30
+ const { user: n } = u();
31
+ return { user: n };
32
+ }, f = () => {
33
+ const { isAuthenticated: n, isLoading: t } = u();
34
+ return { isAuthenticated: n, isLoading: t };
51
35
  };
52
36
  export {
53
- useAuthState,
54
- useAuthUser,
55
- useStrandsAuth
37
+ f as useAuthState,
38
+ U as useAuthUser,
39
+ u as useStrandsAuth
56
40
  };
@@ -1 +1 @@
1
- "use strict";const e=require("nuxt/app"),t=e.defineNuxtRouteMiddleware(t=>{const n=e.useRuntimeConfig().public.strandsAuth;return new Promise(r=>{Promise.resolve().then(()=>require("../composables/useStrandsAuth.cjs.js")).then(({useStrandsAuth:o})=>{const{isAuthenticated:i,isLoading:s}=o(),u=()=>{if(s.value)return void setTimeout(u,50);const o=t.path,d=n.protectedRoutes?.some(e=>e.endsWith("*")?o.startsWith(e.slice(0,-1)):o===e||o.startsWith(e+"/")),c=n.guestOnlyRoutes?.some(e=>e.endsWith("*")?o.startsWith(e.slice(0,-1)):o===e||o.startsWith(e+"/"));if(d&&!i.value){const t=n.onSignOutUrl||"/auth",r=t.includes("?")?`${t}&redirect=${encodeURIComponent(o)}`:`${t}?redirect=${encodeURIComponent(o)}`;try{return e.navigateTo(r)}catch(a){if("undefined"!=typeof window)return void(window.location.href=r);throw a}}if(c&&i.value)return e.navigateTo(n.onSignInUrl||"/dashboard");r()};u()})})});module.exports=t;
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.onSignOutUrl||"/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;