@7365admin1/core 3.34.4-staging.19 → 3.34.4-staging.21
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 +4 -1
- package/dist/index.js +92 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3108,7 +3108,7 @@ declare function useGuestManagementController(): {
|
|
|
3108
3108
|
declare const site_people_namespace_collection = "site.people";
|
|
3109
3109
|
declare function usePersonRepo(): {
|
|
3110
3110
|
add: (value: TPerson, session?: ClientSession) => Promise<ObjectId>;
|
|
3111
|
-
getAll: ({ search, page, limit, sort, status, dateFrom, dateTo, org, site, type, }: {
|
|
3111
|
+
getAll: ({ search, page, limit, sort, status, dateFrom, dateTo, org, site, type, nric, contact, plateNumber, }: {
|
|
3112
3112
|
search?: string | undefined;
|
|
3113
3113
|
page?: number | undefined;
|
|
3114
3114
|
limit?: number | undefined;
|
|
@@ -3119,6 +3119,9 @@ declare function usePersonRepo(): {
|
|
|
3119
3119
|
org?: string | undefined;
|
|
3120
3120
|
site?: string | undefined;
|
|
3121
3121
|
type?: string | undefined;
|
|
3122
|
+
nric?: string | undefined;
|
|
3123
|
+
contact?: string | undefined;
|
|
3124
|
+
plateNumber: string;
|
|
3122
3125
|
}, session?: ClientSession) => Promise<{
|
|
3123
3126
|
items: any[];
|
|
3124
3127
|
pages: number;
|
package/dist/index.js
CHANGED
|
@@ -25185,6 +25185,16 @@ var import_node_server_utils78 = require("@7365admin1/node-server-utils");
|
|
|
25185
25185
|
// src/repositories/person.repo.ts
|
|
25186
25186
|
var import_node_server_utils74 = require("@7365admin1/node-server-utils");
|
|
25187
25187
|
var import_mongodb45 = require("mongodb");
|
|
25188
|
+
|
|
25189
|
+
// src/utils/sanitizer.ts
|
|
25190
|
+
var makeContainsRegex = (input) => {
|
|
25191
|
+
if (!input)
|
|
25192
|
+
return "";
|
|
25193
|
+
const sanitized = input.replace(/\s+/g, "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25194
|
+
return sanitized;
|
|
25195
|
+
};
|
|
25196
|
+
|
|
25197
|
+
// src/repositories/person.repo.ts
|
|
25188
25198
|
var site_people_namespace_collection = "site.people";
|
|
25189
25199
|
function usePersonRepo() {
|
|
25190
25200
|
const db = import_node_server_utils74.useAtlas.getDb();
|
|
@@ -25257,7 +25267,10 @@ function usePersonRepo() {
|
|
|
25257
25267
|
dateTo,
|
|
25258
25268
|
org = "",
|
|
25259
25269
|
site = "",
|
|
25260
|
-
type = ""
|
|
25270
|
+
type = "",
|
|
25271
|
+
nric = "",
|
|
25272
|
+
contact = "",
|
|
25273
|
+
plateNumber = ""
|
|
25261
25274
|
}, session) {
|
|
25262
25275
|
page = page > 0 ? page - 1 : 0;
|
|
25263
25276
|
const start = dateFrom ? { $gte: new Date(dateFrom).toISOString() } : void 0;
|
|
@@ -25276,12 +25289,28 @@ function usePersonRepo() {
|
|
|
25276
25289
|
{ name: { $regex: search, $options: "i" } },
|
|
25277
25290
|
{ email: { $regex: search, $options: "i" } },
|
|
25278
25291
|
{ nric: { $regex: search, $options: "i" } },
|
|
25279
|
-
{ "plates.plateNumber": { $regex: search, $options: "i" } }
|
|
25292
|
+
{ "plates.plateNumber": { $regex: search, $options: "i" } },
|
|
25293
|
+
{ contact: { $regex: makeContainsRegex(contact) } },
|
|
25294
|
+
{ contacts: { $regex: makeContainsRegex(contact) } },
|
|
25295
|
+
{ plateNumbers: { $regex: makeContainsRegex(plateNumber) } }
|
|
25280
25296
|
]
|
|
25281
25297
|
},
|
|
25282
25298
|
...import_mongodb45.ObjectId.isValid(org) && { org: new import_mongodb45.ObjectId(org) },
|
|
25283
25299
|
...import_mongodb45.ObjectId.isValid(site) && { site: new import_mongodb45.ObjectId(site) },
|
|
25284
|
-
...PERSON_TYPES.includes(type) && { type }
|
|
25300
|
+
...PERSON_TYPES.includes(type) && { type },
|
|
25301
|
+
...nric && { nric: { $regex: makeContainsRegex(nric), $options: "i" } },
|
|
25302
|
+
...contact && {
|
|
25303
|
+
$or: [
|
|
25304
|
+
{ contact: { $regex: makeContainsRegex(contact) } },
|
|
25305
|
+
{ contacts: { $regex: makeContainsRegex(contact) } }
|
|
25306
|
+
]
|
|
25307
|
+
},
|
|
25308
|
+
...plateNumber && {
|
|
25309
|
+
$or: [
|
|
25310
|
+
{ "plates.plateNumber": { $regex: makeContainsRegex(plateNumber) } },
|
|
25311
|
+
{ plateNumbers: { $regex: makeContainsRegex(plateNumber) } }
|
|
25312
|
+
]
|
|
25313
|
+
}
|
|
25285
25314
|
};
|
|
25286
25315
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
25287
25316
|
try {
|
|
@@ -37065,17 +37094,21 @@ function usePersonController() {
|
|
|
37065
37094
|
const validation = import_joi60.default.object({
|
|
37066
37095
|
page: import_joi60.default.number().integer().min(1).allow("", null).default(1),
|
|
37067
37096
|
limit: import_joi60.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
37068
|
-
sort: import_joi60.default.string().pattern(/^([a-zA-Z0-9_]+)(,[a-zA-Z0-9_]+)*$/).optional().allow("",
|
|
37097
|
+
sort: import_joi60.default.string().pattern(/^([a-zA-Z0-9_]+)(,[a-zA-Z0-9_]+)*$/).optional().allow("", null),
|
|
37098
|
+
order: import_joi60.default.string().pattern(/^(asc|desc)(,(asc|desc))*$/i).optional().allow("", null),
|
|
37069
37099
|
status: import_joi60.default.string().optional().allow(null, ""),
|
|
37070
37100
|
search: import_joi60.default.string().optional().allow(null, ""),
|
|
37071
37101
|
dateFrom: import_joi60.default.date().iso().optional().allow(null, ""),
|
|
37072
37102
|
dateTo: import_joi60.default.date().iso().optional().allow(null, ""),
|
|
37073
|
-
org: import_joi60.default.string().optional().allow(null, ""),
|
|
37074
|
-
site: import_joi60.default.string().optional().allow(null, ""),
|
|
37103
|
+
org: import_joi60.default.string().hex().length(24).optional().allow(null, ""),
|
|
37104
|
+
site: import_joi60.default.string().hex().length(24).optional().allow(null, ""),
|
|
37075
37105
|
type: import_joi60.default.alternatives().try(
|
|
37076
37106
|
import_joi60.default.string().valid(...PERSON_TYPES),
|
|
37077
37107
|
import_joi60.default.array().items(import_joi60.default.string().valid(...PERSON_TYPES))
|
|
37078
|
-
).optional().allow(null, "")
|
|
37108
|
+
).optional().allow(null, ""),
|
|
37109
|
+
nric: import_joi60.default.string().optional().allow(null, ""),
|
|
37110
|
+
contact: import_joi60.default.string().optional().allow(null, ""),
|
|
37111
|
+
plateNumber: import_joi60.default.string().optional().allow(null, "")
|
|
37079
37112
|
});
|
|
37080
37113
|
const query = { ...req.query };
|
|
37081
37114
|
const { error } = validation.validate(query, {
|
|
@@ -37096,6 +37129,9 @@ function usePersonController() {
|
|
|
37096
37129
|
const org = req.query.org;
|
|
37097
37130
|
const site = req.query.site;
|
|
37098
37131
|
const type = req.query.type;
|
|
37132
|
+
const nric = req.query.nric;
|
|
37133
|
+
const contact = req.query.contact;
|
|
37134
|
+
const plateNumber = req.query.plateNumber;
|
|
37099
37135
|
const sortObj = {};
|
|
37100
37136
|
const sortFields = String(req.query.sort).split(",");
|
|
37101
37137
|
const sortOrders = String(req.query.order).split(",");
|
|
@@ -37116,7 +37152,10 @@ function usePersonController() {
|
|
|
37116
37152
|
dateTo,
|
|
37117
37153
|
org,
|
|
37118
37154
|
site,
|
|
37119
|
-
type
|
|
37155
|
+
type,
|
|
37156
|
+
nric,
|
|
37157
|
+
contact,
|
|
37158
|
+
plateNumber
|
|
37120
37159
|
});
|
|
37121
37160
|
res.status(200).json(data);
|
|
37122
37161
|
return;
|
|
@@ -64464,34 +64503,62 @@ var import_axios3 = __toESM(require("axios"));
|
|
|
64464
64503
|
|
|
64465
64504
|
// src/utils/payment-signature.util.ts
|
|
64466
64505
|
var crypto3 = __toESM(require("crypto"));
|
|
64506
|
+
function hasOwn(obj, key) {
|
|
64507
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
64508
|
+
}
|
|
64509
|
+
function sha512(input) {
|
|
64510
|
+
return crypto3.createHash("sha512").update(input).digest("hex");
|
|
64511
|
+
}
|
|
64512
|
+
function assertSecret(secretKey) {
|
|
64513
|
+
if (!secretKey) {
|
|
64514
|
+
throw new Error("Payment signature: missing secret key.");
|
|
64515
|
+
}
|
|
64516
|
+
}
|
|
64467
64517
|
function paymentSignature(params, secretKey) {
|
|
64468
|
-
|
|
64518
|
+
assertSecret(secretKey);
|
|
64519
|
+
const fieldOrder = [
|
|
64520
|
+
"mid",
|
|
64521
|
+
"order_id",
|
|
64522
|
+
"payment_type",
|
|
64523
|
+
"amount",
|
|
64524
|
+
"ccy",
|
|
64525
|
+
"card_no",
|
|
64526
|
+
"exp_date",
|
|
64527
|
+
"cvv2"
|
|
64528
|
+
];
|
|
64469
64529
|
let concatenated = "";
|
|
64470
64530
|
fieldOrder.forEach((v) => {
|
|
64471
|
-
if (!params
|
|
64531
|
+
if (!hasOwn(params, v)) {
|
|
64472
64532
|
return;
|
|
64473
|
-
}
|
|
64474
|
-
|
|
64533
|
+
}
|
|
64534
|
+
const raw = String(params[v] ?? "");
|
|
64535
|
+
if (v === "cvv2") {
|
|
64536
|
+
concatenated += raw.slice(-1);
|
|
64475
64537
|
} else if (v === "card_no") {
|
|
64476
|
-
concatenated +=
|
|
64538
|
+
concatenated += raw.substring(0, 6) + raw.slice(-4);
|
|
64477
64539
|
} else {
|
|
64478
|
-
concatenated +=
|
|
64540
|
+
concatenated += raw;
|
|
64479
64541
|
}
|
|
64480
64542
|
});
|
|
64481
64543
|
concatenated += secretKey;
|
|
64482
|
-
|
|
64483
|
-
return signature;
|
|
64544
|
+
return sha512(concatenated);
|
|
64484
64545
|
}
|
|
64485
64546
|
function genericSignature(params, secretKey) {
|
|
64486
|
-
|
|
64547
|
+
assertSecret(secretKey);
|
|
64548
|
+
const paramsCopy = {
|
|
64549
|
+
...params
|
|
64550
|
+
};
|
|
64487
64551
|
delete paramsCopy["signature"];
|
|
64488
|
-
const
|
|
64489
|
-
|
|
64490
|
-
|
|
64491
|
-
|
|
64492
|
-
|
|
64493
|
-
|
|
64494
|
-
|
|
64552
|
+
const concatenated = Object.keys(paramsCopy).sort().map((key) => {
|
|
64553
|
+
const value = paramsCopy[key];
|
|
64554
|
+
if (value !== null && typeof value === "object") {
|
|
64555
|
+
throw new Error(
|
|
64556
|
+
`Payment signature: non-primitive value for field "${key}".`
|
|
64557
|
+
);
|
|
64558
|
+
}
|
|
64559
|
+
return String(value ?? "");
|
|
64560
|
+
}).join("") + secretKey;
|
|
64561
|
+
return sha512(concatenated);
|
|
64495
64562
|
}
|
|
64496
64563
|
|
|
64497
64564
|
// src/repositories/reddot-payment.repository.ts
|
|
@@ -64914,7 +64981,7 @@ var useRedDotPaymentSvc = () => {
|
|
|
64914
64981
|
};
|
|
64915
64982
|
if (!process.env.MERCHANT_ENQUIRY) {
|
|
64916
64983
|
throw new Error(
|
|
64917
|
-
"
|
|
64984
|
+
"MERCHANT_ENQUIRY environment variable is not defined."
|
|
64918
64985
|
);
|
|
64919
64986
|
}
|
|
64920
64987
|
const url = process.env.MERCHANT_ENQUIRY;
|