reifyui 0.13.14 → 0.13.15
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/index.cjs +122 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +122 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/auth/AuthForm.jsx +2 -0
- package/src/auth/client.js +34 -4
- package/src/auth/personCheck.js +98 -0
- package/src/index.d.ts +7 -1
- package/src/index.js +2 -1
package/dist/index.cjs
CHANGED
|
@@ -76,6 +76,7 @@ __export(src_exports, {
|
|
|
76
76
|
MentionText: () => MentionText,
|
|
77
77
|
MicrosoftButton: () => MicrosoftButton,
|
|
78
78
|
Modal: () => Modal,
|
|
79
|
+
PERSON_CHECK_FAILED: () => PERSON_CHECK_FAILED,
|
|
79
80
|
PaneResizer: () => PaneResizer,
|
|
80
81
|
Panel: () => Panel,
|
|
81
82
|
PanelGrid: () => PanelGrid,
|
|
@@ -121,12 +122,14 @@ __export(src_exports, {
|
|
|
121
122
|
microsoftSignIn: () => microsoftSignIn,
|
|
122
123
|
packLayout: () => packLayout,
|
|
123
124
|
parseArgs: () => parseArgs,
|
|
125
|
+
personToken: () => personToken,
|
|
124
126
|
prettyJson: () => prettyJson,
|
|
125
127
|
pumpResponsesStream: () => pumpResponsesStream,
|
|
126
128
|
readSSEStream: () => readSSEStream,
|
|
127
129
|
refreshToken: () => refreshToken,
|
|
128
130
|
register: () => register,
|
|
129
131
|
requestPasswordReset: () => requestPasswordReset,
|
|
132
|
+
resendVerification: () => resendVerification,
|
|
130
133
|
sheetToAoA: () => sheetToAoA,
|
|
131
134
|
sheetToDelimited: () => sheetToDelimited,
|
|
132
135
|
summarizeSteps: () => summarizeSteps,
|
|
@@ -981,10 +984,10 @@ var Chip = (0, import_react6.forwardRef)(function Chip2(props, ref) {
|
|
|
981
984
|
removeLabel,
|
|
982
985
|
trailing,
|
|
983
986
|
className,
|
|
984
|
-
slot,
|
|
987
|
+
slot: slot2,
|
|
985
988
|
...rest
|
|
986
989
|
} = props;
|
|
987
|
-
const isSlot =
|
|
990
|
+
const isSlot = slot2 ?? (Boolean(onClick) && !selected);
|
|
988
991
|
const cls = [
|
|
989
992
|
"uic-chip",
|
|
990
993
|
selected ? "is-selected" : "",
|
|
@@ -1676,8 +1679,8 @@ function PaneResizer(props) {
|
|
|
1676
1679
|
const { pane, className, title = "Drag to resize (double-click to reset)" } = props;
|
|
1677
1680
|
const vertical = pane.axis === "y";
|
|
1678
1681
|
const onKeyDown = (e) => {
|
|
1679
|
-
const
|
|
1680
|
-
if (!
|
|
1682
|
+
const keys2 = vertical ? ["ArrowUp", "ArrowDown"] : ["ArrowLeft", "ArrowRight"];
|
|
1683
|
+
if (!keys2.includes(e.key)) return;
|
|
1681
1684
|
if (!pane.nudge) return;
|
|
1682
1685
|
e.preventDefault();
|
|
1683
1686
|
const step = e.shiftKey ? 96 : 24;
|
|
@@ -2193,6 +2196,96 @@ function ChoiceList({ label, entry, onPick }) {
|
|
|
2193
2196
|
] });
|
|
2194
2197
|
}
|
|
2195
2198
|
|
|
2199
|
+
// src/auth/personCheck.js
|
|
2200
|
+
var SCRIPT = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";
|
|
2201
|
+
var WAIT_MS = 6e4;
|
|
2202
|
+
var PERSON_CHECK_FAILED = "We couldn't confirm you're a person. Please try again.";
|
|
2203
|
+
var keys = /* @__PURE__ */ new Map();
|
|
2204
|
+
var script = null;
|
|
2205
|
+
function siteKey(engine) {
|
|
2206
|
+
let p = keys.get(engine);
|
|
2207
|
+
if (!p) {
|
|
2208
|
+
p = fetch(`${engine}/v1/auth/person-check`, { cache: "no-store" }).then(async (r) => {
|
|
2209
|
+
if (!r.ok) throw new Error("no answer");
|
|
2210
|
+
const b = await r.json();
|
|
2211
|
+
return typeof b?.site_key === "string" ? b.site_key : "";
|
|
2212
|
+
}).catch(() => {
|
|
2213
|
+
keys.delete(engine);
|
|
2214
|
+
return "";
|
|
2215
|
+
});
|
|
2216
|
+
keys.set(engine, p);
|
|
2217
|
+
}
|
|
2218
|
+
return p;
|
|
2219
|
+
}
|
|
2220
|
+
function loadScript() {
|
|
2221
|
+
script ?? (script = new Promise((resolve, reject) => {
|
|
2222
|
+
if (window.turnstile) {
|
|
2223
|
+
resolve(window.turnstile);
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2226
|
+
const s = document.createElement("script");
|
|
2227
|
+
s.src = SCRIPT;
|
|
2228
|
+
s.async = true;
|
|
2229
|
+
s.defer = true;
|
|
2230
|
+
s.onload = () => window.turnstile ? resolve(window.turnstile) : reject(new Error(PERSON_CHECK_FAILED));
|
|
2231
|
+
s.onerror = () => {
|
|
2232
|
+
script = null;
|
|
2233
|
+
s.remove();
|
|
2234
|
+
reject(new Error(PERSON_CHECK_FAILED));
|
|
2235
|
+
};
|
|
2236
|
+
document.head.appendChild(s);
|
|
2237
|
+
}));
|
|
2238
|
+
return script;
|
|
2239
|
+
}
|
|
2240
|
+
function slot() {
|
|
2241
|
+
const shown = Array.from(document.querySelectorAll("[data-person-check]")).find((el2) => el2.offsetParent !== null);
|
|
2242
|
+
if (shown) return shown;
|
|
2243
|
+
let el = document.getElementById("person-check-fallback");
|
|
2244
|
+
if (!el) {
|
|
2245
|
+
el = document.createElement("div");
|
|
2246
|
+
el.id = "person-check-fallback";
|
|
2247
|
+
el.className = "person-check-fallback";
|
|
2248
|
+
document.body.appendChild(el);
|
|
2249
|
+
}
|
|
2250
|
+
return el;
|
|
2251
|
+
}
|
|
2252
|
+
async function personToken(door, engine) {
|
|
2253
|
+
const key = await siteKey(engine);
|
|
2254
|
+
if (!key) return "";
|
|
2255
|
+
const ts = await loadScript();
|
|
2256
|
+
const host = document.createElement("div");
|
|
2257
|
+
slot().appendChild(host);
|
|
2258
|
+
return new Promise((resolve, reject) => {
|
|
2259
|
+
let id = "";
|
|
2260
|
+
const done = (fn) => {
|
|
2261
|
+
clearTimeout(timer);
|
|
2262
|
+
try {
|
|
2263
|
+
if (id) ts.remove(id);
|
|
2264
|
+
} catch {
|
|
2265
|
+
}
|
|
2266
|
+
host.remove();
|
|
2267
|
+
fn();
|
|
2268
|
+
};
|
|
2269
|
+
const fail = () => done(() => reject(new Error(PERSON_CHECK_FAILED)));
|
|
2270
|
+
const timer = setTimeout(fail, WAIT_MS);
|
|
2271
|
+
try {
|
|
2272
|
+
id = ts.render(host, {
|
|
2273
|
+
sitekey: key,
|
|
2274
|
+
action: door,
|
|
2275
|
+
appearance: "interaction-only",
|
|
2276
|
+
theme: "auto",
|
|
2277
|
+
"refresh-expired": "never",
|
|
2278
|
+
callback: (token) => done(() => resolve(token)),
|
|
2279
|
+
"error-callback": fail,
|
|
2280
|
+
"expired-callback": fail,
|
|
2281
|
+
"timeout-callback": fail
|
|
2282
|
+
});
|
|
2283
|
+
} catch {
|
|
2284
|
+
fail();
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2196
2289
|
// src/auth/client.js
|
|
2197
2290
|
var _cfg = {
|
|
2198
2291
|
// Same-origin. A product that forgets to configure gets the working default rather than the
|
|
@@ -2269,7 +2362,8 @@ async function login(email, password) {
|
|
|
2269
2362
|
return s;
|
|
2270
2363
|
}
|
|
2271
2364
|
async function register(email, password, name = "") {
|
|
2272
|
-
const
|
|
2365
|
+
const turnstile_token = await personToken("register", _cfg.engine);
|
|
2366
|
+
const s = toSession(await authPost("/v1/auth/register", { email, password, name, product: _cfg.product, turnstile_token }));
|
|
2273
2367
|
setSession(s);
|
|
2274
2368
|
return s;
|
|
2275
2369
|
}
|
|
@@ -2283,12 +2377,30 @@ async function microsoftSignIn(credential) {
|
|
|
2283
2377
|
setSession(s);
|
|
2284
2378
|
return s;
|
|
2285
2379
|
}
|
|
2286
|
-
async function
|
|
2287
|
-
|
|
2380
|
+
async function readMailDoorError(res) {
|
|
2381
|
+
if (res.status === 400 || res.status === 403 || res.status === 503) {
|
|
2382
|
+
try {
|
|
2383
|
+
const d = (await res.json())?.detail;
|
|
2384
|
+
if (typeof d === "string" && d.length > 0 && d.length < 200) return d;
|
|
2385
|
+
} catch {
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
return "We could not send the request. Please try again later.";
|
|
2389
|
+
}
|
|
2390
|
+
async function mailDoor(path, door, email) {
|
|
2391
|
+
const turnstile_token = await personToken(door, _cfg.engine);
|
|
2392
|
+
const res = await fetch(`${_cfg.engine}${path}`, {
|
|
2288
2393
|
method: "POST",
|
|
2289
2394
|
headers: { "content-type": "application/json" },
|
|
2290
|
-
body: JSON.stringify({ email, product: _cfg.product })
|
|
2395
|
+
body: JSON.stringify({ email, product: _cfg.product, turnstile_token })
|
|
2291
2396
|
});
|
|
2397
|
+
if (!res.ok) throw new Error(await readMailDoorError(res));
|
|
2398
|
+
}
|
|
2399
|
+
async function requestPasswordReset(email) {
|
|
2400
|
+
await mailDoor("/v1/auth/request-password-reset", "reset", email);
|
|
2401
|
+
}
|
|
2402
|
+
async function resendVerification(email) {
|
|
2403
|
+
await mailDoor("/v1/auth/resend-verification", "resend", email);
|
|
2292
2404
|
}
|
|
2293
2405
|
async function switchOrg(orgId) {
|
|
2294
2406
|
const current = getSession();
|
|
@@ -2666,6 +2778,7 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
|
|
|
2666
2778
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { children: "Email" }),
|
|
2667
2779
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
|
|
2668
2780
|
] }),
|
|
2781
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { "data-person-check": "", className: "person-check" }),
|
|
2669
2782
|
err && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "auth-err", children: err }),
|
|
2670
2783
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
|
|
2671
2784
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "auth-switch", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: () => {
|
|
@@ -2703,6 +2816,7 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
|
|
|
2703
2816
|
}
|
|
2704
2817
|
)
|
|
2705
2818
|
] }),
|
|
2819
|
+
mode === "register" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { "data-person-check": "", className: "person-check" }),
|
|
2706
2820
|
err && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "auth-err", children: err }),
|
|
2707
2821
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : mode === "register" ? "Create account" : "Sign in" }),
|
|
2708
2822
|
(GOOGLE_ENABLED || MICROSOFT_ENABLED) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "auth-or", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "or" }) }),
|