@apify/utilities 2.15.1 → 2.15.3

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/esm/index.mjs CHANGED
@@ -4,7 +4,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
 
6
6
  // src/utilities.ts
7
- import crypto from "crypto";
7
+ import crypto from "node:crypto";
8
8
  import { ANONYMOUS_USERNAME, APIFY_ID_REGEX } from "@apify/consts";
9
9
  import log, { LoggerJson, LogLevel } from "@apify/log";
10
10
  function cryptoRandomObjectId(length = 17) {
@@ -60,7 +60,8 @@ __name(http404Route, "http404Route");
60
60
  function expressErrorHandler(err, req, res, next) {
61
61
  log.warning("Client HTTP request failed", { url: req.url, errMsg: err.message });
62
62
  if (res.headersSent) {
63
- return next(err);
63
+ next(err);
64
+ return;
64
65
  }
65
66
  res.status(505);
66
67
  res.send("Internal server error");
@@ -71,7 +72,9 @@ function betterSetInterval(func, delay) {
71
72
  let timeoutId;
72
73
  let isRunning = true;
73
74
  const funcWrapper = /* @__PURE__ */ __name(function() {
74
- void new Promise((resolve) => resolve(func(() => void 0))).finally(scheduleNextRun);
75
+ void new Promise((resolve) => {
76
+ resolve(func(() => void 0));
77
+ }).finally(scheduleNextRun);
75
78
  }, "funcWrapper");
76
79
  scheduleNextRun = /* @__PURE__ */ __name(function() {
77
80
  if (isRunning) timeoutId = setTimeout(funcWrapper, delay);
@@ -994,7 +997,10 @@ async function timeoutPromise(promise, timeoutMillis, errorMessage = "Promise ha
994
997
  if (hasFulfilled) return;
995
998
  clearTimeout(timeout);
996
999
  hasFulfilled = true;
997
- if (err) return reject(err);
1000
+ if (err) {
1001
+ reject(err);
1002
+ return;
1003
+ }
998
1004
  resolve(result);
999
1005
  }, "callback");
1000
1006
  promise.then((result) => callback(null, result), callback);
@@ -1004,7 +1010,7 @@ async function timeoutPromise(promise, timeoutMillis, errorMessage = "Promise ha
1004
1010
  __name(timeoutPromise, "timeoutPromise");
1005
1011
 
1006
1012
  // src/utilities.client.ts
1007
- import { VERSION_INT_MAJOR_BASE, VERSION_INT_MINOR_BASE, RELATIVE_URL_REGEX } from "@apify/consts";
1013
+ import { RELATIVE_URL_REGEX, VERSION_INT_MAJOR_BASE, VERSION_INT_MINOR_BASE } from "@apify/consts";
1008
1014
  function isNullOrUndefined(obj) {
1009
1015
  return obj == null;
1010
1016
  }
@@ -1125,7 +1131,7 @@ function markedSetNofollowLinks(href, title, text, referrerHostname) {
1125
1131
  let urlParsed;
1126
1132
  try {
1127
1133
  urlParsed = new URL(href);
1128
- } catch (e) {
1134
+ } catch {
1129
1135
  }
1130
1136
  const isApifyLink = urlParsed && /(\.|^)apify\.com$/i.test(urlParsed.hostname);
1131
1137
  const isSameHostname = !referrerHostname || urlParsed && urlParsed.hostname === referrerHostname;
@@ -1444,7 +1450,7 @@ __publicField(_HealthChecker, "CHECK_TYPES", CHECK_TYPES);
1444
1450
  var HealthChecker = _HealthChecker;
1445
1451
 
1446
1452
  // src/parse_jsonl_stream.ts
1447
- import { Transform } from "stream";
1453
+ import { Transform } from "node:stream";
1448
1454
  var _ParseJsonlStream = class _ParseJsonlStream extends Transform {
1449
1455
  constructor() {
1450
1456
  super(...arguments);
@@ -1717,7 +1723,7 @@ __name(_WebhookPayloadTemplate, "WebhookPayloadTemplate");
1717
1723
  var WebhookPayloadTemplate = _WebhookPayloadTemplate;
1718
1724
 
1719
1725
  // src/crypto.ts
1720
- import crypto2 from "crypto";
1726
+ import crypto2 from "node:crypto";
1721
1727
  var ENCRYPTION_ALGORITHM = "aes-256-gcm";
1722
1728
  var ENCRYPTION_KEY_LENGTH = 32;
1723
1729
  var ENCRYPTION_IV_LENGTH = 16;
@@ -1770,7 +1776,7 @@ function separateImports(code) {
1770
1776
  __name(separateImports, "separateImports");
1771
1777
 
1772
1778
  // src/code_hash_manager.ts
1773
- import { timingSafeEqual, createHmac } from "node:crypto";
1779
+ import { createHmac, timingSafeEqual } from "node:crypto";
1774
1780
  var CodeHashMetaKey = /* @__PURE__ */ ((CodeHashMetaKey2) => {
1775
1781
  CodeHashMetaKey2["VERSION"] = "v";
1776
1782
  CodeHashMetaKey2["USER"] = "u";
@@ -1829,7 +1835,7 @@ __publicField(_CodeHashManager, "VERSION", 1);
1829
1835
  var CodeHashManager = _CodeHashManager;
1830
1836
 
1831
1837
  // src/hmac.ts
1832
- import crypto3 from "crypto";
1838
+ import crypto3 from "node:crypto";
1833
1839
  var CHARSET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
1834
1840
  function encodeBase62(num) {
1835
1841
  if (num === 0n) {