@7365admin1/layer-common 4.97.1-staging.560 → 4.97.1-staging.561

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.
@@ -129,7 +129,11 @@
129
129
  </span>
130
130
  <v-spacer />
131
131
  <AppButton variant="ghost" :disabled="saving" @click="open = false">Cancel</AppButton>
132
+ <!-- Reachable only from a menu item the users right draws; the same
133
+ right is asked again here so the dialog stays read only if it is
134
+ ever opened some other way. -->
132
135
  <AppButton
136
+ v-if="canManageHidUsers"
133
137
  icon="mdi-content-save-outline"
134
138
  :loading="saving"
135
139
  :disabled="!readerLocation || !dirty || saving"
@@ -185,6 +189,8 @@ const props = defineProps<{
185
189
  reader: Record<string, unknown> | null;
186
190
  }>();
187
191
 
192
+ const { canManageHidUsers } = useHidAccessPermission();
193
+
188
194
  const emit = defineEmits<{
189
195
  (event: "update:modelValue", value: boolean): void;
190
196
  (event: "saved"): void;
@@ -22,16 +22,14 @@
22
22
  denial here would flash "no permission" at the owner on every load. -->
23
23
  <template v-if="!isAppRoleResolved" />
24
24
 
25
- <slot v-else-if="hidEnabled && canAccessHidScreens" />
25
+ <slot v-else-if="hidEnabled && permitted" />
26
26
 
27
27
  <div v-else-if="hidEnabled" class="screen-empty hid-gate">
28
28
  <span class="hid-gate__icon tone-info">
29
29
  <v-icon icon="mdi-lock-outline" size="24" />
30
30
  </span>
31
- <h2 class="hid-gate__title">You do not have permission for HID access management</h2>
32
- <p class="hid-gate__body">
33
- Ask an administrator to grant your role access card management for this site.
34
- </p>
31
+ <h2 class="hid-gate__title">{{ deniedTitle }}</h2>
32
+ <p class="hid-gate__body">{{ deniedBody }}</p>
35
33
  </div>
36
34
 
37
35
  <div v-else class="screen-empty hid-gate">
@@ -50,10 +48,18 @@ const props = withDefaults(
50
48
  org: string;
51
49
  message?: string;
52
50
  redirectToSettings?: boolean;
51
+ /**
52
+ * Which HID right opens the screen behind this gate. `view` is the admin
53
+ * screens (readers, users, cards, intercom, access logs: `canViewHid`);
54
+ * `use` is the member's own HID QR Code page (`canUseHid`). Defaults to the
55
+ * stricter one, so a page that forgets to say is an admin page.
56
+ */
57
+ level?: "view" | "use";
53
58
  }>(),
54
59
  {
55
60
  message: "Enable HID as a service for this site before accessing this screen.",
56
61
  redirectToSettings: true,
62
+ level: "view",
57
63
  },
58
64
  );
59
65
 
@@ -61,13 +67,26 @@ const { getSiteById } = useSiteSettings();
61
67
  const { getHidServiceEnabled } = useOptionalServices();
62
68
 
63
69
  // The permission half of the same gate. This component is the only thing all
64
- // six `access-mgmt` pages have in common, so putting the check here governs all
65
- // six -- and all 66 inherited routes across the eleven apps -- without a page
66
- // guard per screen. See `composables/useHidAccessPermission.ts` for why the
67
- // gate cannot remove access that currently works.
68
- const { canAccessHidScreens } = useHidAccessPermission();
70
+ // seven `access-mgmt` HID pages have in common, so putting the check here
71
+ // governs all of them, and every inherited route across the eleven apps,
72
+ // without a page guard per screen. See `composables/useHidAccessPermission.ts`
73
+ // for the five flags and the alias period.
74
+ const { canViewHid, canUseHid } = useHidAccessPermission();
69
75
  const { isAppRoleResolved } = useLocalSetup();
70
76
 
77
+ const permitted = computed(() => (props.level === "use" ? canUseHid.value : canViewHid.value));
78
+
79
+ const deniedTitle = computed(() =>
80
+ props.level === "use"
81
+ ? "You do not have permission for HID access"
82
+ : "You do not have permission for HID access management",
83
+ );
84
+ const deniedBody = computed(() =>
85
+ props.level === "use"
86
+ ? "Ask an administrator to grant your role HID access for this site."
87
+ : "Ask an administrator to grant your role HID management for this site.",
88
+ );
89
+
71
90
  // Do not await this request during route setup. Every HID page uses this gate;
72
91
  // awaiting it makes Nuxt Suspense keep rendering the previous page until the
73
92
  // site request finishes, so the URL changes while the visible module appears
@@ -46,16 +46,18 @@
46
46
  @update:page="page = $event"
47
47
  >
48
48
  <!-- The action swaps with the tab, as it did in the old top bar. -->
49
+ <!-- Contacts are reader objects, so adding one is the readers right.
50
+ The web call is a member level call and stays for everyone. -->
49
51
  <template #actions>
50
52
  <AppButton
51
- v-if="activeTab === 'contacts'"
53
+ v-if="activeTab === 'contacts' && canManageHidReaders"
52
54
  icon="mdi-plus"
53
55
  @click="openContactDialog()"
54
56
  >
55
57
  Add Contacts
56
58
  </AppButton>
57
59
  <AppButton
58
- v-else
60
+ v-else-if="activeTab !== 'contacts'"
59
61
  icon="mdi-phone-in-talk-outline"
60
62
  class="web-call-button"
61
63
  :class="webPhoneButtonClass"
@@ -151,23 +153,30 @@
151
153
  <template #activator="{ props: menuProps }">
152
154
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
153
155
  </template>
156
+ <!-- The reader's SIP settings, call settings, dial code and contacts
157
+ are reader configuration: the readers right. View and the status
158
+ check stay for the view right. -->
154
159
  <v-list v-if="activeTab === 'intercom'" density="compact" class="screen-menu">
155
160
  <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openViewDialog(item)" />
156
- <v-list-item
157
- class="screen-menu__item"
158
- title="Test Connection with SIP"
159
- prepend-icon="mdi-lan-check"
160
- :disabled="testingSipReaderId === item.reader._id"
161
- @click="testSipConnection(item)"
162
- />
163
- <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
164
- <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
161
+ <template v-if="canManageHidReaders">
162
+ <v-list-item
163
+ class="screen-menu__item"
164
+ title="Test Connection with SIP"
165
+ prepend-icon="mdi-lan-check"
166
+ :disabled="testingSipReaderId === item.reader._id"
167
+ @click="testSipConnection(item)"
168
+ />
169
+ <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
170
+ <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
171
+ </template>
165
172
  </v-list>
166
173
  <v-list v-else density="compact" class="screen-menu">
167
174
  <v-list-item class="screen-menu__item" title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
168
175
  <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openContactView(item)" />
169
- <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
170
- <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
176
+ <template v-if="canManageHidReaders">
177
+ <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
178
+ <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
179
+ </template>
171
180
  </v-list>
172
181
  </v-menu>
173
182
  </template>
@@ -749,6 +758,10 @@ type IntercomRow = {
749
758
  pjsip: Record<string, unknown>;
750
759
  };
751
760
 
761
+ // Reader configuration (SIP, call settings, dial code, contacts) is the readers
762
+ // right. The screen itself is behind `HidEnabledGate` (the view right).
763
+ const { canManageHidReaders } = useHidAccessPermission();
764
+
752
765
  const {
753
766
  getReaders,
754
767
  getReaderConfiguration,
@@ -121,7 +121,7 @@ import type { HidProfileQr } from "../composables/useHidAmico";
121
121
 
122
122
  const props = defineProps<{ site: string }>();
123
123
 
124
- const { getReaders, getProfileQr, issueProfileQr, deleteProfileQr } = useHidAmico();
124
+ const { getEnrollmentReaders, getProfileQr, issueProfileQr, deleteProfileQr } = useHidAmico();
125
125
 
126
126
  type HidReaderOption = { _id: string; name?: string; portalName?: string };
127
127
 
@@ -200,7 +200,11 @@ function downloadQr() {
200
200
 
201
201
  async function loadReaders() {
202
202
  if (!props.site) return;
203
- const response = toRecord(await getReaders({ site: props.site, page: 1, limit: 100 }));
203
+ /* The self service list, not the admin one. `GET /readers` sits behind the
204
+ HID view right, so a member holding only `hid-mgmt:use-hid-access` (the
205
+ right this page is drawn for) was refused before the picker could fill.
206
+ `enrollment-readers` is the same site's enabled readers, for members. */
207
+ const response = toRecord(await getEnrollmentReaders(props.site));
204
208
  const data = toRecord(response.data);
205
209
  const items = response.items ?? data.items ?? data.readers ?? [];
206
210
  readers.value = (Array.isArray(items) ? items : []).filter((reader) => reader?._id);
@@ -29,7 +29,10 @@
29
29
  show-header
30
30
  @refresh="loadReaders"
31
31
  >
32
- <template #actions>
32
+ <!-- Hidden, not disabled, for a member without the right: the server
33
+ refuses the call anyway, and a button that cannot work is noise.
34
+ `hid-mgmt:manage-hid-readers` (`useHidAccessPermission`). -->
35
+ <template v-if="canManageHidReaders" #actions>
33
36
  <AppButton icon="mdi-plus" @click="openAdd">Add HID Reader</AppButton>
34
37
  </template>
35
38
 
@@ -85,14 +88,23 @@
85
88
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
86
89
  </template>
87
90
 
91
+ <!-- View is the view right. Access Permissions assigns people to the
92
+ reader's group, so it is the users right; everything else acts on
93
+ the reader itself and is the readers right. -->
88
94
  <v-list density="compact" min-width="180">
89
95
  <v-list-item title="View" @click="openView(item)" />
90
- <v-list-item title="Access Permissions" @click="openPermissions(item)" />
91
- <v-list-item title="Identification Methods" @click="openIdentification(item)" />
92
- <v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
93
- <v-list-item title="Test Connection" @click="openTestConfirm(item)" />
94
- <v-list-item title="Edit" @click="openEdit(item)" />
95
- <v-list-item title="Delete" class="text-error" @click="openDeleteConfirm(item)" />
96
+ <v-list-item
97
+ v-if="canManageHidUsers"
98
+ title="Access Permissions"
99
+ @click="openPermissions(item)"
100
+ />
101
+ <template v-if="canManageHidReaders">
102
+ <v-list-item title="Identification Methods" @click="openIdentification(item)" />
103
+ <v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
104
+ <v-list-item title="Test Connection" @click="openTestConfirm(item)" />
105
+ <v-list-item title="Edit" @click="openEdit(item)" />
106
+ <v-list-item title="Delete" class="text-error" @click="openDeleteConfirm(item)" />
107
+ </template>
96
108
  </v-list>
97
109
  </v-menu>
98
110
  </template>
@@ -136,7 +148,7 @@
136
148
  <span>Username</span><strong>{{ selectedReader?.username || "N/A" }}</strong>
137
149
  </div>
138
150
 
139
- <div class="dialog-actions-inline">
151
+ <div v-if="canManageHidReaders" class="dialog-actions-inline">
140
152
  <AppButton variant="ghost" @click="openTestConfirm(selectedReader)">Test Connection</AppButton>
141
153
  <AppButton variant="ghost" @click="openSyncConfirm(selectedReader)">Sync Reader</AppButton>
142
154
  </div>
@@ -481,6 +493,10 @@ const props = defineProps({
481
493
  },
482
494
  });
483
495
 
496
+ // Which buttons this member gets. The screen itself is behind `HidEnabledGate`
497
+ // (the view right); these two decide the write actions on it.
498
+ const { canManageHidReaders, canManageHidUsers } = useHidAccessPermission();
499
+
484
500
  const {
485
501
  getReaders,
486
502
  createReader,
@@ -68,7 +68,8 @@
68
68
  </span>
69
69
  </template>
70
70
 
71
- <template #[`item.action-table`]="{ item }">
71
+ <!-- Setting a PIN is the users right; the roster itself is the view right. -->
72
+ <template v-if="canManageHidUsers" #[`item.action-table`]="{ item }">
72
73
  <AppButton
73
74
  variant="row"
74
75
  icon="mdi-form-textbox-password"
@@ -199,6 +200,7 @@ type HidReaderUser = Record<string, unknown> & {
199
200
  metadata?: HidMetadata;
200
201
  };
201
202
 
203
+ const { canManageHidUsers } = useHidAccessPermission();
202
204
  const {
203
205
  getReaders,
204
206
  getReaderUsers,
@@ -53,7 +53,9 @@
53
53
  @refresh="loadUsers"
54
54
  @update:page="goToPage"
55
55
  >
56
- <template v-if="!props.cardManagement" #actions>
56
+ <!-- Enrolling is the users right (`hid-mgmt:manage-hid-users`). Hidden,
57
+ not disabled: the server refuses the call for a member without it. -->
58
+ <template v-if="!props.cardManagement && canManageHidUsers" #actions>
57
59
  <AppButton icon="mdi-account-plus" @click="openEnroll"
58
60
  >Enroll</AppButton
59
61
  >
@@ -141,14 +143,14 @@
141
143
 
142
144
  <template #[`item.action-table`]="{ item }">
143
145
  <AppButton
144
- v-if="props.cardManagement"
146
+ v-if="props.cardManagement && canManageHidUsers"
145
147
  variant="secondary"
146
148
  icon="mdi-card-account-details-outline"
147
149
  @click="openCardManager(item)"
148
150
  >
149
151
  Manage
150
152
  </AppButton>
151
- <v-menu v-else>
153
+ <v-menu v-else-if="!props.cardManagement">
152
154
  <template #activator="{ props: menuProps }">
153
155
  <AppButton
154
156
  v-bind="menuProps"
@@ -159,16 +161,18 @@
159
161
 
160
162
  <v-list density="compact" min-width="150">
161
163
  <v-list-item title="View" @click="openView(item)" />
162
- <v-list-item title="Edit" @click="openEdit(item)" />
163
- <v-list-item
164
- title="Manage HID Cards"
165
- @click="openCardManager(item)"
166
- />
167
- <v-list-item
168
- title="Delete"
169
- class="text-error"
170
- @click="openDelete(item)"
171
- />
164
+ <template v-if="canManageHidUsers">
165
+ <v-list-item title="Edit" @click="openEdit(item)" />
166
+ <v-list-item
167
+ title="Manage HID Cards"
168
+ @click="openCardManager(item)"
169
+ />
170
+ <v-list-item
171
+ title="Delete"
172
+ class="text-error"
173
+ @click="openDelete(item)"
174
+ />
175
+ </template>
172
176
  </v-list>
173
177
  </v-menu>
174
178
  </template>
@@ -1261,6 +1265,10 @@ const props = defineProps({
1261
1265
  },
1262
1266
  });
1263
1267
 
1268
+ // Enrol, edit, delete, cards and PINs are all the users right. The screen
1269
+ // itself is behind `HidEnabledGate` (the view right).
1270
+ const { canManageHidUsers } = useHidAccessPermission();
1271
+
1264
1272
  const {
1265
1273
  getReaders,
1266
1274
  getIdentities,
@@ -186,7 +186,9 @@
186
186
  </v-expansion-panel-text>
187
187
  </v-expansion-panel>
188
188
 
189
- <v-expansion-panel>
189
+ <!-- HID on or off for the site and the HID QR configuration:
190
+ `hid-mgmt:manage-hid-settings` (`useHidAccessPermission`). -->
191
+ <v-expansion-panel v-if="canManageHidSettings">
190
192
  <v-expansion-panel-title>
191
193
  <v-icon class="mr-2">mdi-face-recognition</v-icon>
192
194
  HID Face Reader
@@ -304,6 +306,7 @@ const { canManageSiteInformation,
304
306
  canManageVehicleQr,
305
307
  canManageSiteSettings: canManageAnySiteSetting,
306
308
  } = useSettingsPermission();
309
+ const { canManageHidSettings } = useHidAccessPermission();
307
310
 
308
311
  const { getSiteById, updateSitebyId, updateSiteInformation } =
309
312
  useSiteSettings();
@@ -673,7 +673,7 @@ const {
673
673
  const { getBySiteId: getEntryPassSettingsBySiteId } =
674
674
  useSiteEntryPassSettings();
675
675
  const { createVisitorPass, signQr, visitorCheckout } = useAccessManagement();
676
- const { getReaders, issueVisitorQr } = useHidAmico();
676
+ const { getEnrollmentReaders, issueVisitorQr } = useHidAmico();
677
677
  const { testConnection } = useWebUsb();
678
678
  const {
679
679
  findPersonByNRIC,
@@ -1561,8 +1561,14 @@ watch(
1561
1561
  hidQrReader.value = null;
1562
1562
  if (!site) return;
1563
1563
  try {
1564
- const response = await getReaders({ site, page: 1, limit: 100 });
1565
- const readers: unknown = response?.items ?? response?.data?.items ?? response?.data?.readers ?? [];
1564
+ /* The member's list, not the admin one. `POST /readers/:id/visitor-qr`
1565
+ asks for membership plus `hid-mgmt:use-hid-access` (API-core #1772),
1566
+ while `GET /readers` asks for the HID view right, so a member who may
1567
+ issue a visitor pass but holds no admin right got the pass route and
1568
+ not the reader it needs. `enrollment-readers` is the site's enabled
1569
+ readers with a portal, `{ data: { items } }`, for any member. */
1570
+ const response = await getEnrollmentReaders(site);
1571
+ const readers: unknown = response?.data?.items ?? [];
1566
1572
  const availableReaders = Array.isArray(readers)
1567
1573
  ? readers.filter((reader: unknown): reader is HidQrReaderSummary => (
1568
1574
  typeof reader === "object"
@@ -83,6 +83,17 @@ export default function useCleaningPermission() {
83
83
  description: "Allows the user to manage and update site settings.",
84
84
  },
85
85
  },
86
+ // HID access, user side only (decision of 2026-10-16). The service apps
87
+ // have no HID admin screens yet, so a role here can be prepared with the
88
+ // one string that lets a member use their own QR code, face, PIN, card and
89
+ // intercom. Mirrored from core `src/utils/hid-access.util.ts`.
90
+ "hid-mgmt": {
91
+ "use-hid-access": {
92
+ check: true,
93
+ description:
94
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
95
+ },
96
+ },
86
97
  toilet_locations: {
87
98
  "create-toilet-location": {
88
99
  check: true,
@@ -1,124 +1,217 @@
1
+ import { permissionsDenied } from "../utils/module-routes";
2
+
1
3
  /**
2
- * WHO MAY REACH THE SIX HID `access-mgmt` SCREENS.
3
- *
4
- * `pages/[org]/[site]/access-mgmt/{access-logs, administrator, hid-cards,
5
- * hid-readers, hid-users, intercom}/index.vue` shipped with
6
- * `middleware: ["01-auth","02-org"], memberOnly: true` and no permission check
7
- * at all. Every one of the eleven Nuxt apps inherits all six, so that was 66
8
- * routes on which any member of any organisation could type the URL and reach
9
- * door access, biometric enrolment, physical cards and the access log. The menu
10
- * that links five of them (`useHidNavigation`) is gated on
11
- * `getHidServiceEnabled(site)` -- a SITE SERVICE FLAG, not a permission -- so
12
- * the menu was never a boundary either.
4
+ * WHO MAY DO WHAT ON HID: the five flags every HID screen, menu and button asks.
13
5
  *
14
- * ## Why adding this gate cannot lock anybody out
6
+ * Decision of 2026-10-16. HID has its own permission resource, `hid-mgmt`, with
7
+ * five actions. Core defines the lists in `src/utils/hid-access.util.ts` and
8
+ * every `/api/access-management/hid` route reads them; this package does not
9
+ * depend on `@7365admin1/core`, so the strings are copied here and
10
+ * `test/hid-access-gate.test.mjs` pins the copy to the five.
15
11
  *
16
- * Every data call these screens make goes through `useHidAmico` to
17
- * `/api/access-management/hid`, and every route there carries `requireAuth`
18
- * plus `authorizeView` or `authorizeManage`. Those resolve through
19
- * `authorizeHidAccess` (`core/services/hid-amico.service.ts`) to the lists in
20
- * `core/utils/hid-access.util.ts` -- the nine `access-card-mgmt` strings below.
12
+ * canUseHid hid-mgmt:use-hid-access own QR, face, PIN, card,
13
+ * intercom; the HID QR Code page
14
+ * canViewHid hid-mgmt:see-all-hid open any HID admin screen
15
+ * canManageHidReaders hid-mgmt:manage-hid-readers add, configure, test, sync,
16
+ * remove readers
17
+ * canManageHidUsers hid-mgmt:manage-hid-users enrol and remove people,
18
+ * cards, PINs, access groups
19
+ * canManageHidSettings hid-mgmt:manage-hid-settings HID on or off, QR configuration
21
20
  *
22
- * WARNING: there are TWO different `HID_MANAGE_PERMISSIONS` in `core` and they
23
- * are NOT the same list. `hid-amico-authz.util.ts` exports
24
- * `["site-settings:manage-entry-pass"]`; `hid-access.util.ts` exports the
25
- * `access-card-mgmt` family. `hid-amico.service.ts` imports the one from
26
- * `hid-access.util.ts` -- and `authorizeSiteForCaller`'s own doc comment is
27
- * stale and still claims the other. Follow the import, not the name.
21
+ * ## The rules, in the order each flag applies them
28
22
  *
29
- * So a member holding none of these strings already gets a 401 on every list
30
- * call on all six screens: the screens are non-functional for them today, and
31
- * they see chrome plus an error toast. The set this gate refuses is a strict
32
- * SUBSET of the set the server already refuses in production, which is a
33
- * stronger guarantee than the usual widen-never-swap argument because it is
34
- * anchored on live server behaviour rather than on a role census.
23
+ * 1. No role loaded: false. `userAppRole` is null on the first tick for
24
+ * everyone, the `*` owner included; `HidEnabledGate` waits on
25
+ * `isAppRoleResolved` before it draws a refusal.
26
+ * 2. The client's module list (RP-5): `hid-mgmt` denied closes every flag,
27
+ * including for a wildcard role. A wildcard role is exactly the role a
28
+ * module list exists to narrow, so this is asked BEFORE the `*` check.
29
+ * 3. `*` passes every flag.
30
+ * 4. An EMPTY permission list passes nothing. This is deliberately not the
31
+ * estate rule `hasPermission` applies (`grantsPermission`: empty means
32
+ * everything). The owner's decision for HID is strict on empty, everywhere,
33
+ * so the empty list is refused here before `hasPermission` can widen it.
34
+ * 5. Either manage right implies view: a role holding only
35
+ * `manage-hid-readers` could otherwise create a reader and not list them.
36
+ * Settings does NOT imply view, and use implies nothing.
35
37
  *
36
- * `site-settings:manage-entry-pass` is unioned in -- it is what
37
- * `hid-amico-authz.util.ts` enforces on the entry-pass paths and the string the
38
- * HID menu has always been associated with -- and `*` keeps its short-circuit.
38
+ * ## The alias period
39
39
  *
40
- * ## Intercom is gated with the other five
40
+ * Until the live roles are backfilled onto `hid-mgmt`, core still accepts the
41
+ * Access Cards strings HID borrowed before, at the levels
42
+ * `HID_LEGACY_VIEW_PERMISSIONS` and `HID_LEGACY_MANAGE_PERMISSIONS` give them:
43
+ * `see-all-card`, `see-all-qr-tagging` and `view` open the admin screens; the
44
+ * five card write strings and `manage-hid` manage readers and users; only
45
+ * `manage-hid` reaches settings. The same strings pass here at the same levels,
46
+ * so nothing that works today stops working before the backfill. The follow-up
47
+ * that drops the aliases deletes the `legacy*` branches below and the two
48
+ * `RETIRED_PERMISSIONS` in `constants/permissions.ts` together.
41
49
  *
42
- * `intercom` was the one screen that might have lived entirely on
43
- * `authorizeMember` endpoints (`/intercom/status`, `/intercom/call`,
44
- * `/intercom/hangup`). It does not. `HidIntercomManagement.reload()` opens with
45
- * `getReaders()` (`GET /readers`, `authorizeView`) and filters its rows out of
46
- * that response; the contacts tab, the dial-code dialog, the make-call dialog
47
- * and the web phone are all reached from a row, and `loadSipAccount()` is only
48
- * ever called from one of those dialogs. Without `authorizeView` the screen is
49
- * an empty table and an error, so gating it removes nothing that works.
50
+ * `site-settings:manage-entry-pass` is Entry Pass only again. It opened the HID
51
+ * screens from 4.2.14 to this release because a core utility of the same name
52
+ * once listed it; it never opened a HID endpoint.
50
53
  *
51
54
  * ## Drawing, not securing
52
55
  *
53
- * The server re-decides every HID call on its own. This hides screens that do
54
- * not work; it does not add protection the API does not already have.
56
+ * The server re-decides every HID call on its own. These flags hide screens and
57
+ * buttons that would be refused; they add no protection the API lacks.
55
58
  */
56
59
 
57
60
  /**
58
- * The nine strings `core/utils/hid-access.util.ts` enforces, view + manage.
59
- *
60
- * Written out in full `resource:action` form on purpose. `permission-vocabulary`
61
- * harvests what this package checks by reading literals out of the source, and a
62
- * bare action fed through a loop into `hasPermission(role, cat, "access-card-mgmt",
63
- * action)` is invisible to it. Spelling the strings out keeps all nine visible.
61
+ * Written out in full `resource:action` form on purpose: `permission-vocabulary`
62
+ * harvests what this package checks by reading literals out of the source, and
63
+ * a string built from a loop is invisible to it.
64
64
  */
65
- const HID_PERMISSIONS = [
65
+ export const HID_RESOURCE = "hid-mgmt";
66
+
67
+ export const HID_PERMISSION_STRINGS = [
68
+ "hid-mgmt:use-hid-access",
69
+ "hid-mgmt:see-all-hid",
70
+ "hid-mgmt:manage-hid-readers",
71
+ "hid-mgmt:manage-hid-users",
72
+ "hid-mgmt:manage-hid-settings",
73
+ ] as const;
74
+
75
+ /** Core `HID_LEGACY_VIEW_PERMISSIONS`: open the admin screens during the alias period. */
76
+ export const HID_LEGACY_VIEW_PERMISSIONS = [
66
77
  "access-card-mgmt:see-all-card",
67
78
  "access-card-mgmt:see-all-qr-tagging",
68
79
  "access-card-mgmt:view",
80
+ ] as const;
81
+
82
+ /** Core `HID_LEGACY_MANAGE_PERMISSIONS`: manage readers and users during the alias period. */
83
+ export const HID_LEGACY_MANAGE_PERMISSIONS = [
69
84
  "access-card-mgmt:add-access-card",
70
85
  "access-card-mgmt:update-access-card",
71
- "access-card-mgmt:replace-access-card",
72
86
  "access-card-mgmt:delete-access-card",
73
87
  "access-card-mgmt:assign-access-card",
88
+ "access-card-mgmt:replace-access-card",
74
89
  "access-card-mgmt:manage-hid",
75
90
  ] as const;
76
91
 
77
- const HID_ACTIONS = HID_PERMISSIONS.map((p) => p.split(":")[1]);
92
+ const HID_ACTIONS = HID_PERMISSION_STRINGS.map((p) => p.split(":")[1]);
93
+ const LEGACY_ACTIONS = [...HID_LEGACY_VIEW_PERMISSIONS, ...HID_LEGACY_MANAGE_PERMISSIONS].map(
94
+ (p) => p.split(":")[1],
95
+ );
78
96
 
79
97
  export function useHidAccessPermission() {
80
98
  const { hasPermission } = usePermission();
81
- const { siteSettingsPermissions } = useCommonPermissions();
82
- const { userAppRole } = useLocalSetup();
99
+ const { userAppRole, userAppModulesDenied } = useLocalSetup();
83
100
 
84
- // `hasPermission` needs BOTH the role's string AND a catalogue entry for it:
85
- // a resource missing from the catalogue is a dead gate however the role is
86
- // granted. `access-card-mgmt` exists in no shared catalogue composable, so it
87
- // is built here, exactly as `useServiceProviderPermission` builds its own.
101
+ // `hasPermission` needs BOTH the role's string AND a catalogue entry for it.
102
+ // The property and security catalogues carry `hid-mgmt`, the four service
103
+ // catalogues carry only `use-hid-access`, and no catalogue offers the retired
104
+ // `view` and `manage-hid` any more, so the lookup table is built here: these
105
+ // flags must answer the same in every app that mounts a HID screen.
88
106
  const permissions: TPermissions = {
107
+ "hid-mgmt": Object.fromEntries(
108
+ HID_ACTIONS.map((action) => [action, { check: true, description: `HID: ${action}.` }]),
109
+ ),
89
110
  "access-card-mgmt": Object.fromEntries(
90
- HID_ACTIONS.map((action) => [
111
+ LEGACY_ACTIONS.map((action) => [
91
112
  action,
92
- {
93
- check: true,
94
- description: `Allows the user to reach the HID access management screens (${action}).`,
95
- },
113
+ { check: true, description: `HID alias period: access-card-mgmt:${action}.` },
96
114
  ]),
97
115
  ),
98
- "site-settings": siteSettingsPermissions,
99
116
  };
100
117
 
118
+ // `?.` on purpose: an app pinned to an older layer-common, or a caller that
119
+ // stubs `useLocalSetup` without this field, hands back `undefined` here. That
120
+ // must mean "nothing denied", never a TypeError inside every gate.
121
+ const moduleDenied = (...modules: string[]) =>
122
+ permissionsDenied(modules, userAppModulesDenied?.value);
123
+
101
124
  /**
102
- * Can this member open a HID `access-mgmt` screen at all? Any single string
103
- * the server accepts is enough -- somebody granted only `delete-access-card`
104
- * still has to open the screen to use it.
125
+ * Rules 1 to 4. `null` means "decide from the strings"; a boolean is final.
126
+ * The empty list is refused HERE because `hasPermission` would admit it.
105
127
  */
106
- const canAccessHidScreens = computed(() => {
128
+ function decided(): boolean | null {
107
129
  const role = userAppRole.value;
108
130
  if (!role) return false;
109
- if (role.permissions.includes("*")) return true;
110
- if (hasPermission(role, permissions, "site-settings", "manage-entry-pass")) return true;
111
- return HID_ACTIONS.some((action) =>
112
- hasPermission(role, permissions, "access-card-mgmt", action),
113
- );
114
- });
115
-
116
- // Only the gate is returned. `isAppRoleResolved` is deliberately NOT
117
- // re-exported: `gate-defaults.test.mjs` sweeps every ref a permission
118
- // composable returns and requires it to read false for an unresolved role,
119
- // which a "has the lookup finished" flag is not. Callers that need it take it
120
- // from `useLocalSetup()`, which is where it lives.
121
- return { canAccessHidScreens };
131
+ if (moduleDenied("hid-mgmt")) return false;
132
+ const held: unknown = role.permissions;
133
+ if (!Array.isArray(held) || !held.length) return false;
134
+ if (held.includes("*")) return true;
135
+ return null;
136
+ }
137
+
138
+ // Only reached once `decided()` has answered `null`, so the role is loaded.
139
+ const has = (resource: string, action: string) => {
140
+ const role = userAppRole.value;
141
+ return Boolean(role) && hasPermission(role, permissions, resource, action);
142
+ };
143
+
144
+ // The alias period, string by string so both source sweeps can see them.
145
+ const legacyView = () =>
146
+ has("access-card-mgmt", "see-all-card") ||
147
+ has("access-card-mgmt", "see-all-qr-tagging") ||
148
+ has("access-card-mgmt", "view");
149
+ const legacyManage = () =>
150
+ has("access-card-mgmt", "add-access-card") ||
151
+ has("access-card-mgmt", "update-access-card") ||
152
+ has("access-card-mgmt", "delete-access-card") ||
153
+ has("access-card-mgmt", "assign-access-card") ||
154
+ has("access-card-mgmt", "replace-access-card") ||
155
+ has("access-card-mgmt", "manage-hid");
156
+ const legacySettings = () => has("access-card-mgmt", "manage-hid");
157
+
158
+ // The five, each as a literal `hasPermission` call so the gate sweep
159
+ // (`gate-defaults.test.mjs`) and the vocabulary sweep both read them.
160
+ const useHid = () => {
161
+ const role = userAppRole.value;
162
+ return Boolean(role) && hasPermission(role, permissions, "hid-mgmt", "use-hid-access");
163
+ };
164
+ const viewHid = () => {
165
+ const role = userAppRole.value;
166
+ return Boolean(role) && hasPermission(role, permissions, "hid-mgmt", "see-all-hid");
167
+ };
168
+ const manageReaders = () => {
169
+ const role = userAppRole.value;
170
+ return Boolean(role) && hasPermission(role, permissions, "hid-mgmt", "manage-hid-readers");
171
+ };
172
+ const manageUsers = () => {
173
+ const role = userAppRole.value;
174
+ return Boolean(role) && hasPermission(role, permissions, "hid-mgmt", "manage-hid-users");
175
+ };
176
+ const manageSettings = () => {
177
+ const role = userAppRole.value;
178
+ return Boolean(role) && hasPermission(role, permissions, "hid-mgmt", "manage-hid-settings");
179
+ };
180
+
181
+ /** The user side: HID Access in the app, own QR, face, PIN, card, intercom. */
182
+ const canUseHid = computed(() => decided() ?? useHid());
183
+
184
+ /** Any manage right implies view (rule 5). */
185
+ const canManageHidReaders = computed(() => decided() ?? (manageReaders() || legacyManage()));
186
+ const canManageHidUsers = computed(() => decided() ?? (manageUsers() || legacyManage()));
187
+ const canViewHid = computed(
188
+ () =>
189
+ decided() ??
190
+ (viewHid() || legacyView() || manageReaders() || manageUsers() || legacyManage()),
191
+ );
192
+
193
+ /** HID on or off for the site, and the HID QR code configuration. */
194
+ const canManageHidSettings = computed(() => decided() ?? (manageSettings() || legacySettings()));
195
+
196
+ /**
197
+ * @deprecated The pre 2026-10 single gate: "may this member open a HID admin
198
+ * screen". Kept for any app on this layer that still reads it; it is
199
+ * `canViewHid` and nothing else. Use the five flags above.
200
+ */
201
+ const canAccessHidScreens = canViewHid;
202
+
203
+ // `isAppRoleResolved` is deliberately NOT re-exported: `gate-defaults.test.mjs`
204
+ // sweeps every ref a permission composable returns and requires it to read
205
+ // false for an unresolved role, which a "has the lookup finished" flag is not.
206
+ // Callers that need it take it from `useLocalSetup()`, which is where it lives.
207
+ return {
208
+ canUseHid,
209
+ canViewHid,
210
+ canManageHidReaders,
211
+ canManageHidUsers,
212
+ canManageHidSettings,
213
+ canAccessHidScreens,
214
+ };
122
215
  }
123
216
 
124
217
  export default useHidAccessPermission;
@@ -204,6 +204,22 @@ export default function useHidAmico() {
204
204
  });
205
205
  }
206
206
 
207
+ /**
208
+ * The readers a member may enrol THEMSELVES on: the site's enabled readers
209
+ * with a portal, each with its credential capabilities, and nothing else.
210
+ *
211
+ * The self service screens (own QR, face, PIN, card) load this instead of
212
+ * `getReaders`: that one is an admin list behind the HID view right, and a
213
+ * member holding only `hid-mgmt:use-hid-access` is refused on it. This route
214
+ * asks for site membership and the use right. Response: `{ data: { items } }`.
215
+ */
216
+ function getEnrollmentReaders(siteId: string) {
217
+ return useNuxtApp().$api<{ data: { items: HidApiRecord[] } }>(
218
+ `${basePath}/sites/${siteId}/enrollment-readers`,
219
+ { method: "GET" },
220
+ );
221
+ }
222
+
207
223
  /**
208
224
  * The signed-in member's own QR code on one reader.
209
225
  *
@@ -679,6 +695,7 @@ export default function useHidAmico() {
679
695
 
680
696
  return {
681
697
  getReaders,
698
+ getEnrollmentReaders,
682
699
  getProfileQr,
683
700
  issueProfileQr,
684
701
  deleteProfileQr,
@@ -3,23 +3,23 @@ import type { ComputedRef, Ref } from "vue";
3
3
  /**
4
4
  * THE HID FACE READER MENU IS A PERMISSION, NOT A SERVICE FLAG.
5
5
  *
6
- * This composable used to draw the five-item "HID Face Reader" group whenever
7
- * `getHidServiceEnabled(site)` was true. That is a SITE SERVICE FLAG — it says
8
- * the estate bought HID, not that this member may use it. Since the six
9
- * `access-mgmt` screens were gated (`HidEnabledGate.vue`, layer-common #1363 /
10
- * 4.2.14) a member without an access-card right still saw all five items and
11
- * only met the refusal after clicking. A module a member cannot use should not
12
- * be in the menu at all.
6
+ * This composable used to draw the six item "HID Face Reader" group whenever
7
+ * `getHidServiceEnabled(site)` was true. That is a SITE SERVICE FLAG: it says
8
+ * the estate bought HID, not that this member may use it. A module a member
9
+ * cannot use should not be in the menu at all, so the menu asks the same
10
+ * questions the pages ask (`useHidAccessPermission`), ANDed with the service
11
+ * flag: no HID service still means no menu.
13
12
  *
14
- * The menu now asks the SAME question the pages ask —
15
- * `useHidAccessPermission().canAccessHidScreens` — ANDed with the service flag,
16
- * so no HID service still means no menu.
13
+ * Decision of 2026-10-16: the admin entries (Face Reader, HID Reader Users, HID
14
+ * Cards, Intercom, Access Logs) follow `canViewHid`; the member's own "HID QR
15
+ * Code" entry follows `canUseHid`. The group is drawn when at least one entry
16
+ * is, so a member holding only `use-hid-access` still finds their QR page, and
17
+ * a member holding only the admin rights does not see a page the server would
18
+ * refuse them. `site-settings:manage-entry-pass` no longer draws anything here.
17
19
  *
18
- * `Layout/NavigationDrawer.vue` used to keep its own hand-written copy of the
19
- * permission list, and that copy was NARROWER than the page gate: it omitted
20
- * `replace-access-card` and `site-settings:manage-entry-pass`. Folding it in
21
- * here therefore WIDENS — nobody who could see the menu can lose it — and
22
- * leaves one list in one place.
20
+ * `Layout/NavigationDrawer.vue` keeps no permission list of its own: it takes
21
+ * `menuItem` from here and runs it through `withoutDeniedRoutes`, where the
22
+ * client's module list (`hid-mgmt`) can take the whole group away again.
23
23
  */
24
24
 
25
25
  type HidNavigationParams = {
@@ -32,14 +32,21 @@ type HidNavigationSite = Record<string, unknown>;
32
32
  export default function useHidNavigation() {
33
33
  const { getSiteById } = useSiteSettings();
34
34
  const { getHidServiceEnabled } = useOptionalServices();
35
- const { canAccessHidScreens } = useHidAccessPermission();
35
+ const { canViewHid, canUseHid } = useHidAccessPermission();
36
36
 
37
+ /**
38
+ * The whole group, unfiltered. Exported for callers that compose their own
39
+ * menus; `useHidFaceReaderMenu` below is the one that applies the rights.
40
+ * Each entry says which right draws it so the filter cannot drift from the
41
+ * list.
42
+ */
37
43
  function getHidFaceReaderMenu({ org, site }: HidNavigationParams) {
38
44
  return {
39
45
  title: "HID Face Reader",
40
46
  children: [
41
47
  {
42
48
  title: "Face Reader",
49
+ hidRight: "view" as const,
43
50
  route: {
44
51
  name: "org-site-access-mgmt-hid-readers",
45
52
  params: { org, site },
@@ -61,6 +68,7 @@ export default function useHidNavigation() {
61
68
  // `hid-users` is left in place and simply unlisted - the same state
62
69
  // `administrator` was in - so any existing link to it still resolves.
63
70
  title: "HID Reader Users",
71
+ hidRight: "view" as const,
64
72
  route: {
65
73
  name: "org-site-access-mgmt-administrator",
66
74
  params: { org, site },
@@ -71,6 +79,7 @@ export default function useHidNavigation() {
71
79
  // entry in this group acts on a resident or a visitor; this one has
72
80
  // no subject but the caller.
73
81
  title: "HID QR Code",
82
+ hidRight: "use" as const,
74
83
  route: {
75
84
  name: "org-site-access-mgmt-hid-qr-code",
76
85
  params: { org, site },
@@ -78,6 +87,7 @@ export default function useHidNavigation() {
78
87
  },
79
88
  {
80
89
  title: "HID Cards",
90
+ hidRight: "view" as const,
81
91
  route: {
82
92
  name: "org-site-access-mgmt-hid-cards",
83
93
  params: { org, site },
@@ -85,6 +95,7 @@ export default function useHidNavigation() {
85
95
  },
86
96
  {
87
97
  title: "Intercom",
98
+ hidRight: "view" as const,
88
99
  route: {
89
100
  name: "org-site-access-mgmt-intercom",
90
101
  params: { org, site },
@@ -92,6 +103,7 @@ export default function useHidNavigation() {
92
103
  },
93
104
  {
94
105
  title: "Access Logs",
106
+ hidRight: "view" as const,
95
107
  route: {
96
108
  name: "org-site-access-mgmt-access-logs",
97
109
  params: { org, site },
@@ -138,14 +150,23 @@ export default function useHidNavigation() {
138
150
  getHidServiceEnabled(site.value, siteDetails.value || fallbackSite?.value),
139
151
  );
140
152
 
141
- // ...AND this member may open the screens behind it. `enabled` keeps its
142
- // name and its meaning for callers: "should the HID menu be drawn".
143
- const enabled = computed(() => serviceEnabled.value && canAccessHidScreens.value);
144
-
145
- const menuItem = computed(() =>
146
- enabled.value ? getHidFaceReaderMenu({ org: org.value, site: site.value }) : null,
153
+ // ...AND this member may open at least one screen behind it. `enabled`
154
+ // keeps its name and its meaning for callers: "should the HID menu be drawn".
155
+ const enabled = computed(
156
+ () => serviceEnabled.value && (canViewHid.value || canUseHid.value),
147
157
  );
148
158
 
159
+ // Only the entries this member's rights draw. The admin entries need
160
+ // `canViewHid`; the member's own QR page needs `canUseHid`.
161
+ const menuItem = computed(() => {
162
+ if (!enabled.value) return null;
163
+ const group = getHidFaceReaderMenu({ org: org.value, site: site.value });
164
+ const children = group.children.filter((child) =>
165
+ child.hidRight === "use" ? canUseHid.value : canViewHid.value,
166
+ );
167
+ return children.length ? { ...group, children } : null;
168
+ });
169
+
149
170
  return {
150
171
  enabled,
151
172
  serviceEnabled,
@@ -283,6 +283,17 @@ export default function useLandscapingPermission() {
283
283
  description: "Allows the user to manage site settings.",
284
284
  },
285
285
  },
286
+ // HID access, user side only (decision of 2026-10-16). The service apps
287
+ // have no HID admin screens yet, so a role here can be prepared with the
288
+ // one string that lets a member use their own QR code, face, PIN, card and
289
+ // intercom. Mirrored from core `src/utils/hid-access.util.ts`.
290
+ "hid-mgmt": {
291
+ "use-hid-access": {
292
+ check: true,
293
+ description:
294
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
295
+ },
296
+ },
286
297
  };
287
298
 
288
299
  return {
@@ -91,6 +91,17 @@ export default function usePestControlPermission() {
91
91
  description: "Allows the user to manage and update site settings.",
92
92
  },
93
93
  },
94
+ // HID access, user side only (decision of 2026-10-16). The service apps
95
+ // have no HID admin screens yet, so a role here can be prepared with the
96
+ // one string that lets a member use their own QR code, face, PIN, card and
97
+ // intercom. Mirrored from core `src/utils/hid-access.util.ts`.
98
+ "hid-mgmt": {
99
+ "use-hid-access": {
100
+ check: true,
101
+ description:
102
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
103
+ },
104
+ },
94
105
  // area management permissions
95
106
  "area-mgmt": {
96
107
  "see-all-areas": {
@@ -91,6 +91,17 @@ export default function usePoolMaintenancePermission() {
91
91
  description: "Allows the user to manage and update site settings.",
92
92
  },
93
93
  },
94
+ // HID access, user side only (decision of 2026-10-16). The service apps
95
+ // have no HID admin screens yet, so a role here can be prepared with the
96
+ // one string that lets a member use their own QR code, face, PIN, card and
97
+ // intercom. Mirrored from core `src/utils/hid-access.util.ts`.
98
+ "hid-mgmt": {
99
+ "use-hid-access": {
100
+ check: true,
101
+ description:
102
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
103
+ },
104
+ },
94
105
  // area management permissions
95
106
  "area-mgmt": {
96
107
  "see-all-areas": {
@@ -14,7 +14,8 @@ import { useCommonPermissions } from "./useCommonPermission";
14
14
  * Two copies is how they drift. On 2026-09-05 the `-org` copy was found to be a
15
15
  * strict SUBSET of `-property-management`'s — **32 permissions short**, nine
16
16
  * whole families plus all six `access-card-mgmt` strings that
17
- * `core/utils/hid-access.util.ts` actually enforces — so a role built through
17
+ * `core/utils/hid-access.util.ts` enforced at the time (HID reads its own
18
+ * `hid-mgmt` family since 2026-10-16) — so a role built through
18
19
  * the onboarding wizard could never be granted them, and the modules were
19
20
  * unreachable for anybody who joined that way. web-app-org #189 closed it by
20
21
  * copying the file across, which left two identical copies and the same trap
@@ -256,10 +257,6 @@ export default function usePropertyPermission() {
256
257
  description:
257
258
  "Allows the user to remove an access card from the system permanently.",
258
259
  },
259
- view: {
260
- check: true,
261
- description: "Allows the user to view an access card's details.",
262
- },
263
260
  "assign-access-card": {
264
261
  check: true,
265
262
  description: "Allows the user to assign an access card to a person.",
@@ -269,10 +266,37 @@ export default function usePropertyPermission() {
269
266
  description:
270
267
  "Allows the user to replace a lost or damaged access card with a new one.",
271
268
  },
272
- "manage-hid": {
269
+ },
270
+ // HID access management (decision of 2026-10-16). Five strings under one
271
+ // resource, mirrored from core `src/utils/hid-access.util.ts`; the HID
272
+ // screens, menu and buttons (`useHidAccessPermission`) and every
273
+ // `/api/access-management/hid` route read them. Wildcard passes all five,
274
+ // an empty list passes none, either manage right implies view.
275
+ "hid-mgmt": {
276
+ "use-hid-access": {
277
+ check: true,
278
+ description:
279
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
280
+ },
281
+ "see-all-hid": {
282
+ check: true,
283
+ description:
284
+ "Allows the user to view the site's HID readers, enrolled people, cards and access logs.",
285
+ },
286
+ "manage-hid-readers": {
287
+ check: true,
288
+ description:
289
+ "Allows the user to add, configure, test, sync and remove HID readers. Includes viewing.",
290
+ },
291
+ "manage-hid-users": {
292
+ check: true,
293
+ description:
294
+ "Allows the user to enrol and remove people, cards and PINs, and assign HID access groups. Includes viewing.",
295
+ },
296
+ "manage-hid-settings": {
273
297
  check: true,
274
298
  description:
275
- "Allows the user to manage the HID door readers an access card opens.",
299
+ "Allows the user to switch HID on or off for the site and configure the HID QR code.",
276
300
  },
277
301
  },
278
302
  "service-provider-mgmt": {
@@ -531,12 +531,10 @@ export default function useSecurityPermission() {
531
531
  description: "Allows the user to delete/remove a unit.",
532
532
  },
533
533
  },
534
- // The strings API-core's HID routes already enforce. `authorizeView` and
535
- // `authorizeManage` on every `/api/access-management/hid` route resolve to
536
- // core's `utils/hid-access.util.ts` lists -- this family -- so a security
537
- // agency that cannot be granted them is refused by the server on every HID
538
- // call. Offering them here does not open any gate; it makes the server's
539
- // existing rule grantable.
534
+ // Access cards. Until 2026-10 this family was also what every
535
+ // `/api/access-management/hid` route read; HID now has `hid-mgmt` below and
536
+ // the card strings here mean cards again (the server still accepts them
537
+ // for HID during the alias period, see `useHidAccessPermission`).
540
538
  "access-card-mgmt": {
541
539
  "see-all-card": {
542
540
  check: true,
@@ -546,11 +544,6 @@ export default function useSecurityPermission() {
546
544
  check: true,
547
545
  description: "Allows the user to view QR tagging.",
548
546
  },
549
- view: {
550
- check: true,
551
- description:
552
- "Allows the user to view access card management, including HID readers and access logs.",
553
- },
554
547
  "add-access-card": {
555
548
  check: true,
556
549
  description: "Allows the user to add a new access card to the system.",
@@ -572,10 +565,37 @@ export default function useSecurityPermission() {
572
565
  check: true,
573
566
  description: "Allows the user to replace a lost or damaged access card.",
574
567
  },
575
- "manage-hid": {
568
+ },
569
+ // HID access management (decision of 2026-10-16). Five strings under one
570
+ // resource, mirrored from core `src/utils/hid-access.util.ts`; the HID
571
+ // screens, menu and buttons (`useHidAccessPermission`) and every
572
+ // `/api/access-management/hid` route read them. Wildcard passes all five,
573
+ // an empty list passes none, either manage right implies view.
574
+ "hid-mgmt": {
575
+ "use-hid-access": {
576
+ check: true,
577
+ description:
578
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
579
+ },
580
+ "see-all-hid": {
581
+ check: true,
582
+ description:
583
+ "Allows the user to view the site's HID readers, enrolled people, cards and access logs.",
584
+ },
585
+ "manage-hid-readers": {
586
+ check: true,
587
+ description:
588
+ "Allows the user to add, configure, test, sync and remove HID readers. Includes viewing.",
589
+ },
590
+ "manage-hid-users": {
591
+ check: true,
592
+ description:
593
+ "Allows the user to enrol and remove people, cards and PINs, and assign HID access groups. Includes viewing.",
594
+ },
595
+ "manage-hid-settings": {
576
596
  check: true,
577
597
  description:
578
- "Allows the user to manage HID face readers, cards and access records for the site.",
598
+ "Allows the user to switch HID on or off for the site and configure the HID QR code.",
579
599
  },
580
600
  },
581
601
  // Two resources below are checked ONLY by the iSecure365 mobile app, which
@@ -378,16 +378,38 @@ export const PERMISSIONS = {
378
378
  "add-service-provider",
379
379
  "invite-service-provider",
380
380
  ],
381
+ // Access cards and QR tagging: the Property Management screens of those
382
+ // names. Until 2026-10 the HID screens borrowed this family (core
383
+ // `hid-access.util.ts` read nine of its strings); HID now has `hid-mgmt`
384
+ // below. `view` and `manage-hid` were only ever HID rights, so they left with
385
+ // it: see `RETIRED_PERMISSIONS` for how they are still read during the alias
386
+ // period.
381
387
  "access-card-mgmt": [
382
388
  "see-all-card",
383
389
  "see-all-qr-tagging",
384
- "view",
385
390
  "add-access-card",
386
391
  "update-access-card",
387
392
  "replace-access-card",
388
393
  "delete-access-card",
389
394
  "assign-access-card",
390
- "manage-hid",
395
+ ],
396
+ // HID access management (decision of 2026-10-16). The five strings are
397
+ // defined in core `src/utils/hid-access.util.ts` (`HID_RESOURCE` and the
398
+ // `HID_*_PERMISSIONS` lists); this package does not depend on `@7365admin1/core`,
399
+ // so it keeps its own copy and `test/hid-access-gate.test.mjs` pins the five.
400
+ // use-hid-access user side: own QR, face, PIN, card, intercom
401
+ // see-all-hid read any HID admin screen
402
+ // manage-hid-readers add, configure, test, sync, remove readers
403
+ // manage-hid-users enrol and remove people, cards, PINs, groups
404
+ // manage-hid-settings HID on or off and the QR configuration for a site
405
+ // Wildcard passes all five; an empty list passes none; either manage right
406
+ // implies view. The module deny list key is the resource name.
407
+ "hid-mgmt": [
408
+ "use-hid-access",
409
+ "see-all-hid",
410
+ "manage-hid-readers",
411
+ "manage-hid-users",
412
+ "manage-hid-settings",
391
413
  ],
392
414
 
393
415
  // ---- security ----
@@ -650,12 +672,14 @@ export const LEGACY_PERMISSION_ALIASES: Readonly<
650
672
  /**
651
673
  * Strings the SERVER enforces that no UI checks and no role editor can grant.
652
674
  *
653
- * `core/src/utils/hid-access.util.ts:36-38` gates the HID Amico visitor
654
- * endpoints on `visitor:create`, `visitor:update` and `visitor:check-out`. The
655
- * whole estate spells visitor rights `visitor-mgmt:add-visitor`,
656
- * `:update-visitor` and so on; a bare `visitor` resource appears in no catalogue
657
- * in any repo, so no role can hold these and the branch is reachable only
658
- * through `*` or through the `access-card-mgmt` strings the same list unions in.
675
+ * `core/src/utils/hid-access.util.ts` keeps `visitor:create`, `visitor:update`
676
+ * and `visitor:check-out` in `HID_VISITOR_PERMISSIONS` (the visitor pass revoke
677
+ * routes) until the alias drop. The whole estate spells visitor rights
678
+ * `visitor-mgmt:add-visitor`, `:update-visitor` and so on; a bare `visitor`
679
+ * resource appears in no catalogue in any repo, so no role can hold these and
680
+ * the branch is reachable only through `*`, through
681
+ * `visitor-mgmt:update-visitor` (which the same list now also accepts) or
682
+ * through the HID manage users strings it unions in.
659
683
  *
660
684
  * They are NOT aliased to `visitor-mgmt:*` here, because doing so would be a
661
685
  * decision with a real consequence in both directions:
@@ -686,19 +710,47 @@ export const SERVER_ONLY_UNGRANTABLE: readonly string[] = Object.freeze([
686
710
  * Canonical strings that are CHECKED -- by this package and by the server -- and
687
711
  * that no role editor can GRANT.
688
712
  *
689
- * `NavigationDrawer.vue:172-180` accepts eight `access-card-mgmt` strings for
690
- * the HID menu and `core/src/utils/hid-access.util.ts:19-32` enforces all nine;
691
- * only six of them appear in any app's catalogue. The menu still opens, because
692
- * the gate is an OR and the other six are grantable -- but a role built out of
693
- * only these three is refused at both ends while looking correctly configured in
694
- * the role editor. Frozen here so the list cannot grow without somebody noticing.
713
+ * Empty since 2026-10-16. It used to hold `access-card-mgmt:view`,
714
+ * `:assign-access-card` and `:manage-hid`, which the HID menu accepted and
715
+ * `core/src/utils/hid-access.util.ts` enforced while no app's catalogue offered
716
+ * them. HID now has its own `hid-mgmt` family, offered in full by the property
717
+ * and security catalogues and as `use-hid-access` by the four service
718
+ * catalogues; `assign-access-card` is offered by both card catalogues; `view`
719
+ * and `manage-hid` are retired (below). Kept, and still pinned by the drift
720
+ * test, so the next string of this shape is recorded here rather than found
721
+ * by somebody staring at a blank screen.
695
722
  */
696
723
  export const CHECKED_BUT_UNGRANTABLE: readonly TPermissionString[] =
697
- Object.freeze([
698
- "access-card-mgmt:view",
699
- "access-card-mgmt:assign-access-card",
700
- "access-card-mgmt:manage-hid",
701
- ]);
724
+ Object.freeze([]);
725
+
726
+ /**
727
+ * Strings that are no longer canonical and have no canonical equivalent, but
728
+ * that this package and the server STILL READ for one release.
729
+ *
730
+ * `access-card-mgmt:view` and `access-card-mgmt:manage-hid` were the HID
731
+ * rights before `hid-mgmt` existed. Core `hid-access.util.ts` keeps them in
732
+ * `HID_LEGACY_VIEW_PERMISSIONS` and `HID_LEGACY_MANAGE_PERMISSIONS` until the
733
+ * live roles are backfilled onto the five `hid-mgmt` strings, and
734
+ * `useHidAccessPermission` reads them at the same levels during that period.
735
+ * No role editor offers them any more, and nothing new may be written against
736
+ * them.
737
+ *
738
+ * They are NOT legacy aliases: an alias joins two spellings of ONE grant into
739
+ * an equivalence class (`utils/permission-spellings.ts`) and joins the two
740
+ * resources into one module spelling group (`utils/org-modules.ts`). Access
741
+ * cards and HID are two modules, and `manage-hid` meant three HID levels at
742
+ * once, so neither of those is true here.
743
+ *
744
+ * `isKnownPermission` answers true for these; `canonicalPermission` does not
745
+ * resolve them. The alias drop deletes this list and the composable's legacy
746
+ * branches together.
747
+ */
748
+ export const RETIRED_PERMISSIONS: Readonly<Record<string, string>> = Object.freeze({
749
+ "access-card-mgmt:view":
750
+ "HID view right before hid-mgmt:see-all-hid; read until the alias drop",
751
+ "access-card-mgmt:manage-hid":
752
+ "HID manage right before hid-mgmt:manage-hid-*; read until the alias drop",
753
+ });
702
754
 
703
755
  const CANONICAL = new Set<string>(PERMISSION_STRINGS);
704
756
 
@@ -715,7 +767,7 @@ export function canonicalPermission(
715
767
  return LEGACY_PERMISSION_ALIASES[value];
716
768
  }
717
769
 
718
- /** Is this string one the catalogue knows, canonical or legacy? */
770
+ /** Is this string one the catalogue knows: canonical, legacy, or retired but still read? */
719
771
  export function isKnownPermission(value: string): boolean {
720
- return canonicalPermission(value) !== undefined;
772
+ return canonicalPermission(value) !== undefined || value in RETIRED_PERMISSIONS;
721
773
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.97.1-staging.560",
5
+ "version": "4.97.1-staging.561",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -1,8 +1,11 @@
1
1
  <template>
2
2
  <v-container fluid>
3
+ <!-- The member's own pass, so the gate asks for the use right, not the
4
+ admin view right every other HID page asks for. -->
3
5
  <HidEnabledGate
4
6
  :site="siteId"
5
7
  :org="orgId"
8
+ level="use"
6
9
  message="Enable HID as a service for this site before generating a QR code."
7
10
  >
8
11
  <HidProfileQrCode :site="siteId" />
@@ -11,8 +11,10 @@
11
11
  * Only prefixes whose page each app gates on exactly one module are listed
12
12
  * (checked against every app's own `useLocalPermission` nav gate, 2026-09-11).
13
13
  * Shared or ambiguous pages stay out: calendar, keys (gated on `site-settings`),
14
- * access-mgmt (`site-settings:manage-entry-pass` also opens it), equipment and
15
- * inventory, service-providers and support tickets.
14
+ * the Cards and QR Tagging pages under access-mgmt (each app's own
15
+ * `access-card-mgmt` gate), equipment and inventory, service-providers and
16
+ * support tickets. The HID pages under access-mgmt ARE listed, one by one,
17
+ * because each is gated on `hid-mgmt` alone (`useHidAccessPermission`).
16
18
  *
17
19
  * NEVER MAPPED: the dashboard, settings, members, invitations and roles. A client
18
20
  * must always be able to run its own people and roles; the server never denies
@@ -68,6 +70,17 @@ export const MODULE_ROUTES: Readonly<Record<string, string>> = Object.freeze({
68
70
  "org-site-pool-schedule-area": "area-mgmt",
69
71
  "org-site-pool-schedule-unit": "unit-mgmt",
70
72
  "org-site-service-provider-mgmt": "service-provider-mgmt",
73
+ // HID access management (decision of 2026-10-16): the seven HID pages under
74
+ // `access-mgmt`, named one by one so the Cards and QR Tagging pages beside
75
+ // them stay unmapped. `hid-mgmt` is a governed module in core, so a client
76
+ // that was not given it loses the pages and the drawer group together.
77
+ "org-site-access-mgmt-hid-readers": "hid-mgmt",
78
+ "org-site-access-mgmt-administrator": "hid-mgmt",
79
+ "org-site-access-mgmt-hid-users": "hid-mgmt",
80
+ "org-site-access-mgmt-hid-qr-code": "hid-mgmt",
81
+ "org-site-access-mgmt-hid-cards": "hid-mgmt",
82
+ "org-site-access-mgmt-intercom": "hid-mgmt",
83
+ "org-site-access-mgmt-access-logs": "hid-mgmt",
71
84
  "org-site-online-forms": "online-form-configuration",
72
85
  "org-site-nfc": "nfc-patrol",
73
86
  "org-site-document-mgmt": "document-mgmt",