@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.
- package/dist/StrandsUIPlugin-Bwc7jBcb.cjs.js +143 -0
- package/dist/StrandsUIPlugin-RTFzvRED.es.js +20536 -0
- package/dist/accui.css +1 -1
- package/dist/index.cjs.js +5 -1
- package/dist/index.es.js +8822 -12491
- package/dist/nuxt/module.cjs.js +23 -1
- package/dist/nuxt/module.es.js +58 -82
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.cjs.js +1 -1
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.es.js +82 -111
- package/dist/nuxt/runtime/composables/useStrandsAuth.cjs.js +1 -1
- package/dist/nuxt/runtime/composables/useStrandsAuth.es.js +30 -46
- package/dist/nuxt/runtime/middleware/auth.global.cjs.js +1 -1
- package/dist/nuxt/runtime/middleware/auth.global.es.js +28 -44
- package/dist/nuxt/runtime/plugin.client.cjs.js +1 -1
- package/dist/nuxt/runtime/plugin.client.es.js +10 -19
- package/dist/nuxt/runtime/plugin.server.cjs.js +1 -1
- package/dist/nuxt/runtime/plugin.server.es.js +8 -10
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.cjs.js +1 -1
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.es.js +27 -48
- package/dist/nuxt/types.d.ts +1 -0
- package/dist/nuxt.cjs.js +1 -1
- package/dist/nuxt.es.js +9 -9
- package/dist/types/index.d.ts +5 -0
- package/dist/useStrandsAuth-DSBvF4ky.es.js +653 -0
- package/dist/useStrandsAuth-EqbzuNAn.cjs.js +1 -0
- package/dist/useStrandsConfig-B5kp4aF9.cjs.js +1 -0
- package/dist/useStrandsConfig-CMKVW1p3.es.js +210 -0
- package/dist/vite.cjs.js +29 -1
- package/dist/vite.es.js +58 -75
- package/dist/vue/utils/modalStack.d.ts +3 -0
- package/dist/webcomponents/define-element.d.ts +3 -2
- package/package.json +2 -2
- package/dist/StrandsUIPlugin-C9rrMU2i.cjs.js +0 -1
- package/dist/StrandsUIPlugin-tl7L52hZ.es.js +0 -26130
- package/dist/useStrandsAuth-BCnUxo-R.es.js +0 -915
- package/dist/useStrandsAuth-DoJxpNLb.cjs.js +0 -1
- package/dist/useStrandsConfig-Sr6NG90B.cjs.js +0 -1
- package/dist/useStrandsConfig-fRu-OG08.es.js +0 -248
package/dist/nuxt/module.cjs.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
"use strict";const
|
|
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;
|
package/dist/nuxt/module.es.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin, addRouteMiddleware, addImports, addComponent } from "@nuxt/kit";
|
|
2
|
-
const
|
|
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:
|
|
8
|
+
autoRefresh: !0,
|
|
9
9
|
refreshInterval: 4,
|
|
10
10
|
protectedRoutes: [],
|
|
11
11
|
guestOnlyRoutes: ["/auth", "/login", "/register"],
|
|
12
|
-
devMode:
|
|
13
|
-
styles:
|
|
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:
|
|
26
|
-
async setup(
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
...
|
|
31
|
-
styles:
|
|
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
|
-
|
|
34
|
-
|
|
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: ${
|
|
45
|
-
--strands-custom-50: color-mix(in srgb, ${
|
|
46
|
-
--strands-custom-100: color-mix(in srgb, ${
|
|
47
|
-
--strands-custom-200: color-mix(in srgb, ${
|
|
48
|
-
--strands-custom-300: color-mix(in srgb, ${
|
|
49
|
-
--strands-custom-400: color-mix(in srgb, ${
|
|
50
|
-
--strands-custom-500: ${
|
|
51
|
-
--strands-custom-600: color-mix(in srgb, ${
|
|
52
|
-
--strands-custom-700: color-mix(in srgb, ${
|
|
53
|
-
--strands-custom-800: color-mix(in srgb, ${
|
|
54
|
-
--strands-custom-900: color-mix(in srgb, ${
|
|
55
|
-
--strands-custom-950: color-mix(in srgb, ${
|
|
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
|
-
|
|
59
|
-
|
|
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
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
75
|
-
src: serverPluginPath,
|
|
58
|
+
}), a({
|
|
59
|
+
src: u,
|
|
76
60
|
mode: "server"
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
src: authInterceptorPath,
|
|
61
|
+
}), a({
|
|
62
|
+
src: d,
|
|
80
63
|
mode: "client"
|
|
81
|
-
})
|
|
82
|
-
addRouteMiddleware({
|
|
64
|
+
}), g({
|
|
83
65
|
name: "auth",
|
|
84
|
-
path:
|
|
85
|
-
global:
|
|
86
|
-
})
|
|
87
|
-
|
|
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:
|
|
73
|
+
from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
|
|
94
74
|
},
|
|
95
75
|
{
|
|
96
76
|
name: "useAuthUser",
|
|
97
77
|
as: "useAuthUser",
|
|
98
|
-
from:
|
|
78
|
+
from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
|
|
99
79
|
},
|
|
100
80
|
{
|
|
101
81
|
name: "useAuthState",
|
|
102
82
|
as: "useAuthState",
|
|
103
|
-
from:
|
|
83
|
+
from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
|
|
104
84
|
},
|
|
105
85
|
{
|
|
106
86
|
name: "useAuthenticatedFetch",
|
|
107
87
|
as: "useAuthenticatedFetch",
|
|
108
|
-
from:
|
|
88
|
+
from: s.resolve(`./runtime/composables/useAuthenticatedFetch.${o}`)
|
|
109
89
|
}
|
|
110
90
|
]);
|
|
111
|
-
const
|
|
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
|
|
168
|
-
|
|
169
|
-
name:
|
|
170
|
-
export:
|
|
147
|
+
for (const e of l)
|
|
148
|
+
f({
|
|
149
|
+
name: e,
|
|
150
|
+
export: e,
|
|
171
151
|
filePath: "@strands.gg/accui"
|
|
172
152
|
});
|
|
173
|
-
|
|
174
|
-
|
|
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('${
|
|
182
|
-
const useAuthUser: typeof import('${
|
|
183
|
-
const useAuthState: typeof import('${
|
|
184
|
-
const useAuthenticatedFetch: typeof import('${
|
|
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
|
-
|
|
168
|
+
U as default
|
|
193
169
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
4
|
-
const
|
|
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 =
|
|
9
|
-
requireAuth =
|
|
10
|
-
baseURL,
|
|
11
|
-
...
|
|
12
|
-
} =
|
|
13
|
-
if (
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
25
|
-
Object.entries(
|
|
26
|
-
|
|
19
|
+
const h = c();
|
|
20
|
+
Object.entries(h).forEach(([l, T]) => {
|
|
21
|
+
f.set(l, T);
|
|
27
22
|
});
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("[Strands Auth] Failed to get auth headers:",
|
|
30
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
headers
|
|
27
|
+
const w = {
|
|
28
|
+
...y,
|
|
29
|
+
headers: f
|
|
38
30
|
};
|
|
39
|
-
let
|
|
40
|
-
if (
|
|
31
|
+
let d = await fetch(p, w);
|
|
32
|
+
if (d.status === 401 && a && t.value?.refreshToken)
|
|
41
33
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 (
|
|
51
|
-
console.error("[Strands Auth] Token refresh failed:",
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
108
|
-
get: async (
|
|
109
|
-
const { get } =
|
|
110
|
-
return
|
|
78
|
+
const R = {
|
|
79
|
+
get: async (r, t) => {
|
|
80
|
+
const { get: o } = u();
|
|
81
|
+
return o(r, t);
|
|
111
82
|
},
|
|
112
|
-
post: async (
|
|
113
|
-
const { post } =
|
|
114
|
-
return
|
|
83
|
+
post: async (r, t, o) => {
|
|
84
|
+
const { post: c } = u();
|
|
85
|
+
return c(r, t, o);
|
|
115
86
|
},
|
|
116
|
-
put: async (
|
|
117
|
-
const { put } =
|
|
118
|
-
return
|
|
87
|
+
put: async (r, t, o) => {
|
|
88
|
+
const { put: c } = u();
|
|
89
|
+
return c(r, t, o);
|
|
119
90
|
},
|
|
120
|
-
delete: async (
|
|
121
|
-
const { delete:
|
|
122
|
-
return
|
|
91
|
+
delete: async (r, t) => {
|
|
92
|
+
const { delete: o } = u();
|
|
93
|
+
return o(r, t);
|
|
123
94
|
},
|
|
124
|
-
patch: async (
|
|
125
|
-
const { patch } =
|
|
126
|
-
return
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("nuxt/app"),a=require("../../../useStrandsAuth-EqbzuNAn.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
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
email:
|
|
1
|
+
import { useRuntimeConfig as e, navigateTo as a } from "nuxt/app";
|
|
2
|
+
import { u as r } from "../../../useStrandsAuth-DSBvF4ky.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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
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;
|