@strands.gg/accui 2.6.2 → 2.6.4
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 -1
- package/dist/nuxt/runtime/composables/useStrandsAuth.cjs.js +1 -1
- package/dist/nuxt/runtime/composables/useStrandsAuth.es.js +1 -1
- package/dist/nuxt/runtime/plugin.client.cjs.js +1 -1
- package/dist/nuxt/runtime/plugin.client.es.js +1 -1
- package/dist/nuxt/runtime/plugin.server.cjs.js +1 -1
- package/dist/nuxt/runtime/plugin.server.es.js +1 -1
- package/dist/strands-auth-ui.cjs.js +1 -1
- package/dist/strands-auth-ui.es.js +89 -70
- package/dist/{useStrandsAuth-DoUupKb8.es.js → useStrandsAuth-B0jI8Gbq.es.js} +1 -1
- package/dist/{useStrandsAuth-WChBcwNF.cjs.js → useStrandsAuth-Dt4KTg73.cjs.js} +1 -1
- package/dist/useStrandsConfig-BUmt8HfH.cjs.js +1 -0
- package/dist/{useStrandsConfig-C3gBJK6y.es.js → useStrandsConfig-f200kXFG.es.js} +6 -1
- package/package.json +1 -1
- package/dist/useStrandsConfig-B6uW6Zkd.cjs.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import { u as useStrandsConfig, p as provideStrandsConfig } from "./useStrandsConfig-
|
|
3
|
-
import { s } from "./useStrandsConfig-
|
|
4
|
-
import { u as useStrandsAuth } from "./useStrandsAuth-
|
|
2
|
+
import { u as useStrandsConfig, p as provideStrandsConfig } from "./useStrandsConfig-f200kXFG.es.js";
|
|
3
|
+
import { s } from "./useStrandsConfig-f200kXFG.es.js";
|
|
4
|
+
import { u as useStrandsAuth } from "./useStrandsAuth-B0jI8Gbq.es.js";
|
|
5
5
|
const _hoisted_1$T = { class: "app-content" };
|
|
6
6
|
const _hoisted_2$K = {
|
|
7
7
|
key: 0,
|
|
@@ -206,9 +206,9 @@ const _hoisted_7$r = {
|
|
|
206
206
|
const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
207
207
|
__name: "UiLoader",
|
|
208
208
|
props: {
|
|
209
|
-
size: { default:
|
|
209
|
+
size: { default: "md" },
|
|
210
210
|
color: { default: "primary" },
|
|
211
|
-
variant: { default: "
|
|
211
|
+
variant: { default: "circle" },
|
|
212
212
|
text: {},
|
|
213
213
|
centered: { type: Boolean, default: true },
|
|
214
214
|
weight: { default: 30 },
|
|
@@ -217,6 +217,19 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
|
217
217
|
setup(__props) {
|
|
218
218
|
const path = logo.replace(/<svg[^>]*>/, "").replace(/<\/svg>/, "").trim();
|
|
219
219
|
const d = path.match(/d="([^"]*)"/)?.[1] || "";
|
|
220
|
+
const props = __props;
|
|
221
|
+
const sizeMap = {
|
|
222
|
+
"sm": 32,
|
|
223
|
+
"md": 48,
|
|
224
|
+
"lg": 64,
|
|
225
|
+
"xl": 80
|
|
226
|
+
};
|
|
227
|
+
const computedSize = computed(() => {
|
|
228
|
+
if (typeof props.size === "number") {
|
|
229
|
+
return props.size;
|
|
230
|
+
}
|
|
231
|
+
return sizeMap[props.size] || sizeMap.md;
|
|
232
|
+
});
|
|
220
233
|
return (_ctx, _cache) => {
|
|
221
234
|
return openBlock(), createElementBlock("div", {
|
|
222
235
|
class: normalizeClass(["loader-container", [
|
|
@@ -226,8 +239,8 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
|
226
239
|
}, [
|
|
227
240
|
_ctx.variant === "spinner" ? (openBlock(), createElementBlock("div", _hoisted_1$R, [
|
|
228
241
|
(openBlock(), createElementBlock("svg", {
|
|
229
|
-
width:
|
|
230
|
-
height:
|
|
242
|
+
width: computedSize.value,
|
|
243
|
+
height: computedSize.value,
|
|
231
244
|
viewBox: "0 0 500 500"
|
|
232
245
|
}, [
|
|
233
246
|
createElementVNode("defs", null, [
|
|
@@ -258,11 +271,11 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
|
258
271
|
])) : _ctx.variant === "circle" ? (openBlock(), createElementBlock("div", {
|
|
259
272
|
key: 1,
|
|
260
273
|
class: "loader-circle",
|
|
261
|
-
style: normalizeStyle({ width: `${
|
|
274
|
+
style: normalizeStyle({ width: `${computedSize.value}px`, height: `${computedSize.value}px` })
|
|
262
275
|
}, [
|
|
263
276
|
(openBlock(), createElementBlock("svg", {
|
|
264
|
-
width:
|
|
265
|
-
height:
|
|
277
|
+
width: computedSize.value,
|
|
278
|
+
height: computedSize.value,
|
|
266
279
|
viewBox: "0 0 50 50"
|
|
267
280
|
}, [..._cache[0] || (_cache[0] = [
|
|
268
281
|
createElementVNode("circle", {
|
|
@@ -280,8 +293,8 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
|
280
293
|
key: 2,
|
|
281
294
|
class: "loader-bar",
|
|
282
295
|
style: normalizeStyle({
|
|
283
|
-
width: _ctx.fullWidth ? "100%" : `${
|
|
284
|
-
height: `${Math.max(
|
|
296
|
+
width: _ctx.fullWidth ? "100%" : `${computedSize.value * 1.5}px`,
|
|
297
|
+
height: `${Math.max(computedSize.value * 0.1, 4)}px`
|
|
285
298
|
})
|
|
286
299
|
}, [..._cache[1] || (_cache[1] = [
|
|
287
300
|
createElementVNode("div", { class: "loader-bar-track" }, [
|
|
@@ -293,7 +306,7 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
|
293
306
|
};
|
|
294
307
|
}
|
|
295
308
|
});
|
|
296
|
-
const StrandsUiLoader = /* @__PURE__ */ _export_sfc(_sfc_main$Z, [["__scopeId", "data-v-
|
|
309
|
+
const StrandsUiLoader = /* @__PURE__ */ _export_sfc(_sfc_main$Z, [["__scopeId", "data-v-4b565c5d"]]);
|
|
297
310
|
const _hoisted_1$Q = {
|
|
298
311
|
key: 0,
|
|
299
312
|
class: "button-loading-content"
|
|
@@ -26741,11 +26754,14 @@ function useModalStack(options = {}) {
|
|
|
26741
26754
|
if (!modalInstance.value) return null;
|
|
26742
26755
|
return document.querySelector(`.ui-app-modal-backdrop[style*="z-index: ${modalInstance.value.zIndex - 1}"]`);
|
|
26743
26756
|
};
|
|
26744
|
-
|
|
26745
|
-
|
|
26746
|
-
|
|
26747
|
-
|
|
26748
|
-
|
|
26757
|
+
try {
|
|
26758
|
+
onUnmounted(() => {
|
|
26759
|
+
if (isOpen.value) {
|
|
26760
|
+
closeModal();
|
|
26761
|
+
}
|
|
26762
|
+
});
|
|
26763
|
+
} catch (e) {
|
|
26764
|
+
}
|
|
26749
26765
|
return {
|
|
26750
26766
|
// State
|
|
26751
26767
|
isOpen,
|
|
@@ -26782,7 +26798,10 @@ function useGlobalModalStack() {
|
|
|
26782
26798
|
const unsubscribe = modalStack.subscribe((state) => {
|
|
26783
26799
|
stackState.value = state;
|
|
26784
26800
|
});
|
|
26785
|
-
|
|
26801
|
+
try {
|
|
26802
|
+
onUnmounted(unsubscribe);
|
|
26803
|
+
} catch (e) {
|
|
26804
|
+
}
|
|
26786
26805
|
return {
|
|
26787
26806
|
state: stackState,
|
|
26788
26807
|
closeAll: () => {
|
|
@@ -27664,7 +27683,7 @@ const _hoisted_20$9 = {
|
|
|
27664
27683
|
};
|
|
27665
27684
|
const _hoisted_21$9 = ["cx", "fill"];
|
|
27666
27685
|
const _hoisted_22$7 = { class: "ui-color-picker-inputs" };
|
|
27667
|
-
const _hoisted_23$
|
|
27686
|
+
const _hoisted_23$6 = {
|
|
27668
27687
|
key: 0,
|
|
27669
27688
|
class: "ui-color-picker-input-row"
|
|
27670
27689
|
};
|
|
@@ -29523,7 +29542,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
29523
29542
|
}, null, 4)
|
|
29524
29543
|
], 544)) : createCommentVNode("", true),
|
|
29525
29544
|
createElementVNode("div", _hoisted_22$7, [
|
|
29526
|
-
currentColorFormat.value === "hex" ? (openBlock(), createElementBlock("div", _hoisted_23$
|
|
29545
|
+
currentColorFormat.value === "hex" ? (openBlock(), createElementBlock("div", _hoisted_23$6, [
|
|
29527
29546
|
createElementVNode("div", _hoisted_24$6, [
|
|
29528
29547
|
_cache[24] || (_cache[24] = createElementVNode("label", { class: "ui-color-picker-label" }, "Hex", -1)),
|
|
29529
29548
|
withDirectives(createElementVNode("input", {
|
|
@@ -30262,7 +30281,7 @@ const _hoisted_19$a = { class: "ui-table-group-count" };
|
|
|
30262
30281
|
const _hoisted_20$8 = ["onClick"];
|
|
30263
30282
|
const _hoisted_21$8 = ["onClick"];
|
|
30264
30283
|
const _hoisted_22$6 = { class: "ui-table-subrow-content" };
|
|
30265
|
-
const _hoisted_23$
|
|
30284
|
+
const _hoisted_23$5 = { class: "ui-table-subrow-default" };
|
|
30266
30285
|
const _hoisted_24$5 = {
|
|
30267
30286
|
key: 0,
|
|
30268
30287
|
class: "ui-table-empty"
|
|
@@ -30712,7 +30731,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
30712
30731
|
row,
|
|
30713
30732
|
rowIndex
|
|
30714
30733
|
}, () => [
|
|
30715
|
-
createElementVNode("div", _hoisted_23$
|
|
30734
|
+
createElementVNode("div", _hoisted_23$5, [
|
|
30716
30735
|
createElementVNode("pre", null, toDisplayString(JSON.stringify(row, null, 2)), 1)
|
|
30717
30736
|
])
|
|
30718
30737
|
], true)
|
|
@@ -32253,7 +32272,7 @@ const _hoisted_19$8 = { class: "mfa-hardware-prompt" };
|
|
|
32253
32272
|
const _hoisted_20$6 = { class: "mfa-hardware-prompt-content" };
|
|
32254
32273
|
const _hoisted_21$6 = { class: "mfa-hardware-prompt-icon" };
|
|
32255
32274
|
const _hoisted_22$5 = { class: "mfa-hardware-prompt-text" };
|
|
32256
|
-
const _hoisted_23$
|
|
32275
|
+
const _hoisted_23$4 = { class: "mfa-hardware-prompt-title" };
|
|
32257
32276
|
const _hoisted_24$4 = { class: "mfa-hardware-prompt-description" };
|
|
32258
32277
|
const _hoisted_25$4 = { class: "mfa-backup-option" };
|
|
32259
32278
|
const _hoisted_26$4 = {
|
|
@@ -32762,7 +32781,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
32762
32781
|
}))
|
|
32763
32782
|
]),
|
|
32764
32783
|
createElementVNode("div", _hoisted_22$5, [
|
|
32765
|
-
createElementVNode("h4", _hoisted_23$
|
|
32784
|
+
createElementVNode("h4", _hoisted_23$4, toDisplayString(selectedMethod.value.device_type === "passkey" ? "Use your passkey" : "Touch your hardware key"), 1),
|
|
32766
32785
|
createElementVNode("p", _hoisted_24$4, toDisplayString(selectedMethod.value.device_type === "passkey" ? "Use biometrics, PIN, or device security to authenticate" : "Insert and touch your hardware key to authenticate"), 1)
|
|
32767
32786
|
])
|
|
32768
32787
|
])
|
|
@@ -33202,64 +33221,63 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
33202
33221
|
};
|
|
33203
33222
|
}
|
|
33204
33223
|
});
|
|
33205
|
-
const _hoisted_1$l = {
|
|
33206
|
-
const _hoisted_2$h = {
|
|
33224
|
+
const _hoisted_1$l = {
|
|
33207
33225
|
key: 0,
|
|
33208
33226
|
class: "auth-logo-header"
|
|
33209
33227
|
};
|
|
33210
|
-
const
|
|
33211
|
-
const
|
|
33228
|
+
const _hoisted_2$h = { class: "auth-header" };
|
|
33229
|
+
const _hoisted_3$g = {
|
|
33212
33230
|
key: 0,
|
|
33213
33231
|
class: "auth-success-text"
|
|
33214
33232
|
};
|
|
33215
|
-
const
|
|
33216
|
-
const
|
|
33217
|
-
const
|
|
33218
|
-
const
|
|
33233
|
+
const _hoisted_4$g = { key: 1 };
|
|
33234
|
+
const _hoisted_5$e = { key: 2 };
|
|
33235
|
+
const _hoisted_6$d = { key: 3 };
|
|
33236
|
+
const _hoisted_7$d = {
|
|
33219
33237
|
key: 0,
|
|
33220
33238
|
class: "auth-tabs-container"
|
|
33221
33239
|
};
|
|
33222
|
-
const
|
|
33240
|
+
const _hoisted_8$c = {
|
|
33223
33241
|
key: 0,
|
|
33224
33242
|
class: "auth-oauth-providers"
|
|
33225
33243
|
};
|
|
33226
|
-
const
|
|
33227
|
-
const
|
|
33244
|
+
const _hoisted_9$c = { class: "auth-oauth-icon-container" };
|
|
33245
|
+
const _hoisted_10$c = {
|
|
33228
33246
|
key: 0,
|
|
33229
33247
|
class: "auth-oauth-icon"
|
|
33230
33248
|
};
|
|
33231
|
-
const
|
|
33232
|
-
const
|
|
33249
|
+
const _hoisted_11$c = ["src", "alt"];
|
|
33250
|
+
const _hoisted_12$c = {
|
|
33233
33251
|
key: 1,
|
|
33234
33252
|
viewBox: "0 0 24 24",
|
|
33235
33253
|
class: "auth-oauth-icon"
|
|
33236
33254
|
};
|
|
33237
|
-
const
|
|
33255
|
+
const _hoisted_13$c = {
|
|
33238
33256
|
key: 2,
|
|
33239
33257
|
class: "auth-oauth-icon auth-oauth-github",
|
|
33240
33258
|
viewBox: "0 0 24 24"
|
|
33241
33259
|
};
|
|
33242
|
-
const
|
|
33260
|
+
const _hoisted_14$c = {
|
|
33243
33261
|
key: 3,
|
|
33244
33262
|
class: "auth-oauth-generic-icon"
|
|
33245
33263
|
};
|
|
33246
|
-
const
|
|
33247
|
-
const
|
|
33248
|
-
const
|
|
33264
|
+
const _hoisted_15$a = { class: "auth-oauth-generic-text" };
|
|
33265
|
+
const _hoisted_16$a = { class: "auth-oauth-text" };
|
|
33266
|
+
const _hoisted_17$9 = {
|
|
33249
33267
|
key: 0,
|
|
33250
33268
|
class: "auth-divider"
|
|
33251
33269
|
};
|
|
33252
|
-
const
|
|
33253
|
-
const
|
|
33270
|
+
const _hoisted_18$8 = { class: "auth-divider-text" };
|
|
33271
|
+
const _hoisted_19$7 = {
|
|
33254
33272
|
key: 0,
|
|
33255
33273
|
class: "auth-password-field"
|
|
33256
33274
|
};
|
|
33257
|
-
const
|
|
33258
|
-
const
|
|
33275
|
+
const _hoisted_20$5 = { class: "auth-password-header" };
|
|
33276
|
+
const _hoisted_21$5 = {
|
|
33259
33277
|
key: 0,
|
|
33260
33278
|
class: "auth-back-link-container"
|
|
33261
33279
|
};
|
|
33262
|
-
const
|
|
33280
|
+
const _hoisted_22$4 = { class: "auth-support-text" };
|
|
33263
33281
|
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
33264
33282
|
__name: "StrandsAuth",
|
|
33265
33283
|
props: {
|
|
@@ -33512,18 +33530,19 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33512
33530
|
element.style.overflow = "";
|
|
33513
33531
|
};
|
|
33514
33532
|
return (_ctx, _cache) => {
|
|
33515
|
-
return openBlock(), createElementBlock(
|
|
33533
|
+
return openBlock(), createElementBlock(Fragment$1, null, [
|
|
33516
33534
|
createVNode(unref(StrandsUiCard), {
|
|
33517
33535
|
variant: props.inModal ? "simple" : "modern",
|
|
33518
33536
|
color: props.inModal ? "default" : "secondary",
|
|
33537
|
+
padding: "sm",
|
|
33519
33538
|
class: normalizeClass(props.inModal ? "auth-full-width auth-min-width" : "auth-full-width auth-min-width auth-max-width auth-center auth-slide-up")
|
|
33520
33539
|
}, {
|
|
33521
33540
|
default: withCtx(() => [
|
|
33522
33541
|
createElementVNode("div", null, [
|
|
33523
|
-
!props.inModal ? (openBlock(), createElementBlock("div",
|
|
33542
|
+
!props.inModal ? (openBlock(), createElementBlock("div", _hoisted_1$l, [
|
|
33524
33543
|
createVNode(_sfc_main$o)
|
|
33525
33544
|
])) : createCommentVNode("", true),
|
|
33526
|
-
createElementVNode("div",
|
|
33545
|
+
createElementVNode("div", _hoisted_2$h, [
|
|
33527
33546
|
createVNode(Transition, {
|
|
33528
33547
|
name: "fade",
|
|
33529
33548
|
mode: "out-in"
|
|
@@ -33545,7 +33564,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33545
33564
|
key: currentMode.value,
|
|
33546
33565
|
class: "auth-subtitle"
|
|
33547
33566
|
}, [
|
|
33548
|
-
isPasswordResetSubmitted.value ? (openBlock(), createElementBlock("span",
|
|
33567
|
+
isPasswordResetSubmitted.value ? (openBlock(), createElementBlock("span", _hoisted_3$g, " We've sent a password reset link to your email ")) : isPasswordReset.value ? (openBlock(), createElementBlock("span", _hoisted_4$g, " Enter your email to reset your password ")) : isSignUp.value ? (openBlock(), createElementBlock("span", _hoisted_5$e, " Create an account to get started ")) : (openBlock(), createElementBlock("span", _hoisted_6$d, [..._cache[6] || (_cache[6] = [
|
|
33549
33568
|
createTextVNode(" Sign in or register a ", -1),
|
|
33550
33569
|
createElementVNode("b", null, "Strands account", -1),
|
|
33551
33570
|
createTextVNode(" to continue ", -1)
|
|
@@ -33564,7 +33583,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33564
33583
|
onAfterLeave
|
|
33565
33584
|
}, {
|
|
33566
33585
|
default: withCtx(() => [
|
|
33567
|
-
!isPasswordReset.value ? (openBlock(), createElementBlock("div",
|
|
33586
|
+
!isPasswordReset.value ? (openBlock(), createElementBlock("div", _hoisted_7$d, [
|
|
33568
33587
|
createVNode(unref(StrandsUiTabs), {
|
|
33569
33588
|
modelValue: currentMode.value,
|
|
33570
33589
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentMode.value = $event),
|
|
@@ -33587,7 +33606,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33587
33606
|
onAfterLeave
|
|
33588
33607
|
}, {
|
|
33589
33608
|
default: withCtx(() => [
|
|
33590
|
-
!isPasswordReset.value && displayProviders.value?.length ? (openBlock(), createElementBlock("div",
|
|
33609
|
+
!isPasswordReset.value && displayProviders.value?.length ? (openBlock(), createElementBlock("div", _hoisted_8$c, [
|
|
33591
33610
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList(displayProviders.value, (provider) => {
|
|
33592
33611
|
return openBlock(), createBlock(unref(CompoundUiButton), {
|
|
33593
33612
|
key: provider.id,
|
|
@@ -33598,16 +33617,16 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33598
33617
|
class: "auth-oauth-button"
|
|
33599
33618
|
}, {
|
|
33600
33619
|
default: withCtx(() => [
|
|
33601
|
-
createElementVNode("div",
|
|
33602
|
-
provider.icon || provider.iconUrl ? (openBlock(), createElementBlock("div",
|
|
33620
|
+
createElementVNode("div", _hoisted_9$c, [
|
|
33621
|
+
provider.icon || provider.iconUrl ? (openBlock(), createElementBlock("div", _hoisted_10$c, [
|
|
33603
33622
|
createElementVNode("img", {
|
|
33604
33623
|
src: provider.icon || provider.iconUrl,
|
|
33605
33624
|
alt: `${provider.displayName || provider.name} icon`,
|
|
33606
33625
|
class: "auth-oauth-icon",
|
|
33607
33626
|
width: "20",
|
|
33608
33627
|
height: "20"
|
|
33609
|
-
}, null, 8,
|
|
33610
|
-
])) : provider.id === "google" ? (openBlock(), createElementBlock("svg",
|
|
33628
|
+
}, null, 8, _hoisted_11$c)
|
|
33629
|
+
])) : provider.id === "google" ? (openBlock(), createElementBlock("svg", _hoisted_12$c, [..._cache[7] || (_cache[7] = [
|
|
33611
33630
|
createElementVNode("path", {
|
|
33612
33631
|
fill: "#4285F4",
|
|
33613
33632
|
d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
@@ -33624,13 +33643,13 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33624
33643
|
fill: "#EA4335",
|
|
33625
33644
|
d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
33626
33645
|
}, null, -1)
|
|
33627
|
-
])])) : provider.id === "github" ? (openBlock(), createElementBlock("svg",
|
|
33646
|
+
])])) : provider.id === "github" ? (openBlock(), createElementBlock("svg", _hoisted_13$c, [..._cache[8] || (_cache[8] = [
|
|
33628
33647
|
createElementVNode("path", { d: "M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" }, null, -1)
|
|
33629
|
-
])])) : (openBlock(), createElementBlock("div",
|
|
33630
|
-
createElementVNode("span",
|
|
33648
|
+
])])) : (openBlock(), createElementBlock("div", _hoisted_14$c, [
|
|
33649
|
+
createElementVNode("span", _hoisted_15$a, toDisplayString((provider.displayName || provider.name).charAt(0).toUpperCase()), 1)
|
|
33631
33650
|
]))
|
|
33632
33651
|
]),
|
|
33633
|
-
createElementVNode("span",
|
|
33652
|
+
createElementVNode("span", _hoisted_16$a, " Continue with " + toDisplayString(provider.displayName || provider.name.charAt(0).toUpperCase() + provider.name.slice(1)), 1)
|
|
33634
33653
|
]),
|
|
33635
33654
|
_: 2
|
|
33636
33655
|
}, 1032, ["disabled", "onClick"]);
|
|
@@ -33648,8 +33667,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33648
33667
|
onAfterLeave
|
|
33649
33668
|
}, {
|
|
33650
33669
|
default: withCtx(() => [
|
|
33651
|
-
!isPasswordReset.value && displayProviders.value?.length ? (openBlock(), createElementBlock("div",
|
|
33652
|
-
createElementVNode("span",
|
|
33670
|
+
!isPasswordReset.value && displayProviders.value?.length ? (openBlock(), createElementBlock("div", _hoisted_17$9, [
|
|
33671
|
+
createElementVNode("span", _hoisted_18$8, "Or " + toDisplayString(isSignUp.value ? "create account" : "sign in") + " with email", 1)
|
|
33653
33672
|
])) : createCommentVNode("", true)
|
|
33654
33673
|
]),
|
|
33655
33674
|
_: 1
|
|
@@ -33682,8 +33701,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33682
33701
|
onAfterLeave
|
|
33683
33702
|
}, {
|
|
33684
33703
|
default: withCtx(() => [
|
|
33685
|
-
!isPasswordReset.value && !isSignUp.value ? (openBlock(), createElementBlock("div",
|
|
33686
|
-
createElementVNode("div",
|
|
33704
|
+
!isPasswordReset.value && !isSignUp.value ? (openBlock(), createElementBlock("div", _hoisted_19$7, [
|
|
33705
|
+
createElementVNode("div", _hoisted_20$5, [
|
|
33687
33706
|
_cache[10] || (_cache[10] = createElementVNode("span", { class: "auth-password-label" }, "Password", -1)),
|
|
33688
33707
|
createVNode(unref(StrandsUiLink), {
|
|
33689
33708
|
variant: "primary",
|
|
@@ -33747,7 +33766,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33747
33766
|
onAfterLeave
|
|
33748
33767
|
}, {
|
|
33749
33768
|
default: withCtx(() => [
|
|
33750
|
-
isPasswordReset.value ? (openBlock(), createElementBlock("div",
|
|
33769
|
+
isPasswordReset.value ? (openBlock(), createElementBlock("div", _hoisted_21$5, [
|
|
33751
33770
|
createVNode(unref(StrandsUiLink), {
|
|
33752
33771
|
onClick: _cache[4] || (_cache[4] = ($event) => currentMode.value = "signin"),
|
|
33753
33772
|
class: "auth-back-link"
|
|
@@ -33791,7 +33810,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33791
33810
|
name: "support-fade"
|
|
33792
33811
|
}, {
|
|
33793
33812
|
default: withCtx(() => [
|
|
33794
|
-
createElementVNode("p",
|
|
33813
|
+
createElementVNode("p", _hoisted_22$4, [
|
|
33795
33814
|
_cache[13] || (_cache[13] = createTextVNode(" Need help? ", -1)),
|
|
33796
33815
|
createVNode(unref(StrandsUiLink), {
|
|
33797
33816
|
variant: "primary",
|
|
@@ -33820,11 +33839,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
33820
33839
|
onClose: handleMfaClose,
|
|
33821
33840
|
onError: handleMfaError
|
|
33822
33841
|
}, null, 8, ["show", "available-mfa-methods"])
|
|
33823
|
-
]);
|
|
33842
|
+
], 64);
|
|
33824
33843
|
};
|
|
33825
33844
|
}
|
|
33826
33845
|
});
|
|
33827
|
-
const StrandsAuth = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["__scopeId", "data-v-
|
|
33846
|
+
const StrandsAuth = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["__scopeId", "data-v-31b99c9b"]]);
|
|
33828
33847
|
const _hoisted_1$k = {
|
|
33829
33848
|
viewBox: "0 0 24 24",
|
|
33830
33849
|
class: "accui-w-5 accui-h-5"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, ref, onUnmounted } from "vue";
|
|
2
|
-
import { u as useStrandsConfig } from "./useStrandsConfig-
|
|
2
|
+
import { u as useStrandsConfig } from "./useStrandsConfig-f200kXFG.es.js";
|
|
3
3
|
class RequestCache {
|
|
4
4
|
cache = /* @__PURE__ */ new Map();
|
|
5
5
|
DEFAULT_TTL = 5 * 60 * 1e3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),t=require("./useStrandsConfig-B6uW6Zkd.cjs.js"),a=new class{cache=new Map;DEFAULT_TTL=3e5;async fetch(e,t,a=this.DEFAULT_TTL){const n=Date.now(),i=this.cache.get(e);if(i&&n-i.timestamp<i.ttl)return i.promise;this.cleanExpired();const r=t().finally(()=>{setTimeout(()=>{this.cache.delete(e)},a)});return this.cache.set(e,{promise:r,timestamp:n,ttl:a}),r}clear(){this.cache.clear()}invalidate(e){this.cache.delete(e)}cleanExpired(){const e=Date.now();for(const[t,a]of this.cache.entries())e-a.timestamp>a.ttl&&this.cache.delete(t)}getStats(){return{size:this.cache.size,entries:Array.from(this.cache.keys())}}},n=function(){let e=null;return(...t)=>{e&&clearTimeout(e),e=setTimeout(()=>{((e,t)=>{"undefined"!=typeof window&&localStorage.setItem(e,t)})(...t)},300)}}(),i=e=>({id:e.id,email:e.email,firstName:e.first_name||e.firstName||"",lastName:e.last_name||e.lastName||"",avatar:e.avatar_url||e.avatar,mfaEnabled:e.mfa_enabled??e.mfaEnabled??0,emailVerified:e.email_verified??e.emailVerified??0,passwordUpdatedAt:e.password_updated_at||e.passwordUpdatedAt,settings:e.settings||{},xp:e.xp||0,level:e.level||1,next_level_xp:e.next_level_xp||e.next_level_xp||4,username:e.username,usernameLastChangedAt:e.username_last_changed_at||e.usernameLastChangedAt,createdAt:e.created_at||e.createdAt,updatedAt:e.updated_at||e.updatedAt||(new Date).toISOString()}),r={currentUser:e.ref(null),currentSession:e.ref(null),loadingStates:e.ref({initializing:1,signingIn:0,signingUp:0,signingOut:0,refreshingToken:0,sendingMfaEmail:0,verifyingMfa:0,loadingProfile:0}),isInitialized:e.ref(0),mfaRequired:e.ref(0),mfaSessionId:e.ref(null),availableMfaMethods:e.ref([])};let o=null,s=null;exports.useStrandsAuth=function(){const{getUrl:c}=t.useStrandsConfig(),{fetch:d,clear:l,invalidate:h}={fetch:a.fetch.bind(a),clear:a.clear.bind(a),invalidate:a.invalidate.bind(a),getStats:a.getStats.bind(a)},{currentUser:u,currentSession:f,loadingStates:w,isInitialized:y,mfaRequired:g,mfaSessionId:m,availableMfaMethods:p}=r,S=e.computed(()=>w.value.initializing),_=e.computed(()=>w.value.signingIn),T=e.computed(()=>w.value.signingUp),E=e.computed(()=>w.value.signingOut),v=e.computed(()=>w.value.refreshingToken),O=e.computed(()=>w.value.sendingMfaEmail),A=e.computed(()=>w.value.verifyingMfa);e.computed(()=>w.value.loadingProfile);const $=e.computed(()=>w.value.signingIn||w.value.signingUp||w.value.signingOut||w.value.refreshingToken||w.value.sendingMfaEmail||w.value.verifyingMfa||w.value.loadingProfile),N=e.computed(()=>w.value.initializing||$.value),b=e.computed(()=>{const e=w.value;return e.initializing?"Checking authentication...":e.signingIn?"Signing you in...":e.signingUp?"Creating your account...":e.signingOut?"Signing you out...":e.refreshingToken?"Refreshing session...":e.sendingMfaEmail?"Sending verification code...":e.verifyingMfa?"Verifying code...":e.loadingProfile?"Loading profile...":"Loading..."}),k=()=>{const e={};return f.value?.accessToken&&(e.Authorization=`Bearer ${f.value.accessToken}`),f.value?.refreshToken&&(e["x-refresh-token"]=f.value.refreshToken),e},C=e.computed(()=>null!==u.value),J=async()=>{w.value.signingOut=1;try{U(),s=null,l(),u.value=null,f.value=null,g.value=0,m.value=null,p.value=[],"undefined"!=typeof window&&(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"))}finally{w.value.signingOut=0}},P=async()=>{if(!f.value?.refreshToken)return 0;if(s)return await s;s=(async()=>{w.value.refreshingToken=1;try{const e=await fetch(c("refresh"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:f.value.refreshToken})});if(!e.ok){if(401===e.status)return await J(),0;throw new Error(`Token refresh failed: ${e.status} ${e.statusText}`)}const t=await e.json();t.user&&(u.value=i(t.user),u.value&&"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value)));const a={accessToken:t.access_token,refreshToken:t.refresh_token,expiresAt:new Date(Date.now()+3e5),userId:t.user?.id||u.value?.id};return f.value=a,"undefined"!=typeof window&&localStorage.setItem("strands_auth_session",JSON.stringify(a)),M(),h(`sessions:${f.value.accessToken.slice(0,20)}`),1}catch(e){return await J(),0}finally{w.value.refreshingToken=0}})();const e=await s;return s=null,e},F=async e=>{try{e.user&&(u.value=i(e.user));const t={accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:new Date(Date.now()+3e5),userId:u.value?.id||e.user?.id};f.value=t,"undefined"!=typeof window&&(localStorage.setItem("strands_auth_session",JSON.stringify(t)),u.value&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value))),M()}catch(t){}},M=()=>{if(o&&clearTimeout(o),!f.value)return;if("undefined"!=typeof document&&"hidden"===document.visibilityState)return;const e=new Date,t=f.value.expiresAt.getTime()-e.getTime()-6e4;t<=0?P():o=setTimeout(async()=>{"undefined"!=typeof document&&"visible"!==document.visibilityState||await P()&&M()},t)},U=()=>{o&&(clearTimeout(o),o=null)},D=async()=>{if(!y.value){w.value.initializing=1;try{if("undefined"!=typeof window){const t=localStorage.getItem("strands_auth_session"),a=localStorage.getItem("strands_auth_user");if(t&&a)try{const e=JSON.parse(t),n=JSON.parse(a);e.expiresAt=new Date(e.expiresAt),e.expiresAt<=new Date&&e.refreshToken?(f.value=e,u.value=n,await P()||(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"),f.value=null,u.value=null)):e.expiresAt>new Date?(f.value=e,u.value=n,M()):(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"))}catch(e){localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")}}y.value=1,await new Promise(e=>setTimeout(e,50))}catch(e){}finally{w.value.initializing=0}}};"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&f.value?M():"hidden"===document.visibilityState&&U()});const I=()=>{U(),l(),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",()=>{})};try{e.onUnmounted(I)}catch(j){}return y.value||D(),{user:e.computed(()=>u.value),currentUser:e.computed(()=>u.value),currentSession:e.computed(()=>f.value),isAuthenticated:C,isLoading:e.computed(()=>N.value||!y.value),loading:e.computed(()=>$.value),loadingMessage:b,isInitializing:S,isSigningIn:_,isSigningUp:T,isSigningOut:E,isRefreshingToken:v,isSendingMfaEmail:O,isVerifyingMfa:A,mfaRequired:e.computed(()=>g.value),mfaSessionId:e.computed(()=>m.value),availableMfaMethods:e.computed(()=>p.value),signIn:async e=>{w.value.signingIn=1;try{g.value=0,m.value=null,p.value=[];const t={"Content-Type":"application/json"};"undefined"!=typeof window&&window.location&&(t.Origin=window.location.origin);const a=await fetch(c("signIn"),{method:"POST",headers:t,body:JSON.stringify(e)});if(!a.ok)throw 401===a.status?new Error("Invalid email or password"):403===a.status?new Error("Please verify your email address before signing in"):new Error(`Sign in failed: ${a.status} ${a.statusText}`);const n=await a.json();if(n.mfa_required){g.value=1,m.value=n.mfa_session_id||null;const e=(n.available_mfa_methods||[]).map(e=>{let t=`${e.device_type.charAt(0).toUpperCase()+e.device_type.slice(1)} Authentication`;return"hardware"===e.device_type?t=e.device_name||"Security Key":"totp"===e.device_type?t=e.device_name||"Authenticator App":"email"===e.device_type&&(t=e.device_name||"Email Verification"),{id:e.device_id,device_type:e.device_type,device_name:e.device_name||t,is_active:1,created_at:(new Date).toISOString(),last_used_at:e.last_used_at,credential_id:e.credential_id,device_info:e.device_info}});return p.value=e,w.value.signingIn=0,n}return await F(n),n}catch(t){throw t}finally{w.value.signingIn=0}},signUp:async e=>{w.value.signingUp=1;try{throw new Error("Sign up not implemented - please integrate with auth SDK")}finally{w.value.signingUp=0}},signOut:J,refreshToken:P,fetchProfile:async()=>{const e=`profile:${f.value.accessToken.slice(0,20)}`;w.value.loadingProfile=1;try{return await d(e,async()=>{const e=await fetch(c("profile"),{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value?.accessToken}`}});if(!e.ok)throw 401===e.status?new Error("Authentication expired. Please sign in again."):new Error(`Failed to fetch profile: ${e.status} ${e.statusText}`);const t=await e.json();return u.value=i(t),u.value&&"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value)),u.value})}finally{w.value.loadingProfile=0}},updateProfile:async e=>{w.value.loadingProfile=1;try{const t=await fetch(c("profile"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({first_name:e.firstName,last_name:e.lastName})});if(!t.ok)throw 401===t.status?new Error("Authentication expired. Please sign in again."):new Error(`Profile update failed: ${t.status} ${t.statusText}`);const a=await t.json();return u.value=i(a),u.value&&n("strands_auth_user",JSON.stringify(u.value)),u.value}finally{w.value.loadingProfile=0}},updateUserSettings:async e=>{w.value.loadingProfile=1;try{const t=await fetch(c("settings"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({settings:e})});if(!t.ok)throw 401===t.status?new Error("Authentication expired. Please sign in again."):new Error(`Settings update failed: ${t.status} ${t.statusText}`);const a=await t.json();return u.value=i(a),u.value&&n("strands_auth_user",JSON.stringify(u.value)),u.value}finally{w.value.loadingProfile=0}},changeEmail:async(e,t)=>{w.value.loadingProfile=1;try{const a=await fetch(c("changeEmail"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({new_email:e,password:t})});if(!a.ok){if(401===a.status)throw new Error("Authentication expired. Please sign in again.");{const e=await a.json().catch(()=>({}));throw new Error(e.message||`Email change failed: ${a.status} ${a.statusText}`)}}const n=await a.json();return u.value&&(u.value={...u.value,email:e,emailVerified:0,updatedAt:(new Date).toISOString()},"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value))),n}finally{w.value.loadingProfile=0}},changeUsername:async e=>{w.value.loadingProfile=1;try{const t=await fetch(c("changeUsername"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({username:e})});if(!t.ok){const e=await t.json().catch(()=>({}));if(409===t.status)throw new Error("Username is already taken");if(e.cooldown_end)throw new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(e.cooldown_end).toLocaleDateString()}`);throw new Error(e.message||`Username change failed: ${t.status} ${t.statusText}`)}const a=await t.json();return u.value&&(u.value={...u.value,username:e,usernameLastChangedAt:(new Date).toISOString(),updatedAt:(new Date).toISOString()},"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value))),a}finally{w.value.loadingProfile=0}},getUsernameCooldown:async()=>{const e=await fetch(c("usernameCooldown"),{method:"GET",headers:{Authorization:`Bearer ${f.value.accessToken}`}});if(!e.ok)throw new Error(`Failed to get username cooldown: ${e.status} ${e.statusText}`);return e.json()},checkUsernameAvailability:async e=>{const t=c("checkUsernameAvailability").replace("{username}",encodeURIComponent(e)),a=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok)throw new Error(`Failed to check username availability: ${a.status} ${a.statusText}`);return a.json()},getUserSessions:async()=>{const e=`sessions:${f.value?.accessToken?.slice(0,20)||"no-token"}`;try{return await d(e,async()=>{const e=k(),t=await fetch(c("sessions"),{method:"GET",headers:e});if(!t.ok)throw await t.text(),new Error(`Failed to get user sessions: ${t.status} ${t.statusText}`);return t.json()},12e4)}catch(t){throw t}},getSessionStats:async()=>{const e=await fetch(c("sessionsStats"),{method:"GET",headers:k()});if(!e.ok)throw new Error(`Failed to get session stats: ${e.status} ${e.statusText}`);return e.json()},revokeSession:async e=>{const t=c("sessionRevoke").replace("{session_id}",encodeURIComponent(e)),a=await fetch(t,{method:"POST",headers:k()});if(!a.ok)throw new Error(`Failed to revoke session: ${a.status} ${a.statusText}`);return 200===a.status},revokeAllOtherSessions:async()=>{const e=await fetch(c("sessionsRevokeAll"),{method:"POST",headers:k()});if(!e.ok)throw new Error(`Failed to revoke all other sessions: ${e.status} ${e.statusText}`);return 200===e.status},initialize:D,setAuthData:F,verifyMfa:async(e,t,a=0)=>{if(!m.value)throw new Error("No MFA session available");w.value.verifyingMfa=1;try{const n=c(a?"mfaBackupCodeVerify":"mfaSigninVerify"),i=a?{mfa_session_id:m.value,backup_code:t}:{mfa_session_id:m.value,device_id:e,code:t},r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok){const e=await r.text();let t="MFA verification failed";try{const a=JSON.parse(e);t=a.message||a.error||e}catch{t=e||"MFA verification failed"}throw new Error(t)}const o=await r.json();return g.value=0,m.value=null,p.value=[],await F(o),o}finally{w.value.verifyingMfa=0}},sendMfaEmailCode:async e=>{if(!m.value)throw new Error("No MFA session available");w.value.sendingMfaEmail=1;try{const t=await fetch(c("mfaSigninSendEmail"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:m.value,device_id:e})});if(!t.ok){const e=await t.text();let a="Failed to send MFA email code";try{const t=JSON.parse(e);a=t.message||t.error||e}catch{a=e||"Failed to send MFA email code"}throw new Error(a)}return await t.json()}finally{w.value.sendingMfaEmail=0}},getMfaWebAuthnChallenge:async e=>{if(!m.value)throw new Error("No MFA session available");const t=await fetch(c("mfaWebAuthnChallenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:m.value,device_id:e})});if(!t.ok){const e=await t.text();let a="Failed to get WebAuthn challenge";try{const t=JSON.parse(e);a=t.message||t.error||e}catch{a=e||a}throw new Error(a)}return t.json()},registerHardwareKey:async(e,t,a="hardware")=>{const n=await fetch(c("mfaHardwareStartRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({device_name:e,device_type:a})});if(!n.ok){const e=await n.text();let t="Failed to start hardware key registration";try{const a=JSON.parse(e);t=a.message||a.error||e}catch{t=e||"Failed to start hardware key registration"}throw new Error(t)}return n.json()},completeHardwareKeyRegistration:async(e,t,a)=>{const n=await fetch(c("mfaHardwareCompleteRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({device_id:e,credential:t})});if(!n.ok){const e=await n.text();let t="Failed to complete hardware key registration";try{const a=JSON.parse(e);t=a.message||a.error||e}catch{t=e||"Failed to complete hardware key registration"}throw new Error(t)}return n.json()},startTokenRefreshTimer:M,stopTokenRefreshTimer:U,getAuthHeaders:k,forceReInit:()=>{y.value=0,w.value.initializing=1,D()}}};
|
|
1
|
+
"use strict";const e=require("vue"),t=require("./useStrandsConfig-BUmt8HfH.cjs.js"),a=new class{cache=new Map;DEFAULT_TTL=3e5;async fetch(e,t,a=this.DEFAULT_TTL){const n=Date.now(),i=this.cache.get(e);if(i&&n-i.timestamp<i.ttl)return i.promise;this.cleanExpired();const r=t().finally(()=>{setTimeout(()=>{this.cache.delete(e)},a)});return this.cache.set(e,{promise:r,timestamp:n,ttl:a}),r}clear(){this.cache.clear()}invalidate(e){this.cache.delete(e)}cleanExpired(){const e=Date.now();for(const[t,a]of this.cache.entries())e-a.timestamp>a.ttl&&this.cache.delete(t)}getStats(){return{size:this.cache.size,entries:Array.from(this.cache.keys())}}},n=function(){let e=null;return(...t)=>{e&&clearTimeout(e),e=setTimeout(()=>{((e,t)=>{"undefined"!=typeof window&&localStorage.setItem(e,t)})(...t)},300)}}(),i=e=>({id:e.id,email:e.email,firstName:e.first_name||e.firstName||"",lastName:e.last_name||e.lastName||"",avatar:e.avatar_url||e.avatar,mfaEnabled:e.mfa_enabled??e.mfaEnabled??0,emailVerified:e.email_verified??e.emailVerified??0,passwordUpdatedAt:e.password_updated_at||e.passwordUpdatedAt,settings:e.settings||{},xp:e.xp||0,level:e.level||1,next_level_xp:e.next_level_xp||e.next_level_xp||4,username:e.username,usernameLastChangedAt:e.username_last_changed_at||e.usernameLastChangedAt,createdAt:e.created_at||e.createdAt,updatedAt:e.updated_at||e.updatedAt||(new Date).toISOString()}),r={currentUser:e.ref(null),currentSession:e.ref(null),loadingStates:e.ref({initializing:1,signingIn:0,signingUp:0,signingOut:0,refreshingToken:0,sendingMfaEmail:0,verifyingMfa:0,loadingProfile:0}),isInitialized:e.ref(0),mfaRequired:e.ref(0),mfaSessionId:e.ref(null),availableMfaMethods:e.ref([])};let o=null,s=null;exports.useStrandsAuth=function(){const{getUrl:c}=t.useStrandsConfig(),{fetch:d,clear:l,invalidate:h}={fetch:a.fetch.bind(a),clear:a.clear.bind(a),invalidate:a.invalidate.bind(a),getStats:a.getStats.bind(a)},{currentUser:u,currentSession:f,loadingStates:w,isInitialized:y,mfaRequired:g,mfaSessionId:m,availableMfaMethods:p}=r,S=e.computed(()=>w.value.initializing),_=e.computed(()=>w.value.signingIn),T=e.computed(()=>w.value.signingUp),E=e.computed(()=>w.value.signingOut),v=e.computed(()=>w.value.refreshingToken),O=e.computed(()=>w.value.sendingMfaEmail),A=e.computed(()=>w.value.verifyingMfa);e.computed(()=>w.value.loadingProfile);const $=e.computed(()=>w.value.signingIn||w.value.signingUp||w.value.signingOut||w.value.refreshingToken||w.value.sendingMfaEmail||w.value.verifyingMfa||w.value.loadingProfile),N=e.computed(()=>w.value.initializing||$.value),b=e.computed(()=>{const e=w.value;return e.initializing?"Checking authentication...":e.signingIn?"Signing you in...":e.signingUp?"Creating your account...":e.signingOut?"Signing you out...":e.refreshingToken?"Refreshing session...":e.sendingMfaEmail?"Sending verification code...":e.verifyingMfa?"Verifying code...":e.loadingProfile?"Loading profile...":"Loading..."}),k=()=>{const e={};return f.value?.accessToken&&(e.Authorization=`Bearer ${f.value.accessToken}`),f.value?.refreshToken&&(e["x-refresh-token"]=f.value.refreshToken),e},C=e.computed(()=>null!==u.value),J=async()=>{w.value.signingOut=1;try{U(),s=null,l(),u.value=null,f.value=null,g.value=0,m.value=null,p.value=[],"undefined"!=typeof window&&(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"))}finally{w.value.signingOut=0}},P=async()=>{if(!f.value?.refreshToken)return 0;if(s)return await s;s=(async()=>{w.value.refreshingToken=1;try{const e=await fetch(c("refresh"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:f.value.refreshToken})});if(!e.ok){if(401===e.status)return await J(),0;throw new Error(`Token refresh failed: ${e.status} ${e.statusText}`)}const t=await e.json();t.user&&(u.value=i(t.user),u.value&&"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value)));const a={accessToken:t.access_token,refreshToken:t.refresh_token,expiresAt:new Date(Date.now()+3e5),userId:t.user?.id||u.value?.id};return f.value=a,"undefined"!=typeof window&&localStorage.setItem("strands_auth_session",JSON.stringify(a)),M(),h(`sessions:${f.value.accessToken.slice(0,20)}`),1}catch(e){return await J(),0}finally{w.value.refreshingToken=0}})();const e=await s;return s=null,e},F=async e=>{try{e.user&&(u.value=i(e.user));const t={accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:new Date(Date.now()+3e5),userId:u.value?.id||e.user?.id};f.value=t,"undefined"!=typeof window&&(localStorage.setItem("strands_auth_session",JSON.stringify(t)),u.value&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value))),M()}catch(t){}},M=()=>{if(o&&clearTimeout(o),!f.value)return;if("undefined"!=typeof document&&"hidden"===document.visibilityState)return;const e=new Date,t=f.value.expiresAt.getTime()-e.getTime()-6e4;t<=0?P():o=setTimeout(async()=>{"undefined"!=typeof document&&"visible"!==document.visibilityState||await P()&&M()},t)},U=()=>{o&&(clearTimeout(o),o=null)},D=async()=>{if(!y.value){w.value.initializing=1;try{if("undefined"!=typeof window){const t=localStorage.getItem("strands_auth_session"),a=localStorage.getItem("strands_auth_user");if(t&&a)try{const e=JSON.parse(t),n=JSON.parse(a);e.expiresAt=new Date(e.expiresAt),e.expiresAt<=new Date&&e.refreshToken?(f.value=e,u.value=n,await P()||(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"),f.value=null,u.value=null)):e.expiresAt>new Date?(f.value=e,u.value=n,M()):(localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user"))}catch(e){localStorage.removeItem("strands_auth_session"),localStorage.removeItem("strands_auth_user")}}y.value=1,await new Promise(e=>setTimeout(e,50))}catch(e){}finally{w.value.initializing=0}}};"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&f.value?M():"hidden"===document.visibilityState&&U()});const I=()=>{U(),l(),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",()=>{})};try{e.onUnmounted(I)}catch(j){}return y.value||D(),{user:e.computed(()=>u.value),currentUser:e.computed(()=>u.value),currentSession:e.computed(()=>f.value),isAuthenticated:C,isLoading:e.computed(()=>N.value||!y.value),loading:e.computed(()=>$.value),loadingMessage:b,isInitializing:S,isSigningIn:_,isSigningUp:T,isSigningOut:E,isRefreshingToken:v,isSendingMfaEmail:O,isVerifyingMfa:A,mfaRequired:e.computed(()=>g.value),mfaSessionId:e.computed(()=>m.value),availableMfaMethods:e.computed(()=>p.value),signIn:async e=>{w.value.signingIn=1;try{g.value=0,m.value=null,p.value=[];const t={"Content-Type":"application/json"};"undefined"!=typeof window&&window.location&&(t.Origin=window.location.origin);const a=await fetch(c("signIn"),{method:"POST",headers:t,body:JSON.stringify(e)});if(!a.ok)throw 401===a.status?new Error("Invalid email or password"):403===a.status?new Error("Please verify your email address before signing in"):new Error(`Sign in failed: ${a.status} ${a.statusText}`);const n=await a.json();if(n.mfa_required){g.value=1,m.value=n.mfa_session_id||null;const e=(n.available_mfa_methods||[]).map(e=>{let t=`${e.device_type.charAt(0).toUpperCase()+e.device_type.slice(1)} Authentication`;return"hardware"===e.device_type?t=e.device_name||"Security Key":"totp"===e.device_type?t=e.device_name||"Authenticator App":"email"===e.device_type&&(t=e.device_name||"Email Verification"),{id:e.device_id,device_type:e.device_type,device_name:e.device_name||t,is_active:1,created_at:(new Date).toISOString(),last_used_at:e.last_used_at,credential_id:e.credential_id,device_info:e.device_info}});return p.value=e,w.value.signingIn=0,n}return await F(n),n}catch(t){throw t}finally{w.value.signingIn=0}},signUp:async e=>{w.value.signingUp=1;try{throw new Error("Sign up not implemented - please integrate with auth SDK")}finally{w.value.signingUp=0}},signOut:J,refreshToken:P,fetchProfile:async()=>{const e=`profile:${f.value.accessToken.slice(0,20)}`;w.value.loadingProfile=1;try{return await d(e,async()=>{const e=await fetch(c("profile"),{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value?.accessToken}`}});if(!e.ok)throw 401===e.status?new Error("Authentication expired. Please sign in again."):new Error(`Failed to fetch profile: ${e.status} ${e.statusText}`);const t=await e.json();return u.value=i(t),u.value&&"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value)),u.value})}finally{w.value.loadingProfile=0}},updateProfile:async e=>{w.value.loadingProfile=1;try{const t=await fetch(c("profile"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({first_name:e.firstName,last_name:e.lastName})});if(!t.ok)throw 401===t.status?new Error("Authentication expired. Please sign in again."):new Error(`Profile update failed: ${t.status} ${t.statusText}`);const a=await t.json();return u.value=i(a),u.value&&n("strands_auth_user",JSON.stringify(u.value)),u.value}finally{w.value.loadingProfile=0}},updateUserSettings:async e=>{w.value.loadingProfile=1;try{const t=await fetch(c("settings"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({settings:e})});if(!t.ok)throw 401===t.status?new Error("Authentication expired. Please sign in again."):new Error(`Settings update failed: ${t.status} ${t.statusText}`);const a=await t.json();return u.value=i(a),u.value&&n("strands_auth_user",JSON.stringify(u.value)),u.value}finally{w.value.loadingProfile=0}},changeEmail:async(e,t)=>{w.value.loadingProfile=1;try{const a=await fetch(c("changeEmail"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({new_email:e,password:t})});if(!a.ok){if(401===a.status)throw new Error("Authentication expired. Please sign in again.");{const e=await a.json().catch(()=>({}));throw new Error(e.message||`Email change failed: ${a.status} ${a.statusText}`)}}const n=await a.json();return u.value&&(u.value={...u.value,email:e,emailVerified:0,updatedAt:(new Date).toISOString()},"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value))),n}finally{w.value.loadingProfile=0}},changeUsername:async e=>{w.value.loadingProfile=1;try{const t=await fetch(c("changeUsername"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({username:e})});if(!t.ok){const e=await t.json().catch(()=>({}));if(409===t.status)throw new Error("Username is already taken");if(e.cooldown_end)throw new Error(`You can only change your username once every 30 days. You can change it again on ${new Date(e.cooldown_end).toLocaleDateString()}`);throw new Error(e.message||`Username change failed: ${t.status} ${t.statusText}`)}const a=await t.json();return u.value&&(u.value={...u.value,username:e,usernameLastChangedAt:(new Date).toISOString(),updatedAt:(new Date).toISOString()},"undefined"!=typeof window&&localStorage.setItem("strands_auth_user",JSON.stringify(u.value))),a}finally{w.value.loadingProfile=0}},getUsernameCooldown:async()=>{const e=await fetch(c("usernameCooldown"),{method:"GET",headers:{Authorization:`Bearer ${f.value.accessToken}`}});if(!e.ok)throw new Error(`Failed to get username cooldown: ${e.status} ${e.statusText}`);return e.json()},checkUsernameAvailability:async e=>{const t=c("checkUsernameAvailability").replace("{username}",encodeURIComponent(e)),a=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok)throw new Error(`Failed to check username availability: ${a.status} ${a.statusText}`);return a.json()},getUserSessions:async()=>{const e=`sessions:${f.value?.accessToken?.slice(0,20)||"no-token"}`;try{return await d(e,async()=>{const e=k(),t=await fetch(c("sessions"),{method:"GET",headers:e});if(!t.ok)throw await t.text(),new Error(`Failed to get user sessions: ${t.status} ${t.statusText}`);return t.json()},12e4)}catch(t){throw t}},getSessionStats:async()=>{const e=await fetch(c("sessionsStats"),{method:"GET",headers:k()});if(!e.ok)throw new Error(`Failed to get session stats: ${e.status} ${e.statusText}`);return e.json()},revokeSession:async e=>{const t=c("sessionRevoke").replace("{session_id}",encodeURIComponent(e)),a=await fetch(t,{method:"POST",headers:k()});if(!a.ok)throw new Error(`Failed to revoke session: ${a.status} ${a.statusText}`);return 200===a.status},revokeAllOtherSessions:async()=>{const e=await fetch(c("sessionsRevokeAll"),{method:"POST",headers:k()});if(!e.ok)throw new Error(`Failed to revoke all other sessions: ${e.status} ${e.statusText}`);return 200===e.status},initialize:D,setAuthData:F,verifyMfa:async(e,t,a=0)=>{if(!m.value)throw new Error("No MFA session available");w.value.verifyingMfa=1;try{const n=c(a?"mfaBackupCodeVerify":"mfaSigninVerify"),i=a?{mfa_session_id:m.value,backup_code:t}:{mfa_session_id:m.value,device_id:e,code:t},r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok){const e=await r.text();let t="MFA verification failed";try{const a=JSON.parse(e);t=a.message||a.error||e}catch{t=e||"MFA verification failed"}throw new Error(t)}const o=await r.json();return g.value=0,m.value=null,p.value=[],await F(o),o}finally{w.value.verifyingMfa=0}},sendMfaEmailCode:async e=>{if(!m.value)throw new Error("No MFA session available");w.value.sendingMfaEmail=1;try{const t=await fetch(c("mfaSigninSendEmail"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:m.value,device_id:e})});if(!t.ok){const e=await t.text();let a="Failed to send MFA email code";try{const t=JSON.parse(e);a=t.message||t.error||e}catch{a=e||"Failed to send MFA email code"}throw new Error(a)}return await t.json()}finally{w.value.sendingMfaEmail=0}},getMfaWebAuthnChallenge:async e=>{if(!m.value)throw new Error("No MFA session available");const t=await fetch(c("mfaWebAuthnChallenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mfa_session_id:m.value,device_id:e})});if(!t.ok){const e=await t.text();let a="Failed to get WebAuthn challenge";try{const t=JSON.parse(e);a=t.message||t.error||e}catch{a=e||a}throw new Error(a)}return t.json()},registerHardwareKey:async(e,t,a="hardware")=>{const n=await fetch(c("mfaHardwareStartRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({device_name:e,device_type:a})});if(!n.ok){const e=await n.text();let t="Failed to start hardware key registration";try{const a=JSON.parse(e);t=a.message||a.error||e}catch{t=e||"Failed to start hardware key registration"}throw new Error(t)}return n.json()},completeHardwareKeyRegistration:async(e,t,a)=>{const n=await fetch(c("mfaHardwareCompleteRegistration"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.value.accessToken}`},body:JSON.stringify({device_id:e,credential:t})});if(!n.ok){const e=await n.text();let t="Failed to complete hardware key registration";try{const a=JSON.parse(e);t=a.message||a.error||e}catch{t=e||"Failed to complete hardware key registration"}throw new Error(t)}return n.json()},startTokenRefreshTimer:M,stopTokenRefreshTimer:U,getAuthHeaders:k,forceReInit:()=>{y.value=0,w.value.initializing=1,D()}}};
|
|
@@ -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{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}};
|
|
@@ -106,7 +106,12 @@ function provideStrandsConfig(config) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
function useStrandsConfig(fallbackConfig) {
|
|
109
|
-
|
|
109
|
+
let injectedConfig = null;
|
|
110
|
+
try {
|
|
111
|
+
injectedConfig = inject(STRANDS_CONFIG_KEY, null);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
injectedConfig = null;
|
|
114
|
+
}
|
|
110
115
|
let nuxtConfig = null;
|
|
111
116
|
try {
|
|
112
117
|
if (typeof window !== "undefined") {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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){const n=e.inject(a,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}};
|