@sectester/core 0.16.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.
- package/LICENSE +21 -0
- package/README.md +281 -0
- package/package.json +49 -0
- package/src/bus/Command.d.ts +14 -0
- package/src/bus/Command.js +23 -0
- package/src/bus/Command.js.map +1 -0
- package/src/bus/CommandDispatcher.d.ts +5 -0
- package/src/bus/CommandDispatcher.js +5 -0
- package/src/bus/CommandDispatcher.js.map +1 -0
- package/src/bus/Event.d.ts +7 -0
- package/src/bus/Event.js +14 -0
- package/src/bus/Event.js.map +1 -0
- package/src/bus/EventBus.d.ts +10 -0
- package/src/bus/EventBus.js +5 -0
- package/src/bus/EventBus.js.map +1 -0
- package/src/bus/EventDispatcher.d.ts +5 -0
- package/src/bus/EventDispatcher.js +5 -0
- package/src/bus/EventDispatcher.js.map +1 -0
- package/src/bus/EventHandler.d.ts +4 -0
- package/src/bus/EventHandler.js +3 -0
- package/src/bus/EventHandler.js.map +1 -0
- package/src/bus/Message.d.ts +7 -0
- package/src/bus/Message.js +15 -0
- package/src/bus/Message.js.map +1 -0
- package/src/bus/RetryStartegy.d.ts +4 -0
- package/src/bus/RetryStartegy.js +5 -0
- package/src/bus/RetryStartegy.js.map +1 -0
- package/src/bus/decorators/bind.d.ts +3 -0
- package/src/bus/decorators/bind.js +22 -0
- package/src/bus/decorators/bind.js.map +1 -0
- package/src/bus/decorators/index.d.ts +1 -0
- package/src/bus/decorators/index.js +5 -0
- package/src/bus/decorators/index.js.map +1 -0
- package/src/bus/exceptions/EventHandlerNotFound.d.ts +4 -0
- package/src/bus/exceptions/EventHandlerNotFound.js +11 -0
- package/src/bus/exceptions/EventHandlerNotFound.js.map +1 -0
- package/src/bus/exceptions/IllegalOperation.d.ts +6 -0
- package/src/bus/exceptions/IllegalOperation.js +12 -0
- package/src/bus/exceptions/IllegalOperation.js.map +1 -0
- package/src/bus/exceptions/NoResponse.d.ts +4 -0
- package/src/bus/exceptions/NoResponse.js +11 -0
- package/src/bus/exceptions/NoResponse.js.map +1 -0
- package/src/bus/exceptions/NoSubscriptionsFound.d.ts +5 -0
- package/src/bus/exceptions/NoSubscriptionsFound.js +12 -0
- package/src/bus/exceptions/NoSubscriptionsFound.js.map +1 -0
- package/src/bus/exceptions/UnsupportedEventType.d.ts +4 -0
- package/src/bus/exceptions/UnsupportedEventType.js +12 -0
- package/src/bus/exceptions/UnsupportedEventType.js.map +1 -0
- package/src/bus/exceptions/index.d.ts +5 -0
- package/src/bus/exceptions/index.js +9 -0
- package/src/bus/exceptions/index.js.map +1 -0
- package/src/bus/index.d.ts +10 -0
- package/src/bus/index.js +14 -0
- package/src/bus/index.js.map +1 -0
- package/src/configuration/Configuration.d.ts +33 -0
- package/src/configuration/Configuration.js +96 -0
- package/src/configuration/Configuration.js.map +1 -0
- package/src/configuration/index.d.ts +1 -0
- package/src/configuration/index.js +5 -0
- package/src/configuration/index.js.map +1 -0
- package/src/credentials-provider/Credentials.d.ts +9 -0
- package/src/credentials-provider/Credentials.js +20 -0
- package/src/credentials-provider/Credentials.js.map +1 -0
- package/src/credentials-provider/CredentialsProvider.d.ts +5 -0
- package/src/credentials-provider/CredentialsProvider.js +5 -0
- package/src/credentials-provider/CredentialsProvider.js.map +1 -0
- package/src/credentials-provider/EnvCredentialProvider.d.ts +5 -0
- package/src/credentials-provider/EnvCredentialProvider.js +12 -0
- package/src/credentials-provider/EnvCredentialProvider.js.map +1 -0
- package/src/credentials-provider/index.d.ts +3 -0
- package/src/credentials-provider/index.js +7 -0
- package/src/credentials-provider/index.js.map +1 -0
- package/src/exceptions/SecTesterError.d.ts +3 -0
- package/src/exceptions/SecTesterError.js +11 -0
- package/src/exceptions/SecTesterError.js.map +1 -0
- package/src/exceptions/index.d.ts +1 -0
- package/src/exceptions/index.js +5 -0
- package/src/exceptions/index.js.map +1 -0
- package/src/index.d.ts +8 -0
- package/src/index.js +26 -0
- package/src/index.js.map +1 -0
- package/src/logger/Logger.d.ts +21 -0
- package/src/logger/Logger.js +70 -0
- package/src/logger/Logger.js.map +1 -0
- package/src/logger/index.d.ts +1 -0
- package/src/logger/index.js +5 -0
- package/src/logger/index.js.map +1 -0
- package/src/register.d.ts +1 -0
- package/src/register.js +13 -0
- package/src/register.js.map +1 -0
- package/src/utils/check-boundaries.d.ts +7 -0
- package/src/utils/check-boundaries.js +24 -0
- package/src/utils/check-boundaries.js.map +1 -0
- package/src/utils/contains.d.ts +1 -0
- package/src/utils/contains.js +6 -0
- package/src/utils/contains.js.map +1 -0
- package/src/utils/delay.d.ts +1 -0
- package/src/utils/delay.js +7 -0
- package/src/utils/delay.js.map +1 -0
- package/src/utils/first.d.ts +1 -0
- package/src/utils/first.js +10 -0
- package/src/utils/first.js.map +1 -0
- package/src/utils/get-type-name.d.ts +6 -0
- package/src/utils/get-type-name.js +11 -0
- package/src/utils/get-type-name.js.map +1 -0
- package/src/utils/index.d.ts +7 -0
- package/src/utils/index.js +11 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/truncate.d.ts +1 -0
- package/src/utils/truncate.js +6 -0
- package/src/utils/truncate.js.map +1 -0
- package/src/utils/types.d.ts +11 -0
- package/src/utils/types.js +26 -0
- package/src/utils/types.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoResponse.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/NoResponse.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAElD,MAAa,UAAW,SAAQ,2BAAc;IAC5C,YAAY,QAAgB;QAC1B,KAAK,CAAC,mBAAmB,QAAQ,WAAW,CAAC,CAAC;IAChD,CAAC;CACF;AAJD,gCAIC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoSubscriptionsFound = void 0;
|
|
4
|
+
const exceptions_1 = require("../../exceptions");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
class NoSubscriptionsFound extends exceptions_1.SecTesterError {
|
|
7
|
+
constructor(handler) {
|
|
8
|
+
super(`No subscriptions found. Please use '@bind()' decorator to subscribe ${(0, utils_1.getTypeName)(handler)} to events.`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.NoSubscriptionsFound = NoSubscriptionsFound;
|
|
12
|
+
//# sourceMappingURL=NoSubscriptionsFound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoSubscriptionsFound.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/NoSubscriptionsFound.ts"],"names":[],"mappings":";;;AACA,iDAAkD;AAClD,uCAA0C;AAE1C,MAAa,oBAAqB,SAAQ,2BAAc;IACtD,YAAY,OAAuC;QACjD,KAAK,CACH,uEAAuE,IAAA,mBAAW,EAChF,OAAO,CACR,aAAa,CACf,CAAC;IACJ,CAAC;CACF;AARD,oDAQC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnsupportedEventType = void 0;
|
|
4
|
+
const exceptions_1 = require("../../exceptions");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
class UnsupportedEventType extends exceptions_1.SecTesterError {
|
|
7
|
+
constructor(event) {
|
|
8
|
+
super(`${(0, utils_1.getTypeName)(event)} cannot be used with the @bind decorator.`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.UnsupportedEventType = UnsupportedEventType;
|
|
12
|
+
//# sourceMappingURL=UnsupportedEventType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnsupportedEventType.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/UnsupportedEventType.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAClD,uCAA0C;AAE1C,MAAa,oBAAqB,SAAQ,2BAAc;IACtD,YAAY,KAAc;QACxB,KAAK,CAAC,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC1E,CAAC;CACF;AAJD,oDAIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./NoResponse"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./IllegalOperation"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./EventHandlerNotFound"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./NoSubscriptionsFound"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./UnsupportedEventType"), exports);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,4DAA6B;AAC7B,kEAAmC;AACnC,sEAAuC;AACvC,sEAAuC;AACvC,sEAAuC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './Command';
|
|
2
|
+
export * from './CommandDispatcher';
|
|
3
|
+
export * from './Event';
|
|
4
|
+
export * from './Message';
|
|
5
|
+
export * from './EventDispatcher';
|
|
6
|
+
export * from './EventBus';
|
|
7
|
+
export * from './RetryStartegy';
|
|
8
|
+
export * from './EventHandler';
|
|
9
|
+
export * from './exceptions';
|
|
10
|
+
export * from './decorators';
|
package/src/bus/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./Command"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./CommandDispatcher"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./Event"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./Message"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./EventDispatcher"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./EventBus"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./RetryStartegy"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./EventHandler"), exports);
|
|
12
|
+
(0, tslib_1.__exportStar)(require("./exceptions"), exports);
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./decorators"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/index.ts"],"names":[],"mappings":";;;AAAA,yDAA0B;AAC1B,mEAAoC;AACpC,uDAAwB;AACxB,yDAA0B;AAC1B,iEAAkC;AAClC,0DAA2B;AAC3B,+DAAgC;AAChC,8DAA+B;AAC/B,4DAA6B;AAC7B,4DAA6B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CredentialProvider, Credentials, CredentialsOptions } from '../credentials-provider';
|
|
2
|
+
import { LogLevel } from '../logger';
|
|
3
|
+
export interface ConfigurationOptions {
|
|
4
|
+
hostname: string;
|
|
5
|
+
logLevel?: LogLevel;
|
|
6
|
+
credentials?: Credentials | CredentialsOptions;
|
|
7
|
+
credentialProviders?: CredentialProvider[];
|
|
8
|
+
}
|
|
9
|
+
export declare class Configuration {
|
|
10
|
+
private readonly SCHEMA_REGEXP;
|
|
11
|
+
private readonly HOSTNAME_NORMALIZATION_REGEXP;
|
|
12
|
+
private _credentialProviders?;
|
|
13
|
+
get credentialProviders(): readonly CredentialProvider[] | undefined;
|
|
14
|
+
private _container;
|
|
15
|
+
get container(): import("tsyringe").DependencyContainer;
|
|
16
|
+
private _credentials?;
|
|
17
|
+
get credentials(): Credentials | undefined;
|
|
18
|
+
private _bus;
|
|
19
|
+
get bus(): string;
|
|
20
|
+
private _api;
|
|
21
|
+
get api(): string;
|
|
22
|
+
private _logLevel?;
|
|
23
|
+
get logLevel(): LogLevel | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated use {@link version} right after v1 has been released
|
|
26
|
+
*/
|
|
27
|
+
get repeaterVersion(): string;
|
|
28
|
+
get version(): string;
|
|
29
|
+
get name(): string;
|
|
30
|
+
constructor({ hostname, credentials, logLevel, credentialProviders }: ConfigurationOptions);
|
|
31
|
+
loadCredentials(): Promise<void>;
|
|
32
|
+
private resolveUrls;
|
|
33
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var Configuration_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Configuration = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const credentials_provider_1 = require("../credentials-provider");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const package_json_1 = require("../../package.json");
|
|
10
|
+
const tsyringe_1 = require("tsyringe");
|
|
11
|
+
let Configuration = Configuration_1 = class Configuration {
|
|
12
|
+
constructor({ hostname, credentials, logLevel = logger_1.LogLevel.ERROR, credentialProviders = [new credentials_provider_1.EnvCredentialProvider()] }) {
|
|
13
|
+
this.SCHEMA_REGEXP = /^.+:\/\//;
|
|
14
|
+
this.HOSTNAME_NORMALIZATION_REGEXP = /^(?!(?:\w+:)?\/\/)|^\/\//;
|
|
15
|
+
this._container = tsyringe_1.container.createChildContainer();
|
|
16
|
+
if (!credentials && !(credentialProviders === null || credentialProviders === void 0 ? void 0 : credentialProviders.length)) {
|
|
17
|
+
throw new Error(`Please provide either 'credentials' or 'credentialProviders'`);
|
|
18
|
+
}
|
|
19
|
+
if (credentials) {
|
|
20
|
+
this._credentials = new credentials_provider_1.Credentials(credentials);
|
|
21
|
+
}
|
|
22
|
+
this._credentialProviders = credentialProviders;
|
|
23
|
+
if (!hostname) {
|
|
24
|
+
throw new Error(`Please provide 'hostname' option.`);
|
|
25
|
+
}
|
|
26
|
+
this.resolveUrls(hostname);
|
|
27
|
+
this._logLevel = logLevel;
|
|
28
|
+
this._container.register(Configuration_1, { useValue: this });
|
|
29
|
+
}
|
|
30
|
+
get credentialProviders() {
|
|
31
|
+
return this._credentialProviders;
|
|
32
|
+
}
|
|
33
|
+
get container() {
|
|
34
|
+
return this._container;
|
|
35
|
+
}
|
|
36
|
+
get credentials() {
|
|
37
|
+
return this._credentials;
|
|
38
|
+
}
|
|
39
|
+
get bus() {
|
|
40
|
+
return this._bus;
|
|
41
|
+
}
|
|
42
|
+
get api() {
|
|
43
|
+
return this._api;
|
|
44
|
+
}
|
|
45
|
+
get logLevel() {
|
|
46
|
+
return this._logLevel;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated use {@link version} right after v1 has been released
|
|
50
|
+
*/
|
|
51
|
+
get repeaterVersion() {
|
|
52
|
+
return package_json_1.secTester.repeaterVersion;
|
|
53
|
+
}
|
|
54
|
+
get version() {
|
|
55
|
+
return package_json_1.version;
|
|
56
|
+
}
|
|
57
|
+
get name() {
|
|
58
|
+
return package_json_1.secTester.name;
|
|
59
|
+
}
|
|
60
|
+
async loadCredentials() {
|
|
61
|
+
var _a;
|
|
62
|
+
if (!this.credentials) {
|
|
63
|
+
const chain = ((_a = this.credentialProviders) !== null && _a !== void 0 ? _a : []).map(provider => provider.get());
|
|
64
|
+
const credentials = await (0, utils_1.first)(chain, val => !!val);
|
|
65
|
+
if (!credentials) {
|
|
66
|
+
throw new Error('Could not load credentials from any providers');
|
|
67
|
+
}
|
|
68
|
+
this._credentials = new credentials_provider_1.Credentials(credentials);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
resolveUrls(hostname) {
|
|
72
|
+
if (!this.SCHEMA_REGEXP.test(hostname)) {
|
|
73
|
+
hostname = hostname.replace(this.HOSTNAME_NORMALIZATION_REGEXP, 'https://');
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
({ hostname } = new URL(hostname));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new Error(`Please make sure that you pass correct 'hostname' option.`);
|
|
80
|
+
}
|
|
81
|
+
if (['localhost', '127.0.0.1'].includes(hostname)) {
|
|
82
|
+
this._bus = `amqp://${hostname}:5672`;
|
|
83
|
+
this._api = `http://${hostname}:8000`;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this._bus = `amqps://amq.${hostname}:5672`;
|
|
87
|
+
this._api = `https://${hostname}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
Configuration = Configuration_1 = (0, tslib_1.__decorate)([
|
|
92
|
+
(0, tsyringe_1.injectable)(),
|
|
93
|
+
(0, tslib_1.__metadata)("design:paramtypes", [Object])
|
|
94
|
+
], Configuration);
|
|
95
|
+
exports.Configuration = Configuration;
|
|
96
|
+
//# sourceMappingURL=Configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../../../packages/core/src/configuration/Configuration.ts"],"names":[],"mappings":";;;;;AAAA,kEAKiC;AACjC,oCAAiC;AACjC,sCAAqC;AACrC,qDAAwD;AACxD,uCAAiD;AAUjD,IAAa,aAAa,qBAA1B,MAAa,aAAa;IAuDxB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,GAAG,iBAAQ,CAAC,KAAK,EACzB,mBAAmB,GAAG,CAAC,IAAI,4CAAqB,EAAE,CAAC,EAC9B;QA3DN,kBAAa,GAAG,UAAU,CAAC;QAC3B,kCAA6B,GAAG,0BAA0B,CAAC;QAQpE,eAAU,GAAG,oBAAS,CAAC,oBAAoB,EAAE,CAAC;QAmDpD,IAAI,CAAC,WAAW,IAAI,CAAC,CAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,C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":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/configuration/index.ts"],"names":[],"mappings":";;;AAAA,+DAAgC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Credentials = void 0;
|
|
4
|
+
class Credentials {
|
|
5
|
+
constructor({ token }) {
|
|
6
|
+
this.TOKEN_VALIDATION_REGEXP = /^[A-Za-z0-9+/=]{7}\.nex[apr]\.[A-Za-z0-9+/=]{32}$/;
|
|
7
|
+
if (!token) {
|
|
8
|
+
throw new Error('Provide an API key.');
|
|
9
|
+
}
|
|
10
|
+
if (!this.TOKEN_VALIDATION_REGEXP.test(token)) {
|
|
11
|
+
throw new Error('Unable to recognize the API key.');
|
|
12
|
+
}
|
|
13
|
+
this._token = token;
|
|
14
|
+
}
|
|
15
|
+
get token() {
|
|
16
|
+
return this._token;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.Credentials = Credentials;
|
|
20
|
+
//# sourceMappingURL=Credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Credentials.js","sourceRoot":"","sources":["../../../../../packages/core/src/credentials-provider/Credentials.ts"],"names":[],"mappings":";;;AAIA,MAAa,WAAW;IAUtB,YAAY,EAAE,KAAK,EAAsB;QATxB,4BAAuB,GACtC,mDAAmD,CAAC;QASpD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;SACxC;QAED,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC7C,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAdD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CAaF;AArBD,kCAqBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialsProvider.js","sourceRoot":"","sources":["../../../../../packages/core/src/credentials-provider/CredentialsProvider.ts"],"names":[],"mappings":";;;AAMa,QAAA,kBAAkB,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvCredentialProvider = void 0;
|
|
4
|
+
class EnvCredentialProvider {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
6
|
+
async get() {
|
|
7
|
+
const token = process.env.BRIGHT_TOKEN;
|
|
8
|
+
return token ? { token } : undefined;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.EnvCredentialProvider = EnvCredentialProvider;
|
|
12
|
+
//# sourceMappingURL=EnvCredentialProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvCredentialProvider.js","sourceRoot":"","sources":["../../../../../packages/core/src/credentials-provider/EnvCredentialProvider.ts"],"names":[],"mappings":";;;AAGA,MAAa,qBAAqB;IAChC,4DAA4D;IACrD,KAAK,CAAC,GAAG;QACd,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;QAEvC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACvC,CAAC;CACF;AAPD,sDAOC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./Credentials"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./CredentialsProvider"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./EnvCredentialProvider"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/credentials-provider/index.ts"],"names":[],"mappings":";;;AAAA,6DAA8B;AAC9B,qEAAsC;AACtC,uEAAwC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecTesterError = void 0;
|
|
4
|
+
class SecTesterError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = new.target.name;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SecTesterError = SecTesterError;
|
|
11
|
+
//# sourceMappingURL=SecTesterError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecTesterError.js","sourceRoot":"","sources":["../../../../../packages/core/src/exceptions/SecTesterError.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AALD,wCAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SecTesterError';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,gEAAiC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import './register';
|
|
3
|
+
export * from './bus';
|
|
4
|
+
export * from './configuration';
|
|
5
|
+
export * from './credentials-provider';
|
|
6
|
+
export * from './exceptions';
|
|
7
|
+
export * from './logger';
|
|
8
|
+
export { NumBoundaries, checkBoundaries, contains, delay, isBoolean, isDate, isFormData, isNumber, isObject, isPresent, isStream, isString, isURLSearchParams, truncate } from './utils';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.truncate = exports.isURLSearchParams = exports.isString = exports.isStream = exports.isPresent = exports.isObject = exports.isNumber = exports.isFormData = exports.isDate = exports.isBoolean = exports.delay = exports.contains = exports.checkBoundaries = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
require("reflect-metadata");
|
|
6
|
+
require("./register");
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./bus"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./configuration"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./credentials-provider"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./exceptions"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./logger"), exports);
|
|
12
|
+
var utils_1 = require("./utils");
|
|
13
|
+
Object.defineProperty(exports, "checkBoundaries", { enumerable: true, get: function () { return utils_1.checkBoundaries; } });
|
|
14
|
+
Object.defineProperty(exports, "contains", { enumerable: true, get: function () { return utils_1.contains; } });
|
|
15
|
+
Object.defineProperty(exports, "delay", { enumerable: true, get: function () { return utils_1.delay; } });
|
|
16
|
+
Object.defineProperty(exports, "isBoolean", { enumerable: true, get: function () { return utils_1.isBoolean; } });
|
|
17
|
+
Object.defineProperty(exports, "isDate", { enumerable: true, get: function () { return utils_1.isDate; } });
|
|
18
|
+
Object.defineProperty(exports, "isFormData", { enumerable: true, get: function () { return utils_1.isFormData; } });
|
|
19
|
+
Object.defineProperty(exports, "isNumber", { enumerable: true, get: function () { return utils_1.isNumber; } });
|
|
20
|
+
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return utils_1.isObject; } });
|
|
21
|
+
Object.defineProperty(exports, "isPresent", { enumerable: true, get: function () { return utils_1.isPresent; } });
|
|
22
|
+
Object.defineProperty(exports, "isStream", { enumerable: true, get: function () { return utils_1.isStream; } });
|
|
23
|
+
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return utils_1.isString; } });
|
|
24
|
+
Object.defineProperty(exports, "isURLSearchParams", { enumerable: true, get: function () { return utils_1.isURLSearchParams; } });
|
|
25
|
+
Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return utils_1.truncate; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;;AAAA,4BAA0B;AAC1B,sBAAoB;AAEpB,qDAAsB;AACtB,+DAAgC;AAChC,sEAAuC;AACvC,4DAA6B;AAC7B,wDAAyB;AACzB,iCAeiB;AAbf,wGAAA,eAAe,OAAA;AACf,iGAAA,QAAQ,OAAA;AACR,8FAAA,KAAK,OAAA;AACL,kGAAA,SAAS,OAAA;AACT,+FAAA,MAAM,OAAA;AACN,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,kGAAA,SAAS,OAAA;AACT,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,0GAAA,iBAAiB,OAAA;AACjB,iGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
SILENT = 0,
|
|
3
|
+
ERROR = 1,
|
|
4
|
+
WARN = 2,
|
|
5
|
+
NOTICE = 3,
|
|
6
|
+
VERBOSE = 4
|
|
7
|
+
}
|
|
8
|
+
export declare class Logger {
|
|
9
|
+
private MAX_FORMATTED_LEVEL_LENGTH;
|
|
10
|
+
get logLevel(): LogLevel;
|
|
11
|
+
set logLevel(value: LogLevel);
|
|
12
|
+
private _logLevel;
|
|
13
|
+
constructor(logLevel?: LogLevel);
|
|
14
|
+
error(message: string, ...args: any[]): void;
|
|
15
|
+
warn(message: string, ...args: any[]): void;
|
|
16
|
+
log(message: string, ...args: any[]): void;
|
|
17
|
+
debug(message: string, ...args: any[]): void;
|
|
18
|
+
private write;
|
|
19
|
+
private formatHeader;
|
|
20
|
+
private formattedLevel;
|
|
21
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = exports.LogLevel = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
var LogLevel;
|
|
8
|
+
(function (LogLevel) {
|
|
9
|
+
LogLevel[LogLevel["SILENT"] = 0] = "SILENT";
|
|
10
|
+
LogLevel[LogLevel["ERROR"] = 1] = "ERROR";
|
|
11
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
12
|
+
LogLevel[LogLevel["NOTICE"] = 3] = "NOTICE";
|
|
13
|
+
LogLevel[LogLevel["VERBOSE"] = 4] = "VERBOSE";
|
|
14
|
+
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
15
|
+
class Logger {
|
|
16
|
+
constructor(logLevel = LogLevel.NOTICE) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
|
+
this.MAX_FORMATTED_LEVEL_LENGTH = Object.keys(LogLevel)
|
|
19
|
+
.sort((a, b) => a.length - b.length)
|
|
20
|
+
.slice(0)
|
|
21
|
+
.pop().length;
|
|
22
|
+
this._logLevel = logLevel;
|
|
23
|
+
}
|
|
24
|
+
get logLevel() {
|
|
25
|
+
return this._logLevel;
|
|
26
|
+
}
|
|
27
|
+
set logLevel(value) {
|
|
28
|
+
this._logLevel = value;
|
|
29
|
+
}
|
|
30
|
+
error(message, ...args) {
|
|
31
|
+
this.write(message, LogLevel.ERROR, ...args);
|
|
32
|
+
}
|
|
33
|
+
warn(message, ...args) {
|
|
34
|
+
this.write(message, LogLevel.WARN, ...args);
|
|
35
|
+
}
|
|
36
|
+
log(message, ...args) {
|
|
37
|
+
this.write(message, LogLevel.NOTICE, ...args);
|
|
38
|
+
}
|
|
39
|
+
debug(message, ...args) {
|
|
40
|
+
this.write(message, LogLevel.VERBOSE, ...args);
|
|
41
|
+
}
|
|
42
|
+
write(message, level, ...args) {
|
|
43
|
+
if (this.logLevel < level) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.log(`${this.formatHeader(level)} - ${message}`, ...args);
|
|
48
|
+
}
|
|
49
|
+
formatHeader(level) {
|
|
50
|
+
const header = (0, util_1.format)('[%s] [%s]', new Date(), this.formattedLevel(level));
|
|
51
|
+
switch (level) {
|
|
52
|
+
case LogLevel.ERROR:
|
|
53
|
+
return chalk_1.default.red(header);
|
|
54
|
+
case LogLevel.WARN:
|
|
55
|
+
return chalk_1.default.yellow(header);
|
|
56
|
+
case LogLevel.NOTICE:
|
|
57
|
+
return chalk_1.default.green(header);
|
|
58
|
+
case LogLevel.VERBOSE:
|
|
59
|
+
return chalk_1.default.cyan(header);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
formattedLevel(level) {
|
|
63
|
+
return LogLevel[level]
|
|
64
|
+
.toString()
|
|
65
|
+
.toUpperCase()
|
|
66
|
+
.padEnd(this.MAX_FORMATTED_LEVEL_LENGTH, ' ');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Logger = Logger;
|
|
70
|
+
//# sourceMappingURL=Logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../../../packages/core/src/logger/Logger.ts"],"names":[],"mappings":";;;;AAAA,+DAA0B;AAC1B,+BAA8B;AAE9B,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,2CA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IACjD,CAAC;IAEO,KAAK,CAAC,OAAe,EAAE,KAAe,EAAE,GAAG,IAAW;QAC5D,IAAI,IAAI,CAAC,QAAQ,GAAG,KAAK,EAAE;YACzB,OAAO;SACR;QAED,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACnE,CAAC;IAEO,YAAY,CAAC,KAAe;QAClC,MAAM,MAAM,GAAG,IAAA,aAAM,EAAC,WAAW,EAAE,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAE3E,QAAQ,KAAK,EAAE;YACb,KAAK,QAAQ,CAAC,KAAK;gBACjB,OAAO,eAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC3B,KAAK,QAAQ,CAAC,IAAI;gBAChB,OAAO,eAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9B,KAAK,QAAQ,CAAC,MAAM;gBAClB,OAAO,eAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,KAAK,QAAQ,CAAC,OAAO;gBACnB,OAAO,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;IACH,CAAC;IAEO,cAAc,CAAC,KAAe;QACpC,OAAO,QAAQ,CAAC,KAAK,CAAC;aACnB,QAAQ,EAAE;aACV,WAAW,EAAE;aACb,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;CACF;AAnED,wBAmEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Logger';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/logger/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/register.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const configuration_1 = require("./configuration");
|
|
4
|
+
const logger_1 = require("./logger");
|
|
5
|
+
const tsyringe_1 = require("tsyringe");
|
|
6
|
+
tsyringe_1.container.register(logger_1.Logger, {
|
|
7
|
+
useFactory(child) {
|
|
8
|
+
return child.isRegistered(configuration_1.Configuration, true)
|
|
9
|
+
? new logger_1.Logger(child.resolve(configuration_1.Configuration).logLevel)
|
|
10
|
+
: new logger_1.Logger();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../packages/core/src/register.ts"],"names":[],"mappings":";;AAAA,mDAAgD;AAChD,qCAAkC;AAClC,uCAA0D;AAE1D,oBAAS,CAAC,QAAQ,CAAC,eAAM,EAAE;IACzB,UAAU,CAAC,KAA0B;QACnC,OAAO,KAAK,CAAC,YAAY,CAAC,6BAAa,EAAE,IAAI,CAAC;YAC5C,CAAC,CAAC,IAAI,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,6BAAa,CAAC,CAAC,QAAQ,CAAC;YACnD,CAAC,CAAC,IAAI,eAAM,EAAE,CAAC;IACnB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkBoundaries = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
const checkMinimum = (value, { min, exclusiveMin = false }) => (exclusiveMin ? value > min : value >= min);
|
|
6
|
+
const checkMaximum = (value, { max, exclusiveMax = false }) => (exclusiveMax ? value < max : value <= max);
|
|
7
|
+
const checkBoundaries = (value, { min, max, exclusiveMax, exclusiveMin } = {}) => {
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
value = parseFloat(value);
|
|
10
|
+
}
|
|
11
|
+
if (!(0, types_1.isNumber)(value)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
let valid = true;
|
|
15
|
+
if ((0, types_1.isNumber)(max)) {
|
|
16
|
+
valid = checkMaximum(value, { max, exclusiveMax });
|
|
17
|
+
}
|
|
18
|
+
if (valid && (0, types_1.isNumber)(min)) {
|
|
19
|
+
valid = checkMinimum(value, { min, exclusiveMin });
|
|
20
|
+
}
|
|
21
|
+
return valid;
|
|
22
|
+
};
|
|
23
|
+
exports.checkBoundaries = checkBoundaries;
|
|
24
|
+
//# sourceMappingURL=check-boundaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-boundaries.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/check-boundaries.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAWnC,MAAM,YAAY,GAAG,CACnB,KAAa,EACb,EACE,GAAG,EACH,YAAY,GAAG,KAAK,EACqD,EAClE,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;AAE1D,MAAM,YAAY,GAAG,CACnB,KAAa,EACb,EACE,GAAG,EACH,YAAY,GAAG,KAAK,EACqD,EAClE,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;AAEnD,MAAM,eAAe,GAAG,CAC7B,KAAc,EACd,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,KAAoB,EAAE,EAC5D,EAAE;IACF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;KAC3B;IAED,IAAI,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,KAAK,GAAG,IAAI,CAAC;IAEjB,IAAI,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAAE;QACjB,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;KACpD;IAED,IAAI,KAAK,IAAI,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAAE;QAC1B,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;KACpD;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAvBW,QAAA,eAAe,mBAuB1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const contains: <T>(enumType: Record<string, T>, value: T | T[]) => boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contains = void 0;
|
|
4
|
+
const contains = (enumType, value) => (Array.isArray(value) ? value : [value]).every((x) => Object.values(enumType).includes(x));
|
|
5
|
+
exports.contains = contains;
|
|
6
|
+
//# sourceMappingURL=contains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contains.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/contains.ts"],"names":[],"mappings":";;;AAAO,MAAM,QAAQ,GAAG,CAAI,QAA2B,EAAE,KAAc,EAAE,EAAE,CACzE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAI,EAAE,EAAE,CACtD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CACpC,CAAC;AAHS,QAAA,QAAQ,YAGjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const delay: (ms: number) => Promise<void>;
|