@creator.co/wapi 1.2.5 → 1.2.6
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 +216 -5
- package/dist/index.d.ts +15 -0
- package/dist/index.js.map +1 -1
- package/dist/package.json +6 -1
- package/dist/src/API/Request.d.ts +45 -82
- package/dist/src/API/Request.js +49 -77
- package/dist/src/API/Request.js.map +1 -1
- package/dist/src/API/Response.d.ts +94 -163
- package/dist/src/API/Response.js +101 -161
- package/dist/src/API/Response.js.map +1 -1
- package/dist/src/API/Utils.d.ts +21 -42
- package/dist/src/API/Utils.js +22 -43
- package/dist/src/API/Utils.js.map +1 -1
- package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
- package/dist/src/BaseEvent/EventProcessor.js +30 -38
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
- package/dist/src/BaseEvent/Process.d.ts +20 -43
- package/dist/src/BaseEvent/Process.js +16 -27
- package/dist/src/BaseEvent/Process.js.map +1 -1
- package/dist/src/BaseEvent/Transaction.d.ts +94 -2
- package/dist/src/BaseEvent/Transaction.js +49 -4
- package/dist/src/BaseEvent/Transaction.js.map +1 -1
- package/dist/src/Config/Configuration.d.ts +48 -66
- package/dist/src/Config/Configuration.js +25 -42
- package/dist/src/Config/Configuration.js.map +1 -1
- package/dist/src/Config/EnvironmentVar.d.ts +30 -57
- package/dist/src/Config/EnvironmentVar.js +28 -41
- package/dist/src/Config/EnvironmentVar.js.map +1 -1
- package/dist/src/Crypto/Crypto.d.ts +17 -35
- package/dist/src/Crypto/Crypto.js +12 -21
- package/dist/src/Crypto/Crypto.js.map +1 -1
- package/dist/src/Crypto/JWT.d.ts +21 -32
- package/dist/src/Crypto/JWT.js +14 -22
- package/dist/src/Crypto/JWT.js.map +1 -1
- package/dist/src/Globals.d.ts +26 -94
- package/dist/src/Globals.js +26 -95
- package/dist/src/Globals.js.map +1 -1
- package/dist/src/Logger/Logger.d.ts +82 -105
- package/dist/src/Logger/Logger.js +111 -136
- package/dist/src/Logger/Logger.js.map +1 -1
- package/dist/src/Mailer/Mailer.d.ts +39 -75
- package/dist/src/Mailer/Mailer.js +36 -65
- package/dist/src/Mailer/Mailer.js.map +1 -1
- package/dist/src/Publisher/Publisher.d.ts +17 -25
- package/dist/src/Publisher/Publisher.js +21 -32
- package/dist/src/Publisher/Publisher.js.map +1 -1
- package/dist/src/Server/RouteResolver.d.ts +14 -22
- package/dist/src/Server/RouteResolver.js +21 -34
- package/dist/src/Server/RouteResolver.js.map +1 -1
- package/dist/src/Server/Router.d.ts +72 -51
- package/dist/src/Server/Router.js +8 -17
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
- package/dist/src/Server/lib/ContainerServer.js +13 -28
- package/dist/src/Server/lib/ContainerServer.js.map +1 -1
- package/dist/src/Server/lib/Server.d.ts +17 -32
- package/dist/src/Server/lib/Server.js +18 -28
- package/dist/src/Server/lib/Server.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
- package/dist/src/Server/lib/container/GenericHandler.js +16 -3
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
- package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
- package/dist/src/Server/lib/container/HealthHandler.js +6 -0
- package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
- package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
- package/dist/src/Server/lib/container/Proxy.js +49 -50
- package/dist/src/Server/lib/container/Proxy.js.map +1 -1
- package/dist/src/Server/lib/container/Utils.d.ts +6 -10
- package/dist/src/Server/lib/container/Utils.js +6 -10
- package/dist/src/Server/lib/container/Utils.js.map +1 -1
- package/dist/src/Validation/Validator.d.ts +9 -13
- package/dist/src/Validation/Validator.js +8 -12
- package/dist/src/Validation/Validator.js.map +1 -1
- package/index.ts +15 -0
- package/package.json +6 -1
- package/src/API/Request.ts +66 -84
- package/src/API/Response.ts +144 -203
- package/src/API/Utils.ts +28 -44
- package/src/BaseEvent/EventProcessor.ts +52 -77
- package/src/BaseEvent/Process.ts +27 -52
- package/src/BaseEvent/Transaction.ts +100 -10
- package/src/Config/Configuration.ts +59 -76
- package/src/Config/EnvironmentVar.ts +39 -62
- package/src/Crypto/Crypto.ts +20 -36
- package/src/Crypto/JWT.ts +31 -35
- package/src/Globals.ts +28 -96
- package/src/Logger/Logger.ts +141 -160
- package/src/Mailer/Mailer.ts +43 -76
- package/src/Publisher/Publisher.ts +31 -40
- package/src/Server/RouteResolver.ts +31 -52
- package/src/Server/Router.ts +75 -54
- package/src/Server/lib/ContainerServer.ts +20 -32
- package/src/Server/lib/Server.ts +19 -34
- package/src/Server/lib/container/GenericHandler.ts +17 -3
- package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
- package/src/Server/lib/container/HealthHandler.ts +6 -0
- package/src/Server/lib/container/Proxy.ts +37 -57
- package/src/Server/lib/container/Utils.ts +7 -10
- package/src/Validation/Validator.ts +11 -13
- package/tests/API/Response.test.ts +55 -56
- package/tests/BaseEvent/EventProcessor.test.ts +49 -50
- package/tests/BaseEvent/Process.test.ts +2 -2
- package/tests/BaseEvent/Transaction.test.ts +48 -49
- package/tests/Config/Config.test.ts +27 -27
- package/tests/Config/EnvironmentVar.test.ts +54 -18
- package/tests/Publisher/Publisher.test.ts +3 -3
- package/tests/Server/lib/ContainerServer.test.ts +21 -22
- package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
- package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
- package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
- package/tests/Server/lib/container/Proxy.test.ts +37 -35
- package/tsconfig.json +1 -1
|
@@ -49,10 +49,12 @@ var client_ssm_1 = require("@aws-sdk/client-ssm");
|
|
|
49
49
|
*/
|
|
50
50
|
var ssmClient = null, secretsClient = null;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @export
|
|
52
|
+
* An enumeration representing different types of environments.
|
|
55
53
|
* @enum {number}
|
|
54
|
+
* @readonly
|
|
55
|
+
* @property {number} PlainRemote - Represents a plain remote environment.
|
|
56
|
+
* @property {number} SecureRemote - Represents a secure remote environment.
|
|
57
|
+
* @property {number} Local - Represents a local environment.
|
|
56
58
|
*/
|
|
57
59
|
var EnvironmentType;
|
|
58
60
|
(function (EnvironmentType) {
|
|
@@ -61,22 +63,16 @@ var EnvironmentType;
|
|
|
61
63
|
EnvironmentType[EnvironmentType["Local"] = 2] = "Local";
|
|
62
64
|
})(EnvironmentType || (exports.EnvironmentType = EnvironmentType = {}));
|
|
63
65
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @export
|
|
67
|
-
* @class EnvironmentVar
|
|
68
|
-
* @typedef {EnvironmentVar}
|
|
69
|
-
* @template T
|
|
66
|
+
* Represents an environment variable with methods to resolve its value based on the environment type.
|
|
67
|
+
* @template T - The type of the environment variable value.
|
|
70
68
|
*/
|
|
71
69
|
var EnvironmentVar = /** @class */ (function () {
|
|
72
70
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
76
|
-
* @param {
|
|
77
|
-
* @param {
|
|
78
|
-
* @param {?boolean} [optional]
|
|
79
|
-
* @param {string} [paramPrefix=`/creatorco-api-\${process.env.STAGE\}/env/`]
|
|
71
|
+
* Constructs a new instance of the EnvironmentVar class.
|
|
72
|
+
* @param {string} paramName - The name of the environment variable.
|
|
73
|
+
* @param {EnvironmentType} type - The type of the environment.
|
|
74
|
+
* @param {boolean} [optional] - Indicates whether the environment variable is optional.
|
|
75
|
+
* @param {string} [paramPrefix] - The prefix to be added to the environment variable name.
|
|
80
76
|
*/
|
|
81
77
|
function EnvironmentVar(paramName, type, optional, paramPrefix /* only allowed process.env */) {
|
|
82
78
|
if (paramPrefix === void 0) { paramPrefix = "/creatorco-api-".concat(process.env.STAGE, "/env/"); }
|
|
@@ -86,10 +82,9 @@ var EnvironmentVar = /** @class */ (function () {
|
|
|
86
82
|
this.paramPrefix = paramPrefix;
|
|
87
83
|
}
|
|
88
84
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
92
|
-
* @returns {T}
|
|
85
|
+
* Resolves the value of the environment variable synchronously.
|
|
86
|
+
* @returns {T} - The resolved value of the environment variable.
|
|
87
|
+
* @throws {Error} - If the environment type is not 'Local'.
|
|
93
88
|
*/
|
|
94
89
|
EnvironmentVar.prototype.syncResolve = function () {
|
|
95
90
|
if (this.type == EnvironmentType.Local)
|
|
@@ -99,11 +94,8 @@ var EnvironmentVar = /** @class */ (function () {
|
|
|
99
94
|
}
|
|
100
95
|
};
|
|
101
96
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* @public
|
|
105
|
-
* @async
|
|
106
|
-
* @returns {unknown}
|
|
97
|
+
* Resolves the value based on the environment type.
|
|
98
|
+
* @returns {Promise<any>} - The resolved value.
|
|
107
99
|
*/
|
|
108
100
|
EnvironmentVar.prototype.resolve = function () {
|
|
109
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -119,10 +111,9 @@ var EnvironmentVar = /** @class */ (function () {
|
|
|
119
111
|
});
|
|
120
112
|
};
|
|
121
113
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @
|
|
125
|
-
* @returns {T}
|
|
114
|
+
* Retrieves the value of a local environment variable.
|
|
115
|
+
* @returns {T} - The value of the local environment variable.
|
|
116
|
+
* @throws {Error} - If the local environment variable is not defined and is not optional.
|
|
126
117
|
*/
|
|
127
118
|
EnvironmentVar.prototype.getLocalValue = function () {
|
|
128
119
|
var value = process.env[this.paramName];
|
|
@@ -132,11 +123,9 @@ var EnvironmentVar = /** @class */ (function () {
|
|
|
132
123
|
return value;
|
|
133
124
|
};
|
|
134
125
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @
|
|
138
|
-
* @async
|
|
139
|
-
* @returns {Promise<T>}
|
|
126
|
+
* Retrieves the plain value of a remote environment parameter.
|
|
127
|
+
* @returns {Promise<T>} - A promise that resolves to the plain value of the parameter.
|
|
128
|
+
* @throws {Error} - If the parameter cannot be retrieved and is not optional.
|
|
140
129
|
*/
|
|
141
130
|
EnvironmentVar.prototype.getPlainValue = function () {
|
|
142
131
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -170,11 +159,9 @@ var EnvironmentVar = /** @class */ (function () {
|
|
|
170
159
|
});
|
|
171
160
|
};
|
|
172
161
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
176
|
-
* @async
|
|
177
|
-
* @returns {Promise<T>}
|
|
162
|
+
* Retrieves a secure value from the secrets manager.
|
|
163
|
+
* @returns {Promise<T>} - A promise that resolves to the secure value.
|
|
164
|
+
* @throws {Error} - Throws an error if the secure value cannot be retrieved and is not optional.
|
|
178
165
|
*/
|
|
179
166
|
EnvironmentVar.prototype.getSecureValue = function () {
|
|
180
167
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -191,8 +178,8 @@ var EnvironmentVar = /** @class */ (function () {
|
|
|
191
178
|
return [4 /*yield*/, secretsClient.send(new client_secrets_manager_1.GetSecretValueCommand({ SecretId: pName }))];
|
|
192
179
|
case 2:
|
|
193
180
|
data = _a.sent();
|
|
194
|
-
if (data.
|
|
195
|
-
return [2 /*return*/, data.
|
|
181
|
+
if (data.SecretString)
|
|
182
|
+
return [2 /*return*/, data.SecretString];
|
|
196
183
|
return [3 /*break*/, 4];
|
|
197
184
|
case 3:
|
|
198
185
|
error_2 = _a.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentVar.js","sourceRoot":"","sources":["../../../src/Config/EnvironmentVar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;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ACxD,KAAK,GAAG,UAAG,IAAI,CAAC,WAAW,SAAG,IAAI,CAAC,SAAS,CAAE,CAAA;;;;wBAErC,qBAAM,aAAa,CAAC,IAAI,CAAC,IAAI,8CAAqB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,EAAA;;wBAA/E,IAAI,GAAG,SAAwE;wBACrF,IAAI,IAAI,CAAC,YAAY;4BAAE,sBAAO,IAAI,CAAC,YAAiB,EAAA;;;;wBAEpD,OAAO,CAAC,KAAK,CAAC,OAAK,CAAC,CAAA;;;wBAEtB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;4BAClB,MAAM,IAAI,KAAK,CAAC,gDAAyC,KAAK,CAAE,CAAC,CAAA;yBAClE;;;;;KACF;IACH,qBAAC;AAAD,CAAC,AAnHD,IAmHC"}
|
|
@@ -1,57 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @class Crypto
|
|
6
|
-
* @typedef {Crypto}
|
|
2
|
+
* Represents a Crypto class that provides encryption and decryption functionality using AWS KMS.
|
|
7
3
|
*/
|
|
8
4
|
export default class Crypto {
|
|
9
5
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
13
|
-
* @readonly
|
|
14
|
-
* @type {KMSClient}
|
|
6
|
+
* The KMSClient instance used for making requests to the Key Management Service (KMS).
|
|
15
7
|
*/
|
|
16
8
|
private readonly client;
|
|
17
9
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @private
|
|
21
|
-
* @readonly
|
|
22
|
-
* @type {string}
|
|
10
|
+
* The AWS region of the object. This property is readonly and cannot be modified once set.
|
|
23
11
|
*/
|
|
24
12
|
private readonly region;
|
|
25
13
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @private
|
|
14
|
+
* The unique identifier for the KMS.
|
|
29
15
|
* @readonly
|
|
30
16
|
* @type {string}
|
|
31
17
|
*/
|
|
32
18
|
private readonly keyId;
|
|
33
19
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
* @
|
|
38
|
-
* @param {string} keyId
|
|
20
|
+
* Constructs a new instance of the KMSClient class.
|
|
21
|
+
* @param {string} region - The AWS region to use for the client.
|
|
22
|
+
* @param {string} keyId - The AWS KMS key ID to use for encryption and decryption operations.
|
|
23
|
+
* @returns None
|
|
39
24
|
*/
|
|
40
25
|
constructor(region: string, keyId: string);
|
|
41
26
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @
|
|
45
|
-
* @param {(string | any)} data
|
|
46
|
-
* @returns {Promise<string>}
|
|
27
|
+
* Encrypts the given data using RSAES_OAEP_SHA_256 encryption algorithm.
|
|
28
|
+
* @param {string | any} data - The data to be encrypted.
|
|
29
|
+
* @returns {Promise<string | null>} - A promise that resolves to the encrypted data as a hexadecimal string.
|
|
47
30
|
*/
|
|
48
|
-
encryptData(data: string | any): Promise<string>;
|
|
31
|
+
encryptData(data: string | any): Promise<string | null>;
|
|
49
32
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @
|
|
53
|
-
*
|
|
54
|
-
* @returns {Promise<string>}
|
|
33
|
+
* Decrypts the given data using the RSAES_OAEP_SHA_256 encryption algorithm.
|
|
34
|
+
* @param {string} data - The encrypted data to decrypt.
|
|
35
|
+
* @returns {Promise<string | null>} - A promise that resolves to the decrypted plaintext string.
|
|
36
|
+
* If decryption fails, null is returned.
|
|
55
37
|
*/
|
|
56
|
-
decryptData(data: string): Promise<string>;
|
|
38
|
+
decryptData(data: string): Promise<string | null>;
|
|
57
39
|
}
|
|
@@ -38,32 +38,24 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var client_kms_1 = require("@aws-sdk/client-kms");
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @export
|
|
44
|
-
* @class Crypto
|
|
45
|
-
* @typedef {Crypto}
|
|
41
|
+
* Represents a Crypto class that provides encryption and decryption functionality using AWS KMS.
|
|
46
42
|
*/
|
|
47
43
|
var Crypto = /** @class */ (function () {
|
|
48
44
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @
|
|
52
|
-
* @
|
|
53
|
-
* @param {string} keyId
|
|
45
|
+
* Constructs a new instance of the KMSClient class.
|
|
46
|
+
* @param {string} region - The AWS region to use for the client.
|
|
47
|
+
* @param {string} keyId - The AWS KMS key ID to use for encryption and decryption operations.
|
|
48
|
+
* @returns None
|
|
54
49
|
*/
|
|
55
50
|
function Crypto(region, keyId) {
|
|
56
51
|
this.region = region;
|
|
57
52
|
this.keyId = keyId;
|
|
58
53
|
this.client = new client_kms_1.KMSClient({ region: this.region });
|
|
59
54
|
}
|
|
60
|
-
//
|
|
61
55
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
65
|
-
* @param {(string | any)} data
|
|
66
|
-
* @returns {Promise<string>}
|
|
56
|
+
* Encrypts the given data using RSAES_OAEP_SHA_256 encryption algorithm.
|
|
57
|
+
* @param {string | any} data - The data to be encrypted.
|
|
58
|
+
* @returns {Promise<string | null>} - A promise that resolves to the encrypted data as a hexadecimal string.
|
|
67
59
|
*/
|
|
68
60
|
Crypto.prototype.encryptData = function (data) {
|
|
69
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -90,11 +82,10 @@ var Crypto = /** @class */ (function () {
|
|
|
90
82
|
});
|
|
91
83
|
};
|
|
92
84
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @
|
|
96
|
-
*
|
|
97
|
-
* @returns {Promise<string>}
|
|
85
|
+
* Decrypts the given data using the RSAES_OAEP_SHA_256 encryption algorithm.
|
|
86
|
+
* @param {string} data - The encrypted data to decrypt.
|
|
87
|
+
* @returns {Promise<string | null>} - A promise that resolves to the decrypted plaintext string.
|
|
88
|
+
* If decryption fails, null is returned.
|
|
98
89
|
*/
|
|
99
90
|
Crypto.prototype.decryptData = function (data) {
|
|
100
91
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../../../src/Crypto/Crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA+E;AAE/E
|
|
1
|
+
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../../../src/Crypto/Crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA+E;AAE/E;;GAEG;AACH;IAgBE;;;;;OAKG;IACH,gBAAY,MAAc,EAAE,KAAa;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,sBAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACtD,CAAC;IAED;;;;OAIG;IACU,4BAAW,GAAxB,UAAyB,IAAkB;;;;;;;wBAE1B,qBAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,IAAI,2BAAc,CAAC;gCACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gCACjB,mBAAmB,EAAE,oBAAoB;gCACzC,SAAS,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CACjC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CACvD;6BACF,CAAC,CACH,EAAA;;wBARK,IAAI,GAAG,SAQZ;wBACD,sBAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAqB,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAA;;;wBAEtE,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAC,CAAC,CAAA;wBACtC,sBAAO,IAAI,EAAA;;;;;KAEd;IAED;;;;;OAKG;IACU,4BAAW,GAAxB,UAAyB,IAAY;;;;;;;wBAEpB,qBAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,IAAI,2BAAc,CAAC;gCACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gCACjB,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;gCACxC,mBAAmB,EAAE,oBAAoB;6BAC1C,CAAC,CACH,EAAA;;wBANK,IAAI,GAAG,SAMZ;wBACD,sBAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAA;;;wBAE/C,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAC,CAAC,CAAA;wBACtC,sBAAO,IAAI,EAAA;;;;;KAEd;IACH,aAAC;AAAD,CAAC,AAxED,IAwEC"}
|
package/dist/src/Crypto/JWT.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as jwt from 'jsonwebtoken';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
3
|
+
* Represents the response of a JWT validation.
|
|
4
|
+
* @typedef {Object} JWTValidationResponse
|
|
5
|
+
* @property {boolean} isValid - Indicates whether the JWT is valid or not.
|
|
6
|
+
* @property {jwt.JwtPayload} [decodedToken] - The decoded JWT payload if the JWT is valid.
|
|
7
|
+
* @property {boolean} [isExpired] - Indicates whether the JWT is expired or not, only present if isValid is false.
|
|
6
8
|
*/
|
|
7
9
|
type JWTValidationResponse = {
|
|
8
10
|
isValid: true;
|
|
@@ -12,52 +14,39 @@ type JWTValidationResponse = {
|
|
|
12
14
|
isExpired?: boolean;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @export
|
|
18
|
-
* @class JWT
|
|
19
|
-
* @typedef {JWT}
|
|
17
|
+
* Represents a JSON Web Token (JWT) utility class.
|
|
20
18
|
*/
|
|
21
19
|
export default class JWT {
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @private
|
|
26
|
-
* @readonly
|
|
21
|
+
* The secret key used for generating and verifying tokens.
|
|
27
22
|
* @type {string}
|
|
28
23
|
*/
|
|
29
24
|
private readonly tokenSecret;
|
|
30
25
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @private
|
|
34
|
-
* @readonly
|
|
26
|
+
* The default expiration time for a cache entry.
|
|
35
27
|
* @type {string}
|
|
36
28
|
*/
|
|
37
29
|
private readonly defaultExpiration;
|
|
38
30
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
43
|
-
* @param {?string} [defaultExpiration]
|
|
31
|
+
* Constructs a new instance of the class.
|
|
32
|
+
* @param {string} tokenSecret - The secret used to sign the tokens.
|
|
33
|
+
* @param {string} [defaultExpiration] - The default expiration time for the tokens.
|
|
34
|
+
* @returns None
|
|
44
35
|
*/
|
|
45
36
|
constructor(tokenSecret: string, defaultExpiration?: string);
|
|
46
37
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {
|
|
51
|
-
* @param {
|
|
52
|
-
* @
|
|
53
|
-
* @returns {string}
|
|
38
|
+
* Creates a JSON Web Token (JWT) using the provided data and options.
|
|
39
|
+
* @param {object} data - The data to be included in the token payload.
|
|
40
|
+
* @param {string} [expiration] - The expiration time for the token. If not provided, the default expiration time will be used.
|
|
41
|
+
* @param {string} [overrideToken] - An optional token secret to override the default token secret.
|
|
42
|
+
* @param {any} [opts] - Additional options to be passed to the jwt.sign() function.
|
|
43
|
+
* @returns {string} - The generated JWT.
|
|
54
44
|
*/
|
|
55
45
|
createToken(data: object, expiration?: string, overrideToken?: string, opts?: any): string;
|
|
56
46
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @
|
|
60
|
-
* @returns {JWTValidationResponse}
|
|
47
|
+
* Validates a JSON Web Token (JWT) and returns the validation response.
|
|
48
|
+
* @param {string} token - The JWT to validate.
|
|
49
|
+
* @returns {JWTValidationResponse} - The validation response object.
|
|
61
50
|
*/
|
|
62
51
|
validateToken(token: string): JWTValidationResponse;
|
|
63
52
|
}
|
package/dist/src/Crypto/JWT.js
CHANGED
|
@@ -13,43 +13,35 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
var jwt = require("jsonwebtoken");
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @export
|
|
19
|
-
* @class JWT
|
|
20
|
-
* @typedef {JWT}
|
|
16
|
+
* Represents a JSON Web Token (JWT) utility class.
|
|
21
17
|
*/
|
|
22
18
|
var JWT = /** @class */ (function () {
|
|
23
19
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
28
|
-
* @param {?string} [defaultExpiration]
|
|
20
|
+
* Constructs a new instance of the class.
|
|
21
|
+
* @param {string} tokenSecret - The secret used to sign the tokens.
|
|
22
|
+
* @param {string} [defaultExpiration] - The default expiration time for the tokens.
|
|
23
|
+
* @returns None
|
|
29
24
|
*/
|
|
30
25
|
function JWT(tokenSecret, defaultExpiration) {
|
|
31
26
|
this.tokenSecret = tokenSecret;
|
|
32
27
|
this.defaultExpiration = defaultExpiration;
|
|
33
28
|
}
|
|
34
|
-
//
|
|
35
29
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
41
|
-
* @
|
|
42
|
-
* @returns {string}
|
|
30
|
+
* Creates a JSON Web Token (JWT) using the provided data and options.
|
|
31
|
+
* @param {object} data - The data to be included in the token payload.
|
|
32
|
+
* @param {string} [expiration] - The expiration time for the token. If not provided, the default expiration time will be used.
|
|
33
|
+
* @param {string} [overrideToken] - An optional token secret to override the default token secret.
|
|
34
|
+
* @param {any} [opts] - Additional options to be passed to the jwt.sign() function.
|
|
35
|
+
* @returns {string} - The generated JWT.
|
|
43
36
|
*/
|
|
44
37
|
JWT.prototype.createToken = function (data, expiration, overrideToken, opts) {
|
|
45
38
|
var exp = expiration || this.defaultExpiration;
|
|
46
39
|
return jwt.sign(data, overrideToken || this.tokenSecret, exp ? __assign({ expiresIn: exp }, (opts || {})) : opts || {});
|
|
47
40
|
};
|
|
48
41
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @
|
|
52
|
-
* @returns {JWTValidationResponse}
|
|
42
|
+
* Validates a JSON Web Token (JWT) and returns the validation response.
|
|
43
|
+
* @param {string} token - The JWT to validate.
|
|
44
|
+
* @returns {JWTValidationResponse} - The validation response object.
|
|
53
45
|
*/
|
|
54
46
|
JWT.prototype.validateToken = function (token) {
|
|
55
47
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JWT.js","sourceRoot":"","sources":["../../../src/Crypto/JWT.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kCAAmC;
|
|
1
|
+
{"version":3,"file":"JWT.js","sourceRoot":"","sources":["../../../src/Crypto/JWT.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kCAAmC;AAgBnC;;GAEG;AACH;IAYE;;;;;OAKG;IACH,aAAY,WAAmB,EAAE,iBAA0B;QACzD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED;;;;;;;OAOG;IACI,yBAAW,GAAlB,UACE,IAAY,EACZ,UAAmB,EACnB,aAAsB,EACtB,IAAU;QAEV,IAAM,GAAG,GAAG,UAAU,IAAI,IAAI,CAAC,iBAAiB,CAAA;QAChD,OAAO,GAAG,CAAC,IAAI,CACb,IAAI,EACJ,aAAa,IAAI,IAAI,CAAC,WAAW,EACjC,GAAG,CAAC,CAAC,YAAG,SAAS,EAAE,GAAG,IAAK,CAAC,IAAI,IAAI,EAAE,CAAC,EAAG,CAAC,CAAC,IAAI,IAAI,EAAE,CACvD,CAAA;IACH,CAAC;IAED;;;;OAIG;IACI,2BAAa,GAApB,UAAqB,KAAa;QAChC,IAAI;YACF,oBAAoB;YACpB,IAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YACnD,IAAI,OAAO,EAAE;gBACX,IAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;gBACjD,IAAI,OAAO;oBAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAA;aAC7D;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAClB,IAAI,GAAG,YAAY,GAAG,CAAC,iBAAiB;gBAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;SACrF;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;IAC3B,CAAC;IACH,UAAC;AAAD,CAAC,AAhED,IAgEC"}
|
package/dist/src/Globals.d.ts
CHANGED
|
@@ -1,161 +1,93 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @class Globals
|
|
6
|
-
* @typedef {Globals}
|
|
2
|
+
* Class containing global constants and configurations for the application.
|
|
7
3
|
*/
|
|
8
4
|
export default class Globals {
|
|
9
5
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
* @static
|
|
14
|
-
* @type {string}
|
|
6
|
+
* A constant string representing an error message for input validation failure.
|
|
15
7
|
*/
|
|
16
8
|
static ErrorResponseValidationFail: string;
|
|
17
9
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
21
|
-
* @static
|
|
22
|
-
* @type {string}
|
|
10
|
+
* A constant string representing an error response for an invalid server response.
|
|
23
11
|
*/
|
|
24
12
|
static ErrorResponseInvalidServerResponse: string;
|
|
25
13
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @public
|
|
29
|
-
* @static
|
|
30
|
-
* @type {string}
|
|
14
|
+
* The error message for an unhandled error when processing a request.
|
|
31
15
|
*/
|
|
32
16
|
static ErrorResponseUnhandledError: string;
|
|
33
17
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
* @static
|
|
38
|
-
* @type {string}
|
|
18
|
+
* A static string representing an error response when there are no records to be processed.
|
|
39
19
|
*/
|
|
40
20
|
static ErrorResponseNoRecords: string;
|
|
41
21
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @public
|
|
45
|
-
* @static
|
|
22
|
+
* Represents an error code for a missing parameter.
|
|
46
23
|
* @type {string}
|
|
47
24
|
*/
|
|
48
25
|
static ErrorCode_MissingParam: string;
|
|
49
26
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @public
|
|
53
|
-
* @static
|
|
27
|
+
* Represents an error code for invalid input.
|
|
54
28
|
* @type {string}
|
|
55
29
|
*/
|
|
56
30
|
static ErrorCode_InvalidInput: string;
|
|
57
31
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @public
|
|
61
|
-
* @static
|
|
32
|
+
* Represents an error code for an API error.
|
|
62
33
|
* @type {string}
|
|
63
34
|
*/
|
|
64
35
|
static ErrorCode_APIError: string;
|
|
65
36
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @public
|
|
69
|
-
* @static
|
|
37
|
+
* Represents the error code for when there are no records found.
|
|
70
38
|
* @type {string}
|
|
71
39
|
*/
|
|
72
40
|
static ErrorCode_NoRecords: string;
|
|
73
41
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
78
|
-
* @type {*}
|
|
42
|
+
* Retrieves the default port number for HTTP listeners.
|
|
43
|
+
* The port number is obtained from the environment variable "PORT" and parsed as an integer.
|
|
44
|
+
* If the environment variable is not set or cannot be parsed as an integer, the default port number 9000 is used.
|
|
45
|
+
* @returns {number} - The default port number for HTTP listeners.
|
|
79
46
|
*/
|
|
80
47
|
static Listener_HTTP_DefaultPort: number;
|
|
81
48
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @public
|
|
85
|
-
* @static
|
|
86
|
-
* @type {string}
|
|
49
|
+
* The default host for the HTTP listener.
|
|
87
50
|
*/
|
|
88
51
|
static Listener_HTTP_DefaultHost: string;
|
|
89
52
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @public
|
|
93
|
-
* @static
|
|
53
|
+
* The HTTP proxy route listener for all routes.
|
|
94
54
|
* @type {string}
|
|
95
55
|
*/
|
|
96
56
|
static Listener_HTTP_ProxyRoute: string;
|
|
97
57
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* @public
|
|
101
|
-
* @static
|
|
102
|
-
* @type {*}
|
|
58
|
+
* Retrieves the default timeout value for HTTP listeners.
|
|
59
|
+
* @returns {number} The default timeout value in milliseconds.
|
|
103
60
|
*/
|
|
104
61
|
static Listener_HTTP_DefaultTimeout: number;
|
|
105
62
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @public
|
|
109
|
-
* @static
|
|
110
|
-
* @type {*}
|
|
63
|
+
* The default health check route for the HTTP listener.
|
|
64
|
+
* @type {string}
|
|
111
65
|
*/
|
|
112
66
|
static Listener_HTTP_DefaultHealthCheckRoute: string;
|
|
113
67
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* @public
|
|
117
|
-
* @static
|
|
118
|
-
* @type {string}
|
|
68
|
+
* The response message for an exception that occurred during request execution in the Proxy.
|
|
119
69
|
*/
|
|
120
70
|
static Resp_MSG_EXCEPTION: string;
|
|
121
71
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @public
|
|
125
|
-
* @static
|
|
126
|
-
* @type {string}
|
|
72
|
+
* The response code for an exception that occurred during execution.
|
|
127
73
|
*/
|
|
128
74
|
static Resp_CODE_EXCEPTION: string;
|
|
129
75
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @public
|
|
133
|
-
* @static
|
|
134
|
-
* @type {number}
|
|
76
|
+
* The HTTP response status code for an exception scenario.
|
|
135
77
|
*/
|
|
136
78
|
static Resp_STATUSCODE_EXCEPTION: number;
|
|
137
79
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* @public
|
|
141
|
-
* @static
|
|
142
|
-
* @type {string}
|
|
80
|
+
* The error message for an invalid response from the server.
|
|
143
81
|
*/
|
|
144
82
|
static Resp_MSG_INVALIDRESP: string;
|
|
145
83
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* @public
|
|
149
|
-
* @static
|
|
150
|
-
* @type {string}
|
|
84
|
+
* Represents the response code for an invalid response.
|
|
151
85
|
*/
|
|
152
86
|
static Resp_CODE_INVALIDRESP: string;
|
|
153
87
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @public
|
|
157
|
-
* @static
|
|
88
|
+
* The HTTP response status code for an invalid response.
|
|
158
89
|
* @type {number}
|
|
90
|
+
* @default 400
|
|
159
91
|
*/
|
|
160
92
|
static Resp_STATUSCODE_INVALIDRESP: number;
|
|
161
93
|
}
|