mogh_ui 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs +156 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +50 -0
- package/dist/auth/index.d.ts +50 -0
- package/dist/auth/index.js +115 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/login/header.cjs +74 -0
- package/dist/auth/login/header.cjs.map +1 -0
- package/dist/auth/login/header.d.cts +8 -0
- package/dist/auth/login/header.d.ts +8 -0
- package/dist/auth/login/header.js +60 -0
- package/dist/auth/login/header.js.map +1 -0
- package/dist/auth/login/index.cjs +245 -0
- package/dist/auth/login/index.cjs.map +1 -0
- package/dist/auth/login/index.d.cts +15 -0
- package/dist/auth/login/index.d.ts +15 -0
- package/dist/auth/login/index.js +220 -0
- package/dist/auth/login/index.js.map +1 -0
- package/dist/auth/profile/index.cjs +27 -0
- package/dist/auth/profile/index.cjs.map +1 -0
- package/dist/auth/profile/index.d.cts +5 -0
- package/dist/auth/profile/index.d.ts +5 -0
- package/dist/auth/profile/index.js +4 -0
- package/dist/auth/profile/index.js.map +1 -0
- package/dist/auth/profile/linked-logins.cjs +177 -0
- package/dist/auth/profile/linked-logins.cjs.map +1 -0
- package/dist/auth/profile/linked-logins.d.cts +13 -0
- package/dist/auth/profile/linked-logins.d.ts +13 -0
- package/dist/auth/profile/linked-logins.js +150 -0
- package/dist/auth/profile/linked-logins.js.map +1 -0
- package/dist/auth/profile/passkey.cjs +109 -0
- package/dist/auth/profile/passkey.cjs.map +1 -0
- package/dist/auth/profile/passkey.d.cts +9 -0
- package/dist/auth/profile/passkey.d.ts +9 -0
- package/dist/auth/profile/passkey.js +75 -0
- package/dist/auth/profile/passkey.js.map +1 -0
- package/dist/auth/profile/totp.cjs +147 -0
- package/dist/auth/profile/totp.cjs.map +1 -0
- package/dist/auth/profile/totp.d.cts +9 -0
- package/dist/auth/profile/totp.d.ts +9 -0
- package/dist/auth/profile/totp.js +131 -0
- package/dist/auth/profile/totp.js.map +1 -0
- package/dist/auth/utils.cjs +42 -0
- package/dist/auth/utils.cjs.map +1 -0
- package/dist/auth/utils.d.cts +4 -0
- package/dist/auth/utils.d.ts +4 -0
- package/dist/auth/utils.js +17 -0
- package/dist/auth/utils.js.map +1 -0
- package/dist/components/page-guard.d.cts +2 -2
- package/dist/components/page-guard.d.ts +2 -2
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +12 -4
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.d.cts +7 -4
- package/dist/theme.d.ts +7 -4
- package/dist/theme.js +12 -4
- package/dist/theme.js.map +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var totp_exports = {};
|
|
20
|
+
__export(totp_exports, {
|
|
21
|
+
EnrollTotp: () => EnrollTotp
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(totp_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_core = require("@mantine/core");
|
|
26
|
+
var import_notifications = require("@mantine/notifications");
|
|
27
|
+
var import_lucide_react = require("lucide-react");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import__ = require("../..");
|
|
30
|
+
const EnrollTotp = ({
|
|
31
|
+
userInvalidate,
|
|
32
|
+
passkeyEnrolled,
|
|
33
|
+
totpEnrolled
|
|
34
|
+
}) => {
|
|
35
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
36
|
+
const [submitted, setSubmitted] = (0, import_react.useState)();
|
|
37
|
+
const [confirm, setConfirm] = (0, import_react.useState)("");
|
|
38
|
+
const [recovery, setRecovery] = (0, import_react.useState)(void 0);
|
|
39
|
+
const { mutate: beginEnrollment } = (0, import__.useManageAuth)("BeginTotpEnrollment", {
|
|
40
|
+
onSuccess: ({ uri, png }) => setSubmitted({ uri, png })
|
|
41
|
+
});
|
|
42
|
+
const { mutate: confirmEnrollment, isPending: confirmPending } = (0, import__.useManageAuth)("ConfirmTotpEnrollment", {
|
|
43
|
+
onSuccess: ({ recovery_codes }) => {
|
|
44
|
+
setRecovery(recovery_codes);
|
|
45
|
+
userInvalidate?.();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const { mutateAsync: unenroll, isPending: unenrollPending } = (0, import__.useManageAuth)(
|
|
49
|
+
"UnenrollTotp",
|
|
50
|
+
{
|
|
51
|
+
onSuccess: () => {
|
|
52
|
+
userInvalidate?.();
|
|
53
|
+
import_notifications.notifications.show({
|
|
54
|
+
message: "Unenrolled in TOTP 2FA.",
|
|
55
|
+
color: "green"
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
const onOpenChange = (open2) => {
|
|
61
|
+
setOpen(open2);
|
|
62
|
+
if (open2) {
|
|
63
|
+
beginEnrollment({});
|
|
64
|
+
} else {
|
|
65
|
+
setSubmitted(void 0);
|
|
66
|
+
setRecovery(void 0);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
70
|
+
!totpEnrolled && !passkeyEnrolled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
71
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Modal, { opened: open, onClose: () => onOpenChange(false), children: [
|
|
72
|
+
recovery && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Flex, { direction: "column", gap: "lg", children: [
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Text, { size: "lg", children: "Save recovery keys" }),
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Flex, { direction: "column", gap: "sm", children: recovery.map((code) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.TextInput, { w: 200, value: code, disabled: true }, code)) }),
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.CopyButton, { content: recovery.join("\n") })
|
|
76
|
+
] }),
|
|
77
|
+
!recovery && submitted && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Flex, { direction: "column", gap: "lg", children: [
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Text, { size: "lg", children: "Scan this QR code with your authenticator app, and enter the 6 digit code below." }),
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Center, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
80
|
+
"img",
|
|
81
|
+
{
|
|
82
|
+
width: 250,
|
|
83
|
+
height: 250,
|
|
84
|
+
src: "data:image/png;base64," + submitted.png,
|
|
85
|
+
alt: "QRCode"
|
|
86
|
+
}
|
|
87
|
+
) }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Flex, { align: "center", justify: "space-between", gap: "sm", children: [
|
|
89
|
+
"URI",
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.TextInput, { w: 250, value: submitted.uri, disabled: true }),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.CopyButton, { content: submitted.uri })
|
|
92
|
+
] }),
|
|
93
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Flex, { align: "center", justify: "space-between", children: [
|
|
94
|
+
"Confirm Code",
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
+
import_core.TextInput,
|
|
97
|
+
{
|
|
98
|
+
w: 250,
|
|
99
|
+
value: confirm,
|
|
100
|
+
onChange: (e) => setConfirm(e.target.value),
|
|
101
|
+
autoFocus: true
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] }),
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Flex, { justify: "flex-end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
import_core.Button,
|
|
107
|
+
{
|
|
108
|
+
onClick: () => confirmEnrollment({ code: confirm }),
|
|
109
|
+
disabled: confirm.length !== 6 || confirmPending,
|
|
110
|
+
leftSection: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Check, { size: "1rem" }),
|
|
111
|
+
loading: confirmPending,
|
|
112
|
+
children: "Confirm"
|
|
113
|
+
}
|
|
114
|
+
) })
|
|
115
|
+
] }),
|
|
116
|
+
!recovery && !submitted && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Center, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Loader, {}) })
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
|
+
import_core.Button,
|
|
120
|
+
{
|
|
121
|
+
leftSection: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.RotateCcwKey, { size: "1rem" }),
|
|
122
|
+
variant: "default",
|
|
123
|
+
onClick: () => onOpenChange(true),
|
|
124
|
+
w: 220,
|
|
125
|
+
children: "Enroll TOTP 2FA"
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] }),
|
|
129
|
+
totpEnrolled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
+
import__.ConfirmModal,
|
|
131
|
+
{
|
|
132
|
+
confirmText: "Unenroll",
|
|
133
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Trash, { size: "1rem" }),
|
|
134
|
+
loading: unenrollPending,
|
|
135
|
+
onConfirm: () => unenroll({}),
|
|
136
|
+
targetProps: { c: "bw", w: 220 },
|
|
137
|
+
confirmProps: { variant: "filled", color: "red" },
|
|
138
|
+
children: "Unenroll TOTP 2FA"
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
] });
|
|
142
|
+
};
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
EnrollTotp
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=totp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/profile/totp.tsx"],"sourcesContent":["import {\n Button,\n Center,\n Flex,\n Loader,\n Modal,\n Text,\n TextInput,\n} from \"@mantine/core\";\nimport { notifications } from \"@mantine/notifications\";\nimport { Check, RotateCcwKey, Trash } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { ConfirmModal, CopyButton, useManageAuth } from \"../..\";\n\nexport const EnrollTotp = ({\n userInvalidate,\n passkeyEnrolled,\n totpEnrolled,\n}: {\n userInvalidate?: () => void;\n passkeyEnrolled?: boolean;\n totpEnrolled?: boolean;\n}) => {\n const [open, setOpen] = useState(false);\n const [submitted, setSubmitted] = useState<{ uri: string; png: string }>();\n const [confirm, setConfirm] = useState(\"\");\n const [recovery, setRecovery] = useState<string[] | undefined>(undefined);\n\n const { mutate: beginEnrollment } = useManageAuth(\"BeginTotpEnrollment\", {\n onSuccess: ({ uri, png }) => setSubmitted({ uri, png }),\n });\n\n const { mutate: confirmEnrollment, isPending: confirmPending } =\n useManageAuth(\"ConfirmTotpEnrollment\", {\n onSuccess: ({ recovery_codes }) => {\n setRecovery(recovery_codes);\n userInvalidate?.();\n },\n });\n\n const { mutateAsync: unenroll, isPending: unenrollPending } = useManageAuth(\n \"UnenrollTotp\",\n {\n onSuccess: () => {\n userInvalidate?.();\n notifications.show({\n message: \"Unenrolled in TOTP 2FA.\",\n color: \"green\",\n });\n },\n },\n );\n\n const onOpenChange = (open: boolean) => {\n setOpen(open);\n if (open) {\n beginEnrollment({});\n } else {\n setSubmitted(undefined);\n setRecovery(undefined);\n }\n };\n\n return (\n <>\n {!totpEnrolled && !passkeyEnrolled && (\n <>\n <Modal opened={open} onClose={() => onOpenChange(false)}>\n {recovery && (\n <Flex direction=\"column\" gap=\"lg\">\n <Text size=\"lg\">Save recovery keys</Text>\n <Flex direction=\"column\" gap=\"sm\">\n {recovery.map((code) => (\n <TextInput key={code} w={200} value={code} disabled />\n ))}\n </Flex>\n <CopyButton content={recovery.join(\"\\n\")} />\n </Flex>\n )}\n {!recovery && submitted && (\n <Flex direction=\"column\" gap=\"lg\">\n <Text size=\"lg\">\n Scan this QR code with your authenticator app, and enter the 6\n digit code below.\n </Text>\n <Center>\n <img\n width={250}\n height={250}\n src={\"data:image/png;base64,\" + submitted.png}\n alt=\"QRCode\"\n />\n </Center>\n <Flex align=\"center\" justify=\"space-between\" gap=\"sm\">\n URI\n <TextInput w={250} value={submitted.uri} disabled />\n <CopyButton content={submitted.uri} />\n </Flex>\n <Flex align=\"center\" justify=\"space-between\">\n Confirm Code\n <TextInput\n w={250}\n value={confirm}\n onChange={(e) => setConfirm(e.target.value)}\n autoFocus\n />\n </Flex>\n <Flex justify=\"flex-end\">\n <Button\n onClick={() => confirmEnrollment({ code: confirm })}\n disabled={confirm.length !== 6 || confirmPending}\n leftSection={<Check size=\"1rem\" />}\n loading={confirmPending}\n >\n Confirm\n </Button>\n </Flex>\n </Flex>\n )}\n {!recovery && !submitted && (\n <Center>\n <Loader />\n </Center>\n )}\n </Modal>\n <Button\n leftSection={<RotateCcwKey size=\"1rem\" />}\n variant=\"default\"\n onClick={() => onOpenChange(true)}\n w={220}\n >\n Enroll TOTP 2FA\n </Button>\n </>\n )}\n {totpEnrolled && (\n <ConfirmModal\n confirmText=\"Unenroll\"\n icon={<Trash size=\"1rem\" />}\n loading={unenrollPending}\n onConfirm={() => unenroll({})}\n targetProps={{ c: \"bw\", w: 220 }}\n confirmProps={{ variant: \"filled\", color: \"red\" }}\n >\n Unenroll TOTP 2FA\n </ConfirmModal>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkEQ;AAlER,kBAQO;AACP,2BAA8B;AAC9B,0BAA2C;AAC3C,mBAAyB;AACzB,eAAwD;AAEjD,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,MAIM;AACJ,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAuC;AACzE,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,EAAE;AACzC,QAAM,CAAC,UAAU,WAAW,QAAI,uBAA+B,MAAS;AAExE,QAAM,EAAE,QAAQ,gBAAgB,QAAI,wBAAc,uBAAuB;AAAA,IACvE,WAAW,CAAC,EAAE,KAAK,IAAI,MAAM,aAAa,EAAE,KAAK,IAAI,CAAC;AAAA,EACxD,CAAC;AAED,QAAM,EAAE,QAAQ,mBAAmB,WAAW,eAAe,QAC3D,wBAAc,yBAAyB;A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
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
declare const EnrollTotp: ({ userInvalidate, passkeyEnrolled, totpEnrolled, }: {
|
|
4
|
+
userInvalidate?: () => void;
|
|
5
|
+
passkeyEnrolled?: boolean;
|
|
6
|
+
totpEnrolled?: boolean;
|
|
7
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { EnrollTotp };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
declare const EnrollTotp: ({ userInvalidate, passkeyEnrolled, totpEnrolled, }: {
|
|
4
|
+
userInvalidate?: () => void;
|
|
5
|
+
passkeyEnrolled?: boolean;
|
|
6
|
+
totpEnrolled?: boolean;
|
|
7
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { EnrollTotp };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Center,
|
|
5
|
+
Flex,
|
|
6
|
+
Loader,
|
|
7
|
+
Modal,
|
|
8
|
+
Text,
|
|
9
|
+
TextInput
|
|
10
|
+
} from "@mantine/core";
|
|
11
|
+
import { notifications } from "@mantine/notifications";
|
|
12
|
+
import { Check, RotateCcwKey, Trash } from "lucide-react";
|
|
13
|
+
import { useState } from "react";
|
|
14
|
+
import { ConfirmModal, CopyButton, useManageAuth } from "../..";
|
|
15
|
+
const EnrollTotp = ({
|
|
16
|
+
userInvalidate,
|
|
17
|
+
passkeyEnrolled,
|
|
18
|
+
totpEnrolled
|
|
19
|
+
}) => {
|
|
20
|
+
const [open, setOpen] = useState(false);
|
|
21
|
+
const [submitted, setSubmitted] = useState();
|
|
22
|
+
const [confirm, setConfirm] = useState("");
|
|
23
|
+
const [recovery, setRecovery] = useState(void 0);
|
|
24
|
+
const { mutate: beginEnrollment } = useManageAuth("BeginTotpEnrollment", {
|
|
25
|
+
onSuccess: ({ uri, png }) => setSubmitted({ uri, png })
|
|
26
|
+
});
|
|
27
|
+
const { mutate: confirmEnrollment, isPending: confirmPending } = useManageAuth("ConfirmTotpEnrollment", {
|
|
28
|
+
onSuccess: ({ recovery_codes }) => {
|
|
29
|
+
setRecovery(recovery_codes);
|
|
30
|
+
userInvalidate?.();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const { mutateAsync: unenroll, isPending: unenrollPending } = useManageAuth(
|
|
34
|
+
"UnenrollTotp",
|
|
35
|
+
{
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
userInvalidate?.();
|
|
38
|
+
notifications.show({
|
|
39
|
+
message: "Unenrolled in TOTP 2FA.",
|
|
40
|
+
color: "green"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
const onOpenChange = (open2) => {
|
|
46
|
+
setOpen(open2);
|
|
47
|
+
if (open2) {
|
|
48
|
+
beginEnrollment({});
|
|
49
|
+
} else {
|
|
50
|
+
setSubmitted(void 0);
|
|
51
|
+
setRecovery(void 0);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
+
!totpEnrolled && !passkeyEnrolled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56
|
+
/* @__PURE__ */ jsxs(Modal, { opened: open, onClose: () => onOpenChange(false), children: [
|
|
57
|
+
recovery && /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "lg", children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", children: "Save recovery keys" }),
|
|
59
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", gap: "sm", children: recovery.map((code) => /* @__PURE__ */ jsx(TextInput, { w: 200, value: code, disabled: true }, code)) }),
|
|
60
|
+
/* @__PURE__ */ jsx(CopyButton, { content: recovery.join("\n") })
|
|
61
|
+
] }),
|
|
62
|
+
!recovery && submitted && /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "lg", children: [
|
|
63
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", children: "Scan this QR code with your authenticator app, and enter the 6 digit code below." }),
|
|
64
|
+
/* @__PURE__ */ jsx(Center, { children: /* @__PURE__ */ jsx(
|
|
65
|
+
"img",
|
|
66
|
+
{
|
|
67
|
+
width: 250,
|
|
68
|
+
height: 250,
|
|
69
|
+
src: "data:image/png;base64," + submitted.png,
|
|
70
|
+
alt: "QRCode"
|
|
71
|
+
}
|
|
72
|
+
) }),
|
|
73
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", gap: "sm", children: [
|
|
74
|
+
"URI",
|
|
75
|
+
/* @__PURE__ */ jsx(TextInput, { w: 250, value: submitted.uri, disabled: true }),
|
|
76
|
+
/* @__PURE__ */ jsx(CopyButton, { content: submitted.uri })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
79
|
+
"Confirm Code",
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
TextInput,
|
|
82
|
+
{
|
|
83
|
+
w: 250,
|
|
84
|
+
value: confirm,
|
|
85
|
+
onChange: (e) => setConfirm(e.target.value),
|
|
86
|
+
autoFocus: true
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsx(Flex, { justify: "flex-end", children: /* @__PURE__ */ jsx(
|
|
91
|
+
Button,
|
|
92
|
+
{
|
|
93
|
+
onClick: () => confirmEnrollment({ code: confirm }),
|
|
94
|
+
disabled: confirm.length !== 6 || confirmPending,
|
|
95
|
+
leftSection: /* @__PURE__ */ jsx(Check, { size: "1rem" }),
|
|
96
|
+
loading: confirmPending,
|
|
97
|
+
children: "Confirm"
|
|
98
|
+
}
|
|
99
|
+
) })
|
|
100
|
+
] }),
|
|
101
|
+
!recovery && !submitted && /* @__PURE__ */ jsx(Center, { children: /* @__PURE__ */ jsx(Loader, {}) })
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
Button,
|
|
105
|
+
{
|
|
106
|
+
leftSection: /* @__PURE__ */ jsx(RotateCcwKey, { size: "1rem" }),
|
|
107
|
+
variant: "default",
|
|
108
|
+
onClick: () => onOpenChange(true),
|
|
109
|
+
w: 220,
|
|
110
|
+
children: "Enroll TOTP 2FA"
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] }),
|
|
114
|
+
totpEnrolled && /* @__PURE__ */ jsx(
|
|
115
|
+
ConfirmModal,
|
|
116
|
+
{
|
|
117
|
+
confirmText: "Unenroll",
|
|
118
|
+
icon: /* @__PURE__ */ jsx(Trash, { size: "1rem" }),
|
|
119
|
+
loading: unenrollPending,
|
|
120
|
+
onConfirm: () => unenroll({}),
|
|
121
|
+
targetProps: { c: "bw", w: 220 },
|
|
122
|
+
confirmProps: { variant: "filled", color: "red" },
|
|
123
|
+
children: "Unenroll TOTP 2FA"
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
] });
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
EnrollTotp
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=totp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/profile/totp.tsx"],"sourcesContent":["import {\n Button,\n Center,\n Flex,\n Loader,\n Modal,\n Text,\n TextInput,\n} from \"@mantine/core\";\nimport { notifications } from \"@mantine/notifications\";\nimport { Check, RotateCcwKey, Trash } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { ConfirmModal, CopyButton, useManageAuth } from \"../..\";\n\nexport const EnrollTotp = ({\n userInvalidate,\n passkeyEnrolled,\n totpEnrolled,\n}: {\n userInvalidate?: () => void;\n passkeyEnrolled?: boolean;\n totpEnrolled?: boolean;\n}) => {\n const [open, setOpen] = useState(false);\n const [submitted, setSubmitted] = useState<{ uri: string; png: string }>();\n const [confirm, setConfirm] = useState(\"\");\n const [recovery, setRecovery] = useState<string[] | undefined>(undefined);\n\n const { mutate: beginEnrollment } = useManageAuth(\"BeginTotpEnrollment\", {\n onSuccess: ({ uri, png }) => setSubmitted({ uri, png }),\n });\n\n const { mutate: confirmEnrollment, isPending: confirmPending } =\n useManageAuth(\"ConfirmTotpEnrollment\", {\n onSuccess: ({ recovery_codes }) => {\n setRecovery(recovery_codes);\n userInvalidate?.();\n },\n });\n\n const { mutateAsync: unenroll, isPending: unenrollPending } = useManageAuth(\n \"UnenrollTotp\",\n {\n onSuccess: () => {\n userInvalidate?.();\n notifications.show({\n message: \"Unenrolled in TOTP 2FA.\",\n color: \"green\",\n });\n },\n },\n );\n\n const onOpenChange = (open: boolean) => {\n setOpen(open);\n if (open) {\n beginEnrollment({});\n } else {\n setSubmitted(undefined);\n setRecovery(undefined);\n }\n };\n\n return (\n <>\n {!totpEnrolled && !passkeyEnrolled && (\n <>\n <Modal opened={open} onClose={() => onOpenChange(false)}>\n {recovery && (\n <Flex direction=\"column\" gap=\"lg\">\n <Text size=\"lg\">Save recovery keys</Text>\n <Flex direction=\"column\" gap=\"sm\">\n {recovery.map((code) => (\n <TextInput key={code} w={200} value={code} disabled />\n ))}\n </Flex>\n <CopyButton content={recovery.join(\"\\n\")} />\n </Flex>\n )}\n {!recovery && submitted && (\n <Flex direction=\"column\" gap=\"lg\">\n <Text size=\"lg\">\n Scan this QR code with your authenticator app, and enter the 6\n digit code below.\n </Text>\n <Center>\n <img\n width={250}\n height={250}\n src={\"data:image/png;base64,\" + submitted.png}\n alt=\"QRCode\"\n />\n </Center>\n <Flex align=\"center\" justify=\"space-between\" gap=\"sm\">\n URI\n <TextInput w={250} value={submitted.uri} disabled />\n <CopyButton content={submitted.uri} />\n </Flex>\n <Flex align=\"center\" justify=\"space-between\">\n Confirm Code\n <TextInput\n w={250}\n value={confirm}\n onChange={(e) => setConfirm(e.target.value)}\n autoFocus\n />\n </Flex>\n <Flex justify=\"flex-end\">\n <Button\n onClick={() => confirmEnrollment({ code: confirm })}\n disabled={confirm.length !== 6 || confirmPending}\n leftSection={<Check size=\"1rem\" />}\n loading={confirmPending}\n >\n Confirm\n </Button>\n </Flex>\n </Flex>\n )}\n {!recovery && !submitted && (\n <Center>\n <Loader />\n </Center>\n )}\n </Modal>\n <Button\n leftSection={<RotateCcwKey size=\"1rem\" />}\n variant=\"default\"\n onClick={() => onOpenChange(true)}\n w={220}\n >\n Enroll TOTP 2FA\n </Button>\n </>\n )}\n {totpEnrolled && (\n <ConfirmModal\n confirmText=\"Unenroll\"\n icon={<Trash size=\"1rem\" />}\n loading={unenrollPending}\n onConfirm={() => unenroll({})}\n targetProps={{ c: \"bw\", w: 220 }}\n confirmProps={{ variant: \"filled\", color: \"red\" }}\n >\n Unenroll TOTP 2FA\n </ConfirmModal>\n )}\n </>\n );\n};\n"],"mappings":"AAkEQ,mBAIQ,KADF,YAHN;AAlER;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,OAAO,cAAc,aAAa;AAC3C,SAAS,gBAAgB;AACzB,SAAS,cAAc,YAAY,qBAAqB;AAEjD,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,MAIM;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAuC;AACzE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,EAAE;AACzC,QAAM,CAAC,UAAU,WAAW,IAAI,SAA+B,MAAS;AAExE,QAAM,EAAE,QAAQ,gBAAgB,IAAI,cAAc,uBAAuB;AAAA,IACvE,WAAW,CAAC,EAAE,KAAK,IAAI,MAAM,aAAa,EAAE,KAAK,IAAI,CAAC;AAAA,EACxD,CAAC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AEJ;AAEJ;","names":["open"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
sanitizeQuery: () => sanitizeQuery,
|
|
22
|
+
sanitizeQueryInner: () => sanitizeQueryInner
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
function sanitizeQuery() {
|
|
26
|
+
sanitizeQueryInner(new URLSearchParams(location.search));
|
|
27
|
+
}
|
|
28
|
+
function sanitizeQueryInner(search) {
|
|
29
|
+
search.delete("redeem_ready");
|
|
30
|
+
search.delete("totp");
|
|
31
|
+
search.delete("passkey");
|
|
32
|
+
const query = search.toString();
|
|
33
|
+
location.replace(
|
|
34
|
+
`${location.origin}${location.pathname}${query.length ? "?" + query : ""}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
sanitizeQuery,
|
|
40
|
+
sanitizeQueryInner
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth/utils.ts"],"sourcesContent":["export function sanitizeQuery() {\n sanitizeQueryInner(new URLSearchParams(location.search));\n}\n\nexport function sanitizeQueryInner(search: URLSearchParams) {\n search.delete(\"redeem_ready\");\n search.delete(\"totp\");\n search.delete(\"passkey\");\n const query = search.toString();\n location.replace(\n `${location.origin}${location.pathname}${query.length ? \"?\" + query : \"\"}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,gBAAgB;AAC9B,qBAAmB,IAAI,gBAAgB,SAAS,MAAM,CAAC;AACzD;AAEO,SAAS,mBAAmB,QAAyB;AAC1D,SAAO,OAAO,cAAc;AAC5B,SAAO,OAAO,MAAM;AACpB,SAAO,OAAO,SAAS;AACvB,QAAM,QAAQ,OAAO,SAAS;AAC9B,WAAS;AAAA,IACP,GAAG,SAAS,MAAM,GAAG,SAAS,QAAQ,GAAG,MAAM,SAAS,MAAM,QAAQ,EAAE;AAAA,EAC1E;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function sanitizeQuery() {
|
|
2
|
+
sanitizeQueryInner(new URLSearchParams(location.search));
|
|
3
|
+
}
|
|
4
|
+
function sanitizeQueryInner(search) {
|
|
5
|
+
search.delete("redeem_ready");
|
|
6
|
+
search.delete("totp");
|
|
7
|
+
search.delete("passkey");
|
|
8
|
+
const query = search.toString();
|
|
9
|
+
location.replace(
|
|
10
|
+
`${location.origin}${location.pathname}${query.length ? "?" + query : ""}`
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
sanitizeQuery,
|
|
15
|
+
sanitizeQueryInner
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth/utils.ts"],"sourcesContent":["export function sanitizeQuery() {\n sanitizeQueryInner(new URLSearchParams(location.search));\n}\n\nexport function sanitizeQueryInner(search: URLSearchParams) {\n search.delete(\"redeem_ready\");\n search.delete(\"totp\");\n search.delete(\"passkey\");\n const query = search.toString();\n location.replace(\n `${location.origin}${location.pathname}${query.length ? \"?\" + query : \"\"}`,\n );\n}\n"],"mappings":"AAAO,SAAS,gBAAgB;AAC9B,qBAAmB,IAAI,gBAAgB,SAAS,MAAM,CAAC;AACzD;AAEO,SAAS,mBAAmB,QAAyB;AAC1D,SAAO,OAAO,cAAc;AAC5B,SAAO,OAAO,MAAM;AACpB,SAAO,OAAO,SAAS;AACvB,QAAM,QAAQ,OAAO,SAAS;AAC9B,WAAS;AAAA,IACP,GAAG,SAAS,MAAM,GAAG,SAAS,QAAQ,GAAG,MAAM,SAAS,MAAM,QAAQ,EAAE;AAAA,EAC1E;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as react from 'react';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { CenterProps } from '@mantine/core';
|
|
5
5
|
|
|
6
6
|
interface PageGuardProps extends CenterProps {
|
|
@@ -8,6 +8,6 @@ interface PageGuardProps extends CenterProps {
|
|
|
8
8
|
error?: false | string;
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
}
|
|
11
|
-
declare function PageGuard({ isPending, error, children, ...centerProps }: PageGuardProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
11
|
+
declare function PageGuard({ isPending, error, children, ...centerProps }: PageGuardProps): string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
12
12
|
|
|
13
13
|
export { PageGuard, type PageGuardProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as react from 'react';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { CenterProps } from '@mantine/core';
|
|
5
5
|
|
|
6
6
|
interface PageGuardProps extends CenterProps {
|
|
@@ -8,6 +8,6 @@ interface PageGuardProps extends CenterProps {
|
|
|
8
8
|
error?: false | string;
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
}
|
|
11
|
-
declare function PageGuard({ isPending, error, children, ...centerProps }: PageGuardProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
11
|
+
declare function PageGuard({ isPending, error, children, ...centerProps }: PageGuardProps): string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
12
12
|
|
|
13
13
|
export { PageGuard, type PageGuardProps };
|
package/dist/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var index_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./auth"), module.exports);
|
|
18
19
|
__reExport(index_exports, require("./color"), module.exports);
|
|
19
20
|
__reExport(index_exports, require("./formatting"), module.exports);
|
|
20
21
|
__reExport(index_exports, require("./hooks"), module.exports);
|
|
@@ -56,6 +57,7 @@ __reExport(index_exports, require("./components/text-update-modal"), module.expo
|
|
|
56
57
|
__reExport(index_exports, require("./components/theme-toggle"), module.exports);
|
|
57
58
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
59
|
0 && (module.exports = {
|
|
60
|
+
...require("./auth"),
|
|
59
61
|
...require("./color"),
|
|
60
62
|
...require("./formatting"),
|
|
61
63
|
...require("./hooks"),
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./color\";\nexport * from \"./formatting\";\nexport * from \"./hooks\";\nexport * from \"./theme\";\nexport * from \"./components/config\";\nexport * from \"./components/divided-children\";\nexport * from \"./components/fancy-card\";\nexport * from \"./components/monaco\";\nexport * from \"./components/back-button\";\nexport * from \"./components/confirm-button\";\nexport * from \"./components/confirm-icon\";\nexport * from \"./components/confirm-modal\";\nexport * from \"./components/copy-button\";\nexport * from \"./components/copy-text\";\nexport * from \"./components/create-modal\";\nexport * from \"./components/data-table\";\nexport * from \"./components/enable-switch\";\nexport * from \"./components/entity-header\";\nexport * from \"./components/entity-page\";\nexport * from \"./components/hover-error\";\nexport * from \"./components/info-card\";\nexport * from \"./components/input-list\";\nexport * from \"./components/labelled-switch\";\nexport * from \"./components/labels-group\";\nexport * from \"./components/loading-screen\";\nexport * from \"./components/mobile-friendly-tabs\";\nexport * from \"./components/page-guard\";\nexport * from \"./components/page\";\nexport * from \"./components/search-input\";\nexport * from \"./components/section\";\nexport * from \"./components/shared-text-update\";\nexport * from \"./components/show-hide-button\";\nexport * from \"./components/stat-bar\";\nexport * from \"./components/stat-cell\";\nexport * from \"./components/status-badge\";\nexport * from \"./components/tabbed-page\";\nexport * from \"./components/table-skeleton\";\nexport * from \"./components/text-update-modal\";\nexport * from \"./components/theme-toggle\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./auth\";\nexport * from \"./color\";\nexport * from \"./formatting\";\nexport * from \"./hooks\";\nexport * from \"./theme\";\nexport * from \"./components/config\";\nexport * from \"./components/divided-children\";\nexport * from \"./components/fancy-card\";\nexport * from \"./components/monaco\";\nexport * from \"./components/back-button\";\nexport * from \"./components/confirm-button\";\nexport * from \"./components/confirm-icon\";\nexport * from \"./components/confirm-modal\";\nexport * from \"./components/copy-button\";\nexport * from \"./components/copy-text\";\nexport * from \"./components/create-modal\";\nexport * from \"./components/data-table\";\nexport * from \"./components/enable-switch\";\nexport * from \"./components/entity-header\";\nexport * from \"./components/entity-page\";\nexport * from \"./components/hover-error\";\nexport * from \"./components/info-card\";\nexport * from \"./components/input-list\";\nexport * from \"./components/labelled-switch\";\nexport * from \"./components/labels-group\";\nexport * from \"./components/loading-screen\";\nexport * from \"./components/mobile-friendly-tabs\";\nexport * from \"./components/page-guard\";\nexport * from \"./components/page\";\nexport * from \"./components/search-input\";\nexport * from \"./components/section\";\nexport * from \"./components/shared-text-update\";\nexport * from \"./components/show-hide-button\";\nexport * from \"./components/stat-bar\";\nexport * from \"./components/stat-cell\";\nexport * from \"./components/status-badge\";\nexport * from \"./components/tabbed-page\";\nexport * from \"./components/table-skeleton\";\nexport * from \"./components/text-update-modal\";\nexport * from \"./components/theme-toggle\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,mBAAd;AACA,0BAAc,oBADd;AAEA,0BAAc,yBAFd;AAGA,0BAAc,oBAHd;AAIA,0BAAc,oBAJd;AAKA,0BAAc,gCALd;AAMA,0BAAc,0CANd;AAOA,0BAAc,oCAPd;AAQA,0BAAc,gCARd;AASA,0BAAc,qCATd;AAUA,0BAAc,wCAVd;AAWA,0BAAc,sCAXd;AAYA,0BAAc,uCAZd;AAaA,0BAAc,qCAbd;AAcA,0BAAc,mCAdd;AAeA,0BAAc,sCAfd;AAgBA,0BAAc,oCAhBd;AAiBA,0BAAc,uCAjBd;AAkBA,0BAAc,uCAlBd;AAmBA,0BAAc,qCAnBd;AAoBA,0BAAc,qCApBd;AAqBA,0BAAc,mCArBd;AAsBA,0BAAc,oCAtBd;AAuBA,0BAAc,yCAvBd;AAwBA,0BAAc,sCAxBd;AAyBA,0BAAc,wCAzBd;AA0BA,0BAAc,8CA1Bd;AA2BA,0BAAc,oCA3Bd;AA4BA,0BAAc,8BA5Bd;AA6BA,0BAAc,sCA7Bd;AA8BA,0BAAc,iCA9Bd;AA+BA,0BAAc,4CA/Bd;AAgCA,0BAAc,0CAhCd;AAiCA,0BAAc,kCAjCd;AAkCA,0BAAc,mCAlCd;AAmCA,0BAAc,sCAnCd;AAoCA,0BAAc,qCApCd;AAqCA,0BAAc,wCArCd;AAsCA,0BAAc,2CAtCd;AAuCA,0BAAc,sCAvCd;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { AUTH_URL, authClient, setAuthUrl, useAuthState, useLogin, useLoginOptions, useManageAuth } from './auth/index.cjs';
|
|
1
2
|
export { ColorIntention, colorByIntention, hexColorByIntention } from './color.cjs';
|
|
2
3
|
export { BYTES_PER_GB, BYTES_PER_KB, BYTES_PER_MB, fmtDate, fmtDateWithMinutes, fmtDuration, fmtMonth, fmtRateBytes, fmtSizeBytes, fmtSnakeCaseToUpperSpaceCase, fmtUpperCamelcase, fmtUtcDate } from './formatting.cjs';
|
|
3
4
|
export { Dimensions, useCtrlKeyListener, useDebounce, useKeyListener, useSearchCombobox, useShiftKeyListener, useWindowDimensions } from './hooks.cjs';
|
|
4
|
-
export { AdditionalColors, DARK_BODY, LIGHT_BODY, ThemeProvider, functionColorsTuple, opacityColorsTuple } from './theme.cjs';
|
|
5
|
+
export { AdditionalColors, DARK_BODY, LIGHT_BODY, ThemeProvider, ThemeProviderProps, functionColorsTuple, opacityColorsTuple } from './theme.cjs';
|
|
5
6
|
export { Config, ConfigFieldArgs, ConfigGroup, ConfigGroupArgs, ConfigProps } from './components/config/index.cjs';
|
|
6
7
|
export { DividedChildren } from './components/divided-children/index.cjs';
|
|
7
8
|
export { FancyCard } from './components/fancy-card/index.cjs';
|
|
@@ -40,7 +41,14 @@ export { ThemeToggle } from './components/theme-toggle.cjs';
|
|
|
40
41
|
export { ConfigInput, ConfigItem, ConfigItemProps, ConfigList, ConfigSwitch } from './components/config/item.cjs';
|
|
41
42
|
export { ConfigLayout } from './components/config/layout.cjs';
|
|
42
43
|
export { ConfirmUpdate, ConfirmUpdateProps } from './components/config/confirm.cjs';
|
|
44
|
+
export { EnrollPasskey } from './auth/profile/passkey.cjs';
|
|
45
|
+
export { EnrollTotp } from './auth/profile/totp.cjs';
|
|
46
|
+
export { LinkedLogins } from './auth/profile/linked-logins.cjs';
|
|
47
|
+
export { LoginBrandingProps, LoginPage } from './auth/login/index.cjs';
|
|
43
48
|
export { UnsavedChanges } from './components/config/unsaved-changes.cjs';
|
|
49
|
+
export { sanitizeQuery, sanitizeQueryInner } from './auth/utils.cjs';
|
|
50
|
+
import '@tanstack/react-query';
|
|
51
|
+
import 'mogh_auth_client';
|
|
44
52
|
import '@mantine/core';
|
|
45
53
|
import 'react';
|
|
46
54
|
import 'react/jsx-runtime';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { AUTH_URL, authClient, setAuthUrl, useAuthState, useLogin, useLoginOptions, useManageAuth } from './auth/index.js';
|
|
1
2
|
export { ColorIntention, colorByIntention, hexColorByIntention } from './color.js';
|
|
2
3
|
export { BYTES_PER_GB, BYTES_PER_KB, BYTES_PER_MB, fmtDate, fmtDateWithMinutes, fmtDuration, fmtMonth, fmtRateBytes, fmtSizeBytes, fmtSnakeCaseToUpperSpaceCase, fmtUpperCamelcase, fmtUtcDate } from './formatting.js';
|
|
3
4
|
export { Dimensions, useCtrlKeyListener, useDebounce, useKeyListener, useSearchCombobox, useShiftKeyListener, useWindowDimensions } from './hooks.js';
|
|
4
|
-
export { AdditionalColors, DARK_BODY, LIGHT_BODY, ThemeProvider, functionColorsTuple, opacityColorsTuple } from './theme.js';
|
|
5
|
+
export { AdditionalColors, DARK_BODY, LIGHT_BODY, ThemeProvider, ThemeProviderProps, functionColorsTuple, opacityColorsTuple } from './theme.js';
|
|
5
6
|
export { Config, ConfigFieldArgs, ConfigGroup, ConfigGroupArgs, ConfigProps } from './components/config/index.js';
|
|
6
7
|
export { DividedChildren } from './components/divided-children/index.js';
|
|
7
8
|
export { FancyCard } from './components/fancy-card/index.js';
|
|
@@ -40,7 +41,14 @@ export { ThemeToggle } from './components/theme-toggle.js';
|
|
|
40
41
|
export { ConfigInput, ConfigItem, ConfigItemProps, ConfigList, ConfigSwitch } from './components/config/item.js';
|
|
41
42
|
export { ConfigLayout } from './components/config/layout.js';
|
|
42
43
|
export { ConfirmUpdate, ConfirmUpdateProps } from './components/config/confirm.js';
|
|
44
|
+
export { EnrollPasskey } from './auth/profile/passkey.js';
|
|
45
|
+
export { EnrollTotp } from './auth/profile/totp.js';
|
|
46
|
+
export { LinkedLogins } from './auth/profile/linked-logins.js';
|
|
47
|
+
export { LoginBrandingProps, LoginPage } from './auth/login/index.js';
|
|
43
48
|
export { UnsavedChanges } from './components/config/unsaved-changes.js';
|
|
49
|
+
export { sanitizeQuery, sanitizeQueryInner } from './auth/utils.js';
|
|
50
|
+
import '@tanstack/react-query';
|
|
51
|
+
import 'mogh_auth_client';
|
|
44
52
|
import '@mantine/core';
|
|
45
53
|
import 'react';
|
|
46
54
|
import 'react/jsx-runtime';
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./color\";\nexport * from \"./formatting\";\nexport * from \"./hooks\";\nexport * from \"./theme\";\nexport * from \"./components/config\";\nexport * from \"./components/divided-children\";\nexport * from \"./components/fancy-card\";\nexport * from \"./components/monaco\";\nexport * from \"./components/back-button\";\nexport * from \"./components/confirm-button\";\nexport * from \"./components/confirm-icon\";\nexport * from \"./components/confirm-modal\";\nexport * from \"./components/copy-button\";\nexport * from \"./components/copy-text\";\nexport * from \"./components/create-modal\";\nexport * from \"./components/data-table\";\nexport * from \"./components/enable-switch\";\nexport * from \"./components/entity-header\";\nexport * from \"./components/entity-page\";\nexport * from \"./components/hover-error\";\nexport * from \"./components/info-card\";\nexport * from \"./components/input-list\";\nexport * from \"./components/labelled-switch\";\nexport * from \"./components/labels-group\";\nexport * from \"./components/loading-screen\";\nexport * from \"./components/mobile-friendly-tabs\";\nexport * from \"./components/page-guard\";\nexport * from \"./components/page\";\nexport * from \"./components/search-input\";\nexport * from \"./components/section\";\nexport * from \"./components/shared-text-update\";\nexport * from \"./components/show-hide-button\";\nexport * from \"./components/stat-bar\";\nexport * from \"./components/stat-cell\";\nexport * from \"./components/status-badge\";\nexport * from \"./components/tabbed-page\";\nexport * from \"./components/table-skeleton\";\nexport * from \"./components/text-update-modal\";\nexport * from \"./components/theme-toggle\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./auth\";\nexport * from \"./color\";\nexport * from \"./formatting\";\nexport * from \"./hooks\";\nexport * from \"./theme\";\nexport * from \"./components/config\";\nexport * from \"./components/divided-children\";\nexport * from \"./components/fancy-card\";\nexport * from \"./components/monaco\";\nexport * from \"./components/back-button\";\nexport * from \"./components/confirm-button\";\nexport * from \"./components/confirm-icon\";\nexport * from \"./components/confirm-modal\";\nexport * from \"./components/copy-button\";\nexport * from \"./components/copy-text\";\nexport * from \"./components/create-modal\";\nexport * from \"./components/data-table\";\nexport * from \"./components/enable-switch\";\nexport * from \"./components/entity-header\";\nexport * from \"./components/entity-page\";\nexport * from \"./components/hover-error\";\nexport * from \"./components/info-card\";\nexport * from \"./components/input-list\";\nexport * from \"./components/labelled-switch\";\nexport * from \"./components/labels-group\";\nexport * from \"./components/loading-screen\";\nexport * from \"./components/mobile-friendly-tabs\";\nexport * from \"./components/page-guard\";\nexport * from \"./components/page\";\nexport * from \"./components/search-input\";\nexport * from \"./components/section\";\nexport * from \"./components/shared-text-update\";\nexport * from \"./components/show-hide-button\";\nexport * from \"./components/stat-bar\";\nexport * from \"./components/stat-cell\";\nexport * from \"./components/status-badge\";\nexport * from \"./components/tabbed-page\";\nexport * from \"./components/table-skeleton\";\nexport * from \"./components/text-update-modal\";\nexport * from \"./components/theme-toggle\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
package/dist/theme.cjs
CHANGED
|
@@ -33,22 +33,25 @@ const DARK_BODY = "#0f1115";
|
|
|
33
33
|
const DEFAULT_COLOR_SCHEME = "auto";
|
|
34
34
|
function ThemeProvider({
|
|
35
35
|
children,
|
|
36
|
-
|
|
36
|
+
...props
|
|
37
37
|
}) {
|
|
38
38
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
39
|
import_core.MantineProvider,
|
|
40
40
|
{
|
|
41
|
-
theme: theme(
|
|
41
|
+
theme: theme(props),
|
|
42
42
|
cssVariablesResolver,
|
|
43
43
|
defaultColorScheme: DEFAULT_COLOR_SCHEME,
|
|
44
44
|
children
|
|
45
45
|
}
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
function theme(
|
|
48
|
+
function theme({
|
|
49
|
+
primaryColor = "accent",
|
|
50
|
+
additionalColors
|
|
51
|
+
}) {
|
|
49
52
|
return (0, import_core.createTheme)({
|
|
50
53
|
cursorType: "pointer",
|
|
51
|
-
primaryColor
|
|
54
|
+
primaryColor,
|
|
52
55
|
breakpoints: {
|
|
53
56
|
xs: "36em",
|
|
54
57
|
sm: "48em",
|
|
@@ -266,6 +269,11 @@ function theme(additionalColors) {
|
|
|
266
269
|
classNames: { root: "bordered-heavy" }
|
|
267
270
|
}),
|
|
268
271
|
Progress: import_core.Progress.extend({
|
|
272
|
+
vars: (theme2) => ({
|
|
273
|
+
root: {
|
|
274
|
+
"--progress-radius": theme2.radius.md
|
|
275
|
+
}
|
|
276
|
+
}),
|
|
269
277
|
styles: (theme2) => ({
|
|
270
278
|
root: {
|
|
271
279
|
backgroundColor: theme2.colors.accent[4]
|