@7365admin1/layer-common 4.34.1-staging.369 → 4.35.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +47 -4
  2. package/components/AccessCardAddForm.vue +4 -5
  3. package/components/AccessCardAssignToUnitForm.vue +2 -3
  4. package/components/AccessCardPreviewDialog.vue +3 -4
  5. package/components/Dialog/UpdateMoreAction.vue +1 -11
  6. package/components/DocumentForm.vue +112 -407
  7. package/components/DocumentManagement.vue +12 -213
  8. package/components/EntryPass/QrTemplatePreview.vue +25 -21
  9. package/components/EntryPassInformation.vue +24 -119
  10. package/components/Facility/BookingSetup.vue +0 -63
  11. package/components/HidAccessLogDashboard.vue +8 -41
  12. package/components/HidIntercomManagement.vue +14 -148
  13. package/components/HidQrCodeConfiguration.vue +195 -17
  14. package/components/HidReaderManagement.vue +0 -306
  15. package/components/HidReaderUserRoster.vue +3 -44
  16. package/components/HidUserEnrollment.vue +155 -845
  17. package/components/InvitationClientForm.vue +1 -19
  18. package/components/VisitorForm.vue +0 -12
  19. package/components/VisitorManagement.vue +5 -267
  20. package/composables/useAccessManagement.ts +0 -5
  21. package/composables/useDocument.ts +0 -7
  22. package/composables/useFacility.ts +0 -11
  23. package/composables/useHidAmico.ts +0 -134
  24. package/composables/useHidNavigation.ts +1 -25
  25. package/composables/usePeople.ts +0 -19
  26. package/composables/useSiteEntryPassSettings.ts +0 -26
  27. package/composables/useWebUsb.ts +11 -14
  28. package/package.json +1 -1
  29. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  30. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  31. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  32. package/types/document.d.ts +0 -14
  33. package/types/facility.d.ts +0 -4
  34. package/types/people.d.ts +1 -28
  35. package/components/HidAccessPermissions.vue +0 -424
  36. package/components/HidProfileQrCode.vue +0 -332
  37. package/composables/useHidReaderSelection.ts +0 -50
  38. package/composables/useSiteCategory.ts +0 -45
  39. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
  40. package/utils/hid-permission-assignments.ts +0 -190
  41. package/utils/hid-reader-selection.ts +0 -52
  42. package/utils/occupancy-role.ts +0 -109
@@ -376,7 +376,6 @@ const visitorRecords = ref<Record<string, HidAccessRecord>>({});
376
376
  const logs = ref<HidAccessRecord[]>([]);
377
377
  const liveAccessLogs = ref<HidAccessRecord[]>([]);
378
378
  const administratorUserIds = ref<Set<number>>(new Set());
379
- const { selectHidReader, resolveForSite } = useHidReaderSelection();
380
379
  const selectedReaderId = ref("");
381
380
  const activeTab = ref<AccessTab>("all");
382
381
  const search = ref("");
@@ -402,10 +401,7 @@ const exportForm = reactive({
402
401
  });
403
402
 
404
403
  const statusOptions = ["Authorized", "Not Authorized", "Unknown"];
405
- const accessMethodFilterOptions = ["Facial", "QR Code", "ID and Password", "PIN", "Card", "Intercom"];
406
-
407
- /** The persisted event the resident app records when it opens a door on a call. */
408
- const INTERCOM_DOOR_OPEN_EVENT = "intercom_door_open";
404
+ const accessMethodFilterOptions = ["Facial", "QR Code", "ID and Password", "PIN", "Card"];
409
405
  const accessMethodOptions = ["All", ...accessMethodFilterOptions];
410
406
 
411
407
  const readerOptions = computed(() =>
@@ -593,11 +589,9 @@ async function loadReaders() {
593
589
  if (!props.site) return;
594
590
  const response = await getReaders({ site: props.site, page: 1, limit: 100 });
595
591
  readers.value = response?.items ?? response?.data?.items ?? response?.data?.readers ?? [];
596
- /* Shared with every other HID screen — see `useHidReaderSelection`. The
597
- resolver refuses a remembered reader that is not this site's, so a site
598
- switch or a deleted reader falls back to the first rather than querying
599
- an id the site does not own. */
600
- selectedReaderId.value = resolveForSite(props.site, readers.value);
592
+ if (!selectedReaderId.value && readers.value.length) {
593
+ selectedReaderId.value = readers.value[0]._id;
594
+ }
601
595
  }
602
596
 
603
597
  async function loadDashboard() {
@@ -612,7 +606,7 @@ async function loadDashboard() {
612
606
  resetDashboardData();
613
607
  try {
614
608
  const isVisitorTab = activeTab.value === "visitor";
615
- const [logResponse, intercomLogResponse, hidAccessLogResponse, visitorResponse, readerUserResponse] = await Promise.all([
609
+ const [logResponse, hidAccessLogResponse, visitorResponse, readerUserResponse] = await Promise.all([
616
610
  loadDashboardSource(
617
611
  getLogs(selectedReaderId.value, {
618
612
  page: page.value,
@@ -621,20 +615,6 @@ async function loadDashboard() {
621
615
  null,
622
616
  "persisted access logs",
623
617
  ),
624
- // Door opens from the resident app during an intercom call. The reader
625
- // never logs a DTMF door open, so these exist only as persisted events
626
- // and are fetched by type: the general page above is shared with every
627
- // other event the reader emits and is dropped whenever the reader has
628
- // live logs, which it always has.
629
- loadDashboardSource(
630
- getLogs(selectedReaderId.value, {
631
- page: page.value,
632
- limit,
633
- type: INTERCOM_DOOR_OPEN_EVENT,
634
- }),
635
- null,
636
- "intercom door-open logs",
637
- ),
638
618
  loadDashboardSource(
639
619
  getReaderAccessLogs(selectedReaderId.value, {
640
620
  page: page.value,
@@ -701,14 +681,9 @@ async function loadDashboard() {
701
681
  // identity metadata here: it can contain a stale photo from another user.
702
682
  allIdentities.value = readerUsers;
703
683
  identities.value = readerUsers;
704
- const intercomItems = intercomLogResponse?.items ?? intercomLogResponse?.data?.items ?? intercomLogResponse?.data?.logs ?? [];
705
- logs.value = [
706
- ...(liveItems.length
707
- ? []
708
- : logResponse?.items ?? logResponse?.data?.items ?? logResponse?.data?.logs ?? []),
709
- // Always kept: the reader has no live counterpart for these.
710
- ...intercomItems,
711
- ];
684
+ logs.value = liveItems.length
685
+ ? []
686
+ : logResponse?.items ?? logResponse?.data?.items ?? logResponse?.data?.logs ?? [];
712
687
  liveAccessLogs.value = liveItems;
713
688
  serverPages.value = Number(hidAccessLogResponse?.pages ?? hidAccessLogResponse?.data?.pages ?? 1);
714
689
  serverPageRange.value = String(
@@ -844,8 +819,6 @@ function getAccessMethod(identity: HidAccessRecord, log?: HidAccessRecord) {
844
819
  id_password: "ID and Password",
845
820
  pin: "PIN",
846
821
  card: "Card",
847
- // Set by the API on intercom_door_open events; no reader field implies it.
848
- intercom: "Intercom",
849
822
  };
850
823
  const normalizedMethod = String(payload.normalizedMethod || "");
851
824
  if (normalizedMethodLabels[normalizedMethod]) return normalizedMethodLabels[normalizedMethod];
@@ -1575,12 +1548,6 @@ function escapeHtml(value: unknown) {
1575
1548
  .replace(/"/g, "&quot;")
1576
1549
  .replace(/'/g, "&#039;");
1577
1550
  }
1578
-
1579
- /* Publish every change, including the seed above: a screen that had to fall
1580
- back to the first reader should leave the others agreeing with it. */
1581
- watch(selectedReaderId, (value) => {
1582
- if (value) selectHidReader(props.site, value);
1583
- });
1584
1551
  </script>
1585
1552
 
1586
1553
  <style scoped>
@@ -162,8 +162,11 @@
162
162
  />
163
163
  <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
164
164
  <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
165
+ <v-list-item class="screen-menu__item" title="Make a call" prepend-icon="mdi-phone" @click="openMakeCallDialog(item)" />
166
+ <v-list-item class="screen-menu__item" title="Web call" prepend-icon="mdi-headset" @click="openWebPhoneDialog(item)" />
165
167
  </v-list>
166
168
  <v-list v-else density="compact" class="screen-menu">
169
+ <v-list-item class="screen-menu__item" title="Call" prepend-icon="mdi-phone" @click="openContactCall(item)" />
167
170
  <v-list-item class="screen-menu__item" title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
168
171
  <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openContactView(item)" />
169
172
  <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
@@ -586,31 +589,9 @@
586
589
  :disabled="Boolean(contactForm.id)"
587
590
  />
588
591
  <FieldLabel text="Name" required />
589
- <!-- The name is picked from the site's SIP accounts (`hid-sip-accounts`)
590
- rather than typed, so a contact always names a person who holds an
591
- extension. The model stays the plain name string the reader stores,
592
- so `saveContact` is unchanged; an existing contact whose name is not
593
- in the list still displays it (AppSelect falls back to the raw value). -->
594
- <AppSelect
595
- v-model="contactForm.name"
596
- :items="sipAccountOptions"
597
- :disabled="sipAccountsLoading"
598
- :placeholder="sipAccountsLoading ? 'Loading SIP accounts…' : 'Name shown on calls'"
599
- class="my-3"
600
- @update:model-value="applySipAccountToContact"
601
- />
602
- <p v-if="sipAccountsError" class="field-hint field-hint--error">{{ sipAccountsError }}</p>
603
- <p v-else-if="!sipAccountsLoading && !sipAccounts.length" class="field-hint">
604
- No SIP accounts on this site yet. An account is created the first time a user opens Web Call.
605
- </p>
592
+ <AppField v-model="contactForm.name" placeholder="Name shown on calls" class="my-3" />
606
593
  <FieldLabel text="Address" required />
607
- <!-- Always read-only: it shows the extension of the chosen SIP account
608
- and is never typed into. -->
609
- <AppField
610
- v-model="contactForm.serverAddress"
611
- :placeholder="contactAddressPlaceholder"
612
- disabled
613
- />
594
+ <AppField v-model="contactForm.serverAddress" :placeholder="contactAddressPlaceholder" />
614
595
  <p class="field-hint">{{ contactAddressHint }}</p>
615
596
  </v-card-text>
616
597
  <v-card-actions class="dialog-actions pa-0">
@@ -655,8 +636,6 @@
655
636
  </template>
656
637
 
657
638
  <script setup lang="ts">
658
- import type { HidSipAccountListItem } from "../composables/useHidAmico";
659
-
660
639
  const props = defineProps({
661
640
  org: {
662
641
  type: String,
@@ -753,8 +732,6 @@ const {
753
732
  makeIntercomCall,
754
733
  finalizeIntercomCall,
755
734
  ensureSipAccount,
756
- getSipAccounts,
757
- notifyIntercomCall,
758
735
  } = useHidAmico();
759
736
 
760
737
  const activeTab = ref<IntercomTab>("intercom");
@@ -783,11 +760,6 @@ const webPhoneActionLoading = ref(false);
783
760
  const sipAccount = ref<SipAccount | null>(null);
784
761
  const sipAccountLoading = ref(false);
785
762
  const sipAccountError = ref("");
786
- // The site's SIP account list for the contact dialog's name picker. Distinct
787
- // from `sipAccount` above, which is the CALLER's own account for the web phone.
788
- const sipAccounts = ref<HidSipAccountListItem[]>([]);
789
- const sipAccountsLoading = ref(false);
790
- const sipAccountsError = ref("");
791
763
  const remoteVideoEl = ref<HTMLVideoElement | null>(null);
792
764
  const remoteAudioEl = ref<HTMLAudioElement | null>(null);
793
765
  const webPhone = useSipWebPhone();
@@ -892,31 +864,6 @@ const readerOptions = computed(() => readers.value.map((reader) => ({
892
864
  value: reader._id,
893
865
  })));
894
866
 
895
- /**
896
- * The contact name picker. `value` is the bare name because that is what the
897
- * reader stores and what `saveContact` sends; the extension goes into the
898
- * Address field, not the label. A name that already sits on the contact being
899
- * edited but is no longer in the SIP list is kept as an option so the picker
900
- * does not silently drop it.
901
- */
902
- const sipAccountOptions = computed(() => {
903
- const options: Array<{ title: string; value: string }> = sipAccounts.value
904
- .filter((account: HidSipAccountListItem) => account.name)
905
- .map((account: HidSipAccountListItem) => ({ title: account.name, value: account.name }));
906
- const current = contactForm.name.trim();
907
- if (current && !options.some((option) => option.value === current)) {
908
- options.unshift({ title: current, value: current });
909
- }
910
- return options;
911
- });
912
-
913
- /** The SIP account behind the picked name, or null for a legacy / unpicked name. */
914
- const selectedSipAccount = computed(() => {
915
- const name = contactForm.name.trim();
916
- const match = sipAccounts.value.find((account: HidSipAccountListItem) => account.name === name);
917
- return (match ?? null) as HidSipAccountListItem | null;
918
- });
919
-
920
867
  const visibleRows = computed(() => activeTab.value === "intercom" ? filteredIntercomRows.value : filteredContacts.value);
921
868
  const pages = computed(() => Math.max(1, Math.ceil(visibleRows.value.length / limit)));
922
869
  const pageRange = computed(() => {
@@ -1029,11 +976,14 @@ const contactReaderRow = computed(() =>
1029
976
  );
1030
977
  const isContactReaderPeerToPeer = computed(() => contactReaderRow.value?.operatingMode === "Peer-to-Peer");
1031
978
  const contactAddressPlaceholder = computed(() => (isContactReaderPeerToPeer.value ? "192.168.0.129" : "7100"));
1032
- const contactAddressHint = computed(() => (
1033
- selectedSipAccount.value
1034
- ? "Extension of the selected SIP account."
1035
- : "Filled from the SIP account of the name selected above."
1036
- ));
979
+ const contactAddressHint = computed(() => {
980
+ if (!contactReaderRow.value) {
981
+ return "Extension number (SIP Client) or local IP address (Peer-to-Peer), depending on the reader's operating mode.";
982
+ }
983
+ return isContactReaderPeerToPeer.value
984
+ ? "Peer-to-Peer mode: enter the contact's local IP address."
985
+ : "SIP Client mode: enter the contact's extension number.";
986
+ });
1037
987
  const areSipCredentialFieldsDisabled = computed(() => !sipForm.enabled || isPeerToPeerMode.value);
1038
988
  const intercomDetailSections = computed(() => {
1039
989
  const row = selectedRow.value;
@@ -1449,37 +1399,6 @@ async function loadSipAccount() {
1449
1399
  }
1450
1400
  }
1451
1401
 
1452
- async function loadSipAccounts() {
1453
- if (!props.org || !props.site) return;
1454
-
1455
- sipAccountsLoading.value = true;
1456
- sipAccountsError.value = "";
1457
- try {
1458
- const response = await getSipAccounts(props.site, props.org);
1459
- const rows = toRecord(response).data;
1460
- sipAccounts.value = Array.isArray(rows) ? rows as HidSipAccountListItem[] : [];
1461
- // An existing contact opened before the list arrived: once its name is
1462
- // matched to an account, show that account's extension in the locked field.
1463
- applySipAccountToContact(contactForm.name.trim());
1464
- } catch (error: unknown) {
1465
- sipAccounts.value = [];
1466
- sipAccountsError.value = getErrorMessage(error);
1467
- } finally {
1468
- sipAccountsLoading.value = false;
1469
- }
1470
- }
1471
-
1472
- /**
1473
- * Picking a SIP account sets the address to its extension. The Address field
1474
- * is always disabled, so this is the only way it gets a value; a name that is
1475
- * not an account (a legacy contact) leaves whatever address it already had.
1476
- */
1477
- function applySipAccountToContact(name: string) {
1478
- const account = sipAccounts.value.find((item: HidSipAccountListItem) => item.name === name);
1479
- if (!account) return;
1480
- contactForm.serverAddress = account.extension;
1481
- }
1482
-
1483
1402
  async function connectWebPhone() {
1484
1403
  const account = sipAccount.value;
1485
1404
  if (!account) {
@@ -1523,10 +1442,8 @@ async function disconnectWebPhone() {
1523
1442
 
1524
1443
  async function startWebCall() {
1525
1444
  webPhoneActionLoading.value = true;
1526
- const destination = webPhoneForm.destination;
1527
1445
  try {
1528
- await webPhone.call(destination);
1529
- void ringResidentPhone(destination);
1446
+ await webPhone.call(webPhoneForm.destination);
1530
1447
  } catch (error: unknown) {
1531
1448
  showMessage(getErrorMessage(error), "error");
1532
1449
  } finally {
@@ -1534,50 +1451,6 @@ async function startWebCall() {
1534
1451
  }
1535
1452
  }
1536
1453
 
1537
- /**
1538
- * Wake the called resident's mobile so they are there to answer.
1539
- *
1540
- * Deliberately fired AFTER the INVITE and never awaited. The SIP leg is the
1541
- * call: it is already ringing by the time this runs, and a resident whose
1542
- * phone is asleep is the only thing this fixes. So a failure here is logged
1543
- * and dropped rather than shown — telling the operator "call failed" for a
1544
- * call that is ringing would be worse than a silent miss.
1545
- *
1546
- * A destination with no resident behind it (a staff extension, an external SIP
1547
- * address) comes back `notified: false` with a reason and is not an error.
1548
- */
1549
- async function ringResidentPhone(destination: string) {
1550
- if (!props.org || !props.site) return;
1551
-
1552
- try {
1553
- // No `readerId`: this call came from the web phone, not a door station.
1554
- // The reader selected in the table above is whatever the operator happens
1555
- // to be looking at, and sending it would tell the resident's app the call
1556
- // arrived at a door it never touched.
1557
- await notifyIntercomCall(props.site, {
1558
- orgId: props.org,
1559
- destination,
1560
- callId: createCallId(),
1561
- });
1562
- } catch (error: unknown) {
1563
- console.warn("[intercom] could not send the incoming-call push", error);
1564
- }
1565
- }
1566
-
1567
- /**
1568
- * A per-call id, so a second push for the same call replaces the first on the
1569
- * resident's lock screen rather than stacking a second ringing card.
1570
- * `randomUUID` needs a secure context, which the web phone already requires —
1571
- * getUserMedia does not run without one — but the fallback keeps a call from
1572
- * failing on that account alone.
1573
- */
1574
- function createCallId() {
1575
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1576
- return crypto.randomUUID();
1577
- }
1578
- return `call-${Date.now()}-${Math.random().toString(16).slice(2)}`;
1579
- }
1580
-
1581
1454
  async function answerWebCall() {
1582
1455
  webPhoneActionLoading.value = true;
1583
1456
  try {
@@ -1635,9 +1508,6 @@ function openContactDialog(contact?: ContactRow) {
1635
1508
  contactForm.location = contact?.location === "N/A" ? "" : contact?.location || selectedReader?.location || "";
1636
1509
  contactForm.serverAddress = contact?.serverAddress === "N/A" ? "" : contact?.serverAddress || "";
1637
1510
  contactDialog.value = true;
1638
- // Fetched on every open, not cached: an account is provisioned the first
1639
- // time a user opens Web Call, so the list can grow between two dialogs.
1640
- void loadSipAccounts();
1641
1511
  }
1642
1512
 
1643
1513
  function openContactView(contact: ContactRow) {
@@ -2226,10 +2096,6 @@ export default {
2226
2096
  line-height: 1.4;
2227
2097
  }
2228
2098
 
2229
- .field-hint--error {
2230
- color: var(--err);
2231
- }
2232
-
2233
2099
  .sip-settings-dialog .field-label {
2234
2100
  margin-top: 14px;
2235
2101
  }
@@ -21,6 +21,33 @@
21
21
  <div class="config-body">
22
22
  <div class="section-label config-body__title">HID Configuration</div>
23
23
 
24
+ <div class="form-section identification-section">
25
+ <div class="section-label">Enable/disable reader identification method</div>
26
+ <p class="section-description">
27
+ Toggles multi-factor access methods, allowing users to authenticate via biometric, physical card, or credential inputs.
28
+ </p>
29
+ <div class="methods-grid">
30
+ <div
31
+ v-for="method in identificationMethodOptions"
32
+ :key="method.key"
33
+ class="method-control"
34
+ >
35
+ <span>{{ method.label }}</span>
36
+ <v-switch
37
+ v-model="form.identificationMethods[method.key]"
38
+ class="app-switch"
39
+ hide-details
40
+ density="compact"
41
+ :loading="savingSection === `method-${method.key}`"
42
+ :disabled="Boolean(savingSection) || !form.readerId"
43
+ @update:model-value="saveIdentificationMethod(method.key)"
44
+ />
45
+ </div>
46
+ </div>
47
+ </div>
48
+
49
+ <v-divider />
50
+
24
51
  <div class="form-section">
25
52
  <div class="section-label">Printer Setup</div>
26
53
  <div class="printer-grid">
@@ -197,11 +224,14 @@
197
224
 
198
225
 
199
226
  <script setup lang="ts">
227
+ type HidIdentificationMethod = keyof NonNullable<THidQrCodePassConfig["identificationMethods"]>;
228
+
200
229
  type HidQrConfig = Omit<
201
230
  THidQrCodePassConfig,
202
231
  "identificationMethods" | "onlineMode" | "updatedAt" | "qrGatePermissions"
203
232
  > & {
204
233
  onlineMode: boolean;
234
+ identificationMethods: Record<HidIdentificationMethod, boolean>;
205
235
  qrGatePermissions: {
206
236
  resident: string[];
207
237
  propertyManagement: string[];
@@ -235,7 +265,11 @@ const runtimeConfig = useRuntimeConfig();
235
265
  const isPermissionManager = computed(() => runtimeConfig.public.APP === "security_agency");
236
266
 
237
267
  const { getSiteById, updateSitebyId } = useSiteSettings();
238
- const { getReaders } = useHidAmico();
268
+ const {
269
+ getReaders,
270
+ getReaderConfiguration,
271
+ setReaderConfiguration,
272
+ } = useHidAmico();
239
273
  const {
240
274
  requestDevice: requestPrinterDevice,
241
275
  testConnection: testPrinterConnection,
@@ -250,6 +284,14 @@ const defaultConfig: HidQrConfig = {
250
284
  propertyManagement: [],
251
285
  },
252
286
  qrFormat: "0",
287
+ identificationMethods: {
288
+ facial: true,
289
+ card: true,
290
+ qrCode: false,
291
+ idPassword: true,
292
+ pin: false,
293
+ bluetooth: false,
294
+ },
253
295
  printer: {
254
296
  vendorId: "",
255
297
  productId: "",
@@ -279,6 +321,16 @@ const visitorQrGateOptions = computed(() => readers.value
279
321
  title: String(reader.name || reader.deviceId || reader._id) + " - " + String(reader.portalName || "Portal"),
280
322
  value: reader._id,
281
323
  })));
324
+ const identificationMethodOptions: Array<{
325
+ key: HidIdentificationMethod;
326
+ label: string;
327
+ }> = [
328
+ { key: "facial", label: "Facial" },
329
+ { key: "card", label: "Card" },
330
+ { key: "qrCode", label: "QR Code" },
331
+ { key: "idPassword", label: "ID Password" },
332
+ { key: "pin", label: "PIN" },
333
+ ];
282
334
  const siteName = computed(() => siteData.value?.name || "Site");
283
335
  const siteLabel = computed(() => siteData.value?.code || siteData.value?.block || props.site);
284
336
  const primaryQrGateReaderId = computed(() => (
@@ -319,6 +371,7 @@ async function loadConfig() {
319
371
  const readerList = readerResponse as HidReaderListResponse;
320
372
  readers.value = readerList.items ?? readerList.data?.items ?? readerList.data?.readers ?? [];
321
373
  const config = siteData.value?.metadata?.hidQrCodePass || {};
374
+ const configuredMethods = config.identificationMethods;
322
375
  Object.assign(form, {
323
376
  enabled: Boolean(config.enabled),
324
377
  // Visitor QR is reader-local. Do not restore a legacy Online Mode value
@@ -339,6 +392,14 @@ async function loadConfig() {
339
392
  || "",
340
393
  ),
341
394
  qrFormat: "0",
395
+ identificationMethods: {
396
+ facial: configuredMethods?.facial ?? true,
397
+ card: configuredMethods?.card ?? true,
398
+ qrCode: configuredMethods?.qrCode ?? Boolean(config.enabled),
399
+ idPassword: configuredMethods?.idPassword ?? true,
400
+ pin: configuredMethods?.pin ?? false,
401
+ bluetooth: false,
402
+ },
342
403
  printer: {
343
404
  vendorId: String(config.printer?.vendorId || ""),
344
405
  productId: String(config.printer?.productId || ""),
@@ -349,25 +410,57 @@ async function loadConfig() {
349
410
  },
350
411
  validityMinutes: config.validityMinutes ? Number(config.validityMinutes) : null,
351
412
  });
413
+
414
+ await loadReaderConfiguration();
415
+ }
416
+
417
+ function isUnknownRecord(value: unknown): value is Record<string, unknown> {
418
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
419
+ }
420
+
421
+ function getConfigurationData(response: unknown) {
422
+ if (!isUnknownRecord(response)) return {};
423
+ return isUnknownRecord(response.data) ? response.data : response;
424
+ }
425
+
426
+ function isEnabledConfiguration(value: unknown) {
427
+ return value === true || value === 1 || value === "1";
428
+ }
429
+
430
+ async function loadReaderConfiguration() {
431
+ if (!form.readerId) return;
432
+
433
+ try {
434
+ const response = await getReaderConfiguration(form.readerId, {
435
+ identifier: [
436
+ "card_identification_enabled",
437
+ "pin_identification_enabled",
438
+ "multi_factor_authentication",
439
+ ],
440
+ });
441
+ const configuration = getConfigurationData(response);
442
+ const identifier = isUnknownRecord(configuration.identifier) ? configuration.identifier : {};
443
+
444
+ if (identifier.pin_identification_enabled !== undefined) {
445
+ const pinEnabled = isEnabledConfiguration(identifier.pin_identification_enabled);
446
+ form.identificationMethods.pin = pinEnabled;
447
+ form.identificationMethods.idPassword = !pinEnabled;
448
+ }
449
+ if (identifier.card_identification_enabled !== undefined) {
450
+ form.identificationMethods.card = isEnabledConfiguration(
451
+ identifier.card_identification_enabled,
452
+ );
453
+ }
454
+ } catch (error: unknown) {
455
+ console.warn("Unable to load HID reader configuration:", errorConverter(error));
456
+ }
352
457
  }
353
458
 
354
459
  function buildPayload() {
355
- /*
356
- * `enabled` and `identificationMethods` are passed through from what was
357
- * loaded, never recomputed.
358
- *
359
- * Which credentials a reader accepts now lives on the READER record and is
360
- * set from HID Readers > Identification Methods, because the device is what
361
- * holds them. The toggles that used to derive these two values are gone from
362
- * this screen, so deriving them again from a form that no longer has them
363
- * would erase the stored copy and flip `enabled` every time somebody saved
364
- * the printer settings.
365
- */
366
- const storedQrPass = siteData.value?.metadata?.hidQrCodePass || {};
367
460
  const metadata = {
368
461
  ...(siteData.value?.metadata || {}),
369
462
  hidQrCodePass: {
370
- enabled: Boolean(storedQrPass.enabled),
463
+ enabled: form.identificationMethods.qrCode,
371
464
  onlineMode: false,
372
465
  // Kept only for old background/mobile flows. Gate permissions, not this
373
466
  // compatibility value, decide where a new Visitor QR may be scanned.
@@ -378,9 +471,7 @@ function buildPayload() {
378
471
  },
379
472
  // Visitor QR passes always use Amico alphanumeric qrcodes.
380
473
  qrFormat: "0",
381
- ...(storedQrPass.identificationMethods
382
- ? { identificationMethods: storedQrPass.identificationMethods }
383
- : {}),
474
+ identificationMethods: { ...form.identificationMethods },
384
475
  printer: {
385
476
  vendorId: form.printer.vendorId.trim(),
386
477
  productId: form.printer.productId.trim(),
@@ -416,6 +507,43 @@ async function saveSection(section: string) {
416
507
  }
417
508
  }
418
509
 
510
+ async function saveIdentificationMethod(method: HidIdentificationMethod) {
511
+ if (!props.site) return;
512
+
513
+ form.enabled = form.identificationMethods.qrCode;
514
+
515
+ savingSection.value = `method-${method}`;
516
+ try {
517
+ if (method === "card") {
518
+ await setReaderConfiguration(form.readerId, {
519
+ identifier: {
520
+ card_identification_enabled: form.identificationMethods.card ? "1" : "0",
521
+ },
522
+ });
523
+ } else if (method === "pin" || method === "idPassword") {
524
+ if (method === "pin" && form.identificationMethods.pin) {
525
+ form.identificationMethods.idPassword = false;
526
+ } else if (method === "idPassword" && form.identificationMethods.idPassword) {
527
+ form.identificationMethods.pin = false;
528
+ }
529
+ await setReaderConfiguration(form.readerId, {
530
+ identifier: {
531
+ pin_identification_enabled: form.identificationMethods.pin ? "1" : "0",
532
+ // Mode 1: PIN is an alternative credential, never a second factor.
533
+ multi_factor_authentication: "0",
534
+ },
535
+ });
536
+ }
537
+ await updateSitebyId(props.site, buildPayload());
538
+ showMessage(`${identificationMethodOptions.find((item) => item.key === method)?.label || "Identification method"} updated.`, "success");
539
+ } catch (error: unknown) {
540
+ await loadConfig();
541
+ showMessage(errorConverter(error), "error");
542
+ } finally {
543
+ savingSection.value = "";
544
+ }
545
+ }
546
+
419
547
  async function scanPrinter() {
420
548
  if (!("usb" in navigator)) {
421
549
  showMessage("USB printer scan is not available in this browser.", "error");
@@ -523,6 +651,51 @@ function showMessage(text: string, color: string) {
523
651
  padding: 16px 0;
524
652
  }
525
653
 
654
+ .identification-section {
655
+ padding-bottom: 20px;
656
+ }
657
+
658
+ .methods-grid {
659
+ display: grid;
660
+ grid-template-columns: repeat(6, minmax(120px, 1fr));
661
+ gap: 18px;
662
+ margin-top: 16px;
663
+ }
664
+
665
+ .method-control {
666
+ display: flex;
667
+ align-items: center;
668
+ justify-content: space-between;
669
+ min-width: 0;
670
+ min-height: 42px;
671
+ padding: 0 10px 0 14px;
672
+ border: 1px solid var(--border);
673
+ border-radius: var(--r-inner);
674
+ color: var(--text2);
675
+ font-family: var(--font-sans);
676
+ font-size: 12px;
677
+ font-weight: 700;
678
+ }
679
+
680
+ .method-control span {
681
+ overflow: hidden;
682
+ text-overflow: ellipsis;
683
+ white-space: nowrap;
684
+ }
685
+
686
+ .method-control--disabled {
687
+ background-color: var(--hover);
688
+ color: var(--muted);
689
+ }
690
+
691
+ .method-control :deep(.v-switch) {
692
+ flex: 0 0 auto;
693
+ }
694
+
695
+ .method-control :deep(.v-selection-control) {
696
+ min-height: 32px;
697
+ }
698
+
526
699
  /* The three `.hid-config-switch` rules are gone: `.app-switch` in
527
700
  primitives.css is the handoff's toggle, and it is shared with the other two
528
701
  HID panels that have one. */
@@ -694,6 +867,10 @@ function showMessage(text: string, color: string) {
694
867
  }
695
868
 
696
869
  @media (max-width: 1100px) {
870
+ .methods-grid {
871
+ grid-template-columns: repeat(3, minmax(140px, 1fr));
872
+ }
873
+
697
874
  .printer-grid,
698
875
  .reader-grid,
699
876
  .template-grid,
@@ -714,6 +891,7 @@ function showMessage(text: string, color: string) {
714
891
  .reader-grid,
715
892
  .template-grid,
716
893
  .validity-grid,
894
+ .methods-grid,
717
895
  .permission-location,
718
896
  .permission-row,
719
897
  .permission-actions {