@discover-cloud/shared 1.2.9 → 1.4.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.
- package/dist/authorization/index.d.ts +2 -2
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/permission-cache.service.d.ts +104 -16
- package/dist/authorization/permission-cache.service.js +177 -148
- package/dist/authorization/permission-checker.d.ts +30 -0
- package/dist/authorization/permission-checker.js +40 -0
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/request-context.storage.d.ts +21 -0
- package/dist/context/request-context.storage.js +37 -0
- package/dist/contracts/auth-service/account.dto.d.ts +30 -0
- package/dist/contracts/auth-service/account.dto.js +7 -0
- package/dist/contracts/auth-service/auth.dto.d.ts +21 -0
- package/dist/contracts/auth-service/auth.dto.js +10 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/{security → contracts}/index.js +1 -1
- package/dist/contracts/visibility.d.ts +63 -0
- package/dist/contracts/visibility.js +10 -0
- package/dist/dtos/audit-service.types.d.ts +42 -0
- package/dist/dtos/audit-service.types.js +31 -0
- package/dist/dtos/auth-service.dto.d.ts +87 -26
- package/dist/dtos/auth-service.dto.js +4 -0
- package/dist/dtos/cloud-service.dto.d.ts +57 -27
- package/dist/dtos/cloud-service.dto.js +5 -0
- package/dist/dtos/index.d.ts +6 -5
- package/dist/dtos/index.js +1 -0
- package/dist/dtos/insights-service.dto.d.ts +184 -32
- package/dist/dtos/insights-service.dto.js +8 -0
- package/dist/dtos/response.dto.d.ts +12 -83
- package/dist/dtos/response.dto.js +2 -21
- package/dist/dtos/user-service.dto.d.ts +163 -13
- package/dist/enums/domain.enums.d.ts +272 -75
- package/dist/enums/domain.enums.js +329 -102
- package/dist/enums/index.d.ts +2 -2
- package/dist/enums/permissions.enums.d.ts +142 -80
- package/dist/enums/permissions.enums.js +174 -133
- package/dist/errors/app-error.d.ts +13 -18
- package/dist/errors/app-error.js +15 -21
- package/dist/errors/http-errors.d.ts +106 -18
- package/dist/errors/http-errors.js +136 -51
- package/dist/errors/index.d.ts +2 -2
- package/dist/http/index.d.ts +2 -1
- package/dist/http/index.js +1 -0
- package/dist/http/request-context.d.ts +8 -0
- package/dist/http/request-context.js +37 -0
- package/dist/http/service-client.d.ts +93 -40
- package/dist/http/service-client.js +104 -55
- package/dist/index.d.ts +11 -9
- package/dist/index.js +2 -0
- package/dist/jwt/index.d.ts +3 -2
- package/dist/jwt/index.js +2 -1
- package/dist/jwt/machine-jwt-verifier.d.ts +21 -0
- package/dist/jwt/machine-jwt-verifier.js +83 -0
- package/dist/jwt/machine-token-client.d.ts +36 -5
- package/dist/jwt/machine-token-client.js +61 -27
- package/dist/jwt/user-jwt-verifier.d.ts +31 -0
- package/dist/jwt/user-jwt-verifier.js +102 -0
- package/dist/messaging/audit.publisher.d.ts +14 -0
- package/dist/messaging/audit.publisher.js +49 -0
- package/dist/messaging/index.d.ts +2 -0
- package/dist/{dto → messaging}/index.js +2 -3
- package/dist/messaging/rabbitmq.client.d.ts +15 -0
- package/dist/messaging/rabbitmq.client.js +133 -0
- package/dist/middleware/error-handler.middleware.d.ts +8 -28
- package/dist/middleware/error-handler.middleware.js +63 -54
- package/dist/middleware/index.d.ts +10 -8
- package/dist/middleware/index.js +7 -5
- package/dist/middleware/request-context.middleware.d.ts +6 -0
- package/dist/middleware/request-context.middleware.js +48 -0
- package/dist/middleware/require-auth.middleware.d.ts +7 -76
- package/dist/middleware/require-auth.middleware.js +29 -117
- package/dist/middleware/require-machine.middleware.d.ts +13 -0
- package/dist/middleware/require-machine.middleware.js +128 -0
- package/dist/middleware/require-org-permission-from-body.middleware.d.ts +10 -0
- package/dist/middleware/require-org-permission-from-body.middleware.js +23 -0
- package/dist/middleware/require-org-permission.middleware.d.ts +19 -0
- package/dist/middleware/require-org-permission.middleware.js +115 -0
- package/dist/middleware/require-platform-permission.middleware.d.ts +19 -0
- package/dist/middleware/require-platform-permission.middleware.js +91 -0
- package/dist/middleware/require-user.middleware.d.ts +14 -0
- package/dist/middleware/require-user.middleware.js +30 -0
- package/dist/middleware/require-workspace-permission.middleware.d.ts +20 -0
- package/dist/middleware/require-workspace-permission.middleware.js +114 -0
- package/dist/middleware/validate.middleware.d.ts +31 -31
- package/dist/middleware/validate.middleware.js +31 -33
- package/dist/types/audit.types.d.ts +39 -0
- package/dist/types/audit.types.js +30 -0
- package/dist/types/express.types.d.ts +92 -124
- package/dist/types/express.types.js +30 -49
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/date.util.d.ts +6 -0
- package/dist/utils/date.util.js +11 -0
- package/dist/utils/env.util.d.ts +6 -0
- package/dist/utils/env.util.js +19 -0
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +5 -4
- package/dist/utils/logger.util.d.ts +31 -0
- package/dist/utils/logger.util.js +91 -0
- package/dist/utils/pagination.util.d.ts +6 -0
- package/dist/utils/pagination.util.js +20 -0
- package/dist/utils/request-context.als.d.ts +10 -0
- package/dist/utils/request-context.als.js +5 -0
- package/dist/utils/response.util.d.ts +27 -0
- package/dist/utils/response.util.js +56 -0
- package/dist/utils/slug.util.d.ts +9 -0
- package/dist/utils/slug.util.js +32 -0
- package/dist/utils/url-safety.util.d.ts +6 -0
- package/dist/utils/url-safety.util.js +75 -0
- package/package.json +3 -1
- package/dist/authorization/permissions.d.ts +0 -78
- package/dist/authorization/permissions.js +0 -174
- package/dist/context/access-context.d.ts +0 -10
- package/dist/context/access-context.js +0 -2
- package/dist/dto/auth-service.dtos.d.ts +0 -44
- package/dist/dto/auth-service.dtos.js +0 -2
- package/dist/dto/index.d.ts +0 -3
- package/dist/dto/response.dtos.d.ts +0 -55
- package/dist/dto/response.dtos.js +0 -6
- package/dist/dto/user-service.dtos.d.ts +0 -50
- package/dist/dto/user-service.dtos.js +0 -2
- package/dist/enums/auth-service.enums.d.ts +0 -12
- package/dist/enums/auth-service.enums.js +0 -17
- package/dist/enums/permissions.types.d.ts +0 -12
- package/dist/enums/permissions.types.js +0 -17
- package/dist/enums/user-service.enums.d.ts +0 -32
- package/dist/enums/user-service.enums.js +0 -41
- package/dist/internal/index.d.ts +0 -4
- package/dist/internal/index.js +0 -20
- package/dist/internal/internal-jwt.service.d.ts +0 -13
- package/dist/internal/internal-jwt.service.js +0 -88
- package/dist/internal/internal-jwt.types.d.ts +0 -7
- package/dist/internal/internal-jwt.types.js +0 -2
- package/dist/internal/internal-key-manager.d.ts +0 -16
- package/dist/internal/internal-key-manager.js +0 -67
- package/dist/internal/registry.d.ts +0 -8
- package/dist/internal/registry.js +0 -34
- package/dist/internal/service-client.d.ts +0 -9
- package/dist/internal/service-client.js +0 -94
- package/dist/jwt/internal-jwt-verifier.d.ts +0 -41
- package/dist/jwt/internal-jwt-verifier.js +0 -185
- package/dist/jwt/jwt-verifier.d.ts +0 -9
- package/dist/jwt/jwt-verifier.js +0 -36
- package/dist/jwt/service-client.d.ts +0 -7
- package/dist/jwt/service-client.js +0 -87
- package/dist/middleware/authorize.d.ts +0 -3
- package/dist/middleware/authorize.js +0 -24
- package/dist/middleware/authorize.middleware.d.ts +0 -54
- package/dist/middleware/authorize.middleware.js +0 -104
- package/dist/middleware/error-handler.d.ts +0 -4
- package/dist/middleware/error-handler.js +0 -23
- package/dist/middleware/request-id.d.ts +0 -2
- package/dist/middleware/request-id.js +0 -9
- package/dist/middleware/request-id.middleware.d.ts +0 -22
- package/dist/middleware/request-id.middleware.js +0 -34
- package/dist/middleware/require-auth.d.ts +0 -10
- package/dist/middleware/require-auth.js +0 -34
- package/dist/middleware/require-human.middleware.d.ts +0 -2
- package/dist/middleware/require-human.middleware.js +0 -18
- package/dist/middleware/require-internal.middleware.d.ts +0 -18
- package/dist/middleware/require-internal.middleware.js +0 -183
- package/dist/middleware/validate.d.ts +0 -5
- package/dist/middleware/validate.js +0 -18
- package/dist/middleware/validated-merge.middleware.d.ts +0 -20
- package/dist/middleware/validated-merge.middleware.js +0 -33
- package/dist/middleware/verify-internal-jwt.d.ts +0 -7
- package/dist/middleware/verify-internal-jwt.js +0 -25
- package/dist/security/guard.d.ts +0 -10
- package/dist/security/guard.js +0 -40
- package/dist/security/index.d.ts +0 -1
- package/dist/types/express.d.ts +0 -22
- package/dist/types/express.js +0 -3
- package/dist/utils/date.utils.d.ts +0 -25
- package/dist/utils/date.utils.js +0 -30
- package/dist/utils/env.d.ts +0 -46
- package/dist/utils/env.js +0 -61
- package/dist/utils/env.utils.d.ts +0 -46
- package/dist/utils/env.utils.js +0 -61
- package/dist/utils/logger.utils.d.ts +0 -66
- package/dist/utils/logger.utils.js +0 -97
- package/dist/utils/response.d.ts +0 -4
- package/dist/utils/response.js +0 -35
- package/dist/utils/response.utils.d.ts +0 -54
- package/dist/utils/response.utils.js +0 -85
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestContextProvider = exports.requestContextStorage = void 0;
|
|
4
|
+
const async_hooks_1 = require("async_hooks");
|
|
5
|
+
exports.requestContextStorage = new async_hooks_1.AsyncLocalStorage();
|
|
6
|
+
class RequestContextProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the current context if it exists.
|
|
9
|
+
*/
|
|
10
|
+
static get() {
|
|
11
|
+
return exports.requestContextStorage.getStore();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves the current context or throws an error.
|
|
15
|
+
* Use this in deeper repositories where context is strictly required.
|
|
16
|
+
*/
|
|
17
|
+
static getOrThrow() {
|
|
18
|
+
const ctx = exports.requestContextStorage.getStore();
|
|
19
|
+
if (!ctx) {
|
|
20
|
+
throw new Error('AuditRequestContext is missing. Ensure the context middleware is active.');
|
|
21
|
+
}
|
|
22
|
+
return ctx;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Attaches the authenticated actor to the current request context.
|
|
26
|
+
*/
|
|
27
|
+
static setActor(actor) {
|
|
28
|
+
const ctx = exports.requestContextStorage.getStore();
|
|
29
|
+
if (!ctx) {
|
|
30
|
+
// Fail-fast: If we reach the authentication layer but have no context,
|
|
31
|
+
// the middleware pipeline is fundamentally broken.
|
|
32
|
+
throw new Error('Cannot set actor: AuditRequestContext is not initialized.');
|
|
33
|
+
}
|
|
34
|
+
ctx.actor = actor;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.RequestContextProvider = RequestContextProvider;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file account.dto.ts
|
|
3
|
+
* @description Data transfer objects (DTOs) for account management resources.
|
|
4
|
+
* Public DTOs never expose credentials, hashes, or encrypted secrets.
|
|
5
|
+
*/
|
|
6
|
+
import { AccountStatus } from '../../enums';
|
|
7
|
+
/** Public account representation. */
|
|
8
|
+
export interface AccountDto {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
isVerified: boolean;
|
|
12
|
+
status: AccountStatus;
|
|
13
|
+
lastLoginAt: string | null;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}
|
|
17
|
+
/** OAuth provider identity metadata. */
|
|
18
|
+
export interface OAuthIdentityDto {
|
|
19
|
+
id: string;
|
|
20
|
+
accountId: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
providerId: string;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
}
|
|
26
|
+
/** Standard action tracking and confirmation signature message payload. */
|
|
27
|
+
export interface ActionResponseDto {
|
|
28
|
+
action: string;
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file auth.dto.ts
|
|
3
|
+
* @description Data transfer objects (DTOs) for authentication resources.
|
|
4
|
+
* Public DTOs never expose credentials, hashes, or encrypted secrets.
|
|
5
|
+
*
|
|
6
|
+
* Refresh tokens are never returned in the public HTTP body.
|
|
7
|
+
* They are transported securely using HttpOnly cookies.
|
|
8
|
+
*/
|
|
9
|
+
/** Tokens returned upon successful authentication. */
|
|
10
|
+
export interface AuthTokenDto {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
}
|
|
13
|
+
/** Internal auth-service resolution block mapping backend tokens to transport layers. */
|
|
14
|
+
export interface AuthSessionResultDto {
|
|
15
|
+
accessToken: string;
|
|
16
|
+
refreshToken: string;
|
|
17
|
+
}
|
|
18
|
+
/** Generic message response payload contract. */
|
|
19
|
+
export interface MessageResponseDto {
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file auth.dto.ts
|
|
4
|
+
* @description Data transfer objects (DTOs) for authentication resources.
|
|
5
|
+
* Public DTOs never expose credentials, hashes, or encrypted secrets.
|
|
6
|
+
*
|
|
7
|
+
* Refresh tokens are never returned in the public HTTP body.
|
|
8
|
+
* They are transported securely using HttpOnly cookies.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './visibility';
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./visibility"), exports);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file visibility.ts
|
|
3
|
+
* @description Shared contracts for the Workspace-Centric Visibility Architecture.
|
|
4
|
+
*
|
|
5
|
+
* These are pure type definitions with no business logic.
|
|
6
|
+
* The VisibilityResolver lives in User Service behind the internal Visibility API.
|
|
7
|
+
* Insights Service repositories consume ResourceQueryScope, never VisibilityContext directly.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Defines the resource-level filters that narrow which cloud resources
|
|
11
|
+
* belong to a workspace beyond just cloud account membership.
|
|
12
|
+
*
|
|
13
|
+
* All fields are optional — a null/empty ResourceFilter means no additional
|
|
14
|
+
* narrowing beyond cloud account membership.
|
|
15
|
+
*/
|
|
16
|
+
export interface ResourceFilter {
|
|
17
|
+
/** Match resources with these exact tag key-value pairs. */
|
|
18
|
+
tags?: Record<string, string>;
|
|
19
|
+
/** Restrict to these resource groups (Azure-specific). */
|
|
20
|
+
resourceGroups?: string[];
|
|
21
|
+
/** Restrict to these cloud provider regions. */
|
|
22
|
+
regions?: string[];
|
|
23
|
+
/** Restrict to these cloud service types (e.g. 'ec2', 's3', 'lambda'). */
|
|
24
|
+
services?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The resolved visibility boundary for a workspace.
|
|
28
|
+
* Produced by the User Service VisibilityResolver and returned by
|
|
29
|
+
* GET /internal/v1/workspaces/{workspaceId}/visibility.
|
|
30
|
+
*
|
|
31
|
+
* Must not be passed directly to repositories — application services
|
|
32
|
+
* must first map it to a ResourceQueryScope.
|
|
33
|
+
*/
|
|
34
|
+
export interface VisibilityContext {
|
|
35
|
+
/** The workspace this context belongs to. */
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
/**
|
|
38
|
+
* Monotonically increasing version, incremented whenever
|
|
39
|
+
* WorkspaceCloudAccounts or resourceFilter changes.
|
|
40
|
+
* Used for cache validation.
|
|
41
|
+
*/
|
|
42
|
+
version: number;
|
|
43
|
+
/** IDs of all cloud accounts this workspace is allowed to access. */
|
|
44
|
+
cloudAccountIds: string[];
|
|
45
|
+
/** Additional resource-level narrowing applied on top of account membership. */
|
|
46
|
+
resourceFilter: ResourceFilter;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Repository-specific query object derived from VisibilityContext.
|
|
50
|
+
* Application services transform VisibilityContext → ResourceQueryScope
|
|
51
|
+
* before passing it to repositories.
|
|
52
|
+
*
|
|
53
|
+
* Repositories must never receive VisibilityContext or call HTTP APIs.
|
|
54
|
+
* They only consume this scope object.
|
|
55
|
+
*/
|
|
56
|
+
export interface ResourceQueryScope {
|
|
57
|
+
/** The workspace whose data is being queried. */
|
|
58
|
+
workspaceId: string;
|
|
59
|
+
/** Cloud accounts whose data is visible in this scope. */
|
|
60
|
+
cloudAccountIds: string[];
|
|
61
|
+
/** Resource-level filter predicates. */
|
|
62
|
+
resourceFilter: ResourceFilter;
|
|
63
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file visibility.ts
|
|
4
|
+
* @description Shared contracts for the Workspace-Centric Visibility Architecture.
|
|
5
|
+
*
|
|
6
|
+
* These are pure type definitions with no business logic.
|
|
7
|
+
* The VisibilityResolver lives in User Service behind the internal Visibility API.
|
|
8
|
+
* Insights Service repositories consume ResourceQueryScope, never VisibilityContext directly.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare enum AuditActorType {
|
|
2
|
+
USER = "USER",
|
|
3
|
+
SERVICE = "SERVICE",
|
|
4
|
+
SYSTEM = "SYSTEM",
|
|
5
|
+
ANONYMOUS = "ANONYMOUS"
|
|
6
|
+
}
|
|
7
|
+
export declare enum AuditResourceType {
|
|
8
|
+
ACCOUNT = "ACCOUNT",
|
|
9
|
+
USER = "USER",
|
|
10
|
+
ORGANIZATION = "ORGANIZATION",
|
|
11
|
+
WORKSPACE = "WORKSPACE",
|
|
12
|
+
ROLE = "ROLE",
|
|
13
|
+
PERMISSION = "PERMISSION",
|
|
14
|
+
SERVICE_CLIENT = "SERVICE_CLIENT",
|
|
15
|
+
ALERT_RULE = "ALERT_RULE",
|
|
16
|
+
CLOUD_ACCOUNT = "CLOUD_ACCOUNT",
|
|
17
|
+
SYNC_JOB = "SYNC_JOB",
|
|
18
|
+
SYSTEM = "SYSTEM"
|
|
19
|
+
}
|
|
20
|
+
export declare enum AuditSeverity {
|
|
21
|
+
INFO = "info",
|
|
22
|
+
WARNING = "warning",
|
|
23
|
+
ERROR = "error",
|
|
24
|
+
CRITICAL = "critical"
|
|
25
|
+
}
|
|
26
|
+
export interface RecordAuditActionInput {
|
|
27
|
+
actorId?: string | null;
|
|
28
|
+
actorType?: AuditActorType;
|
|
29
|
+
action: string;
|
|
30
|
+
severity?: AuditSeverity;
|
|
31
|
+
resourceType: AuditResourceType;
|
|
32
|
+
resourceId?: string | null;
|
|
33
|
+
organizationId?: string | null;
|
|
34
|
+
workspaceId?: string | null;
|
|
35
|
+
/** For resources (like CloudAccount) owned by an org or personal workspace rather than a workspace directly. */
|
|
36
|
+
ownerId?: string | null;
|
|
37
|
+
ipAddress?: string | null;
|
|
38
|
+
userAgent?: string | null;
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
requestId?: string | null;
|
|
41
|
+
traceId?: string | null;
|
|
42
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditSeverity = exports.AuditResourceType = exports.AuditActorType = void 0;
|
|
4
|
+
var AuditActorType;
|
|
5
|
+
(function (AuditActorType) {
|
|
6
|
+
AuditActorType["USER"] = "USER";
|
|
7
|
+
AuditActorType["SERVICE"] = "SERVICE";
|
|
8
|
+
AuditActorType["SYSTEM"] = "SYSTEM";
|
|
9
|
+
AuditActorType["ANONYMOUS"] = "ANONYMOUS";
|
|
10
|
+
})(AuditActorType || (exports.AuditActorType = AuditActorType = {}));
|
|
11
|
+
var AuditResourceType;
|
|
12
|
+
(function (AuditResourceType) {
|
|
13
|
+
AuditResourceType["ACCOUNT"] = "ACCOUNT";
|
|
14
|
+
AuditResourceType["USER"] = "USER";
|
|
15
|
+
AuditResourceType["ORGANIZATION"] = "ORGANIZATION";
|
|
16
|
+
AuditResourceType["WORKSPACE"] = "WORKSPACE";
|
|
17
|
+
AuditResourceType["ROLE"] = "ROLE";
|
|
18
|
+
AuditResourceType["PERMISSION"] = "PERMISSION";
|
|
19
|
+
AuditResourceType["SERVICE_CLIENT"] = "SERVICE_CLIENT";
|
|
20
|
+
AuditResourceType["ALERT_RULE"] = "ALERT_RULE";
|
|
21
|
+
AuditResourceType["CLOUD_ACCOUNT"] = "CLOUD_ACCOUNT";
|
|
22
|
+
AuditResourceType["SYNC_JOB"] = "SYNC_JOB";
|
|
23
|
+
AuditResourceType["SYSTEM"] = "SYSTEM";
|
|
24
|
+
})(AuditResourceType || (exports.AuditResourceType = AuditResourceType = {}));
|
|
25
|
+
var AuditSeverity;
|
|
26
|
+
(function (AuditSeverity) {
|
|
27
|
+
AuditSeverity["INFO"] = "info";
|
|
28
|
+
AuditSeverity["WARNING"] = "warning";
|
|
29
|
+
AuditSeverity["ERROR"] = "error";
|
|
30
|
+
AuditSeverity["CRITICAL"] = "critical";
|
|
31
|
+
})(AuditSeverity || (exports.AuditSeverity = AuditSeverity = {}));
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
import { AccountStatus } from "../enums";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Internal data shapes produced by the auth service.
|
|
6
|
-
*
|
|
7
|
-
* SECURITY RULE: DTOs containing secrets (token, hash fields) must NEVER
|
|
8
|
-
* be returned directly in HTTP responses. They exist so internal service
|
|
9
|
-
* methods have typed return values — mappers are responsible for stripping
|
|
10
|
-
* secrets before anything reaches the wire.
|
|
11
|
-
*
|
|
12
|
-
* Secret fields are annotated with // SECRET — internal use only
|
|
13
|
-
* to make accidental exposure visible at a glance during code review.
|
|
2
|
+
* @file account.dto.ts
|
|
3
|
+
* @description Transport-safe DTOs for Account domain entities.
|
|
14
4
|
*/
|
|
15
5
|
export interface AccountDto {
|
|
16
6
|
id: string;
|
|
17
7
|
email: string;
|
|
18
8
|
isVerified: boolean;
|
|
19
|
-
status:
|
|
9
|
+
status: string;
|
|
10
|
+
mfaEnabled: boolean;
|
|
11
|
+
lastLoginAt: string | null;
|
|
20
12
|
createdAt: string;
|
|
21
13
|
updatedAt: string;
|
|
22
14
|
}
|
|
23
|
-
export interface
|
|
15
|
+
export interface SessionDto {
|
|
24
16
|
id: string;
|
|
25
17
|
accountId: string;
|
|
26
|
-
|
|
18
|
+
familyId: string;
|
|
19
|
+
ipAddress: string | null;
|
|
20
|
+
userAgent: string | null;
|
|
21
|
+
device: string | null;
|
|
27
22
|
expiresAt: string;
|
|
28
|
-
isUsed: boolean;
|
|
29
23
|
createdAt: string;
|
|
30
24
|
}
|
|
31
25
|
export interface OAuthIdentityDto {
|
|
@@ -34,24 +28,91 @@ export interface OAuthIdentityDto {
|
|
|
34
28
|
provider: string;
|
|
35
29
|
providerId: string;
|
|
36
30
|
createdAt: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ServiceClientDto {
|
|
33
|
+
id: string;
|
|
34
|
+
serviceId: string;
|
|
35
|
+
name: string;
|
|
36
|
+
scopes: string[];
|
|
37
|
+
status: string;
|
|
38
|
+
lastUsedAt: string | null;
|
|
39
|
+
rotatedAt: string | null;
|
|
40
|
+
expiresAt: string | null;
|
|
41
|
+
createdById: string | null;
|
|
42
|
+
createdAt: string;
|
|
37
43
|
updatedAt: string;
|
|
38
44
|
}
|
|
39
|
-
export interface
|
|
45
|
+
export interface PlatformPermissionDto {
|
|
40
46
|
id: string;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
key: string;
|
|
48
|
+
resource: string;
|
|
49
|
+
action: string;
|
|
50
|
+
category: string;
|
|
51
|
+
description: string | null;
|
|
52
|
+
serviceOwner: string | null;
|
|
53
|
+
dangerous: boolean;
|
|
45
54
|
createdAt: string;
|
|
46
55
|
}
|
|
47
|
-
export interface
|
|
56
|
+
export interface PlatformRoleDto {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: string;
|
|
60
|
+
category: string;
|
|
61
|
+
isProtected: boolean;
|
|
62
|
+
createdById: string | null;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
}
|
|
66
|
+
export interface PlatformRoleWithPermissionsDto extends PlatformRoleDto {
|
|
67
|
+
permissions: PlatformPermissionDto[];
|
|
68
|
+
}
|
|
69
|
+
export interface PlatformRoleAssignmentDto {
|
|
48
70
|
id: string;
|
|
49
71
|
accountId: string;
|
|
50
|
-
|
|
72
|
+
roleId: string;
|
|
73
|
+
status: string;
|
|
74
|
+
assignedById: string | null;
|
|
75
|
+
revokedById: string | null;
|
|
51
76
|
revokedAt: string | null;
|
|
52
|
-
|
|
53
|
-
userAgent: string | null;
|
|
54
|
-
device: string | null;
|
|
77
|
+
role?: PlatformRoleDto;
|
|
55
78
|
createdAt: string;
|
|
56
79
|
updatedAt: string;
|
|
57
80
|
}
|
|
81
|
+
export interface AuthTokensDto {
|
|
82
|
+
accessToken: string;
|
|
83
|
+
refreshToken: string;
|
|
84
|
+
expiresIn: number;
|
|
85
|
+
}
|
|
86
|
+
export interface LoginResponseDto {
|
|
87
|
+
tokens: AuthTokensDto;
|
|
88
|
+
account: AccountDto;
|
|
89
|
+
mfaRequired: false;
|
|
90
|
+
}
|
|
91
|
+
export interface MfaRequiredResponseDto {
|
|
92
|
+
mfaRequired: true;
|
|
93
|
+
mfaToken: string;
|
|
94
|
+
}
|
|
95
|
+
export type LoginOrMfaResponseDto = LoginResponseDto | MfaRequiredResponseDto;
|
|
96
|
+
export interface MfaSetupDto {
|
|
97
|
+
secret: string;
|
|
98
|
+
otpauthUrl: string;
|
|
99
|
+
qrCodeDataUrl: string;
|
|
100
|
+
}
|
|
101
|
+
export interface MfaBackupCodesDto {
|
|
102
|
+
backupCodes: string[];
|
|
103
|
+
}
|
|
104
|
+
export interface AuthResponseDto {
|
|
105
|
+
tokens: AuthTokensDto;
|
|
106
|
+
account: AccountDto;
|
|
107
|
+
}
|
|
108
|
+
export interface PlatformPermissionCheckDto {
|
|
109
|
+
accountId: string;
|
|
110
|
+
permissionKey: string;
|
|
111
|
+
}
|
|
112
|
+
export interface PlatformPermissionCheckResultDto extends PlatformPermissionCheckDto {
|
|
113
|
+
granted: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface ServiceClientCreatedResponseDto {
|
|
116
|
+
client: ServiceClientDto;
|
|
117
|
+
secret: string;
|
|
118
|
+
}
|
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
import { CloudProvider, CloudAccountStatus, AwsAuthMethod, GcpAuthMethod, AzureAuthMethod, SyncStatus, SyncType } from "../enums";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Date handling:
|
|
8
|
-
* JSON has no Date type. Domain models use Date internally; these DTOs
|
|
9
|
-
* are the serialised form at the HTTP boundary — all timestamps are ISO 8601 strings.
|
|
10
|
-
*
|
|
11
|
-
* Credential handling:
|
|
12
|
-
* CloudAccountDto intentionally omits encryptedCredentials — credentials
|
|
13
|
-
* are write-only. The connect DTOs accept credentials as `unknown` because
|
|
14
|
-
* the shape differs per provider and per authMethod; Zod schemas in the
|
|
15
|
-
* cloud service validate the concrete shape at runtime.
|
|
16
|
-
*
|
|
17
|
-
* SyncJobDto:
|
|
18
|
-
* Read-only. Sync jobs are created internally by the scheduler and exposed
|
|
19
|
-
* for status polling only — clients never POST a sync job directly.
|
|
20
|
-
*
|
|
21
|
-
* Provider push DTOs (CloudCostRecordDto, CloudResourceDto, CloudBudgetDto):
|
|
22
|
-
* Used when cloud-service pushes collected data to insights-service.
|
|
23
|
-
* They include cloudAccountId for scoping — insights-service uses this to
|
|
24
|
-
* associate records with the correct account without re-fetching.
|
|
2
|
+
* @file cloud-service.dto.ts
|
|
3
|
+
* @description Data transfer objects (DTOs) for cloud accounts,
|
|
4
|
+
* sync jobs, provider ingestion, and insights communication.
|
|
25
5
|
*/
|
|
6
|
+
import { CloudProvider, CloudAccountStatus, CloudAccountOwnerType, AwsAuthMethod, GcpAuthMethod, AzureAuthMethod, SyncStatus, SyncType } from '../enums';
|
|
7
|
+
/** Public representation of a connected cloud account. */
|
|
26
8
|
export interface CloudAccountDto {
|
|
27
9
|
id: string;
|
|
28
|
-
|
|
10
|
+
/** Whether this account belongs to an Organization or a Personal Workspace. */
|
|
11
|
+
ownerType: CloudAccountOwnerType;
|
|
12
|
+
/** The ID of the owning entity (organizationId or workspaceId depending on ownerType). */
|
|
13
|
+
ownerId: string;
|
|
14
|
+
/** User who originally connected this account. */
|
|
15
|
+
createdBy: string;
|
|
29
16
|
alias: string;
|
|
30
17
|
provider: CloudProvider;
|
|
31
18
|
status: CloudAccountStatus;
|
|
@@ -36,24 +23,25 @@ export interface CloudAccountDto {
|
|
|
36
23
|
createdAt: string;
|
|
37
24
|
updatedAt: string;
|
|
38
25
|
}
|
|
39
|
-
/**
|
|
26
|
+
/** Request payload to connect a new AWS account. */
|
|
40
27
|
export interface ConnectAwsAccountDto {
|
|
41
28
|
alias: string;
|
|
42
29
|
authMethod: AwsAuthMethod;
|
|
43
30
|
credentials: unknown;
|
|
44
31
|
}
|
|
45
|
-
/**
|
|
32
|
+
/** Request payload to connect a new GCP account. */
|
|
46
33
|
export interface ConnectGcpAccountDto {
|
|
47
34
|
alias: string;
|
|
48
35
|
authMethod: GcpAuthMethod;
|
|
49
36
|
credentials: unknown;
|
|
50
37
|
}
|
|
51
|
-
/**
|
|
38
|
+
/** Request payload to connect a new Azure account. */
|
|
52
39
|
export interface ConnectAzureAccountDto {
|
|
53
40
|
alias: string;
|
|
54
41
|
authMethod: AzureAuthMethod;
|
|
55
42
|
credentials: unknown;
|
|
56
43
|
}
|
|
44
|
+
/** Metadata tracking a single cloud synchronization job. */
|
|
57
45
|
export interface SyncJobDto {
|
|
58
46
|
id: string;
|
|
59
47
|
cloudAccountId: string;
|
|
@@ -68,6 +56,42 @@ export interface SyncJobDto {
|
|
|
68
56
|
createdAt: string;
|
|
69
57
|
updatedAt: string;
|
|
70
58
|
}
|
|
59
|
+
/** Consolidated collection metrics normalized from a cloud provider. */
|
|
60
|
+
export interface ProviderFetchResultDto {
|
|
61
|
+
costs: ProviderCostDto[];
|
|
62
|
+
resources: ProviderResourceDto[];
|
|
63
|
+
budgets: ProviderBudgetDto[];
|
|
64
|
+
}
|
|
65
|
+
/** Normalized cost record details fetched from a cloud provider. */
|
|
66
|
+
export interface ProviderCostDto {
|
|
67
|
+
service: string;
|
|
68
|
+
region: string;
|
|
69
|
+
amount: number;
|
|
70
|
+
currency: string;
|
|
71
|
+
periodStart: string;
|
|
72
|
+
periodEnd: string;
|
|
73
|
+
usageType: string;
|
|
74
|
+
}
|
|
75
|
+
/** Normalized resource metadata details fetched from a cloud provider. */
|
|
76
|
+
export interface ProviderResourceDto {
|
|
77
|
+
resourceType: string;
|
|
78
|
+
resourceId: string;
|
|
79
|
+
region: string;
|
|
80
|
+
name: string | null;
|
|
81
|
+
status: string;
|
|
82
|
+
tags: Record<string, string>;
|
|
83
|
+
metadata: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** Normalized budget configuration fetched from a cloud provider. */
|
|
86
|
+
export interface ProviderBudgetDto {
|
|
87
|
+
name: string;
|
|
88
|
+
limitAmount: number;
|
|
89
|
+
currency: string;
|
|
90
|
+
period: string;
|
|
91
|
+
actualSpend?: number;
|
|
92
|
+
forecastSpend?: number;
|
|
93
|
+
}
|
|
94
|
+
/** Enriched cost record details pushed to the insights service. */
|
|
71
95
|
export interface CloudCostRecordDto {
|
|
72
96
|
cloudAccountId: string;
|
|
73
97
|
provider: CloudProvider;
|
|
@@ -79,6 +103,7 @@ export interface CloudCostRecordDto {
|
|
|
79
103
|
periodEnd: string;
|
|
80
104
|
usageType: string;
|
|
81
105
|
}
|
|
106
|
+
/** Enriched resource metadata details pushed to the insights service. */
|
|
82
107
|
export interface CloudResourceDto {
|
|
83
108
|
cloudAccountId: string;
|
|
84
109
|
provider: CloudProvider;
|
|
@@ -90,6 +115,7 @@ export interface CloudResourceDto {
|
|
|
90
115
|
tags: Record<string, string>;
|
|
91
116
|
metadata: Record<string, unknown>;
|
|
92
117
|
}
|
|
118
|
+
/** Enriched budget configuration details pushed to the insights service. */
|
|
93
119
|
export interface CloudBudgetDto {
|
|
94
120
|
cloudAccountId: string;
|
|
95
121
|
name: string;
|
|
@@ -99,3 +125,7 @@ export interface CloudBudgetDto {
|
|
|
99
125
|
forecastSpend: number;
|
|
100
126
|
period: string;
|
|
101
127
|
}
|
|
128
|
+
export interface BulkDeleteCloudAccountsResponseDto {
|
|
129
|
+
deletedCount: number;
|
|
130
|
+
skippedAccountIds: string[];
|
|
131
|
+
}
|
package/dist/dtos/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './user-service.dto';
|
|
2
|
+
export * from './auth-service.dto';
|
|
3
|
+
export * from './cloud-service.dto';
|
|
4
|
+
export * from './insights-service.dto';
|
|
5
|
+
export * from './audit-service.types';
|
|
6
|
+
export * from './response.dto';
|
package/dist/dtos/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./user-service.dto"), exports);
|
|
|
18
18
|
__exportStar(require("./auth-service.dto"), exports);
|
|
19
19
|
__exportStar(require("./cloud-service.dto"), exports);
|
|
20
20
|
__exportStar(require("./insights-service.dto"), exports);
|
|
21
|
+
__exportStar(require("./audit-service.types"), exports);
|
|
21
22
|
__exportStar(require("./response.dto"), exports);
|