@ampsec/platform-client 48.0.0 → 48.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.
- package/build/src/dto/notification.dto.d.ts +10 -0
- package/build/src/services/lookup.service.d.ts +6 -0
- package/build/src/services/lookup.service.js +15 -0
- package/build/src/services/lookup.service.js.map +1 -1
- package/package.json +1 -1
- package/src/dto/notification.dto.ts +10 -0
- package/src/services/lookup.service.ts +18 -0
|
@@ -45,6 +45,8 @@ export type CreateNotificationDto = BaseUpsertDto & {
|
|
|
45
45
|
uid?: string;
|
|
46
46
|
/** The finding id this notification is in regards to */
|
|
47
47
|
fid?: string;
|
|
48
|
+
/** ID of the user from which the notification was sent */
|
|
49
|
+
fuid?: string | null;
|
|
48
50
|
};
|
|
49
51
|
export type FindingNotificationContext = {
|
|
50
52
|
/** Severity of the finding */
|
|
@@ -89,11 +91,17 @@ export type ProviderNotificationContext = {
|
|
|
89
91
|
export type NotificationContext = {
|
|
90
92
|
/** Estimated completion time for the remediation described by the notification */
|
|
91
93
|
estimatedCompletionTime: number;
|
|
94
|
+
/** Asset to which the notification refers */
|
|
92
95
|
asset?: AssetNotificationContext;
|
|
96
|
+
/** Finding that generated the notification */
|
|
93
97
|
finding?: FindingNotificationContext;
|
|
98
|
+
/** Provider to which the notification is associated */
|
|
94
99
|
provider?: ProviderNotificationContext;
|
|
100
|
+
/** Training to which the notification refers */
|
|
95
101
|
training?: TrainingNotificationContext;
|
|
102
|
+
/** User to which the notification is being sent */
|
|
96
103
|
user?: UserNotificationContext;
|
|
104
|
+
/** Vulnerability to which the notification refers */
|
|
97
105
|
vulnerability?: VulnerabilityNotificationContext;
|
|
98
106
|
};
|
|
99
107
|
export type ContentStrategySpecification = {
|
|
@@ -142,5 +150,7 @@ export type NotificationUpsertDto = BaseUpsertDto & {
|
|
|
142
150
|
fid?: string | null;
|
|
143
151
|
/** ID of the user to which the notification is being sent */
|
|
144
152
|
uid?: string | null;
|
|
153
|
+
/** ID of the user from which the notification was sent */
|
|
154
|
+
fuid?: string | null;
|
|
145
155
|
};
|
|
146
156
|
export type NotificationDto = NotificationUpsertDto & BaseDto;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AssetIdDto, AssetKeys, RawUserIds, SaasComponentIdDto, UserIdDto } from '../dto';
|
|
2
2
|
export declare class UserLookupService {
|
|
3
|
+
private readonly ids;
|
|
3
4
|
private readonly emailLookupMap;
|
|
4
5
|
private readonly extIdLookupMap;
|
|
5
6
|
private lastUpdated;
|
|
6
7
|
getLastUpdated(): string;
|
|
8
|
+
getIds(): UserIdDto[];
|
|
7
9
|
/**
|
|
8
10
|
* Emails are normalized to lower case but external IDs are case sensitive
|
|
9
11
|
*/
|
|
@@ -26,11 +28,13 @@ export declare class UserLookupService {
|
|
|
26
28
|
byExtId(extId: string): UserIdDto | undefined;
|
|
27
29
|
}
|
|
28
30
|
export declare class AssetLookupService {
|
|
31
|
+
private readonly ids;
|
|
29
32
|
private readonly macsLookupMap;
|
|
30
33
|
private readonly snLookupMap;
|
|
31
34
|
private readonly extIdLookupMap;
|
|
32
35
|
private lastUpdated;
|
|
33
36
|
getLastUpdated(): string;
|
|
37
|
+
getIds(): AssetIdDto[];
|
|
34
38
|
/**
|
|
35
39
|
* Macs are normalized to standard format using `formatMacAddress` but serial numbers and external IDs are case sensitive
|
|
36
40
|
*/
|
|
@@ -47,9 +51,11 @@ export declare class AssetLookupService {
|
|
|
47
51
|
byExtId(extId: string): AssetIdDto | undefined;
|
|
48
52
|
}
|
|
49
53
|
export declare class SaasComponentLookupService {
|
|
54
|
+
private readonly ids;
|
|
50
55
|
private readonly extIdLookupMap;
|
|
51
56
|
private lastUpdated;
|
|
52
57
|
getLastUpdated(): string;
|
|
58
|
+
getIds(): SaasComponentIdDto[];
|
|
53
59
|
add(sc: SaasComponentIdDto): void;
|
|
54
60
|
byExtId(extId: string): SaasComponentIdDto | undefined;
|
|
55
61
|
}
|
|
@@ -8,6 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
class UserLookupService {
|
|
10
10
|
constructor() {
|
|
11
|
+
this.ids = [];
|
|
11
12
|
this.emailLookupMap = new Map();
|
|
12
13
|
this.extIdLookupMap = new Map();
|
|
13
14
|
this.lastUpdated = new Date('2023-04-17T13:00:00.000Z');
|
|
@@ -15,11 +16,15 @@ class UserLookupService {
|
|
|
15
16
|
getLastUpdated() {
|
|
16
17
|
return this.lastUpdated.toISOString();
|
|
17
18
|
}
|
|
19
|
+
getIds() {
|
|
20
|
+
return this.ids; // TODO make this immutable?
|
|
21
|
+
}
|
|
18
22
|
// TODO throw errors if conflicts are found
|
|
19
23
|
/**
|
|
20
24
|
* Emails are normalized to lower case but external IDs are case sensitive
|
|
21
25
|
*/
|
|
22
26
|
add(user) {
|
|
27
|
+
this.ids.push(user);
|
|
23
28
|
user.emails.forEach(email => this.emailLookupMap.set(email.toLowerCase(), user));
|
|
24
29
|
if (user.extId) {
|
|
25
30
|
this.extIdLookupMap.set(user.extId, user);
|
|
@@ -84,6 +89,7 @@ class UserLookupService {
|
|
|
84
89
|
exports.UserLookupService = UserLookupService;
|
|
85
90
|
class AssetLookupService {
|
|
86
91
|
constructor() {
|
|
92
|
+
this.ids = [];
|
|
87
93
|
this.macsLookupMap = new Map();
|
|
88
94
|
this.snLookupMap = new Map();
|
|
89
95
|
this.extIdLookupMap = new Map();
|
|
@@ -92,12 +98,16 @@ class AssetLookupService {
|
|
|
92
98
|
getLastUpdated() {
|
|
93
99
|
return this.lastUpdated.toISOString();
|
|
94
100
|
}
|
|
101
|
+
getIds() {
|
|
102
|
+
return this.ids; // TODO make this immutable?
|
|
103
|
+
}
|
|
95
104
|
// TODO throw errors if conflicts are found
|
|
96
105
|
/**
|
|
97
106
|
* Macs are normalized to standard format using `formatMacAddress` but serial numbers and external IDs are case sensitive
|
|
98
107
|
*/
|
|
99
108
|
add(asset) {
|
|
100
109
|
var _a;
|
|
110
|
+
this.ids.push(asset);
|
|
101
111
|
(_a = asset.macs) === null || _a === void 0 ? void 0 : _a.forEach(mac => this.macsLookupMap.set((0, utils_1.formatMacAddress)(mac), asset));
|
|
102
112
|
if (asset.sn) {
|
|
103
113
|
this.snLookupMap.set(asset.sn, asset);
|
|
@@ -154,14 +164,19 @@ class AssetLookupService {
|
|
|
154
164
|
exports.AssetLookupService = AssetLookupService;
|
|
155
165
|
class SaasComponentLookupService {
|
|
156
166
|
constructor() {
|
|
167
|
+
this.ids = [];
|
|
157
168
|
this.extIdLookupMap = new Map();
|
|
158
169
|
this.lastUpdated = new Date('2023-04-17T13:00:00.000Z');
|
|
159
170
|
}
|
|
160
171
|
getLastUpdated() {
|
|
161
172
|
return this.lastUpdated.toISOString();
|
|
162
173
|
}
|
|
174
|
+
getIds() {
|
|
175
|
+
return this.ids; // TODO make this immutable?
|
|
176
|
+
}
|
|
163
177
|
// TODO throw errors if conflicts are found
|
|
164
178
|
add(sc) {
|
|
179
|
+
this.ids.push(sc);
|
|
165
180
|
this.extIdLookupMap.set(sc.extId, sc);
|
|
166
181
|
this.lastUpdated = new Date();
|
|
167
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.service.js","sourceRoot":"","sources":["../../../src/services/lookup.service.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,mCAAyC;AAEzC,MAAa,iBAAiB;IAA9B;QACmB,mBAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC9C,mBAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;QACvD,gBAAW,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"lookup.service.js","sourceRoot":"","sources":["../../../src/services/lookup.service.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,mCAAyC;AAEzC,MAAa,iBAAiB;IAA9B;QACmB,QAAG,GAAgB,EAAE,CAAC;QACtB,mBAAc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I,CAAC,0BAA0B,CAAC,CAAC;IAoB7D,CAAC;IAlBC,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,4BAA4B;IAC/C,CAAC;IAED,2CAA2C;IAC3C,GAAG,CAAC,EAAsB;QACxB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,KAAa;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF;AAvBD,gEAuBC"}
|
package/package.json
CHANGED
|
@@ -52,6 +52,8 @@ export type CreateNotificationDto = BaseUpsertDto & {
|
|
|
52
52
|
uid?: string;
|
|
53
53
|
/** The finding id this notification is in regards to */
|
|
54
54
|
fid?: string;
|
|
55
|
+
/** ID of the user from which the notification was sent */
|
|
56
|
+
fuid?: string | null;
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
export type FindingNotificationContext = {
|
|
@@ -102,11 +104,17 @@ export type ProviderNotificationContext = {
|
|
|
102
104
|
export type NotificationContext = {
|
|
103
105
|
/** Estimated completion time for the remediation described by the notification */
|
|
104
106
|
estimatedCompletionTime: number;
|
|
107
|
+
/** Asset to which the notification refers */
|
|
105
108
|
asset?: AssetNotificationContext;
|
|
109
|
+
/** Finding that generated the notification */
|
|
106
110
|
finding?: FindingNotificationContext;
|
|
111
|
+
/** Provider to which the notification is associated */
|
|
107
112
|
provider?: ProviderNotificationContext;
|
|
113
|
+
/** Training to which the notification refers */
|
|
108
114
|
training?: TrainingNotificationContext;
|
|
115
|
+
/** User to which the notification is being sent */
|
|
109
116
|
user?: UserNotificationContext;
|
|
117
|
+
/** Vulnerability to which the notification refers */
|
|
110
118
|
vulnerability?: VulnerabilityNotificationContext;
|
|
111
119
|
};
|
|
112
120
|
|
|
@@ -159,6 +167,8 @@ export type NotificationUpsertDto = BaseUpsertDto & {
|
|
|
159
167
|
fid?: string | null;
|
|
160
168
|
/** ID of the user to which the notification is being sent */
|
|
161
169
|
uid?: string | null;
|
|
170
|
+
/** ID of the user from which the notification was sent */
|
|
171
|
+
fuid?: string | null;
|
|
162
172
|
};
|
|
163
173
|
|
|
164
174
|
export type NotificationDto = NotificationUpsertDto & BaseDto;
|
|
@@ -3,6 +3,7 @@ import {AssetIdDto, AssetKeys, RawUserIds, SaasComponentIdDto, UserIdDto} from '
|
|
|
3
3
|
import {formatMacAddress} from './utils';
|
|
4
4
|
|
|
5
5
|
export class UserLookupService {
|
|
6
|
+
private readonly ids: UserIdDto[] = [];
|
|
6
7
|
private readonly emailLookupMap = new Map<string, UserIdDto>();
|
|
7
8
|
private readonly extIdLookupMap = new Map<string, UserIdDto>();
|
|
8
9
|
private lastUpdated = new Date('2023-04-17T13:00:00.000Z');
|
|
@@ -11,11 +12,16 @@ export class UserLookupService {
|
|
|
11
12
|
return this.lastUpdated.toISOString();
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
getIds(): UserIdDto[] {
|
|
16
|
+
return this.ids; // TODO make this immutable?
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
// TODO throw errors if conflicts are found
|
|
15
20
|
/**
|
|
16
21
|
* Emails are normalized to lower case but external IDs are case sensitive
|
|
17
22
|
*/
|
|
18
23
|
add(user: UserIdDto) {
|
|
24
|
+
this.ids.push(user);
|
|
19
25
|
user.emails.forEach(email => this.emailLookupMap.set(email.toLowerCase(), user));
|
|
20
26
|
if (user.extId) {
|
|
21
27
|
this.extIdLookupMap.set(user.extId, user);
|
|
@@ -84,6 +90,7 @@ export class UserLookupService {
|
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
export class AssetLookupService {
|
|
93
|
+
private readonly ids: AssetIdDto[] = [];
|
|
87
94
|
private readonly macsLookupMap = new Map<string, AssetIdDto>();
|
|
88
95
|
private readonly snLookupMap = new Map<string, AssetIdDto>();
|
|
89
96
|
private readonly extIdLookupMap = new Map<string, AssetIdDto>();
|
|
@@ -93,11 +100,16 @@ export class AssetLookupService {
|
|
|
93
100
|
return this.lastUpdated.toISOString();
|
|
94
101
|
}
|
|
95
102
|
|
|
103
|
+
getIds(): AssetIdDto[] {
|
|
104
|
+
return this.ids; // TODO make this immutable?
|
|
105
|
+
}
|
|
106
|
+
|
|
96
107
|
// TODO throw errors if conflicts are found
|
|
97
108
|
/**
|
|
98
109
|
* Macs are normalized to standard format using `formatMacAddress` but serial numbers and external IDs are case sensitive
|
|
99
110
|
*/
|
|
100
111
|
add(asset: AssetIdDto) {
|
|
112
|
+
this.ids.push(asset);
|
|
101
113
|
asset.macs?.forEach(mac => this.macsLookupMap.set(formatMacAddress(mac), asset));
|
|
102
114
|
if (asset.sn) {
|
|
103
115
|
this.snLookupMap.set(asset.sn, asset);
|
|
@@ -157,6 +169,7 @@ export class AssetLookupService {
|
|
|
157
169
|
}
|
|
158
170
|
|
|
159
171
|
export class SaasComponentLookupService {
|
|
172
|
+
private readonly ids: SaasComponentIdDto[] = [];
|
|
160
173
|
private readonly extIdLookupMap = new Map<string, SaasComponentIdDto>();
|
|
161
174
|
private lastUpdated = new Date('2023-04-17T13:00:00.000Z');
|
|
162
175
|
|
|
@@ -164,8 +177,13 @@ export class SaasComponentLookupService {
|
|
|
164
177
|
return this.lastUpdated.toISOString();
|
|
165
178
|
}
|
|
166
179
|
|
|
180
|
+
getIds(): SaasComponentIdDto[] {
|
|
181
|
+
return this.ids; // TODO make this immutable?
|
|
182
|
+
}
|
|
183
|
+
|
|
167
184
|
// TODO throw errors if conflicts are found
|
|
168
185
|
add(sc: SaasComponentIdDto) {
|
|
186
|
+
this.ids.push(sc);
|
|
169
187
|
this.extIdLookupMap.set(sc.extId, sc);
|
|
170
188
|
this.lastUpdated = new Date();
|
|
171
189
|
}
|