@uipath/codedapp-tool 1.202.0-preview.154 → 1.202.0-preview.156
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/THIRD-PARTY-NOTICES.md +39 -789
- package/dist/{index-d9c1ecq8.js → index-7zbv11qn.js} +3 -3
- package/dist/{index-sm3z7s8x.js → index-m7gsq50b.js} +5 -5
- package/dist/index.js +5 -6
- package/dist/{packager-tool-m73htrq7.js → packager-tool-26b8hr4k.js} +359 -11689
- package/dist/{packager-tool-tbmk2m6m.js → packager-tool-58asqeb7.js} +2 -82
- package/dist/{packager-tool-8hncwr6a.js → packager-tool-pvtdkdk8.js} +5 -5
- package/dist/tool.js +5 -6
- package/package.json +2 -2
- package/dist/multipart-parser-ab4q7byb.js +0 -353
- package/dist/packager-tool-vv9c52ax.js +0 -4452
|
@@ -4089,86 +4089,6 @@ function recordCommandDuration(durationMs) {
|
|
|
4089
4089
|
}
|
|
4090
4090
|
getState().commandMs = durationMs;
|
|
4091
4091
|
}
|
|
4092
|
-
function recordHttpCall(durationMs) {
|
|
4093
|
-
if (!timingsEnabled()) {
|
|
4094
|
-
return;
|
|
4095
|
-
}
|
|
4096
|
-
const state = getState();
|
|
4097
|
-
state.httpMs += durationMs;
|
|
4098
|
-
state.httpCalls += 1;
|
|
4099
|
-
}
|
|
4100
|
-
|
|
4101
|
-
// ../common/src/telemetry/tracked-fetch.ts
|
|
4102
|
-
var W3C_TRACE_FLAGS_SAMPLED = "01";
|
|
4103
|
-
function makeTrackedFetch(realFetch) {
|
|
4104
|
-
return async (input, init) => {
|
|
4105
|
-
const context = telemetry.createDependencyContext();
|
|
4106
|
-
const url = resolveUrl(input);
|
|
4107
|
-
if (!context || !url) {
|
|
4108
|
-
return realFetch(input, init);
|
|
4109
|
-
}
|
|
4110
|
-
const method = resolveMethod(input, init).toUpperCase();
|
|
4111
|
-
const headers = mergeHeaders(input, init);
|
|
4112
|
-
if (!headers.has("traceparent")) {
|
|
4113
|
-
headers.set("traceparent", `00-${context.operationId}-${context.id}-${W3C_TRACE_FLAGS_SAMPLED}`);
|
|
4114
|
-
}
|
|
4115
|
-
const name = `${method} ${url.pathname}`;
|
|
4116
|
-
const clock = startSpanClock();
|
|
4117
|
-
context.startedAt = clock.startedAt;
|
|
4118
|
-
try {
|
|
4119
|
-
const response = await realFetch(input, { ...init, headers });
|
|
4120
|
-
const durationMs = clock.elapsedMs();
|
|
4121
|
-
recordHttpCall(durationMs);
|
|
4122
|
-
telemetry.trackDependencyResult(name, "HTTP", durationMs, response.ok, {
|
|
4123
|
-
"server.address": url.host,
|
|
4124
|
-
"http.request.method": method,
|
|
4125
|
-
"http.response.status_code": response.status
|
|
4126
|
-
}, context, String(response.status));
|
|
4127
|
-
return response;
|
|
4128
|
-
} catch (error) {
|
|
4129
|
-
const durationMs = clock.elapsedMs();
|
|
4130
|
-
recordHttpCall(durationMs);
|
|
4131
|
-
telemetry.trackDependencyResult(name, "HTTP", durationMs, false, {
|
|
4132
|
-
"server.address": url.host,
|
|
4133
|
-
"http.request.method": method,
|
|
4134
|
-
errorMessage: error instanceof Error ? error.message : String(error)
|
|
4135
|
-
}, context);
|
|
4136
|
-
throw error;
|
|
4137
|
-
}
|
|
4138
|
-
};
|
|
4139
|
-
}
|
|
4140
|
-
function resolveUrl(input) {
|
|
4141
|
-
try {
|
|
4142
|
-
if (typeof input === "string")
|
|
4143
|
-
return new URL(input);
|
|
4144
|
-
if (input instanceof URL)
|
|
4145
|
-
return input;
|
|
4146
|
-
if (input instanceof Request)
|
|
4147
|
-
return new URL(input.url);
|
|
4148
|
-
} catch {}
|
|
4149
|
-
return;
|
|
4150
|
-
}
|
|
4151
|
-
function resolveMethod(input, init) {
|
|
4152
|
-
if (init?.method)
|
|
4153
|
-
return init.method;
|
|
4154
|
-
if (input instanceof Request)
|
|
4155
|
-
return input.method;
|
|
4156
|
-
return "GET";
|
|
4157
|
-
}
|
|
4158
|
-
function mergeHeaders(input, init) {
|
|
4159
|
-
const headers = new Headers;
|
|
4160
|
-
if (input instanceof Request) {
|
|
4161
|
-
input.headers.forEach((value, key) => {
|
|
4162
|
-
headers.set(key, value);
|
|
4163
|
-
});
|
|
4164
|
-
}
|
|
4165
|
-
if (init?.headers) {
|
|
4166
|
-
new Headers(init.headers).forEach((value, key) => {
|
|
4167
|
-
headers.set(key, value);
|
|
4168
|
-
});
|
|
4169
|
-
}
|
|
4170
|
-
return headers;
|
|
4171
|
-
}
|
|
4172
4092
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
4173
4093
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
4174
4094
|
|
|
@@ -6000,6 +5920,6 @@ async function findSolutionFileUpward(fs, startDir) {
|
|
|
6000
5920
|
}
|
|
6001
5921
|
}
|
|
6002
5922
|
|
|
6003
|
-
export { catchError, describeConnectivityError, extractErrorDetails, extractErrorMessage, getOutputSink, logger,
|
|
5923
|
+
export { catchError, describeConnectivityError, extractErrorDetails, extractErrorMessage, getOutputSink, logger, RESULTS, OutputFormatter, InvalidArgumentError, Command, Option, processContext, isGuid, canPrompt, registerPackageMetadataOptions, mapPackageMetadataOptions, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, trackShipSucceeded, normalizeProjectType, tryRegisterProjectInParentSolution, findNearestParentUipxFile, findSolutionFileUpward };
|
|
6004
5924
|
|
|
6005
|
-
//# debugId=
|
|
5925
|
+
//# debugId=DE37B105000E327A64756E2164756E21
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
catchError,
|
|
3
|
-
getFileSystem
|
|
4
|
-
} from "./packager-tool-qyctya2j.js";
|
|
5
1
|
import {
|
|
6
2
|
getGlobalThis,
|
|
7
3
|
isBrowser
|
|
8
4
|
} from "./packager-tool-0gctz400.js";
|
|
5
|
+
import {
|
|
6
|
+
catchError,
|
|
7
|
+
getFileSystem
|
|
8
|
+
} from "./packager-tool-qyctya2j.js";
|
|
9
9
|
import {
|
|
10
10
|
AUTH_FILENAME,
|
|
11
11
|
DEFAULT_BASE_URL,
|
|
@@ -2322,4 +2322,4 @@ var authenticate = async ({
|
|
|
2322
2322
|
|
|
2323
2323
|
export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, parseJWT, parseAuthFlow, resolveSessionIdentity, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, TokenRefreshOAuthError, isTokenRefreshOAuthFailure, refreshAccessToken, AUTH_FLOW_ENV_VAR, DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME, resolveEnvFileLocationAsync, resolveEnvFilePathAsync, loadEnvFileAsync, saveEnvFileAsync, CredentialSource, getLoginStatusAsync, getLoginStatusWithDeps, getAuthContext, getAuthEnv, ClientCredentialsAuthenticationError, clientCredentialsLogin, JWT_BEARER_ASSERTION_TYPE, FederatedCredentialsAuthenticationError, federatedCredentialsLogin, fetchTenantsAndOrganizations, TENANT_SELECTION_REQUIRED_CODE, INVALID_TENANT_CODE, TenantSelectionError, TenantSelectionRequiredError, InvalidTenantError, isTenantSelectionError, selectTenantWithDeps, interactiveLoginWithDeps, interactiveLogin, logoutWithDeps, logout, authenticate };
|
|
2324
2324
|
|
|
2325
|
-
//# debugId=
|
|
2325
|
+
//# debugId=3D2BACA7964D278C64756E2164756E21
|
package/dist/tool.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
metadata,
|
|
3
3
|
registerCommands
|
|
4
|
-
} from "./packager-tool-
|
|
5
|
-
import"./packager-tool-
|
|
6
|
-
import"./packager-tool-
|
|
7
|
-
import"./packager-tool-qyctya2j.js";
|
|
4
|
+
} from "./packager-tool-26b8hr4k.js";
|
|
5
|
+
import"./packager-tool-58asqeb7.js";
|
|
6
|
+
import"./packager-tool-pvtdkdk8.js";
|
|
8
7
|
import"./packager-tool-05wez2xw.js";
|
|
9
8
|
import"./packager-tool-aybzcdfg.js";
|
|
10
|
-
import"./packager-tool-vv9c52ax.js";
|
|
11
9
|
import"./packager-tool-0gctz400.js";
|
|
10
|
+
import"./packager-tool-qyctya2j.js";
|
|
12
11
|
import"./packager-tool-yc4kw997.js";
|
|
13
12
|
import"./packager-tool-1yh8g550.js";
|
|
14
13
|
export {
|
|
@@ -16,4 +15,4 @@ export {
|
|
|
16
15
|
registerCommands
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
//# debugId=
|
|
18
|
+
//# debugId=E2C761283604C84064756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/codedapp-tool",
|
|
3
3
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "1.202.0-preview.
|
|
4
|
+
"version": "1.202.0-preview.156",
|
|
5
5
|
"description": "Build, pack, publish, deploy, and manage UiPath Coded Web Applications.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cli-tool",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"registry": "https://registry.npmjs.org/"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f5a11df096a9331e48a61fd5fbeea98c974f6770"
|
|
32
32
|
}
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FormData,
|
|
3
|
-
file_default
|
|
4
|
-
} from "./packager-tool-vv9c52ax.js";
|
|
5
|
-
import"./packager-tool-1yh8g550.js";
|
|
6
|
-
|
|
7
|
-
// ../../node_modules/node-fetch/src/utils/multipart-parser.js
|
|
8
|
-
var s = 0;
|
|
9
|
-
var S = {
|
|
10
|
-
START_BOUNDARY: s++,
|
|
11
|
-
HEADER_FIELD_START: s++,
|
|
12
|
-
HEADER_FIELD: s++,
|
|
13
|
-
HEADER_VALUE_START: s++,
|
|
14
|
-
HEADER_VALUE: s++,
|
|
15
|
-
HEADER_VALUE_ALMOST_DONE: s++,
|
|
16
|
-
HEADERS_ALMOST_DONE: s++,
|
|
17
|
-
PART_DATA_START: s++,
|
|
18
|
-
PART_DATA: s++,
|
|
19
|
-
END: s++
|
|
20
|
-
};
|
|
21
|
-
var f = 1;
|
|
22
|
-
var F = {
|
|
23
|
-
PART_BOUNDARY: f,
|
|
24
|
-
LAST_BOUNDARY: f *= 2
|
|
25
|
-
};
|
|
26
|
-
var LF = 10;
|
|
27
|
-
var CR = 13;
|
|
28
|
-
var SPACE = 32;
|
|
29
|
-
var HYPHEN = 45;
|
|
30
|
-
var COLON = 58;
|
|
31
|
-
var A = 97;
|
|
32
|
-
var Z = 122;
|
|
33
|
-
var lower = (c) => c | 32;
|
|
34
|
-
var noop = () => {};
|
|
35
|
-
|
|
36
|
-
class MultipartParser {
|
|
37
|
-
constructor(boundary) {
|
|
38
|
-
this.index = 0;
|
|
39
|
-
this.flags = 0;
|
|
40
|
-
this.onHeaderEnd = noop;
|
|
41
|
-
this.onHeaderField = noop;
|
|
42
|
-
this.onHeadersEnd = noop;
|
|
43
|
-
this.onHeaderValue = noop;
|
|
44
|
-
this.onPartBegin = noop;
|
|
45
|
-
this.onPartData = noop;
|
|
46
|
-
this.onPartEnd = noop;
|
|
47
|
-
this.boundaryChars = {};
|
|
48
|
-
boundary = `\r
|
|
49
|
-
--` + boundary;
|
|
50
|
-
const ui8a = new Uint8Array(boundary.length);
|
|
51
|
-
for (let i = 0;i < boundary.length; i++) {
|
|
52
|
-
ui8a[i] = boundary.charCodeAt(i);
|
|
53
|
-
this.boundaryChars[ui8a[i]] = true;
|
|
54
|
-
}
|
|
55
|
-
this.boundary = ui8a;
|
|
56
|
-
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
|
57
|
-
this.state = S.START_BOUNDARY;
|
|
58
|
-
}
|
|
59
|
-
write(data) {
|
|
60
|
-
let i = 0;
|
|
61
|
-
const length_ = data.length;
|
|
62
|
-
let previousIndex = this.index;
|
|
63
|
-
let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
|
|
64
|
-
const boundaryLength = this.boundary.length;
|
|
65
|
-
const boundaryEnd = boundaryLength - 1;
|
|
66
|
-
const bufferLength = data.length;
|
|
67
|
-
let c;
|
|
68
|
-
let cl;
|
|
69
|
-
const mark = (name) => {
|
|
70
|
-
this[name + "Mark"] = i;
|
|
71
|
-
};
|
|
72
|
-
const clear = (name) => {
|
|
73
|
-
delete this[name + "Mark"];
|
|
74
|
-
};
|
|
75
|
-
const callback = (callbackSymbol, start, end, ui8a) => {
|
|
76
|
-
if (start === undefined || start !== end) {
|
|
77
|
-
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const dataCallback = (name, clear2) => {
|
|
81
|
-
const markSymbol = name + "Mark";
|
|
82
|
-
if (!(markSymbol in this)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (clear2) {
|
|
86
|
-
callback(name, this[markSymbol], i, data);
|
|
87
|
-
delete this[markSymbol];
|
|
88
|
-
} else {
|
|
89
|
-
callback(name, this[markSymbol], data.length, data);
|
|
90
|
-
this[markSymbol] = 0;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
for (i = 0;i < length_; i++) {
|
|
94
|
-
c = data[i];
|
|
95
|
-
switch (state) {
|
|
96
|
-
case S.START_BOUNDARY:
|
|
97
|
-
if (index === boundary.length - 2) {
|
|
98
|
-
if (c === HYPHEN) {
|
|
99
|
-
flags |= F.LAST_BOUNDARY;
|
|
100
|
-
} else if (c !== CR) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
index++;
|
|
104
|
-
break;
|
|
105
|
-
} else if (index - 1 === boundary.length - 2) {
|
|
106
|
-
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
|
107
|
-
state = S.END;
|
|
108
|
-
flags = 0;
|
|
109
|
-
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
|
110
|
-
index = 0;
|
|
111
|
-
callback("onPartBegin");
|
|
112
|
-
state = S.HEADER_FIELD_START;
|
|
113
|
-
} else {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
if (c !== boundary[index + 2]) {
|
|
119
|
-
index = -2;
|
|
120
|
-
}
|
|
121
|
-
if (c === boundary[index + 2]) {
|
|
122
|
-
index++;
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
case S.HEADER_FIELD_START:
|
|
126
|
-
state = S.HEADER_FIELD;
|
|
127
|
-
mark("onHeaderField");
|
|
128
|
-
index = 0;
|
|
129
|
-
case S.HEADER_FIELD:
|
|
130
|
-
if (c === CR) {
|
|
131
|
-
clear("onHeaderField");
|
|
132
|
-
state = S.HEADERS_ALMOST_DONE;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
index++;
|
|
136
|
-
if (c === HYPHEN) {
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
if (c === COLON) {
|
|
140
|
-
if (index === 1) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
dataCallback("onHeaderField", true);
|
|
144
|
-
state = S.HEADER_VALUE_START;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
cl = lower(c);
|
|
148
|
-
if (cl < A || cl > Z) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
break;
|
|
152
|
-
case S.HEADER_VALUE_START:
|
|
153
|
-
if (c === SPACE) {
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
mark("onHeaderValue");
|
|
157
|
-
state = S.HEADER_VALUE;
|
|
158
|
-
case S.HEADER_VALUE:
|
|
159
|
-
if (c === CR) {
|
|
160
|
-
dataCallback("onHeaderValue", true);
|
|
161
|
-
callback("onHeaderEnd");
|
|
162
|
-
state = S.HEADER_VALUE_ALMOST_DONE;
|
|
163
|
-
}
|
|
164
|
-
break;
|
|
165
|
-
case S.HEADER_VALUE_ALMOST_DONE:
|
|
166
|
-
if (c !== LF) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
state = S.HEADER_FIELD_START;
|
|
170
|
-
break;
|
|
171
|
-
case S.HEADERS_ALMOST_DONE:
|
|
172
|
-
if (c !== LF) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
callback("onHeadersEnd");
|
|
176
|
-
state = S.PART_DATA_START;
|
|
177
|
-
break;
|
|
178
|
-
case S.PART_DATA_START:
|
|
179
|
-
state = S.PART_DATA;
|
|
180
|
-
mark("onPartData");
|
|
181
|
-
case S.PART_DATA:
|
|
182
|
-
previousIndex = index;
|
|
183
|
-
if (index === 0) {
|
|
184
|
-
i += boundaryEnd;
|
|
185
|
-
while (i < bufferLength && !(data[i] in boundaryChars)) {
|
|
186
|
-
i += boundaryLength;
|
|
187
|
-
}
|
|
188
|
-
i -= boundaryEnd;
|
|
189
|
-
c = data[i];
|
|
190
|
-
}
|
|
191
|
-
if (index < boundary.length) {
|
|
192
|
-
if (boundary[index] === c) {
|
|
193
|
-
if (index === 0) {
|
|
194
|
-
dataCallback("onPartData", true);
|
|
195
|
-
}
|
|
196
|
-
index++;
|
|
197
|
-
} else {
|
|
198
|
-
index = 0;
|
|
199
|
-
}
|
|
200
|
-
} else if (index === boundary.length) {
|
|
201
|
-
index++;
|
|
202
|
-
if (c === CR) {
|
|
203
|
-
flags |= F.PART_BOUNDARY;
|
|
204
|
-
} else if (c === HYPHEN) {
|
|
205
|
-
flags |= F.LAST_BOUNDARY;
|
|
206
|
-
} else {
|
|
207
|
-
index = 0;
|
|
208
|
-
}
|
|
209
|
-
} else if (index - 1 === boundary.length) {
|
|
210
|
-
if (flags & F.PART_BOUNDARY) {
|
|
211
|
-
index = 0;
|
|
212
|
-
if (c === LF) {
|
|
213
|
-
flags &= ~F.PART_BOUNDARY;
|
|
214
|
-
callback("onPartEnd");
|
|
215
|
-
callback("onPartBegin");
|
|
216
|
-
state = S.HEADER_FIELD_START;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
} else if (flags & F.LAST_BOUNDARY) {
|
|
220
|
-
if (c === HYPHEN) {
|
|
221
|
-
callback("onPartEnd");
|
|
222
|
-
state = S.END;
|
|
223
|
-
flags = 0;
|
|
224
|
-
} else {
|
|
225
|
-
index = 0;
|
|
226
|
-
}
|
|
227
|
-
} else {
|
|
228
|
-
index = 0;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (index > 0) {
|
|
232
|
-
lookbehind[index - 1] = c;
|
|
233
|
-
} else if (previousIndex > 0) {
|
|
234
|
-
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
|
235
|
-
callback("onPartData", 0, previousIndex, _lookbehind);
|
|
236
|
-
previousIndex = 0;
|
|
237
|
-
mark("onPartData");
|
|
238
|
-
i--;
|
|
239
|
-
}
|
|
240
|
-
break;
|
|
241
|
-
case S.END:
|
|
242
|
-
break;
|
|
243
|
-
default:
|
|
244
|
-
throw new Error(`Unexpected state entered: ${state}`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
dataCallback("onHeaderField");
|
|
248
|
-
dataCallback("onHeaderValue");
|
|
249
|
-
dataCallback("onPartData");
|
|
250
|
-
this.index = index;
|
|
251
|
-
this.state = state;
|
|
252
|
-
this.flags = flags;
|
|
253
|
-
}
|
|
254
|
-
end() {
|
|
255
|
-
if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) {
|
|
256
|
-
this.onPartEnd();
|
|
257
|
-
} else if (this.state !== S.END) {
|
|
258
|
-
throw new Error("MultipartParser.end(): stream ended unexpectedly");
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function _fileName(headerValue) {
|
|
263
|
-
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
|
264
|
-
if (!m) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
const match = m[2] || m[3] || "";
|
|
268
|
-
let filename = match.slice(match.lastIndexOf("\\") + 1);
|
|
269
|
-
filename = filename.replace(/%22/g, '"');
|
|
270
|
-
filename = filename.replace(/&#(\d{4});/g, (m2, code) => {
|
|
271
|
-
return String.fromCharCode(code);
|
|
272
|
-
});
|
|
273
|
-
return filename;
|
|
274
|
-
}
|
|
275
|
-
async function toFormData(Body, ct) {
|
|
276
|
-
if (!/multipart/i.test(ct)) {
|
|
277
|
-
throw new TypeError("Failed to fetch");
|
|
278
|
-
}
|
|
279
|
-
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
|
280
|
-
if (!m) {
|
|
281
|
-
throw new TypeError("no or bad content-type header, no multipart boundary");
|
|
282
|
-
}
|
|
283
|
-
const parser = new MultipartParser(m[1] || m[2]);
|
|
284
|
-
let headerField;
|
|
285
|
-
let headerValue;
|
|
286
|
-
let entryValue;
|
|
287
|
-
let entryName;
|
|
288
|
-
let contentType;
|
|
289
|
-
let filename;
|
|
290
|
-
const entryChunks = [];
|
|
291
|
-
const formData = new FormData;
|
|
292
|
-
const onPartData = (ui8a) => {
|
|
293
|
-
entryValue += decoder.decode(ui8a, { stream: true });
|
|
294
|
-
};
|
|
295
|
-
const appendToFile = (ui8a) => {
|
|
296
|
-
entryChunks.push(ui8a);
|
|
297
|
-
};
|
|
298
|
-
const appendFileToFormData = () => {
|
|
299
|
-
const file = new file_default(entryChunks, filename, { type: contentType });
|
|
300
|
-
formData.append(entryName, file);
|
|
301
|
-
};
|
|
302
|
-
const appendEntryToFormData = () => {
|
|
303
|
-
formData.append(entryName, entryValue);
|
|
304
|
-
};
|
|
305
|
-
const decoder = new TextDecoder("utf-8");
|
|
306
|
-
decoder.decode();
|
|
307
|
-
parser.onPartBegin = function() {
|
|
308
|
-
parser.onPartData = onPartData;
|
|
309
|
-
parser.onPartEnd = appendEntryToFormData;
|
|
310
|
-
headerField = "";
|
|
311
|
-
headerValue = "";
|
|
312
|
-
entryValue = "";
|
|
313
|
-
entryName = "";
|
|
314
|
-
contentType = "";
|
|
315
|
-
filename = null;
|
|
316
|
-
entryChunks.length = 0;
|
|
317
|
-
};
|
|
318
|
-
parser.onHeaderField = function(ui8a) {
|
|
319
|
-
headerField += decoder.decode(ui8a, { stream: true });
|
|
320
|
-
};
|
|
321
|
-
parser.onHeaderValue = function(ui8a) {
|
|
322
|
-
headerValue += decoder.decode(ui8a, { stream: true });
|
|
323
|
-
};
|
|
324
|
-
parser.onHeaderEnd = function() {
|
|
325
|
-
headerValue += decoder.decode();
|
|
326
|
-
headerField = headerField.toLowerCase();
|
|
327
|
-
if (headerField === "content-disposition") {
|
|
328
|
-
const m2 = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
|
329
|
-
if (m2) {
|
|
330
|
-
entryName = m2[2] || m2[3] || "";
|
|
331
|
-
}
|
|
332
|
-
filename = _fileName(headerValue);
|
|
333
|
-
if (filename) {
|
|
334
|
-
parser.onPartData = appendToFile;
|
|
335
|
-
parser.onPartEnd = appendFileToFormData;
|
|
336
|
-
}
|
|
337
|
-
} else if (headerField === "content-type") {
|
|
338
|
-
contentType = headerValue;
|
|
339
|
-
}
|
|
340
|
-
headerValue = "";
|
|
341
|
-
headerField = "";
|
|
342
|
-
};
|
|
343
|
-
for await (const chunk of Body) {
|
|
344
|
-
parser.write(chunk);
|
|
345
|
-
}
|
|
346
|
-
parser.end();
|
|
347
|
-
return formData;
|
|
348
|
-
}
|
|
349
|
-
export {
|
|
350
|
-
toFormData
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
//# debugId=EC19E2789120610F64756E2164756E21
|