@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
@@ -1,88 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { __asyncGenerator, __asyncValues, __await } from "tslib";
4
- import { Readable } from "stream";
5
- import { isBlob } from "./typeGuards.js";
6
- import { getRawContent } from "./file.js";
7
- function streamAsyncIterator() {
8
- return __asyncGenerator(this, arguments, function* streamAsyncIterator_1() {
9
- const reader = this.getReader();
10
- try {
11
- while (true) {
12
- const { done, value } = yield __await(reader.read());
13
- if (done) {
14
- return yield __await(void 0);
15
- }
16
- yield yield __await(value);
17
- }
18
- }
19
- finally {
20
- reader.releaseLock();
21
- }
22
- });
23
- }
24
- function makeAsyncIterable(webStream) {
25
- if (!webStream[Symbol.asyncIterator]) {
26
- webStream[Symbol.asyncIterator] = streamAsyncIterator.bind(webStream);
27
- }
28
- if (!webStream.values) {
29
- webStream.values = streamAsyncIterator.bind(webStream);
30
- }
31
- }
32
- function ensureNodeStream(stream) {
33
- if (stream instanceof ReadableStream) {
34
- makeAsyncIterable(stream);
35
- return Readable.fromWeb(stream);
36
- }
37
- else {
38
- return stream;
39
- }
40
- }
41
- function toStream(source) {
42
- if (source instanceof Uint8Array) {
43
- return Readable.from(Buffer.from(source));
44
- }
45
- else if (isBlob(source)) {
46
- return toStream(getRawContent(source));
47
- }
48
- else {
49
- return ensureNodeStream(source);
50
- }
51
- }
52
- /**
53
- * Utility function that concatenates a set of binary inputs into one combined output.
54
- *
55
- * @param sources - array of sources for the concatenation
56
- * @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
57
- * In browser, returns a `Blob` representing all the concatenated inputs.
58
- *
59
- * @internal
60
- */
61
- export async function concat(sources) {
62
- return function () {
63
- const streams = sources.map((x) => (typeof x === "function" ? x() : x)).map(toStream);
64
- return Readable.from((function () {
65
- return __asyncGenerator(this, arguments, function* () {
66
- var _a, e_1, _b, _c;
67
- for (const stream of streams) {
68
- try {
69
- for (var _d = true, stream_1 = (e_1 = void 0, __asyncValues(stream)), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
70
- _c = stream_1_1.value;
71
- _d = false;
72
- const chunk = _c;
73
- yield yield __await(chunk);
74
- }
75
- }
76
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
77
- finally {
78
- try {
79
- if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
80
- }
81
- finally { if (e_1) throw e_1.error; }
82
- }
83
- }
84
- });
85
- })());
86
- };
87
- }
88
- //# sourceMappingURL=concat.js.map
3
+ export * from "./concat.common.js";
4
+ //# sourceMappingURL=concat-react-native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect-react-native.d.mts","sourceRoot":"","sources":["../../../src/util/inspect-react-native.mts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect-react-native.mjs","sourceRoot":"","sources":["../../../src/util/inspect-react-native.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: symbol;
2
- //# sourceMappingURL=inspect.d.ts.map
1
+ export * from "./inspect.common.js";
2
+ //# sourceMappingURL=inspect-react-native.d.mts.map
@@ -1,5 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { inspect } from "node:util";
4
- export const custom = inspect.custom;
5
- //# sourceMappingURL=inspect.js.map
3
+ export * from "./inspect.common.js";
4
+ //# sourceMappingURL=inspect-react-native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha256-react-native.d.mts","sourceRoot":"","sources":["../../../src/util/sha256-react-native.mts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha256-react-native.mjs","sourceRoot":"","sources":["../../../src/util/sha256-react-native.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.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha256.common.js","sourceRoot":"","sources":["../../../src/util/sha256.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EA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BAAkB,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>;
14
- //# sourceMappingURL=sha256.d.ts.map
1
+ export * from "./sha256.common.js";
2
+ //# sourceMappingURL=sha256-react-native.d.mts.map
@@ -1,22 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { createHash, createHmac } from "node:crypto";
4
- /**
5
- * Generates a SHA-256 HMAC signature.
6
- * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.
7
- * @param stringToSign - The data to be signed.
8
- * @param encoding - The textual encoding to use for the returned HMAC digest.
9
- */
10
- export async function computeSha256Hmac(key, stringToSign, encoding) {
11
- const decodedKey = Buffer.from(key, "base64");
12
- return createHmac("sha256", decodedKey).update(stringToSign).digest(encoding);
13
- }
14
- /**
15
- * Generates a SHA-256 hash.
16
- * @param content - The data to be included in the hash.
17
- * @param encoding - The textual encoding to use for the returned hash.
18
- */
19
- export async function computeSha256Hash(content, encoding) {
20
- return createHash("sha256").update(content).digest(encoding);
21
- }
22
- //# sourceMappingURL=sha256.js.map
3
+ export * from "./sha256.common.js";
4
+ //# sourceMappingURL=sha256-react-native.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-react-native.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAMtE"}
1
+ {"version":3,"file":"userAgentPlatform-react-native.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrF"}
@@ -1 +1 @@
1
- {"version":3,"file":"userAgentPlatform-react-native.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,6DAA6D;AAC7D,gBAAgB;AAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAwB;;IAC9D,IAAI,MAAA,QAAQ,CAAC,SAAS,0CAAE,kBAAkB,EAAE,CAAC;QAC3C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,kBAAkB,CAAC;QACtE,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n/* @ts-ignore */\nconst { Platform } = await import(\"react-native\");\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\n/**\n * @internal\n */\nexport function setPlatformSpecificData(map: Map<string, string>): void {\n if (Platform.constants?.reactNativeVersion) {\n const { major, minor, patch } = Platform.constants.reactNativeVersion;\n map.set(\"react-native\", `${major}.${minor}.${patch}`);\n }\n map.set(\"OS\", `${Platform.OS}-${Platform.Version}`);\n}\n"]}
1
+ {"version":3,"file":"userAgentPlatform-react-native.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAwB;;IACpE,IAAI,MAAA,QAAQ,CAAC,SAAS,0CAAE,kBAAkB,EAAE,CAAC;QAC3C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,kBAAkB,CAAC;QACtE,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Platform } from \"react-native\";\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\n/**\n * @internal\n */\nexport async function setPlatformSpecificData(map: Map<string, string>): Promise<void> {\n if (Platform.constants?.reactNativeVersion) {\n const { major, minor, patch } = Platform.constants.reactNativeVersion;\n map.set(\"react-native\", `${major}.${minor}.${patch}`);\n }\n map.set(\"OS\", `${Platform.OS}-${Platform.Version}`);\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-react-native.d.mts.map
@@ -1,8 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
- /* @ts-ignore */
5
- const { Platform } = await import("react-native");
3
+ import { Platform } from "react-native";
6
4
  /**
7
5
  * @internal
8
6
  */
@@ -12,7 +10,7 @@ export function getHeaderName() {
12
10
  /**
13
11
  * @internal
14
12
  */
15
- export function setPlatformSpecificData(map) {
13
+ export async function setPlatformSpecificData(map) {
16
14
  var _a;
17
15
  if ((_a = Platform.constants) === null || _a === void 0 ? void 0 : _a.reactNativeVersion) {
18
16
  const { major, minor, patch } = Platform.constants.reactNativeVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/ts-http-runtime",
3
- "version": "1.0.0-alpha.20240618.1",
3
+ "version": "1.0.0-alpha.20240621.10",
4
4
  "description": "Isomorphic client library for making HTTP requests in node.js and browser.",
5
5
  "sdk-type": "client",
6
6
  "type": "module",
@@ -99,7 +99,7 @@
99
99
  },
100
100
  "devDependencies": {
101
101
  "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
102
- "@azure/eslint-plugin-azure-sdk": "^3.0.0",
102
+ "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
103
103
  "@azure-tools/vite-plugin-browser-test-map": ">=1.0.0-alpha <1.0.0-alphb",
104
104
  "@microsoft/api-extractor": "^7.40.3",
105
105
  "@types/node": "^18.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxyPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQrD;;GAEG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAAO,CAAC;AAkE9C,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAWtC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAgBpF;AAyED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,aAAa,CAAC,EAAE,aAAa,EAC7B,OAAO,CAAC,EAAE;IACR,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B,GACA,cAAc,CAkChB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxyPolicy.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQlD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B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B,CAAC,IAAI,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,YAAY,GAAG,aAAa;QAChC,CAAC,CAAC,uBAAuB,CAAC,aAAa,CAAC;QACxC,CAAC,CAAC,+BAA+B,EAAE,CAAC;IAEtC,MAAM,YAAY,GAAiB,EAAE,CAAC;IAEtC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;;YAC3D,IACE,CAAC,OAAO,CAAC,aAAa;gBACtB,YAAY;gBACZ,CAAC,UAAU,CACT,OAAO,CAAC,GAAG,EACX,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,mCAAI,iBAAiB,EAC/C,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAC3D,EACD,CAAC;gBACD,sBAAsB,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;YAC9D,CAAC;iBAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;gBACjC,sBAAsB,CACpB,OAAO,EACP,YAAY,EACZ,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAC/C,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport type * as http from \"http\";\nimport type * as https from \"https\";\nimport { HttpsProxyAgent } from \"https-proxy-agent\";\nimport { HttpProxyAgent } from \"http-proxy-agent\";\nimport type {\n PipelineRequest,\n PipelineResponse,\n ProxySettings,\n SendRequest,\n} from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { logger } from \"../log.js\";\n\nconst HTTPS_PROXY = \"HTTPS_PROXY\";\nconst HTTP_PROXY = \"HTTP_PROXY\";\nconst ALL_PROXY = \"ALL_PROXY\";\nconst NO_PROXY = \"NO_PROXY\";\n\n/**\n * The programmatic identifier of the proxyPolicy.\n */\nexport const proxyPolicyName = \"proxyPolicy\";\n\n/**\n * Stores the patterns specified in NO_PROXY environment variable.\n * @internal\n */\nexport const globalNoProxyList: string[] = [];\nlet noProxyListLoaded: boolean = false;\n\n/** A cache of whether a host should bypass the proxy. */\nconst globalBypassedMap: Map<string, boolean> = new Map();\n\nfunction getEnvironmentValue(name: string): string | undefined {\n if (process.env[name]) {\n return process.env[name];\n } else if (process.env[name.toLowerCase()]) {\n return process.env[name.toLowerCase()];\n }\n return undefined;\n}\n\nfunction loadEnvironmentProxyValue(): string | undefined {\n if (!process) {\n return undefined;\n }\n\n const httpsProxy = getEnvironmentValue(HTTPS_PROXY);\n const allProxy = getEnvironmentValue(ALL_PROXY);\n const httpProxy = getEnvironmentValue(HTTP_PROXY);\n\n return httpsProxy || allProxy || httpProxy;\n}\n\n/**\n * Check whether the host of a given `uri` matches any pattern in the no proxy list.\n * If there's a match, any request sent to the same host shouldn't have the proxy settings set.\n * This implementation is a port of https://github.com/Azure/azure-sdk-for-net/blob/8cca811371159e527159c7eb65602477898683e2/sdk/core/Azure.Core/src/Pipeline/Internal/HttpEnvironmentProxy.cs#L210\n */\nfunction isBypassed(\n uri: string,\n noProxyList: string[],\n bypassedMap?: Map<string, boolean>,\n): boolean | undefined {\n if (noProxyList.length === 0) {\n return false;\n }\n const host = new URL(uri).hostname;\n if (bypassedMap?.has(host)) {\n return bypassedMap.get(host);\n }\n let isBypassedFlag = false;\n for (const pattern of noProxyList) {\n if (pattern[0] === \".\") {\n // This should match either domain it self or any subdomain or host\n // .foo.com will match foo.com it self or *.foo.com\n if (host.endsWith(pattern)) {\n isBypassedFlag = true;\n } else {\n if (host.length === pattern.length - 1 && host === pattern.slice(1)) {\n isBypassedFlag = true;\n }\n }\n } else {\n if (host === pattern) {\n isBypassedFlag = true;\n }\n }\n }\n bypassedMap?.set(host, isBypassedFlag);\n return isBypassedFlag;\n}\n\nexport function loadNoProxy(): string[] {\n const noProxy = getEnvironmentValue(NO_PROXY);\n noProxyListLoaded = true;\n if (noProxy) {\n return noProxy\n .split(\",\")\n .map((item) => item.trim())\n .filter((item) => item.length);\n }\n\n return [];\n}\n\n/**\n * This method converts a proxy url into `ProxySettings` for use with ProxyPolicy.\n * If no argument is given, it attempts to parse a proxy URL from the environment\n * variables `HTTPS_PROXY` or `HTTP_PROXY`.\n * @param proxyUrl - The url of the proxy to use. May contain authentication information.\n * @deprecated - Internally this method is no longer necessary when setting proxy information.\n */\nexport function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined {\n if (!proxyUrl) {\n proxyUrl = loadEnvironmentProxyValue();\n if (!proxyUrl) {\n return undefined;\n }\n }\n\n const parsedUrl = new URL(proxyUrl);\n const schema = parsedUrl.protocol ? parsedUrl.protocol + \"//\" : \"\";\n return {\n host: schema + parsedUrl.hostname,\n port: Number.parseInt(parsedUrl.port || \"80\"),\n username: parsedUrl.username,\n password: parsedUrl.password,\n };\n}\n\n/**\n * This method attempts to parse a proxy URL from the environment\n * variables `HTTPS_PROXY` or `HTTP_PROXY`.\n */\nfunction getDefaultProxySettingsInternal(): URL | undefined {\n const envProxy = loadEnvironmentProxyValue();\n return envProxy ? new URL(envProxy) : undefined;\n}\n\nfunction getUrlFromProxySettings(settings: ProxySettings): URL {\n let parsedProxyUrl: URL;\n try {\n parsedProxyUrl = new URL(settings.host);\n } catch (_error) {\n throw new Error(\n `Expecting a valid host string in proxy settings, but found \"${settings.host}\".`,\n );\n }\n\n parsedProxyUrl.port = String(settings.port);\n if (settings.username) {\n parsedProxyUrl.username = settings.username;\n }\n if (settings.password) {\n parsedProxyUrl.password = settings.password;\n }\n\n return parsedProxyUrl;\n}\n\nfunction setProxyAgentOnRequest(\n request: PipelineRequest,\n cachedAgents: CachedAgents,\n proxyUrl: URL,\n): void {\n // Custom Agent should take precedence so if one is present\n // we should skip to avoid overwriting it.\n if (request.agent) {\n return;\n }\n\n const url = new URL(request.url);\n\n const isInsecure = url.protocol !== \"https:\";\n\n if (request.tlsSettings) {\n logger.warning(\n \"TLS settings are not supported in combination with custom Proxy, certificates provided to the client will be ignored.\",\n );\n }\n\n const headers = request.headers.toJSON();\n\n if (isInsecure) {\n if (!cachedAgents.httpProxyAgent) {\n cachedAgents.httpProxyAgent = new HttpProxyAgent(proxyUrl, { headers });\n }\n request.agent = cachedAgents.httpProxyAgent;\n } else {\n if (!cachedAgents.httpsProxyAgent) {\n cachedAgents.httpsProxyAgent = new HttpsProxyAgent(proxyUrl, { headers });\n }\n request.agent = cachedAgents.httpsProxyAgent;\n }\n}\n\ninterface CachedAgents {\n httpsProxyAgent?: https.Agent;\n httpProxyAgent?: http.Agent;\n}\n\n/**\n * A policy that allows one to apply proxy settings to all requests.\n * If not passed static settings, they will be retrieved from the HTTPS_PROXY\n * or HTTP_PROXY environment variables.\n * @param proxySettings - ProxySettings to use on each request.\n * @param options - additional settings, for example, custom NO_PROXY patterns\n */\nexport function proxyPolicy(\n proxySettings?: ProxySettings,\n options?: {\n /** a list of patterns to override those loaded from NO_PROXY environment variable. */\n customNoProxyList?: string[];\n },\n): PipelinePolicy {\n if (!noProxyListLoaded) {\n globalNoProxyList.push(...loadNoProxy());\n }\n\n const defaultProxy = proxySettings\n ? getUrlFromProxySettings(proxySettings)\n : getDefaultProxySettingsInternal();\n\n const cachedAgents: CachedAgents = {};\n\n return {\n name: proxyPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (\n !request.proxySettings &&\n defaultProxy &&\n !isBypassed(\n request.url,\n options?.customNoProxyList ?? globalNoProxyList,\n options?.customNoProxyList ? undefined : globalBypassedMap,\n )\n ) {\n setProxyAgentOnRequest(request, cachedAgents, defaultProxy);\n } else if (request.proxySettings) {\n setProxyAgentOnRequest(\n request,\n cachedAgents,\n getUrlFromProxySettings(request.proxySettings),\n );\n }\n return next(request);\n },\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"bytesEncoding.d.ts","sourceRoot":"","sources":["../../../src/util/bytesEncoding.ts"],"names":[],"mappings":"AAGA,4CAA4C;AAC5C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,UAAU,CAElF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"bytesEncoding.js","sourceRoot":"","sources":["../../../src/util/bytesEncoding.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB,EAAE,MAAoB;IACxE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa,EAAE,MAAoB;IACpE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** The supported character encoding type */\nexport type EncodingType = \"utf-8\" | \"base64\" | \"base64url\" | \"hex\";\n\n/**\n * The helper that transforms bytes with specific character encoding into string\n * @param bytes - the uint8array bytes\n * @param format - the format we use to encode the byte\n * @returns a string of the encoded string\n */\nexport function uint8ArrayToString(bytes: Uint8Array, format: EncodingType): string {\n return Buffer.from(bytes).toString(format);\n}\n\n/**\n * The helper that transforms string to specific character encoded bytes array.\n * @param value - the string to be converted\n * @param format - the format we use to decode the value\n * @returns a uint8array\n */\nexport function stringToUint8Array(value: string, format: EncodingType): Uint8Array {\n return Buffer.from(value, format);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"concat.d.ts","sourceRoot":"","sources":["../../../src/util/concat.ts"],"names":[],"mappings":";AA2DA;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,UAAU,GAAG,IAAI,CAAC;AAElG;;;;;;;;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,CAc/C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/util/concat.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,SAAgB,mBAAmB;;QAGjC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,cAAM,MAAM,CAAC,IAAI,EAAE,CAAA,CAAC;gBAC5C,IAAI,IAAI,EAAE,CAAC;oBACT,6BAAO;gBACT,CAAC;gBAED,oBAAM,KAAK,CAAA,CAAC;YACd,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CAAA;AAED,SAAS,iBAAiB,CAAI,SAAc;IAC1C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC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OAAkC,EAAE,CAAC;;wBACxD,KAA0B,eAAA,0BAAA,cAAA,MAAM,CAAA,CAAA,YAAA,qFAAE,CAAC;4BAAT,sBAAM;4BAAN,WAAM;4BAArB,MAAM,KAAK,KAAA,CAAA;4BACpB,oBAAM,KAAK,CAAA,CAAC;wBACd,CAAC;;;;;;;;;gBACH,CAAC;YACH,CAAC;SAAA,CAAC,EAAE,CACL,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Readable } from \"stream\";\nimport type { ReadableStream as AsyncIterableReadableStream } from \"stream/web\";\nimport { isBlob } from \"./typeGuards.js\";\nimport { getRawContent } from \"./file.js\";\n\nasync function* streamAsyncIterator(\n this: ReadableStream<Uint8Array>,\n): AsyncIterableIterator<Uint8Array> {\n const reader = this.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n return;\n }\n\n yield value;\n }\n } finally {\n reader.releaseLock();\n }\n}\n\nfunction makeAsyncIterable<T>(webStream: any): asserts webStream is AsyncIterableReadableStream<T> {\n if (!webStream[Symbol.asyncIterator]) {\n webStream[Symbol.asyncIterator] = streamAsyncIterator.bind(webStream);\n }\n\n if (!webStream.values) {\n webStream.values = streamAsyncIterator.bind(webStream);\n }\n}\n\nfunction ensureNodeStream(\n stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n): NodeJS.ReadableStream {\n if (stream instanceof ReadableStream) {\n makeAsyncIterable<Uint8Array>(stream);\n return Readable.fromWeb(stream);\n } else {\n return stream;\n }\n}\n\nfunction toStream(\n source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob,\n): NodeJS.ReadableStream {\n if (source instanceof Uint8Array) {\n return Readable.from(Buffer.from(source));\n } else if (isBlob(source)) {\n return toStream(getRawContent(source));\n } else {\n return ensureNodeStream(source);\n }\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 return function () {\n const streams = sources.map((x) => (typeof x === \"function\" ? x() : x)).map(toStream);\n\n return Readable.from(\n (async function* () {\n for (const stream of streams as NodeJS.ReadableStream[]) {\n for await (const chunk of stream) {\n yield chunk;\n }\n }\n })(),\n );\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../src/util/inspect.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,QAAiB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../../src/util/inspect.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { inspect } from \"node:util\";\n\nexport const custom = inspect.custom;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../../src/util/sha256.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,QAAQ,GAAG,KAAK,GACzB,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,GAAG,KAAK,GACzB,OAAO,CAAC,MAAM,CAAC,CAEjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../../src/util/sha256.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,YAAoB,EACpB,QAA0B;IAE1B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE9C,OAAO,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,QAA0B;IAE1B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHash, createHmac } from \"node:crypto\";\n\n/**\n * Generates a SHA-256 HMAC signature.\n * @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.\n * @param stringToSign - The data to be signed.\n * @param encoding - The textual encoding to use for the returned HMAC digest.\n */\nexport async function computeSha256Hmac(\n key: string,\n stringToSign: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n const decodedKey = Buffer.from(key, \"base64\");\n\n return createHmac(\"sha256\", decodedKey).update(stringToSign).digest(encoding);\n}\n\n/**\n * Generates a SHA-256 hash.\n * @param content - The data to be included in the hash.\n * @param encoding - The textual encoding to use for the returned hash.\n */\nexport async function computeSha256Hash(\n content: string,\n encoding: \"base64\" | \"hex\",\n): Promise<string> {\n return createHash(\"sha256\").update(content).digest(encoding);\n}\n"]}