@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.
Files changed (53) hide show
  1. package/dist/lib/AlertUtils.js +71 -56
  2. package/dist/lib/AlertUtils.js.map +1 -1
  3. package/dist/lib/ApiError.js +8 -1
  4. package/dist/lib/ApiError.js.map +1 -1
  5. package/dist/lib/CacheUtils.js +23 -0
  6. package/dist/lib/CacheUtils.js.map +1 -0
  7. package/dist/lib/ClassLoader.js +48 -44
  8. package/dist/lib/ClassLoader.js.map +1 -1
  9. package/dist/lib/FileUtils.js +133 -60
  10. package/dist/lib/FileUtils.js.map +1 -1
  11. package/dist/lib/JWTUtils.js +250 -145
  12. package/dist/lib/JWTUtils.js.map +1 -1
  13. package/dist/lib/Logger.js +39 -7
  14. package/dist/lib/Logger.js.map +1 -1
  15. package/dist/lib/MemoryStore.js +8 -6
  16. package/dist/lib/MemoryStore.js.map +1 -1
  17. package/dist/lib/MessagingUtils.js +71 -35
  18. package/dist/lib/MessagingUtils.js.map +1 -1
  19. package/dist/lib/NotificationsUtils.js +60 -8
  20. package/dist/lib/NotificationsUtils.js.map +1 -1
  21. package/dist/lib/OASUtils.js +67 -18
  22. package/dist/lib/OASUtils.js.map +1 -1
  23. package/dist/lib/ObjectFactory.js +151 -63
  24. package/dist/lib/ObjectFactory.js.map +1 -1
  25. package/dist/lib/ObjectUtils.js +48 -7
  26. package/dist/lib/ObjectUtils.js.map +1 -1
  27. package/dist/lib/StringUtils.js +55 -21
  28. package/dist/lib/StringUtils.js.map +1 -1
  29. package/dist/lib/TelemetryUtils.js +41 -5
  30. package/dist/lib/TelemetryUtils.js.map +1 -1
  31. package/dist/lib/UserUtils.js +5 -6
  32. package/dist/lib/UserUtils.js.map +1 -1
  33. package/dist/lib/ValidationUtils.js +16 -4
  34. package/dist/lib/ValidationUtils.js.map +1 -1
  35. package/dist/lib/index.js +2 -0
  36. package/dist/lib/index.js.map +1 -1
  37. package/dist/lib/threads/ThreadPool.js +198 -58
  38. package/dist/lib/threads/ThreadPool.js.map +1 -1
  39. package/dist/types/AlertUtils.d.ts +4 -0
  40. package/dist/types/CacheUtils.d.ts +14 -0
  41. package/dist/types/ClassLoader.d.ts +10 -0
  42. package/dist/types/FileUtils.d.ts +23 -7
  43. package/dist/types/JWTUtils.d.ts +88 -18
  44. package/dist/types/MessagingUtils.d.ts +7 -1
  45. package/dist/types/NotificationsUtils.d.ts +30 -0
  46. package/dist/types/ObjectFactory.d.ts +25 -1
  47. package/dist/types/ObjectUtils.d.ts +14 -0
  48. package/dist/types/StringUtils.d.ts +8 -0
  49. package/dist/types/TelemetryUtils.d.ts +19 -1
  50. package/dist/types/ValidationUtils.d.ts +1 -1
  51. package/dist/types/index.d.ts +2 -0
  52. package/dist/types/threads/ThreadPool.d.ts +34 -2
  53. package/package.json +1 -1
@@ -13,20 +13,56 @@ const logger = Logger();
13
13
  */
14
14
  export class FileUtils {
15
15
  /**
16
- * Throws an error if the resolved `target` path is not contained within the resolved `rootDir` directory. Used
17
- * to prevent path traversal (e.g. `../`) from escaping an intended root when a caller opts in by providing
18
- * `rootDir`.
16
+ * Determines if the provided path exists on the filesystem.
17
+ */
18
+ static async exists(target) {
19
+ try {
20
+ await fs.promises.access(target);
21
+ return true;
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ }
27
+ /**
28
+ * Throws an error if `target` is not contained within `rootDir`. Used to prevent path traversal (e.g. `../`)
29
+ * from escaping an intended root when a caller opts in by providing `rootDir`.
30
+ *
31
+ * Both `rootDir` and the longest already-existing ancestor of `target` are resolved via `fs.promises.realpath`
32
+ * before the containment check, not just `path.resolve`. Without this, a symlink placed anywhere on disk
33
+ * within `target`'s existing ancestry (including `target` itself) that points outside `rootDir` would pass
34
+ * a purely lexical check, yet `fs.existsSync`/`fs.writeFileSync`/`fs.readFileSync` etc. would transparently
35
+ * follow it - defeating the containment guarantee entirely. Any remaining (not-yet-existing) trailing path
36
+ * segments can't be symlinks yet, so they're safely appended as literal strings.
19
37
  *
20
- * @param {string} rootDir The directory that `target` must be contained within.
21
- * @param {string} target The fully resolved path to verify.
38
+ * @param {string} rootDir The directory that `target` must be contained within. Must exist.
39
+ * @param {string} target The path to verify.
40
+ * @returns The fully resolved (existing-portion realpath'd) path. Callers should use this value - not the
41
+ * original `target` - for the actual filesystem operation, so a symlink swapped in after this check can't
42
+ * reintroduce the gap it closes.
22
43
  */
23
- static assertContained(rootDir, target) {
24
- const rootResolved = path.resolve(rootDir);
25
- const targetResolved = path.resolve(target);
26
- const rel = path.relative(rootResolved, targetResolved);
44
+ static async assertContained(rootDir, target) {
45
+ const rootReal = await fs.promises.realpath(path.resolve(rootDir));
46
+ let existingPart = path.resolve(target);
47
+ const remainder = [];
48
+ while (!(await FileUtils.exists(existingPart))) {
49
+ const parent = path.dirname(existingPart);
50
+ // `path.dirname()` of a filesystem root returns that same root, which is the only way this loop
51
+ // could otherwise become infinite. Not practically reachable in a real filesystem (the root itself
52
+ // always exists), so this is defense-in-depth rather than an expected/tested case.
53
+ /* v8 ignore next */
54
+ if (parent === existingPart)
55
+ break;
56
+ remainder.unshift(path.basename(existingPart));
57
+ existingPart = parent;
58
+ }
59
+ const existingReal = await fs.promises.realpath(existingPart);
60
+ const targetReal = remainder.length > 0 ? path.join(existingReal, ...remainder) : existingReal;
61
+ const rel = path.relative(rootReal, targetReal);
27
62
  if (rel !== "" && (rel.startsWith("..") || path.isAbsolute(rel))) {
28
- throw new Error(`Path "${target}" escapes the allowed root directory "${rootResolved}".`);
63
+ throw new Error(`Path "${target}" escapes the allowed root directory "${rootReal}".`);
29
64
  }
65
+ return targetReal;
30
66
  }
31
67
  /**
32
68
  * Attempts to write the provided contents to the file path given. If a file already exists at the destination
@@ -44,21 +80,28 @@ export class FileUtils {
44
80
  let srcPathFull = path.resolve(srcPath);
45
81
  let outPathFull = path.resolve(outPath);
46
82
  if (rootDir) {
47
- FileUtils.assertContained(rootDir, srcPathFull);
48
- FileUtils.assertContained(rootDir, outPathFull);
83
+ await FileUtils.assertContained(rootDir, srcPathFull);
84
+ outPathFull = await FileUtils.assertContained(rootDir, outPathFull);
49
85
  }
50
- let fileExists = fs.existsSync(outPathFull);
51
86
  // Make sure the path leading to the final destination exists
52
- let outDirPath = path.dirname(outPath);
53
- if (!fs.existsSync(outDirPath)) {
87
+ let outDirPath = path.dirname(outPathFull);
88
+ if (!(await FileUtils.exists(outDirPath))) {
54
89
  await mkdirp(outDirPath);
55
90
  }
56
- if (fileExists && !overwrite) {
57
- throw new Error(`File already exists at "${outPathFull}". Pass overwrite=true to replace it.`);
58
- }
59
- // Write the final output to disk
91
+ // Write the final output to disk. When `overwrite` is `false`, the exclusive `"wx"` flag makes the
92
+ // existence check and the write atomic - `fs.existsSync()` followed by a plain write would otherwise
93
+ // leave a window where two concurrent calls both see no existing file and one silently clobbers the
94
+ // other's output.
60
95
  logger.info("Writing: " + outPathFull);
61
- fs.writeFileSync(outPathFull, contents);
96
+ try {
97
+ await fs.promises.writeFile(outPathFull, contents, overwrite ? undefined : { flag: "wx" });
98
+ }
99
+ catch (err) {
100
+ if (!overwrite && err?.code === "EEXIST") {
101
+ throw new Error(`File already exists at "${outPathFull}". Pass overwrite=true to replace it.`);
102
+ }
103
+ throw err;
104
+ }
62
105
  }
63
106
  /**
64
107
  * Generates a copy of the source file at the desired output destination and performs a swap of all values of the
@@ -72,28 +115,25 @@ export class FileUtils {
72
115
  * within this directory, otherwise an error is thrown.
73
116
  */
74
117
  static async copyFile(srcPath, outPath, variables = {}, overwrite = false, rootDir) {
118
+ variables = variables ?? {};
75
119
  let srcPathFull = path.resolve(srcPath);
120
+ // Containment is checked *before* existence: assertContained() already tolerates a not-yet-existing
121
+ // target (it walks up to the nearest existing ancestor), so checking existence first would let a path
122
+ // outside rootDir get a different error ("File does not exist") depending on whether it happens to
123
+ // exist on disk - a file-existence oracle for paths the caller is supposed to be sandboxed away from.
76
124
  if (rootDir) {
77
- FileUtils.assertContained(rootDir, srcPathFull);
125
+ // Re-resolved via the realpath'd return value so the subsequent read follows the *validated* path
126
+ // rather than the original (potentially symlinked) one.
127
+ srcPathFull = await FileUtils.assertContained(rootDir, srcPathFull);
78
128
  }
79
- if (!fs.existsSync(srcPathFull)) {
129
+ if (!(await FileUtils.exists(srcPathFull))) {
80
130
  throw new Error("File does not exist: " + srcPathFull);
81
131
  }
82
- // Make sure the path leading to the final destination exists
83
- let outDirPath = path.dirname(outPath);
84
- if (!fs.existsSync(outDirPath)) {
85
- await mkdirp(outDirPath);
86
- }
87
- let template = fs.readFileSync(srcPathFull, "utf-8");
88
- if (template) {
89
- let output = StringUtils.findAndReplace(template, variables);
90
- let outPathFinal = path.resolve(StringUtils.findAndReplace(outPath, variables));
91
- logger.info("Writing: " + outPathFinal);
92
- await FileUtils.writeFile(srcPath, outPathFinal, output, overwrite, rootDir);
93
- }
94
- else {
95
- throw new Error("Failed to read file: " + srcPathFull);
96
- }
132
+ let template = await fs.promises.readFile(srcPathFull, "utf-8");
133
+ let output = StringUtils.findAndReplace(template, variables);
134
+ let outPathFinal = path.resolve(StringUtils.findAndReplace(outPath, variables));
135
+ logger.info("Writing: " + outPathFinal);
136
+ await FileUtils.writeFile(srcPath, outPathFinal, output, overwrite, rootDir);
97
137
  }
98
138
  /**
99
139
  * Generates a copy of the source file at the desired output destination using binary copy mode.
@@ -103,25 +143,55 @@ export class FileUtils {
103
143
  * @param {Map<string,string>} variables The map of variable names to values to swap. Applies to outPath only.
104
144
  * @param {string} rootDir Optional. When provided, all resolved source and destination paths must be contained
105
145
  * within this directory, otherwise an error is thrown.
146
+ * @param {boolean} overwrite Set to `true` to overwrite an existing file at the destination. Default is `false`,
147
+ * matching the behavior of `writeFile`/`copyFile`. Appended after `rootDir` to preserve the existing positional
148
+ * call signature - note this is the opposite order from `copyFile`'s `(overwrite, rootDir)`.
106
149
  */
107
- static async copyBinaryFile(srcPath, outPath, variables = {}, rootDir) {
108
- let srcPathFull = path.resolve(srcPath);
109
- if (rootDir) {
110
- FileUtils.assertContained(rootDir, srcPathFull);
150
+ static async copyBinaryFile(srcPath, outPath, variables = {}, rootDir, overwrite = false) {
151
+ // `copyBinaryFile`'s `(rootDir, overwrite)` parameter order is the reverse of `copyFile`'s
152
+ // `(overwrite, rootDir)`. A caller that swaps them by analogy with `copyFile` would otherwise either
153
+ // silently disable overwrite protection (a boolean passed where `rootDir` is expected is truthy and
154
+ // simply fails the `typeof` check for a path) or crash confusingly deep inside `path.resolve()`, so it's
155
+ // rejected here with a message that explains the actual mistake.
156
+ if (rootDir !== undefined && typeof rootDir !== "string") {
157
+ throw new TypeError(`copyBinaryFile: "rootDir" must be a string, got ${typeof rootDir}. Did you mean to swap the ` +
158
+ `"overwrite" and "rootDir" arguments? Unlike copyFile, copyBinaryFile's signature is ` +
159
+ `(srcPath, outPath, variables, rootDir, overwrite).`);
111
160
  }
112
- if (!fs.existsSync(srcPathFull)) {
161
+ if (typeof overwrite !== "boolean") {
162
+ throw new TypeError(`copyBinaryFile: "overwrite" must be a boolean, got ${typeof overwrite}.`);
163
+ }
164
+ variables = variables ?? {};
165
+ let srcPathFull = path.resolve(srcPath);
166
+ if (!(await FileUtils.exists(srcPathFull))) {
113
167
  throw new Error("File does not exist: " + srcPathFull);
114
168
  }
115
- // Make sure the path leading to the final destination exists
116
- let outDirPath = path.resolve(path.dirname(outPath));
117
- if (!fs.existsSync(outDirPath)) {
118
- await mkdirp(outDirPath);
169
+ if (rootDir) {
170
+ srcPathFull = await FileUtils.assertContained(rootDir, srcPathFull);
119
171
  }
120
172
  let outPathFinal = path.resolve(StringUtils.findAndReplace(outPath, variables));
121
173
  if (rootDir) {
122
- FileUtils.assertContained(rootDir, outPathFinal);
174
+ outPathFinal = await FileUtils.assertContained(rootDir, outPathFinal);
175
+ }
176
+ // Make sure the path leading to the final (template-substituted) destination exists. Must be derived from
177
+ // `outPathFinal`, not the raw `outPath`, otherwise the created directory can differ from the one actually
178
+ // written to whenever `outPath`'s directory itself contains template variables.
179
+ let outDirPath = path.dirname(outPathFinal);
180
+ if (!(await FileUtils.exists(outDirPath))) {
181
+ await mkdirp(outDirPath);
182
+ }
183
+ // `COPYFILE_EXCL` makes the existence check and the copy atomic when `overwrite` is `false` - a plain
184
+ // `fs.existsSync()` check followed by an unconditional copy would otherwise leave a window where two
185
+ // concurrent calls both see no existing file and one silently clobbers the other's output.
186
+ try {
187
+ await fs.promises.copyFile(srcPathFull, outPathFinal, overwrite ? 0 : fs.constants.COPYFILE_EXCL);
188
+ }
189
+ catch (err) {
190
+ if (!overwrite && err?.code === "EEXIST") {
191
+ throw new Error(`File already exists at "${outPathFinal}". Pass overwrite=true to replace it.`);
192
+ }
193
+ throw err;
123
194
  }
124
- fs.copyFileSync(srcPathFull, outPathFinal);
125
195
  }
126
196
  /**
127
197
  * Performs a deep copy of a directory tree at the given srcPath to the specified output directory. Performs
@@ -137,15 +207,18 @@ export class FileUtils {
137
207
  * within this directory, otherwise an error is thrown.
138
208
  */
139
209
  static async copyDirectory(srcPath, outPath, vars = {}, excludeFilters = [], binaryFilters = [], force = false, rootDir) {
140
- const templatePath = path.resolve(srcPath);
210
+ vars = vars ?? {};
211
+ let templatePath = path.resolve(srcPath);
141
212
  if (rootDir) {
142
- FileUtils.assertContained(rootDir, templatePath);
213
+ templatePath = await FileUtils.assertContained(rootDir, templatePath);
143
214
  }
144
- let files = fs.readdirSync(templatePath, { withFileTypes: true });
145
- // Iterated with a sequentially-awaited for-of (not `Array#forEach`, which ignores the promise its async
146
- // callback returns): copyDirectory must not resolve until every nested copy has actually finished, and
147
- // any error thrown by a nested copy must propagate to the caller instead of becoming an unhandled rejection.
148
- for (const file of files) {
215
+ let files = await fs.promises.readdir(templatePath, { withFileTypes: true });
216
+ // Copied concurrently via `Promise.all` rather than a sequentially-awaited loop, since sibling entries
217
+ // in the same directory are independent of one another. `Promise.all` still `await`s every entry before
218
+ // `copyDirectory` itself resolves and still propagates the first rejection to the caller, so this keeps
219
+ // the same "wait for everything, never swallow an error" guarantee a sequential loop would - it just lets
220
+ // independent copies overlap instead of running strictly one at a time.
221
+ await Promise.all(files.map(async (file) => {
149
222
  let extension = path.extname(file.name);
150
223
  if (!extension) {
151
224
  extension = file.name;
@@ -154,24 +227,24 @@ export class FileUtils {
154
227
  if (excludeFilters.indexOf(extension) === -1) {
155
228
  let destPath = StringUtils.findAndReplace(path.join(outPath, file.name), vars);
156
229
  if (rootDir) {
157
- FileUtils.assertContained(rootDir, destPath);
230
+ destPath = await FileUtils.assertContained(rootDir, destPath);
158
231
  }
159
232
  if (file.isDirectory()) {
160
- if (!fs.existsSync(destPath)) {
233
+ if (!(await FileUtils.exists(destPath))) {
161
234
  // Recursive: `outPath` itself may not exist yet either, e.g. when directory entries are
162
235
  // processed ahead of any file entry that would otherwise implicitly create it via mkdirp.
163
- fs.mkdirSync(destPath, { recursive: true });
236
+ await fs.promises.mkdir(destPath, { recursive: true });
164
237
  }
165
238
  await FileUtils.copyDirectory(path.join(templatePath, file.name), destPath, vars, excludeFilters, binaryFilters, force, rootDir);
166
239
  }
167
240
  else if (binaryFilters.indexOf(extension) >= 0) {
168
- await FileUtils.copyBinaryFile(path.join(templatePath, file.name), destPath, vars, rootDir);
241
+ await FileUtils.copyBinaryFile(path.join(templatePath, file.name), destPath, vars, rootDir, force);
169
242
  }
170
243
  else {
171
244
  await FileUtils.copyFile(path.join(templatePath, file.name), destPath, vars, force, rootDir);
172
245
  }
173
246
  }
174
- }
247
+ }));
175
248
  }
176
249
  }
177
250
  //# sourceMappingURL=FileUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileUtils.js","sourceRoot":"","sources":["../../src/FileUtils.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM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