@7365admin1/core 3.32.2-staging.70 → 3.32.2-staging.72
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 +6 -0
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -74915,13 +74915,19 @@ function decryptSecret(value) {
|
|
|
74915
74915
|
if (!value?.startsWith(`${PASSWORD_PREFIX}:`)) {
|
|
74916
74916
|
return value;
|
|
74917
74917
|
}
|
|
74918
|
-
|
|
74919
|
-
|
|
74920
|
-
|
|
74921
|
-
|
|
74922
|
-
|
|
74923
|
-
|
|
74924
|
-
|
|
74918
|
+
try {
|
|
74919
|
+
const [, ivHex, tagHex, encryptedHex] = value.split(":");
|
|
74920
|
+
const decipher = import_crypto4.default.createDecipheriv("aes-256-gcm", getSecretKey(), Buffer.from(ivHex, "hex"));
|
|
74921
|
+
decipher.setAuthTag(Buffer.from(tagHex, "hex"));
|
|
74922
|
+
return Buffer.concat([
|
|
74923
|
+
decipher.update(Buffer.from(encryptedHex, "hex")),
|
|
74924
|
+
decipher.final()
|
|
74925
|
+
]).toString("utf8");
|
|
74926
|
+
} catch {
|
|
74927
|
+
throw new import_node_server_utils266.BadRequestError(
|
|
74928
|
+
"The stored HID credential cannot be decrypted. Re-enter and save the credential before trying again."
|
|
74929
|
+
);
|
|
74930
|
+
}
|
|
74925
74931
|
}
|
|
74926
74932
|
function formatHidResponse(data) {
|
|
74927
74933
|
if (data === void 0 || data === null) {
|
|
@@ -74995,9 +75001,17 @@ function createVisitorQrCredential(visitorId, readerId, qrFormat) {
|
|
|
74995
75001
|
qrValue: value.toString(16).toUpperCase()
|
|
74996
75002
|
};
|
|
74997
75003
|
}
|
|
74998
|
-
const token = `VIS
|
|
75004
|
+
const token = `VIS${import_crypto4.default.randomBytes(12).toString("hex").toUpperCase()}`;
|
|
74999
75005
|
return { credentialId, object: "qrcodes", value: token, qrValue: token };
|
|
75000
75006
|
}
|
|
75007
|
+
async function configureVisitorQrReader(client, qrFormat) {
|
|
75008
|
+
await client.setConfiguration({
|
|
75009
|
+
face_id: { qrcode_legacy_mode_enabled: qrFormat }
|
|
75010
|
+
});
|
|
75011
|
+
await client.setConfiguration({
|
|
75012
|
+
identifier: { qrcode_identification_enabled: "1" }
|
|
75013
|
+
});
|
|
75014
|
+
}
|
|
75001
75015
|
function getRelayAuth() {
|
|
75002
75016
|
const username = process.env.HID_AMICO_RELAY_USERNAME;
|
|
75003
75017
|
const password = process.env.HID_AMICO_RELAY_PASSWORD;
|
|
@@ -75595,6 +75609,7 @@ function useHidAmicoService() {
|
|
|
75595
75609
|
const client = new HidAmicoClient(reader);
|
|
75596
75610
|
try {
|
|
75597
75611
|
await client.login();
|
|
75612
|
+
await configureVisitorQrReader(client, value.qrFormat);
|
|
75598
75613
|
const existingUserResponse = await client.loadObjects({
|
|
75599
75614
|
object: "users",
|
|
75600
75615
|
where: { users: { id: hidUserId } },
|
|
@@ -75642,6 +75657,21 @@ function useHidAmicoService() {
|
|
|
75642
75657
|
user_id: hidUserId
|
|
75643
75658
|
}]
|
|
75644
75659
|
});
|
|
75660
|
+
const savedCredentialResponse = await client.loadObjects({
|
|
75661
|
+
object: credential.object,
|
|
75662
|
+
where: { [credential.object]: { id: credential.credentialId } },
|
|
75663
|
+
limit: 1,
|
|
75664
|
+
offset: 0
|
|
75665
|
+
});
|
|
75666
|
+
const savedCredential = getHidObjectRows(
|
|
75667
|
+
savedCredentialResponse,
|
|
75668
|
+
credential.object
|
|
75669
|
+
)[0];
|
|
75670
|
+
if (!savedCredential || String(savedCredential.user_id) !== String(hidUserId) || String(savedCredential.value) !== String(credential.value)) {
|
|
75671
|
+
throw new import_node_server_utils266.BadRequestError(
|
|
75672
|
+
"The HID reader did not retain the generated visitor QR credential."
|
|
75673
|
+
);
|
|
75674
|
+
}
|
|
75645
75675
|
const identityPayload = {
|
|
75646
75676
|
hidUserId: String(hidUserId),
|
|
75647
75677
|
registration,
|