intlayer-editor 7.3.12 → 7.3.14
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/client/dist/assets/{CodeBlockShiki-C3xG8AyL.js → CodeBlockShiki-B4oIr_Ja.js} +3 -3
- package/client/dist/assets/{bundle-web-06zUzoaF.js → bundle-web-iXynhYBw.js} +117 -117
- package/client/dist/assets/{index-CpI4KDfc.css → index-B6iFg1jy.css} +6 -0
- package/client/dist/assets/{index-OEPa9TO7.js → index-DZJci7kl.js} +1659 -1650
- package/client/dist/index.html +2 -2
- package/package.json +23 -35
|
@@ -12546,7 +12546,7 @@ const logger = (content2, details) => {
|
|
|
12546
12546
|
if (level === "error") return error(...flatContent);
|
|
12547
12547
|
log2(...flatContent);
|
|
12548
12548
|
};
|
|
12549
|
-
let ANSIColors = /* @__PURE__ */ function(ANSIColors$1) {
|
|
12549
|
+
let ANSIColors = /* @__PURE__ */ (function(ANSIColors$1) {
|
|
12550
12550
|
ANSIColors$1["RESET"] = "\x1B[0m";
|
|
12551
12551
|
ANSIColors$1["GREY"] = "\x1B[90m";
|
|
12552
12552
|
ANSIColors$1["GREY_DARK"] = "\x1B[38;5;239m";
|
|
@@ -12562,7 +12562,7 @@ let ANSIColors = /* @__PURE__ */ function(ANSIColors$1) {
|
|
|
12562
12562
|
ANSIColors$1["WHITE"] = "\x1B[37m";
|
|
12563
12563
|
ANSIColors$1["BOLD"] = "\x1B[1m";
|
|
12564
12564
|
return ANSIColors$1;
|
|
12565
|
-
}({});
|
|
12565
|
+
})({});
|
|
12566
12566
|
const getAppLogger = (configuration2, globalDetails) => (content2, details) => logger(content2, {
|
|
12567
12567
|
...details ?? {},
|
|
12568
12568
|
config: {
|
|
@@ -13524,7 +13524,7 @@ const ALL_LOCALES = {
|
|
|
13524
13524
|
ARABIC_CHAD,
|
|
13525
13525
|
ARABIC_COMOROS
|
|
13526
13526
|
};
|
|
13527
|
-
let NodeType = /* @__PURE__ */ function(NodeType$1) {
|
|
13527
|
+
let NodeType = /* @__PURE__ */ (function(NodeType$1) {
|
|
13528
13528
|
NodeType$1["Translation"] = "translation";
|
|
13529
13529
|
NodeType$1["Enumeration"] = "enumeration";
|
|
13530
13530
|
NodeType$1["Condition"] = "condition";
|
|
@@ -13542,7 +13542,7 @@ let NodeType = /* @__PURE__ */ function(NodeType$1) {
|
|
|
13542
13542
|
NodeType$1["Null"] = "null";
|
|
13543
13543
|
NodeType$1["Unknown"] = "unknown";
|
|
13544
13544
|
return NodeType$1;
|
|
13545
|
-
}({});
|
|
13545
|
+
})({});
|
|
13546
13546
|
var internationalization_exports = /* @__PURE__ */ __export$1({
|
|
13547
13547
|
DEFAULT_LOCALE: () => DEFAULT_LOCALE,
|
|
13548
13548
|
LOCALES: () => LOCALES,
|
|
@@ -14930,7 +14930,7 @@ const mergeIframeClick = (event) => {
|
|
|
14930
14930
|
window.dispatchEvent(simulatedClickEvent);
|
|
14931
14931
|
window.dispatchEvent(simulatedMouseDownEvent);
|
|
14932
14932
|
};
|
|
14933
|
-
let MessageKey = /* @__PURE__ */ function(MessageKey$1) {
|
|
14933
|
+
let MessageKey = /* @__PURE__ */ (function(MessageKey$1) {
|
|
14934
14934
|
MessageKey$1["INTLAYER_CONFIGURATION"] = "INTLAYER_CONFIGURATION";
|
|
14935
14935
|
MessageKey$1["INTLAYER_CURRENT_LOCALE"] = "INTLAYER_CURRENT_LOCALE";
|
|
14936
14936
|
MessageKey$1["INTLAYER_EDITOR_ENABLED"] = "INTLAYER_EDITOR_ENABLED";
|
|
@@ -14942,7 +14942,7 @@ let MessageKey = /* @__PURE__ */ function(MessageKey$1) {
|
|
|
14942
14942
|
MessageKey$1["INTLAYER_EDITED_CONTENT_CHANGED"] = "INTLAYER_EDITED_CONTENT_CHANGED";
|
|
14943
14943
|
MessageKey$1["INTLAYER_IFRAME_CLICKED"] = "INTLAYER_IFRAME_CLICKED";
|
|
14944
14944
|
return MessageKey$1;
|
|
14945
|
-
}({});
|
|
14945
|
+
})({});
|
|
14946
14946
|
const useCrossFrameMessageListener = (key2, onEventTriggered, revalidator) => {
|
|
14947
14947
|
const { allowedOrigins, postMessage, senderId } = useCommunicator();
|
|
14948
14948
|
reactExports.useEffect(() => {
|
|
@@ -20925,7 +20925,7 @@ const containerVariants$1 = cva("flex flex-col text-text backdrop-blur", {
|
|
|
20925
20925
|
gap: "none"
|
|
20926
20926
|
}
|
|
20927
20927
|
});
|
|
20928
|
-
let ContainerRoundedSize = /* @__PURE__ */ function(ContainerRoundedSize$1) {
|
|
20928
|
+
let ContainerRoundedSize = /* @__PURE__ */ (function(ContainerRoundedSize$1) {
|
|
20929
20929
|
ContainerRoundedSize$1["NONE"] = "none";
|
|
20930
20930
|
ContainerRoundedSize$1["SM"] = "sm";
|
|
20931
20931
|
ContainerRoundedSize$1["MD"] = "md";
|
|
@@ -20935,7 +20935,7 @@ let ContainerRoundedSize = /* @__PURE__ */ function(ContainerRoundedSize$1) {
|
|
|
20935
20935
|
ContainerRoundedSize$1["THREE_XL"] = "3xl";
|
|
20936
20936
|
ContainerRoundedSize$1["FULL"] = "full";
|
|
20937
20937
|
return ContainerRoundedSize$1;
|
|
20938
|
-
}({});
|
|
20938
|
+
})({});
|
|
20939
20939
|
const Container = ({
|
|
20940
20940
|
children,
|
|
20941
20941
|
roundedSize,
|
|
@@ -21055,7 +21055,7 @@ const Loader = ({
|
|
|
21055
21055
|
})
|
|
21056
21056
|
}) : children ?? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})
|
|
21057
21057
|
});
|
|
21058
|
-
let ButtonSize = /* @__PURE__ */ function(ButtonSize$1) {
|
|
21058
|
+
let ButtonSize = /* @__PURE__ */ (function(ButtonSize$1) {
|
|
21059
21059
|
ButtonSize$1["SM"] = "sm";
|
|
21060
21060
|
ButtonSize$1["MD"] = "md";
|
|
21061
21061
|
ButtonSize$1["LG"] = "lg";
|
|
@@ -21065,7 +21065,7 @@ let ButtonSize = /* @__PURE__ */ function(ButtonSize$1) {
|
|
|
21065
21065
|
ButtonSize$1["ICON_LG"] = "icon-lg";
|
|
21066
21066
|
ButtonSize$1["ICON_XL"] = "icon-xl";
|
|
21067
21067
|
return ButtonSize$1;
|
|
21068
|
-
}({});
|
|
21068
|
+
})({});
|
|
21069
21069
|
const buttonIconVariants = cva("flex-none shrink-0", {
|
|
21070
21070
|
variants: {
|
|
21071
21071
|
size: {
|
|
@@ -21083,7 +21083,7 @@ const buttonIconVariants = cva("flex-none shrink-0", {
|
|
|
21083
21083
|
size: ButtonSize.MD
|
|
21084
21084
|
}
|
|
21085
21085
|
});
|
|
21086
|
-
let ButtonVariant = /* @__PURE__ */ function(ButtonVariant$1) {
|
|
21086
|
+
let ButtonVariant = /* @__PURE__ */ (function(ButtonVariant$1) {
|
|
21087
21087
|
ButtonVariant$1["DEFAULT"] = "default";
|
|
21088
21088
|
ButtonVariant$1["NONE"] = "none";
|
|
21089
21089
|
ButtonVariant$1["OUTLINE"] = "outline";
|
|
@@ -21093,8 +21093,8 @@ let ButtonVariant = /* @__PURE__ */ function(ButtonVariant$1) {
|
|
|
21093
21093
|
ButtonVariant$1["FADE"] = "fade";
|
|
21094
21094
|
ButtonVariant$1["INPUT"] = "input";
|
|
21095
21095
|
return ButtonVariant$1;
|
|
21096
|
-
}({});
|
|
21097
|
-
let ButtonColor = /* @__PURE__ */ function(ButtonColor$1) {
|
|
21096
|
+
})({});
|
|
21097
|
+
let ButtonColor = /* @__PURE__ */ (function(ButtonColor$1) {
|
|
21098
21098
|
ButtonColor$1["PRIMARY"] = "primary";
|
|
21099
21099
|
ButtonColor$1["SECONDARY"] = "secondary";
|
|
21100
21100
|
ButtonColor$1["DESTRUCTIVE"] = "destructive";
|
|
@@ -21109,13 +21109,13 @@ let ButtonColor = /* @__PURE__ */ function(ButtonColor$1) {
|
|
|
21109
21109
|
ButtonColor$1["SUCCESS"] = "success";
|
|
21110
21110
|
ButtonColor$1["CUSTOM"] = "custom";
|
|
21111
21111
|
return ButtonColor$1;
|
|
21112
|
-
}({});
|
|
21113
|
-
let ButtonTextAlign = /* @__PURE__ */ function(ButtonTextAlign$1) {
|
|
21112
|
+
})({});
|
|
21113
|
+
let ButtonTextAlign = /* @__PURE__ */ (function(ButtonTextAlign$1) {
|
|
21114
21114
|
ButtonTextAlign$1["LEFT"] = "left";
|
|
21115
21115
|
ButtonTextAlign$1["CENTER"] = "center";
|
|
21116
21116
|
ButtonTextAlign$1["RIGHT"] = "right";
|
|
21117
21117
|
return ButtonTextAlign$1;
|
|
21118
|
-
}({});
|
|
21118
|
+
})({});
|
|
21119
21119
|
const buttonVariants = cva("relative inline-flex cursor-pointer items-center justify-center font-medium ring-0 transition-all duration-300 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50", {
|
|
21120
21120
|
variants: {
|
|
21121
21121
|
size: {
|
|
@@ -21594,7 +21594,7 @@ const Accordion = ({
|
|
|
21594
21594
|
})]
|
|
21595
21595
|
});
|
|
21596
21596
|
};
|
|
21597
|
-
let BadgeColor = /* @__PURE__ */ function(BadgeColor$1) {
|
|
21597
|
+
let BadgeColor = /* @__PURE__ */ (function(BadgeColor$1) {
|
|
21598
21598
|
BadgeColor$1["PRIMARY"] = "primary";
|
|
21599
21599
|
BadgeColor$1["SECONDARY"] = "secondary";
|
|
21600
21600
|
BadgeColor$1["DESTRUCTIVE"] = "destructive";
|
|
@@ -21606,20 +21606,20 @@ let BadgeColor = /* @__PURE__ */ function(BadgeColor$1) {
|
|
|
21606
21606
|
BadgeColor$1["TEXT"] = "text";
|
|
21607
21607
|
BadgeColor$1["CUSTOM"] = "custom";
|
|
21608
21608
|
return BadgeColor$1;
|
|
21609
|
-
}({});
|
|
21610
|
-
let BadgeVariant = /* @__PURE__ */ function(BadgeVariant$1) {
|
|
21609
|
+
})({});
|
|
21610
|
+
let BadgeVariant = /* @__PURE__ */ (function(BadgeVariant$1) {
|
|
21611
21611
|
BadgeVariant$1["DEFAULT"] = "default";
|
|
21612
21612
|
BadgeVariant$1["NONE"] = "none";
|
|
21613
21613
|
BadgeVariant$1["OUTLINE"] = "outline";
|
|
21614
21614
|
BadgeVariant$1["HOVERABLE"] = "hoverable";
|
|
21615
21615
|
return BadgeVariant$1;
|
|
21616
|
-
}({});
|
|
21617
|
-
let BadgeSize = /* @__PURE__ */ function(BadgeSize$1) {
|
|
21616
|
+
})({});
|
|
21617
|
+
let BadgeSize = /* @__PURE__ */ (function(BadgeSize$1) {
|
|
21618
21618
|
BadgeSize$1["SMALL"] = "sm";
|
|
21619
21619
|
BadgeSize$1["MEDIUM"] = "md";
|
|
21620
21620
|
BadgeSize$1["LARGE"] = "lg";
|
|
21621
21621
|
return BadgeSize$1;
|
|
21622
|
-
}({});
|
|
21622
|
+
})({});
|
|
21623
21623
|
const badgeVariants = cva("inline-flex items-center rounded-md border px-2.5 py-0.5 font-semibold text-xs transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2", {
|
|
21624
21624
|
variants: {
|
|
21625
21625
|
color: {
|
|
@@ -21711,15 +21711,15 @@ const Badge = ({
|
|
|
21711
21711
|
})]
|
|
21712
21712
|
});
|
|
21713
21713
|
};
|
|
21714
|
-
let LinkVariant = /* @__PURE__ */ function(LinkVariant$1) {
|
|
21714
|
+
let LinkVariant = /* @__PURE__ */ (function(LinkVariant$1) {
|
|
21715
21715
|
LinkVariant$1["DEFAULT"] = "default";
|
|
21716
21716
|
LinkVariant$1["INVISIBLE_LINK"] = "invisible-link";
|
|
21717
21717
|
LinkVariant$1["BUTTON"] = "button";
|
|
21718
21718
|
LinkVariant$1["BUTTON_OUTLINED"] = "button-outlined";
|
|
21719
21719
|
LinkVariant$1["HOVERABLE"] = "hoverable";
|
|
21720
21720
|
return LinkVariant$1;
|
|
21721
|
-
}({});
|
|
21722
|
-
let LinkColor = /* @__PURE__ */ function(LinkColor$1) {
|
|
21721
|
+
})({});
|
|
21722
|
+
let LinkColor = /* @__PURE__ */ (function(LinkColor$1) {
|
|
21723
21723
|
LinkColor$1["PRIMARY"] = "primary";
|
|
21724
21724
|
LinkColor$1["SECONDARY"] = "secondary";
|
|
21725
21725
|
LinkColor$1["DESTRUCTIVE"] = "destructive";
|
|
@@ -21732,13 +21732,13 @@ let LinkColor = /* @__PURE__ */ function(LinkColor$1) {
|
|
|
21732
21732
|
LinkColor$1["SUCCESS"] = "success";
|
|
21733
21733
|
LinkColor$1["CUSTOM"] = "custom";
|
|
21734
21734
|
return LinkColor$1;
|
|
21735
|
-
}({});
|
|
21736
|
-
let LinkUnderlined = /* @__PURE__ */ function(LinkUnderlined$1) {
|
|
21735
|
+
})({});
|
|
21736
|
+
let LinkUnderlined = /* @__PURE__ */ (function(LinkUnderlined$1) {
|
|
21737
21737
|
LinkUnderlined$1["DEFAULT"] = "default";
|
|
21738
21738
|
LinkUnderlined$1["TRUE"] = "true";
|
|
21739
21739
|
LinkUnderlined$1["FALSE"] = "false";
|
|
21740
21740
|
return LinkUnderlined$1;
|
|
21741
|
-
}({});
|
|
21741
|
+
})({});
|
|
21742
21742
|
const linkVariants = cva("gap-3 transition focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50", {
|
|
21743
21743
|
variants: {
|
|
21744
21744
|
variant: {
|
|
@@ -25116,19 +25116,19 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
25116
25116
|
return { schedule, cancel, state, steps };
|
|
25117
25117
|
}
|
|
25118
25118
|
const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop$2, true);
|
|
25119
|
-
let now;
|
|
25119
|
+
let now$2;
|
|
25120
25120
|
function clearTime() {
|
|
25121
|
-
now = void 0;
|
|
25121
|
+
now$2 = void 0;
|
|
25122
25122
|
}
|
|
25123
25123
|
const time$2 = {
|
|
25124
25124
|
now: () => {
|
|
25125
|
-
if (now === void 0) {
|
|
25125
|
+
if (now$2 === void 0) {
|
|
25126
25126
|
time$2.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming ? frameData.timestamp : performance.now());
|
|
25127
25127
|
}
|
|
25128
|
-
return now;
|
|
25128
|
+
return now$2;
|
|
25129
25129
|
},
|
|
25130
25130
|
set: (newTime) => {
|
|
25131
|
-
now = newTime;
|
|
25131
|
+
now$2 = newTime;
|
|
25132
25132
|
queueMicrotask(clearTime);
|
|
25133
25133
|
}
|
|
25134
25134
|
};
|
|
@@ -30168,7 +30168,7 @@ class VisualElementDragControls {
|
|
|
30168
30168
|
}
|
|
30169
30169
|
frame.read(measureDragConstraints);
|
|
30170
30170
|
const stopResizeListener = addDomEvent(window, "resize", () => this.scalePositionWithinConstraints());
|
|
30171
|
-
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", ({ delta, hasLayoutChanged }) => {
|
|
30171
|
+
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
|
|
30172
30172
|
if (this.isDragging && hasLayoutChanged) {
|
|
30173
30173
|
eachAxis((axis) => {
|
|
30174
30174
|
const motionValue2 = this.getAxisMotionValue(axis);
|
|
@@ -30179,7 +30179,7 @@ class VisualElementDragControls {
|
|
|
30179
30179
|
});
|
|
30180
30180
|
this.visualElement.render();
|
|
30181
30181
|
}
|
|
30182
|
-
});
|
|
30182
|
+
}));
|
|
30183
30183
|
return () => {
|
|
30184
30184
|
stopResizeListener();
|
|
30185
30185
|
stopPointerListener();
|
|
@@ -31995,14 +31995,14 @@ const domAnimation = {
|
|
|
31995
31995
|
...animations,
|
|
31996
31996
|
...gestureAnimations
|
|
31997
31997
|
};
|
|
31998
|
-
let ModalSize = /* @__PURE__ */ function(ModalSize$1) {
|
|
31998
|
+
let ModalSize = /* @__PURE__ */ (function(ModalSize$1) {
|
|
31999
31999
|
ModalSize$1["SM"] = "sm";
|
|
32000
32000
|
ModalSize$1["MD"] = "md";
|
|
32001
32001
|
ModalSize$1["LG"] = "lg";
|
|
32002
32002
|
ModalSize$1["XL"] = "xl";
|
|
32003
32003
|
ModalSize$1["UNSET"] = "unset";
|
|
32004
32004
|
return ModalSize$1;
|
|
32005
|
-
}({});
|
|
32005
|
+
})({});
|
|
32006
32006
|
const modalVariants = cva("flex cursor-default flex-col overflow-hidden p-3 shadow-sm", {
|
|
32007
32007
|
variants: {
|
|
32008
32008
|
size: {
|
|
@@ -32209,11 +32209,11 @@ const inputVariants = cva(["w-full select-text resize-none text-base shadow-none
|
|
|
32209
32209
|
validationStyleEnabled: "disabled"
|
|
32210
32210
|
}
|
|
32211
32211
|
});
|
|
32212
|
-
let InputVariant = /* @__PURE__ */ function(InputVariant$1) {
|
|
32212
|
+
let InputVariant = /* @__PURE__ */ (function(InputVariant$1) {
|
|
32213
32213
|
InputVariant$1["DEFAULT"] = "default";
|
|
32214
32214
|
InputVariant$1["INVISIBLE"] = "invisible";
|
|
32215
32215
|
return InputVariant$1;
|
|
32216
|
-
}({});
|
|
32216
|
+
})({});
|
|
32217
32217
|
const Input = ({
|
|
32218
32218
|
validationStyleEnabled = false,
|
|
32219
32219
|
variant,
|
|
@@ -37898,609 +37898,430 @@ const useOAuth2 = (intlayerConfiguration) => {
|
|
|
37898
37898
|
});
|
|
37899
37899
|
return { oAuth2AccessToken: data?.data };
|
|
37900
37900
|
};
|
|
37901
|
-
|
|
37902
|
-
|
|
37903
|
-
|
|
37904
|
-
|
|
37905
|
-
|
|
37906
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
37907
|
-
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
37908
|
-
var __spreadValues = (a2, b) => {
|
|
37909
|
-
for (var prop in b || (b = {}))
|
|
37910
|
-
if (__hasOwnProp.call(b, prop))
|
|
37911
|
-
__defNormalProp(a2, prop, b[prop]);
|
|
37912
|
-
if (__getOwnPropSymbols)
|
|
37913
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
37914
|
-
if (__propIsEnum.call(b, prop))
|
|
37915
|
-
__defNormalProp(a2, prop, b[prop]);
|
|
37916
|
-
}
|
|
37917
|
-
return a2;
|
|
37918
|
-
};
|
|
37919
|
-
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
|
|
37920
|
-
var BetterFetchError = class extends Error {
|
|
37921
|
-
constructor(status, statusText, error) {
|
|
37922
|
-
super(statusText || status.toString(), {
|
|
37923
|
-
cause: error
|
|
37924
|
-
});
|
|
37925
|
-
this.status = status;
|
|
37926
|
-
this.statusText = statusText;
|
|
37927
|
-
this.error = error;
|
|
37928
|
-
}
|
|
37929
|
-
};
|
|
37930
|
-
var initializePlugins = async (url, options) => {
|
|
37931
|
-
var _a2, _b, _c, _d, _e2, _f;
|
|
37932
|
-
let opts = options || {};
|
|
37933
|
-
const hooks = {
|
|
37934
|
-
onRequest: [options == null ? void 0 : options.onRequest],
|
|
37935
|
-
onResponse: [options == null ? void 0 : options.onResponse],
|
|
37936
|
-
onSuccess: [options == null ? void 0 : options.onSuccess],
|
|
37937
|
-
onError: [options == null ? void 0 : options.onError],
|
|
37938
|
-
onRetry: [options == null ? void 0 : options.onRetry]
|
|
37939
|
-
};
|
|
37940
|
-
if (!options || !(options == null ? void 0 : options.plugins)) {
|
|
37941
|
-
return {
|
|
37942
|
-
url,
|
|
37943
|
-
options: opts,
|
|
37944
|
-
hooks
|
|
37945
|
-
};
|
|
37901
|
+
function bufferToBase64URLString(buffer) {
|
|
37902
|
+
const bytes = new Uint8Array(buffer);
|
|
37903
|
+
let str = "";
|
|
37904
|
+
for (const charCode of bytes) {
|
|
37905
|
+
str += String.fromCharCode(charCode);
|
|
37946
37906
|
}
|
|
37947
|
-
|
|
37948
|
-
|
|
37949
|
-
|
|
37950
|
-
|
|
37951
|
-
|
|
37952
|
-
|
|
37953
|
-
|
|
37954
|
-
|
|
37955
|
-
|
|
37956
|
-
|
|
37957
|
-
|
|
37907
|
+
const base64String = btoa(str);
|
|
37908
|
+
return base64String.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
37909
|
+
}
|
|
37910
|
+
function base64URLStringToBuffer(base64URLString) {
|
|
37911
|
+
const base642 = base64URLString.replace(/-/g, "+").replace(/_/g, "/");
|
|
37912
|
+
const padLength = (4 - base642.length % 4) % 4;
|
|
37913
|
+
const padded = base642.padEnd(base642.length + padLength, "=");
|
|
37914
|
+
const binary = atob(padded);
|
|
37915
|
+
const buffer = new ArrayBuffer(binary.length);
|
|
37916
|
+
const bytes = new Uint8Array(buffer);
|
|
37917
|
+
for (let i2 = 0; i2 < binary.length; i2++) {
|
|
37918
|
+
bytes[i2] = binary.charCodeAt(i2);
|
|
37958
37919
|
}
|
|
37920
|
+
return buffer;
|
|
37921
|
+
}
|
|
37922
|
+
function browserSupportsWebAuthn() {
|
|
37923
|
+
return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== void 0 && typeof globalThis.PublicKeyCredential === "function");
|
|
37924
|
+
}
|
|
37925
|
+
const _browserSupportsWebAuthnInternals = {
|
|
37926
|
+
stubThis: (value) => value
|
|
37927
|
+
};
|
|
37928
|
+
function toPublicKeyCredentialDescriptor(descriptor) {
|
|
37929
|
+
const { id: id2 } = descriptor;
|
|
37959
37930
|
return {
|
|
37960
|
-
|
|
37961
|
-
|
|
37962
|
-
|
|
37931
|
+
...descriptor,
|
|
37932
|
+
id: base64URLStringToBuffer(id2),
|
|
37933
|
+
/**
|
|
37934
|
+
* `descriptor.transports` is an array of our `AuthenticatorTransportFuture` that includes newer
|
|
37935
|
+
* transports that TypeScript's DOM lib is ignorant of. Convince TS that our list of transports
|
|
37936
|
+
* are fine to pass to WebAuthn since browsers will recognize the new value.
|
|
37937
|
+
*/
|
|
37938
|
+
transports: descriptor.transports
|
|
37963
37939
|
};
|
|
37964
|
-
}
|
|
37965
|
-
|
|
37966
|
-
|
|
37967
|
-
|
|
37968
|
-
|
|
37969
|
-
|
|
37970
|
-
|
|
37971
|
-
|
|
37972
|
-
|
|
37973
|
-
|
|
37974
|
-
|
|
37975
|
-
|
|
37976
|
-
|
|
37977
|
-
|
|
37978
|
-
|
|
37940
|
+
}
|
|
37941
|
+
function isValidDomain(hostname) {
|
|
37942
|
+
return (
|
|
37943
|
+
// Consider localhost valid as well since it's okay wrt Secure Contexts
|
|
37944
|
+
hostname === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(hostname)
|
|
37945
|
+
);
|
|
37946
|
+
}
|
|
37947
|
+
class WebAuthnError extends Error {
|
|
37948
|
+
constructor({ message, code, cause, name }) {
|
|
37949
|
+
super(message, { cause });
|
|
37950
|
+
Object.defineProperty(this, "code", {
|
|
37951
|
+
enumerable: true,
|
|
37952
|
+
configurable: true,
|
|
37953
|
+
writable: true,
|
|
37954
|
+
value: void 0
|
|
37955
|
+
});
|
|
37956
|
+
this.name = name ?? cause.name;
|
|
37957
|
+
this.code = code;
|
|
37979
37958
|
}
|
|
37980
|
-
}
|
|
37981
|
-
|
|
37982
|
-
|
|
37983
|
-
|
|
37959
|
+
}
|
|
37960
|
+
function identifyRegistrationError({ error, options }) {
|
|
37961
|
+
const { publicKey } = options;
|
|
37962
|
+
if (!publicKey) {
|
|
37963
|
+
throw Error("options was missing required publicKey property");
|
|
37984
37964
|
}
|
|
37985
|
-
|
|
37986
|
-
if (
|
|
37987
|
-
return
|
|
37988
|
-
|
|
37989
|
-
|
|
37965
|
+
if (error.name === "AbortError") {
|
|
37966
|
+
if (options.signal instanceof AbortSignal) {
|
|
37967
|
+
return new WebAuthnError({
|
|
37968
|
+
message: "Registration ceremony was sent an abort signal",
|
|
37969
|
+
code: "ERROR_CEREMONY_ABORTED",
|
|
37970
|
+
cause: error
|
|
37971
|
+
});
|
|
37990
37972
|
}
|
|
37991
|
-
|
|
37992
|
-
|
|
37993
|
-
|
|
37994
|
-
|
|
37995
|
-
|
|
37996
|
-
|
|
37997
|
-
|
|
37998
|
-
|
|
37999
|
-
|
|
38000
|
-
|
|
38001
|
-
|
|
38002
|
-
|
|
38003
|
-
|
|
38004
|
-
|
|
38005
|
-
|
|
38006
|
-
|
|
37973
|
+
} else if (error.name === "ConstraintError") {
|
|
37974
|
+
if (publicKey.authenticatorSelection?.requireResidentKey === true) {
|
|
37975
|
+
return new WebAuthnError({
|
|
37976
|
+
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
37977
|
+
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
37978
|
+
cause: error
|
|
37979
|
+
});
|
|
37980
|
+
} else if (
|
|
37981
|
+
// @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
|
|
37982
|
+
options.mediation === "conditional" && publicKey.authenticatorSelection?.userVerification === "required"
|
|
37983
|
+
) {
|
|
37984
|
+
return new WebAuthnError({
|
|
37985
|
+
message: "User verification was required during automatic registration but it could not be performed",
|
|
37986
|
+
code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
|
|
37987
|
+
cause: error
|
|
37988
|
+
});
|
|
37989
|
+
} else if (publicKey.authenticatorSelection?.userVerification === "required") {
|
|
37990
|
+
return new WebAuthnError({
|
|
37991
|
+
message: "User verification was required but no available authenticator supported it",
|
|
37992
|
+
code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
|
|
37993
|
+
cause: error
|
|
37994
|
+
});
|
|
37995
|
+
}
|
|
37996
|
+
} else if (error.name === "InvalidStateError") {
|
|
37997
|
+
return new WebAuthnError({
|
|
37998
|
+
message: "The authenticator was previously registered",
|
|
37999
|
+
code: "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",
|
|
38000
|
+
cause: error
|
|
38007
38001
|
});
|
|
38008
|
-
}
|
|
38009
|
-
|
|
38010
|
-
|
|
38011
|
-
|
|
38012
|
-
|
|
38013
|
-
|
|
38014
|
-
|
|
38015
|
-
|
|
38016
|
-
|
|
38017
|
-
|
|
38018
|
-
|
|
38019
|
-
|
|
38020
|
-
|
|
38021
|
-
|
|
38022
|
-
if (options.auth.type === "Bearer") {
|
|
38023
|
-
const token = await getValue(options.auth.token);
|
|
38024
|
-
if (!token) {
|
|
38025
|
-
return headers;
|
|
38026
|
-
}
|
|
38027
|
-
headers["authorization"] = `Bearer ${token}`;
|
|
38028
|
-
} else if (options.auth.type === "Basic") {
|
|
38029
|
-
const username = getValue(options.auth.username);
|
|
38030
|
-
const password = getValue(options.auth.password);
|
|
38031
|
-
if (!username || !password) {
|
|
38032
|
-
return headers;
|
|
38033
|
-
}
|
|
38034
|
-
headers["authorization"] = `Basic ${btoa(`${username}:${password}`)}`;
|
|
38035
|
-
} else if (options.auth.type === "Custom") {
|
|
38036
|
-
const value = getValue(options.auth.value);
|
|
38037
|
-
if (!value) {
|
|
38038
|
-
return headers;
|
|
38039
|
-
}
|
|
38040
|
-
headers["authorization"] = `${getValue(options.auth.prefix)} ${value}`;
|
|
38002
|
+
} else if (error.name === "NotAllowedError") {
|
|
38003
|
+
return new WebAuthnError({
|
|
38004
|
+
message: error.message,
|
|
38005
|
+
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
38006
|
+
cause: error
|
|
38007
|
+
});
|
|
38008
|
+
} else if (error.name === "NotSupportedError") {
|
|
38009
|
+
const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === "public-key");
|
|
38010
|
+
if (validPubKeyCredParams.length === 0) {
|
|
38011
|
+
return new WebAuthnError({
|
|
38012
|
+
message: 'No entry in pubKeyCredParams was of type "public-key"',
|
|
38013
|
+
code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
|
|
38014
|
+
cause: error
|
|
38015
|
+
});
|
|
38041
38016
|
}
|
|
38017
|
+
return new WebAuthnError({
|
|
38018
|
+
message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
|
|
38019
|
+
code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
|
|
38020
|
+
cause: error
|
|
38021
|
+
});
|
|
38022
|
+
} else if (error.name === "SecurityError") {
|
|
38023
|
+
const effectiveDomain = globalThis.location.hostname;
|
|
38024
|
+
if (!isValidDomain(effectiveDomain)) {
|
|
38025
|
+
return new WebAuthnError({
|
|
38026
|
+
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
38027
|
+
code: "ERROR_INVALID_DOMAIN",
|
|
38028
|
+
cause: error
|
|
38029
|
+
});
|
|
38030
|
+
} else if (publicKey.rp.id !== effectiveDomain) {
|
|
38031
|
+
return new WebAuthnError({
|
|
38032
|
+
message: `The RP ID "${publicKey.rp.id}" is invalid for this domain`,
|
|
38033
|
+
code: "ERROR_INVALID_RP_ID",
|
|
38034
|
+
cause: error
|
|
38035
|
+
});
|
|
38036
|
+
}
|
|
38037
|
+
} else if (error.name === "TypeError") {
|
|
38038
|
+
if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {
|
|
38039
|
+
return new WebAuthnError({
|
|
38040
|
+
message: "User ID was not between 1 and 64 characters",
|
|
38041
|
+
code: "ERROR_INVALID_USER_ID_LENGTH",
|
|
38042
|
+
cause: error
|
|
38043
|
+
});
|
|
38044
|
+
}
|
|
38045
|
+
} else if (error.name === "UnknownError") {
|
|
38046
|
+
return new WebAuthnError({
|
|
38047
|
+
message: "The authenticator was unable to process the specified options, or could not create a new credential",
|
|
38048
|
+
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
38049
|
+
cause: error
|
|
38050
|
+
});
|
|
38042
38051
|
}
|
|
38043
|
-
return
|
|
38044
|
-
}
|
|
38045
|
-
|
|
38046
|
-
|
|
38047
|
-
|
|
38048
|
-
|
|
38049
|
-
|
|
38050
|
-
|
|
38051
|
-
|
|
38052
|
-
|
|
38053
|
-
]);
|
|
38054
|
-
if (!_contentType) {
|
|
38055
|
-
return "json";
|
|
38056
|
-
}
|
|
38057
|
-
const contentType = _contentType.split(";").shift() || "";
|
|
38058
|
-
if (JSON_RE.test(contentType)) {
|
|
38059
|
-
return "json";
|
|
38052
|
+
return error;
|
|
38053
|
+
}
|
|
38054
|
+
class BaseWebAuthnAbortService {
|
|
38055
|
+
constructor() {
|
|
38056
|
+
Object.defineProperty(this, "controller", {
|
|
38057
|
+
enumerable: true,
|
|
38058
|
+
configurable: true,
|
|
38059
|
+
writable: true,
|
|
38060
|
+
value: void 0
|
|
38061
|
+
});
|
|
38060
38062
|
}
|
|
38061
|
-
|
|
38062
|
-
|
|
38063
|
+
createNewAbortSignal() {
|
|
38064
|
+
if (this.controller) {
|
|
38065
|
+
const abortError = new Error("Cancelling existing WebAuthn API call for new one");
|
|
38066
|
+
abortError.name = "AbortError";
|
|
38067
|
+
this.controller.abort(abortError);
|
|
38068
|
+
}
|
|
38069
|
+
const newController = new AbortController();
|
|
38070
|
+
this.controller = newController;
|
|
38071
|
+
return newController.signal;
|
|
38063
38072
|
}
|
|
38064
|
-
|
|
38065
|
-
|
|
38066
|
-
|
|
38067
|
-
|
|
38068
|
-
|
|
38069
|
-
|
|
38070
|
-
|
|
38071
|
-
return false;
|
|
38073
|
+
cancelCeremony() {
|
|
38074
|
+
if (this.controller) {
|
|
38075
|
+
const abortError = new Error("Manually cancelling existing WebAuthn API call");
|
|
38076
|
+
abortError.name = "AbortError";
|
|
38077
|
+
this.controller.abort(abortError);
|
|
38078
|
+
this.controller = void 0;
|
|
38079
|
+
}
|
|
38072
38080
|
}
|
|
38073
38081
|
}
|
|
38074
|
-
|
|
38075
|
-
|
|
38076
|
-
|
|
38082
|
+
const WebAuthnAbortService = new BaseWebAuthnAbortService();
|
|
38083
|
+
const attachments = ["cross-platform", "platform"];
|
|
38084
|
+
function toAuthenticatorAttachment(attachment) {
|
|
38085
|
+
if (!attachment) {
|
|
38086
|
+
return;
|
|
38077
38087
|
}
|
|
38078
|
-
|
|
38079
|
-
|
|
38080
|
-
return true;
|
|
38088
|
+
if (attachments.indexOf(attachment) < 0) {
|
|
38089
|
+
return;
|
|
38081
38090
|
}
|
|
38082
|
-
|
|
38083
|
-
|
|
38091
|
+
return attachment;
|
|
38092
|
+
}
|
|
38093
|
+
async function startRegistration(options) {
|
|
38094
|
+
if (!options.optionsJSON && options.challenge) {
|
|
38095
|
+
console.warn("startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.");
|
|
38096
|
+
options = { optionsJSON: options };
|
|
38084
38097
|
}
|
|
38085
|
-
|
|
38086
|
-
|
|
38098
|
+
const { optionsJSON, useAutoRegister = false } = options;
|
|
38099
|
+
if (!browserSupportsWebAuthn()) {
|
|
38100
|
+
throw new Error("WebAuthn is not supported in this browser");
|
|
38087
38101
|
}
|
|
38088
|
-
|
|
38089
|
-
|
|
38102
|
+
const publicKey = {
|
|
38103
|
+
...optionsJSON,
|
|
38104
|
+
challenge: base64URLStringToBuffer(optionsJSON.challenge),
|
|
38105
|
+
user: {
|
|
38106
|
+
...optionsJSON.user,
|
|
38107
|
+
id: base64URLStringToBuffer(optionsJSON.user.id)
|
|
38108
|
+
},
|
|
38109
|
+
excludeCredentials: optionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor)
|
|
38110
|
+
};
|
|
38111
|
+
const createOptions = {};
|
|
38112
|
+
if (useAutoRegister) {
|
|
38113
|
+
createOptions.mediation = "conditional";
|
|
38090
38114
|
}
|
|
38091
|
-
|
|
38092
|
-
|
|
38093
|
-
|
|
38115
|
+
createOptions.publicKey = publicKey;
|
|
38116
|
+
createOptions.signal = WebAuthnAbortService.createNewAbortSignal();
|
|
38117
|
+
let credential;
|
|
38094
38118
|
try {
|
|
38095
|
-
|
|
38096
|
-
} catch (
|
|
38097
|
-
|
|
38098
|
-
}
|
|
38099
|
-
}
|
|
38100
|
-
function isFunction$1(value) {
|
|
38101
|
-
return typeof value === "function";
|
|
38102
|
-
}
|
|
38103
|
-
function getFetch(options) {
|
|
38104
|
-
if (options == null ? void 0 : options.customFetchImpl) {
|
|
38105
|
-
return options.customFetchImpl;
|
|
38106
|
-
}
|
|
38107
|
-
if (typeof globalThis !== "undefined" && isFunction$1(globalThis.fetch)) {
|
|
38108
|
-
return globalThis.fetch;
|
|
38119
|
+
credential = await navigator.credentials.create(createOptions);
|
|
38120
|
+
} catch (err) {
|
|
38121
|
+
throw identifyRegistrationError({ error: err, options: createOptions });
|
|
38109
38122
|
}
|
|
38110
|
-
if (
|
|
38111
|
-
|
|
38123
|
+
if (!credential) {
|
|
38124
|
+
throw new Error("Registration was not completed");
|
|
38112
38125
|
}
|
|
38113
|
-
|
|
38114
|
-
|
|
38115
|
-
|
|
38116
|
-
|
|
38117
|
-
const authHeader = await getAuthHeader(opts);
|
|
38118
|
-
for (const [key2, value] of Object.entries(authHeader || {})) {
|
|
38119
|
-
headers.set(key2, value);
|
|
38126
|
+
const { id: id2, rawId, response, type } = credential;
|
|
38127
|
+
let transports = void 0;
|
|
38128
|
+
if (typeof response.getTransports === "function") {
|
|
38129
|
+
transports = response.getTransports();
|
|
38120
38130
|
}
|
|
38121
|
-
|
|
38122
|
-
|
|
38123
|
-
|
|
38124
|
-
|
|
38131
|
+
let responsePublicKeyAlgorithm = void 0;
|
|
38132
|
+
if (typeof response.getPublicKeyAlgorithm === "function") {
|
|
38133
|
+
try {
|
|
38134
|
+
responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();
|
|
38135
|
+
} catch (error) {
|
|
38136
|
+
warnOnBrokenImplementation("getPublicKeyAlgorithm()", error);
|
|
38125
38137
|
}
|
|
38126
38138
|
}
|
|
38127
|
-
|
|
38128
|
-
|
|
38129
|
-
|
|
38130
|
-
|
|
38131
|
-
|
|
38132
|
-
|
|
38133
|
-
return null;
|
|
38134
|
-
}
|
|
38135
|
-
function getBody(options) {
|
|
38136
|
-
if (!(options == null ? void 0 : options.body)) {
|
|
38137
|
-
return null;
|
|
38138
|
-
}
|
|
38139
|
-
const headers = new Headers(options == null ? void 0 : options.headers);
|
|
38140
|
-
if (isJSONSerializable(options.body) && !headers.has("content-type")) {
|
|
38141
|
-
for (const [key2, value] of Object.entries(options == null ? void 0 : options.body)) {
|
|
38142
|
-
if (value instanceof Date) {
|
|
38143
|
-
options.body[key2] = value.toISOString();
|
|
38139
|
+
let responsePublicKey = void 0;
|
|
38140
|
+
if (typeof response.getPublicKey === "function") {
|
|
38141
|
+
try {
|
|
38142
|
+
const _publicKey = response.getPublicKey();
|
|
38143
|
+
if (_publicKey !== null) {
|
|
38144
|
+
responsePublicKey = bufferToBase64URLString(_publicKey);
|
|
38144
38145
|
}
|
|
38146
|
+
} catch (error) {
|
|
38147
|
+
warnOnBrokenImplementation("getPublicKey()", error);
|
|
38145
38148
|
}
|
|
38146
|
-
return JSON.stringify(options.body);
|
|
38147
|
-
}
|
|
38148
|
-
return options.body;
|
|
38149
|
-
}
|
|
38150
|
-
function getMethod$1(url, options) {
|
|
38151
|
-
var _a2;
|
|
38152
|
-
if (options == null ? void 0 : options.method) {
|
|
38153
|
-
return options.method.toUpperCase();
|
|
38154
38149
|
}
|
|
38155
|
-
|
|
38156
|
-
|
|
38157
|
-
|
|
38158
|
-
|
|
38150
|
+
let responseAuthenticatorData;
|
|
38151
|
+
if (typeof response.getAuthenticatorData === "function") {
|
|
38152
|
+
try {
|
|
38153
|
+
responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());
|
|
38154
|
+
} catch (error) {
|
|
38155
|
+
warnOnBrokenImplementation("getAuthenticatorData()", error);
|
|
38159
38156
|
}
|
|
38160
|
-
return pMethod.toUpperCase();
|
|
38161
|
-
}
|
|
38162
|
-
return (options == null ? void 0 : options.body) ? "POST" : "GET";
|
|
38163
|
-
}
|
|
38164
|
-
function getTimeout(options, controller) {
|
|
38165
|
-
let abortTimeout;
|
|
38166
|
-
if (!(options == null ? void 0 : options.signal) && (options == null ? void 0 : options.timeout)) {
|
|
38167
|
-
abortTimeout = setTimeout(() => controller == null ? void 0 : controller.abort(), options == null ? void 0 : options.timeout);
|
|
38168
38157
|
}
|
|
38169
38158
|
return {
|
|
38170
|
-
|
|
38171
|
-
|
|
38172
|
-
|
|
38173
|
-
|
|
38174
|
-
|
|
38175
|
-
|
|
38159
|
+
id: id2,
|
|
38160
|
+
rawId: bufferToBase64URLString(rawId),
|
|
38161
|
+
response: {
|
|
38162
|
+
attestationObject: bufferToBase64URLString(response.attestationObject),
|
|
38163
|
+
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
38164
|
+
transports,
|
|
38165
|
+
publicKeyAlgorithm: responsePublicKeyAlgorithm,
|
|
38166
|
+
publicKey: responsePublicKey,
|
|
38167
|
+
authenticatorData: responseAuthenticatorData
|
|
38168
|
+
},
|
|
38169
|
+
type,
|
|
38170
|
+
clientExtensionResults: credential.getClientExtensionResults(),
|
|
38171
|
+
authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
|
|
38176
38172
|
};
|
|
38177
38173
|
}
|
|
38178
|
-
|
|
38179
|
-
|
|
38180
|
-
|
|
38181
|
-
|
|
38182
|
-
|
|
38174
|
+
function warnOnBrokenImplementation(methodName, cause) {
|
|
38175
|
+
console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.
|
|
38176
|
+
`, cause);
|
|
38177
|
+
}
|
|
38178
|
+
function browserSupportsWebAuthnAutofill() {
|
|
38179
|
+
if (!browserSupportsWebAuthn()) {
|
|
38180
|
+
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
38183
38181
|
}
|
|
38184
|
-
|
|
38185
|
-
|
|
38186
|
-
|
|
38187
|
-
if (result.issues) {
|
|
38188
|
-
throw new ValidationError(result.issues);
|
|
38182
|
+
const globalPublicKeyCredential = globalThis.PublicKeyCredential;
|
|
38183
|
+
if (globalPublicKeyCredential?.isConditionalMediationAvailable === void 0) {
|
|
38184
|
+
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
38189
38185
|
}
|
|
38190
|
-
return
|
|
38186
|
+
return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
|
|
38191
38187
|
}
|
|
38192
|
-
|
|
38193
|
-
|
|
38194
|
-
id: "apply-schema",
|
|
38195
|
-
name: "Apply Schema",
|
|
38196
|
-
version: "1.0.0",
|
|
38197
|
-
async init(url, options) {
|
|
38198
|
-
var _a2, _b, _c, _d;
|
|
38199
|
-
const schema = ((_b = (_a2 = config2.plugins) == null ? void 0 : _a2.find(
|
|
38200
|
-
(plugin) => {
|
|
38201
|
-
var _a22;
|
|
38202
|
-
return ((_a22 = plugin.schema) == null ? void 0 : _a22.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
|
|
38203
|
-
}
|
|
38204
|
-
)) == null ? void 0 : _b.schema) || config2.schema;
|
|
38205
|
-
if (schema) {
|
|
38206
|
-
let urlKey = url;
|
|
38207
|
-
if ((_c = schema.config) == null ? void 0 : _c.prefix) {
|
|
38208
|
-
if (urlKey.startsWith(schema.config.prefix)) {
|
|
38209
|
-
urlKey = urlKey.replace(schema.config.prefix, "");
|
|
38210
|
-
if (schema.config.baseURL) {
|
|
38211
|
-
url = url.replace(schema.config.prefix, schema.config.baseURL);
|
|
38212
|
-
}
|
|
38213
|
-
}
|
|
38214
|
-
}
|
|
38215
|
-
if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
|
|
38216
|
-
if (urlKey.startsWith(schema.config.baseURL)) {
|
|
38217
|
-
urlKey = urlKey.replace(schema.config.baseURL, "");
|
|
38218
|
-
}
|
|
38219
|
-
}
|
|
38220
|
-
const keySchema = schema.schema[urlKey];
|
|
38221
|
-
if (keySchema) {
|
|
38222
|
-
let opts = __spreadProps(__spreadValues({}, options), {
|
|
38223
|
-
method: keySchema.method,
|
|
38224
|
-
output: keySchema.output
|
|
38225
|
-
});
|
|
38226
|
-
if (!(options == null ? void 0 : options.disableValidation)) {
|
|
38227
|
-
opts = __spreadProps(__spreadValues({}, opts), {
|
|
38228
|
-
body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
|
|
38229
|
-
params: keySchema.params ? await parseStandardSchema(keySchema.params, options == null ? void 0 : options.params) : options == null ? void 0 : options.params,
|
|
38230
|
-
query: keySchema.query ? await parseStandardSchema(keySchema.query, options == null ? void 0 : options.query) : options == null ? void 0 : options.query
|
|
38231
|
-
});
|
|
38232
|
-
}
|
|
38233
|
-
return {
|
|
38234
|
-
url,
|
|
38235
|
-
options: opts
|
|
38236
|
-
};
|
|
38237
|
-
}
|
|
38238
|
-
}
|
|
38239
|
-
return {
|
|
38240
|
-
url,
|
|
38241
|
-
options
|
|
38242
|
-
};
|
|
38243
|
-
}
|
|
38244
|
-
});
|
|
38245
|
-
var createFetch = (config2) => {
|
|
38246
|
-
async function $fetch(url, options) {
|
|
38247
|
-
const opts = __spreadProps(__spreadValues(__spreadValues({}, config2), options), {
|
|
38248
|
-
plugins: [...(config2 == null ? void 0 : config2.plugins) || [], applySchemaPlugin(config2 || {})]
|
|
38249
|
-
});
|
|
38250
|
-
if (config2 == null ? void 0 : config2.catchAllError) {
|
|
38251
|
-
try {
|
|
38252
|
-
return await betterFetch(url, opts);
|
|
38253
|
-
} catch (error) {
|
|
38254
|
-
return {
|
|
38255
|
-
data: null,
|
|
38256
|
-
error: {
|
|
38257
|
-
status: 500,
|
|
38258
|
-
statusText: "Fetch Error",
|
|
38259
|
-
message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
|
|
38260
|
-
error
|
|
38261
|
-
}
|
|
38262
|
-
};
|
|
38263
|
-
}
|
|
38264
|
-
}
|
|
38265
|
-
return await betterFetch(url, opts);
|
|
38266
|
-
}
|
|
38267
|
-
return $fetch;
|
|
38188
|
+
const _browserSupportsWebAuthnAutofillInternals = {
|
|
38189
|
+
stubThis: (value) => value
|
|
38268
38190
|
};
|
|
38269
|
-
function
|
|
38270
|
-
|
|
38271
|
-
|
|
38272
|
-
|
|
38273
|
-
baseURL: ""
|
|
38274
|
-
};
|
|
38275
|
-
let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
|
|
38276
|
-
if (url.startsWith("@")) {
|
|
38277
|
-
const m2 = url.toString().split("@")[1].split("/")[0];
|
|
38278
|
-
if (methods.includes(m2)) {
|
|
38279
|
-
url = url.replace(`@${m2}/`, "/");
|
|
38280
|
-
}
|
|
38281
|
-
}
|
|
38282
|
-
if (!basePath.endsWith("/")) basePath += "/";
|
|
38283
|
-
let [path, urlQuery] = url.replace(basePath, "").split("?");
|
|
38284
|
-
const queryParams = new URLSearchParams(urlQuery);
|
|
38285
|
-
for (const [key2, value] of Object.entries(query || {})) {
|
|
38286
|
-
if (value == null) continue;
|
|
38287
|
-
queryParams.set(key2, String(value));
|
|
38191
|
+
function identifyAuthenticationError({ error, options }) {
|
|
38192
|
+
const { publicKey } = options;
|
|
38193
|
+
if (!publicKey) {
|
|
38194
|
+
throw Error("options was missing required publicKey property");
|
|
38288
38195
|
}
|
|
38289
|
-
if (
|
|
38290
|
-
if (
|
|
38291
|
-
|
|
38292
|
-
|
|
38293
|
-
|
|
38294
|
-
|
|
38295
|
-
}
|
|
38296
|
-
} else {
|
|
38297
|
-
for (const [key2, value] of Object.entries(params)) {
|
|
38298
|
-
path = path.replace(`:${key2}`, String(value));
|
|
38299
|
-
}
|
|
38196
|
+
if (error.name === "AbortError") {
|
|
38197
|
+
if (options.signal instanceof AbortSignal) {
|
|
38198
|
+
return new WebAuthnError({
|
|
38199
|
+
message: "Authentication ceremony was sent an abort signal",
|
|
38200
|
+
code: "ERROR_CEREMONY_ABORTED",
|
|
38201
|
+
cause: error
|
|
38202
|
+
});
|
|
38300
38203
|
}
|
|
38204
|
+
} else if (error.name === "NotAllowedError") {
|
|
38205
|
+
return new WebAuthnError({
|
|
38206
|
+
message: error.message,
|
|
38207
|
+
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
38208
|
+
cause: error
|
|
38209
|
+
});
|
|
38210
|
+
} else if (error.name === "SecurityError") {
|
|
38211
|
+
const effectiveDomain = globalThis.location.hostname;
|
|
38212
|
+
if (!isValidDomain(effectiveDomain)) {
|
|
38213
|
+
return new WebAuthnError({
|
|
38214
|
+
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
38215
|
+
code: "ERROR_INVALID_DOMAIN",
|
|
38216
|
+
cause: error
|
|
38217
|
+
});
|
|
38218
|
+
} else if (publicKey.rpId !== effectiveDomain) {
|
|
38219
|
+
return new WebAuthnError({
|
|
38220
|
+
message: `The RP ID "${publicKey.rpId}" is invalid for this domain`,
|
|
38221
|
+
code: "ERROR_INVALID_RP_ID",
|
|
38222
|
+
cause: error
|
|
38223
|
+
});
|
|
38224
|
+
}
|
|
38225
|
+
} else if (error.name === "UnknownError") {
|
|
38226
|
+
return new WebAuthnError({
|
|
38227
|
+
message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
|
|
38228
|
+
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
38229
|
+
cause: error
|
|
38230
|
+
});
|
|
38301
38231
|
}
|
|
38302
|
-
|
|
38303
|
-
if (path.startsWith("/")) path = path.slice(1);
|
|
38304
|
-
let queryParamString = queryParams.toString();
|
|
38305
|
-
queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
|
|
38306
|
-
if (!basePath.startsWith("http")) {
|
|
38307
|
-
return `${basePath}${path}${queryParamString}`;
|
|
38308
|
-
}
|
|
38309
|
-
const _url2 = new URL(`${path}${queryParamString}`, basePath);
|
|
38310
|
-
return _url2;
|
|
38232
|
+
return error;
|
|
38311
38233
|
}
|
|
38312
|
-
|
|
38313
|
-
|
|
38314
|
-
|
|
38315
|
-
|
|
38316
|
-
url: __url,
|
|
38317
|
-
options: opts
|
|
38318
|
-
} = await initializePlugins(url, options);
|
|
38319
|
-
const fetch2 = getFetch(opts);
|
|
38320
|
-
const controller = new AbortController();
|
|
38321
|
-
const signal = (_a2 = opts.signal) != null ? _a2 : controller.signal;
|
|
38322
|
-
const _url2 = getURL2(__url, opts);
|
|
38323
|
-
const body = getBody(opts);
|
|
38324
|
-
const headers = await getHeaders(opts);
|
|
38325
|
-
const method = getMethod$1(__url, opts);
|
|
38326
|
-
let context = __spreadProps(__spreadValues({}, opts), {
|
|
38327
|
-
url: _url2,
|
|
38328
|
-
headers,
|
|
38329
|
-
body,
|
|
38330
|
-
method,
|
|
38331
|
-
signal
|
|
38332
|
-
});
|
|
38333
|
-
for (const onRequest of hooks.onRequest) {
|
|
38334
|
-
if (onRequest) {
|
|
38335
|
-
const res = await onRequest(context);
|
|
38336
|
-
if (res instanceof Object) {
|
|
38337
|
-
context = res;
|
|
38338
|
-
}
|
|
38339
|
-
}
|
|
38234
|
+
async function startAuthentication(options) {
|
|
38235
|
+
if (!options.optionsJSON && options.challenge) {
|
|
38236
|
+
console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.");
|
|
38237
|
+
options = { optionsJSON: options };
|
|
38340
38238
|
}
|
|
38341
|
-
|
|
38342
|
-
|
|
38343
|
-
|
|
38344
|
-
}
|
|
38239
|
+
const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true } = options;
|
|
38240
|
+
if (!browserSupportsWebAuthn()) {
|
|
38241
|
+
throw new Error("WebAuthn is not supported in this browser");
|
|
38345
38242
|
}
|
|
38346
|
-
|
|
38347
|
-
|
|
38348
|
-
|
|
38349
|
-
const responseContext = {
|
|
38350
|
-
response,
|
|
38351
|
-
request: context
|
|
38352
|
-
};
|
|
38353
|
-
for (const onResponse of hooks.onResponse) {
|
|
38354
|
-
if (onResponse) {
|
|
38355
|
-
const r2 = await onResponse(__spreadProps(__spreadValues({}, responseContext), {
|
|
38356
|
-
response: ((_c = options == null ? void 0 : options.hookOptions) == null ? void 0 : _c.cloneResponse) ? response.clone() : response
|
|
38357
|
-
}));
|
|
38358
|
-
if (r2 instanceof Response) {
|
|
38359
|
-
response = r2;
|
|
38360
|
-
} else if (r2 instanceof Object) {
|
|
38361
|
-
response = r2.response;
|
|
38362
|
-
}
|
|
38363
|
-
}
|
|
38243
|
+
let allowCredentials;
|
|
38244
|
+
if (optionsJSON.allowCredentials?.length !== 0) {
|
|
38245
|
+
allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);
|
|
38364
38246
|
}
|
|
38365
|
-
|
|
38366
|
-
|
|
38367
|
-
|
|
38368
|
-
|
|
38369
|
-
|
|
38370
|
-
|
|
38371
|
-
|
|
38372
|
-
|
|
38373
|
-
|
|
38374
|
-
const successContext = {
|
|
38375
|
-
data: "",
|
|
38376
|
-
response,
|
|
38377
|
-
request: context
|
|
38378
|
-
};
|
|
38379
|
-
if (responseType === "json" || responseType === "text") {
|
|
38380
|
-
const text = await response.text();
|
|
38381
|
-
const parser2 = (_d = context.jsonParser) != null ? _d : jsonParse;
|
|
38382
|
-
const data = await parser2(text);
|
|
38383
|
-
successContext.data = data;
|
|
38384
|
-
} else {
|
|
38385
|
-
successContext.data = await response[responseType]();
|
|
38386
|
-
}
|
|
38387
|
-
if (context == null ? void 0 : context.output) {
|
|
38388
|
-
if (context.output && !context.disableValidation) {
|
|
38389
|
-
successContext.data = await parseStandardSchema(
|
|
38390
|
-
context.output,
|
|
38391
|
-
successContext.data
|
|
38392
|
-
);
|
|
38393
|
-
}
|
|
38394
|
-
}
|
|
38395
|
-
for (const onSuccess of hooks.onSuccess) {
|
|
38396
|
-
if (onSuccess) {
|
|
38397
|
-
await onSuccess(__spreadProps(__spreadValues({}, successContext), {
|
|
38398
|
-
response: ((_e2 = options == null ? void 0 : options.hookOptions) == null ? void 0 : _e2.cloneResponse) ? response.clone() : response
|
|
38399
|
-
}));
|
|
38400
|
-
}
|
|
38247
|
+
const publicKey = {
|
|
38248
|
+
...optionsJSON,
|
|
38249
|
+
challenge: base64URLStringToBuffer(optionsJSON.challenge),
|
|
38250
|
+
allowCredentials
|
|
38251
|
+
};
|
|
38252
|
+
const getOptions = {};
|
|
38253
|
+
if (useBrowserAutofill) {
|
|
38254
|
+
if (!await browserSupportsWebAuthnAutofill()) {
|
|
38255
|
+
throw Error("Browser does not support WebAuthn autofill");
|
|
38401
38256
|
}
|
|
38402
|
-
|
|
38403
|
-
|
|
38257
|
+
const eligibleInputs = document.querySelectorAll("input[autocomplete$='webauthn']");
|
|
38258
|
+
if (eligibleInputs.length < 1 && verifyBrowserAutofillInput) {
|
|
38259
|
+
throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
|
|
38404
38260
|
}
|
|
38405
|
-
|
|
38406
|
-
|
|
38407
|
-
error: null
|
|
38408
|
-
};
|
|
38261
|
+
getOptions.mediation = "conditional";
|
|
38262
|
+
publicKey.allowCredentials = [];
|
|
38409
38263
|
}
|
|
38410
|
-
|
|
38411
|
-
|
|
38412
|
-
|
|
38413
|
-
|
|
38414
|
-
|
|
38415
|
-
|
|
38416
|
-
|
|
38417
|
-
request: context,
|
|
38418
|
-
error: __spreadProps(__spreadValues({}, errorObject), {
|
|
38419
|
-
status: response.status,
|
|
38420
|
-
statusText: response.statusText
|
|
38421
|
-
})
|
|
38422
|
-
};
|
|
38423
|
-
for (const onError of hooks.onError) {
|
|
38424
|
-
if (onError) {
|
|
38425
|
-
await onError(__spreadProps(__spreadValues({}, errorContext), {
|
|
38426
|
-
response: ((_g = options == null ? void 0 : options.hookOptions) == null ? void 0 : _g.cloneResponse) ? response.clone() : response
|
|
38427
|
-
}));
|
|
38428
|
-
}
|
|
38264
|
+
getOptions.publicKey = publicKey;
|
|
38265
|
+
getOptions.signal = WebAuthnAbortService.createNewAbortSignal();
|
|
38266
|
+
let credential;
|
|
38267
|
+
try {
|
|
38268
|
+
credential = await navigator.credentials.get(getOptions);
|
|
38269
|
+
} catch (err) {
|
|
38270
|
+
throw identifyAuthenticationError({ error: err, options: getOptions });
|
|
38429
38271
|
}
|
|
38430
|
-
if (
|
|
38431
|
-
|
|
38432
|
-
const _retryAttempt = (_h = options.retryAttempt) != null ? _h : 0;
|
|
38433
|
-
if (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {
|
|
38434
|
-
for (const onRetry of hooks.onRetry) {
|
|
38435
|
-
if (onRetry) {
|
|
38436
|
-
await onRetry(responseContext);
|
|
38437
|
-
}
|
|
38438
|
-
}
|
|
38439
|
-
const delay2 = retryStrategy.getDelay(_retryAttempt);
|
|
38440
|
-
await new Promise((resolve) => setTimeout(resolve, delay2));
|
|
38441
|
-
return await betterFetch(url, __spreadProps(__spreadValues({}, options), {
|
|
38442
|
-
retryAttempt: _retryAttempt + 1
|
|
38443
|
-
}));
|
|
38444
|
-
}
|
|
38272
|
+
if (!credential) {
|
|
38273
|
+
throw new Error("Authentication was not completed");
|
|
38445
38274
|
}
|
|
38446
|
-
|
|
38447
|
-
|
|
38448
|
-
|
|
38449
|
-
|
|
38450
|
-
isJSONResponse ? errorObject : responseText
|
|
38451
|
-
);
|
|
38275
|
+
const { id: id2, rawId, response, type } = credential;
|
|
38276
|
+
let userHandle = void 0;
|
|
38277
|
+
if (response.userHandle) {
|
|
38278
|
+
userHandle = bufferToBase64URLString(response.userHandle);
|
|
38452
38279
|
}
|
|
38453
38280
|
return {
|
|
38454
|
-
|
|
38455
|
-
|
|
38456
|
-
|
|
38457
|
-
|
|
38458
|
-
|
|
38281
|
+
id: id2,
|
|
38282
|
+
rawId: bufferToBase64URLString(rawId),
|
|
38283
|
+
response: {
|
|
38284
|
+
authenticatorData: bufferToBase64URLString(response.authenticatorData),
|
|
38285
|
+
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
38286
|
+
signature: bufferToBase64URLString(response.signature),
|
|
38287
|
+
userHandle
|
|
38288
|
+
},
|
|
38289
|
+
type,
|
|
38290
|
+
clientExtensionResults: credential.getClientExtensionResults(),
|
|
38291
|
+
authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
|
|
38459
38292
|
};
|
|
38460
|
-
}
|
|
38293
|
+
}
|
|
38461
38294
|
var define_globalThis_process_env_default = {};
|
|
38462
38295
|
var define_process_env_default = {};
|
|
38463
38296
|
const _envShim = /* @__PURE__ */ Object.create(null);
|
|
38464
|
-
const _getEnv = (useShim) => define_globalThis_process_env_default ||
|
|
38465
|
-
globalThis.Deno?.env.toObject() || //@ts-expect-error
|
|
38466
|
-
globalThis.__env__ || (useShim ? _envShim : globalThis);
|
|
38297
|
+
const _getEnv = (useShim) => define_globalThis_process_env_default || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
|
|
38467
38298
|
const env = new Proxy(_envShim, {
|
|
38468
38299
|
get(_2, prop) {
|
|
38469
|
-
|
|
38470
|
-
return env2[prop] ?? _envShim[prop];
|
|
38300
|
+
return _getEnv()[prop] ?? _envShim[prop];
|
|
38471
38301
|
},
|
|
38472
38302
|
has(_2, prop) {
|
|
38473
|
-
|
|
38474
|
-
return prop in env2 || prop in _envShim;
|
|
38303
|
+
return prop in _getEnv() || prop in _envShim;
|
|
38475
38304
|
},
|
|
38476
38305
|
set(_2, prop, value) {
|
|
38477
|
-
const
|
|
38478
|
-
|
|
38306
|
+
const env$1 = _getEnv(true);
|
|
38307
|
+
env$1[prop] = value;
|
|
38479
38308
|
return true;
|
|
38480
38309
|
},
|
|
38481
38310
|
deleteProperty(_2, prop) {
|
|
38482
|
-
if (!prop)
|
|
38483
|
-
|
|
38484
|
-
|
|
38485
|
-
const env2 = _getEnv(true);
|
|
38486
|
-
delete env2[prop];
|
|
38311
|
+
if (!prop) return false;
|
|
38312
|
+
const env$1 = _getEnv(true);
|
|
38313
|
+
delete env$1[prop];
|
|
38487
38314
|
return true;
|
|
38488
38315
|
},
|
|
38489
38316
|
ownKeys() {
|
|
38490
|
-
const
|
|
38491
|
-
return Object.keys(
|
|
38317
|
+
const env$1 = _getEnv(true);
|
|
38318
|
+
return Object.keys(env$1);
|
|
38492
38319
|
}
|
|
38493
38320
|
});
|
|
38494
38321
|
function getEnvVar(key2, fallback) {
|
|
38495
|
-
if (typeof process !== "undefined" && define_process_env_default)
|
|
38496
|
-
|
|
38497
|
-
|
|
38498
|
-
if (typeof Deno !== "undefined") {
|
|
38499
|
-
return Deno.env.get(key2) ?? fallback;
|
|
38500
|
-
}
|
|
38501
|
-
if (typeof Bun !== "undefined") {
|
|
38502
|
-
return Bun.env[key2] ?? fallback;
|
|
38503
|
-
}
|
|
38322
|
+
if (typeof process !== "undefined" && define_process_env_default) return define_process_env_default[key2] ?? fallback;
|
|
38323
|
+
if (typeof Deno !== "undefined") return Deno.env.get(key2) ?? fallback;
|
|
38324
|
+
if (typeof Bun !== "undefined") return Bun.env[key2] ?? fallback;
|
|
38504
38325
|
return fallback;
|
|
38505
38326
|
}
|
|
38506
38327
|
const COLORS_2 = 1;
|
|
@@ -38522,24 +38343,20 @@ const TERM_ENVS = {
|
|
|
38522
38343
|
mosh: COLORS_16m,
|
|
38523
38344
|
putty: COLORS_16,
|
|
38524
38345
|
st: COLORS_16,
|
|
38525
|
-
// http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html
|
|
38526
38346
|
"rxvt-unicode-24bit": COLORS_16m,
|
|
38527
|
-
// https://bugs.launchpad.net/terminator/+bug/1030562
|
|
38528
38347
|
terminator: COLORS_16m,
|
|
38529
38348
|
"xterm-kitty": COLORS_16m
|
|
38530
38349
|
};
|
|
38531
|
-
const CI_ENVS_MAP = new Map(
|
|
38532
|
-
|
|
38533
|
-
|
|
38534
|
-
|
|
38535
|
-
|
|
38536
|
-
|
|
38537
|
-
|
|
38538
|
-
|
|
38539
|
-
|
|
38540
|
-
|
|
38541
|
-
})
|
|
38542
|
-
);
|
|
38350
|
+
const CI_ENVS_MAP = new Map(Object.entries({
|
|
38351
|
+
APPVEYOR: COLORS_256,
|
|
38352
|
+
BUILDKITE: COLORS_256,
|
|
38353
|
+
CIRCLECI: COLORS_16m,
|
|
38354
|
+
DRONE: COLORS_256,
|
|
38355
|
+
GITEA_ACTIONS: COLORS_16m,
|
|
38356
|
+
GITHUB_ACTIONS: COLORS_16m,
|
|
38357
|
+
GITLAB_CI: COLORS_256,
|
|
38358
|
+
TRAVIS: COLORS_256
|
|
38359
|
+
}));
|
|
38543
38360
|
const TERM_ENVS_REG_EXP = [
|
|
38544
38361
|
/ansi/,
|
|
38545
38362
|
/color/,
|
|
@@ -38553,54 +38370,30 @@ const TERM_ENVS_REG_EXP = [
|
|
|
38553
38370
|
/^vt220/
|
|
38554
38371
|
];
|
|
38555
38372
|
function getColorDepth() {
|
|
38556
|
-
if (getEnvVar("FORCE_COLOR") !== void 0) {
|
|
38557
|
-
|
|
38558
|
-
|
|
38559
|
-
|
|
38560
|
-
|
|
38561
|
-
|
|
38562
|
-
|
|
38563
|
-
|
|
38564
|
-
|
|
38565
|
-
|
|
38566
|
-
|
|
38567
|
-
return COLORS_2;
|
|
38568
|
-
}
|
|
38569
|
-
}
|
|
38570
|
-
if (getEnvVar("NODE_DISABLE_COLORS") !== void 0 && getEnvVar("NODE_DISABLE_COLORS") !== "" || // See https://no-color.org/
|
|
38571
|
-
getEnvVar("NO_COLOR") !== void 0 && getEnvVar("NO_COLOR") !== "" || // The "dumb" special terminal, as defined by terminfo, doesn't support
|
|
38572
|
-
// ANSI color control codes.
|
|
38573
|
-
// See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials
|
|
38574
|
-
getEnvVar("TERM") === "dumb") {
|
|
38575
|
-
return COLORS_2;
|
|
38576
|
-
}
|
|
38577
|
-
if (getEnvVar("TMUX")) {
|
|
38578
|
-
return COLORS_16m;
|
|
38579
|
-
}
|
|
38580
|
-
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
38581
|
-
return COLORS_16;
|
|
38373
|
+
if (getEnvVar("FORCE_COLOR") !== void 0) switch (getEnvVar("FORCE_COLOR")) {
|
|
38374
|
+
case "":
|
|
38375
|
+
case "1":
|
|
38376
|
+
case "true":
|
|
38377
|
+
return COLORS_16;
|
|
38378
|
+
case "2":
|
|
38379
|
+
return COLORS_256;
|
|
38380
|
+
case "3":
|
|
38381
|
+
return COLORS_16m;
|
|
38382
|
+
default:
|
|
38383
|
+
return COLORS_2;
|
|
38582
38384
|
}
|
|
38385
|
+
if (getEnvVar("NODE_DISABLE_COLORS") !== void 0 && getEnvVar("NODE_DISABLE_COLORS") !== "" || getEnvVar("NO_COLOR") !== void 0 && getEnvVar("NO_COLOR") !== "" || getEnvVar("TERM") === "dumb") return COLORS_2;
|
|
38386
|
+
if (getEnvVar("TMUX")) return COLORS_16m;
|
|
38387
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) return COLORS_16;
|
|
38583
38388
|
if ("CI" in env) {
|
|
38584
|
-
for (const { 0: envName, 1: colors } of CI_ENVS_MAP)
|
|
38585
|
-
|
|
38586
|
-
return colors;
|
|
38587
|
-
}
|
|
38588
|
-
}
|
|
38589
|
-
if (getEnvVar("CI_NAME") === "codeship") {
|
|
38590
|
-
return COLORS_256;
|
|
38591
|
-
}
|
|
38389
|
+
for (const { 0: envName, 1: colors } of CI_ENVS_MAP) if (envName in env) return colors;
|
|
38390
|
+
if (getEnvVar("CI_NAME") === "codeship") return COLORS_256;
|
|
38592
38391
|
return COLORS_2;
|
|
38593
38392
|
}
|
|
38594
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
38595
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(
|
|
38596
|
-
getEnvVar("TEAMCITY_VERSION")
|
|
38597
|
-
) !== null ? COLORS_16 : COLORS_2;
|
|
38598
|
-
}
|
|
38393
|
+
if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(getEnvVar("TEAMCITY_VERSION")) !== null ? COLORS_16 : COLORS_2;
|
|
38599
38394
|
switch (getEnvVar("TERM_PROGRAM")) {
|
|
38600
38395
|
case "iTerm.app":
|
|
38601
|
-
if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null)
|
|
38602
|
-
return COLORS_256;
|
|
38603
|
-
}
|
|
38396
|
+
if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null) return COLORS_256;
|
|
38604
38397
|
return COLORS_16m;
|
|
38605
38398
|
case "HyperTerm":
|
|
38606
38399
|
case "MacTerm":
|
|
@@ -38608,27 +38401,15 @@ function getColorDepth() {
|
|
|
38608
38401
|
case "Apple_Terminal":
|
|
38609
38402
|
return COLORS_256;
|
|
38610
38403
|
}
|
|
38611
|
-
if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit")
|
|
38612
|
-
return COLORS_16m;
|
|
38613
|
-
}
|
|
38404
|
+
if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit") return COLORS_16m;
|
|
38614
38405
|
if (getEnvVar("TERM")) {
|
|
38615
|
-
if (/truecolor/.exec(getEnvVar("TERM")) !== null)
|
|
38616
|
-
|
|
38617
|
-
}
|
|
38618
|
-
if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) {
|
|
38619
|
-
return COLORS_256;
|
|
38620
|
-
}
|
|
38406
|
+
if (/truecolor/.exec(getEnvVar("TERM")) !== null) return COLORS_16m;
|
|
38407
|
+
if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) return COLORS_256;
|
|
38621
38408
|
const termEnv = getEnvVar("TERM").toLowerCase();
|
|
38622
|
-
if (TERM_ENVS[termEnv])
|
|
38623
|
-
|
|
38624
|
-
}
|
|
38625
|
-
if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {
|
|
38626
|
-
return COLORS_16;
|
|
38627
|
-
}
|
|
38628
|
-
}
|
|
38629
|
-
if (getEnvVar("COLORTERM")) {
|
|
38630
|
-
return COLORS_16;
|
|
38409
|
+
if (TERM_ENVS[termEnv]) return TERM_ENVS[termEnv];
|
|
38410
|
+
if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) return COLORS_16;
|
|
38631
38411
|
}
|
|
38412
|
+
if (getEnvVar("COLORTERM")) return COLORS_16;
|
|
38632
38413
|
return COLORS_2;
|
|
38633
38414
|
}
|
|
38634
38415
|
const TTY_COLORS = {
|
|
@@ -38643,9 +38424,15 @@ const TTY_COLORS = {
|
|
|
38643
38424
|
magenta: "\x1B[35m"
|
|
38644
38425
|
}
|
|
38645
38426
|
};
|
|
38646
|
-
const levels = [
|
|
38427
|
+
const levels = [
|
|
38428
|
+
"debug",
|
|
38429
|
+
"info",
|
|
38430
|
+
"success",
|
|
38431
|
+
"warn",
|
|
38432
|
+
"error"
|
|
38433
|
+
];
|
|
38647
38434
|
function shouldPublishLog(currentLogLevel, logLevel) {
|
|
38648
|
-
return levels.indexOf(logLevel)
|
|
38435
|
+
return levels.indexOf(logLevel) >= levels.indexOf(currentLogLevel);
|
|
38649
38436
|
}
|
|
38650
38437
|
const levelColors = {
|
|
38651
38438
|
info: TTY_COLORS.fg.blue,
|
|
@@ -38656,45 +38443,34 @@ const levelColors = {
|
|
|
38656
38443
|
};
|
|
38657
38444
|
const formatMessage = (level, message, colorsEnabled) => {
|
|
38658
38445
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
38659
|
-
if (colorsEnabled) {
|
|
38660
|
-
return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${levelColors[level]}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${TTY_COLORS.reset} ${message}`;
|
|
38661
|
-
}
|
|
38446
|
+
if (colorsEnabled) return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${levelColors[level]}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${TTY_COLORS.reset} ${message}`;
|
|
38662
38447
|
return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
|
|
38663
38448
|
};
|
|
38664
38449
|
const createLogger = (options) => {
|
|
38665
38450
|
const logLevel = "error";
|
|
38666
38451
|
const colorsEnabled = getColorDepth() !== 1;
|
|
38667
38452
|
const LogFunc = (level, message, args = []) => {
|
|
38668
|
-
if (!shouldPublishLog(logLevel, level))
|
|
38669
|
-
return;
|
|
38670
|
-
}
|
|
38453
|
+
if (!shouldPublishLog(logLevel, level)) return;
|
|
38671
38454
|
const formattedMessage = formatMessage(level, message, colorsEnabled);
|
|
38672
38455
|
{
|
|
38673
|
-
if (level === "error")
|
|
38674
|
-
|
|
38675
|
-
|
|
38676
|
-
console.warn(formattedMessage, ...args);
|
|
38677
|
-
} else {
|
|
38678
|
-
console.log(formattedMessage, ...args);
|
|
38679
|
-
}
|
|
38456
|
+
if (level === "error") console.error(formattedMessage, ...args);
|
|
38457
|
+
else if (level === "warn") console.warn(formattedMessage, ...args);
|
|
38458
|
+
else console.log(formattedMessage, ...args);
|
|
38680
38459
|
return;
|
|
38681
38460
|
}
|
|
38682
38461
|
};
|
|
38683
|
-
const logger2 = Object.fromEntries(
|
|
38684
|
-
levels.map((level) => [
|
|
38685
|
-
level,
|
|
38686
|
-
(...[message, ...args]) => LogFunc(level, message, args)
|
|
38687
|
-
])
|
|
38688
|
-
);
|
|
38689
38462
|
return {
|
|
38690
|
-
...
|
|
38463
|
+
...Object.fromEntries(levels.map((level) => [level, (...[message, ...args]) => LogFunc(level, message, args)])),
|
|
38691
38464
|
get level() {
|
|
38692
38465
|
return logLevel;
|
|
38693
38466
|
}
|
|
38694
38467
|
};
|
|
38695
38468
|
};
|
|
38696
38469
|
createLogger();
|
|
38697
|
-
|
|
38470
|
+
function capitalizeFirstLetter(str) {
|
|
38471
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
38472
|
+
}
|
|
38473
|
+
var BetterAuthError = class extends Error {
|
|
38698
38474
|
constructor(message, cause) {
|
|
38699
38475
|
super(message);
|
|
38700
38476
|
this.name = "BetterAuthError";
|
|
@@ -38702,44 +38478,106 @@ class BetterAuthError extends Error {
|
|
|
38702
38478
|
this.cause = cause;
|
|
38703
38479
|
this.stack = "";
|
|
38704
38480
|
}
|
|
38705
|
-
}
|
|
38481
|
+
};
|
|
38706
38482
|
function checkHasPath(url) {
|
|
38483
|
+
try {
|
|
38484
|
+
return (new URL(url).pathname.replace(/\/+$/, "") || "/") !== "/";
|
|
38485
|
+
} catch (error) {
|
|
38486
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
38487
|
+
}
|
|
38488
|
+
}
|
|
38489
|
+
function assertHasProtocol(url) {
|
|
38707
38490
|
try {
|
|
38708
38491
|
const parsedUrl = new URL(url);
|
|
38709
|
-
|
|
38710
|
-
return pathname !== "/";
|
|
38492
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
|
|
38711
38493
|
} catch (error) {
|
|
38712
|
-
|
|
38713
|
-
|
|
38714
|
-
);
|
|
38494
|
+
if (error instanceof BetterAuthError) throw error;
|
|
38495
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, String(error));
|
|
38715
38496
|
}
|
|
38716
38497
|
}
|
|
38717
38498
|
function withPath(url, path = "/api/auth") {
|
|
38718
|
-
|
|
38719
|
-
if (
|
|
38720
|
-
return url;
|
|
38721
|
-
}
|
|
38499
|
+
assertHasProtocol(url);
|
|
38500
|
+
if (checkHasPath(url)) return url;
|
|
38722
38501
|
const trimmedUrl = url.replace(/\/+$/, "");
|
|
38723
|
-
if (!path || path === "/")
|
|
38724
|
-
return trimmedUrl;
|
|
38725
|
-
}
|
|
38502
|
+
if (!path || path === "/") return trimmedUrl;
|
|
38726
38503
|
path = path.startsWith("/") ? path : `/${path}`;
|
|
38727
38504
|
return `${trimmedUrl}${path}`;
|
|
38728
38505
|
}
|
|
38729
|
-
function getBaseURL(url, path, request, loadEnv) {
|
|
38730
|
-
if (url)
|
|
38731
|
-
return withPath(url, path);
|
|
38732
|
-
}
|
|
38506
|
+
function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
|
|
38507
|
+
if (url) return withPath(url, path);
|
|
38733
38508
|
{
|
|
38734
38509
|
const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
|
|
38735
|
-
if (fromEnv)
|
|
38736
|
-
|
|
38737
|
-
|
|
38510
|
+
if (fromEnv) return withPath(fromEnv, path);
|
|
38511
|
+
}
|
|
38512
|
+
if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
|
|
38513
|
+
}
|
|
38514
|
+
const PROTO_POLLUTION_PATTERNS = {
|
|
38515
|
+
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
38516
|
+
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
38517
|
+
protoShort: /"__proto__"\s*:/,
|
|
38518
|
+
constructorShort: /"constructor"\s*:/
|
|
38519
|
+
};
|
|
38520
|
+
const JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
38521
|
+
const SPECIAL_VALUES = {
|
|
38522
|
+
true: true,
|
|
38523
|
+
false: false,
|
|
38524
|
+
null: null,
|
|
38525
|
+
undefined: void 0,
|
|
38526
|
+
nan: NaN,
|
|
38527
|
+
infinity: Number.POSITIVE_INFINITY,
|
|
38528
|
+
"-infinity": Number.NEGATIVE_INFINITY
|
|
38529
|
+
};
|
|
38530
|
+
const ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
38531
|
+
function isValidDate(date2) {
|
|
38532
|
+
return date2 instanceof Date && !isNaN(date2.getTime());
|
|
38533
|
+
}
|
|
38534
|
+
function parseISODate(value) {
|
|
38535
|
+
const match = ISO_DATE_REGEX.exec(value);
|
|
38536
|
+
if (!match) return null;
|
|
38537
|
+
const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
|
|
38538
|
+
let date2 = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
|
|
38539
|
+
if (offsetSign) {
|
|
38540
|
+
const offset2 = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
38541
|
+
date2.setUTCMinutes(date2.getUTCMinutes() + offset2);
|
|
38738
38542
|
}
|
|
38739
|
-
|
|
38740
|
-
|
|
38543
|
+
return isValidDate(date2) ? date2 : null;
|
|
38544
|
+
}
|
|
38545
|
+
function betterJSONParse(value, options = {}) {
|
|
38546
|
+
const { strict = false, warnings = false, reviver, parseDates = true } = options;
|
|
38547
|
+
if (typeof value !== "string") return value;
|
|
38548
|
+
const trimmed = value.trim();
|
|
38549
|
+
if (trimmed.length > 0 && trimmed[0] === '"' && trimmed.endsWith('"') && !trimmed.slice(1, -1).includes('"')) return trimmed.slice(1, -1);
|
|
38550
|
+
const lowerValue = trimmed.toLowerCase();
|
|
38551
|
+
if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
|
|
38552
|
+
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
38553
|
+
if (strict) throw new SyntaxError("[better-json] Invalid JSON");
|
|
38554
|
+
return value;
|
|
38741
38555
|
}
|
|
38742
|
-
|
|
38556
|
+
if (Object.entries(PROTO_POLLUTION_PATTERNS).some(([key2, pattern]) => {
|
|
38557
|
+
const matches = pattern.test(trimmed);
|
|
38558
|
+
if (matches && warnings) console.warn(`[better-json] Detected potential prototype pollution attempt using ${key2} pattern`);
|
|
38559
|
+
return matches;
|
|
38560
|
+
}) && strict) throw new Error("[better-json] Potential prototype pollution attempt detected");
|
|
38561
|
+
try {
|
|
38562
|
+
const secureReviver = (key2, value$1) => {
|
|
38563
|
+
if (key2 === "__proto__" || key2 === "constructor" && value$1 && typeof value$1 === "object" && "prototype" in value$1) {
|
|
38564
|
+
if (warnings) console.warn(`[better-json] Dropping "${key2}" key to prevent prototype pollution`);
|
|
38565
|
+
return;
|
|
38566
|
+
}
|
|
38567
|
+
if (parseDates && typeof value$1 === "string") {
|
|
38568
|
+
const date2 = parseISODate(value$1);
|
|
38569
|
+
if (date2) return date2;
|
|
38570
|
+
}
|
|
38571
|
+
return reviver ? reviver(key2, value$1) : value$1;
|
|
38572
|
+
};
|
|
38573
|
+
return JSON.parse(trimmed, secureReviver);
|
|
38574
|
+
} catch (error) {
|
|
38575
|
+
if (strict) throw error;
|
|
38576
|
+
return value;
|
|
38577
|
+
}
|
|
38578
|
+
}
|
|
38579
|
+
function parseJSON(value, options = { strict: true }) {
|
|
38580
|
+
return betterJSONParse(value, options);
|
|
38743
38581
|
}
|
|
38744
38582
|
let listenerQueue = [];
|
|
38745
38583
|
let lqIndex = 0;
|
|
@@ -38867,918 +38705,1073 @@ let onMount = ($store, initialize) => {
|
|
|
38867
38705
|
};
|
|
38868
38706
|
});
|
|
38869
38707
|
};
|
|
38870
|
-
|
|
38871
|
-
|
|
38872
|
-
|
|
38873
|
-
|
|
38874
|
-
|
|
38875
|
-
|
|
38876
|
-
|
|
38877
|
-
|
|
38878
|
-
|
|
38879
|
-
|
|
38880
|
-
|
|
38881
|
-
|
|
38882
|
-
|
|
38883
|
-
|
|
38884
|
-
|
|
38885
|
-
|
|
38886
|
-
|
|
38887
|
-
|
|
38888
|
-
|
|
38889
|
-
|
|
38890
|
-
|
|
38891
|
-
|
|
38892
|
-
|
|
38893
|
-
async onSuccess(context) {
|
|
38894
|
-
value.set({
|
|
38895
|
-
data: context.data,
|
|
38896
|
-
error: null,
|
|
38897
|
-
isPending: false,
|
|
38898
|
-
isRefetching: false,
|
|
38899
|
-
refetch: value.value.refetch
|
|
38900
|
-
});
|
|
38901
|
-
await opts?.onSuccess?.(context);
|
|
38902
|
-
},
|
|
38903
|
-
async onError(context) {
|
|
38904
|
-
const { request } = context;
|
|
38905
|
-
const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
|
|
38906
|
-
const retryAttempt = request.retryAttempt || 0;
|
|
38907
|
-
if (retryAttempts && retryAttempt < retryAttempts) return;
|
|
38908
|
-
value.set({
|
|
38909
|
-
error: context.error,
|
|
38910
|
-
data: null,
|
|
38911
|
-
isPending: false,
|
|
38912
|
-
isRefetching: false,
|
|
38913
|
-
refetch: value.value.refetch
|
|
38914
|
-
});
|
|
38915
|
-
await opts?.onError?.(context);
|
|
38916
|
-
},
|
|
38917
|
-
async onRequest(context) {
|
|
38918
|
-
const currentValue = value.get();
|
|
38919
|
-
value.set({
|
|
38920
|
-
isPending: currentValue.data === null,
|
|
38921
|
-
data: currentValue.data,
|
|
38922
|
-
error: null,
|
|
38923
|
-
isRefetching: true,
|
|
38924
|
-
refetch: value.value.refetch
|
|
38925
|
-
});
|
|
38926
|
-
await opts?.onRequest?.(context);
|
|
38927
|
-
}
|
|
38928
|
-
}).catch((error) => {
|
|
38929
|
-
value.set({
|
|
38930
|
-
error,
|
|
38931
|
-
data: null,
|
|
38932
|
-
isPending: false,
|
|
38933
|
-
isRefetching: false,
|
|
38934
|
-
refetch: value.value.refetch
|
|
38935
|
-
});
|
|
38936
|
-
});
|
|
38937
|
-
};
|
|
38938
|
-
initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
|
|
38939
|
-
let isMounted = false;
|
|
38940
|
-
for (const initAtom of initializedAtom) {
|
|
38941
|
-
initAtom.subscribe(() => {
|
|
38942
|
-
if (isServer) {
|
|
38943
|
-
return;
|
|
38944
|
-
}
|
|
38945
|
-
if (isMounted) {
|
|
38946
|
-
fn();
|
|
38947
|
-
} else {
|
|
38948
|
-
onMount(value, () => {
|
|
38949
|
-
const timeoutId = setTimeout(() => {
|
|
38950
|
-
if (!isMounted) {
|
|
38951
|
-
fn();
|
|
38952
|
-
isMounted = true;
|
|
38953
|
-
}
|
|
38954
|
-
}, 0);
|
|
38955
|
-
return () => {
|
|
38956
|
-
value.off();
|
|
38957
|
-
initAtom.off();
|
|
38958
|
-
clearTimeout(timeoutId);
|
|
38959
|
-
};
|
|
38960
|
-
});
|
|
38961
|
-
}
|
|
38708
|
+
var __defProp = Object.defineProperty;
|
|
38709
|
+
var __defProps = Object.defineProperties;
|
|
38710
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
38711
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
38712
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
38713
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
38714
|
+
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
38715
|
+
var __spreadValues = (a2, b) => {
|
|
38716
|
+
for (var prop in b || (b = {}))
|
|
38717
|
+
if (__hasOwnProp.call(b, prop))
|
|
38718
|
+
__defNormalProp(a2, prop, b[prop]);
|
|
38719
|
+
if (__getOwnPropSymbols)
|
|
38720
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
38721
|
+
if (__propIsEnum.call(b, prop))
|
|
38722
|
+
__defNormalProp(a2, prop, b[prop]);
|
|
38723
|
+
}
|
|
38724
|
+
return a2;
|
|
38725
|
+
};
|
|
38726
|
+
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
|
|
38727
|
+
var BetterFetchError = class extends Error {
|
|
38728
|
+
constructor(status, statusText, error) {
|
|
38729
|
+
super(statusText || status.toString(), {
|
|
38730
|
+
cause: error
|
|
38962
38731
|
});
|
|
38732
|
+
this.status = status;
|
|
38733
|
+
this.statusText = statusText;
|
|
38734
|
+
this.error = error;
|
|
38963
38735
|
}
|
|
38964
|
-
return value;
|
|
38965
38736
|
};
|
|
38966
|
-
|
|
38967
|
-
|
|
38968
|
-
|
|
38969
|
-
|
|
38970
|
-
|
|
38971
|
-
|
|
38972
|
-
|
|
38973
|
-
|
|
38974
|
-
|
|
38975
|
-
|
|
38976
|
-
null:
|
|
38977
|
-
|
|
38978
|
-
|
|
38979
|
-
|
|
38980
|
-
|
|
38737
|
+
var initializePlugins = async (url, options) => {
|
|
38738
|
+
var _a2, _b, _c, _d, _e2, _f;
|
|
38739
|
+
let opts = options || {};
|
|
38740
|
+
const hooks = {
|
|
38741
|
+
onRequest: [options == null ? void 0 : options.onRequest],
|
|
38742
|
+
onResponse: [options == null ? void 0 : options.onResponse],
|
|
38743
|
+
onSuccess: [options == null ? void 0 : options.onSuccess],
|
|
38744
|
+
onError: [options == null ? void 0 : options.onError],
|
|
38745
|
+
onRetry: [options == null ? void 0 : options.onRetry]
|
|
38746
|
+
};
|
|
38747
|
+
if (!options || !(options == null ? void 0 : options.plugins)) {
|
|
38748
|
+
return {
|
|
38749
|
+
url,
|
|
38750
|
+
options: opts,
|
|
38751
|
+
hooks
|
|
38752
|
+
};
|
|
38753
|
+
}
|
|
38754
|
+
for (const plugin of (options == null ? void 0 : options.plugins) || []) {
|
|
38755
|
+
if (plugin.init) {
|
|
38756
|
+
const pluginRes = await ((_a2 = plugin.init) == null ? void 0 : _a2.call(plugin, url.toString(), options));
|
|
38757
|
+
opts = pluginRes.options || opts;
|
|
38758
|
+
url = pluginRes.url;
|
|
38759
|
+
}
|
|
38760
|
+
hooks.onRequest.push((_b = plugin.hooks) == null ? void 0 : _b.onRequest);
|
|
38761
|
+
hooks.onResponse.push((_c = plugin.hooks) == null ? void 0 : _c.onResponse);
|
|
38762
|
+
hooks.onSuccess.push((_d = plugin.hooks) == null ? void 0 : _d.onSuccess);
|
|
38763
|
+
hooks.onError.push((_e2 = plugin.hooks) == null ? void 0 : _e2.onError);
|
|
38764
|
+
hooks.onRetry.push((_f = plugin.hooks) == null ? void 0 : _f.onRetry);
|
|
38765
|
+
}
|
|
38766
|
+
return {
|
|
38767
|
+
url,
|
|
38768
|
+
options: opts,
|
|
38769
|
+
hooks
|
|
38770
|
+
};
|
|
38981
38771
|
};
|
|
38982
|
-
|
|
38983
|
-
|
|
38984
|
-
|
|
38985
|
-
}
|
|
38986
|
-
function parseISODate(value) {
|
|
38987
|
-
const match = ISO_DATE_REGEX.exec(value);
|
|
38988
|
-
if (!match) return null;
|
|
38989
|
-
const [
|
|
38990
|
-
,
|
|
38991
|
-
year,
|
|
38992
|
-
month,
|
|
38993
|
-
day,
|
|
38994
|
-
hour,
|
|
38995
|
-
minute,
|
|
38996
|
-
second,
|
|
38997
|
-
ms,
|
|
38998
|
-
offsetSign,
|
|
38999
|
-
offsetHour,
|
|
39000
|
-
offsetMinute
|
|
39001
|
-
] = match;
|
|
39002
|
-
let date2 = new Date(
|
|
39003
|
-
Date.UTC(
|
|
39004
|
-
parseInt(year, 10),
|
|
39005
|
-
parseInt(month, 10) - 1,
|
|
39006
|
-
parseInt(day, 10),
|
|
39007
|
-
parseInt(hour, 10),
|
|
39008
|
-
parseInt(minute, 10),
|
|
39009
|
-
parseInt(second, 10),
|
|
39010
|
-
ms ? parseInt(ms.padEnd(3, "0"), 10) : 0
|
|
39011
|
-
)
|
|
39012
|
-
);
|
|
39013
|
-
if (offsetSign) {
|
|
39014
|
-
const offset2 = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
39015
|
-
date2.setUTCMinutes(date2.getUTCMinutes() + offset2);
|
|
38772
|
+
var LinearRetryStrategy = class {
|
|
38773
|
+
constructor(options) {
|
|
38774
|
+
this.options = options;
|
|
39016
38775
|
}
|
|
39017
|
-
|
|
39018
|
-
|
|
39019
|
-
|
|
39020
|
-
|
|
39021
|
-
|
|
39022
|
-
|
|
39023
|
-
|
|
39024
|
-
parseDates = true
|
|
39025
|
-
} = options;
|
|
39026
|
-
if (typeof value !== "string") {
|
|
39027
|
-
return value;
|
|
38776
|
+
shouldAttemptRetry(attempt, response) {
|
|
38777
|
+
if (this.options.shouldRetry) {
|
|
38778
|
+
return Promise.resolve(
|
|
38779
|
+
attempt < this.options.attempts && this.options.shouldRetry(response)
|
|
38780
|
+
);
|
|
38781
|
+
}
|
|
38782
|
+
return Promise.resolve(attempt < this.options.attempts);
|
|
39028
38783
|
}
|
|
39029
|
-
|
|
39030
|
-
|
|
39031
|
-
return trimmed.slice(1, -1);
|
|
38784
|
+
getDelay() {
|
|
38785
|
+
return this.options.delay;
|
|
39032
38786
|
}
|
|
39033
|
-
|
|
39034
|
-
|
|
39035
|
-
|
|
38787
|
+
};
|
|
38788
|
+
var ExponentialRetryStrategy = class {
|
|
38789
|
+
constructor(options) {
|
|
38790
|
+
this.options = options;
|
|
39036
38791
|
}
|
|
39037
|
-
|
|
39038
|
-
if (
|
|
39039
|
-
|
|
38792
|
+
shouldAttemptRetry(attempt, response) {
|
|
38793
|
+
if (this.options.shouldRetry) {
|
|
38794
|
+
return Promise.resolve(
|
|
38795
|
+
attempt < this.options.attempts && this.options.shouldRetry(response)
|
|
38796
|
+
);
|
|
39040
38797
|
}
|
|
39041
|
-
return
|
|
38798
|
+
return Promise.resolve(attempt < this.options.attempts);
|
|
39042
38799
|
}
|
|
39043
|
-
|
|
39044
|
-
|
|
39045
|
-
|
|
39046
|
-
|
|
39047
|
-
console.warn(
|
|
39048
|
-
`[better-json] Detected potential prototype pollution attempt using ${key2} pattern`
|
|
39049
|
-
);
|
|
39050
|
-
}
|
|
39051
|
-
return matches;
|
|
39052
|
-
}
|
|
39053
|
-
);
|
|
39054
|
-
if (hasProtoPattern && strict) {
|
|
39055
|
-
throw new Error(
|
|
39056
|
-
"[better-json] Potential prototype pollution attempt detected"
|
|
38800
|
+
getDelay(attempt) {
|
|
38801
|
+
const delay2 = Math.min(
|
|
38802
|
+
this.options.maxDelay,
|
|
38803
|
+
this.options.baseDelay * 2 ** attempt
|
|
39057
38804
|
);
|
|
38805
|
+
return delay2;
|
|
39058
38806
|
}
|
|
39059
|
-
|
|
39060
|
-
|
|
39061
|
-
|
|
39062
|
-
|
|
39063
|
-
|
|
39064
|
-
|
|
39065
|
-
|
|
39066
|
-
|
|
39067
|
-
return void 0;
|
|
39068
|
-
}
|
|
39069
|
-
if (parseDates && typeof value2 === "string") {
|
|
39070
|
-
const date2 = parseISODate(value2);
|
|
39071
|
-
if (date2) {
|
|
39072
|
-
return date2;
|
|
39073
|
-
}
|
|
39074
|
-
}
|
|
39075
|
-
return reviver ? reviver(key2, value2) : value2;
|
|
39076
|
-
};
|
|
39077
|
-
return JSON.parse(trimmed, secureReviver);
|
|
39078
|
-
} catch (error) {
|
|
39079
|
-
if (strict) {
|
|
39080
|
-
throw error;
|
|
39081
|
-
}
|
|
39082
|
-
return value;
|
|
38807
|
+
};
|
|
38808
|
+
function createRetryStrategy(options) {
|
|
38809
|
+
if (typeof options === "number") {
|
|
38810
|
+
return new LinearRetryStrategy({
|
|
38811
|
+
type: "linear",
|
|
38812
|
+
attempts: options,
|
|
38813
|
+
delay: 1e3
|
|
38814
|
+
});
|
|
39083
38815
|
}
|
|
39084
|
-
|
|
39085
|
-
|
|
39086
|
-
|
|
39087
|
-
|
|
39088
|
-
|
|
39089
|
-
|
|
39090
|
-
|
|
39091
|
-
hooks: {
|
|
39092
|
-
onSuccess(context) {
|
|
39093
|
-
if (context.data?.url && context.data?.redirect) {
|
|
39094
|
-
if (typeof window !== "undefined" && window.location) {
|
|
39095
|
-
if (window.location) {
|
|
39096
|
-
try {
|
|
39097
|
-
window.location.href = context.data.url;
|
|
39098
|
-
} catch {
|
|
39099
|
-
}
|
|
39100
|
-
}
|
|
39101
|
-
}
|
|
39102
|
-
}
|
|
39103
|
-
}
|
|
38816
|
+
switch (options.type) {
|
|
38817
|
+
case "linear":
|
|
38818
|
+
return new LinearRetryStrategy(options);
|
|
38819
|
+
case "exponential":
|
|
38820
|
+
return new ExponentialRetryStrategy(options);
|
|
38821
|
+
default:
|
|
38822
|
+
throw new Error("Invalid retry strategy");
|
|
39104
38823
|
}
|
|
39105
|
-
};
|
|
39106
|
-
function getSessionAtom($fetch) {
|
|
39107
|
-
const $signal = /* @__PURE__ */ atom(false);
|
|
39108
|
-
const session = useAuthQuery($signal, "/get-session", $fetch, {
|
|
39109
|
-
method: "GET"
|
|
39110
|
-
});
|
|
39111
|
-
return {
|
|
39112
|
-
session,
|
|
39113
|
-
$sessionSignal: $signal
|
|
39114
|
-
};
|
|
39115
38824
|
}
|
|
39116
|
-
|
|
39117
|
-
const
|
|
39118
|
-
const
|
|
39119
|
-
|
|
39120
|
-
|
|
39121
|
-
|
|
39122
|
-
|
|
39123
|
-
|
|
39124
|
-
onSuccess: options?.fetchOptions?.onSuccess,
|
|
39125
|
-
onError: options?.fetchOptions?.onError,
|
|
39126
|
-
onRequest: options?.fetchOptions?.onRequest,
|
|
39127
|
-
onResponse: options?.fetchOptions?.onResponse
|
|
39128
|
-
}
|
|
39129
|
-
};
|
|
39130
|
-
const { onSuccess, onError, onRequest, onResponse, ...restOfFetchOptions } = options?.fetchOptions || {};
|
|
39131
|
-
const $fetch = createFetch({
|
|
39132
|
-
baseURL,
|
|
39133
|
-
...isCredentialsSupported ? { credentials: "include" } : {},
|
|
39134
|
-
method: "GET",
|
|
39135
|
-
jsonParser(text) {
|
|
39136
|
-
if (!text) {
|
|
39137
|
-
return null;
|
|
38825
|
+
var getAuthHeader = async (options) => {
|
|
38826
|
+
const headers = {};
|
|
38827
|
+
const getValue = async (value) => typeof value === "function" ? await value() : value;
|
|
38828
|
+
if (options == null ? void 0 : options.auth) {
|
|
38829
|
+
if (options.auth.type === "Bearer") {
|
|
38830
|
+
const token = await getValue(options.auth.token);
|
|
38831
|
+
if (!token) {
|
|
38832
|
+
return headers;
|
|
39138
38833
|
}
|
|
39139
|
-
|
|
39140
|
-
|
|
39141
|
-
|
|
39142
|
-
|
|
39143
|
-
|
|
39144
|
-
|
|
39145
|
-
plugins: [
|
|
39146
|
-
lifeCyclePlugin,
|
|
39147
|
-
...restOfFetchOptions.plugins || [],
|
|
39148
|
-
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
39149
|
-
...pluginsFetchPlugins
|
|
39150
|
-
]
|
|
39151
|
-
});
|
|
39152
|
-
const { $sessionSignal, session } = getSessionAtom($fetch);
|
|
39153
|
-
const plugins = options?.plugins || [];
|
|
39154
|
-
let pluginsActions = {};
|
|
39155
|
-
let pluginsAtoms = {
|
|
39156
|
-
$sessionSignal,
|
|
39157
|
-
session
|
|
39158
|
-
};
|
|
39159
|
-
let pluginPathMethods = {
|
|
39160
|
-
"/sign-out": "POST",
|
|
39161
|
-
"/revoke-sessions": "POST",
|
|
39162
|
-
"/revoke-other-sessions": "POST",
|
|
39163
|
-
"/delete-user": "POST"
|
|
39164
|
-
};
|
|
39165
|
-
const atomListeners = [
|
|
39166
|
-
{
|
|
39167
|
-
signal: "$sessionSignal",
|
|
39168
|
-
matcher(path) {
|
|
39169
|
-
return path === "/sign-out" || path === "/update-user" || path.startsWith("/sign-in") || path.startsWith("/sign-up") || path === "/delete-user" || path === "/verify-email";
|
|
38834
|
+
headers["authorization"] = `Bearer ${token}`;
|
|
38835
|
+
} else if (options.auth.type === "Basic") {
|
|
38836
|
+
const username = getValue(options.auth.username);
|
|
38837
|
+
const password = getValue(options.auth.password);
|
|
38838
|
+
if (!username || !password) {
|
|
38839
|
+
return headers;
|
|
39170
38840
|
}
|
|
39171
|
-
|
|
39172
|
-
|
|
39173
|
-
|
|
39174
|
-
|
|
39175
|
-
|
|
39176
|
-
|
|
39177
|
-
|
|
39178
|
-
Object.assign(pluginPathMethods, plugin.pathMethods);
|
|
39179
|
-
}
|
|
39180
|
-
if (plugin.atomListeners) {
|
|
39181
|
-
atomListeners.push(...plugin.atomListeners);
|
|
39182
|
-
}
|
|
39183
|
-
}
|
|
39184
|
-
const $store = {
|
|
39185
|
-
notify: (signal) => {
|
|
39186
|
-
pluginsAtoms[signal].set(
|
|
39187
|
-
!pluginsAtoms[signal].get()
|
|
39188
|
-
);
|
|
39189
|
-
},
|
|
39190
|
-
listen: (signal, listener) => {
|
|
39191
|
-
pluginsAtoms[signal].subscribe(listener);
|
|
39192
|
-
},
|
|
39193
|
-
atoms: pluginsAtoms
|
|
39194
|
-
};
|
|
39195
|
-
for (const plugin of plugins) {
|
|
39196
|
-
if (plugin.getActions) {
|
|
39197
|
-
Object.assign(
|
|
39198
|
-
pluginsActions,
|
|
39199
|
-
plugin.getActions?.($fetch, $store, options)
|
|
39200
|
-
);
|
|
38841
|
+
headers["authorization"] = `Basic ${btoa(`${username}:${password}`)}`;
|
|
38842
|
+
} else if (options.auth.type === "Custom") {
|
|
38843
|
+
const value = getValue(options.auth.value);
|
|
38844
|
+
if (!value) {
|
|
38845
|
+
return headers;
|
|
38846
|
+
}
|
|
38847
|
+
headers["authorization"] = `${getValue(options.auth.prefix)} ${value}`;
|
|
39201
38848
|
}
|
|
39202
38849
|
}
|
|
39203
|
-
return
|
|
39204
|
-
get baseURL() {
|
|
39205
|
-
return baseURL;
|
|
39206
|
-
},
|
|
39207
|
-
pluginsActions,
|
|
39208
|
-
pluginsAtoms,
|
|
39209
|
-
pluginPathMethods,
|
|
39210
|
-
atomListeners,
|
|
39211
|
-
$fetch,
|
|
39212
|
-
$store
|
|
39213
|
-
};
|
|
38850
|
+
return headers;
|
|
39214
38851
|
};
|
|
39215
|
-
|
|
39216
|
-
|
|
38852
|
+
var JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
|
|
38853
|
+
function detectResponseType(request) {
|
|
38854
|
+
const _contentType = request.headers.get("content-type");
|
|
38855
|
+
const textTypes = /* @__PURE__ */ new Set([
|
|
38856
|
+
"image/svg",
|
|
38857
|
+
"application/xml",
|
|
38858
|
+
"application/xhtml",
|
|
38859
|
+
"application/html"
|
|
38860
|
+
]);
|
|
38861
|
+
if (!_contentType) {
|
|
38862
|
+
return "json";
|
|
38863
|
+
}
|
|
38864
|
+
const contentType = _contentType.split(";").shift() || "";
|
|
38865
|
+
if (JSON_RE.test(contentType)) {
|
|
38866
|
+
return "json";
|
|
38867
|
+
}
|
|
38868
|
+
if (textTypes.has(contentType) || contentType.startsWith("text/")) {
|
|
38869
|
+
return "text";
|
|
38870
|
+
}
|
|
38871
|
+
return "blob";
|
|
39217
38872
|
}
|
|
39218
|
-
function
|
|
39219
|
-
|
|
39220
|
-
|
|
39221
|
-
|
|
39222
|
-
|
|
38873
|
+
function isJSONParsable(value) {
|
|
38874
|
+
try {
|
|
38875
|
+
JSON.parse(value);
|
|
38876
|
+
return true;
|
|
38877
|
+
} catch (error) {
|
|
38878
|
+
return false;
|
|
39223
38879
|
}
|
|
39224
|
-
|
|
39225
|
-
|
|
38880
|
+
}
|
|
38881
|
+
function isJSONSerializable(value) {
|
|
38882
|
+
if (value === void 0) {
|
|
38883
|
+
return false;
|
|
38884
|
+
}
|
|
38885
|
+
const t2 = typeof value;
|
|
38886
|
+
if (t2 === "string" || t2 === "number" || t2 === "boolean" || t2 === null) {
|
|
38887
|
+
return true;
|
|
39226
38888
|
}
|
|
39227
|
-
if (
|
|
39228
|
-
return
|
|
38889
|
+
if (t2 !== "object") {
|
|
38890
|
+
return false;
|
|
39229
38891
|
}
|
|
39230
|
-
|
|
38892
|
+
if (Array.isArray(value)) {
|
|
38893
|
+
return true;
|
|
38894
|
+
}
|
|
38895
|
+
if (value.buffer) {
|
|
38896
|
+
return false;
|
|
38897
|
+
}
|
|
38898
|
+
return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
|
|
39231
38899
|
}
|
|
39232
|
-
function
|
|
39233
|
-
|
|
39234
|
-
return
|
|
39235
|
-
|
|
39236
|
-
|
|
39237
|
-
if (typeof prop !== "string") {
|
|
39238
|
-
return void 0;
|
|
39239
|
-
}
|
|
39240
|
-
if (prop === "then" || prop === "catch" || prop === "finally") {
|
|
39241
|
-
return void 0;
|
|
39242
|
-
}
|
|
39243
|
-
const fullPath = [...path, prop];
|
|
39244
|
-
let current = routes;
|
|
39245
|
-
for (const segment of fullPath) {
|
|
39246
|
-
if (current && typeof current === "object" && segment in current) {
|
|
39247
|
-
current = current[segment];
|
|
39248
|
-
} else {
|
|
39249
|
-
current = void 0;
|
|
39250
|
-
break;
|
|
39251
|
-
}
|
|
39252
|
-
}
|
|
39253
|
-
if (typeof current === "function") {
|
|
39254
|
-
return current;
|
|
39255
|
-
}
|
|
39256
|
-
if (isAtom(current)) {
|
|
39257
|
-
return current;
|
|
39258
|
-
}
|
|
39259
|
-
return createProxy(fullPath);
|
|
39260
|
-
},
|
|
39261
|
-
apply: async (_2, __, args) => {
|
|
39262
|
-
const routePath = "/" + path.map(
|
|
39263
|
-
(segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
|
|
39264
|
-
).join("/");
|
|
39265
|
-
const arg = args[0] || {};
|
|
39266
|
-
const fetchOptions = args[1] || {};
|
|
39267
|
-
const { query, fetchOptions: argFetchOptions, ...body } = arg;
|
|
39268
|
-
const options = {
|
|
39269
|
-
...fetchOptions,
|
|
39270
|
-
...argFetchOptions
|
|
39271
|
-
};
|
|
39272
|
-
const method = getMethod(routePath, knownPathMethods, arg);
|
|
39273
|
-
return await client2(routePath, {
|
|
39274
|
-
...options,
|
|
39275
|
-
body: method === "GET" ? void 0 : {
|
|
39276
|
-
...body,
|
|
39277
|
-
...options?.body || {}
|
|
39278
|
-
},
|
|
39279
|
-
query: query || options?.query,
|
|
39280
|
-
method,
|
|
39281
|
-
async onSuccess(context) {
|
|
39282
|
-
await options?.onSuccess?.(context);
|
|
39283
|
-
if (!atomListeners) return;
|
|
39284
|
-
const matches = atomListeners.filter((s2) => s2.matcher(routePath));
|
|
39285
|
-
if (!matches.length) return;
|
|
39286
|
-
for (const match of matches) {
|
|
39287
|
-
const signal = atoms[match.signal];
|
|
39288
|
-
if (!signal) return;
|
|
39289
|
-
const val = signal.get();
|
|
39290
|
-
setTimeout(() => {
|
|
39291
|
-
signal.set(!val);
|
|
39292
|
-
}, 10);
|
|
39293
|
-
}
|
|
39294
|
-
}
|
|
39295
|
-
});
|
|
39296
|
-
}
|
|
39297
|
-
});
|
|
38900
|
+
function jsonParse(text) {
|
|
38901
|
+
try {
|
|
38902
|
+
return JSON.parse(text);
|
|
38903
|
+
} catch (error) {
|
|
38904
|
+
return text;
|
|
39298
38905
|
}
|
|
39299
|
-
return createProxy();
|
|
39300
38906
|
}
|
|
39301
|
-
function
|
|
39302
|
-
return
|
|
38907
|
+
function isFunction$1(value) {
|
|
38908
|
+
return typeof value === "function";
|
|
39303
38909
|
}
|
|
39304
|
-
function
|
|
39305
|
-
|
|
39306
|
-
|
|
39307
|
-
pluginsActions,
|
|
39308
|
-
pluginsAtoms,
|
|
39309
|
-
$fetch,
|
|
39310
|
-
atomListeners,
|
|
39311
|
-
$store
|
|
39312
|
-
} = getClientConfig(options);
|
|
39313
|
-
let resolvedHooks = {};
|
|
39314
|
-
for (const [key2, value] of Object.entries(pluginsAtoms)) {
|
|
39315
|
-
resolvedHooks[`use${capitalizeFirstLetter(key2)}`] = value;
|
|
38910
|
+
function getFetch(options) {
|
|
38911
|
+
if (options == null ? void 0 : options.customFetchImpl) {
|
|
38912
|
+
return options.customFetchImpl;
|
|
39316
38913
|
}
|
|
39317
|
-
|
|
39318
|
-
|
|
39319
|
-
|
|
39320
|
-
|
|
39321
|
-
|
|
39322
|
-
}
|
|
39323
|
-
|
|
39324
|
-
routes,
|
|
39325
|
-
$fetch,
|
|
39326
|
-
pluginPathMethods,
|
|
39327
|
-
pluginsAtoms,
|
|
39328
|
-
atomListeners
|
|
39329
|
-
);
|
|
39330
|
-
return proxy;
|
|
38914
|
+
if (typeof globalThis !== "undefined" && isFunction$1(globalThis.fetch)) {
|
|
38915
|
+
return globalThis.fetch;
|
|
38916
|
+
}
|
|
38917
|
+
if (typeof window !== "undefined" && isFunction$1(window.fetch)) {
|
|
38918
|
+
return window.fetch;
|
|
38919
|
+
}
|
|
38920
|
+
throw new Error("No fetch implementation found");
|
|
39331
38921
|
}
|
|
39332
|
-
function
|
|
39333
|
-
const
|
|
39334
|
-
|
|
39335
|
-
for (const
|
|
39336
|
-
|
|
38922
|
+
async function getHeaders(opts) {
|
|
38923
|
+
const headers = new Headers(opts == null ? void 0 : opts.headers);
|
|
38924
|
+
const authHeader = await getAuthHeader(opts);
|
|
38925
|
+
for (const [key2, value] of Object.entries(authHeader || {})) {
|
|
38926
|
+
headers.set(key2, value);
|
|
39337
38927
|
}
|
|
39338
|
-
|
|
39339
|
-
|
|
38928
|
+
if (!headers.has("content-type")) {
|
|
38929
|
+
const t2 = detectContentType(opts == null ? void 0 : opts.body);
|
|
38930
|
+
if (t2) {
|
|
38931
|
+
headers.set("content-type", t2);
|
|
38932
|
+
}
|
|
38933
|
+
}
|
|
38934
|
+
return headers;
|
|
39340
38935
|
}
|
|
39341
|
-
function
|
|
39342
|
-
|
|
39343
|
-
|
|
39344
|
-
const padded = base642.padEnd(base642.length + padLength, "=");
|
|
39345
|
-
const binary = atob(padded);
|
|
39346
|
-
const buffer = new ArrayBuffer(binary.length);
|
|
39347
|
-
const bytes = new Uint8Array(buffer);
|
|
39348
|
-
for (let i2 = 0; i2 < binary.length; i2++) {
|
|
39349
|
-
bytes[i2] = binary.charCodeAt(i2);
|
|
38936
|
+
function detectContentType(body) {
|
|
38937
|
+
if (isJSONSerializable(body)) {
|
|
38938
|
+
return "application/json";
|
|
39350
38939
|
}
|
|
39351
|
-
return
|
|
38940
|
+
return null;
|
|
39352
38941
|
}
|
|
39353
|
-
function
|
|
39354
|
-
|
|
38942
|
+
function getBody(options) {
|
|
38943
|
+
if (!(options == null ? void 0 : options.body)) {
|
|
38944
|
+
return null;
|
|
38945
|
+
}
|
|
38946
|
+
const headers = new Headers(options == null ? void 0 : options.headers);
|
|
38947
|
+
if (isJSONSerializable(options.body) && !headers.has("content-type")) {
|
|
38948
|
+
for (const [key2, value] of Object.entries(options == null ? void 0 : options.body)) {
|
|
38949
|
+
if (value instanceof Date) {
|
|
38950
|
+
options.body[key2] = value.toISOString();
|
|
38951
|
+
}
|
|
38952
|
+
}
|
|
38953
|
+
return JSON.stringify(options.body);
|
|
38954
|
+
}
|
|
38955
|
+
return options.body;
|
|
39355
38956
|
}
|
|
39356
|
-
|
|
39357
|
-
|
|
39358
|
-
|
|
39359
|
-
|
|
39360
|
-
|
|
38957
|
+
function getMethod$1(url, options) {
|
|
38958
|
+
var _a2;
|
|
38959
|
+
if (options == null ? void 0 : options.method) {
|
|
38960
|
+
return options.method.toUpperCase();
|
|
38961
|
+
}
|
|
38962
|
+
if (url.startsWith("@")) {
|
|
38963
|
+
const pMethod = (_a2 = url.split("@")[1]) == null ? void 0 : _a2.split("/")[0];
|
|
38964
|
+
if (!methods.includes(pMethod)) {
|
|
38965
|
+
return (options == null ? void 0 : options.body) ? "POST" : "GET";
|
|
38966
|
+
}
|
|
38967
|
+
return pMethod.toUpperCase();
|
|
38968
|
+
}
|
|
38969
|
+
return (options == null ? void 0 : options.body) ? "POST" : "GET";
|
|
38970
|
+
}
|
|
38971
|
+
function getTimeout(options, controller) {
|
|
38972
|
+
let abortTimeout;
|
|
38973
|
+
if (!(options == null ? void 0 : options.signal) && (options == null ? void 0 : options.timeout)) {
|
|
38974
|
+
abortTimeout = setTimeout(() => controller == null ? void 0 : controller.abort(), options == null ? void 0 : options.timeout);
|
|
38975
|
+
}
|
|
39361
38976
|
return {
|
|
39362
|
-
|
|
39363
|
-
|
|
39364
|
-
|
|
39365
|
-
|
|
39366
|
-
|
|
39367
|
-
|
|
39368
|
-
*/
|
|
39369
|
-
transports: descriptor.transports
|
|
38977
|
+
abortTimeout,
|
|
38978
|
+
clearTimeout: () => {
|
|
38979
|
+
if (abortTimeout) {
|
|
38980
|
+
clearTimeout(abortTimeout);
|
|
38981
|
+
}
|
|
38982
|
+
}
|
|
39370
38983
|
};
|
|
39371
38984
|
}
|
|
39372
|
-
|
|
39373
|
-
|
|
39374
|
-
|
|
39375
|
-
|
|
39376
|
-
|
|
39377
|
-
}
|
|
39378
|
-
class WebAuthnError extends Error {
|
|
39379
|
-
constructor({ message, code, cause, name }) {
|
|
39380
|
-
super(message, { cause });
|
|
39381
|
-
Object.defineProperty(this, "code", {
|
|
39382
|
-
enumerable: true,
|
|
39383
|
-
configurable: true,
|
|
39384
|
-
writable: true,
|
|
39385
|
-
value: void 0
|
|
39386
|
-
});
|
|
39387
|
-
this.name = name ?? cause.name;
|
|
39388
|
-
this.code = code;
|
|
38985
|
+
var ValidationError = class _ValidationError extends Error {
|
|
38986
|
+
constructor(issues, message) {
|
|
38987
|
+
super(message || JSON.stringify(issues, null, 2));
|
|
38988
|
+
this.issues = issues;
|
|
38989
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
39389
38990
|
}
|
|
39390
|
-
}
|
|
39391
|
-
function
|
|
39392
|
-
|
|
39393
|
-
if (
|
|
39394
|
-
throw
|
|
38991
|
+
};
|
|
38992
|
+
async function parseStandardSchema(schema, input) {
|
|
38993
|
+
let result = await schema["~standard"].validate(input);
|
|
38994
|
+
if (result.issues) {
|
|
38995
|
+
throw new ValidationError(result.issues);
|
|
39395
38996
|
}
|
|
39396
|
-
|
|
39397
|
-
|
|
39398
|
-
|
|
39399
|
-
|
|
39400
|
-
|
|
39401
|
-
|
|
39402
|
-
|
|
39403
|
-
|
|
39404
|
-
|
|
39405
|
-
|
|
39406
|
-
|
|
39407
|
-
|
|
39408
|
-
|
|
39409
|
-
|
|
39410
|
-
|
|
39411
|
-
|
|
39412
|
-
|
|
39413
|
-
|
|
39414
|
-
|
|
39415
|
-
|
|
39416
|
-
|
|
39417
|
-
|
|
39418
|
-
|
|
39419
|
-
|
|
39420
|
-
|
|
39421
|
-
|
|
39422
|
-
|
|
39423
|
-
|
|
39424
|
-
|
|
39425
|
-
}
|
|
39426
|
-
|
|
39427
|
-
|
|
39428
|
-
|
|
39429
|
-
|
|
39430
|
-
|
|
39431
|
-
|
|
39432
|
-
|
|
39433
|
-
|
|
39434
|
-
|
|
39435
|
-
|
|
39436
|
-
|
|
39437
|
-
|
|
39438
|
-
|
|
39439
|
-
|
|
39440
|
-
|
|
39441
|
-
|
|
39442
|
-
|
|
39443
|
-
|
|
39444
|
-
code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
|
|
39445
|
-
cause: error
|
|
39446
|
-
});
|
|
38997
|
+
return result.value;
|
|
38998
|
+
}
|
|
38999
|
+
var methods = ["get", "post", "put", "patch", "delete"];
|
|
39000
|
+
var applySchemaPlugin = (config2) => ({
|
|
39001
|
+
id: "apply-schema",
|
|
39002
|
+
name: "Apply Schema",
|
|
39003
|
+
version: "1.0.0",
|
|
39004
|
+
async init(url, options) {
|
|
39005
|
+
var _a2, _b, _c, _d;
|
|
39006
|
+
const schema = ((_b = (_a2 = config2.plugins) == null ? void 0 : _a2.find(
|
|
39007
|
+
(plugin) => {
|
|
39008
|
+
var _a22;
|
|
39009
|
+
return ((_a22 = plugin.schema) == null ? void 0 : _a22.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
|
|
39010
|
+
}
|
|
39011
|
+
)) == null ? void 0 : _b.schema) || config2.schema;
|
|
39012
|
+
if (schema) {
|
|
39013
|
+
let urlKey = url;
|
|
39014
|
+
if ((_c = schema.config) == null ? void 0 : _c.prefix) {
|
|
39015
|
+
if (urlKey.startsWith(schema.config.prefix)) {
|
|
39016
|
+
urlKey = urlKey.replace(schema.config.prefix, "");
|
|
39017
|
+
if (schema.config.baseURL) {
|
|
39018
|
+
url = url.replace(schema.config.prefix, schema.config.baseURL);
|
|
39019
|
+
}
|
|
39020
|
+
}
|
|
39021
|
+
}
|
|
39022
|
+
if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
|
|
39023
|
+
if (urlKey.startsWith(schema.config.baseURL)) {
|
|
39024
|
+
urlKey = urlKey.replace(schema.config.baseURL, "");
|
|
39025
|
+
}
|
|
39026
|
+
}
|
|
39027
|
+
const keySchema = schema.schema[urlKey];
|
|
39028
|
+
if (keySchema) {
|
|
39029
|
+
let opts = __spreadProps(__spreadValues({}, options), {
|
|
39030
|
+
method: keySchema.method,
|
|
39031
|
+
output: keySchema.output
|
|
39032
|
+
});
|
|
39033
|
+
if (!(options == null ? void 0 : options.disableValidation)) {
|
|
39034
|
+
opts = __spreadProps(__spreadValues({}, opts), {
|
|
39035
|
+
body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
|
|
39036
|
+
params: keySchema.params ? await parseStandardSchema(keySchema.params, options == null ? void 0 : options.params) : options == null ? void 0 : options.params,
|
|
39037
|
+
query: keySchema.query ? await parseStandardSchema(keySchema.query, options == null ? void 0 : options.query) : options == null ? void 0 : options.query
|
|
39038
|
+
});
|
|
39039
|
+
}
|
|
39040
|
+
return {
|
|
39041
|
+
url,
|
|
39042
|
+
options: opts
|
|
39043
|
+
};
|
|
39044
|
+
}
|
|
39447
39045
|
}
|
|
39448
|
-
return
|
|
39449
|
-
|
|
39450
|
-
|
|
39451
|
-
|
|
39046
|
+
return {
|
|
39047
|
+
url,
|
|
39048
|
+
options
|
|
39049
|
+
};
|
|
39050
|
+
}
|
|
39051
|
+
});
|
|
39052
|
+
var createFetch = (config2) => {
|
|
39053
|
+
async function $fetch(url, options) {
|
|
39054
|
+
const opts = __spreadProps(__spreadValues(__spreadValues({}, config2), options), {
|
|
39055
|
+
plugins: [...(config2 == null ? void 0 : config2.plugins) || [], applySchemaPlugin(config2 || {})]
|
|
39452
39056
|
});
|
|
39453
|
-
|
|
39454
|
-
|
|
39455
|
-
|
|
39456
|
-
|
|
39457
|
-
|
|
39458
|
-
|
|
39459
|
-
|
|
39460
|
-
|
|
39461
|
-
|
|
39462
|
-
|
|
39463
|
-
|
|
39464
|
-
|
|
39465
|
-
|
|
39466
|
-
}
|
|
39057
|
+
if (config2 == null ? void 0 : config2.catchAllError) {
|
|
39058
|
+
try {
|
|
39059
|
+
return await betterFetch(url, opts);
|
|
39060
|
+
} catch (error) {
|
|
39061
|
+
return {
|
|
39062
|
+
data: null,
|
|
39063
|
+
error: {
|
|
39064
|
+
status: 500,
|
|
39065
|
+
statusText: "Fetch Error",
|
|
39066
|
+
message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
|
|
39067
|
+
error
|
|
39068
|
+
}
|
|
39069
|
+
};
|
|
39070
|
+
}
|
|
39467
39071
|
}
|
|
39468
|
-
|
|
39469
|
-
|
|
39470
|
-
|
|
39471
|
-
|
|
39472
|
-
|
|
39473
|
-
|
|
39474
|
-
|
|
39072
|
+
return await betterFetch(url, opts);
|
|
39073
|
+
}
|
|
39074
|
+
return $fetch;
|
|
39075
|
+
};
|
|
39076
|
+
function getURL2(url, option) {
|
|
39077
|
+
let { baseURL, params, query } = option || {
|
|
39078
|
+
query: {},
|
|
39079
|
+
params: {},
|
|
39080
|
+
baseURL: ""
|
|
39081
|
+
};
|
|
39082
|
+
let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
|
|
39083
|
+
if (url.startsWith("@")) {
|
|
39084
|
+
const m2 = url.toString().split("@")[1].split("/")[0];
|
|
39085
|
+
if (methods.includes(m2)) {
|
|
39086
|
+
url = url.replace(`@${m2}/`, "/");
|
|
39475
39087
|
}
|
|
39476
|
-
} else if (error.name === "UnknownError") {
|
|
39477
|
-
return new WebAuthnError({
|
|
39478
|
-
message: "The authenticator was unable to process the specified options, or could not create a new credential",
|
|
39479
|
-
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
39480
|
-
cause: error
|
|
39481
|
-
});
|
|
39482
39088
|
}
|
|
39483
|
-
|
|
39484
|
-
|
|
39485
|
-
|
|
39486
|
-
|
|
39487
|
-
|
|
39488
|
-
|
|
39489
|
-
configurable: true,
|
|
39490
|
-
writable: true,
|
|
39491
|
-
value: void 0
|
|
39492
|
-
});
|
|
39089
|
+
if (!basePath.endsWith("/")) basePath += "/";
|
|
39090
|
+
let [path, urlQuery] = url.replace(basePath, "").split("?");
|
|
39091
|
+
const queryParams = new URLSearchParams(urlQuery);
|
|
39092
|
+
for (const [key2, value] of Object.entries(query || {})) {
|
|
39093
|
+
if (value == null) continue;
|
|
39094
|
+
queryParams.set(key2, String(value));
|
|
39493
39095
|
}
|
|
39494
|
-
|
|
39495
|
-
if (
|
|
39496
|
-
const
|
|
39497
|
-
|
|
39498
|
-
|
|
39096
|
+
if (params) {
|
|
39097
|
+
if (Array.isArray(params)) {
|
|
39098
|
+
const paramPaths = path.split("/").filter((p2) => p2.startsWith(":"));
|
|
39099
|
+
for (const [index2, key2] of paramPaths.entries()) {
|
|
39100
|
+
const value = params[index2];
|
|
39101
|
+
path = path.replace(key2, value);
|
|
39102
|
+
}
|
|
39103
|
+
} else {
|
|
39104
|
+
for (const [key2, value] of Object.entries(params)) {
|
|
39105
|
+
path = path.replace(`:${key2}`, String(value));
|
|
39106
|
+
}
|
|
39499
39107
|
}
|
|
39500
|
-
const newController = new AbortController();
|
|
39501
|
-
this.controller = newController;
|
|
39502
|
-
return newController.signal;
|
|
39503
39108
|
}
|
|
39504
|
-
|
|
39505
|
-
|
|
39506
|
-
|
|
39507
|
-
|
|
39508
|
-
|
|
39509
|
-
|
|
39510
|
-
}
|
|
39109
|
+
path = path.split("/").map(encodeURIComponent).join("/");
|
|
39110
|
+
if (path.startsWith("/")) path = path.slice(1);
|
|
39111
|
+
let queryParamString = queryParams.toString();
|
|
39112
|
+
queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
|
|
39113
|
+
if (!basePath.startsWith("http")) {
|
|
39114
|
+
return `${basePath}${path}${queryParamString}`;
|
|
39511
39115
|
}
|
|
39116
|
+
const _url2 = new URL(`${path}${queryParamString}`, basePath);
|
|
39117
|
+
return _url2;
|
|
39512
39118
|
}
|
|
39513
|
-
|
|
39514
|
-
|
|
39515
|
-
|
|
39516
|
-
|
|
39517
|
-
|
|
39119
|
+
var betterFetch = async (url, options) => {
|
|
39120
|
+
var _a2, _b, _c, _d, _e2, _f, _g, _h;
|
|
39121
|
+
const {
|
|
39122
|
+
hooks,
|
|
39123
|
+
url: __url,
|
|
39124
|
+
options: opts
|
|
39125
|
+
} = await initializePlugins(url, options);
|
|
39126
|
+
const fetch2 = getFetch(opts);
|
|
39127
|
+
const controller = new AbortController();
|
|
39128
|
+
const signal = (_a2 = opts.signal) != null ? _a2 : controller.signal;
|
|
39129
|
+
const _url2 = getURL2(__url, opts);
|
|
39130
|
+
const body = getBody(opts);
|
|
39131
|
+
const headers = await getHeaders(opts);
|
|
39132
|
+
const method = getMethod$1(__url, opts);
|
|
39133
|
+
let context = __spreadProps(__spreadValues({}, opts), {
|
|
39134
|
+
url: _url2,
|
|
39135
|
+
headers,
|
|
39136
|
+
body,
|
|
39137
|
+
method,
|
|
39138
|
+
signal
|
|
39139
|
+
});
|
|
39140
|
+
for (const onRequest of hooks.onRequest) {
|
|
39141
|
+
if (onRequest) {
|
|
39142
|
+
const res = await onRequest(context);
|
|
39143
|
+
if (res instanceof Object) {
|
|
39144
|
+
context = res;
|
|
39145
|
+
}
|
|
39146
|
+
}
|
|
39518
39147
|
}
|
|
39519
|
-
if (
|
|
39520
|
-
|
|
39148
|
+
if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof ((_b = options == null ? void 0 : options.body) == null ? void 0 : _b.pipe) === "function") {
|
|
39149
|
+
if (!("duplex" in context)) {
|
|
39150
|
+
context.duplex = "half";
|
|
39151
|
+
}
|
|
39521
39152
|
}
|
|
39522
|
-
|
|
39523
|
-
|
|
39524
|
-
|
|
39525
|
-
|
|
39526
|
-
|
|
39527
|
-
|
|
39153
|
+
const { clearTimeout: clearTimeout2 } = getTimeout(opts, controller);
|
|
39154
|
+
let response = await fetch2(context.url, context);
|
|
39155
|
+
clearTimeout2();
|
|
39156
|
+
const responseContext = {
|
|
39157
|
+
response,
|
|
39158
|
+
request: context
|
|
39159
|
+
};
|
|
39160
|
+
for (const onResponse of hooks.onResponse) {
|
|
39161
|
+
if (onResponse) {
|
|
39162
|
+
const r2 = await onResponse(__spreadProps(__spreadValues({}, responseContext), {
|
|
39163
|
+
response: ((_c = options == null ? void 0 : options.hookOptions) == null ? void 0 : _c.cloneResponse) ? response.clone() : response
|
|
39164
|
+
}));
|
|
39165
|
+
if (r2 instanceof Response) {
|
|
39166
|
+
response = r2;
|
|
39167
|
+
} else if (r2 instanceof Object) {
|
|
39168
|
+
response = r2.response;
|
|
39169
|
+
}
|
|
39170
|
+
}
|
|
39528
39171
|
}
|
|
39529
|
-
|
|
39530
|
-
|
|
39531
|
-
|
|
39172
|
+
if (response.ok) {
|
|
39173
|
+
const hasBody = context.method !== "HEAD";
|
|
39174
|
+
if (!hasBody) {
|
|
39175
|
+
return {
|
|
39176
|
+
data: "",
|
|
39177
|
+
error: null
|
|
39178
|
+
};
|
|
39179
|
+
}
|
|
39180
|
+
const responseType = detectResponseType(response);
|
|
39181
|
+
const successContext = {
|
|
39182
|
+
data: "",
|
|
39183
|
+
response,
|
|
39184
|
+
request: context
|
|
39185
|
+
};
|
|
39186
|
+
if (responseType === "json" || responseType === "text") {
|
|
39187
|
+
const text = await response.text();
|
|
39188
|
+
const parser2 = (_d = context.jsonParser) != null ? _d : jsonParse;
|
|
39189
|
+
const data = await parser2(text);
|
|
39190
|
+
successContext.data = data;
|
|
39191
|
+
} else {
|
|
39192
|
+
successContext.data = await response[responseType]();
|
|
39193
|
+
}
|
|
39194
|
+
if (context == null ? void 0 : context.output) {
|
|
39195
|
+
if (context.output && !context.disableValidation) {
|
|
39196
|
+
successContext.data = await parseStandardSchema(
|
|
39197
|
+
context.output,
|
|
39198
|
+
successContext.data
|
|
39199
|
+
);
|
|
39200
|
+
}
|
|
39201
|
+
}
|
|
39202
|
+
for (const onSuccess of hooks.onSuccess) {
|
|
39203
|
+
if (onSuccess) {
|
|
39204
|
+
await onSuccess(__spreadProps(__spreadValues({}, successContext), {
|
|
39205
|
+
response: ((_e2 = options == null ? void 0 : options.hookOptions) == null ? void 0 : _e2.cloneResponse) ? response.clone() : response
|
|
39206
|
+
}));
|
|
39207
|
+
}
|
|
39208
|
+
}
|
|
39209
|
+
if (options == null ? void 0 : options.throw) {
|
|
39210
|
+
return successContext.data;
|
|
39211
|
+
}
|
|
39212
|
+
return {
|
|
39213
|
+
data: successContext.data,
|
|
39214
|
+
error: null
|
|
39215
|
+
};
|
|
39532
39216
|
}
|
|
39533
|
-
const
|
|
39534
|
-
|
|
39535
|
-
|
|
39536
|
-
|
|
39537
|
-
|
|
39538
|
-
|
|
39539
|
-
|
|
39540
|
-
|
|
39217
|
+
const parser = (_f = options == null ? void 0 : options.jsonParser) != null ? _f : jsonParse;
|
|
39218
|
+
const responseText = await response.text();
|
|
39219
|
+
const isJSONResponse = isJSONParsable(responseText);
|
|
39220
|
+
const errorObject = isJSONResponse ? await parser(responseText) : null;
|
|
39221
|
+
const errorContext = {
|
|
39222
|
+
response,
|
|
39223
|
+
responseText,
|
|
39224
|
+
request: context,
|
|
39225
|
+
error: __spreadProps(__spreadValues({}, errorObject), {
|
|
39226
|
+
status: response.status,
|
|
39227
|
+
statusText: response.statusText
|
|
39228
|
+
})
|
|
39541
39229
|
};
|
|
39542
|
-
const
|
|
39543
|
-
|
|
39544
|
-
|
|
39230
|
+
for (const onError of hooks.onError) {
|
|
39231
|
+
if (onError) {
|
|
39232
|
+
await onError(__spreadProps(__spreadValues({}, errorContext), {
|
|
39233
|
+
response: ((_g = options == null ? void 0 : options.hookOptions) == null ? void 0 : _g.cloneResponse) ? response.clone() : response
|
|
39234
|
+
}));
|
|
39235
|
+
}
|
|
39545
39236
|
}
|
|
39546
|
-
|
|
39547
|
-
|
|
39548
|
-
|
|
39549
|
-
|
|
39550
|
-
|
|
39551
|
-
|
|
39552
|
-
|
|
39237
|
+
if (options == null ? void 0 : options.retry) {
|
|
39238
|
+
const retryStrategy = createRetryStrategy(options.retry);
|
|
39239
|
+
const _retryAttempt = (_h = options.retryAttempt) != null ? _h : 0;
|
|
39240
|
+
if (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {
|
|
39241
|
+
for (const onRetry of hooks.onRetry) {
|
|
39242
|
+
if (onRetry) {
|
|
39243
|
+
await onRetry(responseContext);
|
|
39244
|
+
}
|
|
39245
|
+
}
|
|
39246
|
+
const delay2 = retryStrategy.getDelay(_retryAttempt);
|
|
39247
|
+
await new Promise((resolve) => setTimeout(resolve, delay2));
|
|
39248
|
+
return await betterFetch(url, __spreadProps(__spreadValues({}, options), {
|
|
39249
|
+
retryAttempt: _retryAttempt + 1
|
|
39250
|
+
}));
|
|
39251
|
+
}
|
|
39553
39252
|
}
|
|
39554
|
-
if (
|
|
39555
|
-
throw new
|
|
39253
|
+
if (options == null ? void 0 : options.throw) {
|
|
39254
|
+
throw new BetterFetchError(
|
|
39255
|
+
response.status,
|
|
39256
|
+
response.statusText,
|
|
39257
|
+
isJSONResponse ? errorObject : responseText
|
|
39258
|
+
);
|
|
39556
39259
|
}
|
|
39557
|
-
|
|
39558
|
-
|
|
39559
|
-
|
|
39560
|
-
|
|
39260
|
+
return {
|
|
39261
|
+
data: null,
|
|
39262
|
+
error: __spreadProps(__spreadValues({}, errorObject), {
|
|
39263
|
+
status: response.status,
|
|
39264
|
+
statusText: response.statusText
|
|
39265
|
+
})
|
|
39266
|
+
};
|
|
39267
|
+
};
|
|
39268
|
+
const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
39269
|
+
const now$1 = () => Math.floor(Date.now() / 1e3);
|
|
39270
|
+
var WindowBroadcastChannel = class {
|
|
39271
|
+
listeners = /* @__PURE__ */ new Set();
|
|
39272
|
+
name;
|
|
39273
|
+
constructor(name = "better-auth.message") {
|
|
39274
|
+
this.name = name;
|
|
39561
39275
|
}
|
|
39562
|
-
|
|
39563
|
-
|
|
39564
|
-
|
|
39565
|
-
|
|
39566
|
-
}
|
|
39567
|
-
warnOnBrokenImplementation("getPublicKeyAlgorithm()", error);
|
|
39568
|
-
}
|
|
39276
|
+
subscribe(listener) {
|
|
39277
|
+
this.listeners.add(listener);
|
|
39278
|
+
return () => {
|
|
39279
|
+
this.listeners.delete(listener);
|
|
39280
|
+
};
|
|
39569
39281
|
}
|
|
39570
|
-
|
|
39571
|
-
|
|
39282
|
+
post(message) {
|
|
39283
|
+
if (typeof window === "undefined") return;
|
|
39572
39284
|
try {
|
|
39573
|
-
|
|
39574
|
-
|
|
39575
|
-
|
|
39576
|
-
}
|
|
39577
|
-
} catch
|
|
39578
|
-
warnOnBrokenImplementation("getPublicKey()", error);
|
|
39285
|
+
localStorage.setItem(this.name, JSON.stringify({
|
|
39286
|
+
...message,
|
|
39287
|
+
timestamp: now$1()
|
|
39288
|
+
}));
|
|
39289
|
+
} catch {
|
|
39579
39290
|
}
|
|
39580
39291
|
}
|
|
39581
|
-
|
|
39582
|
-
|
|
39583
|
-
|
|
39584
|
-
|
|
39585
|
-
|
|
39586
|
-
|
|
39587
|
-
|
|
39292
|
+
setup() {
|
|
39293
|
+
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
39294
|
+
};
|
|
39295
|
+
const handler = (event) => {
|
|
39296
|
+
if (event.key !== this.name) return;
|
|
39297
|
+
const message = JSON.parse(event.newValue ?? "{}");
|
|
39298
|
+
if (message?.event !== "session" || !message?.data) return;
|
|
39299
|
+
this.listeners.forEach((listener) => listener(message));
|
|
39300
|
+
};
|
|
39301
|
+
window.addEventListener("storage", handler);
|
|
39302
|
+
return () => {
|
|
39303
|
+
window.removeEventListener("storage", handler);
|
|
39304
|
+
};
|
|
39588
39305
|
}
|
|
39589
|
-
|
|
39590
|
-
|
|
39591
|
-
|
|
39592
|
-
|
|
39593
|
-
attestationObject: bufferToBase64URLString(response.attestationObject),
|
|
39594
|
-
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
39595
|
-
transports,
|
|
39596
|
-
publicKeyAlgorithm: responsePublicKeyAlgorithm,
|
|
39597
|
-
publicKey: responsePublicKey,
|
|
39598
|
-
authenticatorData: responseAuthenticatorData
|
|
39599
|
-
},
|
|
39600
|
-
type,
|
|
39601
|
-
clientExtensionResults: credential.getClientExtensionResults(),
|
|
39602
|
-
authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
|
|
39603
|
-
};
|
|
39604
|
-
}
|
|
39605
|
-
function warnOnBrokenImplementation(methodName, cause) {
|
|
39606
|
-
console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.
|
|
39607
|
-
`, cause);
|
|
39306
|
+
};
|
|
39307
|
+
function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
39308
|
+
if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
|
|
39309
|
+
return globalThis[kBroadcastChannel];
|
|
39608
39310
|
}
|
|
39609
|
-
|
|
39610
|
-
|
|
39611
|
-
|
|
39311
|
+
const kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
39312
|
+
var WindowFocusManager = class {
|
|
39313
|
+
listeners = /* @__PURE__ */ new Set();
|
|
39314
|
+
subscribe(listener) {
|
|
39315
|
+
this.listeners.add(listener);
|
|
39316
|
+
return () => {
|
|
39317
|
+
this.listeners.delete(listener);
|
|
39318
|
+
};
|
|
39612
39319
|
}
|
|
39613
|
-
|
|
39614
|
-
|
|
39615
|
-
|
|
39320
|
+
setFocused(focused) {
|
|
39321
|
+
this.listeners.forEach((listener) => listener(focused));
|
|
39322
|
+
}
|
|
39323
|
+
setup() {
|
|
39324
|
+
if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
39325
|
+
};
|
|
39326
|
+
const visibilityHandler = () => {
|
|
39327
|
+
if (document.visibilityState === "visible") this.setFocused(true);
|
|
39328
|
+
};
|
|
39329
|
+
document.addEventListener("visibilitychange", visibilityHandler, false);
|
|
39330
|
+
return () => {
|
|
39331
|
+
document.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
39332
|
+
};
|
|
39616
39333
|
}
|
|
39617
|
-
return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
|
|
39618
|
-
}
|
|
39619
|
-
const _browserSupportsWebAuthnAutofillInternals = {
|
|
39620
|
-
stubThis: (value) => value
|
|
39621
39334
|
};
|
|
39622
|
-
function
|
|
39623
|
-
|
|
39624
|
-
|
|
39625
|
-
|
|
39335
|
+
function getGlobalFocusManager() {
|
|
39336
|
+
if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
|
|
39337
|
+
return globalThis[kFocusManager];
|
|
39338
|
+
}
|
|
39339
|
+
const kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
39340
|
+
var WindowOnlineManager = class {
|
|
39341
|
+
listeners = /* @__PURE__ */ new Set();
|
|
39342
|
+
isOnline = typeof navigator !== "undefined" ? navigator.onLine : true;
|
|
39343
|
+
subscribe(listener) {
|
|
39344
|
+
this.listeners.add(listener);
|
|
39345
|
+
return () => {
|
|
39346
|
+
this.listeners.delete(listener);
|
|
39347
|
+
};
|
|
39626
39348
|
}
|
|
39627
|
-
|
|
39628
|
-
|
|
39629
|
-
|
|
39630
|
-
|
|
39631
|
-
|
|
39632
|
-
|
|
39349
|
+
setOnline(online) {
|
|
39350
|
+
this.isOnline = online;
|
|
39351
|
+
this.listeners.forEach((listener) => listener(online));
|
|
39352
|
+
}
|
|
39353
|
+
setup() {
|
|
39354
|
+
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
39355
|
+
};
|
|
39356
|
+
const onOnline = () => this.setOnline(true);
|
|
39357
|
+
const onOffline = () => this.setOnline(false);
|
|
39358
|
+
window.addEventListener("online", onOnline, false);
|
|
39359
|
+
window.addEventListener("offline", onOffline, false);
|
|
39360
|
+
return () => {
|
|
39361
|
+
window.removeEventListener("online", onOnline, false);
|
|
39362
|
+
window.removeEventListener("offline", onOffline, false);
|
|
39363
|
+
};
|
|
39364
|
+
}
|
|
39365
|
+
};
|
|
39366
|
+
function getGlobalOnlineManager() {
|
|
39367
|
+
if (!globalThis[kOnlineManager]) globalThis[kOnlineManager] = new WindowOnlineManager();
|
|
39368
|
+
return globalThis[kOnlineManager];
|
|
39369
|
+
}
|
|
39370
|
+
const isServer = () => typeof window === "undefined";
|
|
39371
|
+
const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
39372
|
+
const value = /* @__PURE__ */ atom({
|
|
39373
|
+
data: null,
|
|
39374
|
+
error: null,
|
|
39375
|
+
isPending: true,
|
|
39376
|
+
isRefetching: false,
|
|
39377
|
+
refetch: (queryParams) => fn(queryParams)
|
|
39378
|
+
});
|
|
39379
|
+
const fn = async (queryParams) => {
|
|
39380
|
+
return new Promise((resolve) => {
|
|
39381
|
+
const opts = typeof options === "function" ? options({
|
|
39382
|
+
data: value.get().data,
|
|
39383
|
+
error: value.get().error,
|
|
39384
|
+
isPending: value.get().isPending
|
|
39385
|
+
}) : options;
|
|
39386
|
+
$fetch(path, {
|
|
39387
|
+
...opts,
|
|
39388
|
+
query: {
|
|
39389
|
+
...opts?.query,
|
|
39390
|
+
...queryParams?.query
|
|
39391
|
+
},
|
|
39392
|
+
async onSuccess(context) {
|
|
39393
|
+
value.set({
|
|
39394
|
+
data: context.data,
|
|
39395
|
+
error: null,
|
|
39396
|
+
isPending: false,
|
|
39397
|
+
isRefetching: false,
|
|
39398
|
+
refetch: value.value.refetch
|
|
39399
|
+
});
|
|
39400
|
+
await opts?.onSuccess?.(context);
|
|
39401
|
+
},
|
|
39402
|
+
async onError(context) {
|
|
39403
|
+
const { request } = context;
|
|
39404
|
+
const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
|
|
39405
|
+
const retryAttempt = request.retryAttempt || 0;
|
|
39406
|
+
if (retryAttempts && retryAttempt < retryAttempts) return;
|
|
39407
|
+
value.set({
|
|
39408
|
+
error: context.error,
|
|
39409
|
+
data: null,
|
|
39410
|
+
isPending: false,
|
|
39411
|
+
isRefetching: false,
|
|
39412
|
+
refetch: value.value.refetch
|
|
39413
|
+
});
|
|
39414
|
+
await opts?.onError?.(context);
|
|
39415
|
+
},
|
|
39416
|
+
async onRequest(context) {
|
|
39417
|
+
const currentValue = value.get();
|
|
39418
|
+
value.set({
|
|
39419
|
+
isPending: currentValue.data === null,
|
|
39420
|
+
data: currentValue.data,
|
|
39421
|
+
error: null,
|
|
39422
|
+
isRefetching: true,
|
|
39423
|
+
refetch: value.value.refetch
|
|
39424
|
+
});
|
|
39425
|
+
await opts?.onRequest?.(context);
|
|
39426
|
+
}
|
|
39427
|
+
}).catch((error) => {
|
|
39428
|
+
value.set({
|
|
39429
|
+
error,
|
|
39430
|
+
data: null,
|
|
39431
|
+
isPending: false,
|
|
39432
|
+
isRefetching: false,
|
|
39433
|
+
refetch: value.value.refetch
|
|
39434
|
+
});
|
|
39435
|
+
}).finally(() => {
|
|
39436
|
+
resolve(void 0);
|
|
39633
39437
|
});
|
|
39634
|
-
}
|
|
39635
|
-
} else if (error.name === "NotAllowedError") {
|
|
39636
|
-
return new WebAuthnError({
|
|
39637
|
-
message: error.message,
|
|
39638
|
-
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
39639
|
-
cause: error
|
|
39640
39438
|
});
|
|
39641
|
-
}
|
|
39642
|
-
|
|
39643
|
-
|
|
39644
|
-
|
|
39645
|
-
|
|
39646
|
-
|
|
39647
|
-
|
|
39648
|
-
|
|
39649
|
-
|
|
39650
|
-
|
|
39651
|
-
|
|
39652
|
-
|
|
39653
|
-
|
|
39439
|
+
};
|
|
39440
|
+
initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
|
|
39441
|
+
let isMounted = false;
|
|
39442
|
+
for (const initAtom of initializedAtom) initAtom.subscribe(async () => {
|
|
39443
|
+
if (isServer()) return;
|
|
39444
|
+
if (isMounted) await fn();
|
|
39445
|
+
else onMount(value, () => {
|
|
39446
|
+
const timeoutId = setTimeout(async () => {
|
|
39447
|
+
if (!isMounted) {
|
|
39448
|
+
await fn();
|
|
39449
|
+
isMounted = true;
|
|
39450
|
+
}
|
|
39451
|
+
}, 0);
|
|
39452
|
+
return () => {
|
|
39453
|
+
value.off();
|
|
39454
|
+
initAtom.off();
|
|
39455
|
+
clearTimeout(timeoutId);
|
|
39456
|
+
};
|
|
39457
|
+
});
|
|
39458
|
+
});
|
|
39459
|
+
return value;
|
|
39460
|
+
};
|
|
39461
|
+
const now = () => Math.floor(Date.now() / 1e3);
|
|
39462
|
+
const FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
|
|
39463
|
+
function createSessionRefreshManager(opts) {
|
|
39464
|
+
const { sessionAtom, sessionSignal, $fetch, options = {} } = opts;
|
|
39465
|
+
const refetchInterval = options.sessionOptions?.refetchInterval ?? 0;
|
|
39466
|
+
const refetchOnWindowFocus = options.sessionOptions?.refetchOnWindowFocus ?? true;
|
|
39467
|
+
const refetchWhenOffline = options.sessionOptions?.refetchWhenOffline ?? false;
|
|
39468
|
+
const state = {
|
|
39469
|
+
lastSync: 0,
|
|
39470
|
+
lastSessionRequest: 0,
|
|
39471
|
+
cachedSession: void 0
|
|
39472
|
+
};
|
|
39473
|
+
const shouldRefetch = () => {
|
|
39474
|
+
return refetchWhenOffline || getGlobalOnlineManager().isOnline;
|
|
39475
|
+
};
|
|
39476
|
+
const triggerRefetch = (event) => {
|
|
39477
|
+
if (!shouldRefetch()) return;
|
|
39478
|
+
if (event?.event === "storage") {
|
|
39479
|
+
state.lastSync = now();
|
|
39480
|
+
sessionSignal.set(!sessionSignal.get());
|
|
39481
|
+
return;
|
|
39482
|
+
}
|
|
39483
|
+
const currentSession = sessionAtom.get();
|
|
39484
|
+
if (event?.event === "poll") {
|
|
39485
|
+
state.lastSessionRequest = now();
|
|
39486
|
+
$fetch("/get-session").then((res) => {
|
|
39487
|
+
sessionAtom.set({
|
|
39488
|
+
...currentSession,
|
|
39489
|
+
data: res.data,
|
|
39490
|
+
error: res.error || null
|
|
39491
|
+
});
|
|
39492
|
+
state.lastSync = now();
|
|
39493
|
+
sessionSignal.set(!sessionSignal.get());
|
|
39494
|
+
}).catch(() => {
|
|
39654
39495
|
});
|
|
39496
|
+
return;
|
|
39655
39497
|
}
|
|
39656
|
-
|
|
39657
|
-
|
|
39658
|
-
|
|
39659
|
-
|
|
39660
|
-
|
|
39498
|
+
if (event?.event === "visibilitychange") {
|
|
39499
|
+
if (now() - state.lastSessionRequest < FOCUS_REFETCH_RATE_LIMIT_SECONDS && currentSession?.data !== null && currentSession?.data !== void 0) return;
|
|
39500
|
+
}
|
|
39501
|
+
if (currentSession?.data === null || currentSession?.data === void 0 || event?.event === "visibilitychange") {
|
|
39502
|
+
if (event?.event === "visibilitychange") state.lastSessionRequest = now();
|
|
39503
|
+
state.lastSync = now();
|
|
39504
|
+
sessionSignal.set(!sessionSignal.get());
|
|
39505
|
+
}
|
|
39506
|
+
};
|
|
39507
|
+
const broadcastSessionUpdate = (trigger) => {
|
|
39508
|
+
getGlobalBroadcastChannel().post({
|
|
39509
|
+
event: "session",
|
|
39510
|
+
data: { trigger },
|
|
39511
|
+
clientId: Math.random().toString(36).substring(7)
|
|
39661
39512
|
});
|
|
39662
|
-
}
|
|
39663
|
-
|
|
39513
|
+
};
|
|
39514
|
+
const setupPolling = () => {
|
|
39515
|
+
if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
|
|
39516
|
+
if (sessionAtom.get()?.data) triggerRefetch({ event: "poll" });
|
|
39517
|
+
}, refetchInterval * 1e3);
|
|
39518
|
+
};
|
|
39519
|
+
const setupBroadcast = () => {
|
|
39520
|
+
state.unsubscribeBroadcast = getGlobalBroadcastChannel().subscribe(() => {
|
|
39521
|
+
triggerRefetch({ event: "storage" });
|
|
39522
|
+
});
|
|
39523
|
+
};
|
|
39524
|
+
const setupFocusRefetch = () => {
|
|
39525
|
+
if (!refetchOnWindowFocus) return;
|
|
39526
|
+
state.unsubscribeFocus = getGlobalFocusManager().subscribe(() => {
|
|
39527
|
+
triggerRefetch({ event: "visibilitychange" });
|
|
39528
|
+
});
|
|
39529
|
+
};
|
|
39530
|
+
const setupOnlineRefetch = () => {
|
|
39531
|
+
state.unsubscribeOnline = getGlobalOnlineManager().subscribe((online) => {
|
|
39532
|
+
if (online) triggerRefetch({ event: "visibilitychange" });
|
|
39533
|
+
});
|
|
39534
|
+
};
|
|
39535
|
+
const init2 = () => {
|
|
39536
|
+
setupPolling();
|
|
39537
|
+
setupBroadcast();
|
|
39538
|
+
setupFocusRefetch();
|
|
39539
|
+
setupOnlineRefetch();
|
|
39540
|
+
getGlobalBroadcastChannel().setup();
|
|
39541
|
+
getGlobalFocusManager().setup();
|
|
39542
|
+
getGlobalOnlineManager().setup();
|
|
39543
|
+
};
|
|
39544
|
+
const cleanup = () => {
|
|
39545
|
+
if (state.pollInterval) {
|
|
39546
|
+
clearInterval(state.pollInterval);
|
|
39547
|
+
state.pollInterval = void 0;
|
|
39548
|
+
}
|
|
39549
|
+
if (state.unsubscribeBroadcast) {
|
|
39550
|
+
state.unsubscribeBroadcast();
|
|
39551
|
+
state.unsubscribeBroadcast = void 0;
|
|
39552
|
+
}
|
|
39553
|
+
if (state.unsubscribeFocus) {
|
|
39554
|
+
state.unsubscribeFocus();
|
|
39555
|
+
state.unsubscribeFocus = void 0;
|
|
39556
|
+
}
|
|
39557
|
+
if (state.unsubscribeOnline) {
|
|
39558
|
+
state.unsubscribeOnline();
|
|
39559
|
+
state.unsubscribeOnline = void 0;
|
|
39560
|
+
}
|
|
39561
|
+
state.lastSync = 0;
|
|
39562
|
+
state.lastSessionRequest = 0;
|
|
39563
|
+
state.cachedSession = void 0;
|
|
39564
|
+
};
|
|
39565
|
+
return {
|
|
39566
|
+
init: init2,
|
|
39567
|
+
cleanup,
|
|
39568
|
+
triggerRefetch,
|
|
39569
|
+
broadcastSessionUpdate
|
|
39570
|
+
};
|
|
39664
39571
|
}
|
|
39665
|
-
|
|
39666
|
-
|
|
39667
|
-
|
|
39668
|
-
|
|
39669
|
-
|
|
39670
|
-
|
|
39671
|
-
|
|
39672
|
-
|
|
39673
|
-
|
|
39674
|
-
|
|
39675
|
-
|
|
39676
|
-
|
|
39677
|
-
}
|
|
39678
|
-
|
|
39679
|
-
|
|
39680
|
-
|
|
39681
|
-
|
|
39572
|
+
const redirectPlugin = {
|
|
39573
|
+
id: "redirect",
|
|
39574
|
+
name: "Redirect",
|
|
39575
|
+
hooks: { onSuccess(context) {
|
|
39576
|
+
if (context.data?.url && context.data?.redirect) {
|
|
39577
|
+
if (typeof window !== "undefined" && window.location) {
|
|
39578
|
+
if (window.location) try {
|
|
39579
|
+
window.location.href = context.data.url;
|
|
39580
|
+
} catch {
|
|
39581
|
+
}
|
|
39582
|
+
}
|
|
39583
|
+
}
|
|
39584
|
+
} }
|
|
39585
|
+
};
|
|
39586
|
+
function getSessionAtom($fetch, options) {
|
|
39587
|
+
const $signal = /* @__PURE__ */ atom(false);
|
|
39588
|
+
const session = useAuthQuery($signal, "/get-session", $fetch, { method: "GET" });
|
|
39589
|
+
onMount(session, () => {
|
|
39590
|
+
const refreshManager = createSessionRefreshManager({
|
|
39591
|
+
sessionAtom: session,
|
|
39592
|
+
sessionSignal: $signal,
|
|
39593
|
+
$fetch,
|
|
39594
|
+
options
|
|
39595
|
+
});
|
|
39596
|
+
refreshManager.init();
|
|
39597
|
+
return () => {
|
|
39598
|
+
refreshManager.cleanup();
|
|
39599
|
+
};
|
|
39600
|
+
});
|
|
39601
|
+
return {
|
|
39602
|
+
session,
|
|
39603
|
+
$sessionSignal: $signal
|
|
39682
39604
|
};
|
|
39683
|
-
|
|
39684
|
-
|
|
39685
|
-
|
|
39686
|
-
|
|
39605
|
+
}
|
|
39606
|
+
const getClientConfig = (options, loadEnv) => {
|
|
39607
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
39608
|
+
const baseURL = getBaseURL(options?.baseURL, options?.basePath) ?? "/api/auth";
|
|
39609
|
+
const pluginsFetchPlugins = options?.plugins?.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0) || [];
|
|
39610
|
+
const lifeCyclePlugin = {
|
|
39611
|
+
id: "lifecycle-hooks",
|
|
39612
|
+
name: "lifecycle-hooks",
|
|
39613
|
+
hooks: {
|
|
39614
|
+
onSuccess: options?.fetchOptions?.onSuccess,
|
|
39615
|
+
onError: options?.fetchOptions?.onError,
|
|
39616
|
+
onRequest: options?.fetchOptions?.onRequest,
|
|
39617
|
+
onResponse: options?.fetchOptions?.onResponse
|
|
39687
39618
|
}
|
|
39688
|
-
|
|
39689
|
-
|
|
39690
|
-
|
|
39619
|
+
};
|
|
39620
|
+
const { onSuccess, onError, onRequest, onResponse, ...restOfFetchOptions } = options?.fetchOptions || {};
|
|
39621
|
+
const $fetch = createFetch({
|
|
39622
|
+
baseURL,
|
|
39623
|
+
...isCredentialsSupported ? { credentials: "include" } : {},
|
|
39624
|
+
method: "GET",
|
|
39625
|
+
jsonParser(text) {
|
|
39626
|
+
if (!text) return null;
|
|
39627
|
+
return parseJSON(text, { strict: false });
|
|
39628
|
+
},
|
|
39629
|
+
customFetchImpl: fetch,
|
|
39630
|
+
...restOfFetchOptions,
|
|
39631
|
+
plugins: [
|
|
39632
|
+
lifeCyclePlugin,
|
|
39633
|
+
...restOfFetchOptions.plugins || [],
|
|
39634
|
+
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
39635
|
+
...pluginsFetchPlugins
|
|
39636
|
+
]
|
|
39637
|
+
});
|
|
39638
|
+
const { $sessionSignal, session } = getSessionAtom($fetch, options);
|
|
39639
|
+
const plugins = options?.plugins || [];
|
|
39640
|
+
let pluginsActions = {};
|
|
39641
|
+
let pluginsAtoms = {
|
|
39642
|
+
$sessionSignal,
|
|
39643
|
+
session
|
|
39644
|
+
};
|
|
39645
|
+
let pluginPathMethods = {
|
|
39646
|
+
"/sign-out": "POST",
|
|
39647
|
+
"/revoke-sessions": "POST",
|
|
39648
|
+
"/revoke-other-sessions": "POST",
|
|
39649
|
+
"/delete-user": "POST"
|
|
39650
|
+
};
|
|
39651
|
+
const atomListeners = [{
|
|
39652
|
+
signal: "$sessionSignal",
|
|
39653
|
+
matcher(path) {
|
|
39654
|
+
return path === "/sign-out" || path === "/update-user" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/change-email";
|
|
39691
39655
|
}
|
|
39692
|
-
|
|
39693
|
-
|
|
39694
|
-
|
|
39695
|
-
|
|
39696
|
-
|
|
39697
|
-
let credential;
|
|
39698
|
-
try {
|
|
39699
|
-
credential = await navigator.credentials.get(getOptions);
|
|
39700
|
-
} catch (err) {
|
|
39701
|
-
throw identifyAuthenticationError({ error: err, options: getOptions });
|
|
39702
|
-
}
|
|
39703
|
-
if (!credential) {
|
|
39704
|
-
throw new Error("Authentication was not completed");
|
|
39705
|
-
}
|
|
39706
|
-
const { id: id2, rawId, response, type } = credential;
|
|
39707
|
-
let userHandle = void 0;
|
|
39708
|
-
if (response.userHandle) {
|
|
39709
|
-
userHandle = bufferToBase64URLString(response.userHandle);
|
|
39656
|
+
}];
|
|
39657
|
+
for (const plugin of plugins) {
|
|
39658
|
+
if (plugin.getAtoms) Object.assign(pluginsAtoms, plugin.getAtoms?.($fetch));
|
|
39659
|
+
if (plugin.pathMethods) Object.assign(pluginPathMethods, plugin.pathMethods);
|
|
39660
|
+
if (plugin.atomListeners) atomListeners.push(...plugin.atomListeners);
|
|
39710
39661
|
}
|
|
39711
|
-
|
|
39712
|
-
|
|
39713
|
-
|
|
39714
|
-
response: {
|
|
39715
|
-
authenticatorData: bufferToBase64URLString(response.authenticatorData),
|
|
39716
|
-
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
39717
|
-
signature: bufferToBase64URLString(response.signature),
|
|
39718
|
-
userHandle
|
|
39662
|
+
const $store = {
|
|
39663
|
+
notify: (signal) => {
|
|
39664
|
+
pluginsAtoms[signal].set(!pluginsAtoms[signal].get());
|
|
39719
39665
|
},
|
|
39720
|
-
|
|
39721
|
-
|
|
39722
|
-
|
|
39666
|
+
listen: (signal, listener) => {
|
|
39667
|
+
pluginsAtoms[signal].subscribe(listener);
|
|
39668
|
+
},
|
|
39669
|
+
atoms: pluginsAtoms
|
|
39723
39670
|
};
|
|
39724
|
-
|
|
39725
|
-
const twoFactorClient = (options) => {
|
|
39671
|
+
for (const plugin of plugins) if (plugin.getActions) Object.assign(pluginsActions, plugin.getActions?.($fetch, $store, options));
|
|
39726
39672
|
return {
|
|
39727
|
-
|
|
39728
|
-
|
|
39729
|
-
atomListeners: [
|
|
39730
|
-
{
|
|
39731
|
-
matcher: (path) => path.startsWith("/two-factor/"),
|
|
39732
|
-
signal: "$sessionSignal"
|
|
39733
|
-
}
|
|
39734
|
-
],
|
|
39735
|
-
pathMethods: {
|
|
39736
|
-
"/two-factor/disable": "POST",
|
|
39737
|
-
"/two-factor/enable": "POST",
|
|
39738
|
-
"/two-factor/send-otp": "POST",
|
|
39739
|
-
"/two-factor/generate-backup-codes": "POST"
|
|
39673
|
+
get baseURL() {
|
|
39674
|
+
return baseURL;
|
|
39740
39675
|
},
|
|
39741
|
-
|
|
39742
|
-
|
|
39743
|
-
|
|
39744
|
-
|
|
39745
|
-
|
|
39676
|
+
pluginsActions,
|
|
39677
|
+
pluginsAtoms,
|
|
39678
|
+
pluginPathMethods,
|
|
39679
|
+
atomListeners,
|
|
39680
|
+
$fetch,
|
|
39681
|
+
$store
|
|
39682
|
+
};
|
|
39683
|
+
};
|
|
39684
|
+
function isAtom(value) {
|
|
39685
|
+
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
39686
|
+
}
|
|
39687
|
+
function getMethod(path, knownPathMethods, args) {
|
|
39688
|
+
const method = knownPathMethods[path];
|
|
39689
|
+
const { fetchOptions, query, ...body } = args || {};
|
|
39690
|
+
if (method) return method;
|
|
39691
|
+
if (fetchOptions?.method) return fetchOptions.method;
|
|
39692
|
+
if (body && Object.keys(body).length > 0) return "POST";
|
|
39693
|
+
return "GET";
|
|
39694
|
+
}
|
|
39695
|
+
function createDynamicPathProxy(routes, client2, knownPathMethods, atoms, atomListeners) {
|
|
39696
|
+
function createProxy(path = []) {
|
|
39697
|
+
return new Proxy(function() {
|
|
39698
|
+
}, {
|
|
39699
|
+
get(_2, prop) {
|
|
39700
|
+
if (typeof prop !== "string") return;
|
|
39701
|
+
if (prop === "then" || prop === "catch" || prop === "finally") return;
|
|
39702
|
+
const fullPath = [...path, prop];
|
|
39703
|
+
let current = routes;
|
|
39704
|
+
for (const segment of fullPath) if (current && typeof current === "object" && segment in current) current = current[segment];
|
|
39705
|
+
else {
|
|
39706
|
+
current = void 0;
|
|
39707
|
+
break;
|
|
39708
|
+
}
|
|
39709
|
+
if (typeof current === "function") return current;
|
|
39710
|
+
if (isAtom(current)) return current;
|
|
39711
|
+
return createProxy(fullPath);
|
|
39712
|
+
},
|
|
39713
|
+
apply: async (_2, __, args) => {
|
|
39714
|
+
const routePath = "/" + path.map((segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)).join("/");
|
|
39715
|
+
const arg = args[0] || {};
|
|
39716
|
+
const fetchOptions = args[1] || {};
|
|
39717
|
+
const { query, fetchOptions: argFetchOptions, ...body } = arg;
|
|
39718
|
+
const options = {
|
|
39719
|
+
...fetchOptions,
|
|
39720
|
+
...argFetchOptions
|
|
39721
|
+
};
|
|
39722
|
+
const method = getMethod(routePath, knownPathMethods, arg);
|
|
39723
|
+
return await client2(routePath, {
|
|
39724
|
+
...options,
|
|
39725
|
+
body: method === "GET" ? void 0 : {
|
|
39726
|
+
...body,
|
|
39727
|
+
...options?.body || {}
|
|
39728
|
+
},
|
|
39729
|
+
query: query || options?.query,
|
|
39730
|
+
method,
|
|
39746
39731
|
async onSuccess(context) {
|
|
39747
|
-
|
|
39748
|
-
|
|
39749
|
-
|
|
39750
|
-
|
|
39732
|
+
await options?.onSuccess?.(context);
|
|
39733
|
+
if (!atomListeners || options.disableSignal) return;
|
|
39734
|
+
const matches = atomListeners.filter((s2) => s2.matcher(routePath));
|
|
39735
|
+
if (!matches.length) return;
|
|
39736
|
+
for (const match of matches) {
|
|
39737
|
+
const signal = atoms[match.signal];
|
|
39738
|
+
if (!signal) return;
|
|
39739
|
+
const val = signal.get();
|
|
39740
|
+
setTimeout(() => {
|
|
39741
|
+
signal.set(!val);
|
|
39742
|
+
}, 10);
|
|
39751
39743
|
}
|
|
39752
39744
|
}
|
|
39753
|
-
}
|
|
39745
|
+
});
|
|
39754
39746
|
}
|
|
39755
|
-
|
|
39756
|
-
}
|
|
39757
|
-
|
|
39758
|
-
|
|
39759
|
-
|
|
39760
|
-
$store
|
|
39761
|
-
|
|
39747
|
+
});
|
|
39748
|
+
}
|
|
39749
|
+
return createProxy();
|
|
39750
|
+
}
|
|
39751
|
+
function createAuthClient(options) {
|
|
39752
|
+
const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
39753
|
+
let resolvedHooks = {};
|
|
39754
|
+
for (const [key2, value] of Object.entries(pluginsAtoms)) resolvedHooks[`use${capitalizeFirstLetter(key2)}`] = value;
|
|
39755
|
+
return createDynamicPathProxy({
|
|
39756
|
+
...pluginsActions,
|
|
39757
|
+
...resolvedHooks,
|
|
39758
|
+
$fetch,
|
|
39759
|
+
$store
|
|
39760
|
+
}, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
|
|
39761
|
+
}
|
|
39762
|
+
const getPasskeyActions = ($fetch, { $listPasskeys, $store }) => {
|
|
39762
39763
|
const signInPasskey = async (opts, options) => {
|
|
39763
|
-
const response = await $fetch(
|
|
39764
|
-
"
|
|
39765
|
-
|
|
39766
|
-
|
|
39767
|
-
|
|
39768
|
-
}
|
|
39769
|
-
);
|
|
39770
|
-
if (!response.data) {
|
|
39771
|
-
return response;
|
|
39772
|
-
}
|
|
39764
|
+
const response = await $fetch("/passkey/generate-authenticate-options", {
|
|
39765
|
+
method: "GET",
|
|
39766
|
+
throw: false
|
|
39767
|
+
});
|
|
39768
|
+
if (!response.data) return response;
|
|
39773
39769
|
try {
|
|
39774
|
-
const res = await startAuthentication({
|
|
39775
|
-
optionsJSON: response.data,
|
|
39776
|
-
useBrowserAutofill: opts?.autoFill
|
|
39777
|
-
});
|
|
39778
39770
|
const verified = await $fetch("/passkey/verify-authentication", {
|
|
39779
|
-
body: {
|
|
39780
|
-
|
|
39781
|
-
|
|
39771
|
+
body: { response: await startAuthentication({
|
|
39772
|
+
optionsJSON: response.data,
|
|
39773
|
+
useBrowserAutofill: opts?.autoFill
|
|
39774
|
+
}) },
|
|
39782
39775
|
...opts?.fetchOptions,
|
|
39783
39776
|
...options,
|
|
39784
39777
|
method: "POST",
|
|
@@ -39800,24 +39793,15 @@ const getPasskeyActions = ($fetch, {
|
|
|
39800
39793
|
}
|
|
39801
39794
|
};
|
|
39802
39795
|
const registerPasskey = async (opts, fetchOpts) => {
|
|
39803
|
-
const options = await $fetch(
|
|
39804
|
-
"
|
|
39805
|
-
{
|
|
39806
|
-
|
|
39807
|
-
|
|
39808
|
-
|
|
39809
|
-
|
|
39810
|
-
|
|
39811
|
-
|
|
39812
|
-
name: opts.name
|
|
39813
|
-
}
|
|
39814
|
-
},
|
|
39815
|
-
throw: false
|
|
39816
|
-
}
|
|
39817
|
-
);
|
|
39818
|
-
if (!options.data) {
|
|
39819
|
-
return options;
|
|
39820
|
-
}
|
|
39796
|
+
const options = await $fetch("/passkey/generate-register-options", {
|
|
39797
|
+
method: "GET",
|
|
39798
|
+
query: {
|
|
39799
|
+
...opts?.authenticatorAttachment && { authenticatorAttachment: opts.authenticatorAttachment },
|
|
39800
|
+
...opts?.name && { name: opts.name }
|
|
39801
|
+
},
|
|
39802
|
+
throw: false
|
|
39803
|
+
});
|
|
39804
|
+
if (!options.data) return options;
|
|
39821
39805
|
try {
|
|
39822
39806
|
const res = await startRegistration({
|
|
39823
39807
|
optionsJSON: options.data,
|
|
@@ -39833,34 +39817,29 @@ const getPasskeyActions = ($fetch, {
|
|
|
39833
39817
|
method: "POST",
|
|
39834
39818
|
throw: false
|
|
39835
39819
|
});
|
|
39836
|
-
if (!verified.data)
|
|
39837
|
-
return verified;
|
|
39838
|
-
}
|
|
39820
|
+
if (!verified.data) return verified;
|
|
39839
39821
|
$listPasskeys.set(Math.random());
|
|
39822
|
+
return verified;
|
|
39840
39823
|
} catch (e) {
|
|
39841
39824
|
if (e instanceof WebAuthnError) {
|
|
39842
|
-
if (e.code === "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED") {
|
|
39843
|
-
|
|
39844
|
-
|
|
39845
|
-
|
|
39846
|
-
|
|
39847
|
-
|
|
39848
|
-
|
|
39849
|
-
|
|
39850
|
-
|
|
39851
|
-
|
|
39852
|
-
|
|
39853
|
-
|
|
39854
|
-
|
|
39855
|
-
|
|
39856
|
-
|
|
39857
|
-
|
|
39858
|
-
|
|
39859
|
-
|
|
39860
|
-
statusText: "BAD_REQUEST"
|
|
39861
|
-
}
|
|
39862
|
-
};
|
|
39863
|
-
}
|
|
39825
|
+
if (e.code === "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED") return {
|
|
39826
|
+
data: null,
|
|
39827
|
+
error: {
|
|
39828
|
+
code: e.code,
|
|
39829
|
+
message: "previously registered",
|
|
39830
|
+
status: 400,
|
|
39831
|
+
statusText: "BAD_REQUEST"
|
|
39832
|
+
}
|
|
39833
|
+
};
|
|
39834
|
+
if (e.code === "ERROR_CEREMONY_ABORTED") return {
|
|
39835
|
+
data: null,
|
|
39836
|
+
error: {
|
|
39837
|
+
code: e.code,
|
|
39838
|
+
message: "registration cancelled",
|
|
39839
|
+
status: 400,
|
|
39840
|
+
statusText: "BAD_REQUEST"
|
|
39841
|
+
}
|
|
39842
|
+
};
|
|
39864
39843
|
return {
|
|
39865
39844
|
data: null,
|
|
39866
39845
|
error: {
|
|
@@ -39883,21 +39862,8 @@ const getPasskeyActions = ($fetch, {
|
|
|
39883
39862
|
}
|
|
39884
39863
|
};
|
|
39885
39864
|
return {
|
|
39886
|
-
signIn: {
|
|
39887
|
-
|
|
39888
|
-
* Sign in with a registered passkey
|
|
39889
|
-
*/
|
|
39890
|
-
passkey: signInPasskey
|
|
39891
|
-
},
|
|
39892
|
-
passkey: {
|
|
39893
|
-
/**
|
|
39894
|
-
* Add a passkey to the user account
|
|
39895
|
-
*/
|
|
39896
|
-
addPasskey: registerPasskey
|
|
39897
|
-
},
|
|
39898
|
-
/**
|
|
39899
|
-
* Inferred Internal Types
|
|
39900
|
-
*/
|
|
39865
|
+
signIn: { passkey: signInPasskey },
|
|
39866
|
+
passkey: { addPasskey: registerPasskey },
|
|
39901
39867
|
$Infer: {}
|
|
39902
39868
|
};
|
|
39903
39869
|
};
|
|
@@ -39911,16 +39877,8 @@ const passkeyClient = () => {
|
|
|
39911
39877
|
$store
|
|
39912
39878
|
}),
|
|
39913
39879
|
getAtoms($fetch) {
|
|
39914
|
-
const listPasskeys = useAuthQuery(
|
|
39915
|
-
$listPasskeys,
|
|
39916
|
-
"/passkey/list-user-passkeys",
|
|
39917
|
-
$fetch,
|
|
39918
|
-
{
|
|
39919
|
-
method: "GET"
|
|
39920
|
-
}
|
|
39921
|
-
);
|
|
39922
39880
|
return {
|
|
39923
|
-
listPasskeys,
|
|
39881
|
+
listPasskeys: useAuthQuery($listPasskeys, "/passkey/list-user-passkeys", $fetch, { method: "GET" }),
|
|
39924
39882
|
$listPasskeys
|
|
39925
39883
|
};
|
|
39926
39884
|
},
|
|
@@ -39928,18 +39886,40 @@ const passkeyClient = () => {
|
|
|
39928
39886
|
"/passkey/register": "POST",
|
|
39929
39887
|
"/passkey/authenticate": "POST"
|
|
39930
39888
|
},
|
|
39931
|
-
atomListeners: [
|
|
39932
|
-
{
|
|
39933
|
-
|
|
39934
|
-
return path === "/passkey/verify-registration" || path === "/passkey/delete-passkey" || path === "/passkey/update-passkey" || path === "/sign-out";
|
|
39935
|
-
},
|
|
39936
|
-
signal: "$listPasskeys"
|
|
39889
|
+
atomListeners: [{
|
|
39890
|
+
matcher(path) {
|
|
39891
|
+
return path === "/passkey/verify-registration" || path === "/passkey/delete-passkey" || path === "/passkey/update-passkey" || path === "/sign-out";
|
|
39937
39892
|
},
|
|
39938
|
-
|
|
39939
|
-
|
|
39940
|
-
|
|
39941
|
-
|
|
39942
|
-
]
|
|
39893
|
+
signal: "$listPasskeys"
|
|
39894
|
+
}, {
|
|
39895
|
+
matcher: (path) => path === "/passkey/verify-authentication",
|
|
39896
|
+
signal: "$sessionSignal"
|
|
39897
|
+
}]
|
|
39898
|
+
};
|
|
39899
|
+
};
|
|
39900
|
+
const twoFactorClient = (options) => {
|
|
39901
|
+
return {
|
|
39902
|
+
id: "two-factor",
|
|
39903
|
+
$InferServerPlugin: {},
|
|
39904
|
+
atomListeners: [{
|
|
39905
|
+
matcher: (path) => path.startsWith("/two-factor/"),
|
|
39906
|
+
signal: "$sessionSignal"
|
|
39907
|
+
}],
|
|
39908
|
+
pathMethods: {
|
|
39909
|
+
"/two-factor/disable": "POST",
|
|
39910
|
+
"/two-factor/enable": "POST",
|
|
39911
|
+
"/two-factor/send-otp": "POST",
|
|
39912
|
+
"/two-factor/generate-backup-codes": "POST"
|
|
39913
|
+
},
|
|
39914
|
+
fetchPlugins: [{
|
|
39915
|
+
id: "two-factor",
|
|
39916
|
+
name: "two-factor",
|
|
39917
|
+
hooks: { async onSuccess(context) {
|
|
39918
|
+
if (context.data?.twoFactorRedirect) {
|
|
39919
|
+
if (options?.onTwoFactorRedirect) await options.onTwoFactorRedirect();
|
|
39920
|
+
}
|
|
39921
|
+
} }
|
|
39922
|
+
}]
|
|
39943
39923
|
};
|
|
39944
39924
|
};
|
|
39945
39925
|
const magicLinkClient = () => {
|
|
@@ -44121,11 +44101,11 @@ var ItemIndicator = SelectItemIndicator;
|
|
|
44121
44101
|
var ScrollUpButton = SelectScrollUpButton$1;
|
|
44122
44102
|
var ScrollDownButton = SelectScrollDownButton$1;
|
|
44123
44103
|
var Separator = SelectSeparator$1;
|
|
44124
|
-
let SelectContentPosition = /* @__PURE__ */ function(SelectContentPosition$1) {
|
|
44104
|
+
let SelectContentPosition = /* @__PURE__ */ (function(SelectContentPosition$1) {
|
|
44125
44105
|
SelectContentPosition$1["POPPER"] = "popper";
|
|
44126
44106
|
SelectContentPosition$1["ITEM_ALIGNED"] = "item-aligned";
|
|
44127
44107
|
return SelectContentPosition$1;
|
|
44128
|
-
}({});
|
|
44108
|
+
})({});
|
|
44129
44109
|
const SelectRoot = Root2$1;
|
|
44130
44110
|
const SelectGroup = Group;
|
|
44131
44111
|
const SelectValue = Value;
|
|
@@ -44219,9 +44199,10 @@ Select.Label = SelectLabel;
|
|
|
44219
44199
|
Select.Item = SelectItem;
|
|
44220
44200
|
Select.Separator = SelectSeparator;
|
|
44221
44201
|
const selectorDefault = (option) => option?.getAttribute("aria-selected") === "true";
|
|
44222
|
-
const useItemSelector = (optionsRefs, { selector: selector2 = selectorDefault, isHoverable = false } = {
|
|
44202
|
+
const useItemSelector = (optionsRefs, { selector: selector2 = selectorDefault, isHoverable = false, orientation = "horizontal" } = {
|
|
44223
44203
|
selector: selectorDefault,
|
|
44224
|
-
isHoverable: false
|
|
44204
|
+
isHoverable: false,
|
|
44205
|
+
orientation: "horizontal"
|
|
44225
44206
|
}) => {
|
|
44226
44207
|
const [choiceIndicatorPosition, setChoiceIndicatorPosition] = reactExports.useState(null);
|
|
44227
44208
|
const [hoveredItem, setHoveredItem] = reactExports.useState(null);
|
|
@@ -44231,7 +44212,13 @@ const useItemSelector = (optionsRefs, { selector: selector2 = selectorDefault, i
|
|
|
44231
44212
|
if (hoveredItem) targetElement = hoveredItem;
|
|
44232
44213
|
else targetElement = optionsRefs.current.find(selector2) ?? null;
|
|
44233
44214
|
if (!targetElement) {
|
|
44234
|
-
setChoiceIndicatorPosition((prev) => ({
|
|
44215
|
+
if (orientation === "vertical") setChoiceIndicatorPosition((prev) => ({
|
|
44216
|
+
top: 0,
|
|
44217
|
+
height: 0,
|
|
44218
|
+
...prev,
|
|
44219
|
+
opacity: 0
|
|
44220
|
+
}));
|
|
44221
|
+
else setChoiceIndicatorPosition((prev) => ({
|
|
44235
44222
|
left: 0,
|
|
44236
44223
|
width: 0,
|
|
44237
44224
|
...prev,
|
|
@@ -44239,13 +44226,23 @@ const useItemSelector = (optionsRefs, { selector: selector2 = selectorDefault, i
|
|
|
44239
44226
|
}));
|
|
44240
44227
|
return;
|
|
44241
44228
|
}
|
|
44242
|
-
|
|
44243
|
-
|
|
44244
|
-
|
|
44245
|
-
|
|
44246
|
-
|
|
44247
|
-
|
|
44248
|
-
|
|
44229
|
+
if (orientation === "vertical") {
|
|
44230
|
+
const top = targetElement.offsetTop;
|
|
44231
|
+
const height = targetElement.offsetHeight;
|
|
44232
|
+
setChoiceIndicatorPosition({
|
|
44233
|
+
top,
|
|
44234
|
+
height,
|
|
44235
|
+
opacity: 1
|
|
44236
|
+
});
|
|
44237
|
+
} else {
|
|
44238
|
+
const left = targetElement.offsetLeft;
|
|
44239
|
+
const width = targetElement.offsetWidth;
|
|
44240
|
+
setChoiceIndicatorPosition({
|
|
44241
|
+
left,
|
|
44242
|
+
width,
|
|
44243
|
+
opacity: 1
|
|
44244
|
+
});
|
|
44245
|
+
}
|
|
44249
44246
|
};
|
|
44250
44247
|
reactExports.useEffect(() => {
|
|
44251
44248
|
calculatePosition();
|
|
@@ -44307,11 +44304,13 @@ const useItemSelector = (optionsRefs, { selector: selector2 = selectorDefault, i
|
|
|
44307
44304
|
optionsRefs,
|
|
44308
44305
|
selector2,
|
|
44309
44306
|
hoveredItem,
|
|
44310
|
-
itemsLength
|
|
44307
|
+
itemsLength,
|
|
44308
|
+
orientation
|
|
44311
44309
|
]);
|
|
44312
44310
|
return {
|
|
44313
44311
|
choiceIndicatorPosition,
|
|
44314
|
-
calculatePosition
|
|
44312
|
+
calculatePosition,
|
|
44313
|
+
orientation
|
|
44315
44314
|
};
|
|
44316
44315
|
};
|
|
44317
44316
|
const defaultChoices = [{
|
|
@@ -44321,7 +44320,7 @@ const defaultChoices = [{
|
|
|
44321
44320
|
content: "On",
|
|
44322
44321
|
value: true
|
|
44323
44322
|
}];
|
|
44324
|
-
let SwitchSelectorColor = /* @__PURE__ */ function(SwitchSelectorColor$1) {
|
|
44323
|
+
let SwitchSelectorColor = /* @__PURE__ */ (function(SwitchSelectorColor$1) {
|
|
44325
44324
|
SwitchSelectorColor$1["PRIMARY"] = "primary";
|
|
44326
44325
|
SwitchSelectorColor$1["SECONDARY"] = "secondary";
|
|
44327
44326
|
SwitchSelectorColor$1["DESTRUCTIVE"] = "destructive";
|
|
@@ -44330,7 +44329,7 @@ let SwitchSelectorColor = /* @__PURE__ */ function(SwitchSelectorColor$1) {
|
|
|
44330
44329
|
SwitchSelectorColor$1["DARK"] = "dark";
|
|
44331
44330
|
SwitchSelectorColor$1["TEXT"] = "text";
|
|
44332
44331
|
return SwitchSelectorColor$1;
|
|
44333
|
-
}({});
|
|
44332
|
+
})({});
|
|
44334
44333
|
const switchSelectorVariant = cva("flex w-fit cursor-pointer flex-row gap-2 rounded-full border-[1.5px] p-[1.5px]", {
|
|
44335
44334
|
variants: {
|
|
44336
44335
|
color: {
|
|
@@ -44347,12 +44346,12 @@ const switchSelectorVariant = cva("flex w-fit cursor-pointer flex-row gap-2 roun
|
|
|
44347
44346
|
color: `${SwitchSelectorColor.PRIMARY}`
|
|
44348
44347
|
}
|
|
44349
44348
|
});
|
|
44350
|
-
let SwitchSelectorSize = /* @__PURE__ */ function(SwitchSelectorSize$1) {
|
|
44349
|
+
let SwitchSelectorSize = /* @__PURE__ */ (function(SwitchSelectorSize$1) {
|
|
44351
44350
|
SwitchSelectorSize$1["SM"] = "sm";
|
|
44352
44351
|
SwitchSelectorSize$1["MD"] = "md";
|
|
44353
44352
|
SwitchSelectorSize$1["LG"] = "lg";
|
|
44354
44353
|
return SwitchSelectorSize$1;
|
|
44355
|
-
}({});
|
|
44354
|
+
})({});
|
|
44356
44355
|
const choiceVariant = cva("z-1 w-full flex-1 cursor-pointer font-medium text-sm transition-all duration-300 ease-in-out aria-selected:cursor-default data-[indicator=true]:text-text-opposite motion-reduce:transition-none", {
|
|
44357
44356
|
variants: {
|
|
44358
44357
|
size: {
|
|
@@ -46910,36 +46909,36 @@ function i(r2, e) {
|
|
|
46910
46909
|
return n2;
|
|
46911
46910
|
}
|
|
46912
46911
|
function a(o$1, a2, u2) {
|
|
46913
|
-
if (void 0 === u2 && (u2 = {}), function(r2) {
|
|
46912
|
+
if (void 0 === u2 && (u2 = {}), (function(r2) {
|
|
46914
46913
|
return "_def" in r2 && "object" == typeof r2._def && "typeName" in r2._def;
|
|
46915
|
-
}(o$1)) return function(n2, i2, c) {
|
|
46914
|
+
})(o$1)) return function(n2, i2, c) {
|
|
46916
46915
|
try {
|
|
46917
46916
|
return Promise.resolve(t(function() {
|
|
46918
46917
|
return Promise.resolve(o$1["sync" === u2.mode ? "parse" : "parseAsync"](n2, a2)).then(function(e) {
|
|
46919
46918
|
return c.shouldUseNativeValidation && o({}, c), { errors: {}, values: u2.raw ? Object.assign({}, n2) : e };
|
|
46920
46919
|
});
|
|
46921
46920
|
}, function(r2) {
|
|
46922
|
-
if (function(r3) {
|
|
46921
|
+
if ((function(r3) {
|
|
46923
46922
|
return Array.isArray(null == r3 ? void 0 : r3.issues);
|
|
46924
|
-
}(r2)) return { values: {}, errors: s$1(s(r2.errors, !c.shouldUseNativeValidation && "all" === c.criteriaMode), c) };
|
|
46923
|
+
})(r2)) return { values: {}, errors: s$1(s(r2.errors, !c.shouldUseNativeValidation && "all" === c.criteriaMode), c) };
|
|
46925
46924
|
throw r2;
|
|
46926
46925
|
}));
|
|
46927
46926
|
} catch (r2) {
|
|
46928
46927
|
return Promise.reject(r2);
|
|
46929
46928
|
}
|
|
46930
46929
|
};
|
|
46931
|
-
if (function(r2) {
|
|
46930
|
+
if ((function(r2) {
|
|
46932
46931
|
return "_zod" in r2 && "object" == typeof r2._zod;
|
|
46933
|
-
}(o$1)) return function(s2, c, f) {
|
|
46932
|
+
})(o$1)) return function(s2, c, f) {
|
|
46934
46933
|
try {
|
|
46935
46934
|
return Promise.resolve(t(function() {
|
|
46936
46935
|
return Promise.resolve(("sync" === u2.mode ? parse$2 : parseAsync$1)(o$1, s2, a2)).then(function(e) {
|
|
46937
46936
|
return f.shouldUseNativeValidation && o({}, f), { errors: {}, values: u2.raw ? Object.assign({}, s2) : e };
|
|
46938
46937
|
});
|
|
46939
46938
|
}, function(r2) {
|
|
46940
|
-
if (function(r3) {
|
|
46939
|
+
if ((function(r3) {
|
|
46941
46940
|
return r3 instanceof $ZodError;
|
|
46942
|
-
}(r2)) return { values: {}, errors: s$1(i(r2.issues, !f.shouldUseNativeValidation && "all" === f.criteriaMode), f) };
|
|
46941
|
+
})(r2)) return { values: {}, errors: s$1(i(r2.issues, !f.shouldUseNativeValidation && "all" === f.criteriaMode), f) };
|
|
46943
46942
|
throw r2;
|
|
46944
46943
|
}));
|
|
46945
46944
|
} catch (r2) {
|
|
@@ -48315,10 +48314,10 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
48315
48314
|
};
|
|
48316
48315
|
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
48317
48316
|
inst.brand = () => inst;
|
|
48318
|
-
inst.register = (reg, meta) => {
|
|
48317
|
+
inst.register = ((reg, meta) => {
|
|
48319
48318
|
reg.add(inst, meta);
|
|
48320
48319
|
return inst;
|
|
48321
|
-
};
|
|
48320
|
+
});
|
|
48322
48321
|
inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
|
|
48323
48322
|
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
48324
48323
|
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
@@ -48814,11 +48813,11 @@ const Trigger = ({
|
|
|
48814
48813
|
...props,
|
|
48815
48814
|
children
|
|
48816
48815
|
});
|
|
48817
|
-
let DropDownAlign = /* @__PURE__ */ function(DropDownAlign$1) {
|
|
48816
|
+
let DropDownAlign = /* @__PURE__ */ (function(DropDownAlign$1) {
|
|
48818
48817
|
DropDownAlign$1["START"] = "start";
|
|
48819
48818
|
DropDownAlign$1["END"] = "end";
|
|
48820
48819
|
return DropDownAlign$1;
|
|
48821
|
-
}({});
|
|
48820
|
+
})({});
|
|
48822
48821
|
const Panel = ({
|
|
48823
48822
|
children,
|
|
48824
48823
|
isHidden: isHidden2 = void 0,
|
|
@@ -49437,7 +49436,7 @@ function createPatternAlphabet(pattern) {
|
|
|
49437
49436
|
}
|
|
49438
49437
|
return mask;
|
|
49439
49438
|
}
|
|
49440
|
-
const stripDiacritics = String.prototype.normalize ? (str) => str.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "") : (str) => str;
|
|
49439
|
+
const stripDiacritics = String.prototype.normalize ? ((str) => str.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "")) : ((str) => str);
|
|
49441
49440
|
class BitapSearch {
|
|
49442
49441
|
constructor(pattern, {
|
|
49443
49442
|
location = Config.location,
|
|
@@ -50472,7 +50471,7 @@ const CodeDefault = ({
|
|
|
50472
50471
|
})
|
|
50473
50472
|
})
|
|
50474
50473
|
});
|
|
50475
|
-
const CodeBlockShiki = reactExports.lazy(() => __vitePreload(() => import("./CodeBlockShiki-
|
|
50474
|
+
const CodeBlockShiki = reactExports.lazy(() => __vitePreload(() => import("./CodeBlockShiki-B4oIr_Ja.js"), true ? [] : void 0).then((mod) => ({
|
|
50476
50475
|
default: mod.CodeBlockShiki
|
|
50477
50476
|
})));
|
|
50478
50477
|
const CodeBlock = ({
|
|
@@ -50497,16 +50496,16 @@ const CodeBlock = ({
|
|
|
50497
50496
|
})
|
|
50498
50497
|
})
|
|
50499
50498
|
});
|
|
50500
|
-
let PopoverXAlign = /* @__PURE__ */ function(PopoverXAlign$1) {
|
|
50499
|
+
let PopoverXAlign = /* @__PURE__ */ (function(PopoverXAlign$1) {
|
|
50501
50500
|
PopoverXAlign$1["START"] = "start";
|
|
50502
50501
|
PopoverXAlign$1["END"] = "end";
|
|
50503
50502
|
return PopoverXAlign$1;
|
|
50504
|
-
}({});
|
|
50505
|
-
let PopoverYAlign = /* @__PURE__ */ function(PopoverYAlign$1) {
|
|
50503
|
+
})({});
|
|
50504
|
+
let PopoverYAlign = /* @__PURE__ */ (function(PopoverYAlign$1) {
|
|
50506
50505
|
PopoverYAlign$1["BELOW"] = "bellow";
|
|
50507
50506
|
PopoverYAlign$1["ABOVE"] = "above";
|
|
50508
50507
|
return PopoverYAlign$1;
|
|
50509
|
-
}({});
|
|
50508
|
+
})({});
|
|
50510
50509
|
const PopoverStatic = ({
|
|
50511
50510
|
children,
|
|
50512
50511
|
className,
|
|
@@ -50866,7 +50865,7 @@ const Code = ({
|
|
|
50866
50865
|
})
|
|
50867
50866
|
});
|
|
50868
50867
|
};
|
|
50869
|
-
let TabSelectorColor = /* @__PURE__ */ function(TabSelectorColor$1) {
|
|
50868
|
+
let TabSelectorColor = /* @__PURE__ */ (function(TabSelectorColor$1) {
|
|
50870
50869
|
TabSelectorColor$1["PRIMARY"] = "primary";
|
|
50871
50870
|
TabSelectorColor$1["SECONDARY"] = "secondary";
|
|
50872
50871
|
TabSelectorColor$1["DESTRUCTIVE"] = "destructive";
|
|
@@ -50875,7 +50874,7 @@ let TabSelectorColor = /* @__PURE__ */ function(TabSelectorColor$1) {
|
|
|
50875
50874
|
TabSelectorColor$1["DARK"] = "dark";
|
|
50876
50875
|
TabSelectorColor$1["TEXT"] = "text";
|
|
50877
50876
|
return TabSelectorColor$1;
|
|
50878
|
-
}({});
|
|
50877
|
+
})({});
|
|
50879
50878
|
const tabSelectorVariant = cva("relative flex size-full flex-row items-center gap-2", {
|
|
50880
50879
|
variants: {
|
|
50881
50880
|
color: {
|
|
@@ -50892,7 +50891,7 @@ const tabSelectorVariant = cva("relative flex size-full flex-row items-center ga
|
|
|
50892
50891
|
color: "primary"
|
|
50893
50892
|
}
|
|
50894
50893
|
});
|
|
50895
|
-
const indicatorVariant = cva("absolute
|
|
50894
|
+
const indicatorVariant = cva("absolute z-[-1] rounded-lg duration-300 ease-in-out motion-reduce:transition-none", {
|
|
50896
50895
|
variants: {
|
|
50897
50896
|
color: {
|
|
50898
50897
|
primary: "bg-primary/10 aria-selected:text-text",
|
|
@@ -50902,7 +50901,14 @@ const indicatorVariant = cva("absolute top-0 z-[-1] h-full w-auto rounded-lg tra
|
|
|
50902
50901
|
light: "bg-white/10 aria-selected:text-black",
|
|
50903
50902
|
dark: "bg-neutral-800/10 aria-selected:text-white",
|
|
50904
50903
|
text: "bg-text/10 aria-selected:text-text-opposite"
|
|
50904
|
+
},
|
|
50905
|
+
orientation: {
|
|
50906
|
+
horizontal: "top-0 h-full w-auto transition-[left,width]",
|
|
50907
|
+
vertical: "left-0 h-auto w-full transition-[top,height]"
|
|
50905
50908
|
}
|
|
50909
|
+
},
|
|
50910
|
+
defaultVariants: {
|
|
50911
|
+
orientation: "horizontal"
|
|
50906
50912
|
}
|
|
50907
50913
|
});
|
|
50908
50914
|
const TabSelector = ({
|
|
@@ -50911,6 +50917,7 @@ const TabSelector = ({
|
|
|
50911
50917
|
onTabClick,
|
|
50912
50918
|
color: color2 = TabSelectorColor.PRIMARY,
|
|
50913
50919
|
hoverable = false,
|
|
50920
|
+
orientation = "horizontal",
|
|
50914
50921
|
className
|
|
50915
50922
|
}) => {
|
|
50916
50923
|
const optionsRefs = reactExports.useRef([]);
|
|
@@ -50919,7 +50926,8 @@ const TabSelector = ({
|
|
|
50919
50926
|
choiceIndicatorPosition,
|
|
50920
50927
|
calculatePosition
|
|
50921
50928
|
} = useItemSelector(optionsRefs, {
|
|
50922
|
-
isHoverable: hoverable
|
|
50929
|
+
isHoverable: hoverable,
|
|
50930
|
+
orientation
|
|
50923
50931
|
});
|
|
50924
50932
|
reactExports.useEffect(() => {
|
|
50925
50933
|
calculatePosition();
|
|
@@ -50928,7 +50936,7 @@ const TabSelector = ({
|
|
|
50928
50936
|
className: cn$2(tabSelectorVariant({
|
|
50929
50937
|
color: color2
|
|
50930
50938
|
}), className),
|
|
50931
|
-
"aria-orientation":
|
|
50939
|
+
"aria-orientation": orientation,
|
|
50932
50940
|
"aria-multiselectable": "false",
|
|
50933
50941
|
role: "tablist",
|
|
50934
50942
|
children: [tabs.map((Tab2, index2) => {
|
|
@@ -50950,7 +50958,8 @@ const TabSelector = ({
|
|
|
50950
50958
|
});
|
|
50951
50959
|
}), choiceIndicatorPosition && /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
|
|
50952
50960
|
className: cn$2(indicatorVariant({
|
|
50953
|
-
color: color2
|
|
50961
|
+
color: color2,
|
|
50962
|
+
orientation
|
|
50954
50963
|
})),
|
|
50955
50964
|
style: choiceIndicatorPosition,
|
|
50956
50965
|
ref: indicatorRef
|
|
@@ -53479,11 +53488,11 @@ const ObjectTextEditor = ({
|
|
|
53479
53488
|
})
|
|
53480
53489
|
})
|
|
53481
53490
|
});
|
|
53482
|
-
var MarkdownViewMode = /* @__PURE__ */ function(MarkdownViewMode$1) {
|
|
53491
|
+
var MarkdownViewMode = /* @__PURE__ */ (function(MarkdownViewMode$1) {
|
|
53483
53492
|
MarkdownViewMode$1[MarkdownViewMode$1["Edit"] = 0] = "Edit";
|
|
53484
53493
|
MarkdownViewMode$1[MarkdownViewMode$1["Preview"] = 1] = "Preview";
|
|
53485
53494
|
return MarkdownViewMode$1;
|
|
53486
|
-
}(MarkdownViewMode || {});
|
|
53495
|
+
})(MarkdownViewMode || {});
|
|
53487
53496
|
const MarkdownTextEditor = ({
|
|
53488
53497
|
section,
|
|
53489
53498
|
keyPath,
|
|
@@ -55297,13 +55306,13 @@ const StructureEditor = ({
|
|
|
55297
55306
|
dictionaryLocalId: localId
|
|
55298
55307
|
});
|
|
55299
55308
|
};
|
|
55300
|
-
var EditorViewType = /* @__PURE__ */ function(EditorViewType$1) {
|
|
55309
|
+
var EditorViewType = /* @__PURE__ */ (function(EditorViewType$1) {
|
|
55301
55310
|
EditorViewType$1[EditorViewType$1["DetailsEditor"] = 0] = "DetailsEditor";
|
|
55302
55311
|
EditorViewType$1[EditorViewType$1["ContentEditor"] = 1] = "ContentEditor";
|
|
55303
55312
|
EditorViewType$1[EditorViewType$1["StructureEditor"] = 2] = "StructureEditor";
|
|
55304
55313
|
EditorViewType$1[EditorViewType$1["JSONEditor"] = 3] = "JSONEditor";
|
|
55305
55314
|
return EditorViewType$1;
|
|
55306
|
-
}(EditorViewType || {});
|
|
55315
|
+
})(EditorViewType || {});
|
|
55307
55316
|
const DictionaryFieldEditor = ({
|
|
55308
55317
|
dictionary,
|
|
55309
55318
|
onClickDictionaryList,
|
|
@@ -55616,7 +55625,7 @@ const RightDrawer = ({
|
|
|
55616
55625
|
})
|
|
55617
55626
|
});
|
|
55618
55627
|
};
|
|
55619
|
-
let TagRoundedSize = /* @__PURE__ */ function(TagRoundedSize$1) {
|
|
55628
|
+
let TagRoundedSize = /* @__PURE__ */ (function(TagRoundedSize$1) {
|
|
55620
55629
|
TagRoundedSize$1["NONE"] = "none";
|
|
55621
55630
|
TagRoundedSize$1["SM"] = "sm";
|
|
55622
55631
|
TagRoundedSize$1["MD"] = "md";
|
|
@@ -55626,8 +55635,8 @@ let TagRoundedSize = /* @__PURE__ */ function(TagRoundedSize$1) {
|
|
|
55626
55635
|
TagRoundedSize$1["XXXL"] = "3xl";
|
|
55627
55636
|
TagRoundedSize$1["FULL"] = "full";
|
|
55628
55637
|
return TagRoundedSize$1;
|
|
55629
|
-
}({});
|
|
55630
|
-
let TagColor = /* @__PURE__ */ function(TagColor$1) {
|
|
55638
|
+
})({});
|
|
55639
|
+
let TagColor = /* @__PURE__ */ (function(TagColor$1) {
|
|
55631
55640
|
TagColor$1["SUCCESS"] = "success";
|
|
55632
55641
|
TagColor$1["ERROR"] = "error";
|
|
55633
55642
|
TagColor$1["WARNING"] = "warning";
|
|
@@ -55645,25 +55654,25 @@ let TagColor = /* @__PURE__ */ function(TagColor$1) {
|
|
|
55645
55654
|
TagColor$1["BLACK"] = "black";
|
|
55646
55655
|
TagColor$1["WHITE"] = "white";
|
|
55647
55656
|
return TagColor$1;
|
|
55648
|
-
}({});
|
|
55649
|
-
let TagSize = /* @__PURE__ */ function(TagSize$1) {
|
|
55657
|
+
})({});
|
|
55658
|
+
let TagSize = /* @__PURE__ */ (function(TagSize$1) {
|
|
55650
55659
|
TagSize$1["XS"] = "xs";
|
|
55651
55660
|
TagSize$1["SM"] = "sm";
|
|
55652
55661
|
TagSize$1["MD"] = "md";
|
|
55653
55662
|
TagSize$1["LG"] = "lg";
|
|
55654
55663
|
TagSize$1["XL"] = "xl";
|
|
55655
55664
|
return TagSize$1;
|
|
55656
|
-
}({});
|
|
55657
|
-
let TagBorder = /* @__PURE__ */ function(TagBorder$1) {
|
|
55665
|
+
})({});
|
|
55666
|
+
let TagBorder = /* @__PURE__ */ (function(TagBorder$1) {
|
|
55658
55667
|
TagBorder$1["NONE"] = "none";
|
|
55659
55668
|
TagBorder$1["WITH"] = "with";
|
|
55660
55669
|
return TagBorder$1;
|
|
55661
|
-
}({});
|
|
55662
|
-
let TagBackground = /* @__PURE__ */ function(TagBackground$1) {
|
|
55670
|
+
})({});
|
|
55671
|
+
let TagBackground = /* @__PURE__ */ (function(TagBackground$1) {
|
|
55663
55672
|
TagBackground$1["NONE"] = "none";
|
|
55664
55673
|
TagBackground$1["WITH"] = "with";
|
|
55665
55674
|
return TagBackground$1;
|
|
55666
|
-
}({});
|
|
55675
|
+
})({});
|
|
55667
55676
|
const containerVariants = cva("w-fit backdrop-blur", {
|
|
55668
55677
|
variants: {
|
|
55669
55678
|
roundedSize: {
|
|
@@ -56426,13 +56435,13 @@ const ToastDescription = ({
|
|
|
56426
56435
|
});
|
|
56427
56436
|
const TOAST_LIMIT = 1;
|
|
56428
56437
|
const TOAST_REMOVE_DELAY = 900 * 1e3;
|
|
56429
|
-
var ActionTypes = /* @__PURE__ */ function(ActionTypes$1) {
|
|
56438
|
+
var ActionTypes = /* @__PURE__ */ (function(ActionTypes$1) {
|
|
56430
56439
|
ActionTypes$1["ADD_TOAST"] = "ADD_TOAST";
|
|
56431
56440
|
ActionTypes$1["UPDATE_TOAST"] = "UPDATE_TOAST";
|
|
56432
56441
|
ActionTypes$1["DISMISS_TOAST"] = "DISMISS_TOAST";
|
|
56433
56442
|
ActionTypes$1["REMOVE_TOAST"] = "REMOVE_TOAST";
|
|
56434
56443
|
return ActionTypes$1;
|
|
56435
|
-
}(ActionTypes || {});
|
|
56444
|
+
})(ActionTypes || {});
|
|
56436
56445
|
let count = 0;
|
|
56437
56446
|
const genId = () => {
|
|
56438
56447
|
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|