@fiado/type-kit 3.498.0 → 3.500.0

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.
Files changed (28) hide show
  1. package/_test_/unit/cognitoBackofficeConnector/dtos/AuthStartLogin.test.ts +76 -0
  2. package/_test_/unit/loanCredit/dtos/createCustomerPaymentRequest.test.ts +5 -1
  3. package/_test_/unit/loanCredit/dtos/createSellerPaymentRequest.test.ts +3 -3
  4. package/_test_/unit/platformRbac/auth/dtos.test.ts +33 -0
  5. package/_test_/unit/platformRbac/enums/ChallengeNameEnum.test.ts +17 -0
  6. package/_test_/unit/retailLoan/paymentContract.test.ts +7 -0
  7. package/bin/cognitoBackofficeConnector/dtos/AuthStartLoginRequest.d.ts +13 -0
  8. package/bin/cognitoBackofficeConnector/dtos/AuthStartLoginRequest.js +53 -0
  9. package/bin/cognitoBackofficeConnector/dtos/AuthStartLoginResponse.d.ts +22 -0
  10. package/bin/cognitoBackofficeConnector/dtos/AuthStartLoginResponse.js +79 -0
  11. package/bin/cognitoBackofficeConnector/index.d.ts +2 -0
  12. package/bin/cognitoBackofficeConnector/index.js +2 -0
  13. package/bin/loanCredit/dtos/requests/CreateCustomerPaymentRequest.js +1 -1
  14. package/bin/loanCredit/dtos/requests/CreateSellerPaymentRequest.js +1 -1
  15. package/bin/platformRbac/auth/DefineNextChallengeRequest.d.ts +1 -0
  16. package/bin/platformRbac/auth/DefineNextChallengeRequest.js +5 -0
  17. package/bin/platformRbac/enums/ChallengeNameEnum.d.ts +3 -1
  18. package/bin/platformRbac/enums/ChallengeNameEnum.js +4 -0
  19. package/bin/retailLoan/dtos/CreateMyPaymentRequest.js +1 -1
  20. package/package.json +1 -1
  21. package/src/cognitoBackofficeConnector/dtos/AuthStartLoginRequest.ts +16 -0
  22. package/src/cognitoBackofficeConnector/dtos/AuthStartLoginResponse.ts +29 -0
  23. package/src/cognitoBackofficeConnector/index.ts +2 -0
  24. package/src/loanCredit/dtos/requests/CreateCustomerPaymentRequest.ts +1 -1
  25. package/src/loanCredit/dtos/requests/CreateSellerPaymentRequest.ts +1 -1
  26. package/src/platformRbac/auth/DefineNextChallengeRequest.ts +7 -1
  27. package/src/platformRbac/enums/ChallengeNameEnum.ts +4 -0
  28. package/src/retailLoan/dtos/CreateMyPaymentRequest.ts +1 -1
@@ -0,0 +1,76 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validate } from 'class-validator';
4
+ import { AuthStartLoginRequest } from '../../../../src/cognitoBackofficeConnector/dtos/AuthStartLoginRequest';
5
+ import {
6
+ AuthStartLoginResponse,
7
+ AuthStartLoginTokens,
8
+ } from '../../../../src/cognitoBackofficeConnector/dtos/AuthStartLoginResponse';
9
+ import { CognitoChallengeType } from '../../../../src/cognitoBackofficeConnector/enums/CognitoChallengeType';
10
+
11
+ describe('AuthStartLoginRequest', () => {
12
+ const base = {
13
+ userPoolId: 'us-east-1_abc',
14
+ region: 'us-east-1',
15
+ clientId: 'client-123',
16
+ username: 'sub-123',
17
+ password: 'Secret123!',
18
+ };
19
+
20
+ it('valida happy path', async () => {
21
+ const dto = plainToInstance(AuthStartLoginRequest, base);
22
+ expect(await validate(dto)).toEqual([]);
23
+ });
24
+
25
+ it('falla si falta password', async () => {
26
+ const dto = plainToInstance(AuthStartLoginRequest, { ...base, password: '' });
27
+ expect((await validate(dto)).some((e) => e.property === 'password')).toBe(true);
28
+ });
29
+
30
+ it('falla si clientId no es string', async () => {
31
+ const dto = plainToInstance(AuthStartLoginRequest, { ...base, clientId: 42 });
32
+ expect((await validate(dto)).some((e) => e.property === 'clientId')).toBe(true);
33
+ });
34
+ });
35
+
36
+ describe('AuthStartLoginResponse', () => {
37
+ it('tokens directos (2FA apagado)', async () => {
38
+ const dto = plainToInstance(AuthStartLoginResponse, {
39
+ tokens: {
40
+ accessToken: 'a',
41
+ idToken: 'i',
42
+ refreshToken: 'r',
43
+ expiresIn: 3600,
44
+ tokenType: 'Bearer',
45
+ },
46
+ });
47
+ expect(await validate(dto)).toEqual([]);
48
+ expect(dto.tokens).toBeInstanceOf(AuthStartLoginTokens);
49
+ });
50
+
51
+ it('challenge CUSTOM_CHALLENGE + session + parameters', async () => {
52
+ const dto = plainToInstance(AuthStartLoginResponse, {
53
+ challengeType: CognitoChallengeType.CUSTOM_CHALLENGE,
54
+ session: 'sess-123',
55
+ challengeParameters: { challengeName: 'EMAIL_OTP' },
56
+ });
57
+ expect(await validate(dto)).toEqual([]);
58
+ });
59
+
60
+ it('vacio es valido (todos opcionales)', async () => {
61
+ const dto = plainToInstance(AuthStartLoginResponse, {});
62
+ expect(await validate(dto)).toEqual([]);
63
+ });
64
+
65
+ it('falla si challengeType no es del enum', async () => {
66
+ const dto = plainToInstance(AuthStartLoginResponse, { challengeType: 'BOGUS' });
67
+ expect((await validate(dto)).some((e) => e.property === 'challengeType')).toBe(true);
68
+ });
69
+
70
+ it('falla si expiresIn de tokens no es number', async () => {
71
+ const dto = plainToInstance(AuthStartLoginResponse, {
72
+ tokens: { accessToken: 'a', idToken: 'i', refreshToken: 'r', expiresIn: 'x', tokenType: 'Bearer' },
73
+ });
74
+ expect((await validate(dto)).length).toBeGreaterThan(0);
75
+ });
76
+ });
@@ -65,7 +65,11 @@ describe('CreateCustomerPaymentRequest', () => {
65
65
  expect(await errorProperties({ ...VALID, type: LoanCustomerPaymentTypeEnum.ADVANCE, installmentCount: 3 })).toEqual([]);
66
66
  });
67
67
 
68
- it.each([[1], [0], [2.5], ['3']])('rechaza el número de cuotas %p', async installmentCount => {
68
+ it('acepta adelantar una sola cuota', async () => {
69
+ expect(await errorProperties({ ...VALID, type: LoanCustomerPaymentTypeEnum.ADVANCE, installmentCount: 1 })).toEqual([]);
70
+ });
71
+
72
+ it.each([[0], [2.5], ['3']])('rechaza el número de cuotas %p', async installmentCount => {
69
73
  expect(await errorProperties({ ...VALID, type: LoanCustomerPaymentTypeEnum.ADVANCE, installmentCount })).toEqual([
70
74
  'installmentCount',
71
75
  ]);
@@ -51,9 +51,9 @@ describe('CreateSellerPaymentRequest', () => {
51
51
  expect(await errorPaths({ ...BASE, idempotencyKey: 'no-uuid' })).toEqual(['idempotencyKey']);
52
52
  });
53
53
 
54
- it('cuotas solo de 2 en adelante', async () => {
55
- expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount: 1 })).toEqual(['installmentCount']);
56
- expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount: 2 })).toEqual([]);
54
+ it('cuotas desde 1', async () => {
55
+ expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount: 0 })).toEqual(['installmentCount']);
56
+ expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount: 1 })).toEqual([]);
57
57
  });
58
58
 
59
59
  it('no declara CLABE: con whitelist se descarta y nunca llega al dominio', () => {
@@ -39,4 +39,37 @@ describe('DefineNextChallengeRequest', () => {
39
39
  expect(errors.length).toBeGreaterThan(0);
40
40
  expect(errors[0].property).toBe('cognitoSub');
41
41
  });
42
+
43
+ it('acepta userStatus opcional (cognito:user_status, C-06)', async () => {
44
+ const dto = plainToInstance(DefineNextChallengeRequest, {
45
+ cognitoSub: 'abc-123',
46
+ userNotFound: false,
47
+ session: [],
48
+ userStatus: 'FORCE_CHANGE_PASSWORD',
49
+ });
50
+ const errors = await validate(dto);
51
+ expect(errors).toEqual([]);
52
+ expect(dto.userStatus).toBe('FORCE_CHANGE_PASSWORD');
53
+ });
54
+
55
+ it('userStatus ausente sigue siendo valido (aditivo)', async () => {
56
+ const dto = plainToInstance(DefineNextChallengeRequest, {
57
+ cognitoSub: 'abc-123',
58
+ userNotFound: false,
59
+ session: [],
60
+ });
61
+ expect(await validate(dto)).toEqual([]);
62
+ expect(dto.userStatus).toBeUndefined();
63
+ });
64
+
65
+ it('falla si userStatus no es string', async () => {
66
+ const dto = plainToInstance(DefineNextChallengeRequest, {
67
+ cognitoSub: 'abc-123',
68
+ userNotFound: false,
69
+ session: [],
70
+ userStatus: 99,
71
+ });
72
+ const errors = await validate(dto);
73
+ expect(errors.some((e) => e.property === 'userStatus')).toBe(true);
74
+ });
42
75
  });
@@ -0,0 +1,17 @@
1
+ import { ChallengeNameEnum } from '../../../../src/platformRbac/enums/ChallengeNameEnum';
2
+
3
+ describe('ChallengeNameEnum', () => {
4
+ it('incluye SRP_A y PASSWORD_VERIFIER (SRP dentro de CUSTOM_AUTH)', () => {
5
+ expect(ChallengeNameEnum.SRP_A).toBe('SRP_A');
6
+ expect(ChallengeNameEnum.PASSWORD_VERIFIER).toBe('PASSWORD_VERIFIER');
7
+ });
8
+
9
+ it('conserva los valores previos', () => {
10
+ expect(ChallengeNameEnum.PASSWORD).toBe('PASSWORD');
11
+ expect(ChallengeNameEnum.EMAIL_OTP).toBe('EMAIL_OTP');
12
+ expect(ChallengeNameEnum.TOTP).toBe('TOTP');
13
+ expect(ChallengeNameEnum.NEW_PASSWORD_REQUIRED).toBe('NEW_PASSWORD_REQUIRED');
14
+ expect(ChallengeNameEnum.RESET_PASSWORD).toBe('RESET_PASSWORD');
15
+ expect(ChallengeNameEnum.SMS_OTP).toBe('SMS_OTP');
16
+ });
17
+ });
@@ -72,6 +72,13 @@ describe('CreateMyPaymentRequest', () => {
72
72
  it.each([[0], [-1050], [10.123], ['1050']])('rechaza el monto %p', async expectedAmount => {
73
73
  expect(await errorProperties({ type: MyPaymentTypeEnum.SETTLEMENT, expectedAmount })).toEqual(['expectedAmount']);
74
74
  });
75
+
76
+ it('pagar por adelantado acepta desde una cuota', async () => {
77
+ expect(await errorProperties({ type: MyPaymentTypeEnum.ADVANCE, expectedAmount: 1050, installmentCount: 1 })).toEqual([]);
78
+ expect(await errorProperties({ type: MyPaymentTypeEnum.ADVANCE, expectedAmount: 1050, installmentCount: 0 })).toEqual([
79
+ 'installmentCount',
80
+ ]);
81
+ });
75
82
  });
76
83
 
77
84
  describe('retailLoan — opciones y respuesta del pago', () => {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Request del login de un solo flujo (SRP dentro de CUSTOM_AUTH). El connector
3
+ * hace InitiateAuth(CUSTOM_AUTH, CHALLENGE_NAME=SRP_A) y responde PASSWORD_VERIFIER
4
+ * firmado en la misma operacion. La contraseña nunca viaja en claro a Cognito: SRP
5
+ * la convierte en prueba. El caller (rbac) no conoce el mecanismo.
6
+ */
7
+ export declare class AuthStartLoginRequest {
8
+ userPoolId: string;
9
+ region: string;
10
+ clientId: string;
11
+ username: string;
12
+ password: string;
13
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuthStartLoginRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ /**
16
+ * Request del login de un solo flujo (SRP dentro de CUSTOM_AUTH). El connector
17
+ * hace InitiateAuth(CUSTOM_AUTH, CHALLENGE_NAME=SRP_A) y responde PASSWORD_VERIFIER
18
+ * firmado en la misma operacion. La contraseña nunca viaja en claro a Cognito: SRP
19
+ * la convierte en prueba. El caller (rbac) no conoce el mecanismo.
20
+ */
21
+ class AuthStartLoginRequest {
22
+ }
23
+ exports.AuthStartLoginRequest = AuthStartLoginRequest;
24
+ __decorate([
25
+ (0, class_transformer_1.Expose)(),
26
+ (0, class_validator_1.IsString)(),
27
+ (0, class_validator_1.IsNotEmpty)(),
28
+ __metadata("design:type", String)
29
+ ], AuthStartLoginRequest.prototype, "userPoolId", void 0);
30
+ __decorate([
31
+ (0, class_transformer_1.Expose)(),
32
+ (0, class_validator_1.IsString)(),
33
+ (0, class_validator_1.IsNotEmpty)(),
34
+ __metadata("design:type", String)
35
+ ], AuthStartLoginRequest.prototype, "region", void 0);
36
+ __decorate([
37
+ (0, class_transformer_1.Expose)(),
38
+ (0, class_validator_1.IsString)(),
39
+ (0, class_validator_1.IsNotEmpty)(),
40
+ __metadata("design:type", String)
41
+ ], AuthStartLoginRequest.prototype, "clientId", void 0);
42
+ __decorate([
43
+ (0, class_transformer_1.Expose)(),
44
+ (0, class_validator_1.IsString)(),
45
+ (0, class_validator_1.IsNotEmpty)(),
46
+ __metadata("design:type", String)
47
+ ], AuthStartLoginRequest.prototype, "username", void 0);
48
+ __decorate([
49
+ (0, class_transformer_1.Expose)(),
50
+ (0, class_validator_1.IsString)(),
51
+ (0, class_validator_1.IsNotEmpty)(),
52
+ __metadata("design:type", String)
53
+ ], AuthStartLoginRequest.prototype, "password", void 0);
@@ -0,0 +1,22 @@
1
+ import { CognitoChallengeType } from '../enums/CognitoChallengeType';
2
+ export declare class AuthStartLoginTokens {
3
+ accessToken: string;
4
+ idToken: string;
5
+ refreshToken: string;
6
+ expiresIn: number;
7
+ tokenType: string;
8
+ }
9
+ /**
10
+ * Respuesta de `authStartLogin`. Tras verificar el password via SRP
11
+ * (PASSWORD_VERIFIER), Cognito devuelve una de dos cosas: `tokens` si el flujo
12
+ * quedo completo (2FA apagado), o `challengeType` + `session` + `challengeParameters`
13
+ * si falta un paso (NEW_PASSWORD_REQUIRED, o el CUSTOM_CHALLENGE del 2do factor con
14
+ * el sub-challenge real en `challengeParameters.challengeName`). Todos los campos son
15
+ * opcionales: el caller (rbac) decide por que rama sigue.
16
+ */
17
+ export declare class AuthStartLoginResponse {
18
+ tokens?: AuthStartLoginTokens;
19
+ challengeType?: CognitoChallengeType;
20
+ session?: string;
21
+ challengeParameters?: Record<string, string>;
22
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuthStartLoginResponse = exports.AuthStartLoginTokens = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const CognitoChallengeType_1 = require("../enums/CognitoChallengeType");
16
+ class AuthStartLoginTokens {
17
+ }
18
+ exports.AuthStartLoginTokens = AuthStartLoginTokens;
19
+ __decorate([
20
+ (0, class_transformer_1.Expose)(),
21
+ (0, class_validator_1.IsString)(),
22
+ __metadata("design:type", String)
23
+ ], AuthStartLoginTokens.prototype, "accessToken", void 0);
24
+ __decorate([
25
+ (0, class_transformer_1.Expose)(),
26
+ (0, class_validator_1.IsString)(),
27
+ __metadata("design:type", String)
28
+ ], AuthStartLoginTokens.prototype, "idToken", void 0);
29
+ __decorate([
30
+ (0, class_transformer_1.Expose)(),
31
+ (0, class_validator_1.IsString)(),
32
+ __metadata("design:type", String)
33
+ ], AuthStartLoginTokens.prototype, "refreshToken", void 0);
34
+ __decorate([
35
+ (0, class_transformer_1.Expose)(),
36
+ (0, class_validator_1.IsNumber)(),
37
+ __metadata("design:type", Number)
38
+ ], AuthStartLoginTokens.prototype, "expiresIn", void 0);
39
+ __decorate([
40
+ (0, class_transformer_1.Expose)(),
41
+ (0, class_validator_1.IsString)(),
42
+ __metadata("design:type", String)
43
+ ], AuthStartLoginTokens.prototype, "tokenType", void 0);
44
+ /**
45
+ * Respuesta de `authStartLogin`. Tras verificar el password via SRP
46
+ * (PASSWORD_VERIFIER), Cognito devuelve una de dos cosas: `tokens` si el flujo
47
+ * quedo completo (2FA apagado), o `challengeType` + `session` + `challengeParameters`
48
+ * si falta un paso (NEW_PASSWORD_REQUIRED, o el CUSTOM_CHALLENGE del 2do factor con
49
+ * el sub-challenge real en `challengeParameters.challengeName`). Todos los campos son
50
+ * opcionales: el caller (rbac) decide por que rama sigue.
51
+ */
52
+ class AuthStartLoginResponse {
53
+ }
54
+ exports.AuthStartLoginResponse = AuthStartLoginResponse;
55
+ __decorate([
56
+ (0, class_transformer_1.Expose)(),
57
+ (0, class_validator_1.IsOptional)(),
58
+ (0, class_validator_1.ValidateNested)(),
59
+ (0, class_transformer_1.Type)(() => AuthStartLoginTokens),
60
+ __metadata("design:type", AuthStartLoginTokens)
61
+ ], AuthStartLoginResponse.prototype, "tokens", void 0);
62
+ __decorate([
63
+ (0, class_transformer_1.Expose)(),
64
+ (0, class_validator_1.IsOptional)(),
65
+ (0, class_validator_1.IsEnum)(CognitoChallengeType_1.CognitoChallengeType),
66
+ __metadata("design:type", String)
67
+ ], AuthStartLoginResponse.prototype, "challengeType", void 0);
68
+ __decorate([
69
+ (0, class_transformer_1.Expose)(),
70
+ (0, class_validator_1.IsOptional)(),
71
+ (0, class_validator_1.IsString)(),
72
+ __metadata("design:type", String)
73
+ ], AuthStartLoginResponse.prototype, "session", void 0);
74
+ __decorate([
75
+ (0, class_transformer_1.Expose)(),
76
+ (0, class_validator_1.IsOptional)(),
77
+ (0, class_validator_1.IsObject)(),
78
+ __metadata("design:type", Object)
79
+ ], AuthStartLoginResponse.prototype, "challengeParameters", void 0);
@@ -21,6 +21,8 @@ export * from './dtos/UserDetailResponse';
21
21
  export * from './dtos/AuthEventsRequest';
22
22
  export * from './dtos/AuthEventResponse';
23
23
  export * from './dtos/AuthTokensResponse';
24
+ export * from './dtos/AuthStartLoginRequest';
25
+ export * from './dtos/AuthStartLoginResponse';
24
26
  export * from './dtos/InitiateAuthRequest';
25
27
  export * from './dtos/InitiateAuthResponse';
26
28
  export * from './dtos/VerifyPasswordRequest';
@@ -37,6 +37,8 @@ __exportStar(require("./dtos/UserDetailResponse"), exports);
37
37
  __exportStar(require("./dtos/AuthEventsRequest"), exports);
38
38
  __exportStar(require("./dtos/AuthEventResponse"), exports);
39
39
  __exportStar(require("./dtos/AuthTokensResponse"), exports);
40
+ __exportStar(require("./dtos/AuthStartLoginRequest"), exports);
41
+ __exportStar(require("./dtos/AuthStartLoginResponse"), exports);
40
42
  __exportStar(require("./dtos/InitiateAuthRequest"), exports);
41
43
  __exportStar(require("./dtos/InitiateAuthResponse"), exports);
42
44
  __exportStar(require("./dtos/VerifyPasswordRequest"), exports);
@@ -37,6 +37,6 @@ __decorate([
37
37
  (0, class_transformer_1.Expose)(),
38
38
  (0, class_validator_1.IsOptional)(),
39
39
  (0, class_validator_1.IsInt)(),
40
- (0, class_validator_1.Min)(2),
40
+ (0, class_validator_1.Min)(1),
41
41
  __metadata("design:type", Number)
42
42
  ], CreateCustomerPaymentRequest.prototype, "installmentCount", void 0);
@@ -34,7 +34,7 @@ __decorate([
34
34
  (0, class_transformer_1.Expose)(),
35
35
  (0, class_validator_1.IsOptional)(),
36
36
  (0, class_validator_1.IsInt)(),
37
- (0, class_validator_1.Min)(2),
37
+ (0, class_validator_1.Min)(1),
38
38
  __metadata("design:type", Number)
39
39
  ], CreateSellerPaymentRequest.prototype, "installmentCount", void 0);
40
40
  __decorate([
@@ -8,4 +8,5 @@ export declare class DefineNextChallengeRequest {
8
8
  cognitoSub: string;
9
9
  userNotFound: boolean;
10
10
  session: ChallengeResultEntry[];
11
+ userStatus?: string;
11
12
  }
@@ -42,3 +42,8 @@ __decorate([
42
42
  (0, class_transformer_1.Type)(() => ChallengeResultEntry),
43
43
  __metadata("design:type", Array)
44
44
  ], DefineNextChallengeRequest.prototype, "session", void 0);
45
+ __decorate([
46
+ (0, class_validator_1.IsOptional)(),
47
+ (0, class_validator_1.IsString)(),
48
+ __metadata("design:type", String)
49
+ ], DefineNextChallengeRequest.prototype, "userStatus", void 0);
@@ -4,5 +4,7 @@ export declare enum ChallengeNameEnum {
4
4
  TOTP = "TOTP",
5
5
  NEW_PASSWORD_REQUIRED = "NEW_PASSWORD_REQUIRED",
6
6
  RESET_PASSWORD = "RESET_PASSWORD",
7
- SMS_OTP = "SMS_OTP"
7
+ SMS_OTP = "SMS_OTP",
8
+ SRP_A = "SRP_A",
9
+ PASSWORD_VERIFIER = "PASSWORD_VERIFIER"
8
10
  }
@@ -9,4 +9,8 @@ var ChallengeNameEnum;
9
9
  ChallengeNameEnum["NEW_PASSWORD_REQUIRED"] = "NEW_PASSWORD_REQUIRED";
10
10
  ChallengeNameEnum["RESET_PASSWORD"] = "RESET_PASSWORD";
11
11
  ChallengeNameEnum["SMS_OTP"] = "SMS_OTP";
12
+ // SRP dentro de CUSTOM_AUTH: entries nativos que Cognito deja en session[] y que
13
+ // el orquestador del rbac lee para decidir el siguiente paso del login de un solo flujo.
14
+ ChallengeNameEnum["SRP_A"] = "SRP_A";
15
+ ChallengeNameEnum["PASSWORD_VERIFIER"] = "PASSWORD_VERIFIER";
12
16
  })(ChallengeNameEnum || (exports.ChallengeNameEnum = ChallengeNameEnum = {}));
@@ -32,6 +32,6 @@ __decorate([
32
32
  (0, class_transformer_1.Expose)(),
33
33
  (0, class_validator_1.IsOptional)(),
34
34
  (0, class_validator_1.IsInt)(),
35
- (0, class_validator_1.Min)(2),
35
+ (0, class_validator_1.Min)(1),
36
36
  __metadata("design:type", Number)
37
37
  ], CreateMyPaymentRequest.prototype, "installmentCount", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.498.0",
3
+ "version": "3.500.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -0,0 +1,16 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsNotEmpty, IsString } from 'class-validator';
3
+
4
+ /**
5
+ * Request del login de un solo flujo (SRP dentro de CUSTOM_AUTH). El connector
6
+ * hace InitiateAuth(CUSTOM_AUTH, CHALLENGE_NAME=SRP_A) y responde PASSWORD_VERIFIER
7
+ * firmado en la misma operacion. La contraseña nunca viaja en claro a Cognito: SRP
8
+ * la convierte en prueba. El caller (rbac) no conoce el mecanismo.
9
+ */
10
+ export class AuthStartLoginRequest {
11
+ @Expose() @IsString() @IsNotEmpty() userPoolId!: string;
12
+ @Expose() @IsString() @IsNotEmpty() region!: string;
13
+ @Expose() @IsString() @IsNotEmpty() clientId!: string;
14
+ @Expose() @IsString() @IsNotEmpty() username!: string;
15
+ @Expose() @IsString() @IsNotEmpty() password!: string;
16
+ }
@@ -0,0 +1,29 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { IsEnum, IsNumber, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';
3
+ import { CognitoChallengeType } from '../enums/CognitoChallengeType';
4
+
5
+ export class AuthStartLoginTokens {
6
+ @Expose() @IsString() accessToken!: string;
7
+ @Expose() @IsString() idToken!: string;
8
+ @Expose() @IsString() refreshToken!: string;
9
+ @Expose() @IsNumber() expiresIn!: number;
10
+ @Expose() @IsString() tokenType!: string;
11
+ }
12
+
13
+ /**
14
+ * Respuesta de `authStartLogin`. Tras verificar el password via SRP
15
+ * (PASSWORD_VERIFIER), Cognito devuelve una de dos cosas: `tokens` si el flujo
16
+ * quedo completo (2FA apagado), o `challengeType` + `session` + `challengeParameters`
17
+ * si falta un paso (NEW_PASSWORD_REQUIRED, o el CUSTOM_CHALLENGE del 2do factor con
18
+ * el sub-challenge real en `challengeParameters.challengeName`). Todos los campos son
19
+ * opcionales: el caller (rbac) decide por que rama sigue.
20
+ */
21
+ export class AuthStartLoginResponse {
22
+ @Expose() @IsOptional() @ValidateNested() @Type(() => AuthStartLoginTokens) tokens?: AuthStartLoginTokens;
23
+
24
+ @Expose() @IsOptional() @IsEnum(CognitoChallengeType) challengeType?: CognitoChallengeType;
25
+
26
+ @Expose() @IsOptional() @IsString() session?: string;
27
+
28
+ @Expose() @IsOptional() @IsObject() challengeParameters?: Record<string, string>;
29
+ }
@@ -21,6 +21,8 @@ export * from './dtos/UserDetailResponse';
21
21
  export * from './dtos/AuthEventsRequest';
22
22
  export * from './dtos/AuthEventResponse';
23
23
  export * from './dtos/AuthTokensResponse';
24
+ export * from './dtos/AuthStartLoginRequest';
25
+ export * from './dtos/AuthStartLoginResponse';
24
26
  export * from './dtos/InitiateAuthRequest';
25
27
  export * from './dtos/InitiateAuthResponse';
26
28
  export * from './dtos/VerifyPasswordRequest';
@@ -23,6 +23,6 @@ export class CreateCustomerPaymentRequest {
23
23
  @Expose()
24
24
  @IsOptional()
25
25
  @IsInt()
26
- @Min(2)
26
+ @Min(1)
27
27
  installmentCount?: number;
28
28
  }
@@ -20,7 +20,7 @@ export class CreateSellerPaymentRequest {
20
20
  @Expose()
21
21
  @IsOptional()
22
22
  @IsInt()
23
- @Min(2)
23
+ @Min(1)
24
24
  installmentCount?: number;
25
25
 
26
26
  @Expose()
@@ -1,6 +1,6 @@
1
1
  import 'reflect-metadata';
2
2
  import { Type } from 'class-transformer';
3
- import { IsArray, IsBoolean, IsEnum, IsString, ValidateNested } from 'class-validator';
3
+ import { IsArray, IsBoolean, IsEnum, IsOptional, IsString, ValidateNested } from 'class-validator';
4
4
  import { ChallengeNameEnum } from '../enums/ChallengeNameEnum';
5
5
 
6
6
  export class ChallengeResultEntry {
@@ -22,4 +22,10 @@ export class DefineNextChallengeRequest {
22
22
  @ValidateNested({ each: true })
23
23
  @Type(() => ChallengeResultEntry)
24
24
  session!: ChallengeResultEntry[];
25
+
26
+ // cognito:user_status del evento de Define (C-06). El orquestador decide
27
+ // NEW_PASSWORD_REQUIRED por este valor, no por el fail-safe de getUser.
28
+ @IsOptional()
29
+ @IsString()
30
+ userStatus?: string;
25
31
  }
@@ -5,4 +5,8 @@ export enum ChallengeNameEnum {
5
5
  NEW_PASSWORD_REQUIRED = 'NEW_PASSWORD_REQUIRED',
6
6
  RESET_PASSWORD = 'RESET_PASSWORD',
7
7
  SMS_OTP = 'SMS_OTP',
8
+ // SRP dentro de CUSTOM_AUTH: entries nativos que Cognito deja en session[] y que
9
+ // el orquestador del rbac lee para decidir el siguiente paso del login de un solo flujo.
10
+ SRP_A = 'SRP_A',
11
+ PASSWORD_VERIFIER = 'PASSWORD_VERIFIER',
8
12
  }
@@ -18,6 +18,6 @@ export class CreateMyPaymentRequest {
18
18
  @Expose()
19
19
  @IsOptional()
20
20
  @IsInt()
21
- @Min(2)
21
+ @Min(1)
22
22
  installmentCount?: number;
23
23
  }