@ampsec/platform-client 45.7.0 → 45.8.1

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.
@@ -31,7 +31,7 @@ class AmpApi {
31
31
  this.enums = new EnumService_1.DefaultEnumService(rest);
32
32
  this.findings = new findings_service_1.FindingsService(rest);
33
33
  this.identity = new AgentIdentityService_1.AgentIdentityService(rest);
34
- this.install = new ConnectorInstallService_1.ConnectorInstallService(rest);
34
+ this.install = new ConnectorInstallService_1.ConnectorInstallService(rest, constants_1.KIND.AGENTS);
35
35
  this.notifications = new entity_service_1.AmpEntityServiceImpl(rest, constants_1.KIND.NOTIFICATIONS);
36
36
  this.providers = new data_service_1.AmpDataServiceImpl(rest, constants_1.KIND.PROVIDERS);
37
37
  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;AACjE,4EAAuE;AACvE,yDAAmD;AAInD;;;;;;;;;;;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,G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AO,GAAG,IAAI,sCAAoB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,IAAI,iCAAkB,CAAe,IAAI,EAAE,gBAAI,CAAC,WAAW,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,GAAG,IAAI,iCAAkB,CAAmB,IAAI,EAAE,gBAAI,CAAC,eAAe,CAAC,CAAC;QAC3F,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAkB,CAAc,IAAI,EAAE,gBAAI,CAAC,UAAU,CAAC,CAAC;QAC5E,IAAI,CAAC,QAAQ,GAAG,IAAI,qCAAkB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,qCAAoB,CAA6B,IAAI,EAAE,gBAAI,CAAC,OAAO,CAAC,CAAC;QACxF,IAAI,CAAC,KAAK,GAAG,IAAI,iCAAkB,CAAU,IAAI,EAAE,gBAAI,CAAC,KAAK,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,CAAC,QAAQ,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"}
@@ -1,7 +1,12 @@
1
1
  import { RestClient } from './RestClient';
2
2
  export declare class ConnectorInstallService {
3
3
  private readonly rest;
4
- constructor(rest: RestClient);
4
+ private readonly targetApi;
5
+ constructor(rest: RestClient, targetApi: string);
6
+ credentials: (cid: string, credentials: {
7
+ [key: string]: unknown;
8
+ }) => Promise<boolean>;
5
9
  getInstallToken: (cid: string) => Promise<string>;
6
- buildInstallOAuthUrl: (apiBaseUrl: string, token: string, redirectUrl: string) => string;
10
+ getRedirectUrl: (token: string) => Promise<string>;
11
+ buildInstallOAuthUrl: (token: string, redirectUrl: string) => string;
7
12
  }
@@ -2,20 +2,39 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConnectorInstallService = void 0;
4
4
  class ConnectorInstallService {
5
- constructor(rest) {
5
+ constructor(rest, targetApi) {
6
+ this.credentials = async (cid, credentials) => {
7
+ const res = await this.rest.call({
8
+ url: `/${this.targetApi}/v1/install/credentials`,
9
+ method: 'POST',
10
+ data: { cid, credentials },
11
+ });
12
+ const success = res.data.success;
13
+ return success;
14
+ };
6
15
  this.getInstallToken = async (cid) => {
7
16
  const res = await this.rest.call({
8
- url: '/install/oauth/token',
17
+ url: `/${this.targetApi}/v1/install/oauth/token`,
9
18
  method: 'POST',
10
19
  data: { cid },
11
20
  });
12
21
  const token = res.data.token;
13
22
  return token;
14
23
  };
15
- this.buildInstallOAuthUrl = (apiBaseUrl, token, redirectUrl) => {
16
- return `${apiBaseUrl}/install/oauth?token=${token}&redirect=${encodeURIComponent(redirectUrl)}`;
24
+ this.getRedirectUrl = async (token) => {
25
+ const res = await this.rest.call({
26
+ url: `/${this.targetApi}/v1/install/oauth/login`,
27
+ method: 'GET',
28
+ params: { token },
29
+ });
30
+ const redirectUrl = res.data.redirect;
31
+ return redirectUrl;
32
+ };
33
+ this.buildInstallOAuthUrl = (token, redirectUrl) => {
34
+ return `/${this.targetApi}/v1/install/oauth?token=${token}&redirect=${encodeURIComponent(redirectUrl)}`;
17
35
  };
18
36
  this.rest = rest;
37
+ this.targetApi = targetApi;
19
38
  }
20
39
  }
21
40
  exports.ConnectorInstallService = ConnectorInstallService;
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectorInstallService.js","sourceRoot":"","sources":["../../../../src/services/rest/ConnectorInstallService.ts"],"names":[],"mappings":";;;AAEA,MAAa,uBAAuB;IAGlC,YAAY,IAAgB;QAI5B,oBAAe,GAAG,KAAK,EAAE,GAAW,EAAmB,EAAE;YACvD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC/B,GAAG,EAAE,sBAAsB;gBAC3B,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAC,GAAG,EAAC;aACZ,CAAC,CAAC;YACH,MAAM,KAAK,GAAI,GAAG,CAAC,IAAwB,CAAC,KAAK,CAAC;YAClD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;QAEF,yBAAoB,GAAG,CAAC,UAAkB,EAAE,KAAa,EAAE,WAAmB,EAAU,EAAE;YACxF,OAAO,GAAG,UAAU,wBAAwB,KAAK,aAAa,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;QAClG,CAAC,CAAC;QAfA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CAeF;AApBD,0DAoBC"}
1
+ {"version":3,"file":"ConnectorInstallService.js","sourceRoot":"","sources":["../../../../src/services/rest/ConnectorInstallService.ts"],"names":[],"mappings":";;;AAEA,MAAa,uBAAuB;IAIlC,YAAY,IAAgB,EAAE,SAAiB;QAK/C,gBAAW,GAAG,KAAK,EAAE,GAAW,EAAE,WAAqC,EAAoB,EAAE;YAC3F,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC/B,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,yBAAyB;gBAChD,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAC,GAAG,EAAE,WAAW,EAAC;aACzB,CAAC,CAAC;YACH,MAAM,OAAO,GAAI,GAAG,CAAC,IAA2B,CAAC,OAAO,CAAC;YAEzD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;QAEF,oBAAe,GAAG,KAAK,EAAE,GAAW,EAAmB,EAAE;YACvD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC/B,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,yBAAyB;gBAChD,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAC,GAAG,EAAC;aACZ,CAAC,CAAC;YACH,MAAM,KAAK,GAAI,GAAG,CAAC,IAAwB,CAAC,KAAK,CAAC;YAClD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;QAEF,mBAAc,GAAG,KAAK,EAAE,KAAa,EAAmB,EAAE;YACxD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC/B,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,yBAAyB;gBAChD,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,EAAC,KAAK,EAAC;aAChB,CAAC,CAAC;YACH,MAAM,WAAW,GAAI,GAAG,CAAC,IAA2B,CAAC,QAAQ,CAAC;YAC9D,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC;QAEF,yBAAoB,GAAG,CAAC,KAAa,EAAE,WAAmB,EAAU,EAAE;YACpE,OAAO,IAAI,IAAI,CAAC,SAAS,2BAA2B,KAAK,aAAa,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;QAC1G,CAAC,CAAC;QArCA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CAoCF;AA3CD,0DA2CC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "45.7.0",
3
+ "version": "45.8.1",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -66,7 +66,7 @@ export class AmpApi {
66
66
  this.enums = new DefaultEnumService(rest);
67
67
  this.findings = new FindingsService(rest);
68
68
  this.identity = new AgentIdentityService(rest);
69
- this.install = new ConnectorInstallService(rest);
69
+ this.install = new ConnectorInstallService(rest, KIND.AGENTS);
70
70
  this.notifications = new AmpEntityServiceImpl<NotificationUpsertDto, NotificationDto>(rest, KIND.NOTIFICATIONS);
71
71
  this.providers = new AmpDataServiceImpl<ProviderDto>(rest, KIND.PROVIDERS);
72
72
  this.reportResults = new AmpDataServiceImpl<ReportResultDto>(rest, KIND.REPORT_RESULTS);
@@ -2,14 +2,27 @@ import {RestClient} from './RestClient';
2
2
 
3
3
  export class ConnectorInstallService {
4
4
  private readonly rest: RestClient;
5
+ private readonly targetApi: string;
5
6
 
6
- constructor(rest: RestClient) {
7
+ constructor(rest: RestClient, targetApi: string) {
7
8
  this.rest = rest;
9
+ this.targetApi = targetApi;
8
10
  }
9
11
 
12
+ credentials = async (cid: string, credentials: {[key: string]: unknown}): Promise<boolean> => {
13
+ const res = await this.rest.call({
14
+ url: `/${this.targetApi}/v1/install/credentials`,
15
+ method: 'POST',
16
+ data: {cid, credentials},
17
+ });
18
+ const success = (res.data as {success: boolean}).success;
19
+
20
+ return success;
21
+ };
22
+
10
23
  getInstallToken = async (cid: string): Promise<string> => {
11
24
  const res = await this.rest.call({
12
- url: '/install/oauth/token',
25
+ url: `/${this.targetApi}/v1/install/oauth/token`,
13
26
  method: 'POST',
14
27
  data: {cid},
15
28
  });
@@ -17,7 +30,17 @@ export class ConnectorInstallService {
17
30
  return token;
18
31
  };
19
32
 
20
- buildInstallOAuthUrl = (apiBaseUrl: string, token: string, redirectUrl: string): string => {
21
- return `${apiBaseUrl}/install/oauth?token=${token}&redirect=${encodeURIComponent(redirectUrl)}`;
33
+ getRedirectUrl = async (token: string): Promise<string> => {
34
+ const res = await this.rest.call({
35
+ url: `/${this.targetApi}/v1/install/oauth/login`,
36
+ method: 'GET',
37
+ params: {token},
38
+ });
39
+ const redirectUrl = (res.data as {redirect: string}).redirect;
40
+ return redirectUrl;
41
+ };
42
+
43
+ buildInstallOAuthUrl = (token: string, redirectUrl: string): string => {
44
+ return `/${this.targetApi}/v1/install/oauth?token=${token}&redirect=${encodeURIComponent(redirectUrl)}`;
22
45
  };
23
46
  }