@ampsec/platform-client 32.3.1 → 33.0.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/README.md CHANGED
@@ -2,72 +2,47 @@
2
2
 
3
3
  Collection of data models, utilities, and clients used by and with our Platform API.
4
4
 
5
- ## Install
5
+ ## Entry Points
6
6
 
7
- ```sh
8
- npm install @ampsec/platform-client
9
- ```
7
+ ### API Clients
8
+
9
+ - Agents
10
+ - [src/services/AmpApi.ts](https://amplifier-security.gitlab.io/ampsec-platform/amp-platform-client/classes/AmpApi.html)
11
+ - Service Accounts
12
+ - [src/services/AmpSdk.ts](https://amplifier-security.gitlab.io/ampsec-platform/amp-platform-client/classes/AmpSdk.html)
13
+ - End Users
14
+ - [src/services/EngageApi.ts](https://amplifier-security.gitlab.io/ampsec-platform/amp-platform-client/classes/AmpSdk.html)
15
+
16
+ ### Services
10
17
 
11
- ## Usage
18
+ - Settings
19
+ - [AmpSettingsService - src/services/settings.service.ts](https://amplifier-security.gitlab.io/ampsec-platform/amp-platform-client/classes/AmpSettingsService.html)
20
+ - [AmpSettingsMap - src/services/settings.service.ts](https://amplifier-security.gitlab.io/ampsec-platform/amp-platform-client/classes/AmpSettingsMap.html)
12
21
 
13
- You can use the types by simply importing them.
22
+ ## Getting Started
14
23
 
15
24
  ```ts
16
25
  import {UpsertUserDto} from '@ampsec/platform-client'
17
26
 
18
- const user: UpsertUserDto = {
19
- id?: number;
20
- etag: string;
21
- department?: string;
22
- emails: string[];
23
- firstName: string;
24
- lastName: string;
25
- oid: number;
26
- startDate?: string;
27
+ async function testAgentApi() {
28
+ const agentApi = AmpApi.instance({
29
+ baseUrl: process.env.PLATFORM_API_URL,
30
+ token: process.env.PLATFORM_TOKEN,
31
+ })
32
+ const me = await agentApi.identity.me();
33
+ console.log(me);
27
34
  }
28
- ```
29
-
30
- TODO: deploy docs for refrence
31
-
32
- ## Development
33
-
34
- ```sh
35
- npm install
36
- npm run dev
37
- npm run test
38
-
39
- # Optional
40
- npm link
41
- cd /path/to/application
42
- npm link @ampsec/platform-client
43
- ```
44
-
45
- ## Testing
46
35
 
47
- Unit tests are written with [Jest](https://jestjs.io/). To run the tests:
48
-
49
- ```sh
50
- npm run test
51
- ```
52
-
53
- Integration tests are written with [Jest](https://jestjs.io/). To run the tests:
54
-
55
- ```sh
56
- npm run test:integration
57
- ```
58
-
59
- ### Generating Docs
60
-
61
- Published to <https://amplifier-security.gitlab.io/ampsec-platform/amp-platform-client/>
62
-
63
- ```sh
64
- npm run docs
65
- # preview before deploying
66
- npm run docs:serve
36
+ async function testAgentApi() {
37
+ const sdk = AmpSdkServices.instance({
38
+ baseUrl: process.env.PLATFORM_API_URL,
39
+ token: process.env.PLATFORM_TOKEN,
40
+ })
41
+ const me = await agentApi.identity.me();
42
+ console.log(me);
43
+ }
67
44
  ```
68
45
 
69
- ### Upgrade the dependencies
46
+ ## Development
70
47
 
71
- ```sh
72
- npm upgrade
73
- ```
48
+ See [DEVELOPMENT.md](DEVELOPMENT.md)
@@ -1,39 +1,58 @@
1
1
  import { ChangeAwareDto, ChangeAwareUpsertDto } from './base.dto';
2
2
  import { Category, FindingSeverity, SaasComponentKind } from './enums';
3
+ export type RawUserIds = {
4
+ uid?: string;
5
+ /** Provider id used against the API */
6
+ extId?: string;
7
+ primaryEmail?: string;
8
+ emails?: string[];
9
+ };
10
+ export type RawAssetIds = {
11
+ aid?: string;
12
+ /** Provider id used against the API */
13
+ extId?: string;
14
+ /** Serial Number */
15
+ sn?: string;
16
+ /** Hostnames */
17
+ hostnames?: string[];
18
+ /** MAC Addresses */
19
+ macs?: string[];
20
+ };
21
+ export type RawTrainingContext = {
22
+ title?: string;
23
+ url?: string;
24
+ enrollDate?: string | null;
25
+ };
26
+ export type RawVulnerabilityContext = {
27
+ cve?: string;
28
+ cvss?: number;
29
+ description?: string;
30
+ solution?: string;
31
+ };
32
+ export type RawFindingsContext = {
33
+ /**
34
+ * Uses styling to display the finding in the UI
35
+ * - `+` is used to denote success, e.g. `+ACTIVE`
36
+ * - `-` is used to denote failure, e.g. `-FAILED`
37
+ * - `?` is used to denote unknown, e.g. `?ASSIGNED` for a pending not-out-of-sla training
38
+ */
39
+ displayValue?: string;
40
+ active?: boolean;
41
+ enabled?: boolean;
42
+ failedPhishing?: boolean;
43
+ loggedIn?: boolean;
44
+ overdue?: boolean;
45
+ severity?: FindingSeverity;
46
+ isExecutive?: boolean;
47
+ hasProdAccess?: boolean;
48
+ hasPrivilegedAccess?: boolean;
49
+ };
3
50
  export type SaasComponentMeta = {
4
- _findings: {
5
- /**
6
- * Uses styling to display the finding in the UI
7
- * - `+` is used to denote success, e.g. `+ACTIVE`
8
- * - `-` is used to denote failure, e.g. `-FAILED`
9
- * - `?` is used to denote unknown, e.g. `?ASSIGNED` for a pending not-out-of-sla training
10
- */
11
- displayValue?: string;
12
- active?: boolean;
13
- enabled?: boolean;
14
- failedPhishing?: boolean;
15
- loggedIn?: boolean;
16
- overdue?: boolean;
17
- severity?: FindingSeverity;
18
- isExecutive?: boolean;
19
- hasProdAccess?: boolean;
20
- hasPrivilegedAccess?: boolean;
21
- };
22
- _asset?: {
23
- extId?: string;
24
- sn?: string;
25
- hostnames?: string[];
26
- macs?: string[];
27
- };
28
- _user?: {
29
- extId?: string;
30
- email?: string;
31
- };
32
- _training?: {
33
- title?: string;
34
- enrollDate?: string | null;
35
- startDate?: string | null;
36
- };
51
+ _findings: RawFindingsContext;
52
+ _asset?: RawAssetIds;
53
+ _user?: RawUserIds;
54
+ _training?: RawTrainingContext;
55
+ _vulnerability?: RawVulnerabilityContext;
37
56
  [propName: string]: unknown;
38
57
  };
39
58
  export type SaasComponentUpsertDto = ChangeAwareUpsertDto & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "32.3.1",
3
+ "version": "33.0.0",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -1,40 +1,64 @@
1
1
  import {ChangeAwareDto, ChangeAwareUpsertDto} from './base.dto';
2
2
  import {Category, FindingSeverity, SaasComponentKind} from './enums';
3
3
 
4
+ export type RawUserIds = {
5
+ uid?: string;
6
+ /** Provider id used against the API */
7
+ extId?: string;
8
+ primaryEmail?: string;
9
+ emails?: string[];
10
+ };
11
+
12
+ export type RawAssetIds = {
13
+ aid?: string;
14
+ /** Provider id used against the API */
15
+ extId?: string;
16
+ /** Serial Number */
17
+ sn?: string;
18
+ /** Hostnames */
19
+ hostnames?: string[];
20
+ /** MAC Addresses */
21
+ macs?: string[];
22
+ };
23
+
24
+ export type RawTrainingContext = {
25
+ title?: string;
26
+ url?: string;
27
+ enrollDate?: string | null;
28
+ };
29
+
30
+ export type RawVulnerabilityContext = {
31
+ cve?: string;
32
+ cvss?: number;
33
+ description?: string;
34
+ solution?: string;
35
+ };
36
+
37
+ export type RawFindingsContext = {
38
+ /**
39
+ * Uses styling to display the finding in the UI
40
+ * - `+` is used to denote success, e.g. `+ACTIVE`
41
+ * - `-` is used to denote failure, e.g. `-FAILED`
42
+ * - `?` is used to denote unknown, e.g. `?ASSIGNED` for a pending not-out-of-sla training
43
+ */
44
+ displayValue?: string;
45
+ active?: boolean;
46
+ enabled?: boolean;
47
+ failedPhishing?: boolean;
48
+ loggedIn?: boolean;
49
+ overdue?: boolean;
50
+ severity?: FindingSeverity;
51
+ isExecutive?: boolean;
52
+ hasProdAccess?: boolean;
53
+ hasPrivilegedAccess?: boolean;
54
+ };
55
+
4
56
  export type SaasComponentMeta = {
5
- _findings: {
6
- /**
7
- * Uses styling to display the finding in the UI
8
- * - `+` is used to denote success, e.g. `+ACTIVE`
9
- * - `-` is used to denote failure, e.g. `-FAILED`
10
- * - `?` is used to denote unknown, e.g. `?ASSIGNED` for a pending not-out-of-sla training
11
- */
12
- displayValue?: string;
13
- active?: boolean;
14
- enabled?: boolean;
15
- failedPhishing?: boolean;
16
- loggedIn?: boolean;
17
- overdue?: boolean;
18
- severity?: FindingSeverity;
19
- isExecutive?: boolean;
20
- hasProdAccess?: boolean;
21
- hasPrivilegedAccess?: boolean;
22
- };
23
- _asset?: {
24
- extId?: string;
25
- sn?: string;
26
- hostnames?: string[];
27
- macs?: string[];
28
- };
29
- _user?: {
30
- extId?: string;
31
- email?: string;
32
- };
33
- _training?: {
34
- title?: string;
35
- enrollDate?: string | null;
36
- startDate?: string | null;
37
- };
57
+ _findings: RawFindingsContext;
58
+ _asset?: RawAssetIds;
59
+ _user?: RawUserIds;
60
+ _training?: RawTrainingContext;
61
+ _vulnerability?: RawVulnerabilityContext;
38
62
  [propName: string]: unknown;
39
63
  };
40
64