@typespec/ts-http-runtime 1.0.0-alpha.20240618.1 → 1.0.0-alpha.20240621.10

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 (183) hide show
  1. package/dist/browser/policies/proxyPolicy-browser.d.mts.map +1 -1
  2. package/dist/browser/policies/proxyPolicy-browser.mjs.map +1 -1
  3. package/dist/browser/policies/proxyPolicy.common.d.ts +15 -0
  4. package/dist/browser/policies/proxyPolicy.common.d.ts.map +1 -0
  5. package/dist/browser/policies/proxyPolicy.common.js +24 -0
  6. package/dist/browser/policies/proxyPolicy.common.js.map +1 -0
  7. package/dist/browser/policies/proxyPolicy.d.ts +1 -14
  8. package/dist/browser/policies/proxyPolicy.js +1 -24
  9. package/dist/browser/policies/tracingPolicy.d.ts.map +1 -1
  10. package/dist/browser/policies/tracingPolicy.js +2 -1
  11. package/dist/browser/policies/tracingPolicy.js.map +1 -1
  12. package/dist/browser/policies/userAgentPolicy.js +1 -1
  13. package/dist/browser/policies/userAgentPolicy.js.map +1 -1
  14. package/dist/browser/util/bytesEncoding-browser.d.mts.map +1 -1
  15. package/dist/browser/util/bytesEncoding-browser.mjs.map +1 -1
  16. package/dist/browser/util/bytesEncoding.common.d.ts +61 -0
  17. package/dist/browser/util/bytesEncoding.common.d.ts.map +1 -0
  18. package/dist/browser/util/bytesEncoding.common.js +110 -0
  19. package/dist/browser/util/bytesEncoding.common.js.map +1 -0
  20. package/dist/browser/util/bytesEncoding.d.ts +1 -60
  21. package/dist/browser/util/bytesEncoding.js +1 -107
  22. package/dist/browser/util/concat-browser.d.mts.map +1 -1
  23. package/dist/browser/util/concat-browser.mjs.map +1 -1
  24. package/dist/browser/util/concat.common.d.ts +19 -0
  25. package/dist/browser/util/concat.common.d.ts.map +1 -0
  26. package/dist/browser/util/concat.common.js +45 -0
  27. package/dist/browser/util/concat.common.js.map +1 -0
  28. package/dist/browser/util/concat.d.ts +1 -18
  29. package/dist/browser/util/concat.js +1 -42
  30. package/dist/browser/util/inspect-browser.d.mts.map +1 -1
  31. package/dist/browser/util/inspect-browser.mjs.map +1 -1
  32. package/dist/browser/util/inspect.common.d.ts +2 -0
  33. package/dist/browser/util/inspect.common.d.ts.map +1 -0
  34. package/dist/browser/util/inspect.common.js +4 -0
  35. package/dist/browser/util/inspect.common.js.map +1 -0
  36. package/dist/browser/util/inspect.d.ts +1 -1
  37. package/dist/browser/util/inspect.js +1 -1
  38. package/dist/browser/util/sha256-browser.d.mts.map +1 -1
  39. package/dist/browser/util/sha256-browser.mjs.map +1 -1
  40. package/dist/browser/util/sha256.common.d.ts +14 -0
  41. package/dist/browser/util/sha256.common.d.ts.map +1 -0
  42. package/dist/browser/util/sha256.common.js +49 -0
  43. package/dist/browser/util/sha256.common.js.map +1 -0
  44. package/dist/browser/util/sha256.d.ts +1 -13
  45. package/dist/browser/util/sha256.js +1 -46
  46. package/dist/browser/util/userAgent.d.ts +1 -1
  47. package/dist/browser/util/userAgent.d.ts.map +1 -1
  48. package/dist/browser/util/userAgent.js +2 -2
  49. package/dist/browser/util/userAgent.js.map +1 -1
  50. package/dist/browser/util/userAgentPlatform-browser.d.mts.map +1 -1
  51. package/dist/browser/util/userAgentPlatform-browser.mjs.map +1 -1
  52. package/dist/browser/util/userAgentPlatform.d.ts +1 -1
  53. package/dist/browser/util/userAgentPlatform.js +28 -6
  54. package/dist/commonjs/policies/proxyPolicy.common.d.ts +15 -0
  55. package/dist/commonjs/policies/proxyPolicy.common.d.ts.map +1 -0
  56. package/dist/commonjs/policies/proxyPolicy.common.js +30 -0
  57. package/dist/commonjs/policies/proxyPolicy.common.js.map +1 -0
  58. package/dist/commonjs/policies/tracingPolicy.d.ts.map +1 -1
  59. package/dist/commonjs/policies/tracingPolicy.js +2 -1
  60. package/dist/commonjs/policies/tracingPolicy.js.map +1 -1
  61. package/dist/commonjs/policies/userAgentPolicy.js +1 -1
  62. package/dist/commonjs/policies/userAgentPolicy.js.map +1 -1
  63. package/dist/commonjs/util/bytesEncoding.common.d.ts +61 -0
  64. package/dist/commonjs/util/bytesEncoding.common.d.ts.map +1 -0
  65. package/dist/commonjs/util/bytesEncoding.common.js +123 -0
  66. package/dist/commonjs/util/bytesEncoding.common.js.map +1 -0
  67. package/dist/commonjs/util/concat.common.d.ts +19 -0
  68. package/dist/commonjs/util/concat.common.d.ts.map +1 -0
  69. package/dist/commonjs/util/concat.common.js +49 -0
  70. package/dist/commonjs/util/concat.common.js.map +1 -0
  71. package/dist/commonjs/util/inspect.common.d.ts +2 -0
  72. package/dist/commonjs/util/inspect.common.d.ts.map +1 -0
  73. package/dist/commonjs/util/inspect.common.js +7 -0
  74. package/dist/commonjs/util/inspect.common.js.map +1 -0
  75. package/dist/commonjs/util/sha256.common.d.ts +14 -0
  76. package/dist/commonjs/util/sha256.common.d.ts.map +1 -0
  77. package/dist/commonjs/util/sha256.common.js +54 -0
  78. package/dist/commonjs/util/sha256.common.js.map +1 -0
  79. package/dist/commonjs/util/userAgent.d.ts +1 -1
  80. package/dist/commonjs/util/userAgent.d.ts.map +1 -1
  81. package/dist/commonjs/util/userAgent.js +2 -2
  82. package/dist/commonjs/util/userAgent.js.map +1 -1
  83. package/dist/commonjs/util/userAgentPlatform.d.ts +1 -1
  84. package/dist/commonjs/util/userAgentPlatform.d.ts.map +1 -1
  85. package/dist/commonjs/util/userAgentPlatform.js +1 -1
  86. package/dist/commonjs/util/userAgentPlatform.js.map +1 -1
  87. package/dist/esm/policies/proxyPolicy.common.d.ts +15 -0
  88. package/dist/esm/policies/proxyPolicy.common.d.ts.map +1 -0
  89. package/dist/esm/policies/proxyPolicy.common.js +24 -0
  90. package/dist/esm/policies/proxyPolicy.common.js.map +1 -0
  91. package/dist/esm/policies/tracingPolicy.d.ts.map +1 -1
  92. package/dist/esm/policies/tracingPolicy.js +2 -1
  93. package/dist/esm/policies/tracingPolicy.js.map +1 -1
  94. package/dist/esm/policies/userAgentPolicy.js +1 -1
  95. package/dist/esm/policies/userAgentPolicy.js.map +1 -1
  96. package/dist/esm/util/bytesEncoding.common.d.ts +61 -0
  97. package/dist/esm/util/bytesEncoding.common.d.ts.map +1 -0
  98. package/dist/esm/util/bytesEncoding.common.js +110 -0
  99. package/dist/esm/util/bytesEncoding.common.js.map +1 -0
  100. package/dist/esm/util/concat.common.d.ts +19 -0
  101. package/dist/esm/util/concat.common.d.ts.map +1 -0
  102. package/dist/esm/util/concat.common.js +45 -0
  103. package/dist/esm/util/concat.common.js.map +1 -0
  104. package/dist/esm/util/inspect.common.d.ts +2 -0
  105. package/dist/esm/util/inspect.common.d.ts.map +1 -0
  106. package/dist/esm/util/inspect.common.js +4 -0
  107. package/dist/esm/util/inspect.common.js.map +1 -0
  108. package/dist/esm/util/sha256.common.d.ts +14 -0
  109. package/dist/esm/util/sha256.common.d.ts.map +1 -0
  110. package/dist/esm/util/sha256.common.js +49 -0
  111. package/dist/esm/util/sha256.common.js.map +1 -0
  112. package/dist/esm/util/userAgent.d.ts +1 -1
  113. package/dist/esm/util/userAgent.d.ts.map +1 -1
  114. package/dist/esm/util/userAgent.js +2 -2
  115. package/dist/esm/util/userAgent.js.map +1 -1
  116. package/dist/esm/util/userAgentPlatform.d.ts +1 -1
  117. package/dist/esm/util/userAgentPlatform.d.ts.map +1 -1
  118. package/dist/esm/util/userAgentPlatform.js +1 -1
  119. package/dist/esm/util/userAgentPlatform.js.map +1 -1
  120. package/dist/react-native/policies/proxyPolicy-react-native.d.mts.map +1 -0
  121. package/dist/react-native/policies/proxyPolicy-react-native.mjs.map +1 -0
  122. package/dist/react-native/policies/proxyPolicy.common.d.ts +15 -0
  123. package/dist/react-native/policies/proxyPolicy.common.d.ts.map +1 -0
  124. package/dist/react-native/policies/proxyPolicy.common.js +24 -0
  125. package/dist/react-native/policies/proxyPolicy.common.js.map +1 -0
  126. package/dist/react-native/policies/proxyPolicy.d.ts +2 -32
  127. package/dist/react-native/policies/proxyPolicy.js +2 -189
  128. package/dist/react-native/policies/tracingPolicy.d.ts.map +1 -1
  129. package/dist/react-native/policies/tracingPolicy.js +2 -1
  130. package/dist/react-native/policies/tracingPolicy.js.map +1 -1
  131. package/dist/react-native/policies/userAgentPolicy.js +1 -1
  132. package/dist/react-native/policies/userAgentPolicy.js.map +1 -1
  133. package/dist/react-native/util/bytesEncoding-react-native.d.mts.map +1 -0
  134. package/dist/react-native/util/bytesEncoding-react-native.mjs.map +1 -0
  135. package/dist/react-native/util/bytesEncoding.common.d.ts +61 -0
  136. package/dist/react-native/util/bytesEncoding.common.d.ts.map +1 -0
  137. package/dist/react-native/util/bytesEncoding.common.js +110 -0
  138. package/dist/react-native/util/bytesEncoding.common.js.map +1 -0
  139. package/dist/react-native/util/bytesEncoding.d.ts +2 -17
  140. package/dist/react-native/util/bytesEncoding.js +2 -19
  141. package/dist/react-native/util/concat-react-native.d.mts.map +1 -0
  142. package/dist/react-native/util/concat-react-native.mjs.map +1 -0
  143. package/dist/react-native/util/concat.common.d.ts +19 -0
  144. package/dist/react-native/util/concat.common.d.ts.map +1 -0
  145. package/dist/react-native/util/concat.common.js +45 -0
  146. package/dist/react-native/util/concat.common.js.map +1 -0
  147. package/dist/react-native/util/concat.d.ts +2 -18
  148. package/dist/react-native/util/concat.js +2 -86
  149. package/dist/react-native/util/inspect-react-native.d.mts.map +1 -0
  150. package/dist/react-native/util/inspect-react-native.mjs.map +1 -0
  151. package/dist/react-native/util/inspect.common.d.ts +2 -0
  152. package/dist/react-native/util/inspect.common.d.ts.map +1 -0
  153. package/dist/react-native/util/inspect.common.js +4 -0
  154. package/dist/react-native/util/inspect.common.js.map +1 -0
  155. package/dist/react-native/util/inspect.d.ts +2 -2
  156. package/dist/react-native/util/inspect.js +2 -3
  157. package/dist/react-native/util/sha256-react-native.d.mts.map +1 -0
  158. package/dist/react-native/util/sha256-react-native.mjs.map +1 -0
  159. package/dist/react-native/util/sha256.common.d.ts +14 -0
  160. package/dist/react-native/util/sha256.common.d.ts.map +1 -0
  161. package/dist/react-native/util/sha256.common.js +49 -0
  162. package/dist/react-native/util/sha256.common.js.map +1 -0
  163. package/dist/react-native/util/sha256.d.ts +2 -14
  164. package/dist/react-native/util/sha256.js +2 -20
  165. package/dist/react-native/util/userAgent.d.ts +1 -1
  166. package/dist/react-native/util/userAgent.d.ts.map +1 -1
  167. package/dist/react-native/util/userAgent.js +2 -2
  168. package/dist/react-native/util/userAgent.js.map +1 -1
  169. package/dist/react-native/util/userAgentPlatform-react-native.d.mts.map +1 -1
  170. package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +1 -1
  171. package/dist/react-native/util/userAgentPlatform.d.ts +1 -1
  172. package/dist/react-native/util/userAgentPlatform.js +2 -4
  173. package/package.json +2 -2
  174. package/dist/react-native/policies/proxyPolicy.d.ts.map +0 -1
  175. package/dist/react-native/policies/proxyPolicy.js.map +0 -1
  176. package/dist/react-native/util/bytesEncoding.d.ts.map +0 -1
  177. package/dist/react-native/util/bytesEncoding.js.map +0 -1
  178. package/dist/react-native/util/concat.d.ts.map +0 -1
  179. package/dist/react-native/util/concat.js.map +0 -1
  180. package/dist/react-native/util/inspect.d.ts.map +0 -1
  181. package/dist/react-native/util/inspect.js.map +0 -1
  182. package/dist/react-native/util/sha256.d.ts.map +0 -1
  183. package/dist/react-native/util/sha256.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concat.common.d.ts","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":";AAwCA;;;;GAIG;AACH,KAAK,YAAY,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC;AAEnE;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,CAAC,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,CAAC,EAAE,GAC/C,OAAO,CAAC,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAO/C"}
@@ -0,0 +1,45 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { getRawContent } from "./file.js";
4
+ import { isNodeReadableStream, isWebReadableStream } from "./typeGuards.js";
5
+ /**
6
+ * Drain the content of the given ReadableStream into a Blob.
7
+ * The blob's content may end up in memory or on disk dependent on size.
8
+ */
9
+ function drain(stream) {
10
+ return new Response(stream).blob();
11
+ }
12
+ async function toBlobPart(source) {
13
+ if (source instanceof Blob || source instanceof Uint8Array) {
14
+ return source;
15
+ }
16
+ if (isWebReadableStream(source)) {
17
+ return drain(source);
18
+ }
19
+ // If it's not a true Blob, and it's not a Uint8Array, we can assume the source
20
+ // is a fake File created by createFileFromStream and we can get the original stream
21
+ // using getRawContent.
22
+ const rawContent = getRawContent(source);
23
+ // Shouldn't happen but guard for it anyway
24
+ if (isNodeReadableStream(rawContent)) {
25
+ throw new Error("Encountered unexpected type. In the browser, `concat` supports Web ReadableStream, Blob, Uint8Array, and files created using `createFile` only.");
26
+ }
27
+ return toBlobPart(rawContent);
28
+ }
29
+ /**
30
+ * Utility function that concatenates a set of binary inputs into one combined output.
31
+ *
32
+ * @param sources - array of sources for the concatenation
33
+ * @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
34
+ * In browser, returns a `Blob` representing all the concatenated inputs.
35
+ *
36
+ * @internal
37
+ */
38
+ export async function concat(sources) {
39
+ const parts = [];
40
+ for (const source of sources) {
41
+ parts.push(await toBlobPart(typeof source === "function" ? source() : source));
42
+ }
43
+ return new Blob(parts);
44
+ }
45
+ //# sourceMappingURL=concat.common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concat.common.js","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE5E;;;GAGG;AACH,SAAS,KAAK,CAAC,MAAkC;IAC/C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,MAAsD;IAEtD,IAAI,MAAM,YAAY,IAAI,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,+EAA+E;IAC/E,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAEzC,2CAA2C;IAC3C,IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,iJAAiJ,CAClJ,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgD;IAEhD,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getRawContent } from \"./file.js\";\nimport { isNodeReadableStream, 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(\n source: ReadableStream<Uint8Array> | Blob | Uint8Array,\n): Promise<BlobPart> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n }\n\n // If it's not a true Blob, and it's not a Uint8Array, we can assume the source\n // is a fake File created by createFileFromStream and we can get the original stream\n // using getRawContent.\n const rawContent = getRawContent(source);\n\n // Shouldn't happen but guard for it anyway\n if (isNodeReadableStream(rawContent)) {\n throw new Error(\n \"Encountered unexpected type. In the browser, `concat` supports Web ReadableStream, Blob, Uint8Array, and files created using `createFile` only.\",\n );\n }\n\n return toBlobPart(rawContent);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\ntype ConcatSource = ReadableStream<Uint8Array> | Blob | Uint8Array;\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 parts.push(await toBlobPart(typeof source === \"function\" ? source() : source));\n }\n\n return new Blob(parts);\n}\n"]}
@@ -1,19 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /**
3
- * Accepted binary data types for concat
4
- *
5
- * @internal
6
- */
7
- type ConcatSource = ReadableStream<Uint8Array> | Blob | Uint8Array;
8
- /**
9
- * Utility function that concatenates a set of binary inputs into one combined output.
10
- *
11
- * @param sources - array of sources for the concatenation
12
- * @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
13
- * In browser, returns a `Blob` representing all the concatenated inputs.
14
- *
15
- * @internal
16
- */
17
- export declare function concat(sources: (ConcatSource | (() => ConcatSource))[]): Promise<(() => NodeJS.ReadableStream) | Blob>;
18
- export {};
1
+ export * from "./concat.common.js";
19
2
  //# sourceMappingURL=concat-browser.d.mts.map
@@ -1,45 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { getRawContent } from "./file.js";
4
- import { isNodeReadableStream, isWebReadableStream } from "./typeGuards.js";
5
- /**
6
- * Drain the content of the given ReadableStream into a Blob.
7
- * The blob's content may end up in memory or on disk dependent on size.
8
- */
9
- function drain(stream) {
10
- return new Response(stream).blob();
11
- }
12
- async function toBlobPart(source) {
13
- if (source instanceof Blob || source instanceof Uint8Array) {
14
- return source;
15
- }
16
- if (isWebReadableStream(source)) {
17
- return drain(source);
18
- }
19
- // If it's not a true Blob, and it's not a Uint8Array, we can assume the source
20
- // is a fake File created by createFileFromStream and we can get the original stream
21
- // using getRawContent.
22
- const rawContent = getRawContent(source);
23
- // Shouldn't happen but guard for it anyway
24
- if (isNodeReadableStream(rawContent)) {
25
- throw new Error("Encountered unexpected type. In the browser, `concat` supports Web ReadableStream, Blob, Uint8Array, and files created using `createFile` only.");
26
- }
27
- return toBlobPart(rawContent);
28
- }
29
- /**
30
- * Utility function that concatenates a set of binary inputs into one combined output.
31
- *
32
- * @param sources - array of sources for the concatenation
33
- * @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
34
- * In browser, returns a `Blob` representing all the concatenated inputs.
35
- *
36
- * @internal
37
- */
38
- export async function concat(sources) {
39
- const parts = [];
40
- for (const source of sources) {
41
- parts.push(await toBlobPart(typeof source === "function" ? source() : source));
42
- }
43
- return new Blob(parts);
44
- }
3
+ export * from "./concat.common.js";
45
4
  //# sourceMappingURL=concat-browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"inspect-browser.d.mts","sourceRoot":"","sources":["../../../src/util/inspect-browser.mts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,IAAK,CAAC"}
1
+ {"version":3,"file":"inspect-browser.d.mts","sourceRoot":"","sources":["../../../src/util/inspect-browser.mts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"inspect-browser.mjs","sourceRoot":"","sources":["../../../src/util/inspect-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const custom = {};\n"]}
1
+ {"version":3,"file":"inspect-browser.mjs","sourceRoot":"","sources":["../../../src/util/inspect-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./inspect.common.js\";\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const custom: {};
2
+ //# sourceMappingURL=inspect.common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.common.d.ts","sourceRoot":"","sources":["../../../src/util/inspect.common.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,IAAK,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export const custom = {};
4
+ //# sourceMappingURL=inspect.common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.common.js","sourceRoot":"","sources":["../../../src/util/inspect.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const custom = {};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const custom: {};
1
+ export * from "./inspect.common.js";
2
2
  //# sourceMappingURL=inspect-browser.d.mts.map
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- export const custom = {};
3
+ export * from "./inspect.common.js";
4
4
  //# sourceMappingURL=inspect-browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sha256-browser.d.mts","sourceRoot":"","sources":["../../../src/util/sha256-browser.mts"],"names":[],"mappings":"AAmEA;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,QAAQ,GAAG,KAAK,GACzB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,GAAG,KAAK,GACzB,OAAO,CAAC,MAAM,CAAC,CAKjB"}
1
+ {"version":3,"file":"sha256-browser.d.mts","sourceRoot":"","sources":["../../../src/util/sha256-browser.mts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sha256-browser.mjs","sourceRoot":"","sources":["../../../src/util/sha256-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AA6C5E,IAAI,YAAsC,CAAC;AAE3C;;;GAGG;AACH,SAAS,SAAS;IAChB,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IAED,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,YAAoB,EACpB,QAA0B;IAE1B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEpE,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,SAAS,CACtC,KAAK,EACL,QAAQ,EACR;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC1B,EACD,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CACjC;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC1B,EACD,SAAS,EACT,iBAAiB,CAClB,CAAC;IAEF,OAAO,kBAAkB,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA0B;IAE1B,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO,kBAAkB,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { stringToUint8Array, uint8ArrayToString } from \"./bytesEncoding.js\";\n\n// stubs for browser self.crypto\ninterface JsonWebKey {}\ninterface CryptoKey {}\ntype KeyUsage =\n | \"decrypt\"\n | \"deriveBits\"\n | \"deriveKey\"\n | \"encrypt\"\n | \"sign\"\n | \"unwrapKey\"\n | \"verify\"\n | \"wrapKey\";\ninterface Algorithm {\n name: string;\n}\ninterface SubtleCrypto {\n importKey(\n format: string,\n keyData: JsonWebKey,\n algorithm: HmacImportParams,\n extractable: boolean,\n usage: KeyUsage[],\n ): Promise<CryptoKey>;\n sign(\n algorithm: HmacImportParams,\n key: CryptoKey,\n data: ArrayBufferView | ArrayBuffer,\n ): Promise<ArrayBuffer>;\n digest(algorithm: Algorithm, data: ArrayBufferView | ArrayBuffer): Promise<ArrayBuffer>;\n}\ninterface Crypto {\n readonly subtle: SubtleCrypto;\n getRandomValues<T extends ArrayBufferView | null>(array: T): T;\n}\ndeclare const self: {\n crypto: Crypto;\n};\ninterface HmacImportParams {\n name: string;\n hash: Algorithm;\n length?: number;\n}\n\nlet subtleCrypto: SubtleCrypto | undefined;\n\n/**\n * Returns a cached reference to the Web API crypto.subtle object.\n * @internal\n */\nfunction getCrypto(): SubtleCrypto {\n if (subtleCrypto) {\n return subtleCrypto;\n }\n\n if (!self.crypto || !self.crypto.subtle) {\n throw new Error(\"Your browser environment does not support cryptography functions.\");\n }\n\n subtleCrypto = self.crypto.subtle;\n return subtleCrypto;\n}\n\n/**\n * Generates a SHA-256 HMAC signature.\n * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.\n * @param stringToSign - The data to be signed.\n * @param encoding - The textual encoding to use for the returned HMAC digest.\n */\nexport async function computeSha256Hmac(\n key: string,\n stringToSign: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const crypto = getCrypto();\n const keyBytes = stringToUint8Array(key, \"base64\");\n const stringToSignBytes = stringToUint8Array(stringToSign, \"utf-8\");\n\n const cryptoKey = await crypto.importKey(\n \"raw\",\n keyBytes,\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n false,\n [\"sign\"],\n );\n const signature = await crypto.sign(\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n cryptoKey,\n stringToSignBytes,\n );\n\n return uint8ArrayToString(new Uint8Array(signature), encoding);\n}\n\n/**\n * Generates a SHA-256 hash.\n * @param content - The data to be included in the hash.\n * @param encoding - The textual encoding to use for the returned hash.\n */\nexport async function computeSha256Hash(\n content: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const contentBytes = stringToUint8Array(content, \"utf-8\");\n const digest = await getCrypto().digest({ name: \"SHA-256\" }, contentBytes);\n\n return uint8ArrayToString(new Uint8Array(digest), encoding);\n}\n"]}
1
+ {"version":3,"file":"sha256-browser.mjs","sourceRoot":"","sources":["../../../src/util/sha256-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./sha256.common.js\";\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generates a SHA-256 HMAC signature.
3
+ * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.
4
+ * @param stringToSign - The data to be signed.
5
+ * @param encoding - The textual encoding to use for the returned HMAC digest.
6
+ */
7
+ export declare function computeSha256Hmac(key: string, stringToSign: string, encoding: "base64" | "hex"): Promise<string>;
8
+ /**
9
+ * Generates a SHA-256 hash.
10
+ * @param content - The data to be included in the hash.
11
+ * @param encoding - The textual encoding to use for the returned hash.
12
+ */
13
+ export declare function computeSha256Hash(content: string, encoding: "base64" | "hex"): Promise<string>;
14
+ //# sourceMappingURL=sha256.common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha256.common.d.ts","sourceRoot":"","sources":["../../../src/util/sha256.common.ts"],"names":[],"mappings":"AAmEA;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,QAAQ,GAAG,KAAK,GACzB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,GAAG,KAAK,GACzB,OAAO,CAAC,MAAM,CAAC,CAKjB"}
@@ -0,0 +1,49 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { stringToUint8Array, uint8ArrayToString } from "./bytesEncoding.js";
4
+ let subtleCrypto;
5
+ /**
6
+ * Returns a cached reference to the Web API crypto.subtle object.
7
+ * @internal
8
+ */
9
+ function getCrypto() {
10
+ if (subtleCrypto) {
11
+ return subtleCrypto;
12
+ }
13
+ if (!self.crypto || !self.crypto.subtle) {
14
+ throw new Error("Your browser environment does not support cryptography functions.");
15
+ }
16
+ subtleCrypto = self.crypto.subtle;
17
+ return subtleCrypto;
18
+ }
19
+ /**
20
+ * Generates a SHA-256 HMAC signature.
21
+ * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.
22
+ * @param stringToSign - The data to be signed.
23
+ * @param encoding - The textual encoding to use for the returned HMAC digest.
24
+ */
25
+ export async function computeSha256Hmac(key, stringToSign, encoding) {
26
+ const crypto = getCrypto();
27
+ const keyBytes = stringToUint8Array(key, "base64");
28
+ const stringToSignBytes = stringToUint8Array(stringToSign, "utf-8");
29
+ const cryptoKey = await crypto.importKey("raw", keyBytes, {
30
+ name: "HMAC",
31
+ hash: { name: "SHA-256" },
32
+ }, false, ["sign"]);
33
+ const signature = await crypto.sign({
34
+ name: "HMAC",
35
+ hash: { name: "SHA-256" },
36
+ }, cryptoKey, stringToSignBytes);
37
+ return uint8ArrayToString(new Uint8Array(signature), encoding);
38
+ }
39
+ /**
40
+ * Generates a SHA-256 hash.
41
+ * @param content - The data to be included in the hash.
42
+ * @param encoding - The textual encoding to use for the returned hash.
43
+ */
44
+ export async function computeSha256Hash(content, encoding) {
45
+ const contentBytes = stringToUint8Array(content, "utf-8");
46
+ const digest = await getCrypto().digest({ name: "SHA-256" }, contentBytes);
47
+ return uint8ArrayToString(new Uint8Array(digest), encoding);
48
+ }
49
+ //# sourceMappingURL=sha256.common.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IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA0B;IAE1B,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO,kBAAkB,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { stringToUint8Array, uint8ArrayToString } from \"./bytesEncoding.js\";\n\n// stubs for browser self.crypto\ninterface JsonWebKey {}\ninterface CryptoKey {}\ntype KeyUsage =\n | \"decrypt\"\n | \"deriveBits\"\n | \"deriveKey\"\n | \"encrypt\"\n | \"sign\"\n | \"unwrapKey\"\n | \"verify\"\n | \"wrapKey\";\ninterface Algorithm {\n name: string;\n}\ninterface SubtleCrypto {\n importKey(\n format: string,\n keyData: JsonWebKey,\n algorithm: HmacImportParams,\n extractable: boolean,\n usage: KeyUsage[],\n ): Promise<CryptoKey>;\n sign(\n algorithm: HmacImportParams,\n key: CryptoKey,\n data: ArrayBufferView | ArrayBuffer,\n ): Promise<ArrayBuffer>;\n digest(algorithm: Algorithm, data: ArrayBufferView | ArrayBuffer): Promise<ArrayBuffer>;\n}\ninterface Crypto {\n readonly subtle: SubtleCrypto;\n getRandomValues<T extends ArrayBufferView | null>(array: T): T;\n}\ndeclare const self: {\n crypto: Crypto;\n};\ninterface HmacImportParams {\n name: string;\n hash: Algorithm;\n length?: number;\n}\n\nlet subtleCrypto: SubtleCrypto | undefined;\n\n/**\n * Returns a cached reference to the Web API crypto.subtle object.\n * @internal\n */\nfunction getCrypto(): SubtleCrypto {\n if (subtleCrypto) {\n return subtleCrypto;\n }\n\n if (!self.crypto || !self.crypto.subtle) {\n throw new Error(\"Your browser environment does not support cryptography functions.\");\n }\n\n subtleCrypto = self.crypto.subtle;\n return subtleCrypto;\n}\n\n/**\n * Generates a SHA-256 HMAC signature.\n * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.\n * @param stringToSign - The data to be signed.\n * @param encoding - The textual encoding to use for the returned HMAC digest.\n */\nexport async function computeSha256Hmac(\n key: string,\n stringToSign: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const crypto = getCrypto();\n const keyBytes = stringToUint8Array(key, \"base64\");\n const stringToSignBytes = stringToUint8Array(stringToSign, \"utf-8\");\n\n const cryptoKey = await crypto.importKey(\n \"raw\",\n keyBytes,\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n false,\n [\"sign\"],\n );\n const signature = await crypto.sign(\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n cryptoKey,\n stringToSignBytes,\n );\n\n return uint8ArrayToString(new Uint8Array(signature), encoding);\n}\n\n/**\n * Generates a SHA-256 hash.\n * @param content - The data to be included in the hash.\n * @param encoding - The textual encoding to use for the returned hash.\n */\nexport async function computeSha256Hash(\n content: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const contentBytes = stringToUint8Array(content, \"utf-8\");\n const digest = await getCrypto().digest({ name: \"SHA-256\" }, contentBytes);\n\n return uint8ArrayToString(new Uint8Array(digest), encoding);\n}\n"]}
@@ -1,14 +1,2 @@
1
- /**
2
- * Generates a SHA-256 HMAC signature.
3
- * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.
4
- * @param stringToSign - The data to be signed.
5
- * @param encoding - The textual encoding to use for the returned HMAC digest.
6
- */
7
- export declare function computeSha256Hmac(key: string, stringToSign: string, encoding: "base64" | "hex"): Promise<string>;
8
- /**
9
- * Generates a SHA-256 hash.
10
- * @param content - The data to be included in the hash.
11
- * @param encoding - The textual encoding to use for the returned hash.
12
- */
13
- export declare function computeSha256Hash(content: string, encoding: "base64" | "hex"): Promise<string>;
1
+ export * from "./sha256.common.js";
14
2
  //# sourceMappingURL=sha256-browser.d.mts.map
@@ -1,49 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { stringToUint8Array, uint8ArrayToString } from "./bytesEncoding.js";
4
- let subtleCrypto;
5
- /**
6
- * Returns a cached reference to the Web API crypto.subtle object.
7
- * @internal
8
- */
9
- function getCrypto() {
10
- if (subtleCrypto) {
11
- return subtleCrypto;
12
- }
13
- if (!self.crypto || !self.crypto.subtle) {
14
- throw new Error("Your browser environment does not support cryptography functions.");
15
- }
16
- subtleCrypto = self.crypto.subtle;
17
- return subtleCrypto;
18
- }
19
- /**
20
- * Generates a SHA-256 HMAC signature.
21
- * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.
22
- * @param stringToSign - The data to be signed.
23
- * @param encoding - The textual encoding to use for the returned HMAC digest.
24
- */
25
- export async function computeSha256Hmac(key, stringToSign, encoding) {
26
- const crypto = getCrypto();
27
- const keyBytes = stringToUint8Array(key, "base64");
28
- const stringToSignBytes = stringToUint8Array(stringToSign, "utf-8");
29
- const cryptoKey = await crypto.importKey("raw", keyBytes, {
30
- name: "HMAC",
31
- hash: { name: "SHA-256" },
32
- }, false, ["sign"]);
33
- const signature = await crypto.sign({
34
- name: "HMAC",
35
- hash: { name: "SHA-256" },
36
- }, cryptoKey, stringToSignBytes);
37
- return uint8ArrayToString(new Uint8Array(signature), encoding);
38
- }
39
- /**
40
- * Generates a SHA-256 hash.
41
- * @param content - The data to be included in the hash.
42
- * @param encoding - The textual encoding to use for the returned hash.
43
- */
44
- export async function computeSha256Hash(content, encoding) {
45
- const contentBytes = stringToUint8Array(content, "utf-8");
46
- const digest = await getCrypto().digest({ name: "SHA-256" }, contentBytes);
47
- return uint8ArrayToString(new Uint8Array(digest), encoding);
48
- }
3
+ export * from "./sha256.common.js";
49
4
  //# sourceMappingURL=sha256-browser.mjs.map
@@ -5,5 +5,5 @@ export declare function getUserAgentHeaderName(): string;
5
5
  /**
6
6
  * @internal
7
7
  */
8
- export declare function getUserAgentValue(prefix?: string): string;
8
+ export declare function getUserAgentValue(prefix?: string): Promise<string>;
9
9
  //# sourceMappingURL=userAgent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"userAgent.d.ts","sourceRoot":"","sources":["../../../src/util/userAgent.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOzD"}
1
+ {"version":3,"file":"userAgent.d.ts","sourceRoot":"","sources":["../../../src/util/userAgent.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxE"}
@@ -19,10 +19,10 @@ export function getUserAgentHeaderName() {
19
19
  /**
20
20
  * @internal
21
21
  */
22
- export function getUserAgentValue(prefix) {
22
+ export async function getUserAgentValue(prefix) {
23
23
  const runtimeInfo = new Map();
24
24
  runtimeInfo.set("ts-http-runtime", SDK_VERSION);
25
- setPlatformSpecificData(runtimeInfo);
25
+ await setPlatformSpecificData(runtimeInfo);
26
26
  const defaultAgent = getUserAgentString(runtimeInfo);
27
27
  const userAgentValue = prefix ? `${prefix} ${defaultAgent}` : defaultAgent;
28
28
  return userAgentValue;
@@ -1 +1 @@
1
- {"version":3,"file":"userAgent.js","sourceRoot":"","sources":["../../../src/util/userAgent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,SAAS,kBAAkB,CAAC,aAAkC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,aAAa,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,WAAW,CAAC,GAAG,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;IAChD,uBAAuB,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3E,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getHeaderName, setPlatformSpecificData } from \"./userAgentPlatform.js\";\nimport { SDK_VERSION } from \"../constants.js\";\n\nfunction getUserAgentString(telemetryInfo: Map<string, string>): string {\n const parts: string[] = [];\n for (const [key, value] of telemetryInfo) {\n const token = value ? `${key}/${value}` : key;\n parts.push(token);\n }\n return parts.join(\" \");\n}\n\n/**\n * @internal\n */\nexport function getUserAgentHeaderName(): string {\n return getHeaderName();\n}\n\n/**\n * @internal\n */\nexport function getUserAgentValue(prefix?: string): string {\n const runtimeInfo = new Map<string, string>();\n runtimeInfo.set(\"ts-http-runtime\", SDK_VERSION);\n setPlatformSpecificData(runtimeInfo);\n const defaultAgent = getUserAgentString(runtimeInfo);\n const userAgentValue = prefix ? `${prefix} ${defaultAgent}` : defaultAgent;\n return userAgentValue;\n}\n"]}
1
+ {"version":3,"file":"userAgent.js","sourceRoot":"","sources":["../../../src/util/userAgent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,SAAS,kBAAkB,CAAC,aAAkC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,aAAa,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAe;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,WAAW,CAAC,GAAG,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;IAChD,MAAM,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3E,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getHeaderName, setPlatformSpecificData } from \"./userAgentPlatform.js\";\nimport { SDK_VERSION } from \"../constants.js\";\n\nfunction getUserAgentString(telemetryInfo: Map<string, string>): string {\n const parts: string[] = [];\n for (const [key, value] of telemetryInfo) {\n const token = value ? `${key}/${value}` : key;\n parts.push(token);\n }\n return parts.join(\" \");\n}\n\n/**\n * @internal\n */\nexport function getUserAgentHeaderName(): string {\n return getHeaderName();\n}\n\n/**\n * @internal\n */\nexport async function getUserAgentValue(prefix?: string): Promise<string> {\n const runtimeInfo = new Map<string, string>();\n runtimeInfo.set(\"ts-http-runtime\", SDK_VERSION);\n await setPlatformSpecificData(runtimeInfo);\n const defaultAgent = getUserAgentString(runtimeInfo);\n const userAgentValue = prefix ? `${prefix} ${defaultAgent}` : defaultAgent;\n return userAgentValue;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"userAgentPlatform-browser.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAQD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAStE"}
1
+ {"version":3,"file":"userAgentPlatform-browser.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAmCD;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrF"}
@@ -1 +1 @@
1
- {"version":3,"file":"userAgentPlatform-browser.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAQD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAwB;;IAC9D,MAAM,cAAc,GAAG,UAAU,CAAC,SAAwB,CAAC;IAC3D,GAAG,CAAC,GAAG,CACL,IAAI,EACJ,CAAC,MAAA,MAAA,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,aAAa,0CAAE,QAAQ,mCAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,QAAQ,mCAAI,SAAS,CAAC,CAAC,OAAO,CACxF,GAAG,EACH,EAAE,CACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/*\n * NOTE: When moving this file, please update \"browser\" section in package.json.\n */\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\ninterface NavigatorEx extends Navigator {\n userAgentData?: {\n platform?: string;\n };\n}\n\n/**\n * @internal\n */\nexport function setPlatformSpecificData(map: Map<string, string>): void {\n const localNavigator = globalThis.navigator as NavigatorEx;\n map.set(\n \"OS\",\n (localNavigator?.userAgentData?.platform ?? localNavigator?.platform ?? \"unknown\").replace(\n \" \",\n \"\",\n ),\n );\n}\n"]}
1
+ {"version":3,"file":"userAgentPlatform-browser.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAsBD,SAAS,qBAAqB,CAC5B,MAA4C;IAE5C,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5E,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,CAAC;QACzD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAwB;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,SAAwB,CAAC;IAC3D,IAAI,UAAU,GAAG,SAAS,CAAC;IAC3B,IAAI,cAAc,CAAC,aAAa,EAAE,CAAC;QACjC,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAC5E,cAAc;YACd,iBAAiB;SAClB,CAAC,CAAC;QACH,UAAU,GAAG,GAAG,aAAa,CAAC,YAAY,IAAI,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,eAAe,EAAE,CAAC;QAExG,4BAA4B;QAC5B,MAAM,KAAK,GAAG,qBAAqB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,KAAK,EAAE,CAAC;YACV,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,IAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,QAAQ,EAAE,CAAC;QACpC,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC5B,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 NavigatorEx extends Navigator {\n userAgentData?: {\n brands: { brand: string; version: string }[];\n mobile: boolean;\n platform?: string;\n getHighEntropyValues: (hints: string[]) => Promise<{\n architecture: string;\n bitness: string;\n brands: { brand: string; version: string }[];\n formFactor: string;\n fullVersionList: { brand: string; version: string }[];\n mobile: boolean;\n model: string;\n platform: string;\n platformVersion: string;\n wow64: boolean;\n }>;\n };\n}\n\nfunction getBrandVersionString(\n brands: { brand: string; version: string }[],\n): { brand: string; version: string } | undefined {\n const brandOrder = [\"Google Chrome\", \"Microsoft Edge\", \"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 osPlatform = \"unknown\";\n if (localNavigator.userAgentData) {\n const entropyValues = await localNavigator.userAgentData.getHighEntropyValues([\n \"architecture\",\n \"platformVersion\",\n ]);\n osPlatform = `${entropyValues.architecture}-${entropyValues.platform}-${entropyValues.platformVersion}`;\n\n // Get the brand and version\n const brand = getBrandVersionString(entropyValues.brands);\n if (brand) {\n map.set(brand.brand, brand.version);\n }\n } else if (localNavigator?.platform) {\n osPlatform = localNavigator.platform;\n }\n\n map.set(\"OS\", osPlatform);\n}\n"]}
@@ -5,5 +5,5 @@ export declare function getHeaderName(): string;
5
5
  /**
6
6
  * @internal
7
7
  */
8
- export declare function setPlatformSpecificData(map: Map<string, string>): void;
8
+ export declare function setPlatformSpecificData(map: Map<string, string>): Promise<void>;
9
9
  //# sourceMappingURL=userAgentPlatform-browser.d.mts.map
@@ -1,20 +1,42 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- /*
4
- * NOTE: When moving this file, please update "browser" section in package.json.
5
- */
6
3
  /**
7
4
  * @internal
8
5
  */
9
6
  export function getHeaderName() {
10
7
  return "x-ms-useragent";
11
8
  }
9
+ function getBrandVersionString(brands) {
10
+ const brandOrder = ["Google Chrome", "Microsoft Edge", "Brave", "Chromium"];
11
+ for (const brand of brandOrder) {
12
+ const foundBrand = brands.find((b) => b.brand === brand);
13
+ if (foundBrand) {
14
+ return foundBrand;
15
+ }
16
+ }
17
+ return undefined;
18
+ }
12
19
  /**
13
20
  * @internal
14
21
  */
15
- export function setPlatformSpecificData(map) {
16
- var _a, _b, _c;
22
+ export async function setPlatformSpecificData(map) {
17
23
  const localNavigator = globalThis.navigator;
18
- map.set("OS", ((_c = (_b = (_a = localNavigator === null || localNavigator === void 0 ? void 0 : localNavigator.userAgentData) === null || _a === void 0 ? void 0 : _a.platform) !== null && _b !== void 0 ? _b : localNavigator === null || localNavigator === void 0 ? void 0 : localNavigator.platform) !== null && _c !== void 0 ? _c : "unknown").replace(" ", ""));
24
+ let osPlatform = "unknown";
25
+ if (localNavigator.userAgentData) {
26
+ const entropyValues = await localNavigator.userAgentData.getHighEntropyValues([
27
+ "architecture",
28
+ "platformVersion",
29
+ ]);
30
+ osPlatform = `${entropyValues.architecture}-${entropyValues.platform}-${entropyValues.platformVersion}`;
31
+ // Get the brand and version
32
+ const brand = getBrandVersionString(entropyValues.brands);
33
+ if (brand) {
34
+ map.set(brand.brand, brand.version);
35
+ }
36
+ }
37
+ else if (localNavigator === null || localNavigator === void 0 ? void 0 : localNavigator.platform) {
38
+ osPlatform = localNavigator.platform;
39
+ }
40
+ map.set("OS", osPlatform);
19
41
  }
20
42
  //# sourceMappingURL=userAgentPlatform-browser.mjs.map
@@ -0,0 +1,15 @@
1
+ export declare const proxyPolicyName = "proxyPolicy";
2
+ export declare function getDefaultProxySettings(): never;
3
+ /**
4
+ * proxyPolicy is not supported in the browser and attempting
5
+ * to use it will raise an error.
6
+ */
7
+ export declare function proxyPolicy(): never;
8
+ /**
9
+ * A function to reset the cached agents.
10
+ * proxyPolicy is not supported in the browser and attempting
11
+ * to use it will raise an error.
12
+ * @internal
13
+ */
14
+ export declare function resetCachedProxyAgents(): never;
15
+ //# sourceMappingURL=proxyPolicy.common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxyPolicy.common.d.ts","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.common.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAG7C,wBAAgB,uBAAuB,IAAI,KAAK,CAE/C;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,KAAK,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,KAAK,CAE9C"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.resetCachedProxyAgents = exports.proxyPolicy = exports.getDefaultProxySettings = exports.proxyPolicyName = void 0;
6
+ exports.proxyPolicyName = "proxyPolicy";
7
+ const errorMessage = "proxyPolicy is not supported in browser environment";
8
+ function getDefaultProxySettings() {
9
+ throw new Error(errorMessage);
10
+ }
11
+ exports.getDefaultProxySettings = getDefaultProxySettings;
12
+ /**
13
+ * proxyPolicy is not supported in the browser and attempting
14
+ * to use it will raise an error.
15
+ */
16
+ function proxyPolicy() {
17
+ throw new Error(errorMessage);
18
+ }
19
+ exports.proxyPolicy = proxyPolicy;
20
+ /**
21
+ * A function to reset the cached agents.
22
+ * proxyPolicy is not supported in the browser and attempting
23
+ * to use it will raise an error.
24
+ * @internal
25
+ */
26
+ function resetCachedProxyAgents() {
27
+ throw new Error(errorMessage);
28
+ }
29
+ exports.resetCachedProxyAgents = resetCachedProxyAgents;
30
+ //# sourceMappingURL=proxyPolicy.common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxyPolicy.common.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.common.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAErB,QAAA,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM,YAAY,GAAG,qDAAqD,CAAC;AAE3E,SAAgB,uBAAuB;IACrC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAFD,0DAEC;AAED;;;GAGG;AACH,SAAgB,WAAW;IACzB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAFD,kCAEC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB;IACpC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAFD,wDAEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const proxyPolicyName = \"proxyPolicy\";\nconst errorMessage = \"proxyPolicy is not supported in browser environment\";\n\nexport function getDefaultProxySettings(): never {\n throw new Error(errorMessage);\n}\n\n/**\n * proxyPolicy is not supported in the browser and attempting\n * to use it will raise an error.\n */\nexport function proxyPolicy(): never {\n throw new Error(errorMessage);\n}\n\n/**\n * A function to reset the cached agents.\n * proxyPolicy is not supported in the browser and attempting\n * to use it will raise an error.\n * @internal\n */\nexport function resetCachedProxyAgents(): never {\n throw new Error(errorMessage);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tracingPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/tracingPolicy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOhD;;GAEG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,gCAAgC,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,cAAc,CAwChF"}
1
+ {"version":3,"file":"tracingPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/tracingPolicy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOhD;;GAEG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,gCAAgC,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,cAAc,CA0ChF"}
@@ -21,7 +21,7 @@ exports.tracingPolicyName = "tracingPolicy";
21
21
  * @param options - Options to configure the telemetry logged by the tracing policy.
22
22
  */
23
23
  function tracingPolicy(options = {}) {
24
- const userAgent = (0, userAgent_js_1.getUserAgentValue)(options.userAgentPrefix);
24
+ const userAgentValue = (0, userAgent_js_1.getUserAgentValue)(options.userAgentPrefix);
25
25
  const sanitizer = new sanitizer_js_1.Sanitizer({
26
26
  additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,
27
27
  });
@@ -33,6 +33,7 @@ function tracingPolicy(options = {}) {
33
33
  if (!tracingClient || !((_a = request.tracingOptions) === null || _a === void 0 ? void 0 : _a.tracingContext)) {
34
34
  return next(request);
35
35
  }
36
+ const userAgent = await userAgentValue;
36
37
  const spanAttributes = {
37
38
  "http.url": sanitizer.sanitizeUrl(request.url),
38
39
  "http.method": request.method,
@@ -1 +1 @@
1
- {"version":3,"file":"tracingPolicy.js","sourceRoot":"","sources":["../../../src/policies/tracingPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,kEAAkE;AAClE,kDAA8C;AAG9C,uDAAyD;AACzD,sCAAmC;AACnC,+CAA4D;AAC5D,kDAA8C;AAC9C,uDAAiD;AAEjD;;GAEG;AACU,QAAA,iBAAiB,GAAG,eAAe,CAAC;AAmBjD;;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AAC;YACb,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,eAAM,CAAC,OAAO,CAAC,qDAAqD,IAAA,0BAAe,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TracingClient, TracingContext, TracingSpan } from \"../tracing/interfaces.js\";\nimport { createTracingClient } from \"../tracing/tracingClient.js\";\nimport { SDK_VERSION } from \"../constants.js\";\nimport { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport { PipelinePolicy } from \"../pipeline.js\";\nimport { getUserAgentValue } from \"../util/userAgent.js\";\nimport { logger } from \"../log.js\";\nimport { getErrorMessage, isError } from \"../util/error.js\";\nimport { isRestError } from \"../restError.js\";\nimport { Sanitizer } from \"../util/sanitizer.js\";\n\n/**\n * The programmatic identifier of the tracingPolicy.\n */\nexport const tracingPolicyName = \"tracingPolicy\";\n\n/**\n * Options to configure the tracing policy.\n */\nexport interface TracingPolicyOptions {\n /**\n * String prefix to add to the user agent logged as metadata\n * on the generated Span.\n * Defaults to an empty string.\n */\n userAgentPrefix?: string;\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\n/**\n * A simple policy to create OpenTelemetry Spans for each request made by the pipeline\n * that has SpanOptions with a parent.\n * Requests made without a parent Span will not be recorded.\n * @param options - Options to configure the telemetry logged by the tracing policy.\n */\nexport function tracingPolicy(options: TracingPolicyOptions = {}): PipelinePolicy {\n const userAgent = getUserAgentValue(options.userAgentPrefix);\n const sanitizer = new Sanitizer({\n additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,\n });\n const tracingClient = tryCreateTracingClient();\n\n return {\n name: tracingPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!tracingClient || !request.tracingOptions?.tracingContext) {\n return next(request);\n }\n\n const spanAttributes = {\n \"http.url\": sanitizer.sanitizeUrl(request.url),\n \"http.method\": request.method,\n \"http.user_agent\": userAgent,\n requestId: request.requestId,\n };\n if (userAgent) {\n spanAttributes[\"http.user_agent\"] = userAgent;\n }\n\n const { span, tracingContext } = tryCreateSpan(tracingClient, request, spanAttributes) ?? {};\n\n if (!span || !tracingContext) {\n return next(request);\n }\n\n try {\n const response = await tracingClient.withContext(tracingContext, next, request);\n tryProcessResponse(span, response);\n return response;\n } catch (err: any) {\n tryProcessError(span, err);\n throw err;\n }\n },\n };\n}\n\nfunction tryCreateTracingClient(): TracingClient | undefined {\n try {\n return createTracingClient({\n namespace: \"\",\n packageName: \"@typespec/ts-http-runtime\",\n packageVersion: SDK_VERSION,\n });\n } catch (e: unknown) {\n logger.warning(`Error when creating the TracingClient: ${getErrorMessage(e)}`);\n return undefined;\n }\n}\n\nfunction tryCreateSpan(\n tracingClient: TracingClient,\n request: PipelineRequest,\n spanAttributes: Record<string, unknown>,\n): { span: TracingSpan; tracingContext: TracingContext } | undefined {\n try {\n // As per spec, we do not need to differentiate between HTTP and HTTPS in span name.\n const { span, updatedOptions } = tracingClient.startSpan(\n `HTTP ${request.method}`,\n { tracingOptions: request.tracingOptions },\n {\n spanKind: \"client\",\n spanAttributes,\n },\n );\n\n // If the span is not recording, don't do any more work.\n if (!span.isRecording()) {\n span.end();\n return undefined;\n }\n\n // set headers\n const headers = tracingClient.createRequestHeaders(\n updatedOptions.tracingOptions.tracingContext,\n );\n for (const [key, value] of Object.entries(headers)) {\n request.headers.set(key, value);\n }\n return { span, tracingContext: updatedOptions.tracingOptions.tracingContext };\n } catch (e: any) {\n logger.warning(`Skipping creating a tracing span due to an error: ${getErrorMessage(e)}`);\n return undefined;\n }\n}\n\nfunction tryProcessError(span: TracingSpan, error: unknown): void {\n try {\n span.setStatus({\n status: \"error\",\n error: isError(error) ? error : undefined,\n });\n if (isRestError(error) && error.statusCode) {\n span.setAttribute(\"http.status_code\", error.statusCode);\n }\n span.end();\n } catch (e: any) {\n logger.warning(`Skipping tracing span processing due to an error: ${getErrorMessage(e)}`);\n }\n}\n\nfunction tryProcessResponse(span: TracingSpan, response: PipelineResponse): void {\n try {\n span.setAttribute(\"http.status_code\", response.status);\n const serviceRequestId = response.headers.get(\"x-ms-request-id\");\n if (serviceRequestId) {\n span.setAttribute(\"serviceRequestId\", serviceRequestId);\n }\n span.setStatus({\n status: \"success\",\n });\n span.end();\n } catch (e: any) {\n logger.warning(`Skipping tracing span processing due to an error: ${getErrorMessage(e)}`);\n }\n}\n"]}
1
+ {"version":3,"file":"tracingPolicy.js","sourceRoot":"","sources":["../../../src/policies/tracingPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,kEAAkE;AAClE,kDAA8C;AAG9C,uDAAyD;AACzD,sCAAmC;AACnC,+CAA4D;AAC5D,kDAA8C;AAC9C,uDAAiD;AAEjD;;GAEG;AACU,QAAA,iBAAiB,GAAG,eAAe,CAAC;AAmBjD;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,UAAgC,EAAE;IAC9D,MAAM,cAAc,GAAG,IAAA,gCAAiB,EAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,SAAS,GAAG,IAAI,wBAAS,CAAC;QAC9B,gCAAgC,EAAE,OAAO,CAAC,gCAAgC;KAC3E,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,sBAAsB,EAAE,CAAC;IAE/C,OAAO;QACL,IAAI,EAAE,yBAAiB;QACvB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;;YAC3D,IAAI,CAAC,aAAa,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,cAAc,CAAA,EAAE,CAAC;gBAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,SAAS,GAAG,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AS;SAC1C,CAAC,CAAC;QACH,IAAI,IAAA,0BAAW,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YAC3C,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,eAAM,CAAC,OAAO,CAAC,qDAAqD,IAAA,0BAAe,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAiB,EAAE,QAA0B;IACvE,IAAI,CAAC;QACH,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjE,IAAI,gBAAgB,EAAE,CAAC;YACrB,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,eAAM,CAAC,OAAO,CAAC,qDAAqD,IAAA,0BAAe,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TracingClient, TracingContext, TracingSpan } from \"../tracing/interfaces.js\";\nimport { createTracingClient } from \"../tracing/tracingClient.js\";\nimport { SDK_VERSION } from \"../constants.js\";\nimport { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport { PipelinePolicy } from \"../pipeline.js\";\nimport { getUserAgentValue } from \"../util/userAgent.js\";\nimport { logger } from \"../log.js\";\nimport { getErrorMessage, isError } from \"../util/error.js\";\nimport { isRestError } from \"../restError.js\";\nimport { Sanitizer } from \"../util/sanitizer.js\";\n\n/**\n * The programmatic identifier of the tracingPolicy.\n */\nexport const tracingPolicyName = \"tracingPolicy\";\n\n/**\n * Options to configure the tracing policy.\n */\nexport interface TracingPolicyOptions {\n /**\n * String prefix to add to the user agent logged as metadata\n * on the generated Span.\n * Defaults to an empty string.\n */\n userAgentPrefix?: string;\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\n/**\n * A simple policy to create OpenTelemetry Spans for each request made by the pipeline\n * that has SpanOptions with a parent.\n * Requests made without a parent Span will not be recorded.\n * @param options - Options to configure the telemetry logged by the tracing policy.\n */\nexport function tracingPolicy(options: TracingPolicyOptions = {}): PipelinePolicy {\n const userAgentValue = getUserAgentValue(options.userAgentPrefix);\n const sanitizer = new Sanitizer({\n additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,\n });\n const tracingClient = tryCreateTracingClient();\n\n return {\n name: tracingPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!tracingClient || !request.tracingOptions?.tracingContext) {\n return next(request);\n }\n\n const userAgent = await userAgentValue;\n\n const spanAttributes = {\n \"http.url\": sanitizer.sanitizeUrl(request.url),\n \"http.method\": request.method,\n \"http.user_agent\": userAgent,\n requestId: request.requestId,\n };\n if (userAgent) {\n spanAttributes[\"http.user_agent\"] = userAgent;\n }\n\n const { span, tracingContext } = tryCreateSpan(tracingClient, request, spanAttributes) ?? {};\n\n if (!span || !tracingContext) {\n return next(request);\n }\n\n try {\n const response = await tracingClient.withContext(tracingContext, next, request);\n tryProcessResponse(span, response);\n return response;\n } catch (err: any) {\n tryProcessError(span, err);\n throw err;\n }\n },\n };\n}\n\nfunction tryCreateTracingClient(): TracingClient | undefined {\n try {\n return createTracingClient({\n namespace: \"\",\n packageName: \"@typespec/ts-http-runtime\",\n packageVersion: SDK_VERSION,\n });\n } catch (e: unknown) {\n logger.warning(`Error when creating the TracingClient: ${getErrorMessage(e)}`);\n return undefined;\n }\n}\n\nfunction tryCreateSpan(\n tracingClient: TracingClient,\n request: PipelineRequest,\n spanAttributes: Record<string, unknown>,\n): { span: TracingSpan; tracingContext: TracingContext } | undefined {\n try {\n // As per spec, we do not need to differentiate between HTTP and HTTPS in span name.\n const { span, updatedOptions } = tracingClient.startSpan(\n `HTTP ${request.method}`,\n { tracingOptions: request.tracingOptions },\n {\n spanKind: \"client\",\n spanAttributes,\n },\n );\n\n // If the span is not recording, don't do any more work.\n if (!span.isRecording()) {\n span.end();\n return undefined;\n }\n\n // set headers\n const headers = tracingClient.createRequestHeaders(\n updatedOptions.tracingOptions.tracingContext,\n );\n for (const [key, value] of Object.entries(headers)) {\n request.headers.set(key, value);\n }\n return { span, tracingContext: updatedOptions.tracingOptions.tracingContext };\n } catch (e: any) {\n logger.warning(`Skipping creating a tracing span due to an error: ${getErrorMessage(e)}`);\n return undefined;\n }\n}\n\nfunction tryProcessError(span: TracingSpan, error: unknown): void {\n try {\n span.setStatus({\n status: \"error\",\n error: isError(error) ? error : undefined,\n });\n if (isRestError(error) && error.statusCode) {\n span.setAttribute(\"http.status_code\", error.statusCode);\n }\n span.end();\n } catch (e: any) {\n logger.warning(`Skipping tracing span processing due to an error: ${getErrorMessage(e)}`);\n }\n}\n\nfunction tryProcessResponse(span: TracingSpan, response: PipelineResponse): void {\n try {\n span.setAttribute(\"http.status_code\", response.status);\n const serviceRequestId = response.headers.get(\"x-ms-request-id\");\n if (serviceRequestId) {\n span.setAttribute(\"serviceRequestId\", serviceRequestId);\n }\n span.setStatus({\n status: \"success\",\n });\n span.end();\n } catch (e: any) {\n logger.warning(`Skipping tracing span processing due to an error: ${getErrorMessage(e)}`);\n }\n}\n"]}
@@ -20,7 +20,7 @@ function userAgentPolicy(options = {}) {
20
20
  name: exports.userAgentPolicyName,
21
21
  async sendRequest(request, next) {
22
22
  if (!request.headers.has(UserAgentHeaderName)) {
23
- request.headers.set(UserAgentHeaderName, userAgentValue);
23
+ request.headers.set(UserAgentHeaderName, await userAgentValue);
24
24
  }
25
25
  return next(request);
26
26
  },
@@ -1 +1 @@
1
- {"version":3,"file":"userAgentPolicy.js","sourceRoot":"","sources":["../../../src/policies/userAgentPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,uDAAiF;AAEjF,MAAM,mBAAmB,GAAG,IAAA,qCAAsB,GAAE,CAAC;AAErD;;GAEG;AACU,QAAA,mBAAmB,GAAG,iBAAiB,CAAC;AAarD;;;;GAIG;AACH,SAAgB,eAAe,CAAC,UAAkC,EAAE;IAClE,MAAM,cAAc,GAAG,IAAA,gCAAiB,EAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAClE,OAAO;QACL,IAAI,EAAE,2BAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBAC9C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAXD,0CAWC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport { PipelinePolicy } from \"../pipeline.js\";\nimport { getUserAgentHeaderName, getUserAgentValue } from \"../util/userAgent.js\";\n\nconst UserAgentHeaderName = getUserAgentHeaderName();\n\n/**\n * The programmatic identifier of the userAgentPolicy.\n */\nexport const userAgentPolicyName = \"userAgentPolicy\";\n\n/**\n * Options for adding user agent details to outgoing requests.\n */\nexport interface UserAgentPolicyOptions {\n /**\n * String prefix to add to the user agent for outgoing requests.\n * Defaults to an empty string.\n */\n userAgentPrefix?: string;\n}\n\n/**\n * A policy that sets the User-Agent header (or equivalent) to reflect\n * the library version.\n * @param options - Options to customize the user agent value.\n */\nexport function userAgentPolicy(options: UserAgentPolicyOptions = {}): PipelinePolicy {\n const userAgentValue = getUserAgentValue(options.userAgentPrefix);\n return {\n name: userAgentPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!request.headers.has(UserAgentHeaderName)) {\n request.headers.set(UserAgentHeaderName, userAgentValue);\n }\n return next(request);\n },\n };\n}\n"]}
1
+ {"version":3,"file":"userAgentPolicy.js","sourceRoot":"","sources":["../../../src/policies/userAgentPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,uDAAiF;AAEjF,MAAM,mBAAmB,GAAG,IAAA,qCAAsB,GAAE,CAAC;AAErD;;GAEG;AACU,QAAA,mBAAmB,GAAG,iBAAiB,CAAC;AAarD;;;;GAIG;AACH,SAAgB,eAAe,CAAC,UAAkC,EAAE;IAClE,MAAM,cAAc,GAAG,IAAA,gCAAiB,EAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAClE,OAAO;QACL,IAAI,EAAE,2BAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBAC9C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,cAAc,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAXD,0CAWC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport { PipelinePolicy } from \"../pipeline.js\";\nimport { getUserAgentHeaderName, getUserAgentValue } from \"../util/userAgent.js\";\n\nconst UserAgentHeaderName = getUserAgentHeaderName();\n\n/**\n * The programmatic identifier of the userAgentPolicy.\n */\nexport const userAgentPolicyName = \"userAgentPolicy\";\n\n/**\n * Options for adding user agent details to outgoing requests.\n */\nexport interface UserAgentPolicyOptions {\n /**\n * String prefix to add to the user agent for outgoing requests.\n * Defaults to an empty string.\n */\n userAgentPrefix?: string;\n}\n\n/**\n * A policy that sets the User-Agent header (or equivalent) to reflect\n * the library version.\n * @param options - Options to customize the user agent value.\n */\nexport function userAgentPolicy(options: UserAgentPolicyOptions = {}): PipelinePolicy {\n const userAgentValue = getUserAgentValue(options.userAgentPrefix);\n return {\n name: userAgentPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!request.headers.has(UserAgentHeaderName)) {\n request.headers.set(UserAgentHeaderName, await userAgentValue);\n }\n return next(request);\n },\n };\n}\n"]}