opticore-webapp-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1177 -0
- package/dist/index.d.cts +438 -0
- package/dist/index.d.ts +438 -0
- package/dist/index.js +1128 -0
- package/package.json +50 -0
- package/tsconfig.json +26 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { StackTraceError } from 'opticore-catch-exception-error';
|
|
2
|
+
import mySQL from 'mysql';
|
|
3
|
+
import { ConnectionOptions } from 'tls';
|
|
4
|
+
import { CustomTypesConfig } from 'pg';
|
|
5
|
+
import { ServerResponse, IncomingMessage } from 'node:http';
|
|
6
|
+
|
|
7
|
+
declare class SAsymmetricCryptionDataWithPrivateRSAKey {
|
|
8
|
+
private static log;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param rsaKey
|
|
12
|
+
* @param keyType
|
|
13
|
+
* @protected
|
|
14
|
+
*
|
|
15
|
+
* Return ErrorHandler | string
|
|
16
|
+
*/
|
|
17
|
+
protected static verifyExistingKey(rsaKey: string, keyType: string): StackTraceError | string;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param privateKey
|
|
21
|
+
* @param payload
|
|
22
|
+
* @private
|
|
23
|
+
*
|
|
24
|
+
* Return Buffer
|
|
25
|
+
*/
|
|
26
|
+
private static encryptionWithPrivateKey;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param privateKey
|
|
30
|
+
* @param publicKey
|
|
31
|
+
* @param payload
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private static decryptionWithPublicKey;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param privateKey
|
|
38
|
+
* @param payload
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
private static signWithRSAKey;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param privateKey
|
|
45
|
+
* @param publicKey
|
|
46
|
+
* @param payload
|
|
47
|
+
*/
|
|
48
|
+
static verifyRSAKey(privateKey: string, publicKey: string, payload: any): string | Error;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param props
|
|
52
|
+
* @param name
|
|
53
|
+
* @param status
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
private static traceError;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare class SAsymmetricCryptionDataWithPublicRSAKey {
|
|
60
|
+
private static log;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param rsaKey
|
|
64
|
+
* @param keyType
|
|
65
|
+
* @protected
|
|
66
|
+
*/
|
|
67
|
+
protected static verifyExistingKey(rsaKey: string, keyType: string): string | Error;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param publicKey
|
|
71
|
+
* @param payload
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
private static encryptionWithPublicKey;
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param privateKey
|
|
78
|
+
* @param publicKey
|
|
79
|
+
* @param payload
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
private static decryptionWithPrivateKey;
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param publicKey
|
|
86
|
+
* @param payload
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
private static signWithPublicRSAKey;
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param privateKey
|
|
93
|
+
* @param publicKey
|
|
94
|
+
* @param payload
|
|
95
|
+
*/
|
|
96
|
+
static verifyPublicRSAKey(privateKey: string, publicKey: string, payload: any): string | StackTraceError;
|
|
97
|
+
private static traceError;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param url
|
|
103
|
+
* @param user
|
|
104
|
+
* @param password
|
|
105
|
+
* @param dbName
|
|
106
|
+
* @constructor
|
|
107
|
+
*/
|
|
108
|
+
declare function SCheckerMongoDatabaseConnection(url: string, user: string | any, password: string | any, dbName: string | any): Promise<void>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param dbConnection
|
|
113
|
+
* @param user
|
|
114
|
+
* @param database
|
|
115
|
+
* @param dbHost
|
|
116
|
+
* @param password
|
|
117
|
+
* @constructor
|
|
118
|
+
*
|
|
119
|
+
* Return void
|
|
120
|
+
*/
|
|
121
|
+
declare function SCheckerMySqlDatabaseConnection(dbConnection: mySQL.Connection, user: string, database: string, dbHost: string, password: string): void;
|
|
122
|
+
|
|
123
|
+
declare function SCheckerPostgresDatabaseConnection(connectionString: any, keepAlive?: boolean | undefined, stream?: any, statement_timeout?: false | number | undefined, ssl?: boolean | ConnectionOptions | undefined, query_timeout?: number | undefined, keepAliveInitialDelayMillis?: number | undefined, idle_in_transaction_session_timeout?: number | undefined, application_name?: string | undefined, connectionTimeoutMillis?: number | undefined, types?: CustomTypesConfig | undefined, options?: string | undefined): Promise<void>;
|
|
124
|
+
|
|
125
|
+
declare const CLogLevel: {
|
|
126
|
+
readonly debug: "DEBUG";
|
|
127
|
+
readonly info: "INFO";
|
|
128
|
+
readonly warn: "WARN";
|
|
129
|
+
readonly error: "ERROR";
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/** --------------------------------------------------------------------------------------------------------------------------------
|
|
133
|
+
* Arguments: A connection URL can also take arguments. Here is the same example from above with placeholder
|
|
134
|
+
* values in uppercase letters for three arguments: mysql://USER:PASSWORD@HOST:PORT/DATABASE?KEY1=VALUE&KEY2=VALUE&KEY3=VALUE
|
|
135
|
+
*
|
|
136
|
+
* The following arguments can be used:
|
|
137
|
+
* connection_limit: Maximum size of the connection pool,
|
|
138
|
+
* connect_timeout: Maximum number of seconds to wait for a new connection to be opened, 0 means no timeout,
|
|
139
|
+
* pool_timeout: Maximum number of seconds to wait for a new connection from the pool, 0 means no timeout,
|
|
140
|
+
* sslcert: Path to the server certificate. Certificate paths are resolved relative to the ./prisma folder,
|
|
141
|
+
* sslidentity: Path to the PKCS12 certificate,
|
|
142
|
+
* sslpassword: Password that was used to secure the PKCS12 file,
|
|
143
|
+
* sslaccept: Configures whether to check for missing values in the certificate. Possible values: accept_invalid_certs, strict,
|
|
144
|
+
* socket: Points to a directory that contains a socket to be used for the connection,
|
|
145
|
+
* socket_timeout: Number of seconds to wait until a single query terminates
|
|
146
|
+
*
|
|
147
|
+
* So if you want to use argument: write it like this "?sslidentity=client-identity.p12&sslpassword=mypassword&sslcert=rootca.cert"
|
|
148
|
+
*
|
|
149
|
+
* ---------------------------------------------------------------------------------------------------------------------------------
|
|
150
|
+
*/
|
|
151
|
+
declare const optionalArgumentConnectionUtil: string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* This class contains methods that allow to decrypt data using public and private keys.
|
|
155
|
+
*/
|
|
156
|
+
declare class RSAKeyDecryption {
|
|
157
|
+
static privateDecrypt(privateKey: any, decryptData: any): Buffer;
|
|
158
|
+
static publicDecrypt(publicKey: any, decryptData: any): Buffer;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* This class contains methods which allow encrypting data by passing as arguments
|
|
163
|
+
* the public/private keys and the data to be encrypted.
|
|
164
|
+
*/
|
|
165
|
+
declare class RSAKeyEncryption {
|
|
166
|
+
static privateEncrypt(privateKey: any, encryptData: any): Buffer;
|
|
167
|
+
static publicEncrypt(publicKey: any, encryptData: any): Buffer;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class YamlParsing {
|
|
171
|
+
private static logger;
|
|
172
|
+
static readFile(filePath: string): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
*
|
|
175
|
+
* @param content
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
private static parsing;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Give time like: 6-8-2024 4:30:29
|
|
183
|
+
*/
|
|
184
|
+
declare const dateTimeFormatted: string;
|
|
185
|
+
|
|
186
|
+
declare class Environment<T> {
|
|
187
|
+
private readonly config;
|
|
188
|
+
constructor(config: T);
|
|
189
|
+
get<K extends keyof T>(key: K): T[K];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare const MMongoCheckerDatabase: (optionalArgumentConnection: string | any) => Promise<void>;
|
|
193
|
+
|
|
194
|
+
declare const MMySqlCheckerDatabase: (optionalArgumentConnection: string | any) => void;
|
|
195
|
+
|
|
196
|
+
declare const MPostgresCheckerDatabase: (optionalArgumentConnection: string | any) => Promise<void>;
|
|
197
|
+
|
|
198
|
+
declare const loggerConfig: {
|
|
199
|
+
logLevels: string[];
|
|
200
|
+
transports: {
|
|
201
|
+
file: {
|
|
202
|
+
enabled: boolean;
|
|
203
|
+
maxSizeMB: number;
|
|
204
|
+
rotate: boolean;
|
|
205
|
+
};
|
|
206
|
+
console: {
|
|
207
|
+
enabled: boolean;
|
|
208
|
+
};
|
|
209
|
+
remote: {
|
|
210
|
+
enabled: boolean;
|
|
211
|
+
endpoint: string;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
declare const CSignRSAKeyComponent: {
|
|
217
|
+
algorithm: {
|
|
218
|
+
RSA_MD5: string;
|
|
219
|
+
RSA_RIPEMD160: string;
|
|
220
|
+
RSA_SHA1: string;
|
|
221
|
+
RSA_SHA1_2: string;
|
|
222
|
+
RSA_SHA224: string;
|
|
223
|
+
RSA_SHA256: string;
|
|
224
|
+
RSA_SHA3_224: string;
|
|
225
|
+
RSA_SHA3_256: string;
|
|
226
|
+
RSA_SHA3_384: string;
|
|
227
|
+
RSA_SHA3_512: string;
|
|
228
|
+
RSA_SHA384: string;
|
|
229
|
+
RSA_SHA512: string;
|
|
230
|
+
RSA_SHA512_224: string;
|
|
231
|
+
RSA_SHA512_256: string;
|
|
232
|
+
RSA_SM3: string;
|
|
233
|
+
blake2b512: string;
|
|
234
|
+
blake2s256: string;
|
|
235
|
+
id_rsassa_pkcs1_v1_5_with_sha3_224: string;
|
|
236
|
+
id_rsassa_pkcs1_v1_5_with_sha3_256: string;
|
|
237
|
+
id_rsassa_pkcs1_v1_5_with_sha3_384: string;
|
|
238
|
+
id_rsassa_pkcs1_v1_5_with_sha3_512: string;
|
|
239
|
+
md5: string;
|
|
240
|
+
md5_sha1: string;
|
|
241
|
+
md5WithRSAEncryption: string;
|
|
242
|
+
ripemd: string;
|
|
243
|
+
ripemd160: string;
|
|
244
|
+
ripemd160WithRSA: string;
|
|
245
|
+
rmd160: string;
|
|
246
|
+
sha1: string;
|
|
247
|
+
sha1WithRSAEncryption: string;
|
|
248
|
+
sha224: string;
|
|
249
|
+
sha224WithRSAEncryption: string;
|
|
250
|
+
sha256: string;
|
|
251
|
+
sha256WithRSAEncryption: string;
|
|
252
|
+
sha3_224: string;
|
|
253
|
+
sha3_256: string;
|
|
254
|
+
sha3_384: string;
|
|
255
|
+
sha3_512: string;
|
|
256
|
+
sha384: string;
|
|
257
|
+
sha384WithRSAEncryption: string;
|
|
258
|
+
sha512: string;
|
|
259
|
+
sha512_224: string;
|
|
260
|
+
sha512_224WithRSAEncryption: string;
|
|
261
|
+
sha512_256: string;
|
|
262
|
+
sha512_256WithRSAEncryption: string;
|
|
263
|
+
sha512WithRSAEncryption: string;
|
|
264
|
+
shake128: string;
|
|
265
|
+
shake256: string;
|
|
266
|
+
sm3: string;
|
|
267
|
+
sm3WithRSAEncryption: string;
|
|
268
|
+
ssl3_md5: string;
|
|
269
|
+
ssl3_sha1: string;
|
|
270
|
+
};
|
|
271
|
+
keyType: {
|
|
272
|
+
private: string;
|
|
273
|
+
public: string;
|
|
274
|
+
};
|
|
275
|
+
outputFormat: {
|
|
276
|
+
base64: string;
|
|
277
|
+
base64url: string;
|
|
278
|
+
hex: string;
|
|
279
|
+
binary: string;
|
|
280
|
+
};
|
|
281
|
+
encodingFormat: {
|
|
282
|
+
ascii: string;
|
|
283
|
+
utf8: string;
|
|
284
|
+
utf_8: string;
|
|
285
|
+
utf16le: string;
|
|
286
|
+
utf_16le: string;
|
|
287
|
+
ucs2: string;
|
|
288
|
+
ucs_2: string;
|
|
289
|
+
base64: string;
|
|
290
|
+
base64url: string;
|
|
291
|
+
latin1: string;
|
|
292
|
+
binary: string;
|
|
293
|
+
hex: string;
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
declare class Utility {
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* @param data
|
|
301
|
+
* @private
|
|
302
|
+
* Return a string converted in MegaBytes
|
|
303
|
+
*/
|
|
304
|
+
private formatMemoryUsage;
|
|
305
|
+
/**
|
|
306
|
+
* Returns an Object containing a node version, openssl, and v0
|
|
307
|
+
*/
|
|
308
|
+
getVersions(): {
|
|
309
|
+
nodeVersion: string;
|
|
310
|
+
openssl: string;
|
|
311
|
+
v8: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Return an Object containing a Resident Set Size - total memory allocated for the process execution
|
|
315
|
+
* Total size of the allocated heap
|
|
316
|
+
* Actual memory used during the execution
|
|
317
|
+
* Memory usage user
|
|
318
|
+
* and Memory usage system
|
|
319
|
+
*/
|
|
320
|
+
getUsageMemory(): {
|
|
321
|
+
rss: string;
|
|
322
|
+
heapTotal: string;
|
|
323
|
+
heapUsed: string;
|
|
324
|
+
external: string;
|
|
325
|
+
user: string;
|
|
326
|
+
system: string;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Return an Object containing a project path and running server time
|
|
330
|
+
*/
|
|
331
|
+
getProjectInfo(): {
|
|
332
|
+
projectPath: string;
|
|
333
|
+
startingTime: string;
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
*
|
|
337
|
+
* @param filePath
|
|
338
|
+
* @private
|
|
339
|
+
*/
|
|
340
|
+
private getEnvFileLoading;
|
|
341
|
+
/**
|
|
342
|
+
*
|
|
343
|
+
* @param development
|
|
344
|
+
* @param production
|
|
345
|
+
*/
|
|
346
|
+
getServerRunningMode(development: string, production: string): string;
|
|
347
|
+
infoServer(nodeVersion: string, startingTime: any, host: string, port: number, rss: string, heapUsed: string, user: string, system: string): void;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
declare class PathModuleVerifier {
|
|
351
|
+
private static log;
|
|
352
|
+
/**
|
|
353
|
+
* Verifies if modules at specific paths are loaded.
|
|
354
|
+
* If any module is not loaded, it throws an error.
|
|
355
|
+
* @param modulePaths - An array of paths to the modules to verify.
|
|
356
|
+
*/
|
|
357
|
+
static verifyModulePaths(modulePaths: string[]): void;
|
|
358
|
+
/**
|
|
359
|
+
* Checks if a specific module at a given path is loaded in the Node.js require cache.
|
|
360
|
+
* @param modulePath - The path to the module.
|
|
361
|
+
* @returns True if the module is loaded, false otherwise.
|
|
362
|
+
*/
|
|
363
|
+
private static isModulePathLoaded;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
declare const translateLanguageLoader: () => void;
|
|
367
|
+
|
|
368
|
+
interface IBodyParserOptions {
|
|
369
|
+
type: string;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
interface IResponseBodyEndFromResponseEvent {
|
|
373
|
+
(cb?: () => void): ServerResponse<IncomingMessage>;
|
|
374
|
+
(chunk: any, cb?: () => void): ServerResponse<IncomingMessage>;
|
|
375
|
+
(chunk: any, encoding: BufferEncoding, cb?: () => void): ServerResponse<IncomingMessage>;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
interface IResponseBodyWriteFromResponseEvent {
|
|
379
|
+
(chunk: any, callback?: (error: (Error | null | undefined)) => void): boolean;
|
|
380
|
+
(chunk: any, encoding: BufferEncoding, callback?: (error: (Error | null | undefined)) => void): boolean;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
interface IWrappingBodyResponse {
|
|
384
|
+
(chunk: any, callback?: (error: (Error | null | undefined)) => void): boolean;
|
|
385
|
+
(chunk: any, encoding: BufferEncoding, callback?: (error: (Error | null | undefined)) => void): boolean;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
type TLogLevel = typeof CLogLevel;
|
|
389
|
+
|
|
390
|
+
type TOriginalWriteEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
|
|
391
|
+
|
|
392
|
+
type TParseFunction = (rawBody: string) => any;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
*
|
|
396
|
+
* @param options
|
|
397
|
+
*
|
|
398
|
+
* Use by this: TJSONBodyParser({ type: 'application/vnd.custom-type' })
|
|
399
|
+
*
|
|
400
|
+
* in express, it can be used like this: app.use(TJSONBodyParser({ type: 'application/vnd.custom-type' }));
|
|
401
|
+
*
|
|
402
|
+
*/
|
|
403
|
+
declare function TJSONBodyParser(options: IBodyParserOptions): void;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
*
|
|
407
|
+
* @param options
|
|
408
|
+
*
|
|
409
|
+
* Use by this: TRawBodyParser({ type: 'application/vnd.custom-type' })
|
|
410
|
+
*
|
|
411
|
+
* in express, it can be used like this: app.use(rawBodyParserType({ type: 'application/vnd.custom-type' }));
|
|
412
|
+
*
|
|
413
|
+
*/
|
|
414
|
+
declare function TRawBodyParser(options: IBodyParserOptions): void;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
*
|
|
418
|
+
* @param options
|
|
419
|
+
*
|
|
420
|
+
* Use by this: textBodyParserType({ type: 'text/html' })
|
|
421
|
+
*
|
|
422
|
+
* in express, it can be used like this: app.use(textBodyParserType({ type: 'text/html' }));
|
|
423
|
+
*
|
|
424
|
+
*/
|
|
425
|
+
declare function TTextBodyParser(options: IBodyParserOptions): void;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
*
|
|
429
|
+
* @param options
|
|
430
|
+
*
|
|
431
|
+
* Use by this: urlencodedBodyParserType({ type: 'application/x-www-form-urlencoded' })
|
|
432
|
+
*
|
|
433
|
+
* in express, it can be used like this: app.use(urlencodedBodyParserType({ type: 'application/x-www-form-urlencoded' }));
|
|
434
|
+
*
|
|
435
|
+
*/
|
|
436
|
+
declare function TUrlencodedBodyParser(options: IBodyParserOptions): void;
|
|
437
|
+
|
|
438
|
+
export { CLogLevel, CSignRSAKeyComponent, Environment, type IBodyParserOptions, type IResponseBodyEndFromResponseEvent, type IResponseBodyWriteFromResponseEvent, type IWrappingBodyResponse, MMongoCheckerDatabase, MMySqlCheckerDatabase, MPostgresCheckerDatabase, PathModuleVerifier, RSAKeyDecryption, RSAKeyEncryption, SAsymmetricCryptionDataWithPrivateRSAKey, SAsymmetricCryptionDataWithPublicRSAKey, SCheckerMongoDatabaseConnection, SCheckerMySqlDatabaseConnection, SCheckerPostgresDatabaseConnection, TJSONBodyParser, type TLogLevel, type TOriginalWriteEncoding, type TParseFunction, TRawBodyParser, TTextBodyParser, TUrlencodedBodyParser, Utility, YamlParsing, dateTimeFormatted, loggerConfig, optionalArgumentConnectionUtil, translateLanguageLoader };
|