@strands.gg/accui 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +1 -3
  2. package/dist/nuxt/module.cjs.js +1 -1
  3. package/dist/nuxt/module.es.js +64 -13
  4. package/dist/strands-auth-ui.cjs.js +1 -1
  5. package/dist/strands-auth-ui.es.js +3 -3
  6. package/package.json +1 -11
  7. package/dist/nuxt-v4/module.cjs.js +0 -1
  8. package/dist/nuxt-v4/module.d.ts +0 -1
  9. package/dist/nuxt-v4/module.es.js +0 -151
  10. package/dist/nuxt-v4/runtime/composables/useAuthenticatedFetch.cjs.js +0 -1
  11. package/dist/nuxt-v4/runtime/composables/useAuthenticatedFetch.d.ts +0 -1
  12. package/dist/nuxt-v4/runtime/composables/useAuthenticatedFetch.es.js +0 -134
  13. package/dist/nuxt-v4/runtime/composables/useStrandsAuth.cjs.js +0 -1
  14. package/dist/nuxt-v4/runtime/composables/useStrandsAuth.d.ts +0 -1
  15. package/dist/nuxt-v4/runtime/composables/useStrandsAuth.es.js +0 -70
  16. package/dist/nuxt-v4/runtime/middleware/auth.global.cjs.js +0 -1
  17. package/dist/nuxt-v4/runtime/middleware/auth.global.d.ts +0 -1
  18. package/dist/nuxt-v4/runtime/middleware/auth.global.es.js +0 -42
  19. package/dist/nuxt-v4/runtime/plugin.client.cjs.js +0 -1
  20. package/dist/nuxt-v4/runtime/plugin.client.d.ts +0 -1
  21. package/dist/nuxt-v4/runtime/plugin.client.es.js +0 -26
  22. package/dist/nuxt-v4/runtime/plugin.server.cjs.js +0 -1
  23. package/dist/nuxt-v4/runtime/plugin.server.d.ts +0 -1
  24. package/dist/nuxt-v4/runtime/plugin.server.es.js +0 -22
  25. package/dist/nuxt-v4/runtime/plugins/auth-interceptor.client.cjs.js +0 -1
  26. package/dist/nuxt-v4/runtime/plugins/auth-interceptor.client.d.ts +0 -1
  27. package/dist/nuxt-v4/runtime/plugins/auth-interceptor.client.es.js +0 -77
  28. package/dist/nuxt-v4.cjs.js +0 -1
  29. package/dist/nuxt-v4.d.ts +0 -1
  30. package/dist/nuxt-v4.es.js +0 -11
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, provide, onMounted, onUnmounted, createElementBlock, openBlock, normalizeClass, createElementVNode, createBlock, renderSlot, Teleport, createCommentVNode, toDisplayString, createTextVNode, unref, normalizeStyle, useSlots, createVNode, Fragment as Fragment$1, withCtx, resolveComponent, createSlots, h as h$1, ref, nextTick, withModifiers, renderList, watch, toRefs, withDirectives, vModelSelect, getCurrentInstance, watchEffect, onBeforeUnmount, shallowRef, markRaw, customRef, useCssVars, reactive, createStaticVNode, vModelText, Transition, mergeProps, inject, resolveDynamicComponent, withKeys, isMemoSame } from "vue";
1
+ import { defineComponent, computed, provide, onMounted, onUnmounted, createElementBlock, openBlock, normalizeClass, createElementVNode, createBlock, renderSlot, Teleport, createCommentVNode, toDisplayString, createTextVNode, unref, normalizeStyle, useSlots, createVNode, Fragment as Fragment$1, withCtx, resolveComponent, resolveDynamicComponent, createSlots, h as h$1, ref, nextTick, withModifiers, renderList, watch, toRefs, withDirectives, vModelSelect, getCurrentInstance, watchEffect, onBeforeUnmount, shallowRef, markRaw, customRef, useCssVars, reactive, createStaticVNode, vModelText, Transition, mergeProps, inject, withKeys, isMemoSame } from "vue";
2
2
  import { u as useStrandsConfig, p as provideStrandsConfig } from "./useStrandsConfig-C3gBJK6y.es.js";
3
3
  import { s } from "./useStrandsConfig-C3gBJK6y.es.js";
4
4
  import { u as useStrandsAuth } from "./useStrandsAuth-DoUupKb8.es.js";
@@ -458,6 +458,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
458
458
  },
459
459
  emits: ["click"],
460
460
  setup(__props, { emit: __emit }) {
461
+ const NuxtLinkComponent = resolveComponent("NuxtLink");
461
462
  const props = __props;
462
463
  const emit = __emit;
463
464
  const handleLinkClick = (event) => {
@@ -468,8 +469,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
468
469
  emit("click", event);
469
470
  };
470
471
  return (_ctx, _cache) => {
471
- const _component_nuxt_link = resolveComponent("nuxt-link");
472
- return openBlock(), createBlock(_component_nuxt_link, {
472
+ return openBlock(), createBlock(resolveDynamicComponent(unref(NuxtLinkComponent)), {
473
473
  to: _ctx.to,
474
474
  class: normalizeClass(_ctx.buttonClasses),
475
475
  style: normalizeStyle(_ctx.buttonStyles),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strands.gg/accui",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Strands Authentication UI Components",
5
5
  "type": "module",
6
6
  "main": "./dist/strands-auth-ui.cjs.js",
@@ -33,16 +33,6 @@
33
33
  "import": "./dist/nuxt/*.es.js",
34
34
  "require": "./dist/nuxt/*.cjs.js"
35
35
  },
36
- "./nuxt-v4": {
37
- "types": "./dist/nuxt-v4.d.ts",
38
- "import": "./dist/nuxt-v4.es.js",
39
- "require": "./dist/nuxt-v4.cjs.js"
40
- },
41
- "./nuxt-v4/*": {
42
- "types": "./dist/nuxt-v4/*.d.ts",
43
- "import": "./dist/nuxt-v4/*.es.js",
44
- "require": "./dist/nuxt-v4/*.cjs.js"
45
- },
46
36
  "./fetch": {
47
37
  "types": "./dist/vue/composables/useAuthenticatedFetch.d.ts",
48
38
  "import": "./dist/strands-auth-ui.es.js",
@@ -1 +0,0 @@
1
- "use strict";const t=require("@nuxt/kit");var s="undefined"!=typeof document?document.currentScript:null;const e=t.defineNuxtModule({meta:{name:"@strands.gg/accui/nuxt-v4",configKey:"strandsAuth",compatibility:{nuxt:"^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(e,n){const r=t.createResolver("undefined"==typeof document?require("url").pathToFileURL(__filename).href:s&&"SCRIPT"===s.tagName.toUpperCase()&&s.src||new URL("nuxt-v4/module.cjs.js",document.baseURI).href);n.options.runtimeConfig.public=n.options.runtimeConfig.public||{};const o={...e,styles:0!=e.styles};if(n.options.runtimeConfig.public.strandsAuth=o,n.options.appConfig.strandsAuth=o,0!=e.styles&&n.options.css.push("@strands.gg/accui/style.css"),e.accentColor&&"#EA00A8"!==e.accentColor){const t=e.accentColor,s=`\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:s,key:"strands-accent-override"})}const a="es.js",u=r.resolve(`./runtime/plugin.client.${a}`),i=r.resolve(`./runtime/plugin.server.${a}`),c=r.resolve(`./runtime/middleware/auth.global.${a}`);t.addPlugin({src:u,mode:"client"}),t.addPlugin({src:i,mode:"server"}),t.addPlugin({src:r.resolve(`./runtime/plugins/auth-interceptor.client.${a}`),mode:"client"}),t.addRouteMiddleware({name:"auth",path:c,global:1}),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 d=["StrandsAuth","StrandsSignIn","StrandsSignUp","StrandsCompleteSignUp","StrandsUserProfile","StrandsUserButton","StrandsPasswordReset","StrandsMFASetup","StrandsConfigProvider","SignedIn","StrandsLogo","StrandsSecuredFooter","StrandsUiAlert","StrandsUiButton","StrandsUiCard","StrandsUiInput","StrandsUiLink","StrandsUiTabs","StrandsUiLoader"];for(const s of d)t.addComponent({name:s,export:s,filePath:"@strands.gg/accui"});n.hook("prepare:types",t=>{t.references.push({types:"@strands.gg/auth-nuxt-v4"}),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 }\n `)})}});module.exports=e;
@@ -1 +0,0 @@
1
- export {}
@@ -1,151 +0,0 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addRouteMiddleware, addImports, addComponent } from "@nuxt/kit";
2
- const moduleDefaults = {
3
- baseUrl: "https://your-api.example.com",
4
- accentColor: "#EA00A8",
5
- redirectUrl: "/",
6
- onSignInUrl: "/dashboard",
7
- onSignOutUrl: "/",
8
- autoRefresh: true,
9
- refreshInterval: 4,
10
- protectedRoutes: [],
11
- guestOnlyRoutes: ["/auth", "/login", "/register"],
12
- devMode: false,
13
- styles: true,
14
- supportEmail: "",
15
- oauth2RedirectUrl: ""
16
- };
17
- const module = defineNuxtModule({
18
- meta: {
19
- name: "@strands.gg/accui/nuxt-v4",
20
- configKey: "strandsAuth",
21
- compatibility: {
22
- nuxt: "^4.0.0"
23
- }
24
- },
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
32
- };
33
- nuxt.options.runtimeConfig.public.strandsAuth = runtimeConfig;
34
- nuxt.options.appConfig.strandsAuth = runtimeConfig;
35
- if (options.styles !== false) {
36
- nuxt.options.css.push("@strands.gg/accui/style.css");
37
- }
38
- if (options.accentColor && options.accentColor !== "#EA00A8") {
39
- const accentColor = options.accentColor;
40
- const cssVariables = `
41
- :root {
42
- --strands-custom-accent: ${accentColor};
43
- --strands-custom-50: color-mix(in srgb, ${accentColor} 10%, white);
44
- --strands-custom-100: color-mix(in srgb, ${accentColor} 20%, white);
45
- --strands-custom-200: color-mix(in srgb, ${accentColor} 30%, white);
46
- --strands-custom-300: color-mix(in srgb, ${accentColor} 40%, white);
47
- --strands-custom-400: color-mix(in srgb, ${accentColor} 70%, white);
48
- --strands-custom-500: ${accentColor};
49
- --strands-custom-600: color-mix(in srgb, ${accentColor} 85%, black);
50
- --strands-custom-700: color-mix(in srgb, ${accentColor} 70%, black);
51
- --strands-custom-800: color-mix(in srgb, ${accentColor} 55%, black);
52
- --strands-custom-900: color-mix(in srgb, ${accentColor} 40%, black);
53
- --strands-custom-950: color-mix(in srgb, ${accentColor} 25%, black);
54
- }
55
- `;
56
- nuxt.options.app.head = nuxt.options.app.head || {};
57
- nuxt.options.app.head.style = nuxt.options.app.head.style || [];
58
- nuxt.options.app.head.style.unshift({
59
- innerHTML: cssVariables,
60
- key: "strands-accent-override"
61
- });
62
- }
63
- const ext = "es.js";
64
- const clientPluginPath = resolver.resolve(`./runtime/plugin.client.${ext}`);
65
- const serverPluginPath = resolver.resolve(`./runtime/plugin.server.${ext}`);
66
- const middlewarePath = resolver.resolve(`./runtime/middleware/auth.global.${ext}`);
67
- addPlugin({
68
- src: clientPluginPath,
69
- mode: "client"
70
- });
71
- addPlugin({
72
- src: serverPluginPath,
73
- mode: "server"
74
- });
75
- addPlugin({
76
- src: resolver.resolve(`./runtime/plugins/auth-interceptor.client.${ext}`),
77
- mode: "client"
78
- });
79
- addRouteMiddleware({
80
- name: "auth",
81
- path: middlewarePath,
82
- global: true
83
- });
84
- addImports([
85
- {
86
- name: "useStrandsAuth",
87
- as: "useStrandsAuth",
88
- from: resolver.resolve(`./runtime/composables/useStrandsAuth.${ext}`)
89
- },
90
- {
91
- name: "useAuthUser",
92
- as: "useAuthUser",
93
- from: resolver.resolve(`./runtime/composables/useStrandsAuth.${ext}`)
94
- },
95
- {
96
- name: "useAuthState",
97
- as: "useAuthState",
98
- from: resolver.resolve(`./runtime/composables/useStrandsAuth.${ext}`)
99
- },
100
- {
101
- name: "useAuthenticatedFetch",
102
- as: "useAuthenticatedFetch",
103
- from: resolver.resolve(`./runtime/composables/useAuthenticatedFetch.${ext}`)
104
- }
105
- ]);
106
- const components = [
107
- "StrandsAuth",
108
- "StrandsSignIn",
109
- "StrandsSignUp",
110
- "StrandsCompleteSignUp",
111
- "StrandsUserProfile",
112
- "StrandsUserButton",
113
- "StrandsPasswordReset",
114
- "StrandsMFASetup",
115
- "StrandsConfigProvider",
116
- "SignedIn",
117
- "StrandsLogo",
118
- "StrandsSecuredFooter",
119
- // UI Components
120
- "StrandsUiAlert",
121
- "StrandsUiButton",
122
- "StrandsUiCard",
123
- "StrandsUiInput",
124
- "StrandsUiLink",
125
- "StrandsUiTabs",
126
- "StrandsUiLoader"
127
- ];
128
- for (const component of components) {
129
- addComponent({
130
- name: component,
131
- export: component,
132
- filePath: "@strands.gg/accui"
133
- });
134
- }
135
- nuxt.hook("prepare:types", (opts) => {
136
- opts.references.push({
137
- types: "@strands.gg/auth-nuxt-v4"
138
- });
139
- opts.declarations.push(`
140
- declare global {
141
- const useStrandsAuth: typeof import('${resolver.resolve(`./runtime/composables/useStrandsAuth.d.ts`)}')['useStrandsAuth']
142
- const useAuthUser: typeof import('${resolver.resolve(`./runtime/composables/useStrandsAuth.d.ts`)}')['useAuthUser']
143
- const useAuthState: typeof import('${resolver.resolve(`./runtime/composables/useStrandsAuth.d.ts`)}')['useAuthState']
144
- }
145
- `);
146
- });
147
- }
148
- });
149
- export {
150
- module as default
151
- };
@@ -1 +0,0 @@
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,134 +0,0 @@
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 = {}) => {
7
- const {
8
- autoRefresh = true,
9
- requireAuth = true,
10
- baseURL,
11
- ...fetchOptions
12
- } = options;
13
- if (requireAuth && !currentSession.value?.accessToken) {
14
- 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) {
23
- try {
24
- const authHeaders = getAuthHeaders();
25
- Object.entries(authHeaders).forEach(([key, value]) => {
26
- headers.set(key, value);
27
- });
28
- } catch (error) {
29
- console.warn("[Strands Auth] Failed to get auth headers:", error);
30
- if (requireAuth) {
31
- throw error;
32
- }
33
- }
34
- }
35
- const enhancedOptions = {
36
- ...fetchOptions,
37
- headers
38
- };
39
- let response = await fetch(fullUrl, enhancedOptions);
40
- if (response.status === 401 && autoRefresh && currentSession.value?.refreshToken) {
41
- console.log("[Strands Auth] Request failed with 401, attempting token refresh...");
42
- try {
43
- const refreshed = await refreshToken();
44
- if (refreshed && currentSession.value?.accessToken) {
45
- const newAuthHeaders = getAuthHeaders();
46
- Object.entries(newAuthHeaders).forEach(([key, value]) => {
47
- headers.set(key, value);
48
- });
49
- console.log("[Strands Auth] Retrying request with refreshed token");
50
- response = await fetch(fullUrl, { ...enhancedOptions, headers });
51
- }
52
- } catch (refreshError) {
53
- console.error("[Strands Auth] Token refresh failed:", refreshError);
54
- }
55
- }
56
- return response;
57
- };
58
- const get = (url, options) => {
59
- return authenticatedFetch(url, { ...options, method: "GET" });
60
- };
61
- const post = (url, body, options) => {
62
- const headers = new Headers(options?.headers);
63
- if (body && typeof body === "object" && !headers.has("Content-Type")) {
64
- headers.set("Content-Type", "application/json");
65
- }
66
- return authenticatedFetch(url, {
67
- ...options,
68
- method: "POST",
69
- headers,
70
- body: typeof body === "object" ? JSON.stringify(body) : body
71
- });
72
- };
73
- const put = (url, body, options) => {
74
- const headers = new Headers(options?.headers);
75
- if (body && typeof body === "object" && !headers.has("Content-Type")) {
76
- headers.set("Content-Type", "application/json");
77
- }
78
- return authenticatedFetch(url, {
79
- ...options,
80
- method: "PUT",
81
- headers,
82
- body: typeof body === "object" ? JSON.stringify(body) : body
83
- });
84
- };
85
- const del = (url, options) => {
86
- return authenticatedFetch(url, { ...options, method: "DELETE" });
87
- };
88
- const patch = (url, body, options) => {
89
- const headers = new Headers(options?.headers);
90
- if (body && typeof body === "object" && !headers.has("Content-Type")) {
91
- headers.set("Content-Type", "application/json");
92
- }
93
- return authenticatedFetch(url, {
94
- ...options,
95
- method: "PATCH",
96
- headers,
97
- body: typeof body === "object" ? JSON.stringify(body) : body
98
- });
99
- };
100
- return {
101
- authenticatedFetch,
102
- get,
103
- post,
104
- put,
105
- delete: del,
106
- patch
107
- };
108
- }
109
- const $authFetch = {
110
- get: async (url, options) => {
111
- const { get } = useAuthenticatedFetch();
112
- return get(url, options);
113
- },
114
- post: async (url, body, options) => {
115
- const { post } = useAuthenticatedFetch();
116
- return post(url, body, options);
117
- },
118
- put: async (url, body, options) => {
119
- const { put } = useAuthenticatedFetch();
120
- return put(url, body, options);
121
- },
122
- delete: async (url, options) => {
123
- const { delete: del } = useAuthenticatedFetch();
124
- return del(url, options);
125
- },
126
- patch: async (url, body, options) => {
127
- const { patch } = useAuthenticatedFetch();
128
- return patch(url, body, options);
129
- }
130
- };
131
- export {
132
- $authFetch,
133
- useAuthenticatedFetch
134
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("nuxt/app"),e=require("../../../useStrandsAuth-WChBcwNF.cjs.js"),s=()=>{const s=t.useRuntimeConfig().public.strandsAuth,a=e.useStrandsAuth();return{user:a.user,currentUser:a.currentUser,currentSession:a.currentSession,isAuthenticated:a.isAuthenticated,isLoading:a.isLoading,loading:a.loading,signIn:async e=>{const i=await a.signIn(e);return i&&s.onSignInUrl&&await t.navigateTo(s.onSignInUrl),i},signUp:async t=>await a.signUp({email:t.email,password:"",firstName:"",lastName:""}),signOut:async()=>{await a.signOut(),s.onSignOutUrl&&await t.navigateTo(s.onSignOutUrl)},refreshToken:a.refreshToken,updateProfile:a.updateProfile,setAuthData:a.setAuthData,getAuthHeaders:a.getAuthHeaders,initialize:async()=>{try{await a.initialize()}catch(t){}}}};exports.useAuthState=()=>{const{isAuthenticated:t,isLoading:e}=s();return{isAuthenticated:t,isLoading:e}},exports.useAuthUser=()=>{const{user:t}=s();return{user:t}},exports.useStrandsAuth=s;
@@ -1 +0,0 @@
1
- export {}
@@ -1,70 +0,0 @@
1
- import { useRuntimeConfig, navigateTo } from "nuxt/app";
2
- import { u as useStrandsAuth$1 } from "../../../useStrandsAuth-DoUupKb8.es.js";
3
- const useStrandsAuth = () => {
4
- const config = useRuntimeConfig().public["strandsAuth"];
5
- const vueAuth = useStrandsAuth$1();
6
- const initialize = async () => {
7
- try {
8
- await vueAuth.initialize();
9
- } catch (error) {
10
- console.warn("[Strands Auth v4] Initialize failed:", error);
11
- }
12
- };
13
- const signIn = async (credentials) => {
14
- const result = await vueAuth.signIn(credentials);
15
- if (result && config.onSignInUrl) {
16
- await navigateTo(config.onSignInUrl);
17
- }
18
- return result;
19
- };
20
- const signUp = async (userData) => {
21
- const result = await vueAuth.signUp({
22
- email: userData.email,
23
- password: "",
24
- // Empty password for magic link
25
- firstName: "",
26
- // Will be filled later in the magic link flow
27
- lastName: ""
28
- });
29
- return result;
30
- };
31
- const signOut = async () => {
32
- await vueAuth.signOut();
33
- if (config.onSignOutUrl) {
34
- await navigateTo(config.onSignOutUrl);
35
- }
36
- };
37
- return {
38
- // Re-export Vue composable state and methods with explicit typing
39
- user: vueAuth.user,
40
- currentUser: vueAuth.currentUser,
41
- currentSession: vueAuth.currentSession,
42
- isAuthenticated: vueAuth.isAuthenticated,
43
- isLoading: vueAuth.isLoading,
44
- loading: vueAuth.loading,
45
- // Methods with Nuxt-specific navigation overrides
46
- signIn,
47
- signUp,
48
- signOut,
49
- // Other methods from Vue composable
50
- refreshToken: vueAuth.refreshToken,
51
- updateProfile: vueAuth.updateProfile,
52
- setAuthData: vueAuth.setAuthData,
53
- getAuthHeaders: vueAuth.getAuthHeaders,
54
- // Initialize function
55
- initialize
56
- };
57
- };
58
- const useAuthUser = () => {
59
- const { user } = useStrandsAuth();
60
- return { user };
61
- };
62
- const useAuthState = () => {
63
- const { isAuthenticated, isLoading } = useStrandsAuth();
64
- return { isAuthenticated, isLoading };
65
- };
66
- export {
67
- useAuthState,
68
- useAuthUser,
69
- useStrandsAuth
70
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("nuxt/app"),s=e.defineNuxtRouteMiddleware(s=>{const t=e.useRuntimeConfig().public.strandsAuth;if(!process.server)return new Promise(r=>{Promise.resolve().then(()=>require("../composables/useStrandsAuth.cjs.js")).then(({useStrandsAuth:o})=>{const{isAuthenticated:n,isLoading:i}=o(),u=()=>{if(i.value)return void setTimeout(u,50);const o=s.path,c=t.protectedRoutes?.some(e=>e.endsWith("*")?o.startsWith(e.slice(0,-1)):o===e||o.startsWith(e+"/")),d=t.guestOnlyRoutes?.some(e=>e.endsWith("*")?o.startsWith(e.slice(0,-1)):o===e||o.startsWith(e+"/"));return c&&!n.value?e.navigateTo("/auth?redirect="+encodeURIComponent(o)):d&&n.value?e.navigateTo(t.onSignInUrl||"/dashboard"):void r()};u()})})});module.exports=s;
@@ -1 +0,0 @@
1
- export {}
@@ -1,42 +0,0 @@
1
- import { defineNuxtRouteMiddleware, useRuntimeConfig, navigateTo } from "nuxt/app";
2
- const auth_global = defineNuxtRouteMiddleware((to) => {
3
- const config = useRuntimeConfig().public["strandsAuth"];
4
- if (process.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));
17
- }
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
- console.log("[Strands Auth v4] Protected route accessed without authentication, redirecting to auth");
28
- return navigateTo("/auth?redirect=" + encodeURIComponent(currentPath));
29
- }
30
- if (isGuestOnlyRoute && isAuthenticated.value) {
31
- console.log("[Strands Auth v4] Guest-only route accessed while authenticated, redirecting");
32
- return navigateTo(config.onSignInUrl || "/dashboard");
33
- }
34
- resolve();
35
- };
36
- checkAuth();
37
- });
38
- });
39
- });
40
- export {
41
- auth_global as default
42
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("nuxt/app"),s=require("../../useStrandsConfig-B6uW6Zkd.cjs.js"),n=e.defineNuxtPlugin({name:"strands-auth-client-v4",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 +0,0 @@
1
- export {}
@@ -1,26 +0,0 @@
1
- import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
2
- import { s as setStrandsConfig, S as STRANDS_AUTH_DEFAULTS } from "../../useStrandsConfig-C3gBJK6y.es.js";
3
- const plugin_client = defineNuxtPlugin({
4
- name: "strands-auth-client-v4",
5
- async setup() {
6
- const config = useRuntimeConfig();
7
- const strandsConfig = config.public["strandsAuth"];
8
- const mergedConfig = {
9
- ...STRANDS_AUTH_DEFAULTS,
10
- ...strandsConfig
11
- };
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();
22
- }
23
- });
24
- export {
25
- plugin_client as default
26
- };
@@ -1 +0,0 @@
1
- "use strict";const s=require("nuxt/app"),e=require("../../useStrandsConfig-B6uW6Zkd.cjs.js"),t=s.defineNuxtPlugin({name:"strands-auth-server-v4",setup(){try{const t=s.useRuntimeConfig(),r=t.public?.strandsAuth,u={...e.STRANDS_AUTH_DEFAULTS,...r||{}};e.setStrandsConfig(u)}catch(t){e.setStrandsConfig(e.STRANDS_AUTH_DEFAULTS)}}});module.exports=t;
@@ -1 +0,0 @@
1
- export {}
@@ -1,22 +0,0 @@
1
- import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
2
- import { s as setStrandsConfig, S as STRANDS_AUTH_DEFAULTS } from "../../useStrandsConfig-C3gBJK6y.es.js";
3
- const plugin_server = defineNuxtPlugin({
4
- name: "strands-auth-server-v4",
5
- setup() {
6
- try {
7
- const config = useRuntimeConfig();
8
- const strandsConfig = config.public?.["strandsAuth"];
9
- const mergedConfig = {
10
- ...STRANDS_AUTH_DEFAULTS,
11
- ...strandsConfig || {}
12
- };
13
- setStrandsConfig(mergedConfig);
14
- } catch (error) {
15
- console.warn("[Strands Auth] Server plugin could not access runtime config, using defaults");
16
- setStrandsConfig(STRANDS_AUTH_DEFAULTS);
17
- }
18
- }
19
- });
20
- export {
21
- plugin_server as default
22
- };
@@ -1 +0,0 @@
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,77 +0,0 @@
1
- import { defineNuxtPlugin } from "nuxt/app";
2
- const authInterceptor_client = defineNuxtPlugin({
3
- name: "strands-auth-interceptor",
4
- setup() {
5
- if (process.server) return;
6
- const originalFetch = globalThis.fetch;
7
- globalThis.fetch = async (input, init) => {
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) {
21
- try {
22
- const authHeaders = getAuthHeaders();
23
- const headers = new Headers(init?.headers);
24
- Object.entries(authHeaders).forEach(([key, value]) => {
25
- headers.set(key, value);
26
- });
27
- const enhancedInit = {
28
- ...init,
29
- headers
30
- };
31
- console.log("[Strands Auth] Injecting auth headers for request:", url);
32
- return originalFetch(input, enhancedInit);
33
- } catch (error) {
34
- console.warn("[Strands Auth] Failed to inject auth headers:", error);
35
- }
36
- }
37
- return originalFetch(input, init);
38
- } catch (error) {
39
- console.error("[Strands Auth] Error in fetch interceptor:", error);
40
- return originalFetch(input, init);
41
- }
42
- };
43
- }
44
- });
45
- function shouldInjectAuth(url) {
46
- if (!url.startsWith("http")) {
47
- return false;
48
- }
49
- const skipDomains = [
50
- "googleapis.com",
51
- "github.com/api",
52
- "api.github.com",
53
- "discord.com/api",
54
- "graph.microsoft.com",
55
- "api.stripe.com",
56
- "api.twilio.com"
57
- // Add other third-party APIs here
58
- ];
59
- const shouldSkip = skipDomains.some((domain) => url.includes(domain));
60
- if (shouldSkip) {
61
- return false;
62
- }
63
- const apiPatterns = [
64
- "/api/",
65
- "/v1/",
66
- "/v2/",
67
- "/graphql",
68
- "/trpc"
69
- ];
70
- const isApiRequest = apiPatterns.some((pattern) => url.includes(pattern));
71
- const apiPorts = [":3001", ":8000", ":8080", ":5000", ":4000"];
72
- const hasApiPort = apiPorts.some((port) => url.includes(port));
73
- return isApiRequest || hasApiPort;
74
- }
75
- export {
76
- authInterceptor_client as default
77
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{t:{value:1},[Symbol.toStringTag]:{value:"Module"}});const e=require("./nuxt-v4/module.cjs.js"),s=require("./nuxt-v4/runtime/composables/useStrandsAuth.cjs.js"),t=require("./nuxt-v4/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;
package/dist/nuxt-v4.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}
@@ -1,11 +0,0 @@
1
- import { default as default2 } from "./nuxt-v4/module.es.js";
2
- import { useAuthState, useAuthUser, useStrandsAuth } from "./nuxt-v4/runtime/composables/useStrandsAuth.es.js";
3
- import { $authFetch, useAuthenticatedFetch } from "./nuxt-v4/runtime/composables/useAuthenticatedFetch.es.js";
4
- export {
5
- $authFetch,
6
- default2 as default,
7
- useAuthState,
8
- useAuthUser,
9
- useAuthenticatedFetch,
10
- useStrandsAuth
11
- };