@azure/storage-blob 12.12.0-alpha.20220811.2 → 12.12.0-alpha.20220816.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/dist/index.js CHANGED
@@ -13333,6 +13333,7 @@ const BLOCK_BLOB_MAX_BLOCKS = 50000;
13333
13333
  const DEFAULT_BLOCK_BUFFER_SIZE_BYTES = 8 * 1024 * 1024; // 8MB
13334
13334
  const DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES = 4 * 1024 * 1024; // 4MB
13335
13335
  const DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS = 5;
13336
+ const REQUEST_TIMEOUT = 100 * 1000; // In ms
13336
13337
  /**
13337
13338
  * The OAuth scope to use with Azure Storage.
13338
13339
  */
@@ -13520,6 +13521,30 @@ const StorageBlobLoggingAllowedQueryParameters = [
13520
13521
  ];
13521
13522
  const BlobUsesCustomerSpecifiedEncryptionMsg = "BlobUsesCustomerSpecifiedEncryption";
13522
13523
  const BlobDoesNotUseCustomerSpecifiedEncryption = "BlobDoesNotUseCustomerSpecifiedEncryption";
13524
+ /// List of ports used for path style addressing.
13525
+ /// Path style addressing means that storage account is put in URI's Path segment in instead of in host.
13526
+ const PathStylePorts = [
13527
+ "10000",
13528
+ "10001",
13529
+ "10002",
13530
+ "10003",
13531
+ "10004",
13532
+ "10100",
13533
+ "10101",
13534
+ "10102",
13535
+ "10103",
13536
+ "10104",
13537
+ "11000",
13538
+ "11001",
13539
+ "11002",
13540
+ "11003",
13541
+ "11004",
13542
+ "11100",
13543
+ "11101",
13544
+ "11102",
13545
+ "11103",
13546
+ "11104",
13547
+ ];
13523
13548
 
13524
13549
  // Copyright (c) Microsoft Corporation.
13525
13550
  /**
@@ -13961,7 +13986,8 @@ function isIpEndpointStyle(parsedUrl) {
13961
13986
  // Case 2: localhost(:port), use broad regex to match port part.
13962
13987
  // Case 3: Ipv4, use broad regex which just check if host contains Ipv4.
13963
13988
  // For valid host please refer to https://man7.org/linux/man-pages/man7/hostname.7.html.
13964
- return /^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host);
13989
+ return (/^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host) ||
13990
+ (parsedUrl.getPort() !== undefined && PathStylePorts.includes(parsedUrl.getPort())));
13965
13991
  }
13966
13992
  /**
13967
13993
  * Convert Tags to encoded string.
@@ -19351,8 +19377,10 @@ async function streamToBuffer(stream, buffer, offset, end, encoding) {
19351
19377
  let pos = 0; // Position in stream
19352
19378
  const count = end - offset; // Total amount of data needed in stream
19353
19379
  return new Promise((resolve, reject) => {
19380
+ const timeout = setTimeout(() => reject(new Error(`The operation cannot be completed in timeout.`)), REQUEST_TIMEOUT);
19354
19381
  stream.on("readable", () => {
19355
19382
  if (pos >= count) {
19383
+ clearTimeout(timeout);
19356
19384
  resolve();
19357
19385
  return;
19358
19386
  }
@@ -19369,12 +19397,16 @@ async function streamToBuffer(stream, buffer, offset, end, encoding) {
19369
19397
  pos += chunkLength;
19370
19398
  });
19371
19399
  stream.on("end", () => {
19400
+ clearTimeout(timeout);
19372
19401
  if (pos < count) {
19373
19402
  reject(new Error(`Stream drains before getting enough data needed. Data read: ${pos}, data need: ${count}`));
19374
19403
  }
19375
19404
  resolve();
19376
19405
  });
19377
- stream.on("error", reject);
19406
+ stream.on("error", (msg) => {
19407
+ clearTimeout(timeout);
19408
+ reject(msg);
19409
+ });
19378
19410
  });
19379
19411
  }
19380
19412
  /**