@strands.gg/accui 2.17.55 → 2.17.57
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/package.json +1 -1
- package/dist/StrandsUIPlugin-CSsUxobq.es.js +0 -20558
- package/dist/StrandsUIPlugin-fvlbvZ-P.cjs.js +0 -143
- package/dist/accui.css +0 -1
- package/dist/index.cjs.js +0 -5
- package/dist/index.d.ts +0 -7
- package/dist/index.es.js +0 -11942
- package/dist/nuxt/module.cjs.js +0 -23
- package/dist/nuxt/module.d.ts +0 -4
- package/dist/nuxt/module.es.js +0 -170
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.cjs.js +0 -1
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.d.ts +0 -20
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.es.js +0 -103
- package/dist/nuxt/runtime/composables/useStrandsAuth.cjs.js +0 -1
- package/dist/nuxt/runtime/composables/useStrandsAuth.d.ts +0 -66
- package/dist/nuxt/runtime/composables/useStrandsAuth.es.js +0 -40
- package/dist/nuxt/runtime/middleware/auth.d.ts +0 -6
- package/dist/nuxt/runtime/middleware/auth.global.cjs.js +0 -1
- package/dist/nuxt/runtime/middleware/auth.global.d.ts +0 -2
- package/dist/nuxt/runtime/middleware/auth.global.es.js +0 -35
- package/dist/nuxt/runtime/middleware/guest.d.ts +0 -6
- package/dist/nuxt/runtime/plugin.client.cjs.js +0 -1
- package/dist/nuxt/runtime/plugin.client.d.ts +0 -2
- package/dist/nuxt/runtime/plugin.client.es.js +0 -21
- package/dist/nuxt/runtime/plugin.server.cjs.js +0 -1
- package/dist/nuxt/runtime/plugin.server.d.ts +0 -2
- package/dist/nuxt/runtime/plugin.server.es.js +0 -15
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.cjs.js +0 -1
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.d.ts +0 -2
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.es.js +0 -55
- package/dist/nuxt/types.d.ts +0 -51
- package/dist/nuxt.cjs.js +0 -1
- package/dist/nuxt.d.ts +0 -4
- package/dist/nuxt.es.js +0 -11
- package/dist/robots.txt +0 -4
- package/dist/shared/defaults.d.ts +0 -2
- package/dist/sitemap.xml +0 -9
- package/dist/types/composables.d.ts +0 -97
- package/dist/types/index.d.ts +0 -255
- package/dist/useDarkMode-Cew-NWjS.cjs.js +0 -1
- package/dist/useDarkMode-CvinMR9O.es.js +0 -102
- package/dist/useStrandsAuth-CmAxFCQ_.cjs.js +0 -1
- package/dist/useStrandsAuth-DWsqp9WI.es.js +0 -661
- package/dist/useStrandsConfig-CKLyNlSd.es.js +0 -207
- package/dist/useStrandsConfig-nOR0oGdb.cjs.js +0 -1
- package/dist/utils/colors.d.ts +0 -10
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/slots.d.ts +0 -1
- package/dist/utils/validation.d.ts +0 -12
- package/dist/vite/index.d.ts +0 -2
- package/dist/vite/plugin.d.ts +0 -68
- package/dist/vite.cjs.js +0 -29
- package/dist/vite.es.js +0 -92
- package/dist/vue/components/StrandsNav/index.d.ts +0 -8
- package/dist/vue/components/StrandsNav/types.d.ts +0 -12
- package/dist/vue/components/icons/index.d.ts +0 -2
- package/dist/vue/components/index.d.ts +0 -27
- package/dist/vue/composables/useAuthenticatedFetch.d.ts +0 -20
- package/dist/vue/composables/useDarkMode.d.ts +0 -48
- package/dist/vue/composables/useFloatingPosition.d.ts +0 -22
- package/dist/vue/composables/useModalStack.d.ts +0 -86
- package/dist/vue/composables/useOAuthProviders.d.ts +0 -73
- package/dist/vue/composables/useStrandsAuth.d.ts +0 -2
- package/dist/vue/composables/useStrandsConfig.d.ts +0 -5
- package/dist/vue/composables/useStrandsMfa.d.ts +0 -36
- package/dist/vue/composables/useTheme.d.ts +0 -18
- package/dist/vue/index.d.ts +0 -16
- package/dist/vue/plugins/StrandsUIPlugin.d.ts +0 -20
- package/dist/vue/ui/UiButton/index.d.ts +0 -11
- package/dist/vue/ui/index.d.ts +0 -54
- package/dist/vue/utils/contrast.d.ts +0 -75
- package/dist/vue/utils/debounce.d.ts +0 -12
- package/dist/vue/utils/fontPreloader.d.ts +0 -11
- package/dist/vue/utils/iconProps.d.ts +0 -9
- package/dist/vue/utils/lazyComponents.d.ts +0 -4
- package/dist/vue/utils/levels.d.ts +0 -27
- package/dist/vue/utils/modalStack.d.ts +0 -34
- package/dist/vue/utils/performanceInit.d.ts +0 -40
- package/dist/vue/utils/requestCache.d.ts +0 -49
- package/dist/vue/utils/slots.d.ts +0 -9
- package/dist/vue/utils/sounds.d.ts +0 -57
- package/dist/webcomponents/define-element.d.ts +0 -25
- package/dist/webcomponents/entries/strands-alert.d.ts +0 -12
- package/dist/webcomponents/entries/strands-button.d.ts +0 -12
- package/dist/webcomponents/entries/strands-card.d.ts +0 -12
- package/dist/webcomponents/entries/strands-checkbox-group.d.ts +0 -11
- package/dist/webcomponents/entries/strands-divider.d.ts +0 -12
- package/dist/webcomponents/entries/strands-input.d.ts +0 -14
- package/dist/webcomponents/entries/strands-link.d.ts +0 -12
- package/dist/webcomponents/entries/strands-loader-spinner.d.ts +0 -10
- package/dist/webcomponents/entries/strands-modal.d.ts +0 -16
- package/dist/webcomponents/entries/strands-pill.d.ts +0 -11
- package/dist/webcomponents/entries/strands-radio-group.d.ts +0 -11
- package/dist/webcomponents/entries/strands-slider.d.ts +0 -10
- package/dist/webcomponents/entries/strands-table.d.ts +0 -13
- package/dist/webcomponents/entries/strands-tabs.d.ts +0 -12
- package/dist/webcomponents/entries/strands-theme-toggle.d.ts +0 -10
- package/dist/webcomponents/entries/strands-toggle.d.ts +0 -10
- package/dist/webcomponents/entries/strands-tooltip.d.ts +0 -12
- package/dist/webcomponents/index.d.ts +0 -8
- package/dist/webcomponents/loader.d.ts +0 -73
- package/dist/webcomponents/registry.d.ts +0 -41
package/dist/nuxt/module.cjs.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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:"",theme:"system"},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.d.ts
DELETED
package/dist/nuxt/module.es.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
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
|
-
baseUrl: "https://your-api.example.com",
|
|
4
|
-
accentColor: "#EA00A8",
|
|
5
|
-
redirectUrl: "/",
|
|
6
|
-
onSignInUrl: "/dashboard",
|
|
7
|
-
onSignOutUrl: "/",
|
|
8
|
-
autoRefresh: !0,
|
|
9
|
-
refreshInterval: 4,
|
|
10
|
-
protectedRoutes: [],
|
|
11
|
-
guestOnlyRoutes: ["/auth", "/login", "/register"],
|
|
12
|
-
devMode: !1,
|
|
13
|
-
styles: !0,
|
|
14
|
-
supportEmail: "",
|
|
15
|
-
oauth2RedirectUrl: "",
|
|
16
|
-
theme: "system"
|
|
17
|
-
}, U = p({
|
|
18
|
-
meta: {
|
|
19
|
-
name: "@strands.gg/accui/nuxt",
|
|
20
|
-
configKey: "strandsAuth",
|
|
21
|
-
compatibility: {
|
|
22
|
-
nuxt: "^3.0.0 || ^4.0.0"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
defaults: b,
|
|
26
|
-
async setup(r, t) {
|
|
27
|
-
const s = h(import.meta.url);
|
|
28
|
-
t.options.runtimeConfig.public = t.options.runtimeConfig.public || {};
|
|
29
|
-
const n = {
|
|
30
|
-
...r,
|
|
31
|
-
styles: r.styles !== !1
|
|
32
|
-
};
|
|
33
|
-
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") {
|
|
34
|
-
const e = r.accentColor, m = `
|
|
35
|
-
:root {
|
|
36
|
-
--strands-custom-accent: ${e};
|
|
37
|
-
--strands-custom-50: color-mix(in srgb, ${e} 10%, white);
|
|
38
|
-
--strands-custom-100: color-mix(in srgb, ${e} 20%, white);
|
|
39
|
-
--strands-custom-200: color-mix(in srgb, ${e} 30%, white);
|
|
40
|
-
--strands-custom-300: color-mix(in srgb, ${e} 40%, white);
|
|
41
|
-
--strands-custom-400: color-mix(in srgb, ${e} 70%, white);
|
|
42
|
-
--strands-custom-500: ${e};
|
|
43
|
-
--strands-custom-600: color-mix(in srgb, ${e} 85%, black);
|
|
44
|
-
--strands-custom-700: color-mix(in srgb, ${e} 70%, black);
|
|
45
|
-
--strands-custom-800: color-mix(in srgb, ${e} 55%, black);
|
|
46
|
-
--strands-custom-900: color-mix(in srgb, ${e} 40%, black);
|
|
47
|
-
--strands-custom-950: color-mix(in srgb, ${e} 25%, black);
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
t.options.app.head = t.options.app.head || {}, t.options.app.head.style = t.options.app.head.style || [], t.options.app.head.style.unshift({
|
|
51
|
-
innerHTML: m,
|
|
52
|
-
key: "strands-accent-override"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
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}`);
|
|
56
|
-
a({
|
|
57
|
-
src: i,
|
|
58
|
-
mode: "client"
|
|
59
|
-
}), a({
|
|
60
|
-
src: u,
|
|
61
|
-
mode: "server"
|
|
62
|
-
}), a({
|
|
63
|
-
src: d,
|
|
64
|
-
mode: "client"
|
|
65
|
-
}), g({
|
|
66
|
-
name: "auth",
|
|
67
|
-
path: c,
|
|
68
|
-
global: !0
|
|
69
|
-
}), t.hook("pages:extend", () => {
|
|
70
|
-
}), S([
|
|
71
|
-
{
|
|
72
|
-
name: "useStrandsAuth",
|
|
73
|
-
as: "useStrandsAuth",
|
|
74
|
-
from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "useAuthUser",
|
|
78
|
-
as: "useAuthUser",
|
|
79
|
-
from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "useAuthState",
|
|
83
|
-
as: "useAuthState",
|
|
84
|
-
from: s.resolve(`./runtime/composables/useStrandsAuth.${o}`)
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "useAuthenticatedFetch",
|
|
88
|
-
as: "useAuthenticatedFetch",
|
|
89
|
-
from: s.resolve(`./runtime/composables/useAuthenticatedFetch.${o}`)
|
|
90
|
-
}
|
|
91
|
-
]);
|
|
92
|
-
const l = [
|
|
93
|
-
// Strands Auth Components
|
|
94
|
-
"StrandsAuth",
|
|
95
|
-
"StrandsSignIn",
|
|
96
|
-
"StrandsSignUp",
|
|
97
|
-
"StrandsCompleteSignUp",
|
|
98
|
-
"StrandsUserProfile",
|
|
99
|
-
"StrandsUserButton",
|
|
100
|
-
"StrandsPasswordReset",
|
|
101
|
-
"StrandsMFASetup",
|
|
102
|
-
"StrandsMfaVerification",
|
|
103
|
-
"StrandsMfaModal",
|
|
104
|
-
"StrandsBackupCodesModal",
|
|
105
|
-
"StrandsConfirmModal",
|
|
106
|
-
"StrandsEmailMfaSetupModal",
|
|
107
|
-
"StrandsHardwareKeySetupModal",
|
|
108
|
-
"StrandsSessionsModal",
|
|
109
|
-
"StrandsSettingsModal",
|
|
110
|
-
"StrandsTotpSetupModal",
|
|
111
|
-
"StrandsConfigProvider",
|
|
112
|
-
"SignedIn",
|
|
113
|
-
"StrandsLogo",
|
|
114
|
-
"StrandsSecuredFooter",
|
|
115
|
-
"StrandsNav",
|
|
116
|
-
"StrandsNavItem",
|
|
117
|
-
// UI Components
|
|
118
|
-
"UiAlert",
|
|
119
|
-
"UiApp",
|
|
120
|
-
"UiAvatarEditor",
|
|
121
|
-
"UiButton",
|
|
122
|
-
"UiCard",
|
|
123
|
-
"UiCheckboxGroup",
|
|
124
|
-
"UiColorPicker",
|
|
125
|
-
"UiDateTimePicker",
|
|
126
|
-
"UiDivider",
|
|
127
|
-
"UiHero",
|
|
128
|
-
"UiInput",
|
|
129
|
-
"UiLevelProgress",
|
|
130
|
-
"UiLink",
|
|
131
|
-
"UiLoader",
|
|
132
|
-
"UiModal",
|
|
133
|
-
"UiPill",
|
|
134
|
-
"UiRadioGroup",
|
|
135
|
-
"UiSlider",
|
|
136
|
-
"UiTable",
|
|
137
|
-
"UiTabs",
|
|
138
|
-
"UiThemeToggle",
|
|
139
|
-
"UiToggle",
|
|
140
|
-
"UiTooltip",
|
|
141
|
-
// Utility Components
|
|
142
|
-
"VirtualList",
|
|
143
|
-
"SvgIcon",
|
|
144
|
-
// Icons
|
|
145
|
-
"IconGithub",
|
|
146
|
-
"IconGoogle"
|
|
147
|
-
];
|
|
148
|
-
for (const e of l)
|
|
149
|
-
f({
|
|
150
|
-
name: e,
|
|
151
|
-
export: e,
|
|
152
|
-
filePath: "@strands.gg/accui"
|
|
153
|
-
});
|
|
154
|
-
t.hook("prepare:types", (e) => {
|
|
155
|
-
e.references.push({
|
|
156
|
-
types: "@strands.gg/auth-nuxt"
|
|
157
|
-
}), e.declarations && e.declarations.push(`
|
|
158
|
-
declare global {
|
|
159
|
-
const useStrandsAuth: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useStrandsAuth']
|
|
160
|
-
const useAuthUser: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthUser']
|
|
161
|
-
const useAuthState: typeof import('${s.resolve("./runtime/composables/useStrandsAuth.d.ts")}')['useAuthState']
|
|
162
|
-
const useAuthenticatedFetch: typeof import('${s.resolve("./runtime/composables/useAuthenticatedFetch.d.ts")}')['useAuthenticatedFetch']
|
|
163
|
-
}
|
|
164
|
-
`);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
export {
|
|
169
|
-
U as default
|
|
170
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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,20 +0,0 @@
|
|
|
1
|
-
import type { AuthenticatedFetchOptions } from '../../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Enhanced fetch composable that automatically includes auth headers
|
|
4
|
-
* and handles token refresh for API requests
|
|
5
|
-
*/
|
|
6
|
-
export declare function useAuthenticatedFetch(): {
|
|
7
|
-
authenticatedFetch: (url: string | URL, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
8
|
-
get: (url: string | URL, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
9
|
-
post: (url: string | URL, body?: any, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
10
|
-
put: (url: string | URL, body?: any, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
11
|
-
delete: (url: string | URL, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
12
|
-
patch: (url: string | URL, body?: any, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
13
|
-
};
|
|
14
|
-
export declare const $authFetch: {
|
|
15
|
-
get: (url: string | URL, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
16
|
-
post: (url: string | URL, body?: any, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
17
|
-
put: (url: string | URL, body?: any, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
18
|
-
delete: (url: string | URL, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
19
|
-
patch: (url: string | URL, body?: any, options?: AuthenticatedFetchOptions) => Promise<Response>;
|
|
20
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
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 = {}) => {
|
|
5
|
-
const {
|
|
6
|
-
autoRefresh: a = !0,
|
|
7
|
-
requireAuth: n = !0,
|
|
8
|
-
baseURL: j,
|
|
9
|
-
...y
|
|
10
|
-
} = e;
|
|
11
|
-
if (n && !t.value?.accessToken)
|
|
12
|
-
throw new Error("User is not authenticated");
|
|
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)
|
|
18
|
-
try {
|
|
19
|
-
const h = c();
|
|
20
|
-
Object.entries(h).forEach(([l, T]) => {
|
|
21
|
-
f.set(l, T);
|
|
22
|
-
});
|
|
23
|
-
} catch (h) {
|
|
24
|
-
if (console.warn("[Strands Auth] Failed to get auth headers:", h), n)
|
|
25
|
-
throw h;
|
|
26
|
-
}
|
|
27
|
-
const w = {
|
|
28
|
-
...y,
|
|
29
|
-
headers: f
|
|
30
|
-
};
|
|
31
|
-
let d = await fetch(p, w);
|
|
32
|
-
if (d.status === 401 && a && t.value?.refreshToken)
|
|
33
|
-
try {
|
|
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 });
|
|
39
|
-
}
|
|
40
|
-
} catch (h) {
|
|
41
|
-
console.error("[Strands Auth] Token refresh failed:", h);
|
|
42
|
-
}
|
|
43
|
-
return d;
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
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
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
const R = {
|
|
79
|
-
get: async (r, t) => {
|
|
80
|
-
const { get: o } = u();
|
|
81
|
-
return o(r, t);
|
|
82
|
-
},
|
|
83
|
-
post: async (r, t, o) => {
|
|
84
|
-
const { post: c } = u();
|
|
85
|
-
return c(r, t, o);
|
|
86
|
-
},
|
|
87
|
-
put: async (r, t, o) => {
|
|
88
|
-
const { put: c } = u();
|
|
89
|
-
return c(r, t, o);
|
|
90
|
-
},
|
|
91
|
-
delete: async (r, t) => {
|
|
92
|
-
const { delete: o } = u();
|
|
93
|
-
return o(r, t);
|
|
94
|
-
},
|
|
95
|
-
patch: async (r, t, o) => {
|
|
96
|
-
const { patch: c } = u();
|
|
97
|
-
return c(r, t, o);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
export {
|
|
101
|
-
R as $authFetch,
|
|
102
|
-
u as useAuthenticatedFetch
|
|
103
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("nuxt/app"),a=require("../../../useStrandsAuth-CmAxFCQ_.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,66 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef } from 'vue';
|
|
2
|
-
import type { User } from '../../../types';
|
|
3
|
-
export declare const useStrandsAuth: () => {
|
|
4
|
-
initialize: () => Promise<void>;
|
|
5
|
-
signIn: (credentials: {
|
|
6
|
-
email: string;
|
|
7
|
-
password: string;
|
|
8
|
-
}) => Promise<any>;
|
|
9
|
-
signUp: (userData: {
|
|
10
|
-
email: string;
|
|
11
|
-
}) => Promise<void>;
|
|
12
|
-
signOut: () => Promise<void>;
|
|
13
|
-
user: ComputedRef<User | null>;
|
|
14
|
-
currentUser: ComputedRef<User | null>;
|
|
15
|
-
currentSession: ComputedRef<import("../../..").Session | null>;
|
|
16
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
17
|
-
isLoading: ComputedRef<boolean>;
|
|
18
|
-
loading: ComputedRef<boolean>;
|
|
19
|
-
loadingMessage: ComputedRef<string>;
|
|
20
|
-
isInitializing: ComputedRef<boolean>;
|
|
21
|
-
isInitialized: ComputedRef<boolean>;
|
|
22
|
-
isSigningIn: ComputedRef<boolean>;
|
|
23
|
-
isSigningUp: ComputedRef<boolean>;
|
|
24
|
-
isSigningOut: ComputedRef<boolean>;
|
|
25
|
-
isRefreshingToken: ComputedRef<boolean>;
|
|
26
|
-
isSendingMfaEmail: ComputedRef<boolean>;
|
|
27
|
-
isVerifyingMfa: ComputedRef<boolean>;
|
|
28
|
-
mfaRequired: ComputedRef<boolean>;
|
|
29
|
-
mfaSessionId: ComputedRef<string | null>;
|
|
30
|
-
availableMfaMethods: ComputedRef<import("../../..").MfaDevice[]>;
|
|
31
|
-
refreshToken: () => Promise<boolean>;
|
|
32
|
-
fetchProfile: () => Promise<User>;
|
|
33
|
-
updateProfile: (updates: Partial<User>) => Promise<User>;
|
|
34
|
-
updateUserSettings: (settings: any) => Promise<User>;
|
|
35
|
-
changeEmail: (newEmail: string, password: string) => Promise<void>;
|
|
36
|
-
changeUsername: (newUsername: string) => Promise<void>;
|
|
37
|
-
getUsernameCooldown: () => Promise<{
|
|
38
|
-
canChange: boolean;
|
|
39
|
-
cooldownEndsAt?: Date;
|
|
40
|
-
}>;
|
|
41
|
-
checkUsernameAvailability: (username: string) => Promise<{
|
|
42
|
-
available: boolean;
|
|
43
|
-
suggestion?: string;
|
|
44
|
-
}>;
|
|
45
|
-
getUserSessions: () => Promise<import("../../..").SessionInfo[]>;
|
|
46
|
-
getSessionStats: () => Promise<import("../../..").SessionStats>;
|
|
47
|
-
revokeSession: (sessionId: string) => Promise<boolean>;
|
|
48
|
-
revokeAllOtherSessions: () => Promise<boolean>;
|
|
49
|
-
forceReInit: () => void;
|
|
50
|
-
setAuthData: (authData: any) => Promise<void>;
|
|
51
|
-
verifyMfa: (code: string, method?: string) => Promise<any>;
|
|
52
|
-
sendMfaEmailCode: (deviceId: string) => Promise<any>;
|
|
53
|
-
getMfaWebAuthnChallenge: (deviceId: string) => Promise<any>;
|
|
54
|
-
registerHardwareKey: (deviceName: string, accessToken: string, deviceType?: "hardware" | "passkey") => Promise<any>;
|
|
55
|
-
completeHardwareKeyRegistration: (deviceId: string, credential: any, accessToken: string) => Promise<any>;
|
|
56
|
-
startTokenRefreshTimer: () => void;
|
|
57
|
-
stopTokenRefreshTimer: () => void;
|
|
58
|
-
getAuthHeaders: () => Record<string, string>;
|
|
59
|
-
};
|
|
60
|
-
export declare const useAuthUser: () => {
|
|
61
|
-
user: ComputedRef<User | null>;
|
|
62
|
-
};
|
|
63
|
-
export declare const useAuthState: () => {
|
|
64
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
65
|
-
isLoading: ComputedRef<boolean>;
|
|
66
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useRuntimeConfig as e, navigateTo as a } from "nuxt/app";
|
|
2
|
-
import { u as r } from "../../../useStrandsAuth-DWsqp9WI.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
|
-
password: "",
|
|
20
|
-
// Empty password for magic link
|
|
21
|
-
firstName: "",
|
|
22
|
-
// Will be filled later in the magic link flow
|
|
23
|
-
lastName: ""
|
|
24
|
-
}),
|
|
25
|
-
signOut: async () => {
|
|
26
|
-
await t.signOut(), n.onSignOutUrl && await a(n.onSignOutUrl);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
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 };
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
f as useAuthState,
|
|
38
|
-
U as useAuthUser,
|
|
39
|
-
u as useStrandsAuth
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("nuxt/app"),g=r.defineNuxtRouteMiddleware(c=>{const n=r.useRuntimeConfig().public.strandsAuth;return new Promise(a=>{Promise.resolve().then(()=>require("../composables/useStrandsAuth.cjs.js")).then(({useStrandsAuth:d})=>{const{isAuthenticated:i,isLoading:l}=d(),o=()=>{if(l.value){setTimeout(o,50);return}const e=c.path,h=n.protectedRoutes?.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(t+"/")),f=n.guestOnlyRoutes?.some(t=>t.endsWith("*")?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(t+"/"));if(h&&!i.value&&n.authUrl){const t=n.authUrl,s=t.includes("?")?`${t}&redirect=${encodeURIComponent(e)}`:`${t}?redirect=${encodeURIComponent(e)}`;try{return r.navigateTo(s)}catch(u){if(console.warn("[Strands Auth] navigateTo failed, using window.location:",u),typeof window<"u"){window.location.href=s;return}throw u}}if(f&&i.value&&n.onSignInUrl)return r.navigateTo(n.onSignInUrl);a()};o()})})});module.exports=g;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { defineNuxtRouteMiddleware as m, useRuntimeConfig as g, navigateTo as u } from "nuxt/app";
|
|
2
|
-
const w = m((a) => {
|
|
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;
|
|
11
|
-
}
|
|
12
|
-
const e = a.path, h = n.protectedRoutes?.some((t) => t.endsWith("*") ? e.startsWith(t.slice(0, -1)) : e === t || e.startsWith(t + "/")), f = n.guestOnlyRoutes?.some((t) => t.endsWith("*") ? e.startsWith(t.slice(0, -1)) : e === t || e.startsWith(t + "/"));
|
|
13
|
-
if (h && !r.value && n.authUrl) {
|
|
14
|
-
const t = n.authUrl, o = t.includes("?") ? `${t}&redirect=${encodeURIComponent(e)}` : `${t}?redirect=${encodeURIComponent(e)}`;
|
|
15
|
-
try {
|
|
16
|
-
return u(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;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (f && r.value && n.onSignInUrl)
|
|
26
|
-
return u(n.onSignInUrl);
|
|
27
|
-
c();
|
|
28
|
-
};
|
|
29
|
-
i();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
export {
|
|
34
|
-
w as default
|
|
35
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("nuxt/app"),t=require("../../useStrandsConfig-nOR0oGdb.cjs.js"),d=require("../../useDarkMode-Cew-NWjS.cjs.js"),c=n.defineNuxtPlugin({name:"strands-auth-client",async setup(){const o=n.useRuntimeConfig().public.strandsAuth,e={...t.STRANDS_AUTH_DEFAULTS,...o};if(t.setStrandsConfig(e),typeof window<"u"&&(window.__STRANDS_CONFIG__=e),e?.accentColor&&typeof window<"u"&&document.documentElement.style.setProperty("--strands-accent",e.accentColor),typeof window<"u"){const r=e?.theme||"system";d.useGlobalDarkMode().setTheme(r)}const{useStrandsAuth:s}=await Promise.resolve().then(()=>require("./composables/useStrandsAuth.cjs.js")),{initialize:i}=s();await i()}});module.exports=c;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineNuxtPlugin as s, useRuntimeConfig as a } from "nuxt/app";
|
|
2
|
-
import { s as d, S as c } from "../../useStrandsConfig-CKLyNlSd.es.js";
|
|
3
|
-
import { u as r } from "../../useDarkMode-CvinMR9O.es.js";
|
|
4
|
-
const g = s({
|
|
5
|
-
name: "strands-auth-client",
|
|
6
|
-
async setup() {
|
|
7
|
-
const e = a().public.strandsAuth, t = {
|
|
8
|
-
...c,
|
|
9
|
-
...e
|
|
10
|
-
};
|
|
11
|
-
if (d(t), typeof window < "u" && (window.__STRANDS_CONFIG__ = t), t?.accentColor && typeof window < "u" && document.documentElement.style.setProperty("--strands-accent", t.accentColor), typeof window < "u") {
|
|
12
|
-
const i = t?.theme || "system";
|
|
13
|
-
r().setTheme(i);
|
|
14
|
-
}
|
|
15
|
-
const { useStrandsAuth: n } = await import("./composables/useStrandsAuth.es.js"), { initialize: o } = n();
|
|
16
|
-
await o();
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
export {
|
|
20
|
-
g as default
|
|
21
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("nuxt/app"),s=require("../../useStrandsConfig-nOR0oGdb.cjs.js"),r=n.defineNuxtPlugin({name:"strands-auth-server",setup(){const e=n.useRuntimeConfig().public.strandsAuth,t={...s.STRANDS_AUTH_DEFAULTS,...e};s.setStrandsConfig(t)}});module.exports=r;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineNuxtPlugin as t, useRuntimeConfig as e } from "nuxt/app";
|
|
2
|
-
import { s as o, S as r } from "../../useStrandsConfig-CKLyNlSd.es.js";
|
|
3
|
-
const u = t({
|
|
4
|
-
name: "strands-auth-server",
|
|
5
|
-
setup() {
|
|
6
|
-
const s = e().public.strandsAuth, n = {
|
|
7
|
-
...r,
|
|
8
|
-
...s
|
|
9
|
-
};
|
|
10
|
-
o(n);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
export {
|
|
14
|
-
u as default
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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,55 +0,0 @@
|
|
|
1
|
-
import { defineNuxtPlugin as p } from "nuxt/app";
|
|
2
|
-
const g = p({
|
|
3
|
-
name: "strands-auth-interceptor",
|
|
4
|
-
setup() {
|
|
5
|
-
if (process.server) return;
|
|
6
|
-
const e = globalThis.fetch;
|
|
7
|
-
globalThis.fetch = async (t, o) => {
|
|
8
|
-
try {
|
|
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)
|
|
12
|
-
try {
|
|
13
|
-
const n = i(), h = new Headers(o?.headers);
|
|
14
|
-
Object.entries(n).forEach(([d, l]) => {
|
|
15
|
-
h.set(d, l);
|
|
16
|
-
});
|
|
17
|
-
const u = {
|
|
18
|
-
...o,
|
|
19
|
-
headers: h
|
|
20
|
-
};
|
|
21
|
-
return e(t, u);
|
|
22
|
-
} catch (n) {
|
|
23
|
-
console.warn("[Strands Auth] Failed to inject auth headers:", n);
|
|
24
|
-
}
|
|
25
|
-
return e(t, o);
|
|
26
|
-
} catch (a) {
|
|
27
|
-
return console.error("[Strands Auth] Error in fetch interceptor:", a), e(t, o);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
function f(e) {
|
|
33
|
-
if (!e.startsWith("http") || [
|
|
34
|
-
"googleapis.com",
|
|
35
|
-
"github.com/api",
|
|
36
|
-
"api.github.com",
|
|
37
|
-
"discord.com/api",
|
|
38
|
-
"graph.microsoft.com",
|
|
39
|
-
"api.stripe.com",
|
|
40
|
-
"api.twilio.com"
|
|
41
|
-
// Add other third-party APIs here
|
|
42
|
-
].some((r) => e.includes(r)))
|
|
43
|
-
return !1;
|
|
44
|
-
const c = [
|
|
45
|
-
"/api/",
|
|
46
|
-
"/v1/",
|
|
47
|
-
"/v2/",
|
|
48
|
-
"/graphql",
|
|
49
|
-
"/trpc"
|
|
50
|
-
].some((r) => e.includes(r)), s = [":3001", ":8000", ":8080", ":5000", ":4000"].some((r) => e.includes(r));
|
|
51
|
-
return c || s;
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
g as default
|
|
55
|
-
};
|