opticore-webapp-core 1.0.7 → 1.0.8
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.cjs +232 -187
- package/dist/index.d.cts +38 -22
- package/dist/index.d.ts +38 -22
- package/dist/index.js +242 -197
- package/dist/utils/translations/message.translation.en.json +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -59,7 +59,6 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
59
59
|
// src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
|
|
60
60
|
var import_crypto3 = __toESM(require("crypto"), 1);
|
|
61
61
|
var import_opticore_http_response = require("opticore-http-response");
|
|
62
|
-
var import_opticore_logger = require("opticore-logger");
|
|
63
62
|
var import_opticore_translator = require("opticore-translator");
|
|
64
63
|
var import_opticore_catch_exception_error = require("opticore-catch-exception-error");
|
|
65
64
|
|
|
@@ -189,6 +188,9 @@ var RSAKeyDecryption = class {
|
|
|
189
188
|
}
|
|
190
189
|
};
|
|
191
190
|
|
|
191
|
+
// src/application/services/loggerFileConfiguration.service.ts
|
|
192
|
+
var import_opticore_logger = require("opticore-logger");
|
|
193
|
+
|
|
192
194
|
// src/core/config/logger/logger.config.ts
|
|
193
195
|
var import_opticore_env_access = require("opticore-env-access");
|
|
194
196
|
var loggerConfig = {
|
|
@@ -215,28 +217,34 @@ var loggerConfig = {
|
|
|
215
217
|
}
|
|
216
218
|
};
|
|
217
219
|
|
|
220
|
+
// src/application/services/loggerFileConfiguration.service.ts
|
|
221
|
+
var SLoggerFileConfiguration = () => {
|
|
222
|
+
return new import_opticore_logger.LoggerCore(loggerConfig);
|
|
223
|
+
};
|
|
224
|
+
|
|
218
225
|
// src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
|
|
219
226
|
var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
220
|
-
static log =
|
|
227
|
+
static log = SLoggerFileConfiguration();
|
|
221
228
|
/**
|
|
222
|
-
*
|
|
229
|
+
*
|
|
223
230
|
* @param rsaKey
|
|
224
231
|
* @param keyType
|
|
232
|
+
* @param localeLanguage
|
|
225
233
|
* @protected
|
|
226
|
-
*
|
|
234
|
+
*
|
|
227
235
|
* Return ErrorHandler | string
|
|
228
236
|
*/
|
|
229
|
-
static verifyExistingKey(rsaKey, keyType) {
|
|
237
|
+
static verifyExistingKey(rsaKey, keyType, localeLanguage) {
|
|
230
238
|
if (!rsaKey) {
|
|
231
239
|
const stackTrace = this.traceError(
|
|
232
|
-
keyType + " " + import_opticore_translator.TranslationLoader.t("rsaKeyNotFound",
|
|
233
|
-
import_opticore_translator.TranslationLoader.t("erBadDbError",
|
|
240
|
+
keyType + " " + import_opticore_translator.TranslationLoader.t("rsaKeyNotFound", localeLanguage, this.log),
|
|
241
|
+
import_opticore_translator.TranslationLoader.t("erBadDbError", localeLanguage, this.log),
|
|
234
242
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
235
243
|
);
|
|
236
244
|
this.log.error(
|
|
237
|
-
import_opticore_translator.TranslationLoader.t("rsaKeyNotFound",
|
|
238
|
-
import_opticore_translator.TranslationLoader.t("verifyExistingKey",
|
|
239
|
-
import_opticore_translator.TranslationLoader.t("erBadDbError",
|
|
245
|
+
import_opticore_translator.TranslationLoader.t("rsaKeyNotFound", localeLanguage, this.log),
|
|
246
|
+
import_opticore_translator.TranslationLoader.t("verifyExistingKey", localeLanguage, this.log),
|
|
247
|
+
import_opticore_translator.TranslationLoader.t("erBadDbError", localeLanguage, this.log),
|
|
240
248
|
stackTrace.stack,
|
|
241
249
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
242
250
|
);
|
|
@@ -248,25 +256,26 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
248
256
|
*
|
|
249
257
|
* @param privateKey
|
|
250
258
|
* @param payload
|
|
259
|
+
* @param localeLanguage
|
|
251
260
|
* @private
|
|
252
261
|
*
|
|
253
262
|
* Return Buffer
|
|
254
263
|
*/
|
|
255
|
-
static encryptionWithPrivateKey(privateKey, payload) {
|
|
256
|
-
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
|
|
264
|
+
static encryptionWithPrivateKey(privateKey, payload, localeLanguage) {
|
|
265
|
+
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private, localeLanguage);
|
|
257
266
|
try {
|
|
258
267
|
const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
|
|
259
268
|
return RSAKeyEncryption.privateEncrypt(privateKey, bufferedData);
|
|
260
269
|
} catch (err) {
|
|
261
270
|
const stackTrace = this.traceError(
|
|
262
|
-
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed",
|
|
263
|
-
import_opticore_translator.TranslationLoader.t("encryptionFailed",
|
|
271
|
+
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed", localeLanguage, this.log),
|
|
272
|
+
import_opticore_translator.TranslationLoader.t("encryptionFailed", localeLanguage, this.log),
|
|
264
273
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
265
274
|
);
|
|
266
275
|
this.log.error(
|
|
267
276
|
err.message,
|
|
268
|
-
import_opticore_translator.TranslationLoader.t("encryptionFailed",
|
|
269
|
-
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed",
|
|
277
|
+
import_opticore_translator.TranslationLoader.t("encryptionFailed", localeLanguage, this.log),
|
|
278
|
+
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed", localeLanguage, this.log),
|
|
270
279
|
stackTrace.stack,
|
|
271
280
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
272
281
|
);
|
|
@@ -278,24 +287,25 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
278
287
|
* @param privateKey
|
|
279
288
|
* @param publicKey
|
|
280
289
|
* @param payload
|
|
290
|
+
* @param localeLanguage
|
|
281
291
|
* @private
|
|
282
292
|
*/
|
|
283
|
-
static decryptionWithPublicKey(privateKey, publicKey, payload) {
|
|
284
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
293
|
+
static decryptionWithPublicKey(privateKey, publicKey, payload, localeLanguage) {
|
|
294
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public, localeLanguage);
|
|
285
295
|
try {
|
|
286
|
-
const encryptedPayload = this.encryptionWithPrivateKey(privateKey, payload);
|
|
296
|
+
const encryptedPayload = this.encryptionWithPrivateKey(privateKey, payload, localeLanguage);
|
|
287
297
|
return RSAKeyDecryption.publicDecrypt(publicKey, encryptedPayload);
|
|
288
298
|
} catch (error) {
|
|
289
299
|
const stackTrace = this.traceError(
|
|
290
|
-
import_opticore_translator.TranslationLoader.t("errorDecryption",
|
|
291
|
-
import_opticore_translator.TranslationLoader.t("decryptionFailed",
|
|
300
|
+
import_opticore_translator.TranslationLoader.t("errorDecryption", localeLanguage, this.log),
|
|
301
|
+
import_opticore_translator.TranslationLoader.t("decryptionFailed", localeLanguage, this.log),
|
|
292
302
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
293
303
|
);
|
|
294
304
|
this.log.error(
|
|
295
|
-
import_opticore_translator.TranslationLoader.t("decryptionWithPublicKeyFailed",
|
|
296
|
-
import_opticore_translator.TranslationLoader.t("decryptionFailed",
|
|
305
|
+
import_opticore_translator.TranslationLoader.t("decryptionWithPublicKeyFailed", localeLanguage, this.log),
|
|
306
|
+
import_opticore_translator.TranslationLoader.t("decryptionFailed", localeLanguage, this.log),
|
|
297
307
|
stackTrace.stack,
|
|
298
|
-
import_opticore_translator.TranslationLoader.t("errorDecryption",
|
|
308
|
+
import_opticore_translator.TranslationLoader.t("errorDecryption", localeLanguage, this.log),
|
|
299
309
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
300
310
|
);
|
|
301
311
|
throw new Error();
|
|
@@ -305,10 +315,11 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
305
315
|
*
|
|
306
316
|
* @param privateKey
|
|
307
317
|
* @param payload
|
|
318
|
+
* @param localeLanguage
|
|
308
319
|
* @private
|
|
309
320
|
*/
|
|
310
|
-
static signWithRSAKey(privateKey, payload) {
|
|
311
|
-
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
|
|
321
|
+
static signWithRSAKey(privateKey, payload, localeLanguage) {
|
|
322
|
+
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private, localeLanguage);
|
|
312
323
|
const sign = import_crypto3.default.createSign(CSignRSAKeyComponent.algorithm.sha256);
|
|
313
324
|
sign.update(payload);
|
|
314
325
|
return sign.sign(privateKey, CSignRSAKeyComponent.outputFormat.base64);
|
|
@@ -318,27 +329,28 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
318
329
|
* @param privateKey
|
|
319
330
|
* @param publicKey
|
|
320
331
|
* @param payload
|
|
332
|
+
* @param localeLanguage
|
|
321
333
|
*/
|
|
322
|
-
static verifyRSAKey(privateKey, publicKey, payload) {
|
|
334
|
+
static verifyRSAKey(privateKey, publicKey, payload, localeLanguage) {
|
|
323
335
|
try {
|
|
324
336
|
const verify = import_crypto3.default.createVerify(CSignRSAKeyComponent.algorithm.sha256);
|
|
325
337
|
verify.update(payload);
|
|
326
|
-
const signature = this.signWithRSAKey(privateKey, payload);
|
|
338
|
+
const signature = this.signWithRSAKey(privateKey, payload, localeLanguage);
|
|
327
339
|
const isVerified = verify.verify(publicKey, signature, CSignRSAKeyComponent.outputFormat.base64);
|
|
328
340
|
if (isVerified) {
|
|
329
|
-
const decryptedData = this.decryptionWithPublicKey(privateKey, publicKey, payload);
|
|
341
|
+
const decryptedData = this.decryptionWithPublicKey(privateKey, publicKey, payload, localeLanguage);
|
|
330
342
|
return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
|
|
331
343
|
} else {
|
|
332
344
|
const stackTrace = this.traceError(
|
|
333
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed",
|
|
334
|
-
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed",
|
|
345
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed", localeLanguage, this.log),
|
|
346
|
+
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed", localeLanguage, this.log),
|
|
335
347
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
336
348
|
);
|
|
337
349
|
this.log.error(
|
|
338
|
-
import_opticore_translator.TranslationLoader.t("verifyRSAKey",
|
|
339
|
-
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed",
|
|
350
|
+
import_opticore_translator.TranslationLoader.t("verifyRSAKey", localeLanguage, this.log),
|
|
351
|
+
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed", localeLanguage, this.log),
|
|
340
352
|
stackTrace.stack,
|
|
341
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed",
|
|
353
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed", localeLanguage, this.log),
|
|
342
354
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
343
355
|
);
|
|
344
356
|
return new Error();
|
|
@@ -346,12 +358,12 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
346
358
|
} catch (err) {
|
|
347
359
|
const stackTrace = this.traceError(
|
|
348
360
|
err.name,
|
|
349
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError",
|
|
361
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError", localeLanguage, this.log),
|
|
350
362
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
351
363
|
);
|
|
352
364
|
this.log.error(
|
|
353
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError",
|
|
354
|
-
import_opticore_translator.TranslationLoader.t("errorNameNotVerifyingRSAKey",
|
|
365
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError", localeLanguage, this.log),
|
|
366
|
+
import_opticore_translator.TranslationLoader.t("errorNameNotVerifyingRSAKey", localeLanguage, this.log),
|
|
355
367
|
stackTrace.stack,
|
|
356
368
|
err.message,
|
|
357
369
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
@@ -373,30 +385,30 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
373
385
|
|
|
374
386
|
// src/application/services/asymmetricCryptionDataWithPublicRSAKey.service.ts
|
|
375
387
|
var import_crypto4 = __toESM(require("crypto"), 1);
|
|
376
|
-
var import_opticore_logger2 = require("opticore-logger");
|
|
377
388
|
var import_opticore_translator2 = require("opticore-translator");
|
|
378
389
|
var import_opticore_http_response2 = require("opticore-http-response");
|
|
379
390
|
var import_opticore_catch_exception_error2 = require("opticore-catch-exception-error");
|
|
380
391
|
var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
381
|
-
static
|
|
392
|
+
static logger = SLoggerFileConfiguration();
|
|
382
393
|
/**
|
|
383
394
|
*
|
|
384
395
|
* @param rsaKey
|
|
385
396
|
* @param keyType
|
|
397
|
+
* @param localeLanguage
|
|
386
398
|
* @protected
|
|
387
399
|
*/
|
|
388
|
-
static verifyExistingKey(rsaKey, keyType) {
|
|
400
|
+
static verifyExistingKey(rsaKey, keyType, localeLanguage) {
|
|
389
401
|
if (!rsaKey) {
|
|
390
402
|
const stackTrace = this.traceError(
|
|
391
|
-
keyType + import_opticore_translator2.TranslationLoader.t("verifyExistingKey",
|
|
392
|
-
import_opticore_translator2.TranslationLoader.t("verifyExistingKey",
|
|
403
|
+
keyType + import_opticore_translator2.TranslationLoader.t("verifyExistingKey", localeLanguage, this.logger),
|
|
404
|
+
import_opticore_translator2.TranslationLoader.t("verifyExistingKey", localeLanguage, this.logger),
|
|
393
405
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
394
406
|
);
|
|
395
|
-
this.
|
|
396
|
-
import_opticore_translator2.TranslationLoader.t("verifyExistingKey",
|
|
407
|
+
this.logger.error(
|
|
408
|
+
import_opticore_translator2.TranslationLoader.t("verifyExistingKey", localeLanguage, this.logger),
|
|
397
409
|
"key verification",
|
|
398
410
|
stackTrace.stack,
|
|
399
|
-
import_opticore_translator2.TranslationLoader.t("verifyExistingKeyError",
|
|
411
|
+
import_opticore_translator2.TranslationLoader.t("verifyExistingKeyError", localeLanguage, this.logger),
|
|
400
412
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
401
413
|
);
|
|
402
414
|
return new Error();
|
|
@@ -407,22 +419,23 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
407
419
|
*
|
|
408
420
|
* @param publicKey
|
|
409
421
|
* @param payload
|
|
422
|
+
* @param localeLanguage
|
|
410
423
|
* @private
|
|
411
424
|
*/
|
|
412
|
-
static encryptionWithPublicKey(publicKey, payload) {
|
|
413
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
425
|
+
static encryptionWithPublicKey(publicKey, payload, localeLanguage) {
|
|
426
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public, localeLanguage);
|
|
414
427
|
try {
|
|
415
428
|
const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
|
|
416
429
|
return RSAKeyEncryption.publicEncrypt(publicKey, bufferedData);
|
|
417
430
|
} catch (err) {
|
|
418
431
|
const stackTrace = this.traceError(
|
|
419
432
|
err.message,
|
|
420
|
-
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey",
|
|
433
|
+
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey", localeLanguage, this.logger),
|
|
421
434
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
422
435
|
);
|
|
423
|
-
this.
|
|
424
|
-
import_opticore_translator2.TranslationLoader.t("errorEncryptionPublicKey",
|
|
425
|
-
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey",
|
|
436
|
+
this.logger.error(
|
|
437
|
+
import_opticore_translator2.TranslationLoader.t("errorEncryptionPublicKey", localeLanguage, this.logger),
|
|
438
|
+
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey", localeLanguage, this.logger),
|
|
426
439
|
stackTrace.stack,
|
|
427
440
|
err.message,
|
|
428
441
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -435,22 +448,23 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
435
448
|
* @param privateKey
|
|
436
449
|
* @param publicKey
|
|
437
450
|
* @param payload
|
|
451
|
+
* @param localeLanguage
|
|
438
452
|
* @private
|
|
439
453
|
*/
|
|
440
|
-
static decryptionWithPrivateKey(privateKey, publicKey, payload) {
|
|
441
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
454
|
+
static decryptionWithPrivateKey(privateKey, publicKey, payload, localeLanguage) {
|
|
455
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public, localeLanguage);
|
|
442
456
|
try {
|
|
443
|
-
const encryptedPayload = this.encryptionWithPublicKey(publicKey, payload);
|
|
457
|
+
const encryptedPayload = this.encryptionWithPublicKey(publicKey, payload, localeLanguage);
|
|
444
458
|
return RSAKeyDecryption.privateDecrypt(privateKey, encryptedPayload);
|
|
445
459
|
} catch (err) {
|
|
446
460
|
const stackTrace = this.traceError(
|
|
447
461
|
err.code,
|
|
448
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryption",
|
|
462
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryption", localeLanguage, this.logger),
|
|
449
463
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
450
464
|
);
|
|
451
|
-
this.
|
|
452
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryptionWithPrivateKey",
|
|
453
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryption",
|
|
465
|
+
this.logger.error(
|
|
466
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryptionWithPrivateKey", localeLanguage, this.logger),
|
|
467
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryption", localeLanguage, this.logger),
|
|
454
468
|
stackTrace.stack,
|
|
455
469
|
err.message,
|
|
456
470
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -462,10 +476,11 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
462
476
|
*
|
|
463
477
|
* @param publicKey
|
|
464
478
|
* @param payload
|
|
479
|
+
* @param localeLanguage
|
|
465
480
|
* @private
|
|
466
481
|
*/
|
|
467
|
-
static signWithPublicRSAKey(publicKey, payload) {
|
|
468
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.private);
|
|
482
|
+
static signWithPublicRSAKey(publicKey, payload, localeLanguage) {
|
|
483
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.private, localeLanguage);
|
|
469
484
|
const sign = import_crypto4.default.createSign(CSignRSAKeyComponent.algorithm.sha256);
|
|
470
485
|
sign.update(payload);
|
|
471
486
|
return sign.sign(publicKey, CSignRSAKeyComponent.outputFormat.base64);
|
|
@@ -475,27 +490,28 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
475
490
|
* @param privateKey
|
|
476
491
|
* @param publicKey
|
|
477
492
|
* @param payload
|
|
493
|
+
* @param localeLanguage
|
|
478
494
|
*/
|
|
479
|
-
static verifyPublicRSAKey(privateKey, publicKey, payload) {
|
|
495
|
+
static verifyPublicRSAKey(privateKey, publicKey, payload, localeLanguage) {
|
|
480
496
|
try {
|
|
481
497
|
const verify = import_crypto4.default.createVerify(CSignRSAKeyComponent.algorithm.sha256);
|
|
482
498
|
verify.update(payload);
|
|
483
|
-
const signature = this.signWithPublicRSAKey(publicKey, payload);
|
|
499
|
+
const signature = this.signWithPublicRSAKey(publicKey, payload, localeLanguage);
|
|
484
500
|
const isVerified = verify.verify(publicKey, signature, CSignRSAKeyComponent.outputFormat.base64);
|
|
485
501
|
if (isVerified) {
|
|
486
|
-
const decryptedData = this.decryptionWithPrivateKey(privateKey, publicKey, payload);
|
|
502
|
+
const decryptedData = this.decryptionWithPrivateKey(privateKey, publicKey, payload, localeLanguage);
|
|
487
503
|
return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
|
|
488
504
|
} else {
|
|
489
505
|
const stackTrace = this.traceError(
|
|
490
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError",
|
|
491
|
-
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed",
|
|
506
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError", localeLanguage, this.logger),
|
|
507
|
+
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed", localeLanguage, this.logger),
|
|
492
508
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
493
509
|
);
|
|
494
|
-
this.
|
|
495
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey",
|
|
496
|
-
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed",
|
|
510
|
+
this.logger.error(
|
|
511
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey", localeLanguage, this.logger),
|
|
512
|
+
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed", localeLanguage, this.logger),
|
|
497
513
|
stackTrace.stack,
|
|
498
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError",
|
|
514
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError", localeLanguage, this.logger),
|
|
499
515
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
500
516
|
);
|
|
501
517
|
return stackTrace;
|
|
@@ -503,12 +519,12 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
503
519
|
} catch (err) {
|
|
504
520
|
const stackTrace = this.traceError(
|
|
505
521
|
err.code,
|
|
506
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey",
|
|
522
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey", localeLanguage, this.logger),
|
|
507
523
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
508
524
|
);
|
|
509
|
-
this.
|
|
510
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey",
|
|
511
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryption",
|
|
525
|
+
this.logger.error(
|
|
526
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey", localeLanguage, this.logger),
|
|
527
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryption", localeLanguage, this.logger),
|
|
512
528
|
stackTrace.stack,
|
|
513
529
|
err.message,
|
|
514
530
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -534,44 +550,44 @@ async function SCheckerMongoDatabaseConnection(url, user, password, dbName) {
|
|
|
534
550
|
}
|
|
535
551
|
|
|
536
552
|
// src/core/handlers/errors/database/mySqlError.handler.database.ts
|
|
537
|
-
var
|
|
553
|
+
var import_opticore_logger2 = require("opticore-logger");
|
|
538
554
|
var import_opticore_http_response3 = require("opticore-http-response");
|
|
539
555
|
var import_opticore_translator3 = require("opticore-translator");
|
|
540
|
-
function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
541
|
-
const logger = new
|
|
556
|
+
function mySqlErrorHandlerDatabase(localLanguage, err, dbHost, database, user, password) {
|
|
557
|
+
const logger = new import_opticore_logger2.LoggerCore(loggerConfig);
|
|
542
558
|
switch (err.code) {
|
|
543
559
|
case "EAI_AGAIN":
|
|
544
560
|
logger.error(
|
|
545
|
-
import_opticore_translator3.TranslationLoader.t("errorDBHost",
|
|
546
|
-
import_opticore_translator3.TranslationLoader.t("mySQLError",
|
|
547
|
-
import_opticore_translator3.TranslationLoader.t("eAiAgain",
|
|
561
|
+
import_opticore_translator3.TranslationLoader.t("errorDBHost", localLanguage, { dbHost }),
|
|
562
|
+
import_opticore_translator3.TranslationLoader.t("mySQLError", localLanguage),
|
|
563
|
+
import_opticore_translator3.TranslationLoader.t("eAiAgain", localLanguage),
|
|
548
564
|
err.stack,
|
|
549
565
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
550
566
|
);
|
|
551
567
|
break;
|
|
552
568
|
case "ER_NOT_SUPPORTED_AUTH_MODE":
|
|
553
569
|
logger.error(
|
|
554
|
-
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthModeError",
|
|
555
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
556
|
-
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthMode",
|
|
570
|
+
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthModeError", localLanguage),
|
|
571
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
572
|
+
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthMode", localLanguage),
|
|
557
573
|
err.stack,
|
|
558
574
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
559
575
|
);
|
|
560
576
|
break;
|
|
561
577
|
case "ER_ACCESS_DENIED_ERROR":
|
|
562
578
|
logger.error(
|
|
563
|
-
import_opticore_translator3.TranslationLoader.t("accessDeniedToDBCon",
|
|
564
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
565
|
-
import_opticore_translator3.TranslationLoader.t("erAccessDeniedError",
|
|
579
|
+
import_opticore_translator3.TranslationLoader.t("accessDeniedToDBCon", localLanguage, { user, password }),
|
|
580
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
581
|
+
import_opticore_translator3.TranslationLoader.t("erAccessDeniedError", localLanguage),
|
|
566
582
|
err.stack,
|
|
567
583
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
568
584
|
);
|
|
569
585
|
break;
|
|
570
586
|
case "ER_BAD_DB_ERROR":
|
|
571
587
|
logger.error(
|
|
572
|
-
import_opticore_translator3.TranslationLoader.t("unknownDB",
|
|
573
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
574
|
-
import_opticore_translator3.TranslationLoader.t("erBadDbError",
|
|
588
|
+
import_opticore_translator3.TranslationLoader.t("unknownDB", localLanguage, { database }),
|
|
589
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
590
|
+
import_opticore_translator3.TranslationLoader.t("erBadDbError", localLanguage),
|
|
575
591
|
err.stack,
|
|
576
592
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
577
593
|
);
|
|
@@ -579,8 +595,8 @@ function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
|
579
595
|
default:
|
|
580
596
|
logger.error(
|
|
581
597
|
err.message,
|
|
582
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
583
|
-
import_opticore_translator3.TranslationLoader.t("mysqlErrorCon",
|
|
598
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
599
|
+
import_opticore_translator3.TranslationLoader.t("mysqlErrorCon", localLanguage),
|
|
584
600
|
err.stack,
|
|
585
601
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
586
602
|
);
|
|
@@ -589,25 +605,24 @@ function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
|
589
605
|
}
|
|
590
606
|
|
|
591
607
|
// src/application/services/checkerMySqlDatabaseConnection.service.ts
|
|
592
|
-
var import_opticore_logger4 = require("opticore-logger");
|
|
593
608
|
var import_opticore_translator4 = require("opticore-translator");
|
|
594
|
-
function SCheckerMySqlDatabaseConnection(dbConnection, user, database, dbHost, password) {
|
|
595
|
-
const
|
|
609
|
+
function SCheckerMySqlDatabaseConnection(localeLanguage, dbConnection, user, database, dbHost, password) {
|
|
610
|
+
const logger = SLoggerFileConfiguration();
|
|
596
611
|
dbConnection.connect((err) => {
|
|
597
612
|
if (err) {
|
|
598
|
-
return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
|
|
613
|
+
return mySqlErrorHandlerDatabase(localeLanguage, err, dbHost, database, user, password);
|
|
599
614
|
} else {
|
|
600
|
-
|
|
601
|
-
import_opticore_translator4.TranslationLoader.t("dbConnection",
|
|
602
|
-
import_opticore_translator4.TranslationLoader.t("dbConnexionSuccess",
|
|
615
|
+
logger.success(
|
|
616
|
+
import_opticore_translator4.TranslationLoader.t("dbConnection", localeLanguage, logger),
|
|
617
|
+
import_opticore_translator4.TranslationLoader.t("dbConnexionSuccess", localeLanguage, logger)
|
|
603
618
|
);
|
|
604
619
|
return dbConnection.end((endConErr) => {
|
|
605
620
|
if (endConErr) {
|
|
606
|
-
return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
|
|
621
|
+
return mySqlErrorHandlerDatabase(localeLanguage, err, dbHost, database, user, password);
|
|
607
622
|
} else {
|
|
608
|
-
|
|
609
|
-
import_opticore_translator4.TranslationLoader.t("dbConnection",
|
|
610
|
-
import_opticore_translator4.TranslationLoader.t("dbConnectionClosed",
|
|
623
|
+
logger.success(
|
|
624
|
+
import_opticore_translator4.TranslationLoader.t("dbConnection", localeLanguage, logger),
|
|
625
|
+
import_opticore_translator4.TranslationLoader.t("dbConnectionClosed", localeLanguage, logger)
|
|
611
626
|
);
|
|
612
627
|
console.log("");
|
|
613
628
|
}
|
|
@@ -618,11 +633,10 @@ function SCheckerMySqlDatabaseConnection(dbConnection, user, database, dbHost, p
|
|
|
618
633
|
|
|
619
634
|
// src/application/services/checkerPostgresDatabaseConnection.service.ts
|
|
620
635
|
var import_opticore_http_response4 = require("opticore-http-response");
|
|
621
|
-
var import_pg = require("pg");
|
|
622
|
-
var import_opticore_logger5 = require("opticore-logger");
|
|
636
|
+
var import_pg = __toESM(require("pg"), 1);
|
|
623
637
|
var import_opticore_translator5 = require("opticore-translator");
|
|
624
|
-
async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
625
|
-
const logger =
|
|
638
|
+
async function SCheckerPostgresDatabaseConnection(localeLanguage, connectionString, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
639
|
+
const logger = SLoggerFileConfiguration();
|
|
626
640
|
const configOptions = {
|
|
627
641
|
connectionString,
|
|
628
642
|
keepAlive,
|
|
@@ -637,20 +651,20 @@ async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, s
|
|
|
637
651
|
types,
|
|
638
652
|
options
|
|
639
653
|
};
|
|
640
|
-
const client = new import_pg.Client(configOptions);
|
|
654
|
+
const client = new import_pg.default.Client(configOptions);
|
|
641
655
|
await client.connect();
|
|
642
656
|
await client.end().then(
|
|
643
657
|
() => {
|
|
644
658
|
logger.success(
|
|
645
|
-
import_opticore_translator5.TranslationLoader.t("postgresSuccessConn",
|
|
646
|
-
import_opticore_translator5.TranslationLoader.t("postgresClosingConnSuccess",
|
|
659
|
+
import_opticore_translator5.TranslationLoader.t("postgresSuccessConn", localeLanguage, logger),
|
|
660
|
+
import_opticore_translator5.TranslationLoader.t("postgresClosingConnSuccess", localeLanguage, logger)
|
|
647
661
|
);
|
|
648
662
|
},
|
|
649
663
|
(onRejected) => {
|
|
650
664
|
logger.error(
|
|
651
|
-
import_opticore_translator5.TranslationLoader.t("postgresEndClientRejection",
|
|
652
|
-
import_opticore_translator5.TranslationLoader.t("postgresClientError",
|
|
653
|
-
import_opticore_translator5.TranslationLoader.t("postgresEndRejection",
|
|
665
|
+
import_opticore_translator5.TranslationLoader.t("postgresEndClientRejection", localeLanguage, logger),
|
|
666
|
+
import_opticore_translator5.TranslationLoader.t("postgresClientError", localeLanguage, logger),
|
|
667
|
+
import_opticore_translator5.TranslationLoader.t("postgresEndRejection", localeLanguage, logger),
|
|
654
668
|
onRejected,
|
|
655
669
|
import_opticore_http_response4.HttpStatusCode.BAD_REQUEST
|
|
656
670
|
);
|
|
@@ -658,8 +672,8 @@ async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, s
|
|
|
658
672
|
).catch((onError) => {
|
|
659
673
|
logger.error(
|
|
660
674
|
onError.message,
|
|
661
|
-
import_opticore_translator5.TranslationLoader.t("postgresConnError",
|
|
662
|
-
import_opticore_translator5.TranslationLoader.t("postgresException",
|
|
675
|
+
import_opticore_translator5.TranslationLoader.t("postgresConnError", localeLanguage, logger),
|
|
676
|
+
import_opticore_translator5.TranslationLoader.t("postgresException", localeLanguage, logger),
|
|
663
677
|
onError.stack,
|
|
664
678
|
import_opticore_http_response4.HttpStatusCode.BAD_REQUEST
|
|
665
679
|
);
|
|
@@ -681,51 +695,50 @@ var optionalArgumentConnectionUtil = import_opticore_env_access2.getEnvVariable.
|
|
|
681
695
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
682
696
|
var import_promises = require("fs/promises");
|
|
683
697
|
var import_opticore_http_response5 = require("opticore-http-response");
|
|
684
|
-
var
|
|
698
|
+
var import_opticore_logger3 = require("opticore-logger");
|
|
685
699
|
var import_opticore_translator7 = require("opticore-translator");
|
|
686
700
|
|
|
687
701
|
// src/core/config/loaders/translateLanguage.loader.ts
|
|
688
702
|
var import_path = __toESM(require("path"), 1);
|
|
689
703
|
var import_module = require("module");
|
|
690
704
|
var import_opticore_translator6 = require("opticore-translator");
|
|
691
|
-
var translateWebAppCoreLanguageLoader = (
|
|
705
|
+
var translateWebAppCoreLanguageLoader = () => {
|
|
692
706
|
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
693
707
|
const packagePath = import_path.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
694
708
|
const translateMsgJsonFilePath = import_path.default.join(packagePath, "utils", "translations");
|
|
695
|
-
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath
|
|
709
|
+
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
696
710
|
};
|
|
697
711
|
|
|
698
712
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
699
713
|
var YamlParsing = class {
|
|
700
|
-
static logger = new
|
|
701
|
-
static
|
|
714
|
+
static logger = new import_opticore_logger3.LoggerCore(loggerConfig);
|
|
715
|
+
static localeLanguage;
|
|
716
|
+
static __init(localeLanguage) {
|
|
717
|
+
translateWebAppCoreLanguageLoader();
|
|
718
|
+
this.localeLanguage = localeLanguage;
|
|
719
|
+
return this;
|
|
720
|
+
}
|
|
721
|
+
static async readFile(filePath, localeLanguage) {
|
|
702
722
|
try {
|
|
703
723
|
const yamlContent = await (0, import_promises.readFile)(filePath, "utf-8");
|
|
704
|
-
await this.parsing(yamlContent);
|
|
724
|
+
await this.parsing(yamlContent, localeLanguage);
|
|
705
725
|
} catch (error) {
|
|
706
726
|
this.logger.error(
|
|
707
727
|
error.message,
|
|
708
|
-
import_opticore_translator7.TranslationLoader.t("parsingFailed",
|
|
709
|
-
import_opticore_translator7.TranslationLoader.t("readingError",
|
|
728
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", localeLanguage, this.logger),
|
|
729
|
+
import_opticore_translator7.TranslationLoader.t("readingError", localeLanguage, this.logger),
|
|
710
730
|
error.stack,
|
|
711
731
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
712
732
|
);
|
|
713
733
|
}
|
|
714
734
|
}
|
|
715
|
-
/**
|
|
716
|
-
*
|
|
717
|
-
* @param defaultLocalLang
|
|
718
|
-
*/
|
|
719
|
-
static __init(defaultLocalLang) {
|
|
720
|
-
translateWebAppCoreLanguageLoader(defaultLocalLang);
|
|
721
|
-
return this;
|
|
722
|
-
}
|
|
723
735
|
/**
|
|
724
736
|
*
|
|
725
737
|
* @param content
|
|
738
|
+
* @param localeLanguage
|
|
726
739
|
* @private
|
|
727
740
|
*/
|
|
728
|
-
static async parsing(content) {
|
|
741
|
+
static async parsing(content, localeLanguage) {
|
|
729
742
|
const result = {};
|
|
730
743
|
const lines = content.split("\n");
|
|
731
744
|
let currentKey = null;
|
|
@@ -745,9 +758,9 @@ var YamlParsing = class {
|
|
|
745
758
|
}
|
|
746
759
|
} else {
|
|
747
760
|
this.logger.error(
|
|
748
|
-
import_opticore_translator7.TranslationLoader.t("badFormat",
|
|
749
|
-
import_opticore_translator7.TranslationLoader.t("parsingFailed",
|
|
750
|
-
import_opticore_translator7.TranslationLoader.t("unsupportedFormat",
|
|
761
|
+
import_opticore_translator7.TranslationLoader.t("badFormat", localeLanguage, { line }),
|
|
762
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", localeLanguage, this.logger),
|
|
763
|
+
import_opticore_translator7.TranslationLoader.t("unsupportedFormat", localeLanguage, this.logger),
|
|
751
764
|
content,
|
|
752
765
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
753
766
|
);
|
|
@@ -775,86 +788,90 @@ var Environment = class {
|
|
|
775
788
|
var import_mysql = __toESM(require("mysql"), 1);
|
|
776
789
|
var import_opticore_http_response7 = require("opticore-http-response");
|
|
777
790
|
var import_opticore_env_access3 = require("opticore-env-access");
|
|
778
|
-
var
|
|
791
|
+
var import_opticore_logger5 = require("opticore-logger");
|
|
779
792
|
var import_opticore_translator9 = require("opticore-translator");
|
|
780
793
|
|
|
781
794
|
// src/core/errors/databaseConnexion.error.ts
|
|
782
795
|
var import_opticore_http_response6 = require("opticore-http-response");
|
|
783
|
-
var
|
|
796
|
+
var import_opticore_logger4 = require("opticore-logger");
|
|
784
797
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
785
798
|
var import_opticore_translator8 = require("opticore-translator");
|
|
786
799
|
var DbConnexionConfigError = class {
|
|
787
|
-
static logger = new
|
|
800
|
+
static logger = new import_opticore_logger4.LoggerCore(loggerConfig);
|
|
788
801
|
/**
|
|
789
802
|
*
|
|
803
|
+
* @param localLanguage
|
|
790
804
|
* @param e
|
|
791
805
|
*/
|
|
792
|
-
static mongoDBAuthenticationFailed(e) {
|
|
806
|
+
static mongoDBAuthenticationFailed(localLanguage, e) {
|
|
793
807
|
const stackTrace = this.traceError(
|
|
794
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
795
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBAuthentication",
|
|
808
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { e }),
|
|
809
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthentication", localLanguage),
|
|
796
810
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
797
811
|
);
|
|
798
812
|
this.logger.error(
|
|
799
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationError",
|
|
800
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
801
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationFailed",
|
|
813
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationError", localLanguage),
|
|
814
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
815
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationFailed", localLanguage),
|
|
802
816
|
stackTrace.stack,
|
|
803
817
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
804
818
|
);
|
|
805
819
|
}
|
|
806
820
|
/**
|
|
807
821
|
*
|
|
822
|
+
* @param localLanguage
|
|
808
823
|
* @param err
|
|
809
824
|
* @param dbHost
|
|
810
825
|
* @param dbPort
|
|
811
826
|
*/
|
|
812
|
-
static mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
827
|
+
static mongoDBInvalidUrl(localLanguage, err, dbHost, dbPort) {
|
|
813
828
|
const stackTrace = this.traceError(
|
|
814
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
815
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl",
|
|
829
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { err }),
|
|
830
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", localLanguage),
|
|
816
831
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
817
832
|
);
|
|
818
833
|
this.logger.error(
|
|
819
|
-
import_opticore_translator8.TranslationLoader.t("dbUrlParsingError",
|
|
820
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
821
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl",
|
|
834
|
+
import_opticore_translator8.TranslationLoader.t("dbUrlParsingError", localLanguage, { dbHost, dbPort }),
|
|
835
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
836
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", localLanguage),
|
|
822
837
|
stackTrace.stack,
|
|
823
838
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
824
839
|
);
|
|
825
840
|
}
|
|
826
841
|
/**
|
|
827
842
|
*
|
|
843
|
+
* @param localLanguage
|
|
828
844
|
* @param err
|
|
829
845
|
* @param dbHost
|
|
830
846
|
*/
|
|
831
|
-
static mongoDBEaiAgain(err, dbHost) {
|
|
847
|
+
static mongoDBEaiAgain(localLanguage, err, dbHost) {
|
|
832
848
|
const stackTrace = this.traceError(
|
|
833
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
834
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection",
|
|
849
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { err }),
|
|
850
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", localLanguage),
|
|
835
851
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
836
852
|
);
|
|
837
853
|
this.logger.error(
|
|
838
|
-
import_opticore_translator8.TranslationLoader.t("mongoServerError",
|
|
839
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
840
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection",
|
|
854
|
+
import_opticore_translator8.TranslationLoader.t("mongoServerError", localLanguage, { dbHost }),
|
|
855
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
856
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", localLanguage),
|
|
841
857
|
stackTrace.stack,
|
|
842
858
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
843
859
|
);
|
|
844
860
|
}
|
|
845
861
|
/**
|
|
846
862
|
*
|
|
863
|
+
* @param localLanguage
|
|
847
864
|
* @param err
|
|
848
865
|
*/
|
|
849
|
-
static mongoDbGlobalError(err) {
|
|
866
|
+
static mongoDbGlobalError(localLanguage, err) {
|
|
850
867
|
const stackTrace = this.traceError(
|
|
851
|
-
|
|
852
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
868
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { err }),
|
|
869
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
853
870
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
854
871
|
);
|
|
855
872
|
this.logger.error(
|
|
856
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
857
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionError",
|
|
873
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
874
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionError", localLanguage),
|
|
858
875
|
stackTrace.stack,
|
|
859
876
|
err.message,
|
|
860
877
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -876,34 +893,39 @@ var DbConnexionConfigError = class {
|
|
|
876
893
|
var import_opticore_catch_exception_error4 = require("opticore-catch-exception-error");
|
|
877
894
|
var DatabaseConnectionConfig = class {
|
|
878
895
|
env = new Environment(import_opticore_env_access3.getEnvVariable);
|
|
879
|
-
logger = new
|
|
896
|
+
logger = new import_opticore_logger5.LoggerCore(loggerConfig);
|
|
880
897
|
/**
|
|
898
|
+
*
|
|
899
|
+
* @param optionalArgumentConnection
|
|
900
|
+
* @param localeLanguage
|
|
901
|
+
*
|
|
881
902
|
* MySQL database connection with an optional arguments
|
|
882
903
|
* Establish the connection between app and Database Management System.
|
|
883
904
|
* Inside this class, a checker verifies if database credentials are right,
|
|
884
905
|
* and it's show off in the log that the connection has been created successfully.
|
|
885
906
|
* But if any error is occurring during trying connection, it'd specify that error by stack traces.
|
|
886
907
|
*/
|
|
887
|
-
databaseMySQLConnexionChecker(optionalArgumentConnection) {
|
|
908
|
+
databaseMySQLConnexionChecker(optionalArgumentConnection, localeLanguage) {
|
|
888
909
|
const dbURL = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
889
910
|
let url = `mysql://${dbURL}?${optionalArgumentConnection}`;
|
|
890
911
|
const dbConnection = import_mysql.default.createConnection(url);
|
|
891
|
-
return SCheckerMySqlDatabaseConnection(dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
|
|
912
|
+
return SCheckerMySqlDatabaseConnection(localeLanguage, dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
|
|
892
913
|
}
|
|
893
914
|
/**
|
|
894
915
|
*
|
|
895
916
|
* @param optionalArgumentConnection
|
|
917
|
+
* @param localeLanguage
|
|
896
918
|
*
|
|
897
919
|
* Mongo database connection with optional connection arguments
|
|
898
920
|
*/
|
|
899
|
-
async databaseMongoDBConnectionChecker(optionalArgumentConnection) {
|
|
921
|
+
async databaseMongoDBConnectionChecker(optionalArgumentConnection, localeLanguage) {
|
|
900
922
|
const dbUrl = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
901
923
|
const url = `mongodb://${dbUrl}${optionalArgumentConnection}`;
|
|
902
924
|
try {
|
|
903
925
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
904
926
|
this.logger.success(
|
|
905
|
-
import_opticore_translator9.TranslationLoader.t("mongoDBConnectionChecker",
|
|
906
|
-
import_opticore_translator9.TranslationLoader.t("mongoConnectionSuccess",
|
|
927
|
+
import_opticore_translator9.TranslationLoader.t("mongoDBConnectionChecker", localeLanguage, loggerConfig),
|
|
928
|
+
import_opticore_translator9.TranslationLoader.t("mongoConnectionSuccess", localeLanguage, loggerConfig)
|
|
907
929
|
);
|
|
908
930
|
console.log("");
|
|
909
931
|
} catch (e) {
|
|
@@ -922,6 +944,7 @@ var DatabaseConnectionConfig = class {
|
|
|
922
944
|
}
|
|
923
945
|
/**
|
|
924
946
|
*
|
|
947
|
+
* @param localeLanguage
|
|
925
948
|
* @param keepAlive
|
|
926
949
|
* @param stream
|
|
927
950
|
* @param statement_timeout
|
|
@@ -936,10 +959,11 @@ var DatabaseConnectionConfig = class {
|
|
|
936
959
|
*
|
|
937
960
|
* Postgres database connection with optional connection arguments
|
|
938
961
|
*/
|
|
939
|
-
async databasePostgresDBConnectionChecker(keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
962
|
+
async databasePostgresDBConnectionChecker(localeLanguage, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
940
963
|
const url = `postgresql:/${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
941
964
|
try {
|
|
942
965
|
await SCheckerPostgresDatabaseConnection(
|
|
966
|
+
localeLanguage,
|
|
943
967
|
url,
|
|
944
968
|
keepAlive,
|
|
945
969
|
stream,
|
|
@@ -953,11 +977,14 @@ var DatabaseConnectionConfig = class {
|
|
|
953
977
|
types,
|
|
954
978
|
options
|
|
955
979
|
);
|
|
956
|
-
this.logger.success(
|
|
980
|
+
this.logger.success(
|
|
981
|
+
import_opticore_translator9.TranslationLoader.t("postgresDBConnectionChecker", localeLanguage, loggerConfig),
|
|
982
|
+
import_opticore_translator9.TranslationLoader.t("postgresConnectionSuccess", localeLanguage, loggerConfig)
|
|
983
|
+
);
|
|
957
984
|
console.log("");
|
|
958
985
|
} catch (err) {
|
|
959
986
|
const stackTrace = this.traceError(
|
|
960
|
-
import_opticore_translator9.TranslationLoader.t(`${err.message}`,
|
|
987
|
+
import_opticore_translator9.TranslationLoader.t(`${err.message}`, localeLanguage, loggerConfig),
|
|
961
988
|
"PostgresConnectionError",
|
|
962
989
|
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
963
990
|
);
|
|
@@ -976,21 +1003,34 @@ var DatabaseConnectionConfig = class {
|
|
|
976
1003
|
};
|
|
977
1004
|
|
|
978
1005
|
// src/core/config/database/middleware/mongoChecker.database.ts
|
|
979
|
-
var MMongoCheckerDatabase = (optionalArgumentConnection) => {
|
|
1006
|
+
var MMongoCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
980
1007
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
981
|
-
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection);
|
|
1008
|
+
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection, localLanguage);
|
|
982
1009
|
};
|
|
983
1010
|
|
|
984
1011
|
// src/core/config/database/middleware/mySqlChecker.database.ts
|
|
985
|
-
var MMySqlCheckerDatabase = (optionalArgumentConnection) => {
|
|
1012
|
+
var MMySqlCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
986
1013
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
987
|
-
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection);
|
|
1014
|
+
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection, localLanguage);
|
|
988
1015
|
};
|
|
989
1016
|
|
|
990
1017
|
// src/core/config/database/middleware/postgresChecker.database.ts
|
|
991
|
-
var MPostgresCheckerDatabase = (
|
|
1018
|
+
var MPostgresCheckerDatabase = (localLanguage, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) => {
|
|
992
1019
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
993
|
-
return DbConnexion.databasePostgresDBConnectionChecker(
|
|
1020
|
+
return DbConnexion.databasePostgresDBConnectionChecker(
|
|
1021
|
+
localLanguage,
|
|
1022
|
+
keepAlive,
|
|
1023
|
+
stream,
|
|
1024
|
+
statement_timeout,
|
|
1025
|
+
ssl,
|
|
1026
|
+
query_timeout,
|
|
1027
|
+
keepAliveInitialDelayMillis,
|
|
1028
|
+
idle_in_transaction_session_timeout,
|
|
1029
|
+
application_name,
|
|
1030
|
+
connectionTimeoutMillis,
|
|
1031
|
+
types,
|
|
1032
|
+
options
|
|
1033
|
+
);
|
|
994
1034
|
};
|
|
995
1035
|
|
|
996
1036
|
// src/utils/utility.utils.ts
|
|
@@ -1001,6 +1041,10 @@ var import_path2 = __toESM(require("path"), 1);
|
|
|
1001
1041
|
var import_fs = __toESM(require("fs"), 1);
|
|
1002
1042
|
var import_opticore_translator10 = require("opticore-translator");
|
|
1003
1043
|
var Utility = class {
|
|
1044
|
+
localLang;
|
|
1045
|
+
constructor(localLanguage) {
|
|
1046
|
+
this.localLang = localLanguage;
|
|
1047
|
+
}
|
|
1004
1048
|
/**
|
|
1005
1049
|
*
|
|
1006
1050
|
* @param data
|
|
@@ -1092,19 +1136,19 @@ var Utility = class {
|
|
|
1092
1136
|
this.getEnvFileLoading(".env");
|
|
1093
1137
|
const isDevelopment = import_node_process.default.env.NODE_ENV === "development";
|
|
1094
1138
|
if (isDevelopment) {
|
|
1095
|
-
return `${import_opticore_translator10.TranslationLoader.t("serverRunning",
|
|
1139
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${development}`)}`)} mode`;
|
|
1096
1140
|
} else {
|
|
1097
|
-
return `${import_opticore_translator10.TranslationLoader.t("serverRunning",
|
|
1141
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${production}`)}`)} mode`;
|
|
1098
1142
|
}
|
|
1099
1143
|
}
|
|
1100
1144
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1101
1145
|
const paddingLength = 52;
|
|
1102
1146
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1103
|
-
const msg1 = ` ${import_opticore_translator10.TranslationLoader.t("okServerListening",
|
|
1147
|
+
const msg1 = ` ${import_opticore_translator10.TranslationLoader.t("okServerListening", this.localLang)}`;
|
|
1104
1148
|
const msg2Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${nodeVersion}`)}`)}`;
|
|
1105
|
-
const msg2 = ` ${import_opticore_translator10.TranslationLoader.t("webServerUseNodeVersion",
|
|
1149
|
+
const msg2 = ` ${import_opticore_translator10.TranslationLoader.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1106
1150
|
const msg3Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${startingTime}`)}`)}`;
|
|
1107
|
-
const msg3 = ` ${import_opticore_translator10.TranslationLoader.t("startupTime",
|
|
1151
|
+
const msg3 = ` ${import_opticore_translator10.TranslationLoader.t("startupTime", this.localLang)}`;
|
|
1108
1152
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1109
1153
|
const msg5 = ` ${import_ansi_colors.default.underline(`http://${host}:${port}`)}`;
|
|
1110
1154
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1115,27 +1159,28 @@ var Utility = class {
|
|
|
1115
1159
|
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1116
1160
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1117
1161
|
console.log(``);
|
|
1118
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("totalMemory",
|
|
1119
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedDuringExecution",
|
|
1120
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedByUser",
|
|
1121
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedBySystem",
|
|
1162
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("totalMemory", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${rss}`)}`)}`);
|
|
1163
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedDuringExecution", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${heapUsed}`)}`)}`);
|
|
1164
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedByUser", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${user}`)}`)}`);
|
|
1165
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedBySystem", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${system}`)}`)}`);
|
|
1122
1166
|
console.log(``);
|
|
1123
1167
|
}
|
|
1124
1168
|
};
|
|
1125
1169
|
|
|
1126
1170
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1127
1171
|
var import_path3 = require("path");
|
|
1128
|
-
var
|
|
1172
|
+
var import_opticore_logger6 = require("opticore-logger");
|
|
1129
1173
|
var import_opticore_http_response8 = require("opticore-http-response");
|
|
1130
1174
|
var import_opticore_translator11 = require("opticore-translator");
|
|
1131
1175
|
var PathModuleVerifier = class {
|
|
1132
|
-
static log = new
|
|
1176
|
+
static log = new import_opticore_logger6.LoggerCore(loggerConfig);
|
|
1133
1177
|
/**
|
|
1134
1178
|
* Verifies if modules at specific paths are loaded.
|
|
1135
1179
|
* If any module is not loaded, it throws an error.
|
|
1180
|
+
* @param localLanguage
|
|
1136
1181
|
* @param modulePaths - An array of paths to the modules to verify.
|
|
1137
1182
|
*/
|
|
1138
|
-
static verifyModulePaths(modulePaths) {
|
|
1183
|
+
static verifyModulePaths(localLanguage, modulePaths) {
|
|
1139
1184
|
const notLoadedPaths = [];
|
|
1140
1185
|
for (const modulePath of modulePaths) {
|
|
1141
1186
|
if (!this.isModulePathLoaded(modulePath)) {
|
|
@@ -1144,7 +1189,7 @@ var PathModuleVerifier = class {
|
|
|
1144
1189
|
}
|
|
1145
1190
|
if (notLoadedPaths.length > 0) {
|
|
1146
1191
|
this.log.error(
|
|
1147
|
-
import_opticore_translator11.TranslationLoader.t("moduleNotLoaded",
|
|
1192
|
+
import_opticore_translator11.TranslationLoader.t("moduleNotLoaded", localLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1148
1193
|
"",
|
|
1149
1194
|
"",
|
|
1150
1195
|
modulePaths,
|