@azure/storage-common 12.4.1 → 12.6.0-beta.1

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 (155) hide show
  1. package/dist/browser/StorageResponseFormat.d.ts +22 -0
  2. package/dist/browser/StorageResponseFormat.d.ts.map +1 -0
  3. package/dist/browser/StorageResponseFormat.js +20 -0
  4. package/dist/browser/StorageResponseFormat.js.map +1 -0
  5. package/dist/browser/StructuredMessageEncodingStream-browser.d.mts.map +1 -1
  6. package/dist/browser/StructuredMessageEncodingStream-browser.mjs +1 -2
  7. package/dist/browser/StructuredMessageEncodingStream-browser.mjs.map +1 -1
  8. package/dist/browser/crc64.js +6 -93
  9. package/dist/browser/indexPlatform-browser.d.mts +2 -0
  10. package/dist/browser/indexPlatform-browser.d.mts.map +1 -1
  11. package/dist/browser/indexPlatform-browser.mjs +2 -0
  12. package/dist/browser/indexPlatform-browser.mjs.map +1 -1
  13. package/dist/browser/package.json +6 -1
  14. package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
  15. package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
  16. package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.js +22 -0
  17. package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.js.map +1 -0
  18. package/dist/browser/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
  19. package/dist/browser/policies/StorageRequestFailureDetailsParserPolicy.js +12 -0
  20. package/dist/browser/policies/StorageRequestFailureDetailsParserPolicy.js.map +1 -1
  21. package/dist/browser/policies/StorageRetryPolicy.d.ts.map +1 -1
  22. package/dist/browser/policies/StorageRetryPolicy.js +2 -3
  23. package/dist/browser/policies/StorageRetryPolicy.js.map +1 -1
  24. package/dist/browser/policies/StorageRetryPolicyV2.d.ts.map +1 -1
  25. package/dist/browser/policies/StorageRetryPolicyV2.js +28 -0
  26. package/dist/browser/policies/StorageRetryPolicyV2.js.map +1 -1
  27. package/dist/browser/utils/constants.d.ts.map +1 -1
  28. package/dist/browser/utils/constants.js +1 -1
  29. package/dist/browser/utils/constants.js.map +1 -1
  30. package/dist/browser/utils/utils.common.d.ts.map +1 -1
  31. package/dist/browser/utils/utils.common.js +5 -9
  32. package/dist/browser/utils/utils.common.js.map +1 -1
  33. package/dist/commonjs/BufferScheduler.d.ts.map +1 -1
  34. package/dist/commonjs/BufferScheduler.js +24 -7
  35. package/dist/commonjs/BufferScheduler.js.map +2 -2
  36. package/dist/commonjs/BuffersStream.d.ts.map +1 -1
  37. package/dist/commonjs/BuffersStream.js +0 -1
  38. package/dist/commonjs/BuffersStream.js.map +2 -2
  39. package/dist/commonjs/StorageResponseFormat.d.ts +22 -0
  40. package/dist/commonjs/StorageResponseFormat.d.ts.map +1 -0
  41. package/dist/commonjs/StorageResponseFormat.js +41 -0
  42. package/dist/commonjs/StorageResponseFormat.js.map +7 -0
  43. package/dist/commonjs/crc64.js +6 -134
  44. package/dist/commonjs/indexPlatform.d.ts +3 -0
  45. package/dist/commonjs/indexPlatform.d.ts.map +1 -1
  46. package/dist/commonjs/indexPlatform.js +7 -0
  47. package/dist/commonjs/indexPlatform.js.map +2 -2
  48. package/dist/commonjs/package.json +6 -1
  49. package/dist/commonjs/policies/SharedKeySigning.d.ts +32 -0
  50. package/dist/commonjs/policies/SharedKeySigning.d.ts.map +1 -0
  51. package/dist/commonjs/policies/SharedKeySigning.js +125 -0
  52. package/dist/commonjs/policies/SharedKeySigning.js.map +7 -0
  53. package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
  54. package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
  55. package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.js +42 -0
  56. package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.js.map +7 -0
  57. package/dist/commonjs/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
  58. package/dist/commonjs/policies/StorageRequestFailureDetailsParserPolicy.js +6 -0
  59. package/dist/commonjs/policies/StorageRequestFailureDetailsParserPolicy.js.map +2 -2
  60. package/dist/commonjs/policies/StorageRetryPolicy.d.ts.map +1 -1
  61. package/dist/commonjs/policies/StorageRetryPolicy.js +1 -1
  62. package/dist/commonjs/policies/StorageRetryPolicy.js.map +2 -2
  63. package/dist/commonjs/policies/StorageRetryPolicyV2.d.ts.map +1 -1
  64. package/dist/commonjs/policies/StorageRetryPolicyV2.js +16 -0
  65. package/dist/commonjs/policies/StorageRetryPolicyV2.js.map +2 -2
  66. package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.d.ts +0 -28
  67. package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -1
  68. package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js +10 -94
  69. package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js.map +2 -2
  70. package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.d.ts.map +1 -1
  71. package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js +2 -76
  72. package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js.map +2 -2
  73. package/dist/commonjs/tsdoc-metadata.json +1 -1
  74. package/dist/commonjs/utils/constants.d.ts.map +1 -1
  75. package/dist/commonjs/utils/constants.js +1 -1
  76. package/dist/commonjs/utils/constants.js.map +1 -1
  77. package/dist/commonjs/utils/utils.common.d.ts.map +1 -1
  78. package/dist/commonjs/utils/utils.common.js +11 -9
  79. package/dist/commonjs/utils/utils.common.js.map +2 -2
  80. package/dist/esm/BufferScheduler.d.ts.map +1 -1
  81. package/dist/esm/BufferScheduler.js +29 -7
  82. package/dist/esm/BufferScheduler.js.map +1 -1
  83. package/dist/esm/BuffersStream.d.ts.map +1 -1
  84. package/dist/esm/BuffersStream.js +0 -1
  85. package/dist/esm/BuffersStream.js.map +1 -1
  86. package/dist/esm/StorageResponseFormat.d.ts +22 -0
  87. package/dist/esm/StorageResponseFormat.d.ts.map +1 -0
  88. package/dist/esm/StorageResponseFormat.js +20 -0
  89. package/dist/esm/StorageResponseFormat.js.map +1 -0
  90. package/dist/esm/crc64.js +6 -156
  91. package/dist/esm/indexPlatform.d.ts +3 -0
  92. package/dist/esm/indexPlatform.d.ts.map +1 -1
  93. package/dist/esm/indexPlatform.js +3 -0
  94. package/dist/esm/indexPlatform.js.map +1 -1
  95. package/dist/esm/package.json +6 -1
  96. package/dist/esm/policies/SharedKeySigning.d.ts +32 -0
  97. package/dist/esm/policies/SharedKeySigning.d.ts.map +1 -0
  98. package/dist/esm/policies/SharedKeySigning.js +156 -0
  99. package/dist/esm/policies/SharedKeySigning.js.map +1 -0
  100. package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
  101. package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
  102. package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.js +22 -0
  103. package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.js.map +1 -0
  104. package/dist/esm/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
  105. package/dist/esm/policies/StorageRequestFailureDetailsParserPolicy.js +12 -0
  106. package/dist/esm/policies/StorageRequestFailureDetailsParserPolicy.js.map +1 -1
  107. package/dist/esm/policies/StorageRetryPolicy.d.ts.map +1 -1
  108. package/dist/esm/policies/StorageRetryPolicy.js +2 -3
  109. package/dist/esm/policies/StorageRetryPolicy.js.map +1 -1
  110. package/dist/esm/policies/StorageRetryPolicyV2.d.ts.map +1 -1
  111. package/dist/esm/policies/StorageRetryPolicyV2.js +28 -0
  112. package/dist/esm/policies/StorageRetryPolicyV2.js.map +1 -1
  113. package/dist/esm/policies/StorageSharedKeyCredentialPolicy.d.ts +0 -28
  114. package/dist/esm/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -1
  115. package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js +9 -105
  116. package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
  117. package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.d.ts.map +1 -1
  118. package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js +2 -101
  119. package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -1
  120. package/dist/esm/utils/constants.d.ts.map +1 -1
  121. package/dist/esm/utils/constants.js +1 -1
  122. package/dist/esm/utils/constants.js.map +1 -1
  123. package/dist/esm/utils/utils.common.d.ts.map +1 -1
  124. package/dist/esm/utils/utils.common.js +5 -9
  125. package/dist/esm/utils/utils.common.js.map +1 -1
  126. package/dist/react-native/StorageResponseFormat.d.ts +22 -0
  127. package/dist/react-native/StorageResponseFormat.d.ts.map +1 -0
  128. package/dist/react-native/StorageResponseFormat.js +20 -0
  129. package/dist/react-native/StorageResponseFormat.js.map +1 -0
  130. package/dist/react-native/crc64.js +6 -93
  131. package/dist/react-native/indexPlatform-browser.d.mts +2 -0
  132. package/dist/react-native/indexPlatform-browser.d.mts.map +1 -1
  133. package/dist/react-native/indexPlatform-browser.mjs +2 -0
  134. package/dist/react-native/indexPlatform-browser.mjs.map +1 -1
  135. package/dist/react-native/package.json +6 -1
  136. package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
  137. package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
  138. package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.js +22 -0
  139. package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.js.map +1 -0
  140. package/dist/react-native/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
  141. package/dist/react-native/policies/StorageRequestFailureDetailsParserPolicy.js +12 -0
  142. package/dist/react-native/policies/StorageRequestFailureDetailsParserPolicy.js.map +1 -1
  143. package/dist/react-native/policies/StorageRetryPolicy.d.ts.map +1 -1
  144. package/dist/react-native/policies/StorageRetryPolicy.js +2 -3
  145. package/dist/react-native/policies/StorageRetryPolicy.js.map +1 -1
  146. package/dist/react-native/policies/StorageRetryPolicyV2.d.ts.map +1 -1
  147. package/dist/react-native/policies/StorageRetryPolicyV2.js +28 -0
  148. package/dist/react-native/policies/StorageRetryPolicyV2.js.map +1 -1
  149. package/dist/react-native/utils/constants.d.ts.map +1 -1
  150. package/dist/react-native/utils/constants.js +1 -1
  151. package/dist/react-native/utils/constants.js.map +1 -1
  152. package/dist/react-native/utils/utils.common.d.ts.map +1 -1
  153. package/dist/react-native/utils/utils.common.js +5 -9
  154. package/dist/react-native/utils/utils.common.js.map +1 -1
  155. package/package.json +14 -14
package/dist/esm/crc64.js CHANGED
@@ -1,33 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
 
4
- // ESM-COMPAT-START (this block is stripped from dist/commonjs by copyJSFiles.cjs)
5
- // In ESM under Node, `require`, `__filename`, and `__dirname` are not defined.
6
- // Synthesize them from `import.meta.url` so the Emscripten Node branch below works as-is.
7
- // Specifiers are held in variables to prevent web bundlers from statically resolving `node:*`.
8
- // The detection check below MUST stay byte-for-byte identical to the Emscripten-generated
9
- // `ENVIRONMENT_IS_NODE` check later in this file; otherwise the polyfill and the Node branch
10
- // can disagree and the ESM `ReferenceError: require is not defined` bug returns.
11
- import { createRequire } from "node:module";
12
- import { dirname } from "node:path";
13
- import { fileURLToPath } from "node:url";
14
- const __isNode__ =
15
- typeof process === "object" &&
16
- typeof process.versions === "object" &&
17
- typeof process.versions.node === "string";
18
- let require;
19
- let __filename;
20
- let __dirname;
21
- if (__isNode__) {
22
- require = createRequire(import.meta.url);
23
- __filename = fileURLToPath(import.meta.url);
24
- __dirname = dirname(__filename);
25
- }
26
- // ESM-COMPAT-END
27
-
28
4
  var NativeCRC64 = (() => {
29
5
  var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
30
- if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
31
6
  return (
32
7
  function(NativeCRC64) {
33
8
  NativeCRC64 = NativeCRC64 || {};
@@ -133,52 +108,10 @@ function logExceptionOnExit(e) {
133
108
 
134
109
  if (ENVIRONMENT_IS_NODE) {
135
110
  if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
136
- // NODE-READ-START (this block is replaced with a no-op in dist/browser and dist/react-native by copyJSFiles.cjs)
137
- // `require()` is no-op in an ESM module, use `createRequire()` to construct
138
- // the require()` function. This is only necessary for multi-environment
139
- // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
140
- // TODO: Swap all `require()`'s with `import()`'s?
141
- // These modules will usually be used on Node.js. Load them eagerly to avoid
142
- // the complexity of lazy-loading.
143
- var fs = require('fs');
144
- var nodePath = require('path');
145
-
146
- if (ENVIRONMENT_IS_WORKER) {
147
- scriptDirectory = nodePath.dirname(scriptDirectory) + '/';
148
- } else {
149
- scriptDirectory = __dirname + '/';
150
- }
151
-
152
- // include: node_shell_read.js
153
-
154
-
155
- read_ = (filename, binary) => {
156
- // We need to re-wrap `file://` strings to URLs. Normalizing isn't
157
- // necessary in that case, the path should already be absolute.
158
- filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
159
- return fs.readFileSync(filename, binary ? undefined : 'utf8');
160
- };
161
-
162
- readBinary = (filename) => {
163
- var ret = read_(filename, true);
164
- if (!ret.buffer) {
165
- ret = new Uint8Array(ret);
166
- }
167
- assert(ret.buffer);
168
- return ret;
169
- };
170
-
171
- readAsync = (filename, onload, onerror) => {
172
- // See the comment in the `read_` function.
173
- filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
174
- fs.readFile(filename, function(err, data) {
175
- if (err) onerror(err);
176
- else onload(data.buffer);
177
- });
178
- };
179
-
180
- // end include: node_shell_read.js
181
- // NODE-READ-END
111
+ // The wasm is base64-embedded (see `binaryInString`) and loaded via `getBinary()`,
112
+ // so the Node fs/path read hooks emitted by Emscripten are never exercised and
113
+ // have been removed. This keeps the file free of Node built-in imports so it can be
114
+ // consumed as-is by web bundlers and by ESM-to-CommonJS bundlers (see issue #39057).
182
115
  if (process['argv'].length > 1) {
183
116
  thisProgram = process['argv'][1].replace(/\\/g, '/');
184
117
  }
@@ -217,26 +150,6 @@ if (ENVIRONMENT_IS_SHELL) {
217
150
 
218
151
  if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
219
152
 
220
- if (typeof read != 'undefined') {
221
- read_ = function shell_read(f) {
222
- return read(f);
223
- };
224
- }
225
-
226
- readBinary = function readBinary(f) {
227
- let data;
228
- if (typeof readbuffer == 'function') {
229
- return new Uint8Array(readbuffer(f));
230
- }
231
- data = read(f, 'binary');
232
- assert(typeof data == 'object');
233
- return data;
234
- };
235
-
236
- readAsync = function readAsync(f, onload, onerror) {
237
- setTimeout(() => onload(readBinary(f)), 0);
238
- };
239
-
240
153
  if (typeof scriptArgs != 'undefined') {
241
154
  arguments_ = scriptArgs;
242
155
  } else if (typeof arguments != 'undefined') {
@@ -263,72 +176,9 @@ if (ENVIRONMENT_IS_SHELL) {
263
176
  // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
264
177
  // ENVIRONMENT_IS_NODE.
265
178
  if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
266
- if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
267
- scriptDirectory = self.location.href;
268
- } else if (typeof document != 'undefined' && document.currentScript) { // web
269
- scriptDirectory = document.currentScript.src;
270
- }
271
- // When MODULARIZE, this JS may be executed later, after document.currentScript
272
- // is gone, so we saved it, and we use it here instead of any other info.
273
- if (_scriptDir) {
274
- scriptDirectory = _scriptDir;
275
- }
276
- // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
277
- // otherwise, slice off the final part of the url to find the script directory.
278
- // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
279
- // and scriptDirectory will correctly be replaced with an empty string.
280
- // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
281
- // they are removed because they could contain a slash.
282
- if (scriptDirectory.indexOf('blob:') !== 0) {
283
- scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
284
- } else {
285
- scriptDirectory = '';
286
- }
287
-
288
179
  if (!(typeof window == 'object' || typeof importScripts == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
289
-
290
- // Differentiate the Web Worker from the Node Worker case, as reading must
291
- // be done differently.
292
- {
293
- // include: web_or_worker_shell_read.js
294
-
295
-
296
- read_ = (url) => {
297
- var xhr = new XMLHttpRequest();
298
- xhr.open('GET', url, false);
299
- xhr.send(null);
300
- return xhr.responseText;
301
- }
302
-
303
- if (ENVIRONMENT_IS_WORKER) {
304
- readBinary = (url) => {
305
- var xhr = new XMLHttpRequest();
306
- xhr.open('GET', url, false);
307
- xhr.responseType = 'arraybuffer';
308
- xhr.send(null);
309
- return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
310
- };
311
- }
312
-
313
- readAsync = (url, onload, onerror) => {
314
- var xhr = new XMLHttpRequest();
315
- xhr.open('GET', url, true);
316
- xhr.responseType = 'arraybuffer';
317
- xhr.onload = () => {
318
- if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
319
- onload(xhr.response);
320
- return;
321
- }
322
- onerror();
323
- };
324
- xhr.onerror = onerror;
325
- xhr.send(null);
326
- }
327
-
328
- // end include: web_or_worker_shell_read.js
329
- }
330
-
331
- setWindowTitle = (title) => document.title = title;
180
+ // The XHR-based read hooks emitted by Emscripten are unused because the wasm is
181
+ // base64-embedded; they have been removed so the file contains no DOM/XHR I/O.
332
182
  } else
333
183
  {
334
184
  throw new Error('environment detection error');
@@ -6,6 +6,7 @@ export * from "./StructuredMessageDecodingStream.js";
6
6
  export * from "./StorageCRC64Calculator.js";
7
7
  export { getCachedDefaultHttpClient } from "./cache.js";
8
8
  export type * from "./interfaces.js";
9
+ export * from "./StorageResponseFormat.js";
9
10
  export * from "./StorageBrowserPolicyFactory.js";
10
11
  export * from "./credentials/AnonymousCredential.js";
11
12
  export * from "./credentials/Credential.js";
@@ -19,6 +20,8 @@ export * from "./policies/StorageCorrectContentLengthPolicy.js";
19
20
  export * from "./policies/StorageRetryPolicyV2.js";
20
21
  export * from "./policies/StorageSharedKeyCredentialPolicy.js";
21
22
  export * from "./policies/StorageSharedKeyCredentialPolicyV2.js";
23
+ export { buildStorageSharedKeyStringToSign } from "./policies/SharedKeySigning.js";
24
+ export * from "./policies/StorageRedirectRangeHeaderPolicy.js";
22
25
  export * from "./policies/StorageRequestFailureDetailsParserPolicy.js";
23
26
  export * from "./credentials/UserDelegationKeyCredential.js";
24
27
  export type { UserDelegationKey } from "./credentials/UserDelegationKey.js";
@@ -1 +1 @@
1
- {"version":3,"file":"indexPlatform.d.ts","sourceRoot":"","sources":["../../src/indexPlatform.ts"],"names":[],"mappings":"AAGA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,mBAAmB,sBAAsB,CAAC;AAE1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kDAAkD,CAAC;AAEjE,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,cAAc,yCAAyC,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2CAA2C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AAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
@@ -7,6 +7,7 @@ export * from "./StructuredMessageEncodingStream.js";
7
7
  export * from "./StructuredMessageDecodingStream.js";
8
8
  export * from "./StorageCRC64Calculator.js";
9
9
  export { getCachedDefaultHttpClient } from "./cache.js";
10
+ export * from "./StorageResponseFormat.js";
10
11
  export * from "./StorageBrowserPolicyFactory.js";
11
12
  export * from "./credentials/AnonymousCredential.js";
12
13
  export * from "./credentials/Credential.js";
@@ -20,6 +21,8 @@ export * from "./policies/StorageCorrectContentLengthPolicy.js";
20
21
  export * from "./policies/StorageRetryPolicyV2.js";
21
22
  export * from "./policies/StorageSharedKeyCredentialPolicy.js";
22
23
  export * from "./policies/StorageSharedKeyCredentialPolicyV2.js";
24
+ export { buildStorageSharedKeyStringToSign } from "./policies/SharedKeySigning.js";
25
+ export * from "./policies/StorageRedirectRangeHeaderPolicy.js";
23
26
  export * from "./policies/StorageRequestFailureDetailsParserPolicy.js";
24
27
  export * from "./credentials/UserDelegationKeyCredential.js";
25
28
  //# sourceMappingURL=indexPlatform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"indexPlatform.js","sourceRoot":"","sources":["../../src/indexPlatform.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAGxD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kDAAkD,CAAC;AAEjE,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,cAAc,yCAAyC,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,mDAAmD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"#platform/BufferScheduler\";\nexport * from \"#platform/bufferHelpers\";\nexport { createBlobFromData } from \"./bufferHelpers.common.js\";\nexport * from \"#platform/StructuredMessageEncodingStream\";\nexport * from \"#platform/StructuredMessageDecodingStream\";\nexport * from \"./StorageCRC64Calculator.js\";\nexport { getCachedDefaultHttpClient } from \"./cache.js\";\nexport type * from \"#platform/interfaces\";\n\nexport * from \"./StorageBrowserPolicyFactory.js\";\nexport * from \"./credentials/AnonymousCredential.js\";\nexport * from \"./credentials/Credential.js\";\nexport * from \"#platform/credentials/StorageSharedKeyCredential\";\n\nexport * from \"./StorageRetryPolicyFactory.js\";\nexport { BaseRequestPolicy } from \"./policies/RequestPolicy.js\";\nexport * from \"./policies/AnonymousCredentialPolicy.js\";\nexport * from \"./policies/CredentialPolicy.js\";\nexport * from \"#platform/policies/StorageBrowserPolicyV2\";\nexport * from \"#platform/policies/StorageCorrectContentLengthPolicy\";\nexport * from \"./policies/StorageRetryPolicyV2.js\";\nexport * from \"./policies/StorageSharedKeyCredentialPolicy.js\";\nexport * from \"#platform/policies/StorageSharedKeyCredentialPolicyV2\";\nexport * from \"#platform/policies/StorageRequestFailureDetailsParserPolicy\";\nexport * from \"#platform/credentials/UserDelegationKeyCredential\";\nexport type { UserDelegationKey } from \"./credentials/UserDelegationKey.js\";\n\n// Re-export Readable stream type for Node.js (never in browser/react-native)\nexport type { Readable } from \"node:stream\";\n"]}
1
+ {"version":3,"file":"indexPlatform.js","sourceRoot":"","sources":["../../src/indexPlatform.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAExD,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kDAAkD,CAAC;AAEjE,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,cAAc,yCAAyC,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACnF,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wDAAwD,CAAC;AACvE,cAAc,mDAAmD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"#platform/BufferScheduler\";\nexport * from \"#platform/bufferHelpers\";\nexport { createBlobFromData } from \"./bufferHelpers.common.js\";\nexport * from \"#platform/StructuredMessageEncodingStream\";\nexport * from \"#platform/StructuredMessageDecodingStream\";\nexport * from \"./StorageCRC64Calculator.js\";\nexport { getCachedDefaultHttpClient } from \"./cache.js\";\nexport type * from \"#platform/interfaces\";\nexport * from \"./StorageResponseFormat.js\";\n\nexport * from \"./StorageBrowserPolicyFactory.js\";\nexport * from \"./credentials/AnonymousCredential.js\";\nexport * from \"./credentials/Credential.js\";\nexport * from \"#platform/credentials/StorageSharedKeyCredential\";\n\nexport * from \"./StorageRetryPolicyFactory.js\";\nexport { BaseRequestPolicy } from \"./policies/RequestPolicy.js\";\nexport * from \"./policies/AnonymousCredentialPolicy.js\";\nexport * from \"./policies/CredentialPolicy.js\";\nexport * from \"#platform/policies/StorageBrowserPolicyV2\";\nexport * from \"#platform/policies/StorageCorrectContentLengthPolicy\";\nexport * from \"./policies/StorageRetryPolicyV2.js\";\nexport * from \"./policies/StorageSharedKeyCredentialPolicy.js\";\nexport * from \"#platform/policies/StorageSharedKeyCredentialPolicyV2\";\nexport { buildStorageSharedKeyStringToSign } from \"./policies/SharedKeySigning.js\";\nexport * from \"./policies/StorageRedirectRangeHeaderPolicy.js\";\nexport * from \"./policies/StorageRequestFailureDetailsParserPolicy.js\";\nexport * from \"#platform/credentials/UserDelegationKeyCredential\";\nexport type { UserDelegationKey } from \"./credentials/UserDelegationKey.js\";\n\n// Re-export Readable stream type for Node.js (never in browser/react-native)\nexport type { Readable } from \"node:stream\";\n"]}
@@ -1,3 +1,8 @@
1
1
  {
2
- "type": "module"
2
+ "name": "@azure/storage-common",
3
+ "version": "12.6.0-beta.1",
4
+ "type": "module",
5
+ "exports": {
6
+ "./package.json": "./package.json"
7
+ }
3
8
  }
@@ -0,0 +1,32 @@
1
+ import type { PipelineRequest } from "@azure/core-rest-pipeline";
2
+ /**
3
+ * Sets the request headers that participate in the Shared Key signature and are derived from
4
+ * the request itself: `x-ms-date`, and `Content-Length` for a string or Buffer body.
5
+ *
6
+ * `Content-Length` is a signed field: a request with a body whose `Content-Length` isn't set
7
+ * gets a signature the service rejects.
8
+ */
9
+ export declare function prepareSharedKeyHeaders(request: PipelineRequest): void;
10
+ /**
11
+ * Builds the string to sign for the Azure Storage Shared Key authorization scheme.
12
+ *
13
+ * Before building it, sets the request headers that the signature covers and that come from
14
+ * the request itself: `x-ms-date`, and `Content-Length` for a string or Buffer body. Send the
15
+ * request with these headers, since the signature depends on them.
16
+ *
17
+ * @param request - The request to sign. Its `x-ms-date` header is set, and so is its
18
+ * `Content-Length` header when the body is a string or a Buffer.
19
+ * @param accountName - The storage account name used to build the canonicalized resource.
20
+ * @returns The string to sign, ready to be signed with HMAC-SHA256.
21
+ * @see https://learn.microsoft.com/rest/api/storageservices/authorize-with-shared-key
22
+ */
23
+ export declare function buildStorageSharedKeyStringToSign(request: PipelineRequest, accountName: string): string;
24
+ /**
25
+ * Builds the string to sign from the request as it is, without setting any header. For a caller
26
+ * that sets the signed headers itself on the request it sends.
27
+ *
28
+ * @param request - The request whose headers and URL form the string to sign.
29
+ * @param accountName - The storage account name used to build the canonicalized resource.
30
+ */
31
+ export declare function buildStringToSign(request: PipelineRequest, accountName: string): string;
32
+ //# sourceMappingURL=SharedKeySigning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SharedKeySigning.d.ts","sourceRoot":"","sources":["../../../src/policies/SharedKeySigning.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAmHjE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAUtE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,GAClB,MAAM,CAGR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAqBvF"}
@@ -0,0 +1,156 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { HeaderConstants } from "../utils/constants.js";
4
+ import { getURLPath } from "../utils/utils.common.js";
5
+ import { compareHeader } from "../utils/SharedKeyComparator.js";
6
+ /**
7
+ * Retrieve header value according to shared key sign rules.
8
+ * @see https://learn.microsoft.com/rest/api/storageservices/authenticate-with-shared-key
9
+ */
10
+ function getHeaderValueToSign(request, headerName) {
11
+ const value = request.headers.get(headerName);
12
+ if (!value) {
13
+ return "";
14
+ }
15
+ // When using version 2015-02-21 or later, if Content-Length is zero, then
16
+ // set the Content-Length part of the StringToSign to an empty string.
17
+ // https://learn.microsoft.com/rest/api/storageservices/authenticate-with-shared-key
18
+ if (headerName === HeaderConstants.CONTENT_LENGTH && value === "0") {
19
+ return "";
20
+ }
21
+ return value;
22
+ }
23
+ /**
24
+ * To construct the CanonicalizedHeaders portion of the signature string, follow these steps:
25
+ * 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header.
26
+ * 2. Convert each HTTP header name to lowercase.
27
+ * 3. Sort the headers lexicographically by header name, in ascending order.
28
+ * Each header may appear only once in the string.
29
+ * 4. Replace any linear whitespace in the header value with a single space.
30
+ * 5. Trim any whitespace around the colon in the header.
31
+ * 6. Finally, append a new-line character to each canonicalized header in the resulting list.
32
+ * Construct the CanonicalizedHeaders string by concatenating all headers in this list into a single string.
33
+ *
34
+ */
35
+ function getCanonicalizedHeadersString(request) {
36
+ let headersArray = [];
37
+ for (const [name, value] of request.headers) {
38
+ if (name.toLowerCase().startsWith(HeaderConstants.PREFIX_FOR_STORAGE)) {
39
+ headersArray.push({ name, value });
40
+ }
41
+ }
42
+ headersArray.sort((a, b) => {
43
+ return compareHeader(a.name.toLowerCase(), b.name.toLowerCase());
44
+ });
45
+ // Remove duplicate headers
46
+ headersArray = headersArray.filter((value, index, array) => {
47
+ if (index > 0 && value.name.toLowerCase() === array[index - 1].name.toLowerCase()) {
48
+ return false;
49
+ }
50
+ return true;
51
+ });
52
+ let canonicalizedHeadersStringToSign = "";
53
+ headersArray.forEach((header) => {
54
+ canonicalizedHeadersStringToSign += `${header.name
55
+ .toLowerCase()
56
+ .trimRight()}:${header.value.trimLeft()}\n`;
57
+ });
58
+ return canonicalizedHeadersStringToSign;
59
+ }
60
+ function getCanonicalizedResourceString(request, accountName) {
61
+ const path = getURLPath(request.url) || "/";
62
+ let canonicalizedResourceString = "";
63
+ canonicalizedResourceString += `/${accountName}${path}`;
64
+ // A name that repeats, whether spelled identically or differing only by case, contributes all
65
+ // of its values as one sorted, comma-joined line.
66
+ const valuesByKey = getCanonicalizedQueryValues(request.url);
67
+ for (const key of [...valuesByKey.keys()].sort()) {
68
+ canonicalizedResourceString += `\n${key}:${valuesByKey.get(key).sort().join(",")}`;
69
+ }
70
+ return canonicalizedResourceString;
71
+ }
72
+ /**
73
+ * Groups query parameter values by lowercased name. Parses the raw query rather than reusing
74
+ * `getURLQueries`, which keeps only the last value for a repeated name and discards parameters
75
+ * that the service still canonicalizes.
76
+ */
77
+ function getCanonicalizedQueryValues(url) {
78
+ const valuesByKey = new Map();
79
+ const queryString = new URL(url).search.replace(/^\?/, "").trim();
80
+ if (!queryString) {
81
+ return valuesByKey;
82
+ }
83
+ for (const pair of queryString.split("&")) {
84
+ if (!pair) {
85
+ continue;
86
+ }
87
+ // Split at the first "=" only: "=" is legal inside a value, and a name carried without one
88
+ // still participates in the signature.
89
+ const separator = pair.indexOf("=");
90
+ const key = decodeURIComponent(separator === -1 ? pair : pair.substring(0, separator)).toLowerCase();
91
+ const values = valuesByKey.get(key) ?? [];
92
+ values.push(separator === -1 ? "" : decodeURIComponent(pair.substring(separator + 1)));
93
+ valuesByKey.set(key, values);
94
+ }
95
+ return valuesByKey;
96
+ }
97
+ /**
98
+ * Sets the request headers that participate in the Shared Key signature and are derived from
99
+ * the request itself: `x-ms-date`, and `Content-Length` for a string or Buffer body.
100
+ *
101
+ * `Content-Length` is a signed field: a request with a body whose `Content-Length` isn't set
102
+ * gets a signature the service rejects.
103
+ */
104
+ export function prepareSharedKeyHeaders(request) {
105
+ request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());
106
+ if (request.body &&
107
+ (typeof request.body === "string" || Buffer.isBuffer(request.body)) &&
108
+ request.body.length > 0) {
109
+ request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
110
+ }
111
+ }
112
+ /**
113
+ * Builds the string to sign for the Azure Storage Shared Key authorization scheme.
114
+ *
115
+ * Before building it, sets the request headers that the signature covers and that come from
116
+ * the request itself: `x-ms-date`, and `Content-Length` for a string or Buffer body. Send the
117
+ * request with these headers, since the signature depends on them.
118
+ *
119
+ * @param request - The request to sign. Its `x-ms-date` header is set, and so is its
120
+ * `Content-Length` header when the body is a string or a Buffer.
121
+ * @param accountName - The storage account name used to build the canonicalized resource.
122
+ * @returns The string to sign, ready to be signed with HMAC-SHA256.
123
+ * @see https://learn.microsoft.com/rest/api/storageservices/authorize-with-shared-key
124
+ */
125
+ export function buildStorageSharedKeyStringToSign(request, accountName) {
126
+ prepareSharedKeyHeaders(request);
127
+ return buildStringToSign(request, accountName);
128
+ }
129
+ /**
130
+ * Builds the string to sign from the request as it is, without setting any header. For a caller
131
+ * that sets the signed headers itself on the request it sends.
132
+ *
133
+ * @param request - The request whose headers and URL form the string to sign.
134
+ * @param accountName - The storage account name used to build the canonicalized resource.
135
+ */
136
+ export function buildStringToSign(request, accountName) {
137
+ return ([
138
+ request.method.toUpperCase(),
139
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_ENCODING),
140
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_LANGUAGE),
141
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_LENGTH),
142
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_MD5),
143
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_TYPE),
144
+ // Signed requests always carry x-ms-date, which requires this slot to stay empty.
145
+ "",
146
+ getHeaderValueToSign(request, HeaderConstants.IF_MODIFIED_SINCE),
147
+ getHeaderValueToSign(request, HeaderConstants.IF_MATCH),
148
+ getHeaderValueToSign(request, HeaderConstants.IF_NONE_MATCH),
149
+ getHeaderValueToSign(request, HeaderConstants.IF_UNMODIFIED_SINCE),
150
+ getHeaderValueToSign(request, HeaderConstants.RANGE),
151
+ ].join("\n") +
152
+ "\n" +
153
+ getCanonicalizedHeadersString(request) +
154
+ getCanonicalizedResourceString(request, accountName));
155
+ }
156
+ //# sourceMappingURL=SharedKeySigning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SharedKeySigning.js","sourceRoot":"","sources":["../../../src/policies/SharedKeySigning.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE;;;GAGG;AACH,SAAS,oBAAoB,CAAC,OAAwB,EAAE,UAAkB;IACxE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAE9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,0EAA0E;IAC1E,sEAAsE;IACtE,oFAAoF;IACpF,IAAI,UAAU,KAAK,eAAe,CAAC,cAAc,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QACnE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,6BAA6B,CAAC,OAAwB;IAC7D,IAAI,YAAY,GAA2C,EAAE,CAAC;IAC9D,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACtE,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAU,EAAE;QACjC,OAAO,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,C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,eAAe,CAAC,aAAa,CAAC;QAC5D,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,mBAAmB,CAAC;QAClE,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC;KACrD,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,IAAI;QACJ,6BAA6B,CAAC,OAAO,CAAC;QACtC,8BAA8B,CAAC,OAAO,EAAE,WAAW,CAAC,CACrD,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest } from \"@azure/core-rest-pipeline\";\nimport { HeaderConstants } from \"../utils/constants.js\";\nimport { getURLPath } from \"../utils/utils.common.js\";\nimport { compareHeader } from \"../utils/SharedKeyComparator.js\";\n\n/**\n * Retrieve header value according to shared key sign rules.\n * @see https://learn.microsoft.com/rest/api/storageservices/authenticate-with-shared-key\n */\nfunction getHeaderValueToSign(request: PipelineRequest, headerName: string): string {\n const value = request.headers.get(headerName);\n\n if (!value) {\n return \"\";\n }\n\n // When using version 2015-02-21 or later, if Content-Length is zero, then\n // set the Content-Length part of the StringToSign to an empty string.\n // https://learn.microsoft.com/rest/api/storageservices/authenticate-with-shared-key\n if (headerName === HeaderConstants.CONTENT_LENGTH && value === \"0\") {\n return \"\";\n }\n\n return value;\n}\n\n/**\n * To construct the CanonicalizedHeaders portion of the signature string, follow these steps:\n * 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header.\n * 2. Convert each HTTP header name to lowercase.\n * 3. Sort the headers lexicographically by header name, in ascending order.\n * Each header may appear only once in the string.\n * 4. Replace any linear whitespace in the header value with a single space.\n * 5. Trim any whitespace around the colon in the header.\n * 6. Finally, append a new-line character to each canonicalized header in the resulting list.\n * Construct the CanonicalizedHeaders string by concatenating all headers in this list into a single string.\n *\n */\nfunction getCanonicalizedHeadersString(request: PipelineRequest): string {\n let headersArray: Array<{ name: string; value: string }> = [];\n for (const [name, value] of request.headers) {\n if (name.toLowerCase().startsWith(HeaderConstants.PREFIX_FOR_STORAGE)) {\n headersArray.push({ name, value });\n }\n }\n\n headersArray.sort((a, b): number => {\n return compareHeader(a.name.toLowerCase(), b.name.toLowerCase());\n });\n\n // Remove duplicate headers\n headersArray = headersArray.filter((value, index, array) => {\n if (index > 0 && value.name.toLowerCase() === array[index - 1].name.toLowerCase()) {\n return false;\n }\n return true;\n });\n\n let canonicalizedHeadersStringToSign: string = \"\";\n headersArray.forEach((header) => {\n canonicalizedHeadersStringToSign += `${header.name\n .toLowerCase()\n .trimRight()}:${header.value.trimLeft()}\\n`;\n });\n\n return canonicalizedHeadersStringToSign;\n}\n\nfunction getCanonicalizedResourceString(request: PipelineRequest, accountName: string): string {\n const path = getURLPath(request.url) || \"/\";\n\n let canonicalizedResourceString: string = \"\";\n canonicalizedResourceString += `/${accountName}${path}`;\n\n // A name that repeats, whether spelled identically or differing only by case, contributes all\n // of its values as one sorted, comma-joined line.\n const valuesByKey = getCanonicalizedQueryValues(request.url);\n for (const key of [...valuesByKey.keys()].sort()) {\n canonicalizedResourceString += `\\n${key}:${valuesByKey.get(key)!.sort().join(\",\")}`;\n }\n\n return canonicalizedResourceString;\n}\n\n/**\n * Groups query parameter values by lowercased name. Parses the raw query rather than reusing\n * `getURLQueries`, which keeps only the last value for a repeated name and discards parameters\n * that the service still canonicalizes.\n */\nfunction getCanonicalizedQueryValues(url: string): Map<string, string[]> {\n const valuesByKey = new Map<string, string[]>();\n const queryString = new URL(url).search.replace(/^\\?/, \"\").trim();\n if (!queryString) {\n return valuesByKey;\n }\n\n for (const pair of queryString.split(\"&\")) {\n if (!pair) {\n continue;\n }\n\n // Split at the first \"=\" only: \"=\" is legal inside a value, and a name carried without one\n // still participates in the signature.\n const separator = pair.indexOf(\"=\");\n const key = decodeURIComponent(\n separator === -1 ? pair : pair.substring(0, separator),\n ).toLowerCase();\n const values = valuesByKey.get(key) ?? [];\n values.push(separator === -1 ? \"\" : decodeURIComponent(pair.substring(separator + 1)));\n valuesByKey.set(key, values);\n }\n\n return valuesByKey;\n}\n\n/**\n * Sets the request headers that participate in the Shared Key signature and are derived from\n * the request itself: `x-ms-date`, and `Content-Length` for a string or Buffer body.\n *\n * `Content-Length` is a signed field: a request with a body whose `Content-Length` isn't set\n * gets a signature the service rejects.\n */\nexport function prepareSharedKeyHeaders(request: PipelineRequest): void {\n request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());\n\n if (\n request.body &&\n (typeof request.body === \"string\" || Buffer.isBuffer(request.body)) &&\n request.body.length > 0\n ) {\n request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));\n }\n}\n\n/**\n * Builds the string to sign for the Azure Storage Shared Key authorization scheme.\n *\n * Before building it, sets the request headers that the signature covers and that come from\n * the request itself: `x-ms-date`, and `Content-Length` for a string or Buffer body. Send the\n * request with these headers, since the signature depends on them.\n *\n * @param request - The request to sign. Its `x-ms-date` header is set, and so is its\n * `Content-Length` header when the body is a string or a Buffer.\n * @param accountName - The storage account name used to build the canonicalized resource.\n * @returns The string to sign, ready to be signed with HMAC-SHA256.\n * @see https://learn.microsoft.com/rest/api/storageservices/authorize-with-shared-key\n */\nexport function buildStorageSharedKeyStringToSign(\n request: PipelineRequest,\n accountName: string,\n): string {\n prepareSharedKeyHeaders(request);\n return buildStringToSign(request, accountName);\n}\n\n/**\n * Builds the string to sign from the request as it is, without setting any header. For a caller\n * that sets the signed headers itself on the request it sends.\n *\n * @param request - The request whose headers and URL form the string to sign.\n * @param accountName - The storage account name used to build the canonicalized resource.\n */\nexport function buildStringToSign(request: PipelineRequest, accountName: string): string {\n return (\n [\n request.method.toUpperCase(),\n getHeaderValueToSign(request, HeaderConstants.CONTENT_ENCODING),\n getHeaderValueToSign(request, HeaderConstants.CONTENT_LANGUAGE),\n getHeaderValueToSign(request, HeaderConstants.CONTENT_LENGTH),\n getHeaderValueToSign(request, HeaderConstants.CONTENT_MD5),\n getHeaderValueToSign(request, HeaderConstants.CONTENT_TYPE),\n // Signed requests always carry x-ms-date, which requires this slot to stay empty.\n \"\",\n getHeaderValueToSign(request, HeaderConstants.IF_MODIFIED_SINCE),\n getHeaderValueToSign(request, HeaderConstants.IF_MATCH),\n getHeaderValueToSign(request, HeaderConstants.IF_NONE_MATCH),\n getHeaderValueToSign(request, HeaderConstants.IF_UNMODIFIED_SINCE),\n getHeaderValueToSign(request, HeaderConstants.RANGE),\n ].join(\"\\n\") +\n \"\\n\" +\n getCanonicalizedHeadersString(request) +\n getCanonicalizedResourceString(request, accountName)\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { PipelinePolicy } from "@azure/core-rest-pipeline";
2
+ /**
3
+ * Redirects the "range" header to "x-ms-range" for Azure Storage requests as the latter is preferred.
4
+ */
5
+ export declare const storageRedirectRangeHeaderPolicyName = "storageRedirectRangeHeaderPolicy";
6
+ /**
7
+ * StorageRedirectRangeHeaderPolicy
8
+ */
9
+ export declare function storageRedirectRangeHeaderPolicy(): PipelinePolicy;
10
+ //# sourceMappingURL=StorageRedirectRangeHeaderPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageRedirectRangeHeaderPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRedirectRangeHeaderPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,oCAAoC,qCAAqC,CAAC;AAEvF;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,cAAc,CAWjE"}
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Redirects the "range" header to "x-ms-range" for Azure Storage requests as the latter is preferred.
5
+ */
6
+ export const storageRedirectRangeHeaderPolicyName = "storageRedirectRangeHeaderPolicy";
7
+ /**
8
+ * StorageRedirectRangeHeaderPolicy
9
+ */
10
+ export function storageRedirectRangeHeaderPolicy() {
11
+ return {
12
+ name: storageRedirectRangeHeaderPolicyName,
13
+ async sendRequest(request, next) {
14
+ if (request.headers.has("range")) {
15
+ request.headers.set("x-ms-range", request.headers.get("range"));
16
+ request.headers.delete("range");
17
+ }
18
+ return next(request);
19
+ },
20
+ };
21
+ }
22
+ //# sourceMappingURL=StorageRedirectRangeHeaderPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageRedirectRangeHeaderPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRedirectRangeHeaderPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,kCAAkC,CAAC;AAEvF;;GAEG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,oCAAoC;QAC1C,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC,CAAC;gBACjE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * Redirects the \"range\" header to \"x-ms-range\" for Azure Storage requests as the latter is preferred.\n */\nexport const storageRedirectRangeHeaderPolicyName = \"storageRedirectRangeHeaderPolicy\";\n\n/**\n * StorageRedirectRangeHeaderPolicy\n */\nexport function storageRedirectRangeHeaderPolicy(): PipelinePolicy {\n return {\n name: storageRedirectRangeHeaderPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (request.headers.has(\"range\")) {\n request.headers.set(\"x-ms-range\", request.headers.get(\"range\")!);\n request.headers.delete(\"range\");\n }\n return next(request);\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StorageRequestFailureDetailsParserPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,4CAA4C,6CACb,CAAC;AAE7C;;GAEG;AACH,wBAAgB,wCAAwC,IAAI,cAAc,CA0BzE"}
1
+ {"version":3,"file":"StorageRequestFailureDetailsParserPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,4CAA4C,6CACb,CAAC;AAE7C;;GAEG;AACH,wBAAgB,wCAAwC,IAAI,cAAc,CA2CzE"}
@@ -13,6 +13,18 @@ export function storageRequestFailureDetailsParserPolicy() {
13
13
  async sendRequest(request, next) {
14
14
  try {
15
15
  const response = await next(request);
16
+ if (response.status === 400 &&
17
+ response.bodyAsText?.includes("<Error><Code>InvalidHeaderValue</Code>") &&
18
+ response.bodyAsText.includes("<HeaderName>x-ms-version</HeaderName>")) {
19
+ // replace the error message with a more user-friendly one that includes a link to documentation
20
+ /* example response text:
21
+ `<?xml version="1.0" encoding="utf-8"?>
22
+ <Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.
23
+ RequestId:e5ea566c-101e-001c-1ec4-acf180000000
24
+ Time:2026-03-05T17:24:34.6688015Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>3025-01-01</HeaderValue></Error>`
25
+ */
26
+ response.bodyAsText = response.bodyAsText.replace(/<Message>.*<\/Message>/s, "<Message>The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.</Message>");
27
+ }
16
28
  return response;
17
29
  }
18
30
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"StorageRequestFailureDetailsParserPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,CAAC,MAAM,4CAA4C,GACvD,0CAA0C,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,wCAAwC;IACtD,OAAO;QACL,IAAI,EAAE,4CAA4C;QAClD,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrC,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,OAAO,GAAG,KAAK,QAAQ;oBACvB,GAAG,KAAK,IAAI;oBACX,GAAW,CAAC,QAAQ;oBACpB,GAAW,CAAC,QAAQ,CAAC,UAAU,EAChC,CAAC;oBACD,IACG,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,oBAAoB;wBAC7D,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,KAAK,cAAc,EAC9D,CAAC;wBACA,GAAW,CAAC,OAAO;4BAClB,8MAA8M,CAAC;oBACnN,CAAC;gBACH,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the StorageRequestFailureDetailsParserPolicy.\n */\nexport const storageRequestFailureDetailsParserPolicyName =\n \"storageRequestFailureDetailsParserPolicy\";\n\n/**\n * StorageRequestFailureDetailsParserPolicy\n */\nexport function storageRequestFailureDetailsParserPolicy(): PipelinePolicy {\n return {\n name: storageRequestFailureDetailsParserPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n try {\n const response = await next(request);\n return response;\n } catch (err) {\n if (\n typeof err === \"object\" &&\n err !== null &&\n (err as any).response &&\n (err as any).response.parsedBody\n ) {\n if (\n (err as any).response.parsedBody.code === \"InvalidHeaderValue\" &&\n (err as any).response.parsedBody.HeaderName === \"x-ms-version\"\n ) {\n (err as any).message =\n \"The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.\\n\";\n }\n }\n throw err;\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"StorageRequestFailureDetailsParserPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,CAAC,MAAM,4CAA4C,GACvD,0CAA0C,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,wCAAwC;IACtD,OAAO;QACL,IAAI,EAAE,4CAA4C;QAClD,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrC,IACE,QAAQ,CAAC,MAAM,KAAK,GAAG;oBACvB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,wCAAwC,CAAC;oBACvE,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,uCAAuC,CAAC,EACrE,CAAC;oBACD,gGAAgG;oBAChG;;;;;sBAKE;oBACF,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAC/C,yBAAyB,EACzB,+NAA+N,CAChO,CAAC;gBACJ,CAAC;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,OAAO,GAAG,KAAK,QAAQ;oBACvB,GAAG,KAAK,IAAI;oBACX,GAAW,CAAC,QAAQ;oBACpB,GAAW,CAAC,QAAQ,CAAC,UAAU,EAChC,CAAC;oBACD,IACG,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,oBAAoB;wBAC7D,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,KAAK,cAAc,EAC9D,CAAC;wBACA,GAAW,CAAC,OAAO;4BAClB,8MAA8M,CAAC;oBACnN,CAAC;gBACH,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the StorageRequestFailureDetailsParserPolicy.\n */\nexport const storageRequestFailureDetailsParserPolicyName =\n \"storageRequestFailureDetailsParserPolicy\";\n\n/**\n * StorageRequestFailureDetailsParserPolicy\n */\nexport function storageRequestFailureDetailsParserPolicy(): PipelinePolicy {\n return {\n name: storageRequestFailureDetailsParserPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n try {\n const response = await next(request);\n if (\n response.status === 400 &&\n response.bodyAsText?.includes(\"<Error><Code>InvalidHeaderValue</Code>\") &&\n response.bodyAsText.includes(\"<HeaderName>x-ms-version</HeaderName>\")\n ) {\n // replace the error message with a more user-friendly one that includes a link to documentation\n /* example response text:\n `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.\nRequestId:e5ea566c-101e-001c-1ec4-acf180000000\nTime:2026-03-05T17:24:34.6688015Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>3025-01-01</HeaderValue></Error>`\n */\n response.bodyAsText = response.bodyAsText.replace(\n /<Message>.*<\\/Message>/s,\n \"<Message>The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.</Message>\",\n );\n }\n return response;\n } catch (err) {\n if (\n typeof err === \"object\" &&\n err !== null &&\n (err as any).response &&\n (err as any).response.parsedBody\n ) {\n if (\n (err as any).response.parsedBody.code === \"InvalidHeaderValue\" &&\n (err as any).response.parsedBody.HeaderName === \"x-ms-version\"\n ) {\n (err as any).message =\n \"The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.\\n\";\n }\n }\n throw err;\n }\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StorageRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRetryPolicy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,IAAI,oBAAoB,EAChD,oBAAoB,EACpB,eAAe,IAAI,WAAW,EAC9B,cAAc,IAAI,qBAAqB,EACxC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAM3E;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,CAAC,EAAE,mBAAmB,GAAG,oBAAoB,CAM9F;AAcD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IAEnD;;;;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;;;;OAIG;IACU,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI9E;;;;;;;;;OASG;cACa,kBAAkB,CAChC,OAAO,EAAE,WAAW,EACpB,eAAe,EAAE,OAAO,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC;IA0CjC;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACnB,cAAc,EAAE,OAAO,EACvB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,qBAAqB,EAChC,GAAG,CAAC,EAAE,SAAS,GACd,OAAO;IA8EV;;;;;;OAMG;YACW,KAAK;CA0BpB"}
@@ -116,7 +116,7 @@ export class StorageRetryPolicy extends BaseRequestPolicy {
116
116
  }
117
117
  }
118
118
  await this.delay(isPrimaryRetry, attempt, request.abortSignal);
119
- return this.attemptSendRequest(request, secondaryHas404, ++attempt);
119
+ return this.attemptSendRequest(request, secondaryHas404, attempt + 1);
120
120
  }
121
121
  /**
122
122
  * Decide whether to retry according to last HTTP response and retry counters.
@@ -128,8 +128,7 @@ export class StorageRetryPolicy extends BaseRequestPolicy {
128
128
  */
129
129
  shouldRetry(isPrimaryRetry, attempt, response, err) {
130
130
  if (attempt >= this.retryOptions.maxTries) {
131
- logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions
132
- .maxTries}, no further try.`);
131
+ logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions.maxTries}, no further try.`);
133
132
  return false;
134
133
  }
135
134
  // Handle network failures, you may need to customize the list when you implement