@7365admin1/core 3.96.1-staging.365 → 3.96.1-staging.366
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 +102 -15
- package/dist/index.js +186 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +186 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/hid-identification-drift.test.mjs +363 -0
package/dist/index.d.ts
CHANGED
|
@@ -14300,7 +14300,7 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
14300
14300
|
pages: number;
|
|
14301
14301
|
pageRange: string;
|
|
14302
14302
|
success?: undefined;
|
|
14303
|
-
message?: undefined;
|
|
14303
|
+
readonly message?: undefined;
|
|
14304
14304
|
count?: undefined;
|
|
14305
14305
|
} | {
|
|
14306
14306
|
success: boolean;
|
|
@@ -14330,7 +14330,7 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
14330
14330
|
};
|
|
14331
14331
|
};
|
|
14332
14332
|
success?: undefined;
|
|
14333
|
-
message?: undefined;
|
|
14333
|
+
readonly message?: undefined;
|
|
14334
14334
|
} | {
|
|
14335
14335
|
success: boolean;
|
|
14336
14336
|
message: any;
|
|
@@ -14404,7 +14404,7 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
14404
14404
|
totalCount: number;
|
|
14405
14405
|
};
|
|
14406
14406
|
success?: undefined;
|
|
14407
|
-
message?: undefined;
|
|
14407
|
+
readonly message?: undefined;
|
|
14408
14408
|
count?: undefined;
|
|
14409
14409
|
} | {
|
|
14410
14410
|
success: boolean;
|
|
@@ -14440,7 +14440,7 @@ declare function useHrmLabsAttendanceSrvc(): {
|
|
|
14440
14440
|
normal: number;
|
|
14441
14441
|
}[];
|
|
14442
14442
|
success?: undefined;
|
|
14443
|
-
message?: undefined;
|
|
14443
|
+
readonly message?: undefined;
|
|
14444
14444
|
items?: undefined;
|
|
14445
14445
|
pages?: undefined;
|
|
14446
14446
|
pageRange?: undefined;
|
|
@@ -15056,7 +15056,7 @@ declare function useVerificationServiceV2(): {
|
|
|
15056
15056
|
status: string;
|
|
15057
15057
|
attemptsLeft: number;
|
|
15058
15058
|
message: string;
|
|
15059
|
-
reason?: undefined;
|
|
15059
|
+
readonly reason?: undefined;
|
|
15060
15060
|
expiredAt?: undefined;
|
|
15061
15061
|
verificationId?: undefined;
|
|
15062
15062
|
type?: undefined;
|
|
@@ -15067,7 +15067,7 @@ declare function useVerificationServiceV2(): {
|
|
|
15067
15067
|
type: string;
|
|
15068
15068
|
email: string;
|
|
15069
15069
|
message: string;
|
|
15070
|
-
reason?: undefined;
|
|
15070
|
+
readonly reason?: undefined;
|
|
15071
15071
|
expiredAt?: undefined;
|
|
15072
15072
|
attemptsLeft?: undefined;
|
|
15073
15073
|
}>;
|
|
@@ -16261,6 +16261,14 @@ type THidAmicoReader = {
|
|
|
16261
16261
|
* not be doing what the record says.
|
|
16262
16262
|
*/
|
|
16263
16263
|
identificationMethodsAppliedAt?: Date | string;
|
|
16264
|
+
/**
|
|
16265
|
+
* When the reader was last READ to see whether its settings still match.
|
|
16266
|
+
*
|
|
16267
|
+
* Not the same as applied: a check finding no drift updates both, a check
|
|
16268
|
+
* that could not reach the reader updates neither. It also throttles the
|
|
16269
|
+
* check on the callback path, which must never make a door event wait.
|
|
16270
|
+
*/
|
|
16271
|
+
identificationMethodsCheckedAt?: Date | string;
|
|
16264
16272
|
portalId?: number;
|
|
16265
16273
|
portalName?: string;
|
|
16266
16274
|
monitorPath?: string;
|
|
@@ -16595,6 +16603,7 @@ declare function useHidAmicoRepo(): {
|
|
|
16595
16603
|
serial?: unknown;
|
|
16596
16604
|
excludeId?: string | ObjectId;
|
|
16597
16605
|
}) => Promise<PublicHidReader | null>;
|
|
16606
|
+
listLiveReaderIdentities: () => Promise<mongodb.WithId<bson.Document>[]>;
|
|
16598
16607
|
getByCallbackTokenHash: {
|
|
16599
16608
|
(callbackTokenHash: string, options: {
|
|
16600
16609
|
includeCallbackTokenHash: true;
|
|
@@ -16919,6 +16928,7 @@ declare function useHidAmicoService(): {
|
|
|
16919
16928
|
firmwareVersion?: string | undefined;
|
|
16920
16929
|
readerModel?: "unknown" | "VL35LF" | "VL70LF" | undefined;
|
|
16921
16930
|
identificationMethodsAppliedAt?: string | Date | undefined;
|
|
16931
|
+
identificationMethodsCheckedAt?: string | Date | undefined;
|
|
16922
16932
|
portalId?: number | undefined;
|
|
16923
16933
|
portalName?: string | undefined;
|
|
16924
16934
|
monitorPath?: string | undefined;
|
|
@@ -16945,17 +16955,52 @@ declare function useHidAmicoService(): {
|
|
|
16945
16955
|
passwordSet: boolean;
|
|
16946
16956
|
}>;
|
|
16947
16957
|
testReader: (id: string) => Promise<{
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16958
|
+
identificationMethods: {
|
|
16959
|
+
readonly readerId: string;
|
|
16960
|
+
readonly status: "skipped";
|
|
16961
|
+
readonly reason: "not_found";
|
|
16962
|
+
readonly duplicateReaderId?: undefined;
|
|
16963
|
+
drifted?: undefined;
|
|
16964
|
+
checkedAt?: undefined;
|
|
16965
|
+
readonly message?: undefined;
|
|
16966
|
+
} | {
|
|
16967
|
+
readonly readerId: string;
|
|
16968
|
+
readonly status: "skipped";
|
|
16969
|
+
readonly reason: "not_configured";
|
|
16970
|
+
readonly duplicateReaderId?: undefined;
|
|
16971
|
+
drifted?: undefined;
|
|
16972
|
+
checkedAt?: undefined;
|
|
16973
|
+
readonly message?: undefined;
|
|
16974
|
+
} | {
|
|
16975
|
+
readonly readerId: string;
|
|
16976
|
+
readonly status: "skipped";
|
|
16977
|
+
readonly reason: "duplicate_reader";
|
|
16978
|
+
readonly duplicateReaderId: string;
|
|
16979
|
+
drifted?: undefined;
|
|
16980
|
+
checkedAt?: undefined;
|
|
16981
|
+
readonly message?: undefined;
|
|
16982
|
+
} | {
|
|
16983
|
+
readerId: string;
|
|
16984
|
+
status: string;
|
|
16985
|
+
drifted: string[];
|
|
16986
|
+
checkedAt: Date;
|
|
16987
|
+
readonly reason?: undefined;
|
|
16988
|
+
readonly duplicateReaderId?: undefined;
|
|
16989
|
+
readonly message?: undefined;
|
|
16990
|
+
} | {
|
|
16991
|
+
readonly readerId: string;
|
|
16992
|
+
readonly status: "failed";
|
|
16993
|
+
readonly message: string;
|
|
16994
|
+
readonly reason?: undefined;
|
|
16995
|
+
readonly duplicateReaderId?: undefined;
|
|
16996
|
+
drifted?: undefined;
|
|
16997
|
+
checkedAt?: undefined;
|
|
16955
16998
|
};
|
|
16956
|
-
|
|
16957
|
-
valid: boolean;
|
|
16999
|
+
valid: unknown;
|
|
16958
17000
|
message: string;
|
|
17001
|
+
firmwareVersion?: string | undefined;
|
|
17002
|
+
readerModel: THidAmicoReader["readerModel"];
|
|
17003
|
+
capabilities: THidAmicoReader["capabilities"];
|
|
16959
17004
|
}>;
|
|
16960
17005
|
syncReader: (id: string, payload: unknown) => Promise<{
|
|
16961
17006
|
message: string;
|
|
@@ -17001,6 +17046,47 @@ declare function useHidAmicoService(): {
|
|
|
17001
17046
|
};
|
|
17002
17047
|
appliedAt: Date;
|
|
17003
17048
|
}>;
|
|
17049
|
+
reconcileIdentificationMethods: (readerId: string) => Promise<{
|
|
17050
|
+
readonly readerId: string;
|
|
17051
|
+
readonly status: "skipped";
|
|
17052
|
+
readonly reason: "not_found";
|
|
17053
|
+
readonly duplicateReaderId?: undefined;
|
|
17054
|
+
drifted?: undefined;
|
|
17055
|
+
checkedAt?: undefined;
|
|
17056
|
+
readonly message?: undefined;
|
|
17057
|
+
} | {
|
|
17058
|
+
readonly readerId: string;
|
|
17059
|
+
readonly status: "skipped";
|
|
17060
|
+
readonly reason: "not_configured";
|
|
17061
|
+
readonly duplicateReaderId?: undefined;
|
|
17062
|
+
drifted?: undefined;
|
|
17063
|
+
checkedAt?: undefined;
|
|
17064
|
+
readonly message?: undefined;
|
|
17065
|
+
} | {
|
|
17066
|
+
readonly readerId: string;
|
|
17067
|
+
readonly status: "skipped";
|
|
17068
|
+
readonly reason: "duplicate_reader";
|
|
17069
|
+
readonly duplicateReaderId: string;
|
|
17070
|
+
drifted?: undefined;
|
|
17071
|
+
checkedAt?: undefined;
|
|
17072
|
+
readonly message?: undefined;
|
|
17073
|
+
} | {
|
|
17074
|
+
readerId: string;
|
|
17075
|
+
status: string;
|
|
17076
|
+
drifted: string[];
|
|
17077
|
+
checkedAt: Date;
|
|
17078
|
+
readonly reason?: undefined;
|
|
17079
|
+
readonly duplicateReaderId?: undefined;
|
|
17080
|
+
readonly message?: undefined;
|
|
17081
|
+
} | {
|
|
17082
|
+
readonly readerId: string;
|
|
17083
|
+
readonly status: "failed";
|
|
17084
|
+
readonly message: string;
|
|
17085
|
+
readonly reason?: undefined;
|
|
17086
|
+
readonly duplicateReaderId?: undefined;
|
|
17087
|
+
drifted?: undefined;
|
|
17088
|
+
checkedAt?: undefined;
|
|
17089
|
+
}>;
|
|
17004
17090
|
receiveNotification: (callbackToken: string, type: string, payload: UnknownRecord) => Promise<{
|
|
17005
17091
|
event: null;
|
|
17006
17092
|
response: null;
|
|
@@ -17433,6 +17519,7 @@ declare function useHidAmicoController(): {
|
|
|
17433
17519
|
configureReaderIntegration: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
17434
17520
|
setReaderMonitor: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
17435
17521
|
setReaderIdentificationMethods: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
17522
|
+
reconcileReaderIdentificationMethods: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
17436
17523
|
setOperatingMode: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
17437
17524
|
listLogs: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
17438
17525
|
listIdentities: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -46576,6 +46576,7 @@ var schemaHidAmicoReader = import_joi67.default.object({
|
|
|
46576
46576
|
credentialMode: import_joi67.default.string().valid("pin", "idPassword").required()
|
|
46577
46577
|
}).optional(),
|
|
46578
46578
|
identificationMethodsAppliedAt: import_joi67.default.date().optional(),
|
|
46579
|
+
identificationMethodsCheckedAt: import_joi67.default.date().optional(),
|
|
46579
46580
|
portalId: import_joi67.default.number().integer().positive().required(),
|
|
46580
46581
|
portalName: import_joi67.default.string().trim().allow("").optional(),
|
|
46581
46582
|
monitorPath: import_joi67.default.string().allow(null, "").optional(),
|
|
@@ -46627,6 +46628,7 @@ var schemaUpdateHidAmicoReader = import_joi67.default.object({
|
|
|
46627
46628
|
credentialMode: import_joi67.default.string().valid("pin", "idPassword").required()
|
|
46628
46629
|
}).optional(),
|
|
46629
46630
|
identificationMethodsAppliedAt: import_joi67.default.date().optional(),
|
|
46631
|
+
identificationMethodsCheckedAt: import_joi67.default.date().optional(),
|
|
46630
46632
|
portalId: import_joi67.default.number().integer().positive().optional(),
|
|
46631
46633
|
portalName: import_joi67.default.string().trim().optional(),
|
|
46632
46634
|
monitorPath: import_joi67.default.string().allow(null, "").optional(),
|
|
@@ -47293,6 +47295,16 @@ function hidFirmwareAtLeast(value, required) {
|
|
|
47293
47295
|
|
|
47294
47296
|
// src/utils/hid-duplicate.util.ts
|
|
47295
47297
|
var HID_LIVE_READER_STATUSES = ["active", "offline"];
|
|
47298
|
+
function isSameHidDevice(existing, discovered) {
|
|
47299
|
+
const existingDeviceId = readIdentityValue(existing.deviceId);
|
|
47300
|
+
const discoveredDeviceId = readIdentityValue(discovered.deviceId);
|
|
47301
|
+
if (existingDeviceId && discoveredDeviceId && existingDeviceId === discoveredDeviceId) {
|
|
47302
|
+
return true;
|
|
47303
|
+
}
|
|
47304
|
+
const existingSerial = readIdentityValue(existing.serial);
|
|
47305
|
+
const discoveredSerial = readIdentityValue(discovered.serial);
|
|
47306
|
+
return Boolean(existingSerial) && existingSerial === discoveredSerial;
|
|
47307
|
+
}
|
|
47296
47308
|
function hidIdentityConditions(discovered) {
|
|
47297
47309
|
const conditions = [];
|
|
47298
47310
|
const deviceId = readIdentityValue(discovered.deviceId);
|
|
@@ -47314,6 +47326,27 @@ function readIdentityValue(value) {
|
|
|
47314
47326
|
return "";
|
|
47315
47327
|
return String(value).trim();
|
|
47316
47328
|
}
|
|
47329
|
+
function normalizeHidHost(baseUrl) {
|
|
47330
|
+
const raw = String(baseUrl ?? "").trim();
|
|
47331
|
+
if (!raw)
|
|
47332
|
+
return "";
|
|
47333
|
+
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw : `http://${raw}`;
|
|
47334
|
+
try {
|
|
47335
|
+
return new URL(withScheme).hostname.toLowerCase();
|
|
47336
|
+
} catch {
|
|
47337
|
+
return "";
|
|
47338
|
+
}
|
|
47339
|
+
}
|
|
47340
|
+
function findDuplicateReaderRecord(candidates, target) {
|
|
47341
|
+
const others = (Array.isArray(candidates) ? candidates : []).filter((candidate) => String(candidate?._id ?? "") !== String(target._id ?? ""));
|
|
47342
|
+
const byIdentity = others.find((candidate) => isSameHidDevice(candidate, target));
|
|
47343
|
+
if (byIdentity)
|
|
47344
|
+
return byIdentity;
|
|
47345
|
+
const host = normalizeHidHost(target.baseUrl);
|
|
47346
|
+
if (!host)
|
|
47347
|
+
return null;
|
|
47348
|
+
return others.find((candidate) => normalizeHidHost(candidate.baseUrl) === host) ?? null;
|
|
47349
|
+
}
|
|
47317
47350
|
|
|
47318
47351
|
// src/repositories/hid-amico.repo.ts
|
|
47319
47352
|
function isUnknownRecord(value) {
|
|
@@ -47501,6 +47534,12 @@ function useHidAmicoRepo() {
|
|
|
47501
47534
|
}
|
|
47502
47535
|
return options.includePassword ? reader : hideSecret(reader);
|
|
47503
47536
|
}
|
|
47537
|
+
async function listLiveReaderIdentities() {
|
|
47538
|
+
return readers().find(
|
|
47539
|
+
{ status: { $in: [...HID_LIVE_READER_STATUSES] } },
|
|
47540
|
+
{ projection: { _id: 1, name: 1, site: 1, deviceId: 1, serial: 1, baseUrl: 1, status: 1 } }
|
|
47541
|
+
).toArray();
|
|
47542
|
+
}
|
|
47504
47543
|
async function findDuplicateByIdentity(value) {
|
|
47505
47544
|
const conditions = hidIdentityConditions(value);
|
|
47506
47545
|
if (!conditions.length)
|
|
@@ -48370,6 +48409,7 @@ function useHidAmicoRepo() {
|
|
|
48370
48409
|
getById,
|
|
48371
48410
|
getByDeviceId,
|
|
48372
48411
|
findDuplicateByIdentity,
|
|
48412
|
+
listLiveReaderIdentities,
|
|
48373
48413
|
getByCallbackTokenHash,
|
|
48374
48414
|
updateById,
|
|
48375
48415
|
markDeleted,
|
|
@@ -48591,6 +48631,38 @@ function buildIdentifierPayload(methods) {
|
|
|
48591
48631
|
multi_factor_authentication: "0"
|
|
48592
48632
|
};
|
|
48593
48633
|
}
|
|
48634
|
+
function readIdentifierFlag(value) {
|
|
48635
|
+
if (value === true)
|
|
48636
|
+
return "1";
|
|
48637
|
+
if (value === false)
|
|
48638
|
+
return "0";
|
|
48639
|
+
return String(value ?? "").trim();
|
|
48640
|
+
}
|
|
48641
|
+
function driftedIdentifierFields(methods, liveIdentifier) {
|
|
48642
|
+
const expected = buildIdentifierPayload(methods);
|
|
48643
|
+
const live = liveIdentifier && typeof liveIdentifier === "object" ? liveIdentifier : {};
|
|
48644
|
+
const drifted = [];
|
|
48645
|
+
let comparable = 0;
|
|
48646
|
+
for (const [field, value] of Object.entries(expected)) {
|
|
48647
|
+
const reported = live[field];
|
|
48648
|
+
if (reported === void 0 || reported === null)
|
|
48649
|
+
continue;
|
|
48650
|
+
comparable += 1;
|
|
48651
|
+
if (readIdentifierFlag(reported) !== value)
|
|
48652
|
+
drifted.push(field);
|
|
48653
|
+
}
|
|
48654
|
+
return { comparable, drifted };
|
|
48655
|
+
}
|
|
48656
|
+
function identificationDriftCheckDue(checkedAt, throttleMs, now = Date.now()) {
|
|
48657
|
+
if (checkedAt === null || checkedAt === void 0 || checkedAt === "")
|
|
48658
|
+
return true;
|
|
48659
|
+
const last = checkedAt instanceof Date ? checkedAt.getTime() : new Date(String(checkedAt)).getTime();
|
|
48660
|
+
if (!Number.isFinite(last))
|
|
48661
|
+
return true;
|
|
48662
|
+
if (last > now)
|
|
48663
|
+
return true;
|
|
48664
|
+
return now - last >= throttleMs;
|
|
48665
|
+
}
|
|
48594
48666
|
|
|
48595
48667
|
// src/utils/hid-json.util.ts
|
|
48596
48668
|
var import_node_crypto5 = __toESM(require("crypto"));
|
|
@@ -51009,6 +51081,93 @@ function useHidAmicoService() {
|
|
|
51009
51081
|
await client.logout();
|
|
51010
51082
|
}
|
|
51011
51083
|
}
|
|
51084
|
+
const IDENTIFICATION_DRIFT_THROTTLE_MS = 15 * 60 * 1e3;
|
|
51085
|
+
async function reconcileIdentificationMethods(readerId) {
|
|
51086
|
+
const id = String(readerId);
|
|
51087
|
+
let reader = null;
|
|
51088
|
+
try {
|
|
51089
|
+
reader = await repo.getById(id, { includePassword: true });
|
|
51090
|
+
if (!reader)
|
|
51091
|
+
return { readerId: id, status: "skipped", reason: "not_found" };
|
|
51092
|
+
const stored = reader.identificationMethods;
|
|
51093
|
+
if (!stored) {
|
|
51094
|
+
return { readerId: id, status: "skipped", reason: "not_configured" };
|
|
51095
|
+
}
|
|
51096
|
+
const duplicate = findDuplicateReaderRecord(
|
|
51097
|
+
await repo.listLiveReaderIdentities(),
|
|
51098
|
+
{ _id: reader._id, deviceId: reader.deviceId, serial: reader.serial, baseUrl: reader.baseUrl }
|
|
51099
|
+
);
|
|
51100
|
+
if (duplicate) {
|
|
51101
|
+
await repo.addEvent({
|
|
51102
|
+
reader: id,
|
|
51103
|
+
site: String(reader.site || ""),
|
|
51104
|
+
type: "reader_duplicate_registration_detected",
|
|
51105
|
+
status: "failed",
|
|
51106
|
+
payload: {
|
|
51107
|
+
duplicateReaderId: String(duplicate._id ?? ""),
|
|
51108
|
+
duplicateReaderName: String(duplicate.name ?? ""),
|
|
51109
|
+
duplicateSiteId: String(duplicate.site ?? "")
|
|
51110
|
+
}
|
|
51111
|
+
});
|
|
51112
|
+
return {
|
|
51113
|
+
readerId: id,
|
|
51114
|
+
status: "skipped",
|
|
51115
|
+
reason: "duplicate_reader",
|
|
51116
|
+
duplicateReaderId: String(duplicate._id ?? "")
|
|
51117
|
+
};
|
|
51118
|
+
}
|
|
51119
|
+
let liveIdentifier = {};
|
|
51120
|
+
const client = new HidAmicoClient(reader);
|
|
51121
|
+
try {
|
|
51122
|
+
await client.login();
|
|
51123
|
+
const live = await client.getConfiguration({
|
|
51124
|
+
identifier: Object.keys(buildIdentifierPayload(stored))
|
|
51125
|
+
});
|
|
51126
|
+
const liveRoot = isUnknownRecord2(live) ? live : {};
|
|
51127
|
+
liveIdentifier = isUnknownRecord2(liveRoot.identifier) ? liveRoot.identifier : {};
|
|
51128
|
+
} finally {
|
|
51129
|
+
await client.logout();
|
|
51130
|
+
}
|
|
51131
|
+
const { comparable, drifted } = driftedIdentifierFields(stored, liveIdentifier);
|
|
51132
|
+
if (!comparable) {
|
|
51133
|
+
throw new import_node_server_utils143.BadRequestError("The HID reader did not report its identification settings.");
|
|
51134
|
+
}
|
|
51135
|
+
if (!drifted.length) {
|
|
51136
|
+
const checkedAt2 = /* @__PURE__ */ new Date();
|
|
51137
|
+
await repo.updateById(id, {
|
|
51138
|
+
identificationMethodsCheckedAt: checkedAt2,
|
|
51139
|
+
// A confirmed match IS a confirmation, so both move.
|
|
51140
|
+
identificationMethodsAppliedAt: checkedAt2
|
|
51141
|
+
});
|
|
51142
|
+
return { readerId: id, status: "in_sync", drifted: [], checkedAt: checkedAt2 };
|
|
51143
|
+
}
|
|
51144
|
+
const before = {};
|
|
51145
|
+
for (const field of drifted)
|
|
51146
|
+
before[field] = liveIdentifier[field];
|
|
51147
|
+
await setReaderIdentificationMethods(id, stored);
|
|
51148
|
+
const checkedAt = /* @__PURE__ */ new Date();
|
|
51149
|
+
await repo.updateById(id, { identificationMethodsCheckedAt: checkedAt });
|
|
51150
|
+
await repo.addEvent({
|
|
51151
|
+
reader: id,
|
|
51152
|
+
site: String(reader.site || ""),
|
|
51153
|
+
type: "reader_identification_methods_drift_corrected",
|
|
51154
|
+
status: "processed",
|
|
51155
|
+
payload: { before, after: stored, fields: drifted }
|
|
51156
|
+
});
|
|
51157
|
+
return { readerId: id, status: "drift_corrected", drifted, checkedAt };
|
|
51158
|
+
} catch (error) {
|
|
51159
|
+
const message = getErrorMessage2(error);
|
|
51160
|
+
import_node_server_utils143.logger.log({ level: "error", message: `HID drift check failed for ${id}: ${message}` });
|
|
51161
|
+
await repo.addEvent({
|
|
51162
|
+
reader: id,
|
|
51163
|
+
site: String(reader?.site || ""),
|
|
51164
|
+
type: "reader_identification_methods_drift_check_failed",
|
|
51165
|
+
status: "failed",
|
|
51166
|
+
payload: { message }
|
|
51167
|
+
}).catch(() => void 0);
|
|
51168
|
+
return { readerId: id, status: "failed", message };
|
|
51169
|
+
}
|
|
51170
|
+
}
|
|
51012
51171
|
async function listReaders(value) {
|
|
51013
51172
|
return repo.list(value);
|
|
51014
51173
|
}
|
|
@@ -51062,6 +51221,7 @@ function useHidAmicoService() {
|
|
|
51062
51221
|
async function testReader(id) {
|
|
51063
51222
|
const reader = await repo.getById(id, { includePassword: true });
|
|
51064
51223
|
const client = new HidAmicoClient(reader);
|
|
51224
|
+
let result;
|
|
51065
51225
|
try {
|
|
51066
51226
|
await client.login();
|
|
51067
51227
|
const [valid, systemResponse] = await Promise.all([
|
|
@@ -51102,7 +51262,7 @@ function useHidAmicoService() {
|
|
|
51102
51262
|
capabilities
|
|
51103
51263
|
}
|
|
51104
51264
|
});
|
|
51105
|
-
|
|
51265
|
+
result = {
|
|
51106
51266
|
valid,
|
|
51107
51267
|
message: firmwareVersion ? `HID Amico connection test succeeded. Firmware ${firmwareVersion}.` : "HID Amico connection test succeeded.",
|
|
51108
51268
|
...firmwareVersion ? { firmwareVersion } : {},
|
|
@@ -51122,6 +51282,8 @@ function useHidAmicoService() {
|
|
|
51122
51282
|
} finally {
|
|
51123
51283
|
await client.logout();
|
|
51124
51284
|
}
|
|
51285
|
+
const identificationMethods = await reconcileIdentificationMethods(id);
|
|
51286
|
+
return { ...result, identificationMethods };
|
|
51125
51287
|
}
|
|
51126
51288
|
async function syncReader(id, payload) {
|
|
51127
51289
|
const reader = await getActiveReader(id);
|
|
@@ -51210,6 +51372,12 @@ function useHidAmicoService() {
|
|
|
51210
51372
|
throw new import_node_server_utils143.BadRequestError("The HID callback device ID does not match the registered reader.");
|
|
51211
51373
|
}
|
|
51212
51374
|
const readerId = String(reader._id);
|
|
51375
|
+
if (identificationDriftCheckDue(
|
|
51376
|
+
reader.identificationMethodsCheckedAt,
|
|
51377
|
+
IDENTIFICATION_DRIFT_THROTTLE_MS
|
|
51378
|
+
)) {
|
|
51379
|
+
void reconcileIdentificationMethods(readerId).catch(() => void 0);
|
|
51380
|
+
}
|
|
51213
51381
|
const objectChanges = Array.isArray(payload.object_changes) ? payload.object_changes : [];
|
|
51214
51382
|
const accessLogChange = objectChanges.find((change) => isUnknownRecord2(change) && change.object === "access_logs" && change.type !== "deleted" && isUnknownRecord2(change.values));
|
|
51215
51383
|
const accessLogValues = isUnknownRecord2(accessLogChange) && isUnknownRecord2(accessLogChange.values) ? accessLogChange.values : {};
|
|
@@ -53810,6 +53978,7 @@ function useHidAmicoService() {
|
|
|
53810
53978
|
setReaderMonitor,
|
|
53811
53979
|
setOperatingMode,
|
|
53812
53980
|
setReaderIdentificationMethods,
|
|
53981
|
+
reconcileIdentificationMethods,
|
|
53813
53982
|
receiveNotification,
|
|
53814
53983
|
listLogs,
|
|
53815
53984
|
listIdentities,
|
|
@@ -98596,6 +98765,21 @@ function useHidAmicoController() {
|
|
|
98596
98765
|
next(error);
|
|
98597
98766
|
}
|
|
98598
98767
|
}
|
|
98768
|
+
async function reconcileReaderIdentificationMethods(req, res, next) {
|
|
98769
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
98770
|
+
if (params.error) {
|
|
98771
|
+
next(new import_node_server_utils313.BadRequestError(params.error.message));
|
|
98772
|
+
return;
|
|
98773
|
+
}
|
|
98774
|
+
try {
|
|
98775
|
+
await authorizeReaderAccess(req, params.value.readerId, "manage");
|
|
98776
|
+
res.json({
|
|
98777
|
+
data: await service.reconcileIdentificationMethods(params.value.readerId)
|
|
98778
|
+
});
|
|
98779
|
+
} catch (error) {
|
|
98780
|
+
next(error);
|
|
98781
|
+
}
|
|
98782
|
+
}
|
|
98599
98783
|
async function setOperatingMode(req, res, next) {
|
|
98600
98784
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
98601
98785
|
const body = schemaHidAmicoOperatingMode.validate(req.body);
|
|
@@ -99251,6 +99435,7 @@ function useHidAmicoController() {
|
|
|
99251
99435
|
configureReaderIntegration,
|
|
99252
99436
|
setReaderMonitor,
|
|
99253
99437
|
setReaderIdentificationMethods,
|
|
99438
|
+
reconcileReaderIdentificationMethods,
|
|
99254
99439
|
setOperatingMode,
|
|
99255
99440
|
listLogs,
|
|
99256
99441
|
listIdentities,
|