@apify/utilities 2.16.2 → 2.18.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/cjs/index.d.ts CHANGED
@@ -547,4 +547,18 @@ declare class CodeHashManager {
547
547
  */
548
548
  declare function createHmacSignature(secretKey: string, message: string): string;
549
549
 
550
- export { type BetterIntervalID, CHECK_TYPES, CodeHashManager, CodeHashMetaKey, HealthChecker, InvalidJsonError, InvalidVariableError, JsonVariable, ParseJsonlStream, RetryableError, WebhookPayloadTemplate, betterClearInterval, betterSetInterval, buildOrVersionNumberIntToStr, checkParamPrototypeOrThrow, concatStreamToBuffer, configureLogger, createHmacSignature, cryptoRandomObjectId, dateToString, delayPromise, deterministicUniqueId, escapeForBson, escapePropertyName, escapeRegExp, expressErrorHandler, getOrdinalSuffix, getRandomInt, http404Route, isBadForMongo, isBuffer, isForbiddenUsername, isNullOrUndefined, isUrlRelative, jsonStringifyExtended, leftpad, markedDecreaseHeadsLevel, markedSetNofollowLinks, normalizeUrl, parseDateFromJson, parseUrl, privateDecrypt, promisifyServerListen, publicEncrypt, readStreamToString, removeFromArray, retryWithExpBackoff, separateImports, sequentializePromises, splitFullName, timeoutPromise, traverseObject, truncate, unescapeFromBson, unescapePropertyName, weightedAverage };
550
+ /**
551
+ * Creates a secure signature for a resource like a dataset or key-value store.
552
+ * This signature is used to generate a signed URL for authenticated access, which can be expiring or permanent.
553
+ * The signature is created using HMAC with the provided secret key and includes the resource ID, expiration time, and version.
554
+ *
555
+ * Note: expirationMillis is optional. If not provided, the signature will not expire.
556
+ */
557
+ declare function createStorageContentSignature({ resourceId, urlSigningSecretKey, expiresInMillis, version, }: {
558
+ resourceId: string;
559
+ urlSigningSecretKey: string;
560
+ expiresInMillis?: number;
561
+ version?: number;
562
+ }): string;
563
+
564
+ export { type BetterIntervalID, CHECK_TYPES, CodeHashManager, CodeHashMetaKey, HealthChecker, InvalidJsonError, InvalidVariableError, JsonVariable, ParseJsonlStream, RetryableError, WebhookPayloadTemplate, betterClearInterval, betterSetInterval, buildOrVersionNumberIntToStr, checkParamPrototypeOrThrow, concatStreamToBuffer, configureLogger, createHmacSignature, createStorageContentSignature, cryptoRandomObjectId, dateToString, delayPromise, deterministicUniqueId, escapeForBson, escapePropertyName, escapeRegExp, expressErrorHandler, getOrdinalSuffix, getRandomInt, http404Route, isBadForMongo, isBuffer, isForbiddenUsername, isNullOrUndefined, isUrlRelative, jsonStringifyExtended, leftpad, markedDecreaseHeadsLevel, markedSetNofollowLinks, normalizeUrl, parseDateFromJson, parseUrl, privateDecrypt, promisifyServerListen, publicEncrypt, readStreamToString, removeFromArray, retryWithExpBackoff, separateImports, sequentializePromises, splitFullName, timeoutPromise, traverseObject, truncate, unescapeFromBson, unescapePropertyName, weightedAverage };
package/esm/index.d.mts CHANGED
@@ -547,4 +547,18 @@ declare class CodeHashManager {
547
547
  */
548
548
  declare function createHmacSignature(secretKey: string, message: string): string;
549
549
 
550
- export { type BetterIntervalID, CHECK_TYPES, CodeHashManager, CodeHashMetaKey, HealthChecker, InvalidJsonError, InvalidVariableError, JsonVariable, ParseJsonlStream, RetryableError, WebhookPayloadTemplate, betterClearInterval, betterSetInterval, buildOrVersionNumberIntToStr, checkParamPrototypeOrThrow, concatStreamToBuffer, configureLogger, createHmacSignature, cryptoRandomObjectId, dateToString, delayPromise, deterministicUniqueId, escapeForBson, escapePropertyName, escapeRegExp, expressErrorHandler, getOrdinalSuffix, getRandomInt, http404Route, isBadForMongo, isBuffer, isForbiddenUsername, isNullOrUndefined, isUrlRelative, jsonStringifyExtended, leftpad, markedDecreaseHeadsLevel, markedSetNofollowLinks, normalizeUrl, parseDateFromJson, parseUrl, privateDecrypt, promisifyServerListen, publicEncrypt, readStreamToString, removeFromArray, retryWithExpBackoff, separateImports, sequentializePromises, splitFullName, timeoutPromise, traverseObject, truncate, unescapeFromBson, unescapePropertyName, weightedAverage };
550
+ /**
551
+ * Creates a secure signature for a resource like a dataset or key-value store.
552
+ * This signature is used to generate a signed URL for authenticated access, which can be expiring or permanent.
553
+ * The signature is created using HMAC with the provided secret key and includes the resource ID, expiration time, and version.
554
+ *
555
+ * Note: expirationMillis is optional. If not provided, the signature will not expire.
556
+ */
557
+ declare function createStorageContentSignature({ resourceId, urlSigningSecretKey, expiresInMillis, version, }: {
558
+ resourceId: string;
559
+ urlSigningSecretKey: string;
560
+ expiresInMillis?: number;
561
+ version?: number;
562
+ }): string;
563
+
564
+ export { type BetterIntervalID, CHECK_TYPES, CodeHashManager, CodeHashMetaKey, HealthChecker, InvalidJsonError, InvalidVariableError, JsonVariable, ParseJsonlStream, RetryableError, WebhookPayloadTemplate, betterClearInterval, betterSetInterval, buildOrVersionNumberIntToStr, checkParamPrototypeOrThrow, concatStreamToBuffer, configureLogger, createHmacSignature, createStorageContentSignature, cryptoRandomObjectId, dateToString, delayPromise, deterministicUniqueId, escapeForBson, escapePropertyName, escapeRegExp, expressErrorHandler, getOrdinalSuffix, getRandomInt, http404Route, isBadForMongo, isBuffer, isForbiddenUsername, isNullOrUndefined, isUrlRelative, jsonStringifyExtended, leftpad, markedDecreaseHeadsLevel, markedSetNofollowLinks, normalizeUrl, parseDateFromJson, parseUrl, privateDecrypt, promisifyServerListen, publicEncrypt, readStreamToString, removeFromArray, retryWithExpBackoff, separateImports, sequentializePromises, splitFullName, timeoutPromise, traverseObject, truncate, unescapeFromBson, unescapePropertyName, weightedAverage };
package/esm/index.mjs CHANGED
@@ -118,7 +118,7 @@ function weightedAverage(val1, weight1, val2, weight2) {
118
118
  }
119
119
  __name(weightedAverage, "weightedAverage");
120
120
  var FORBIDDEN_USERNAMES_REGEXPS = [
121
- // Meteor app routes
121
+ // App routes
122
122
  "page-not-found",
123
123
  "docs",
124
124
  "terms-of-use",
@@ -314,6 +314,10 @@ var FORBIDDEN_USERNAMES_REGEXPS = [
314
314
  "model-context-protocol",
315
315
  "modelcontextprotocol",
316
316
  "apify.com",
317
+ "design-kit",
318
+ "press-kit",
319
+ "scrapers",
320
+ "professional-services",
317
321
  // Special files
318
322
  "index",
319
323
  "index\\.html",
@@ -1858,6 +1862,19 @@ function createHmacSignature(secretKey, message) {
1858
1862
  return encodeBase62(BigInt(`0x${signature}`));
1859
1863
  }
1860
1864
  __name(createHmacSignature, "createHmacSignature");
1865
+
1866
+ // src/storages.ts
1867
+ function createStorageContentSignature({
1868
+ resourceId,
1869
+ urlSigningSecretKey,
1870
+ expiresInMillis,
1871
+ version = 0
1872
+ }) {
1873
+ const expiresAt = expiresInMillis ? (/* @__PURE__ */ new Date()).getTime() + expiresInMillis : 0;
1874
+ const hmac = createHmacSignature(urlSigningSecretKey, `${version}.${expiresAt}.${resourceId}`);
1875
+ return Buffer.from(`${version}.${expiresAt}.${hmac}`).toString("base64url");
1876
+ }
1877
+ __name(createStorageContentSignature, "createStorageContentSignature");
1861
1878
  export {
1862
1879
  CHECK_TYPES,
1863
1880
  CodeHashManager,
@@ -1876,6 +1893,7 @@ export {
1876
1893
  concatStreamToBuffer,
1877
1894
  configureLogger,
1878
1895
  createHmacSignature,
1896
+ createStorageContentSignature,
1879
1897
  cryptoRandomObjectId,
1880
1898
  dateToString,
1881
1899
  delayPromise,