@7365admin1/layer-common 4.2.14 → 4.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.2.15
4
+
5
+ ### Patch Changes
6
+
7
+ - b63f7a6: Hide the HID Face Reader menu from members who cannot open the screens
8
+
9
+ The menu was drawn from `getHidServiceEnabled(site)` — a site service flag, not
10
+ a permission — so a member with no access-card right saw all five items and only
11
+ met the refusal after clicking. `useHidNavigation` now asks the same question the
12
+ pages ask (`useHidAccessPermission.canAccessHidScreens`), ANDed with the service
13
+ flag. The duplicate, narrower permission list in `Layout/NavigationDrawer.vue` is
14
+ removed; folding it into the shared gate widens it (it omitted
15
+ `replace-access-card` and `site-settings:manage-entry-pass`).
16
+
3
17
  ## 4.2.14
4
18
 
5
19
  ### Patch Changes
@@ -611,11 +625,11 @@
611
625
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
612
626
  own rule from two endpoints the console already calls, unprojected:
613
627
 
614
- GET /api/members/user/:user/app/admin the Seven365 staff membership
615
- GET /api/roles/id/:role that membership's role document
628
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
629
+ GET /api/roles/id/:role that membership's role document
616
630
 
617
- owner = member.type === "admin" && role.type === "admin" && role.default === true
618
- staff = member.type === "admin" && role.type === "admin"
631
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
632
+ staff = member.type === "admin" && role.type === "admin"
619
633
 
620
634
  `role.default` is the marker because it is the only property of a platform
621
635
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -169,30 +169,10 @@ const { menuItem: hidFaceReaderMenu } = useHidFaceReaderMenu({
169
169
  cacheKey: "layout-navigation-hid-site",
170
170
  });
171
171
 
172
- const HID_NAVIGATION_PERMISSIONS = [
173
- "access-card-mgmt:see-all-card",
174
- "access-card-mgmt:see-all-qr-tagging",
175
- "access-card-mgmt:view",
176
- "access-card-mgmt:add-access-card",
177
- "access-card-mgmt:update-access-card",
178
- "access-card-mgmt:delete-access-card",
179
- "access-card-mgmt:assign-access-card",
180
- "access-card-mgmt:manage-hid",
181
- ];
182
-
183
- const { userAppRole } = useLocalSetup();
184
- const canAccessHid = computed(() => {
185
- const permissions = userAppRole.value?.permissions ?? [];
186
- return permissions.includes("*") || HID_NAVIGATION_PERMISSIONS.some(
187
- (permission) => permissions.includes(permission),
188
- );
189
- });
190
-
191
172
  const navigationItems = computed(() => {
192
173
  const items = [...(props.navigationItems as TNavigationItem[])];
193
174
 
194
175
  if (
195
- canAccessHid.value &&
196
176
  hidFaceReaderMenu.value &&
197
177
  !items.some((item) => item.title === hidFaceReaderMenu.value?.title)
198
178
  ) {
@@ -54,19 +54,28 @@
54
54
  * not work; it does not add protection the API does not already have.
55
55
  */
56
56
 
57
- /** The nine strings `core/utils/hid-access.util.ts` enforces, view + manage. */
58
- const HID_ACTIONS = [
59
- "see-all-card",
60
- "see-all-qr-tagging",
61
- "view",
62
- "add-access-card",
63
- "update-access-card",
64
- "replace-access-card",
65
- "delete-access-card",
66
- "assign-access-card",
67
- "manage-hid",
57
+ /**
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.
64
+ */
65
+ const HID_PERMISSIONS = [
66
+ "access-card-mgmt:see-all-card",
67
+ "access-card-mgmt:see-all-qr-tagging",
68
+ "access-card-mgmt:view",
69
+ "access-card-mgmt:add-access-card",
70
+ "access-card-mgmt:update-access-card",
71
+ "access-card-mgmt:replace-access-card",
72
+ "access-card-mgmt:delete-access-card",
73
+ "access-card-mgmt:assign-access-card",
74
+ "access-card-mgmt:manage-hid",
68
75
  ] as const;
69
76
 
77
+ const HID_ACTIONS = HID_PERMISSIONS.map((p) => p.split(":")[1]);
78
+
70
79
  export function useHidAccessPermission() {
71
80
  const { hasPermission } = usePermission();
72
81
  const { siteSettingsPermissions } = useCommonPermissions();
@@ -1,5 +1,27 @@
1
1
  import type { ComputedRef, Ref } from "vue";
2
2
 
3
+ /**
4
+ * THE HID FACE READER MENU IS A PERMISSION, NOT A SERVICE FLAG.
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.
13
+ *
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.
17
+ *
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.
23
+ */
24
+
3
25
  type HidNavigationParams = {
4
26
  org: string;
5
27
  site: string;
@@ -10,6 +32,7 @@ type HidNavigationSite = Record<string, unknown>;
10
32
  export default function useHidNavigation() {
11
33
  const { getSiteById } = useSiteSettings();
12
34
  const { getHidServiceEnabled } = useOptionalServices();
35
+ const { canAccessHidScreens } = useHidAccessPermission();
13
36
 
14
37
  function getHidFaceReaderMenu({ org, site }: HidNavigationParams) {
15
38
  return {
@@ -86,16 +109,22 @@ export default function useHidNavigation() {
86
109
  { immediate: true },
87
110
  );
88
111
 
89
- const enabled = computed(() =>
112
+ // The site bought HID.
113
+ const serviceEnabled = computed(() =>
90
114
  getHidServiceEnabled(site.value, siteDetails.value || fallbackSite?.value),
91
115
  );
92
116
 
117
+ // ...AND this member may open the screens behind it. `enabled` keeps its
118
+ // name and its meaning for callers: "should the HID menu be drawn".
119
+ const enabled = computed(() => serviceEnabled.value && canAccessHidScreens.value);
120
+
93
121
  const menuItem = computed(() =>
94
122
  enabled.value ? getHidFaceReaderMenu({ org: org.value, site: site.value }) : null,
95
123
  );
96
124
 
97
125
  return {
98
126
  enabled,
127
+ serviceEnabled,
99
128
  menuItem,
100
129
  siteDetails,
101
130
  };
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.2.14",
5
+ "version": "4.2.15",
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.",