tychat-contracts 1.5.2 → 1.5.3

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.
@@ -7,5 +7,5 @@ export { RequestPasswordResetResponseDto } from './request-password-reset-respon
7
7
  export { PasswordResetFinalize2faDto } from './password-reset-finalize-2fa.dto';
8
8
  export { AuthLoginResponseDto } from './auth-login-response.dto';
9
9
  export { Login2faDto } from './login-2fa.dto';
10
- export { TotpSetupConfirmDto, TotpDisableDto, TotpSetupStartResponseDto, } from './totp-user.dto';
10
+ export { TotpSetupConfirmDto, TotpSetupConfirmResponseDto, TotpDisableDto, TotpSetupStartResponseDto, } from './totp-user.dto';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TotpSetupStartResponseDto = exports.TotpDisableDto = exports.TotpSetupConfirmDto = exports.Login2faDto = exports.AuthLoginResponseDto = exports.PasswordResetFinalize2faDto = exports.RequestPasswordResetResponseDto = exports.ConfirmPasswordResetDto = exports.RequestPasswordResetDto = exports.RefreshTokenDto = exports.PasswordResetFinalize2faPayload = exports.ConfirmPasswordResetPayload = exports.RequestPasswordResetPayload = exports.GetProfilePayload = exports.RefreshPayload = exports.ValidatePayload = exports.Login2faPayload = exports.LoginPayload = exports.LoginDto = void 0;
3
+ exports.TotpSetupStartResponseDto = exports.TotpDisableDto = exports.TotpSetupConfirmResponseDto = exports.TotpSetupConfirmDto = exports.Login2faDto = exports.AuthLoginResponseDto = exports.PasswordResetFinalize2faDto = exports.RequestPasswordResetResponseDto = exports.ConfirmPasswordResetDto = exports.RequestPasswordResetDto = exports.RefreshTokenDto = exports.PasswordResetFinalize2faPayload = exports.ConfirmPasswordResetPayload = exports.RequestPasswordResetPayload = exports.GetProfilePayload = exports.RefreshPayload = exports.ValidatePayload = exports.Login2faPayload = exports.LoginPayload = exports.LoginDto = void 0;
4
4
  var login_dto_1 = require("./login.dto");
5
5
  Object.defineProperty(exports, "LoginDto", { enumerable: true, get: function () { return login_dto_1.LoginDto; } });
6
6
  var auth_kafka_payloads_1 = require("./auth-kafka.payloads");
@@ -28,5 +28,6 @@ var login_2fa_dto_1 = require("./login-2fa.dto");
28
28
  Object.defineProperty(exports, "Login2faDto", { enumerable: true, get: function () { return login_2fa_dto_1.Login2faDto; } });
29
29
  var totp_user_dto_1 = require("./totp-user.dto");
30
30
  Object.defineProperty(exports, "TotpSetupConfirmDto", { enumerable: true, get: function () { return totp_user_dto_1.TotpSetupConfirmDto; } });
31
+ Object.defineProperty(exports, "TotpSetupConfirmResponseDto", { enumerable: true, get: function () { return totp_user_dto_1.TotpSetupConfirmResponseDto; } });
31
32
  Object.defineProperty(exports, "TotpDisableDto", { enumerable: true, get: function () { return totp_user_dto_1.TotpDisableDto; } });
32
33
  Object.defineProperty(exports, "TotpSetupStartResponseDto", { enumerable: true, get: function () { return totp_user_dto_1.TotpSetupStartResponseDto; } });
@@ -1,9 +1,15 @@
1
1
  export declare class TotpSetupConfirmDto {
2
2
  totp: string;
3
3
  }
4
+ /** Resposta após confirmar o 2FA: códigos de recuperação mostrados uma única vez. */
5
+ export declare class TotpSetupConfirmResponseDto {
6
+ success: true;
7
+ recovery_codes: string[];
8
+ }
4
9
  export declare class TotpDisableDto {
5
10
  current_password: string;
6
- totp: string;
11
+ totp?: string;
12
+ recovery_code?: string;
7
13
  }
8
14
  export declare class TotpSetupStartResponseDto {
9
15
  otpauth_url: string;
@@ -1 +1 @@
1
- {"version":3,"file":"totp-user.dto.d.ts","sourceRoot":"","sources":["../../src/auth/totp-user.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,mBAAmB;IAI9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,cAAc;IAIzB,gBAAgB,EAAE,MAAM,CAAC;IAKzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,yBAAyB;IAEpC,WAAW,EAAE,MAAM,CAAC;IAGpB,aAAa,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"totp-user.dto.d.ts","sourceRoot":"","sources":["../../src/auth/totp-user.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,mBAAmB;IAI9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qFAAqF;AACrF,qBAAa,2BAA2B;IAEtC,OAAO,EAAE,IAAI,CAAC;IAOd,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,qBAAa,cAAc;IAIzB,gBAAgB,EAAE,MAAM,CAAC;IASzB,IAAI,CAAC,EAAE,MAAM,CAAC;IAYd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,yBAAyB;IAEpC,WAAW,EAAE,MAAM,CAAC;IAGpB,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TotpSetupStartResponseDto = exports.TotpDisableDto = exports.TotpSetupConfirmDto = void 0;
12
+ exports.TotpSetupStartResponseDto = exports.TotpDisableDto = exports.TotpSetupConfirmResponseDto = exports.TotpSetupConfirmDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  class TotpSetupConfirmDto {
@@ -22,9 +22,27 @@ __decorate([
22
22
  (0, class_validator_1.Matches)(/^\d{6}$/, { message: 'totp deve ser exatamente 6 dígitos' }),
23
23
  __metadata("design:type", String)
24
24
  ], TotpSetupConfirmDto.prototype, "totp", void 0);
25
+ /** Resposta após confirmar o 2FA: códigos de recuperação mostrados uma única vez. */
26
+ class TotpSetupConfirmResponseDto {
27
+ success;
28
+ recovery_codes;
29
+ }
30
+ exports.TotpSetupConfirmResponseDto = TotpSetupConfirmResponseDto;
31
+ __decorate([
32
+ (0, swagger_1.ApiProperty)({ description: 'Confirmação de sucesso' }),
33
+ __metadata("design:type", Boolean)
34
+ ], TotpSetupConfirmResponseDto.prototype, "success", void 0);
35
+ __decorate([
36
+ (0, swagger_1.ApiProperty)({
37
+ type: [String],
38
+ description: 'Seis códigos de recuperação (hex, 10 caracteres). Guardar em local seguro; não serão repetidos pela API.',
39
+ }),
40
+ __metadata("design:type", Array)
41
+ ], TotpSetupConfirmResponseDto.prototype, "recovery_codes", void 0);
25
42
  class TotpDisableDto {
26
43
  current_password;
27
44
  totp;
45
+ recovery_code;
28
46
  }
29
47
  exports.TotpDisableDto = TotpDisableDto;
30
48
  __decorate([
@@ -34,11 +52,27 @@ __decorate([
34
52
  __metadata("design:type", String)
35
53
  ], TotpDisableDto.prototype, "current_password", void 0);
36
54
  __decorate([
37
- (0, swagger_1.ApiProperty)({ description: 'Código TOTP atual de 6 dígitos' }),
55
+ (0, swagger_1.ApiProperty)({
56
+ required: false,
57
+ description: 'Código TOTP atual de 6 dígitos (obrigatório se não enviar recovery_code)',
58
+ }),
59
+ (0, class_validator_1.ValidateIf)((o) => o.recovery_code == null || String(o.recovery_code).trim() === ''),
38
60
  (0, class_validator_1.IsString)(),
39
61
  (0, class_validator_1.Matches)(/^\d{6}$/, { message: 'totp deve ser exatamente 6 dígitos' }),
40
62
  __metadata("design:type", String)
41
63
  ], TotpDisableDto.prototype, "totp", void 0);
64
+ __decorate([
65
+ (0, swagger_1.ApiProperty)({
66
+ required: false,
67
+ description: 'Um dos códigos de recuperação gerados na ativação (obrigatório se não enviar totp)',
68
+ }),
69
+ (0, class_validator_1.ValidateIf)((o) => o.totp == null || String(o.totp).trim() === ''),
70
+ (0, class_validator_1.IsString)(),
71
+ (0, class_validator_1.MinLength)(10, { message: 'recovery_code inválido' }),
72
+ (0, class_validator_1.MaxLength)(64, { message: 'recovery_code inválido' }),
73
+ (0, class_validator_1.Matches)(/^[a-fA-F0-9\s-]+$/, { message: 'recovery_code inválido' }),
74
+ __metadata("design:type", String)
75
+ ], TotpDisableDto.prototype, "recovery_code", void 0);
42
76
  class TotpSetupStartResponseDto {
43
77
  otpauth_url;
44
78
  secret_base32;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "DTOs compartilhados com class-validator (API e microserviços)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/auth/index.ts CHANGED
@@ -18,6 +18,7 @@ export { AuthLoginResponseDto } from './auth-login-response.dto';
18
18
  export { Login2faDto } from './login-2fa.dto';
19
19
  export {
20
20
  TotpSetupConfirmDto,
21
+ TotpSetupConfirmResponseDto,
21
22
  TotpDisableDto,
22
23
  TotpSetupStartResponseDto,
23
24
  } from './totp-user.dto';
@@ -1,5 +1,5 @@
1
1
  import { ApiProperty } from '@nestjs/swagger';
2
- import { IsString, Matches, MinLength } from 'class-validator';
2
+ import { IsString, Matches, MaxLength, MinLength, ValidateIf } from 'class-validator';
3
3
 
4
4
  export class TotpSetupConfirmDto {
5
5
  @ApiProperty({ description: 'Código TOTP de 6 dígitos para confirmar o pareamento' })
@@ -8,16 +8,45 @@ export class TotpSetupConfirmDto {
8
8
  totp: string;
9
9
  }
10
10
 
11
+ /** Resposta após confirmar o 2FA: códigos de recuperação mostrados uma única vez. */
12
+ export class TotpSetupConfirmResponseDto {
13
+ @ApiProperty({ description: 'Confirmação de sucesso' })
14
+ success: true;
15
+
16
+ @ApiProperty({
17
+ type: [String],
18
+ description:
19
+ 'Seis códigos de recuperação (hex, 10 caracteres). Guardar em local seguro; não serão repetidos pela API.',
20
+ })
21
+ recovery_codes: string[];
22
+ }
23
+
11
24
  export class TotpDisableDto {
12
25
  @ApiProperty({ description: 'Senha atual do utilizador' })
13
26
  @IsString()
14
27
  @MinLength(1, { message: 'current_password não pode ser vazio' })
15
28
  current_password: string;
16
29
 
17
- @ApiProperty({ description: 'Código TOTP atual de 6 dígitos' })
30
+ @ApiProperty({
31
+ required: false,
32
+ description: 'Código TOTP atual de 6 dígitos (obrigatório se não enviar recovery_code)',
33
+ })
34
+ @ValidateIf((o) => o.recovery_code == null || String(o.recovery_code).trim() === '')
18
35
  @IsString()
19
36
  @Matches(/^\d{6}$/, { message: 'totp deve ser exatamente 6 dígitos' })
20
- totp: string;
37
+ totp?: string;
38
+
39
+ @ApiProperty({
40
+ required: false,
41
+ description:
42
+ 'Um dos códigos de recuperação gerados na ativação (obrigatório se não enviar totp)',
43
+ })
44
+ @ValidateIf((o) => o.totp == null || String(o.totp).trim() === '')
45
+ @IsString()
46
+ @MinLength(10, { message: 'recovery_code inválido' })
47
+ @MaxLength(64, { message: 'recovery_code inválido' })
48
+ @Matches(/^[a-fA-F0-9\s-]+$/, { message: 'recovery_code inválido' })
49
+ recovery_code?: string;
21
50
  }
22
51
 
23
52
  export class TotpSetupStartResponseDto {