@ampsec/platform-client 27.2.0 → 27.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/build/src/dto/findings.dto.d.ts +6 -0
- package/build/src/services/AmpApi.d.ts +2 -0
- package/build/src/services/AmpApi.js +2 -0
- package/build/src/services/AmpApi.js.map +1 -1
- package/build/src/services/AmpSdk.d.ts +1 -1
- package/build/src/services/AmpSdk.js +1 -1
- package/build/src/services/EngageApi.d.ts +37 -0
- package/build/src/services/EngageApi.js +46 -0
- package/build/src/services/EngageApi.js.map +1 -0
- package/build/src/services/constants.d.ts +2 -1
- package/build/src/services/constants.js +2 -1
- package/build/src/services/constants.js.map +1 -1
- package/build/src/services/data.service.d.ts +11 -1
- package/build/src/services/data.service.js +20 -1
- package/build/src/services/data.service.js.map +1 -1
- package/build/src/services/rest/ConnectorInstallService.d.ts +7 -0
- package/build/src/services/rest/ConnectorInstallService.js +22 -0
- package/build/src/services/rest/ConnectorInstallService.js.map +1 -0
- package/build/src/services/rest/RestRequest.d.ts +1 -1
- package/build/src/services/rest/UserIdentityService.d.ts +10 -0
- package/build/src/services/rest/UserIdentityService.js +17 -0
- package/build/src/services/rest/UserIdentityService.js.map +1 -0
- package/package.json +1 -1
- package/src/dto/findings.dto.ts +7 -0
- package/src/services/AmpApi.ts +3 -0
- package/src/services/AmpSdk.ts +1 -1
- package/src/services/EngageApi.ts +54 -0
- package/src/services/constants.ts +2 -1
- package/src/services/data.service.ts +27 -1
- package/src/services/rest/ConnectorInstallService.ts +23 -0
- package/src/services/rest/RestRequest.ts +1 -1
- package/src/services/rest/UserIdentityService.ts +20 -0
|
@@ -2,6 +2,12 @@ import { BaseDto, BaseUpsertDto } from './base.dto';
|
|
|
2
2
|
import { Category, FindingKind } from './enums';
|
|
3
3
|
import { FindingSeverity } from './enums/finding.severity';
|
|
4
4
|
import { FindingStatus } from './enums/finding.status';
|
|
5
|
+
export type FindingsStatusPathDto = {
|
|
6
|
+
/** Id of the connector to which the finding applies */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Status of the finding, e.g. OPEN */
|
|
9
|
+
status: FindingStatus.PENDING_VERIFICATION | FindingStatus.OPEN;
|
|
10
|
+
};
|
|
5
11
|
export type FindingUpsertDto = BaseUpsertDto & {
|
|
6
12
|
/** Date the finding was closed */
|
|
7
13
|
closedAt?: string;
|
|
@@ -6,6 +6,7 @@ import { AmpReportService } from './reports.service';
|
|
|
6
6
|
import { EnumService } from './rest/EnumService';
|
|
7
7
|
import { AmpSettingsService } from './settings.service';
|
|
8
8
|
import { AgentIdentityService } from './rest/AgentIdentityService';
|
|
9
|
+
import { ConnectorInstallService } from './rest/ConnectorInstallService';
|
|
9
10
|
export type AmpApiOptions = AmpRestClientOptions;
|
|
10
11
|
/**
|
|
11
12
|
* AMP API
|
|
@@ -26,6 +27,7 @@ export declare class AmpApi {
|
|
|
26
27
|
readonly enums: EnumService;
|
|
27
28
|
readonly findings: AmpDataService<FindingDto>;
|
|
28
29
|
readonly identity: AgentIdentityService;
|
|
30
|
+
readonly install: ConnectorInstallService;
|
|
29
31
|
readonly notifications: AmpDataService<NotificationDto>;
|
|
30
32
|
readonly providers: AmpDataService<ProviderDto>;
|
|
31
33
|
readonly reportResults: AmpDataService<ReportResultDto>;
|
|
@@ -9,6 +9,7 @@ const reports_service_1 = require("./reports.service");
|
|
|
9
9
|
const EnumService_1 = require("./rest/EnumService");
|
|
10
10
|
const settings_service_1 = require("./settings.service");
|
|
11
11
|
const AgentIdentityService_1 = require("./rest/AgentIdentityService");
|
|
12
|
+
const ConnectorInstallService_1 = require("./rest/ConnectorInstallService");
|
|
12
13
|
/**
|
|
13
14
|
* AMP API
|
|
14
15
|
* This client is a wrapper around the AMP REST API meant to be used by
|
|
@@ -29,6 +30,7 @@ class AmpApi {
|
|
|
29
30
|
this.enums = new EnumService_1.DefaultEnumService(rest);
|
|
30
31
|
this.findings = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.FINDINGS);
|
|
31
32
|
this.identity = new AgentIdentityService_1.AgentIdentityService(rest);
|
|
33
|
+
this.install = new ConnectorInstallService_1.ConnectorInstallService(rest);
|
|
32
34
|
this.notifications = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.NOTIFICATIONS);
|
|
33
35
|
this.providers = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.PROVIDERS);
|
|
34
36
|
this.reportResults = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.REPORT_RESULTS);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmpApi.js","sourceRoot":"","sources":["../../../src/services/AmpApi.ts"],"names":[],"mappings":";;;AAiBA,qDAAwE;AACxE,iDAAkE;AAClE,iCAA0E;AAC1E,2CAAiC;AACjC,uDAAyE;AACzE,oDAAmE;AACnE,yDAAsD;AACtD,sEAAiE;
|
|
1
|
+
{"version":3,"file":"AmpApi.js","sourceRoot":"","sources":["../../../src/services/AmpApi.ts"],"names":[],"mappings":";;;AAiBA,qDAAwE;AACxE,iDAAkE;AAClE,iCAA0E;AAC1E,2CAAiC;AACjC,uDAAyE;AACzE,oDAAmE;AACnE,yDAAsD;AACtD,sEAAiE;AACjE,4EAAuE;AAIvE;;;;;;;;;;;GAWG;AACH,MAAa,MAAM;IAmBjB,YAAY,IAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,qCAAoB,CAA2B,IAAI,EAAE,gBAAI,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,CAAC,KAAK,GAAG,IAAI,iCAAkB,CAAW,IAAI,EAAE,gBAAI,CAAC,MAAM,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAoB,CAAmC,IAAI,EAAE,gBAAI,CAAC,UAAU,CAAC,CAAC;QACpG,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAkB,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAkB,CAAa,IAAI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C,CAAC;IAC1B,CAAC;CACF;AA3CD,wBA2CC"}
|
|
@@ -11,7 +11,7 @@ export type AmpSdkOptions = AmpRestClientOptions;
|
|
|
11
11
|
* This client is a wrapper around the AMP REST API meant to be used by
|
|
12
12
|
* service accounts, i.e. plugins and platform extensions. If you are
|
|
13
13
|
* trying to implement a simple web client you should leverage the AmpApi
|
|
14
|
-
* instead (see {@link AmpApi} ).
|
|
14
|
+
* of EngageApi instead (see {@link AmpApi} and {@link EngageApi} ).
|
|
15
15
|
*
|
|
16
16
|
* This client provides CRUD access to all of the AMP API.
|
|
17
17
|
*/
|
|
@@ -11,7 +11,7 @@ const settings_service_1 = require("./settings.service");
|
|
|
11
11
|
* This client is a wrapper around the AMP REST API meant to be used by
|
|
12
12
|
* service accounts, i.e. plugins and platform extensions. If you are
|
|
13
13
|
* trying to implement a simple web client you should leverage the AmpApi
|
|
14
|
-
* instead (see {@link AmpApi} ).
|
|
14
|
+
* of EngageApi instead (see {@link AmpApi} and {@link EngageApi} ).
|
|
15
15
|
*
|
|
16
16
|
* This client provides CRUD access to all of the AMP API.
|
|
17
17
|
*/
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ConnectorDto, FindingDto, FindingsStatusPathDto as FindingsStatusPatchDto, NotificationDto, ProviderDto } from '../dto';
|
|
2
|
+
import { AmpDataService, AmpPatchDataService } from './data.service';
|
|
3
|
+
import { AmpRestClientOptions, RestClient } from './rest';
|
|
4
|
+
import { AmpReportService } from './reports.service';
|
|
5
|
+
import { AmpSettingsService } from './settings.service';
|
|
6
|
+
import { UserIdentityService } from './rest/UserIdentityService';
|
|
7
|
+
export type EngageApiOptions = AmpRestClientOptions;
|
|
8
|
+
/**
|
|
9
|
+
* Engage API
|
|
10
|
+
* This client is a wrapper around the AMP REST API meant to be used by
|
|
11
|
+
* end users, i.e. Amplifier Security's managed users. If you are trying to implement
|
|
12
|
+
* a plugin leverage the AmpSdk instead (see {@link AmpSdkServices} ), or
|
|
13
|
+
* a an extension for Agents use AmpApi instead (see {@link AmpApi}).
|
|
14
|
+
*
|
|
15
|
+
* This client provides READ_ONLY access to The folloing resoureces:
|
|
16
|
+
* - Connectors: {@link EngageApi.connectors}
|
|
17
|
+
* - Findings: {@link EngageApi.findings}
|
|
18
|
+
* - Identity: {@link EngageApi.identity}
|
|
19
|
+
* - Notifications: {@link EngageApi.notifications}
|
|
20
|
+
* - Providers: {@link EngageApi.providers}
|
|
21
|
+
* - Reporting: {@link EngageApi.reports}
|
|
22
|
+
* - Settings: {@link EngageApi.settings}
|
|
23
|
+
*
|
|
24
|
+
* This client provides PATCH access to The folloing resoureces:
|
|
25
|
+
* - Findings: {@link EngageApi.findings}
|
|
26
|
+
*/
|
|
27
|
+
export declare class EngageApi {
|
|
28
|
+
readonly connectors: AmpDataService<ConnectorDto>;
|
|
29
|
+
readonly findings: AmpPatchDataService<FindingsStatusPatchDto, FindingDto>;
|
|
30
|
+
readonly identity: UserIdentityService;
|
|
31
|
+
readonly notifications: AmpDataService<NotificationDto>;
|
|
32
|
+
readonly providers: AmpDataService<ProviderDto>;
|
|
33
|
+
readonly reports: AmpReportService;
|
|
34
|
+
readonly settings: AmpSettingsService;
|
|
35
|
+
constructor(rest: RestClient);
|
|
36
|
+
static instance(options: EngageApiOptions): EngageApi;
|
|
37
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EngageApi = void 0;
|
|
4
|
+
const entity_service_1 = require("./entity.service");
|
|
5
|
+
const data_service_1 = require("./data.service");
|
|
6
|
+
const rest_1 = require("./rest");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const reports_service_1 = require("./reports.service");
|
|
9
|
+
const settings_service_1 = require("./settings.service");
|
|
10
|
+
const UserIdentityService_1 = require("./rest/UserIdentityService");
|
|
11
|
+
/**
|
|
12
|
+
* Engage API
|
|
13
|
+
* This client is a wrapper around the AMP REST API meant to be used by
|
|
14
|
+
* end users, i.e. Amplifier Security's managed users. If you are trying to implement
|
|
15
|
+
* a plugin leverage the AmpSdk instead (see {@link AmpSdkServices} ), or
|
|
16
|
+
* a an extension for Agents use AmpApi instead (see {@link AmpApi}).
|
|
17
|
+
*
|
|
18
|
+
* This client provides READ_ONLY access to The folloing resoureces:
|
|
19
|
+
* - Connectors: {@link EngageApi.connectors}
|
|
20
|
+
* - Findings: {@link EngageApi.findings}
|
|
21
|
+
* - Identity: {@link EngageApi.identity}
|
|
22
|
+
* - Notifications: {@link EngageApi.notifications}
|
|
23
|
+
* - Providers: {@link EngageApi.providers}
|
|
24
|
+
* - Reporting: {@link EngageApi.reports}
|
|
25
|
+
* - Settings: {@link EngageApi.settings}
|
|
26
|
+
*
|
|
27
|
+
* This client provides PATCH access to The folloing resoureces:
|
|
28
|
+
* - Findings: {@link EngageApi.findings}
|
|
29
|
+
*/
|
|
30
|
+
class EngageApi {
|
|
31
|
+
constructor(rest) {
|
|
32
|
+
this.connectors = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.CONNECTORS, constants_1.TARGET_API_ENGAGE); // TODO: add /eng endpoint... needed?
|
|
33
|
+
this.findings = new data_service_1.AmpPatchDataServiceImpl(rest, constants_1.KIND.FINDINGS, constants_1.TARGET_API_ENGAGE);
|
|
34
|
+
this.identity = new UserIdentityService_1.UserIdentityService(rest);
|
|
35
|
+
this.notifications = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.NOTIFICATIONS, constants_1.TARGET_API_ENGAGE); // TODO: add /eng endpoint
|
|
36
|
+
this.providers = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.PROVIDERS, constants_1.TARGET_API_ENGAGE); // TODO: add /eng endpoint... needed?
|
|
37
|
+
this.reports = new reports_service_1.AmpReportServiceImpl(rest);
|
|
38
|
+
this.settings = new settings_service_1.AmpSettingsService(rest); // TODO: add /eng endpoint
|
|
39
|
+
}
|
|
40
|
+
static instance(options) {
|
|
41
|
+
const rest = (0, rest_1.getAmpRestClient)(options);
|
|
42
|
+
return new EngageApi(rest);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.EngageApi = EngageApi;
|
|
46
|
+
//# sourceMappingURL=EngageApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EngageApi.js","sourceRoot":"","sources":["../../../src/services/EngageApi.ts"],"names":[],"mappings":";;;AACA,qDAAsD;AACtD,iDAAgH;AAChH,iCAA0E;AAC1E,2CAAoD;AACpD,uDAAyE;AACzE,yDAAsD;AACtD,oEAA+D;AAI/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,SAAS;IASpB,YAAY,IAAgB;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,qCAAoB,CAAmC,IAAI,EAAE,gBAAI,CAAC,UAAU,EAAE,6BAAiB,CAAC,CAAC,CAAC,qCAAqC;QAC7J,IAAI,CAAC,QAAQ,GAAG,IAAI,sCAAuB,CAAqC,IAAI,EAAE,gBAAI,CAAC,QAAQ,EAAE,6BAAiB,CAAC,CAAC;QACxH,IAAI,CAAC,QAAQ,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,IAAI,iCAAkB,CAAkB,IAAI,EAAE,gBAAI,CAAC,aAAa,EAAE,6BAAiB,CAAC,CAAC,CAAC,0BAA0B;QACrI,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAkB,CAAc,IAAI,EAAE,gBAAI,CAAC,SAAS,EAAE,6BAAiB,CAAC,CAAC,CAAC,qCAAqC;QACpI,IAAI,CAAC,OAAO,GAAG,IAAI,sCAAoB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,qCAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B;IAC1E,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAyB;QACvC,MAAM,IAAI,GAAG,IAAA,uBAAgB,EAAC,OAAO,CAAC,CAAC;QACvC,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAvBD,8BAuBC"}
|
|
@@ -2,9 +2,10 @@ export interface ErrorHandler<T> {
|
|
|
2
2
|
(_error: unknown): T;
|
|
3
3
|
}
|
|
4
4
|
export declare const DEFAULT_TREND_WINDOW_MONTHS = 6;
|
|
5
|
-
export type TargetApi = 'api' | 'platform';
|
|
5
|
+
export type TargetApi = 'api' | 'platform' | 'eng';
|
|
6
6
|
export declare const TARGET_API_PLATFORM: TargetApi;
|
|
7
7
|
export declare const TARGET_API_AGENT: TargetApi;
|
|
8
|
+
export declare const TARGET_API_ENGAGE: TargetApi;
|
|
8
9
|
export declare const KIND: {
|
|
9
10
|
AGENTS: string;
|
|
10
11
|
ASSETS: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REPORTS = exports.KIND = exports.TARGET_API_AGENT = exports.TARGET_API_PLATFORM = exports.DEFAULT_TREND_WINDOW_MONTHS = void 0;
|
|
3
|
+
exports.REPORTS = exports.KIND = exports.TARGET_API_ENGAGE = exports.TARGET_API_AGENT = exports.TARGET_API_PLATFORM = exports.DEFAULT_TREND_WINDOW_MONTHS = void 0;
|
|
4
4
|
exports.DEFAULT_TREND_WINDOW_MONTHS = 6;
|
|
5
5
|
exports.TARGET_API_PLATFORM = 'platform';
|
|
6
6
|
exports.TARGET_API_AGENT = 'api';
|
|
7
|
+
exports.TARGET_API_ENGAGE = 'eng';
|
|
7
8
|
exports.KIND = {
|
|
8
9
|
AGENTS: 'agents',
|
|
9
10
|
ASSETS: 'assets',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/services/constants.ts"],"names":[],"mappings":";;;AAIa,QAAA,2BAA2B,GAAG,CAAC,CAAC;AAGhC,QAAA,mBAAmB,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@@
|
|
|
1
|
-
import { BaseDto, Page } from '../dto';
|
|
1
|
+
import { BaseDto, BaseUpsertDto, Page } from '../dto';
|
|
2
2
|
import { FilterCriteria } from '../FilterCriteria';
|
|
3
3
|
import { ErrorHandler, TargetApi } from './constants';
|
|
4
4
|
import { RestClient, RestRequest } from './rest';
|
|
5
|
+
export type DataServiceCallOptions = {
|
|
6
|
+
params: unknown;
|
|
7
|
+
};
|
|
5
8
|
export interface AmpDataService<ReadT extends BaseDto> {
|
|
6
9
|
list(_filter: FilterCriteria): Promise<Page<ReadT>>;
|
|
7
10
|
getById(_id: string): Promise<Page<ReadT>>;
|
|
8
11
|
}
|
|
12
|
+
export interface AmpPatchDataService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
13
|
+
patch(_model: WriteT | WriteT[], _options: DataServiceCallOptions): Promise<Page<ReadT>>;
|
|
14
|
+
}
|
|
9
15
|
export declare class AmpDataServiceImpl<ReadT extends BaseDto> implements AmpDataService<ReadT> {
|
|
10
16
|
protected readonly rest: RestClient;
|
|
11
17
|
protected readonly kind: string;
|
|
@@ -16,3 +22,7 @@ export declare class AmpDataServiceImpl<ReadT extends BaseDto> implements AmpDat
|
|
|
16
22
|
list(filter: FilterCriteria): Promise<Page<ReadT>>;
|
|
17
23
|
getById(id: string): Promise<Page<ReadT>>;
|
|
18
24
|
}
|
|
25
|
+
export declare class AmpPatchDataServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpPatchDataService<WriteT, ReadT> {
|
|
26
|
+
constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
|
|
27
|
+
patch(model: WriteT | WriteT[], options: DataServiceCallOptions): Promise<Page<ReadT>>;
|
|
28
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AmpDataServiceImpl = void 0;
|
|
6
|
+
exports.AmpPatchDataServiceImpl = exports.AmpDataServiceImpl = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
4
8
|
class AmpDataServiceImpl {
|
|
5
9
|
constructor(rest, kind, targetApi = 'api') {
|
|
6
10
|
this.rest = rest;
|
|
@@ -45,4 +49,19 @@ class AmpDataServiceImpl {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
exports.AmpDataServiceImpl = AmpDataServiceImpl;
|
|
52
|
+
class AmpPatchDataServiceImpl extends AmpDataServiceImpl {
|
|
53
|
+
constructor(rest, kind, targetApi = 'api') {
|
|
54
|
+
super(rest, kind, targetApi);
|
|
55
|
+
}
|
|
56
|
+
patch(model, options) {
|
|
57
|
+
const url = lodash_1.default.isArray(model) ? `/${this.targetApi}/v1/${this.kind}` : `/${this.targetApi}/v1/${this.kind}/${model.id}`;
|
|
58
|
+
return this.getPage({
|
|
59
|
+
url,
|
|
60
|
+
method: 'PATCH',
|
|
61
|
+
params: options.params,
|
|
62
|
+
data: model,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.AmpPatchDataServiceImpl = AmpPatchDataServiceImpl;
|
|
48
67
|
//# sourceMappingURL=data.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.service.js","sourceRoot":"","sources":["../../../src/services/data.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data.service.js","sourceRoot":"","sources":["../../../src/services/data.service.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAoBvB,MAAa,kBAAkB;IAK7B,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,KAAK;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAA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,CAAC;CACF;AAjDD,gDAiDC;AAED,MAAa,uBAA6E,SAAQ,kBAAyB;IACzH,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,KAAK;QACtE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAwB,EAAE,OAA+B;QAC7D,MAAM,GAAG,GAAG,gBAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;QACvH,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,GAAG;YACH,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,OAAO,CAAC,MAAkB;YAClC,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;CACF;AAdD,0DAcC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RestClient } from './RestClient';
|
|
2
|
+
export declare class ConnectorInstallService {
|
|
3
|
+
private readonly rest;
|
|
4
|
+
constructor(rest: RestClient);
|
|
5
|
+
getInstallToken(cid: string): Promise<string>;
|
|
6
|
+
buildInstallOAuthUrl(apiBaseUrl: string, token: string, redirectUrl: string): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectorInstallService = void 0;
|
|
4
|
+
class ConnectorInstallService {
|
|
5
|
+
constructor(rest) {
|
|
6
|
+
this.rest = rest;
|
|
7
|
+
}
|
|
8
|
+
async getInstallToken(cid) {
|
|
9
|
+
const res = await this.rest.call({
|
|
10
|
+
url: '/install/oauth/token',
|
|
11
|
+
method: 'POST',
|
|
12
|
+
data: { cid },
|
|
13
|
+
});
|
|
14
|
+
const token = res.data.token;
|
|
15
|
+
return token;
|
|
16
|
+
}
|
|
17
|
+
buildInstallOAuthUrl(apiBaseUrl, token, redirectUrl) {
|
|
18
|
+
return `${apiBaseUrl}/install/oauth?token=${token}&redirect=${encodeURIComponent(redirectUrl)}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ConnectorInstallService = ConnectorInstallService;
|
|
22
|
+
//# sourceMappingURL=ConnectorInstallService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectorInstallService.js","sourceRoot":"","sources":["../../../../src/services/rest/ConnectorInstallService.ts"],"names":[],"mappings":";;;AAEA,MAAa,uBAAuB;IAGlC,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,GAAW;QAC/B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,GAAG,EAAE,sBAAsB;YAC3B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAC,GAAG,EAAC;SACZ,CAAC,CAAC;QACH,MAAM,KAAK,GAAI,GAAG,CAAC,IAAwB,CAAC,KAAK,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oBAAoB,CAAC,UAAkB,EAAE,KAAa,EAAE,WAAmB;QACzE,OAAO,GAAG,UAAU,wBAAwB,KAAK,aAAa,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;IAClG,CAAC;CACF;AApBD,0DAoBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AmpJwtToken } from '../../dto';
|
|
2
|
+
import { RestClient } from './RestClient';
|
|
3
|
+
export type TokenResponse = {
|
|
4
|
+
token: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class UserIdentityService {
|
|
7
|
+
protected readonly rest: RestClient;
|
|
8
|
+
constructor(rest: RestClient);
|
|
9
|
+
me(): Promise<AmpJwtToken>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserIdentityService = void 0;
|
|
4
|
+
class UserIdentityService {
|
|
5
|
+
constructor(rest) {
|
|
6
|
+
this.rest = rest;
|
|
7
|
+
}
|
|
8
|
+
async me() {
|
|
9
|
+
const res = await this.rest.call({
|
|
10
|
+
url: '/eng/v1/me',
|
|
11
|
+
method: 'GET',
|
|
12
|
+
});
|
|
13
|
+
return res.data;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.UserIdentityService = UserIdentityService;
|
|
17
|
+
//# sourceMappingURL=UserIdentityService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserIdentityService.js","sourceRoot":"","sources":["../../../../src/services/rest/UserIdentityService.ts"],"names":[],"mappings":";;;AAOA,MAAa,mBAAmB;IAE9B,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,EAAE;QACN,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,GAAG,EAAE,YAAY;YACjB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAmB,CAAC;IACjC,CAAC;CACF;AAZD,kDAYC"}
|
package/package.json
CHANGED
package/src/dto/findings.dto.ts
CHANGED
|
@@ -3,6 +3,13 @@ import {Category, FindingKind} from './enums';
|
|
|
3
3
|
import {FindingSeverity} from './enums/finding.severity';
|
|
4
4
|
import {FindingStatus} from './enums/finding.status';
|
|
5
5
|
|
|
6
|
+
export type FindingsStatusPathDto = {
|
|
7
|
+
/** Id of the connector to which the finding applies */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Status of the finding, e.g. OPEN */
|
|
10
|
+
status: FindingStatus.PENDING_VERIFICATION | FindingStatus.OPEN;
|
|
11
|
+
};
|
|
12
|
+
|
|
6
13
|
export type FindingUpsertDto = BaseUpsertDto & {
|
|
7
14
|
/** Date the finding was closed */
|
|
8
15
|
closedAt?: string;
|
package/src/services/AmpApi.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {AmpReportService, AmpReportServiceImpl} from './reports.service';
|
|
|
23
23
|
import {DefaultEnumService, EnumService} from './rest/EnumService';
|
|
24
24
|
import {AmpSettingsService} from './settings.service';
|
|
25
25
|
import {AgentIdentityService} from './rest/AgentIdentityService';
|
|
26
|
+
import {ConnectorInstallService} from './rest/ConnectorInstallService';
|
|
26
27
|
|
|
27
28
|
export type AmpApiOptions = AmpRestClientOptions;
|
|
28
29
|
|
|
@@ -45,6 +46,7 @@ export class AmpApi {
|
|
|
45
46
|
readonly enums: EnumService;
|
|
46
47
|
readonly findings: AmpDataService<FindingDto>;
|
|
47
48
|
readonly identity: AgentIdentityService;
|
|
49
|
+
readonly install: ConnectorInstallService;
|
|
48
50
|
readonly notifications: AmpDataService<NotificationDto>;
|
|
49
51
|
readonly providers: AmpDataService<ProviderDto>;
|
|
50
52
|
readonly reportResults: AmpDataService<ReportResultDto>;
|
|
@@ -63,6 +65,7 @@ export class AmpApi {
|
|
|
63
65
|
this.enums = new DefaultEnumService(rest);
|
|
64
66
|
this.findings = new AmpDataServiceImpl<FindingDto>(rest, KIND.FINDINGS);
|
|
65
67
|
this.identity = new AgentIdentityService(rest);
|
|
68
|
+
this.install = new ConnectorInstallService(rest);
|
|
66
69
|
this.notifications = new AmpDataServiceImpl<NotificationDto>(rest, KIND.NOTIFICATIONS);
|
|
67
70
|
this.providers = new AmpDataServiceImpl<ProviderDto>(rest, KIND.PROVIDERS);
|
|
68
71
|
this.reportResults = new AmpDataServiceImpl<ReportResultDto>(rest, KIND.REPORT_RESULTS);
|
package/src/services/AmpSdk.ts
CHANGED
|
@@ -51,7 +51,7 @@ export type AmpSdkOptions = AmpRestClientOptions;
|
|
|
51
51
|
* This client is a wrapper around the AMP REST API meant to be used by
|
|
52
52
|
* service accounts, i.e. plugins and platform extensions. If you are
|
|
53
53
|
* trying to implement a simple web client you should leverage the AmpApi
|
|
54
|
-
* instead (see {@link AmpApi} ).
|
|
54
|
+
* of EngageApi instead (see {@link AmpApi} and {@link EngageApi} ).
|
|
55
55
|
*
|
|
56
56
|
* This client provides CRUD access to all of the AMP API.
|
|
57
57
|
*/
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {ConnectorDto, ConnectorUpsertDto, FindingDto, FindingsStatusPathDto as FindingsStatusPatchDto, NotificationDto, ProviderDto} from '../dto';
|
|
2
|
+
import {AmpEntityServiceImpl} from './entity.service';
|
|
3
|
+
import {AmpDataService, AmpDataServiceImpl, AmpPatchDataService, AmpPatchDataServiceImpl} from './data.service';
|
|
4
|
+
import {AmpRestClientOptions, RestClient, getAmpRestClient} from './rest';
|
|
5
|
+
import {KIND, TARGET_API_ENGAGE} from './constants';
|
|
6
|
+
import {AmpReportService, AmpReportServiceImpl} from './reports.service';
|
|
7
|
+
import {AmpSettingsService} from './settings.service';
|
|
8
|
+
import {UserIdentityService} from './rest/UserIdentityService';
|
|
9
|
+
|
|
10
|
+
export type EngageApiOptions = AmpRestClientOptions;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Engage API
|
|
14
|
+
* This client is a wrapper around the AMP REST API meant to be used by
|
|
15
|
+
* end users, i.e. Amplifier Security's managed users. If you are trying to implement
|
|
16
|
+
* a plugin leverage the AmpSdk instead (see {@link AmpSdkServices} ), or
|
|
17
|
+
* a an extension for Agents use AmpApi instead (see {@link AmpApi}).
|
|
18
|
+
*
|
|
19
|
+
* This client provides READ_ONLY access to The folloing resoureces:
|
|
20
|
+
* - Connectors: {@link EngageApi.connectors}
|
|
21
|
+
* - Findings: {@link EngageApi.findings}
|
|
22
|
+
* - Identity: {@link EngageApi.identity}
|
|
23
|
+
* - Notifications: {@link EngageApi.notifications}
|
|
24
|
+
* - Providers: {@link EngageApi.providers}
|
|
25
|
+
* - Reporting: {@link EngageApi.reports}
|
|
26
|
+
* - Settings: {@link EngageApi.settings}
|
|
27
|
+
*
|
|
28
|
+
* This client provides PATCH access to The folloing resoureces:
|
|
29
|
+
* - Findings: {@link EngageApi.findings}
|
|
30
|
+
*/
|
|
31
|
+
export class EngageApi {
|
|
32
|
+
readonly connectors: AmpDataService<ConnectorDto>;
|
|
33
|
+
readonly findings: AmpPatchDataService<FindingsStatusPatchDto, FindingDto>;
|
|
34
|
+
readonly identity: UserIdentityService;
|
|
35
|
+
readonly notifications: AmpDataService<NotificationDto>;
|
|
36
|
+
readonly providers: AmpDataService<ProviderDto>;
|
|
37
|
+
readonly reports: AmpReportService;
|
|
38
|
+
readonly settings: AmpSettingsService;
|
|
39
|
+
|
|
40
|
+
constructor(rest: RestClient) {
|
|
41
|
+
this.connectors = new AmpEntityServiceImpl<ConnectorUpsertDto, ConnectorDto>(rest, KIND.CONNECTORS, TARGET_API_ENGAGE); // TODO: add /eng endpoint... needed?
|
|
42
|
+
this.findings = new AmpPatchDataServiceImpl<FindingsStatusPatchDto, FindingDto>(rest, KIND.FINDINGS, TARGET_API_ENGAGE);
|
|
43
|
+
this.identity = new UserIdentityService(rest);
|
|
44
|
+
this.notifications = new AmpDataServiceImpl<NotificationDto>(rest, KIND.NOTIFICATIONS, TARGET_API_ENGAGE); // TODO: add /eng endpoint
|
|
45
|
+
this.providers = new AmpDataServiceImpl<ProviderDto>(rest, KIND.PROVIDERS, TARGET_API_ENGAGE); // TODO: add /eng endpoint... needed?
|
|
46
|
+
this.reports = new AmpReportServiceImpl(rest);
|
|
47
|
+
this.settings = new AmpSettingsService(rest); // TODO: add /eng endpoint
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static instance(options: EngageApiOptions): EngageApi {
|
|
51
|
+
const rest = getAmpRestClient(options);
|
|
52
|
+
return new EngageApi(rest);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -4,9 +4,10 @@ export interface ErrorHandler<T> {
|
|
|
4
4
|
|
|
5
5
|
export const DEFAULT_TREND_WINDOW_MONTHS = 6;
|
|
6
6
|
|
|
7
|
-
export type TargetApi = 'api' | 'platform';
|
|
7
|
+
export type TargetApi = 'api' | 'platform' | 'eng';
|
|
8
8
|
export const TARGET_API_PLATFORM: TargetApi = 'platform';
|
|
9
9
|
export const TARGET_API_AGENT: TargetApi = 'api';
|
|
10
|
+
export const TARGET_API_ENGAGE: TargetApi = 'eng';
|
|
10
11
|
|
|
11
12
|
export const KIND = {
|
|
12
13
|
AGENTS: 'agents',
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import {BaseDto, BaseUpsertDto, Page} from '../dto';
|
|
2
3
|
import {FilterCriteria} from '../FilterCriteria';
|
|
3
4
|
import {ErrorHandler, TargetApi} from './constants';
|
|
4
5
|
import {RestClient, RestRequest} from './rest';
|
|
6
|
+
import {QueryMap} from './rest/utils';
|
|
7
|
+
|
|
8
|
+
export type DataServiceCallOptions = {
|
|
9
|
+
params: unknown;
|
|
10
|
+
};
|
|
5
11
|
|
|
6
12
|
export interface AmpDataService<ReadT extends BaseDto> {
|
|
7
13
|
list(_filter: FilterCriteria): Promise<Page<ReadT>>;
|
|
8
14
|
getById(_id: string): Promise<Page<ReadT>>;
|
|
9
15
|
}
|
|
10
16
|
|
|
17
|
+
export interface AmpPatchDataService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
|
|
18
|
+
patch(_model: WriteT | WriteT[], _options: DataServiceCallOptions): Promise<Page<ReadT>>;
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
export class AmpDataServiceImpl<ReadT extends BaseDto> implements AmpDataService<ReadT> {
|
|
12
22
|
protected readonly rest: RestClient;
|
|
13
23
|
protected readonly kind: string;
|
|
@@ -58,3 +68,19 @@ export class AmpDataServiceImpl<ReadT extends BaseDto> implements AmpDataService
|
|
|
58
68
|
});
|
|
59
69
|
}
|
|
60
70
|
}
|
|
71
|
+
|
|
72
|
+
export class AmpPatchDataServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpPatchDataService<WriteT, ReadT> {
|
|
73
|
+
constructor(rest: RestClient, kind: string, targetApi: TargetApi = 'api') {
|
|
74
|
+
super(rest, kind, targetApi);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
patch(model: WriteT | WriteT[], options: DataServiceCallOptions): Promise<Page<ReadT>> {
|
|
78
|
+
const url = _.isArray(model) ? `/${this.targetApi}/v1/${this.kind}` : `/${this.targetApi}/v1/${this.kind}/${model.id}`;
|
|
79
|
+
return this.getPage({
|
|
80
|
+
url,
|
|
81
|
+
method: 'PATCH',
|
|
82
|
+
params: options.params as QueryMap,
|
|
83
|
+
data: model,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {RestClient} from './RestClient';
|
|
2
|
+
|
|
3
|
+
export class ConnectorInstallService {
|
|
4
|
+
private readonly rest: RestClient;
|
|
5
|
+
|
|
6
|
+
constructor(rest: RestClient) {
|
|
7
|
+
this.rest = rest;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async getInstallToken(cid: string): Promise<string> {
|
|
11
|
+
const res = await this.rest.call({
|
|
12
|
+
url: '/install/oauth/token',
|
|
13
|
+
method: 'POST',
|
|
14
|
+
data: {cid},
|
|
15
|
+
});
|
|
16
|
+
const token = (res.data as {token: string}).token;
|
|
17
|
+
return token;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
buildInstallOAuthUrl(apiBaseUrl: string, token: string, redirectUrl: string): string {
|
|
21
|
+
return `${apiBaseUrl}/install/oauth?token=${token}&redirect=${encodeURIComponent(redirectUrl)}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {AmpJwtToken} from '../../dto';
|
|
2
|
+
import {RestClient} from './RestClient';
|
|
3
|
+
|
|
4
|
+
export type TokenResponse = {
|
|
5
|
+
token: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export class UserIdentityService {
|
|
9
|
+
protected readonly rest: RestClient;
|
|
10
|
+
constructor(rest: RestClient) {
|
|
11
|
+
this.rest = rest;
|
|
12
|
+
}
|
|
13
|
+
async me(): Promise<AmpJwtToken> {
|
|
14
|
+
const res = await this.rest.call({
|
|
15
|
+
url: '/eng/v1/me',
|
|
16
|
+
method: 'GET',
|
|
17
|
+
});
|
|
18
|
+
return res.data as AmpJwtToken;
|
|
19
|
+
}
|
|
20
|
+
}
|