@ai-matrx/vault 0.1.46 → 0.1.48

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.js CHANGED
@@ -1396,6 +1396,7 @@ import { useEffect as useEffect8, useRef as useRef6, useState as useState8 } fro
1396
1396
  import { Button as Button5, Field as Field2 } from "@ai-matrx/design-system/controls";
1397
1397
 
1398
1398
  // src/authenticator/qr.ts
1399
+ import { listMediaDevices } from "@ai-matrx/browser-audio/core";
1399
1400
  import { decodeQrFromElement, decodeQrFromImageFile } from "@ai-matrx/capture/qr";
1400
1401
  function canDecodeQrLocally() {
1401
1402
  if (typeof document === "undefined") return Promise.resolve(false);
@@ -1409,9 +1410,9 @@ function hasCamera() {
1409
1410
  return typeof navigator !== "undefined" && typeof navigator.mediaDevices?.getUserMedia === "function";
1410
1411
  }
1411
1412
  async function hasCameraDevice() {
1412
- if (!hasCamera() || typeof navigator.mediaDevices?.enumerateDevices !== "function") return false;
1413
+ if (!hasCamera()) return false;
1413
1414
  try {
1414
- return (await navigator.mediaDevices.enumerateDevices()).some((d) => d.kind === "videoinput");
1415
+ return (await listMediaDevices()).videoInputs.length > 0;
1415
1416
  } catch {
1416
1417
  return false;
1417
1418
  }
@@ -1750,7 +1751,7 @@ function TotpRow({ port, item, onChanged }) {
1750
1751
  VaultRow,
1751
1752
  {
1752
1753
  label: "Authenticator",
1753
- className: "@max-[24rem]/otprow:grid-cols-[4.5rem_minmax(0,1fr)_auto]",
1754
+ className: "@max-[24rem]/otprow:grid-cols-[5.25rem_minmax(0,1fr)_auto] @max-[24rem]/otprow:gap-x-1 @max-[24rem]/otprow:px-2",
1754
1755
  actions: /* @__PURE__ */ jsxs7(Fragment5, { children: [
1755
1756
  a.enabled ? /* @__PURE__ */ jsx8("span", { className: "hidden @[24rem]/otprow:contents", "data-copy-code-button": "", children: /* @__PURE__ */ jsx8(CopyCodeButton, { live, label: item.name }) }) : null,
1756
1757
  menu
@@ -2789,6 +2790,7 @@ function orderOrganizations(orgs, items, recentItemIds) {
2789
2790
  const group = (o) => recent.has(o.id) ? 0 : (counts.get(o.id) ?? 0) > 0 ? 1 : 2;
2790
2791
  return [...orgs].sort((a, b) => group(a) - group(b) || (recent.get(a.id) ?? 0) - (recent.get(b.id) ?? 0) || a.name.localeCompare(b.name, void 0, { sensitivity: "base" }) || a.id.localeCompare(b.id));
2791
2792
  }
2793
+ var HINT_LENGTH = 8;
2792
2794
  function organizationHints(orgs) {
2793
2795
  const groups = /* @__PURE__ */ new Map();
2794
2796
  for (const o of orgs) {
@@ -2798,12 +2800,11 @@ function organizationHints(orgs) {
2798
2800
  const hints = /* @__PURE__ */ new Map();
2799
2801
  for (const group of groups.values()) {
2800
2802
  if (group.length < 2) continue;
2801
- const longest = Math.max(...group.map((o) => o.id.length));
2802
- const fragment = (o, n2) => o.id.slice(0, n2);
2803
- let n = 8;
2804
- while (n < longest && new Set(group.map((o) => fragment(o, n))).size < group.length) n += 1;
2805
- const useSuffix = new Set(group.map((o) => fragment(o, n))).size < group.length;
2806
- for (const o of group) hints.set(o.id, useSuffix ? o.id.slice(-8) : fragment(o, n));
2803
+ const distinct = (pick2) => new Set(group.map(pick2)).size === group.length;
2804
+ const head = (o) => o.id.slice(0, HINT_LENGTH);
2805
+ const tail = (o) => `\u2026${o.id.slice(-HINT_LENGTH)}`;
2806
+ const pick = distinct(head) || !distinct(tail) ? head : tail;
2807
+ for (const o of group) hints.set(o.id, pick(o));
2807
2808
  }
2808
2809
  return hints;
2809
2810
  }