@strands.gg/accui 2.9.0 → 2.9.1
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/accui.css +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.es.js +40821 -0
- package/dist/nuxt/module.cjs.js +1 -0
- package/dist/nuxt/module.es.js +193 -0
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.cjs.js +1 -0
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.es.js +134 -0
- package/dist/nuxt/runtime/composables/useStrandsAuth.cjs.js +1 -0
- package/dist/nuxt/runtime/composables/useStrandsAuth.es.js +56 -0
- package/dist/nuxt/runtime/middleware/auth.global.cjs.js +1 -0
- package/dist/nuxt/runtime/middleware/auth.global.es.js +54 -0
- package/dist/nuxt/runtime/plugin.client.cjs.js +1 -0
- package/dist/nuxt/runtime/plugin.client.es.js +26 -0
- package/dist/nuxt/runtime/plugin.server.cjs.js +1 -0
- package/dist/nuxt/runtime/plugin.server.es.js +17 -0
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.cjs.js +1 -0
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.es.js +77 -0
- package/dist/nuxt.cjs.js +1 -0
- package/dist/nuxt.es.js +11 -0
- package/dist/useStrandsAuth-Bp5aTR3h.cjs.js +1 -0
- package/dist/useStrandsAuth-Xz8lnhv7.es.js +916 -0
- package/dist/useStrandsConfig-CLSzvTvE.cjs.js +1 -0
- package/dist/useStrandsConfig-XmPqJn_B.es.js +241 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),i={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,endpoints:{},useSquircle:1},a=Symbol("strands-config"),s=e.ref(null);function t(e){if("undefined"==typeof window||!document.documentElement)return;if("undefined"!=typeof CSS&&CSS.registerProperty)try{CSS.registerProperty({name:"--strands-accent",syntax:"<color>",inherits:1,initialValue:e})}catch(a){}document.documentElement.style.setProperty("--strands-accent",e),document.documentElement.style.setProperty("--accui-strands-accent",e);const i={"--accui-strands-50":`color-mix(in srgb, ${e} 10%, white)`,"--accui-strands-100":`color-mix(in srgb, ${e} 20%, white)`,"--accui-strands-200":`color-mix(in srgb, ${e} 30%, white)`,"--accui-strands-300":`color-mix(in srgb, ${e} 40%, white)`,"--accui-strands-400":`color-mix(in srgb, ${e} 70%, white)`,"--accui-strands-500":e,"--accui-strands-600":`color-mix(in srgb, ${e} 85%, black)`,"--accui-strands-700":`color-mix(in srgb, ${e} 70%, black)`,"--accui-strands-800":`color-mix(in srgb, ${e} 55%, black)`,"--accui-strands-900":`color-mix(in srgb, ${e} 40%, black)`,"--accui-strands-950":`color-mix(in srgb, ${e} 25%, black)`};for(const[s,t]of Object.entries(i))document.documentElement.style.setProperty(s,t)}exports.STRANDS_AUTH_DEFAULTS=i,exports.provideStrandsConfig=function(i){if(s.value=i,"undefined"!=typeof window&&document.documentElement){const e=void 0!==i.useSquircle?i.useSquircle:1;document.documentElement.style.setProperty("--strands-allow-squircle",e?"1":"0"),i.accentColor&&t(i.accentColor)}try{e.provide(a,i)}catch(n){}},exports.setStrandsConfig=function(e){if(s.value=e,"undefined"!=typeof window&&document.documentElement){const i=void 0!==e.useSquircle?e.useSquircle:1;document.documentElement.style.setProperty("--strands-allow-squircle",i?"1":"0"),e.accentColor&&t(e.accentColor)}},exports.useStrandsConfig=function(t){let n=null;try{e.getCurrentInstance()&&(n=e.inject(a,null))}catch(u){n=null}let r=null;try{if("undefined"!=typeof window)if(window.__STRANDS_CONFIG__)r=window.__STRANDS_CONFIG__;else if(window.__NUXT__){const e=window.__NUXT__;r=e?.config?.public?.strandsAuth||e?.public?.strandsAuth||e?.strandsAuth}}catch(u){}const o=e.computed(()=>{const e={...i,...t||{},...n||{},...s.value||{},...r||{}};if(e.baseUrl,"undefined"!=typeof window&&document.documentElement){const i=void 0!==e.useSquircle?e.useSquircle:1;document.documentElement.style.setProperty("--strands-allow-squircle",i?"1":"0"),e.accentColor&&document.documentElement.style.setProperty("--strands-accent",e.accentColor)}return e}),c=e.computed(()=>{const e=o.value.endpoints||{};return{signIn:e.signIn||"/api/v1/auth/sign-in",signUp:e.signUp||"/api/v1/auth/sign-up",signOut:e.signOut||"/api/v1/auth/sign-out",refresh:e.refresh||"/api/v1/auth/refresh",passwordReset:e.passwordReset||"/api/v1/auth/password-reset",passwordResetConfirm:e.passwordResetConfirm||"/api/v1/auth/password-reset/confirm",completeRegistration:e.completeRegistration||"/api/v1/auth/complete-registration",profile:e.profile||"/api/v1/user/profile",verifyEmail:e.verifyEmail||"/api/v1/auth/verify-email",oauthProviders:e.oauthProviders||"/api/v1/oauth/providers",oauthProvider:e.oauthProvider||"/api/v1/oauth/providers/{provider_id}",changeEmail:e.changeEmail||"/api/v1/user/change-email",avatar:e.avatar||"/api/v1/user/avatar",settings:e.settings||"/api/v1/user/settings",changeUsername:e.changeUsername||"/api/v1/user/username",usernameCooldown:e.usernameCooldown||"/api/v1/user/username/cooldown",checkUsernameAvailability:e.checkUsernameAvailability||"/api/v1/username/{username}/available",mfaDevices:e.mfaDevices||"/api/v1/mfa/devices",mfaTotpSetup:e.mfaTotpSetup||"/api/v1/mfa/totp/setup",mfaTotpVerify:e.mfaTotpVerify||"/api/v1/mfa/totp/verify",mfaEmailSetup:e.mfaEmailSetup||"/api/v1/mfa/email/setup",mfaEmailSend:e.mfaEmailSend||"/api/v1/mfa/email/send",mfaEmailVerify:e.mfaEmailVerify||"/api/v1/mfa/email/verify",mfaDeviceDisable:e.mfaDeviceDisable||"/api/v1/mfa/device/disable",mfaBackupCodes:e.mfaBackupCodes||"/api/v1/mfa/backup-codes/regenerate",mfaHardwareStartRegistration:e.mfaHardwareStartRegistration||"/api/v1/mfa/hardware/start-registration",mfaHardwareCompleteRegistration:e.mfaHardwareCompleteRegistration||"/api/v1/mfa/hardware/complete-registration",mfaSigninSendEmail:e.mfaSigninSendEmail||"/api/v1/auth/mfa/email/send",mfaSigninVerify:e.mfaSigninVerify||"/api/v1/auth/mfa/verify",mfaBackupCodeVerify:e.mfaBackupCodeVerify||"/api/v1/auth/mfa/backup-code/verify",mfaWebAuthnChallenge:e.mfaWebAuthnChallenge||"/api/v1/auth/mfa/webauthn/challenge",sessions:e.sessions||"/api/v1/sessions",sessionsStats:e.sessionsStats||"/api/v1/sessions/stats",sessionRevoke:e.sessionRevoke||"/api/v1/sessions/{session_id}/revoke",sessionsRevokeAll:e.sessionsRevokeAll||"/api/v1/sessions/revoke-all"}});return{config:o,endpoints:c,getUrl:e=>{const i=o.value;if(!i.baseUrl)throw new Error("Base URL is required in configuration");let a;return a="string"==typeof e&&e in c.value?c.value[e]:"string"==typeof e?e:c.value[e],`${i.baseUrl.replace(/\/$/,"")}${a.startsWith("/")?a:`/${a}`}`},getSupportEmail:()=>o.value.supportEmail||null}};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { ref, getCurrentInstance, inject, computed, provide } from "vue";
|
|
2
|
+
const STRANDS_AUTH_DEFAULTS = {
|
|
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
|
+
endpoints: {},
|
|
15
|
+
useSquircle: true
|
|
16
|
+
};
|
|
17
|
+
const DEFAULT_ENDPOINTS = {
|
|
18
|
+
signIn: "/api/v1/auth/sign-in",
|
|
19
|
+
signUp: "/api/v1/auth/sign-up",
|
|
20
|
+
signOut: "/api/v1/auth/sign-out",
|
|
21
|
+
refresh: "/api/v1/auth/refresh",
|
|
22
|
+
passwordReset: "/api/v1/auth/password-reset",
|
|
23
|
+
passwordResetConfirm: "/api/v1/auth/password-reset/confirm",
|
|
24
|
+
completeRegistration: "/api/v1/auth/complete-registration",
|
|
25
|
+
profile: "/api/v1/user/profile",
|
|
26
|
+
verifyEmail: "/api/v1/auth/verify-email",
|
|
27
|
+
oauthProviders: "/api/v1/oauth/providers",
|
|
28
|
+
oauthProvider: "/api/v1/oauth/providers/{provider_id}",
|
|
29
|
+
changeEmail: "/api/v1/user/change-email",
|
|
30
|
+
avatar: "/api/v1/user/avatar",
|
|
31
|
+
settings: "/api/v1/user/settings",
|
|
32
|
+
// Username endpoints
|
|
33
|
+
changeUsername: "/api/v1/user/username",
|
|
34
|
+
usernameCooldown: "/api/v1/user/username/cooldown",
|
|
35
|
+
checkUsernameAvailability: "/api/v1/username/{username}/available",
|
|
36
|
+
// MFA endpoints
|
|
37
|
+
mfaDevices: "/api/v1/mfa/devices",
|
|
38
|
+
mfaTotpSetup: "/api/v1/mfa/totp/setup",
|
|
39
|
+
mfaTotpVerify: "/api/v1/mfa/totp/verify",
|
|
40
|
+
mfaEmailSetup: "/api/v1/mfa/email/setup",
|
|
41
|
+
mfaEmailSend: "/api/v1/mfa/email/send",
|
|
42
|
+
mfaEmailVerify: "/api/v1/mfa/email/verify",
|
|
43
|
+
mfaDeviceDisable: "/api/v1/mfa/device/disable",
|
|
44
|
+
mfaBackupCodes: "/api/v1/mfa/backup-codes/regenerate",
|
|
45
|
+
// Hardware key endpoints
|
|
46
|
+
mfaHardwareStartRegistration: "/api/v1/mfa/hardware/start-registration",
|
|
47
|
+
mfaHardwareCompleteRegistration: "/api/v1/mfa/hardware/complete-registration",
|
|
48
|
+
// MFA sign-in specific endpoints
|
|
49
|
+
mfaSigninSendEmail: "/api/v1/auth/mfa/email/send",
|
|
50
|
+
mfaSigninVerify: "/api/v1/auth/mfa/verify",
|
|
51
|
+
mfaBackupCodeVerify: "/api/v1/auth/mfa/backup-code/verify",
|
|
52
|
+
mfaWebAuthnChallenge: "/api/v1/auth/mfa/webauthn/challenge",
|
|
53
|
+
// Session management endpoints
|
|
54
|
+
sessions: "/api/v1/sessions",
|
|
55
|
+
sessionsStats: "/api/v1/sessions/stats",
|
|
56
|
+
sessionRevoke: "/api/v1/sessions/{session_id}/revoke",
|
|
57
|
+
sessionsRevokeAll: "/api/v1/sessions/revoke-all"
|
|
58
|
+
};
|
|
59
|
+
const STRANDS_CONFIG_KEY = Symbol("strands-config");
|
|
60
|
+
const globalConfig = ref(null);
|
|
61
|
+
function generateColorShades(accentColor) {
|
|
62
|
+
if (typeof window === "undefined" || !document.documentElement) return;
|
|
63
|
+
if (typeof CSS !== "undefined" && CSS.registerProperty) {
|
|
64
|
+
try {
|
|
65
|
+
CSS.registerProperty({
|
|
66
|
+
name: "--strands-accent",
|
|
67
|
+
syntax: "<color>",
|
|
68
|
+
inherits: true,
|
|
69
|
+
initialValue: accentColor
|
|
70
|
+
});
|
|
71
|
+
} catch (e) {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
document.documentElement.style.setProperty("--strands-accent", accentColor);
|
|
75
|
+
document.documentElement.style.setProperty("--accui-strands-accent", accentColor);
|
|
76
|
+
const shades = {
|
|
77
|
+
"--accui-strands-50": `color-mix(in srgb, ${accentColor} 10%, white)`,
|
|
78
|
+
"--accui-strands-100": `color-mix(in srgb, ${accentColor} 20%, white)`,
|
|
79
|
+
"--accui-strands-200": `color-mix(in srgb, ${accentColor} 30%, white)`,
|
|
80
|
+
"--accui-strands-300": `color-mix(in srgb, ${accentColor} 40%, white)`,
|
|
81
|
+
"--accui-strands-400": `color-mix(in srgb, ${accentColor} 70%, white)`,
|
|
82
|
+
"--accui-strands-500": accentColor,
|
|
83
|
+
"--accui-strands-600": `color-mix(in srgb, ${accentColor} 85%, black)`,
|
|
84
|
+
"--accui-strands-700": `color-mix(in srgb, ${accentColor} 70%, black)`,
|
|
85
|
+
"--accui-strands-800": `color-mix(in srgb, ${accentColor} 55%, black)`,
|
|
86
|
+
"--accui-strands-900": `color-mix(in srgb, ${accentColor} 40%, black)`,
|
|
87
|
+
"--accui-strands-950": `color-mix(in srgb, ${accentColor} 25%, black)`
|
|
88
|
+
};
|
|
89
|
+
for (const [property, value] of Object.entries(shades)) {
|
|
90
|
+
document.documentElement.style.setProperty(property, value);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function provideStrandsConfig(config) {
|
|
94
|
+
globalConfig.value = config;
|
|
95
|
+
if (typeof window !== "undefined" && document.documentElement) {
|
|
96
|
+
const useSquircle = config.useSquircle !== void 0 ? config.useSquircle : true;
|
|
97
|
+
document.documentElement.style.setProperty("--strands-allow-squircle", useSquircle ? "1" : "0");
|
|
98
|
+
if (config.accentColor) {
|
|
99
|
+
generateColorShades(config.accentColor);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
provide(STRANDS_CONFIG_KEY, config);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.warn("[Strands Auth] Could not provide config via Vue provide/inject. Config available via global state only.", error);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function useStrandsConfig(fallbackConfig) {
|
|
109
|
+
let injectedConfig = null;
|
|
110
|
+
try {
|
|
111
|
+
const currentInstance = getCurrentInstance();
|
|
112
|
+
if (currentInstance) {
|
|
113
|
+
injectedConfig = inject(STRANDS_CONFIG_KEY, null);
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
injectedConfig = null;
|
|
117
|
+
}
|
|
118
|
+
let nuxtConfig = null;
|
|
119
|
+
try {
|
|
120
|
+
if (typeof window !== "undefined") {
|
|
121
|
+
if (window.__STRANDS_CONFIG__) {
|
|
122
|
+
nuxtConfig = window.__STRANDS_CONFIG__;
|
|
123
|
+
} else if (window.__NUXT__) {
|
|
124
|
+
const nuxtData = window.__NUXT__;
|
|
125
|
+
nuxtConfig = nuxtData?.config?.public?.strandsAuth || nuxtData?.public?.strandsAuth || nuxtData?.strandsAuth;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error("[Strands Auth] Error accessing runtime configuration:", error);
|
|
130
|
+
}
|
|
131
|
+
const activeConfig = computed(() => {
|
|
132
|
+
const config = {
|
|
133
|
+
...STRANDS_AUTH_DEFAULTS,
|
|
134
|
+
...fallbackConfig || {},
|
|
135
|
+
...injectedConfig || {},
|
|
136
|
+
...globalConfig.value || {},
|
|
137
|
+
...nuxtConfig || {}
|
|
138
|
+
};
|
|
139
|
+
if (config.baseUrl === STRANDS_AUTH_DEFAULTS.baseUrl && typeof window === "undefined") {
|
|
140
|
+
console.warn("[Strands Auth] No baseUrl configured for SSR. Please provide a baseUrl in your strandsAuth configuration.");
|
|
141
|
+
}
|
|
142
|
+
if (typeof window !== "undefined" && document.documentElement) {
|
|
143
|
+
const useSquircle = config.useSquircle !== void 0 ? config.useSquircle : true;
|
|
144
|
+
document.documentElement.style.setProperty("--strands-allow-squircle", useSquircle ? "1" : "0");
|
|
145
|
+
if (config.accentColor) {
|
|
146
|
+
document.documentElement.style.setProperty("--strands-accent", config.accentColor);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return config;
|
|
150
|
+
});
|
|
151
|
+
const endpoints = computed(() => {
|
|
152
|
+
const config = activeConfig.value;
|
|
153
|
+
const customEndpoints = config.endpoints || {};
|
|
154
|
+
return {
|
|
155
|
+
signIn: customEndpoints.signIn || DEFAULT_ENDPOINTS.signIn,
|
|
156
|
+
signUp: customEndpoints.signUp || DEFAULT_ENDPOINTS.signUp,
|
|
157
|
+
signOut: customEndpoints.signOut || DEFAULT_ENDPOINTS.signOut,
|
|
158
|
+
refresh: customEndpoints.refresh || DEFAULT_ENDPOINTS.refresh,
|
|
159
|
+
passwordReset: customEndpoints.passwordReset || DEFAULT_ENDPOINTS.passwordReset,
|
|
160
|
+
passwordResetConfirm: customEndpoints.passwordResetConfirm || DEFAULT_ENDPOINTS.passwordResetConfirm,
|
|
161
|
+
completeRegistration: customEndpoints.completeRegistration || DEFAULT_ENDPOINTS.completeRegistration,
|
|
162
|
+
profile: customEndpoints.profile || DEFAULT_ENDPOINTS.profile,
|
|
163
|
+
verifyEmail: customEndpoints.verifyEmail || DEFAULT_ENDPOINTS.verifyEmail,
|
|
164
|
+
oauthProviders: customEndpoints.oauthProviders || DEFAULT_ENDPOINTS.oauthProviders,
|
|
165
|
+
oauthProvider: customEndpoints.oauthProvider || DEFAULT_ENDPOINTS.oauthProvider,
|
|
166
|
+
changeEmail: customEndpoints.changeEmail || DEFAULT_ENDPOINTS.changeEmail,
|
|
167
|
+
avatar: customEndpoints.avatar || DEFAULT_ENDPOINTS.avatar,
|
|
168
|
+
settings: customEndpoints.settings || DEFAULT_ENDPOINTS.settings,
|
|
169
|
+
// Username endpoints
|
|
170
|
+
changeUsername: customEndpoints.changeUsername || DEFAULT_ENDPOINTS.changeUsername,
|
|
171
|
+
usernameCooldown: customEndpoints.usernameCooldown || DEFAULT_ENDPOINTS.usernameCooldown,
|
|
172
|
+
checkUsernameAvailability: customEndpoints.checkUsernameAvailability || DEFAULT_ENDPOINTS.checkUsernameAvailability,
|
|
173
|
+
// MFA endpoints
|
|
174
|
+
mfaDevices: customEndpoints.mfaDevices || DEFAULT_ENDPOINTS.mfaDevices,
|
|
175
|
+
mfaTotpSetup: customEndpoints.mfaTotpSetup || DEFAULT_ENDPOINTS.mfaTotpSetup,
|
|
176
|
+
mfaTotpVerify: customEndpoints.mfaTotpVerify || DEFAULT_ENDPOINTS.mfaTotpVerify,
|
|
177
|
+
mfaEmailSetup: customEndpoints.mfaEmailSetup || DEFAULT_ENDPOINTS.mfaEmailSetup,
|
|
178
|
+
mfaEmailSend: customEndpoints.mfaEmailSend || DEFAULT_ENDPOINTS.mfaEmailSend,
|
|
179
|
+
mfaEmailVerify: customEndpoints.mfaEmailVerify || DEFAULT_ENDPOINTS.mfaEmailVerify,
|
|
180
|
+
mfaDeviceDisable: customEndpoints.mfaDeviceDisable || DEFAULT_ENDPOINTS.mfaDeviceDisable,
|
|
181
|
+
mfaBackupCodes: customEndpoints.mfaBackupCodes || DEFAULT_ENDPOINTS.mfaBackupCodes,
|
|
182
|
+
// Hardware key endpoints
|
|
183
|
+
mfaHardwareStartRegistration: customEndpoints.mfaHardwareStartRegistration || DEFAULT_ENDPOINTS.mfaHardwareStartRegistration,
|
|
184
|
+
mfaHardwareCompleteRegistration: customEndpoints.mfaHardwareCompleteRegistration || DEFAULT_ENDPOINTS.mfaHardwareCompleteRegistration,
|
|
185
|
+
// MFA sign-in specific endpoints
|
|
186
|
+
mfaSigninSendEmail: customEndpoints.mfaSigninSendEmail || DEFAULT_ENDPOINTS.mfaSigninSendEmail,
|
|
187
|
+
mfaSigninVerify: customEndpoints.mfaSigninVerify || DEFAULT_ENDPOINTS.mfaSigninVerify,
|
|
188
|
+
mfaBackupCodeVerify: customEndpoints.mfaBackupCodeVerify || DEFAULT_ENDPOINTS.mfaBackupCodeVerify,
|
|
189
|
+
mfaWebAuthnChallenge: customEndpoints.mfaWebAuthnChallenge || DEFAULT_ENDPOINTS.mfaWebAuthnChallenge,
|
|
190
|
+
// Session management endpoints
|
|
191
|
+
sessions: customEndpoints.sessions || DEFAULT_ENDPOINTS.sessions,
|
|
192
|
+
sessionsStats: customEndpoints.sessionsStats || DEFAULT_ENDPOINTS.sessionsStats,
|
|
193
|
+
sessionRevoke: customEndpoints.sessionRevoke || DEFAULT_ENDPOINTS.sessionRevoke,
|
|
194
|
+
sessionsRevokeAll: customEndpoints.sessionsRevokeAll || DEFAULT_ENDPOINTS.sessionsRevokeAll
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
const getUrl = (endpoint) => {
|
|
198
|
+
const config = activeConfig.value;
|
|
199
|
+
if (!config.baseUrl) {
|
|
200
|
+
throw new Error("Base URL is required in configuration");
|
|
201
|
+
}
|
|
202
|
+
let endpointPath;
|
|
203
|
+
if (typeof endpoint === "string" && endpoint in endpoints.value) {
|
|
204
|
+
endpointPath = endpoints.value[endpoint];
|
|
205
|
+
} else if (typeof endpoint === "string") {
|
|
206
|
+
endpointPath = endpoint;
|
|
207
|
+
} else {
|
|
208
|
+
endpointPath = endpoints.value[endpoint];
|
|
209
|
+
}
|
|
210
|
+
const baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
211
|
+
const path = endpointPath.startsWith("/") ? endpointPath : `/${endpointPath}`;
|
|
212
|
+
console.debug(`[Strands Auth] Constructing URL for endpoint "${endpoint}": ${baseUrl}${path}`);
|
|
213
|
+
return `${baseUrl}${path}`;
|
|
214
|
+
};
|
|
215
|
+
const getSupportEmail = () => {
|
|
216
|
+
const config = activeConfig.value;
|
|
217
|
+
return config.supportEmail || null;
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
config: activeConfig,
|
|
221
|
+
endpoints,
|
|
222
|
+
getUrl,
|
|
223
|
+
getSupportEmail
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function setStrandsConfig(config) {
|
|
227
|
+
globalConfig.value = config;
|
|
228
|
+
if (typeof window !== "undefined" && document.documentElement) {
|
|
229
|
+
const useSquircle = config.useSquircle !== void 0 ? config.useSquircle : true;
|
|
230
|
+
document.documentElement.style.setProperty("--strands-allow-squircle", useSquircle ? "1" : "0");
|
|
231
|
+
if (config.accentColor) {
|
|
232
|
+
generateColorShades(config.accentColor);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
export {
|
|
237
|
+
STRANDS_AUTH_DEFAULTS as S,
|
|
238
|
+
provideStrandsConfig as p,
|
|
239
|
+
setStrandsConfig as s,
|
|
240
|
+
useStrandsConfig as u
|
|
241
|
+
};
|