@digitaldefiance/node-express-suite 1.3.28 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +482 -2
- package/package.json +9 -6
- package/src/application-base.d.ts +12 -2
- package/src/application-base.d.ts.map +1 -1
- package/src/application-base.js +15 -0
- package/src/application-base.js.map +1 -1
- package/src/application.d.ts +3 -2
- package/src/application.d.ts.map +1 -1
- package/src/application.js +5 -0
- package/src/application.js.map +1 -1
- package/src/backup-code.d.ts.map +1 -1
- package/src/backup-code.js +1 -1
- package/src/backup-code.js.map +1 -1
- package/src/builders/application-builder.d.ts +34 -0
- package/src/builders/application-builder.d.ts.map +1 -0
- package/src/builders/application-builder.js +64 -0
- package/src/builders/application-builder.js.map +1 -0
- package/src/builders/index.d.ts +2 -0
- package/src/builders/index.d.ts.map +1 -0
- package/src/builders/index.js +5 -0
- package/src/builders/index.js.map +1 -0
- package/src/container/index.d.ts +3 -0
- package/src/container/index.d.ts.map +1 -0
- package/src/container/index.js +6 -0
- package/src/container/index.js.map +1 -0
- package/src/container/service-container.d.ts +11 -0
- package/src/container/service-container.d.ts.map +1 -0
- package/src/container/service-container.js +38 -0
- package/src/container/service-container.js.map +1 -0
- package/src/container/service-definitions.d.ts +11 -0
- package/src/container/service-definitions.d.ts.map +1 -0
- package/src/container/service-definitions.js +13 -0
- package/src/container/service-definitions.js.map +1 -0
- package/src/controllers/base.d.ts +8 -5
- package/src/controllers/base.d.ts.map +1 -1
- package/src/controllers/base.js +38 -8
- package/src/controllers/base.js.map +1 -1
- package/src/controllers/user.d.ts +3 -5
- package/src/controllers/user.d.ts.map +1 -1
- package/src/controllers/user.js +222 -196
- package/src/controllers/user.js.map +1 -1
- package/src/database/database-initializer.d.ts +7 -0
- package/src/database/database-initializer.d.ts.map +1 -0
- package/src/database/database-initializer.js +3 -0
- package/src/database/database-initializer.js.map +1 -0
- package/src/database/index.d.ts +2 -0
- package/src/database/index.d.ts.map +1 -0
- package/src/database/index.js +5 -0
- package/src/database/index.js.map +1 -0
- package/src/decorators/base-controller.d.ts +1 -5
- package/src/decorators/base-controller.d.ts.map +1 -1
- package/src/decorators/base-controller.js +8 -2
- package/src/decorators/base-controller.js.map +1 -1
- package/src/decorators/controller.d.ts +8 -2
- package/src/decorators/controller.d.ts.map +1 -1
- package/src/decorators/controller.js.map +1 -1
- package/src/documents/user.d.ts +1 -2
- package/src/documents/user.d.ts.map +1 -1
- package/src/environment.d.ts +1 -2
- package/src/environment.d.ts.map +1 -1
- package/src/environment.js +6 -6
- package/src/environment.js.map +1 -1
- package/src/errors/express-validation.d.ts +2 -2
- package/src/errors/express-validation.d.ts.map +1 -1
- package/src/errors/express-validation.js +1 -1
- package/src/errors/express-validation.js.map +1 -1
- package/src/errors/symmetric.d.ts +1 -1
- package/src/errors/symmetric.d.ts.map +1 -1
- package/src/errors/symmetric.js +1 -2
- package/src/errors/symmetric.js.map +1 -1
- package/src/get-timezone.d.ts +1 -2
- package/src/get-timezone.d.ts.map +1 -1
- package/src/get-timezone.js +15 -7
- package/src/get-timezone.js.map +1 -1
- package/src/index.d.ts +13 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +14 -1
- package/src/index.js.map +1 -1
- package/src/interfaces/application.d.ts +8 -5
- package/src/interfaces/application.d.ts.map +1 -1
- package/src/interfaces/constants.d.ts +0 -1
- package/src/interfaces/constants.d.ts.map +1 -1
- package/src/interfaces/controller-config.d.ts +21 -0
- package/src/interfaces/controller-config.d.ts.map +1 -0
- package/src/interfaces/controller-config.js +3 -0
- package/src/interfaces/controller-config.js.map +1 -0
- package/src/interfaces/environment.d.ts +1 -2
- package/src/interfaces/environment.d.ts.map +1 -1
- package/src/interfaces/index.d.ts +1 -0
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +1 -0
- package/src/interfaces/index.js.map +1 -1
- package/src/middlewares/authenticate-crypto.d.ts +1 -5
- package/src/middlewares/authenticate-crypto.d.ts.map +1 -1
- package/src/middlewares/authenticate-crypto.js +2 -17
- package/src/middlewares/authenticate-crypto.js.map +1 -1
- package/src/middlewares/authenticate-token.d.ts +1 -4
- package/src/middlewares/authenticate-token.d.ts.map +1 -1
- package/src/middlewares/authenticate-token.js +8 -2
- package/src/middlewares/authenticate-token.js.map +1 -1
- package/src/middlewares.d.ts.map +1 -1
- package/src/middlewares.js +2 -1
- package/src/middlewares.js.map +1 -1
- package/src/pipeline/index.d.ts +2 -0
- package/src/pipeline/index.d.ts.map +1 -0
- package/src/pipeline/index.js +5 -0
- package/src/pipeline/index.js.map +1 -0
- package/src/pipeline/pipeline-builder.d.ts +8 -0
- package/src/pipeline/pipeline-builder.d.ts.map +1 -0
- package/src/pipeline/pipeline-builder.js +18 -0
- package/src/pipeline/pipeline-builder.js.map +1 -0
- package/src/plugins/index.d.ts +3 -0
- package/src/plugins/index.d.ts.map +1 -0
- package/src/plugins/index.js +6 -0
- package/src/plugins/index.js.map +1 -0
- package/src/plugins/plugin-interface.d.ts +8 -0
- package/src/plugins/plugin-interface.d.ts.map +1 -0
- package/src/plugins/plugin-interface.js +3 -0
- package/src/plugins/plugin-interface.js.map +1 -0
- package/src/plugins/plugin-manager.d.ts +12 -0
- package/src/plugins/plugin-manager.d.ts.map +1 -0
- package/src/plugins/plugin-manager.js +37 -0
- package/src/plugins/plugin-manager.js.map +1 -0
- package/src/responses/index.d.ts +2 -0
- package/src/responses/index.d.ts.map +1 -0
- package/src/responses/index.js +5 -0
- package/src/responses/index.js.map +1 -0
- package/src/responses/response-builder.d.ts +24 -0
- package/src/responses/response-builder.d.ts.map +1 -0
- package/src/responses/response-builder.js +62 -0
- package/src/responses/response-builder.js.map +1 -0
- package/src/routers/api.d.ts +2 -1
- package/src/routers/api.d.ts.map +1 -1
- package/src/routers/api.js +43 -15
- package/src/routers/api.js.map +1 -1
- package/src/routers/app.d.ts +1 -5
- package/src/routers/app.d.ts.map +1 -1
- package/src/routers/app.js +2 -2
- package/src/routers/app.js.map +1 -1
- package/src/routers/base.d.ts +1 -5
- package/src/routers/base.d.ts.map +1 -1
- package/src/routers/base.js.map +1 -1
- package/src/routers/router-config.d.ts +18 -0
- package/src/routers/router-config.d.ts.map +1 -0
- package/src/routers/router-config.js +8 -0
- package/src/routers/router-config.js.map +1 -0
- package/src/routing/index.d.ts +2 -0
- package/src/routing/index.d.ts.map +1 -0
- package/src/routing/index.js +5 -0
- package/src/routing/index.js.map +1 -0
- package/src/routing/route-builder.d.ts +36 -0
- package/src/routing/route-builder.d.ts.map +1 -0
- package/src/routing/route-builder.js +86 -0
- package/src/routing/route-builder.js.map +1 -0
- package/src/schemas/user.d.ts +1 -1
- package/src/schemas/user.d.ts.map +1 -1
- package/src/schemas/user.js +1 -1
- package/src/schemas/user.js.map +1 -1
- package/src/services/backup-code.d.ts +2 -4
- package/src/services/backup-code.d.ts.map +1 -1
- package/src/services/backup-code.js.map +1 -1
- package/src/services/base.d.ts +2 -5
- package/src/services/base.d.ts.map +1 -1
- package/src/services/base.js.map +1 -1
- package/src/services/database-initialization.d.ts +4 -8
- package/src/services/database-initialization.d.ts.map +1 -1
- package/src/services/database-initialization.js +39 -39
- package/src/services/database-initialization.js.map +1 -1
- package/src/services/direct-login-token.d.ts +1 -4
- package/src/services/direct-login-token.d.ts.map +1 -1
- package/src/services/direct-login-token.js.map +1 -1
- package/src/services/jwt.d.ts +1 -4
- package/src/services/jwt.d.ts.map +1 -1
- package/src/services/jwt.js.map +1 -1
- package/src/services/role.d.ts +2 -4
- package/src/services/role.d.ts.map +1 -1
- package/src/services/role.js.map +1 -1
- package/src/services/system-user.js +1 -1
- package/src/services/system-user.js.map +1 -1
- package/src/services/user.d.ts +2 -2
- package/src/services/user.d.ts.map +1 -1
- package/src/services/user.js +3 -3
- package/src/services/user.js.map +1 -1
- package/src/transactions/index.d.ts +2 -0
- package/src/transactions/index.d.ts.map +1 -0
- package/src/transactions/index.js +5 -0
- package/src/transactions/index.js.map +1 -0
- package/src/transactions/transaction-manager.d.ts +12 -0
- package/src/transactions/transaction-manager.d.ts.map +1 -0
- package/src/transactions/transaction-manager.js +30 -0
- package/src/transactions/transaction-manager.js.map +1 -0
- package/src/types/app-config.d.ts +16 -0
- package/src/types/app-config.d.ts.map +1 -0
- package/src/types/app-config.js +3 -0
- package/src/types/app-config.js.map +1 -0
- package/src/types/controller-config.d.ts +14 -0
- package/src/types/controller-config.d.ts.map +1 -0
- package/src/types/controller-config.js +3 -0
- package/src/types/controller-config.js.map +1 -0
- package/src/types/index.d.ts +3 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +6 -0
- package/src/types/index.js.map +1 -0
- package/src/types.d.ts +2 -0
- package/src/types.d.ts.map +1 -1
- package/src/types.js.map +1 -1
- package/src/utils.js +2 -2
- package/src/utils.js.map +1 -1
- package/src/validation/index.d.ts +2 -0
- package/src/validation/index.d.ts.map +1 -0
- package/src/validation/index.js +5 -0
- package/src/validation/index.js.map +1 -0
- package/src/validation/validation-builder.d.ts +32 -0
- package/src/validation/validation-builder.d.ts.map +1 -0
- package/src/validation/validation-builder.js +81 -0
- package/src/validation/validation-builder.js.map +1 -0
package/src/controllers/user.js
CHANGED
|
@@ -426,22 +426,24 @@ tslib_1.__decorate([
|
|
|
426
426
|
tslib_1.__decorate([
|
|
427
427
|
(0, controller_1.Post)('/register', {
|
|
428
428
|
schema: RegisterSchema,
|
|
429
|
-
validation: (validationLanguage)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
.
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
.
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
429
|
+
validation: function (validationLanguage) {
|
|
430
|
+
return [
|
|
431
|
+
(0, express_validator_1.body)('username')
|
|
432
|
+
.matches(this.constants.UsernameRegex)
|
|
433
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate, undefined, validationLanguage)),
|
|
434
|
+
(0, express_validator_1.body)('email')
|
|
435
|
+
.isEmail()
|
|
436
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail, undefined, validationLanguage)),
|
|
437
|
+
(0, express_validator_1.body)('timezone')
|
|
438
|
+
.isString()
|
|
439
|
+
.custom((value) => (0, i18n_lib_1.isValidTimezone)(value))
|
|
440
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid, undefined, validationLanguage)),
|
|
441
|
+
(0, express_validator_1.body)('password')
|
|
442
|
+
.optional()
|
|
443
|
+
.matches(this.constants.PasswordRegex)
|
|
444
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate)),
|
|
445
|
+
];
|
|
446
|
+
},
|
|
445
447
|
}),
|
|
446
448
|
tslib_1.__metadata("design:type", Function),
|
|
447
449
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -449,14 +451,16 @@ tslib_1.__decorate([
|
|
|
449
451
|
], UserController.prototype, "register", null);
|
|
450
452
|
tslib_1.__decorate([
|
|
451
453
|
(0, controller_1.Post)('/account-verification', {
|
|
452
|
-
validation: (validationLanguage)
|
|
453
|
-
|
|
454
|
-
.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
454
|
+
validation: function (validationLanguage) {
|
|
455
|
+
return [
|
|
456
|
+
(0, express_validator_1.body)('token')
|
|
457
|
+
.not()
|
|
458
|
+
.isEmpty()
|
|
459
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_TokenRequired, undefined, validationLanguage))
|
|
460
|
+
.matches(new RegExp(`^[a-f0-9]{${this.constants.EmailTokenLength * 2}}$`))
|
|
461
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidToken, undefined, validationLanguage)),
|
|
462
|
+
];
|
|
463
|
+
},
|
|
460
464
|
}),
|
|
461
465
|
tslib_1.__metadata("design:type", Function),
|
|
462
466
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -465,13 +469,15 @@ tslib_1.__decorate([
|
|
|
465
469
|
tslib_1.__decorate([
|
|
466
470
|
(0, controller_1.Post)('/language', {
|
|
467
471
|
auth: true,
|
|
468
|
-
validation: (validationLanguage)
|
|
469
|
-
|
|
470
|
-
.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
validation: function (validationLanguage) {
|
|
473
|
+
return [
|
|
474
|
+
(0, express_validator_1.body)('language')
|
|
475
|
+
.isString()
|
|
476
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidLanguage, undefined, validationLanguage))
|
|
477
|
+
.isIn(Object.values(i18n_lib_1.LanguageCodes))
|
|
478
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidLanguage, undefined, validationLanguage)),
|
|
479
|
+
];
|
|
480
|
+
},
|
|
475
481
|
}),
|
|
476
482
|
tslib_1.__metadata("design:type", Function),
|
|
477
483
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -487,24 +493,26 @@ tslib_1.__decorate([
|
|
|
487
493
|
(0, controller_1.Post)('/backup-codes', {
|
|
488
494
|
auth: true,
|
|
489
495
|
cryptoAuth: true,
|
|
490
|
-
validation: (validationLanguage)
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
.
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
.
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
496
|
+
validation: function (validationLanguage) {
|
|
497
|
+
return [
|
|
498
|
+
(0, express_validator_1.body)().custom((value, { req }) => {
|
|
499
|
+
if (!req.body?.password && !req.body?.mnemonic) {
|
|
500
|
+
throw new mnemonic_or_password_required_1.MnemonicOrPasswordRequiredError();
|
|
501
|
+
}
|
|
502
|
+
return true;
|
|
503
|
+
}),
|
|
504
|
+
(0, express_validator_1.body)('password')
|
|
505
|
+
.optional()
|
|
506
|
+
.notEmpty()
|
|
507
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_CurrentPasswordRequired, undefined, validationLanguage)),
|
|
508
|
+
(0, express_validator_1.body)('mnemonic')
|
|
509
|
+
.optional()
|
|
510
|
+
.notEmpty()
|
|
511
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicRequired, undefined, validationLanguage))
|
|
512
|
+
.matches(this.constants.MnemonicRegex)
|
|
513
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicRegex, undefined, validationLanguage)),
|
|
514
|
+
];
|
|
515
|
+
},
|
|
508
516
|
}),
|
|
509
517
|
tslib_1.__metadata("design:type", Function),
|
|
510
518
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -514,11 +522,13 @@ tslib_1.__decorate([
|
|
|
514
522
|
(0, controller_1.Post)('/recover-mnemonic', {
|
|
515
523
|
auth: true,
|
|
516
524
|
cryptoAuth: true,
|
|
517
|
-
validation: (validationLanguage)
|
|
518
|
-
|
|
519
|
-
.
|
|
520
|
-
|
|
521
|
-
|
|
525
|
+
validation: function (validationLanguage) {
|
|
526
|
+
return [
|
|
527
|
+
(0, express_validator_1.body)('password')
|
|
528
|
+
.isString()
|
|
529
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_CurrentPasswordRequired, undefined, validationLanguage)),
|
|
530
|
+
];
|
|
531
|
+
},
|
|
522
532
|
}),
|
|
523
533
|
tslib_1.__metadata("design:type", Function),
|
|
524
534
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -527,16 +537,18 @@ tslib_1.__decorate([
|
|
|
527
537
|
tslib_1.__decorate([
|
|
528
538
|
(0, controller_1.Post)('/change-password', {
|
|
529
539
|
auth: true,
|
|
530
|
-
validation: (validationLanguage)
|
|
531
|
-
|
|
532
|
-
.
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
+
validation: function (validationLanguage) {
|
|
541
|
+
return [
|
|
542
|
+
(0, express_validator_1.body)('currentPassword')
|
|
543
|
+
.notEmpty()
|
|
544
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_Required, undefined, validationLanguage)),
|
|
545
|
+
(0, express_validator_1.body)('newPassword')
|
|
546
|
+
.matches(this.constants.PasswordRegex)
|
|
547
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate))
|
|
548
|
+
.notEmpty()
|
|
549
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_Required, undefined, validationLanguage)),
|
|
550
|
+
];
|
|
551
|
+
},
|
|
540
552
|
}),
|
|
541
553
|
tslib_1.__metadata("design:type", Function),
|
|
542
554
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -551,34 +563,36 @@ tslib_1.__decorate([
|
|
|
551
563
|
tslib_1.__decorate([
|
|
552
564
|
(0, controller_1.Post)('/direct-challenge', {
|
|
553
565
|
schema: DirectLoginChallengeSchema,
|
|
554
|
-
validation: (validationLanguage)
|
|
555
|
-
|
|
556
|
-
.
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
.
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
.
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
566
|
+
validation: function (validationLanguage) {
|
|
567
|
+
return [
|
|
568
|
+
(0, express_validator_1.body)('challenge')
|
|
569
|
+
.not()
|
|
570
|
+
.isEmpty()
|
|
571
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidChallenge, undefined, validationLanguage))
|
|
572
|
+
.matches(new RegExp(`^[a-f0-9]{${(ecies_lib_1.UINT64_SIZE + 32 + ecies_lib_1.ECIES.SIGNATURE_SIZE) * 2}}$`))
|
|
573
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidChallenge, undefined, validationLanguage)),
|
|
574
|
+
(0, express_validator_1.body)('signature')
|
|
575
|
+
.not()
|
|
576
|
+
.isEmpty()
|
|
577
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidSignature))
|
|
578
|
+
.matches(new RegExp(`^[a-f0-9]{${ecies_lib_1.ECIES.SIGNATURE_SIZE * 2}}$`))
|
|
579
|
+
.withMessage(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidSignature),
|
|
580
|
+
(0, express_validator_1.body)().custom((value, { req }) => {
|
|
581
|
+
if (!req.body.username && !req.body.email) {
|
|
582
|
+
throw new suite_core_lib_1.UsernameOrEmailRequiredError();
|
|
583
|
+
}
|
|
584
|
+
return true;
|
|
585
|
+
}),
|
|
586
|
+
(0, express_validator_1.body)('username')
|
|
587
|
+
.optional()
|
|
588
|
+
.matches(this.constants.UsernameRegex)
|
|
589
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate, undefined, validationLanguage)),
|
|
590
|
+
(0, express_validator_1.body)('email')
|
|
591
|
+
.optional()
|
|
592
|
+
.isEmail()
|
|
593
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail, undefined, validationLanguage)),
|
|
594
|
+
];
|
|
595
|
+
},
|
|
582
596
|
}),
|
|
583
597
|
tslib_1.__metadata("design:type", Function),
|
|
584
598
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -586,22 +600,24 @@ tslib_1.__decorate([
|
|
|
586
600
|
], UserController.prototype, "directLoginChallenge", null);
|
|
587
601
|
tslib_1.__decorate([
|
|
588
602
|
(0, controller_1.Post)('/request-email-login', {
|
|
589
|
-
validation: (validationLanguage)
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
.
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
603
|
+
validation: function (validationLanguage) {
|
|
604
|
+
return [
|
|
605
|
+
(0, express_validator_1.body)().custom((value, { req }) => {
|
|
606
|
+
if (!req.body.username && !req.body.email) {
|
|
607
|
+
throw new suite_core_lib_1.UsernameOrEmailRequiredError();
|
|
608
|
+
}
|
|
609
|
+
return true;
|
|
610
|
+
}),
|
|
611
|
+
(0, express_validator_1.body)('username')
|
|
612
|
+
.optional()
|
|
613
|
+
.matches(this.constants.UsernameRegex)
|
|
614
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate, undefined, validationLanguage)),
|
|
615
|
+
(0, express_validator_1.body)('email')
|
|
616
|
+
.optional()
|
|
617
|
+
.isEmail()
|
|
618
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail, undefined, validationLanguage)),
|
|
619
|
+
];
|
|
620
|
+
},
|
|
605
621
|
}),
|
|
606
622
|
tslib_1.__metadata("design:type", Function),
|
|
607
623
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -610,34 +626,36 @@ tslib_1.__decorate([
|
|
|
610
626
|
tslib_1.__decorate([
|
|
611
627
|
(0, controller_1.Post)('/email-challenge', {
|
|
612
628
|
schema: EmailLoginChallengeSchema,
|
|
613
|
-
validation: (validationLanguage)
|
|
614
|
-
|
|
615
|
-
.
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
.
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
.
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
.
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
629
|
+
validation: function (validationLanguage) {
|
|
630
|
+
return [
|
|
631
|
+
(0, express_validator_1.body)('token')
|
|
632
|
+
.not()
|
|
633
|
+
.isEmpty()
|
|
634
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_TokenRequired, undefined, validationLanguage))
|
|
635
|
+
.matches(new RegExp(`^[a-f0-9]{${this.constants.EmailTokenLength * 2}}$`))
|
|
636
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidToken, undefined, validationLanguage)),
|
|
637
|
+
(0, express_validator_1.body)('signature')
|
|
638
|
+
.not()
|
|
639
|
+
.isEmpty()
|
|
640
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidSignature))
|
|
641
|
+
.matches(new RegExp(`^[a-f0-9]{${ecies_lib_1.ECIES.SIGNATURE_SIZE * 2}}$`))
|
|
642
|
+
.withMessage(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidSignature),
|
|
643
|
+
(0, express_validator_1.body)().custom((value, { req }) => {
|
|
644
|
+
if (!req.body.username && !req.body.email) {
|
|
645
|
+
throw new suite_core_lib_1.UsernameOrEmailRequiredError();
|
|
646
|
+
}
|
|
647
|
+
return true;
|
|
648
|
+
}),
|
|
649
|
+
(0, express_validator_1.body)('username')
|
|
650
|
+
.optional()
|
|
651
|
+
.matches(this.constants.UsernameRegex)
|
|
652
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate, undefined, validationLanguage)),
|
|
653
|
+
(0, express_validator_1.body)('email')
|
|
654
|
+
.optional()
|
|
655
|
+
.isEmail()
|
|
656
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail, undefined, validationLanguage)),
|
|
657
|
+
];
|
|
658
|
+
},
|
|
641
659
|
}),
|
|
642
660
|
tslib_1.__metadata("design:type", Function),
|
|
643
661
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -645,20 +663,22 @@ tslib_1.__decorate([
|
|
|
645
663
|
], UserController.prototype, "emailLoginChallenge", null);
|
|
646
664
|
tslib_1.__decorate([
|
|
647
665
|
(0, controller_1.Post)('/resend-verification', {
|
|
648
|
-
validation: (validationLanguage)
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
.
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
666
|
+
validation: function (validationLanguage) {
|
|
667
|
+
return [
|
|
668
|
+
(0, express_validator_1.body)().custom((value, { req }) => {
|
|
669
|
+
if (!req.body.username && !req.body.email) {
|
|
670
|
+
throw new suite_core_lib_1.UsernameOrEmailRequiredError();
|
|
671
|
+
}
|
|
672
|
+
return true;
|
|
673
|
+
}),
|
|
674
|
+
(0, express_validator_1.body)('username')
|
|
675
|
+
.optional()
|
|
676
|
+
.isString()
|
|
677
|
+
.matches(this.constants.UsernameRegex)
|
|
678
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate, undefined, validationLanguage)),
|
|
679
|
+
(0, express_validator_1.body)('email').optional().isEmail(),
|
|
680
|
+
];
|
|
681
|
+
},
|
|
662
682
|
}),
|
|
663
683
|
tslib_1.__metadata("design:type", Function),
|
|
664
684
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -666,25 +686,27 @@ tslib_1.__decorate([
|
|
|
666
686
|
], UserController.prototype, "resendVerification", null);
|
|
667
687
|
tslib_1.__decorate([
|
|
668
688
|
(0, controller_1.Post)('/backup-code', {
|
|
669
|
-
validation: (validationLanguage)
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
.
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
.
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
.
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
689
|
+
validation: function (validationLanguage) {
|
|
690
|
+
return [
|
|
691
|
+
(0, express_validator_1.body)('email').optional().isEmail(),
|
|
692
|
+
(0, express_validator_1.body)('username')
|
|
693
|
+
.optional()
|
|
694
|
+
.matches(this.constants.UsernameRegex)
|
|
695
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate, undefined, validationLanguage)),
|
|
696
|
+
(0, express_validator_1.body)('code')
|
|
697
|
+
.custom((value) => {
|
|
698
|
+
const normalized = backup_code_1.BackupCode.normalizeCode(value);
|
|
699
|
+
return (this.constants.BACKUP_CODES.DisplayRegex.test(value) ||
|
|
700
|
+
this.constants.BACKUP_CODES.NormalizedHexRegex.test(normalized));
|
|
701
|
+
})
|
|
702
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidBackupCode, undefined, validationLanguage)),
|
|
703
|
+
(0, express_validator_1.body)('recoverMnemonic').isBoolean().optional(),
|
|
704
|
+
(0, express_validator_1.body)('newPassword')
|
|
705
|
+
.optional()
|
|
706
|
+
.matches(this.constants.PasswordRegex)
|
|
707
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate, undefined, validationLanguage)),
|
|
708
|
+
];
|
|
709
|
+
},
|
|
688
710
|
}),
|
|
689
711
|
tslib_1.__metadata("design:type", Function),
|
|
690
712
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -692,11 +714,13 @@ tslib_1.__decorate([
|
|
|
692
714
|
], UserController.prototype, "useBackupCodeLogin", null);
|
|
693
715
|
tslib_1.__decorate([
|
|
694
716
|
(0, controller_1.Post)('/forgot-password', {
|
|
695
|
-
validation: (validationLanguage)
|
|
696
|
-
|
|
697
|
-
.
|
|
698
|
-
|
|
699
|
-
|
|
717
|
+
validation: function (validationLanguage) {
|
|
718
|
+
return [
|
|
719
|
+
(0, express_validator_1.body)('email')
|
|
720
|
+
.isEmail()
|
|
721
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail, undefined, validationLanguage)),
|
|
722
|
+
];
|
|
723
|
+
},
|
|
700
724
|
}),
|
|
701
725
|
tslib_1.__metadata("design:type", Function),
|
|
702
726
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|
|
@@ -710,28 +734,30 @@ tslib_1.__decorate([
|
|
|
710
734
|
], UserController.prototype, "verifyResetToken", null);
|
|
711
735
|
tslib_1.__decorate([
|
|
712
736
|
(0, controller_1.Post)('/reset-password', {
|
|
713
|
-
validation: (validationLanguage)
|
|
714
|
-
|
|
715
|
-
.
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
.
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
737
|
+
validation: function (validationLanguage) {
|
|
738
|
+
return [
|
|
739
|
+
(0, express_validator_1.body)('token')
|
|
740
|
+
.not()
|
|
741
|
+
.isEmpty()
|
|
742
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_TokenRequired, undefined, validationLanguage))
|
|
743
|
+
.matches(new RegExp(`^[a-f0-9]{${this.constants.EmailTokenLength * 2}}$`))
|
|
744
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidToken, undefined, validationLanguage)),
|
|
745
|
+
(0, express_validator_1.body)('newPassword')
|
|
746
|
+
.optional()
|
|
747
|
+
.isLength({ min: 8 })
|
|
748
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMinLengthTemplate, undefined, validationLanguage))
|
|
749
|
+
.matches(this.constants.PasswordRegex)
|
|
750
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate, undefined, validationLanguage)),
|
|
751
|
+
(0, express_validator_1.body)('password')
|
|
752
|
+
.optional()
|
|
753
|
+
.isLength({ min: 8 })
|
|
754
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMinLengthTemplate, undefined, validationLanguage))
|
|
755
|
+
.matches(this.constants.PasswordRegex)
|
|
756
|
+
.withMessage((0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate, undefined, validationLanguage)),
|
|
757
|
+
(0, express_validator_1.body)('currentPassword').optional().isString(),
|
|
758
|
+
(0, express_validator_1.body)('mnemonic').optional().isString(),
|
|
759
|
+
];
|
|
760
|
+
},
|
|
735
761
|
}),
|
|
736
762
|
tslib_1.__metadata("design:type", Function),
|
|
737
763
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Function]),
|