@rapidrest/core 1.14.0 → 2.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/lib/AlertUtils.js +71 -56
- package/dist/lib/AlertUtils.js.map +1 -1
- package/dist/lib/ApiError.js +8 -1
- package/dist/lib/ApiError.js.map +1 -1
- package/dist/lib/CacheUtils.js +23 -0
- package/dist/lib/CacheUtils.js.map +1 -0
- package/dist/lib/ClassLoader.js +48 -44
- package/dist/lib/ClassLoader.js.map +1 -1
- package/dist/lib/FileUtils.js +133 -60
- package/dist/lib/FileUtils.js.map +1 -1
- package/dist/lib/JWTUtils.js +250 -145
- package/dist/lib/JWTUtils.js.map +1 -1
- package/dist/lib/Logger.js +39 -7
- package/dist/lib/Logger.js.map +1 -1
- package/dist/lib/MemoryStore.js +8 -6
- package/dist/lib/MemoryStore.js.map +1 -1
- package/dist/lib/MessagingUtils.js +71 -35
- package/dist/lib/MessagingUtils.js.map +1 -1
- package/dist/lib/NotificationsUtils.js +60 -8
- package/dist/lib/NotificationsUtils.js.map +1 -1
- package/dist/lib/OASUtils.js +67 -18
- package/dist/lib/OASUtils.js.map +1 -1
- package/dist/lib/ObjectFactory.js +151 -63
- package/dist/lib/ObjectFactory.js.map +1 -1
- package/dist/lib/ObjectUtils.js +48 -7
- package/dist/lib/ObjectUtils.js.map +1 -1
- package/dist/lib/StringUtils.js +55 -21
- package/dist/lib/StringUtils.js.map +1 -1
- package/dist/lib/TelemetryUtils.js +41 -5
- package/dist/lib/TelemetryUtils.js.map +1 -1
- package/dist/lib/UserUtils.js +5 -6
- package/dist/lib/UserUtils.js.map +1 -1
- package/dist/lib/ValidationUtils.js +16 -4
- package/dist/lib/ValidationUtils.js.map +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/threads/ThreadPool.js +198 -58
- package/dist/lib/threads/ThreadPool.js.map +1 -1
- package/dist/types/AlertUtils.d.ts +4 -0
- package/dist/types/CacheUtils.d.ts +14 -0
- package/dist/types/ClassLoader.d.ts +10 -0
- package/dist/types/FileUtils.d.ts +23 -7
- package/dist/types/JWTUtils.d.ts +88 -18
- package/dist/types/MessagingUtils.d.ts +7 -1
- package/dist/types/NotificationsUtils.d.ts +30 -0
- package/dist/types/ObjectFactory.d.ts +25 -1
- package/dist/types/ObjectUtils.d.ts +14 -0
- package/dist/types/StringUtils.d.ts +8 -0
- package/dist/types/TelemetryUtils.d.ts +19 -1
- package/dist/types/ValidationUtils.d.ts +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/threads/ThreadPool.d.ts +34 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadPool.js","sourceRoot":"","sources":["../../../src/threads/ThreadPool.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9D,OAAO,EAAiB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"ThreadPool.js","sourceRoot":"","sources":["../../../src/threads/ThreadPool.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OA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AAC;QAChC,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;;AAhZD,+HAA+H;AACvG,+BAAoB,GAAG,IAAI,AAAP,CAAQ;AACpD,4LAA4L;AACpK,2BAAgB,GAAG,KAAK,AAAR,CAAS;AAOzC;IADP,MAAM;;0CACc;AAGb;IADP,MAAM,CAAC,yBAAyB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;;8CACN;AA4RjC;IADZ,OAAO;;;;sCAwCP"}
|
|
@@ -100,6 +100,10 @@ export declare class AlertUtils {
|
|
|
100
100
|
* @param options The configuration options to use.
|
|
101
101
|
*/
|
|
102
102
|
constructor(options: AlertUtilsOptions);
|
|
103
|
+
/** Returns `true` if `status` is a 2XX HTTP success code. Shared by every method below that inspects a
|
|
104
|
+
* response's status, so a future change to what counts as "success" (e.g. also accepting 304) only needs
|
|
105
|
+
* to be made in one place. */
|
|
106
|
+
private static isSuccess;
|
|
103
107
|
/**
|
|
104
108
|
* Attempts to close the existing alert with the given identifier.
|
|
105
109
|
* @param id The unique identifier of the alert to close.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for working with bounded in-memory caches.
|
|
3
|
+
*
|
|
4
|
+
* @author Jean-Philippe Steinmetz
|
|
5
|
+
*/
|
|
6
|
+
export declare class CacheUtils {
|
|
7
|
+
/**
|
|
8
|
+
* Evicts the oldest inserted entry from `map`, if any. A `Map` preserves insertion order, so this removes
|
|
9
|
+
* whatever entry was `set()` least recently among those still present.
|
|
10
|
+
*
|
|
11
|
+
* @param map The map to evict the oldest entry from.
|
|
12
|
+
*/
|
|
13
|
+
static evictOldest<K, V>(map: Map<K, V>): void;
|
|
14
|
+
}
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
* an ESM-only project you must use the `ts-node/esm` module loader. This can be specified by passing the `--loader` to
|
|
35
35
|
* node at runtime.
|
|
36
36
|
*
|
|
37
|
+
* Also, this code intentionally does not perform path-containment and symlink checks during it's load process as the
|
|
38
|
+
* purpose of this utility is never to be exposed to a client-facing API or process. Doing so would never make sense
|
|
39
|
+
* anyway. The lack of containment checks here is to eliminate real performance costs that such containment introduces.
|
|
40
|
+
*
|
|
37
41
|
* ```
|
|
38
42
|
* node --loader ts-node/esm <module>
|
|
39
43
|
* ```
|
|
@@ -77,6 +81,12 @@ export declare class ClassLoader {
|
|
|
77
81
|
* @returns `true` if a class definition exists for the given fully qualified name, otherwise `false`.
|
|
78
82
|
*/
|
|
79
83
|
hasClass(fqn: string): any | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Imports the module at `fullpath` and registers each of its exports as a class under its fully qualified
|
|
86
|
+
* name, shared by both the JavaScript and TypeScript loading branches of `load()` so a future change to
|
|
87
|
+
* how exports are turned into registered classes only needs to be made in one place.
|
|
88
|
+
*/
|
|
89
|
+
private registerModule;
|
|
80
90
|
/**
|
|
81
91
|
* Loads all modules exports contained in the directory specified. The folder must be a child
|
|
82
92
|
* directory to the `rootDir` parameter passed in to the constructor.
|
|
@@ -4,14 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class FileUtils {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
* Determines if the provided path exists on the filesystem.
|
|
8
|
+
*/
|
|
9
|
+
static exists(target: string): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Throws an error if `target` is not contained within `rootDir`. Used to prevent path traversal (e.g. `../`)
|
|
12
|
+
* from escaping an intended root when a caller opts in by providing `rootDir`.
|
|
13
|
+
*
|
|
14
|
+
* Both `rootDir` and the longest already-existing ancestor of `target` are resolved via `fs.promises.realpath`
|
|
15
|
+
* before the containment check, not just `path.resolve`. Without this, a symlink placed anywhere on disk
|
|
16
|
+
* within `target`'s existing ancestry (including `target` itself) that points outside `rootDir` would pass
|
|
17
|
+
* a purely lexical check, yet `fs.existsSync`/`fs.writeFileSync`/`fs.readFileSync` etc. would transparently
|
|
18
|
+
* follow it - defeating the containment guarantee entirely. Any remaining (not-yet-existing) trailing path
|
|
19
|
+
* segments can't be symlinks yet, so they're safely appended as literal strings.
|
|
10
20
|
*
|
|
11
|
-
* @param {string} rootDir The directory that `target` must be contained within.
|
|
12
|
-
* @param {string} target The
|
|
21
|
+
* @param {string} rootDir The directory that `target` must be contained within. Must exist.
|
|
22
|
+
* @param {string} target The path to verify.
|
|
23
|
+
* @returns The fully resolved (existing-portion realpath'd) path. Callers should use this value - not the
|
|
24
|
+
* original `target` - for the actual filesystem operation, so a symlink swapped in after this check can't
|
|
25
|
+
* reintroduce the gap it closes.
|
|
13
26
|
*/
|
|
14
|
-
|
|
27
|
+
static assertContained(rootDir: string, target: string): Promise<string>;
|
|
15
28
|
/**
|
|
16
29
|
* Attempts to write the provided contents to the file path given. If a file already exists at the destination
|
|
17
30
|
* an error is thrown unless `overwrite` is set to `true`.
|
|
@@ -45,8 +58,11 @@ export declare class FileUtils {
|
|
|
45
58
|
* @param {Map<string,string>} variables The map of variable names to values to swap. Applies to outPath only.
|
|
46
59
|
* @param {string} rootDir Optional. When provided, all resolved source and destination paths must be contained
|
|
47
60
|
* within this directory, otherwise an error is thrown.
|
|
61
|
+
* @param {boolean} overwrite Set to `true` to overwrite an existing file at the destination. Default is `false`,
|
|
62
|
+
* matching the behavior of `writeFile`/`copyFile`. Appended after `rootDir` to preserve the existing positional
|
|
63
|
+
* call signature - note this is the opposite order from `copyFile`'s `(overwrite, rootDir)`.
|
|
48
64
|
*/
|
|
49
|
-
static copyBinaryFile(srcPath: string, outPath: string, variables?: any, rootDir?: string): Promise<void>;
|
|
65
|
+
static copyBinaryFile(srcPath: string, outPath: string, variables?: any, rootDir?: string, overwrite?: boolean): Promise<void>;
|
|
50
66
|
/**
|
|
51
67
|
* Performs a deep copy of a directory tree at the given srcPath to the specified output directory. Performs
|
|
52
68
|
* template replacement for all variables given and skips any files in the specified filter.
|
package/dist/types/JWTUtils.d.ts
CHANGED
|
@@ -122,34 +122,103 @@ export interface JWTUtilsConfig {
|
|
|
122
122
|
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
123
123
|
*/
|
|
124
124
|
export declare class JWTUtils {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
/** HMAC algorithm names that must never be permitted alongside a non-HMAC secret (see `assertSafeAlgorithm`). */
|
|
126
|
+
private static readonly HMAC_ALGORITHMS;
|
|
127
|
+
/** Maximum size, in bytes, a compressed profile is allowed to decompress to (see `finalizePayload`). Guards
|
|
128
|
+
* against a decompression bomb - a small compressed payload expanding to consume excessive memory. */
|
|
129
|
+
private static readonly MAX_DECOMPRESSED_PROFILE_BYTES;
|
|
130
|
+
/**
|
|
131
|
+
* Returns `true` if `secret` is a form that is only ever usable as a genuine HMAC secret - a plain
|
|
132
|
+
* string/Buffer that isn't PEM-encoded, or a `KeyObject` of type `"secret"`. Anything else (a PEM
|
|
133
|
+
* string/Buffer, an asymmetric `KeyObject`, a `{ key, passphrase }` wrapper, a `GetPublicKeyOrSecret`
|
|
134
|
+
* callback, a JWK-shaped object, etc.) is *not* considered safe, since it may resolve to a non-secret
|
|
135
|
+
* (public) value that an attacker could use to forge an HS256/384/512 token.
|
|
136
|
+
*/
|
|
137
|
+
private static isKnownSafeHmacSecret;
|
|
138
|
+
/**
|
|
139
|
+
* Throws unless `config.secret` is a known-safe plain HMAC secret. Any other secret shape is treated
|
|
140
|
+
* conservatively as potentially asymmetric (fail closed, rather than only matching a fixed allowlist of
|
|
141
|
+
* asymmetric shapes seen so far) and requires `config.options.algorithms` to be explicitly set to a list
|
|
142
|
+
* that does not itself include an HMAC algorithm. Without this, signing/verifying with e.g. an RSA key
|
|
143
|
+
* while leaving `algorithms` unset - or restricting it to `["RS256", "HS256"]` - opens the door to
|
|
144
|
+
* algorithm-confusion attacks: an attacker holding only the public half of the key pair can forge a token
|
|
145
|
+
* by signing it with HS256 using that public value as the HMAC secret.
|
|
131
146
|
*
|
|
132
147
|
* @param config The JWT configuration to validate.
|
|
133
148
|
*/
|
|
134
149
|
private static assertSafeAlgorithm;
|
|
135
150
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
151
|
+
* Returns the key length, in bytes, required by `algorithm` (e.g. 32 for `aes-256-cbc`, 24 for
|
|
152
|
+
* `aes-192-cbc`), so the scrypt-derived key `deriveKey`/`deriveKeySync` produce always matches whatever
|
|
153
|
+
* cipher `passwordOptions.algorithm` actually names, instead of a length hard-coded for one specific
|
|
154
|
+
* algorithm. Throws a clear error for an algorithm Node's `crypto` module doesn't recognize, rather than
|
|
155
|
+
* letting `createCipheriv`/`createDecipheriv` fail later with an opaque "Invalid key length".
|
|
156
|
+
*/
|
|
157
|
+
private static resolveKeyLength;
|
|
158
|
+
/**
|
|
159
|
+
* Derives a symmetric encryption key from `password`/`salt` for use with `algorithm`.
|
|
141
160
|
*/
|
|
142
161
|
private static deriveKey;
|
|
143
162
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* @param user The user to encode into the token's payload.
|
|
163
|
+
* Synchronous counterpart to `deriveKey()`. **Blocks the event loop** for the duration of the scrypt
|
|
164
|
+
* derivation (deliberately CPU-expensive, typically tens of milliseconds) - `createTokenSync`/
|
|
165
|
+
* `decodeTokenSync` should therefore be avoided on a request-handling path when password-based payload
|
|
166
|
+
* encryption is configured; prefer `createToken`/`decodeToken` there.
|
|
149
167
|
*/
|
|
150
168
|
private static deriveKeySync;
|
|
169
|
+
/**
|
|
170
|
+
* Encrypts `plaintext` for `publicKey` using hybrid encryption: `plaintext` is encrypted with a fresh
|
|
171
|
+
* AES-256-GCM key, which is itself wrapped with RSA. This avoids `crypto.publicEncrypt`'s fixed plaintext-size
|
|
172
|
+
* limit (e.g. ~214 bytes for a 2048-bit key with OAEP padding), which a raw JSON user profile easily exceeds.
|
|
173
|
+
*
|
|
174
|
+
* @param publicKey The RSA public key to wrap the AES key with.
|
|
175
|
+
* @param plaintext The data to encrypt.
|
|
176
|
+
* @returns The encrypted data, encoded as `<wrapped-key>.<iv>.<authTag>.<ciphertext>`, all base64.
|
|
177
|
+
*/
|
|
178
|
+
private static hybridEncrypt;
|
|
179
|
+
/**
|
|
180
|
+
* Returns the base64-encoded authentication tag for `cipher` if it's an AEAD cipher, otherwise `""`. Rather
|
|
181
|
+
* than pattern-matching the algorithm name (which only recognizes a fixed list of known AEAD naming
|
|
182
|
+
* conventions), this asks the cipher itself via `getAuthTag()`, which throws for any non-AEAD cipher - so
|
|
183
|
+
* any AEAD cipher/alias supported by the current Node/OpenSSL build is handled correctly, including ones
|
|
184
|
+
* not known when this was last updated.
|
|
185
|
+
*/
|
|
186
|
+
private static getAuthTagIfAEAD;
|
|
187
|
+
/**
|
|
188
|
+
* Decrypts data produced by `hybridEncrypt`.
|
|
189
|
+
*
|
|
190
|
+
* @param privateKey The RSA private key to unwrap the AES key with.
|
|
191
|
+
* @param encoded The encrypted data, as produced by `hybridEncrypt`.
|
|
192
|
+
*/
|
|
193
|
+
private static hybridDecrypt;
|
|
194
|
+
/**
|
|
195
|
+
* Builds the signable payload shared by `createToken`/`createTokenSync`: validates `config`/`user`, spreads
|
|
196
|
+
* `data`, compresses the profile if requested, and - for public-key encryption only, which has no async
|
|
197
|
+
* dependency - encrypts it. Password-based encryption is left for the caller to finish via
|
|
198
|
+
* `finishPasswordEncryption()`, since deriving the key is the one step that differs between the sync and
|
|
199
|
+
* async entry points.
|
|
200
|
+
*/
|
|
201
|
+
private static preparePayload;
|
|
202
|
+
/** Finishes password-based payload encryption once `key` has been derived (sync or async). */
|
|
203
|
+
private static finishPasswordEncryption;
|
|
151
204
|
static createToken(config: JWTUtilsConfig, user: JWTUser, data?: any): Promise<string>;
|
|
205
|
+
/**
|
|
206
|
+
* Synchronous counterpart to `createToken()`. **Blocks the event loop** while deriving the encryption key
|
|
207
|
+
* when password-based payload encryption is configured (see `deriveKeySync`) - prefer `createToken()` on a
|
|
208
|
+
* request-handling path in that case.
|
|
209
|
+
*/
|
|
152
210
|
static createTokenSync(config: JWTUtilsConfig, user: JWTUser, data?: any): string;
|
|
211
|
+
/**
|
|
212
|
+
* Verifies `token` and prepares its payload for `decodeToken`/`decodeTokenSync`: validates the signature/
|
|
213
|
+
* shape, and - for private-key decryption only, which has no async dependency - decrypts it in place.
|
|
214
|
+
* Password-based decryption is left for the caller to finish via `finishPasswordDecryption()`, since
|
|
215
|
+
* deriving the key is the one step that differs between the sync and async entry points.
|
|
216
|
+
*/
|
|
217
|
+
private static preDecode;
|
|
218
|
+
/** Finishes password-based payload decryption once `key` has been derived (sync or async). */
|
|
219
|
+
private static finishPasswordDecryption;
|
|
220
|
+
/** Decompresses (if applicable) and parses the final payload profile shared by both decode entry points. */
|
|
221
|
+
private static finalizePayload;
|
|
153
222
|
/**
|
|
154
223
|
* Decodes the given JWT authentication token using the provided configuration. If the token is not valid an
|
|
155
224
|
* error is thrown with the reason. Returns the encoded user object payload upon success.
|
|
@@ -160,8 +229,9 @@ export declare class JWTUtils {
|
|
|
160
229
|
*/
|
|
161
230
|
static decodeToken(config: JWTUtilsConfig, token: string): Promise<JWTPayload>;
|
|
162
231
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
232
|
+
* Synchronous counterpart to `decodeToken()`. **Blocks the event loop** while deriving the decryption key
|
|
233
|
+
* when password-based payload encryption is configured (see `deriveKeySync`) - prefer `decodeToken()` on a
|
|
234
|
+
* request-handling path in that case.
|
|
165
235
|
*
|
|
166
236
|
* @param config The JWT configuration to use when validating the token.
|
|
167
237
|
* @param token The JWT token to validate.
|
|
@@ -57,12 +57,18 @@ export declare class MessagingUtils {
|
|
|
57
57
|
private _transporter;
|
|
58
58
|
/** Cache of compiled Handlebars delegates keyed by "<templateName>:<field>". */
|
|
59
59
|
private _compiledTemplates;
|
|
60
|
+
/** Source string each `_compiledTemplates` entry was compiled from, keyed the same way. Lets `loadTemplate()`
|
|
61
|
+
* detect when an existing field's value has changed (e.g. a live config reload editing a template's subject/
|
|
62
|
+
* text/html) and recompile, instead of only ever compiling a field once and rendering stale content forever. */
|
|
63
|
+
private _compiledTemplateSources;
|
|
64
|
+
/** Names of templates already compiled into `_compiledTemplates` for this instance. See `loadTemplate()`. */
|
|
65
|
+
private _loadedTemplates;
|
|
60
66
|
init(): Promise<void>;
|
|
61
67
|
/**
|
|
62
68
|
* Loads the template with the given name and returns its contents as a string.
|
|
63
69
|
* @param name The name of the template to load.
|
|
64
70
|
*/
|
|
65
|
-
loadTemplate(name: string): Template
|
|
71
|
+
loadTemplate(name: string): Promise<Template>;
|
|
66
72
|
/**
|
|
67
73
|
* Sends an email using the given template name and variables.
|
|
68
74
|
* @param templateName The name of the email template to send.
|
|
@@ -4,17 +4,42 @@
|
|
|
4
4
|
* @author Jean-Philippe Steinmetz
|
|
5
5
|
*/
|
|
6
6
|
export declare class NotificationUtils {
|
|
7
|
+
/**
|
|
8
|
+
* The redis channel `broadcastMessage()` publishes to. Namespaced (rather than a bare `"allusers"`) so it
|
|
9
|
+
* can never collide with a per-recipient channel `sendMessage()` derives from a caller-supplied uid - a
|
|
10
|
+
* client-facing "send a message to this uid" feature that passes its recipient straight through to
|
|
11
|
+
* `sendMessage()` must not be able to choose a uid that lands on the broadcast channel and reach every
|
|
12
|
+
* subscriber instead of the intended one recipient.
|
|
13
|
+
*/
|
|
14
|
+
static readonly BROADCAST_CHANNEL = "broadcast:allusers";
|
|
15
|
+
/**
|
|
16
|
+
* Prefix applied to every per-recipient channel in `sendMessage()`. Combined with `BROADCAST_CHANNEL`'s own
|
|
17
|
+
* distinct `"broadcast:"` prefix, this guarantees the two channel namespaces can never overlap regardless of
|
|
18
|
+
* what uid value a caller supplies.
|
|
19
|
+
*/
|
|
20
|
+
static readonly USER_CHANNEL_PREFIX = "user:";
|
|
7
21
|
/** The redis client to use for broadcasting messages. */
|
|
8
22
|
private redis;
|
|
23
|
+
/** The logging utility to use. */
|
|
24
|
+
private logger?;
|
|
9
25
|
/**
|
|
10
26
|
* Initializes the utility using the given redis connection.
|
|
11
27
|
*
|
|
12
28
|
* @param {any} redis The redis connection to publish to.
|
|
29
|
+
* @param {any} logger The logging utility to use.
|
|
13
30
|
*/
|
|
14
31
|
constructor(redis: any);
|
|
32
|
+
/**
|
|
33
|
+
* Publishes to the given redis channel, logging (rather than crashing the process via an unhandled rejection)
|
|
34
|
+
* if the underlying client's `publish()` rejects.
|
|
35
|
+
*/
|
|
36
|
+
private publish;
|
|
15
37
|
/**
|
|
16
38
|
* Broadcasts a given message to all users.
|
|
17
39
|
*
|
|
40
|
+
* Subscribers must listen on `NotificationUtils.BROADCAST_CHANNEL` (rather than a bare `"allusers"`) to
|
|
41
|
+
* receive these messages.
|
|
42
|
+
*
|
|
18
43
|
* @param {any} type The type of message being sent.
|
|
19
44
|
* @param {string} action The action performed on the data (if applicable).
|
|
20
45
|
* @param {string} data The contents of the message to send.
|
|
@@ -23,6 +48,11 @@ export declare class NotificationUtils {
|
|
|
23
48
|
/**
|
|
24
49
|
* Sends a given message to the room or user with the specified uid(s).
|
|
25
50
|
*
|
|
51
|
+
* Each recipient's channel is `NotificationUtils.USER_CHANNEL_PREFIX + uid` (rather than the bare uid), so
|
|
52
|
+
* that no caller-supplied uid can collide with `NotificationUtils.BROADCAST_CHANNEL` or any other reserved
|
|
53
|
+
* channel and be delivered to unintended subscribers. Subscribers must listen on that prefixed channel name
|
|
54
|
+
* to receive messages sent to their uid.
|
|
55
|
+
*
|
|
26
56
|
* @param {string} uids The universally unique identifier of the room or user to send the message to.
|
|
27
57
|
* @param {string} type The type of message being sent.
|
|
28
58
|
* @param {string} action The action performed on the data (if applicable).
|
|
@@ -22,7 +22,10 @@ export declare class ObjectFactory {
|
|
|
22
22
|
readonly classes: Map<string, any>;
|
|
23
23
|
/** The global application configuration object. */
|
|
24
24
|
protected config: any;
|
|
25
|
-
/** A map for the unique name to the intance of a particular class type.
|
|
25
|
+
/** A map for the unique name to the intance of a particular class type.
|
|
26
|
+
*
|
|
27
|
+
* Note that this map is unbounded and only shrinks via an explicit `destroy()` call.
|
|
28
|
+
*/
|
|
26
29
|
readonly instances: Map<string, any>;
|
|
27
30
|
/** The application logging utility. */
|
|
28
31
|
protected logger: any;
|
|
@@ -30,6 +33,12 @@ export declare class ObjectFactory {
|
|
|
30
33
|
private readonly _metadataCache;
|
|
31
34
|
/** Secondary index: className → first registered instance key, for O(1) getInstance() fallback. */
|
|
32
35
|
private readonly _firstByClass;
|
|
36
|
+
/** Tracks in-flight `initialize()` promises, keyed by registry name, for instances currently completing
|
|
37
|
+
* async initialization. `newInstance()` registers an instance in `instances` before its (possibly async)
|
|
38
|
+
* initialization completes, so a concurrent `newInstance()` call for the same name would otherwise find the
|
|
39
|
+
* entry via the instances-map fast path and receive the not-yet-initialized instance synchronously instead
|
|
40
|
+
* of waiting. Consulting this map lets that caller await the same in-flight initialization instead. */
|
|
41
|
+
private readonly _pendingInit;
|
|
33
42
|
constructor(config?: any, logger?: any);
|
|
34
43
|
/** Walks the prototype chain once for `obj` and caches the discovered decorator metadata on the constructor. */
|
|
35
44
|
private _getOrBuildMetadata;
|
|
@@ -37,6 +46,11 @@ export declare class ObjectFactory {
|
|
|
37
46
|
* Destroys the specified objects. If `undefined` is passed in, all objects managed by the factory are destroyed.
|
|
38
47
|
*/
|
|
39
48
|
destroy(objs?: any | any[]): Promise<void>;
|
|
49
|
+
/** Removes `name` from `instances`. If it was the secondary index's "first" entry for its class, promotes
|
|
50
|
+
* another surviving instance of the same class if one exists, otherwise drops the entry so `getInstance()`
|
|
51
|
+
* correctly reports no instance is available. Shared by `destroy()` and `newInstance()`'s failed-initialization
|
|
52
|
+
* cleanup. */
|
|
53
|
+
private _removeInstance;
|
|
40
54
|
/**
|
|
41
55
|
* Deletes all instantiated objects.
|
|
42
56
|
*/
|
|
@@ -57,6 +71,16 @@ export declare class ObjectFactory {
|
|
|
57
71
|
* @returns The list of functions that implements the `@Init` decorator if found, otherwise undefined.
|
|
58
72
|
*/
|
|
59
73
|
getInitMethods(obj: any): Function[];
|
|
74
|
+
/**
|
|
75
|
+
* Derives the class name/fqn used to index `instances`/`classes` from a class type, fully qualified name
|
|
76
|
+
* string, or (defensively) a live instance. Shared by `getInstance`, `newInstance` and `register` so the
|
|
77
|
+
* three can never disagree about which string identifies a given class - a custom `.fqn` (e.g. one assigned
|
|
78
|
+
* by `ClassLoader`) always takes precedence over the bare `.name`, honored consistently everywhere a class
|
|
79
|
+
* identity is resolved.
|
|
80
|
+
*
|
|
81
|
+
* @param typeOrInstance The class type, fqn string, or instance to derive the name from.
|
|
82
|
+
*/
|
|
83
|
+
private static classNameOf;
|
|
60
84
|
/**
|
|
61
85
|
* Returns the object instance with the given unique name. Unique names take the form `<ClassName>:<InstanceName>`.
|
|
62
86
|
* It is possible to only specifiy the `<ClassName>`, doing so will automatically look for the `<ClassName>:default`
|
|
@@ -6,6 +6,10 @@ import { JWTUser } from "./JWTUtils.js";
|
|
|
6
6
|
* @author Jean-Philippe Steinmetz
|
|
7
7
|
*/
|
|
8
8
|
export declare class ObjectUtils {
|
|
9
|
+
/** Maximum object nesting depth `deleteScopedProps`/`validate` will recurse into with `recurse: true`. Guards
|
|
10
|
+
* against stack exhaustion from a pathologically deep (but otherwise valid, e.g. attacker-controlled JSON)
|
|
11
|
+
* object graph - cycle detection alone doesn't bound depth for a non-cyclic but very deep structure. */
|
|
12
|
+
private static readonly MAX_RECURSE_DEPTH;
|
|
9
13
|
/**
|
|
10
14
|
* Deletes all properties from the given object(s) that the specified user does not have scope to read.
|
|
11
15
|
*
|
|
@@ -15,6 +19,11 @@ export declare class ObjectUtils {
|
|
|
15
19
|
* @param recurse Set to `true` to validate all child objects.
|
|
16
20
|
*/
|
|
17
21
|
static deleteScopedProps(obj: any, user?: JWTUser, clazz?: any, recurse?: boolean): void;
|
|
22
|
+
/**
|
|
23
|
+
* Internal implementation of `deleteScopedProps` that tracks already-visited objects so that circular
|
|
24
|
+
* references (e.g. ORM-populated relations that reference each other) don't cause infinite recursion.
|
|
25
|
+
*/
|
|
26
|
+
private static _deleteScopedProps;
|
|
18
27
|
/**
|
|
19
28
|
* Performs validation of the given object or array. Validation is performed by scanning the object class for properties
|
|
20
29
|
* decorated with `@Validator` and executing the provided validation function.
|
|
@@ -24,4 +33,9 @@ export declare class ObjectUtils {
|
|
|
24
33
|
* @param recurse Set to `true` to validate all child objects.
|
|
25
34
|
*/
|
|
26
35
|
static validate(obj: any, clazz?: any, recurse?: boolean): void;
|
|
36
|
+
/**
|
|
37
|
+
* Internal implementation of `validate` that tracks already-visited objects so that circular references
|
|
38
|
+
* (e.g. ORM-populated relations that reference each other) don't cause infinite recursion.
|
|
39
|
+
*/
|
|
40
|
+
private static _validate;
|
|
27
41
|
}
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* @author Jean-Philippe Steinmetz
|
|
5
5
|
*/
|
|
6
6
|
export declare class StringUtils {
|
|
7
|
+
/**
|
|
8
|
+
* Escapes all regular expression metacharacters in `str` so it can be safely embedded in a `RegExp` pattern
|
|
9
|
+
* and matched as a literal string.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} str The string to escape.
|
|
12
|
+
* @returns {string} The escaped string.
|
|
13
|
+
*/
|
|
14
|
+
static escapeRegExp(str: string): string;
|
|
7
15
|
/**
|
|
8
16
|
* Returns a list of all parameters contained within the string. A parameter is a bracket delimited substring
|
|
9
17
|
* (e.g. /my/{key}/with/{id}).
|
|
@@ -49,6 +49,14 @@ export declare class Event implements NewEvent {
|
|
|
49
49
|
* The `on` function allows code within the same application or service to listen for outgoing events that have been
|
|
50
50
|
* sent via the `record` function.
|
|
51
51
|
*
|
|
52
|
+
* The utility uses an application specific JWT access token for sending telemetry events. The purpose of using an
|
|
53
|
+
* application specific JWT token versus user token is to identify a potentially compromised application server. This
|
|
54
|
+
* also allows the server to send telemetry events on behalf of the user that the user may not otherwise have permission
|
|
55
|
+
* to send.
|
|
56
|
+
*
|
|
57
|
+
* Note: This class is considered a runtime singleton and intentionally uses static state. Do not initialize this
|
|
58
|
+
* class more than once in your application.
|
|
59
|
+
*
|
|
52
60
|
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
53
61
|
*/
|
|
54
62
|
export declare class EventUtils {
|
|
@@ -63,7 +71,7 @@ export declare class EventUtils {
|
|
|
63
71
|
*
|
|
64
72
|
* @param config The application configuration to use.
|
|
65
73
|
* @param logger The logging utility to use.
|
|
66
|
-
* @param jwtToken The
|
|
74
|
+
* @param jwtToken The application's JWT token to send telemetry events on behalf of.
|
|
67
75
|
*/
|
|
68
76
|
static init(config: any, logger: any, jwtToken: string): Promise<void>;
|
|
69
77
|
/**
|
|
@@ -81,4 +89,14 @@ export declare class EventUtils {
|
|
|
81
89
|
* @param callback The function to call when an event is recorded.
|
|
82
90
|
*/
|
|
83
91
|
static on(type: string, callback: Function): void;
|
|
92
|
+
/**
|
|
93
|
+
* Unregisters a `callback` previously registered via `on()` for the given event `type`. Since `EventUtils` is
|
|
94
|
+
* a long-lived process-wide singleton, any listener registered dynamically (rather than once at startup) must
|
|
95
|
+
* eventually be removed via this method or its closure - and anything it captures - is retained for the life
|
|
96
|
+
* of the process.
|
|
97
|
+
*
|
|
98
|
+
* @param type The type of event the callback was registered for.
|
|
99
|
+
* @param callback The exact function reference passed to `on()`.
|
|
100
|
+
*/
|
|
101
|
+
static off(type: string, callback: Function): void;
|
|
84
102
|
}
|
|
@@ -24,7 +24,7 @@ export declare class ValidationUtils {
|
|
|
24
24
|
*/
|
|
25
25
|
static checkEmail(val: string): string;
|
|
26
26
|
/**
|
|
27
|
-
* Validates that the provided array is not empty.
|
|
27
|
+
* Validates that the provided array is not empty (nor `null`/`undefined`).
|
|
28
28
|
*/
|
|
29
29
|
static checkEmpty(val: Array<any>): Array<any>;
|
|
30
30
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./ApiError.js";
|
|
2
2
|
export * from "./AlertUtils.js";
|
|
3
|
+
export * from "./CacheUtils.js";
|
|
3
4
|
export * from "./ClassLoader.js";
|
|
4
5
|
export * from "./decorators/index.js";
|
|
5
6
|
export * from "./FileUtils.js";
|
|
@@ -7,6 +8,7 @@ export * from "./JWTUtils.js";
|
|
|
7
8
|
export * from "./Logger.js";
|
|
8
9
|
export * from "./MemoryStore.js";
|
|
9
10
|
export * from "./MessagingUtils.js";
|
|
11
|
+
export * from "./NotificationsUtils.js";
|
|
10
12
|
export * from "./ObjectFactory.js";
|
|
11
13
|
export * from "./ObjectUtils.js";
|
|
12
14
|
export * from "./OASUtils.js";
|
|
@@ -20,6 +20,13 @@ export interface WorkerOptions {
|
|
|
20
20
|
allowTs?: boolean;
|
|
21
21
|
/** The path to the worker file. This must be set when using `ThreadWorkerEntry` as the default entry file. */
|
|
22
22
|
worker?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The maximum amount of time, in milliseconds, to wait for all worker threads to report readiness before
|
|
25
|
+
* `start()` rejects. Default is `ThreadPool.START_TIMEOUT_MS`. Guards against a worker whose entry script
|
|
26
|
+
* hangs during its own setup and never posts online/emits an error, which would otherwise leave the
|
|
27
|
+
* returned promise hanging forever with no way to detect or recover.
|
|
28
|
+
*/
|
|
29
|
+
startupTimeoutMs?: number;
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
25
32
|
* The `ThreadPool` class provides an interface for managing a pool of execution threads that can be used for parallel
|
|
@@ -49,6 +56,10 @@ export interface WorkerOptions {
|
|
|
49
56
|
* @author Jean-Philippe Steinmetz
|
|
50
57
|
*/
|
|
51
58
|
export declare class ThreadPool {
|
|
59
|
+
/** The maximum amount of time, in milliseconds, `stop()` waits for a worker to exit on its own before force-terminating it. */
|
|
60
|
+
private static readonly STOP_GRACE_PERIOD_MS;
|
|
61
|
+
/** The default maximum amount of time, in milliseconds, `start()` waits for all workers to report readiness before rejecting. Overridable per-call via `WorkerOptions.startupTimeoutMs`. */
|
|
62
|
+
private static readonly START_TIMEOUT_MS;
|
|
52
63
|
/** The map of event types to a list of callback functions. */
|
|
53
64
|
private callbacks;
|
|
54
65
|
/** The index of the last worker that was assigned work. */
|
|
@@ -61,6 +72,10 @@ export declare class ThreadPool {
|
|
|
61
72
|
readonly workers: Array<Worker>;
|
|
62
73
|
/** Used to indicate that the pool is shutting down. */
|
|
63
74
|
private shutdown;
|
|
75
|
+
/** Tracks workers whose "exit" event has already fired, so a dead worker left in `workers` (e.g. exited
|
|
76
|
+
* without `restartOnExit`) is never sent a message via `postMessage()`, which throws synchronously once a
|
|
77
|
+
* worker has exited. */
|
|
78
|
+
private exitedWorkers;
|
|
64
79
|
/**
|
|
65
80
|
* The maximum number of threads that can be created by the pool.
|
|
66
81
|
*/
|
|
@@ -76,6 +91,20 @@ export declare class ThreadPool {
|
|
|
76
91
|
* @param logger The Winston logger instance to forward all worker thread logs to.
|
|
77
92
|
*/
|
|
78
93
|
constructor(max?: number, logger?: any);
|
|
94
|
+
/**
|
|
95
|
+
* @param onRestart Invoked with the replacement `Worker` whenever `restartOnExit` recreates the worker for
|
|
96
|
+
* `idx`. Lets `start()` re-attach its readiness-tracking listeners to the replacement - without this, a
|
|
97
|
+
* worker that crashes and is restarted before ever reporting ready would leave `start()`'s returned promise
|
|
98
|
+
* hanging forever, since nothing would be listening for the *replacement's* readiness signal.
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* Invokes every callback registered for `type` via `on()`, passing `idx` and optional `data`. Centralizes
|
|
102
|
+
* the "look up listeners, no-op if none registered" dispatch idiom shared by every worker event handler in
|
|
103
|
+
* `createWorker()`/`stop()` below, so a future change to how listeners are invoked - or a new message type
|
|
104
|
+
* that needs routing to a given event - only has to be made in one place instead of risking a hand-copied
|
|
105
|
+
* site being missed (as happened with WorkerMessageType.ERROR previously falling through to "message").
|
|
106
|
+
*/
|
|
107
|
+
private dispatch;
|
|
79
108
|
private createWorker;
|
|
80
109
|
/**
|
|
81
110
|
* Initializes the thread pool with the initial worker threads and begins execution.
|
|
@@ -85,7 +114,8 @@ export declare class ThreadPool {
|
|
|
85
114
|
*/
|
|
86
115
|
start(options?: WorkerOptions, num?: number): Promise<void>;
|
|
87
116
|
/**
|
|
88
|
-
* Stops all running thread executions.
|
|
117
|
+
* Stops all running thread executions. Each worker is given `ThreadPool.STOP_GRACE_PERIOD_MS` to gracefully
|
|
118
|
+
* finish its own `stop()` and exit on its own before being force-terminated.
|
|
89
119
|
*/
|
|
90
120
|
stop(): Promise<void>;
|
|
91
121
|
/**
|
|
@@ -101,7 +131,9 @@ export declare class ThreadPool {
|
|
|
101
131
|
*/
|
|
102
132
|
send(msg: any): void;
|
|
103
133
|
/**
|
|
104
|
-
* Sends the provided message to all worker threads in the pool.
|
|
134
|
+
* Sends the provided message to all worker threads in the pool. Workers that have already exited (e.g.
|
|
135
|
+
* crashed with no `restartOnExit`) are silently skipped rather than throwing, so one dead worker doesn't
|
|
136
|
+
* prevent delivery to every worker after it in the array.
|
|
105
137
|
* @param msg The message to send to all workers.
|
|
106
138
|
*/
|
|
107
139
|
sendAll(msg: any): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rapidrest/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A collection of common utilities and core functionality for rapidly building RESTful applications.",
|
|
5
5
|
"repository": "https://github.com/rapidrest/core.git",
|
|
6
6
|
"author": "RapidREST <rapidrests@gmail.com>",
|