@ampsec/platform-client 27.1.1 → 27.3.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.
@@ -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;
@@ -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,GAAc,UAAU,CAAC;AAC5C,QAAA,gBAAgB,GAAc,KAAK,CAAC;AAEpC,QAAA,IAAI,GAAG;IAClB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,gBAAgB,EAAE,aAAa;IAC/B,kBAAkB,EAAE,eAAe;IACnC,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,UAAU;IACpB,cAAc,EAAE,gBAAgB;IAChC,QAAQ,EAAE,MAAM;IAChB,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,WAAW;IACtB,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,WAAW,EAAE,aAAa;IAC1B,eAAe,EAAE,iBAAiB;IAClC,UAAU,EAAE,YAAY;IACxB,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,QAAA,OAAO,GAAG;IACrB,YAAY,EAAE,cAAc;IAC5B,yBAAyB,EAAE,qCAAqC;IAChE,yBAAyB,EAAE,qCAAqC;IAChE,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,qBAAqB,EAAE,uBAAuB;IAC9C,2BAA2B,EAAE,6BAA6B;IAC1D,YAAY,EAAE,0BAA0B;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,gBAAgB,EAAE,kBAAkB;IACpC,WAAW,EAAE,aAAa;IAC1B,mBAAmB;IACnB,kBAAkB,EAAE,sBAAsB;CAC3C,CAAC"}
@@ -1,11 +1,17 @@
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":";;;AAUA,MAAa,kBAAkB;IAK7B,YAAY,IAAgB,EAAE,IAAY,EAAE,YAAuB,KAAK;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAES,KAAK,CAAC,IAAI,CAAI,GAAgB,EAAE,YAA6B;QACrE,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACtC,OAAO,GAAG,CAAC,IAAS,CAAC;SACtB;QAAC,OAAO,KAAc,EAAE;YACvB,IAAI,KAAK,YAAY,KAAK,EAAE;gBAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aAC9B;YACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;SAC5B;IACH,CAAC;IAES,KAAK,CAAC,OAAO,CAAC,GAAgB;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAc,EAAE,EAAE;YACvC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YACzE,OAAO;gBACL,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBAC7B,KAAK,EAAE,OAAO;gBACd,KAAK,EAAE,EAAE;aACV,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAsB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,EAAE;YACzC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE;YAC/C,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;CACF;AAjDD,gDAiDC"}
1
+ {"version":3,"file":"data.service.js","sourceRoot":"","sources":["../../../src/services/data.service.ts"],"names":[],"mappings":";;;;;;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AAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE;YAC/C,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,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"}
@@ -6,31 +6,31 @@ export type EntityCallOptions = {
6
6
  params: unknown;
7
7
  };
8
8
  export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
9
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
10
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
9
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
10
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
11
11
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
12
12
  }
13
13
  export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
14
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
15
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
14
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
15
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
16
16
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
17
17
  }
18
18
  export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
19
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
20
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
19
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
20
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
21
21
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
22
22
  getLookupIds(_tid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
23
23
  }
24
24
  export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
25
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
26
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
25
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
26
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
27
27
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
28
28
  getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
29
29
  }
30
30
  export declare class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataServiceImpl<ReadT> implements AmpEntityService<WriteT, ReadT> {
31
31
  constructor(rest: RestClient, kind: string, targetApi?: TargetApi);
32
- create(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>>;
33
- update(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>>;
32
+ create(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>>;
33
+ update(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>>;
34
34
  delete(id: string, options?: EntityCallOptions): Promise<Page<ReadT>>;
35
35
  }
36
36
  export declare class AmpGlobalEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpEntityServiceImpl<WriteT, ReadT> implements AmpGlobalEntityService<WriteT, ReadT> {
@@ -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
6
  exports.AmpSaaSEntityServiceImpl = exports.AmpGlobalEntityServiceImpl = exports.AmpEntityServiceImpl = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
4
8
  const constants_1 = require("./constants");
5
9
  const data_service_1 = require("./data.service");
6
10
  class AmpEntityServiceImpl extends data_service_1.AmpDataServiceImpl {
@@ -16,8 +20,9 @@ class AmpEntityServiceImpl extends data_service_1.AmpDataServiceImpl {
16
20
  });
17
21
  }
18
22
  update(model, options) {
23
+ const url = lodash_1.default.isArray(model) ? `/${this.targetApi}/v1/${this.kind}` : `/${this.targetApi}/v1/${this.kind}/${model.id}`;
19
24
  return this.getPage({
20
- url: `/${this.targetApi}/v1/${this.kind}/${model.id}`,
25
+ url,
21
26
  method: 'PUT',
22
27
  params: options === null || options === void 0 ? void 0 : options.params,
23
28
  data: model,
@@ -1 +1 @@
1
- {"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../../src/services/entity.service.ts"],"names":[],"mappings":";;;AACA,2CAAsE;AACtE,iDAAkE;AAgClE,M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headers?: HeadersMap;
5
5
  params?: QueryMap;
6
6
  data?: unknown;
7
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
7
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
8
8
  };
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "27.1.1",
3
+ "version": "27.3.0",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -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;
@@ -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 {BaseDto, Page} from '../dto';
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
+ }
@@ -1,3 +1,4 @@
1
+ import _ from 'lodash';
1
2
  import {BaseDto, BaseUpsertDto, ExtKeyMap, Page} from '../dto';
2
3
  import {TargetApi, TARGET_API_AGENT, ErrorHandler} from './constants';
3
4
  import {AmpDataService, AmpDataServiceImpl} from './data.service';
@@ -9,25 +10,25 @@ export type EntityCallOptions = {
9
10
  };
10
11
 
11
12
  export interface AmpEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
12
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
13
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
13
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
14
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
14
15
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
15
16
  }
16
17
 
17
18
  export interface AmpSdkTenantService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
18
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
19
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
19
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
20
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
20
21
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
21
22
  }
22
23
  export interface AmpGlobalEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
23
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
24
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
24
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
25
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
25
26
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
26
27
  getLookupIds(_tid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
27
28
  }
28
29
  export interface AmpSaaSEntityService<WriteT extends BaseUpsertDto, ReadT extends BaseDto> extends AmpDataService<ReadT> {
29
- create(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
30
- update(_model: WriteT, _options?: EntityCallOptions): Promise<Page<ReadT>>;
30
+ create(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
31
+ update(_model: WriteT | WriteT[], _options?: EntityCallOptions): Promise<Page<ReadT>>;
31
32
  delete(_id: string, _options?: EntityCallOptions): Promise<Page<ReadT>>;
32
33
  getLookupIds(_cid: string, _options?: EntityCallOptions): Promise<ExtKeyMap>;
33
34
  }
@@ -37,7 +38,7 @@ export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends Ba
37
38
  super(rest, kind, targetApi);
38
39
  }
39
40
 
40
- create(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>> {
41
+ create(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>> {
41
42
  return this.getPage({
42
43
  url: `/${this.targetApi}/v1/${this.kind}`,
43
44
  method: 'POST',
@@ -46,9 +47,10 @@ export class AmpEntityServiceImpl<WriteT extends BaseUpsertDto, ReadT extends Ba
46
47
  });
47
48
  }
48
49
 
49
- update(model: WriteT, options?: EntityCallOptions): Promise<Page<ReadT>> {
50
+ update(model: WriteT | WriteT[], options?: EntityCallOptions): Promise<Page<ReadT>> {
51
+ const url = _.isArray(model) ? `/${this.targetApi}/v1/${this.kind}` : `/${this.targetApi}/v1/${this.kind}/${model.id}`;
50
52
  return this.getPage({
51
- url: `/${this.targetApi}/v1/${this.kind}/${model.id}`,
53
+ url,
52
54
  method: 'PUT',
53
55
  params: options?.params as QueryMap,
54
56
  data: model,
@@ -5,5 +5,5 @@ export type RestRequest = {
5
5
  headers?: HeadersMap;
6
6
  params?: QueryMap;
7
7
  data?: unknown;
8
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
8
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
9
9
  };
@@ -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
+ }