@dereekb/nestjs 13.10.8 → 13.11.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/index.cjs.js CHANGED
@@ -9,9 +9,11 @@ var querystring = require('querystring');
9
9
  var bodyParser = require('body-parser');
10
10
  var util = require('@dereekb/util');
11
11
  var config = require('@nestjs/config');
12
+ var node_fs = require('node:fs');
13
+ var promises$1 = require('node:fs/promises');
12
14
  var node_crypto = require('node:crypto');
13
15
 
14
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
16
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
15
17
  try {
16
18
  var info = gen[key](arg);
17
19
  var value = info.value;
@@ -25,22 +27,22 @@ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
25
27
  Promise.resolve(value).then(_next, _throw);
26
28
  }
27
29
  }
28
- function _async_to_generator$1(fn) {
30
+ function _async_to_generator$2(fn) {
29
31
  return function() {
30
32
  var self = this, args = arguments;
31
33
  return new Promise(function(resolve, reject) {
32
34
  var gen = fn.apply(self, args);
33
35
  function _next(value) {
34
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
36
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
35
37
  }
36
38
  function _throw(err) {
37
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
39
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
38
40
  }
39
41
  _next(undefined);
40
42
  });
41
43
  };
42
44
  }
43
- function _ts_generator$1(thisArg, body) {
45
+ function _ts_generator$2(thisArg, body) {
44
46
  var f, y, t, _ = {
45
47
  label: 0,
46
48
  sent: function() {
@@ -159,9 +161,9 @@ function _ts_generator$1(thisArg, body) {
159
161
  */ function nodeJsLocalAssetLoader(config) {
160
162
  var basePath = config.basePath;
161
163
  var getFn = function getFn(ref) {
162
- return _async_to_generator$1(function() {
164
+ return _async_to_generator$2(function() {
163
165
  var localRef, fullPath, buffer;
164
- return _ts_generator$1(this, function(_state) {
166
+ return _ts_generator$2(this, function(_state) {
165
167
  switch(_state.label){
166
168
  case 0:
167
169
  localRef = ref;
@@ -240,7 +242,7 @@ function _ts_generator$1(thisArg, body) {
240
242
  return origin.startsWith('http://localhost') || origin.startsWith('https://localhost');
241
243
  }
242
244
 
243
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
245
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
244
246
  try {
245
247
  var info = gen[key](arg);
246
248
  var value = info.value;
@@ -254,22 +256,22 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
254
256
  Promise.resolve(value).then(_next, _throw);
255
257
  }
256
258
  }
257
- function _async_to_generator(fn) {
259
+ function _async_to_generator$1(fn) {
258
260
  return function() {
259
261
  var self = this, args = arguments;
260
262
  return new Promise(function(resolve, reject) {
261
263
  var gen = fn.apply(self, args);
262
264
  function _next(value) {
263
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
265
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
264
266
  }
265
267
  function _throw(err) {
266
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
268
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
267
269
  }
268
270
  _next(undefined);
269
271
  });
270
272
  };
271
273
  }
272
- function _ts_generator(thisArg, body) {
274
+ function _ts_generator$1(thisArg, body) {
273
275
  var f, y, t, _ = {
274
276
  label: 0,
275
277
  sent: function() {
@@ -382,9 +384,9 @@ function _ts_generator(thisArg, body) {
382
384
  * ```
383
385
  */ var rawBodyLogger = new common.Logger('RawBody');
384
386
  var ParseRawBody = common.createParamDecorator(function(_, context) {
385
- return _async_to_generator(function() {
387
+ return _async_to_generator$1(function() {
386
388
  var req, body;
387
- return _ts_generator(this, function(_state) {
389
+ return _ts_generator$1(this, function(_state) {
388
390
  switch(_state.label){
389
391
  case 0:
390
392
  req = context.switchToHttp().getRequest();
@@ -419,9 +421,9 @@ var ParseRawBody = common.createParamDecorator(function(_, context) {
419
421
  * handleWebhook(@RawBody() body: RawBodyBuffer) { ... }
420
422
  * ```
421
423
  */ var RawBody = common.createParamDecorator(function(_, context) {
422
- return _async_to_generator(function() {
424
+ return _async_to_generator$1(function() {
423
425
  var req, body;
424
- return _ts_generator(this, function(_state) {
426
+ return _ts_generator$1(this, function(_state) {
425
427
  req = context.switchToHttp().getRequest();
426
428
  body = req.body;
427
429
  if (!Buffer.isBuffer(body)) {
@@ -445,9 +447,9 @@ var ParseRawBody = common.createParamDecorator(function(_, context) {
445
447
  * handleForm(@ParsedQueryRawBody() body: ParsedUrlQuery) { ... }
446
448
  * ```
447
449
  */ var ParsedQueryRawBody = common.createParamDecorator(function(_, context) {
448
- return _async_to_generator(function() {
450
+ return _async_to_generator$1(function() {
449
451
  var req;
450
- return _ts_generator(this, function(_state) {
452
+ return _ts_generator$1(this, function(_state) {
451
453
  req = context.switchToHttp().getRequest();
452
454
  req.body = RawBodyToParsedQueryString(req.body);
453
455
  return [
@@ -631,7 +633,7 @@ function _create_class$3(Constructor, protoProps, staticProps) {
631
633
  if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
632
634
  return Constructor;
633
635
  }
634
- function _define_property$3(obj, key, value) {
636
+ function _define_property$4(obj, key, value) {
635
637
  if (key in obj) {
636
638
  Object.defineProperty(obj, key, {
637
639
  value: value,
@@ -739,7 +741,7 @@ var DEFAULT_WEBHOOK_MIDDLEWARE_ROUTE_INFO = {
739
741
  function ConfigureWebhookMiddlewareModule() {
740
742
  _class_call_check$5(this, ConfigureWebhookMiddlewareModule);
741
743
  var _this;
742
- _this = _call_super(this, ConfigureWebhookMiddlewareModule, arguments), _define_property$3(_this, "logger", new common.Logger('ConfigureWebhookMiddlewareModule'));
744
+ _this = _call_super(this, ConfigureWebhookMiddlewareModule, arguments), _define_property$4(_this, "logger", new common.Logger('ConfigureWebhookMiddlewareModule'));
743
745
  return _this;
744
746
  }
745
747
  _create_class$3(ConfigureWebhookMiddlewareModule, [
@@ -836,7 +838,7 @@ function _create_class$2(Constructor, protoProps, staticProps) {
836
838
  if (staticProps) _defineProperties$2(Constructor, staticProps);
837
839
  return Constructor;
838
840
  }
839
- function _define_property$2(obj, key, value) {
841
+ function _define_property$3(obj, key, value) {
840
842
  if (key in obj) {
841
843
  Object.defineProperty(obj, key, {
842
844
  value: value,
@@ -856,7 +858,7 @@ function _define_property$2(obj, key, value) {
856
858
  */ var ClientAppServiceConfig = /*#__PURE__*/ function() {
857
859
  function ClientAppServiceConfig() {
858
860
  _class_call_check$4(this, ClientAppServiceConfig);
859
- _define_property$2(this, "client", void 0);
861
+ _define_property$3(this, "client", void 0);
860
862
  }
861
863
  _create_class$2(ClientAppServiceConfig, null, [
862
864
  {
@@ -895,7 +897,7 @@ function _create_class$1(Constructor, protoProps, staticProps) {
895
897
  if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
896
898
  return Constructor;
897
899
  }
898
- function _define_property$1(obj, key, value) {
900
+ function _define_property$2(obj, key, value) {
899
901
  if (key in obj) {
900
902
  Object.defineProperty(obj, key, {
901
903
  value: value,
@@ -913,7 +915,7 @@ function _define_property$1(obj, key, value) {
913
915
  */ exports.ClientAppService = /*#__PURE__*/ function() {
914
916
  function ClientAppService(config) {
915
917
  _class_call_check$3(this, ClientAppService);
916
- _define_property$1(this, "_config", void 0);
918
+ _define_property$2(this, "_config", void 0);
917
919
  this._config = config;
918
920
  }
919
921
  _create_class$1(ClientAppService, [
@@ -1052,7 +1054,7 @@ function _create_class(Constructor, protoProps, staticProps) {
1052
1054
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1053
1055
  return Constructor;
1054
1056
  }
1055
- function _define_property(obj, key, value) {
1057
+ function _define_property$1(obj, key, value) {
1056
1058
  if (key in obj) {
1057
1059
  Object.defineProperty(obj, key, {
1058
1060
  value: value,
@@ -1068,7 +1070,7 @@ function _define_property(obj, key, value) {
1068
1070
  exports.ServerEnvironmentService = /*#__PURE__*/ function() {
1069
1071
  function ServerEnvironmentService(env) {
1070
1072
  _class_call_check(this, ServerEnvironmentService);
1071
- _define_property(this, "env", void 0);
1073
+ _define_property$1(this, "env", void 0);
1072
1074
  this.env = env;
1073
1075
  }
1074
1076
  _create_class(ServerEnvironmentService, [
@@ -1116,6 +1118,639 @@ exports.ServerEnvironmentService = __decorate([
1116
1118
  __param(0, common.Inject(SERVER_ENV_TOKEN))
1117
1119
  ], exports.ServerEnvironmentService);
1118
1120
 
1121
+ /**
1122
+ * Reads JSON from disk, resolving `undefined` when the file is missing (ENOENT) or its
1123
+ * contents fail to parse as JSON. Other I/O errors (permission denied, busy handles) are
1124
+ * forwarded to the caller — silently swallowing them masks real failures.
1125
+ *
1126
+ * @param filePath - Absolute path to the JSON file to read.
1127
+ * @returns The parsed JSON cast to `T`, or `undefined` when the file does not exist or its contents are not valid JSON.
1128
+ */ function readJsonFile(filePath) {
1129
+ return new Promise(function(resolve, reject) {
1130
+ node_fs.readFile(filePath, {
1131
+ encoding: 'utf-8'
1132
+ }, function(err, data) {
1133
+ if (err) {
1134
+ if (err.code === 'ENOENT') {
1135
+ resolve(undefined);
1136
+ } else {
1137
+ reject(err);
1138
+ }
1139
+ return;
1140
+ }
1141
+ try {
1142
+ resolve(JSON.parse(data));
1143
+ } catch (unused) {
1144
+ resolve(undefined);
1145
+ }
1146
+ });
1147
+ });
1148
+ }
1149
+ /**
1150
+ * Writes a value to disk as JSON. Creates the parent directory if it does not exist.
1151
+ *
1152
+ * The `mode` option is enforced via an explicit `chmod` after the write — `writeFile`'s `mode`
1153
+ * parameter is ignored when the file already exists, which would otherwise leave a
1154
+ * pre-existing file at its original (potentially world-readable) permissions.
1155
+ *
1156
+ * @param input - Configuration describing the destination, payload, and optional file mode.
1157
+ * @param input.filePath - Absolute path to the file to write.
1158
+ * @param input.dirPath - Absolute path to the parent directory; created (recursively) when missing.
1159
+ * @param input.data - Value to serialize as JSON (pretty-printed with two-space indentation).
1160
+ * @param input.mode - Optional numeric file mode (e.g. `0o600`) applied via `chmod` after the write.
1161
+ * @returns A promise that resolves once the JSON has been written and the optional `chmod` has completed.
1162
+ */ function writeJsonFile(input) {
1163
+ node_fs.mkdirSync(input.dirPath, {
1164
+ recursive: true
1165
+ });
1166
+ return new Promise(function(resolve, reject) {
1167
+ node_fs.writeFile(input.filePath, JSON.stringify(input.data, null, 2), {
1168
+ mode: input.mode
1169
+ }, function(err) {
1170
+ if (err) {
1171
+ reject(err);
1172
+ return;
1173
+ }
1174
+ if (input.mode == null) {
1175
+ resolve();
1176
+ return;
1177
+ }
1178
+ node_fs.chmod(input.filePath, input.mode, function(chmodErr) {
1179
+ if (chmodErr) reject(chmodErr);
1180
+ else resolve();
1181
+ });
1182
+ });
1183
+ });
1184
+ }
1185
+ /**
1186
+ * Removes the file at the given path.
1187
+ *
1188
+ * Resolves silently when the file does not exist (`force: true`); other errors
1189
+ * (permission denied, busy file handles) are forwarded to the caller — silently
1190
+ * swallowing them masks real failures and makes operations appear to have succeeded.
1191
+ *
1192
+ * @param filePath - Absolute path to the file to remove.
1193
+ * @returns A promise that resolves once the file is removed (or was already absent).
1194
+ */ function removeFile(filePath) {
1195
+ return promises$1.rm(filePath, {
1196
+ force: true
1197
+ });
1198
+ }
1199
+
1200
+ function _array_like_to_array$1(arr, len) {
1201
+ if (len == null || len > arr.length) len = arr.length;
1202
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1203
+ return arr2;
1204
+ }
1205
+ function _array_with_holes$1(arr) {
1206
+ if (Array.isArray(arr)) return arr;
1207
+ }
1208
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1209
+ try {
1210
+ var info = gen[key](arg);
1211
+ var value = info.value;
1212
+ } catch (error) {
1213
+ reject(error);
1214
+ return;
1215
+ }
1216
+ if (info.done) {
1217
+ resolve(value);
1218
+ } else {
1219
+ Promise.resolve(value).then(_next, _throw);
1220
+ }
1221
+ }
1222
+ function _async_to_generator(fn) {
1223
+ return function() {
1224
+ var self = this, args = arguments;
1225
+ return new Promise(function(resolve, reject) {
1226
+ var gen = fn.apply(self, args);
1227
+ function _next(value) {
1228
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1229
+ }
1230
+ function _throw(err) {
1231
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1232
+ }
1233
+ _next(undefined);
1234
+ });
1235
+ };
1236
+ }
1237
+ function _define_property(obj, key, value) {
1238
+ if (key in obj) {
1239
+ Object.defineProperty(obj, key, {
1240
+ value: value,
1241
+ enumerable: true,
1242
+ configurable: true,
1243
+ writable: true
1244
+ });
1245
+ } else {
1246
+ obj[key] = value;
1247
+ }
1248
+ return obj;
1249
+ }
1250
+ function _iterable_to_array_limit$1(arr, i) {
1251
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1252
+ if (_i == null) return;
1253
+ var _arr = [];
1254
+ var _n = true;
1255
+ var _d = false;
1256
+ var _s, _e;
1257
+ try {
1258
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1259
+ _arr.push(_s.value);
1260
+ if (i && _arr.length === i) break;
1261
+ }
1262
+ } catch (err) {
1263
+ _d = true;
1264
+ _e = err;
1265
+ } finally{
1266
+ try {
1267
+ if (!_n && _i["return"] != null) _i["return"]();
1268
+ } finally{
1269
+ if (_d) throw _e;
1270
+ }
1271
+ }
1272
+ return _arr;
1273
+ }
1274
+ function _non_iterable_rest$1() {
1275
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1276
+ }
1277
+ function _object_spread(target) {
1278
+ for(var i = 1; i < arguments.length; i++){
1279
+ var source = arguments[i] != null ? arguments[i] : {};
1280
+ var ownKeys = Object.keys(source);
1281
+ if (typeof Object.getOwnPropertySymbols === "function") {
1282
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1283
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1284
+ }));
1285
+ }
1286
+ ownKeys.forEach(function(key) {
1287
+ _define_property(target, key, source[key]);
1288
+ });
1289
+ }
1290
+ return target;
1291
+ }
1292
+ function ownKeys(object, enumerableOnly) {
1293
+ var keys = Object.keys(object);
1294
+ if (Object.getOwnPropertySymbols) {
1295
+ var symbols = Object.getOwnPropertySymbols(object);
1296
+ keys.push.apply(keys, symbols);
1297
+ }
1298
+ return keys;
1299
+ }
1300
+ function _object_spread_props(target, source) {
1301
+ source = source != null ? source : {};
1302
+ if (Object.getOwnPropertyDescriptors) {
1303
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1304
+ } else {
1305
+ ownKeys(Object(source)).forEach(function(key) {
1306
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1307
+ });
1308
+ }
1309
+ return target;
1310
+ }
1311
+ function _sliced_to_array$1(arr, i) {
1312
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
1313
+ }
1314
+ function _unsupported_iterable_to_array$1(o, minLen) {
1315
+ if (!o) return;
1316
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
1317
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1318
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1319
+ if (n === "Map" || n === "Set") return Array.from(n);
1320
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
1321
+ }
1322
+ function _ts_generator(thisArg, body) {
1323
+ var f, y, t, _ = {
1324
+ label: 0,
1325
+ sent: function() {
1326
+ if (t[0] & 1) throw t[1];
1327
+ return t[1];
1328
+ },
1329
+ trys: [],
1330
+ ops: []
1331
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
1332
+ return d(g, "next", {
1333
+ value: verb(0)
1334
+ }), d(g, "throw", {
1335
+ value: verb(1)
1336
+ }), d(g, "return", {
1337
+ value: verb(2)
1338
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
1339
+ value: function() {
1340
+ return this;
1341
+ }
1342
+ }), g;
1343
+ function verb(n) {
1344
+ return function(v) {
1345
+ return step([
1346
+ n,
1347
+ v
1348
+ ]);
1349
+ };
1350
+ }
1351
+ function step(op) {
1352
+ if (f) throw new TypeError("Generator is already executing.");
1353
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1354
+ 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;
1355
+ if (y = 0, t) op = [
1356
+ op[0] & 2,
1357
+ t.value
1358
+ ];
1359
+ switch(op[0]){
1360
+ case 0:
1361
+ case 1:
1362
+ t = op;
1363
+ break;
1364
+ case 4:
1365
+ _.label++;
1366
+ return {
1367
+ value: op[1],
1368
+ done: false
1369
+ };
1370
+ case 5:
1371
+ _.label++;
1372
+ y = op[1];
1373
+ op = [
1374
+ 0
1375
+ ];
1376
+ continue;
1377
+ case 7:
1378
+ op = _.ops.pop();
1379
+ _.trys.pop();
1380
+ continue;
1381
+ default:
1382
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1383
+ _ = 0;
1384
+ continue;
1385
+ }
1386
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1387
+ _.label = op[1];
1388
+ break;
1389
+ }
1390
+ if (op[0] === 6 && _.label < t[1]) {
1391
+ _.label = t[1];
1392
+ t = op;
1393
+ break;
1394
+ }
1395
+ if (t && _.label < t[2]) {
1396
+ _.label = t[2];
1397
+ _.ops.push(op);
1398
+ break;
1399
+ }
1400
+ if (t[2]) _.ops.pop();
1401
+ _.trys.pop();
1402
+ continue;
1403
+ }
1404
+ op = body.call(thisArg, _);
1405
+ } catch (e) {
1406
+ op = [
1407
+ 6,
1408
+ e
1409
+ ];
1410
+ y = 0;
1411
+ } finally{
1412
+ f = t = 0;
1413
+ }
1414
+ if (op[0] & 5) throw op[1];
1415
+ return {
1416
+ value: op[0] ? op[1] : void 0,
1417
+ done: true
1418
+ };
1419
+ }
1420
+ }
1421
+ /**
1422
+ * Default file mode used by the JSON-file caches when none is provided.
1423
+ *
1424
+ * 0o600 restricts the file to read/write for the owning user only — appropriate for
1425
+ * secrets like cached access/refresh tokens.
1426
+ */ var DEFAULT_JSON_FILE_CACHE_MODE = 384;
1427
+ /**
1428
+ * Creates an {@link AsyncValueCache} backed by a single JSON file on disk.
1429
+ *
1430
+ * Reads always touch disk; wrap with {@link memoizeAsyncValueCache} (or use
1431
+ * {@link createMemoizedJsonFileAsyncValueCache}) to add per-process memoization.
1432
+ *
1433
+ * Multi-process invalidation is not provided. Two processes writing to the same file
1434
+ * will last-writer-wins; once memoized, a long-running process will not observe writes
1435
+ * from another process.
1436
+ *
1437
+ * @param input - Configuration bag describing the backing file and optional JSON revive/replace hooks.
1438
+ * @param input.filePath - Absolute path to the JSON file that backs the cache.
1439
+ * @param input.mode - Optional file mode applied on write; defaults to {@link DEFAULT_JSON_FILE_CACHE_MODE} (0o600).
1440
+ * @param input.reviver - Optional transform applied to the raw JSON-parsed payload before it is returned from `load()` (e.g. revive `Date` fields).
1441
+ * @param input.replacer - Optional transform applied to the value before it is stringified to JSON on `update()`.
1442
+ * @returns An {@link AsyncValueCache} that persists the value to the configured JSON file.
1443
+ */ function createJsonFileAsyncValueCache(input) {
1444
+ var filePath = input.filePath, mode = input.mode, reviver = input.reviver, replacer = input.replacer;
1445
+ var fileMode = mode !== null && mode !== void 0 ? mode : DEFAULT_JSON_FILE_CACHE_MODE;
1446
+ return {
1447
+ load: function load() {
1448
+ return _async_to_generator(function() {
1449
+ var raw;
1450
+ return _ts_generator(this, function(_state) {
1451
+ switch(_state.label){
1452
+ case 0:
1453
+ return [
1454
+ 4,
1455
+ readJsonFile(filePath)
1456
+ ];
1457
+ case 1:
1458
+ raw = _state.sent();
1459
+ if (raw == null) {
1460
+ return [
1461
+ 2,
1462
+ undefined
1463
+ ];
1464
+ }
1465
+ return [
1466
+ 2,
1467
+ reviver == null ? raw : reviver(raw)
1468
+ ];
1469
+ }
1470
+ });
1471
+ })();
1472
+ },
1473
+ update: function update(value) {
1474
+ return _async_to_generator(function() {
1475
+ var data;
1476
+ return _ts_generator(this, function(_state) {
1477
+ switch(_state.label){
1478
+ case 0:
1479
+ data = replacer == null ? value : replacer(value);
1480
+ return [
1481
+ 4,
1482
+ writeJsonFile({
1483
+ filePath: filePath,
1484
+ dirPath: node_path.dirname(filePath),
1485
+ data: data,
1486
+ mode: fileMode
1487
+ })
1488
+ ];
1489
+ case 1:
1490
+ _state.sent();
1491
+ return [
1492
+ 2
1493
+ ];
1494
+ }
1495
+ });
1496
+ })();
1497
+ },
1498
+ clear: function clear() {
1499
+ return _async_to_generator(function() {
1500
+ return _ts_generator(this, function(_state) {
1501
+ switch(_state.label){
1502
+ case 0:
1503
+ return [
1504
+ 4,
1505
+ removeFile(filePath)
1506
+ ];
1507
+ case 1:
1508
+ _state.sent();
1509
+ return [
1510
+ 2
1511
+ ];
1512
+ }
1513
+ });
1514
+ })();
1515
+ }
1516
+ };
1517
+ }
1518
+ /**
1519
+ * Convenience wrapper around {@link createJsonFileAsyncValueCache} composed with
1520
+ * {@link memoizeAsyncValueCache}.
1521
+ *
1522
+ * @param input - Same configuration accepted by {@link createJsonFileAsyncValueCache}; see {@link CreateJsonFileAsyncValueCacheInput}.
1523
+ * @returns An {@link AsyncValueCache} backed by the JSON file with a per-process single-load memoization layer in front.
1524
+ */ function createMemoizedJsonFileAsyncValueCache(input) {
1525
+ return util.memoizeAsyncValueCache(createJsonFileAsyncValueCache(input));
1526
+ }
1527
+ /**
1528
+ * Creates an {@link AsyncKeyedValueCache} backed by a single JSON file holding a `Record<string, T>`.
1529
+ *
1530
+ * Reads/writes always touch disk; wrap with {@link memoizeAsyncKeyedValueCache} (or use
1531
+ * {@link createMemoizedJsonFileAsyncKeyedValueCache}) to add per-process memoization of the
1532
+ * entire record.
1533
+ *
1534
+ * Multi-process invalidation is not provided; see {@link createJsonFileAsyncValueCache} for caveats.
1535
+ *
1536
+ * Concurrent `set`/`remove`/`clear` calls are serialized through a per-instance promise chain so
1537
+ * the read-modify-write of the entire record file does not race within the same process.
1538
+ *
1539
+ * @param input - Configuration bag describing the backing file and optional per-entry revive/replace hooks.
1540
+ * @param input.filePath - Absolute path to the JSON file that holds the entire `Record<string, T>`.
1541
+ * @param input.mode - Optional file mode applied on write; defaults to {@link DEFAULT_JSON_FILE_CACHE_MODE} (0o600).
1542
+ * @param input.reviver - Optional transform applied to each entry after it is JSON-parsed on `load()`/`get()`. Returning null/undefined drops the entry.
1543
+ * @param input.replacer - Optional transform applied to each entry before it is stringified on `set()`.
1544
+ * @returns An {@link AsyncKeyedValueCache} that persists all entries in the configured JSON file.
1545
+ */ function createJsonFileAsyncKeyedValueCache(input) {
1546
+ var filePath = input.filePath, mode = input.mode, reviver = input.reviver, replacer = input.replacer;
1547
+ var fileMode = mode !== null && mode !== void 0 ? mode : DEFAULT_JSON_FILE_CACHE_MODE;
1548
+ function readEntries() {
1549
+ return _async_to_generator(function() {
1550
+ var raw, result, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, revived;
1551
+ return _ts_generator(this, function(_state) {
1552
+ switch(_state.label){
1553
+ case 0:
1554
+ return [
1555
+ 4,
1556
+ readJsonFile(filePath)
1557
+ ];
1558
+ case 1:
1559
+ raw = _state.sent();
1560
+ if (raw == null) {
1561
+ return [
1562
+ 2,
1563
+ {}
1564
+ ];
1565
+ }
1566
+ if (reviver == null) {
1567
+ return [
1568
+ 2,
1569
+ raw
1570
+ ];
1571
+ }
1572
+ result = {};
1573
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1574
+ try {
1575
+ for(_iterator = Object.keys(raw)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1576
+ key = _step.value;
1577
+ revived = reviver(raw[key]);
1578
+ if (revived != null) {
1579
+ result[key] = revived;
1580
+ }
1581
+ }
1582
+ } catch (err) {
1583
+ _didIteratorError = true;
1584
+ _iteratorError = err;
1585
+ } finally{
1586
+ try {
1587
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1588
+ _iterator.return();
1589
+ }
1590
+ } finally{
1591
+ if (_didIteratorError) {
1592
+ throw _iteratorError;
1593
+ }
1594
+ }
1595
+ }
1596
+ return [
1597
+ 2,
1598
+ result
1599
+ ];
1600
+ }
1601
+ });
1602
+ })();
1603
+ }
1604
+ function writeEntries(entries) {
1605
+ return _async_to_generator(function() {
1606
+ var data;
1607
+ return _ts_generator(this, function(_state) {
1608
+ switch(_state.label){
1609
+ case 0:
1610
+ data = replacer == null ? entries : Object.fromEntries(Object.entries(entries).map(function(param) {
1611
+ var _param = _sliced_to_array$1(param, 2), key = _param[0], value = _param[1];
1612
+ return [
1613
+ key,
1614
+ replacer(value)
1615
+ ];
1616
+ }));
1617
+ return [
1618
+ 4,
1619
+ writeJsonFile({
1620
+ filePath: filePath,
1621
+ dirPath: node_path.dirname(filePath),
1622
+ data: data,
1623
+ mode: fileMode
1624
+ })
1625
+ ];
1626
+ case 1:
1627
+ _state.sent();
1628
+ return [
1629
+ 2
1630
+ ];
1631
+ }
1632
+ });
1633
+ })();
1634
+ }
1635
+ // Serialize set/remove through a per-instance promise chain. Without this, two concurrent
1636
+ // mutations would race on the read-modify-write of the entire record file and the second
1637
+ // writer's snapshot of the entries would clobber the first.
1638
+ var mutationQueue = Promise.resolve();
1639
+ function enqueueMutation(fn) {
1640
+ var next = mutationQueue.then(fn, fn);
1641
+ mutationQueue = next.catch(function() {
1642
+ return undefined;
1643
+ });
1644
+ return next;
1645
+ }
1646
+ return {
1647
+ load: readEntries,
1648
+ get: function get(key) {
1649
+ return _async_to_generator(function() {
1650
+ return _ts_generator(this, function(_state) {
1651
+ switch(_state.label){
1652
+ case 0:
1653
+ return [
1654
+ 4,
1655
+ readEntries()
1656
+ ];
1657
+ case 1:
1658
+ return [
1659
+ 2,
1660
+ _state.sent()[key]
1661
+ ];
1662
+ }
1663
+ });
1664
+ })();
1665
+ },
1666
+ set: function set(key, value) {
1667
+ return enqueueMutation(function() {
1668
+ return _async_to_generator(function() {
1669
+ var current;
1670
+ return _ts_generator(this, function(_state) {
1671
+ switch(_state.label){
1672
+ case 0:
1673
+ return [
1674
+ 4,
1675
+ readEntries()
1676
+ ];
1677
+ case 1:
1678
+ current = _state.sent();
1679
+ return [
1680
+ 4,
1681
+ writeEntries(_object_spread_props(_object_spread({}, current), _define_property({}, key, value)))
1682
+ ];
1683
+ case 2:
1684
+ _state.sent();
1685
+ return [
1686
+ 2
1687
+ ];
1688
+ }
1689
+ });
1690
+ })();
1691
+ });
1692
+ },
1693
+ remove: function remove(key) {
1694
+ return enqueueMutation(function() {
1695
+ return _async_to_generator(function() {
1696
+ var current, next;
1697
+ return _ts_generator(this, function(_state) {
1698
+ switch(_state.label){
1699
+ case 0:
1700
+ return [
1701
+ 4,
1702
+ readEntries()
1703
+ ];
1704
+ case 1:
1705
+ current = _state.sent();
1706
+ next = _object_spread({}, current);
1707
+ delete next[key];
1708
+ return [
1709
+ 4,
1710
+ writeEntries(next)
1711
+ ];
1712
+ case 2:
1713
+ _state.sent();
1714
+ return [
1715
+ 2
1716
+ ];
1717
+ }
1718
+ });
1719
+ })();
1720
+ });
1721
+ },
1722
+ clear: function clear() {
1723
+ return enqueueMutation(function() {
1724
+ return _async_to_generator(function() {
1725
+ return _ts_generator(this, function(_state) {
1726
+ switch(_state.label){
1727
+ case 0:
1728
+ return [
1729
+ 4,
1730
+ removeFile(filePath)
1731
+ ];
1732
+ case 1:
1733
+ _state.sent();
1734
+ return [
1735
+ 2
1736
+ ];
1737
+ }
1738
+ });
1739
+ })();
1740
+ });
1741
+ }
1742
+ };
1743
+ }
1744
+ /**
1745
+ * Convenience wrapper around {@link createJsonFileAsyncKeyedValueCache} composed with
1746
+ * {@link memoizeAsyncKeyedValueCache}.
1747
+ *
1748
+ * @param input - Same configuration accepted by {@link createJsonFileAsyncKeyedValueCache}; see {@link CreateJsonFileAsyncKeyedValueCacheInput}.
1749
+ * @returns An {@link AsyncKeyedValueCache} backed by the JSON file with a per-process record-level memoization layer in front.
1750
+ */ function createMemoizedJsonFileAsyncKeyedValueCache(input) {
1751
+ return util.memoizeAsyncKeyedValueCache(createJsonFileAsyncKeyedValueCache(input));
1752
+ }
1753
+
1119
1754
  // MARK: Constants
1120
1755
  /**
1121
1756
  * AES-256-GCM encryption constants.
@@ -1307,10 +1942,799 @@ var ENCRYPTED_FIELD_KEY_LENGTH = 32;
1307
1942
  return result;
1308
1943
  }
1309
1944
 
1945
+ function _array_like_to_array(arr, len) {
1946
+ if (len == null || len > arr.length) len = arr.length;
1947
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1948
+ return arr2;
1949
+ }
1950
+ function _array_with_holes(arr) {
1951
+ if (Array.isArray(arr)) return arr;
1952
+ }
1953
+ function _iterable_to_array_limit(arr, i) {
1954
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1955
+ if (_i == null) return;
1956
+ var _arr = [];
1957
+ var _n = true;
1958
+ var _d = false;
1959
+ var _s, _e;
1960
+ try {
1961
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1962
+ _arr.push(_s.value);
1963
+ if (i && _arr.length === i) break;
1964
+ }
1965
+ } catch (err) {
1966
+ _d = true;
1967
+ _e = err;
1968
+ } finally{
1969
+ try {
1970
+ if (!_n && _i["return"] != null) _i["return"]();
1971
+ } finally{
1972
+ if (_d) throw _e;
1973
+ }
1974
+ }
1975
+ return _arr;
1976
+ }
1977
+ function _non_iterable_rest() {
1978
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1979
+ }
1980
+ function _sliced_to_array(arr, i) {
1981
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
1982
+ }
1983
+ function _unsupported_iterable_to_array(o, minLen) {
1984
+ if (!o) return;
1985
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
1986
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1987
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1988
+ if (n === "Map" || n === "Set") return Array.from(n);
1989
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1990
+ }
1991
+ /**
1992
+ * 32-byte password padding string defined by ISO 32000 §7.6.3.3 (Algorithm 2).
1993
+ * Used to pad short or empty user/owner passwords for the standard security handler.
1994
+ */ var PDF_PASSWORD_PADDING = Buffer.from([
1995
+ 0x28,
1996
+ 0xbf,
1997
+ 0x4e,
1998
+ 0x5e,
1999
+ 0x4e,
2000
+ 0x75,
2001
+ 0x8a,
2002
+ 0x41,
2003
+ 0x64,
2004
+ 0x00,
2005
+ 0x4e,
2006
+ 0x56,
2007
+ 0xff,
2008
+ 0xfa,
2009
+ 0x01,
2010
+ 0x08,
2011
+ 0x2e,
2012
+ 0x2e,
2013
+ 0x00,
2014
+ 0xb6,
2015
+ 0xd0,
2016
+ 0x68,
2017
+ 0x3e,
2018
+ 0x80,
2019
+ 0x2f,
2020
+ 0x0c,
2021
+ 0xa9,
2022
+ 0xfe,
2023
+ 0x64,
2024
+ 0x53,
2025
+ 0x69,
2026
+ 0x7a
2027
+ ]);
2028
+ /**
2029
+ * Detects whether a PDF is unencrypted, write-protected (openable without a password
2030
+ * but restricted from editing/printing), or fully encrypted (requires a password to open).
2031
+ *
2032
+ * Implements the user-password validation algorithms from ISO 32000-1 §7.6.3 (R≤4) and
2033
+ * ISO 32000-2 §7.6.4.4 (R=5/6) using only the empty password. If the empty password
2034
+ * validates successfully, the PDF is openable by anyone and only its modify/print/copy
2035
+ * permissions are restricted; otherwise a non-empty user password is required.
2036
+ *
2037
+ * Supported security handlers:
2038
+ * - Standard security handler, R=2,3,4 (RC4-40, RC4-128, AES-128 with crypt filters).
2039
+ * - Standard security handler, R=5 (AES-256, deprecated Adobe extension).
2040
+ * - Standard security handler, R=6 (AES-256, ISO 32000-2 / PDF 2.0).
2041
+ *
2042
+ * Unrecognised security handlers (e.g. PubSec, custom handlers) return
2043
+ * `unknown_encrypted` so callers can choose whether to treat them as fully encrypted.
2044
+ *
2045
+ * Lives in `@dereekb/nestjs` (rather than `@dereekb/util`) because it uses Node's
2046
+ * built-in `node:crypto` module, which isn't available in the browser.
2047
+ *
2048
+ * @example
2049
+ * ```ts
2050
+ * const status = detectPdfEncryption(buffer);
2051
+ *
2052
+ * if (status === 'fully_encrypted') {
2053
+ * throw new Error('PDF requires a password to open.');
2054
+ * }
2055
+ * if (status === 'write_protected_only') {
2056
+ * // Safe to read, but not to mutate without the owner password.
2057
+ * }
2058
+ * ```
2059
+ *
2060
+ * @param buffer - PDF file contents.
2061
+ * @returns The encryption status of the PDF.
2062
+ */ function detectPdfEncryption(buffer) {
2063
+ var result = 'unknown_encrypted';
2064
+ var encryptIndex = findEncryptKeywordIndex(buffer);
2065
+ if (encryptIndex < 0) {
2066
+ result = 'none';
2067
+ } else {
2068
+ var dict = extractEncryptionDictionary(buffer, encryptIndex);
2069
+ var info = dict ? parseEncryptionInfo(dict) : null;
2070
+ if ((info === null || info === void 0 ? void 0 : info.filter) === 'Standard') {
2071
+ var opensWithEmptyPassword = checkStandardHandlerEmptyPassword(info, buffer);
2072
+ if (opensWithEmptyPassword !== null) {
2073
+ result = opensWithEmptyPassword ? 'write_protected_only' : 'fully_encrypted';
2074
+ }
2075
+ }
2076
+ }
2077
+ return result;
2078
+ }
2079
+ function checkStandardHandlerEmptyPassword(info, buffer) {
2080
+ var result = null;
2081
+ if (info.R >= 2 && info.R <= 4) {
2082
+ var fileId = extractFirstFileId(buffer);
2083
+ if (fileId && info.O.length >= 32 && info.U.length >= 32) {
2084
+ result = validateEmptyPasswordR2to4(info, fileId);
2085
+ }
2086
+ } else if (info.R === 5 && info.U.length >= 48) {
2087
+ result = validateEmptyPasswordR5(info);
2088
+ } else if (info.R === 6 && info.U.length >= 48) {
2089
+ result = validateEmptyPasswordR6(info);
2090
+ }
2091
+ return result;
2092
+ }
2093
+ function isPdfWhitespaceByte(b) {
2094
+ return b === 0x00 || b === 0x09 || b === 0x0a || b === 0x0c || b === 0x0d || b === 0x20;
2095
+ }
2096
+ function isPdfDelimiterByte(b) {
2097
+ return b === 0x28 || b === 0x29 || b === 0x3c || b === 0x3e || b === 0x5b || b === 0x5d || b === 0x7b || b === 0x7d || b === 0x2f || b === 0x25;
2098
+ }
2099
+ function isPdfWhitespaceOrDelimiter(b) {
2100
+ return isPdfWhitespaceByte(b) || isPdfDelimiterByte(b);
2101
+ }
2102
+ function skipPdfWhitespaceAndComments(buffer, start) {
2103
+ var i = start;
2104
+ while(i < buffer.length){
2105
+ var b = buffer[i];
2106
+ if (isPdfWhitespaceByte(b)) {
2107
+ i++;
2108
+ } else if (b === 0x25 /* % */ ) {
2109
+ while(i < buffer.length && buffer[i] !== 0x0a && buffer[i] !== 0x0d)i++;
2110
+ } else {
2111
+ break;
2112
+ }
2113
+ }
2114
+ return i;
2115
+ }
2116
+ function skipPdfLiteralString(buffer, start) {
2117
+ var depth = 1;
2118
+ var i = start + 1;
2119
+ while(i < buffer.length && depth > 0){
2120
+ var b = buffer[i];
2121
+ if (b === 0x5c /* \ */ ) {
2122
+ i += 2;
2123
+ } else if (b === 0x28 /* ( */ ) {
2124
+ depth++;
2125
+ i++;
2126
+ } else if (b === 0x29 /* ) */ ) {
2127
+ depth--;
2128
+ i++;
2129
+ } else {
2130
+ i++;
2131
+ }
2132
+ }
2133
+ return i;
2134
+ }
2135
+ function skipPdfHexString(buffer, start) {
2136
+ var i = start + 1;
2137
+ while(i < buffer.length && buffer[i] !== 0x3e /* > */ )i++;
2138
+ return i < buffer.length ? i + 1 : i;
2139
+ }
2140
+ function findDictEnd(buffer, start) {
2141
+ var depth = 1;
2142
+ var i = start;
2143
+ var endIndex = -1;
2144
+ while(i < buffer.length && endIndex < 0){
2145
+ var b = buffer[i];
2146
+ if (b === 0x3c && buffer[i + 1] === 0x3c) {
2147
+ depth++;
2148
+ i += 2;
2149
+ } else if (b === 0x3e && buffer[i + 1] === 0x3e) {
2150
+ depth--;
2151
+ if (depth === 0) {
2152
+ endIndex = i;
2153
+ } else {
2154
+ i += 2;
2155
+ }
2156
+ } else if (b === 0x28) {
2157
+ i = skipPdfLiteralString(buffer, i);
2158
+ } else if (b === 0x3c) {
2159
+ i = skipPdfHexString(buffer, i);
2160
+ } else if (b === 0x25) {
2161
+ while(i < buffer.length && buffer[i] !== 0x0a && buffer[i] !== 0x0d)i++;
2162
+ } else {
2163
+ i++;
2164
+ }
2165
+ }
2166
+ return endIndex >= 0 ? endIndex : i;
2167
+ }
2168
+ function decodePdfLiteralString(content) {
2169
+ var out = [];
2170
+ var i = 0;
2171
+ while(i < content.length){
2172
+ var b = content[i];
2173
+ if (b !== 0x5c /* \ */ ) {
2174
+ out.push(b);
2175
+ i++;
2176
+ continue;
2177
+ }
2178
+ i++;
2179
+ if (i >= content.length) break;
2180
+ var c = content[i];
2181
+ if (c >= 0x30 && c <= 0x37) {
2182
+ var oct = c - 0x30;
2183
+ i++;
2184
+ if (i < content.length && content[i] >= 0x30 && content[i] <= 0x37) {
2185
+ oct = oct * 8 + (content[i] - 0x30);
2186
+ i++;
2187
+ if (i < content.length && content[i] >= 0x30 && content[i] <= 0x37) {
2188
+ oct = oct * 8 + (content[i] - 0x30);
2189
+ i++;
2190
+ }
2191
+ }
2192
+ out.push(oct & 0xff);
2193
+ } else if (c === 0x6e /* n */ ) {
2194
+ out.push(0x0a);
2195
+ i++;
2196
+ } else if (c === 0x72 /* r */ ) {
2197
+ out.push(0x0d);
2198
+ i++;
2199
+ } else if (c === 0x74 /* t */ ) {
2200
+ out.push(0x09);
2201
+ i++;
2202
+ } else if (c === 0x62 /* b */ ) {
2203
+ out.push(0x08);
2204
+ i++;
2205
+ } else if (c === 0x66 /* f */ ) {
2206
+ out.push(0x0c);
2207
+ i++;
2208
+ } else if (c === 0x0a) {
2209
+ i++;
2210
+ } else if (c === 0x0d) {
2211
+ i++;
2212
+ if (i < content.length && content[i] === 0x0a) i++;
2213
+ } else {
2214
+ out.push(c);
2215
+ i++;
2216
+ }
2217
+ }
2218
+ return Buffer.from(out);
2219
+ }
2220
+ function decodePdfHexString(content) {
2221
+ var hex = [];
2222
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2223
+ try {
2224
+ for(var _iterator = content[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2225
+ var b = _step.value;
2226
+ if (isPdfWhitespaceByte(b)) continue;
2227
+ if (b >= 0x30 && b <= 0x39 || b >= 0x41 && b <= 0x46 || b >= 0x61 && b <= 0x66) hex.push(b);
2228
+ }
2229
+ } catch (err) {
2230
+ _didIteratorError = true;
2231
+ _iteratorError = err;
2232
+ } finally{
2233
+ try {
2234
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2235
+ _iterator.return();
2236
+ }
2237
+ } finally{
2238
+ if (_didIteratorError) {
2239
+ throw _iteratorError;
2240
+ }
2241
+ }
2242
+ }
2243
+ if (hex.length % 2 === 1) hex.push(0x30);
2244
+ var out = Buffer.alloc(hex.length / 2);
2245
+ for(var i = 0; i < out.length; i++){
2246
+ out[i] = parseInt(String.fromCharCode(hex[i * 2], hex[i * 2 + 1]), 16);
2247
+ }
2248
+ return out;
2249
+ }
2250
+ function readPdfNumber(buffer, start) {
2251
+ var i = start;
2252
+ while(i < buffer.length && !isPdfWhitespaceOrDelimiter(buffer[i]))i++;
2253
+ var result = null;
2254
+ if (i > start) {
2255
+ var text = buffer.toString('latin1', start, i);
2256
+ var value = Number(text);
2257
+ if (!Number.isNaN(value)) {
2258
+ result = {
2259
+ value: value,
2260
+ end: i
2261
+ };
2262
+ }
2263
+ }
2264
+ return result;
2265
+ }
2266
+ function parsePdfDict(buffer, dictStart) {
2267
+ // dictStart is the byte after `<<`.
2268
+ var entries = new Map();
2269
+ var i = skipPdfWhitespaceAndComments(buffer, dictStart);
2270
+ var result = null;
2271
+ var aborted = false;
2272
+ while(i < buffer.length && !aborted && result === null){
2273
+ if (buffer[i] === 0x3e && buffer[i + 1] === 0x3e) {
2274
+ result = {
2275
+ entries: entries,
2276
+ end: i + 2
2277
+ };
2278
+ } else if (buffer[i] !== 0x2f /* / */ ) {
2279
+ aborted = true;
2280
+ } else {
2281
+ var nameStart = i + 1;
2282
+ var nameEnd = nameStart;
2283
+ while(nameEnd < buffer.length && !isPdfWhitespaceOrDelimiter(buffer[nameEnd]))nameEnd++;
2284
+ var name = buffer.toString('latin1', nameStart, nameEnd);
2285
+ i = skipPdfWhitespaceAndComments(buffer, nameEnd);
2286
+ if (i >= buffer.length) {
2287
+ aborted = true;
2288
+ } else {
2289
+ var valueResult = readPdfValue(buffer, i);
2290
+ if (!valueResult) {
2291
+ aborted = true;
2292
+ } else {
2293
+ entries.set(name, valueResult.entry);
2294
+ i = skipPdfWhitespaceAndComments(buffer, valueResult.end);
2295
+ }
2296
+ }
2297
+ }
2298
+ }
2299
+ return result;
2300
+ }
2301
+ function readPdfValue(buffer, start) {
2302
+ var b = buffer[start];
2303
+ var result;
2304
+ if (b === 0x3c && buffer[start + 1] === 0x3c) {
2305
+ result = readPdfDictValue(buffer, start);
2306
+ } else if (b === 0x3c) {
2307
+ result = readPdfHexStringValue(buffer, start);
2308
+ } else if (b === 0x28) {
2309
+ result = readPdfLiteralStringValue(buffer, start);
2310
+ } else if (b === 0x5b /* [ */ ) {
2311
+ result = readPdfArrayValue(buffer, start);
2312
+ } else if (b === 0x2f /* / */ ) {
2313
+ result = readPdfNameValue(buffer, start);
2314
+ } else {
2315
+ result = readPdfTokenOrRefValue(buffer, start);
2316
+ }
2317
+ return result;
2318
+ }
2319
+ function readPdfDictValue(buffer, start) {
2320
+ var dictEnd = findDictEnd(buffer, start + 2);
2321
+ var end = dictEnd < buffer.length && buffer[dictEnd] === 0x3e && buffer[dictEnd + 1] === 0x3e ? dictEnd + 2 : dictEnd;
2322
+ return {
2323
+ entry: {
2324
+ type: 'dict',
2325
+ raw: buffer.subarray(start, end)
2326
+ },
2327
+ end: end
2328
+ };
2329
+ }
2330
+ function readPdfHexStringValue(buffer, start) {
2331
+ var end = skipPdfHexString(buffer, start);
2332
+ return {
2333
+ entry: {
2334
+ type: 'string',
2335
+ raw: decodePdfHexString(buffer.subarray(start + 1, end - 1))
2336
+ },
2337
+ end: end
2338
+ };
2339
+ }
2340
+ function readPdfLiteralStringValue(buffer, start) {
2341
+ var end = skipPdfLiteralString(buffer, start);
2342
+ return {
2343
+ entry: {
2344
+ type: 'string',
2345
+ raw: decodePdfLiteralString(buffer.subarray(start + 1, end - 1))
2346
+ },
2347
+ end: end
2348
+ };
2349
+ }
2350
+ function readPdfArrayValue(buffer, start) {
2351
+ var depth = 1;
2352
+ var i = start + 1;
2353
+ while(i < buffer.length && depth > 0){
2354
+ var c = buffer[i];
2355
+ if (c === 0x5b) {
2356
+ depth++;
2357
+ i++;
2358
+ } else if (c === 0x5d) {
2359
+ depth--;
2360
+ i++;
2361
+ } else if (c === 0x28) {
2362
+ i = skipPdfLiteralString(buffer, i);
2363
+ } else if (c === 0x3c && buffer[i + 1] === 0x3c) {
2364
+ var e = findDictEnd(buffer, i + 2);
2365
+ i = e < buffer.length && buffer[e] === 0x3e && buffer[e + 1] === 0x3e ? e + 2 : e;
2366
+ } else if (c === 0x3c) {
2367
+ i = skipPdfHexString(buffer, i);
2368
+ } else if (c === 0x25) {
2369
+ while(i < buffer.length && buffer[i] !== 0x0a && buffer[i] !== 0x0d)i++;
2370
+ } else {
2371
+ i++;
2372
+ }
2373
+ }
2374
+ return {
2375
+ entry: {
2376
+ type: 'array',
2377
+ raw: buffer.subarray(start, i)
2378
+ },
2379
+ end: i
2380
+ };
2381
+ }
2382
+ function readPdfNameValue(buffer, start) {
2383
+ var i = start + 1;
2384
+ while(i < buffer.length && !isPdfWhitespaceOrDelimiter(buffer[i]))i++;
2385
+ return {
2386
+ entry: {
2387
+ type: 'name',
2388
+ raw: buffer.subarray(start + 1, i)
2389
+ },
2390
+ end: i
2391
+ };
2392
+ }
2393
+ function readPdfTokenOrRefValue(buffer, start) {
2394
+ // Number, boolean, null, or indirect reference like `12 0 R`.
2395
+ var i = start;
2396
+ while(i < buffer.length && !isPdfWhitespaceOrDelimiter(buffer[i]))i++;
2397
+ var tokenEnd = i;
2398
+ var token = buffer.toString('latin1', start, tokenEnd);
2399
+ var referenceEnd = readIndirectReferenceEnd(buffer, tokenEnd);
2400
+ var result;
2401
+ if (referenceEnd !== null) {
2402
+ result = {
2403
+ entry: {
2404
+ type: 'ref',
2405
+ raw: buffer.subarray(start, referenceEnd)
2406
+ },
2407
+ end: referenceEnd
2408
+ };
2409
+ } else if (token === 'true' || token === 'false') {
2410
+ result = {
2411
+ entry: {
2412
+ type: 'boolean',
2413
+ raw: buffer.subarray(start, tokenEnd)
2414
+ },
2415
+ end: tokenEnd
2416
+ };
2417
+ } else if (token === 'null') {
2418
+ result = {
2419
+ entry: {
2420
+ type: 'null',
2421
+ raw: buffer.subarray(start, tokenEnd)
2422
+ },
2423
+ end: tokenEnd
2424
+ };
2425
+ } else {
2426
+ result = {
2427
+ entry: {
2428
+ type: 'number',
2429
+ raw: buffer.subarray(start, tokenEnd)
2430
+ },
2431
+ end: tokenEnd
2432
+ };
2433
+ }
2434
+ return result;
2435
+ }
2436
+ function readIndirectReferenceEnd(buffer, tokenEnd) {
2437
+ // Probe ahead for `GEN R` after a leading object number to detect `N G R`.
2438
+ var result = null;
2439
+ var probe = skipPdfWhitespaceAndComments(buffer, tokenEnd);
2440
+ if (probe < buffer.length) {
2441
+ var c = buffer[probe];
2442
+ if (c >= 0x30 && c <= 0x39) {
2443
+ var secondEnd = probe;
2444
+ while(secondEnd < buffer.length && !isPdfWhitespaceOrDelimiter(buffer[secondEnd]))secondEnd++;
2445
+ var probe2 = skipPdfWhitespaceAndComments(buffer, secondEnd);
2446
+ if (probe2 < buffer.length && buffer[probe2] === 0x52 /* R */ && (probe2 + 1 === buffer.length || isPdfWhitespaceOrDelimiter(buffer[probe2 + 1]))) {
2447
+ result = probe2 + 1;
2448
+ }
2449
+ }
2450
+ }
2451
+ return result;
2452
+ }
2453
+ function findEncryptKeywordIndex(buffer) {
2454
+ var marker = util.PDF_ENCRYPT_MARKER;
2455
+ var last = -1;
2456
+ var pos = 0;
2457
+ while(true){
2458
+ var found = buffer.indexOf(marker, pos);
2459
+ if (found < 0) break;
2460
+ var next = buffer[found + marker.length];
2461
+ // Avoid matching `/EncryptMetadata` (a different name).
2462
+ var isAlpha = next >= 0x41 && next <= 0x5a || next >= 0x61 && next <= 0x7a;
2463
+ if (!isAlpha) last = found;
2464
+ pos = found + marker.length;
2465
+ }
2466
+ return last;
2467
+ }
2468
+ function extractEncryptionDictionary(buffer, encryptIndex) {
2469
+ var result = null;
2470
+ var i = encryptIndex + util.PDF_ENCRYPT_MARKER.length;
2471
+ i = skipPdfWhitespaceAndComments(buffer, i);
2472
+ if (i < buffer.length) {
2473
+ if (buffer[i] === 0x3c && buffer[i + 1] === 0x3c) {
2474
+ // Inline dictionary.
2475
+ var dictEnd = findDictEnd(buffer, i + 2);
2476
+ result = buffer.subarray(i, dictEnd + 2);
2477
+ } else {
2478
+ // Indirect reference: `N G R`.
2479
+ result = resolveIndirectEncryptionDictionary(buffer, i);
2480
+ }
2481
+ }
2482
+ return result;
2483
+ }
2484
+ function resolveIndirectEncryptionDictionary(buffer, start) {
2485
+ var result = null;
2486
+ var numResult = readPdfNumber(buffer, start);
2487
+ if (numResult) {
2488
+ var afterFirst = skipPdfWhitespaceAndComments(buffer, numResult.end);
2489
+ var genResult = readPdfNumber(buffer, afterFirst);
2490
+ if (genResult) {
2491
+ var afterSecond = skipPdfWhitespaceAndComments(buffer, genResult.end);
2492
+ if (buffer[afterSecond] === 0x52 /* R */ ) {
2493
+ var objStart = findIndirectObjectStart(buffer, numResult.value, genResult.value);
2494
+ if (objStart >= 0) {
2495
+ var dictStart = buffer.indexOf('<<', objStart);
2496
+ if (dictStart >= 0) {
2497
+ var dictEnd = findDictEnd(buffer, dictStart + 2);
2498
+ result = buffer.subarray(dictStart, dictEnd + 2);
2499
+ }
2500
+ }
2501
+ }
2502
+ }
2503
+ }
2504
+ return result;
2505
+ }
2506
+ function findIndirectObjectStart(buffer, objNum, objGen) {
2507
+ var text = buffer.toString('latin1');
2508
+ var re = new RegExp("(?:^|[\\r\\n\\s])".concat(objNum, "\\s+").concat(objGen, "\\s+obj\\b"));
2509
+ var match = re.exec(text);
2510
+ return match ? match.index + match[0].length : -1;
2511
+ }
2512
+ function parseEncryptionInfo(dictBuffer) {
2513
+ // `dictBuffer` is the full `<< ... >>`; pass the body to parsePdfDict.
2514
+ var result = null;
2515
+ var isDict = dictBuffer.length >= 4 && dictBuffer[0] === 0x3c && dictBuffer[1] === 0x3c;
2516
+ var parsed = isDict ? parsePdfDict(dictBuffer, 2) : null;
2517
+ if (parsed) {
2518
+ var _readNameValue, _readNumberValue, _readNumberValue1, _readNumberValue2, _readStringValue, _readStringValue1, _readNumberValue3, _readBooleanValue;
2519
+ var entries = parsed.entries;
2520
+ var filter = (_readNameValue = readNameValue(entries.get('Filter'))) !== null && _readNameValue !== void 0 ? _readNameValue : '';
2521
+ var V = (_readNumberValue = readNumberValue(entries.get('V'))) !== null && _readNumberValue !== void 0 ? _readNumberValue : 0;
2522
+ var R = (_readNumberValue1 = readNumberValue(entries.get('R'))) !== null && _readNumberValue1 !== void 0 ? _readNumberValue1 : 0;
2523
+ var Length = (_readNumberValue2 = readNumberValue(entries.get('Length'))) !== null && _readNumberValue2 !== void 0 ? _readNumberValue2 : V >= 5 ? 256 : 40;
2524
+ var O = (_readStringValue = readStringValue(entries.get('O'))) !== null && _readStringValue !== void 0 ? _readStringValue : Buffer.alloc(0);
2525
+ var U = (_readStringValue1 = readStringValue(entries.get('U'))) !== null && _readStringValue1 !== void 0 ? _readStringValue1 : Buffer.alloc(0);
2526
+ var P = (_readNumberValue3 = readNumberValue(entries.get('P'))) !== null && _readNumberValue3 !== void 0 ? _readNumberValue3 : 0;
2527
+ var encryptMetadataEntry = entries.get('EncryptMetadata');
2528
+ var encryptMetadata = encryptMetadataEntry ? (_readBooleanValue = readBooleanValue(encryptMetadataEntry)) !== null && _readBooleanValue !== void 0 ? _readBooleanValue : true : true;
2529
+ if (R !== 0 && V !== 0) {
2530
+ result = {
2531
+ filter: filter,
2532
+ V: V,
2533
+ R: R,
2534
+ Length: Length,
2535
+ O: O,
2536
+ U: U,
2537
+ P: P,
2538
+ encryptMetadata: encryptMetadata
2539
+ };
2540
+ }
2541
+ }
2542
+ return result;
2543
+ }
2544
+ function readNumberValue(entry) {
2545
+ var result = null;
2546
+ if ((entry === null || entry === void 0 ? void 0 : entry.type) === 'number') {
2547
+ var value = Number(entry.raw.toString('latin1'));
2548
+ if (!Number.isNaN(value)) {
2549
+ result = value;
2550
+ }
2551
+ }
2552
+ return result;
2553
+ }
2554
+ function readNameValue(entry) {
2555
+ return (entry === null || entry === void 0 ? void 0 : entry.type) === 'name' ? entry.raw.toString('latin1') : null;
2556
+ }
2557
+ function readStringValue(entry) {
2558
+ return (entry === null || entry === void 0 ? void 0 : entry.type) === 'string' ? entry.raw : null;
2559
+ }
2560
+ function readBooleanValue(entry) {
2561
+ return entry.type === 'boolean' ? entry.raw.toString('latin1') === 'true' : null;
2562
+ }
2563
+ function extractFirstFileId(buffer) {
2564
+ // The /ID array lives in the trailer or the cross-reference stream dictionary.
2565
+ // Walk the buffer right-to-left to find the most recent /ID array.
2566
+ var result = null;
2567
+ var pos = buffer.length;
2568
+ var done = false;
2569
+ while(pos > 0 && !done){
2570
+ var found = buffer.lastIndexOf('/ID', pos);
2571
+ if (found < 0) {
2572
+ done = true;
2573
+ } else {
2574
+ var after = found + 3;
2575
+ var isExactName = after >= buffer.length || isPdfWhitespaceOrDelimiter(buffer[after]);
2576
+ if (isExactName) {
2577
+ var i = skipPdfWhitespaceAndComments(buffer, after);
2578
+ if (buffer[i] === 0x5b /* [ */ ) {
2579
+ i = skipPdfWhitespaceAndComments(buffer, i + 1);
2580
+ var valueResult = readPdfValue(buffer, i);
2581
+ if ((valueResult === null || valueResult === void 0 ? void 0 : valueResult.entry.type) === 'string') {
2582
+ result = valueResult.entry.raw;
2583
+ done = true;
2584
+ }
2585
+ }
2586
+ }
2587
+ if (!done) {
2588
+ pos = found - 1;
2589
+ }
2590
+ }
2591
+ }
2592
+ return result;
2593
+ }
2594
+ // MARK: Standard security handler — empty-password validation
2595
+ function rc4(key, data) {
2596
+ var S = new Uint8Array(256);
2597
+ for(var i = 0; i < 256; i++)S[i] = i;
2598
+ var j = 0;
2599
+ for(var i1 = 0; i1 < 256; i1++){
2600
+ j = j + S[i1] + key[i1 % key.length] & 0xff;
2601
+ var t = S[i1];
2602
+ S[i1] = S[j];
2603
+ S[j] = t;
2604
+ }
2605
+ var out = Buffer.alloc(data.length);
2606
+ var ii = 0;
2607
+ var jj = 0;
2608
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2609
+ try {
2610
+ for(var _iterator = data.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2611
+ var _step_value = _sliced_to_array(_step.value, 2), n = _step_value[0], byte = _step_value[1];
2612
+ ii = ii + 1 & 0xff;
2613
+ jj = jj + S[ii] & 0xff;
2614
+ var t1 = S[ii];
2615
+ S[ii] = S[jj];
2616
+ S[jj] = t1;
2617
+ out[n] = byte ^ S[S[ii] + S[jj] & 0xff];
2618
+ }
2619
+ } catch (err) {
2620
+ _didIteratorError = true;
2621
+ _iteratorError = err;
2622
+ } finally{
2623
+ try {
2624
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2625
+ _iterator.return();
2626
+ }
2627
+ } finally{
2628
+ if (_didIteratorError) {
2629
+ throw _iteratorError;
2630
+ }
2631
+ }
2632
+ }
2633
+ return out;
2634
+ }
2635
+ function computeFileEncryptionKeyR2to4(info, password, fileId) {
2636
+ var padded = Buffer.alloc(32);
2637
+ password.copy(padded, 0, 0, Math.min(password.length, 32));
2638
+ if (password.length < 32) PDF_PASSWORD_PADDING.copy(padded, password.length, 0, 32 - password.length);
2639
+ var md5 = node_crypto.createHash('md5');
2640
+ md5.update(padded);
2641
+ md5.update(info.O);
2642
+ var pBytes = Buffer.alloc(4);
2643
+ pBytes.writeInt32LE(info.P | 0, 0);
2644
+ md5.update(pBytes);
2645
+ md5.update(fileId);
2646
+ if (info.R >= 4 && !info.encryptMetadata) md5.update(Buffer.from([
2647
+ 0xff,
2648
+ 0xff,
2649
+ 0xff,
2650
+ 0xff
2651
+ ]));
2652
+ var key = md5.digest();
2653
+ var keyBytes = Math.min(Math.floor(info.Length / 8), key.length);
2654
+ if (info.R >= 3) {
2655
+ for(var i = 0; i < 50; i++){
2656
+ key = node_crypto.createHash('md5').update(key.subarray(0, keyBytes)).digest();
2657
+ }
2658
+ }
2659
+ return key.subarray(0, keyBytes);
2660
+ }
2661
+ function validateEmptyPasswordR2to4(info, fileId) {
2662
+ var password = Buffer.alloc(0);
2663
+ var key = computeFileEncryptionKeyR2to4(info, password, fileId);
2664
+ var matches;
2665
+ if (info.R === 2) {
2666
+ var expected = rc4(key, PDF_PASSWORD_PADDING);
2667
+ matches = constantTimeEquals(expected, info.U.subarray(0, 32));
2668
+ } else {
2669
+ var computed = node_crypto.createHash('md5').update(PDF_PASSWORD_PADDING).update(fileId).digest();
2670
+ computed = rc4(key, computed);
2671
+ for(var i = 1; i <= 19; i++){
2672
+ var xorKey = Buffer.alloc(key.length);
2673
+ for(var j = 0; j < key.length; j++)xorKey[j] = key[j] ^ i;
2674
+ computed = rc4(xorKey, computed);
2675
+ }
2676
+ matches = constantTimeEquals(computed, info.U.subarray(0, 16));
2677
+ }
2678
+ return matches;
2679
+ }
2680
+ function validateEmptyPasswordR5(info) {
2681
+ var validationSalt = info.U.subarray(32, 40);
2682
+ var computed = node_crypto.createHash('sha256').update(validationSalt).digest();
2683
+ return constantTimeEquals(computed, info.U.subarray(0, 32));
2684
+ }
2685
+ function validateEmptyPasswordR6(info) {
2686
+ var validationSalt = info.U.subarray(32, 40);
2687
+ var password = Buffer.alloc(0);
2688
+ var computed = pdfAlgorithm2B(Buffer.concat([
2689
+ password,
2690
+ validationSalt
2691
+ ]), password, Buffer.alloc(0));
2692
+ return constantTimeEquals(computed, info.U.subarray(0, 32));
2693
+ }
2694
+ function pdfAlgorithm2B(input, password, userKey) {
2695
+ var K = node_crypto.createHash('sha256').update(input).digest();
2696
+ var round = 0;
2697
+ var lastE = Buffer.alloc(0);
2698
+ while(true){
2699
+ var part = Buffer.concat([
2700
+ password,
2701
+ K,
2702
+ userKey
2703
+ ]);
2704
+ var K1 = Buffer.alloc(part.length * 64);
2705
+ for(var i = 0; i < 64; i++)part.copy(K1, i * part.length);
2706
+ var cipher = node_crypto.createCipheriv('aes-128-cbc', K.subarray(0, 16), K.subarray(16, 32));
2707
+ cipher.setAutoPadding(false);
2708
+ var E = Buffer.concat([
2709
+ cipher.update(K1),
2710
+ cipher.final()
2711
+ ]);
2712
+ lastE = E;
2713
+ var n = 0;
2714
+ for(var i1 = 0; i1 < 16; i1++)n = (n * 256 + E[i1]) % 3;
2715
+ if (n === 0) K = node_crypto.createHash('sha256').update(E).digest();
2716
+ else if (n === 1) K = node_crypto.createHash('sha384').update(E).digest();
2717
+ else K = node_crypto.createHash('sha512').update(E).digest();
2718
+ round++;
2719
+ if (round >= 64 && lastE[lastE.length - 1] <= round - 32) break;
2720
+ }
2721
+ return K.subarray(0, 32);
2722
+ }
2723
+ function constantTimeEquals(a, b) {
2724
+ var result = false;
2725
+ if (a.length === b.length) {
2726
+ var diff = 0;
2727
+ for(var i = 0; i < a.length; i++)diff |= a[i] ^ b[i];
2728
+ result = diff === 0;
2729
+ }
2730
+ return result;
2731
+ }
2732
+
1310
2733
  exports.AppModuleWithWebhooksEnabled = AppModuleWithWebhooksEnabled;
1311
2734
  exports.CLIENT_WEB_APP_URL_ENV_VAR = CLIENT_WEB_APP_URL_ENV_VAR;
1312
2735
  exports.ClientAppServiceConfig = ClientAppServiceConfig;
1313
2736
  exports.DEFAULT_BASE_WEBHOOK_PATH = DEFAULT_BASE_WEBHOOK_PATH;
2737
+ exports.DEFAULT_JSON_FILE_CACHE_MODE = DEFAULT_JSON_FILE_CACHE_MODE;
1314
2738
  exports.DEFAULT_WEBHOOK_MIDDLEWARE_ROUTE_INFO = DEFAULT_WEBHOOK_MIDDLEWARE_ROUTE_INFO;
1315
2739
  exports.IsRequestFromLocalHost = IsRequestFromLocalHost;
1316
2740
  exports.ParseRawBody = ParseRawBody;
@@ -1326,7 +2750,12 @@ exports.clientAppConfigFactory = clientAppConfigFactory;
1326
2750
  exports.consumeWebhooksWithRawBodyMiddleware = consumeWebhooksWithRawBodyMiddleware;
1327
2751
  exports.createAES256GCMEncryption = createAES256GCMEncryption;
1328
2752
  exports.createAesStringEncryptionProvider = createAesStringEncryptionProvider;
2753
+ exports.createJsonFileAsyncKeyedValueCache = createJsonFileAsyncKeyedValueCache;
2754
+ exports.createJsonFileAsyncValueCache = createJsonFileAsyncValueCache;
2755
+ exports.createMemoizedJsonFileAsyncKeyedValueCache = createMemoizedJsonFileAsyncKeyedValueCache;
2756
+ exports.createMemoizedJsonFileAsyncValueCache = createMemoizedJsonFileAsyncValueCache;
1329
2757
  exports.decryptValue = decryptValue;
2758
+ exports.detectPdfEncryption = detectPdfEncryption;
1330
2759
  exports.encryptValue = encryptValue;
1331
2760
  exports.injectionTokensFromProviders = injectionTokensFromProviders;
1332
2761
  exports.isLocalhost = isLocalhost;
@@ -1334,5 +2763,8 @@ exports.isTestNodeEnv = isTestNodeEnv;
1334
2763
  exports.isValidAES256GCMEncryptionSecret = isValidAES256GCMEncryptionSecret;
1335
2764
  exports.mergeModuleMetadata = mergeModuleMetadata;
1336
2765
  exports.nodeJsLocalAssetLoader = nodeJsLocalAssetLoader;
2766
+ exports.readJsonFile = readJsonFile;
2767
+ exports.removeFile = removeFile;
1337
2768
  exports.resolveEncryptionKey = resolveEncryptionKey;
1338
2769
  exports.serverEnvTokenProvider = serverEnvTokenProvider;
2770
+ exports.writeJsonFile = writeJsonFile;