@ampsec/platform-client 46.0.0 → 46.2.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,5 +2,8 @@ export declare enum ConnectorStatus {
2
2
  ACTIVE = "ACTIVE",
3
3
  DELETED = "DELETED",
4
4
  FAILED = "FAILED",
5
- DISABLED = "DISABLED"
5
+ DISABLED = "DISABLED",
6
+ SYNCING = "SYNCING",
7
+ DEGRADED = "DEGRADED",
8
+ PAUSED = "PAUSED"
6
9
  }
@@ -8,5 +8,8 @@ var ConnectorStatus;
8
8
  ConnectorStatus["DELETED"] = "DELETED";
9
9
  ConnectorStatus["FAILED"] = "FAILED";
10
10
  ConnectorStatus["DISABLED"] = "DISABLED";
11
+ ConnectorStatus["SYNCING"] = "SYNCING";
12
+ ConnectorStatus["DEGRADED"] = "DEGRADED";
13
+ ConnectorStatus["PAUSED"] = "PAUSED";
11
14
  })(ConnectorStatus || (exports.ConnectorStatus = ConnectorStatus = {}));
12
15
  //# sourceMappingURL=connector.status.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connector.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/connector.status.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;AACvB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B"}
1
+ {"version":3,"file":"connector.status.js","sourceRoot":"","sources":["../../../../src/dto/enums/connector.status.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;IACrB,sCAAmB,CAAA;IACnB,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;AACnB,CAAC,EARW,eAAe,+BAAf,eAAe,QAQ1B"}
@@ -16,6 +16,28 @@ export type AssetNotificationContext = {
16
16
  /** Name of the asset */
17
17
  deviceName: string;
18
18
  };
19
+ export type CreateNotificationOptions = {
20
+ /** Whether to CC the secops team of the notification, likely a tenant setting once implemented */
21
+ copySecOpsTeam: boolean;
22
+ };
23
+ export type CreateNotificationContent = {
24
+ /** Kind of the content strategy */
25
+ kind: ContentStrategyKind;
26
+ /** Content of the notification */
27
+ content: string;
28
+ };
29
+ export type CreateNotificationDto = BaseUpsertDto & {
30
+ /** Channel type that should be used for sending the notificaiton */
31
+ channel: DeliveryStrategyKind;
32
+ /** Content settings of the notification */
33
+ content: CreateNotificationContent;
34
+ /** Additional options for the notification */
35
+ options?: CreateNotificationOptions;
36
+ /** The user id this notification will be sent to, optional as not all findings are associated to a user */
37
+ uid?: string;
38
+ /** The finding id this notification is in regards to */
39
+ fid?: string;
40
+ };
19
41
  export type FindingNotificationContext = {
20
42
  /** Severity of the finding */
21
43
  severity: FindingSeverity;
@@ -1,4 +1,4 @@
1
- import { AgentDto, AgentUpsertDto, AssetDto, ConnectorDto, ConnectorUpsertDto, NotificationDto, NotificationUpsertDto, ProviderDto, ReportResultDto, SaasAssetDto, SaasComponentDto, SaasUserDto, TenantDto, TenantUpsertDto, UserDto } from '../dto';
1
+ import { AgentDto, AgentUpsertDto, AssetDto, ConnectorDto, ConnectorUpsertDto, ProviderDto, ReportResultDto, SaasAssetDto, SaasComponentDto, SaasUserDto, TenantDto, TenantUpsertDto, UserDto } from '../dto';
2
2
  import { AmpEntityService } from './entity.service';
3
3
  import { AmpDataService } from './data.service';
4
4
  import { AmpRestClientOptions, RestClient } from './rest';
@@ -8,6 +8,7 @@ import { AmpSettingsService } from './settings.service';
8
8
  import { AgentIdentityService } from './rest/AgentIdentityService';
9
9
  import { ConnectorInstallService } from './rest/ConnectorInstallService';
10
10
  import { FindingsService } from './findings.service';
11
+ import NotificationService from './notification.service';
11
12
  export type AmpApiOptions = AmpRestClientOptions;
12
13
  /**
13
14
  * AMP API
@@ -29,7 +30,7 @@ export declare class AmpApi {
29
30
  readonly findings: FindingsService;
30
31
  readonly identity: AgentIdentityService;
31
32
  readonly install: ConnectorInstallService;
32
- readonly notifications: AmpEntityService<NotificationUpsertDto, NotificationDto>;
33
+ readonly notifications: NotificationService;
33
34
  readonly providers: AmpDataService<ProviderDto>;
34
35
  readonly reportResults: AmpDataService<ReportResultDto>;
35
36
  readonly reports: AmpReportService;
@@ -1,4 +1,7 @@
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.AmpApi = void 0;
4
7
  const entity_service_1 = require("./entity.service");
@@ -11,6 +14,7 @@ const settings_service_1 = require("./settings.service");
11
14
  const AgentIdentityService_1 = require("./rest/AgentIdentityService");
12
15
  const ConnectorInstallService_1 = require("./rest/ConnectorInstallService");
13
16
  const findings_service_1 = require("./findings.service");
17
+ const notification_service_1 = __importDefault(require("./notification.service"));
14
18
  /**
15
19
  * AMP API
16
20
  * This client is a wrapper around the AMP REST API meant to be used by
@@ -32,7 +36,7 @@ class AmpApi {
32
36
  this.findings = new findings_service_1.FindingsService(rest);
33
37
  this.identity = new AgentIdentityService_1.AgentIdentityService(rest);
34
38
  this.install = new ConnectorInstallService_1.ConnectorInstallService(rest, constants_1.TARGET_API_AGENT);
35
- this.notifications = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.NOTIFICATIONS);
39
+ this.notifications = new notification_service_1.default(rest);
36
40
  this.providers = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.PROVIDERS);
37
41
  this.reportResults = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.REPORT_RESULTS);
38
42
  this.reports = new reports_service_1.AmpReportServiceImpl(rest);
@@ -1 +1 @@
1
- {"version":3,"file":"AmpApi.js","sourceRoot":"","sources":["../../../src/services/AmpApi.ts"],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CAAC,OAAsB;QACpC,MAAM,IAAI,GAAG,IAAA,uBAAgB,EAAC,OAAO,CAAC,CAAC;QACvC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AA3CD,wBA2CC"}
@@ -0,0 +1,8 @@
1
+ import { CreateNotificationDto, NotificationDto, Page } from '../dto';
2
+ import { AmpDataServiceImpl } from './data.service';
3
+ import { RestClient } from './rest';
4
+ declare class NotificationService extends AmpDataServiceImpl<NotificationDto> {
5
+ constructor(rest: RestClient);
6
+ createNew: (notification: CreateNotificationDto | CreateNotificationDto[]) => Promise<Page<NotificationDto>>;
7
+ }
8
+ export default NotificationService;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("./constants");
4
+ const data_service_1 = require("./data.service");
5
+ class NotificationService extends data_service_1.AmpDataServiceImpl {
6
+ constructor(rest) {
7
+ super(rest, constants_1.KIND.NOTIFICATIONS);
8
+ this.createNew = (notification) => this.getPage({
9
+ url: `${this.targetApi}/v1/${this.kind}/create`,
10
+ method: 'POST',
11
+ data: Array.isArray(notification) ? notification : [notification],
12
+ });
13
+ }
14
+ }
15
+ exports.default = NotificationService;
16
+ //# sourceMappingURL=notification.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../../src/services/notification.service.ts"],"names":[],"mappings":";;AACA,2CAAiC;AACjC,iDAAkD;AAGlD,MAAM,mBAAoB,SAAQ,iCAAmC;IACnE,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,EAAE,gBAAI,CAAC,aAAa,CAAC,CAAC;QAGlC,cAAS,GAAG,CAAC,YAA6D,EAAkC,EAAE,CAC5G,IAAI,CAAC,OAAO,CAAC;YACX,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,SAAS;YAC/C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;SAClE,CAAC,CAAC;IAPL,CAAC;CAQF;AAED,kBAAe,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "46.0.0",
3
+ "version": "46.2.0",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -4,4 +4,7 @@ export enum ConnectorStatus {
4
4
  DELETED = 'DELETED',
5
5
  FAILED = 'FAILED',
6
6
  DISABLED = 'DISABLED',
7
+ SYNCING = 'SYNCING',
8
+ DEGRADED = 'DEGRADED',
9
+ PAUSED = 'PAUSED',
7
10
  }
@@ -19,6 +19,31 @@ export type AssetNotificationContext = {
19
19
  deviceName: string;
20
20
  };
21
21
 
22
+ export type CreateNotificationOptions = {
23
+ /** Whether to CC the secops team of the notification, likely a tenant setting once implemented */
24
+ copySecOpsTeam: boolean;
25
+ };
26
+
27
+ export type CreateNotificationContent = {
28
+ /** Kind of the content strategy */
29
+ kind: ContentStrategyKind; // Future kinds will exist, but for now we only support RAW
30
+ /** Content of the notification */
31
+ content: string;
32
+ };
33
+
34
+ export type CreateNotificationDto = BaseUpsertDto & {
35
+ /** Channel type that should be used for sending the notificaiton */
36
+ channel: DeliveryStrategyKind;
37
+ /** Content settings of the notification */
38
+ content: CreateNotificationContent;
39
+ /** Additional options for the notification */
40
+ options?: CreateNotificationOptions;
41
+ /** The user id this notification will be sent to, optional as not all findings are associated to a user */
42
+ uid?: string;
43
+ /** The finding id this notification is in regards to */
44
+ fid?: string;
45
+ };
46
+
22
47
  export type FindingNotificationContext = {
23
48
  /** Severity of the finding */
24
49
  severity: FindingSeverity;
@@ -4,8 +4,6 @@ import {
4
4
  AssetDto,
5
5
  ConnectorDto,
6
6
  ConnectorUpsertDto,
7
- NotificationDto,
8
- NotificationUpsertDto,
9
7
  ProviderDto,
10
8
  ReportResultDto,
11
9
  SaasAssetDto,
@@ -25,6 +23,7 @@ import {AmpSettingsService} from './settings.service';
25
23
  import {AgentIdentityService} from './rest/AgentIdentityService';
26
24
  import {ConnectorInstallService} from './rest/ConnectorInstallService';
27
25
  import {FindingsService} from './findings.service';
26
+ import NotificationService from './notification.service';
28
27
 
29
28
  export type AmpApiOptions = AmpRestClientOptions;
30
29
 
@@ -48,7 +47,7 @@ export class AmpApi {
48
47
  readonly findings: FindingsService;
49
48
  readonly identity: AgentIdentityService;
50
49
  readonly install: ConnectorInstallService;
51
- readonly notifications: AmpEntityService<NotificationUpsertDto, NotificationDto>;
50
+ readonly notifications: NotificationService;
52
51
  readonly providers: AmpDataService<ProviderDto>;
53
52
  readonly reportResults: AmpDataService<ReportResultDto>;
54
53
  readonly reports: AmpReportService;
@@ -67,7 +66,7 @@ export class AmpApi {
67
66
  this.findings = new FindingsService(rest);
68
67
  this.identity = new AgentIdentityService(rest);
69
68
  this.install = new ConnectorInstallService(rest, TARGET_API_AGENT);
70
- this.notifications = new AmpEntityServiceImpl<NotificationUpsertDto, NotificationDto>(rest, KIND.NOTIFICATIONS);
69
+ this.notifications = new NotificationService(rest);
71
70
  this.providers = new AmpDataServiceImpl<ProviderDto>(rest, KIND.PROVIDERS);
72
71
  this.reportResults = new AmpDataServiceImpl<ReportResultDto>(rest, KIND.REPORT_RESULTS);
73
72
  this.reports = new AmpReportServiceImpl(rest);
@@ -0,0 +1,19 @@
1
+ import {CreateNotificationDto, NotificationDto, Page} from '../dto';
2
+ import {KIND} from './constants';
3
+ import {AmpDataServiceImpl} from './data.service';
4
+ import {RestClient} from './rest';
5
+
6
+ class NotificationService extends AmpDataServiceImpl<NotificationDto> {
7
+ constructor(rest: RestClient) {
8
+ super(rest, KIND.NOTIFICATIONS);
9
+ }
10
+
11
+ createNew = (notification: CreateNotificationDto | CreateNotificationDto[]): Promise<Page<NotificationDto>> =>
12
+ this.getPage({
13
+ url: `${this.targetApi}/v1/${this.kind}/create`,
14
+ method: 'POST',
15
+ data: Array.isArray(notification) ? notification : [notification],
16
+ });
17
+ }
18
+
19
+ export default NotificationService;