@viardex/viardex-libs 1.0.10 → 1.0.12
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/README.md +14 -14
- package/dist/cache/{cache.service.d.ts → index.d.mts} +14 -4
- package/dist/cache/index.d.ts +40 -3
- package/dist/cache/index.js +227 -17
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/index.mjs +193 -0
- package/dist/cache/index.mjs.map +1 -0
- package/dist/common/index.d.mts +215 -0
- package/dist/common/index.d.ts +215 -10
- package/dist/common/index.js +979 -26
- package/dist/common/index.js.map +1 -0
- package/dist/common/index.mjs +874 -0
- package/dist/common/index.mjs.map +1 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -9
- package/dist/index.js +1661 -25
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1527 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger/index.d.mts +15 -0
- package/dist/logger/index.d.ts +14 -2
- package/dist/logger/index.js +207 -19
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/index.mjs +183 -0
- package/dist/logger/index.mjs.map +1 -0
- package/dist/nats/{constants/nats.constants.d.ts → index.d.mts} +61 -18
- package/dist/nats/index.d.ts +200 -5
- package/dist/nats/index.js +270 -20
- package/dist/nats/index.js.map +1 -0
- package/dist/nats/index.mjs +226 -0
- package/dist/nats/index.mjs.map +1 -0
- package/dist/rpc/index.d.mts +22 -0
- package/dist/rpc/index.d.ts +7 -3
- package/dist/rpc/index.js +91 -63
- package/dist/rpc/index.js.map +1 -0
- package/dist/rpc/index.mjs +71 -0
- package/dist/rpc/index.mjs.map +1 -0
- package/package.json +31 -62
- package/dist/argon/argon.module.d.ts +0 -2
- package/dist/argon/argon.module.js +0 -21
- package/dist/argon/argon.service.d.ts +0 -6
- package/dist/argon/argon.service.js +0 -74
- package/dist/argon/index.d.ts +0 -2
- package/dist/argon/index.js +0 -18
- package/dist/auth/auth.constants.d.ts +0 -4
- package/dist/auth/auth.constants.js +0 -7
- package/dist/auth/auth.interfaces.d.ts +0 -19
- package/dist/auth/auth.interfaces.js +0 -2
- package/dist/auth/auth.module.d.ts +0 -2
- package/dist/auth/auth.module.js +0 -31
- package/dist/auth/auth.service.d.ts +0 -13
- package/dist/auth/auth.service.js +0 -104
- package/dist/auth/decorators/auth-token-types.decorator.d.ts +0 -2
- package/dist/auth/decorators/auth-token-types.decorator.js +0 -7
- package/dist/auth/decorators/current-auth.decorator.d.ts +0 -1
- package/dist/auth/decorators/current-auth.decorator.js +0 -10
- package/dist/auth/decorators/index.d.ts +0 -5
- package/dist/auth/decorators/index.js +0 -21
- package/dist/auth/decorators/permissions.decorator.d.ts +0 -1
- package/dist/auth/decorators/permissions.decorator.js +0 -7
- package/dist/auth/decorators/public.decorator.d.ts +0 -1
- package/dist/auth/decorators/public.decorator.js +0 -7
- package/dist/auth/decorators/roles.decorator.d.ts +0 -1
- package/dist/auth/decorators/roles.decorator.js +0 -7
- package/dist/auth/guards/auth.guard.d.ts +0 -10
- package/dist/auth/guards/auth.guard.js +0 -65
- package/dist/auth/guards/index.d.ts +0 -3
- package/dist/auth/guards/index.js +0 -19
- package/dist/auth/guards/permissions.guard.d.ts +0 -7
- package/dist/auth/guards/permissions.guard.js +0 -52
- package/dist/auth/guards/roles.guard.d.ts +0 -7
- package/dist/auth/guards/roles.guard.js +0 -53
- package/dist/auth/index.d.ts +0 -6
- package/dist/auth/index.js +0 -22
- package/dist/cache/cache.constants.d.ts +0 -1
- package/dist/cache/cache.constants.js +0 -4
- package/dist/cache/cache.interface.d.ts +0 -2
- package/dist/cache/cache.interface.js +0 -2
- package/dist/cache/cache.module.d.ts +0 -5
- package/dist/cache/cache.module.js +0 -31
- package/dist/cache/cache.service.js +0 -125
- package/dist/common/cards/card.utils.d.ts +0 -9
- package/dist/common/cards/card.utils.js +0 -48
- package/dist/common/cards/index.d.ts +0 -1
- package/dist/common/cards/index.js +0 -17
- package/dist/common/config/index.d.ts +0 -1
- package/dist/common/config/index.js +0 -17
- package/dist/common/config/nats.config.d.ts +0 -8
- package/dist/common/config/nats.config.js +0 -33
- package/dist/common/constants/index.d.ts +0 -2
- package/dist/common/constants/index.js +0 -18
- package/dist/common/constants/otp.constants.d.ts +0 -15
- package/dist/common/constants/otp.constants.js +0 -18
- package/dist/common/constants/queues.constants.d.ts +0 -9
- package/dist/common/constants/queues.constants.js +0 -12
- package/dist/common/crypto/crypto.utils.d.ts +0 -7
- package/dist/common/crypto/crypto.utils.js +0 -42
- package/dist/common/crypto/index.d.ts +0 -1
- package/dist/common/crypto/index.js +0 -17
- package/dist/common/dto/index.d.ts +0 -1
- package/dist/common/dto/index.js +0 -17
- package/dist/common/dto/pagination-query.dto.d.ts +0 -7
- package/dist/common/dto/pagination-query.dto.js +0 -51
- package/dist/common/enums/index.d.ts +0 -1
- package/dist/common/enums/index.js +0 -17
- package/dist/common/enums/otp.enum.d.ts +0 -16
- package/dist/common/enums/otp.enum.js +0 -20
- package/dist/common/interfaces/index.d.ts +0 -1
- package/dist/common/interfaces/index.js +0 -17
- package/dist/common/interfaces/response.interface.d.ts +0 -27
- package/dist/common/interfaces/response.interface.js +0 -2
- package/dist/common/pipes/file-validation.pipe.d.ts +0 -22
- package/dist/common/pipes/file-validation.pipe.js +0 -78
- package/dist/common/pipes/index.d.ts +0 -2
- package/dist/common/pipes/index.js +0 -18
- package/dist/common/pipes/pagination-query-cleaner.pipe.d.ts +0 -4
- package/dist/common/pipes/pagination-query-cleaner.pipe.js +0 -24
- package/dist/common/response/http-exception.filter.d.ts +0 -6
- package/dist/common/response/http-exception.filter.js +0 -61
- package/dist/common/response/index.d.ts +0 -3
- package/dist/common/response/index.js +0 -19
- package/dist/common/response/response.interceptor.d.ts +0 -6
- package/dist/common/response/response.interceptor.js +0 -57
- package/dist/common/response/response.utils.d.ts +0 -6
- package/dist/common/response/response.utils.js +0 -34
- package/dist/common/utils/country.utils.d.ts +0 -1
- package/dist/common/utils/country.utils.js +0 -38
- package/dist/common/utils/date.utils.d.ts +0 -6
- package/dist/common/utils/date.utils.js +0 -48
- package/dist/common/utils/decimal.utils.d.ts +0 -3
- package/dist/common/utils/decimal.utils.js +0 -22
- package/dist/common/utils/format.utils.d.ts +0 -13
- package/dist/common/utils/format.utils.js +0 -127
- package/dist/common/utils/index.d.ts +0 -8
- package/dist/common/utils/index.js +0 -24
- package/dist/common/utils/random.utils.d.ts +0 -10
- package/dist/common/utils/random.utils.js +0 -27
- package/dist/common/utils/reference.utils.d.ts +0 -1
- package/dist/common/utils/reference.utils.js +0 -17
- package/dist/common/utils/string.utils.d.ts +0 -10
- package/dist/common/utils/string.utils.js +0 -34
- package/dist/common/utils/validation.utils.d.ts +0 -8
- package/dist/common/utils/validation.utils.js +0 -44
- package/dist/health/health.controller.d.ts +0 -19
- package/dist/health/health.controller.js +0 -103
- package/dist/health/health.module.d.ts +0 -2
- package/dist/health/health.module.js +0 -21
- package/dist/health/index.d.ts +0 -2
- package/dist/health/index.js +0 -18
- package/dist/logger/logger.module.d.ts +0 -2
- package/dist/logger/logger.module.js +0 -72
- package/dist/logger/logging.interceptor.d.ts +0 -8
- package/dist/logger/logging.interceptor.js +0 -66
- package/dist/nats/constants/nats.constants.js +0 -101
- package/dist/nats/decorators/nats-event-pattern.decorator.d.ts +0 -2
- package/dist/nats/decorators/nats-event-pattern.decorator.js +0 -11
- package/dist/nats/dto/nats-message.dto.d.ts +0 -5
- package/dist/nats/dto/nats-message.dto.js +0 -33
- package/dist/nats/interceptors/nats-logging.interceptor.d.ts +0 -6
- package/dist/nats/interceptors/nats-logging.interceptor.js +0 -33
- package/dist/nats/interfaces/nats-options.interface.d.ts +0 -23
- package/dist/nats/interfaces/nats-options.interface.js +0 -2
- package/dist/storage/index.d.ts +0 -5
- package/dist/storage/index.js +0 -21
- package/dist/storage/r2.service.d.ts +0 -20
- package/dist/storage/r2.service.js +0 -213
- package/dist/storage/s3.service.d.ts +0 -20
- package/dist/storage/s3.service.js +0 -209
- package/dist/storage/storage.interface.d.ts +0 -29
- package/dist/storage/storage.interface.js +0 -2
- package/dist/storage/storage.module.d.ts +0 -2
- package/dist/storage/storage.module.js +0 -24
- package/dist/storage/storage.service.d.ts +0 -22
- package/dist/storage/storage.service.js +0 -63
package/dist/common/index.js
CHANGED
|
@@ -1,26 +1,979 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/common/index.ts
|
|
31
|
+
var common_exports = {};
|
|
32
|
+
__export(common_exports, {
|
|
33
|
+
AppResponse: () => AppResponse,
|
|
34
|
+
BANKING_QUEUE: () => BANKING_QUEUE,
|
|
35
|
+
CARD_QUEUE: () => CARD_QUEUE,
|
|
36
|
+
CRYPTO_QUEUE: () => CRYPTO_QUEUE,
|
|
37
|
+
DEFAULT_OTP_EXPIRY: () => DEFAULT_OTP_EXPIRY,
|
|
38
|
+
DEFAULT_OTP_LENGTH: () => DEFAULT_OTP_LENGTH,
|
|
39
|
+
DEFAULT_OTP_OPTIONS: () => DEFAULT_OTP_OPTIONS,
|
|
40
|
+
FileValidationPipe: () => FileValidationPipe,
|
|
41
|
+
HttpExceptionFilter: () => HttpExceptionFilter,
|
|
42
|
+
HttpOnlyExceptionFilter: () => HttpOnlyExceptionFilter,
|
|
43
|
+
KYC_QUEUE: () => KYC_QUEUE,
|
|
44
|
+
LEDGER_QUEUE: () => LEDGER_QUEUE,
|
|
45
|
+
MAX_OTP_ATTEMPTS: () => MAX_OTP_ATTEMPTS,
|
|
46
|
+
NOTIFICATION_QUEUE: () => NOTIFICATION_QUEUE,
|
|
47
|
+
OPS_QUEUE: () => OPS_QUEUE,
|
|
48
|
+
OTP_ATTEMPTS_CACHE_PREFIX: () => OTP_ATTEMPTS_CACHE_PREFIX,
|
|
49
|
+
OTP_BLOCK_DURATION: () => OTP_BLOCK_DURATION,
|
|
50
|
+
OTP_CACHE_PREFIX: () => OTP_CACHE_PREFIX,
|
|
51
|
+
OtpPurpose: () => OtpPurpose,
|
|
52
|
+
PaginationQueryCleanerPipe: () => PaginationQueryCleanerPipe,
|
|
53
|
+
PaginationQueryDto: () => PaginationQueryDto,
|
|
54
|
+
ResponseInterceptor: () => ResponseInterceptor,
|
|
55
|
+
USER_QUEUE: () => USER_QUEUE,
|
|
56
|
+
VAS_QUEUE: () => VAS_QUEUE,
|
|
57
|
+
calculateNextDate: () => calculateNextDate,
|
|
58
|
+
countryDialCodes: () => countryDialCodes,
|
|
59
|
+
extractBin: () => extractBin,
|
|
60
|
+
extractLast4: () => extractLast4,
|
|
61
|
+
formatAccountNumber: () => formatAccountNumber,
|
|
62
|
+
formatAmount: () => formatAmount,
|
|
63
|
+
formatCardExpiry: () => formatCardExpiry,
|
|
64
|
+
formatCardLabel: () => formatCardLabel,
|
|
65
|
+
formatCryptoAmount: () => formatCryptoAmount,
|
|
66
|
+
formatCurrency: () => formatCurrency,
|
|
67
|
+
formatDate: () => formatDate,
|
|
68
|
+
formatDateTime: () => formatDateTime,
|
|
69
|
+
formatFileSize: () => formatFileSize,
|
|
70
|
+
formatPercentage: () => formatPercentage,
|
|
71
|
+
formatPhoneNumber: () => formatPhoneNumber,
|
|
72
|
+
formatRelativeTime: () => formatRelativeTime,
|
|
73
|
+
fromAtomicUnits: () => fromAtomicUnits,
|
|
74
|
+
generateRandomString: () => generateRandomString,
|
|
75
|
+
generateReference: () => generateReference,
|
|
76
|
+
getNatsConfig: () => getNatsConfig,
|
|
77
|
+
getNatsMicroserviceConfig: () => getNatsMicroserviceConfig,
|
|
78
|
+
getNatsServers: () => getNatsServers,
|
|
79
|
+
isDateInRange: () => isDateInRange,
|
|
80
|
+
isHexTxHash: () => isHexTxHash,
|
|
81
|
+
isNotPastDate: () => isNotPastDate,
|
|
82
|
+
isPositiveAmount: () => isPositiveAmount,
|
|
83
|
+
isStrongPassword: () => isStrongPassword,
|
|
84
|
+
isToday: () => isToday,
|
|
85
|
+
isValidAccountNumber: () => isValidAccountNumber,
|
|
86
|
+
isValidAge: () => isValidAge,
|
|
87
|
+
isValidAmount: () => isValidAmount,
|
|
88
|
+
isValidBVN: () => isValidBVN,
|
|
89
|
+
isValidEmail: () => isValidEmail,
|
|
90
|
+
isValidNIN: () => isValidNIN,
|
|
91
|
+
isValidNigerianPhone: () => isValidNigerianPhone,
|
|
92
|
+
isValidTransactionReference: () => isValidTransactionReference,
|
|
93
|
+
maskAccountNumber: () => maskAccountNumber,
|
|
94
|
+
maskEmail: () => maskEmail,
|
|
95
|
+
maskPan: () => maskPan,
|
|
96
|
+
maskPhoneNumber: () => maskPhoneNumber,
|
|
97
|
+
normalizeCardExpiry: () => normalizeCardExpiry,
|
|
98
|
+
normalizeNigerianPhone: () => normalizeNigerianPhone,
|
|
99
|
+
normalizeTxHash: () => normalizeTxHash,
|
|
100
|
+
toAtomicUnits: () => toAtomicUnits,
|
|
101
|
+
toDecimal: () => toDecimal,
|
|
102
|
+
toRoundedNumber: () => toRoundedNumber,
|
|
103
|
+
toTitleCase: () => toTitleCase,
|
|
104
|
+
truncateText: () => truncateText
|
|
105
|
+
});
|
|
106
|
+
module.exports = __toCommonJS(common_exports);
|
|
107
|
+
|
|
108
|
+
// src/common/constants/queues.constants.ts
|
|
109
|
+
var USER_QUEUE = "user_queue";
|
|
110
|
+
var KYC_QUEUE = "kyc_queue";
|
|
111
|
+
var LEDGER_QUEUE = "ledger_queue";
|
|
112
|
+
var BANKING_QUEUE = "banking_queue";
|
|
113
|
+
var CARD_QUEUE = "card_queue";
|
|
114
|
+
var CRYPTO_QUEUE = "crypto_queue";
|
|
115
|
+
var VAS_QUEUE = "vas_queue";
|
|
116
|
+
var OPS_QUEUE = "ops_queue";
|
|
117
|
+
var NOTIFICATION_QUEUE = "notification_queue";
|
|
118
|
+
|
|
119
|
+
// src/common/constants/otp.constants.ts
|
|
120
|
+
var DEFAULT_OTP_LENGTH = 6;
|
|
121
|
+
var DEFAULT_OTP_EXPIRY = 10;
|
|
122
|
+
var MAX_OTP_ATTEMPTS = 3;
|
|
123
|
+
var OTP_BLOCK_DURATION = 30;
|
|
124
|
+
var DEFAULT_OTP_OPTIONS = {
|
|
125
|
+
length: DEFAULT_OTP_LENGTH,
|
|
126
|
+
expiry: DEFAULT_OTP_EXPIRY,
|
|
127
|
+
caseSensitive: false,
|
|
128
|
+
digits: true,
|
|
129
|
+
lowerCaseAlphabets: false,
|
|
130
|
+
upperCaseAlphabets: false,
|
|
131
|
+
specialChars: false
|
|
132
|
+
};
|
|
133
|
+
var OTP_CACHE_PREFIX = "otp:";
|
|
134
|
+
var OTP_ATTEMPTS_CACHE_PREFIX = "otp:attempts:";
|
|
135
|
+
|
|
136
|
+
// src/common/cards/card.utils.ts
|
|
137
|
+
var maskPan = /* @__PURE__ */ __name((pan, visiblePrefix = 0, visibleSuffix = 4) => {
|
|
138
|
+
const digits = pan.replace(/\s+/g, "");
|
|
139
|
+
if (digits.length <= visibleSuffix) {
|
|
140
|
+
return digits;
|
|
141
|
+
}
|
|
142
|
+
const prefix = digits.slice(0, visiblePrefix);
|
|
143
|
+
const suffix = digits.slice(-visibleSuffix);
|
|
144
|
+
const maskedLength = Math.max(0, digits.length - visiblePrefix - visibleSuffix);
|
|
145
|
+
return `${prefix}${"*".repeat(maskedLength)}${suffix}`;
|
|
146
|
+
}, "maskPan");
|
|
147
|
+
var extractLast4 = /* @__PURE__ */ __name((pan) => {
|
|
148
|
+
const digits = pan.replace(/\s+/g, "");
|
|
149
|
+
return digits.slice(-4);
|
|
150
|
+
}, "extractLast4");
|
|
151
|
+
var extractBin = /* @__PURE__ */ __name((pan, length = 6) => {
|
|
152
|
+
const digits = pan.replace(/\s+/g, "");
|
|
153
|
+
return digits.slice(0, length);
|
|
154
|
+
}, "extractBin");
|
|
155
|
+
var formatCardExpiry = /* @__PURE__ */ __name((month, year) => {
|
|
156
|
+
const normalizedMonth = String(month).padStart(2, "0");
|
|
157
|
+
const normalizedYear = String(year).slice(-2);
|
|
158
|
+
return `${normalizedMonth}/${normalizedYear}`;
|
|
159
|
+
}, "formatCardExpiry");
|
|
160
|
+
var normalizeCardExpiry = /* @__PURE__ */ __name((expiry) => {
|
|
161
|
+
const normalized = expiry.trim();
|
|
162
|
+
const match = normalized.match(/^(\d{1,2})\s*\/\s*(\d{2,4})$/);
|
|
163
|
+
if (!match) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const month = match[1].padStart(2, "0");
|
|
167
|
+
const year = match[2].length === 2 ? `20${match[2]}` : match[2];
|
|
168
|
+
if (Number(month) < 1 || Number(month) > 12) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
month,
|
|
173
|
+
year
|
|
174
|
+
};
|
|
175
|
+
}, "normalizeCardExpiry");
|
|
176
|
+
var formatCardLabel = /* @__PURE__ */ __name((brand, last4) => {
|
|
177
|
+
return `${brand?.trim() || "Card"} \u2022\u2022\u2022\u2022 ${last4}`;
|
|
178
|
+
}, "formatCardLabel");
|
|
179
|
+
|
|
180
|
+
// src/common/crypto/crypto.utils.ts
|
|
181
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
182
|
+
var DECIMAL_ZERO = new import_decimal.default(0);
|
|
183
|
+
var toAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
|
|
184
|
+
return new import_decimal.default(value).mul(new import_decimal.default(10).pow(decimals)).toDecimalPlaces(0, import_decimal.default.ROUND_DOWN).toFixed(0);
|
|
185
|
+
}, "toAtomicUnits");
|
|
186
|
+
var fromAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
|
|
187
|
+
return new import_decimal.default(value).div(new import_decimal.default(10).pow(decimals)).toFixed();
|
|
188
|
+
}, "fromAtomicUnits");
|
|
189
|
+
var formatCryptoAmount = /* @__PURE__ */ __name((value, decimals = 8) => {
|
|
190
|
+
return new import_decimal.default(value).toDecimalPlaces(decimals).toString();
|
|
191
|
+
}, "formatCryptoAmount");
|
|
192
|
+
var normalizeTxHash = /* @__PURE__ */ __name((hash) => {
|
|
193
|
+
return hash.trim().toLowerCase();
|
|
194
|
+
}, "normalizeTxHash");
|
|
195
|
+
var isHexTxHash = /* @__PURE__ */ __name((hash, expectedLength) => {
|
|
196
|
+
const normalized = hash.trim().toLowerCase();
|
|
197
|
+
if (!/^0x[a-f0-9]+$/.test(normalized)) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
if (expectedLength && normalized.length !== expectedLength) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}, "isHexTxHash");
|
|
205
|
+
var isPositiveAmount = /* @__PURE__ */ __name((value) => {
|
|
206
|
+
return new import_decimal.default(value).greaterThan(DECIMAL_ZERO);
|
|
207
|
+
}, "isPositiveAmount");
|
|
208
|
+
|
|
209
|
+
// src/common/enums/otp.enum.ts
|
|
210
|
+
var OtpPurpose = /* @__PURE__ */ (function(OtpPurpose2) {
|
|
211
|
+
OtpPurpose2["PHONE_VERIFICATION"] = "phone_verification";
|
|
212
|
+
OtpPurpose2["PASSWORD_RESET"] = "password_reset";
|
|
213
|
+
OtpPurpose2["TRANSACTION_AUTHORIZATION"] = "transaction_authorization";
|
|
214
|
+
OtpPurpose2["PROFILE_UPDATE"] = "profile_update";
|
|
215
|
+
OtpPurpose2["KYC_VERIFICATION"] = "kyc_verification";
|
|
216
|
+
OtpPurpose2["LOGIN_VERIFICATION"] = "login_verification";
|
|
217
|
+
OtpPurpose2["EMAIL_VERIFICATION"] = "email_verification";
|
|
218
|
+
OtpPurpose2["STAFF_PASSWORD_RESET"] = "staff_password_reset";
|
|
219
|
+
OtpPurpose2["FORGET_PIN"] = "forget_pin";
|
|
220
|
+
OtpPurpose2["CHANGE_PASSWORD"] = "change_password";
|
|
221
|
+
OtpPurpose2["DEVICE_VERIFICATION"] = "device_verification";
|
|
222
|
+
OtpPurpose2["CHANGE_EMAIL"] = "change_email";
|
|
223
|
+
OtpPurpose2["CHANGE_PHONE"] = "change_phone";
|
|
224
|
+
OtpPurpose2["CHANGE_DATE_OF_BIRTH"] = "change_date_of_birth";
|
|
225
|
+
return OtpPurpose2;
|
|
226
|
+
})({});
|
|
227
|
+
|
|
228
|
+
// src/common/dto/pagination-query.dto.ts
|
|
229
|
+
var import_class_transformer = require("class-transformer");
|
|
230
|
+
var import_class_validator = require("class-validator");
|
|
231
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
232
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
233
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
234
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
235
|
+
} else {
|
|
236
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
237
|
+
if (d = decorators[i]) {
|
|
238
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
243
|
+
}
|
|
244
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
245
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
246
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
247
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
251
|
+
var PaginationQueryDto = class {
|
|
252
|
+
static {
|
|
253
|
+
__name(this, "PaginationQueryDto");
|
|
254
|
+
}
|
|
255
|
+
page;
|
|
256
|
+
limit;
|
|
257
|
+
search;
|
|
258
|
+
sortBy;
|
|
259
|
+
sortOrder;
|
|
260
|
+
};
|
|
261
|
+
_ts_decorate([
|
|
262
|
+
(0, import_class_transformer.Type)(() => Number),
|
|
263
|
+
(0, import_class_validator.IsInt)(),
|
|
264
|
+
(0, import_class_validator.Min)(1),
|
|
265
|
+
(0, import_class_validator.IsOptional)(),
|
|
266
|
+
_ts_metadata("design:type", Number)
|
|
267
|
+
], PaginationQueryDto.prototype, "page", void 0);
|
|
268
|
+
_ts_decorate([
|
|
269
|
+
(0, import_class_transformer.Type)(() => Number),
|
|
270
|
+
(0, import_class_validator.IsInt)(),
|
|
271
|
+
(0, import_class_validator.Min)(1),
|
|
272
|
+
(0, import_class_validator.IsOptional)(),
|
|
273
|
+
_ts_metadata("design:type", Number)
|
|
274
|
+
], PaginationQueryDto.prototype, "limit", void 0);
|
|
275
|
+
_ts_decorate([
|
|
276
|
+
(0, import_class_validator.IsString)(),
|
|
277
|
+
(0, import_class_validator.IsOptional)(),
|
|
278
|
+
_ts_metadata("design:type", String)
|
|
279
|
+
], PaginationQueryDto.prototype, "search", void 0);
|
|
280
|
+
_ts_decorate([
|
|
281
|
+
(0, import_class_validator.IsString)(),
|
|
282
|
+
(0, import_class_validator.IsOptional)(),
|
|
283
|
+
_ts_metadata("design:type", String)
|
|
284
|
+
], PaginationQueryDto.prototype, "sortBy", void 0);
|
|
285
|
+
_ts_decorate([
|
|
286
|
+
(0, import_class_validator.IsIn)([
|
|
287
|
+
"asc",
|
|
288
|
+
"desc"
|
|
289
|
+
]),
|
|
290
|
+
(0, import_class_validator.IsOptional)(),
|
|
291
|
+
_ts_metadata("design:type", String)
|
|
292
|
+
], PaginationQueryDto.prototype, "sortOrder", void 0);
|
|
293
|
+
|
|
294
|
+
// src/common/pipes/file-validation.pipe.ts
|
|
295
|
+
var import_common = require("@nestjs/common");
|
|
296
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
297
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
298
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
299
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
300
|
+
} else {
|
|
301
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
302
|
+
if (d = decorators[i]) {
|
|
303
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
308
|
+
}
|
|
309
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
310
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
311
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
312
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
316
|
+
var DEFAULT_ALLOWED_MIME_TYPES = [
|
|
317
|
+
"image/jpeg",
|
|
318
|
+
"image/jpg",
|
|
319
|
+
"image/png"
|
|
320
|
+
];
|
|
321
|
+
var DEFAULT_MAX_SIZE_BYTES = 5 * 1024 * 1024;
|
|
322
|
+
var FileValidationPipe = class {
|
|
323
|
+
static {
|
|
324
|
+
__name(this, "FileValidationPipe");
|
|
325
|
+
}
|
|
326
|
+
options;
|
|
327
|
+
constructor(options = {}) {
|
|
328
|
+
this.options = options;
|
|
329
|
+
}
|
|
330
|
+
transform(value) {
|
|
331
|
+
const files = this.normalizeFiles(value);
|
|
332
|
+
if (files.length === 0) {
|
|
333
|
+
throw new import_common.BadRequestException("No files uploaded");
|
|
334
|
+
}
|
|
335
|
+
this.validateRequiredFields(value);
|
|
336
|
+
const allowedMimeTypes = this.options.allowedMimeTypes ?? DEFAULT_ALLOWED_MIME_TYPES;
|
|
337
|
+
const maxSizeBytes = this.options.maxSizeBytes ?? DEFAULT_MAX_SIZE_BYTES;
|
|
338
|
+
for (const file of files) {
|
|
339
|
+
const label = file.fieldname || file.originalname || "file";
|
|
340
|
+
if (file.mimetype && !allowedMimeTypes.includes(file.mimetype)) {
|
|
341
|
+
throw new import_common.BadRequestException(`${label} must be one of: ${allowedMimeTypes.join(", ")}`);
|
|
342
|
+
}
|
|
343
|
+
if (typeof file.size === "number" && file.size > maxSizeBytes) {
|
|
344
|
+
throw new import_common.BadRequestException(`${label} size must not exceed ${this.formatFileSize(maxSizeBytes)}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return value;
|
|
348
|
+
}
|
|
349
|
+
validateRequiredFields(value) {
|
|
350
|
+
const requiredFields = this.options.requiredFields ?? [];
|
|
351
|
+
if (requiredFields.length === 0 || !value || Array.isArray(value) || typeof value !== "object") {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
for (const field of requiredFields) {
|
|
355
|
+
const files = value[field];
|
|
356
|
+
if (!files || files.length === 0) {
|
|
357
|
+
throw new import_common.BadRequestException(`${field} file is required`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
normalizeFiles(value) {
|
|
362
|
+
if (!value) {
|
|
363
|
+
return [];
|
|
364
|
+
}
|
|
365
|
+
if (Array.isArray(value)) {
|
|
366
|
+
return value;
|
|
367
|
+
}
|
|
368
|
+
return Object.values(value).flatMap((files) => files ?? []);
|
|
369
|
+
}
|
|
370
|
+
formatFileSize(bytes) {
|
|
371
|
+
if (bytes < 1024) {
|
|
372
|
+
return `${bytes} Bytes`;
|
|
373
|
+
}
|
|
374
|
+
if (bytes < 1024 * 1024) {
|
|
375
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
376
|
+
}
|
|
377
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
FileValidationPipe = _ts_decorate2([
|
|
381
|
+
(0, import_common.Injectable)(),
|
|
382
|
+
_ts_metadata2("design:type", Function),
|
|
383
|
+
_ts_metadata2("design:paramtypes", [
|
|
384
|
+
typeof FileValidationOptions === "undefined" ? Object : FileValidationOptions
|
|
385
|
+
])
|
|
386
|
+
], FileValidationPipe);
|
|
387
|
+
|
|
388
|
+
// src/common/pipes/pagination-query-cleaner.pipe.ts
|
|
389
|
+
var import_common2 = require("@nestjs/common");
|
|
390
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
391
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
392
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
393
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
394
|
+
} else {
|
|
395
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
396
|
+
if (d = decorators[i]) {
|
|
397
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
402
|
+
}
|
|
403
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
404
|
+
var PaginationQueryCleanerPipe = class {
|
|
405
|
+
static {
|
|
406
|
+
__name(this, "PaginationQueryCleanerPipe");
|
|
407
|
+
}
|
|
408
|
+
transform(value, _metadata) {
|
|
409
|
+
if (!value || typeof value !== "object") {
|
|
410
|
+
return value;
|
|
411
|
+
}
|
|
412
|
+
delete value.page;
|
|
413
|
+
delete value.limit;
|
|
414
|
+
return value;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
PaginationQueryCleanerPipe = _ts_decorate3([
|
|
418
|
+
(0, import_common2.Injectable)()
|
|
419
|
+
], PaginationQueryCleanerPipe);
|
|
420
|
+
|
|
421
|
+
// src/common/response/http-exception.filter.ts
|
|
422
|
+
var import_common3 = require("@nestjs/common");
|
|
423
|
+
|
|
424
|
+
// src/common/response/response.utils.ts
|
|
425
|
+
var AppResponse = class {
|
|
426
|
+
static {
|
|
427
|
+
__name(this, "AppResponse");
|
|
428
|
+
}
|
|
429
|
+
static success(message, data, meta) {
|
|
430
|
+
return {
|
|
431
|
+
success: true,
|
|
432
|
+
message,
|
|
433
|
+
data,
|
|
434
|
+
...meta ? {
|
|
435
|
+
meta
|
|
436
|
+
} : {}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
static paginated(message, items, pagination, meta) {
|
|
440
|
+
return {
|
|
441
|
+
success: true,
|
|
442
|
+
message,
|
|
443
|
+
data: items,
|
|
444
|
+
meta: {
|
|
445
|
+
...meta,
|
|
446
|
+
pagination
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
static error(message, errors, meta, data = null) {
|
|
451
|
+
return {
|
|
452
|
+
success: false,
|
|
453
|
+
message,
|
|
454
|
+
data,
|
|
455
|
+
...meta ? {
|
|
456
|
+
meta
|
|
457
|
+
} : {},
|
|
458
|
+
...errors?.length ? {
|
|
459
|
+
errors
|
|
460
|
+
} : {}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
// src/common/response/http-exception.filter.ts
|
|
466
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
467
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
468
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
469
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
470
|
+
} else {
|
|
471
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
472
|
+
if (d = decorators[i]) {
|
|
473
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
478
|
+
}
|
|
479
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
480
|
+
var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
481
|
+
static {
|
|
482
|
+
__name(this, "HttpExceptionFilter");
|
|
483
|
+
}
|
|
484
|
+
logger = new import_common3.Logger(_HttpExceptionFilter.name);
|
|
485
|
+
catch(exception, host) {
|
|
486
|
+
const ctx = host.switchToHttp();
|
|
487
|
+
const response = ctx.getResponse();
|
|
488
|
+
const request = ctx.getRequest();
|
|
489
|
+
const status = exception instanceof import_common3.HttpException ? exception.getStatus() : import_common3.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
490
|
+
const message = exception instanceof import_common3.HttpException ? exception.message : "An unexpected error occurred";
|
|
491
|
+
const errors = this.getValidationErrors(exception);
|
|
492
|
+
this.logger.error({
|
|
493
|
+
method: request.method,
|
|
494
|
+
url: request.url,
|
|
495
|
+
statusCode: status,
|
|
496
|
+
error: message,
|
|
497
|
+
stack: exception instanceof Error ? exception.stack : void 0
|
|
498
|
+
}, "HTTP request failed");
|
|
499
|
+
const body = AppResponse.error(message, errors, {
|
|
500
|
+
path: request.url ? `${request.method ?? "GET"} ${request.url}` : void 0,
|
|
501
|
+
requestId: request.requestId ?? request.id,
|
|
502
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
503
|
+
});
|
|
504
|
+
response.status(status).send(body);
|
|
505
|
+
}
|
|
506
|
+
getValidationErrors(exception) {
|
|
507
|
+
if (!(exception instanceof import_common3.BadRequestException)) {
|
|
508
|
+
return void 0;
|
|
509
|
+
}
|
|
510
|
+
const payload = exception.getResponse();
|
|
511
|
+
if (typeof payload === "object" && payload !== null) {
|
|
512
|
+
const errors = payload.errors;
|
|
513
|
+
if (Array.isArray(errors)) {
|
|
514
|
+
return errors;
|
|
515
|
+
}
|
|
516
|
+
const message = payload.message;
|
|
517
|
+
if (Array.isArray(message)) {
|
|
518
|
+
return message.map((item) => ({
|
|
519
|
+
message: String(item)
|
|
520
|
+
}));
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return void 0;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
HttpExceptionFilter = _ts_decorate4([
|
|
527
|
+
(0, import_common3.Catch)()
|
|
528
|
+
], HttpExceptionFilter);
|
|
529
|
+
|
|
530
|
+
// src/common/response/http-only-exception.filter.ts
|
|
531
|
+
var import_common4 = require("@nestjs/common");
|
|
532
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
533
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
534
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
535
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
536
|
+
} else {
|
|
537
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
538
|
+
if (d = decorators[i]) {
|
|
539
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
544
|
+
}
|
|
545
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
546
|
+
var HttpOnlyExceptionFilter = class {
|
|
547
|
+
static {
|
|
548
|
+
__name(this, "HttpOnlyExceptionFilter");
|
|
549
|
+
}
|
|
550
|
+
httpExceptionFilter = new HttpExceptionFilter();
|
|
551
|
+
catch(exception, host) {
|
|
552
|
+
if (host.getType() !== "http") {
|
|
553
|
+
throw exception;
|
|
554
|
+
}
|
|
555
|
+
this.httpExceptionFilter.catch(exception, host);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
HttpOnlyExceptionFilter = _ts_decorate5([
|
|
559
|
+
(0, import_common4.Catch)()
|
|
560
|
+
], HttpOnlyExceptionFilter);
|
|
561
|
+
|
|
562
|
+
// src/common/response/response.interceptor.ts
|
|
563
|
+
var import_common5 = require("@nestjs/common");
|
|
564
|
+
var import_operators = require("rxjs/operators");
|
|
565
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
566
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
567
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
568
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
569
|
+
} else {
|
|
570
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
571
|
+
if (d = decorators[i]) {
|
|
572
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
577
|
+
}
|
|
578
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
579
|
+
function isApiResponse(value) {
|
|
580
|
+
return typeof value === "object" && value !== null && "success" in value && "message" in value && "data" in value;
|
|
581
|
+
}
|
|
582
|
+
__name(isApiResponse, "isApiResponse");
|
|
583
|
+
function isPaginatedPayload(value) {
|
|
584
|
+
return typeof value === "object" && value !== null && "items" in value && Array.isArray(value.items) && "pagination" in value;
|
|
585
|
+
}
|
|
586
|
+
__name(isPaginatedPayload, "isPaginatedPayload");
|
|
587
|
+
var ResponseInterceptor = class {
|
|
588
|
+
static {
|
|
589
|
+
__name(this, "ResponseInterceptor");
|
|
590
|
+
}
|
|
591
|
+
intercept(context, next) {
|
|
592
|
+
if (context.getType() !== "http") {
|
|
593
|
+
return next.handle();
|
|
594
|
+
}
|
|
595
|
+
const request = context.switchToHttp().getRequest();
|
|
596
|
+
return next.handle().pipe((0, import_operators.map)((data) => {
|
|
597
|
+
if (isApiResponse(data)) {
|
|
598
|
+
return data;
|
|
599
|
+
}
|
|
600
|
+
const meta = {
|
|
601
|
+
path: request.url ? `${request.method ?? "GET"} ${request.url}` : void 0,
|
|
602
|
+
requestId: request.requestId ?? request.id,
|
|
603
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
604
|
+
};
|
|
605
|
+
if (isPaginatedPayload(data)) {
|
|
606
|
+
return AppResponse.paginated(data.message ?? "Request successful", data.items, data.pagination, {
|
|
607
|
+
...meta,
|
|
608
|
+
...data.meta
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
return AppResponse.success("Request successful", data, meta);
|
|
612
|
+
}));
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
ResponseInterceptor = _ts_decorate6([
|
|
616
|
+
(0, import_common5.Injectable)()
|
|
617
|
+
], ResponseInterceptor);
|
|
618
|
+
|
|
619
|
+
// src/common/utils/country.utils.ts
|
|
620
|
+
var CountryCodeList = __toESM(require("country-codes-list"));
|
|
621
|
+
var countryDialCodes = Object.keys(CountryCodeList.customList("countryCallingCode")).map((code) => `+${code}`);
|
|
622
|
+
|
|
623
|
+
// src/common/utils/date.utils.ts
|
|
624
|
+
var calculateNextDate = /* @__PURE__ */ __name((frequency, lastDate) => {
|
|
625
|
+
const nextDate = new Date(lastDate);
|
|
626
|
+
switch (frequency) {
|
|
627
|
+
case "DAILY":
|
|
628
|
+
nextDate.setDate(nextDate.getDate() + 1);
|
|
629
|
+
return nextDate;
|
|
630
|
+
case "WEEKLY":
|
|
631
|
+
nextDate.setDate(nextDate.getDate() + 7);
|
|
632
|
+
return nextDate;
|
|
633
|
+
case "MONTHLY":
|
|
634
|
+
nextDate.setMonth(nextDate.getMonth() + 1);
|
|
635
|
+
return nextDate;
|
|
636
|
+
}
|
|
637
|
+
}, "calculateNextDate");
|
|
638
|
+
var isToday = /* @__PURE__ */ __name((date) => {
|
|
639
|
+
const currentDate = new Date(date);
|
|
640
|
+
const today = /* @__PURE__ */ new Date();
|
|
641
|
+
return currentDate.getDate() === today.getDate() && currentDate.getMonth() === today.getMonth() && currentDate.getFullYear() === today.getFullYear();
|
|
642
|
+
}, "isToday");
|
|
643
|
+
var isNotPastDate = /* @__PURE__ */ __name((date) => {
|
|
644
|
+
return new Date(date).getTime() >= Date.now();
|
|
645
|
+
}, "isNotPastDate");
|
|
646
|
+
var isDateInRange = /* @__PURE__ */ __name((date, minDate, maxDate) => {
|
|
647
|
+
const timestamp = new Date(date).getTime();
|
|
648
|
+
return timestamp >= new Date(minDate).getTime() && timestamp <= new Date(maxDate).getTime();
|
|
649
|
+
}, "isDateInRange");
|
|
650
|
+
var isValidAge = /* @__PURE__ */ __name((dateOfBirth, minAge = 18) => {
|
|
651
|
+
const today = /* @__PURE__ */ new Date();
|
|
652
|
+
const birthDate = new Date(dateOfBirth);
|
|
653
|
+
let age = today.getFullYear() - birthDate.getFullYear();
|
|
654
|
+
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
655
|
+
if (monthDiff < 0 || monthDiff === 0 && today.getDate() < birthDate.getDate()) {
|
|
656
|
+
age--;
|
|
657
|
+
}
|
|
658
|
+
return age >= minAge;
|
|
659
|
+
}, "isValidAge");
|
|
660
|
+
|
|
661
|
+
// src/common/utils/decimal.utils.ts
|
|
662
|
+
var import_decimal2 = __toESM(require("decimal.js"));
|
|
663
|
+
var DEFAULT_DECIMAL_PLACES = 4;
|
|
664
|
+
import_decimal2.default.set({
|
|
665
|
+
precision: 20,
|
|
666
|
+
rounding: import_decimal2.default.ROUND_HALF_UP
|
|
667
|
+
});
|
|
668
|
+
var toDecimal = /* @__PURE__ */ __name((value) => {
|
|
669
|
+
try {
|
|
670
|
+
return new import_decimal2.default(value);
|
|
671
|
+
} catch {
|
|
672
|
+
throw new Error(`Invalid decimal value: ${value}`);
|
|
673
|
+
}
|
|
674
|
+
}, "toDecimal");
|
|
675
|
+
var toRoundedNumber = /* @__PURE__ */ __name((value, decimalPlaces = DEFAULT_DECIMAL_PLACES) => {
|
|
676
|
+
return toDecimal(value).toDecimalPlaces(decimalPlaces).toNumber();
|
|
677
|
+
}, "toRoundedNumber");
|
|
678
|
+
|
|
679
|
+
// src/common/utils/format.utils.ts
|
|
680
|
+
var formatCurrency = /* @__PURE__ */ __name((amount, currencySymbol = "\u20A6", decimals = 2) => {
|
|
681
|
+
const formatted = amount.toLocaleString("en-NG", {
|
|
682
|
+
minimumFractionDigits: decimals,
|
|
683
|
+
maximumFractionDigits: decimals
|
|
684
|
+
});
|
|
685
|
+
return `${currencySymbol}${formatted}`;
|
|
686
|
+
}, "formatCurrency");
|
|
687
|
+
var formatAmount = /* @__PURE__ */ __name((amount, decimals = 2, locale = "en-NG") => {
|
|
688
|
+
return amount.toLocaleString(locale, {
|
|
689
|
+
minimumFractionDigits: decimals,
|
|
690
|
+
maximumFractionDigits: decimals
|
|
691
|
+
});
|
|
692
|
+
}, "formatAmount");
|
|
693
|
+
var formatAccountNumber = /* @__PURE__ */ __name((accountNumber) => {
|
|
694
|
+
if (accountNumber.length !== 10) {
|
|
695
|
+
return accountNumber;
|
|
696
|
+
}
|
|
697
|
+
return `${accountNumber.slice(0, 4)} ${accountNumber.slice(4, 8)} ${accountNumber.slice(8)}`;
|
|
698
|
+
}, "formatAccountNumber");
|
|
699
|
+
var maskAccountNumber = /* @__PURE__ */ __name((accountNumber) => {
|
|
700
|
+
if (accountNumber.length < 4) {
|
|
701
|
+
return accountNumber;
|
|
702
|
+
}
|
|
703
|
+
return "*".repeat(accountNumber.length - 4) + accountNumber.slice(-4);
|
|
704
|
+
}, "maskAccountNumber");
|
|
705
|
+
var maskEmail = /* @__PURE__ */ __name((email) => {
|
|
706
|
+
const [username, domain] = email.split("@");
|
|
707
|
+
if (!username || !domain) {
|
|
708
|
+
return email;
|
|
709
|
+
}
|
|
710
|
+
return `${username[0]}${"*".repeat(Math.max(0, username.length - 1))}@${domain}`;
|
|
711
|
+
}, "maskEmail");
|
|
712
|
+
var formatDate = /* @__PURE__ */ __name((date) => {
|
|
713
|
+
const currentDate = new Date(date);
|
|
714
|
+
const day = String(currentDate.getDate()).padStart(2, "0");
|
|
715
|
+
const month = String(currentDate.getMonth() + 1).padStart(2, "0");
|
|
716
|
+
const year = currentDate.getFullYear();
|
|
717
|
+
return `${day}/${month}/${year}`;
|
|
718
|
+
}, "formatDate");
|
|
719
|
+
var formatDateTime = /* @__PURE__ */ __name((date) => {
|
|
720
|
+
const currentDate = new Date(date);
|
|
721
|
+
const hours = String(currentDate.getHours()).padStart(2, "0");
|
|
722
|
+
const minutes = String(currentDate.getMinutes()).padStart(2, "0");
|
|
723
|
+
return `${formatDate(currentDate)} ${hours}:${minutes}`;
|
|
724
|
+
}, "formatDateTime");
|
|
725
|
+
var formatRelativeTime = /* @__PURE__ */ __name((date) => {
|
|
726
|
+
const currentDate = new Date(date);
|
|
727
|
+
const diffMs = Date.now() - currentDate.getTime();
|
|
728
|
+
const diffSeconds = Math.floor(diffMs / 1e3);
|
|
729
|
+
const diffMinutes = Math.floor(diffSeconds / 60);
|
|
730
|
+
const diffHours = Math.floor(diffMinutes / 60);
|
|
731
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
732
|
+
if (diffSeconds < 60) {
|
|
733
|
+
return "Just now";
|
|
734
|
+
}
|
|
735
|
+
if (diffMinutes < 60) {
|
|
736
|
+
return `${diffMinutes} minute${diffMinutes > 1 ? "s" : ""} ago`;
|
|
737
|
+
}
|
|
738
|
+
if (diffHours < 24) {
|
|
739
|
+
return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
|
|
740
|
+
}
|
|
741
|
+
if (diffDays < 7) {
|
|
742
|
+
return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
|
|
743
|
+
}
|
|
744
|
+
return formatDate(currentDate);
|
|
745
|
+
}, "formatRelativeTime");
|
|
746
|
+
var formatPercentage = /* @__PURE__ */ __name((value, decimals = 1) => {
|
|
747
|
+
return `${(value * 100).toFixed(decimals)}%`;
|
|
748
|
+
}, "formatPercentage");
|
|
749
|
+
var formatFileSize = /* @__PURE__ */ __name((bytes) => {
|
|
750
|
+
if (bytes === 0) {
|
|
751
|
+
return "0 Bytes";
|
|
752
|
+
}
|
|
753
|
+
const unit = 1024;
|
|
754
|
+
const sizes = [
|
|
755
|
+
"Bytes",
|
|
756
|
+
"KB",
|
|
757
|
+
"MB",
|
|
758
|
+
"GB",
|
|
759
|
+
"TB"
|
|
760
|
+
];
|
|
761
|
+
const sizeIndex = Math.floor(Math.log(bytes) / Math.log(unit));
|
|
762
|
+
return `${Number((bytes / unit ** sizeIndex).toFixed(2))} ${sizes[sizeIndex]}`;
|
|
763
|
+
}, "formatFileSize");
|
|
764
|
+
var truncateText = /* @__PURE__ */ __name((text, maxLength) => {
|
|
765
|
+
if (text.length <= maxLength) {
|
|
766
|
+
return text;
|
|
767
|
+
}
|
|
768
|
+
return `${text.slice(0, maxLength - 3)}...`;
|
|
769
|
+
}, "truncateText");
|
|
770
|
+
var toTitleCase = /* @__PURE__ */ __name((text) => {
|
|
771
|
+
return text.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
772
|
+
}, "toTitleCase");
|
|
773
|
+
var normalizeNigerianPhone = /* @__PURE__ */ __name((phone, withPlus = false) => {
|
|
774
|
+
const digits = `${phone}`.replace(/\D/g, "").trim();
|
|
775
|
+
if (digits === "") {
|
|
776
|
+
return "";
|
|
777
|
+
}
|
|
778
|
+
let normalized = digits;
|
|
779
|
+
if (digits.startsWith("234") && digits.length === 13) {
|
|
780
|
+
normalized = digits;
|
|
781
|
+
} else if (digits.startsWith("0") && digits.length === 11) {
|
|
782
|
+
normalized = `234${digits.slice(1)}`;
|
|
783
|
+
} else if (digits.length === 10 && /^[789]/.test(digits)) {
|
|
784
|
+
normalized = `234${digits}`;
|
|
785
|
+
} else if (!digits.startsWith("234") && digits.length === 10) {
|
|
786
|
+
normalized = `234${digits}`;
|
|
787
|
+
}
|
|
788
|
+
return withPlus ? `+${normalized}` : normalized;
|
|
789
|
+
}, "normalizeNigerianPhone");
|
|
790
|
+
|
|
791
|
+
// src/common/utils/string.utils.ts
|
|
792
|
+
var formatPhoneNumber = /* @__PURE__ */ __name((phone) => {
|
|
793
|
+
const cleaned = phone.replace(/[\s\-\(\)]/g, "");
|
|
794
|
+
let formatted = cleaned;
|
|
795
|
+
if (formatted.startsWith("0")) {
|
|
796
|
+
formatted = "234" + formatted.substring(1);
|
|
797
|
+
}
|
|
798
|
+
if (formatted.startsWith("234")) {
|
|
799
|
+
return `+234 ${formatted.substring(3, 6)} ${formatted.substring(6, 9)} ${formatted.substring(9)}`;
|
|
800
|
+
}
|
|
801
|
+
return phone;
|
|
802
|
+
}, "formatPhoneNumber");
|
|
803
|
+
var maskPhoneNumber = /* @__PURE__ */ __name((phone) => {
|
|
804
|
+
const cleaned = phone.replace(/[\s\-\(\)]/g, "");
|
|
805
|
+
if (cleaned.length < 8) return phone;
|
|
806
|
+
const prefix = cleaned.substring(0, 4);
|
|
807
|
+
const suffix = cleaned.slice(-4);
|
|
808
|
+
return `${prefix}****${suffix}`;
|
|
809
|
+
}, "maskPhoneNumber");
|
|
810
|
+
|
|
811
|
+
// src/common/utils/random.utils.ts
|
|
812
|
+
var DIGITS = "0123456789";
|
|
813
|
+
var LOWERCASE_CHARS = "abcdefghijklmnopqrstuvwxyz";
|
|
814
|
+
var UPPERCASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
815
|
+
var SPECIAL_CHARS = "!@#$%^&*()_+-=[]{}|;:,.<>?";
|
|
816
|
+
function generateRandomString(options = {}) {
|
|
817
|
+
const { length = 6, digits = true, lowerCaseAlphabets = false, upperCaseAlphabets = false, specialChars = false } = options;
|
|
818
|
+
let chars = "";
|
|
819
|
+
if (digits) chars += DIGITS;
|
|
820
|
+
if (lowerCaseAlphabets) chars += LOWERCASE_CHARS;
|
|
821
|
+
if (upperCaseAlphabets) chars += UPPERCASE_CHARS;
|
|
822
|
+
if (specialChars) chars += SPECIAL_CHARS;
|
|
823
|
+
if (!chars) chars = DIGITS;
|
|
824
|
+
let result = "";
|
|
825
|
+
const charactersLength = chars.length;
|
|
826
|
+
for (let i = 0; i < length; i++) {
|
|
827
|
+
result += chars.charAt(Math.floor(Math.random() * charactersLength));
|
|
828
|
+
}
|
|
829
|
+
return result;
|
|
830
|
+
}
|
|
831
|
+
__name(generateRandomString, "generateRandomString");
|
|
832
|
+
|
|
833
|
+
// src/common/utils/reference.utils.ts
|
|
834
|
+
var generateRandomString2 = /* @__PURE__ */ __name((length) => {
|
|
835
|
+
const characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
836
|
+
const charactersLength = characters.length;
|
|
837
|
+
let result = "";
|
|
838
|
+
for (let i = 0; i < length; i++) {
|
|
839
|
+
const randomIndex = Math.floor(Math.random() * charactersLength);
|
|
840
|
+
result += characters[randomIndex];
|
|
841
|
+
}
|
|
842
|
+
return result;
|
|
843
|
+
}, "generateRandomString");
|
|
844
|
+
var generateReference = /* @__PURE__ */ __name((prefix = "TRX") => {
|
|
845
|
+
return `${prefix}_${generateRandomString2(12)}`;
|
|
846
|
+
}, "generateReference");
|
|
847
|
+
|
|
848
|
+
// src/common/utils/validation.utils.ts
|
|
849
|
+
var isValidNigerianPhone = /* @__PURE__ */ __name((phone) => {
|
|
850
|
+
const cleaned = phone.replace(/[\s\-()]/g, "");
|
|
851
|
+
const patterns = [
|
|
852
|
+
/^0[7-9][0-1]\d{8}$/,
|
|
853
|
+
/^\+234[7-9][0-1]\d{8}$/,
|
|
854
|
+
/^234[7-9][0-1]\d{8}$/
|
|
855
|
+
];
|
|
856
|
+
return patterns.some((pattern) => pattern.test(cleaned));
|
|
857
|
+
}, "isValidNigerianPhone");
|
|
858
|
+
var isValidEmail = /* @__PURE__ */ __name((email) => {
|
|
859
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
860
|
+
}, "isValidEmail");
|
|
861
|
+
var isValidBVN = /* @__PURE__ */ __name((bvn) => {
|
|
862
|
+
return /^\d{11}$/.test(bvn);
|
|
863
|
+
}, "isValidBVN");
|
|
864
|
+
var isValidNIN = /* @__PURE__ */ __name((nin) => {
|
|
865
|
+
return /^\d{11}$/.test(nin);
|
|
866
|
+
}, "isValidNIN");
|
|
867
|
+
var isValidAccountNumber = /* @__PURE__ */ __name((accountNumber) => {
|
|
868
|
+
return /^\d{10}$/.test(accountNumber);
|
|
869
|
+
}, "isValidAccountNumber");
|
|
870
|
+
var isValidAmount = /* @__PURE__ */ __name((amount) => {
|
|
871
|
+
return typeof amount === "number" && Number.isFinite(amount) && amount > 0;
|
|
872
|
+
}, "isValidAmount");
|
|
873
|
+
var isStrongPassword = /* @__PURE__ */ __name((password) => {
|
|
874
|
+
return password.length >= 8 && /[A-Z]/.test(password) && /[a-z]/.test(password) && /\d/.test(password);
|
|
875
|
+
}, "isStrongPassword");
|
|
876
|
+
var isValidTransactionReference = /* @__PURE__ */ __name((reference) => {
|
|
877
|
+
return /^[A-Z0-9_-]{10,50}$/.test(reference);
|
|
878
|
+
}, "isValidTransactionReference");
|
|
879
|
+
|
|
880
|
+
// src/common/config/nats.config.ts
|
|
881
|
+
var import_microservices = require("@nestjs/microservices");
|
|
882
|
+
var getNatsServers = /* @__PURE__ */ __name((configService) => {
|
|
883
|
+
const rawServers = configService.get("NATS_SERVERS") ?? configService.get("NATS_URL") ?? "nats://localhost:4222";
|
|
884
|
+
return rawServers.split(",").map((server) => server.trim()).filter(Boolean);
|
|
885
|
+
}, "getNatsServers");
|
|
886
|
+
var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
|
|
887
|
+
transport: import_microservices.Transport.NATS,
|
|
888
|
+
options: {
|
|
889
|
+
servers: getNatsServers(configService)
|
|
890
|
+
}
|
|
891
|
+
}), "getNatsMicroserviceConfig");
|
|
892
|
+
var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
|
|
893
|
+
const queue = queueName && configService.get(`NATS_${queueName.toUpperCase()}_QUEUE`);
|
|
894
|
+
return {
|
|
895
|
+
transport: import_microservices.Transport.NATS,
|
|
896
|
+
options: {
|
|
897
|
+
servers: getNatsServers(configService),
|
|
898
|
+
...queue ? {
|
|
899
|
+
queue
|
|
900
|
+
} : {}
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
}, "getNatsConfig");
|
|
904
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
905
|
+
0 && (module.exports = {
|
|
906
|
+
AppResponse,
|
|
907
|
+
BANKING_QUEUE,
|
|
908
|
+
CARD_QUEUE,
|
|
909
|
+
CRYPTO_QUEUE,
|
|
910
|
+
DEFAULT_OTP_EXPIRY,
|
|
911
|
+
DEFAULT_OTP_LENGTH,
|
|
912
|
+
DEFAULT_OTP_OPTIONS,
|
|
913
|
+
FileValidationPipe,
|
|
914
|
+
HttpExceptionFilter,
|
|
915
|
+
HttpOnlyExceptionFilter,
|
|
916
|
+
KYC_QUEUE,
|
|
917
|
+
LEDGER_QUEUE,
|
|
918
|
+
MAX_OTP_ATTEMPTS,
|
|
919
|
+
NOTIFICATION_QUEUE,
|
|
920
|
+
OPS_QUEUE,
|
|
921
|
+
OTP_ATTEMPTS_CACHE_PREFIX,
|
|
922
|
+
OTP_BLOCK_DURATION,
|
|
923
|
+
OTP_CACHE_PREFIX,
|
|
924
|
+
OtpPurpose,
|
|
925
|
+
PaginationQueryCleanerPipe,
|
|
926
|
+
PaginationQueryDto,
|
|
927
|
+
ResponseInterceptor,
|
|
928
|
+
USER_QUEUE,
|
|
929
|
+
VAS_QUEUE,
|
|
930
|
+
calculateNextDate,
|
|
931
|
+
countryDialCodes,
|
|
932
|
+
extractBin,
|
|
933
|
+
extractLast4,
|
|
934
|
+
formatAccountNumber,
|
|
935
|
+
formatAmount,
|
|
936
|
+
formatCardExpiry,
|
|
937
|
+
formatCardLabel,
|
|
938
|
+
formatCryptoAmount,
|
|
939
|
+
formatCurrency,
|
|
940
|
+
formatDate,
|
|
941
|
+
formatDateTime,
|
|
942
|
+
formatFileSize,
|
|
943
|
+
formatPercentage,
|
|
944
|
+
formatPhoneNumber,
|
|
945
|
+
formatRelativeTime,
|
|
946
|
+
fromAtomicUnits,
|
|
947
|
+
generateRandomString,
|
|
948
|
+
generateReference,
|
|
949
|
+
getNatsConfig,
|
|
950
|
+
getNatsMicroserviceConfig,
|
|
951
|
+
getNatsServers,
|
|
952
|
+
isDateInRange,
|
|
953
|
+
isHexTxHash,
|
|
954
|
+
isNotPastDate,
|
|
955
|
+
isPositiveAmount,
|
|
956
|
+
isStrongPassword,
|
|
957
|
+
isToday,
|
|
958
|
+
isValidAccountNumber,
|
|
959
|
+
isValidAge,
|
|
960
|
+
isValidAmount,
|
|
961
|
+
isValidBVN,
|
|
962
|
+
isValidEmail,
|
|
963
|
+
isValidNIN,
|
|
964
|
+
isValidNigerianPhone,
|
|
965
|
+
isValidTransactionReference,
|
|
966
|
+
maskAccountNumber,
|
|
967
|
+
maskEmail,
|
|
968
|
+
maskPan,
|
|
969
|
+
maskPhoneNumber,
|
|
970
|
+
normalizeCardExpiry,
|
|
971
|
+
normalizeNigerianPhone,
|
|
972
|
+
normalizeTxHash,
|
|
973
|
+
toAtomicUnits,
|
|
974
|
+
toDecimal,
|
|
975
|
+
toRoundedNumber,
|
|
976
|
+
toTitleCase,
|
|
977
|
+
truncateText
|
|
978
|
+
});
|
|
979
|
+
//# sourceMappingURL=index.js.map
|