@sectester/repeater 0.27.0 → 0.29.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 +3 -3
- package/package.json +11 -11
- package/src/api/DefaultRepeatersManager.js +1 -1
- package/src/api/DefaultRepeatersManager.js.map +1 -1
- package/src/api/commands/CreateRepeaterRequest.d.ts +1 -1
- package/src/api/commands/CreateRepeaterRequest.js +2 -2
- package/src/api/commands/CreateRepeaterRequest.js.map +1 -1
- package/src/api/commands/DeleteRepeaterRequest.d.ts +1 -1
- package/src/api/commands/DeleteRepeaterRequest.js +2 -2
- package/src/api/commands/DeleteRepeaterRequest.js.map +1 -1
- package/src/api/commands/GetRepeaterRequest.d.ts +1 -1
- package/src/api/commands/GetRepeaterRequest.js +2 -2
- package/src/api/commands/GetRepeaterRequest.js.map +1 -1
- package/src/api/commands/index.d.ts +0 -1
- package/src/api/commands/index.js +1 -4
- package/src/api/commands/index.js.map +1 -1
- package/src/api/index.d.ts +0 -3
- package/src/api/index.js +0 -7
- package/src/api/index.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -2
- package/src/index.js.map +1 -1
- package/src/lib/DefaultRepeaterCommands.d.ts +7 -0
- package/src/lib/DefaultRepeaterCommands.js +26 -0
- package/src/lib/DefaultRepeaterCommands.js.map +1 -0
- package/src/lib/DefaultRepeaterServer.d.ts +57 -0
- package/src/lib/DefaultRepeaterServer.js +218 -0
- package/src/lib/DefaultRepeaterServer.js.map +1 -0
- package/src/lib/Repeater.d.ts +18 -15
- package/src/lib/Repeater.js +90 -62
- package/src/lib/Repeater.js.map +1 -1
- package/src/lib/RepeaterCommands.d.ts +5 -0
- package/src/lib/RepeaterCommands.js +5 -0
- package/src/lib/RepeaterCommands.js.map +1 -0
- package/src/lib/RepeaterFactory.d.ts +3 -4
- package/src/lib/RepeaterFactory.js +18 -35
- package/src/lib/RepeaterFactory.js.map +1 -1
- package/src/lib/RepeaterServer.d.ts +92 -0
- package/src/lib/RepeaterServer.js +15 -0
- package/src/lib/RepeaterServer.js.map +1 -0
- package/src/lib/index.d.ts +8 -5
- package/src/lib/index.js +9 -7
- package/src/lib/index.js.map +1 -1
- package/src/models/Protocol.d.ts +1 -2
- package/src/models/Protocol.js +0 -1
- package/src/models/Protocol.js.map +1 -1
- package/src/register.js +15 -18
- package/src/register.js.map +1 -1
- package/src/request-runner/Request.d.ts +13 -9
- package/src/request-runner/Request.js +9 -19
- package/src/request-runner/Request.js.map +1 -1
- package/src/request-runner/Response.d.ts +5 -3
- package/src/request-runner/Response.js +2 -1
- package/src/request-runner/Response.js.map +1 -1
- package/src/request-runner/protocols/HttpRequestRunner.d.ts +9 -7
- package/src/request-runner/protocols/HttpRequestRunner.js +100 -88
- package/src/request-runner/protocols/HttpRequestRunner.js.map +1 -1
- package/src/request-runner/protocols/index.d.ts +0 -1
- package/src/request-runner/protocols/index.js +0 -1
- package/src/request-runner/protocols/index.js.map +1 -1
- package/src/utils/DefaultProxyFactory.d.ts +20 -0
- package/src/utils/DefaultProxyFactory.js +66 -0
- package/src/utils/DefaultProxyFactory.js.map +1 -0
- package/src/utils/NormalizeZlibDeflateTransformStream.d.ts +8 -0
- package/src/utils/NormalizeZlibDeflateTransformStream.js +25 -0
- package/src/utils/NormalizeZlibDeflateTransformStream.js.map +1 -0
- package/src/utils/PatchedHttpsProxyAgent.d.ts +14 -0
- package/src/utils/PatchedHttpsProxyAgent.js +17 -0
- package/src/utils/PatchedHttpsProxyAgent.js.map +1 -0
- package/src/utils/ProxyFactory.d.ts +19 -0
- package/src/utils/ProxyFactory.js +5 -0
- package/src/utils/ProxyFactory.js.map +1 -0
- package/src/utils/index.d.ts +3 -0
- package/src/utils/index.js +7 -0
- package/src/utils/index.js.map +1 -0
- package/src/api/ExecuteRequestEventHandler.d.ts +0 -24
- package/src/api/ExecuteRequestEventHandler.js +0 -37
- package/src/api/ExecuteRequestEventHandler.js.map +0 -1
- package/src/api/commands/RegisterRepeaterCommand.d.ts +0 -22
- package/src/api/commands/RegisterRepeaterCommand.js +0 -18
- package/src/api/commands/RegisterRepeaterCommand.js.map +0 -1
- package/src/api/events/RepeaterStatusEvent.d.ts +0 -10
- package/src/api/events/RepeaterStatusEvent.js +0 -11
- package/src/api/events/RepeaterStatusEvent.js.map +0 -1
- package/src/api/events/index.d.ts +0 -1
- package/src/api/events/index.js +0 -5
- package/src/api/events/index.js.map +0 -1
- package/src/request-runner/protocols/WsRequestRunner.d.ts +0 -24
- package/src/request-runner/protocols/WsRequestRunner.js +0 -149
- package/src/request-runner/protocols/WsRequestRunner.js.map +0 -1
package/src/lib/Repeater.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Repeater = exports.RepeaterId = exports.RunningStatus = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const RepeaterServer_1 = require("./RepeaterServer");
|
|
6
|
+
const RepeaterCommands_1 = require("./RepeaterCommands");
|
|
7
|
+
const Request_1 = require("../request-runner/Request");
|
|
6
8
|
const core_1 = require("@sectester/core");
|
|
7
|
-
const semver_1 = require("semver");
|
|
8
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
|
+
const tsyringe_1 = require("tsyringe");
|
|
9
11
|
var RunningStatus;
|
|
10
12
|
(function (RunningStatus) {
|
|
11
13
|
RunningStatus[RunningStatus["OFF"] = 0] = "OFF";
|
|
@@ -13,14 +15,46 @@ var RunningStatus;
|
|
|
13
15
|
RunningStatus[RunningStatus["RUNNING"] = 2] = "RUNNING";
|
|
14
16
|
})(RunningStatus = exports.RunningStatus || (exports.RunningStatus = {}));
|
|
15
17
|
exports.RepeaterId = Symbol('RepeaterId');
|
|
16
|
-
class Repeater {
|
|
17
|
-
constructor(
|
|
18
|
-
this._runningStatus = RunningStatus.OFF;
|
|
18
|
+
let Repeater = class Repeater {
|
|
19
|
+
constructor(repeaterId, logger, repeaterServer, repeaterCommands) {
|
|
19
20
|
this.repeaterId = repeaterId;
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
this.
|
|
21
|
+
this.logger = logger;
|
|
22
|
+
this.repeaterServer = repeaterServer;
|
|
23
|
+
this.repeaterCommands = repeaterCommands;
|
|
24
|
+
this._runningStatus = RunningStatus.OFF;
|
|
25
|
+
this.handleError = ({ code, message, remediation }) => {
|
|
26
|
+
const normalizedMessage = this.normalizeMessage(message);
|
|
27
|
+
const normalizedRemediation = this.normalizeMessage(remediation !== null && remediation !== void 0 ? remediation : '');
|
|
28
|
+
if (this.isCriticalError(code)) {
|
|
29
|
+
this.handleCriticalError(normalizedMessage, normalizedRemediation);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.logger.error(normalizedMessage);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
this.upgradeAvailable = (event) => {
|
|
36
|
+
this.logger.warn('%s: A new Repeater version (%s) is available, for update instruction visit https://docs.brightsec.com/docs/installation-options', chalk_1.default.yellow('(!) IMPORTANT'), event.version);
|
|
37
|
+
};
|
|
38
|
+
this.reconnectAttempt = ({ attempt, maxAttempts }) => {
|
|
39
|
+
this.logger.warn('Failed to connect to Bright cloud (attempt %d/%d)', attempt, maxAttempts);
|
|
40
|
+
};
|
|
41
|
+
this.reconnectionFailed = ({ error }) => {
|
|
42
|
+
this.logger.error(error.message);
|
|
43
|
+
this.stop().catch(this.logger.error);
|
|
44
|
+
};
|
|
45
|
+
this.requestReceived = async (event) => {
|
|
46
|
+
const response = await this.repeaterCommands.sendRequest(new Request_1.Request({ ...event }));
|
|
47
|
+
const { statusCode, message, errorCode, body, headers, protocol, encoding } = response;
|
|
48
|
+
return {
|
|
49
|
+
protocol,
|
|
50
|
+
body,
|
|
51
|
+
headers,
|
|
52
|
+
statusCode,
|
|
53
|
+
errorCode,
|
|
54
|
+
message,
|
|
55
|
+
encoding
|
|
56
|
+
};
|
|
57
|
+
};
|
|
24
58
|
}
|
|
25
59
|
get runningStatus() {
|
|
26
60
|
return this._runningStatus;
|
|
@@ -31,9 +65,7 @@ class Repeater {
|
|
|
31
65
|
}
|
|
32
66
|
this._runningStatus = RunningStatus.STARTING;
|
|
33
67
|
try {
|
|
34
|
-
await this.
|
|
35
|
-
await this.subscribeToEvents();
|
|
36
|
-
await this.schedulePing();
|
|
68
|
+
await this.connect();
|
|
37
69
|
this._runningStatus = RunningStatus.RUNNING;
|
|
38
70
|
}
|
|
39
71
|
catch (e) {
|
|
@@ -42,67 +74,63 @@ class Repeater {
|
|
|
42
74
|
}
|
|
43
75
|
}
|
|
44
76
|
async stop() {
|
|
45
|
-
var _a, _b;
|
|
46
77
|
if (this.runningStatus !== RunningStatus.RUNNING) {
|
|
47
78
|
return;
|
|
48
79
|
}
|
|
49
80
|
this._runningStatus = RunningStatus.OFF;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
81
|
+
this.repeaterServer.disconnect();
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
}
|
|
84
|
+
async connect() {
|
|
85
|
+
this.logger.log('Connecting the Bridges');
|
|
86
|
+
this.subscribeDiagnosticEvents();
|
|
87
|
+
await this.repeaterServer.connect();
|
|
88
|
+
this.logger.log('Deploying the repeater');
|
|
89
|
+
await this.deploy();
|
|
90
|
+
this.logger.log('The Repeater (%s) started', this.repeaterId);
|
|
91
|
+
this.subscribeConnectedEvent();
|
|
55
92
|
}
|
|
56
|
-
async
|
|
57
|
-
|
|
58
|
-
version: this.configuration.repeaterVersion,
|
|
93
|
+
async deploy() {
|
|
94
|
+
await this.repeaterServer.deploy({
|
|
59
95
|
repeaterId: this.repeaterId
|
|
60
|
-
})
|
|
61
|
-
if (!res) {
|
|
62
|
-
throw new Error('Error registering repeater.');
|
|
63
|
-
}
|
|
64
|
-
this.handleRegisterResult(res);
|
|
96
|
+
});
|
|
65
97
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
api_1.ExecuteRequestEventHandler
|
|
69
|
-
// TODO repeater scripts
|
|
70
|
-
].map(type => this.bus.register(type)));
|
|
98
|
+
subscribeConnectedEvent() {
|
|
99
|
+
this.repeaterServer.on("connected" /* RepeaterServerEvents.CONNECTED */, this.deploy);
|
|
71
100
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
101
|
+
subscribeDiagnosticEvents() {
|
|
102
|
+
this.repeaterServer.on("error" /* RepeaterServerEvents.ERROR */, this.handleError);
|
|
103
|
+
this.repeaterServer.on("reconnection_failed" /* RepeaterServerEvents.RECONNECTION_FAILED */, this.reconnectionFailed);
|
|
104
|
+
this.repeaterServer.on("request" /* RepeaterServerEvents.REQUEST */, this.requestReceived);
|
|
105
|
+
this.repeaterServer.on("update_available" /* RepeaterServerEvents.UPDATE_AVAILABLE */, this.upgradeAvailable);
|
|
106
|
+
this.repeaterServer.on("reconnect_attempt" /* RepeaterServerEvents.RECONNECT_ATTEMPT */, this.reconnectAttempt);
|
|
107
|
+
this.repeaterServer.on("reconnection_succeeded" /* RepeaterServerEvents.RECONNECTION_SUCCEEDED */, () => this.logger.log('The Repeater (%s) connected', this.repeaterId));
|
|
76
108
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
status,
|
|
80
|
-
repeaterId: this.repeaterId
|
|
81
|
-
}));
|
|
109
|
+
normalizeMessage(message) {
|
|
110
|
+
return message.replace(/\.$/, '');
|
|
82
111
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
112
|
+
isCriticalError(code) {
|
|
113
|
+
return [
|
|
114
|
+
RepeaterServer_1.RepeaterErrorCodes.REPEATER_DEACTIVATED,
|
|
115
|
+
RepeaterServer_1.RepeaterErrorCodes.REPEATER_NO_LONGER_SUPPORTED,
|
|
116
|
+
RepeaterServer_1.RepeaterErrorCodes.REPEATER_UNAUTHORIZED,
|
|
117
|
+
RepeaterServer_1.RepeaterErrorCodes.REPEATER_ALREADY_STARTED,
|
|
118
|
+
RepeaterServer_1.RepeaterErrorCodes.REPEATER_NOT_PERMITTED,
|
|
119
|
+
RepeaterServer_1.RepeaterErrorCodes.UNEXPECTED_ERROR
|
|
120
|
+
].includes(code);
|
|
93
121
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new Error(`Access Refused: The current Repeater is not active.`);
|
|
98
|
-
case api_1.RepeaterRegisteringError.NOT_FOUND:
|
|
99
|
-
throw new Error(`Unauthorized access. Please check your credentials.`);
|
|
100
|
-
case api_1.RepeaterRegisteringError.BUSY:
|
|
101
|
-
throw new Error(`Access Refused: There is an already running Repeater with ID ${this.repeaterId}`);
|
|
102
|
-
case api_1.RepeaterRegisteringError.REQUIRES_TO_BE_UPDATED:
|
|
103
|
-
throw new Error(`${chalk_1.default.red('(!) CRITICAL')}: The current running version is no longer supported, please update @sectester.`);
|
|
104
|
-
}
|
|
122
|
+
handleCriticalError(message, remediation) {
|
|
123
|
+
this.logger.error('%s: %s. %s', chalk_1.default.red('(!) CRITICAL'), message, remediation);
|
|
124
|
+
this.stop().catch(this.logger.error);
|
|
105
125
|
}
|
|
106
|
-
}
|
|
126
|
+
};
|
|
127
|
+
Repeater = tslib_1.__decorate([
|
|
128
|
+
(0, tsyringe_1.scoped)(tsyringe_1.Lifecycle.ContainerScoped),
|
|
129
|
+
(0, tsyringe_1.injectable)(),
|
|
130
|
+
tslib_1.__param(0, (0, tsyringe_1.inject)(exports.RepeaterId)),
|
|
131
|
+
tslib_1.__param(2, (0, tsyringe_1.inject)(RepeaterServer_1.RepeaterServer)),
|
|
132
|
+
tslib_1.__param(3, (0, tsyringe_1.inject)(RepeaterCommands_1.RepeaterCommands)),
|
|
133
|
+
tslib_1.__metadata("design:paramtypes", [String, core_1.Logger, Object, Object])
|
|
134
|
+
], Repeater);
|
|
107
135
|
exports.Repeater = Repeater;
|
|
108
136
|
//# sourceMappingURL=Repeater.js.map
|
package/src/lib/Repeater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repeater.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/Repeater.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Repeater.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/Repeater.ts"],"names":[],"mappings":";;;;AAAA,qDAS0B;AAC1B,yDAAsD;AACtD,uDAAoD;AACpD,0CAAyC;AACzC,0DAA0B;AAC1B,uCAAiE;AAEjE,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+CAAG,CAAA;IACH,yDAAQ,CAAA;IACR,uDAAO,CAAA;AACT,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB;AAGY,QAAA,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAI/C,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAOnB,YAEkB,UAAsB,EACrB,MAAc,EAEd,cAA8B,EAE9B,gBAAkC;QALnC,eAAU,GAAV,UAAU,CAAY;QACrB,WAAM,GAAN,MAAM,CAAQ;QAEd,mBAAc,GAAd,cAAc,CAAgB;QAE9B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAb7C,mBAAc,GAAG,aAAa,CAAC,GAAG,CAAC;QA4FnC,gBAAW,GAAG,CAAC,EACrB,IAAI,EACJ,OAAO,EACP,WAAW,EACc,EAAE,EAAE;YAC7B,MAAM,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACzD,MAAM,qBAAqB,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC,CAAC;YAEvE,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;gBAC9B,IAAI,CAAC,mBAAm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Z,CAAC;QACF,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CAqDF,CAAA;AAxLY,QAAQ;IAFpB,IAAA,iBAAM,EAAC,oBAAS,CAAC,eAAe,CAAC;IACjC,IAAA,qBAAU,GAAE;IASR,mBAAA,IAAA,iBAAM,EAAC,kBAAU,CAAC,CAAA;IAGlB,mBAAA,IAAA,iBAAM,EAAC,+BAAc,CAAC,CAAA;IAEtB,mBAAA,IAAA,iBAAM,EAAC,mCAAgB,CAAC,CAAA;qDAHA,aAAM;GAVtB,QAAQ,CAwLpB;AAxLY,4BAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterCommands.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/RepeaterCommands.ts"],"names":[],"mappings":";;;AAMa,QAAA,gBAAgB,GAAkB,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Repeater } from './Repeater';
|
|
2
|
-
import { RepeaterOptions } from './RepeaterOptions';
|
|
3
2
|
import { RepeaterRequestRunnerOptions } from './RepeaterRequestRunnerOptions';
|
|
3
|
+
import { RepeaterOptions } from './RepeaterOptions';
|
|
4
4
|
import { Configuration } from '@sectester/core';
|
|
5
5
|
/**
|
|
6
6
|
* A factory that is able to create a dedicated instance of the repeater with a bus and other dependencies.
|
|
@@ -11,11 +11,10 @@ export declare class RepeaterFactory {
|
|
|
11
11
|
private readonly repeatersManager;
|
|
12
12
|
private readonly runnerOptions;
|
|
13
13
|
constructor(configuration: Configuration);
|
|
14
|
-
createRepeater({ projectId, description, disableRandomNameGeneration, namePrefix, ...
|
|
14
|
+
createRepeater({ projectId, description, disableRandomNameGeneration, namePrefix, ...options }?: RepeaterOptions): Promise<Repeater>;
|
|
15
15
|
createRepeaterFromExisting(repeaterId: string, options?: RepeaterRequestRunnerOptions): Promise<Repeater>;
|
|
16
16
|
private createRepeaterInstance;
|
|
17
|
-
private createEventBus;
|
|
18
|
-
private generateName;
|
|
19
17
|
private registerRequestRunners;
|
|
20
18
|
private registerRequestRunnerOptions;
|
|
19
|
+
private generateName;
|
|
21
20
|
}
|
|
@@ -20,52 +20,25 @@ let RepeaterFactory = class RepeaterFactory {
|
|
|
20
20
|
this.runnerOptions =
|
|
21
21
|
this.configuration.container.resolve(request_runner_1.RequestRunnerOptions);
|
|
22
22
|
}
|
|
23
|
-
async createRepeater({ projectId, description, disableRandomNameGeneration, namePrefix = 'sectester', ...
|
|
24
|
-
|
|
23
|
+
async createRepeater({ projectId, description, disableRandomNameGeneration, namePrefix = 'sectester', ...options } = {}) {
|
|
24
|
+
await this.configuration.loadCredentials();
|
|
25
25
|
const { repeaterId } = await this.repeatersManager.createRepeater({
|
|
26
26
|
description,
|
|
27
27
|
projectId,
|
|
28
|
-
name
|
|
28
|
+
name: this.generateName(namePrefix, disableRandomNameGeneration)
|
|
29
29
|
});
|
|
30
|
-
return this.createRepeaterInstance(repeaterId,
|
|
30
|
+
return this.createRepeaterInstance(repeaterId, options);
|
|
31
31
|
}
|
|
32
32
|
async createRepeaterFromExisting(repeaterId, options) {
|
|
33
33
|
await this.repeatersManager.getRepeater(repeaterId);
|
|
34
34
|
return this.createRepeaterInstance(repeaterId, options);
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
createRepeaterInstance(repeaterId, { requestRunnerOptions, requestRunners = [] } = {}) {
|
|
37
37
|
const container = this.configuration.container.createChildContainer();
|
|
38
|
-
container.register(Repeater_1.RepeaterId, {
|
|
39
|
-
useValue: repeaterId
|
|
40
|
-
});
|
|
38
|
+
container.register(Repeater_1.RepeaterId, { useValue: repeaterId });
|
|
41
39
|
this.registerRequestRunnerOptions(container, requestRunnerOptions);
|
|
42
|
-
this.registerRequestRunners(container, requestRunners);
|
|
43
|
-
|
|
44
|
-
return new Repeater_1.Repeater({
|
|
45
|
-
bus,
|
|
46
|
-
repeaterId,
|
|
47
|
-
configuration: this.configuration
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async createEventBus(container) {
|
|
51
|
-
var _a;
|
|
52
|
-
await this.configuration.loadCredentials();
|
|
53
|
-
if (!this.configuration.credentials) {
|
|
54
|
-
throw new Error('Please provide credentials to establish a connection with the bus.');
|
|
55
|
-
}
|
|
56
|
-
const bus = container.resolve(core_1.EventBus);
|
|
57
|
-
await ((_a = bus.init) === null || _a === void 0 ? void 0 : _a.call(bus));
|
|
58
|
-
return bus;
|
|
59
|
-
}
|
|
60
|
-
generateName(namePrefix, disableRandomNameGeneration = false) {
|
|
61
|
-
const normalizedPrefix = namePrefix === null || namePrefix === void 0 ? void 0 : namePrefix.trim();
|
|
62
|
-
const randomPostfix = disableRandomNameGeneration ? '' : `-${(0, uuid_1.v4)()}`;
|
|
63
|
-
const name = `${normalizedPrefix}${randomPostfix}`;
|
|
64
|
-
if (name.length > this.MAX_NAME_LENGTH) {
|
|
65
|
-
const maxPrefixLength = this.MAX_NAME_LENGTH - randomPostfix.length;
|
|
66
|
-
throw new Error(`Name prefix must be less than or equal to ${maxPrefixLength} characters.`);
|
|
67
|
-
}
|
|
68
|
-
return name;
|
|
40
|
+
this.registerRequestRunners(container, requestRunners !== null && requestRunners !== void 0 ? requestRunners : []);
|
|
41
|
+
return container.resolve(Repeater_1.Repeater);
|
|
69
42
|
}
|
|
70
43
|
registerRequestRunners(container, requestRunners) {
|
|
71
44
|
requestRunners.forEach(runner => {
|
|
@@ -91,6 +64,16 @@ let RepeaterFactory = class RepeaterFactory {
|
|
|
91
64
|
}
|
|
92
65
|
});
|
|
93
66
|
}
|
|
67
|
+
generateName(namePrefix, disableRandomNameGeneration = false) {
|
|
68
|
+
const normalizedPrefix = namePrefix === null || namePrefix === void 0 ? void 0 : namePrefix.trim();
|
|
69
|
+
const randomPostfix = disableRandomNameGeneration ? '' : `-${(0, uuid_1.v4)()}`;
|
|
70
|
+
const name = `${normalizedPrefix}${randomPostfix}`;
|
|
71
|
+
if (name.length > this.MAX_NAME_LENGTH) {
|
|
72
|
+
const maxPrefixLength = this.MAX_NAME_LENGTH - randomPostfix.length;
|
|
73
|
+
throw new Error(`Name prefix must be less than or equal to ${maxPrefixLength} characters.`);
|
|
74
|
+
}
|
|
75
|
+
return name;
|
|
76
|
+
}
|
|
94
77
|
};
|
|
95
78
|
RepeaterFactory = tslib_1.__decorate([
|
|
96
79
|
(0, tsyringe_1.injectable)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterFactory.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/RepeaterFactory.ts"],"names":[],"mappings":";;;;AAAA,yCAAkD;AAClD,sDAAwE;AAExE,gCAA0C;AAE1C,
|
|
1
|
+
{"version":3,"file":"RepeaterFactory.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/RepeaterFactory.ts"],"names":[],"mappings":";;;;AAAA,yCAAkD;AAClD,sDAAwE;AAExE,gCAA0C;AAE1C,0CAAgD;AAChD,+BAAoC;AACpC,uCAAsE;AAEtE;;GAEG;AAEH,IAAa,eAAe,GAA5B,MAAa,eAAe;IAK1B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAJxC,oBAAe,GAAG,EAAE,CAAC;QAKpC,IAAI,CAAC,gBAAgB;YACnB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,sBAAgB,CAAC,CAAC;QACzD,IAAI,CAAC,aAAa;YAChB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,qCAAoB,CAAC,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,EAC1B,SAAS,EACT,WAAW,EACX,2BAA2B,EAC3B,UAAU,GAAG,WAAW,EACxB,GAAG,OAAO,KACS,EAAE;QACrB,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;QAE3C,MAAM,EAAE,UAAU,EAAE,GAA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QAAQ,CAAC,8BAAa,EAAE;oBAChC,QAAQ,EAAE,MAAM;iBACjB,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,4BAA4B,CAClC,SAA8B,EAC9B,OAAyC;QAEzC,SAAS,CAAC,QAAQ,CAAC,qCAAoB,EAAE;YACvC,QAAQ,EAAE;gBACR,GAAG,IAAI,CAAC,aAAa;gBACrB,GAAG,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;aACnB;SACF,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAClB,UAAkB,EAClB,8BAAuC,KAAK;QAE5C,MAAM,gBAAgB,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,EAAE,CAAC;QAC5C,MAAM,aAAa,GAAG,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAA,SAAM,GAAE,EAAE,CAAC;QACxE,MAAM,IAAI,GAAG,GAAG,gBAAgB,GAAG,aAAa,EAAE,CAAC;QAEnD,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE;YACtC,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC;YAEpE,MAAM,IAAI,KAAK,CACb,6CAA6C,eAAe,cAAc,CAC3E,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAhHY,eAAe;IAD3B,IAAA,qBAAU,GAAE;6CAMiC,oBAAa;GAL9C,eAAe,CAgH3B;AAhHY,0CAAe"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Protocol } from '../models/Protocol';
|
|
2
|
+
export interface RepeaterServerDeployedEvent {
|
|
3
|
+
repeaterId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RepeaterServerRequestEvent {
|
|
6
|
+
protocol: Protocol;
|
|
7
|
+
url: string;
|
|
8
|
+
method?: string;
|
|
9
|
+
headers?: Record<string, string | string[]>;
|
|
10
|
+
correlationIdRegex?: string;
|
|
11
|
+
body?: string;
|
|
12
|
+
encoding?: 'base64';
|
|
13
|
+
maxContentSize?: number;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare type RepeaterServerRequestResponse = {
|
|
17
|
+
protocol: Protocol;
|
|
18
|
+
statusCode?: number;
|
|
19
|
+
message?: string;
|
|
20
|
+
errorCode?: string;
|
|
21
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
22
|
+
body?: string;
|
|
23
|
+
} | {
|
|
24
|
+
protocol: Protocol;
|
|
25
|
+
message?: string;
|
|
26
|
+
errorCode?: string;
|
|
27
|
+
};
|
|
28
|
+
export interface RepeaterServerReconnectionFailedEvent {
|
|
29
|
+
error: Error;
|
|
30
|
+
}
|
|
31
|
+
export interface RepeaterServerReconnectionAttemptedEvent {
|
|
32
|
+
attempt: number;
|
|
33
|
+
maxAttempts: number;
|
|
34
|
+
}
|
|
35
|
+
export declare enum RepeaterErrorCodes {
|
|
36
|
+
REPEATER_NOT_PERMITTED = "repeater_not_permitted",
|
|
37
|
+
REPEATER_ALREADY_STARTED = "repeater_already_started",
|
|
38
|
+
REPEATER_DEACTIVATED = "repeater_deactivated",
|
|
39
|
+
REPEATER_UNAUTHORIZED = "repeater_unauthorized",
|
|
40
|
+
REPEATER_NO_LONGER_SUPPORTED = "repeater_no_longer_supported",
|
|
41
|
+
UNKNOWN_ERROR = "unknown_error",
|
|
42
|
+
UNEXPECTED_ERROR = "unexpected_error"
|
|
43
|
+
}
|
|
44
|
+
export interface RepeaterServerErrorEvent {
|
|
45
|
+
message: string;
|
|
46
|
+
code: RepeaterErrorCodes;
|
|
47
|
+
transaction?: string;
|
|
48
|
+
remediation?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface RepeaterUpgradeAvailableEvent {
|
|
51
|
+
version: string;
|
|
52
|
+
}
|
|
53
|
+
export interface DeployCommandOptions {
|
|
54
|
+
repeaterId?: string;
|
|
55
|
+
}
|
|
56
|
+
export declare const enum RepeaterServerEvents {
|
|
57
|
+
DEPLOYED = "deployed",
|
|
58
|
+
DEPLOY = "deploy",
|
|
59
|
+
CONNECTED = "connected",
|
|
60
|
+
DISCONNECTED = "disconnected",
|
|
61
|
+
REQUEST = "request",
|
|
62
|
+
UPDATE_AVAILABLE = "update_available",
|
|
63
|
+
RECONNECTION_FAILED = "reconnection_failed",
|
|
64
|
+
RECONNECT_ATTEMPT = "reconnect_attempt",
|
|
65
|
+
RECONNECTION_SUCCEEDED = "reconnection_succeeded",
|
|
66
|
+
ERROR = "error",
|
|
67
|
+
PING = "ping"
|
|
68
|
+
}
|
|
69
|
+
export interface RepeaterServerEventsMap {
|
|
70
|
+
[RepeaterServerEvents.DEPLOY]: [DeployCommandOptions];
|
|
71
|
+
[RepeaterServerEvents.DEPLOYED]: RepeaterServerDeployedEvent;
|
|
72
|
+
[RepeaterServerEvents.CONNECTED]: void;
|
|
73
|
+
[RepeaterServerEvents.DISCONNECTED]: void;
|
|
74
|
+
[RepeaterServerEvents.REQUEST]: RepeaterServerRequestEvent;
|
|
75
|
+
[RepeaterServerEvents.UPDATE_AVAILABLE]: RepeaterUpgradeAvailableEvent;
|
|
76
|
+
[RepeaterServerEvents.RECONNECTION_FAILED]: RepeaterServerReconnectionFailedEvent;
|
|
77
|
+
[RepeaterServerEvents.RECONNECT_ATTEMPT]: RepeaterServerReconnectionAttemptedEvent;
|
|
78
|
+
[RepeaterServerEvents.RECONNECTION_SUCCEEDED]: void;
|
|
79
|
+
[RepeaterServerEvents.ERROR]: RepeaterServerErrorEvent;
|
|
80
|
+
[RepeaterServerEvents.PING]: void;
|
|
81
|
+
}
|
|
82
|
+
export declare type RepeaterServerEventHandler<K extends keyof RepeaterServerEventsMap> = (...args: RepeaterServerEventsMap[K] extends (infer U)[] ? U[] : [RepeaterServerEventsMap[K]]) => unknown;
|
|
83
|
+
export declare type CallbackFunction<T = unknown> = (arg: T) => unknown;
|
|
84
|
+
export declare type HandlerFunction = (args: unknown[]) => unknown;
|
|
85
|
+
export interface RepeaterServer {
|
|
86
|
+
connect(domain?: string): Promise<void>;
|
|
87
|
+
disconnect(): void;
|
|
88
|
+
deploy(options?: DeployCommandOptions): Promise<RepeaterServerDeployedEvent>;
|
|
89
|
+
on<K extends keyof RepeaterServerEventsMap>(event: K, handler: RepeaterServerEventHandler<K>): void;
|
|
90
|
+
off<K extends keyof RepeaterServerEventsMap>(event: K, handler?: RepeaterServerEventHandler<K>): void;
|
|
91
|
+
}
|
|
92
|
+
export declare const RepeaterServer: unique symbol;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RepeaterServer = exports.RepeaterErrorCodes = void 0;
|
|
4
|
+
var RepeaterErrorCodes;
|
|
5
|
+
(function (RepeaterErrorCodes) {
|
|
6
|
+
RepeaterErrorCodes["REPEATER_NOT_PERMITTED"] = "repeater_not_permitted";
|
|
7
|
+
RepeaterErrorCodes["REPEATER_ALREADY_STARTED"] = "repeater_already_started";
|
|
8
|
+
RepeaterErrorCodes["REPEATER_DEACTIVATED"] = "repeater_deactivated";
|
|
9
|
+
RepeaterErrorCodes["REPEATER_UNAUTHORIZED"] = "repeater_unauthorized";
|
|
10
|
+
RepeaterErrorCodes["REPEATER_NO_LONGER_SUPPORTED"] = "repeater_no_longer_supported";
|
|
11
|
+
RepeaterErrorCodes["UNKNOWN_ERROR"] = "unknown_error";
|
|
12
|
+
RepeaterErrorCodes["UNEXPECTED_ERROR"] = "unexpected_error";
|
|
13
|
+
})(RepeaterErrorCodes = exports.RepeaterErrorCodes || (exports.RepeaterErrorCodes = {}));
|
|
14
|
+
exports.RepeaterServer = Symbol('RepeaterServer');
|
|
15
|
+
//# sourceMappingURL=RepeaterServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterServer.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/RepeaterServer.ts"],"names":[],"mappings":";;;AA0CA,IAAY,kBAQX;AARD,WAAY,kBAAkB;IAC5B,uEAAiD,CAAA;IACjD,2EAAqD,CAAA;IACrD,mEAA6C,CAAA;IAC7C,qEAA+C,CAAA;IAC/C,mFAA6D,CAAA;IAC7D,qDAA+B,CAAA;IAC/B,2DAAqC,CAAA;AACvC,CAAC,EARW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAQ7B;AA0EY,QAAA,cAAc,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
|
package/src/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export * from './Repeater';
|
|
2
|
+
export * from './RepeaterFactory';
|
|
3
|
+
export * from './RepeaterOptions';
|
|
4
|
+
export * from './RepeaterRequestRunnerOptions';
|
|
5
|
+
export * from './DefaultRepeaterCommands';
|
|
6
|
+
export * from './DefaultRepeaterServer';
|
|
7
|
+
export * from './RepeaterCommands';
|
|
8
|
+
export * from './RepeaterServer';
|
package/src/lib/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./Repeater"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./RepeaterFactory"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./RepeaterOptions"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./RepeaterRequestRunnerOptions"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./DefaultRepeaterCommands"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./DefaultRepeaterServer"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./RepeaterCommands"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./RepeaterServer"), exports);
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/src/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,4DAAkC;AAClC,4DAAkC;AAClC,yEAA+C;AAC/C,oEAA0C;AAC1C,kEAAwC;AACxC,6DAAmC;AACnC,2DAAiC"}
|
package/src/models/Protocol.d.ts
CHANGED
package/src/models/Protocol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Protocol.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/models/Protocol.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"Protocol.js","sourceRoot":"","sources":["../../../../../packages/repeater/src/models/Protocol.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAEX;AAFD,WAAY,QAAQ;IAClB,yBAAa,CAAA;AACf,CAAC,EAFW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAEnB"}
|
package/src/register.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const lib_1 = require("./lib");
|
|
4
|
-
const api_1 = require("./api");
|
|
5
4
|
const request_runner_1 = require("./request-runner");
|
|
5
|
+
const api_1 = require("./api");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
6
7
|
const tsyringe_1 = require("tsyringe");
|
|
7
8
|
const core_1 = require("@sectester/core");
|
|
8
|
-
const bus_1 = require("@sectester/bus");
|
|
9
9
|
tsyringe_1.container.register(request_runner_1.RequestRunner, {
|
|
10
10
|
useClass: request_runner_1.HttpRequestRunner
|
|
11
11
|
});
|
|
12
|
-
tsyringe_1.container.register(request_runner_1.RequestRunner, {
|
|
13
|
-
useClass: request_runner_1.WsRequestRunner
|
|
14
|
-
});
|
|
15
12
|
tsyringe_1.container.register(request_runner_1.RequestRunnerOptions, {
|
|
16
13
|
useValue: {
|
|
17
14
|
timeout: 30000,
|
|
@@ -40,21 +37,21 @@ tsyringe_1.container.register(lib_1.RepeaterFactory, {
|
|
|
40
37
|
return new lib_1.RepeaterFactory(childContainer.resolve(core_1.Configuration));
|
|
41
38
|
}
|
|
42
39
|
});
|
|
43
|
-
tsyringe_1.container.register(
|
|
44
|
-
useFactory: (0, tsyringe_1.instancePerContainerCachingFactory)((childContainer) => ({
|
|
45
|
-
exchange: 'EventBus',
|
|
46
|
-
appQueue: 'app',
|
|
47
|
-
clientQueue: `agent:${childContainer.resolve(lib_1.RepeaterId)}`
|
|
48
|
-
}))
|
|
49
|
-
});
|
|
50
|
-
tsyringe_1.container.register(core_1.EventBus, {
|
|
40
|
+
tsyringe_1.container.register(lib_1.DefaultRepeaterServerOptions, {
|
|
51
41
|
useFactory: (childContainer) => {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return
|
|
42
|
+
const configuration = childContainer.resolve(core_1.Configuration);
|
|
43
|
+
if (!configuration.credentials) {
|
|
44
|
+
throw new Error('Please provide credentials to establish a connection with the bridges.');
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
uri: `${configuration.api}/workstations`,
|
|
48
|
+
token: configuration.credentials.token,
|
|
49
|
+
connectTimeout: 10000
|
|
50
|
+
};
|
|
57
51
|
}
|
|
58
52
|
});
|
|
53
|
+
tsyringe_1.container.register(utils_1.ProxyFactory, { useClass: utils_1.DefaultProxyFactory });
|
|
54
|
+
tsyringe_1.container.register(lib_1.RepeaterServer, { useClass: lib_1.DefaultRepeaterServer });
|
|
55
|
+
tsyringe_1.container.register(lib_1.RepeaterCommands, { useClass: lib_1.DefaultRepeaterCommands });
|
|
59
56
|
tsyringe_1.container.register(api_1.RepeatersManager, { useClass: api_1.DefaultRepeatersManager });
|
|
60
57
|
//# sourceMappingURL=register.js.map
|
package/src/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../packages/repeater/src/register.ts"],"names":[],"mappings":";;AAAA,+
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../packages/repeater/src/register.ts"],"names":[],"mappings":";;AAAA,+BAOe;AACf,qDAI0B;AAC1B,+BAAkE;AAClE,mCAA4D;AAC5D,uCAA0D;AAC1D,0CAAgD;AAEhD,oBAAS,CAAC,QAAQ,CAAC,8BAAa,EAAE;IAChC,QAAQ,EAAE,kCAAiB;CAC5B,CAAC,CAAC;AAEH,oBAAS,CAAC,QAAQ,CAAC,qCAAoB,EAAE;IACvC,QAAQ,EAAE;QACR,OAAO,EAAE,KAAK;QACd,gBAAgB,EAAE,GAAG;QACrB,eAAe,EAAE,KAAK;QACtB,YAAY,EAAE;YACZ,WAAW;YACX,YAAY;YACZ,UAAU;YACV,iBAAiB;YACjB,eAAe;YACf,UAAU;YACV,wBAAwB;YACxB,0BAA0B;YAC1B,kBAAkB;YAClB,iBAAiB;YACjB,mCAAmC;YACnC,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;SACtB;KACF;CACF,CAAC,CAAC;AAEH,oBAAS,CAAC,QAAQ,CAAC,qBAAe,EAAE;IAClC,UAAU,CAAC,cAAmC;QAC5C,OAAO,IAAI,qBAAe,CAAC,cAAc,CAAC,OAAO,CAAC,oBAAa,CAAC,CAAC,CAAC;IACpE,CAAC;CACF,CAAC,CAAC;AAEH,oBAAS,CAAC,QAAQ,CAAC,kCAA4B,EAAE;IAC/C,UAAU,EAAE,CAAC,cAAmC,EAAE,EAAE;QAClD,MAAM,aAAa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