@7365admin1/core 3.46.1-staging.119 → 3.46.1-staging.120

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.
@@ -0,0 +1,21 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ HID: the five reader endpoints added for production readiness now authorise in their own handlers
6
+
7
+ `listReaderUsers`, `listReaderAccessLogs`, `configureReaderIntegration`,
8
+ `setReaderMonitor` and `setOperatingMode` had no check in their bodies. They are
9
+ guarded today by `authorizeView` / `authorizeManage` in the API-core router, so
10
+ this is not a live hole — but the guard and the handler sit in two different
11
+ repositories, and this is a published package: a router edit or a second
12
+ consumer mounting `useHidAmicoController()` would leave an endpoint that reaches
13
+ a physical door reader with nothing in front of it.
14
+
15
+ Each now calls `authorizeHidAccess` itself, at the level the router already
16
+ applies — `view` for the two lists, `manage` for the three writes — with the
17
+ site resolved from the stored reader, never from the request. No caller's
18
+ authority changes.
19
+
20
+ The guard test now covers all fifteen HID handlers and names the unguarded ones
21
+ in its failure message.
package/dist/index.js CHANGED
@@ -84050,6 +84050,11 @@ function useHidAmicoController() {
84050
84050
  const authorizeReader = (req, readerId) => service.authorizeReader(readerId, getAuthenticatedUserId(req));
84051
84051
  const authorizeReaderUser = (req, readerId, hidUserId) => service.authorizeReaderUser(readerId, hidUserId, getAuthenticatedUserId(req));
84052
84052
  const authorizeSite = (req, siteId) => service.authorizeSiteForCaller(siteId, getAuthenticatedUserId(req));
84053
+ const authorizeReaderAccess = (req, readerId, level) => service.authorizeHidAccess({
84054
+ userId: getAuthenticatedUserId(req),
84055
+ level,
84056
+ readerId
84057
+ });
84053
84058
  function authorize(level) {
84054
84059
  return async (req, _res, next) => {
84055
84060
  try {
@@ -84249,6 +84254,7 @@ function useHidAmicoController() {
84249
84254
  return;
84250
84255
  }
84251
84256
  try {
84257
+ await authorizeReaderAccess(req, params.value.readerId, "view");
84252
84258
  res.json(await service.listReaderUsers(
84253
84259
  params.value.readerId,
84254
84260
  query2.value.page,
@@ -84268,6 +84274,7 @@ function useHidAmicoController() {
84268
84274
  return;
84269
84275
  }
84270
84276
  try {
84277
+ await authorizeReaderAccess(req, params.value.readerId, "view");
84271
84278
  res.json(await service.listReaderAccessLogs(
84272
84279
  params.value.readerId,
84273
84280
  query2.value.page,
@@ -84288,6 +84295,7 @@ function useHidAmicoController() {
84288
84295
  return;
84289
84296
  }
84290
84297
  try {
84298
+ await authorizeReaderAccess(req, value.readerId, "manage");
84291
84299
  res.json({ data: await service.configureReaderIntegration(value.readerId) });
84292
84300
  } catch (error2) {
84293
84301
  next(error2);
@@ -84301,6 +84309,7 @@ function useHidAmicoController() {
84301
84309
  return;
84302
84310
  }
84303
84311
  try {
84312
+ await authorizeReaderAccess(req, params.value.readerId, "manage");
84304
84313
  res.json({
84305
84314
  data: await service.setReaderMonitor(params.value.readerId, body.value.enabled)
84306
84315
  });
@@ -84316,6 +84325,7 @@ function useHidAmicoController() {
84316
84325
  return;
84317
84326
  }
84318
84327
  try {
84328
+ await authorizeReaderAccess(req, params.value.readerId, "manage");
84319
84329
  res.json({ data: await service.setOperatingMode(params.value.readerId, body.value.mode) });
84320
84330
  } catch (error) {
84321
84331
  next(error);