@7365admin1/core 3.96.1-staging.367 → 3.96.1-staging.368
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +27 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/hid-face-photo-retention.test.mjs +6 -3
- package/test/hid-facial-without-photo.test.mjs +157 -0
package/dist/index.d.ts
CHANGED
|
@@ -16674,6 +16674,7 @@ declare function useHidAmicoRepo(): {
|
|
|
16674
16674
|
registration?: string;
|
|
16675
16675
|
cardNo?: string;
|
|
16676
16676
|
}) => Promise<mongodb.WithId<bson.Document> | null>;
|
|
16677
|
+
listFacialEnrolledHidUserIds: (readerId: string | ObjectId) => Promise<string[]>;
|
|
16677
16678
|
findExistingIdentity: (value: {
|
|
16678
16679
|
reader: string | ObjectId;
|
|
16679
16680
|
hidUserId?: string | number;
|
package/dist/index.js
CHANGED
|
@@ -47747,6 +47747,17 @@ function useHidAmicoRepo() {
|
|
|
47747
47747
|
session
|
|
47748
47748
|
);
|
|
47749
47749
|
}
|
|
47750
|
+
async function listFacialEnrolledHidUserIds(readerId) {
|
|
47751
|
+
const rows = await identities().find(
|
|
47752
|
+
{
|
|
47753
|
+
reader: toId4(readerId, "reader ID"),
|
|
47754
|
+
status: { $ne: "deleted" },
|
|
47755
|
+
"metadata.facialEnrolled": true
|
|
47756
|
+
},
|
|
47757
|
+
{ projection: { hidUserId: 1 } }
|
|
47758
|
+
).toArray();
|
|
47759
|
+
return rows.map((row) => String(row.hidUserId ?? "").trim()).filter(Boolean);
|
|
47760
|
+
}
|
|
47750
47761
|
async function findIdentity(value) {
|
|
47751
47762
|
const or = buildIdentityKeyQuery(value);
|
|
47752
47763
|
if (!or.length) {
|
|
@@ -48517,6 +48528,7 @@ function useHidAmicoRepo() {
|
|
|
48517
48528
|
updateIdentity,
|
|
48518
48529
|
deleteIdentity,
|
|
48519
48530
|
findIdentity,
|
|
48531
|
+
listFacialEnrolledHidUserIds,
|
|
48520
48532
|
findExistingIdentity,
|
|
48521
48533
|
findIdentityBySubject,
|
|
48522
48534
|
findProfileIdentity,
|
|
@@ -48860,6 +48872,7 @@ function deriveKey(secret) {
|
|
|
48860
48872
|
// src/services/hid-amico.service.ts
|
|
48861
48873
|
var PASSWORD_PREFIX = "v1";
|
|
48862
48874
|
var HID_READER_NOT_FOUND = "HID Amico reader not found.";
|
|
48875
|
+
var HID_KEEP_USER_IMAGE = "0";
|
|
48863
48876
|
var PJSIP_CONFIGURATION_KEYS = [
|
|
48864
48877
|
"enabled",
|
|
48865
48878
|
"server_ip",
|
|
@@ -49972,9 +49985,7 @@ var HidAmicoClient = class {
|
|
|
49972
49985
|
}
|
|
49973
49986
|
await this.setConfiguration({
|
|
49974
49987
|
identifier: { face_identification_enabled: "1" },
|
|
49975
|
-
|
|
49976
|
-
// avatars. HID defaults to keeping it, but make that dependency explicit.
|
|
49977
|
-
general: { keep_user_image: "1" }
|
|
49988
|
+
general: { keep_user_image: HID_KEEP_USER_IMAGE }
|
|
49978
49989
|
});
|
|
49979
49990
|
const facialConfiguration = await this.getConfiguration({
|
|
49980
49991
|
identifier: ["face_identification_enabled"],
|
|
@@ -49983,7 +49994,7 @@ var HidAmicoClient = class {
|
|
|
49983
49994
|
const configuration = isUnknownRecord2(facialConfiguration) ? facialConfiguration : {};
|
|
49984
49995
|
const identifier = isUnknownRecord2(configuration.identifier) ? configuration.identifier : {};
|
|
49985
49996
|
const general = isUnknownRecord2(configuration.general) ? configuration.general : {};
|
|
49986
|
-
if (String(identifier.face_identification_enabled ?? "") !== "1" || String(general.keep_user_image ?? "") !==
|
|
49997
|
+
if (String(identifier.face_identification_enabled ?? "") !== "1" || String(general.keep_user_image ?? "") !== HID_KEEP_USER_IMAGE) {
|
|
49987
49998
|
throw new import_node_server_utils143.BadRequestError(
|
|
49988
49999
|
"The HID reader did not retain facial identification configuration."
|
|
49989
50000
|
);
|
|
@@ -50000,24 +50011,6 @@ var HidAmicoClient = class {
|
|
|
50000
50011
|
const res = await this.postBinary(path5, image, "application/octet-stream");
|
|
50001
50012
|
const result = res.data;
|
|
50002
50013
|
assertSuccessfulFacialResult(result, "enrollment");
|
|
50003
|
-
const verificationPath = this.url(
|
|
50004
|
-
`/user_get_image.fcgi?user_id=${numericUserId}&get_timestamp=1`
|
|
50005
|
-
);
|
|
50006
|
-
const verificationResponse = await this.get(verificationPath, "arraybuffer");
|
|
50007
|
-
const verificationBuffer = Buffer.from(verificationResponse.data);
|
|
50008
|
-
let verification;
|
|
50009
|
-
try {
|
|
50010
|
-
verification = JSON.parse(verificationBuffer.toString("utf8"));
|
|
50011
|
-
} catch {
|
|
50012
|
-
throw new import_node_server_utils143.BadRequestError(
|
|
50013
|
-
"The HID reader did not return facial enrollment verification data."
|
|
50014
|
-
);
|
|
50015
|
-
}
|
|
50016
|
-
if (!isUnknownRecord2(verification) || Number(verification.timestamp) !== timestamp || typeof verification.image !== "string" || !verification.image.length) {
|
|
50017
|
-
throw new import_node_server_utils143.BadRequestError(
|
|
50018
|
-
"The HID reader did not retain the facial image or enrollment timestamp."
|
|
50019
|
-
);
|
|
50020
|
-
}
|
|
50021
50014
|
return {
|
|
50022
50015
|
...isUnknownRecord2(result) ? result : {},
|
|
50023
50016
|
success: true,
|
|
@@ -51593,7 +51586,15 @@ function useHidAmicoService() {
|
|
|
51593
51586
|
});
|
|
51594
51587
|
return getHidObjectRows(roleResponse, "user_roles").length > 0;
|
|
51595
51588
|
})),
|
|
51596
|
-
|
|
51589
|
+
/*
|
|
51590
|
+
* Who is facially enrolled comes from OUR records now, not from the
|
|
51591
|
+
* reader's photo list.
|
|
51592
|
+
*
|
|
51593
|
+
* The reader no longer keeps photographs — only the facial template,
|
|
51594
|
+
* which cannot be listed — so asking the device would report nobody as
|
|
51595
|
+
* enrolled and every resident would look un-enrolled on screen.
|
|
51596
|
+
*/
|
|
51597
|
+
readerSupportsFacial(reader) ? repo.listFacialEnrolledHidUserIds(readerId).catch(() => []) : Promise.resolve([])
|
|
51597
51598
|
]);
|
|
51598
51599
|
const facialUserIdSet = new Set(facialUserIds.map(String));
|
|
51599
51600
|
const items = rows.map((row, index) => {
|
|
@@ -52663,43 +52664,14 @@ function useHidAmicoService() {
|
|
|
52663
52664
|
await client.logout();
|
|
52664
52665
|
}
|
|
52665
52666
|
}
|
|
52666
|
-
async function getReaderFacialUserIds(client) {
|
|
52667
|
-
try {
|
|
52668
|
-
return await client.listUserImageIds();
|
|
52669
|
-
} catch {
|
|
52670
|
-
const usersResponse = await client.loadObjects({
|
|
52671
|
-
object: "users",
|
|
52672
|
-
where: { users: {} },
|
|
52673
|
-
limit: 500,
|
|
52674
|
-
offset: 0,
|
|
52675
|
-
order: ["id", "ascending"]
|
|
52676
|
-
});
|
|
52677
|
-
const userIds = getHidObjectRows(usersResponse, "users").map((user) => Number(user.id)).filter((userId) => Number.isSafeInteger(userId) && userId > 0);
|
|
52678
|
-
const facialUserIds = [];
|
|
52679
|
-
const batchSize = 4;
|
|
52680
|
-
for (let offset = 0; offset < userIds.length; offset += batchSize) {
|
|
52681
|
-
const batch = userIds.slice(offset, offset + batchSize);
|
|
52682
|
-
const results = await Promise.all(batch.map(async (userId) => {
|
|
52683
|
-
try {
|
|
52684
|
-
const image = await client.getUserImage(userId);
|
|
52685
|
-
return image.base64 ? userId : null;
|
|
52686
|
-
} catch {
|
|
52687
|
-
return null;
|
|
52688
|
-
}
|
|
52689
|
-
}));
|
|
52690
|
-
facialUserIds.push(...results.filter((userId) => userId !== null));
|
|
52691
|
-
}
|
|
52692
|
-
return facialUserIds;
|
|
52693
|
-
}
|
|
52694
|
-
}
|
|
52695
52667
|
async function syncReaderFacialData(readerId) {
|
|
52696
52668
|
const reader = await getActiveReader(readerId);
|
|
52697
52669
|
assertReaderCapability(reader, "facial");
|
|
52698
52670
|
const client = new HidAmicoClient(reader);
|
|
52699
52671
|
try {
|
|
52700
52672
|
await client.login();
|
|
52701
|
-
const facialUserIds = await
|
|
52702
|
-
const message = facialUserIds.length ?
|
|
52673
|
+
const facialUserIds = await repo.listFacialEnrolledHidUserIds(readerId);
|
|
52674
|
+
const message = facialUserIds.length ? `${facialUserIds.length} user(s) are facially enrolled on this reader, as recorded by iService365.` : "No facial enrollments recorded for this HID reader.";
|
|
52703
52675
|
await repo.updateById(readerId, { status: "active", lastSeenAt: /* @__PURE__ */ new Date() });
|
|
52704
52676
|
await repo.addEvent({
|
|
52705
52677
|
reader: readerId,
|
|
@@ -52707,7 +52679,7 @@ function useHidAmicoService() {
|
|
|
52707
52679
|
type: "facial_sync",
|
|
52708
52680
|
payload: {
|
|
52709
52681
|
facialDetected: facialUserIds.length,
|
|
52710
|
-
source: "
|
|
52682
|
+
source: "iservice365",
|
|
52711
52683
|
hidUserIds: facialUserIds
|
|
52712
52684
|
}
|
|
52713
52685
|
});
|