@strands.gg/accui 2.16.0 → 2.17.10

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 (38) 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 +8822 -12491
  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/types.d.ts +1 -0
  21. package/dist/nuxt.cjs.js +1 -1
  22. package/dist/nuxt.es.js +9 -9
  23. package/dist/types/index.d.ts +5 -0
  24. package/dist/useStrandsAuth-DSBvF4ky.es.js +653 -0
  25. package/dist/useStrandsAuth-EqbzuNAn.cjs.js +1 -0
  26. package/dist/useStrandsConfig-B5kp4aF9.cjs.js +1 -0
  27. package/dist/useStrandsConfig-CMKVW1p3.es.js +210 -0
  28. package/dist/vite.cjs.js +29 -1
  29. package/dist/vite.es.js +58 -75
  30. package/dist/vue/utils/modalStack.d.ts +3 -0
  31. package/dist/webcomponents/define-element.d.ts +3 -2
  32. package/package.json +2 -2
  33. package/dist/StrandsUIPlugin-C9rrMU2i.cjs.js +0 -1
  34. package/dist/StrandsUIPlugin-tl7L52hZ.es.js +0 -26130
  35. package/dist/useStrandsAuth-BCnUxo-R.es.js +0 -915
  36. package/dist/useStrandsAuth-DoJxpNLb.cjs.js +0 -1
  37. package/dist/useStrandsConfig-Sr6NG90B.cjs.js +0 -1
  38. package/dist/useStrandsConfig-fRu-OG08.es.js +0 -248
@@ -1,51 +1,35 @@
1
- import { defineNuxtRouteMiddleware, useRuntimeConfig, navigateTo } from "nuxt/app";
2
- const auth_global = defineNuxtRouteMiddleware((to) => {
3
- const config = useRuntimeConfig().public["strandsAuth"];
4
- if (import.meta.server) return;
5
- return new Promise((resolve) => {
6
- import("../composables/useStrandsAuth.es.js").then(({ useStrandsAuth }) => {
7
- const { isAuthenticated, isLoading } = useStrandsAuth();
8
- const checkAuth = () => {
9
- if (isLoading.value) {
10
- setTimeout(checkAuth, 50);
11
- return;
12
- }
13
- const currentPath = to.path;
14
- const isProtectedRoute = config.protectedRoutes?.some((route) => {
15
- if (route.endsWith("*")) {
16
- return currentPath.startsWith(route.slice(0, -1));
1
+ import { defineNuxtRouteMiddleware as m, useRuntimeConfig as g, navigateTo as a } from "nuxt/app";
2
+ const w = m((u) => {
3
+ const n = g().public.strandsAuth;
4
+ if (!import.meta.server)
5
+ return new Promise((c) => {
6
+ import("../composables/useStrandsAuth.es.js").then(({ useStrandsAuth: d }) => {
7
+ const { isAuthenticated: r, isLoading: l } = d(), i = () => {
8
+ if (l.value) {
9
+ setTimeout(i, 50);
10
+ return;
17
11
  }
18
- return currentPath === route || currentPath.startsWith(route + "/");
19
- });
20
- const isGuestOnlyRoute = config.guestOnlyRoutes?.some((route) => {
21
- if (route.endsWith("*")) {
22
- return currentPath.startsWith(route.slice(0, -1));
23
- }
24
- return currentPath === route || currentPath.startsWith(route + "/");
25
- });
26
- if (isProtectedRoute && !isAuthenticated.value) {
27
- const authUrl = config.onSignOutUrl || "/auth";
28
- const redirectUrl = authUrl.includes("?") ? `${authUrl}&redirect=${encodeURIComponent(currentPath)}` : `${authUrl}?redirect=${encodeURIComponent(currentPath)}`;
29
- try {
30
- return navigateTo(redirectUrl);
31
- } catch (error) {
32
- console.warn("[Strands Auth] navigateTo failed, using window.location:", error);
33
- if (typeof window !== "undefined") {
34
- window.location.href = redirectUrl;
35
- return;
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)}`;
15
+ try {
16
+ return a(o);
17
+ } catch (s) {
18
+ if (console.warn("[Strands Auth] navigateTo failed, using window.location:", s), typeof window < "u") {
19
+ window.location.href = o;
20
+ return;
21
+ }
22
+ throw s;
36
23
  }
37
- throw error;
38
24
  }
39
- }
40
- if (isGuestOnlyRoute && isAuthenticated.value) {
41
- return navigateTo(config.onSignInUrl || "/dashboard");
42
- }
43
- resolve();
44
- };
45
- checkAuth();
25
+ if (f && r.value)
26
+ return a(n.onSignInUrl || "/dashboard");
27
+ c();
28
+ };
29
+ i();
30
+ });
46
31
  });
47
- });
48
32
  });
49
33
  export {
50
- auth_global as default
34
+ w as default
51
35
  };
@@ -1 +1 @@
1
- "use strict";const e=require("nuxt/app"),s=require("../../useStrandsConfig-Sr6NG90B.cjs.js"),n=e.defineNuxtPlugin({name:"strands-auth-client",async setup(){const n=e.useRuntimeConfig().public.strandsAuth,t={...s.STRANDS_AUTH_DEFAULTS,...n};s.setStrandsConfig(t),"undefined"!=typeof window&&(window.__STRANDS_CONFIG__=t),t?.accentColor&&"undefined"!=typeof window&&document.documentElement.style.setProperty("--strands-accent",t.accentColor);const{useStrandsAuth:i}=await Promise.resolve().then(()=>require("./composables/useStrandsAuth.cjs.js")),{initialize:a}=i();await a()}});module.exports=n;
1
+ "use strict";const e=require("nuxt/app"),t=require("../../useStrandsConfig-B5kp4aF9.cjs.js"),c=e.defineNuxtPlugin({name:"strands-auth-client",async setup(){const i=e.useRuntimeConfig().public.strandsAuth,n={...t.STRANDS_AUTH_DEFAULTS,...i};t.setStrandsConfig(n),typeof window<"u"&&(window.__STRANDS_CONFIG__=n),n?.accentColor&&typeof window<"u"&&document.documentElement.style.setProperty("--strands-accent",n.accentColor);const{useStrandsAuth:s}=await Promise.resolve().then(()=>require("./composables/useStrandsAuth.cjs.js")),{initialize:o}=s();await o()}});module.exports=c;
@@ -1,26 +1,17 @@
1
- import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
2
- import { s as setStrandsConfig, S as STRANDS_AUTH_DEFAULTS } from "../../useStrandsConfig-fRu-OG08.es.js";
3
- const plugin_client = defineNuxtPlugin({
1
+ import { defineNuxtPlugin as i, useRuntimeConfig as s } from "nuxt/app";
2
+ import { s as a, S as c } from "../../useStrandsConfig-CMKVW1p3.es.js";
3
+ const u = i({
4
4
  name: "strands-auth-client",
5
5
  async setup() {
6
- const config = useRuntimeConfig();
7
- const strandsConfig = config.public["strandsAuth"];
8
- const mergedConfig = {
9
- ...STRANDS_AUTH_DEFAULTS,
10
- ...strandsConfig
6
+ const t = s().public.strandsAuth, n = {
7
+ ...c,
8
+ ...t
11
9
  };
12
- setStrandsConfig(mergedConfig);
13
- if (typeof window !== "undefined") {
14
- window.__STRANDS_CONFIG__ = mergedConfig;
15
- }
16
- if (mergedConfig?.accentColor && typeof window !== "undefined") {
17
- document.documentElement.style.setProperty("--strands-accent", mergedConfig.accentColor);
18
- }
19
- const { useStrandsAuth } = await import("./composables/useStrandsAuth.es.js");
20
- const { initialize } = useStrandsAuth();
21
- await initialize();
10
+ a(n), typeof window < "u" && (window.__STRANDS_CONFIG__ = n), n?.accentColor && typeof window < "u" && document.documentElement.style.setProperty("--strands-accent", n.accentColor);
11
+ const { useStrandsAuth: e } = await import("./composables/useStrandsAuth.es.js"), { initialize: o } = e();
12
+ await o();
22
13
  }
23
14
  });
24
15
  export {
25
- plugin_client as default
16
+ u as default
26
17
  };
@@ -1 +1 @@
1
- "use strict";const s=require("nuxt/app"),e=require("../../useStrandsConfig-Sr6NG90B.cjs.js"),r=s.defineNuxtPlugin({name:"strands-auth-server",setup(){const r=s.useRuntimeConfig().public.strandsAuth,t={...e.STRANDS_AUTH_DEFAULTS,...r};e.setStrandsConfig(t)}});module.exports=r;
1
+ "use strict";const n=require("nuxt/app"),s=require("../../useStrandsConfig-B5kp4aF9.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,17 +1,15 @@
1
- import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
2
- import { s as setStrandsConfig, S as STRANDS_AUTH_DEFAULTS } from "../../useStrandsConfig-fRu-OG08.es.js";
3
- const plugin_server = defineNuxtPlugin({
1
+ import { defineNuxtPlugin as t, useRuntimeConfig as e } from "nuxt/app";
2
+ import { s as o, S as r } from "../../useStrandsConfig-CMKVW1p3.es.js";
3
+ const u = t({
4
4
  name: "strands-auth-server",
5
5
  setup() {
6
- const config = useRuntimeConfig();
7
- const strandsConfig = config.public["strandsAuth"];
8
- const mergedConfig = {
9
- ...STRANDS_AUTH_DEFAULTS,
10
- ...strandsConfig
6
+ const s = e().public.strandsAuth, n = {
7
+ ...r,
8
+ ...s
11
9
  };
12
- setStrandsConfig(mergedConfig);
10
+ o(n);
13
11
  }
14
12
  });
15
13
  export {
16
- plugin_server as default
14
+ u as default
17
15
  };
@@ -1 +1 @@
1
- "use strict";const t=require("nuxt/app").defineNuxtPlugin({name:"strands-auth-interceptor",setup(){if(process.server)return;const t=globalThis.fetch;globalThis.fetch=async(r,e)=>{try{const{useStrandsAuth:o}=await Promise.resolve().then(()=>require("../composables/useStrandsAuth.cjs.js")),{currentSession:c,getAuthHeaders:i}=o();let n;n="string"==typeof r?r:r instanceof URL?r.toString():r.url;const a=function(t){if(!t.startsWith("http"))return 0;if(["googleapis.com","github.com/api","api.github.com","discord.com/api","graph.microsoft.com","api.stripe.com","api.twilio.com"].some(r=>t.includes(r)))return 0;const r=["/api/","/v1/","/v2/","/graphql","/trpc"].some(r=>t.includes(r)),e=[":3001",":8000",":8080",":5000",":4000"].some(r=>t.includes(r));return r||e}(n);if(a&&c.value?.accessToken)try{const s=i(),o=new Headers(e?.headers);Object.entries(s).forEach(([t,r])=>{o.set(t,r)});const c={...e,headers:o};return t(r,c)}catch(s){}return t(r,e)}catch(s){return t(r,e)}}}});module.exports=t;
1
+ "use strict";const p=require("nuxt/app"),f=p.defineNuxtPlugin({name:"strands-auth-interceptor",setup(){if(process.server)return;const t=globalThis.fetch;globalThis.fetch=async(e,o)=>{try{const{useStrandsAuth:c}=await Promise.resolve().then(()=>require("../composables/useStrandsAuth.cjs.js")),{currentSession:n,getAuthHeaders:i}=c();let s;if(typeof e=="string"?s=e:e instanceof URL?s=e.toString():s=e.url,m(s)&&n.value?.accessToken)try{const a=i(),h=new Headers(o?.headers);Object.entries(a).forEach(([d,l])=>{h.set(d,l)});const u={...o,headers:h};return t(e,u)}catch(a){console.warn("[Strands Auth] Failed to inject auth headers:",a)}return t(e,o)}catch(c){return console.error("[Strands Auth] Error in fetch interceptor:",c),t(e,o)}}}});function m(t){if(!t.startsWith("http")||["googleapis.com","github.com/api","api.github.com","discord.com/api","graph.microsoft.com","api.stripe.com","api.twilio.com"].some(r=>t.includes(r)))return!1;const n=["/api/","/v1/","/v2/","/graphql","/trpc"].some(r=>t.includes(r)),s=[":3001",":8000",":8080",":5000",":4000"].some(r=>t.includes(r));return n||s}module.exports=f;
@@ -1,51 +1,36 @@
1
- import { defineNuxtPlugin } from "nuxt/app";
2
- const authInterceptor_client = defineNuxtPlugin({
1
+ import { defineNuxtPlugin as p } from "nuxt/app";
2
+ const g = p({
3
3
  name: "strands-auth-interceptor",
4
4
  setup() {
5
5
  if (process.server) return;
6
- const originalFetch = globalThis.fetch;
7
- globalThis.fetch = async (input, init) => {
6
+ const e = globalThis.fetch;
7
+ globalThis.fetch = async (t, o) => {
8
8
  try {
9
- const { useStrandsAuth } = await import("../composables/useStrandsAuth.es.js");
10
- const { currentSession, getAuthHeaders } = useStrandsAuth();
11
- let url;
12
- if (typeof input === "string") {
13
- url = input;
14
- } else if (input instanceof URL) {
15
- url = input.toString();
16
- } else {
17
- url = input.url;
18
- }
19
- const shouldAddAuth = shouldInjectAuth(url);
20
- if (shouldAddAuth && currentSession.value?.accessToken) {
9
+ const { useStrandsAuth: a } = await import("../composables/useStrandsAuth.es.js"), { currentSession: c, getAuthHeaders: i } = a();
10
+ let s;
11
+ if (typeof t == "string" ? s = t : t instanceof URL ? s = t.toString() : s = t.url, f(s) && c.value?.accessToken)
21
12
  try {
22
- const authHeaders = getAuthHeaders();
23
- const headers = new Headers(init?.headers);
24
- Object.entries(authHeaders).forEach(([key, value]) => {
25
- headers.set(key, value);
13
+ const n = i(), h = new Headers(o?.headers);
14
+ Object.entries(n).forEach(([d, l]) => {
15
+ h.set(d, l);
26
16
  });
27
- const enhancedInit = {
28
- ...init,
29
- headers
17
+ const u = {
18
+ ...o,
19
+ headers: h
30
20
  };
31
- return originalFetch(input, enhancedInit);
32
- } catch (error) {
33
- console.warn("[Strands Auth] Failed to inject auth headers:", error);
21
+ return e(t, u);
22
+ } catch (n) {
23
+ console.warn("[Strands Auth] Failed to inject auth headers:", n);
34
24
  }
35
- }
36
- return originalFetch(input, init);
37
- } catch (error) {
38
- console.error("[Strands Auth] Error in fetch interceptor:", error);
39
- return originalFetch(input, init);
25
+ return e(t, o);
26
+ } catch (a) {
27
+ return console.error("[Strands Auth] Error in fetch interceptor:", a), e(t, o);
40
28
  }
41
29
  };
42
30
  }
43
31
  });
44
- function shouldInjectAuth(url) {
45
- if (!url.startsWith("http")) {
46
- return false;
47
- }
48
- const skipDomains = [
32
+ function f(e) {
33
+ if (!e.startsWith("http") || [
49
34
  "googleapis.com",
50
35
  "github.com/api",
51
36
  "api.github.com",
@@ -54,23 +39,17 @@ function shouldInjectAuth(url) {
54
39
  "api.stripe.com",
55
40
  "api.twilio.com"
56
41
  // Add other third-party APIs here
57
- ];
58
- const shouldSkip = skipDomains.some((domain) => url.includes(domain));
59
- if (shouldSkip) {
60
- return false;
61
- }
62
- const apiPatterns = [
42
+ ].some((r) => e.includes(r)))
43
+ return !1;
44
+ const c = [
63
45
  "/api/",
64
46
  "/v1/",
65
47
  "/v2/",
66
48
  "/graphql",
67
49
  "/trpc"
68
- ];
69
- const isApiRequest = apiPatterns.some((pattern) => url.includes(pattern));
70
- const apiPorts = [":3001", ":8000", ":8080", ":5000", ":4000"];
71
- const hasApiPort = apiPorts.some((port) => url.includes(port));
72
- return isApiRequest || hasApiPort;
50
+ ].some((r) => e.includes(r)), s = [":3001", ":8000", ":8080", ":5000", ":4000"].some((r) => e.includes(r));
51
+ return c || s;
73
52
  }
74
53
  export {
75
- authInterceptor_client as default
54
+ g as default
76
55
  };
@@ -25,6 +25,7 @@ declare module '@nuxt/schema' {
25
25
  redirectUrl?: string;
26
26
  onSignInUrl?: string;
27
27
  onSignOutUrl?: string;
28
+ authUrl?: string;
28
29
  /** @deprecated OAuth providers are now dynamically fetched from API */
29
30
  oauthProviders?: string[];
30
31
  autoRefresh?: boolean;
package/dist/nuxt.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{t:{value:1},[Symbol.toStringTag]:{value:"Module"}});const e=require("./nuxt/module.cjs.js"),s=require("./nuxt/runtime/composables/useStrandsAuth.cjs.js"),t=require("./nuxt/runtime/composables/useAuthenticatedFetch.cjs.js");exports.default=e,exports.useAuthState=s.useAuthState,exports.useAuthUser=s.useAuthUser,exports.useStrandsAuth=s.useStrandsAuth,exports.$authFetch=t.$authFetch,exports.useAuthenticatedFetch=t.useAuthenticatedFetch;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./nuxt/module.cjs.js"),e=require("./nuxt/runtime/composables/useStrandsAuth.cjs.js"),t=require("./nuxt/runtime/composables/useAuthenticatedFetch.cjs.js");exports.default=u;exports.useAuthState=e.useAuthState;exports.useAuthUser=e.useAuthUser;exports.useStrandsAuth=e.useStrandsAuth;exports.$authFetch=t.$authFetch;exports.useAuthenticatedFetch=t.useAuthenticatedFetch;
package/dist/nuxt.es.js CHANGED
@@ -1,11 +1,11 @@
1
- import { default as default2 } from "./nuxt/module.es.js";
2
- import { useAuthState, useAuthUser, useStrandsAuth } from "./nuxt/runtime/composables/useStrandsAuth.es.js";
3
- import { $authFetch, useAuthenticatedFetch } from "./nuxt/runtime/composables/useAuthenticatedFetch.es.js";
1
+ import { default as u } from "./nuxt/module.es.js";
2
+ import { useAuthState as h, useAuthUser as o, useStrandsAuth as s } from "./nuxt/runtime/composables/useStrandsAuth.es.js";
3
+ import { $authFetch as f, useAuthenticatedFetch as A } from "./nuxt/runtime/composables/useAuthenticatedFetch.es.js";
4
4
  export {
5
- $authFetch,
6
- default2 as default,
7
- useAuthState,
8
- useAuthUser,
9
- useAuthenticatedFetch,
10
- useStrandsAuth
5
+ f as $authFetch,
6
+ u as default,
7
+ h as useAuthState,
8
+ o as useAuthUser,
9
+ A as useAuthenticatedFetch,
10
+ s as useStrandsAuth
11
11
  };
@@ -114,6 +114,11 @@ export interface StrandsAuthConfig {
114
114
  * @default '/'
115
115
  */
116
116
  onSignOutUrl?: string;
117
+ /**
118
+ * URL of the authentication/login page (where unauthenticated users are redirected)
119
+ * @default '/auth'
120
+ */
121
+ authUrl?: string;
117
122
  /**
118
123
  * Enable automatic token refresh
119
124
  * @default true