@fiado/type-kit 3.47.0 → 3.48.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/Introspect.test.ts +30 -0
  2. package/_test_/unit/platformRbac/dtos/AuthorizeRequest.test.ts +30 -0
  3. package/_test_/unit/platformRbac/dtos/AuthorizeResponse.test.ts +25 -0
  4. package/bin/cognitoBackofficeConnector/dtos/IntrospectRequest.d.ts +7 -0
  5. package/bin/cognitoBackofficeConnector/dtos/IntrospectRequest.js +42 -0
  6. package/bin/cognitoBackofficeConnector/dtos/IntrospectResponse.d.ts +7 -0
  7. package/bin/cognitoBackofficeConnector/dtos/IntrospectResponse.js +36 -0
  8. package/bin/cognitoBackofficeConnector/enums/IntrospectFailReason.d.ts +11 -0
  9. package/bin/cognitoBackofficeConnector/enums/IntrospectFailReason.js +15 -0
  10. package/bin/cognitoBackofficeConnector/index.d.ts +3 -0
  11. package/bin/cognitoBackofficeConnector/index.js +4 -0
  12. package/bin/platformRbac/dtos/AuthorizeRequest.d.ts +11 -0
  13. package/bin/platformRbac/dtos/AuthorizeRequest.js +46 -0
  14. package/bin/platformRbac/dtos/AuthorizeResponse.d.ts +13 -0
  15. package/bin/platformRbac/dtos/AuthorizeResponse.js +35 -0
  16. package/bin/platformRbac/enums/AuthorizeDenyReason.d.ts +10 -0
  17. package/bin/platformRbac/enums/AuthorizeDenyReason.js +14 -0
  18. package/bin/platformRbac/index.d.ts +3 -0
  19. package/bin/platformRbac/index.js +6 -1
  20. package/package.json +1 -1
  21. package/src/cognitoBackofficeConnector/dtos/IntrospectRequest.ts +10 -0
  22. package/src/cognitoBackofficeConnector/dtos/IntrospectResponse.ts +10 -0
  23. package/src/cognitoBackofficeConnector/enums/IntrospectFailReason.ts +11 -0
  24. package/src/cognitoBackofficeConnector/index.ts +5 -0
  25. package/src/platformRbac/dtos/AuthorizeRequest.ts +14 -0
  26. package/src/platformRbac/dtos/AuthorizeResponse.ts +16 -0
  27. package/src/platformRbac/enums/AuthorizeDenyReason.ts +10 -0
  28. package/src/platformRbac/index.ts +5 -0
@@ -0,0 +1,30 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validate } from 'class-validator';
4
+ import { IntrospectRequest } from '../../../../src/cognitoBackofficeConnector/dtos/IntrospectRequest';
5
+ import { IntrospectResponse } from '../../../../src/cognitoBackofficeConnector/dtos/IntrospectResponse';
6
+ import { IntrospectFailReason } from '../../../../src/cognitoBackofficeConnector/enums/IntrospectFailReason';
7
+
8
+ describe('IntrospectRequest', () => {
9
+ it('valida happy path', async () => {
10
+ const dto = plainToInstance(IntrospectRequest, {
11
+ token: 'jwt', userPoolId: 'us-east-1_o0h1s3458', region: 'us-east-1', clientId: '1b8g4shbvbi5jhq19fuc8mi2bk',
12
+ });
13
+ expect(await validate(dto)).toEqual([]);
14
+ });
15
+ it('falla si falta userPoolId', async () => {
16
+ const dto = plainToInstance(IntrospectRequest, { token: 'jwt', region: 'us-east-1', clientId: 'c' });
17
+ expect((await validate(dto)).some(e => e.property === 'userPoolId')).toBe(true);
18
+ });
19
+ });
20
+
21
+ describe('IntrospectResponse', () => {
22
+ it('valid=true con cognitoSub', async () => {
23
+ const dto = plainToInstance(IntrospectResponse, { valid: true, cognitoSub: '248814c8' });
24
+ expect(await validate(dto)).toEqual([]);
25
+ });
26
+ it('valid=false con reason enum', async () => {
27
+ const dto = plainToInstance(IntrospectResponse, { valid: false, reason: IntrospectFailReason.REVOKED });
28
+ expect(await validate(dto)).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,30 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validate } from 'class-validator';
4
+ import { AuthorizeRequest } from '../../../../src/platformRbac/dtos/AuthorizeRequest';
5
+ import { PermissionScope } from '../../../../src/platformRbac/enums/PermissionScope';
6
+
7
+ describe('AuthorizeRequest', () => {
8
+ it('valida happy path con scope opcional', async () => {
9
+ const dto = plainToInstance(AuthorizeRequest, {
10
+ token: 'jwt.abc.def',
11
+ permission: 'tenant.user.create',
12
+ scope: PermissionScope.RETAILER,
13
+ scopeRef: 'VL-001',
14
+ });
15
+ const errors = await validate(dto);
16
+ expect(errors).toEqual([]);
17
+ });
18
+
19
+ it('falla si falta token', async () => {
20
+ const dto = plainToInstance(AuthorizeRequest, { permission: 'tenant.user.create' });
21
+ const errors = await validate(dto);
22
+ expect(errors.some(e => e.property === 'token')).toBe(true);
23
+ });
24
+
25
+ it('acepta sin scope/scopeRef (permiso sin scope)', async () => {
26
+ const dto = plainToInstance(AuthorizeRequest, { token: 'jwt', permission: 'catalog.read' });
27
+ const errors = await validate(dto);
28
+ expect(errors).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,25 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validate } from 'class-validator';
4
+ import { AuthorizeResponse } from '../../../../src/platformRbac/dtos/AuthorizeResponse';
5
+ import { AuthorizeDenyReason } from '../../../../src/platformRbac/enums/AuthorizeDenyReason';
6
+
7
+ describe('AuthorizeResponse', () => {
8
+ it('valida allow=true sin reason', async () => {
9
+ const dto = plainToInstance(AuthorizeResponse, { allow: true });
10
+ const errors = await validate(dto);
11
+ expect(errors).toEqual([]);
12
+ });
13
+
14
+ it('valida allow=false con reason enum', async () => {
15
+ const dto = plainToInstance(AuthorizeResponse, { allow: false, reason: AuthorizeDenyReason.NO_PERMISSION });
16
+ const errors = await validate(dto);
17
+ expect(errors).toEqual([]);
18
+ });
19
+
20
+ it('rechaza reason fuera del enum', async () => {
21
+ const dto = plainToInstance(AuthorizeResponse, { allow: false, reason: 'WHATEVER' });
22
+ const errors = await validate(dto);
23
+ expect(errors.some(e => e.property === 'reason')).toBe(true);
24
+ });
25
+ });
@@ -0,0 +1,7 @@
1
+ /** Input del POST /auth/introspect: token + datos del pool (el connector es stateless). */
2
+ export declare class IntrospectRequest {
3
+ token: string;
4
+ userPoolId: string;
5
+ region: string;
6
+ clientId: string;
7
+ }
@@ -0,0 +1,42 @@
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.IntrospectRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ /** Input del POST /auth/introspect: token + datos del pool (el connector es stateless). */
16
+ class IntrospectRequest {
17
+ }
18
+ exports.IntrospectRequest = IntrospectRequest;
19
+ __decorate([
20
+ (0, class_transformer_1.Expose)(),
21
+ (0, class_validator_1.IsString)(),
22
+ (0, class_validator_1.IsNotEmpty)(),
23
+ __metadata("design:type", String)
24
+ ], IntrospectRequest.prototype, "token", void 0);
25
+ __decorate([
26
+ (0, class_transformer_1.Expose)(),
27
+ (0, class_validator_1.IsString)(),
28
+ (0, class_validator_1.IsNotEmpty)(),
29
+ __metadata("design:type", String)
30
+ ], IntrospectRequest.prototype, "userPoolId", void 0);
31
+ __decorate([
32
+ (0, class_transformer_1.Expose)(),
33
+ (0, class_validator_1.IsString)(),
34
+ (0, class_validator_1.IsNotEmpty)(),
35
+ __metadata("design:type", String)
36
+ ], IntrospectRequest.prototype, "region", void 0);
37
+ __decorate([
38
+ (0, class_transformer_1.Expose)(),
39
+ (0, class_validator_1.IsString)(),
40
+ (0, class_validator_1.IsNotEmpty)(),
41
+ __metadata("design:type", String)
42
+ ], IntrospectRequest.prototype, "clientId", void 0);
@@ -0,0 +1,7 @@
1
+ import { IntrospectFailReason } from '../enums/IntrospectFailReason';
2
+ /** Output del POST /auth/introspect: validez + identidad (sub) o reason del fallo. */
3
+ export declare class IntrospectResponse {
4
+ valid: boolean;
5
+ cognitoSub?: string;
6
+ reason?: IntrospectFailReason;
7
+ }
@@ -0,0 +1,36 @@
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.IntrospectResponse = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const IntrospectFailReason_1 = require("../enums/IntrospectFailReason");
16
+ /** Output del POST /auth/introspect: validez + identidad (sub) o reason del fallo. */
17
+ class IntrospectResponse {
18
+ }
19
+ exports.IntrospectResponse = IntrospectResponse;
20
+ __decorate([
21
+ (0, class_transformer_1.Expose)(),
22
+ (0, class_validator_1.IsBoolean)(),
23
+ __metadata("design:type", Boolean)
24
+ ], IntrospectResponse.prototype, "valid", void 0);
25
+ __decorate([
26
+ (0, class_transformer_1.Expose)(),
27
+ (0, class_validator_1.IsOptional)(),
28
+ (0, class_validator_1.IsString)(),
29
+ __metadata("design:type", String)
30
+ ], IntrospectResponse.prototype, "cognitoSub", void 0);
31
+ __decorate([
32
+ (0, class_transformer_1.Expose)(),
33
+ (0, class_validator_1.IsOptional)(),
34
+ (0, class_validator_1.IsEnum)(IntrospectFailReason_1.IntrospectFailReason),
35
+ __metadata("design:type", String)
36
+ ], IntrospectResponse.prototype, "reason", void 0);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Razón de fallo del POST /auth/introspect del cognito-backoffice-connector.
3
+ */
4
+ export declare enum IntrospectFailReason {
5
+ INVALID_SIGNATURE = "INVALID_SIGNATURE",
6
+ EXPIRED = "EXPIRED",
7
+ CLIENT_ID_MISMATCH = "CLIENT_ID_MISMATCH",
8
+ TOKEN_USE_MISMATCH = "TOKEN_USE_MISMATCH",
9
+ REVOKED = "REVOKED",
10
+ USER_NOT_FOUND = "USER_NOT_FOUND"
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntrospectFailReason = void 0;
4
+ /**
5
+ * Razón de fallo del POST /auth/introspect del cognito-backoffice-connector.
6
+ */
7
+ var IntrospectFailReason;
8
+ (function (IntrospectFailReason) {
9
+ IntrospectFailReason["INVALID_SIGNATURE"] = "INVALID_SIGNATURE";
10
+ IntrospectFailReason["EXPIRED"] = "EXPIRED";
11
+ IntrospectFailReason["CLIENT_ID_MISMATCH"] = "CLIENT_ID_MISMATCH";
12
+ IntrospectFailReason["TOKEN_USE_MISMATCH"] = "TOKEN_USE_MISMATCH";
13
+ IntrospectFailReason["REVOKED"] = "REVOKED";
14
+ IntrospectFailReason["USER_NOT_FOUND"] = "USER_NOT_FOUND";
15
+ })(IntrospectFailReason || (exports.IntrospectFailReason = IntrospectFailReason = {}));
@@ -50,3 +50,6 @@ export * from './dtos/AppClientConfig';
50
50
  export * from './dtos/CreatePoolRequest';
51
51
  export * from './dtos/CreatePoolResponse';
52
52
  export * from './dtos/DeletePoolRequest';
53
+ export * from './enums/IntrospectFailReason';
54
+ export * from './dtos/IntrospectRequest';
55
+ export * from './dtos/IntrospectResponse';
@@ -66,3 +66,7 @@ __exportStar(require("./dtos/AppClientConfig"), exports);
66
66
  __exportStar(require("./dtos/CreatePoolRequest"), exports);
67
67
  __exportStar(require("./dtos/CreatePoolResponse"), exports);
68
68
  __exportStar(require("./dtos/DeletePoolRequest"), exports);
69
+ // Introspección de token (POST /auth/introspect) — consumido por el platform-rbac-business.
70
+ __exportStar(require("./enums/IntrospectFailReason"), exports);
71
+ __exportStar(require("./dtos/IntrospectRequest"), exports);
72
+ __exportStar(require("./dtos/IntrospectResponse"), exports);
@@ -0,0 +1,11 @@
1
+ import { PermissionScope } from '../enums/PermissionScope';
2
+ /**
3
+ * Input del POST /internal/authorize. El decorador @RequirePermission lo construye:
4
+ * token (del cookie session), permission requerida, y scope+scopeRef opcionales.
5
+ */
6
+ export declare class AuthorizeRequest {
7
+ token: string;
8
+ permission: string;
9
+ scope?: PermissionScope;
10
+ scopeRef?: string;
11
+ }
@@ -0,0 +1,46 @@
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.AuthorizeRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const PermissionScope_1 = require("../enums/PermissionScope");
16
+ /**
17
+ * Input del POST /internal/authorize. El decorador @RequirePermission lo construye:
18
+ * token (del cookie session), permission requerida, y scope+scopeRef opcionales.
19
+ */
20
+ class AuthorizeRequest {
21
+ }
22
+ exports.AuthorizeRequest = AuthorizeRequest;
23
+ __decorate([
24
+ (0, class_transformer_1.Expose)(),
25
+ (0, class_validator_1.IsString)(),
26
+ (0, class_validator_1.IsNotEmpty)(),
27
+ __metadata("design:type", String)
28
+ ], AuthorizeRequest.prototype, "token", void 0);
29
+ __decorate([
30
+ (0, class_transformer_1.Expose)(),
31
+ (0, class_validator_1.IsString)(),
32
+ (0, class_validator_1.IsNotEmpty)(),
33
+ __metadata("design:type", String)
34
+ ], AuthorizeRequest.prototype, "permission", void 0);
35
+ __decorate([
36
+ (0, class_transformer_1.Expose)(),
37
+ (0, class_validator_1.IsOptional)(),
38
+ (0, class_validator_1.IsEnum)(PermissionScope_1.PermissionScope),
39
+ __metadata("design:type", String)
40
+ ], AuthorizeRequest.prototype, "scope", void 0);
41
+ __decorate([
42
+ (0, class_transformer_1.Expose)(),
43
+ (0, class_validator_1.IsOptional)(),
44
+ (0, class_validator_1.IsString)(),
45
+ __metadata("design:type", String)
46
+ ], AuthorizeRequest.prototype, "scopeRef", void 0);
@@ -0,0 +1,13 @@
1
+ import { AuthorizeDenyReason } from '../enums/AuthorizeDenyReason';
2
+ import type { AuthContext } from './AuthContext';
3
+ /**
4
+ * Output del POST /internal/authorize. Si allow=true trae el context resuelto
5
+ * (para que el decorador lo populé en el request). Si allow=false trae el reason.
6
+ * `context` es solo contrato TS de salida (AuthContext es interface, no clase) → SIN @Expose,
7
+ * es passthrough; los responses no se validan (fiado-validation-and-dtos § 7).
8
+ */
9
+ export declare class AuthorizeResponse {
10
+ allow: boolean;
11
+ reason?: AuthorizeDenyReason;
12
+ context?: AuthContext;
13
+ }
@@ -0,0 +1,35 @@
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.AuthorizeResponse = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const AuthorizeDenyReason_1 = require("../enums/AuthorizeDenyReason");
16
+ /**
17
+ * Output del POST /internal/authorize. Si allow=true trae el context resuelto
18
+ * (para que el decorador lo populé en el request). Si allow=false trae el reason.
19
+ * `context` es solo contrato TS de salida (AuthContext es interface, no clase) → SIN @Expose,
20
+ * es passthrough; los responses no se validan (fiado-validation-and-dtos § 7).
21
+ */
22
+ class AuthorizeResponse {
23
+ }
24
+ exports.AuthorizeResponse = AuthorizeResponse;
25
+ __decorate([
26
+ (0, class_transformer_1.Expose)(),
27
+ (0, class_validator_1.IsBoolean)(),
28
+ __metadata("design:type", Boolean)
29
+ ], AuthorizeResponse.prototype, "allow", void 0);
30
+ __decorate([
31
+ (0, class_transformer_1.Expose)(),
32
+ (0, class_validator_1.IsOptional)(),
33
+ (0, class_validator_1.IsEnum)(AuthorizeDenyReason_1.AuthorizeDenyReason),
34
+ __metadata("design:type", String)
35
+ ], AuthorizeResponse.prototype, "reason", void 0);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Razón de denegación del endpoint POST /internal/authorize del platform-rbac-business.
3
+ * Consumido por el decorador @RequirePermission del @fiado/gateway-adapter.
4
+ */
5
+ export declare enum AuthorizeDenyReason {
6
+ INVALID_TOKEN = "INVALID_TOKEN",
7
+ NO_PERMISSION = "NO_PERMISSION",
8
+ SCOPE_DENIED = "SCOPE_DENIED",
9
+ USER_NOT_FOUND = "USER_NOT_FOUND"
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizeDenyReason = void 0;
4
+ /**
5
+ * Razón de denegación del endpoint POST /internal/authorize del platform-rbac-business.
6
+ * Consumido por el decorador @RequirePermission del @fiado/gateway-adapter.
7
+ */
8
+ var AuthorizeDenyReason;
9
+ (function (AuthorizeDenyReason) {
10
+ AuthorizeDenyReason["INVALID_TOKEN"] = "INVALID_TOKEN";
11
+ AuthorizeDenyReason["NO_PERMISSION"] = "NO_PERMISSION";
12
+ AuthorizeDenyReason["SCOPE_DENIED"] = "SCOPE_DENIED";
13
+ AuthorizeDenyReason["USER_NOT_FOUND"] = "USER_NOT_FOUND";
14
+ })(AuthorizeDenyReason || (exports.AuthorizeDenyReason = AuthorizeDenyReason = {}));
@@ -18,3 +18,6 @@ export * from './mfa/EnrollTotpResponse';
18
18
  export * from './mfa/VerifyTotpEnrollmentRequest';
19
19
  export * from './mfa/ChangeMfaMethodRequest';
20
20
  export * from './mfa/MfaStatusResponse';
21
+ export { AuthorizeDenyReason } from './enums/AuthorizeDenyReason';
22
+ export * from './dtos/AuthorizeRequest';
23
+ export * from './dtos/AuthorizeResponse';
@@ -23,7 +23,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
23
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.PermissionCategory = exports.PermissionScope = exports.Permission = void 0;
26
+ exports.AuthorizeDenyReason = exports.PermissionCategory = exports.PermissionScope = exports.Permission = void 0;
27
27
  var Permission_1 = require("./enums/Permission");
28
28
  Object.defineProperty(exports, "Permission", { enumerable: true, get: function () { return Permission_1.Permission; } });
29
29
  var PermissionScope_1 = require("./enums/PermissionScope");
@@ -46,3 +46,8 @@ __exportStar(require("./mfa/EnrollTotpResponse"), exports);
46
46
  __exportStar(require("./mfa/VerifyTotpEnrollmentRequest"), exports);
47
47
  __exportStar(require("./mfa/ChangeMfaMethodRequest"), exports);
48
48
  __exportStar(require("./mfa/MfaStatusResponse"), exports);
49
+ // RBAC enforcement (capa de protección) — DTOs del POST /internal/authorize.
50
+ var AuthorizeDenyReason_1 = require("./enums/AuthorizeDenyReason");
51
+ Object.defineProperty(exports, "AuthorizeDenyReason", { enumerable: true, get: function () { return AuthorizeDenyReason_1.AuthorizeDenyReason; } });
52
+ __exportStar(require("./dtos/AuthorizeRequest"), exports);
53
+ __exportStar(require("./dtos/AuthorizeResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.47.0",
3
+ "version": "3.48.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -0,0 +1,10 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsNotEmpty, IsString } from 'class-validator';
3
+
4
+ /** Input del POST /auth/introspect: token + datos del pool (el connector es stateless). */
5
+ export class IntrospectRequest {
6
+ @Expose() @IsString() @IsNotEmpty() token!: string;
7
+ @Expose() @IsString() @IsNotEmpty() userPoolId!: string;
8
+ @Expose() @IsString() @IsNotEmpty() region!: string;
9
+ @Expose() @IsString() @IsNotEmpty() clientId!: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsBoolean, IsEnum, IsOptional, IsString } from 'class-validator';
3
+ import { IntrospectFailReason } from '../enums/IntrospectFailReason';
4
+
5
+ /** Output del POST /auth/introspect: validez + identidad (sub) o reason del fallo. */
6
+ export class IntrospectResponse {
7
+ @Expose() @IsBoolean() valid!: boolean;
8
+ @Expose() @IsOptional() @IsString() cognitoSub?: string;
9
+ @Expose() @IsOptional() @IsEnum(IntrospectFailReason) reason?: IntrospectFailReason;
10
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Razón de fallo del POST /auth/introspect del cognito-backoffice-connector.
3
+ */
4
+ export enum IntrospectFailReason {
5
+ INVALID_SIGNATURE = 'INVALID_SIGNATURE',
6
+ EXPIRED = 'EXPIRED',
7
+ CLIENT_ID_MISMATCH = 'CLIENT_ID_MISMATCH',
8
+ TOKEN_USE_MISMATCH = 'TOKEN_USE_MISMATCH',
9
+ REVOKED = 'REVOKED',
10
+ USER_NOT_FOUND = 'USER_NOT_FOUND',
11
+ }
@@ -50,3 +50,8 @@ export * from './dtos/AppClientConfig';
50
50
  export * from './dtos/CreatePoolRequest';
51
51
  export * from './dtos/CreatePoolResponse';
52
52
  export * from './dtos/DeletePoolRequest';
53
+
54
+ // Introspección de token (POST /auth/introspect) — consumido por el platform-rbac-business.
55
+ export * from './enums/IntrospectFailReason';
56
+ export * from './dtos/IntrospectRequest';
57
+ export * from './dtos/IntrospectResponse';
@@ -0,0 +1,14 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
3
+ import { PermissionScope } from '../enums/PermissionScope';
4
+
5
+ /**
6
+ * Input del POST /internal/authorize. El decorador @RequirePermission lo construye:
7
+ * token (del cookie session), permission requerida, y scope+scopeRef opcionales.
8
+ */
9
+ export class AuthorizeRequest {
10
+ @Expose() @IsString() @IsNotEmpty() token!: string;
11
+ @Expose() @IsString() @IsNotEmpty() permission!: string;
12
+ @Expose() @IsOptional() @IsEnum(PermissionScope) scope?: PermissionScope;
13
+ @Expose() @IsOptional() @IsString() scopeRef?: string;
14
+ }
@@ -0,0 +1,16 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsBoolean, IsEnum, IsOptional } from 'class-validator';
3
+ import { AuthorizeDenyReason } from '../enums/AuthorizeDenyReason';
4
+ import type { AuthContext } from './AuthContext';
5
+
6
+ /**
7
+ * Output del POST /internal/authorize. Si allow=true trae el context resuelto
8
+ * (para que el decorador lo populé en el request). Si allow=false trae el reason.
9
+ * `context` es solo contrato TS de salida (AuthContext es interface, no clase) → SIN @Expose,
10
+ * es passthrough; los responses no se validan (fiado-validation-and-dtos § 7).
11
+ */
12
+ export class AuthorizeResponse {
13
+ @Expose() @IsBoolean() allow!: boolean;
14
+ @Expose() @IsOptional() @IsEnum(AuthorizeDenyReason) reason?: AuthorizeDenyReason;
15
+ context?: AuthContext;
16
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Razón de denegación del endpoint POST /internal/authorize del platform-rbac-business.
3
+ * Consumido por el decorador @RequirePermission del @fiado/gateway-adapter.
4
+ */
5
+ export enum AuthorizeDenyReason {
6
+ INVALID_TOKEN = 'INVALID_TOKEN',
7
+ NO_PERMISSION = 'NO_PERMISSION',
8
+ SCOPE_DENIED = 'SCOPE_DENIED',
9
+ USER_NOT_FOUND = 'USER_NOT_FOUND',
10
+ }
@@ -32,3 +32,8 @@ export * from './mfa/EnrollTotpResponse';
32
32
  export * from './mfa/VerifyTotpEnrollmentRequest';
33
33
  export * from './mfa/ChangeMfaMethodRequest';
34
34
  export * from './mfa/MfaStatusResponse';
35
+
36
+ // RBAC enforcement (capa de protección) — DTOs del POST /internal/authorize.
37
+ export { AuthorizeDenyReason } from './enums/AuthorizeDenyReason';
38
+ export * from './dtos/AuthorizeRequest';
39
+ export * from './dtos/AuthorizeResponse';