@typespec/ts-http-runtime 0.3.5-alpha.20260310.2 → 0.3.5

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 (230) hide show
  1. package/dist/browser/client/multipart.js.map +1 -1
  2. package/dist/browser/client/sendRequest.js +12 -4
  3. package/dist/browser/client/sendRequest.js.map +1 -1
  4. package/dist/browser/client/urlHelpers.js +9 -3
  5. package/dist/browser/client/urlHelpers.js.map +1 -1
  6. package/dist/browser/fetchHttpClient.d.ts +5 -0
  7. package/dist/browser/fetchHttpClient.js.map +1 -1
  8. package/dist/browser/logger/logger.js.map +1 -1
  9. package/dist/browser/policies/retryPolicy.js +4 -3
  10. package/dist/browser/policies/retryPolicy.js.map +1 -1
  11. package/dist/browser/util/concat.d.ts +16 -1
  12. package/dist/browser/util/concat.js +55 -1
  13. package/dist/browser/util/concat.js.map +1 -1
  14. package/dist/browser/util/sanitizer.js +3 -3
  15. package/dist/browser/util/sanitizer.js.map +1 -1
  16. package/dist/browser/util/typeGuards.js +2 -2
  17. package/dist/browser/util/typeGuards.js.map +1 -1
  18. package/dist/browser/util/userAgentPlatform.d.ts +28 -0
  19. package/dist/browser/util/userAgentPlatform.js +9 -10
  20. package/dist/browser/util/userAgentPlatform.js.map +1 -1
  21. package/dist/browser/util/uuidUtils.common.js +1 -1
  22. package/dist/browser/util/uuidUtils.common.js.map +1 -1
  23. package/dist/commonjs/abort-controller/AbortError.js +1 -0
  24. package/dist/commonjs/abort-controller/AbortError.js.map +1 -1
  25. package/dist/commonjs/auth/credentials.js +1 -0
  26. package/dist/commonjs/auth/credentials.js.map +1 -1
  27. package/dist/commonjs/auth/oauth2Flows.js +1 -0
  28. package/dist/commonjs/auth/oauth2Flows.js.map +1 -1
  29. package/dist/commonjs/auth/schemes.js +1 -0
  30. package/dist/commonjs/auth/schemes.js.map +1 -1
  31. package/dist/commonjs/client/apiVersionPolicy.js +1 -0
  32. package/dist/commonjs/client/apiVersionPolicy.js.map +1 -1
  33. package/dist/commonjs/client/clientHelpers.js +1 -0
  34. package/dist/commonjs/client/clientHelpers.js.map +1 -1
  35. package/dist/commonjs/client/common.js +1 -0
  36. package/dist/commonjs/client/common.js.map +1 -1
  37. package/dist/commonjs/client/getClient.js +1 -0
  38. package/dist/commonjs/client/getClient.js.map +1 -1
  39. package/dist/commonjs/client/multipart.js +1 -0
  40. package/dist/commonjs/client/multipart.js.map +3 -3
  41. package/dist/commonjs/client/operationOptionHelpers.js +1 -0
  42. package/dist/commonjs/client/operationOptionHelpers.js.map +1 -1
  43. package/dist/commonjs/client/restError.js +1 -0
  44. package/dist/commonjs/client/restError.js.map +1 -1
  45. package/dist/commonjs/client/sendRequest.js +13 -2
  46. package/dist/commonjs/client/sendRequest.js.map +3 -3
  47. package/dist/commonjs/client/urlHelpers.js +7 -3
  48. package/dist/commonjs/client/urlHelpers.js.map +3 -3
  49. package/dist/commonjs/constants.js +1 -0
  50. package/dist/commonjs/constants.js.map +1 -1
  51. package/dist/commonjs/createPipelineFromOptions.js +1 -0
  52. package/dist/commonjs/createPipelineFromOptions.js.map +1 -1
  53. package/dist/commonjs/defaultHttpClient.js +1 -0
  54. package/dist/commonjs/defaultHttpClient.js.map +1 -1
  55. package/dist/commonjs/fetchHttpClient.d.ts +5 -0
  56. package/dist/commonjs/fetchHttpClient.js +1 -0
  57. package/dist/commonjs/fetchHttpClient.js.map +3 -3
  58. package/dist/commonjs/httpHeaders.js +1 -0
  59. package/dist/commonjs/httpHeaders.js.map +1 -1
  60. package/dist/commonjs/index.js +1 -0
  61. package/dist/commonjs/index.js.map +1 -1
  62. package/dist/commonjs/interfaces.js +1 -0
  63. package/dist/commonjs/interfaces.js.map +1 -1
  64. package/dist/commonjs/log.js +1 -0
  65. package/dist/commonjs/log.js.map +1 -1
  66. package/dist/commonjs/logger/debug.js +1 -0
  67. package/dist/commonjs/logger/debug.js.map +1 -1
  68. package/dist/commonjs/logger/internal.js +1 -0
  69. package/dist/commonjs/logger/internal.js.map +1 -1
  70. package/dist/commonjs/logger/log.common.js +1 -0
  71. package/dist/commonjs/logger/log.common.js.map +1 -1
  72. package/dist/commonjs/logger/log.js +1 -0
  73. package/dist/commonjs/logger/log.js.map +1 -1
  74. package/dist/commonjs/logger/logger.js +1 -0
  75. package/dist/commonjs/logger/logger.js.map +3 -3
  76. package/dist/commonjs/nodeHttpClient.js +1 -0
  77. package/dist/commonjs/nodeHttpClient.js.map +1 -1
  78. package/dist/commonjs/pipeline.js +1 -0
  79. package/dist/commonjs/pipeline.js.map +1 -1
  80. package/dist/commonjs/pipelineRequest.js +1 -0
  81. package/dist/commonjs/pipelineRequest.js.map +1 -1
  82. package/dist/commonjs/policies/agentPolicy.js +1 -0
  83. package/dist/commonjs/policies/agentPolicy.js.map +1 -1
  84. package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js +1 -0
  85. package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -1
  86. package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js +1 -0
  87. package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +1 -1
  88. package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js +1 -0
  89. package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js.map +1 -1
  90. package/dist/commonjs/policies/auth/checkInsecureConnection.js +1 -0
  91. package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +1 -1
  92. package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js +1 -0
  93. package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js.map +1 -1
  94. package/dist/commonjs/policies/decompressResponsePolicy.js +1 -0
  95. package/dist/commonjs/policies/decompressResponsePolicy.js.map +1 -1
  96. package/dist/commonjs/policies/defaultRetryPolicy.js +1 -0
  97. package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -1
  98. package/dist/commonjs/policies/exponentialRetryPolicy.js +1 -0
  99. package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -1
  100. package/dist/commonjs/policies/formDataPolicy.js +1 -0
  101. package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
  102. package/dist/commonjs/policies/internal.js +1 -0
  103. package/dist/commonjs/policies/internal.js.map +1 -1
  104. package/dist/commonjs/policies/logPolicy.js +1 -0
  105. package/dist/commonjs/policies/logPolicy.js.map +1 -1
  106. package/dist/commonjs/policies/multipartPolicy.js +1 -0
  107. package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
  108. package/dist/commonjs/policies/proxyPolicy.common.js +1 -0
  109. package/dist/commonjs/policies/proxyPolicy.common.js.map +1 -1
  110. package/dist/commonjs/policies/proxyPolicy.js +3 -3
  111. package/dist/commonjs/policies/proxyPolicy.js.map +3 -3
  112. package/dist/commonjs/policies/redirectPolicy.js +1 -0
  113. package/dist/commonjs/policies/redirectPolicy.js.map +1 -1
  114. package/dist/commonjs/policies/retryPolicy.js +5 -3
  115. package/dist/commonjs/policies/retryPolicy.js.map +3 -3
  116. package/dist/commonjs/policies/systemErrorRetryPolicy.js +1 -0
  117. package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -1
  118. package/dist/commonjs/policies/throttlingRetryPolicy.js +1 -0
  119. package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -1
  120. package/dist/commonjs/policies/tlsPolicy.js +1 -0
  121. package/dist/commonjs/policies/tlsPolicy.js.map +1 -1
  122. package/dist/commonjs/policies/userAgentPolicy.js +1 -0
  123. package/dist/commonjs/policies/userAgentPolicy.js.map +1 -1
  124. package/dist/commonjs/restError.js +1 -0
  125. package/dist/commonjs/restError.js.map +1 -1
  126. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +1 -0
  127. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +1 -1
  128. package/dist/commonjs/retryStrategies/retryStrategy.js +1 -0
  129. package/dist/commonjs/retryStrategies/retryStrategy.js.map +1 -1
  130. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +1 -0
  131. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +1 -1
  132. package/dist/commonjs/tsdoc-metadata.json +1 -1
  133. package/dist/commonjs/util/arrayBuffer.js +1 -0
  134. package/dist/commonjs/util/arrayBuffer.js.map +1 -1
  135. package/dist/commonjs/util/bytesEncoding.common.js +1 -0
  136. package/dist/commonjs/util/bytesEncoding.common.js.map +1 -1
  137. package/dist/commonjs/util/bytesEncoding.js +1 -0
  138. package/dist/commonjs/util/bytesEncoding.js.map +1 -1
  139. package/dist/commonjs/util/checkEnvironment.js +1 -0
  140. package/dist/commonjs/util/checkEnvironment.js.map +1 -1
  141. package/dist/commonjs/util/concat.js +1 -0
  142. package/dist/commonjs/util/concat.js.map +1 -1
  143. package/dist/commonjs/util/delay.js +1 -0
  144. package/dist/commonjs/util/delay.js.map +1 -1
  145. package/dist/commonjs/util/error.js +1 -0
  146. package/dist/commonjs/util/error.js.map +1 -1
  147. package/dist/commonjs/util/helpers.js +1 -0
  148. package/dist/commonjs/util/helpers.js.map +1 -1
  149. package/dist/commonjs/util/inspect.common.js +1 -0
  150. package/dist/commonjs/util/inspect.common.js.map +1 -1
  151. package/dist/commonjs/util/inspect.js +1 -0
  152. package/dist/commonjs/util/inspect.js.map +1 -1
  153. package/dist/commonjs/util/internal.js +1 -0
  154. package/dist/commonjs/util/internal.js.map +1 -1
  155. package/dist/commonjs/util/object.js +1 -0
  156. package/dist/commonjs/util/object.js.map +1 -1
  157. package/dist/commonjs/util/random.js +1 -0
  158. package/dist/commonjs/util/random.js.map +1 -1
  159. package/dist/commonjs/util/sanitizer.js +4 -3
  160. package/dist/commonjs/util/sanitizer.js.map +3 -3
  161. package/dist/commonjs/util/sha256.common.js +1 -0
  162. package/dist/commonjs/util/sha256.common.js.map +1 -1
  163. package/dist/commonjs/util/sha256.js +1 -0
  164. package/dist/commonjs/util/sha256.js.map +1 -1
  165. package/dist/commonjs/util/typeGuards.js +3 -2
  166. package/dist/commonjs/util/typeGuards.js.map +3 -3
  167. package/dist/commonjs/util/userAgent.js +1 -0
  168. package/dist/commonjs/util/userAgent.js.map +1 -1
  169. package/dist/commonjs/util/userAgentPlatform.d.ts +8 -0
  170. package/dist/commonjs/util/userAgentPlatform.js +7 -7
  171. package/dist/commonjs/util/userAgentPlatform.js.map +3 -3
  172. package/dist/commonjs/util/uuidUtils.common.js +2 -1
  173. package/dist/commonjs/util/uuidUtils.common.js.map +3 -3
  174. package/dist/commonjs/util/uuidUtils.js +1 -0
  175. package/dist/commonjs/util/uuidUtils.js.map +1 -1
  176. package/dist/commonjs/xhrHttpClient.js +1 -0
  177. package/dist/commonjs/xhrHttpClient.js.map +1 -1
  178. package/dist/esm/client/multipart.js.map +1 -1
  179. package/dist/esm/client/sendRequest.js +12 -4
  180. package/dist/esm/client/sendRequest.js.map +1 -1
  181. package/dist/esm/client/urlHelpers.js +9 -3
  182. package/dist/esm/client/urlHelpers.js.map +1 -1
  183. package/dist/esm/fetchHttpClient.d.ts +5 -0
  184. package/dist/esm/fetchHttpClient.js.map +1 -1
  185. package/dist/esm/logger/logger.js.map +1 -1
  186. package/dist/esm/policies/proxyPolicy.js +2 -3
  187. package/dist/esm/policies/proxyPolicy.js.map +1 -1
  188. package/dist/esm/policies/retryPolicy.js +4 -3
  189. package/dist/esm/policies/retryPolicy.js.map +1 -1
  190. package/dist/esm/util/sanitizer.js +3 -3
  191. package/dist/esm/util/sanitizer.js.map +1 -1
  192. package/dist/esm/util/typeGuards.js +2 -2
  193. package/dist/esm/util/typeGuards.js.map +1 -1
  194. package/dist/esm/util/userAgentPlatform.d.ts +8 -0
  195. package/dist/esm/util/userAgentPlatform.js +6 -7
  196. package/dist/esm/util/userAgentPlatform.js.map +1 -1
  197. package/dist/esm/util/uuidUtils.common.js +1 -1
  198. package/dist/esm/util/uuidUtils.common.js.map +1 -1
  199. package/dist/react-native/client/multipart.js.map +1 -1
  200. package/dist/react-native/client/sendRequest.js +12 -4
  201. package/dist/react-native/client/sendRequest.js.map +1 -1
  202. package/dist/react-native/client/urlHelpers.js +9 -3
  203. package/dist/react-native/client/urlHelpers.js.map +1 -1
  204. package/dist/react-native/fetchHttpClient.d.ts +5 -0
  205. package/dist/react-native/fetchHttpClient.js.map +1 -1
  206. package/dist/react-native/logger/logger.js.map +1 -1
  207. package/dist/react-native/policies/retryPolicy.js +4 -3
  208. package/dist/react-native/policies/retryPolicy.js.map +1 -1
  209. package/dist/react-native/util/concat.d.ts +34 -1
  210. package/dist/react-native/util/concat.js +48 -1
  211. package/dist/react-native/util/concat.js.map +1 -1
  212. package/dist/react-native/util/sanitizer.js +3 -3
  213. package/dist/react-native/util/sanitizer.js.map +1 -1
  214. package/dist/react-native/util/typeGuards.js +2 -2
  215. package/dist/react-native/util/typeGuards.js.map +1 -1
  216. package/dist/react-native/util/uuidUtils.common.js +1 -1
  217. package/dist/react-native/util/uuidUtils.common.js.map +1 -1
  218. package/package.json +10 -8
  219. package/dist/browser/util/concat.common.d.ts +0 -17
  220. package/dist/browser/util/concat.common.js +0 -58
  221. package/dist/browser/util/concat.common.js.map +0 -1
  222. package/dist/commonjs/util/concat.common.d.ts +0 -17
  223. package/dist/commonjs/util/concat.common.js +0 -60
  224. package/dist/commonjs/util/concat.common.js.map +0 -7
  225. package/dist/esm/util/concat.common.d.ts +0 -17
  226. package/dist/esm/util/concat.common.js +0 -58
  227. package/dist/esm/util/concat.common.js.map +0 -1
  228. package/dist/react-native/util/concat.common.d.ts +0 -17
  229. package/dist/react-native/util/concat.common.js +0 -58
  230. package/dist/react-native/util/concat.common.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/util/concat.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"./concat.common.js\";\n"]}
1
+ {"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/util/concat.ts"],"names":[],"mappings":"A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C,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Drain the content of the given ReadableStream into a Blob.\n * The blob's content may end up in memory or on disk dependent on size.\n */\nfunction drain(stream: ReadableStream<Uint8Array>): Promise<Blob> {\n return new Response(stream).blob();\n}\n\nasync function toBlobPart(source: ConcatSource): Promise<Blob | Uint8Array> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n } else {\n throw new Error(\n \"Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.\",\n );\n }\n}\n\n/**\n * Converts a Uint8Array to a Uint8Array<ArrayBuffer>.\n * @param source - The source Uint8Array.\n * @returns\n */\nfunction arrayToArrayBuffer(source: Uint8Array): Uint8Array<ArrayBuffer> {\n if (\"resize\" in source.buffer) {\n // ArrayBuffer\n return source as Uint8Array<ArrayBuffer>;\n }\n // SharedArrayBuffer\n return source.map((x) => x);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\nexport type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * @param sources - array of sources for the concatenation\n * @returns - in Node, a (() =\\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.\n * In browser, returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts = [];\n for (const source of sources) {\n const blobPart = await toBlobPart(typeof source === \"function\" ? source() : source);\n if (blobPart instanceof Blob) {\n parts.push(blobPart);\n } else {\n // Uint8Array\n parts.push(new Blob([arrayToArrayBuffer(blobPart)]));\n }\n }\n\n return new Blob(parts);\n}\n"]}
@@ -73,13 +73,13 @@ export class Sanitizer {
73
73
  message: value.message,
74
74
  };
75
75
  }
76
- if (key === "headers") {
76
+ if (key === "headers" && isObject(value)) {
77
77
  return this.sanitizeHeaders(value);
78
78
  }
79
- else if (key === "url") {
79
+ else if (key === "url" && typeof value === "string") {
80
80
  return this.sanitizeUrl(value);
81
81
  }
82
- else if (key === "query") {
82
+ else if (key === "query" && isObject(value)) {
83
83
  return this.sanitizeQuery(value);
84
84
  }
85
85
  else if (key === "body") {
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../../src/util/sanitizer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqB3D,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,sFAAsF;AACtF,MAAM,yBAAyB,GAAG;IAChC,wBAAwB;IACxB,+BAA+B;IAC/B,gBAAgB;IAChB,6BAA6B;IAC7B,iBAAiB;IACjB,mBAAmB;IACnB,OAAO;IACP,0BAA0B;IAC1B,aAAa;IAEb,kCAAkC;IAClC,8BAA8B;IAC9B,8BAA8B;IAC9B,6BAA6B;IAC7B,+BAA+B;IAC/B,wBAAwB;IACxB,gCAAgC;IAChC,+BAA+B;IAC/B,QAAQ;IAER,QAAQ;IACR,iBAAiB;IACjB,eAAe;IACf,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IACV,mBAAmB;IACnB,eAAe;IACf,qBAAqB;IACrB,eAAe;IACf,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,mBAAmB;IACnB,YAAY;IACZ,kBAAkB;CACnB,CAAC;AAEF,MAAM,6BAA6B,GAAa,CAAC,aAAa,CAA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AC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAEO,eAAe,CAAC,GAAkB;QACxC,MAAM,SAAS,GAAkB,EAAE,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACnD,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,aAAa,CAAC,KAAoB;QACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,SAAS,GAAkB,EAAE,CAAC;QAEpC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACrD,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { type UnknownObject, isObject } from \"./object.js\";\n\n/**\n * Sanitizer options\n */\nexport interface SanitizerOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n}\n\nconst RedactedString = \"REDACTED\";\n\n// Make sure this list is up-to-date with the one under core/logger/Readme#Keyconcepts\nconst defaultAllowedHeaderNames = [\n \"x-ms-client-request-id\",\n \"x-ms-return-client-request-id\",\n \"x-ms-useragent\",\n \"x-ms-correlation-request-id\",\n \"x-ms-request-id\",\n \"client-request-id\",\n \"ms-cv\",\n \"return-client-request-id\",\n \"traceparent\",\n\n \"Access-Control-Allow-Credentials\",\n \"Access-Control-Allow-Headers\",\n \"Access-Control-Allow-Methods\",\n \"Access-Control-Allow-Origin\",\n \"Access-Control-Expose-Headers\",\n \"Access-Control-Max-Age\",\n \"Access-Control-Request-Headers\",\n \"Access-Control-Request-Method\",\n \"Origin\",\n\n \"Accept\",\n \"Accept-Encoding\",\n \"Cache-Control\",\n \"Connection\",\n \"Content-Length\",\n \"Content-Type\",\n \"Date\",\n \"ETag\",\n \"Expires\",\n \"If-Match\",\n \"If-Modified-Since\",\n \"If-None-Match\",\n \"If-Unmodified-Since\",\n \"Last-Modified\",\n \"Pragma\",\n \"Request-Id\",\n \"Retry-After\",\n \"Server\",\n \"Transfer-Encoding\",\n \"User-Agent\",\n \"WWW-Authenticate\",\n];\n\nconst defaultAllowedQueryParameters: string[] = [\"api-version\"];\n\n/**\n * A utility class to sanitize objects for logging.\n */\nexport class Sanitizer {\n private allowedHeaderNames: Set<string>;\n private allowedQueryParameters: Set<string>;\n\n constructor({\n additionalAllowedHeaderNames: allowedHeaderNames = [],\n additionalAllowedQueryParameters: allowedQueryParameters = [],\n }: SanitizerOptions = {}) {\n allowedHeaderNames = defaultAllowedHeaderNames.concat(allowedHeaderNames);\n allowedQueryParameters = defaultAllowedQueryParameters.concat(allowedQueryParameters);\n\n this.allowedHeaderNames = new Set(allowedHeaderNames.map((n) => n.toLowerCase()));\n this.allowedQueryParameters = new Set(allowedQueryParameters.map((p) => p.toLowerCase()));\n }\n\n /**\n * Sanitizes an object for logging.\n * @param obj - The object to sanitize\n * @returns - The sanitized object as a string\n */\n public sanitize(obj: unknown): string {\n const seen = new Set<unknown>();\n return JSON.stringify(\n obj,\n (key: string, value: unknown) => {\n // Ensure Errors include their interesting non-enumerable members\n if (value instanceof Error) {\n return {\n ...value,\n name: value.name,\n message: value.message,\n };\n }\n\n if (key === \"headers\") {\n return this.sanitizeHeaders(value as UnknownObject);\n } else if (key === \"url\") {\n return this.sanitizeUrl(value as string);\n } else if (key === \"query\") {\n return this.sanitizeQuery(value as UnknownObject);\n } else if (key === \"body\") {\n // Don't log the request body\n return undefined;\n } else if (key === \"response\") {\n // Don't log response again\n return undefined;\n } else if (key === \"operationSpec\") {\n // When using sendOperationRequest, the request carries a massive\n // field with the autorest spec. No need to log it.\n return undefined;\n } else if (Array.isArray(value) || isObject(value)) {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n }\n\n return value;\n },\n 2,\n );\n }\n\n /**\n * Sanitizes a URL for logging.\n * @param value - The URL to sanitize\n * @returns - The sanitized URL as a string\n */\n public sanitizeUrl(value: string): string {\n if (typeof value !== \"string\" || value === null || value === \"\") {\n return value;\n }\n\n const url = new URL(value);\n\n if (!url.search) {\n return value;\n }\n\n for (const [key] of url.searchParams) {\n if (!this.allowedQueryParameters.has(key.toLowerCase())) {\n url.searchParams.set(key, RedactedString);\n }\n }\n\n return url.toString();\n }\n\n private sanitizeHeaders(obj: UnknownObject): UnknownObject {\n const sanitized: UnknownObject = {};\n for (const key of Object.keys(obj)) {\n if (this.allowedHeaderNames.has(key.toLowerCase())) {\n sanitized[key] = obj[key];\n } else {\n sanitized[key] = RedactedString;\n }\n }\n return sanitized;\n }\n\n private sanitizeQuery(value: UnknownObject): UnknownObject {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n\n const sanitized: UnknownObject = {};\n\n for (const k of Object.keys(value)) {\n if (this.allowedQueryParameters.has(k.toLowerCase())) {\n sanitized[k] = value[k];\n } else {\n sanitized[k] = RedactedString;\n }\n }\n\n return sanitized;\n }\n}\n"]}
1
+ {"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../../src/util/sanitizer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqB3D,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,sFAAsF;AACtF,MAAM,yBAAyB,GAAG;IAChC,wBAAwB;IACxB,+BAA+B;IAC/B,gBAAgB;IAChB,6BAA6B;IAC7B,iBAAiB;IACjB,mBAAmB;IACnB,OAAO;IACP,0BAA0B;IAC1B,aAAa;IAEb,kCAAkC;IAClC,8BAA8B;IAC9B,8BAA8B;IAC9B,6BAA6B;IAC7B,+BAA+B;IAC/B,wBAAwB;IACxB,gCAAgC;IAChC,+BAA+B;IAC/B,QAAQ;IAER,QAAQ;IACR,iBAAiB;IACjB,eAAe;IACf,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IACV,mBAAmB;IACnB,eAAe;IACf,qBAAqB;IACrB,eAAe;IACf,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,mBAAmB;IACnB,YAAY;IACZ,kBAAkB;CACnB,CAAC;AAEF,MAAM,6BAA6B,GAAa,CAAC,aAAa,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,kBAAkB,CAAc;IAChC,sBAAsB,CAAc;IAE5C,YAAY,EACV,4BAA4B,EAAE,kBAAkB,GAAG,EAAE,EACrD,gCAAgC,EAAE,sBAAsB,GAAG,EAAE,MACzC,EAAE;QACtB,kBAAkB,GAAG,yBAAyB,CAA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;IAEO,eAAe,CAAC,GAAkB;QACxC,MAAM,SAAS,GAAkB,EAAE,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACnD,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,aAAa,CAAC,KAAoB;QACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,SAAS,GAAkB,EAAE,CAAC;QAEpC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACrD,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { type UnknownObject, isObject } from \"./object.js\";\n\n/**\n * Sanitizer options\n */\nexport interface SanitizerOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n}\n\nconst RedactedString = \"REDACTED\";\n\n// Make sure this list is up-to-date with the one under core/logger/Readme#Keyconcepts\nconst defaultAllowedHeaderNames = [\n \"x-ms-client-request-id\",\n \"x-ms-return-client-request-id\",\n \"x-ms-useragent\",\n \"x-ms-correlation-request-id\",\n \"x-ms-request-id\",\n \"client-request-id\",\n \"ms-cv\",\n \"return-client-request-id\",\n \"traceparent\",\n\n \"Access-Control-Allow-Credentials\",\n \"Access-Control-Allow-Headers\",\n \"Access-Control-Allow-Methods\",\n \"Access-Control-Allow-Origin\",\n \"Access-Control-Expose-Headers\",\n \"Access-Control-Max-Age\",\n \"Access-Control-Request-Headers\",\n \"Access-Control-Request-Method\",\n \"Origin\",\n\n \"Accept\",\n \"Accept-Encoding\",\n \"Cache-Control\",\n \"Connection\",\n \"Content-Length\",\n \"Content-Type\",\n \"Date\",\n \"ETag\",\n \"Expires\",\n \"If-Match\",\n \"If-Modified-Since\",\n \"If-None-Match\",\n \"If-Unmodified-Since\",\n \"Last-Modified\",\n \"Pragma\",\n \"Request-Id\",\n \"Retry-After\",\n \"Server\",\n \"Transfer-Encoding\",\n \"User-Agent\",\n \"WWW-Authenticate\",\n];\n\nconst defaultAllowedQueryParameters: string[] = [\"api-version\"];\n\n/**\n * A utility class to sanitize objects for logging.\n */\nexport class Sanitizer {\n private allowedHeaderNames: Set<string>;\n private allowedQueryParameters: Set<string>;\n\n constructor({\n additionalAllowedHeaderNames: allowedHeaderNames = [],\n additionalAllowedQueryParameters: allowedQueryParameters = [],\n }: SanitizerOptions = {}) {\n allowedHeaderNames = defaultAllowedHeaderNames.concat(allowedHeaderNames);\n allowedQueryParameters = defaultAllowedQueryParameters.concat(allowedQueryParameters);\n\n this.allowedHeaderNames = new Set(allowedHeaderNames.map((n) => n.toLowerCase()));\n this.allowedQueryParameters = new Set(allowedQueryParameters.map((p) => p.toLowerCase()));\n }\n\n /**\n * Sanitizes an object for logging.\n * @param obj - The object to sanitize\n * @returns - The sanitized object as a string\n */\n public sanitize(obj: unknown): string {\n const seen = new Set<unknown>();\n return JSON.stringify(\n obj,\n (key: string, value: unknown) => {\n // Ensure Errors include their interesting non-enumerable members\n if (value instanceof Error) {\n return {\n ...value,\n name: value.name,\n message: value.message,\n };\n }\n\n if (key === \"headers\" && isObject(value)) {\n return this.sanitizeHeaders(value);\n } else if (key === \"url\" && typeof value === \"string\") {\n return this.sanitizeUrl(value);\n } else if (key === \"query\" && isObject(value)) {\n return this.sanitizeQuery(value);\n } else if (key === \"body\") {\n // Don't log the request body\n return undefined;\n } else if (key === \"response\") {\n // Don't log response again\n return undefined;\n } else if (key === \"operationSpec\") {\n // When using sendOperationRequest, the request carries a massive\n // field with the autorest spec. No need to log it.\n return undefined;\n } else if (Array.isArray(value) || isObject(value)) {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n }\n\n return value;\n },\n 2,\n );\n }\n\n /**\n * Sanitizes a URL for logging.\n * @param value - The URL to sanitize\n * @returns - The sanitized URL as a string\n */\n public sanitizeUrl(value: string): string {\n if (typeof value !== \"string\" || value === null || value === \"\") {\n return value;\n }\n\n const url = new URL(value);\n\n if (!url.search) {\n return value;\n }\n\n for (const [key] of url.searchParams) {\n if (!this.allowedQueryParameters.has(key.toLowerCase())) {\n url.searchParams.set(key, RedactedString);\n }\n }\n\n return url.toString();\n }\n\n private sanitizeHeaders(obj: UnknownObject): UnknownObject {\n const sanitized: UnknownObject = {};\n for (const key of Object.keys(obj)) {\n if (this.allowedHeaderNames.has(key.toLowerCase())) {\n sanitized[key] = obj[key];\n } else {\n sanitized[key] = RedactedString;\n }\n }\n return sanitized;\n }\n\n private sanitizeQuery(value: UnknownObject): UnknownObject {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n\n const sanitized: UnknownObject = {};\n\n for (const k of Object.keys(value)) {\n if (this.allowedQueryParameters.has(k.toLowerCase())) {\n sanitized[k] = value[k];\n } else {\n sanitized[k] = RedactedString;\n }\n }\n\n return sanitized;\n }\n}\n"]}
@@ -13,12 +13,12 @@ export function isBinaryBody(body) {
13
13
  (body instanceof Uint8Array ||
14
14
  isReadableStream(body) ||
15
15
  typeof body === "function" ||
16
- body instanceof Blob));
16
+ (typeof Blob !== "undefined" && body instanceof Blob)));
17
17
  }
18
18
  export function isReadableStream(x) {
19
19
  return isNodeReadableStream(x) || isWebReadableStream(x);
20
20
  }
21
21
  export function isBlob(x) {
22
- return typeof x.stream === "function";
22
+ return typeof Blob !== "undefined" && x instanceof Blob;
23
23
  }
24
24
  //# 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,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CAA2B,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAU;IAC5C,OAAO,OAAO,CACZ,CAAC;QACD,OAAQ,CAAoB,CAAC,SAAS,KAAK,UAAU;QACrD,OAAQ,CAAoB,CAAC,GAAG,KAAK,UAAU,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,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,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,OAAO,oBAAoB,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,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\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;AAElC,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CAA2B,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAU;IAC5C,OAAO,OAAO,CACZ,CAAC;QACD,OAAQ,CAAoB,CAAC,SAAS,KAAK,UAAU;QACrD,OAAQ,CAAoB,CAAC,GAAG,KAAK,UAAU,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,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,CAAC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,OAAO,oBAAoB,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,CAAC,YAAY,IAAI,CAAC;AAC1D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\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 (typeof Blob !== \"undefined\" && 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 Blob !== \"undefined\" && x instanceof Blob;\n}\n"]}
@@ -1,3 +1,30 @@
1
+ interface BrowserBrand {
2
+ brand: string;
3
+ version: string;
4
+ }
5
+ interface UserAgentData {
6
+ brands: BrowserBrand[];
7
+ mobile: boolean;
8
+ platform?: string;
9
+ getHighEntropyValues: (hints: string[]) => Promise<{
10
+ architecture: string;
11
+ bitness: string;
12
+ brands: BrowserBrand[];
13
+ formFactor: string;
14
+ fullVersionList: BrowserBrand[];
15
+ mobile: boolean;
16
+ model: string;
17
+ platform: string;
18
+ platformVersion: string;
19
+ wow64: boolean;
20
+ }>;
21
+ }
22
+ declare global {
23
+ interface Navigator {
24
+ userAgentData?: UserAgentData;
25
+ }
26
+ var EdgeRuntime: string | undefined;
27
+ }
1
28
  /**
2
29
  * @internal
3
30
  */
@@ -6,4 +33,5 @@ export declare function getHeaderName(): string;
6
33
  * @internal
7
34
  */
8
35
  export declare function setPlatformSpecificData(map: Map<string, string>): Promise<void>;
36
+ export {};
9
37
  //# sourceMappingURL=userAgentPlatform.d.ts.map
@@ -33,29 +33,28 @@ function getBrandVersionString(brands) {
33
33
  * @internal
34
34
  */
35
35
  export async function setPlatformSpecificData(map) {
36
- const localNavigator = globalThis.navigator;
36
+ const nav = globalThis.navigator;
37
37
  let osInfo = "unknown";
38
- if (localNavigator?.userAgentData) {
39
- const entropyValues = await localNavigator.userAgentData.getHighEntropyValues([
38
+ if (nav?.userAgentData) {
39
+ const entropyValues = await nav.userAgentData.getHighEntropyValues([
40
40
  "architecture",
41
41
  "platformVersion",
42
42
  ]);
43
43
  osInfo = `${entropyValues.platform} ${entropyValues.platformVersion}; ${entropyValues.architecture}`;
44
- // Get the brand and version
45
- const brand = getBrandVersionString(localNavigator.userAgentData.brands);
44
+ const brand = getBrandVersionString(nav.userAgentData.brands);
46
45
  if (brand) {
47
46
  map.set(brand.brand, `${brand.version} (${osInfo})`);
48
47
  }
49
48
  }
50
- else if (localNavigator?.platform) {
51
- osInfo = localNavigator.platform;
52
- const brand = getBrowserInfo(localNavigator.userAgent);
49
+ else if (nav?.platform) {
50
+ osInfo = nav.platform;
51
+ const brand = getBrowserInfo(nav.userAgent);
53
52
  if (brand) {
54
53
  map.set(brand.brand, `${brand.version} (${osInfo})`);
55
54
  }
56
55
  }
57
- else if (typeof globalThis.EdgeRuntime === "string") {
58
- map.set("EdgeRuntime", `${globalThis.EdgeRuntime} (${osInfo})`);
56
+ else if (typeof EdgeRuntime === "string") {
57
+ map.set("EdgeRuntime", `${EdgeRuntime} (${osInfo})`);
59
58
  }
60
59
  }
61
60
  //# 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;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAgCD,SAAS,cAAc,CAAC,SAAiB;IACvC,MAAM,cAAc,GAAG;QACrB,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,mBAAmB,EAAE;QAC/C,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,2BAA2B,EAAE;KACvD,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAsB;IACnD,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACrF,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,C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AAG,CAAC,CAAC;IAClE,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\ninterface BrowserBrand {\n brand: string;\n version: string;\n}\n\ninterface NavigatorEx extends Navigator {\n userAgentData?: {\n brands: BrowserBrand[];\n mobile: boolean;\n platform?: string;\n getHighEntropyValues: (hints: string[]) => Promise<{\n architecture: string;\n bitness: string;\n brands: BrowserBrand[];\n formFactor: string;\n fullVersionList: BrowserBrand[];\n mobile: boolean;\n model: string;\n platform: string;\n platformVersion: string;\n wow64: boolean;\n }>;\n };\n}\n\ndeclare const globalThis: {\n navigator?: NavigatorEx;\n EdgeRuntime?: unknown;\n};\n\nfunction getBrowserInfo(userAgent: string): BrowserBrand | undefined {\n const browserRegexes = [\n { name: \"Firefox\", regex: /Firefox\\/([\\d.]+)/ },\n { name: \"Safari\", regex: /Version\\/([\\d.]+).*Safari/ },\n ];\n\n for (const browser of browserRegexes) {\n const match = userAgent.match(browser.regex);\n if (match) {\n return { brand: browser.name, version: match[1] };\n }\n }\n\n return undefined;\n}\n\nfunction getBrandVersionString(brands: BrowserBrand[]): BrowserBrand | undefined {\n const brandOrder = [\"Google Chrome\", \"Microsoft Edge\", \"Opera\", \"Brave\", \"Chromium\"];\n for (const brand of brandOrder) {\n const foundBrand = brands.find((b) => b.brand === brand);\n if (foundBrand) {\n return foundBrand;\n }\n }\n return undefined;\n}\n\n/**\n * @internal\n */\nexport async function setPlatformSpecificData(map: Map<string, string>): Promise<void> {\n const localNavigator = globalThis.navigator as NavigatorEx;\n let osInfo = \"unknown\";\n if (localNavigator?.userAgentData) {\n const entropyValues = await localNavigator.userAgentData.getHighEntropyValues([\n \"architecture\",\n \"platformVersion\",\n ]);\n osInfo = `${entropyValues.platform} ${entropyValues.platformVersion}; ${entropyValues.architecture}`;\n\n // Get the brand and version\n const brand = getBrandVersionString(localNavigator.userAgentData.brands);\n if (brand) {\n map.set(brand.brand, `${brand.version} (${osInfo})`);\n }\n } else if (localNavigator?.platform) {\n osInfo = localNavigator.platform;\n const brand = getBrowserInfo(localNavigator.userAgent);\n if (brand) {\n map.set(brand.brand, `${brand.version} (${osInfo})`);\n }\n } else if (typeof globalThis.EdgeRuntime === \"string\") {\n map.set(\"EdgeRuntime\", `${globalThis.EdgeRuntime} (${osInfo})`);\n }\n}\n"]}
1
+ {"version":3,"file":"userAgentPlatform.js","sourceRoot":"","sources":["../../../src/util/userAgentPlatform.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAkClC;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,SAAS,cAAc,CAAC,SAAiB;IACvC,MAAM,cAAc,GAAG;QACrB,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,mBAAmB,EAAE;QAC/C,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,2BAA2B,EAAE;KACvD,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAsB;IACnD,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACrF,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CA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,CAAC,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\ninterface BrowserBrand {\n brand: string;\n version: string;\n}\n\ninterface UserAgentData {\n brands: BrowserBrand[];\n mobile: boolean;\n platform?: string;\n getHighEntropyValues: (hints: string[]) => Promise<{\n architecture: string;\n bitness: string;\n brands: BrowserBrand[];\n formFactor: string;\n fullVersionList: BrowserBrand[];\n mobile: boolean;\n model: string;\n platform: string;\n platformVersion: string;\n wow64: boolean;\n }>;\n}\n\ndeclare global {\n interface Navigator {\n userAgentData?: UserAgentData;\n }\n\n // Vercel Edge Runtime global\n var EdgeRuntime: string | undefined;\n}\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\nfunction getBrowserInfo(userAgent: string): BrowserBrand | undefined {\n const browserRegexes = [\n { name: \"Firefox\", regex: /Firefox\\/([\\d.]+)/ },\n { name: \"Safari\", regex: /Version\\/([\\d.]+).*Safari/ },\n ];\n\n for (const browser of browserRegexes) {\n const match = userAgent.match(browser.regex);\n if (match) {\n return { brand: browser.name, version: match[1] };\n }\n }\n\n return undefined;\n}\n\nfunction getBrandVersionString(brands: BrowserBrand[]): BrowserBrand | undefined {\n const brandOrder = [\"Google Chrome\", \"Microsoft Edge\", \"Opera\", \"Brave\", \"Chromium\"];\n for (const brand of brandOrder) {\n const foundBrand = brands.find((b) => b.brand === brand);\n if (foundBrand) {\n return foundBrand;\n }\n }\n return undefined;\n}\n\n/**\n * @internal\n */\nexport async function setPlatformSpecificData(map: Map<string, string>): Promise<void> {\n const nav = globalThis.navigator;\n let osInfo = \"unknown\";\n\n if (nav?.userAgentData) {\n const entropyValues = await nav.userAgentData.getHighEntropyValues([\n \"architecture\",\n \"platformVersion\",\n ]);\n osInfo = `${entropyValues.platform} ${entropyValues.platformVersion}; ${entropyValues.architecture}`;\n\n const brand = getBrandVersionString(nav.userAgentData.brands);\n if (brand) {\n map.set(brand.brand, `${brand.version} (${osInfo})`);\n }\n } else if (nav?.platform) {\n osInfo = nav.platform;\n const brand = getBrowserInfo(nav.userAgent);\n if (brand) {\n map.set(brand.brand, `${brand.version} (${osInfo})`);\n }\n } else if (typeof EdgeRuntime === \"string\") {\n map.set(\"EdgeRuntime\", `${EdgeRuntime} (${osInfo})`);\n }\n}\n"]}
@@ -16,7 +16,7 @@ export function generateUUID() {
16
16
  }
17
17
  else if (i === 16) {
18
18
  // Set the UUID variant to "10" in the 17th position
19
- uuid += (randomNumber & 0x3) | 0x8;
19
+ uuid += ((randomNumber & 0x3) | 0x8).toString(16);
20
20
  }
21
21
  else {
22
22
  // Add a random hexadecimal digit to the UUID string
@@ -1 +1 @@
1
- {"version":3,"file":"uuidUtils.common.js","sourceRoot":"","sources":["../../../src/util/uuidUtils.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,MAAM,UAAU,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,MAAM,UAAU,UAAU;IACxB,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\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;AAElC;;;;GAIG;AACH,MAAM,UAAU,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,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpD,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,MAAM,UAAU,UAAU;IACxB,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\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).toString(16);\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"]}
@@ -30,3 +30,4 @@ class AbortError extends Error {
30
30
  0 && (module.exports = {
31
31
  AbortError
32
32
  });
33
+ //# sourceMappingURL=AbortError.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/abort-controller/AbortError.ts"],
3
+ "sources": ["../../../src/abort-controller/AbortError.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * ```ts snippet:ReadmeSampleAbortError\n * import { AbortError } from \"@typespec/ts-http-runtime\";\n *\n * async function doAsyncWork(options: { abortSignal: AbortSignal }): Promise<void> {\n * if (options.abortSignal.aborted) {\n * throw new AbortError();\n * }\n *\n * // do async work\n * }\n *\n * const controller = new AbortController();\n * controller.abort();\n *\n * try {\n * doAsyncWork({ abortSignal: controller.signal });\n * } catch (e) {\n * if (e instanceof Error && e.name === \"AbortError\") {\n * // handle abort error here.\n * }\n * }\n * ```\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,MAAM,mBAAmB,MAAM;AAAA,EACpC,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;",
6
6
  "names": []
@@ -42,3 +42,4 @@ function isApiKeyCredential(credential) {
42
42
  isBearerTokenCredential,
43
43
  isOAuth2TokenCredential
44
44
  });
45
+ //# sourceMappingURL=credentials.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/auth/credentials.ts"],
3
+ "sources": ["../../../src/auth/credentials.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OAuth2Flow } from \"./oauth2Flows.js\";\n\n/**\n * Options used when creating and sending get OAuth 2 requests for this operation.\n */\nexport interface GetOAuth2TokenOptions {\n /** Abort signal for the request */\n abortSignal?: AbortSignal;\n}\n\n/**\n * Options used when creating and sending get bearer token requests for this operation.\n */\nexport interface GetBearerTokenOptions {\n /** Abort signal for the request */\n abortSignal?: AbortSignal;\n}\n\n/**\n * Credential for OAuth2 authentication flows.\n */\nexport interface OAuth2TokenCredential<TFlows extends OAuth2Flow> {\n /**\n * Gets an OAuth2 token for the specified flows.\n * @param flows - The OAuth2 flows to use.\n * @param options - Options for the request.\n * @returns - a valid access token which was obtained through one of the flows specified in `flows`.\n */\n getOAuth2Token(flows: TFlows[], options?: GetOAuth2TokenOptions): Promise<string>;\n}\n\n/**\n * Credential for Bearer token authentication.\n */\nexport interface BearerTokenCredential {\n /**\n * Gets a Bearer token for the specified flows.\n * @param options - Options for the request.\n * @returns - a valid access token.\n */\n getBearerToken(options?: GetBearerTokenOptions): Promise<string>;\n}\n\n/**\n * Credential for HTTP Basic authentication.\n * Provides username and password for basic authentication headers.\n */\nexport interface BasicCredential {\n /** The username for basic authentication. */\n username: string;\n /** The password for basic authentication. */\n password: string;\n}\n\n/**\n * Credential for API Key authentication.\n * Provides an API key that will be used in the request headers.\n */\nexport interface ApiKeyCredential {\n /** The API key for authentication. */\n key: string;\n}\n\n/**\n * Union type of all supported authentication credentials.\n */\nexport type ClientCredential =\n | OAuth2TokenCredential<OAuth2Flow>\n | BearerTokenCredential\n | BasicCredential\n | ApiKeyCredential;\n\n/**\n * Type guard to check if a credential is an OAuth2 token credential.\n */\nexport function isOAuth2TokenCredential(\n credential: ClientCredential,\n): credential is OAuth2TokenCredential<OAuth2Flow> {\n return \"getOAuth2Token\" in credential;\n}\n\n/**\n * Type guard to check if a credential is a Bearer token credential.\n */\nexport function isBearerTokenCredential(\n credential: ClientCredential,\n): credential is BearerTokenCredential {\n return \"getBearerToken\" in credential;\n}\n\n/**\n * Type guard to check if a credential is a Basic auth credential.\n */\nexport function isBasicCredential(credential: ClientCredential): credential is BasicCredential {\n return \"username\" in credential && \"password\" in credential;\n}\n\n/**\n * Type guard to check if a credential is an API key credential.\n */\nexport function isApiKeyCredential(credential: ClientCredential): credential is ApiKeyCredential {\n return \"key\" in credential;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8EO,SAAS,wBACd,YACiD;AACjD,SAAO,oBAAoB;AAC7B;AAKO,SAAS,wBACd,YACqC;AACrC,SAAO,oBAAoB;AAC7B;AAKO,SAAS,kBAAkB,YAA6D;AAC7F,SAAO,cAAc,cAAc,cAAc;AACnD;AAKO,SAAS,mBAAmB,YAA8D;AAC/F,SAAO,SAAS;AAClB;",
6
6
  "names": []
@@ -13,3 +13,4 @@ var __copyProps = (to, from, except, desc) => {
13
13
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
14
  var oauth2Flows_exports = {};
15
15
  module.exports = __toCommonJS(oauth2Flows_exports);
16
+ //# sourceMappingURL=oauth2Flows.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/auth/oauth2Flows.ts"],
3
+ "sources": ["../../../src/auth/oauth2Flows.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Represents OAuth2 Authorization Code flow configuration.\n */\nexport interface AuthorizationCodeFlow {\n /** Type of OAuth2 flow */\n kind: \"authorizationCode\";\n /** Authorization endpoint */\n authorizationUrl: string;\n /** Token endpoint */\n tokenUrl: string;\n /** Refresh token endpoint */\n refreshUrl?: string;\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/**\n * Represents OAuth2 Client Credentials flow configuration.\n */\nexport interface ClientCredentialsFlow {\n /** Type of OAuth2 flow */\n kind: \"clientCredentials\";\n /** Token endpoint */\n tokenUrl: string;\n /** Refresh token endpoints */\n refreshUrl?: string[];\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/**\n * Represents OAuth2 Implicit flow configuration.\n */\nexport interface ImplicitFlow {\n /** Type of OAuth2 flow */\n kind: \"implicit\";\n /** Authorization endpoint */\n authorizationUrl: string;\n /** Refresh token endpoint */\n refreshUrl?: string;\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/**\n * Represents OAuth2 Password flow configuration.\n */\nexport interface PasswordFlow {\n /** Type of OAuth2 flow */\n kind: \"password\";\n /** Token endpoint */\n tokenUrl: string;\n /** Refresh token endpoint */\n refreshUrl?: string;\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/** Union type of all supported OAuth2 flows */\nexport type OAuth2Flow =\n | AuthorizationCodeFlow\n | ClientCredentialsFlow\n | ImplicitFlow\n | PasswordFlow;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
@@ -13,3 +13,4 @@ var __copyProps = (to, from, except, desc) => {
13
13
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
14
  var schemes_exports = {};
15
15
  module.exports = __toCommonJS(schemes_exports);
16
+ //# sourceMappingURL=schemes.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/auth/schemes.ts"],
3
+ "sources": ["../../../src/auth/schemes.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OAuth2Flow } from \"./oauth2Flows.js\";\n\n/**\n * Represents HTTP Basic authentication scheme.\n * Basic authentication scheme requires a username and password to be provided with each request.\n * The credentials are encoded using Base64 and included in the Authorization header.\n */\nexport interface BasicAuthScheme {\n /** Type of auth scheme */\n kind: \"http\";\n /** Basic authentication scheme */\n scheme: \"basic\";\n}\n\n/**\n * Represents HTTP Bearer authentication scheme.\n * Bearer authentication scheme requires a bearer token to be provided with each request.\n * The token is included in the Authorization header with the \"Bearer\" prefix.\n */\nexport interface BearerAuthScheme {\n /** Type of auth scheme */\n kind: \"http\";\n /** Bearer authentication scheme */\n scheme: \"bearer\";\n}\n\n/**\n * Represents an endpoint or operation that requires no authentication.\n */\nexport interface NoAuthAuthScheme {\n /** Type of auth scheme */\n kind: \"noAuth\";\n}\n\n/**\n * Represents API Key authentication scheme.\n * API Key authentication requires a key to be provided with each request.\n * The key can be provided in different locations: query parameter, header, or cookie.\n */\nexport interface ApiKeyAuthScheme {\n /** Type of auth scheme */\n kind: \"apiKey\";\n /** Location of the API key */\n apiKeyLocation: \"query\" | \"header\" | \"cookie\";\n /** Name of the API key parameter */\n name: string;\n}\n\n/** Represents OAuth2 authentication scheme with specified flows */\nexport interface OAuth2AuthScheme<TFlows extends OAuth2Flow[]> {\n /** Type of auth scheme */\n kind: \"oauth2\";\n /** Supported OAuth2 flows */\n flows: TFlows;\n}\n\n/** Union type of all supported authentication schemes */\nexport type AuthScheme =\n | BasicAuthScheme\n | BearerAuthScheme\n | NoAuthAuthScheme\n | ApiKeyAuthScheme\n | OAuth2AuthScheme<OAuth2Flow[]>;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
@@ -39,3 +39,4 @@ function apiVersionPolicy(options) {
39
39
  apiVersionPolicy,
40
40
  apiVersionPolicyName
41
41
  });
42
+ //# sourceMappingURL=apiVersionPolicy.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/apiVersionPolicy.ts"],
3
+ "sources": ["../../../src/client/apiVersionPolicy.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport type { ClientOptions } from \"./common.js\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,uBAAuB;AAO7B,SAAS,iBAAiB,SAAwC;AACvE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa,CAAC,KAAK,SAAS;AAG1B,YAAM,MAAM,IAAI,IAAI,IAAI,GAAG;AAC3B,UAAI,CAAC,IAAI,aAAa,IAAI,aAAa,KAAK,QAAQ,YAAY;AAC9D,YAAI,MAAM,GAAG,IAAI,GAAG,GAClB,MAAM,KAAK,IAAI,aAAa,KAAK,CAAC,EAAE,SAAS,IAAI,MAAM,GACzD,eAAe,QAAQ,UAAU;AAAA,MACnC;AAEA,aAAO,KAAK,GAAG;AAAA,IACjB;AAAA,EACF;AACF;",
6
6
  "names": []
@@ -66,3 +66,4 @@ function getCachedDefaultHttpsClient() {
66
66
  createDefaultPipeline,
67
67
  getCachedDefaultHttpsClient
68
68
  });
69
+ //# sourceMappingURL=clientHelpers.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/clientHelpers.ts"],
3
+ "sources": ["../../../src/client/clientHelpers.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient } from \"../interfaces.js\";\nimport type { Pipeline } from \"../pipeline.js\";\nimport { createDefaultHttpClient } from \"../defaultHttpClient.js\";\nimport { createPipelineFromOptions } from \"../createPipelineFromOptions.js\";\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport {\n isApiKeyCredential,\n isBasicCredential,\n isBearerTokenCredential,\n isOAuth2TokenCredential,\n} from \"../auth/credentials.js\";\nimport { apiKeyAuthenticationPolicy } from \"../policies/auth/apiKeyAuthenticationPolicy.js\";\nimport { basicAuthenticationPolicy } from \"../policies/auth/basicAuthenticationPolicy.js\";\nimport { bearerAuthenticationPolicy } from \"../policies/auth/bearerAuthenticationPolicy.js\";\nimport { oauth2AuthenticationPolicy } from \"../policies/auth/oauth2AuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(options: ClientOptions = {}): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n const { credential, authSchemes, allowInsecureConnection } = options;\n if (credential) {\n if (isApiKeyCredential(credential)) {\n pipeline.addPolicy(\n apiKeyAuthenticationPolicy({ authSchemes, credential, allowInsecureConnection }),\n );\n } else if (isBasicCredential(credential)) {\n pipeline.addPolicy(\n basicAuthenticationPolicy({ authSchemes, credential, allowInsecureConnection }),\n );\n } else if (isBearerTokenCredential(credential)) {\n pipeline.addPolicy(\n bearerAuthenticationPolicy({ authSchemes, credential, allowInsecureConnection }),\n );\n } else if (isOAuth2TokenCredential(credential)) {\n pipeline.addPolicy(\n oauth2AuthenticationPolicy({ authSchemes, credential, allowInsecureConnection }),\n );\n }\n }\n\n return pipeline;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,+BAAwC;AACxC,uCAA0C;AAE1C,8BAAiC;AACjC,yBAKO;AACP,wCAA2C;AAC3C,uCAA0C;AAC1C,wCAA2C;AAC3C,wCAA2C;AAE3C,IAAI;AAKG,SAAS,sBAAsB,UAAyB,CAAC,GAAa;AAC3E,QAAM,eAAW,4DAA0B,OAAO;AAElD,WAAS,cAAU,0CAAiB,OAAO,CAAC;AAE5C,QAAM,EAAE,YAAY,aAAa,wBAAwB,IAAI;AAC7D,MAAI,YAAY;AACd,YAAI,uCAAmB,UAAU,GAAG;AAClC,eAAS;AAAA,YACP,8DAA2B,EAAE,aAAa,YAAY,wBAAwB,CAAC;AAAA,MACjF;AAAA,IACF,eAAW,sCAAkB,UAAU,GAAG;AACxC,eAAS;AAAA,YACP,4DAA0B,EAAE,aAAa,YAAY,wBAAwB,CAAC;AAAA,MAChF;AAAA,IACF,eAAW,4CAAwB,UAAU,GAAG;AAC9C,eAAS;AAAA,YACP,8DAA2B,EAAE,aAAa,YAAY,wBAAwB,CAAC;AAAA,MACjF;AAAA,IACF,eAAW,4CAAwB,UAAU,GAAG;AAC9C,eAAS;AAAA,YACP,8DAA2B,EAAE,aAAa,YAAY,wBAAwB,CAAC;AAAA,MACjF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,8BAA0C;AACxD,MAAI,CAAC,kBAAkB;AACrB,2BAAmB,kDAAwB;AAAA,EAC7C;AAEA,SAAO;AACT;",
6
6
  "names": []
@@ -13,3 +13,4 @@ var __copyProps = (to, from, except, desc) => {
13
13
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
14
  var common_exports = {};
15
15
  module.exports = __toCommonJS(common_exports);
16
+ //# sourceMappingURL=common.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/common.ts"],
3
+ "sources": ["../../../src/client/common.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpClient,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n RawHttpHeadersInput,\n} from \"../interfaces.js\";\nimport type { Pipeline, PipelinePolicy } from \"../pipeline.js\";\nimport type { PipelineOptions } from \"../createPipelineFromOptions.js\";\nimport type { LogPolicyOptions } from \"../policies/logPolicy.js\";\nimport type { AuthScheme } from \"../auth/schemes.js\";\nimport type { ClientCredential } from \"../auth/credentials.js\";\n\n/**\n * Shape of the default request parameters, this may be overridden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignal;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n// UNBRANDED DIFFERENCE: onResponse callback does not have a second __legacyError parameter which was provided for backwards compatibility\nexport type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignal;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\n}\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overridden with the generated\n * types. For example:\n * ```typescript snippet:ReadmeSamplePathExample\n * import { Client } from \"@typespec/ts-http-runtime\";\n *\n * type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJS.ReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n /**\n * Returns the response body as a NodeJS stream. Only available in Node-like environments.\n */\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n /**\n * Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the\n * `Readable.toWeb` Node API on the result of `asNodeStream`.\n */\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\n};\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\n}\n\n/**\n * Used to configure additional policies added to the pipeline at construction.\n */\nexport interface AdditionalPolicyConfig {\n /**\n * A policy to be added.\n */\n policy: PipelinePolicy;\n /**\n * Determines if this policy be applied before or after retry logic.\n * Only use `perRetry` if you need to modify the request again\n * each time the operation is retried due to retryable service\n * issues.\n */\n position: \"perCall\" | \"perRetry\";\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * List of authentication schemes supported by the client.\n * These schemes define how the client can authenticate requests.\n */\n authSchemes?: AuthScheme[];\n\n /**\n * The credential used to authenticate requests.\n * Must be compatible with one of the specified authentication schemes.\n */\n credential?: ClientCredential;\n\n // UNBRANDED DIFFERENCE: The deprecated baseUrl property is removed in favor of the endpoint property in the unbranded Core package\n\n /**\n * Endpoint for the client\n */\n endpoint?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n /**\n * Additional policies to include in the HTTP pipeline.\n */\n additionalPolicies?: AdditionalPolicyConfig[];\n /**\n * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n /**\n * Pipeline to use for the client. If not provided, a default pipeline will be created using the options provided.\n * Use with caution -- when setting this option, all client options that are used in the creation of the default pipeline\n * will be ignored.\n */\n pipeline?: Pipeline;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string,\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [\n pathParameter: string | number | PathParameterWithOptions,\n ...pathParameters: PathParameters<Tail>,\n ]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n\n/**\n * An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\nexport interface PathParameterWithOptions {\n /**\n * The value of the parameter.\n */\n value: string | number;\n\n /**\n * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.\n * Defaults to false.\n */\n allowReserved?: boolean;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
@@ -175,3 +175,4 @@ function buildOperation(method, url, pipeline, options, allowInsecureConnection,
175
175
  0 && (module.exports = {
176
176
  getClient
177
177
  });
178
+ //# sourceMappingURL=getClient.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/getClient.ts"],
3
+ "sources": ["../../../src/client/getClient.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, HttpMethods } from \"../interfaces.js\";\nimport type { Pipeline } from \"../pipeline.js\";\nimport { createDefaultPipeline } from \"./clientHelpers.js\";\nimport type {\n Client,\n ClientOptions,\n HttpBrowserStreamResponse,\n HttpNodeStreamResponse,\n RequestParameters,\n ResourceMethods,\n StreamableMethod,\n} from \"./common.js\";\nimport { sendRequest } from \"./sendRequest.js\";\nimport { buildRequestUrl } from \"./urlHelpers.js\";\nimport { isNodeLike } from \"../util/checkEnvironment.js\";\n\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(endpoint: string, clientOptions: ClientOptions = {}): Client {\n const pipeline = clientOptions.pipeline ?? createDefaultPipeline(clientOptions);\n if (clientOptions.additionalPolicies?.length) {\n for (const { policy, position } of clientOptions.additionalPolicies) {\n // Sign happens after Retry and is commonly needed to occur\n // before policies that intercept post-retry.\n const afterPhase = position === \"perRetry\" ? \"Sign\" : undefined;\n pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n\n const { allowInsecureConnection, httpClient } = clientOptions;\n const endpointUrl = clientOptions.endpoint ?? endpoint;\n const client = (path: string, ...args: Array<any>): ResourceMethods<StreamableMethod> => {\n const getUrl = (requestOptions: RequestParameters): string =>\n buildRequestUrl(endpointUrl, path, args, { allowInsecureConnection, ...requestOptions });\n\n return {\n get: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"GET\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n post: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"POST\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n put: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"PUT\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n patch: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"PATCH\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n delete: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"DELETE\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n head: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"HEAD\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n options: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"OPTIONS\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n trace: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"TRACE\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildOperation(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters,\n allowInsecureConnection?: boolean,\n httpClient?: HttpClient,\n): StreamableMethod {\n allowInsecureConnection = options.allowInsecureConnection ?? allowInsecureConnection;\n return {\n then: function (onFulfilled, onrejected) {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection },\n httpClient,\n ).then(onFulfilled, onrejected);\n },\n async asBrowserStream() {\n if (isNodeLike) {\n throw new Error(\n \"`asBrowserStream` is supported only in the browser environment. Use `asNodeStream` instead to obtain the response body stream. If you require a Web stream of the response in Node, consider using `Readable.toWeb` on the result of `asNodeStream`.\",\n );\n } else {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection, responseAsStream: true },\n httpClient,\n ) as Promise<HttpBrowserStreamResponse>;\n }\n },\n async asNodeStream() {\n if (isNodeLike) {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection, responseAsStream: true },\n httpClient,\n ) as Promise<HttpNodeStreamResponse>;\n } else {\n throw new Error(\n \"`isNodeStream` is not supported in the browser environment. Use `asBrowserStream` to obtain the response body stream.\",\n );\n }\n },\n };\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,2BAAsC;AAUtC,yBAA4B;AAC5B,wBAAgC;AAChC,8BAA2B;AAQpB,SAAS,UAAU,UAAkB,gBAA+B,CAAC,GAAW;AACrF,QAAM,WAAW,cAAc,gBAAY,4CAAsB,aAAa;AAC9E,MAAI,cAAc,oBAAoB,QAAQ;AAC5C,eAAW,EAAE,QAAQ,SAAS,KAAK,cAAc,oBAAoB;AAGnE,YAAM,aAAa,aAAa,aAAa,SAAS;AACtD,eAAS,UAAU,QAAQ;AAAA,QACzB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,EAAE,yBAAyB,WAAW,IAAI;AAChD,QAAM,cAAc,cAAc,YAAY;AAC9C,QAAM,SAAS,CAAC,SAAiB,SAAwD;AACvF,UAAM,SAAS,CAAC,uBACd,mCAAgB,aAAa,MAAM,MAAM,EAAE,yBAAyB,GAAG,eAAe,CAAC;AAEzF,WAAO;A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AA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,eAAe;AAAA,IACf;AAAA,EACF;AACF;AAEA,SAAS,eACP,QACA,KACA,UACA,SACA,yBACA,YACkB;AAClB,4BAA0B,QAAQ,2BAA2B;AAC7D,SAAO;AAAA,IACL,MAAM,SAAU,aAAa,YAAY;AACvC,iBAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA,EAAE,GAAG,SAAS,wBAAwB;AAAA,QACtC;AAAA,MACF,EAAE,KAAK,aAAa,UAAU;AAAA,IAChC;AAAA,IACA,MAAM,kBAAkB;AACtB,UAAI,oCAAY;AACd,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF,OAAO;AACL,mBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA,EAAE,GAAG,SAAS,yBAAyB,kBAAkB,KAAK;AAAA,UAC9D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,MAAM,eAAe;AACnB,UAAI,oCAAY;AACd,mBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA,EAAE,GAAG,SAAS,yBAAyB,kBAAkB,KAAK;AAAA,UAC9D;AAAA,QACF;AAAA,MACF,OAAO;AACL,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
@@ -131,3 +131,4 @@ function buildMultipartBody(parts) {
131
131
  buildBodyPart,
132
132
  buildMultipartBody
133
133
  });
134
+ //# sourceMappingURL=multipart.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/multipart.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BodyPart, MultipartRequestBody, RawHttpHeadersInput } from \"../interfaces.js\";\nimport { RestError } from \"../restError.js\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport { stringToUint8Array } from \"../util/bytesEncoding.js\";\nimport { isBinaryBody } from \"../util/typeGuards.js\";\n\n/**\n * Describes a single part in a multipart body.\n */\nexport interface PartDescriptor {\n /**\n * Content type of this part. If set, this value will be used to set the Content-Type MIME header for this part, although explicitly\n * setting the Content-Type header in the headers bag will override this value. If set to `null`, no content type will be inferred from\n * the body field. Otherwise, the value of the Content-Type MIME header will be inferred based on the type of the body.\n */\n contentType?: string | null;\n\n /**\n * The disposition type of this part (for example, \"form-data\" for parts making up a multipart/form-data request). If set, this value\n * will be used to set the Content-Disposition MIME header for this part, in addition to the `name` and `filename` properties.\n * If the `name` or `filename` properties are set while `dispositionType` is left undefined, `dispositionType` will default to \"form-data\".\n *\n * Explicitly setting the Content-Disposition header in the headers bag will override this value.\n */\n dispositionType?: string;\n\n /**\n * The field name associated with this part. This value will be used to construct the Content-Disposition header,\n * along with the `dispositionType` and `filename` properties, if the header has not been set in the `headers` bag.\n */\n name?: string;\n\n /**\n * The file name of the content if it is a file. This value will be used to construct the Content-Disposition header,\n * along with the `dispositionType` and `name` properties, if the header has not been set in the `headers` bag.\n */\n filename?: string;\n\n /**\n * The multipart headers for this part of the multipart body. Values of the Content-Type and Content-Disposition headers set in the headers bag\n * will take precedence over those computed from the request body or the contentType, dispositionType, name, and filename fields on this object.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The body of this part of the multipart request.\n */\n body?: unknown;\n}\n\ntype MultipartBodyType = BodyPart[\"body\"];\n\ntype HeaderValue = RawHttpHeadersInput[string];\n\n/**\n * Get value of a header in the part descriptor ignoring case\n */\nfunction getHeaderValue(descriptor: PartDescriptor, headerName: string): HeaderValue | undefined {\n if (descriptor.headers) {\n const actualHeaderName = Object.keys(descriptor.headers).find(\n (x) => x.toLowerCase() === headerName.toLowerCase(),\n );\n if (actualHeaderName) {\n return descriptor.headers[actualHeaderName];\n }\n }\n\n return undefined;\n}\n\nfunction getPartContentType(descriptor: PartDescriptor): HeaderValue | undefined {\n const contentTypeHeader = getHeaderValue(descriptor, \"content-type\");\n if (contentTypeHeader) {\n return contentTypeHeader;\n }\n\n // Special value of null means content type is to be omitted\n if (descriptor.contentType === null) {\n return undefined;\n }\n\n if (descriptor.contentType) {\n return descriptor.contentType;\n }\n\n const { body } = descriptor;\n\n if (body === null || body === undefined) {\n return undefined;\n }\n\n if (typeof body === \"string\" || typeof body === \"number\" || typeof body === \"boolean\") {\n return \"text/plain; charset=UTF-8\";\n }\n\n if (body instanceof Blob) {\n return body.type || \"application/octet-stream\";\n }\n\n if (isBinaryBody(body)) {\n return \"application/octet-stream\";\n }\n\n // arbitrary non-text object -> generic JSON content type by default. We will try to JSON.stringify the body.\n return \"application/json\";\n}\n\n/**\n * Enclose value in quotes and escape special characters, for use in the Content-Disposition header\n */\nfunction escapeDispositionField(value: string): string {\n return JSON.stringify(value);\n}\n\nfunction getContentDisposition(descriptor: PartDescriptor): HeaderValue | undefined {\n const contentDispositionHeader = getHeaderValue(descriptor, \"content-disposition\");\n if (contentDispositionHeader) {\n return contentDispositionHeader;\n }\n\n if (\n descriptor.dispositionType === undefined &&\n descriptor.name === undefined &&\n descriptor.filename === undefined\n ) {\n return undefined;\n }\n\n const dispositionType = descriptor.dispositionType ?? \"form-data\";\n\n let disposition = dispositionType;\n if (descriptor.name) {\n disposition += `; name=${escapeDispositionField(descriptor.name)}`;\n }\n\n let filename: string | undefined = undefined;\n if (descriptor.filename) {\n filename = descriptor.filename;\n } else if (typeof File !== \"undefined\" && descriptor.body instanceof File) {\n const filenameFromFile = (descriptor.body as File).name;\n if (filenameFromFile !== \"\") {\n filename = filenameFromFile;\n }\n }\n\n if (filename) {\n disposition += `; filename=${escapeDispositionField(filename)}`;\n }\n\n return disposition;\n}\n\nfunction normalizeBody(body?: unknown, contentType?: HeaderValue): MultipartBodyType {\n if (body === undefined) {\n // zero-length body\n return new Uint8Array([]);\n }\n\n // binary and primitives should go straight on the wire regardless of content type\n if (isBinaryBody(body)) {\n return body;\n }\n if (typeof body === \"string\" || typeof body === \"number\" || typeof body === \"boolean\") {\n return stringToUint8Array(String(body), \"utf-8\");\n }\n\n // stringify objects for JSON-ish content types e.g. application/json, application/merge-patch+json, application/vnd.oci.manifest.v1+json, application.json; charset=UTF-8\n if (contentType && /application\\/(.+\\+)?json(;.+)?/i.test(String(contentType))) {\n return stringToUint8Array(JSON.stringify(body), \"utf-8\");\n }\n\n throw new RestError(`Unsupported body/content-type combination: ${body}, ${contentType}`);\n}\n\nexport function buildBodyPart(descriptor: PartDescriptor): BodyPart {\n const contentType = getPartContentType(descriptor);\n const contentDisposition = getContentDisposition(descriptor);\n const headers = createHttpHeaders(descriptor.headers ?? {});\n\n if (contentType) {\n headers.set(\"content-type\", contentType);\n }\n if (contentDisposition) {\n headers.set(\"content-disposition\", contentDisposition);\n }\n\n const body = normalizeBody(descriptor.body, contentType);\n\n return {\n headers,\n body,\n };\n}\n\nexport function buildMultipartBody(parts: PartDescriptor[]): MultipartRequestBody {\n return { parts: parts.map(buildBodyPart) };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAA0B;AAC1B,yBAAkC;AAClC,2BAAmC;AACnC,wBAA6B;AAqD7B,SAAS,eAAe,YAA4B,YAA6C;AAC/F,MAAI,WAAW,SAAS;AACtB,UAAM,mBAAmB,OAAO,KAAK,WAAW,OAAO,EAAE;AAAA,MACvD,CAAC,MAAM,EAAE,YAAY,MAAM,WAAW,YAAY;AAAA,IACpD;AACA,QAAI,kBAAkB;AACpB,aAAO,WAAW,QAAQ,gBAAgB;AAAA,IAC5C;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,mBAAmB,YAAqD;AAC/E,QAAM,oBAAoB,eAAe,YAAY,cAAc;AACnE,MAAI,mBAAmB;AACrB,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,gBAAgB,MAAM;AACnC,WAAO;AAAA,E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AAA,EACT;AACA,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,OAAO,SAAS,WAAW;AACrF,eAAO,yCAAmB,OAAO,IAAI,GAAG,OAAO;AAAA,EACjD;AAGA,MAAI,eAAe,kCAAkC,KAAK,OAAO,WAAW,CAAC,GAAG;AAC9E,eAAO,yCAAmB,KAAK,UAAU,IAAI,GAAG,OAAO;AAAA,EACzD;AAEA,QAAM,IAAI,2BAAU,8CAA8C,IAAI,KAAK,WAAW,EAAE;AAC1F;AAEO,SAAS,cAAc,YAAsC;AAClE,QAAM,cAAc,mBAAmB,UAAU;AACjD,QAAM,qBAAqB,sBAAsB,UAAU;AAC3D,QAAM,cAAU,sCAAkB,WAAW,WAAW,CAAC,CAAC;AAE1D,MAAI,aAAa;AACf,YAAQ,IAAI,gBAAgB,WAAW;AAAA,EACzC;AACA,MAAI,oBAAoB;AACtB,YAAQ,IAAI,uBAAuB,kBAAkB;AAAA,EACvD;AAEA,QAAM,OAAO,cAAc,WAAW,MAAM,WAAW;AAEvD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,mBAAmB,OAA+C;AAChF,SAAO,EAAE,OAAO,MAAM,IAAI,aAAa,EAAE;AAC3C;",
3
+ "sources": ["../../../src/client/multipart.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BodyPart, MultipartRequestBody, RawHttpHeadersInput } from \"../interfaces.js\";\nimport { RestError } from \"../restError.js\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport { stringToUint8Array } from \"../util/bytesEncoding.js\";\nimport { isBinaryBody } from \"../util/typeGuards.js\";\n\n/**\n * Describes a single part in a multipart body.\n */\nexport interface PartDescriptor {\n /**\n * Content type of this part. If set, this value will be used to set the Content-Type MIME header for this part, although explicitly\n * setting the Content-Type header in the headers bag will override this value. If set to `null`, no content type will be inferred from\n * the body field. Otherwise, the value of the Content-Type MIME header will be inferred based on the type of the body.\n */\n contentType?: string | null;\n\n /**\n * The disposition type of this part (for example, \"form-data\" for parts making up a multipart/form-data request). If set, this value\n * will be used to set the Content-Disposition MIME header for this part, in addition to the `name` and `filename` properties.\n * If the `name` or `filename` properties are set while `dispositionType` is left undefined, `dispositionType` will default to \"form-data\".\n *\n * Explicitly setting the Content-Disposition header in the headers bag will override this value.\n */\n dispositionType?: string;\n\n /**\n * The field name associated with this part. This value will be used to construct the Content-Disposition header,\n * along with the `dispositionType` and `filename` properties, if the header has not been set in the `headers` bag.\n */\n name?: string;\n\n /**\n * The file name of the content if it is a file. This value will be used to construct the Content-Disposition header,\n * along with the `dispositionType` and `name` properties, if the header has not been set in the `headers` bag.\n */\n filename?: string;\n\n /**\n * The multipart headers for this part of the multipart body. Values of the Content-Type and Content-Disposition headers set in the headers bag\n * will take precedence over those computed from the request body or the contentType, dispositionType, name, and filename fields on this object.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The body of this part of the multipart request.\n */\n body?: unknown;\n}\n\ntype MultipartBodyType = BodyPart[\"body\"];\n\ntype HeaderValue = RawHttpHeadersInput[string];\n\n/**\n * Get value of a header in the part descriptor ignoring case\n */\nfunction getHeaderValue(descriptor: PartDescriptor, headerName: string): HeaderValue | undefined {\n if (descriptor.headers) {\n const actualHeaderName = Object.keys(descriptor.headers).find(\n (x) => x.toLowerCase() === headerName.toLowerCase(),\n );\n if (actualHeaderName) {\n return descriptor.headers[actualHeaderName];\n }\n }\n\n return undefined;\n}\n\nfunction getPartContentType(descriptor: PartDescriptor): HeaderValue | undefined {\n const contentTypeHeader = getHeaderValue(descriptor, \"content-type\");\n if (contentTypeHeader) {\n return contentTypeHeader;\n }\n\n // Special value of null means content type is to be omitted\n if (descriptor.contentType === null) {\n return undefined;\n }\n\n if (descriptor.contentType) {\n return descriptor.contentType;\n }\n\n const { body } = descriptor;\n\n if (body === null || body === undefined) {\n return undefined;\n }\n\n if (typeof body === \"string\" || typeof body === \"number\" || typeof body === \"boolean\") {\n return \"text/plain; charset=UTF-8\";\n }\n\n if (body instanceof Blob) {\n return body.type || \"application/octet-stream\";\n }\n\n if (isBinaryBody(body)) {\n return \"application/octet-stream\";\n }\n\n // arbitrary non-text object -> generic JSON content type by default. We will try to JSON.stringify the body.\n return \"application/json\";\n}\n\n/**\n * Enclose value in quotes and escape special characters, for use in the Content-Disposition header\n */\nfunction escapeDispositionField(value: string): string {\n return JSON.stringify(value);\n}\n\nfunction getContentDisposition(descriptor: PartDescriptor): HeaderValue | undefined {\n const contentDispositionHeader = getHeaderValue(descriptor, \"content-disposition\");\n if (contentDispositionHeader) {\n return contentDispositionHeader;\n }\n\n if (\n descriptor.dispositionType === undefined &&\n descriptor.name === undefined &&\n descriptor.filename === undefined\n ) {\n return undefined;\n }\n\n const dispositionType = descriptor.dispositionType ?? \"form-data\";\n\n let disposition = dispositionType;\n if (descriptor.name) {\n disposition += `; name=${escapeDispositionField(descriptor.name)}`;\n }\n\n let filename: string | undefined = undefined;\n if (descriptor.filename) {\n filename = descriptor.filename;\n } else if (typeof File !== \"undefined\" && descriptor.body instanceof File) {\n const filenameFromFile = descriptor.body.name;\n if (filenameFromFile !== \"\") {\n filename = filenameFromFile;\n }\n }\n\n if (filename) {\n disposition += `; filename=${escapeDispositionField(filename)}`;\n }\n\n return disposition;\n}\n\nfunction normalizeBody(body?: unknown, contentType?: HeaderValue): MultipartBodyType {\n if (body === undefined) {\n // zero-length body\n return new Uint8Array([]);\n }\n\n // binary and primitives should go straight on the wire regardless of content type\n if (isBinaryBody(body)) {\n return body;\n }\n if (typeof body === \"string\" || typeof body === \"number\" || typeof body === \"boolean\") {\n return stringToUint8Array(String(body), \"utf-8\");\n }\n\n // stringify objects for JSON-ish content types e.g. application/json, application/merge-patch+json, application/vnd.oci.manifest.v1+json, application.json; charset=UTF-8\n if (contentType && /application\\/(.+\\+)?json(;.+)?/i.test(String(contentType))) {\n return stringToUint8Array(JSON.stringify(body), \"utf-8\");\n }\n\n throw new RestError(`Unsupported body/content-type combination: ${body}, ${contentType}`);\n}\n\nexport function buildBodyPart(descriptor: PartDescriptor): BodyPart {\n const contentType = getPartContentType(descriptor);\n const contentDisposition = getContentDisposition(descriptor);\n const headers = createHttpHeaders(descriptor.headers ?? {});\n\n if (contentType) {\n headers.set(\"content-type\", contentType);\n }\n if (contentDisposition) {\n headers.set(\"content-disposition\", contentDisposition);\n }\n\n const body = normalizeBody(descriptor.body, contentType);\n\n return {\n headers,\n body,\n };\n}\n\nexport function buildMultipartBody(parts: PartDescriptor[]): MultipartRequestBody {\n return { parts: parts.map(buildBodyPart) };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAA0B;AAC1B,yBAAkC;AAClC,2BAAmC;AACnC,wBAA6B;AAqD7B,SAAS,eAAe,YAA4B,YAA6C;AAC/F,MAAI,WAAW,SAAS;AACtB,UAAM,mBAAmB,OAAO,KAAK,WAAW,OAAO,EAAE;AAAA,MACvD,CAAC,MAAM,EAAE,YAAY,MAAM,WAAW,YAAY;AAAA,IACpD;AACA,QAAI,kBAAkB;AACpB,aAAO,WAAW,QAAQ,gBAAgB;AAAA,IAC5C;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,mBAAmB,YAAqD;AAC/E,QAAM,oBAAoB,eAAe,YAAY,cAAc;AACnE,MAAI,mBAAmB;AACrB,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,gBAAgB,MAAM;AACnC,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,aAAa;AAC1B,WAAO,WAAW;AAAA,EACpB;AAEA,QAAM,EAAE,KAAK,IAAI;AAEjB,MAAI,SAAS,QAAQ,SAAS,QAAW;AACvC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,OAAO,SAAS,WAAW;AACrF,WAAO;AAAA,EACT;AAEA,MAAI,gBAAgB,MAAM;AACxB,WAAO,KAAK,QAAQ;AAAA,EACtB;A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AAE;AAC1F;AAEO,SAAS,cAAc,YAAsC;AAClE,QAAM,cAAc,mBAAmB,UAAU;AACjD,QAAM,qBAAqB,sBAAsB,UAAU;AAC3D,QAAM,cAAU,sCAAkB,WAAW,WAAW,CAAC,CAAC;AAE1D,MAAI,aAAa;AACf,YAAQ,IAAI,gBAAgB,WAAW;AAAA,EACzC;AACA,MAAI,oBAAoB;AACtB,YAAQ,IAAI,uBAAuB,kBAAkB;AAAA,EACvD;AAEA,QAAM,OAAO,cAAc,WAAW,MAAM,WAAW;AAEvD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,mBAAmB,OAA+C;AAChF,SAAO,EAAE,OAAO,MAAM,IAAI,aAAa,EAAE;AAC3C;",
6
6
  "names": []
7
7
  }
@@ -36,3 +36,4 @@ function operationOptionsToRequestParameters(options) {
36
36
  0 && (module.exports = {
37
37
  operationOptionsToRequestParameters
38
38
  });
39
+ //# sourceMappingURL=operationOptionHelpers.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/operationOptionHelpers.ts"],
3
+ "sources": ["../../../src/client/operationOptionHelpers.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions, RequestParameters } from \"./common.js\";\n\n/**\n * Helper function to convert OperationOptions to RequestParameters\n * @param options - the options that are used by Modular layer to send the request\n * @returns the result of the conversion in RequestParameters of RLC layer\n */\nexport function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters {\n return {\n allowInsecureConnection: options.requestOptions?.allowInsecureConnection,\n timeout: options.requestOptions?.timeout,\n skipUrlEncoding: options.requestOptions?.skipUrlEncoding,\n abortSignal: options.abortSignal,\n onUploadProgress: options.requestOptions?.onUploadProgress,\n onDownloadProgress: options.requestOptions?.onDownloadProgress,\n headers: { ...options.requestOptions?.headers },\n onResponse: options.onResponse,\n };\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,oCAAoC,SAA8C;AAChG,SAAO;AAAA,IACL,yBAAyB,QAAQ,gBAAgB;AAAA,IACjD,SAAS,QAAQ,gBAAgB;AAAA,IACjC,iBAAiB,QAAQ,gBAAgB;AAAA,IACzC,aAAa,QAAQ;AAAA,IACrB,kBAAkB,QAAQ,gBAAgB;AAAA,IAC1C,oBAAoB,QAAQ,gBAAgB;AAAA,IAC5C,SAAS,EAAE,GAAG,QAAQ,gBAAgB,QAAQ;AAAA,IAC9C,YAAY,QAAQ;AAAA,EACtB;AACF;",
6
6
  "names": []
@@ -48,3 +48,4 @@ function statusCodeToNumber(statusCode) {
48
48
  0 && (module.exports = {
49
49
  createRestError
50
50
  });
51
+ //# sourceMappingURL=restError.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/restError.ts"],
3
+ "sources": ["../../../src/client/restError.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineResponse } from \"../interfaces.js\";\nimport { RestError } from \"../restError.js\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport type { PathUncheckedResponse } from \"./common.js\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(response: PathUncheckedResponse): RestError;\n/**\n * Creates a rest error from an error message and a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError;\nexport function createRestError(\n messageOrResponse: string | PathUncheckedResponse,\n response?: PathUncheckedResponse,\n): RestError {\n const resp = typeof messageOrResponse === \"string\" ? response! : messageOrResponse;\n const internalError = resp.body?.error ?? resp.body;\n const message =\n typeof messageOrResponse === \"string\"\n ? messageOrResponse\n : (internalError?.message ?? `Unexpected status code: ${resp.status}`);\n return new RestError(message, {\n statusCode: statusCodeToNumber(resp.status),\n code: internalError?.code,\n request: resp.request,\n response: toPipelineResponse(resp),\n });\n}\n\nfunction toPipelineResponse(response: PathUncheckedResponse): PipelineResponse {\n return {\n headers: createHttpHeaders(response.headers),\n request: response.request,\n status: statusCodeToNumber(response.status) ?? -1,\n };\n}\n\nfunction statusCodeToNumber(statusCode: string): number | undefined {\n const status = Number.parseInt(statusCode);\n\n return Number.isNaN(status) ? undefined : status;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAA0B;AAC1B,yBAAkC;AAW3B,SAAS,gBACd,mBACA,UACW;AACX,QAAM,OAAO,OAAO,sBAAsB,WAAW,WAAY;AACjE,QAAM,gBAAgB,KAAK,MAAM,SAAS,KAAK;AAC/C,QAAM,UACJ,OAAO,sBAAsB,WACzB,oBACC,eAAe,WAAW,2BAA2B,KAAK,MAAM;AACvE,SAAO,IAAI,2BAAU,SAAS;AAAA,IAC5B,YAAY,mBAAmB,KAAK,MAAM;AAAA,IAC1C,MAAM,eAAe;AAAA,IACrB,SAAS,KAAK;AAAA,IACd,UAAU,mBAAmB,IAAI;AAAA,EACnC,CAAC;AACH;AAEA,SAAS,mBAAmB,UAAmD;AAC7E,SAAO;AAAA,IACL,aAAS,sCAAkB,SAAS,OAAO;AAAA,IAC3C,SAAS,SAAS;AAAA,IAClB,QAAQ,mBAAmB,SAAS,MAAM,KAAK;AAAA,EACjD;AACF;AAEA,SAAS,mBAAmB,YAAwC;AAClE,QAAM,SAAS,OAAO,SAAS,UAAU;AAEzC,SAAO,OAAO,MAAM,MAAM,IAAI,SAAY;AAC5C;",
6
6
  "names": []
@@ -55,7 +55,14 @@ async function sendRequest(method, url, pipeline, options = {}, customHttpClient
55
55
  }
56
56
  }
57
57
  function getRequestContentType(options = {}) {
58
- return options.contentType ?? options.headers?.["content-type"] ?? getContentType(options.body);
58
+ if (options.contentType) {
59
+ return options.contentType;
60
+ }
61
+ const headerContentType = options.headers?.["content-type"];
62
+ if (typeof headerContentType === "string") {
63
+ return headerContentType;
64
+ }
65
+ return getContentType(options.body);
59
66
  }
60
67
  function getContentType(body) {
61
68
  if (body === void 0) {
@@ -112,7 +119,10 @@ function getRequestBody(body, contentType = "") {
112
119
  if ((0, import_typeGuards.isBlob)(body)) {
113
120
  return { body };
114
121
  }
115
- if ((0, import_typeGuards.isReadableStream)(body) || typeof body === "function") {
122
+ if ((0, import_typeGuards.isReadableStream)(body)) {
123
+ return { body };
124
+ }
125
+ if (typeof body === "function") {
116
126
  return { body };
117
127
  }
118
128
  if (ArrayBuffer.isView(body)) {
@@ -167,3 +177,4 @@ function createParseError(response, err) {
167
177
  getRequestBody,
168
178
  sendRequest
169
179
  });
180
+ //# sourceMappingURL=sendRequest.js.map