@typespec/ts-http-runtime 0.3.4-alpha.20260227.2 → 0.3.4
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/client/sendRequest.d.ts +10 -1
- package/dist/browser/client/sendRequest.js +8 -2
- package/dist/browser/client/sendRequest.js.map +1 -1
- package/dist/browser/defaultHttpClient.d.ts +1 -1
- package/dist/browser/defaultHttpClient.js +1 -1
- package/dist/browser/defaultHttpClient.js.map +1 -0
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +0 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/logger/log.d.ts +1 -1
- package/dist/browser/logger/log.js +1 -1
- package/dist/browser/logger/log.js.map +1 -0
- package/dist/browser/pipelineRequest.d.ts +1 -1
- package/dist/browser/pipelineRequest.js.map +1 -1
- package/dist/browser/policies/decompressResponsePolicy.d.ts +3 -2
- package/dist/browser/policies/decompressResponsePolicy.js +1 -4
- package/dist/browser/policies/decompressResponsePolicy.js.map +1 -0
- package/dist/browser/policies/internal.d.ts +7 -7
- package/dist/browser/policies/internal.js +2 -2
- package/dist/browser/policies/internal.js.map +1 -1
- package/dist/browser/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/browser/policies/proxyPolicy.common.js +2 -2
- package/dist/browser/policies/proxyPolicy.common.js.map +1 -1
- package/dist/browser/policies/proxyPolicy.d.ts +1 -1
- package/dist/browser/policies/proxyPolicy.js +1 -1
- package/dist/browser/policies/proxyPolicy.js.map +1 -0
- package/dist/browser/policies/redirectPolicy.d.ts +7 -0
- package/dist/browser/policies/redirectPolicy.js +13 -4
- package/dist/browser/policies/redirectPolicy.js.map +1 -1
- package/dist/browser/util/bytesEncoding.d.ts +1 -1
- package/dist/browser/util/bytesEncoding.js +1 -1
- package/dist/browser/util/bytesEncoding.js.map +1 -0
- package/dist/browser/util/concat.common.d.ts +1 -2
- package/dist/browser/util/concat.common.js.map +1 -1
- package/dist/browser/util/concat.d.ts +1 -1
- package/dist/browser/util/concat.js +1 -1
- package/dist/browser/util/concat.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/inspect.js.map +1 -0
- package/dist/browser/util/sha256.d.ts +1 -1
- package/dist/browser/util/sha256.js +1 -1
- package/dist/browser/util/sha256.js.map +1 -0
- package/dist/browser/util/userAgentPlatform.d.ts +1 -1
- package/dist/browser/util/userAgentPlatform.js +1 -1
- package/dist/browser/util/userAgentPlatform.js.map +1 -0
- package/dist/browser/util/uuidUtils.d.ts +1 -1
- package/dist/browser/util/uuidUtils.js +1 -1
- package/dist/browser/util/uuidUtils.js.map +1 -0
- package/dist/commonjs/abort-controller/AbortError.js +30 -40
- package/dist/commonjs/abort-controller/AbortError.js.map +7 -1
- package/dist/commonjs/auth/credentials.js +36 -25
- package/dist/commonjs/auth/credentials.js.map +7 -1
- package/dist/commonjs/auth/oauth2Flows.js +15 -5
- package/dist/commonjs/auth/oauth2Flows.js.map +7 -1
- package/dist/commonjs/auth/schemes.js +15 -5
- package/dist/commonjs/auth/schemes.js.map +7 -1
- package/dist/commonjs/client/apiVersionPolicy.js +39 -25
- package/dist/commonjs/client/apiVersionPolicy.js.map +7 -1
- package/dist/commonjs/client/clientHelpers.js +62 -39
- package/dist/commonjs/client/clientHelpers.js.map +7 -1
- package/dist/commonjs/client/common.js +15 -5
- package/dist/commonjs/client/common.js.map +7 -1
- package/dist/commonjs/client/getClient.js +170 -82
- package/dist/commonjs/client/getClient.js.map +7 -1
- package/dist/commonjs/client/multipart.js +119 -110
- package/dist/commonjs/client/multipart.js.map +7 -1
- package/dist/commonjs/client/operationOptionHelpers.js +36 -21
- package/dist/commonjs/client/operationOptionHelpers.js.map +7 -1
- package/dist/commonjs/client/restError.js +44 -26
- package/dist/commonjs/client/restError.js.map +7 -1
- package/dist/commonjs/client/sendRequest.d.ts +10 -1
- package/dist/commonjs/client/sendRequest.js +150 -164
- package/dist/commonjs/client/sendRequest.js.map +7 -1
- package/dist/commonjs/client/urlHelpers.js +124 -131
- package/dist/commonjs/client/urlHelpers.js.map +7 -1
- package/dist/commonjs/constants.js +30 -8
- package/dist/commonjs/constants.js.map +7 -1
- package/dist/commonjs/createPipelineFromOptions.js +56 -45
- package/dist/commonjs/createPipelineFromOptions.js.map +7 -1
- package/dist/commonjs/defaultHttpClient.js +28 -11
- package/dist/commonjs/defaultHttpClient.js.map +7 -1
- package/dist/commonjs/fetchHttpClient.js +211 -256
- package/dist/commonjs/fetchHttpClient.js.map +7 -1
- package/dist/commonjs/httpHeaders.js +97 -82
- package/dist/commonjs/httpHeaders.js.map +7 -1
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.js +67 -36
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/interfaces.js +15 -5
- package/dist/commonjs/interfaces.js.map +7 -1
- package/dist/commonjs/log.js +28 -8
- package/dist/commonjs/log.js.map +7 -1
- package/dist/commonjs/logger/debug.js +150 -155
- package/dist/commonjs/logger/debug.js.map +7 -1
- package/dist/commonjs/logger/internal.js +27 -8
- package/dist/commonjs/logger/internal.js.map +7 -1
- package/dist/commonjs/logger/log.common.js +39 -23
- package/dist/commonjs/logger/log.common.js.map +7 -1
- package/dist/commonjs/logger/log.js +40 -11
- package/dist/commonjs/logger/log.js.map +7 -1
- package/dist/commonjs/logger/logger.js +120 -110
- package/dist/commonjs/logger/logger.js.map +7 -1
- package/dist/commonjs/nodeHttpClient.js +313 -321
- package/dist/commonjs/nodeHttpClient.js.map +7 -1
- package/dist/commonjs/pipeline.js +190 -247
- package/dist/commonjs/pipeline.js.map +7 -1
- package/dist/commonjs/pipelineRequest.d.ts +1 -1
- package/dist/commonjs/pipelineRequest.js +69 -54
- package/dist/commonjs/pipelineRequest.js.map +7 -1
- package/dist/commonjs/policies/agentPolicy.js +38 -24
- package/dist/commonjs/policies/agentPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js +45 -32
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js +50 -32
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js +47 -32
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/checkInsecureConnection.js +47 -44
- package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +7 -1
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js +45 -32
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/decompressResponsePolicy.js +38 -25
- package/dist/commonjs/policies/decompressResponsePolicy.js.map +7 -1
- package/dist/commonjs/policies/defaultRetryPolicy.js +39 -27
- package/dist/commonjs/policies/defaultRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/exponentialRetryPolicy.js +43 -26
- package/dist/commonjs/policies/exponentialRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/formDataPolicy.js +101 -90
- package/dist/commonjs/policies/formDataPolicy.js.map +7 -1
- package/dist/commonjs/policies/internal.d.ts +7 -7
- package/dist/commonjs/policies/internal.js +94 -48
- package/dist/commonjs/policies/internal.js.map +7 -1
- package/dist/commonjs/policies/logPolicy.js +49 -35
- package/dist/commonjs/policies/logPolicy.js.map +7 -1
- package/dist/commonjs/policies/multipartPolicy.js +117 -99
- package/dist/commonjs/policies/multipartPolicy.js.map +7 -1
- package/dist/commonjs/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/commonjs/policies/proxyPolicy.common.js +38 -25
- package/dist/commonjs/policies/proxyPolicy.common.js.map +7 -1
- package/dist/commonjs/policies/proxyPolicy.js +160 -171
- package/dist/commonjs/policies/proxyPolicy.js.map +7 -1
- package/dist/commonjs/policies/redirectPolicy.d.ts +7 -0
- package/dist/commonjs/policies/redirectPolicy.js +62 -51
- package/dist/commonjs/policies/redirectPolicy.js.map +7 -1
- package/dist/commonjs/policies/retryPolicy.js +123 -105
- package/dist/commonjs/policies/retryPolicy.js.map +7 -1
- package/dist/commonjs/policies/systemErrorRetryPolicy.js +46 -31
- package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/throttlingRetryPolicy.js +38 -30
- package/dist/commonjs/policies/throttlingRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/tlsPolicy.js +38 -24
- package/dist/commonjs/policies/tlsPolicy.js.map +7 -1
- package/dist/commonjs/policies/userAgentPolicy.js +41 -28
- package/dist/commonjs/policies/userAgentPolicy.js.map +7 -1
- package/dist/commonjs/restError.js +93 -90
- package/dist/commonjs/restError.js.map +7 -1
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +63 -62
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +7 -1
- package/dist/commonjs/retryStrategies/retryStrategy.js +15 -5
- package/dist/commonjs/retryStrategies/retryStrategy.js.map +7 -1
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +58 -69
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +7 -1
- package/dist/commonjs/util/arrayBuffer.js +34 -21
- package/dist/commonjs/util/arrayBuffer.js.map +7 -1
- package/dist/commonjs/util/bytesEncoding.common.js +83 -100
- package/dist/commonjs/util/bytesEncoding.common.js.map +7 -1
- package/dist/commonjs/util/bytesEncoding.js +30 -21
- package/dist/commonjs/util/bytesEncoding.js.map +7 -1
- package/dist/commonjs/util/checkEnvironment.js +45 -44
- package/dist/commonjs/util/checkEnvironment.js.map +7 -1
- package/dist/commonjs/util/concat.common.d.ts +1 -2
- package/dist/commonjs/util/concat.common.js +51 -52
- package/dist/commonjs/util/concat.common.js.map +7 -1
- package/dist/commonjs/util/concat.js +70 -61
- package/dist/commonjs/util/concat.js.map +7 -1
- package/dist/commonjs/util/delay.js +31 -21
- package/dist/commonjs/util/delay.js.map +7 -1
- package/dist/commonjs/util/error.js +33 -17
- package/dist/commonjs/util/error.js.map +7 -1
- package/dist/commonjs/util/helpers.js +65 -57
- package/dist/commonjs/util/helpers.js.map +7 -1
- package/dist/commonjs/util/inspect.common.js +27 -7
- package/dist/commonjs/util/inspect.common.js.map +7 -1
- package/dist/commonjs/util/inspect.js +28 -8
- package/dist/commonjs/util/inspect.js.map +7 -1
- package/dist/commonjs/util/internal.js +67 -32
- package/dist/commonjs/util/internal.js.map +7 -1
- package/dist/commonjs/util/object.js +27 -15
- package/dist/commonjs/util/object.js.map +7 -1
- package/dist/commonjs/util/random.js +30 -22
- package/dist/commonjs/util/random.js.map +7 -1
- package/dist/commonjs/util/sanitizer.js +157 -148
- package/dist/commonjs/util/sanitizer.js.map +7 -1
- package/dist/commonjs/util/sha256.common.js +61 -45
- package/dist/commonjs/util/sha256.common.js.map +7 -1
- package/dist/commonjs/util/sha256.js +32 -22
- package/dist/commonjs/util/sha256.js.map +7 -1
- package/dist/commonjs/util/typeGuards.js +41 -21
- package/dist/commonjs/util/typeGuards.js.map +7 -1
- package/dist/commonjs/util/userAgent.js +43 -28
- package/dist/commonjs/util/userAgent.js.map +7 -1
- package/dist/commonjs/util/userAgentPlatform.js +51 -29
- package/dist/commonjs/util/userAgentPlatform.js.map +7 -1
- package/dist/commonjs/util/uuidUtils.common.js +43 -39
- package/dist/commonjs/util/uuidUtils.common.js.map +7 -1
- package/dist/commonjs/util/uuidUtils.js +27 -12
- package/dist/commonjs/util/uuidUtils.js.map +7 -1
- package/dist/commonjs/xhrHttpClient.js +171 -163
- package/dist/commonjs/xhrHttpClient.js.map +7 -1
- package/dist/esm/client/sendRequest.d.ts +10 -1
- package/dist/esm/client/sendRequest.js +8 -2
- package/dist/esm/client/sendRequest.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pipelineRequest.d.ts +1 -1
- package/dist/esm/pipelineRequest.js.map +1 -1
- package/dist/esm/policies/internal.d.ts +7 -7
- package/dist/esm/policies/internal.js +2 -2
- package/dist/esm/policies/internal.js.map +1 -1
- package/dist/esm/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/esm/policies/proxyPolicy.common.js +2 -2
- package/dist/esm/policies/proxyPolicy.common.js.map +1 -1
- package/dist/esm/policies/redirectPolicy.d.ts +7 -0
- package/dist/esm/policies/redirectPolicy.js +13 -4
- package/dist/esm/policies/redirectPolicy.js.map +1 -1
- package/dist/esm/util/concat.common.d.ts +1 -2
- package/dist/esm/util/concat.common.js.map +1 -1
- package/dist/react-native/client/sendRequest.d.ts +10 -1
- package/dist/react-native/client/sendRequest.js +8 -2
- package/dist/react-native/client/sendRequest.js.map +1 -1
- package/dist/react-native/defaultHttpClient.d.ts +1 -1
- package/dist/react-native/defaultHttpClient.js +1 -1
- package/dist/react-native/defaultHttpClient.js.map +1 -0
- package/dist/react-native/index.d.ts +2 -2
- package/dist/react-native/index.js +0 -2
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/logger/log.d.ts +1 -1
- package/dist/react-native/logger/log.js +1 -1
- package/dist/react-native/logger/log.js.map +1 -0
- package/dist/react-native/pipelineRequest.d.ts +1 -1
- package/dist/react-native/pipelineRequest.js.map +1 -1
- package/dist/react-native/policies/internal.d.ts +7 -7
- package/dist/react-native/policies/internal.js +2 -2
- package/dist/react-native/policies/internal.js.map +1 -1
- package/dist/react-native/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/react-native/policies/proxyPolicy.common.js +2 -2
- package/dist/react-native/policies/proxyPolicy.common.js.map +1 -1
- package/dist/react-native/policies/proxyPolicy.d.ts +1 -1
- package/dist/react-native/policies/proxyPolicy.js +1 -1
- package/dist/react-native/policies/proxyPolicy.js.map +1 -0
- package/dist/react-native/policies/redirectPolicy.d.ts +7 -0
- package/dist/react-native/policies/redirectPolicy.js +13 -4
- package/dist/react-native/policies/redirectPolicy.js.map +1 -1
- package/dist/react-native/util/bytesEncoding.d.ts +1 -1
- package/dist/react-native/util/bytesEncoding.js +1 -1
- package/dist/react-native/util/bytesEncoding.js.map +1 -0
- package/dist/react-native/util/concat.common.d.ts +1 -2
- package/dist/react-native/util/concat.common.js.map +1 -1
- package/dist/react-native/util/concat.d.ts +1 -1
- package/dist/react-native/util/concat.js +1 -1
- package/dist/react-native/util/concat.js.map +1 -0
- package/dist/react-native/util/inspect.d.ts +1 -1
- package/dist/react-native/util/inspect.js +1 -1
- package/dist/react-native/util/inspect.js.map +1 -0
- package/dist/react-native/util/sha256.d.ts +1 -1
- package/dist/react-native/util/sha256.js +1 -1
- package/dist/react-native/util/sha256.js.map +1 -0
- package/dist/react-native/util/userAgentPlatform.d.ts +1 -1
- package/dist/react-native/util/userAgentPlatform.js +1 -1
- package/dist/react-native/util/userAgentPlatform.js.map +1 -0
- package/dist/react-native/util/uuidUtils.d.ts +1 -1
- package/dist/react-native/util/uuidUtils.js +1 -1
- package/dist/react-native/util/uuidUtils.js.map +1 -0
- package/package.json +1 -21
- package/dist/browser/defaultHttpClient-browser.mjs.map +0 -1
- package/dist/browser/logger/log-browser.mjs.map +0 -1
- package/dist/browser/policies/decompressResponsePolicy-browser.mjs.map +0 -1
- package/dist/browser/policies/proxyPolicy-browser.mjs.map +0 -1
- package/dist/browser/util/bytesEncoding-browser.mjs.map +0 -1
- package/dist/browser/util/concat-browser.mjs.map +0 -1
- package/dist/browser/util/inspect-browser.mjs.map +0 -1
- package/dist/browser/util/sha256-browser.mjs.map +0 -1
- package/dist/browser/util/userAgentPlatform-browser.mjs.map +0 -1
- package/dist/browser/util/uuidUtils-browser.mjs.map +0 -1
- package/dist/react-native/defaultHttpClient-react-native.mjs.map +0 -1
- package/dist/react-native/logger/log-react-native.mjs.map +0 -1
- package/dist/react-native/policies/proxyPolicy-react-native.mjs.map +0 -1
- package/dist/react-native/util/bytesEncoding-react-native.mjs.map +0 -1
- package/dist/react-native/util/concat-react-native.mjs.map +0 -1
- package/dist/react-native/util/inspect-react-native.mjs.map +0 -1
- package/dist/react-native/util/sha256-react-native.mjs.map +0 -1
- package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +0 -1
- package/dist/react-native/util/uuidUtils-react-native.mjs.map +0 -1
|
@@ -1,115 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var multipartPolicy_exports = {};
|
|
19
|
+
__export(multipartPolicy_exports, {
|
|
20
|
+
multipartPolicy: () => multipartPolicy,
|
|
21
|
+
multipartPolicyName: () => multipartPolicyName
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(multipartPolicy_exports);
|
|
24
|
+
var import_bytesEncoding = require("../util/bytesEncoding.js");
|
|
25
|
+
var import_typeGuards = require("../util/typeGuards.js");
|
|
26
|
+
var import_uuidUtils = require("../util/uuidUtils.js");
|
|
27
|
+
var import_concat = require("../util/concat.js");
|
|
11
28
|
function generateBoundary() {
|
|
12
|
-
|
|
29
|
+
return `----AzSDKFormBoundary${(0, import_uuidUtils.randomUUID)()}`;
|
|
13
30
|
}
|
|
14
31
|
function encodeHeaders(headers) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
let result = "";
|
|
33
|
+
for (const [key, value] of headers) {
|
|
34
|
+
result += `${key}: ${value}\r
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
20
38
|
}
|
|
21
39
|
function getLength(source) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
else {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
40
|
+
if (source instanceof Uint8Array) {
|
|
41
|
+
return source.byteLength;
|
|
42
|
+
} else if ((0, import_typeGuards.isBlob)(source)) {
|
|
43
|
+
return source.size === -1 ? void 0 : source.size;
|
|
44
|
+
} else {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
32
47
|
}
|
|
33
48
|
function getTotalLength(sources) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
total += partLength;
|
|
42
|
-
}
|
|
49
|
+
let total = 0;
|
|
50
|
+
for (const source of sources) {
|
|
51
|
+
const partLength = getLength(source);
|
|
52
|
+
if (partLength === void 0) {
|
|
53
|
+
return void 0;
|
|
54
|
+
} else {
|
|
55
|
+
total += partLength;
|
|
43
56
|
}
|
|
44
|
-
|
|
57
|
+
}
|
|
58
|
+
return total;
|
|
45
59
|
}
|
|
46
60
|
async function buildRequestBody(request, parts, boundary) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const sources = [
|
|
62
|
+
(0, import_bytesEncoding.stringToUint8Array)(`--${boundary}`, "utf-8"),
|
|
63
|
+
...parts.flatMap((part) => [
|
|
64
|
+
(0, import_bytesEncoding.stringToUint8Array)("\r\n", "utf-8"),
|
|
65
|
+
(0, import_bytesEncoding.stringToUint8Array)(encodeHeaders(part.headers), "utf-8"),
|
|
66
|
+
(0, import_bytesEncoding.stringToUint8Array)("\r\n", "utf-8"),
|
|
67
|
+
part.body,
|
|
68
|
+
(0, import_bytesEncoding.stringToUint8Array)(`\r
|
|
69
|
+
--${boundary}`, "utf-8")
|
|
70
|
+
]),
|
|
71
|
+
(0, import_bytesEncoding.stringToUint8Array)("--\r\n\r\n", "utf-8")
|
|
72
|
+
];
|
|
73
|
+
const contentLength = getTotalLength(sources);
|
|
74
|
+
if (contentLength) {
|
|
75
|
+
request.headers.set("Content-Length", contentLength);
|
|
76
|
+
}
|
|
77
|
+
request.body = await (0, import_concat.concat)(sources);
|
|
63
78
|
}
|
|
64
|
-
|
|
65
|
-
* Name of multipart policy
|
|
66
|
-
*/
|
|
67
|
-
exports.multipartPolicyName = "multipartPolicy";
|
|
79
|
+
const multipartPolicyName = "multipartPolicy";
|
|
68
80
|
const maxBoundaryLength = 70;
|
|
69
|
-
const validBoundaryCharacters = new Set(
|
|
81
|
+
const validBoundaryCharacters = new Set(
|
|
82
|
+
`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`
|
|
83
|
+
);
|
|
70
84
|
function assertValidBoundary(boundary) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
if (boundary.length > maxBoundaryLength) {
|
|
86
|
+
throw new Error(`Multipart boundary "${boundary}" exceeds maximum length of 70 characters`);
|
|
87
|
+
}
|
|
88
|
+
if (Array.from(boundary).some((x) => !validBoundaryCharacters.has(x))) {
|
|
89
|
+
throw new Error(`Multipart boundary "${boundary}" contains invalid characters`);
|
|
90
|
+
}
|
|
77
91
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Pipeline policy for multipart requests
|
|
80
|
-
*/
|
|
81
92
|
function multipartPolicy() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
return {
|
|
94
|
+
name: multipartPolicyName,
|
|
95
|
+
async sendRequest(request, next) {
|
|
96
|
+
if (!request.multipartBody) {
|
|
97
|
+
return next(request);
|
|
98
|
+
}
|
|
99
|
+
if (request.body) {
|
|
100
|
+
throw new Error("multipartBody and regular body cannot be set at the same time");
|
|
101
|
+
}
|
|
102
|
+
let boundary = request.multipartBody.boundary;
|
|
103
|
+
const contentTypeHeader = request.headers.get("Content-Type") ?? "multipart/mixed";
|
|
104
|
+
const parsedHeader = contentTypeHeader.match(/^(multipart\/[^ ;]+)(?:; *boundary=(.+))?$/);
|
|
105
|
+
if (!parsedHeader) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
const [, contentType, parsedBoundary] = parsedHeader;
|
|
111
|
+
if (parsedBoundary && boundary && parsedBoundary !== boundary) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
boundary ??= parsedBoundary;
|
|
117
|
+
if (boundary) {
|
|
118
|
+
assertValidBoundary(boundary);
|
|
119
|
+
} else {
|
|
120
|
+
boundary = generateBoundary();
|
|
121
|
+
}
|
|
122
|
+
request.headers.set("Content-Type", `${contentType}; boundary=${boundary}`);
|
|
123
|
+
await buildRequestBody(request, request.multipartBody.parts, boundary);
|
|
124
|
+
request.multipartBody = void 0;
|
|
125
|
+
return next(request);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
114
128
|
}
|
|
115
|
-
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
multipartPolicy,
|
|
132
|
+
multipartPolicyName
|
|
133
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/multipartPolicy.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BodyPart, HttpHeaders, PipelineRequest, PipelineResponse } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { stringToUint8Array } from \"../util/bytesEncoding.js\";\nimport { isBlob } from \"../util/typeGuards.js\";\nimport { randomUUID } from \"../util/uuidUtils.js\";\nimport { concat } from \"../util/concat.js\";\n\nfunction generateBoundary(): string {\n return `----AzSDKFormBoundary${randomUUID()}`;\n}\n\nfunction encodeHeaders(headers: HttpHeaders): string {\n let result = \"\";\n for (const [key, value] of headers) {\n result += `${key}: ${value}\\r\\n`;\n }\n return result;\n}\n\nfunction getLength(\n source:\n | (() => ReadableStream<Uint8Array>)\n | (() => NodeJS.ReadableStream)\n | Uint8Array\n | Blob\n | ReadableStream\n | NodeJS.ReadableStream,\n): number | undefined {\n if (source instanceof Uint8Array) {\n return source.byteLength;\n } else if (isBlob(source)) {\n // if was created using createFile then -1 means we have an unknown size\n return source.size === -1 ? undefined : source.size;\n } else {\n return undefined;\n }\n}\n\nfunction getTotalLength(\n sources: (\n | (() => ReadableStream<Uint8Array>)\n | (() => NodeJS.ReadableStream)\n | Uint8Array\n | Blob\n | ReadableStream\n | NodeJS.ReadableStream\n )[],\n): number | undefined {\n let total = 0;\n for (const source of sources) {\n const partLength = getLength(source);\n if (partLength === undefined) {\n return undefined;\n } else {\n total += partLength;\n }\n }\n return total;\n}\n\nasync function buildRequestBody(\n request: PipelineRequest,\n parts: BodyPart[],\n boundary: string,\n): Promise<void> {\n const sources = [\n stringToUint8Array(`--${boundary}`, \"utf-8\"),\n ...parts.flatMap((part) => [\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n stringToUint8Array(encodeHeaders(part.headers), \"utf-8\"),\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n part.body,\n stringToUint8Array(`\\r\\n--${boundary}`, \"utf-8\"),\n ]),\n stringToUint8Array(\"--\\r\\n\\r\\n\", \"utf-8\"),\n ];\n\n const contentLength = getTotalLength(sources);\n if (contentLength) {\n request.headers.set(\"Content-Length\", contentLength);\n }\n\n request.body = await concat(sources);\n}\n\n/**\n * Name of multipart policy\n */\nexport const multipartPolicyName = \"multipartPolicy\";\n\nconst maxBoundaryLength = 70;\nconst validBoundaryCharacters = new Set(\n `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`,\n);\n\nfunction assertValidBoundary(boundary: string): void {\n if (boundary.length > maxBoundaryLength) {\n throw new Error(`Multipart boundary \"${boundary}\" exceeds maximum length of 70 characters`);\n }\n\n if (Array.from(boundary).some((x) => !validBoundaryCharacters.has(x))) {\n throw new Error(`Multipart boundary \"${boundary}\" contains invalid characters`);\n }\n}\n\n/**\n * Pipeline policy for multipart requests\n */\nexport function multipartPolicy(): PipelinePolicy {\n return {\n name: multipartPolicyName,\n async sendRequest(request, next): Promise<PipelineResponse> {\n if (!request.multipartBody) {\n return next(request);\n }\n\n if (request.body) {\n throw new Error(\"multipartBody and regular body cannot be set at the same time\");\n }\n\n let boundary = request.multipartBody.boundary;\n\n const contentTypeHeader = request.headers.get(\"Content-Type\") ?? \"multipart/mixed\";\n const parsedHeader = contentTypeHeader.match(/^(multipart\\/[^ ;]+)(?:; *boundary=(.+))?$/);\n if (!parsedHeader) {\n throw new Error(\n `Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`,\n );\n }\n\n const [, contentType, parsedBoundary] = parsedHeader;\n if (parsedBoundary && boundary && parsedBoundary !== boundary) {\n throw new Error(\n `Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`,\n );\n }\n\n boundary ??= parsedBoundary;\n if (boundary) {\n assertValidBoundary(boundary);\n } else {\n boundary = generateBoundary();\n }\n request.headers.set(\"Content-Type\", `${contentType}; boundary=${boundary}`);\n await buildRequestBody(request, request.multipartBody.parts, boundary);\n\n request.multipartBody = undefined;\n\n return next(request);\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import type { ProxySettings } from "../interfaces.js";
|
|
2
|
+
import type { PipelinePolicy } from "../pipeline.js";
|
|
1
3
|
export declare const proxyPolicyName = "proxyPolicy";
|
|
2
|
-
export declare function getDefaultProxySettings():
|
|
4
|
+
export declare function getDefaultProxySettings(_proxyUrl?: string): ProxySettings | undefined;
|
|
3
5
|
/**
|
|
4
6
|
* proxyPolicy is not supported in the browser and attempting
|
|
5
7
|
* to use it will raise an error.
|
|
6
8
|
*/
|
|
7
|
-
export declare function proxyPolicy(
|
|
9
|
+
export declare function proxyPolicy(_proxySettings?: ProxySettings, _options?: {
|
|
10
|
+
customNoProxyList?: string[];
|
|
11
|
+
}): PipelinePolicy;
|
|
8
12
|
/**
|
|
9
13
|
* A function to reset the cached agents.
|
|
10
14
|
* proxyPolicy is not supported in the browser and attempting
|
|
11
15
|
* to use it will raise an error.
|
|
12
16
|
* @internal
|
|
13
17
|
*/
|
|
14
|
-
export declare function resetCachedProxyAgents():
|
|
18
|
+
export declare function resetCachedProxyAgents(): void;
|
|
15
19
|
//# sourceMappingURL=proxyPolicy.common.d.ts.map
|
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var proxyPolicy_common_exports = {};
|
|
19
|
+
__export(proxyPolicy_common_exports, {
|
|
20
|
+
getDefaultProxySettings: () => getDefaultProxySettings,
|
|
21
|
+
proxyPolicy: () => proxyPolicy,
|
|
22
|
+
proxyPolicyName: () => proxyPolicyName,
|
|
23
|
+
resetCachedProxyAgents: () => resetCachedProxyAgents
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(proxyPolicy_common_exports);
|
|
26
|
+
const proxyPolicyName = "proxyPolicy";
|
|
10
27
|
const errorMessage = "proxyPolicy is not supported in browser environment";
|
|
11
|
-
function getDefaultProxySettings() {
|
|
12
|
-
|
|
28
|
+
function getDefaultProxySettings(_proxyUrl) {
|
|
29
|
+
throw new Error(errorMessage);
|
|
13
30
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* to use it will raise an error.
|
|
17
|
-
*/
|
|
18
|
-
function proxyPolicy() {
|
|
19
|
-
throw new Error(errorMessage);
|
|
31
|
+
function proxyPolicy(_proxySettings, _options) {
|
|
32
|
+
throw new Error(errorMessage);
|
|
20
33
|
}
|
|
21
|
-
/**
|
|
22
|
-
* A function to reset the cached agents.
|
|
23
|
-
* proxyPolicy is not supported in the browser and attempting
|
|
24
|
-
* to use it will raise an error.
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
34
|
function resetCachedProxyAgents() {
|
|
28
|
-
|
|
35
|
+
throw new Error(errorMessage);
|
|
29
36
|
}
|
|
30
|
-
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
getDefaultProxySettings,
|
|
40
|
+
proxyPolicy,
|
|
41
|
+
proxyPolicyName,
|
|
42
|
+
resetCachedProxyAgents
|
|
43
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/proxyPolicy.common.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ProxySettings } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nexport const proxyPolicyName = \"proxyPolicy\";\nconst errorMessage = \"proxyPolicy is not supported in browser environment\";\n\nexport function getDefaultProxySettings(_proxyUrl?: string): ProxySettings | undefined {\n throw new Error(errorMessage);\n}\n\n/**\n * proxyPolicy is not supported in the browser and attempting\n * to use it will raise an error.\n */\nexport function proxyPolicy(\n _proxySettings?: ProxySettings,\n _options?: {\n customNoProxyList?: string[];\n },\n): PipelinePolicy {\n throw new Error(errorMessage);\n}\n\n/**\n * A function to reset the cached agents.\n * proxyPolicy is not supported in the browser and attempting\n * to use it will raise an error.\n * @internal\n */\nexport function resetCachedProxyAgents(): void {\n throw new Error(errorMessage);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,kBAAkB;AAC/B,MAAM,eAAe;AAEd,SAAS,wBAAwB,WAA+C;AACrF,QAAM,IAAI,MAAM,YAAY;AAC9B;AAMO,SAAS,YACd,gBACA,UAGgB;AAChB,QAAM,IAAI,MAAM,YAAY;AAC9B;AAQO,SAAS,yBAA+B;AAC7C,QAAM,IAAI,MAAM,YAAY;AAC9B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|