@duvdu-v1/duvdu 1.1.334 → 1.1.336
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.
|
@@ -28,4 +28,5 @@ export type UserDocument = Document & Iuser;
|
|
|
28
28
|
export declare const updateRankForUser: (userId: string) => Promise<(Document<unknown, {}, Iuser> & Iuser & {
|
|
29
29
|
_id: import("mongoose").Types.ObjectId;
|
|
30
30
|
}) | undefined>;
|
|
31
|
+
export declare const updateUsersAfterRankDeletion: (deletedRankTitle: string) => Promise<void>;
|
|
31
32
|
export declare const recalculateAllUsersRanks: () => Promise<void>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.recalculateAllUsersRanks = exports.updateRankForUser = void 0;
|
|
12
|
+
exports.recalculateAllUsersRanks = exports.updateUsersAfterRankDeletion = exports.updateRankForUser = void 0;
|
|
13
13
|
const ranks_model_1 = require("../models/ranks.model");
|
|
14
14
|
const User_model_1 = require("../models/User.model");
|
|
15
15
|
const updateRankForUser = (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -81,6 +81,46 @@ const updateRankForUser = (userId) => __awaiter(void 0, void 0, void 0, function
|
|
|
81
81
|
return user;
|
|
82
82
|
});
|
|
83
83
|
exports.updateRankForUser = updateRankForUser;
|
|
84
|
+
const updateUsersAfterRankDeletion = (deletedRankTitle) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const BATCH_SIZE = 100;
|
|
86
|
+
let processedCount = 0;
|
|
87
|
+
try {
|
|
88
|
+
// Find all users who have the deleted rank
|
|
89
|
+
const totalUsersWithRank = yield User_model_1.Users.countDocuments({
|
|
90
|
+
'rank.title': deletedRankTitle,
|
|
91
|
+
});
|
|
92
|
+
if (totalUsersWithRank === 0) {
|
|
93
|
+
console.log('No users found with the deleted rank:', deletedRankTitle);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
console.log(`Found ${totalUsersWithRank} users with rank "${deletedRankTitle}" that need to be updated`);
|
|
97
|
+
// Process users in batches
|
|
98
|
+
while (true) {
|
|
99
|
+
const users = yield User_model_1.Users.find({ 'rank.title': deletedRankTitle })
|
|
100
|
+
.skip(processedCount)
|
|
101
|
+
.limit(BATCH_SIZE);
|
|
102
|
+
if (users.length === 0)
|
|
103
|
+
break;
|
|
104
|
+
// Update rank for each user in the batch using the same logic as updateRankForUser
|
|
105
|
+
yield Promise.all(users.map((user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
try {
|
|
107
|
+
yield (0, exports.updateRankForUser)(user._id.toString());
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error(`Failed to update rank for user ${user._id}:`, error);
|
|
111
|
+
}
|
|
112
|
+
})));
|
|
113
|
+
processedCount += users.length;
|
|
114
|
+
console.log(`Updated ${processedCount}/${totalUsersWithRank} users`);
|
|
115
|
+
}
|
|
116
|
+
console.log(`Successfully updated all ${processedCount} users after rank deletion`);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
console.error('Failed to update users after rank deletion:', error);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
exports.updateUsersAfterRankDeletion = updateUsersAfterRankDeletion;
|
|
84
124
|
const recalculateAllUsersRanks = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
125
|
const BATCH_SIZE = 100;
|
|
86
126
|
let processedCount = 0;
|
package/build/utils/bucket.js
CHANGED
|
@@ -220,7 +220,7 @@ class Bucket {
|
|
|
220
220
|
}
|
|
221
221
|
const face = faceResult.FaceDetails[0];
|
|
222
222
|
// Enhanced confidence check for liveness
|
|
223
|
-
if (!face.Confidence || face.Confidence <
|
|
223
|
+
if (!face.Confidence || face.Confidence < 75) {
|
|
224
224
|
return {
|
|
225
225
|
isValid: false,
|
|
226
226
|
error: {
|
|
@@ -320,8 +320,9 @@ class Bucket {
|
|
|
320
320
|
},
|
|
321
321
|
};
|
|
322
322
|
const textResult = yield this.rekognition.detectText(textParams).promise();
|
|
323
|
-
// If text is detected around the face area, it might be a printed photo
|
|
324
|
-
|
|
323
|
+
// If significant text is detected around the face area, it might be a printed photo
|
|
324
|
+
// Increased threshold to reduce false positives
|
|
325
|
+
if (textResult.TextDetections && textResult.TextDetections.length > 8) {
|
|
325
326
|
return {
|
|
326
327
|
isLive: false,
|
|
327
328
|
error: {
|
|
@@ -343,12 +344,13 @@ class Bucket {
|
|
|
343
344
|
};
|
|
344
345
|
const labelResult = yield this.rekognition.detectLabels(labelParams).promise();
|
|
345
346
|
if (labelResult.Labels) {
|
|
346
|
-
|
|
347
|
+
// Reduced list to only obvious screen/printed content and increased confidence threshold
|
|
348
|
+
const suspiciousLabels = ['Screen', 'Monitor', 'Display', 'Computer Screen', 'Television'];
|
|
347
349
|
for (const label of labelResult.Labels) {
|
|
348
350
|
if (suspiciousLabels.some(suspicious => {
|
|
349
351
|
var _a, _b;
|
|
350
352
|
return ((_a = label.Name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(suspicious.toLowerCase())) &&
|
|
351
|
-
((_b = label.Confidence) !== null && _b !== void 0 ? _b : 0) >
|
|
353
|
+
((_b = label.Confidence) !== null && _b !== void 0 ? _b : 0) > 85;
|
|
352
354
|
})) {
|
|
353
355
|
return {
|
|
354
356
|
isLive: false,
|
|
@@ -365,6 +367,7 @@ class Bucket {
|
|
|
365
367
|
catch (error) {
|
|
366
368
|
console.error('Error in liveness detection:', error);
|
|
367
369
|
// Don't fail the entire validation for liveness detection errors
|
|
370
|
+
// This prevents AWS service issues from blocking legitimate users
|
|
368
371
|
return { isLive: true };
|
|
369
372
|
}
|
|
370
373
|
});
|
|
@@ -372,9 +375,9 @@ class Bucket {
|
|
|
372
375
|
performAntiSpoofingChecks(face) {
|
|
373
376
|
return __awaiter(this, void 0, void 0, function* () {
|
|
374
377
|
try {
|
|
375
|
-
// Check for overly perfect lighting (common in printed photos)
|
|
378
|
+
// Check for overly perfect lighting (common in printed photos) - relaxed threshold
|
|
376
379
|
const qualityMetrics = face.Quality;
|
|
377
|
-
if ((qualityMetrics === null || qualityMetrics === void 0 ? void 0 : qualityMetrics.Brightness) && qualityMetrics.Brightness >
|
|
380
|
+
if ((qualityMetrics === null || qualityMetrics === void 0 ? void 0 : qualityMetrics.Brightness) && qualityMetrics.Brightness > 98) {
|
|
378
381
|
return {
|
|
379
382
|
isValid: false,
|
|
380
383
|
error: {
|
|
@@ -383,8 +386,8 @@ class Bucket {
|
|
|
383
386
|
},
|
|
384
387
|
};
|
|
385
388
|
}
|
|
386
|
-
// Check for suspicious sharpness levels
|
|
387
|
-
if ((qualityMetrics === null || qualityMetrics === void 0 ? void 0 : qualityMetrics.Sharpness) && (qualityMetrics.Sharpness <
|
|
389
|
+
// Check for suspicious sharpness levels - more lenient range
|
|
390
|
+
if ((qualityMetrics === null || qualityMetrics === void 0 ? void 0 : qualityMetrics.Sharpness) && (qualityMetrics.Sharpness < 10 || qualityMetrics.Sharpness > 98)) {
|
|
388
391
|
return {
|
|
389
392
|
isValid: false,
|
|
390
393
|
error: {
|
|
@@ -419,15 +422,16 @@ class Bucket {
|
|
|
419
422
|
}
|
|
420
423
|
catch (error) {
|
|
421
424
|
console.error('Error in anti-spoofing checks:', error);
|
|
422
|
-
|
|
425
|
+
// Don't fail validation for anti-spoofing errors to prevent service issues
|
|
426
|
+
return { isValid: true };
|
|
423
427
|
}
|
|
424
428
|
});
|
|
425
429
|
}
|
|
426
430
|
validateEyesForLiveness(face) {
|
|
427
431
|
var _a;
|
|
428
|
-
// Enhanced eye validation for liveness detection
|
|
432
|
+
// Enhanced eye validation for liveness detection - more lenient
|
|
429
433
|
const eyesOpen = face.EyesOpen;
|
|
430
|
-
if (!(eyesOpen === null || eyesOpen === void 0 ? void 0 : eyesOpen.Value) || ((_a = eyesOpen.Confidence) !== null && _a !== void 0 ? _a : 0) <
|
|
434
|
+
if (!(eyesOpen === null || eyesOpen === void 0 ? void 0 : eyesOpen.Value) || ((_a = eyesOpen.Confidence) !== null && _a !== void 0 ? _a : 0) < 70) {
|
|
431
435
|
return {
|
|
432
436
|
isValid: false,
|
|
433
437
|
error: {
|