@typespec/ts-http-runtime 1.0.0-alpha.20240614.3 → 1.0.0-alpha.20240619.3
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.
- package/dist/browser/logger/log-browser.d.mts.map +1 -1
- package/dist/browser/logger/log-browser.mjs.map +1 -1
- package/dist/browser/logger/log.common.d.ts +2 -0
- package/dist/browser/logger/log.common.d.ts.map +1 -0
- package/dist/browser/logger/log.common.js +23 -0
- package/dist/browser/logger/log.common.js.map +1 -0
- package/dist/browser/logger/log.d.ts +1 -1
- package/dist/browser/logger/log.js +1 -20
- package/dist/browser/policies/proxyPolicy-browser.d.mts.map +1 -1
- package/dist/browser/policies/proxyPolicy-browser.mjs.map +1 -1
- package/dist/browser/policies/proxyPolicy.common.d.ts +15 -0
- package/dist/browser/policies/proxyPolicy.common.d.ts.map +1 -0
- package/dist/browser/policies/proxyPolicy.common.js +24 -0
- package/dist/browser/policies/proxyPolicy.common.js.map +1 -0
- package/dist/browser/policies/proxyPolicy.d.ts +1 -14
- package/dist/browser/policies/proxyPolicy.js +1 -24
- package/dist/browser/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/browser/policies/tracingPolicy.js +2 -1
- package/dist/browser/policies/tracingPolicy.js.map +1 -1
- package/dist/browser/policies/userAgentPolicy.js +1 -1
- package/dist/browser/policies/userAgentPolicy.js.map +1 -1
- package/dist/browser/util/bytesEncoding-browser.d.mts.map +1 -1
- package/dist/browser/util/bytesEncoding-browser.mjs.map +1 -1
- package/dist/browser/util/bytesEncoding.common.d.ts +61 -0
- package/dist/browser/util/bytesEncoding.common.d.ts.map +1 -0
- package/dist/browser/util/bytesEncoding.common.js +110 -0
- package/dist/browser/util/bytesEncoding.common.js.map +1 -0
- package/dist/browser/util/bytesEncoding.d.ts +1 -60
- package/dist/browser/util/bytesEncoding.js +1 -107
- package/dist/browser/util/concat-browser.d.mts.map +1 -1
- package/dist/browser/util/concat-browser.mjs.map +1 -1
- package/dist/browser/util/concat.common.d.ts +19 -0
- package/dist/browser/util/concat.common.d.ts.map +1 -0
- package/dist/browser/util/concat.common.js +45 -0
- package/dist/browser/util/concat.common.js.map +1 -0
- package/dist/browser/util/concat.d.ts +1 -18
- package/dist/browser/util/concat.js +1 -42
- package/dist/browser/util/inspect-browser.d.mts.map +1 -1
- package/dist/browser/util/inspect-browser.mjs.map +1 -1
- package/dist/browser/util/inspect.common.d.ts +2 -0
- package/dist/browser/util/inspect.common.d.ts.map +1 -0
- package/dist/browser/util/inspect.common.js +4 -0
- package/dist/browser/util/inspect.common.js.map +1 -0
- package/dist/browser/util/inspect.d.ts +1 -1
- package/dist/browser/util/inspect.js +1 -1
- package/dist/browser/util/sha256-browser.d.mts.map +1 -1
- package/dist/browser/util/sha256-browser.mjs.map +1 -1
- package/dist/browser/util/sha256.common.d.ts +14 -0
- package/dist/browser/util/sha256.common.d.ts.map +1 -0
- package/dist/browser/util/sha256.common.js +49 -0
- package/dist/browser/util/sha256.common.js.map +1 -0
- package/dist/browser/util/sha256.d.ts +1 -13
- package/dist/browser/util/sha256.js +1 -46
- package/dist/browser/util/userAgent.d.ts +1 -1
- package/dist/browser/util/userAgent.d.ts.map +1 -1
- package/dist/browser/util/userAgent.js +2 -2
- package/dist/browser/util/userAgent.js.map +1 -1
- package/dist/browser/util/userAgentPlatform-browser.d.mts.map +1 -1
- package/dist/browser/util/userAgentPlatform-browser.mjs.map +1 -1
- package/dist/browser/util/userAgentPlatform.d.ts +1 -1
- package/dist/browser/util/userAgentPlatform.js +36 -6
- package/dist/commonjs/logger/log.common.d.ts +2 -0
- package/dist/commonjs/logger/log.common.d.ts.map +1 -0
- package/dist/commonjs/logger/log.common.js +27 -0
- package/dist/commonjs/logger/log.common.js.map +1 -0
- package/dist/commonjs/policies/proxyPolicy.common.d.ts +15 -0
- package/dist/commonjs/policies/proxyPolicy.common.d.ts.map +1 -0
- package/dist/commonjs/policies/proxyPolicy.common.js +30 -0
- package/dist/commonjs/policies/proxyPolicy.common.js.map +1 -0
- package/dist/commonjs/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/tracingPolicy.js +2 -1
- package/dist/commonjs/policies/tracingPolicy.js.map +1 -1
- package/dist/commonjs/policies/userAgentPolicy.js +1 -1
- package/dist/commonjs/policies/userAgentPolicy.js.map +1 -1
- package/dist/commonjs/util/bytesEncoding.common.d.ts +61 -0
- package/dist/commonjs/util/bytesEncoding.common.d.ts.map +1 -0
- package/dist/commonjs/util/bytesEncoding.common.js +123 -0
- package/dist/commonjs/util/bytesEncoding.common.js.map +1 -0
- package/dist/commonjs/util/concat.common.d.ts +19 -0
- package/dist/commonjs/util/concat.common.d.ts.map +1 -0
- package/dist/commonjs/util/concat.common.js +49 -0
- package/dist/commonjs/util/concat.common.js.map +1 -0
- package/dist/commonjs/util/inspect.common.d.ts +2 -0
- package/dist/commonjs/util/inspect.common.d.ts.map +1 -0
- package/dist/commonjs/util/inspect.common.js +7 -0
- package/dist/commonjs/util/inspect.common.js.map +1 -0
- package/dist/commonjs/util/sha256.common.d.ts +14 -0
- package/dist/commonjs/util/sha256.common.d.ts.map +1 -0
- package/dist/commonjs/util/sha256.common.js +54 -0
- package/dist/commonjs/util/sha256.common.js.map +1 -0
- package/dist/commonjs/util/userAgent.d.ts +1 -1
- package/dist/commonjs/util/userAgent.d.ts.map +1 -1
- package/dist/commonjs/util/userAgent.js +2 -2
- package/dist/commonjs/util/userAgent.js.map +1 -1
- package/dist/commonjs/util/userAgentPlatform.d.ts +1 -1
- package/dist/commonjs/util/userAgentPlatform.d.ts.map +1 -1
- package/dist/commonjs/util/userAgentPlatform.js +1 -1
- package/dist/commonjs/util/userAgentPlatform.js.map +1 -1
- package/dist/esm/logger/log.common.d.ts +2 -0
- package/dist/esm/logger/log.common.d.ts.map +1 -0
- package/dist/esm/logger/log.common.js +23 -0
- package/dist/esm/logger/log.common.js.map +1 -0
- package/dist/esm/policies/proxyPolicy.common.d.ts +15 -0
- package/dist/esm/policies/proxyPolicy.common.d.ts.map +1 -0
- package/dist/esm/policies/proxyPolicy.common.js +24 -0
- package/dist/esm/policies/proxyPolicy.common.js.map +1 -0
- package/dist/esm/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/esm/policies/tracingPolicy.js +2 -1
- package/dist/esm/policies/tracingPolicy.js.map +1 -1
- package/dist/esm/policies/userAgentPolicy.js +1 -1
- package/dist/esm/policies/userAgentPolicy.js.map +1 -1
- package/dist/esm/util/bytesEncoding.common.d.ts +61 -0
- package/dist/esm/util/bytesEncoding.common.d.ts.map +1 -0
- package/dist/esm/util/bytesEncoding.common.js +110 -0
- package/dist/esm/util/bytesEncoding.common.js.map +1 -0
- package/dist/esm/util/concat.common.d.ts +19 -0
- package/dist/esm/util/concat.common.d.ts.map +1 -0
- package/dist/esm/util/concat.common.js +45 -0
- package/dist/esm/util/concat.common.js.map +1 -0
- package/dist/esm/util/inspect.common.d.ts +2 -0
- package/dist/esm/util/inspect.common.d.ts.map +1 -0
- package/dist/esm/util/inspect.common.js +4 -0
- package/dist/esm/util/inspect.common.js.map +1 -0
- package/dist/esm/util/sha256.common.d.ts +14 -0
- package/dist/esm/util/sha256.common.d.ts.map +1 -0
- package/dist/esm/util/sha256.common.js +49 -0
- package/dist/esm/util/sha256.common.js.map +1 -0
- package/dist/esm/util/userAgent.d.ts +1 -1
- package/dist/esm/util/userAgent.d.ts.map +1 -1
- package/dist/esm/util/userAgent.js +2 -2
- package/dist/esm/util/userAgent.js.map +1 -1
- package/dist/esm/util/userAgentPlatform.d.ts +1 -1
- package/dist/esm/util/userAgentPlatform.d.ts.map +1 -1
- package/dist/esm/util/userAgentPlatform.js +1 -1
- package/dist/esm/util/userAgentPlatform.js.map +1 -1
- package/dist/react-native/logger/log-react-native.d.mts.map +1 -0
- package/dist/react-native/logger/log-react-native.mjs.map +1 -0
- package/dist/react-native/logger/log.common.d.ts +2 -0
- package/dist/react-native/logger/log.common.d.ts.map +1 -0
- package/dist/react-native/logger/log.common.js +23 -0
- package/dist/react-native/logger/log.common.js.map +1 -0
- package/dist/react-native/logger/log.d.ts +2 -2
- package/dist/react-native/logger/log.js +2 -7
- package/dist/react-native/policies/proxyPolicy-react-native.d.mts.map +1 -0
- package/dist/react-native/policies/proxyPolicy-react-native.mjs.map +1 -0
- package/dist/react-native/policies/proxyPolicy.common.d.ts +15 -0
- package/dist/react-native/policies/proxyPolicy.common.d.ts.map +1 -0
- package/dist/react-native/policies/proxyPolicy.common.js +24 -0
- package/dist/react-native/policies/proxyPolicy.common.js.map +1 -0
- package/dist/react-native/policies/proxyPolicy.d.ts +2 -32
- package/dist/react-native/policies/proxyPolicy.js +2 -189
- package/dist/react-native/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/tracingPolicy.js +2 -1
- package/dist/react-native/policies/tracingPolicy.js.map +1 -1
- package/dist/react-native/policies/userAgentPolicy.js +1 -1
- package/dist/react-native/policies/userAgentPolicy.js.map +1 -1
- package/dist/react-native/util/bytesEncoding-react-native.d.mts.map +1 -0
- package/dist/react-native/util/bytesEncoding-react-native.mjs.map +1 -0
- package/dist/react-native/util/bytesEncoding.common.d.ts +61 -0
- package/dist/react-native/util/bytesEncoding.common.d.ts.map +1 -0
- package/dist/react-native/util/bytesEncoding.common.js +110 -0
- package/dist/react-native/util/bytesEncoding.common.js.map +1 -0
- package/dist/react-native/util/bytesEncoding.d.ts +2 -17
- package/dist/react-native/util/bytesEncoding.js +2 -19
- package/dist/react-native/util/concat-react-native.d.mts.map +1 -0
- package/dist/react-native/util/concat-react-native.mjs.map +1 -0
- package/dist/react-native/util/concat.common.d.ts +19 -0
- package/dist/react-native/util/concat.common.d.ts.map +1 -0
- package/dist/react-native/util/concat.common.js +45 -0
- package/dist/react-native/util/concat.common.js.map +1 -0
- package/dist/react-native/util/concat.d.ts +2 -18
- package/dist/react-native/util/concat.js +2 -86
- package/dist/react-native/util/inspect-react-native.d.mts.map +1 -0
- package/dist/react-native/util/inspect-react-native.mjs.map +1 -0
- package/dist/react-native/util/inspect.common.d.ts +2 -0
- package/dist/react-native/util/inspect.common.d.ts.map +1 -0
- package/dist/react-native/util/inspect.common.js +4 -0
- package/dist/react-native/util/inspect.common.js.map +1 -0
- package/dist/react-native/util/inspect.d.ts +2 -2
- package/dist/react-native/util/inspect.js +2 -3
- package/dist/react-native/util/sha256-react-native.d.mts.map +1 -0
- package/dist/react-native/util/sha256-react-native.mjs.map +1 -0
- package/dist/react-native/util/sha256.common.d.ts +14 -0
- package/dist/react-native/util/sha256.common.d.ts.map +1 -0
- package/dist/react-native/util/sha256.common.js +49 -0
- package/dist/react-native/util/sha256.common.js.map +1 -0
- package/dist/react-native/util/sha256.d.ts +2 -14
- package/dist/react-native/util/sha256.js +2 -20
- package/dist/react-native/util/userAgent.d.ts +1 -1
- package/dist/react-native/util/userAgent.d.ts.map +1 -1
- package/dist/react-native/util/userAgent.js +2 -2
- package/dist/react-native/util/userAgent.js.map +1 -1
- package/dist/react-native/util/userAgentPlatform-react-native.d.mts.map +1 -1
- package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +1 -1
- package/dist/react-native/util/userAgentPlatform.d.ts +1 -1
- package/dist/react-native/util/userAgentPlatform.js +2 -4
- package/package.json +2 -2
- package/dist/react-native/logger/log.d.ts.map +0 -1
- package/dist/react-native/logger/log.js.map +0 -1
- package/dist/react-native/policies/proxyPolicy.d.ts.map +0 -1
- package/dist/react-native/policies/proxyPolicy.js.map +0 -1
- package/dist/react-native/util/bytesEncoding.d.ts.map +0 -1
- package/dist/react-native/util/bytesEncoding.js.map +0 -1
- package/dist/react-native/util/concat.d.ts.map +0 -1
- package/dist/react-native/util/concat.js.map +0 -1
- package/dist/react-native/util/inspect.d.ts.map +0 -1
- package/dist/react-native/util/inspect.js.map +0 -1
- package/dist/react-native/util/sha256.d.ts.map +0 -1
- package/dist/react-native/util/sha256.js.map +0 -1
|
@@ -1,110 +1,4 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
|
|
4
|
-
* The helper that transforms bytes with specific character encoding into string
|
|
5
|
-
* @param bytes - the uint8array bytes
|
|
6
|
-
* @param format - the format we use to encode the byte
|
|
7
|
-
* @returns a string of the encoded string
|
|
8
|
-
*/
|
|
9
|
-
export function uint8ArrayToString(bytes, format) {
|
|
10
|
-
switch (format) {
|
|
11
|
-
case "utf-8":
|
|
12
|
-
return uint8ArrayToUtf8String(bytes);
|
|
13
|
-
case "base64":
|
|
14
|
-
return uint8ArrayToBase64(bytes);
|
|
15
|
-
case "base64url":
|
|
16
|
-
return uint8ArrayToBase64Url(bytes);
|
|
17
|
-
case "hex":
|
|
18
|
-
return uint8ArrayToHexString(bytes);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The helper that transforms string to specific character encoded bytes array.
|
|
23
|
-
* @param value - the string to be converted
|
|
24
|
-
* @param format - the format we use to decode the value
|
|
25
|
-
* @returns a uint8array
|
|
26
|
-
*/
|
|
27
|
-
export function stringToUint8Array(value, format) {
|
|
28
|
-
switch (format) {
|
|
29
|
-
case "utf-8":
|
|
30
|
-
return utf8StringToUint8Array(value);
|
|
31
|
-
case "base64":
|
|
32
|
-
return base64ToUint8Array(value);
|
|
33
|
-
case "base64url":
|
|
34
|
-
return base64UrlToUint8Array(value);
|
|
35
|
-
case "hex":
|
|
36
|
-
return hexStringToUint8Array(value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Decodes a Uint8Array into a Base64 string.
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
export function uint8ArrayToBase64(bytes) {
|
|
44
|
-
return btoa([...bytes].map((x) => String.fromCharCode(x)).join(""));
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Decodes a Uint8Array into a Base64Url string.
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
export function uint8ArrayToBase64Url(bytes) {
|
|
51
|
-
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Decodes a Uint8Array into a javascript string.
|
|
55
|
-
* @internal
|
|
56
|
-
*/
|
|
57
|
-
export function uint8ArrayToUtf8String(bytes) {
|
|
58
|
-
const decoder = new TextDecoder();
|
|
59
|
-
const dataString = decoder.decode(bytes);
|
|
60
|
-
return dataString;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Decodes a Uint8Array into a hex string
|
|
64
|
-
* @internal
|
|
65
|
-
*/
|
|
66
|
-
export function uint8ArrayToHexString(bytes) {
|
|
67
|
-
return [...bytes].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Encodes a JavaScript string into a Uint8Array.
|
|
71
|
-
* @internal
|
|
72
|
-
*/
|
|
73
|
-
export function utf8StringToUint8Array(value) {
|
|
74
|
-
return new TextEncoder().encode(value);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Encodes a Base64 string into a Uint8Array.
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
export function base64ToUint8Array(value) {
|
|
81
|
-
return new Uint8Array([...atob(value)].map((x) => x.charCodeAt(0)));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Encodes a Base64Url string into a Uint8Array.
|
|
85
|
-
* @internal
|
|
86
|
-
*/
|
|
87
|
-
export function base64UrlToUint8Array(value) {
|
|
88
|
-
const base64String = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
89
|
-
return base64ToUint8Array(base64String);
|
|
90
|
-
}
|
|
91
|
-
const hexDigits = new Set("0123456789abcdefABCDEF");
|
|
92
|
-
/**
|
|
93
|
-
* Encodes a hex string into a Uint8Array
|
|
94
|
-
* @internal
|
|
95
|
-
*/
|
|
96
|
-
export function hexStringToUint8Array(value) {
|
|
97
|
-
// If value has odd length, the last character will be ignored, consistent with NodeJS Buffer behavior
|
|
98
|
-
const bytes = new Uint8Array(value.length / 2);
|
|
99
|
-
for (let i = 0; i < value.length / 2; ++i) {
|
|
100
|
-
const highNibble = value[2 * i];
|
|
101
|
-
const lowNibble = value[2 * i + 1];
|
|
102
|
-
if (!hexDigits.has(highNibble) || !hexDigits.has(lowNibble)) {
|
|
103
|
-
// Replicate Node Buffer behavior by exiting early when we encounter an invalid byte
|
|
104
|
-
return bytes.slice(0, i);
|
|
105
|
-
}
|
|
106
|
-
bytes[i] = parseInt(`${highNibble}${lowNibble}`, 16);
|
|
107
|
-
}
|
|
108
|
-
return bytes;
|
|
109
|
-
}
|
|
3
|
+
export * from "./bytesEncoding.common.js";
|
|
110
4
|
//# sourceMappingURL=bytesEncoding-browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concat-browser.d.mts","sourceRoot":"","sources":["../../../src/util/concat-browser.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"concat-browser.d.mts","sourceRoot":"","sources":["../../../src/util/concat-browser.mts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concat-browser.mjs","sourceRoot":"","sources":["../../../src/util/concat-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,
|
|
1
|
+
{"version":3,"file":"concat-browser.mjs","sourceRoot":"","sources":["../../../src/util/concat-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 \"./concat.common.js\";\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 {};
|
|
19
|
+
//# sourceMappingURL=concat.common.d.ts.map
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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 @@
|
|
|
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 @@
|
|
|
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
|
|
1
|
+
export * from "./inspect.common.js";
|
|
2
2
|
//# sourceMappingURL=inspect-browser.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha256-browser.d.mts","sourceRoot":"","sources":["../../../src/util/sha256-browser.mts"],"names":[],"mappings":"
|
|
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,
|
|
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.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,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,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
|
-
|
|
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,
|
|
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;
|
|
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":"
|
|
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;AA8CD;;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;
|
|
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,2BAA2B;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,gBAAgB,CAAC,CAAC;IAC9D,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mBAAmB;IACnB,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,eAAe,CAAC,CAAC;IAC/D,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,qBAAqB;IACrB,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC;IAC5D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,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 // Check for Microsoft Edge\n const edge = brands.find((b) => b.brand === \"Microsoft Edge\");\n if (edge) {\n return edge;\n }\n\n // Check for Chrome\n const chrome = brands.find((b) => b.brand === \"Google Chrome\");\n if (chrome) {\n return chrome;\n }\n\n // Check for Chromium\n const chromium = brands.find((b) => b.brand === \"Chromium\");\n if (chromium) {\n return chromium;\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,50 @@
|
|
|
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
|
+
// Check for Microsoft Edge
|
|
11
|
+
const edge = brands.find((b) => b.brand === "Microsoft Edge");
|
|
12
|
+
if (edge) {
|
|
13
|
+
return edge;
|
|
14
|
+
}
|
|
15
|
+
// Check for Chrome
|
|
16
|
+
const chrome = brands.find((b) => b.brand === "Google Chrome");
|
|
17
|
+
if (chrome) {
|
|
18
|
+
return chrome;
|
|
19
|
+
}
|
|
20
|
+
// Check for Chromium
|
|
21
|
+
const chromium = brands.find((b) => b.brand === "Chromium");
|
|
22
|
+
if (chromium) {
|
|
23
|
+
return chromium;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
12
27
|
/**
|
|
13
28
|
* @internal
|
|
14
29
|
*/
|
|
15
|
-
export function setPlatformSpecificData(map) {
|
|
16
|
-
var _a, _b, _c;
|
|
30
|
+
export async function setPlatformSpecificData(map) {
|
|
17
31
|
const localNavigator = globalThis.navigator;
|
|
18
|
-
|
|
32
|
+
let osPlatform = "unknown";
|
|
33
|
+
if (localNavigator.userAgentData) {
|
|
34
|
+
const entropyValues = await localNavigator.userAgentData.getHighEntropyValues([
|
|
35
|
+
"architecture",
|
|
36
|
+
"platformVersion",
|
|
37
|
+
]);
|
|
38
|
+
osPlatform = `${entropyValues.architecture}-${entropyValues.platform}-${entropyValues.platformVersion}`;
|
|
39
|
+
// Get the brand and version
|
|
40
|
+
const brand = getBrandVersionString(entropyValues.brands);
|
|
41
|
+
if (brand) {
|
|
42
|
+
map.set(brand.brand, brand.version);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (localNavigator === null || localNavigator === void 0 ? void 0 : localNavigator.platform) {
|
|
46
|
+
osPlatform = localNavigator.platform;
|
|
47
|
+
}
|
|
48
|
+
map.set("OS", osPlatform);
|
|
19
49
|
}
|
|
20
50
|
//# sourceMappingURL=userAgentPlatform-browser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.common.d.ts","sourceRoot":"","sources":["../../../src/logger/log.common.ts"],"names":[],"mappings":"AAGA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAexC"}
|