@ai-matrx/vault 0.1.38 → 0.1.39

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.d.cts CHANGED
@@ -1319,6 +1319,11 @@ interface ApiVaultPortOptions {
1319
1319
  platformDoor?: SharingPortOptions["platformDoor"];
1320
1320
  /** The host's `supabase.auth`: turns on approving a browser with a passkey. */
1321
1321
  passkeys?: PasskeyAuthLike;
1322
+ /**
1323
+ * Told once per port when the vault had to work around the server (a problem the person cannot
1324
+ * see). A host forwards it to its own error capture; without it the problem goes to the console.
1325
+ */
1326
+ onHostProblem?: (message: string, detail?: unknown) => void;
1322
1327
  }
1323
1328
  declare function createApiVaultPort(hostApi: Api, options?: ApiVaultPortOptions): VaultPort;
1324
1329
 
package/dist/index.d.ts CHANGED
@@ -1319,6 +1319,11 @@ interface ApiVaultPortOptions {
1319
1319
  platformDoor?: SharingPortOptions["platformDoor"];
1320
1320
  /** The host's `supabase.auth`: turns on approving a browser with a passkey. */
1321
1321
  passkeys?: PasskeyAuthLike;
1322
+ /**
1323
+ * Told once per port when the vault had to work around the server (a problem the person cannot
1324
+ * see). A host forwards it to its own error capture; without it the problem goes to the console.
1325
+ */
1326
+ onHostProblem?: (message: string, detail?: unknown) => void;
1322
1327
  }
1323
1328
  declare function createApiVaultPort(hostApi: Api, options?: ApiVaultPortOptions): VaultPort;
1324
1329
 
package/dist/index.js CHANGED
@@ -1447,6 +1447,11 @@ function useCanScan() {
1447
1447
  }, []);
1448
1448
  return ok;
1449
1449
  }
1450
+ var CAMERA_NOTES = {
1451
+ blocked: "Camera blocked. Paste the key or choose a QR image.",
1452
+ missing: "No camera. Paste the key or choose a QR image.",
1453
+ failed: "Camera did not start. Paste the key or choose a QR image."
1454
+ };
1450
1455
  function QrScanInline({ onResult, onClose }) {
1451
1456
  const video = useRef6(null);
1452
1457
  const [error, setError] = useState8(null);
@@ -1492,7 +1497,7 @@ function QrScanInline({ onResult, onClose }) {
1492
1497
  }).catch((e) => {
1493
1498
  if (!live) return;
1494
1499
  const name = e?.name;
1495
- setError(name === "NotAllowedError" ? "Camera access was not allowed." : name === "NotFoundError" ? "No camera found." : "The camera could not start.");
1500
+ setError(name === "NotAllowedError" ? CAMERA_NOTES.blocked : name === "NotFoundError" ? CAMERA_NOTES.missing : CAMERA_NOTES.failed);
1496
1501
  });
1497
1502
  return () => {
1498
1503
  live = false;
@@ -1502,10 +1507,7 @@ function QrScanInline({ onResult, onClose }) {
1502
1507
  if (error) {
1503
1508
  return /* @__PURE__ */ jsxs6("p", { className: "flex items-center gap-2 px-1 pt-1 text-xs text-muted-foreground", role: "status", "data-camera-note": "", children: [
1504
1509
  /* @__PURE__ */ jsx7(CameraGlyph, { className: "size-3.5 shrink-0", "aria-hidden": true }),
1505
- /* @__PURE__ */ jsxs6("span", { className: "min-w-0 flex-1 truncate", children: [
1506
- error,
1507
- " Paste the setup key or choose a QR image."
1508
- ] }),
1510
+ /* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate", children: error }),
1509
1511
  /* @__PURE__ */ jsx7(Button5, { variant: "quiet", onClick: onClose, children: "Dismiss" })
1510
1512
  ] });
1511
1513
  }
@@ -9547,6 +9549,13 @@ async function retrying(run, tries = 3) {
9547
9549
  }
9548
9550
  function createApiVaultPort(hostApi, options = {}) {
9549
9551
  const api = withServerReasons(hostApi);
9552
+ let problemTold = false;
9553
+ const hostProblem = (message2, detail) => {
9554
+ if (problemTold) return;
9555
+ problemTold = true;
9556
+ if (options.onHostProblem) options.onHostProblem(message2, detail);
9557
+ else console.warn(`[vault] ${message2}`, detail);
9558
+ };
9550
9559
  let defs = /* @__PURE__ */ new Map();
9551
9560
  let auth = /* @__PURE__ */ new Map();
9552
9561
  let orgs = [];
@@ -9646,7 +9655,10 @@ function createApiVaultPort(hostApi, options = {}) {
9646
9655
  const one = await orgItemsP.then(
9647
9656
  (r) => r,
9648
9657
  (e) => {
9649
- if (e?.status === 404) return null;
9658
+ if (e?.status === 404) {
9659
+ hostProblem("GET /vault/organization-items answered 404; reading each organization vault separately", e);
9660
+ return null;
9661
+ }
9650
9662
  return "failed";
9651
9663
  }
9652
9664
  );
@@ -9654,8 +9666,8 @@ function createApiVaultPort(hostApi, options = {}) {
9654
9666
  const byOrg = one === "failed" ? /* @__PURE__ */ new Map() : new Map(one.views.map((v) => [v.organization_id, v.items]));
9655
9667
  const failed = one === "failed" ? new Set(orgs.map((o) => o.id)) : new Set(one.unavailable);
9656
9668
  const settled = orgs.map((o, i) => {
9657
- if (failed.has(o.id)) return Promise.reject(new Error(`${o.name} is unavailable`));
9658
- const items = byOrg.get(o.id) ?? [];
9669
+ const items = byOrg.get(o.id);
9670
+ if (failed.has(o.id) || items === void 0) return Promise.reject(new Error(`${o.name} is unavailable`));
9659
9671
  raw.orgLists[i] = { items, count: items.length };
9660
9672
  return Promise.resolve(raw.orgLists[i]);
9661
9673
  });