@ai-matrx/vault 0.1.49 → 0.1.50
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/CHANGELOG.md +10 -1
- package/dist/{chunk-LXFJBJR6.js → chunk-YDYTU3NY.js} +31 -8
- package/dist/chunk-YDYTU3NY.js.map +1 -0
- package/dist/identity.cjs +30 -7
- package/dist/identity.cjs.map +1 -1
- package/dist/identity.d.cts +4 -0
- package/dist/identity.d.ts +4 -0
- package/dist/identity.js +1 -1
- package/dist/index.cjs +30 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-LXFJBJR6.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -435,6 +435,7 @@ function IdentityGate({ identity, children }) {
|
|
|
435
435
|
setAsking(false);
|
|
436
436
|
return () => {
|
|
437
437
|
activeIdentity.current = null;
|
|
438
|
+
identity?.cancel?.();
|
|
438
439
|
for (const waiter of waiters.current.splice(0)) waiter.reject(new Error(CANCELLED));
|
|
439
440
|
};
|
|
440
441
|
}, [identityVersion]);
|
|
@@ -483,6 +484,7 @@ function IdentityGate({ identity, children }) {
|
|
|
483
484
|
};
|
|
484
485
|
const settle = (ok) => {
|
|
485
486
|
if (activeIdentity.current !== identityVersion) return;
|
|
487
|
+
if (!ok) identity?.cancel?.();
|
|
486
488
|
const w = waiters.current;
|
|
487
489
|
waiters.current = [];
|
|
488
490
|
if (ok) confirmationVersion.current += 1;
|
|
@@ -492,7 +494,7 @@ function IdentityGate({ identity, children }) {
|
|
|
492
494
|
};
|
|
493
495
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Ctx2.Provider, { value: confirmed, children: [
|
|
494
496
|
children,
|
|
495
|
-
identity ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfirmIdentityDialog, { open:
|
|
497
|
+
identity && asking ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfirmIdentityDialog, { open: true, identity, onDone: () => settle(true), onCancel: () => settle(false) }, identityVersion.key) : null,
|
|
496
498
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.Dialog, { open: returnProblem !== null, onOpenChange: (o) => o ? void 0 : setReturnProblem(null), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.DialogContent, { size: "sm", children: [
|
|
497
499
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.DialogHeader, { children: [
|
|
498
500
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.DialogTitle, { children: "Different account" }),
|
|
@@ -504,6 +506,16 @@ function IdentityGate({ identity, children }) {
|
|
|
504
506
|
}
|
|
505
507
|
var wasCancelled = (e) => e instanceof Error && e.message === CANCELLED;
|
|
506
508
|
function ConfirmIdentityDialog({ open, identity, onDone, onCancel }) {
|
|
509
|
+
const live = (0, import_react2.useRef)(false);
|
|
510
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
511
|
+
live.current = true;
|
|
512
|
+
return () => {
|
|
513
|
+
live.current = false;
|
|
514
|
+
};
|
|
515
|
+
}, []);
|
|
516
|
+
const finish = () => {
|
|
517
|
+
if (live.current) onDone();
|
|
518
|
+
};
|
|
507
519
|
const [account10, setAccount] = (0, import_react2.useState)(null);
|
|
508
520
|
const [password, setPassword] = (0, import_react2.useState)("");
|
|
509
521
|
const [code, setCode] = (0, import_react2.useState)("");
|
|
@@ -516,18 +528,29 @@ function ConfirmIdentityDialog({ open, identity, onDone, onCancel }) {
|
|
|
516
528
|
setCode("");
|
|
517
529
|
setCodeSent(false);
|
|
518
530
|
setError(null);
|
|
519
|
-
|
|
531
|
+
let current = true;
|
|
532
|
+
identity.account().then(
|
|
533
|
+
(value) => {
|
|
534
|
+
if (current && live.current) setAccount(value);
|
|
535
|
+
},
|
|
536
|
+
(e) => {
|
|
537
|
+
if (current && live.current) setError(e instanceof Error ? e.message : "Your account could not be read.");
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
return () => {
|
|
541
|
+
current = false;
|
|
542
|
+
};
|
|
520
543
|
}, [open, identity]);
|
|
521
544
|
const attempt = async (step, done = true) => {
|
|
522
545
|
setBusy(true);
|
|
523
546
|
setError(null);
|
|
524
547
|
try {
|
|
525
548
|
await step();
|
|
526
|
-
if (done)
|
|
549
|
+
if (done) finish();
|
|
527
550
|
} catch (e) {
|
|
528
|
-
setError(e instanceof Error ? e.message : "That did not work. Try again.");
|
|
551
|
+
if (live.current) setError(e instanceof Error ? e.message : "That did not work. Try again.");
|
|
529
552
|
} finally {
|
|
530
|
-
setBusy(false);
|
|
553
|
+
if (live.current) setBusy(false);
|
|
531
554
|
}
|
|
532
555
|
};
|
|
533
556
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.Dialog, { open, onOpenChange: (o) => o ? void 0 : onCancel(), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.DialogContent, { size: "sm", children: [
|
|
@@ -550,7 +573,7 @@ function ConfirmIdentityDialog({ open, identity, onDone, onCancel }) {
|
|
|
550
573
|
variant: identity.dev ? "outline" : "primary",
|
|
551
574
|
disabled: busy,
|
|
552
575
|
onClick: () => void attempt(async () => {
|
|
553
|
-
if (await identity.withProvider(p) === "confirmed")
|
|
576
|
+
if (await identity.withProvider(p) === "confirmed") finish();
|
|
554
577
|
}, false),
|
|
555
578
|
children: [
|
|
556
579
|
"Continue with ",
|
|
@@ -574,7 +597,7 @@ function ConfirmIdentityDialog({ open, identity, onDone, onCancel }) {
|
|
|
574
597
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_controls.Button, { variant: "outline", type: "submit", disabled: busy || !code.trim(), children: "Confirm" })
|
|
575
598
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_controls.Button, { variant: "quiet", disabled: busy, onClick: () => void attempt(async () => {
|
|
576
599
|
await identity.sendEmailCode();
|
|
577
|
-
setCodeSent(true);
|
|
600
|
+
if (live.current) setCodeSent(true);
|
|
578
601
|
}, false), children: "Email me a code instead" }) : null,
|
|
579
602
|
error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { role: "alert", className: "text-sm text-destructive", children: error }) : null
|
|
580
603
|
] })
|