@typespec/ts-http-runtime 1.0.0-alpha.20240701.3 → 1.0.0-alpha.20240704.2

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 (174) hide show
  1. package/dist/browser/client/common.d.ts +0 -1
  2. package/dist/browser/client/common.d.ts.map +1 -1
  3. package/dist/browser/interfaces.d.ts +0 -2
  4. package/dist/browser/interfaces.d.ts.map +1 -1
  5. package/dist/browser/util/concat.common.d.ts +0 -1
  6. package/dist/browser/util/concat.common.d.ts.map +1 -1
  7. package/dist/browser/util/file.d.ts +0 -1
  8. package/dist/browser/util/file.d.ts.map +1 -1
  9. package/dist/browser/util/typeGuards.d.ts +0 -1
  10. package/dist/browser/util/typeGuards.d.ts.map +1 -1
  11. package/dist/commonjs/auth/keyCredential.js +1 -2
  12. package/dist/commonjs/auth/keyCredential.js.map +1 -1
  13. package/dist/commonjs/auth/tokenCredential.js +1 -2
  14. package/dist/commonjs/auth/tokenCredential.js.map +1 -1
  15. package/dist/commonjs/client/apiVersionPolicy.js +2 -2
  16. package/dist/commonjs/client/apiVersionPolicy.js.map +1 -1
  17. package/dist/commonjs/client/clientHelpers.js +3 -4
  18. package/dist/commonjs/client/clientHelpers.js.map +1 -1
  19. package/dist/commonjs/client/common.d.ts +0 -1
  20. package/dist/commonjs/client/common.d.ts.map +1 -1
  21. package/dist/commonjs/client/getClient.js +1 -2
  22. package/dist/commonjs/client/getClient.js.map +1 -1
  23. package/dist/commonjs/client/keyCredentialAuthenticationPolicy.js +2 -2
  24. package/dist/commonjs/client/keyCredentialAuthenticationPolicy.js.map +1 -1
  25. package/dist/commonjs/client/multipart.js +2 -3
  26. package/dist/commonjs/client/multipart.js.map +1 -1
  27. package/dist/commonjs/client/operationOptionHelpers.js +1 -2
  28. package/dist/commonjs/client/operationOptionHelpers.js.map +1 -1
  29. package/dist/commonjs/client/restError.js +1 -2
  30. package/dist/commonjs/client/restError.js.map +1 -1
  31. package/dist/commonjs/client/sendRequest.js +1 -2
  32. package/dist/commonjs/client/sendRequest.js.map +1 -1
  33. package/dist/commonjs/client/urlHelpers.js +3 -4
  34. package/dist/commonjs/client/urlHelpers.js.map +1 -1
  35. package/dist/commonjs/createPipelineFromOptions.js +1 -2
  36. package/dist/commonjs/createPipelineFromOptions.js.map +1 -1
  37. package/dist/commonjs/defaultHttpClient.js +1 -2
  38. package/dist/commonjs/defaultHttpClient.js.map +1 -1
  39. package/dist/commonjs/fetchHttpClient.js +1 -2
  40. package/dist/commonjs/fetchHttpClient.js.map +1 -1
  41. package/dist/commonjs/httpHeaders.js +1 -2
  42. package/dist/commonjs/httpHeaders.js.map +1 -1
  43. package/dist/commonjs/interfaces.d.ts +0 -2
  44. package/dist/commonjs/interfaces.d.ts.map +1 -1
  45. package/dist/commonjs/logger/log.common.js +1 -2
  46. package/dist/commonjs/logger/log.common.js.map +1 -1
  47. package/dist/commonjs/logger/log.js +1 -2
  48. package/dist/commonjs/logger/log.js.map +1 -1
  49. package/dist/commonjs/logger/logger.js +4 -4
  50. package/dist/commonjs/logger/logger.js.map +1 -1
  51. package/dist/commonjs/nodeHttpClient.js +2 -3
  52. package/dist/commonjs/nodeHttpClient.js.map +1 -1
  53. package/dist/commonjs/pipeline.js +1 -2
  54. package/dist/commonjs/pipeline.js.map +1 -1
  55. package/dist/commonjs/pipelineRequest.js +1 -2
  56. package/dist/commonjs/pipelineRequest.js.map +1 -1
  57. package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js +2 -2
  58. package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
  59. package/dist/commonjs/policies/decompressResponsePolicy.js +2 -2
  60. package/dist/commonjs/policies/decompressResponsePolicy.js.map +1 -1
  61. package/dist/commonjs/policies/defaultRetryPolicy.js +2 -2
  62. package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -1
  63. package/dist/commonjs/policies/exponentialRetryPolicy.js +2 -2
  64. package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -1
  65. package/dist/commonjs/policies/formDataPolicy.js +2 -2
  66. package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
  67. package/dist/commonjs/policies/logPolicy.js +2 -2
  68. package/dist/commonjs/policies/logPolicy.js.map +1 -1
  69. package/dist/commonjs/policies/multipartPolicy.js +2 -2
  70. package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
  71. package/dist/commonjs/policies/proxyPolicy.common.js +4 -4
  72. package/dist/commonjs/policies/proxyPolicy.common.js.map +1 -1
  73. package/dist/commonjs/policies/proxyPolicy.js +4 -4
  74. package/dist/commonjs/policies/proxyPolicy.js.map +1 -1
  75. package/dist/commonjs/policies/redirectPolicy.js +2 -2
  76. package/dist/commonjs/policies/redirectPolicy.js.map +1 -1
  77. package/dist/commonjs/policies/retryPolicy.js +1 -2
  78. package/dist/commonjs/policies/retryPolicy.js.map +1 -1
  79. package/dist/commonjs/policies/systemErrorRetryPolicy.js +2 -2
  80. package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -1
  81. package/dist/commonjs/policies/throttlingRetryPolicy.js +2 -2
  82. package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -1
  83. package/dist/commonjs/policies/tlsPolicy.js +2 -2
  84. package/dist/commonjs/policies/tlsPolicy.js.map +1 -1
  85. package/dist/commonjs/policies/tracingPolicy.js +2 -2
  86. package/dist/commonjs/policies/tracingPolicy.js.map +1 -1
  87. package/dist/commonjs/policies/userAgentPolicy.js +2 -2
  88. package/dist/commonjs/policies/userAgentPolicy.js.map +1 -1
  89. package/dist/commonjs/restError.js +2 -2
  90. package/dist/commonjs/restError.js.map +1 -1
  91. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +3 -4
  92. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +1 -1
  93. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +2 -3
  94. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +1 -1
  95. package/dist/commonjs/tracing/instrumenter.js +4 -5
  96. package/dist/commonjs/tracing/instrumenter.js.map +1 -1
  97. package/dist/commonjs/tracing/tracingClient.js +1 -2
  98. package/dist/commonjs/tracing/tracingClient.js.map +1 -1
  99. package/dist/commonjs/tracing/tracingContext.js +2 -2
  100. package/dist/commonjs/tracing/tracingContext.js.map +1 -1
  101. package/dist/commonjs/util/aborterUtils.js +1 -2
  102. package/dist/commonjs/util/aborterUtils.js.map +1 -1
  103. package/dist/commonjs/util/bytesEncoding.common.js +10 -11
  104. package/dist/commonjs/util/bytesEncoding.common.js.map +1 -1
  105. package/dist/commonjs/util/bytesEncoding.js +2 -3
  106. package/dist/commonjs/util/bytesEncoding.js.map +1 -1
  107. package/dist/commonjs/util/concat.common.d.ts +0 -1
  108. package/dist/commonjs/util/concat.common.d.ts.map +1 -1
  109. package/dist/commonjs/util/concat.common.js +1 -2
  110. package/dist/commonjs/util/concat.common.js.map +1 -1
  111. package/dist/commonjs/util/concat.d.ts +0 -1
  112. package/dist/commonjs/util/concat.d.ts.map +1 -1
  113. package/dist/commonjs/util/concat.js +1 -2
  114. package/dist/commonjs/util/concat.js.map +1 -1
  115. package/dist/commonjs/util/createAbortablePromise.js +1 -2
  116. package/dist/commonjs/util/createAbortablePromise.js.map +1 -1
  117. package/dist/commonjs/util/delay.js +1 -2
  118. package/dist/commonjs/util/delay.js.map +1 -1
  119. package/dist/commonjs/util/error.js +2 -3
  120. package/dist/commonjs/util/error.js.map +1 -1
  121. package/dist/commonjs/util/file.d.ts +0 -1
  122. package/dist/commonjs/util/file.d.ts.map +1 -1
  123. package/dist/commonjs/util/file.js +3 -4
  124. package/dist/commonjs/util/file.js.map +1 -1
  125. package/dist/commonjs/util/helpers.js +2 -3
  126. package/dist/commonjs/util/helpers.js.map +1 -1
  127. package/dist/commonjs/util/object.js +1 -2
  128. package/dist/commonjs/util/object.js.map +1 -1
  129. package/dist/commonjs/util/random.js +1 -2
  130. package/dist/commonjs/util/random.js.map +1 -1
  131. package/dist/commonjs/util/sha256.common.js +2 -3
  132. package/dist/commonjs/util/sha256.common.js.map +1 -1
  133. package/dist/commonjs/util/sha256.js +2 -3
  134. package/dist/commonjs/util/sha256.js.map +1 -1
  135. package/dist/commonjs/util/tokenCycler.js +2 -2
  136. package/dist/commonjs/util/tokenCycler.js.map +1 -1
  137. package/dist/commonjs/util/typeGuards.d.ts +0 -1
  138. package/dist/commonjs/util/typeGuards.d.ts.map +1 -1
  139. package/dist/commonjs/util/typeGuards.js +8 -9
  140. package/dist/commonjs/util/typeGuards.js.map +1 -1
  141. package/dist/commonjs/util/userAgent.js +2 -3
  142. package/dist/commonjs/util/userAgent.js.map +1 -1
  143. package/dist/commonjs/util/userAgentPlatform.js +2 -3
  144. package/dist/commonjs/util/userAgentPlatform.js.map +1 -1
  145. package/dist/commonjs/util/uuidUtils.common.js +2 -3
  146. package/dist/commonjs/util/uuidUtils.common.js.map +1 -1
  147. package/dist/commonjs/util/uuidUtils.js +1 -2
  148. package/dist/commonjs/util/uuidUtils.js.map +1 -1
  149. package/dist/commonjs/xhrHttpClient.js +1 -2
  150. package/dist/commonjs/xhrHttpClient.js.map +1 -1
  151. package/dist/esm/client/common.d.ts +0 -1
  152. package/dist/esm/client/common.d.ts.map +1 -1
  153. package/dist/esm/interfaces.d.ts +0 -2
  154. package/dist/esm/interfaces.d.ts.map +1 -1
  155. package/dist/esm/util/concat.common.d.ts +0 -1
  156. package/dist/esm/util/concat.common.d.ts.map +1 -1
  157. package/dist/esm/util/concat.d.ts +0 -1
  158. package/dist/esm/util/concat.d.ts.map +1 -1
  159. package/dist/esm/util/file.d.ts +0 -1
  160. package/dist/esm/util/file.d.ts.map +1 -1
  161. package/dist/esm/util/typeGuards.d.ts +0 -1
  162. package/dist/esm/util/typeGuards.d.ts.map +1 -1
  163. package/dist/react-native/client/common.d.ts +0 -1
  164. package/dist/react-native/client/common.d.ts.map +1 -1
  165. package/dist/react-native/interfaces.d.ts +0 -2
  166. package/dist/react-native/interfaces.d.ts.map +1 -1
  167. package/dist/react-native/util/concat.common.d.ts +0 -1
  168. package/dist/react-native/util/concat.common.d.ts.map +1 -1
  169. package/dist/react-native/util/file.d.ts +0 -1
  170. package/dist/react-native/util/file.d.ts.map +1 -1
  171. package/dist/react-native/util/typeGuards.d.ts +0 -1
  172. package/dist/react-native/util/typeGuards.d.ts.map +1 -1
  173. package/dist/ts-http-runtime.d.ts +0 -2
  174. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+DAAmD;AACnD,mDAAuD;AAoCvD,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,KAAK,EAAE,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,EAAE,GAAG,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAkB,MAAM,CAAC,YAAY,CAAC,CAAC;AASvD,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAQ,CAAgB,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,IAAU;IAEV,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AARD,sCAQC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,oBAAoB,CAClC,MAAgE,EAChE,IAAY,EACZ,UAAuC,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CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC;AApBD,gCAoBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isNodeLike } from \"./checkEnvironment.js\";\nimport { isNodeReadableStream } from \"./typeGuards.js\";\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Private symbol used as key on objects created using createFile containing the\n * original source of the file object.\n *\n * This is used in Node to access the original Node stream without using Blob#stream, which\n * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and\n * Readable#to/fromWeb in Node versions we support:\n * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)\n * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)\n *\n * Once these versions are no longer supported, we may be able to stop doing this.\n *\n * @internal\n */\nconst rawContent: unique symbol = Symbol(\"rawContent\");\n\n/**\n * Type signature of a blob-like object with a raw content property.\n */\ninterface RawContent {\n [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;\n}\n\nfunction hasRawContent(x: unknown): x is RawContent {\n return typeof (x as RawContent)[rawContent] === \"function\";\n}\n\n/**\n * Extract the raw content from a given blob-like object. If the input was created using createFile\n * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.\n * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.\n *\n * @internal\n */\nexport function getRawContent(\n blob: Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array {\n if (hasRawContent(blob)) {\n return blob[rawContent]();\n } else {\n return blob.stream();\n }\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => {\n const s = stream();\n if (isNodeReadableStream(s)) {\n throw new Error(\n \"Not supported: a Node stream was provided as input to createFileFromStream.\",\n );\n }\n\n return s;\n },\n [rawContent]: stream,\n } as File & RawContent;\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n if (isNodeLike) {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n [rawContent]: () => content,\n } as File & RawContent;\n } else {\n return new File([content], name, options);\n }\n}\n"]}
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAqFlC,sCAQC;AAmBD,oDAwBC;AAaD,gCAoBC;AAvKD,+DAAmD;AACnD,mDAAuD;AAoCvD,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,KAAK,EAAE,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,EAAE,GAAG,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAkB,MAAM,CAAC,YAAY,CAAC,CAAC;AASvD,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAQ,CAAgB,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,IAAU;IAEV,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,oB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CAAC,OAAO,GACP,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isNodeLike } from \"./checkEnvironment.js\";\nimport { isNodeReadableStream } from \"./typeGuards.js\";\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Private symbol used as key on objects created using createFile containing the\n * original source of the file object.\n *\n * This is used in Node to access the original Node stream without using Blob#stream, which\n * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and\n * Readable#to/fromWeb in Node versions we support:\n * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)\n * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)\n *\n * Once these versions are no longer supported, we may be able to stop doing this.\n *\n * @internal\n */\nconst rawContent: unique symbol = Symbol(\"rawContent\");\n\n/**\n * Type signature of a blob-like object with a raw content property.\n */\ninterface RawContent {\n [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;\n}\n\nfunction hasRawContent(x: unknown): x is RawContent {\n return typeof (x as RawContent)[rawContent] === \"function\";\n}\n\n/**\n * Extract the raw content from a given blob-like object. If the input was created using createFile\n * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.\n * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.\n *\n * @internal\n */\nexport function getRawContent(\n blob: Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array {\n if (hasRawContent(blob)) {\n return blob[rawContent]();\n } else {\n return blob.stream();\n }\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => {\n const s = stream();\n if (isNodeReadableStream(s)) {\n throw new Error(\n \"Not supported: a Node stream was provided as input to createFileFromStream.\",\n );\n }\n\n return s;\n },\n [rawContent]: stream,\n } as File & RawContent;\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n if (isNodeLike) {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n [rawContent]: () => content,\n } as File & RawContent;\n } else {\n return new File([content], name, options);\n }\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.parseHeaderValueAsNumber = exports.delay = void 0;
5
+ exports.delay = delay;
6
+ exports.parseHeaderValueAsNumber = parseHeaderValueAsNumber;
6
7
  const AbortError_js_1 = require("../abort-controller/AbortError.js");
7
8
  const StandardAbortMessage = "The operation was aborted.";
8
9
  /**
@@ -45,7 +46,6 @@ function delay(delayInMs, value, options) {
45
46
  }
46
47
  });
47
48
  }
48
- exports.delay = delay;
49
49
  /**
50
50
  * @internal
51
51
  * @returns the parsed value or undefined if the parsed value is invalid.
@@ -59,5 +59,4 @@ function parseHeaderValueAsNumber(response, headerName) {
59
59
  return;
60
60
  return valueAsNum;
61
61
  }
62
- exports.parseHeaderValueAsNumber = parseHeaderValueAsNumber;
63
62
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/util/helpers.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,qEAA+D;AAI/D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAE1D;;;;;;;;GAQG;AACH,SAAgB,KAAK,CACnB,SAAiB,EACjB,KAAS,EACT,OAGC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,KAAK,GAA8C,SAAS,CAAC;QACjE,IAAI,S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UAAkB;IAElB,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;QAAE,OAAO;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC;AATD,4DASC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError } from \"../abort-controller/AbortError.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { PipelineResponse } from \"../interfaces.js\";\n\nconst StandardAbortMessage = \"The operation was aborted.\";\n\n/**\n * A wrapper for setTimeout that resolves a promise after delayInMs milliseconds.\n * @param delayInMs - The number of milliseconds to be delayed.\n * @param value - The value to be resolved with after a timeout of t milliseconds.\n * @param options - The options for delay - currently abort options\n * - abortSignal - The abortSignal associated with containing operation.\n * - abortErrorMsg - The abort error message associated with containing operation.\n * @returns Resolved promise\n */\nexport function delay<T>(\n delayInMs: number,\n value?: T,\n options?: {\n abortSignal?: AbortSignalLike;\n abortErrorMsg?: string;\n },\n): Promise<T | void> {\n return new Promise((resolve, reject) => {\n let timer: ReturnType<typeof setTimeout> | undefined = undefined;\n let onAborted: (() => void) | undefined = undefined;\n\n const rejectOnAbort = (): void => {\n return reject(\n new AbortError(options?.abortErrorMsg ? options?.abortErrorMsg : StandardAbortMessage),\n );\n };\n\n const removeListeners = (): void => {\n if (options?.abortSignal && onAborted) {\n options.abortSignal.removeEventListener(\"abort\", onAborted);\n }\n };\n\n onAborted = (): void => {\n if (timer) {\n clearTimeout(timer);\n }\n removeListeners();\n return rejectOnAbort();\n };\n\n if (options?.abortSignal && options.abortSignal.aborted) {\n return rejectOnAbort();\n }\n\n timer = setTimeout(() => {\n removeListeners();\n resolve(value);\n }, delayInMs);\n\n if (options?.abortSignal) {\n options.abortSignal.addEventListener(\"abort\", onAborted);\n }\n });\n}\n\n/**\n * @internal\n * @returns the parsed value or undefined if the parsed value is invalid.\n */\nexport function parseHeaderValueAsNumber(\n response: PipelineResponse,\n headerName: string,\n): number | undefined {\n const value = response.headers.get(headerName);\n if (!value) return;\n const valueAsNum = Number(value);\n if (Number.isNaN(valueAsNum)) return;\n return valueAsNum;\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/util/helpers.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAiBlC,sBA6CC;AAMD,4DASC;AA3ED,qEAA+D;AAI/D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAE1D;;;;;;;;GAQG;AACH,SAAgB,KAAK,CACnB,SAAiB,EACjB,KAAS,EACT,OAGC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,KAAK,GAA8C,SAAS,CAAC;QACjE,IAAI,SAAS,GAA6B,SAAS,CAAC;QAEpD,MAAM,aAAa,GAAG,GAAS,EAAE;YAC/B,OAAO,MAAM,CACX,IAAI,0BAAU,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,EAAC,CAAC,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAC,CAAC,CAAC,oBAAoB,CAAC,CACvF,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,GAAS,EAAE;YACjC,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,SAAS,EAAE,CAAC;gBACtC,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC,CAAC;QAEF,SAAS,GAAG,GAAS,EAAE;YACrB,IAAI,KAAK,EAAE,CAAC;gBACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YACD,eAAe,EAAE,CAAC;YAClB,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC;QAEF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACxD,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QAED,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,eAAe,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAE,CAAC;YACzB,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CACtC,QAA0B,EAC1B,UAAkB;IAElB,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;QAAE,OAAO;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError } from \"../abort-controller/AbortError.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { PipelineResponse } from \"../interfaces.js\";\n\nconst StandardAbortMessage = \"The operation was aborted.\";\n\n/**\n * A wrapper for setTimeout that resolves a promise after delayInMs milliseconds.\n * @param delayInMs - The number of milliseconds to be delayed.\n * @param value - The value to be resolved with after a timeout of t milliseconds.\n * @param options - The options for delay - currently abort options\n * - abortSignal - The abortSignal associated with containing operation.\n * - abortErrorMsg - The abort error message associated with containing operation.\n * @returns Resolved promise\n */\nexport function delay<T>(\n delayInMs: number,\n value?: T,\n options?: {\n abortSignal?: AbortSignalLike;\n abortErrorMsg?: string;\n },\n): Promise<T | void> {\n return new Promise((resolve, reject) => {\n let timer: ReturnType<typeof setTimeout> | undefined = undefined;\n let onAborted: (() => void) | undefined = undefined;\n\n const rejectOnAbort = (): void => {\n return reject(\n new AbortError(options?.abortErrorMsg ? options?.abortErrorMsg : StandardAbortMessage),\n );\n };\n\n const removeListeners = (): void => {\n if (options?.abortSignal && onAborted) {\n options.abortSignal.removeEventListener(\"abort\", onAborted);\n }\n };\n\n onAborted = (): void => {\n if (timer) {\n clearTimeout(timer);\n }\n removeListeners();\n return rejectOnAbort();\n };\n\n if (options?.abortSignal && options.abortSignal.aborted) {\n return rejectOnAbort();\n }\n\n timer = setTimeout(() => {\n removeListeners();\n resolve(value);\n }, delayInMs);\n\n if (options?.abortSignal) {\n options.abortSignal.addEventListener(\"abort\", onAborted);\n }\n });\n}\n\n/**\n * @internal\n * @returns the parsed value or undefined if the parsed value is invalid.\n */\nexport function parseHeaderValueAsNumber(\n response: PipelineResponse,\n headerName: string,\n): number | undefined {\n const value = response.headers.get(headerName);\n if (!value) return;\n const valueAsNum = Number(value);\n if (Number.isNaN(valueAsNum)) return;\n return valueAsNum;\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.isObject = void 0;
5
+ exports.isObject = isObject;
6
6
  /**
7
7
  * Helper to determine when an input is a generic JS object.
8
8
  * @returns true when input is an object type that is not null, Array, RegExp, or Date.
@@ -14,5 +14,4 @@ function isObject(input) {
14
14
  !(input instanceof RegExp) &&
15
15
  !(input instanceof Date));
16
16
  }
17
- exports.isObject = isObject;
18
17
  //# sourceMappingURL=object.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/util/object.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAOlC;;;GAGG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC;QAC1B,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC,CACzB,CAAC;AACJ,CAAC;AARD,4BAQC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * A generic shape for a plain JS object.\n */\nexport type UnknownObject = { [s: string]: unknown };\n\n/**\n * Helper to determine when an input is a generic JS object.\n * @returns true when input is an object type that is not null, Array, RegExp, or Date.\n */\nexport function isObject(input: unknown): input is UnknownObject {\n return (\n typeof input === \"object\" &&\n input !== null &&\n !Array.isArray(input) &&\n !(input instanceof RegExp) &&\n !(input instanceof Date)\n );\n}\n"]}
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/util/object.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAWlC,4BAQC;AAZD;;;GAGG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC;QAC1B,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC,CACzB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * A generic shape for a plain JS object.\n */\nexport type UnknownObject = { [s: string]: unknown };\n\n/**\n * Helper to determine when an input is a generic JS object.\n * @returns true when input is an object type that is not null, Array, RegExp, or Date.\n */\nexport function isObject(input: unknown): input is UnknownObject {\n return (\n typeof input === \"object\" &&\n input !== null &&\n !Array.isArray(input) &&\n !(input instanceof RegExp) &&\n !(input instanceof Date)\n );\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getRandomIntegerInclusive = void 0;
5
+ exports.getRandomIntegerInclusive = getRandomIntegerInclusive;
6
6
  /**
7
7
  * Returns a random integer value between a lower and upper bound,
8
8
  * inclusive of both bounds.
@@ -21,5 +21,4 @@ function getRandomIntegerInclusive(min, max) {
21
21
  const offset = Math.floor(Math.random() * (max - min + 1));
22
22
  return offset + min;
23
23
  }
24
- exports.getRandomIntegerInclusive = getRandomIntegerInclusive;
25
24
  //# sourceMappingURL=random.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"random.js","sourceRoot":"","sources":["../../../src/util/random.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CAAC,GAAW,EAAE,GAAW;IAChE,iCAAiC;IACjC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtB,2DAA2D;IAC3D,+EAA+E;IAC/E,yEAAyE;IACzE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,MAAM,GAAG,GAAG,CAAC;AACtB,CAAC;AATD,8DASC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Returns a random integer value between a lower and upper bound,\n * inclusive of both bounds.\n * Note that this uses Math.random and isn't secure. If you need to use\n * this for any kind of security purpose, find a better source of random.\n * @param min - The smallest integer value allowed.\n * @param max - The largest integer value allowed.\n */\nexport function getRandomIntegerInclusive(min: number, max: number): number {\n // Make sure inputs are integers.\n min = Math.ceil(min);\n max = Math.floor(max);\n // Pick a random offset from zero to the size of the range.\n // Since Math.random() can never return 1, we have to make the range one larger\n // in order to be inclusive of the maximum value after we take the floor.\n const offset = Math.floor(Math.random() * (max - min + 1));\n return offset + min;\n}\n"]}
1
+ {"version":3,"file":"random.js","sourceRoot":"","sources":["../../../src/util/random.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAUlC,8DASC;AAjBD;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CAAC,GAAW,EAAE,GAAW;IAChE,iCAAiC;IACjC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtB,2DAA2D;IAC3D,+EAA+E;IAC/E,yEAAyE;IACzE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,MAAM,GAAG,GAAG,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Returns a random integer value between a lower and upper bound,\n * inclusive of both bounds.\n * Note that this uses Math.random and isn't secure. If you need to use\n * this for any kind of security purpose, find a better source of random.\n * @param min - The smallest integer value allowed.\n * @param max - The largest integer value allowed.\n */\nexport function getRandomIntegerInclusive(min: number, max: number): number {\n // Make sure inputs are integers.\n min = Math.ceil(min);\n max = Math.floor(max);\n // Pick a random offset from zero to the size of the range.\n // Since Math.random() can never return 1, we have to make the range one larger\n // in order to be inclusive of the maximum value after we take the floor.\n const offset = Math.floor(Math.random() * (max - min + 1));\n return offset + min;\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.computeSha256Hash = exports.computeSha256Hmac = void 0;
5
+ exports.computeSha256Hmac = computeSha256Hmac;
6
+ exports.computeSha256Hash = computeSha256Hash;
6
7
  const bytesEncoding_js_1 = require("./bytesEncoding.js");
7
8
  let subtleCrypto;
8
9
  /**
@@ -39,7 +40,6 @@ async function computeSha256Hmac(key, stringToSign, encoding) {
39
40
  }, cryptoKey, stringToSignBytes);
40
41
  return (0, bytesEncoding_js_1.uint8ArrayToString)(new Uint8Array(signature), encoding);
41
42
  }
42
- exports.computeSha256Hmac = computeSha256Hmac;
43
43
  /**
44
44
  * Generates a SHA-256 hash.
45
45
  * @param content - The data to be included in the hash.
@@ -50,5 +50,4 @@ async function computeSha256Hash(content, encoding) {
50
50
  const digest = await getCrypto().digest({ name: "SHA-256" }, contentBytes);
51
51
  return (0, bytesEncoding_js_1.uint8ArrayToString)(new Uint8Array(digest), encoding);
52
52
  }
53
- exports.computeSha256Hash = computeSha256Hash;
54
53
  //# sourceMappingURL=sha256.common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sha256.common.js","sourceRoot":"","sources":["../../../src/util/sha256.common.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,yDAA4E;AA6C5E,IAAI,YAAsC,CAAC;AAE3C;;;GAGG;AACH,SAAS,SAAS;IAChB,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IAED,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,YAAoB,EACpB,QAA0B;IAE1B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,IAAA,qCAAkB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,iBAAiB,GAAG,IAAA,qCAAkB,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEpE,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,SAAS,CACtC,KAAK,EACL,QAAQ,EACR;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC1B,EACD,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CACjC;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC1B,EACD,SAAS,EACT,iBAAiB,CAClB,CAAC;IAEF,OAAO,IAAA,qCAAkB,EAAC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;AACjE,CAAC;AA7BD,8CA6BC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA0B;IAE1B,MAAM,YAAY,GAAG,IAAA,qCAAkB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO,IAAA,qCAAkB,EAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AARD,8CAQC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { stringToUint8Array, uint8ArrayToString } from \"./bytesEncoding.js\";\n\n// stubs for browser self.crypto\ninterface JsonWebKey {}\ninterface CryptoKey {}\ntype KeyUsage =\n | \"decrypt\"\n | \"deriveBits\"\n | \"deriveKey\"\n | \"encrypt\"\n | \"sign\"\n | \"unwrapKey\"\n | \"verify\"\n | \"wrapKey\";\ninterface Algorithm {\n name: string;\n}\ninterface SubtleCrypto {\n importKey(\n format: string,\n keyData: JsonWebKey,\n algorithm: HmacImportParams,\n extractable: boolean,\n usage: KeyUsage[],\n ): Promise<CryptoKey>;\n sign(\n algorithm: HmacImportParams,\n key: CryptoKey,\n data: ArrayBufferView | ArrayBuffer,\n ): Promise<ArrayBuffer>;\n digest(algorithm: Algorithm, data: ArrayBufferView | ArrayBuffer): Promise<ArrayBuffer>;\n}\ninterface Crypto {\n readonly subtle: SubtleCrypto;\n getRandomValues<T extends ArrayBufferView | null>(array: T): T;\n}\ndeclare const self: {\n crypto: Crypto;\n};\ninterface HmacImportParams {\n name: string;\n hash: Algorithm;\n length?: number;\n}\n\nlet subtleCrypto: SubtleCrypto | undefined;\n\n/**\n * Returns a cached reference to the Web API crypto.subtle object.\n * @internal\n */\nfunction getCrypto(): SubtleCrypto {\n if (subtleCrypto) {\n return subtleCrypto;\n }\n\n if (!self.crypto || !self.crypto.subtle) {\n throw new Error(\"Your browser environment does not support cryptography functions.\");\n }\n\n subtleCrypto = self.crypto.subtle;\n return subtleCrypto;\n}\n\n/**\n * Generates a SHA-256 HMAC signature.\n * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.\n * @param stringToSign - The data to be signed.\n * @param encoding - The textual encoding to use for the returned HMAC digest.\n */\nexport async function computeSha256Hmac(\n key: string,\n stringToSign: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const crypto = getCrypto();\n const keyBytes = stringToUint8Array(key, \"base64\");\n const stringToSignBytes = stringToUint8Array(stringToSign, \"utf-8\");\n\n const cryptoKey = await crypto.importKey(\n \"raw\",\n keyBytes,\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n false,\n [\"sign\"],\n );\n const signature = await crypto.sign(\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n cryptoKey,\n stringToSignBytes,\n );\n\n return uint8ArrayToString(new Uint8Array(signature), encoding);\n}\n\n/**\n * Generates a SHA-256 hash.\n * @param content - The data to be included in the hash.\n * @param encoding - The textual encoding to use for the returned hash.\n */\nexport async function computeSha256Hash(\n content: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const contentBytes = stringToUint8Array(content, \"utf-8\");\n const digest = await getCrypto().digest({ name: \"SHA-256\" }, contentBytes);\n\n return uint8ArrayToString(new Uint8Array(digest), encoding);\n}\n"]}
1
+ {"version":3,"file":"sha256.common.js","sourceRoot":"","sources":["../../../src/util/sha256.common.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwElC,8CA6BC;AAOD,8CAQC;AAlHD,yDAA4E;AA6C5E,IAAI,YAAsC,CAAC;AAE3C;;;GAGG;AACH,SAAS,SAAS;IAChB,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IAED,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,YAAoB,EACpB,QAA0B;IAE1B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,IAAA,qCAAkB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,iBAAiB,GAAG,IAAA,qCAAkB,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEpE,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,SAAS,CACtC,KAAK,EACL,QAAQ,EACR;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC1B,EACD,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CACjC;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC1B,EACD,SAAS,EACT,iBAAiB,CAClB,CAAC;IAEF,OAAO,IAAA,qCAAkB,EAAC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA0B;IAE1B,MAAM,YAAY,GAAG,IAAA,qCAAkB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO,IAAA,qCAAkB,EAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { stringToUint8Array, uint8ArrayToString } from \"./bytesEncoding.js\";\n\n// stubs for browser self.crypto\ninterface JsonWebKey {}\ninterface CryptoKey {}\ntype KeyUsage =\n | \"decrypt\"\n | \"deriveBits\"\n | \"deriveKey\"\n | \"encrypt\"\n | \"sign\"\n | \"unwrapKey\"\n | \"verify\"\n | \"wrapKey\";\ninterface Algorithm {\n name: string;\n}\ninterface SubtleCrypto {\n importKey(\n format: string,\n keyData: JsonWebKey,\n algorithm: HmacImportParams,\n extractable: boolean,\n usage: KeyUsage[],\n ): Promise<CryptoKey>;\n sign(\n algorithm: HmacImportParams,\n key: CryptoKey,\n data: ArrayBufferView | ArrayBuffer,\n ): Promise<ArrayBuffer>;\n digest(algorithm: Algorithm, data: ArrayBufferView | ArrayBuffer): Promise<ArrayBuffer>;\n}\ninterface Crypto {\n readonly subtle: SubtleCrypto;\n getRandomValues<T extends ArrayBufferView | null>(array: T): T;\n}\ndeclare const self: {\n crypto: Crypto;\n};\ninterface HmacImportParams {\n name: string;\n hash: Algorithm;\n length?: number;\n}\n\nlet subtleCrypto: SubtleCrypto | undefined;\n\n/**\n * Returns a cached reference to the Web API crypto.subtle object.\n * @internal\n */\nfunction getCrypto(): SubtleCrypto {\n if (subtleCrypto) {\n return subtleCrypto;\n }\n\n if (!self.crypto || !self.crypto.subtle) {\n throw new Error(\"Your browser environment does not support cryptography functions.\");\n }\n\n subtleCrypto = self.crypto.subtle;\n return subtleCrypto;\n}\n\n/**\n * Generates a SHA-256 HMAC signature.\n * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.\n * @param stringToSign - The data to be signed.\n * @param encoding - The textual encoding to use for the returned HMAC digest.\n */\nexport async function computeSha256Hmac(\n key: string,\n stringToSign: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const crypto = getCrypto();\n const keyBytes = stringToUint8Array(key, \"base64\");\n const stringToSignBytes = stringToUint8Array(stringToSign, \"utf-8\");\n\n const cryptoKey = await crypto.importKey(\n \"raw\",\n keyBytes,\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n false,\n [\"sign\"],\n );\n const signature = await crypto.sign(\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n cryptoKey,\n stringToSignBytes,\n );\n\n return uint8ArrayToString(new Uint8Array(signature), encoding);\n}\n\n/**\n * Generates a SHA-256 hash.\n * @param content - The data to be included in the hash.\n * @param encoding - The textual encoding to use for the returned hash.\n */\nexport async function computeSha256Hash(\n content: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const contentBytes = stringToUint8Array(content, \"utf-8\");\n const digest = await getCrypto().digest({ name: \"SHA-256\" }, contentBytes);\n\n return uint8ArrayToString(new Uint8Array(digest), encoding);\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.computeSha256Hash = exports.computeSha256Hmac = void 0;
5
+ exports.computeSha256Hmac = computeSha256Hmac;
6
+ exports.computeSha256Hash = computeSha256Hash;
6
7
  const node_crypto_1 = require("node:crypto");
7
8
  /**
8
9
  * Generates a SHA-256 HMAC signature.
@@ -14,7 +15,6 @@ async function computeSha256Hmac(key, stringToSign, encoding) {
14
15
  const decodedKey = Buffer.from(key, "base64");
15
16
  return (0, node_crypto_1.createHmac)("sha256", decodedKey).update(stringToSign).digest(encoding);
16
17
  }
17
- exports.computeSha256Hmac = computeSha256Hmac;
18
18
  /**
19
19
  * Generates a SHA-256 hash.
20
20
  * @param content - The data to be included in the hash.
@@ -23,5 +23,4 @@ exports.computeSha256Hmac = computeSha256Hmac;
23
23
  async function computeSha256Hash(content, encoding) {
24
24
  return (0, node_crypto_1.createHash)("sha256").update(content).digest(encoding);
25
25
  }
26
- exports.computeSha256Hash = computeSha256Hash;
27
26
  //# sourceMappingURL=sha256.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../../src/util/sha256.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,6CAAqD;AAErD;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,YAAoB,EACpB,QAA0B;IAE1B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE9C,OAAO,IAAA,wBAAU,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAChF,CAAC;AARD,8CAQC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA0B;IAE1B,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AALD,8CAKC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHash, createHmac } from \"node:crypto\";\n\n/**\n * Generates a SHA-256 HMAC signature.\n * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.\n * @param stringToSign - The data to be signed.\n * @param encoding - The textual encoding to use for the returned HMAC digest.\n */\nexport async function computeSha256Hmac(\n key: string,\n stringToSign: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const decodedKey = Buffer.from(key, \"base64\");\n\n return createHmac(\"sha256\", decodedKey).update(stringToSign).digest(encoding);\n}\n\n/**\n * Generates a SHA-256 hash.\n * @param content - The data to be included in the hash.\n * @param encoding - The textual encoding to use for the returned hash.\n */\nexport async function computeSha256Hash(\n content: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n return createHash(\"sha256\").update(content).digest(encoding);\n}\n"]}
1
+ {"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../../src/util/sha256.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAUlC,8CAQC;AAOD,8CAKC;AA5BD,6CAAqD;AAErD;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,YAAoB,EACpB,QAA0B;IAE1B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE9C,OAAO,IAAA,wBAAU,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA0B;IAE1B,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHash, createHmac } from \"node:crypto\";\n\n/**\n * Generates a SHA-256 HMAC signature.\n * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.\n * @param stringToSign - The data to be signed.\n * @param encoding - The textual encoding to use for the returned HMAC digest.\n */\nexport async function computeSha256Hmac(\n key: string,\n stringToSign: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const decodedKey = Buffer.from(key, \"base64\");\n\n return createHmac(\"sha256\", decodedKey).update(stringToSign).digest(encoding);\n}\n\n/**\n * Generates a SHA-256 hash.\n * @param content - The data to be included in the hash.\n * @param encoding - The textual encoding to use for the returned hash.\n */\nexport async function computeSha256Hash(\n content: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n return createHash(\"sha256\").update(content).digest(encoding);\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.createTokenCycler = exports.DEFAULT_CYCLER_OPTIONS = void 0;
5
+ exports.DEFAULT_CYCLER_OPTIONS = void 0;
6
+ exports.createTokenCycler = createTokenCycler;
6
7
  const helpers_js_1 = require("./helpers.js");
7
8
  // Default options for the cycler if none are provided
8
9
  exports.DEFAULT_CYCLER_OPTIONS = {
@@ -157,5 +158,4 @@ function createTokenCycler(credential, tokenCyclerOptions) {
157
158
  return token;
158
159
  };
159
160
  }
160
- exports.createTokenCycler = createTokenCycler;
161
161
  //# sourceMappingURL=tokenCycler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokenCycler.js","sourceRoot":"","sources":["../../../src/util/tokenCycler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kC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sEAAsE;gBACtE,qEAAqE;gBACrE,mBAAmB;gBACnB,aAAa,GAAG,IAAI,CAAC;gBACrB,KAAK,GAAG,IAAI,CAAC;gBACb,QAAQ,GAAG,SAAS,CAAC;gBACrB,MAAM,MAAM,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,aAAqC,CAAC;IAC/C,CAAC;IAED,OAAO,KAAK,EAAE,MAAyB,EAAE,YAA6B,EAAwB,EAAE;QAC9F,EAAE;QACF,gBAAgB;QAChB,+DAA+D;QAC/D,6CAA6C;QAC7C,+DAA+D;QAC/D,yCAAyC;QACzC,6DAA6D;QAC7D,YAAY;QACZ,EAAE;QAEF,MAAM,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,eAAe,GAAG,QAAQ,KAAK,YAAY,CAAC,QAAQ,CAAC;QAE3D,IAAI,iBAAiB,EAAE,CAAC;YACtB,oEAAoE;YACpE,iGAAiG;YACjG,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QAED,0EAA0E;QAC1E,kHAAkH;QAClH,oDAAoD;QACpD,MAAM,WAAW,GAAG,eAAe,IAAI,iBAAiB,IAAI,MAAM,CAAC,WAAW,CAAC;QAE/E,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,KAAoB,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AAzHD,8CAyHC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken, GetTokenOptions, TokenCredential } from \"../auth/tokenCredential.js\";\nimport { delay } from \"./helpers.js\";\n\n/**\n * A function that gets a promise of an access token and allows providing\n * options.\n *\n * @param options - the options to pass to the underlying token provider\n */\nexport type AccessTokenGetter = (\n scopes: string | string[],\n options: GetTokenOptions,\n) => Promise<AccessToken>;\n\nexport interface TokenCyclerOptions {\n /**\n * The window of time before token expiration during which the token will be\n * considered unusable due to risk of the token expiring before sending the\n * request.\n *\n * This will only become meaningful if the refresh fails for over\n * (refreshWindow - forcedRefreshWindow) milliseconds.\n */\n forcedRefreshWindowInMs: number;\n /**\n * Interval in milliseconds to retry failed token refreshes.\n */\n retryIntervalInMs: number;\n /**\n * The window of time before token expiration during which\n * we will attempt to refresh the token.\n */\n refreshWindowInMs: number;\n}\n\n// Default options for the cycler if none are provided\nexport const DEFAULT_CYCLER_OPTIONS: TokenCyclerOptions = {\n forcedRefreshWindowInMs: 1000, // Force waiting for a refresh 1s before the token expires\n retryIntervalInMs: 3000, // Allow refresh attempts every 3s\n refreshWindowInMs: 1000 * 60 * 2, // Start refreshing 2m before expiry\n};\n\n/**\n * Converts an an unreliable access token getter (which may resolve with null)\n * into an AccessTokenGetter by retrying the unreliable getter in a regular\n * interval.\n *\n * @param getAccessToken - A function that produces a promise of an access token that may fail by returning null.\n * @param retryIntervalInMs - The time (in milliseconds) to wait between retry attempts.\n * @param refreshTimeout - The timestamp after which the refresh attempt will fail, throwing an exception.\n * @returns - A promise that, if it resolves, will resolve with an access token.\n */\nasync function beginRefresh(\n getAccessToken: () => Promise<AccessToken | null>,\n retryIntervalInMs: number,\n refreshTimeout: number,\n): Promise<AccessToken> {\n // This wrapper handles exceptions gracefully as long as we haven't exceeded\n // the timeout.\n async function tryGetAccessToken(): Promise<AccessToken | null> {\n if (Date.now() < refreshTimeout) {\n try {\n return await getAccessToken();\n } catch {\n return null;\n }\n } else {\n const finalToken = await getAccessToken();\n\n // Timeout is up, so throw if it's still null\n if (finalToken === null) {\n throw new Error(\"Failed to refresh access token.\");\n }\n\n return finalToken;\n }\n }\n\n let token: AccessToken | null = await tryGetAccessToken();\n\n while (token === null) {\n await delay(retryIntervalInMs);\n\n token = await tryGetAccessToken();\n }\n\n return token;\n}\n\n/**\n * Creates a token cycler from a credential, scopes, and optional settings.\n *\n * A token cycler represents a way to reliably retrieve a valid access token\n * from a TokenCredential. It will handle initializing the token, refreshing it\n * when it nears expiration, and synchronizes refresh attempts to avoid\n * concurrency hazards.\n *\n * @param credential - the underlying TokenCredential that provides the access\n * token\n * @param tokenCyclerOptions - optionally override default settings for the cycler\n *\n * @returns - a function that reliably produces a valid access token\n */\nexport function createTokenCycler(\n credential: TokenCredential,\n tokenCyclerOptions?: Partial<TokenCyclerOptions>,\n): AccessTokenGetter {\n let refreshWorker: Promise<AccessToken> | null = null;\n let token: AccessToken | null = null;\n let tenantId: string | undefined;\n\n const options = {\n ...DEFAULT_CYCLER_OPTIONS,\n ...tokenCyclerOptions,\n };\n\n /**\n * This little holder defines several predicates that we use to construct\n * the rules of refreshing the token.\n */\n const cycler = {\n /**\n * Produces true if a refresh job is currently in progress.\n */\n get isRefreshing(): boolean {\n return refreshWorker !== null;\n },\n /**\n * Produces true if the cycler SHOULD refresh (we are within the refresh\n * window and not already refreshing)\n */\n get shouldRefresh(): boolean {\n return (\n !cycler.isRefreshing &&\n (token?.expiresOnTimestamp ?? 0) - options.refreshWindowInMs < Date.now()\n );\n },\n /**\n * Produces true if the cycler MUST refresh (null or nearly-expired\n * token).\n */\n get mustRefresh(): boolean {\n return (\n token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now()\n );\n },\n };\n\n /**\n * Starts a refresh job or returns the existing job if one is already\n * running.\n */\n function refresh(\n scopes: string | string[],\n getTokenOptions: GetTokenOptions,\n ): Promise<AccessToken> {\n if (!cycler.isRefreshing) {\n // We bind `scopes` here to avoid passing it around a lot\n const tryGetAccessToken = (): Promise<AccessToken | null> =>\n credential.getToken(scopes, getTokenOptions);\n\n // Take advantage of promise chaining to insert an assignment to `token`\n // before the refresh can be considered done.\n refreshWorker = beginRefresh(\n tryGetAccessToken,\n options.retryIntervalInMs,\n // If we don't have a token, then we should timeout immediately\n token?.expiresOnTimestamp ?? Date.now(),\n )\n .then((_token) => {\n refreshWorker = null;\n token = _token;\n tenantId = getTokenOptions.tenantId;\n return token;\n })\n .catch((reason) => {\n // We also should reset the refresher if we enter a failed state. All\n // existing awaiters will throw, but subsequent requests will start a\n // new retry chain.\n refreshWorker = null;\n token = null;\n tenantId = undefined;\n throw reason;\n });\n }\n\n return refreshWorker as Promise<AccessToken>;\n }\n\n return async (scopes: string | string[], tokenOptions: GetTokenOptions): Promise<AccessToken> => {\n //\n // Simple rules:\n // - If we MUST refresh, then return the refresh task, blocking\n // the pipeline until a token is available.\n // - If we SHOULD refresh, then run refresh but don't return it\n // (we can still use the cached token).\n // - Return the token, since it's fine if we didn't return in\n // step 1.\n //\n\n const hasClaimChallenge = Boolean(tokenOptions.claims);\n const tenantIdChanged = tenantId !== tokenOptions.tenantId;\n\n if (hasClaimChallenge) {\n // If we've received a claim, we know the existing token isn't valid\n // We want to clear it so that that refresh worker won't use the old expiration time as a timeout\n token = null;\n }\n\n // If the tenantId passed in token options is different to the one we have\n // Or if we are in claim challenge and the token was rejected and a new access token need to be issued, we need to\n // refresh the token with the new tenantId or token.\n const mustRefresh = tenantIdChanged || hasClaimChallenge || cycler.mustRefresh;\n\n if (mustRefresh) {\n return refresh(scopes, tokenOptions);\n }\n\n if (cycler.shouldRefresh) {\n refresh(scopes, tokenOptions);\n }\n\n return token as AccessToken;\n };\n}\n"]}
1
+ {"version":3,"file":"tokenCycler.js","sourceRoot":"","sources":["../../../src/util/tokenCycler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAyGlC,8CAyHC;AA/ND,6CAAqC;AAkCrC,sDAAsD;AACzC,QAAA,sBAAsB,GAAuB;IACxD,uBAAuB,EAAE,IAAI,EAAE,0DAA0D;IACzF,iBAAiB,EAAE,IAAI,EAAE,kCAAkC;IAC3D,iBAAiB,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,oCAAoC;CACvE,CAAC;AAEF;;;;;;;;;GASG;AACH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MAAyB,EAAE,YAA6B,EAAwB,EAAE;QAC9F,EAAE;QACF,gBAAgB;QAChB,+DAA+D;QAC/D,6CAA6C;QAC7C,+DAA+D;QAC/D,yCAAyC;QACzC,6DAA6D;QAC7D,YAAY;QACZ,EAAE;QAEF,MAAM,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,eAAe,GAAG,QAAQ,KAAK,YAAY,CAAC,QAAQ,CAAC;QAE3D,IAAI,iBAAiB,EAAE,CAAC;YACtB,oEAAoE;YACpE,iGAAiG;YACjG,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QAED,0EAA0E;QAC1E,kHAAkH;QAClH,oDAAoD;QACpD,MAAM,WAAW,GAAG,eAAe,IAAI,iBAAiB,IAAI,MAAM,CAAC,WAAW,CAAC;QAE/E,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,KAAoB,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken, GetTokenOptions, TokenCredential } from \"../auth/tokenCredential.js\";\nimport { delay } from \"./helpers.js\";\n\n/**\n * A function that gets a promise of an access token and allows providing\n * options.\n *\n * @param options - the options to pass to the underlying token provider\n */\nexport type AccessTokenGetter = (\n scopes: string | string[],\n options: GetTokenOptions,\n) => Promise<AccessToken>;\n\nexport interface TokenCyclerOptions {\n /**\n * The window of time before token expiration during which the token will be\n * considered unusable due to risk of the token expiring before sending the\n * request.\n *\n * This will only become meaningful if the refresh fails for over\n * (refreshWindow - forcedRefreshWindow) milliseconds.\n */\n forcedRefreshWindowInMs: number;\n /**\n * Interval in milliseconds to retry failed token refreshes.\n */\n retryIntervalInMs: number;\n /**\n * The window of time before token expiration during which\n * we will attempt to refresh the token.\n */\n refreshWindowInMs: number;\n}\n\n// Default options for the cycler if none are provided\nexport const DEFAULT_CYCLER_OPTIONS: TokenCyclerOptions = {\n forcedRefreshWindowInMs: 1000, // Force waiting for a refresh 1s before the token expires\n retryIntervalInMs: 3000, // Allow refresh attempts every 3s\n refreshWindowInMs: 1000 * 60 * 2, // Start refreshing 2m before expiry\n};\n\n/**\n * Converts an an unreliable access token getter (which may resolve with null)\n * into an AccessTokenGetter by retrying the unreliable getter in a regular\n * interval.\n *\n * @param getAccessToken - A function that produces a promise of an access token that may fail by returning null.\n * @param retryIntervalInMs - The time (in milliseconds) to wait between retry attempts.\n * @param refreshTimeout - The timestamp after which the refresh attempt will fail, throwing an exception.\n * @returns - A promise that, if it resolves, will resolve with an access token.\n */\nasync function beginRefresh(\n getAccessToken: () => Promise<AccessToken | null>,\n retryIntervalInMs: number,\n refreshTimeout: number,\n): Promise<AccessToken> {\n // This wrapper handles exceptions gracefully as long as we haven't exceeded\n // the timeout.\n async function tryGetAccessToken(): Promise<AccessToken | null> {\n if (Date.now() < refreshTimeout) {\n try {\n return await getAccessToken();\n } catch {\n return null;\n }\n } else {\n const finalToken = await getAccessToken();\n\n // Timeout is up, so throw if it's still null\n if (finalToken === null) {\n throw new Error(\"Failed to refresh access token.\");\n }\n\n return finalToken;\n }\n }\n\n let token: AccessToken | null = await tryGetAccessToken();\n\n while (token === null) {\n await delay(retryIntervalInMs);\n\n token = await tryGetAccessToken();\n }\n\n return token;\n}\n\n/**\n * Creates a token cycler from a credential, scopes, and optional settings.\n *\n * A token cycler represents a way to reliably retrieve a valid access token\n * from a TokenCredential. It will handle initializing the token, refreshing it\n * when it nears expiration, and synchronizes refresh attempts to avoid\n * concurrency hazards.\n *\n * @param credential - the underlying TokenCredential that provides the access\n * token\n * @param tokenCyclerOptions - optionally override default settings for the cycler\n *\n * @returns - a function that reliably produces a valid access token\n */\nexport function createTokenCycler(\n credential: TokenCredential,\n tokenCyclerOptions?: Partial<TokenCyclerOptions>,\n): AccessTokenGetter {\n let refreshWorker: Promise<AccessToken> | null = null;\n let token: AccessToken | null = null;\n let tenantId: string | undefined;\n\n const options = {\n ...DEFAULT_CYCLER_OPTIONS,\n ...tokenCyclerOptions,\n };\n\n /**\n * This little holder defines several predicates that we use to construct\n * the rules of refreshing the token.\n */\n const cycler = {\n /**\n * Produces true if a refresh job is currently in progress.\n */\n get isRefreshing(): boolean {\n return refreshWorker !== null;\n },\n /**\n * Produces true if the cycler SHOULD refresh (we are within the refresh\n * window and not already refreshing)\n */\n get shouldRefresh(): boolean {\n return (\n !cycler.isRefreshing &&\n (token?.expiresOnTimestamp ?? 0) - options.refreshWindowInMs < Date.now()\n );\n },\n /**\n * Produces true if the cycler MUST refresh (null or nearly-expired\n * token).\n */\n get mustRefresh(): boolean {\n return (\n token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now()\n );\n },\n };\n\n /**\n * Starts a refresh job or returns the existing job if one is already\n * running.\n */\n function refresh(\n scopes: string | string[],\n getTokenOptions: GetTokenOptions,\n ): Promise<AccessToken> {\n if (!cycler.isRefreshing) {\n // We bind `scopes` here to avoid passing it around a lot\n const tryGetAccessToken = (): Promise<AccessToken | null> =>\n credential.getToken(scopes, getTokenOptions);\n\n // Take advantage of promise chaining to insert an assignment to `token`\n // before the refresh can be considered done.\n refreshWorker = beginRefresh(\n tryGetAccessToken,\n options.retryIntervalInMs,\n // If we don't have a token, then we should timeout immediately\n token?.expiresOnTimestamp ?? Date.now(),\n )\n .then((_token) => {\n refreshWorker = null;\n token = _token;\n tenantId = getTokenOptions.tenantId;\n return token;\n })\n .catch((reason) => {\n // We also should reset the refresher if we enter a failed state. All\n // existing awaiters will throw, but subsequent requests will start a\n // new retry chain.\n refreshWorker = null;\n token = null;\n tenantId = undefined;\n throw reason;\n });\n }\n\n return refreshWorker as Promise<AccessToken>;\n }\n\n return async (scopes: string | string[], tokenOptions: GetTokenOptions): Promise<AccessToken> => {\n //\n // Simple rules:\n // - If we MUST refresh, then return the refresh task, blocking\n // the pipeline until a token is available.\n // - If we SHOULD refresh, then run refresh but don't return it\n // (we can still use the cached token).\n // - Return the token, since it's fine if we didn't return in\n // step 1.\n //\n\n const hasClaimChallenge = Boolean(tokenOptions.claims);\n const tenantIdChanged = tenantId !== tokenOptions.tenantId;\n\n if (hasClaimChallenge) {\n // If we've received a claim, we know the existing token isn't valid\n // We want to clear it so that that refresh worker won't use the old expiration time as a timeout\n token = null;\n }\n\n // If the tenantId passed in token options is different to the one we have\n // Or if we are in claim challenge and the token was rejected and a new access token need to be issued, we need to\n // refresh the token with the new tenantId or token.\n const mustRefresh = tenantIdChanged || hasClaimChallenge || cycler.mustRefresh;\n\n if (mustRefresh) {\n return refresh(scopes, tokenOptions);\n }\n\n if (cycler.shouldRefresh) {\n refresh(scopes, tokenOptions);\n }\n\n return token as AccessToken;\n };\n}\n"]}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * Helper TypeGuard that checks if something is defined or not.
4
3
  * @param thing - Anything
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":";AAGA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,SAAS,MAAM,EACvE,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,YAAY,EAAE,GACzB,KAAK,IAAI,KAAK,GAAG,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,CAYhD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,SAAS,MAAM,EAClE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,GACr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AC,CAIhD;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,cAAc,CAE3E;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,cAAc,CAMnE;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,GACZ,IAAI,IACH,UAAU,GACV,MAAM,CAAC,cAAc,GACrB,cAAc,CAAC,UAAU,CAAC,GAC1B,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,GAC7B,CAAC,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC,GAClC,IAAI,CAQP;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,cAAc,GAAG,MAAM,CAAC,cAAc,CAExF;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,IAAI,CAE5C"}
@@ -2,7 +2,14 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.isBlob = exports.isReadableStream = exports.isBinaryBody = exports.isWebReadableStream = exports.isNodeReadableStream = exports.objectHasProperty = exports.isObjectWithProperties = exports.isDefined = void 0;
5
+ exports.isDefined = isDefined;
6
+ exports.isObjectWithProperties = isObjectWithProperties;
7
+ exports.objectHasProperty = objectHasProperty;
8
+ exports.isNodeReadableStream = isNodeReadableStream;
9
+ exports.isWebReadableStream = isWebReadableStream;
10
+ exports.isBinaryBody = isBinaryBody;
11
+ exports.isReadableStream = isReadableStream;
12
+ exports.isBlob = isBlob;
6
13
  /**
7
14
  * Helper TypeGuard that checks if something is defined or not.
8
15
  * @param thing - Anything
@@ -10,7 +17,6 @@ exports.isBlob = exports.isReadableStream = exports.isBinaryBody = exports.isWeb
10
17
  function isDefined(thing) {
11
18
  return typeof thing !== "undefined" && thing !== null;
12
19
  }
13
- exports.isDefined = isDefined;
14
20
  /**
15
21
  * Helper TypeGuard that checks if the input is an object with the specified properties.
16
22
  * @param thing - Anything.
@@ -27,7 +33,6 @@ function isObjectWithProperties(thing, properties) {
27
33
  }
28
34
  return true;
29
35
  }
30
- exports.isObjectWithProperties = isObjectWithProperties;
31
36
  /**
32
37
  * Helper TypeGuard that checks if the input is an object with the specified property.
33
38
  * @param thing - Any object.
@@ -36,17 +41,14 @@ exports.isObjectWithProperties = isObjectWithProperties;
36
41
  function objectHasProperty(thing, property) {
37
42
  return (isDefined(thing) && typeof thing === "object" && property in thing);
38
43
  }
39
- exports.objectHasProperty = objectHasProperty;
40
44
  function isNodeReadableStream(x) {
41
45
  return Boolean(x && typeof x["pipe"] === "function");
42
46
  }
43
- exports.isNodeReadableStream = isNodeReadableStream;
44
47
  function isWebReadableStream(x) {
45
48
  return Boolean(x &&
46
49
  typeof x.getReader === "function" &&
47
50
  typeof x.tee === "function");
48
51
  }
49
- exports.isWebReadableStream = isWebReadableStream;
50
52
  function isBinaryBody(body) {
51
53
  return (body !== undefined &&
52
54
  (body instanceof Uint8Array ||
@@ -54,13 +56,10 @@ function isBinaryBody(body) {
54
56
  typeof body === "function" ||
55
57
  body instanceof Blob));
56
58
  }
57
- exports.isBinaryBody = isBinaryBody;
58
59
  function isReadableStream(x) {
59
60
  return isNodeReadableStream(x) || isWebReadableStream(x);
60
61
  }
61
- exports.isReadableStream = isReadableStream;
62
62
  function isBlob(x) {
63
63
  return typeof x.stream === "function";
64
64
  }
65
- exports.isBlob = isBlob;
66
65
  //# sourceMappingURL=typeGuards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;GAGG;AACH,SAAgB,SAAS,CAAI,KAA2B;IACtD,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,CAAC;AACxD,CAAC;AAFD,8BAEC;AAED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,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAFD,4CAEC;AAED,SAAgB,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAQ,CAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAClD,CAAC;AAFD,wBAEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helper TypeGuard that checks if something is defined or not.\n * @param thing - Anything\n */\nexport function isDefined<T>(thing: T | undefined | null): thing is T {\n return typeof thing !== \"undefined\" && thing !== null;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified properties.\n * @param thing - Anything.\n * @param properties - The name of the properties that should appear in the object.\n */\nexport function isObjectWithProperties<Thing, PropertyName extends string>(\n thing: Thing,\n properties: PropertyName[],\n): thing is Thing & Record<PropertyName, unknown> {\n if (!isDefined(thing) || typeof thing !== \"object\") {\n return false;\n }\n\n for (const property of properties) {\n if (!objectHasProperty(thing, property)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified property.\n * @param thing - Any object.\n * @param property - The name of the property that should appear in the object.\n */\nexport function objectHasProperty<Thing, PropertyName extends string>(\n thing: Thing,\n property: PropertyName,\n): thing is Thing & Record<PropertyName, unknown> {\n return (\n isDefined(thing) && typeof thing === \"object\" && property in (thing as Record<string, unknown>)\n );\n}\n\nexport function isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream {\n return Boolean(x && typeof (x as NodeJS.ReadableStream)[\"pipe\"] === \"function\");\n}\n\nexport function isWebReadableStream(x: unknown): x is ReadableStream {\n return Boolean(\n x &&\n typeof (x as ReadableStream).getReader === \"function\" &&\n typeof (x as ReadableStream).tee === \"function\",\n );\n}\n\nexport function isBinaryBody(\n body: unknown,\n): body is\n | Uint8Array\n | NodeJS.ReadableStream\n | ReadableStream<Uint8Array>\n | (() => NodeJS.ReadableStream)\n | (() => ReadableStream<Uint8Array>)\n | Blob {\n return (\n body !== undefined &&\n (body instanceof Uint8Array ||\n isReadableStream(body) ||\n typeof body === \"function\" ||\n body instanceof Blob)\n );\n}\n\nexport function isReadableStream(x: unknown): x is ReadableStream | NodeJS.ReadableStream {\n return isNodeReadableStream(x) || isWebReadableStream(x);\n}\n\nexport function isBlob(x: unknown): x is Blob {\n return typeof (x as Blob).stream === \"function\";\n}\n"]}
1
+ {"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAMlC,8BAEC;AAOD,wDAeC;AAOD,8CAOC;AAED,oDAEC;AAED,kDAMC;AAED,oCAgBC;AAED,4CAEC;AAED,wBAEC;AAhFD;;;GAGG;AACH,SAAgB,SAAS,CAAI,KAA2B;IACtD,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,KAAY,EACZ,UAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAC/B,KAAY,EACZ,QAAsB;IAEtB,OAAO,CACL,SAAS,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAK,KAAiC,CAChG,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAAC,CAAU;IAC7C,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CAA2B,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AAClF,CAAC;AAED,SAAgB,mBAAmB,CAAC,CAAU;IAC5C,OAAO,OAAO,CACZ,CAAC;QACC,OAAQ,CAAoB,CAAC,SAAS,KAAK,UAAU;QACrD,OAAQ,CAAoB,CAAC,GAAG,KAAK,UAAU,CAClD,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY,CAC1B,IAAa;IAQb,OAAO,CACL,IAAI,KAAK,SAAS;QAClB,CAAC,IAAI,YAAY,UAAU;YACzB,gBAAgB,CAAC,IAAI,CAAC;YACtB,OAAO,IAAI,KAAK,UAAU;YAC1B,IAAI,YAAY,IAAI,CAAC,CACxB,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,CAAU;IACzC,OAAO,oBAAoB,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAQ,CAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAClD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helper TypeGuard that checks if something is defined or not.\n * @param thing - Anything\n */\nexport function isDefined<T>(thing: T | undefined | null): thing is T {\n return typeof thing !== \"undefined\" && thing !== null;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified properties.\n * @param thing - Anything.\n * @param properties - The name of the properties that should appear in the object.\n */\nexport function isObjectWithProperties<Thing, PropertyName extends string>(\n thing: Thing,\n properties: PropertyName[],\n): thing is Thing & Record<PropertyName, unknown> {\n if (!isDefined(thing) || typeof thing !== \"object\") {\n return false;\n }\n\n for (const property of properties) {\n if (!objectHasProperty(thing, property)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified property.\n * @param thing - Any object.\n * @param property - The name of the property that should appear in the object.\n */\nexport function objectHasProperty<Thing, PropertyName extends string>(\n thing: Thing,\n property: PropertyName,\n): thing is Thing & Record<PropertyName, unknown> {\n return (\n isDefined(thing) && typeof thing === \"object\" && property in (thing as Record<string, unknown>)\n );\n}\n\nexport function isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream {\n return Boolean(x && typeof (x as NodeJS.ReadableStream)[\"pipe\"] === \"function\");\n}\n\nexport function isWebReadableStream(x: unknown): x is ReadableStream {\n return Boolean(\n x &&\n typeof (x as ReadableStream).getReader === \"function\" &&\n typeof (x as ReadableStream).tee === \"function\",\n );\n}\n\nexport function isBinaryBody(\n body: unknown,\n): body is\n | Uint8Array\n | NodeJS.ReadableStream\n | ReadableStream<Uint8Array>\n | (() => NodeJS.ReadableStream)\n | (() => ReadableStream<Uint8Array>)\n | Blob {\n return (\n body !== undefined &&\n (body instanceof Uint8Array ||\n isReadableStream(body) ||\n typeof body === \"function\" ||\n body instanceof Blob)\n );\n}\n\nexport function isReadableStream(x: unknown): x is ReadableStream | NodeJS.ReadableStream {\n return isNodeReadableStream(x) || isWebReadableStream(x);\n}\n\nexport function isBlob(x: unknown): x is Blob {\n return typeof (x as Blob).stream === \"function\";\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getUserAgentValue = exports.getUserAgentHeaderName = void 0;
5
+ exports.getUserAgentHeaderName = getUserAgentHeaderName;
6
+ exports.getUserAgentValue = getUserAgentValue;
6
7
  const userAgentPlatform_js_1 = require("./userAgentPlatform.js");
7
8
  const constants_js_1 = require("../constants.js");
8
9
  function getUserAgentString(telemetryInfo) {
@@ -19,7 +20,6 @@ function getUserAgentString(telemetryInfo) {
19
20
  function getUserAgentHeaderName() {
20
21
  return (0, userAgentPlatform_js_1.getHeaderName)();
21
22
  }
22
- exports.getUserAgentHeaderName = getUserAgentHeaderName;
23
23
  /**
24
24
  * @internal
25
25
  */
@@ -31,5 +31,4 @@ async function getUserAgentValue(prefix) {
31
31
  const userAgentValue = prefix ? `${prefix} ${defaultAgent}` : defaultAgent;
32
32
  return userAgentValue;
33
33
  }
34
- exports.getUserAgentValue = getUserAgentValue;
35
34
  //# sourceMappingURL=userAgent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"userAgent.js","sourceRoot":"","sources":["../../../src/util/userAgent.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iEAAgF;AAChF,kDAA8C;AAE9C,SAAS,kBAAkB,CAAC,aAAkC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,aAAa,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB;IACpC,OAAO,IAAA,oCAAa,GAAE,CAAC;AACzB,CAAC;AAFD,wDAEC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB,CAAC,MAAe;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,WAAW,CAAC,GAAG,CAAC,iBAAiB,EAAE,0BAAW,CAAC,CAAC;IAChD,MAAM,IAAA,8CAAuB,EAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3E,OAAO,cAAc,CAAC;AACxB,CAAC;AAPD,8CAOC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getHeaderName, setPlatformSpecificData } from \"./userAgentPlatform.js\";\nimport { SDK_VERSION } from \"../constants.js\";\n\nfunction getUserAgentString(telemetryInfo: Map<string, string>): string {\n const parts: string[] = [];\n for (const [key, value] of telemetryInfo) {\n const token = value ? `${key}/${value}` : key;\n parts.push(token);\n }\n return parts.join(\" \");\n}\n\n/**\n * @internal\n */\nexport function getUserAgentHeaderName(): string {\n return getHeaderName();\n}\n\n/**\n * @internal\n */\nexport async function getUserAgentValue(prefix?: string): Promise<string> {\n const runtimeInfo = new Map<string, string>();\n runtimeInfo.set(\"ts-http-runtime\", SDK_VERSION);\n await setPlatformSpecificData(runtimeInfo);\n const defaultAgent = getUserAgentString(runtimeInfo);\n const userAgentValue = prefix ? `${prefix} ${defaultAgent}` : defaultAgent;\n return userAgentValue;\n}\n"]}
1
+ {"version":3,"file":"userAgent.js","sourceRoot":"","sources":["../../../src/util/userAgent.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAiBlC,wDAEC;AAKD,8CAOC;AA7BD,iEAAgF;AAChF,kDAA8C;AAE9C,SAAS,kBAAkB,CAAC,aAAkC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,aAAa,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB;IACpC,OAAO,IAAA,oCAAa,GAAE,CAAC;AACzB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB,CAAC,MAAe;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,WAAW,CAAC,GAAG,CAAC,iBAAiB,EAAE,0BAAW,CAAC,CAAC;IAChD,MAAM,IAAA,8CAAuB,EAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3E,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getHeaderName, setPlatformSpecificData } from \"./userAgentPlatform.js\";\nimport { SDK_VERSION } from \"../constants.js\";\n\nfunction getUserAgentString(telemetryInfo: Map<string, string>): string {\n const parts: string[] = [];\n for (const [key, value] of telemetryInfo) {\n const token = value ? `${key}/${value}` : key;\n parts.push(token);\n }\n return parts.join(\" \");\n}\n\n/**\n * @internal\n */\nexport function getUserAgentHeaderName(): string {\n return getHeaderName();\n}\n\n/**\n * @internal\n */\nexport async function getUserAgentValue(prefix?: string): Promise<string> {\n const runtimeInfo = new Map<string, string>();\n runtimeInfo.set(\"ts-http-runtime\", SDK_VERSION);\n await setPlatformSpecificData(runtimeInfo);\n const defaultAgent = getUserAgentString(runtimeInfo);\n const userAgentValue = prefix ? `${prefix} ${defaultAgent}` : defaultAgent;\n return userAgentValue;\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.setPlatformSpecificData = exports.getHeaderName = void 0;
5
+ exports.getHeaderName = getHeaderName;
6
+ exports.setPlatformSpecificData = setPlatformSpecificData;
6
7
  const tslib_1 = require("tslib");
7
8
  const os = tslib_1.__importStar(require("node:os"));
8
9
  const process = tslib_1.__importStar(require("node:process"));
@@ -12,7 +13,6 @@ const process = tslib_1.__importStar(require("node:process"));
12
13
  function getHeaderName() {
13
14
  return "User-Agent";
14
15
  }
15
- exports.getHeaderName = getHeaderName;
16
16
  /**
17
17
  * @internal
18
18
  */
@@ -31,5 +31,4 @@ async function setPlatformSpecificData(map) {
31
31
  }
32
32
  map.set("OS", `(${os.arch()}-${os.type()}-${os.release()})`);
33
33
  }
34
- exports.setPlatformSpecificData = setPlatformSpecificData;
35
34
  //# sourceMappingURL=userAgentPlatform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"userAgentPlatform.js","sourceRoot":"","sources":["../../../src/util/userAgentPlatform.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,oDAA8B;AAC9B,8DAAwC;AAUxC;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,sCAEC;AAED;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAAC,GAAwB;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAoC,CAAC;QAC9D,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;YACjB,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC/D,CAAC;AAbD,0DAaC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as os from \"node:os\";\nimport * as process from \"node:process\";\n\n/**\n * @internal\n */\ninterface ExtendedPlatformVersions extends NodeJS.ProcessVersions {\n bun?: string;\n deno?: string;\n}\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"User-Agent\";\n}\n\n/**\n * @internal\n */\nexport async function setPlatformSpecificData(map: Map<string, string>): Promise<void> {\n if (process && process.versions) {\n const versions = process.versions as ExtendedPlatformVersions;\n if (versions.bun) {\n map.set(\"Bun\", versions.bun);\n } else if (versions.deno) {\n map.set(\"Deno\", versions.deno);\n } else if (versions.node) {\n map.set(\"Node\", versions.node);\n }\n }\n\n map.set(\"OS\", `(${os.arch()}-${os.type()}-${os.release()})`);\n}\n"]}
1
+ {"version":3,"file":"userAgentPlatform.js","sourceRoot":"","sources":["../../../src/util/userAgentPlatform.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAgBlC,sCAEC;AAKD,0DAaC;;AAlCD,oDAA8B;AAC9B,8DAAwC;AAUxC;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAAC,GAAwB;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAoC,CAAC;QAC9D,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;YACjB,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as os from \"node:os\";\nimport * as process from \"node:process\";\n\n/**\n * @internal\n */\ninterface ExtendedPlatformVersions extends NodeJS.ProcessVersions {\n bun?: string;\n deno?: string;\n}\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"User-Agent\";\n}\n\n/**\n * @internal\n */\nexport async function setPlatformSpecificData(map: Map<string, string>): Promise<void> {\n if (process && process.versions) {\n const versions = process.versions as ExtendedPlatformVersions;\n if (versions.bun) {\n map.set(\"Bun\", versions.bun);\n } else if (versions.deno) {\n map.set(\"Deno\", versions.deno);\n } else if (versions.node) {\n map.set(\"Node\", versions.node);\n }\n }\n\n map.set(\"OS\", `(${os.arch()}-${os.type()}-${os.release()})`);\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.randomUUID = exports.generateUUID = void 0;
5
+ exports.generateUUID = generateUUID;
6
+ exports.randomUUID = randomUUID;
6
7
  /*
7
8
  * NOTE: When moving this file, please update "react-native" section in package.json.
8
9
  */
@@ -35,7 +36,6 @@ function generateUUID() {
35
36
  }
36
37
  return uuid;
37
38
  }
38
- exports.generateUUID = generateUUID;
39
39
  /**
40
40
  * Generated Universally Unique Identifier
41
41
  *
@@ -44,5 +44,4 @@ exports.generateUUID = generateUUID;
44
44
  function randomUUID() {
45
45
  return generateUUID();
46
46
  }
47
- exports.randomUUID = randomUUID;
48
47
  //# sourceMappingURL=uuidUtils.common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uuidUtils.common.js","sourceRoot":"","sources":["../../../src/util/uuidUtils.common.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AAEH;;;;GAIG;AACH,SAAgB,YAAY;IAC1B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,4CAA4C;QAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACpD,iDAAiD;QACjD,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACb,IAAI,IAAI,GAAG,CAAC;QACd,CAAC;aAAM,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACpB,oDAAoD;YACpD,IAAI,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,oDAAoD;YACpD,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,8DAA8D;QAC9D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YAChD,IAAI,IAAI,GAAG,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AArBD,oCAqBC;AAED;;;;GAIG;AACH,SAAgB,UAAU;IACxB,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC;AAFD,gCAEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/*\n * NOTE: When moving this file, please update \"react-native\" section in package.json.\n */\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function generateUUID(): string {\n let uuid = \"\";\n for (let i = 0; i < 32; i++) {\n // Generate a random number between 0 and 15\n const randomNumber = Math.floor(Math.random() * 16);\n // Set the UUID version to 4 in the 13th position\n if (i === 12) {\n uuid += \"4\";\n } else if (i === 16) {\n // Set the UUID variant to \"10\" in the 17th position\n uuid += (randomNumber & 0x3) | 0x8;\n } else {\n // Add a random hexadecimal digit to the UUID string\n uuid += randomNumber.toString(16);\n }\n // Add hyphens to the UUID string at the appropriate positions\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n uuid += \"-\";\n }\n }\n return uuid;\n}\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function randomUUID(): string {\n return generateUUID();\n}\n"]}
1
+ {"version":3,"file":"uuidUtils.common.js","sourceRoot":"","sources":["../../../src/util/uuidUtils.common.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAWlC,oCAqBC;AAOD,gCAEC;AAvCD;;GAEG;AAEH;;;;GAIG;AACH,SAAgB,YAAY;IAC1B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,4CAA4C;QAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACpD,iDAAiD;QACjD,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACb,IAAI,IAAI,GAAG,CAAC;QACd,CAAC;aAAM,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACpB,oDAAoD;YACpD,IAAI,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,oDAAoD;YACpD,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,8DAA8D;QAC9D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YAChD,IAAI,IAAI,GAAG,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU;IACxB,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/*\n * NOTE: When moving this file, please update \"react-native\" section in package.json.\n */\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function generateUUID(): string {\n let uuid = \"\";\n for (let i = 0; i < 32; i++) {\n // Generate a random number between 0 and 15\n const randomNumber = Math.floor(Math.random() * 16);\n // Set the UUID version to 4 in the 13th position\n if (i === 12) {\n uuid += \"4\";\n } else if (i === 16) {\n // Set the UUID variant to \"10\" in the 17th position\n uuid += (randomNumber & 0x3) | 0x8;\n } else {\n // Add a random hexadecimal digit to the UUID string\n uuid += randomNumber.toString(16);\n }\n // Add hyphens to the UUID string at the appropriate positions\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n uuid += \"-\";\n }\n }\n return uuid;\n}\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function randomUUID(): string {\n return generateUUID();\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  // Licensed under the MIT license.
4
4
  var _a;
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.randomUUID = void 0;
6
+ exports.randomUUID = randomUUID;
7
7
  const node_crypto_1 = require("node:crypto");
8
8
  const uuidUtils_common_js_1 = require("./uuidUtils.common.js");
9
9
  // NOTE: This is a workaround until we can use `globalThis.crypto.randomUUID` in Node.js 19+.
@@ -22,5 +22,4 @@ if (!uuidFunction) {
22
22
  function randomUUID() {
23
23
  return uuidFunction();
24
24
  }
25
- exports.randomUUID = randomUUID;
26
25
  //# sourceMappingURL=uuidUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uuidUtils.js","sourceRoot":"","sources":["../../../src/util/uuidUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,6CAAyD;AACzD,+DAAqD;AAUrD,6FAA6F;AAC7F,IAAI,YAAY,GACd,OAAO,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,UAAU,CAAA,KAAK,UAAU;IAClD,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IACtD,CAAC,CAAC,wBAAY,CAAC;AAEnB,gDAAgD;AAChD,IAAI,CAAC,YAAY,EAAE,CAAC;IAClB,YAAY,GAAG,kCAAY,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU;IACxB,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC;AAFD,gCAEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { randomUUID as v4RandomUUID } from \"node:crypto\";\nimport { generateUUID } from \"./uuidUtils.common.js\";\n\ninterface Crypto {\n randomUUID(): string;\n}\n\ndeclare const globalThis: {\n crypto: Crypto;\n};\n\n// NOTE: This is a workaround until we can use `globalThis.crypto.randomUUID` in Node.js 19+.\nlet uuidFunction =\n typeof globalThis?.crypto?.randomUUID === \"function\"\n ? globalThis.crypto.randomUUID.bind(globalThis.crypto)\n : v4RandomUUID;\n\n// Not defined in earlier versions of Node.js 14\nif (!uuidFunction) {\n uuidFunction = generateUUID;\n}\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function randomUUID(): string {\n return uuidFunction();\n}\n"]}
1
+ {"version":3,"file":"uuidUtils.js","sourceRoot":"","sources":["../../../src/util/uuidUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA6BlC,gCAEC;AA7BD,6CAAyD;AACzD,+DAAqD;AAUrD,6FAA6F;AAC7F,IAAI,YAAY,GACd,OAAO,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,UAAU,CAAA,KAAK,UAAU;IAClD,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IACtD,CAAC,CAAC,wBAAY,CAAC;AAEnB,gDAAgD;AAChD,IAAI,CAAC,YAAY,EAAE,CAAC;IAClB,YAAY,GAAG,kCAAY,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU;IACxB,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { randomUUID as v4RandomUUID } from \"node:crypto\";\nimport { generateUUID } from \"./uuidUtils.common.js\";\n\ninterface Crypto {\n randomUUID(): string;\n}\n\ndeclare const globalThis: {\n crypto: Crypto;\n};\n\n// NOTE: This is a workaround until we can use `globalThis.crypto.randomUUID` in Node.js 19+.\nlet uuidFunction =\n typeof globalThis?.crypto?.randomUUID === \"function\"\n ? globalThis.crypto.randomUUID.bind(globalThis.crypto)\n : v4RandomUUID;\n\n// Not defined in earlier versions of Node.js 14\nif (!uuidFunction) {\n uuidFunction = generateUUID;\n}\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function randomUUID(): string {\n return uuidFunction();\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.createXhrHttpClient = void 0;
5
+ exports.createXhrHttpClient = createXhrHttpClient;
6
6
  const AbortError_js_1 = require("./abort-controller/AbortError.js");
7
7
  const httpHeaders_js_1 = require("./httpHeaders.js");
8
8
  const restError_js_1 = require("./restError.js");
@@ -167,5 +167,4 @@ function rejectOnTerminalEvent(request, xhr, reject) {
167
167
  function createXhrHttpClient() {
168
168
  return new XhrHttpClient();
169
169
  }
170
- exports.createXhrHttpClient = createXhrHttpClient;
171
170
  //# sourceMappingURL=xhrHttpClient.js.map