@creator.co/wapi 1.6.1 → 2.0.0-alpha.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.
Files changed (84) hide show
  1. package/.github/workflows/npmpublish.yml +1 -1
  2. package/.github/workflows/prs.yml +1 -1
  3. package/dist/index.js +45 -31
  4. package/dist/index.js.map +1 -1
  5. package/dist/jest.config.js +2 -4
  6. package/dist/jest.config.js.map +1 -1
  7. package/dist/package.json +12 -12
  8. package/dist/src/API/Request.js +53 -59
  9. package/dist/src/API/Request.js.map +1 -1
  10. package/dist/src/API/Response.js +81 -156
  11. package/dist/src/API/Response.js.map +1 -1
  12. package/dist/src/BaseEvent/EventProcessor.js +54 -132
  13. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  14. package/dist/src/BaseEvent/Process.js +40 -98
  15. package/dist/src/BaseEvent/Process.js.map +1 -1
  16. package/dist/src/BaseEvent/Transaction.js +122 -310
  17. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  18. package/dist/src/Cache/Redis.js +55 -119
  19. package/dist/src/Cache/Redis.js.map +1 -1
  20. package/dist/src/Cache/types.js +1 -2
  21. package/dist/src/Config/Configuration.js +46 -86
  22. package/dist/src/Config/Configuration.js.map +1 -1
  23. package/dist/src/Config/EnvironmentVar.js +57 -119
  24. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  25. package/dist/src/Crypto/Crypto.js +35 -82
  26. package/dist/src/Crypto/Crypto.js.map +1 -1
  27. package/dist/src/Crypto/JWT.js +12 -27
  28. package/dist/src/Crypto/JWT.js.map +1 -1
  29. package/dist/src/Database/Database.js +3 -8
  30. package/dist/src/Database/Database.js.map +1 -1
  31. package/dist/src/Database/DatabaseManager.js +23 -28
  32. package/dist/src/Database/DatabaseManager.js.map +1 -1
  33. package/dist/src/Database/DatabaseTransaction.js +50 -166
  34. package/dist/src/Database/DatabaseTransaction.js.map +1 -1
  35. package/dist/src/Database/index.js +11 -15
  36. package/dist/src/Database/index.js.map +1 -1
  37. package/dist/src/Database/integrations/knex/KnexDatabase.js +22 -76
  38. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
  39. package/dist/src/Database/integrations/knex/KnexTransaction.js +19 -85
  40. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
  41. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +37 -88
  42. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
  43. package/dist/src/Database/integrations/kysely/KyselyTransaction.js +46 -114
  44. package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -1
  45. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +20 -71
  46. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
  47. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +19 -85
  48. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
  49. package/dist/src/Database/types.js +1 -2
  50. package/dist/src/Globals.js +93 -98
  51. package/dist/src/Globals.js.map +1 -1
  52. package/dist/src/Logger/Logger.js +88 -222
  53. package/dist/src/Logger/Logger.js.map +1 -1
  54. package/dist/src/Mailer/Mailer.js +83 -204
  55. package/dist/src/Mailer/Mailer.js.map +1 -1
  56. package/dist/src/Publisher/Publisher.js +43 -107
  57. package/dist/src/Publisher/Publisher.js.map +1 -1
  58. package/dist/src/Server/RouteResolver.js +22 -49
  59. package/dist/src/Server/RouteResolver.js.map +1 -1
  60. package/dist/src/Server/Router.js +12 -16
  61. package/dist/src/Server/Router.js.map +1 -1
  62. package/dist/src/Server/lib/ContainerServer.js +21 -83
  63. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  64. package/dist/src/Server/lib/Server.js +50 -99
  65. package/dist/src/Server/lib/Server.js.map +1 -1
  66. package/dist/src/Server/lib/container/GenericHandler.js +32 -107
  67. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  68. package/dist/src/Server/lib/container/GenericHandlerEvent.js +37 -81
  69. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  70. package/dist/src/Server/lib/container/HealthHandler.js +3 -35
  71. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  72. package/dist/src/Server/lib/container/Proxy.js +64 -127
  73. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  74. package/dist/src/Server/lib/container/Utils.js +12 -55
  75. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  76. package/dist/src/Util/AsyncSingleton.js +40 -164
  77. package/dist/src/Util/AsyncSingleton.js.map +1 -1
  78. package/dist/src/Util/Utils.js +18 -24
  79. package/dist/src/Util/Utils.js.map +1 -1
  80. package/dist/src/Validation/Validator.js +10 -16
  81. package/dist/src/Validation/Validator.js.map +1 -1
  82. package/package.json +12 -12
  83. package/tests/Logger/Logger.test.ts +5 -3
  84. package/tsconfig.json +3 -1
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,37 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.EnvironmentType = void 0;
40
- var client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
41
- var client_ssm_1 = require("@aws-sdk/client-ssm");
10
+ import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
11
+ import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm';
42
12
  // Explicity setting VM level variables in order to persist
43
13
  // client across different important and instances.
44
14
  // eslint-disable-next-line no-var
@@ -47,7 +17,7 @@ var client_ssm_1 = require("@aws-sdk/client-ssm");
47
17
  *
48
18
  * @type {*}
49
19
  */
50
- var ssmClient = null, secretsClient = null;
20
+ let ssmClient = null, secretsClient = null;
51
21
  /**
52
22
  * An enumeration representing different types of environments.
53
23
  * @enum {number}
@@ -56,17 +26,17 @@ var ssmClient = null, secretsClient = null;
56
26
  * @property {number} SecureRemote - Represents a secure remote environment.
57
27
  * @property {number} Local - Represents a local environment.
58
28
  */
59
- var EnvironmentType;
29
+ export var EnvironmentType;
60
30
  (function (EnvironmentType) {
61
31
  EnvironmentType[EnvironmentType["PlainRemote"] = 0] = "PlainRemote";
62
32
  EnvironmentType[EnvironmentType["SecureRemote"] = 1] = "SecureRemote";
63
33
  EnvironmentType[EnvironmentType["Local"] = 2] = "Local";
64
- })(EnvironmentType || (exports.EnvironmentType = EnvironmentType = {}));
34
+ })(EnvironmentType || (EnvironmentType = {}));
65
35
  /**
66
36
  * Represents an environment variable with methods to resolve its value based on the environment type.
67
37
  * @template T - The type of the environment variable value.
68
38
  */
69
- var EnvironmentVar = /** @class */ (function () {
39
+ export default class EnvironmentVar {
70
40
  /**
71
41
  * Constructs a new instance of the EnvironmentVar class.
72
42
  * @param {string} paramName - The name of the environment variable.
@@ -74,8 +44,7 @@ var EnvironmentVar = /** @class */ (function () {
74
44
  * @param {boolean} [optional] - Indicates whether the environment variable is optional.
75
45
  * @param {string} [paramPrefix] - The prefix to be added to the environment variable name.
76
46
  */
77
- function EnvironmentVar(paramName, type, optional, paramPrefix /* only allowed process.env */) {
78
- if (paramPrefix === void 0) { paramPrefix = "/creatorco-api-".concat(process.env.STAGE, "/env/"); }
47
+ constructor(paramName, type, optional, paramPrefix = `/creatorco-api-${process.env.STAGE}/env/` /* only allowed process.env */) {
79
48
  this.paramName = paramName;
80
49
  this.type = type;
81
50
  this.optional = !!optional;
@@ -86,115 +55,84 @@ var EnvironmentVar = /** @class */ (function () {
86
55
  * @returns {T} - The resolved value of the environment variable.
87
56
  * @throws {Error} - If the environment type is not 'Local'.
88
57
  */
89
- EnvironmentVar.prototype.syncResolve = function () {
58
+ syncResolve() {
90
59
  if (this.type == EnvironmentType.Local)
91
60
  return this.getLocalValue();
92
61
  else {
93
62
  throw new Error("EnvironmentVar syncResolve method can only be called for environments of type 'Local'");
94
63
  }
95
- };
64
+ }
96
65
  /**
97
66
  * Resolves the value based on the environment type.
98
67
  * @returns {Promise<any>} - The resolved value.
99
68
  */
100
- EnvironmentVar.prototype.resolve = function () {
101
- return __awaiter(this, void 0, void 0, function () {
102
- return __generator(this, function (_a) {
103
- if (this.type == EnvironmentType.Local)
104
- return [2 /*return*/, this.getLocalValue()];
105
- else if (this.type == EnvironmentType.SecureRemote)
106
- return [2 /*return*/, this.getSecureValue()];
107
- else
108
- return [2 /*return*/, this.getPlainValue()];
109
- return [2 /*return*/];
110
- });
69
+ resolve() {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ if (this.type == EnvironmentType.Local)
72
+ return this.getLocalValue();
73
+ else if (this.type == EnvironmentType.SecureRemote)
74
+ return this.getSecureValue();
75
+ else
76
+ return this.getPlainValue();
111
77
  });
112
- };
78
+ }
113
79
  /**
114
80
  * Retrieves the value of a local environment variable.
115
81
  * @returns {T} - The value of the local environment variable.
116
82
  * @throws {Error} - If the local environment variable is not defined and is not optional.
117
83
  */
118
- EnvironmentVar.prototype.getLocalValue = function () {
119
- var value = process.env[this.paramName];
84
+ getLocalValue() {
85
+ const value = process.env[this.paramName];
120
86
  if (!value && !this.optional) {
121
- throw new Error("Local environment ".concat(this.paramName, " is not defined, please reconfigure the application and redeploy!"));
87
+ throw new Error(`Local environment ${this.paramName} is not defined, please reconfigure the application and redeploy!`);
122
88
  }
123
89
  return value;
124
- };
90
+ }
125
91
  /**
126
92
  * Retrieves the plain value of a remote environment parameter.
127
93
  * @returns {Promise<T>} - A promise that resolves to the plain value of the parameter.
128
94
  * @throws {Error} - If the parameter cannot be retrieved and is not optional.
129
95
  */
130
- EnvironmentVar.prototype.getPlainValue = function () {
131
- return __awaiter(this, void 0, void 0, function () {
132
- var pName, data, error_1;
133
- return __generator(this, function (_a) {
134
- switch (_a.label) {
135
- case 0:
136
- if (!ssmClient)
137
- ssmClient = new client_ssm_1.SSMClient();
138
- pName = "".concat(this.paramPrefix).concat(this.paramName);
139
- _a.label = 1;
140
- case 1:
141
- _a.trys.push([1, 3, , 4]);
142
- return [4 /*yield*/, ssmClient.send(new client_ssm_1.GetParameterCommand({ Name: pName }))];
143
- case 2:
144
- data = _a.sent();
145
- if (data.Parameter && data.Parameter.Value)
146
- return [2 /*return*/, data.Parameter.Value];
147
- return [3 /*break*/, 4];
148
- case 3:
149
- error_1 = _a.sent();
150
- console.error(error_1);
151
- return [3 /*break*/, 4];
152
- case 4:
153
- if (!this.optional) {
154
- throw new Error("Unable to retrieve plain remote env value: ".concat(pName));
155
- }
156
- return [2 /*return*/];
157
- }
158
- });
96
+ getPlainValue() {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ if (!ssmClient)
99
+ ssmClient = new SSMClient();
100
+ const pName = `${this.paramPrefix}${this.paramName}`;
101
+ try {
102
+ const data = yield ssmClient.send(new GetParameterCommand({ Name: pName }));
103
+ if (data.Parameter && data.Parameter.Value)
104
+ return data.Parameter.Value;
105
+ }
106
+ catch (error) {
107
+ console.error(error);
108
+ }
109
+ if (!this.optional) {
110
+ throw new Error(`Unable to retrieve plain remote env value: ${pName}`);
111
+ }
159
112
  });
160
- };
113
+ }
161
114
  /**
162
115
  * Retrieves a secure value from the secrets manager.
163
116
  * @returns {Promise<T>} - A promise that resolves to the secure value.
164
117
  * @throws {Error} - Throws an error if the secure value cannot be retrieved and is not optional.
165
118
  */
166
- EnvironmentVar.prototype.getSecureValue = function () {
167
- return __awaiter(this, void 0, void 0, function () {
168
- var pName, data, error_2;
169
- return __generator(this, function (_a) {
170
- switch (_a.label) {
171
- case 0:
172
- if (!secretsClient)
173
- secretsClient = new client_secrets_manager_1.SecretsManagerClient();
174
- pName = "".concat(this.paramPrefix).concat(this.paramName);
175
- _a.label = 1;
176
- case 1:
177
- _a.trys.push([1, 3, , 4]);
178
- return [4 /*yield*/, secretsClient.send(new client_secrets_manager_1.GetSecretValueCommand({ SecretId: pName }))];
179
- case 2:
180
- data = _a.sent();
181
- if (data.SecretString)
182
- return [2 /*return*/, data.SecretString];
183
- return [3 /*break*/, 4];
184
- case 3:
185
- error_2 = _a.sent();
186
- console.error(error_2);
187
- return [3 /*break*/, 4];
188
- case 4:
189
- if (!this.optional) {
190
- throw new Error("Unable to retrieve secure remote env: ".concat(pName));
191
- }
192
- return [2 /*return*/];
193
- }
194
- });
119
+ getSecureValue() {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ if (!secretsClient)
122
+ secretsClient = new SecretsManagerClient();
123
+ const pName = `${this.paramPrefix}${this.paramName}`;
124
+ try {
125
+ const data = yield secretsClient.send(new GetSecretValueCommand({ SecretId: pName }));
126
+ if (data.SecretString)
127
+ return data.SecretString;
128
+ }
129
+ catch (error) {
130
+ console.error(error);
131
+ }
132
+ if (!this.optional) {
133
+ throw new Error(`Unable to retrieve secure remote env: ${pName}`);
134
+ }
195
135
  });
196
- };
197
- return EnvironmentVar;
198
- }());
199
- exports.default = EnvironmentVar;
136
+ }
137
+ }
200
138
  //# sourceMappingURL=EnvironmentVar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentVar.js","sourceRoot":"","sources":["../../../src/Config/EnvironmentVar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA6F;AAC7F,kDAAoE;AAEpE,2DAA2D;AAC3D,mDAAmD;AACnD,kCAAkC;AAClC;;;;GAIG;AACH,IAAI,SAAS,GAAqB,IAAI,EACpC,aAAa,GAAgC,IAAI,CAAA;AAEnD;;;;;;;GAOG;AACH,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,mEAAW,CAAA;IACX,qEAAY,CAAA;IACZ,uDAAK,CAAA;AACP,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AACD;;;GAGG;AACH;IAoBE;;;;;;OAMG;IACH,wBACE,SAAiB,EACjB,IAAqB,EACrB,QAAkB,EAClB,WAAwD,CAAC,8BAA8B;QAAvF,4BAAA,EAAA,uCAAgC,OAAO,CAAC,GAAG,CAAC,KAAK,UAAO;QAExD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,Q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iB,CAAA;YACtD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,EAAE,CAAC,CAAA;YACnE,CAAC;QACH,CAAC;KAAA;CACF"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,39 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var client_kms_1 = require("@aws-sdk/client-kms");
10
+ import { KMSClient, EncryptCommand, DecryptCommand, } from '@aws-sdk/client-kms';
40
11
  /**
41
12
  * Represents a Crypto class that provides encryption and decryption functionality using AWS KMS.
42
13
  */
43
- var Crypto = /** @class */ (function () {
14
+ export default class Crypto {
44
15
  /**
45
16
  * Constructs a new instance of a KeyManager with the provided region, keyId, and optional encryption algorithm.
46
17
  * @param {string} region - The region where the key is stored.
@@ -48,72 +19,54 @@ var Crypto = /** @class */ (function () {
48
19
  * @param {EncryptionAlgorithmSpec} [optEncryptionAlgorithm='RSAES_OAEP_SHA_256'] - The encryption algorithm to use (default is RSAES_OAEP_SHA_256).
49
20
  * @returns None
50
21
  */
51
- function Crypto(region, keyId, optEncryptionAlgorithm) {
22
+ constructor(region, keyId, optEncryptionAlgorithm) {
52
23
  this.region = region;
53
24
  this.keyId = keyId;
54
25
  this.encryptionAlgorithm = optEncryptionAlgorithm || 'RSAES_OAEP_SHA_256';
55
- this.client = new client_kms_1.KMSClient({ region: this.region });
26
+ this.client = new KMSClient({ region: this.region });
56
27
  }
57
28
  /**
58
29
  * Encrypts the given data using RSAES_OAEP_SHA_256 encryption algorithm.
59
30
  * @param {string | any} data - The data to be encrypted.
60
31
  * @returns {Promise<string | null>} - A promise that resolves to the encrypted data as a hexadecimal string.
61
32
  */
62
- Crypto.prototype.encryptData = function (data) {
63
- return __awaiter(this, void 0, void 0, function () {
64
- var resp, e_1;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- _a.trys.push([0, 2, , 3]);
69
- return [4 /*yield*/, this.client.send(new client_kms_1.EncryptCommand({
70
- KeyId: this.keyId,
71
- EncryptionAlgorithm: this.encryptionAlgorithm,
72
- Plaintext: new TextEncoder().encode(typeof data === 'string' ? data : JSON.stringify(data)),
73
- }))];
74
- case 1:
75
- resp = _a.sent();
76
- return [2 /*return*/, Buffer.from(resp.CiphertextBlob, 'utf8').toString('hex')];
77
- case 2:
78
- e_1 = _a.sent();
79
- console.error('Encryption failure', e_1);
80
- return [2 /*return*/, null];
81
- case 3: return [2 /*return*/];
82
- }
83
- });
33
+ encryptData(data) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ try {
36
+ const resp = yield this.client.send(new EncryptCommand({
37
+ KeyId: this.keyId,
38
+ EncryptionAlgorithm: this.encryptionAlgorithm,
39
+ Plaintext: new TextEncoder().encode(typeof data === 'string' ? data : JSON.stringify(data)),
40
+ }));
41
+ return Buffer.from(resp.CiphertextBlob, 'utf8').toString('hex');
42
+ }
43
+ catch (e) {
44
+ console.error('Encryption failure', e);
45
+ return null;
46
+ }
84
47
  });
85
- };
48
+ }
86
49
  /**
87
50
  * Decrypts the given data using the RSAES_OAEP_SHA_256 encryption algorithm.
88
51
  * @param {string} data - The encrypted data to decrypt.
89
52
  * @returns {Promise<string | null>} - A promise that resolves to the decrypted plaintext string.
90
53
  * If decryption fails, null is returned.
91
54
  */
92
- Crypto.prototype.decryptData = function (data) {
93
- return __awaiter(this, void 0, void 0, function () {
94
- var resp, e_2;
95
- return __generator(this, function (_a) {
96
- switch (_a.label) {
97
- case 0:
98
- _a.trys.push([0, 2, , 3]);
99
- return [4 /*yield*/, this.client.send(new client_kms_1.DecryptCommand({
100
- KeyId: this.keyId,
101
- CiphertextBlob: Buffer.from(data, 'hex'),
102
- EncryptionAlgorithm: this.encryptionAlgorithm,
103
- }))];
104
- case 1:
105
- resp = _a.sent();
106
- return [2 /*return*/, new TextDecoder().decode(resp.Plaintext)];
107
- case 2:
108
- e_2 = _a.sent();
109
- console.error('Decryption failure', e_2);
110
- return [2 /*return*/, null];
111
- case 3: return [2 /*return*/];
112
- }
113
- });
55
+ decryptData(data) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ try {
58
+ const resp = yield this.client.send(new DecryptCommand({
59
+ KeyId: this.keyId,
60
+ CiphertextBlob: Buffer.from(data, 'hex'),
61
+ EncryptionAlgorithm: this.encryptionAlgorithm,
62
+ }));
63
+ return new TextDecoder().decode(resp.Plaintext);
64
+ }
65
+ catch (e) {
66
+ console.error('Decryption failure', e);
67
+ return null;
68
+ }
114
69
  });
115
- };
116
- return Crypto;
117
- }());
118
- exports.default = Crypto;
70
+ }
71
+ }
119
72
  //# sourceMappingURL=Crypto.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../../../src/Crypto/Crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAK4B;AAE5B;;GAEG;AACH;IAoBE;;;;;;OAMG;IACH,gBAAY,MAAc,EAAE,KAAa,EAAE,sBAAgD;QACzF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,mBAAmB,GAAG,sBAAsB,IAAI,oBAAoB,CAAA;QACzE,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,IAAI,CAAC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AE,IAAI,CAAC,mBAAmB;iBAC9C,CAAC,CACH,CAAA;gBACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACjD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAA;gBACtC,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;KAAA;CACF"}
@@ -1,28 +1,15 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var jwt = require("jsonwebtoken");
1
+ import * as jwt from 'jsonwebtoken';
15
2
  /**
16
3
  * Represents a JSON Web Token (JWT) utility class.
17
4
  */
18
- var JWT = /** @class */ (function () {
5
+ export default class JWT {
19
6
  /**
20
7
  * Constructs a new instance of the class.
21
8
  * @param {string} tokenSecret - The secret used to sign the tokens.
22
9
  * @param {string} [defaultExpiration] - The default expiration time for the tokens.
23
10
  * @returns None
24
11
  */
25
- function JWT(tokenSecret, defaultExpiration) {
12
+ constructor(tokenSecret, defaultExpiration) {
26
13
  this.tokenSecret = tokenSecret;
27
14
  this.defaultExpiration = defaultExpiration;
28
15
  }
@@ -34,21 +21,21 @@ var JWT = /** @class */ (function () {
34
21
  * @param {any} [opts] - Additional options to be passed to the jwt.sign() function.
35
22
  * @returns {string} - The generated JWT.
36
23
  */
37
- JWT.prototype.createToken = function (data, expiration, overrideToken, opts) {
38
- var exp = expiration || this.defaultExpiration;
39
- return jwt.sign(data, overrideToken || this.tokenSecret, exp ? __assign({ expiresIn: exp }, (opts || {})) : opts || {});
40
- };
24
+ createToken(data, expiration, overrideToken, opts) {
25
+ const exp = expiration || this.defaultExpiration;
26
+ return jwt.sign(data, overrideToken || this.tokenSecret, exp ? Object.assign({ expiresIn: exp }, (opts || {})) : opts || {});
27
+ }
41
28
  /**
42
29
  * Validates a JSON Web Token (JWT) and returns the validation response.
43
30
  * @param {string} token - The JWT to validate.
44
31
  * @returns {JWTValidationResponse} - The validation response object.
45
32
  */
46
- JWT.prototype.validateToken = function (token) {
33
+ validateToken(token) {
47
34
  try {
48
35
  // Check if is valid
49
- var isValid = jwt.verify(token, this.tokenSecret);
36
+ const isValid = jwt.verify(token, this.tokenSecret);
50
37
  if (isValid) {
51
- var payload = jwt.decode(token, { json: true });
38
+ const payload = jwt.decode(token, { json: true });
52
39
  if (payload)
53
40
  return { isValid: true, decodedToken: payload };
54
41
  }
@@ -59,8 +46,6 @@ var JWT = /** @class */ (function () {
59
46
  return { isValid: false, isExpired: true };
60
47
  }
61
48
  return { isValid: false };
62
- };
63
- return JWT;
64
- }());
65
- exports.default = JWT;
49
+ }
50
+ }
66
51
  //# sourceMappingURL=JWT.js.map
@@ -1 +1 @@
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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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,iBAAG,SAAS,EAAE,GAAG,IAAK,CAAC,IAAI,IAAI,EAAE,CAAC,EAAG,CAAC,CAAC,IAAI,IAAI,EAAE,CACvD,CAAA;IACH,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,KAAa;QAChC,IAAI,CAAC;YACH,oBAAoB;YACpB,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YACnD,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,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;YAC9D,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,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;QACtF,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;IAC3B,CAAC;CACF"}
@@ -1,20 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Database = void 0;
4
1
  /**
5
2
  * Abstract class representing a Database with a generic type extending DatabaseTransaction.
6
3
  * @template T - The type of DatabaseTransaction to be used.
7
4
  */
8
- var Database = /** @class */ (function () {
5
+ export class Database {
9
6
  /**
10
7
  * Constructor for a class that takes in a database configuration object.
11
8
  * @param {DbConfig<any>} config - The database configuration object.
12
9
  * @returns None
13
10
  */
14
- function Database(config) {
11
+ constructor(config) {
15
12
  this.config = config;
16
13
  }
17
- return Database;
18
- }());
19
- exports.Database = Database;
14
+ }
20
15
  //# sourceMappingURL=Database.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Database.js","sourceRoot":"","sources":["../../../src/Database/Database.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH;IACE;;;;OAIG;IACH,kBAAsC,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAQjE,eAAC;AAAD,CAAC,AAdD,IAcC;AAdqB,4BAAQ"}
1
+ {"version":3,"file":"Database.js","sourceRoot":"","sources":["../../../src/Database/Database.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAgB,QAAQ;IAC5B;;;;OAIG;IACH,YAAsC,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;CAQhE"}
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseManager = exports.DATABASES = void 0;
4
- var hash = require("object-hash");
5
- var KnexDatabase_1 = require("./integrations/knex/KnexDatabase");
6
- var KyselyDatabase_1 = require("./integrations/kysely/KyselyDatabase");
7
- var PostgresDatabase_1 = require("./integrations/pgsql/PostgresDatabase");
1
+ import * as hash from 'object-hash';
2
+ import { KnexDatabase } from './integrations/knex/KnexDatabase';
3
+ import { KyselyDatabase } from './integrations/kysely/KyselyDatabase';
4
+ import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase';
8
5
  /**
9
6
  * Object containing different database implementations.
10
7
  * @type {Object}
@@ -12,21 +9,21 @@ var PostgresDatabase_1 = require("./integrations/pgsql/PostgresDatabase");
12
9
  * @property {PostgresDatabase} pg - Postgres database implementation
13
10
  * @property {KyselyDatabase<any>} kysely - Kysely database implementation
14
11
  */
15
- exports.DATABASES = {
16
- knex: KnexDatabase_1.KnexDatabase,
17
- pg: PostgresDatabase_1.PostgresDatabase,
18
- kysely: KyselyDatabase_1.KyselyDatabase,
12
+ export const DATABASES = {
13
+ knex: KnexDatabase,
14
+ pg: PostgresDatabase,
15
+ kysely: KyselyDatabase,
19
16
  };
20
17
  /**
21
18
  * Manages the creation and storage of database instances.
22
19
  */
23
- var DatabaseManager = /** @class */ (function () {
24
- function DatabaseManager() {
20
+ export class DatabaseManager {
21
+ constructor() {
25
22
  /**
26
23
  * A private property that holds a reference to the DATABASES constant.
27
24
  * @type {typeof DATABASES}
28
25
  */
29
- this.databases = exports.DATABASES;
26
+ this.databases = DATABASES;
30
27
  /**
31
28
  * An object that stores instances of DatabaseImplType objects with keys of type string.
32
29
  * @type {Object.<string, DatabaseImplType<any, any>>}
@@ -38,29 +35,27 @@ var DatabaseManager = /** @class */ (function () {
38
35
  * @param {DbConfig<S>} config - The configuration object for the database.
39
36
  * @returns {DatabaseImplType<S, DBSchema>} An instance of the database based on the configuration.
40
37
  */
41
- DatabaseManager.prototype.create = function (config) {
42
- var configHash = hash(config);
38
+ create(config) {
39
+ const configHash = hash(config);
43
40
  if (this.instances[configHash]) {
44
41
  return this.instances[configHash];
45
42
  }
46
- var instance = this.instantiateDb(config);
43
+ const instance = this.instantiateDb(config);
47
44
  this.instances[configHash] = instance;
48
45
  return instance;
49
- };
46
+ }
50
47
  /**
51
48
  * Instantiates a database connection based on the provided configuration.
52
49
  * @param {DbConfig<'knex'> | DbConfig<'pg'> | DbConfig<'kysely'>} config - The configuration object specifying the type of database.
53
50
  * @returns {DatabaseImplType<S, DBSchema>} An instance of the specified database connection.
54
51
  */
55
- DatabaseManager.prototype.instantiateDb = function (config) {
52
+ instantiateDb(config) {
56
53
  return new this.databases[config.type](config);
57
- };
58
- /**
59
- * Singleton instance of the DatabaseManager class.
60
- * This instance is used to interact with the database.
61
- */
62
- DatabaseManager.INSTANCE = new DatabaseManager();
63
- return DatabaseManager;
64
- }());
65
- exports.DatabaseManager = DatabaseManager;
54
+ }
55
+ }
56
+ /**
57
+ * Singleton instance of the DatabaseManager class.
58
+ * This instance is used to interact with the database.
59
+ */
60
+ DatabaseManager.INSTANCE = new DatabaseManager();
66
61
  //# sourceMappingURL=DatabaseManager.js.map