opticore-webapp-core 1.0.6 → 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 +252 -203
- package/dist/index.d.cts +38 -17
- package/dist/index.d.ts +38 -17
- package/dist/index.js +256 -207
- 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,19 +695,38 @@ 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");
|
|
699
|
+
var import_opticore_translator7 = require("opticore-translator");
|
|
700
|
+
|
|
701
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
702
|
+
var import_path = __toESM(require("path"), 1);
|
|
703
|
+
var import_module = require("module");
|
|
685
704
|
var import_opticore_translator6 = require("opticore-translator");
|
|
705
|
+
var translateWebAppCoreLanguageLoader = () => {
|
|
706
|
+
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
707
|
+
const packagePath = import_path.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
708
|
+
const translateMsgJsonFilePath = import_path.default.join(packagePath, "utils", "translations");
|
|
709
|
+
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
// src/utils/parsing/parsingYaml.utils.ts
|
|
686
713
|
var YamlParsing = class {
|
|
687
|
-
static logger = new
|
|
688
|
-
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) {
|
|
689
722
|
try {
|
|
690
723
|
const yamlContent = await (0, import_promises.readFile)(filePath, "utf-8");
|
|
691
|
-
await this.parsing(yamlContent);
|
|
724
|
+
await this.parsing(yamlContent, localeLanguage);
|
|
692
725
|
} catch (error) {
|
|
693
726
|
this.logger.error(
|
|
694
727
|
error.message,
|
|
695
|
-
|
|
696
|
-
|
|
728
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", localeLanguage, this.logger),
|
|
729
|
+
import_opticore_translator7.TranslationLoader.t("readingError", localeLanguage, this.logger),
|
|
697
730
|
error.stack,
|
|
698
731
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
699
732
|
);
|
|
@@ -702,9 +735,10 @@ var YamlParsing = class {
|
|
|
702
735
|
/**
|
|
703
736
|
*
|
|
704
737
|
* @param content
|
|
738
|
+
* @param localeLanguage
|
|
705
739
|
* @private
|
|
706
740
|
*/
|
|
707
|
-
static async parsing(content) {
|
|
741
|
+
static async parsing(content, localeLanguage) {
|
|
708
742
|
const result = {};
|
|
709
743
|
const lines = content.split("\n");
|
|
710
744
|
let currentKey = null;
|
|
@@ -724,9 +758,9 @@ var YamlParsing = class {
|
|
|
724
758
|
}
|
|
725
759
|
} else {
|
|
726
760
|
this.logger.error(
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
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),
|
|
730
764
|
content,
|
|
731
765
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
732
766
|
);
|
|
@@ -754,86 +788,90 @@ var Environment = class {
|
|
|
754
788
|
var import_mysql = __toESM(require("mysql"), 1);
|
|
755
789
|
var import_opticore_http_response7 = require("opticore-http-response");
|
|
756
790
|
var import_opticore_env_access3 = require("opticore-env-access");
|
|
757
|
-
var
|
|
758
|
-
var
|
|
791
|
+
var import_opticore_logger5 = require("opticore-logger");
|
|
792
|
+
var import_opticore_translator9 = require("opticore-translator");
|
|
759
793
|
|
|
760
794
|
// src/core/errors/databaseConnexion.error.ts
|
|
761
795
|
var import_opticore_http_response6 = require("opticore-http-response");
|
|
762
|
-
var
|
|
796
|
+
var import_opticore_logger4 = require("opticore-logger");
|
|
763
797
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
764
|
-
var
|
|
798
|
+
var import_opticore_translator8 = require("opticore-translator");
|
|
765
799
|
var DbConnexionConfigError = class {
|
|
766
|
-
static logger = new
|
|
800
|
+
static logger = new import_opticore_logger4.LoggerCore(loggerConfig);
|
|
767
801
|
/**
|
|
768
802
|
*
|
|
803
|
+
* @param localLanguage
|
|
769
804
|
* @param e
|
|
770
805
|
*/
|
|
771
|
-
static mongoDBAuthenticationFailed(e) {
|
|
806
|
+
static mongoDBAuthenticationFailed(localLanguage, e) {
|
|
772
807
|
const stackTrace = this.traceError(
|
|
773
|
-
|
|
774
|
-
|
|
808
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { e }),
|
|
809
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthentication", localLanguage),
|
|
775
810
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
776
811
|
);
|
|
777
812
|
this.logger.error(
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
813
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationError", localLanguage),
|
|
814
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
815
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationFailed", localLanguage),
|
|
781
816
|
stackTrace.stack,
|
|
782
817
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
783
818
|
);
|
|
784
819
|
}
|
|
785
820
|
/**
|
|
786
821
|
*
|
|
822
|
+
* @param localLanguage
|
|
787
823
|
* @param err
|
|
788
824
|
* @param dbHost
|
|
789
825
|
* @param dbPort
|
|
790
826
|
*/
|
|
791
|
-
static mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
827
|
+
static mongoDBInvalidUrl(localLanguage, err, dbHost, dbPort) {
|
|
792
828
|
const stackTrace = this.traceError(
|
|
793
|
-
|
|
794
|
-
|
|
829
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { err }),
|
|
830
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", localLanguage),
|
|
795
831
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
796
832
|
);
|
|
797
833
|
this.logger.error(
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
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),
|
|
801
837
|
stackTrace.stack,
|
|
802
838
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
803
839
|
);
|
|
804
840
|
}
|
|
805
841
|
/**
|
|
806
842
|
*
|
|
843
|
+
* @param localLanguage
|
|
807
844
|
* @param err
|
|
808
845
|
* @param dbHost
|
|
809
846
|
*/
|
|
810
|
-
static mongoDBEaiAgain(err, dbHost) {
|
|
847
|
+
static mongoDBEaiAgain(localLanguage, err, dbHost) {
|
|
811
848
|
const stackTrace = this.traceError(
|
|
812
|
-
|
|
813
|
-
|
|
849
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { err }),
|
|
850
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", localLanguage),
|
|
814
851
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
815
852
|
);
|
|
816
853
|
this.logger.error(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
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),
|
|
820
857
|
stackTrace.stack,
|
|
821
858
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
822
859
|
);
|
|
823
860
|
}
|
|
824
861
|
/**
|
|
825
862
|
*
|
|
863
|
+
* @param localLanguage
|
|
826
864
|
* @param err
|
|
827
865
|
*/
|
|
828
|
-
static mongoDbGlobalError(err) {
|
|
866
|
+
static mongoDbGlobalError(localLanguage, err) {
|
|
829
867
|
const stackTrace = this.traceError(
|
|
830
|
-
|
|
831
|
-
|
|
868
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage, { err }),
|
|
869
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
832
870
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
833
871
|
);
|
|
834
872
|
this.logger.error(
|
|
835
|
-
|
|
836
|
-
|
|
873
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", localLanguage),
|
|
874
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionError", localLanguage),
|
|
837
875
|
stackTrace.stack,
|
|
838
876
|
err.message,
|
|
839
877
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -855,34 +893,39 @@ var DbConnexionConfigError = class {
|
|
|
855
893
|
var import_opticore_catch_exception_error4 = require("opticore-catch-exception-error");
|
|
856
894
|
var DatabaseConnectionConfig = class {
|
|
857
895
|
env = new Environment(import_opticore_env_access3.getEnvVariable);
|
|
858
|
-
logger = new
|
|
896
|
+
logger = new import_opticore_logger5.LoggerCore(loggerConfig);
|
|
859
897
|
/**
|
|
898
|
+
*
|
|
899
|
+
* @param optionalArgumentConnection
|
|
900
|
+
* @param localeLanguage
|
|
901
|
+
*
|
|
860
902
|
* MySQL database connection with an optional arguments
|
|
861
903
|
* Establish the connection between app and Database Management System.
|
|
862
904
|
* Inside this class, a checker verifies if database credentials are right,
|
|
863
905
|
* and it's show off in the log that the connection has been created successfully.
|
|
864
906
|
* But if any error is occurring during trying connection, it'd specify that error by stack traces.
|
|
865
907
|
*/
|
|
866
|
-
databaseMySQLConnexionChecker(optionalArgumentConnection) {
|
|
908
|
+
databaseMySQLConnexionChecker(optionalArgumentConnection, localeLanguage) {
|
|
867
909
|
const dbURL = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
868
910
|
let url = `mysql://${dbURL}?${optionalArgumentConnection}`;
|
|
869
911
|
const dbConnection = import_mysql.default.createConnection(url);
|
|
870
|
-
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"));
|
|
871
913
|
}
|
|
872
914
|
/**
|
|
873
915
|
*
|
|
874
916
|
* @param optionalArgumentConnection
|
|
917
|
+
* @param localeLanguage
|
|
875
918
|
*
|
|
876
919
|
* Mongo database connection with optional connection arguments
|
|
877
920
|
*/
|
|
878
|
-
async databaseMongoDBConnectionChecker(optionalArgumentConnection) {
|
|
921
|
+
async databaseMongoDBConnectionChecker(optionalArgumentConnection, localeLanguage) {
|
|
879
922
|
const dbUrl = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
880
923
|
const url = `mongodb://${dbUrl}${optionalArgumentConnection}`;
|
|
881
924
|
try {
|
|
882
925
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
883
926
|
this.logger.success(
|
|
884
|
-
|
|
885
|
-
|
|
927
|
+
import_opticore_translator9.TranslationLoader.t("mongoDBConnectionChecker", localeLanguage, loggerConfig),
|
|
928
|
+
import_opticore_translator9.TranslationLoader.t("mongoConnectionSuccess", localeLanguage, loggerConfig)
|
|
886
929
|
);
|
|
887
930
|
console.log("");
|
|
888
931
|
} catch (e) {
|
|
@@ -901,6 +944,7 @@ var DatabaseConnectionConfig = class {
|
|
|
901
944
|
}
|
|
902
945
|
/**
|
|
903
946
|
*
|
|
947
|
+
* @param localeLanguage
|
|
904
948
|
* @param keepAlive
|
|
905
949
|
* @param stream
|
|
906
950
|
* @param statement_timeout
|
|
@@ -915,10 +959,11 @@ var DatabaseConnectionConfig = class {
|
|
|
915
959
|
*
|
|
916
960
|
* Postgres database connection with optional connection arguments
|
|
917
961
|
*/
|
|
918
|
-
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) {
|
|
919
963
|
const url = `postgresql:/${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
920
964
|
try {
|
|
921
965
|
await SCheckerPostgresDatabaseConnection(
|
|
966
|
+
localeLanguage,
|
|
922
967
|
url,
|
|
923
968
|
keepAlive,
|
|
924
969
|
stream,
|
|
@@ -932,11 +977,14 @@ var DatabaseConnectionConfig = class {
|
|
|
932
977
|
types,
|
|
933
978
|
options
|
|
934
979
|
);
|
|
935
|
-
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
|
+
);
|
|
936
984
|
console.log("");
|
|
937
985
|
} catch (err) {
|
|
938
986
|
const stackTrace = this.traceError(
|
|
939
|
-
|
|
987
|
+
import_opticore_translator9.TranslationLoader.t(`${err.message}`, localeLanguage, loggerConfig),
|
|
940
988
|
"PostgresConnectionError",
|
|
941
989
|
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
942
990
|
);
|
|
@@ -955,31 +1003,48 @@ var DatabaseConnectionConfig = class {
|
|
|
955
1003
|
};
|
|
956
1004
|
|
|
957
1005
|
// src/core/config/database/middleware/mongoChecker.database.ts
|
|
958
|
-
var MMongoCheckerDatabase = (optionalArgumentConnection) => {
|
|
1006
|
+
var MMongoCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
959
1007
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
960
|
-
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection);
|
|
1008
|
+
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection, localLanguage);
|
|
961
1009
|
};
|
|
962
1010
|
|
|
963
1011
|
// src/core/config/database/middleware/mySqlChecker.database.ts
|
|
964
|
-
var MMySqlCheckerDatabase = (optionalArgumentConnection) => {
|
|
1012
|
+
var MMySqlCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
965
1013
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
966
|
-
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection);
|
|
1014
|
+
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection, localLanguage);
|
|
967
1015
|
};
|
|
968
1016
|
|
|
969
1017
|
// src/core/config/database/middleware/postgresChecker.database.ts
|
|
970
|
-
var MPostgresCheckerDatabase = (
|
|
1018
|
+
var MPostgresCheckerDatabase = (localLanguage, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) => {
|
|
971
1019
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
972
|
-
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
|
+
);
|
|
973
1034
|
};
|
|
974
1035
|
|
|
975
1036
|
// src/utils/utility.utils.ts
|
|
976
1037
|
var import_node_process = __toESM(require("process"), 1);
|
|
977
1038
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
978
1039
|
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
979
|
-
var
|
|
1040
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
980
1041
|
var import_fs = __toESM(require("fs"), 1);
|
|
981
|
-
var
|
|
1042
|
+
var import_opticore_translator10 = require("opticore-translator");
|
|
982
1043
|
var Utility = class {
|
|
1044
|
+
localLang;
|
|
1045
|
+
constructor(localLanguage) {
|
|
1046
|
+
this.localLang = localLanguage;
|
|
1047
|
+
}
|
|
983
1048
|
/**
|
|
984
1049
|
*
|
|
985
1050
|
* @param data
|
|
@@ -1039,7 +1104,7 @@ var Utility = class {
|
|
|
1039
1104
|
const endTime = import_node_process.default.hrtime(startTime);
|
|
1040
1105
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1041
1106
|
return {
|
|
1042
|
-
"projectPath":
|
|
1107
|
+
"projectPath": import_path2.default.join(import_node_process.default.cwd()),
|
|
1043
1108
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1044
1109
|
};
|
|
1045
1110
|
}
|
|
@@ -1049,7 +1114,7 @@ var Utility = class {
|
|
|
1049
1114
|
* @private
|
|
1050
1115
|
*/
|
|
1051
1116
|
getEnvFileLoading(filePath) {
|
|
1052
|
-
const fullPath =
|
|
1117
|
+
const fullPath = import_path2.default.resolve(import_node_process.default.cwd(), filePath);
|
|
1053
1118
|
if (import_fs.default.existsSync(fullPath)) {
|
|
1054
1119
|
const env = import_fs.default.readFileSync(fullPath, "utf-8");
|
|
1055
1120
|
const lines = env.split("\n");
|
|
@@ -1071,19 +1136,19 @@ var Utility = class {
|
|
|
1071
1136
|
this.getEnvFileLoading(".env");
|
|
1072
1137
|
const isDevelopment = import_node_process.default.env.NODE_ENV === "development";
|
|
1073
1138
|
if (isDevelopment) {
|
|
1074
|
-
return `${
|
|
1139
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${development}`)}`)} mode`;
|
|
1075
1140
|
} else {
|
|
1076
|
-
return `${
|
|
1141
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${production}`)}`)} mode`;
|
|
1077
1142
|
}
|
|
1078
1143
|
}
|
|
1079
1144
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1080
1145
|
const paddingLength = 52;
|
|
1081
1146
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1082
|
-
const msg1 = ` ${
|
|
1147
|
+
const msg1 = ` ${import_opticore_translator10.TranslationLoader.t("okServerListening", this.localLang)}`;
|
|
1083
1148
|
const msg2Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${nodeVersion}`)}`)}`;
|
|
1084
|
-
const msg2 = ` ${
|
|
1149
|
+
const msg2 = ` ${import_opticore_translator10.TranslationLoader.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1085
1150
|
const msg3Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${startingTime}`)}`)}`;
|
|
1086
|
-
const msg3 = ` ${
|
|
1151
|
+
const msg3 = ` ${import_opticore_translator10.TranslationLoader.t("startupTime", this.localLang)}`;
|
|
1087
1152
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1088
1153
|
const msg5 = ` ${import_ansi_colors.default.underline(`http://${host}:${port}`)}`;
|
|
1089
1154
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1094,27 +1159,28 @@ var Utility = class {
|
|
|
1094
1159
|
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1095
1160
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1096
1161
|
console.log(``);
|
|
1097
|
-
console.log(`${`${
|
|
1098
|
-
console.log(`${`${
|
|
1099
|
-
console.log(`${`${
|
|
1100
|
-
console.log(`${`${
|
|
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}`)}`)}`);
|
|
1101
1166
|
console.log(``);
|
|
1102
1167
|
}
|
|
1103
1168
|
};
|
|
1104
1169
|
|
|
1105
1170
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1106
|
-
var
|
|
1107
|
-
var
|
|
1171
|
+
var import_path3 = require("path");
|
|
1172
|
+
var import_opticore_logger6 = require("opticore-logger");
|
|
1108
1173
|
var import_opticore_http_response8 = require("opticore-http-response");
|
|
1109
|
-
var
|
|
1174
|
+
var import_opticore_translator11 = require("opticore-translator");
|
|
1110
1175
|
var PathModuleVerifier = class {
|
|
1111
|
-
static log = new
|
|
1176
|
+
static log = new import_opticore_logger6.LoggerCore(loggerConfig);
|
|
1112
1177
|
/**
|
|
1113
1178
|
* Verifies if modules at specific paths are loaded.
|
|
1114
1179
|
* If any module is not loaded, it throws an error.
|
|
1180
|
+
* @param localLanguage
|
|
1115
1181
|
* @param modulePaths - An array of paths to the modules to verify.
|
|
1116
1182
|
*/
|
|
1117
|
-
static verifyModulePaths(modulePaths) {
|
|
1183
|
+
static verifyModulePaths(localLanguage, modulePaths) {
|
|
1118
1184
|
const notLoadedPaths = [];
|
|
1119
1185
|
for (const modulePath of modulePaths) {
|
|
1120
1186
|
if (!this.isModulePathLoaded(modulePath)) {
|
|
@@ -1123,7 +1189,7 @@ var PathModuleVerifier = class {
|
|
|
1123
1189
|
}
|
|
1124
1190
|
if (notLoadedPaths.length > 0) {
|
|
1125
1191
|
this.log.error(
|
|
1126
|
-
|
|
1192
|
+
import_opticore_translator11.TranslationLoader.t("moduleNotLoaded", localLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1127
1193
|
"",
|
|
1128
1194
|
"",
|
|
1129
1195
|
modulePaths,
|
|
@@ -1139,30 +1205,13 @@ var PathModuleVerifier = class {
|
|
|
1139
1205
|
*/
|
|
1140
1206
|
static isModulePathLoaded(modulePath) {
|
|
1141
1207
|
try {
|
|
1142
|
-
const resolvedPath = (0,
|
|
1208
|
+
const resolvedPath = (0, import_path3.resolve)(modulePath);
|
|
1143
1209
|
return require.cache[resolvedPath] !== void 0;
|
|
1144
1210
|
} catch {
|
|
1145
1211
|
return false;
|
|
1146
1212
|
}
|
|
1147
1213
|
}
|
|
1148
1214
|
};
|
|
1149
|
-
|
|
1150
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
1151
|
-
var import_path3 = __toESM(require("path"), 1);
|
|
1152
|
-
var import_module = require("module");
|
|
1153
|
-
var import_opticore_translator11 = require("opticore-translator");
|
|
1154
|
-
var import_opticore_env_access4 = require("opticore-env-access");
|
|
1155
|
-
var translateWebAppCoreLanguageLoader = () => {
|
|
1156
|
-
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
1157
|
-
const packagePath = import_path3.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
1158
|
-
const translateMsgJsonFilePath = import_path3.default.join(packagePath, "utils", "translations");
|
|
1159
|
-
import_opticore_translator11.TranslationLoader.loadTranslations(translateMsgJsonFilePath, import_opticore_env_access4.getEnvVariable.defaultLocal);
|
|
1160
|
-
};
|
|
1161
|
-
|
|
1162
|
-
// src/index.ts
|
|
1163
|
-
(() => {
|
|
1164
|
-
translateWebAppCoreLanguageLoader();
|
|
1165
|
-
})();
|
|
1166
1215
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1167
1216
|
0 && (module.exports = {
|
|
1168
1217
|
CLogLevel,
|