@awsless/cli 0.0.1
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/README.MD +487 -0
- package/dist/app.json +1 -0
- package/dist/app.stage.json +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +49025 -0
- package/dist/build-json-schema.js +1925 -0
- package/dist/chunk-2TBBLACH.js +37 -0
- package/dist/chunk-3YEPERYO.js +1021 -0
- package/dist/chunk-4JFIJMQ6.js +46 -0
- package/dist/chunk-5TWBDDXS.js +60 -0
- package/dist/chunk-7NRPMOO4.js +876 -0
- package/dist/chunk-7XIGSOF4.js +100 -0
- package/dist/chunk-DSXFE5X2.js +174 -0
- package/dist/chunk-E7FQOYML.js +12 -0
- package/dist/chunk-GH475CSF.js +5005 -0
- package/dist/chunk-JHYKYQ5P.js +163 -0
- package/dist/chunk-LBISIOIM.js +28 -0
- package/dist/chunk-RCNT4C4P.js +50 -0
- package/dist/chunk-SIAA4J6H.js +21 -0
- package/dist/chunk-XNYTWFP6.js +241 -0
- package/dist/chunk-Z37AK4IA.js +546 -0
- package/dist/chunk-ZKH7AMP3.js +42 -0
- package/dist/dist-es-GXHCNXAC.js +489 -0
- package/dist/dist-es-J7SL4PXO.js +88 -0
- package/dist/dist-es-LL3VAI2X.js +70 -0
- package/dist/dist-es-QND3CYLI.js +380 -0
- package/dist/dist-es-STVZUSZG.js +21 -0
- package/dist/dist-es-TCFHB4OF.js +324 -0
- package/dist/dist-es-YFQTZTNE.js +167 -0
- package/dist/event-streams-74K5M656.js +244 -0
- package/dist/layers/sharp-arm.zip +0 -0
- package/dist/loadSso-O7PM54HL.js +592 -0
- package/dist/prebuild/icon/HASH +1 -0
- package/dist/prebuild/icon/bundle.zip +0 -0
- package/dist/prebuild/image/HASH +1 -0
- package/dist/prebuild/image/bundle.zip +0 -0
- package/dist/prebuild/on-error-log/HASH +1 -0
- package/dist/prebuild/on-error-log/bundle.zip +0 -0
- package/dist/prebuild/on-failure/HASH +1 -0
- package/dist/prebuild/on-failure/bundle.zip +0 -0
- package/dist/prebuild/rpc/HASH +1 -0
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/prebuild.js +159 -0
- package/dist/signin-6SPMGGJN.js +704 -0
- package/dist/sso-oidc-5IIWGKXY.js +829 -0
- package/dist/stack.json +1 -0
- package/dist/stack.stage.json +1 -0
- package/dist/sts-6SQWH4BL.js +3788 -0
- package/dist/test-global-setup.js +22 -0
- package/package.json +120 -0
|
@@ -0,0 +1,3788 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RpcProtocol
|
|
3
|
+
} from "./chunk-7XIGSOF4.js";
|
|
4
|
+
import {
|
|
5
|
+
createAggregatedClient
|
|
6
|
+
} from "./chunk-RCNT4C4P.js";
|
|
7
|
+
import {
|
|
8
|
+
Command,
|
|
9
|
+
NoAuthSigner,
|
|
10
|
+
getEndpointPlugin,
|
|
11
|
+
package_default
|
|
12
|
+
} from "./chunk-Z37AK4IA.js";
|
|
13
|
+
import {
|
|
14
|
+
AwsSdkSigV4Signer,
|
|
15
|
+
Client,
|
|
16
|
+
DEFAULT_RETRY_MODE,
|
|
17
|
+
DefaultIdentityProviderConfig,
|
|
18
|
+
EndpointCache,
|
|
19
|
+
FromStringShapeDeserializer,
|
|
20
|
+
Hash,
|
|
21
|
+
NODE_APP_ID_CONFIG_OPTIONS,
|
|
22
|
+
NODE_AUTH_SCHEME_PREFERENCE_OPTIONS,
|
|
23
|
+
NODE_MAX_ATTEMPT_CONFIG_OPTIONS,
|
|
24
|
+
NODE_REGION_CONFIG_FILE_OPTIONS,
|
|
25
|
+
NODE_REGION_CONFIG_OPTIONS,
|
|
26
|
+
NODE_RETRY_MODE_CONFIG_OPTIONS,
|
|
27
|
+
NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS,
|
|
28
|
+
NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,
|
|
29
|
+
NoOpLogger,
|
|
30
|
+
NormalizedSchema,
|
|
31
|
+
NumericValue,
|
|
32
|
+
ProtocolLib,
|
|
33
|
+
SerdeContextConfig,
|
|
34
|
+
ServiceException,
|
|
35
|
+
TypeRegistry,
|
|
36
|
+
UnionSerde,
|
|
37
|
+
awsEndpointFunctions,
|
|
38
|
+
calculateBodyLength,
|
|
39
|
+
collectBody,
|
|
40
|
+
createDefaultUserAgentProvider,
|
|
41
|
+
customEndpointFunctions,
|
|
42
|
+
deref,
|
|
43
|
+
determineTimestampFormat,
|
|
44
|
+
emitWarningIfUnsupportedVersion,
|
|
45
|
+
emitWarningIfUnsupportedVersion2,
|
|
46
|
+
extendedEncodeURIComponent,
|
|
47
|
+
getAwsRegionExtensionConfiguration,
|
|
48
|
+
getContentLengthPlugin,
|
|
49
|
+
getDefaultExtensionConfiguration,
|
|
50
|
+
getHostHeaderPlugin,
|
|
51
|
+
getHttpAuthSchemeEndpointRuleSetPlugin,
|
|
52
|
+
getHttpHandlerExtensionConfiguration,
|
|
53
|
+
getHttpSigningPlugin,
|
|
54
|
+
getLoggerPlugin,
|
|
55
|
+
getRecursionDetectionPlugin,
|
|
56
|
+
getRetryPlugin,
|
|
57
|
+
getSchemaSerdePlugin,
|
|
58
|
+
getSmithyContext,
|
|
59
|
+
getUserAgentPlugin,
|
|
60
|
+
loadConfigsForDefaultMode,
|
|
61
|
+
normalizeProvider,
|
|
62
|
+
resolveAwsRegionExtensionConfiguration,
|
|
63
|
+
resolveAwsSdkSigV4Config,
|
|
64
|
+
resolveDefaultRuntimeConfig,
|
|
65
|
+
resolveDefaultsModeConfig,
|
|
66
|
+
resolveEndpoint,
|
|
67
|
+
resolveEndpointConfig,
|
|
68
|
+
resolveHostHeaderConfig,
|
|
69
|
+
resolveHttpHandlerRuntimeConfig,
|
|
70
|
+
resolveRegionConfig,
|
|
71
|
+
resolveRetryConfig,
|
|
72
|
+
resolveUserAgentConfig,
|
|
73
|
+
v4
|
|
74
|
+
} from "./chunk-GH475CSF.js";
|
|
75
|
+
import {
|
|
76
|
+
loadConfig,
|
|
77
|
+
parseUrl
|
|
78
|
+
} from "./chunk-JHYKYQ5P.js";
|
|
79
|
+
import "./chunk-LBISIOIM.js";
|
|
80
|
+
import {
|
|
81
|
+
NodeHttpHandler,
|
|
82
|
+
dateToUtcString,
|
|
83
|
+
fromBase64,
|
|
84
|
+
streamCollector,
|
|
85
|
+
toBase64
|
|
86
|
+
} from "./chunk-7NRPMOO4.js";
|
|
87
|
+
import "./chunk-5TWBDDXS.js";
|
|
88
|
+
import {
|
|
89
|
+
fromUtf8,
|
|
90
|
+
toUtf8
|
|
91
|
+
} from "./chunk-ZKH7AMP3.js";
|
|
92
|
+
import "./chunk-XNYTWFP6.js";
|
|
93
|
+
import {
|
|
94
|
+
setCredentialFeature
|
|
95
|
+
} from "./chunk-E7FQOYML.js";
|
|
96
|
+
import "./chunk-2TBBLACH.js";
|
|
97
|
+
import "./chunk-SIAA4J6H.js";
|
|
98
|
+
|
|
99
|
+
// ../../node_modules/.pnpm/@smithy+smithy-client@4.12.8/node_modules/@smithy/smithy-client/dist-es/get-value-from-text-node.js
|
|
100
|
+
var getValueFromTextNode = (obj) => {
|
|
101
|
+
const textNodeName = "#text";
|
|
102
|
+
for (const key in obj) {
|
|
103
|
+
if (obj.hasOwnProperty(key) && obj[key][textNodeName] !== void 0) {
|
|
104
|
+
obj[key] = obj[key][textNodeName];
|
|
105
|
+
} else if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
106
|
+
obj[key] = getValueFromTextNode(obj[key]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return obj;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/auth/httpAuthSchemeProvider.js
|
|
113
|
+
var defaultSTSHttpAuthSchemeParametersProvider = async (config, context, input) => {
|
|
114
|
+
return {
|
|
115
|
+
operation: getSmithyContext(context).operation,
|
|
116
|
+
region: await normalizeProvider(config.region)() || (() => {
|
|
117
|
+
throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
|
|
118
|
+
})()
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
function createAwsAuthSigv4HttpAuthOption(authParameters) {
|
|
122
|
+
return {
|
|
123
|
+
schemeId: "aws.auth#sigv4",
|
|
124
|
+
signingProperties: {
|
|
125
|
+
name: "sts",
|
|
126
|
+
region: authParameters.region
|
|
127
|
+
},
|
|
128
|
+
propertiesExtractor: (config, context) => ({
|
|
129
|
+
signingProperties: {
|
|
130
|
+
config,
|
|
131
|
+
context
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function createSmithyApiNoAuthHttpAuthOption(authParameters) {
|
|
137
|
+
return {
|
|
138
|
+
schemeId: "smithy.api#noAuth"
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
var defaultSTSHttpAuthSchemeProvider = (authParameters) => {
|
|
142
|
+
const options = [];
|
|
143
|
+
switch (authParameters.operation) {
|
|
144
|
+
case "AssumeRoleWithWebIdentity": {
|
|
145
|
+
options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
default: {
|
|
149
|
+
options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return options;
|
|
153
|
+
};
|
|
154
|
+
var resolveStsAuthConfig = (input) => Object.assign(input, {
|
|
155
|
+
stsClientCtor: STSClient
|
|
156
|
+
});
|
|
157
|
+
var resolveHttpAuthSchemeConfig = (config) => {
|
|
158
|
+
const config_0 = resolveStsAuthConfig(config);
|
|
159
|
+
const config_1 = resolveAwsSdkSigV4Config(config_0);
|
|
160
|
+
return Object.assign(config_1, {
|
|
161
|
+
authSchemePreference: normalizeProvider(config.authSchemePreference ?? [])
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/endpoint/EndpointParameters.js
|
|
166
|
+
var resolveClientEndpointParameters = (options) => {
|
|
167
|
+
return Object.assign(options, {
|
|
168
|
+
useDualstackEndpoint: options.useDualstackEndpoint ?? false,
|
|
169
|
+
useFipsEndpoint: options.useFipsEndpoint ?? false,
|
|
170
|
+
useGlobalEndpoint: options.useGlobalEndpoint ?? false,
|
|
171
|
+
defaultSigningName: "sts"
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
var commonParams = {
|
|
175
|
+
UseGlobalEndpoint: { type: "builtInParams", name: "useGlobalEndpoint" },
|
|
176
|
+
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
|
|
177
|
+
Endpoint: { type: "builtInParams", name: "endpoint" },
|
|
178
|
+
Region: { type: "builtInParams", name: "region" },
|
|
179
|
+
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/util.js
|
|
183
|
+
var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
184
|
+
var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
185
|
+
var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
|
|
186
|
+
var regexName = new RegExp("^" + nameRegexp + "$");
|
|
187
|
+
function getAllMatches(string, regex) {
|
|
188
|
+
const matches = [];
|
|
189
|
+
let match = regex.exec(string);
|
|
190
|
+
while (match) {
|
|
191
|
+
const allmatches = [];
|
|
192
|
+
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
193
|
+
const len = match.length;
|
|
194
|
+
for (let index = 0; index < len; index++) {
|
|
195
|
+
allmatches.push(match[index]);
|
|
196
|
+
}
|
|
197
|
+
matches.push(allmatches);
|
|
198
|
+
match = regex.exec(string);
|
|
199
|
+
}
|
|
200
|
+
return matches;
|
|
201
|
+
}
|
|
202
|
+
var isName = function(string) {
|
|
203
|
+
const match = regexName.exec(string);
|
|
204
|
+
return !(match === null || typeof match === "undefined");
|
|
205
|
+
};
|
|
206
|
+
function isExist(v2) {
|
|
207
|
+
return typeof v2 !== "undefined";
|
|
208
|
+
}
|
|
209
|
+
var DANGEROUS_PROPERTY_NAMES = [
|
|
210
|
+
// '__proto__',
|
|
211
|
+
// 'constructor',
|
|
212
|
+
// 'prototype',
|
|
213
|
+
"hasOwnProperty",
|
|
214
|
+
"toString",
|
|
215
|
+
"valueOf",
|
|
216
|
+
"__defineGetter__",
|
|
217
|
+
"__defineSetter__",
|
|
218
|
+
"__lookupGetter__",
|
|
219
|
+
"__lookupSetter__"
|
|
220
|
+
];
|
|
221
|
+
var criticalProperties = ["__proto__", "constructor", "prototype"];
|
|
222
|
+
|
|
223
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/validator.js
|
|
224
|
+
var defaultOptions = {
|
|
225
|
+
allowBooleanAttributes: false,
|
|
226
|
+
//A tag can have attributes without any value
|
|
227
|
+
unpairedTags: []
|
|
228
|
+
};
|
|
229
|
+
function validate(xmlData, options) {
|
|
230
|
+
options = Object.assign({}, defaultOptions, options);
|
|
231
|
+
const tags = [];
|
|
232
|
+
let tagFound = false;
|
|
233
|
+
let reachedRoot = false;
|
|
234
|
+
if (xmlData[0] === "\uFEFF") {
|
|
235
|
+
xmlData = xmlData.substr(1);
|
|
236
|
+
}
|
|
237
|
+
for (let i2 = 0; i2 < xmlData.length; i2++) {
|
|
238
|
+
if (xmlData[i2] === "<" && xmlData[i2 + 1] === "?") {
|
|
239
|
+
i2 += 2;
|
|
240
|
+
i2 = readPI(xmlData, i2);
|
|
241
|
+
if (i2.err) return i2;
|
|
242
|
+
} else if (xmlData[i2] === "<") {
|
|
243
|
+
let tagStartPos = i2;
|
|
244
|
+
i2++;
|
|
245
|
+
if (xmlData[i2] === "!") {
|
|
246
|
+
i2 = readCommentAndCDATA(xmlData, i2);
|
|
247
|
+
continue;
|
|
248
|
+
} else {
|
|
249
|
+
let closingTag = false;
|
|
250
|
+
if (xmlData[i2] === "/") {
|
|
251
|
+
closingTag = true;
|
|
252
|
+
i2++;
|
|
253
|
+
}
|
|
254
|
+
let tagName = "";
|
|
255
|
+
for (; i2 < xmlData.length && xmlData[i2] !== ">" && xmlData[i2] !== " " && xmlData[i2] !== " " && xmlData[i2] !== "\n" && xmlData[i2] !== "\r"; i2++) {
|
|
256
|
+
tagName += xmlData[i2];
|
|
257
|
+
}
|
|
258
|
+
tagName = tagName.trim();
|
|
259
|
+
if (tagName[tagName.length - 1] === "/") {
|
|
260
|
+
tagName = tagName.substring(0, tagName.length - 1);
|
|
261
|
+
i2--;
|
|
262
|
+
}
|
|
263
|
+
if (!validateTagName(tagName)) {
|
|
264
|
+
let msg;
|
|
265
|
+
if (tagName.trim().length === 0) {
|
|
266
|
+
msg = "Invalid space after '<'.";
|
|
267
|
+
} else {
|
|
268
|
+
msg = "Tag '" + tagName + "' is an invalid name.";
|
|
269
|
+
}
|
|
270
|
+
return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i2));
|
|
271
|
+
}
|
|
272
|
+
const result = readAttributeStr(xmlData, i2);
|
|
273
|
+
if (result === false) {
|
|
274
|
+
return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i2));
|
|
275
|
+
}
|
|
276
|
+
let attrStr = result.value;
|
|
277
|
+
i2 = result.index;
|
|
278
|
+
if (attrStr[attrStr.length - 1] === "/") {
|
|
279
|
+
const attrStrStart = i2 - attrStr.length;
|
|
280
|
+
attrStr = attrStr.substring(0, attrStr.length - 1);
|
|
281
|
+
const isValid = validateAttributeString(attrStr, options);
|
|
282
|
+
if (isValid === true) {
|
|
283
|
+
tagFound = true;
|
|
284
|
+
} else {
|
|
285
|
+
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
|
|
286
|
+
}
|
|
287
|
+
} else if (closingTag) {
|
|
288
|
+
if (!result.tagClosed) {
|
|
289
|
+
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i2));
|
|
290
|
+
} else if (attrStr.trim().length > 0) {
|
|
291
|
+
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
292
|
+
} else if (tags.length === 0) {
|
|
293
|
+
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
294
|
+
} else {
|
|
295
|
+
const otg = tags.pop();
|
|
296
|
+
if (tagName !== otg.tagName) {
|
|
297
|
+
let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
|
|
298
|
+
return getErrorObject(
|
|
299
|
+
"InvalidTag",
|
|
300
|
+
"Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
|
|
301
|
+
getLineNumberForPosition(xmlData, tagStartPos)
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
if (tags.length == 0) {
|
|
305
|
+
reachedRoot = true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
const isValid = validateAttributeString(attrStr, options);
|
|
310
|
+
if (isValid !== true) {
|
|
311
|
+
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i2 - attrStr.length + isValid.err.line));
|
|
312
|
+
}
|
|
313
|
+
if (reachedRoot === true) {
|
|
314
|
+
return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i2));
|
|
315
|
+
} else if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
316
|
+
} else {
|
|
317
|
+
tags.push({ tagName, tagStartPos });
|
|
318
|
+
}
|
|
319
|
+
tagFound = true;
|
|
320
|
+
}
|
|
321
|
+
for (i2++; i2 < xmlData.length; i2++) {
|
|
322
|
+
if (xmlData[i2] === "<") {
|
|
323
|
+
if (xmlData[i2 + 1] === "!") {
|
|
324
|
+
i2++;
|
|
325
|
+
i2 = readCommentAndCDATA(xmlData, i2);
|
|
326
|
+
continue;
|
|
327
|
+
} else if (xmlData[i2 + 1] === "?") {
|
|
328
|
+
i2 = readPI(xmlData, ++i2);
|
|
329
|
+
if (i2.err) return i2;
|
|
330
|
+
} else {
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
} else if (xmlData[i2] === "&") {
|
|
334
|
+
const afterAmp = validateAmpersand(xmlData, i2);
|
|
335
|
+
if (afterAmp == -1)
|
|
336
|
+
return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i2));
|
|
337
|
+
i2 = afterAmp;
|
|
338
|
+
} else {
|
|
339
|
+
if (reachedRoot === true && !isWhiteSpace(xmlData[i2])) {
|
|
340
|
+
return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i2));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (xmlData[i2] === "<") {
|
|
345
|
+
i2--;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
if (isWhiteSpace(xmlData[i2])) {
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
return getErrorObject("InvalidChar", "char '" + xmlData[i2] + "' is not expected.", getLineNumberForPosition(xmlData, i2));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (!tagFound) {
|
|
356
|
+
return getErrorObject("InvalidXml", "Start tag expected.", 1);
|
|
357
|
+
} else if (tags.length == 1) {
|
|
358
|
+
return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
|
|
359
|
+
} else if (tags.length > 0) {
|
|
360
|
+
return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t2) => t2.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
361
|
+
}
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
function isWhiteSpace(char) {
|
|
365
|
+
return char === " " || char === " " || char === "\n" || char === "\r";
|
|
366
|
+
}
|
|
367
|
+
function readPI(xmlData, i2) {
|
|
368
|
+
const start = i2;
|
|
369
|
+
for (; i2 < xmlData.length; i2++) {
|
|
370
|
+
if (xmlData[i2] == "?" || xmlData[i2] == " ") {
|
|
371
|
+
const tagname = xmlData.substr(start, i2 - start);
|
|
372
|
+
if (i2 > 5 && tagname === "xml") {
|
|
373
|
+
return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i2));
|
|
374
|
+
} else if (xmlData[i2] == "?" && xmlData[i2 + 1] == ">") {
|
|
375
|
+
i2++;
|
|
376
|
+
break;
|
|
377
|
+
} else {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return i2;
|
|
383
|
+
}
|
|
384
|
+
function readCommentAndCDATA(xmlData, i2) {
|
|
385
|
+
if (xmlData.length > i2 + 5 && xmlData[i2 + 1] === "-" && xmlData[i2 + 2] === "-") {
|
|
386
|
+
for (i2 += 3; i2 < xmlData.length; i2++) {
|
|
387
|
+
if (xmlData[i2] === "-" && xmlData[i2 + 1] === "-" && xmlData[i2 + 2] === ">") {
|
|
388
|
+
i2 += 2;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
} else if (xmlData.length > i2 + 8 && xmlData[i2 + 1] === "D" && xmlData[i2 + 2] === "O" && xmlData[i2 + 3] === "C" && xmlData[i2 + 4] === "T" && xmlData[i2 + 5] === "Y" && xmlData[i2 + 6] === "P" && xmlData[i2 + 7] === "E") {
|
|
393
|
+
let angleBracketsCount = 1;
|
|
394
|
+
for (i2 += 8; i2 < xmlData.length; i2++) {
|
|
395
|
+
if (xmlData[i2] === "<") {
|
|
396
|
+
angleBracketsCount++;
|
|
397
|
+
} else if (xmlData[i2] === ">") {
|
|
398
|
+
angleBracketsCount--;
|
|
399
|
+
if (angleBracketsCount === 0) {
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
} else if (xmlData.length > i2 + 9 && xmlData[i2 + 1] === "[" && xmlData[i2 + 2] === "C" && xmlData[i2 + 3] === "D" && xmlData[i2 + 4] === "A" && xmlData[i2 + 5] === "T" && xmlData[i2 + 6] === "A" && xmlData[i2 + 7] === "[") {
|
|
405
|
+
for (i2 += 8; i2 < xmlData.length; i2++) {
|
|
406
|
+
if (xmlData[i2] === "]" && xmlData[i2 + 1] === "]" && xmlData[i2 + 2] === ">") {
|
|
407
|
+
i2 += 2;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return i2;
|
|
413
|
+
}
|
|
414
|
+
var doubleQuote = '"';
|
|
415
|
+
var singleQuote = "'";
|
|
416
|
+
function readAttributeStr(xmlData, i2) {
|
|
417
|
+
let attrStr = "";
|
|
418
|
+
let startChar = "";
|
|
419
|
+
let tagClosed = false;
|
|
420
|
+
for (; i2 < xmlData.length; i2++) {
|
|
421
|
+
if (xmlData[i2] === doubleQuote || xmlData[i2] === singleQuote) {
|
|
422
|
+
if (startChar === "") {
|
|
423
|
+
startChar = xmlData[i2];
|
|
424
|
+
} else if (startChar !== xmlData[i2]) {
|
|
425
|
+
} else {
|
|
426
|
+
startChar = "";
|
|
427
|
+
}
|
|
428
|
+
} else if (xmlData[i2] === ">") {
|
|
429
|
+
if (startChar === "") {
|
|
430
|
+
tagClosed = true;
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
attrStr += xmlData[i2];
|
|
435
|
+
}
|
|
436
|
+
if (startChar !== "") {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
value: attrStr,
|
|
441
|
+
index: i2,
|
|
442
|
+
tagClosed
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
var validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
446
|
+
function validateAttributeString(attrStr, options) {
|
|
447
|
+
const matches = getAllMatches(attrStr, validAttrStrRegxp);
|
|
448
|
+
const attrNames = {};
|
|
449
|
+
for (let i2 = 0; i2 < matches.length; i2++) {
|
|
450
|
+
if (matches[i2][1].length === 0) {
|
|
451
|
+
return getErrorObject("InvalidAttr", "Attribute '" + matches[i2][2] + "' has no space in starting.", getPositionFromMatch(matches[i2]));
|
|
452
|
+
} else if (matches[i2][3] !== void 0 && matches[i2][4] === void 0) {
|
|
453
|
+
return getErrorObject("InvalidAttr", "Attribute '" + matches[i2][2] + "' is without value.", getPositionFromMatch(matches[i2]));
|
|
454
|
+
} else if (matches[i2][3] === void 0 && !options.allowBooleanAttributes) {
|
|
455
|
+
return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i2][2] + "' is not allowed.", getPositionFromMatch(matches[i2]));
|
|
456
|
+
}
|
|
457
|
+
const attrName = matches[i2][2];
|
|
458
|
+
if (!validateAttrName(attrName)) {
|
|
459
|
+
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i2]));
|
|
460
|
+
}
|
|
461
|
+
if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {
|
|
462
|
+
attrNames[attrName] = 1;
|
|
463
|
+
} else {
|
|
464
|
+
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i2]));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
function validateNumberAmpersand(xmlData, i2) {
|
|
470
|
+
let re = /\d/;
|
|
471
|
+
if (xmlData[i2] === "x") {
|
|
472
|
+
i2++;
|
|
473
|
+
re = /[\da-fA-F]/;
|
|
474
|
+
}
|
|
475
|
+
for (; i2 < xmlData.length; i2++) {
|
|
476
|
+
if (xmlData[i2] === ";")
|
|
477
|
+
return i2;
|
|
478
|
+
if (!xmlData[i2].match(re))
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
return -1;
|
|
482
|
+
}
|
|
483
|
+
function validateAmpersand(xmlData, i2) {
|
|
484
|
+
i2++;
|
|
485
|
+
if (xmlData[i2] === ";")
|
|
486
|
+
return -1;
|
|
487
|
+
if (xmlData[i2] === "#") {
|
|
488
|
+
i2++;
|
|
489
|
+
return validateNumberAmpersand(xmlData, i2);
|
|
490
|
+
}
|
|
491
|
+
let count = 0;
|
|
492
|
+
for (; i2 < xmlData.length; i2++, count++) {
|
|
493
|
+
if (xmlData[i2].match(/\w/) && count < 20)
|
|
494
|
+
continue;
|
|
495
|
+
if (xmlData[i2] === ";")
|
|
496
|
+
break;
|
|
497
|
+
return -1;
|
|
498
|
+
}
|
|
499
|
+
return i2;
|
|
500
|
+
}
|
|
501
|
+
function getErrorObject(code, message, lineNumber) {
|
|
502
|
+
return {
|
|
503
|
+
err: {
|
|
504
|
+
code,
|
|
505
|
+
msg: message,
|
|
506
|
+
line: lineNumber.line || lineNumber,
|
|
507
|
+
col: lineNumber.col
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function validateAttrName(attrName) {
|
|
512
|
+
return isName(attrName);
|
|
513
|
+
}
|
|
514
|
+
function validateTagName(tagname) {
|
|
515
|
+
return isName(tagname);
|
|
516
|
+
}
|
|
517
|
+
function getLineNumberForPosition(xmlData, index) {
|
|
518
|
+
const lines = xmlData.substring(0, index).split(/\r?\n/);
|
|
519
|
+
return {
|
|
520
|
+
line: lines.length,
|
|
521
|
+
// column number is last line's length + 1, because column numbering starts at 1:
|
|
522
|
+
col: lines[lines.length - 1].length + 1
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function getPositionFromMatch(match) {
|
|
526
|
+
return match.startIndex + match[1].length;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
|
|
530
|
+
var defaultOnDangerousProperty = (name) => {
|
|
531
|
+
if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
|
|
532
|
+
return "__" + name;
|
|
533
|
+
}
|
|
534
|
+
return name;
|
|
535
|
+
};
|
|
536
|
+
var defaultOptions2 = {
|
|
537
|
+
preserveOrder: false,
|
|
538
|
+
attributeNamePrefix: "@_",
|
|
539
|
+
attributesGroupName: false,
|
|
540
|
+
textNodeName: "#text",
|
|
541
|
+
ignoreAttributes: true,
|
|
542
|
+
removeNSPrefix: false,
|
|
543
|
+
// remove NS from tag name or attribute name if true
|
|
544
|
+
allowBooleanAttributes: false,
|
|
545
|
+
//a tag can have attributes without any value
|
|
546
|
+
//ignoreRootElement : false,
|
|
547
|
+
parseTagValue: true,
|
|
548
|
+
parseAttributeValue: false,
|
|
549
|
+
trimValues: true,
|
|
550
|
+
//Trim string values of tag and attributes
|
|
551
|
+
cdataPropName: false,
|
|
552
|
+
numberParseOptions: {
|
|
553
|
+
hex: true,
|
|
554
|
+
leadingZeros: true,
|
|
555
|
+
eNotation: true
|
|
556
|
+
},
|
|
557
|
+
tagValueProcessor: function(tagName, val) {
|
|
558
|
+
return val;
|
|
559
|
+
},
|
|
560
|
+
attributeValueProcessor: function(attrName, val) {
|
|
561
|
+
return val;
|
|
562
|
+
},
|
|
563
|
+
stopNodes: [],
|
|
564
|
+
//nested tags will not be parsed even for errors
|
|
565
|
+
alwaysCreateTextNode: false,
|
|
566
|
+
isArray: () => false,
|
|
567
|
+
commentPropName: false,
|
|
568
|
+
unpairedTags: [],
|
|
569
|
+
processEntities: true,
|
|
570
|
+
htmlEntities: false,
|
|
571
|
+
ignoreDeclaration: false,
|
|
572
|
+
ignorePiTags: false,
|
|
573
|
+
transformTagName: false,
|
|
574
|
+
transformAttributeName: false,
|
|
575
|
+
updateTag: function(tagName, jPath, attrs) {
|
|
576
|
+
return tagName;
|
|
577
|
+
},
|
|
578
|
+
// skipEmptyListItem: false
|
|
579
|
+
captureMetaData: false,
|
|
580
|
+
maxNestedTags: 100,
|
|
581
|
+
strictReservedNames: true,
|
|
582
|
+
jPath: true,
|
|
583
|
+
// if true, pass jPath string to callbacks; if false, pass matcher instance
|
|
584
|
+
onDangerousProperty: defaultOnDangerousProperty
|
|
585
|
+
};
|
|
586
|
+
function validatePropertyName(propertyName, optionName) {
|
|
587
|
+
if (typeof propertyName !== "string") {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const normalized = propertyName.toLowerCase();
|
|
591
|
+
if (DANGEROUS_PROPERTY_NAMES.some((dangerous) => normalized === dangerous.toLowerCase())) {
|
|
592
|
+
throw new Error(
|
|
593
|
+
`[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
if (criticalProperties.some((dangerous) => normalized === dangerous.toLowerCase())) {
|
|
597
|
+
throw new Error(
|
|
598
|
+
`[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function normalizeProcessEntities(value) {
|
|
603
|
+
if (typeof value === "boolean") {
|
|
604
|
+
return {
|
|
605
|
+
enabled: value,
|
|
606
|
+
// true or false
|
|
607
|
+
maxEntitySize: 1e4,
|
|
608
|
+
maxExpansionDepth: 10,
|
|
609
|
+
maxTotalExpansions: 1e3,
|
|
610
|
+
maxExpandedLength: 1e5,
|
|
611
|
+
maxEntityCount: 100,
|
|
612
|
+
allowedTags: null,
|
|
613
|
+
tagFilter: null
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
if (typeof value === "object" && value !== null) {
|
|
617
|
+
return {
|
|
618
|
+
enabled: value.enabled !== false,
|
|
619
|
+
maxEntitySize: Math.max(1, value.maxEntitySize ?? 1e4),
|
|
620
|
+
maxExpansionDepth: Math.max(1, value.maxExpansionDepth ?? 10),
|
|
621
|
+
maxTotalExpansions: Math.max(1, value.maxTotalExpansions ?? 1e3),
|
|
622
|
+
maxExpandedLength: Math.max(1, value.maxExpandedLength ?? 1e5),
|
|
623
|
+
maxEntityCount: Math.max(1, value.maxEntityCount ?? 100),
|
|
624
|
+
allowedTags: value.allowedTags ?? null,
|
|
625
|
+
tagFilter: value.tagFilter ?? null
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
return normalizeProcessEntities(true);
|
|
629
|
+
}
|
|
630
|
+
var buildOptions = function(options) {
|
|
631
|
+
const built = Object.assign({}, defaultOptions2, options);
|
|
632
|
+
const propertyNameOptions = [
|
|
633
|
+
{ value: built.attributeNamePrefix, name: "attributeNamePrefix" },
|
|
634
|
+
{ value: built.attributesGroupName, name: "attributesGroupName" },
|
|
635
|
+
{ value: built.textNodeName, name: "textNodeName" },
|
|
636
|
+
{ value: built.cdataPropName, name: "cdataPropName" },
|
|
637
|
+
{ value: built.commentPropName, name: "commentPropName" }
|
|
638
|
+
];
|
|
639
|
+
for (const { value, name } of propertyNameOptions) {
|
|
640
|
+
if (value) {
|
|
641
|
+
validatePropertyName(value, name);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (built.onDangerousProperty === null) {
|
|
645
|
+
built.onDangerousProperty = defaultOnDangerousProperty;
|
|
646
|
+
}
|
|
647
|
+
built.processEntities = normalizeProcessEntities(built.processEntities);
|
|
648
|
+
if (built.stopNodes && Array.isArray(built.stopNodes)) {
|
|
649
|
+
built.stopNodes = built.stopNodes.map((node) => {
|
|
650
|
+
if (typeof node === "string" && node.startsWith("*.")) {
|
|
651
|
+
return ".." + node.substring(2);
|
|
652
|
+
}
|
|
653
|
+
return node;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
return built;
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
|
|
660
|
+
var METADATA_SYMBOL;
|
|
661
|
+
if (typeof Symbol !== "function") {
|
|
662
|
+
METADATA_SYMBOL = "@@xmlMetadata";
|
|
663
|
+
} else {
|
|
664
|
+
METADATA_SYMBOL = /* @__PURE__ */ Symbol("XML Node Metadata");
|
|
665
|
+
}
|
|
666
|
+
var XmlNode = class {
|
|
667
|
+
constructor(tagname) {
|
|
668
|
+
this.tagname = tagname;
|
|
669
|
+
this.child = [];
|
|
670
|
+
this[":@"] = /* @__PURE__ */ Object.create(null);
|
|
671
|
+
}
|
|
672
|
+
add(key, val) {
|
|
673
|
+
if (key === "__proto__") key = "#__proto__";
|
|
674
|
+
this.child.push({ [key]: val });
|
|
675
|
+
}
|
|
676
|
+
addChild(node, startIndex) {
|
|
677
|
+
if (node.tagname === "__proto__") node.tagname = "#__proto__";
|
|
678
|
+
if (node[":@"] && Object.keys(node[":@"]).length > 0) {
|
|
679
|
+
this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
|
|
680
|
+
} else {
|
|
681
|
+
this.child.push({ [node.tagname]: node.child });
|
|
682
|
+
}
|
|
683
|
+
if (startIndex !== void 0) {
|
|
684
|
+
this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
/** symbol used for metadata */
|
|
688
|
+
static getMetaDataSymbol() {
|
|
689
|
+
return METADATA_SYMBOL;
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
|
|
694
|
+
var DocTypeReader = class {
|
|
695
|
+
constructor(options) {
|
|
696
|
+
this.suppressValidationErr = !options;
|
|
697
|
+
this.options = options;
|
|
698
|
+
}
|
|
699
|
+
readDocType(xmlData, i2) {
|
|
700
|
+
const entities = /* @__PURE__ */ Object.create(null);
|
|
701
|
+
let entityCount = 0;
|
|
702
|
+
if (xmlData[i2 + 3] === "O" && xmlData[i2 + 4] === "C" && xmlData[i2 + 5] === "T" && xmlData[i2 + 6] === "Y" && xmlData[i2 + 7] === "P" && xmlData[i2 + 8] === "E") {
|
|
703
|
+
i2 = i2 + 9;
|
|
704
|
+
let angleBracketsCount = 1;
|
|
705
|
+
let hasBody = false, comment = false;
|
|
706
|
+
let exp = "";
|
|
707
|
+
for (; i2 < xmlData.length; i2++) {
|
|
708
|
+
if (xmlData[i2] === "<" && !comment) {
|
|
709
|
+
if (hasBody && hasSeq(xmlData, "!ENTITY", i2)) {
|
|
710
|
+
i2 += 7;
|
|
711
|
+
let entityName, val;
|
|
712
|
+
[entityName, val, i2] = this.readEntityExp(xmlData, i2 + 1, this.suppressValidationErr);
|
|
713
|
+
if (val.indexOf("&") === -1) {
|
|
714
|
+
if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
|
|
715
|
+
throw new Error(
|
|
716
|
+
`Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
const escaped = entityName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
720
|
+
entities[entityName] = {
|
|
721
|
+
regx: RegExp(`&${escaped};`, "g"),
|
|
722
|
+
val
|
|
723
|
+
};
|
|
724
|
+
entityCount++;
|
|
725
|
+
}
|
|
726
|
+
} else if (hasBody && hasSeq(xmlData, "!ELEMENT", i2)) {
|
|
727
|
+
i2 += 8;
|
|
728
|
+
const { index } = this.readElementExp(xmlData, i2 + 1);
|
|
729
|
+
i2 = index;
|
|
730
|
+
} else if (hasBody && hasSeq(xmlData, "!ATTLIST", i2)) {
|
|
731
|
+
i2 += 8;
|
|
732
|
+
} else if (hasBody && hasSeq(xmlData, "!NOTATION", i2)) {
|
|
733
|
+
i2 += 9;
|
|
734
|
+
const { index } = this.readNotationExp(xmlData, i2 + 1, this.suppressValidationErr);
|
|
735
|
+
i2 = index;
|
|
736
|
+
} else if (hasSeq(xmlData, "!--", i2)) comment = true;
|
|
737
|
+
else throw new Error(`Invalid DOCTYPE`);
|
|
738
|
+
angleBracketsCount++;
|
|
739
|
+
exp = "";
|
|
740
|
+
} else if (xmlData[i2] === ">") {
|
|
741
|
+
if (comment) {
|
|
742
|
+
if (xmlData[i2 - 1] === "-" && xmlData[i2 - 2] === "-") {
|
|
743
|
+
comment = false;
|
|
744
|
+
angleBracketsCount--;
|
|
745
|
+
}
|
|
746
|
+
} else {
|
|
747
|
+
angleBracketsCount--;
|
|
748
|
+
}
|
|
749
|
+
if (angleBracketsCount === 0) {
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
} else if (xmlData[i2] === "[") {
|
|
753
|
+
hasBody = true;
|
|
754
|
+
} else {
|
|
755
|
+
exp += xmlData[i2];
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
if (angleBracketsCount !== 0) {
|
|
759
|
+
throw new Error(`Unclosed DOCTYPE`);
|
|
760
|
+
}
|
|
761
|
+
} else {
|
|
762
|
+
throw new Error(`Invalid Tag instead of DOCTYPE`);
|
|
763
|
+
}
|
|
764
|
+
return { entities, i: i2 };
|
|
765
|
+
}
|
|
766
|
+
readEntityExp(xmlData, i2) {
|
|
767
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
768
|
+
const startIndex = i2;
|
|
769
|
+
while (i2 < xmlData.length && !/\s/.test(xmlData[i2]) && xmlData[i2] !== '"' && xmlData[i2] !== "'") {
|
|
770
|
+
i2++;
|
|
771
|
+
}
|
|
772
|
+
let entityName = xmlData.substring(startIndex, i2);
|
|
773
|
+
validateEntityName(entityName);
|
|
774
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
775
|
+
if (!this.suppressValidationErr) {
|
|
776
|
+
if (xmlData.substring(i2, i2 + 6).toUpperCase() === "SYSTEM") {
|
|
777
|
+
throw new Error("External entities are not supported");
|
|
778
|
+
} else if (xmlData[i2] === "%") {
|
|
779
|
+
throw new Error("Parameter entities are not supported");
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
let entityValue = "";
|
|
783
|
+
[i2, entityValue] = this.readIdentifierVal(xmlData, i2, "entity");
|
|
784
|
+
if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
|
|
785
|
+
throw new Error(
|
|
786
|
+
`Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
i2--;
|
|
790
|
+
return [entityName, entityValue, i2];
|
|
791
|
+
}
|
|
792
|
+
readNotationExp(xmlData, i2) {
|
|
793
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
794
|
+
const startIndex = i2;
|
|
795
|
+
while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
|
|
796
|
+
i2++;
|
|
797
|
+
}
|
|
798
|
+
let notationName = xmlData.substring(startIndex, i2);
|
|
799
|
+
!this.suppressValidationErr && validateEntityName(notationName);
|
|
800
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
801
|
+
const identifierType = xmlData.substring(i2, i2 + 6).toUpperCase();
|
|
802
|
+
if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
|
|
803
|
+
throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
|
|
804
|
+
}
|
|
805
|
+
i2 += identifierType.length;
|
|
806
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
807
|
+
let publicIdentifier = null;
|
|
808
|
+
let systemIdentifier = null;
|
|
809
|
+
if (identifierType === "PUBLIC") {
|
|
810
|
+
[i2, publicIdentifier] = this.readIdentifierVal(xmlData, i2, "publicIdentifier");
|
|
811
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
812
|
+
if (xmlData[i2] === '"' || xmlData[i2] === "'") {
|
|
813
|
+
[i2, systemIdentifier] = this.readIdentifierVal(xmlData, i2, "systemIdentifier");
|
|
814
|
+
}
|
|
815
|
+
} else if (identifierType === "SYSTEM") {
|
|
816
|
+
[i2, systemIdentifier] = this.readIdentifierVal(xmlData, i2, "systemIdentifier");
|
|
817
|
+
if (!this.suppressValidationErr && !systemIdentifier) {
|
|
818
|
+
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return { notationName, publicIdentifier, systemIdentifier, index: --i2 };
|
|
822
|
+
}
|
|
823
|
+
readIdentifierVal(xmlData, i2, type) {
|
|
824
|
+
let identifierVal = "";
|
|
825
|
+
const startChar = xmlData[i2];
|
|
826
|
+
if (startChar !== '"' && startChar !== "'") {
|
|
827
|
+
throw new Error(`Expected quoted string, found "${startChar}"`);
|
|
828
|
+
}
|
|
829
|
+
i2++;
|
|
830
|
+
const startIndex = i2;
|
|
831
|
+
while (i2 < xmlData.length && xmlData[i2] !== startChar) {
|
|
832
|
+
i2++;
|
|
833
|
+
}
|
|
834
|
+
identifierVal = xmlData.substring(startIndex, i2);
|
|
835
|
+
if (xmlData[i2] !== startChar) {
|
|
836
|
+
throw new Error(`Unterminated ${type} value`);
|
|
837
|
+
}
|
|
838
|
+
i2++;
|
|
839
|
+
return [i2, identifierVal];
|
|
840
|
+
}
|
|
841
|
+
readElementExp(xmlData, i2) {
|
|
842
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
843
|
+
const startIndex = i2;
|
|
844
|
+
while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
|
|
845
|
+
i2++;
|
|
846
|
+
}
|
|
847
|
+
let elementName = xmlData.substring(startIndex, i2);
|
|
848
|
+
if (!this.suppressValidationErr && !isName(elementName)) {
|
|
849
|
+
throw new Error(`Invalid element name: "${elementName}"`);
|
|
850
|
+
}
|
|
851
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
852
|
+
let contentModel = "";
|
|
853
|
+
if (xmlData[i2] === "E" && hasSeq(xmlData, "MPTY", i2)) i2 += 4;
|
|
854
|
+
else if (xmlData[i2] === "A" && hasSeq(xmlData, "NY", i2)) i2 += 2;
|
|
855
|
+
else if (xmlData[i2] === "(") {
|
|
856
|
+
i2++;
|
|
857
|
+
const startIndex2 = i2;
|
|
858
|
+
while (i2 < xmlData.length && xmlData[i2] !== ")") {
|
|
859
|
+
i2++;
|
|
860
|
+
}
|
|
861
|
+
contentModel = xmlData.substring(startIndex2, i2);
|
|
862
|
+
if (xmlData[i2] !== ")") {
|
|
863
|
+
throw new Error("Unterminated content model");
|
|
864
|
+
}
|
|
865
|
+
} else if (!this.suppressValidationErr) {
|
|
866
|
+
throw new Error(`Invalid Element Expression, found "${xmlData[i2]}"`);
|
|
867
|
+
}
|
|
868
|
+
return {
|
|
869
|
+
elementName,
|
|
870
|
+
contentModel: contentModel.trim(),
|
|
871
|
+
index: i2
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
readAttlistExp(xmlData, i2) {
|
|
875
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
876
|
+
let startIndex = i2;
|
|
877
|
+
while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
|
|
878
|
+
i2++;
|
|
879
|
+
}
|
|
880
|
+
let elementName = xmlData.substring(startIndex, i2);
|
|
881
|
+
validateEntityName(elementName);
|
|
882
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
883
|
+
startIndex = i2;
|
|
884
|
+
while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
|
|
885
|
+
i2++;
|
|
886
|
+
}
|
|
887
|
+
let attributeName = xmlData.substring(startIndex, i2);
|
|
888
|
+
if (!validateEntityName(attributeName)) {
|
|
889
|
+
throw new Error(`Invalid attribute name: "${attributeName}"`);
|
|
890
|
+
}
|
|
891
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
892
|
+
let attributeType = "";
|
|
893
|
+
if (xmlData.substring(i2, i2 + 8).toUpperCase() === "NOTATION") {
|
|
894
|
+
attributeType = "NOTATION";
|
|
895
|
+
i2 += 8;
|
|
896
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
897
|
+
if (xmlData[i2] !== "(") {
|
|
898
|
+
throw new Error(`Expected '(', found "${xmlData[i2]}"`);
|
|
899
|
+
}
|
|
900
|
+
i2++;
|
|
901
|
+
let allowedNotations = [];
|
|
902
|
+
while (i2 < xmlData.length && xmlData[i2] !== ")") {
|
|
903
|
+
const startIndex2 = i2;
|
|
904
|
+
while (i2 < xmlData.length && xmlData[i2] !== "|" && xmlData[i2] !== ")") {
|
|
905
|
+
i2++;
|
|
906
|
+
}
|
|
907
|
+
let notation = xmlData.substring(startIndex2, i2);
|
|
908
|
+
notation = notation.trim();
|
|
909
|
+
if (!validateEntityName(notation)) {
|
|
910
|
+
throw new Error(`Invalid notation name: "${notation}"`);
|
|
911
|
+
}
|
|
912
|
+
allowedNotations.push(notation);
|
|
913
|
+
if (xmlData[i2] === "|") {
|
|
914
|
+
i2++;
|
|
915
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
if (xmlData[i2] !== ")") {
|
|
919
|
+
throw new Error("Unterminated list of notations");
|
|
920
|
+
}
|
|
921
|
+
i2++;
|
|
922
|
+
attributeType += " (" + allowedNotations.join("|") + ")";
|
|
923
|
+
} else {
|
|
924
|
+
const startIndex2 = i2;
|
|
925
|
+
while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
|
|
926
|
+
i2++;
|
|
927
|
+
}
|
|
928
|
+
attributeType += xmlData.substring(startIndex2, i2);
|
|
929
|
+
const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
|
930
|
+
if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
|
|
931
|
+
throw new Error(`Invalid attribute type: "${attributeType}"`);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
i2 = skipWhitespace(xmlData, i2);
|
|
935
|
+
let defaultValue = "";
|
|
936
|
+
if (xmlData.substring(i2, i2 + 8).toUpperCase() === "#REQUIRED") {
|
|
937
|
+
defaultValue = "#REQUIRED";
|
|
938
|
+
i2 += 8;
|
|
939
|
+
} else if (xmlData.substring(i2, i2 + 7).toUpperCase() === "#IMPLIED") {
|
|
940
|
+
defaultValue = "#IMPLIED";
|
|
941
|
+
i2 += 7;
|
|
942
|
+
} else {
|
|
943
|
+
[i2, defaultValue] = this.readIdentifierVal(xmlData, i2, "ATTLIST");
|
|
944
|
+
}
|
|
945
|
+
return {
|
|
946
|
+
elementName,
|
|
947
|
+
attributeName,
|
|
948
|
+
attributeType,
|
|
949
|
+
defaultValue,
|
|
950
|
+
index: i2
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
var skipWhitespace = (data, index) => {
|
|
955
|
+
while (index < data.length && /\s/.test(data[index])) {
|
|
956
|
+
index++;
|
|
957
|
+
}
|
|
958
|
+
return index;
|
|
959
|
+
};
|
|
960
|
+
function hasSeq(data, seq, i2) {
|
|
961
|
+
for (let j2 = 0; j2 < seq.length; j2++) {
|
|
962
|
+
if (seq[j2] !== data[i2 + j2 + 1]) return false;
|
|
963
|
+
}
|
|
964
|
+
return true;
|
|
965
|
+
}
|
|
966
|
+
function validateEntityName(name) {
|
|
967
|
+
if (isName(name))
|
|
968
|
+
return name;
|
|
969
|
+
else
|
|
970
|
+
throw new Error(`Invalid entity name ${name}`);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// ../../node_modules/.pnpm/strnum@2.2.2/node_modules/strnum/strnum.js
|
|
974
|
+
var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
|
|
975
|
+
var numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
|
|
976
|
+
var consider = {
|
|
977
|
+
hex: true,
|
|
978
|
+
// oct: false,
|
|
979
|
+
leadingZeros: true,
|
|
980
|
+
decimalPoint: ".",
|
|
981
|
+
eNotation: true,
|
|
982
|
+
//skipLike: /regex/,
|
|
983
|
+
infinity: "original"
|
|
984
|
+
// "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
|
|
985
|
+
};
|
|
986
|
+
function toNumber(str, options = {}) {
|
|
987
|
+
options = Object.assign({}, consider, options);
|
|
988
|
+
if (!str || typeof str !== "string") return str;
|
|
989
|
+
let trimmedStr = str.trim();
|
|
990
|
+
if (trimmedStr.length === 0) return str;
|
|
991
|
+
else if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
|
|
992
|
+
else if (trimmedStr === "0") return 0;
|
|
993
|
+
else if (options.hex && hexRegex.test(trimmedStr)) {
|
|
994
|
+
return parse_int(trimmedStr, 16);
|
|
995
|
+
} else if (!isFinite(trimmedStr)) {
|
|
996
|
+
return handleInfinity(str, Number(trimmedStr), options);
|
|
997
|
+
} else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
|
|
998
|
+
return resolveEnotation(str, trimmedStr, options);
|
|
999
|
+
} else {
|
|
1000
|
+
const match = numRegex.exec(trimmedStr);
|
|
1001
|
+
if (match) {
|
|
1002
|
+
const sign = match[1] || "";
|
|
1003
|
+
const leadingZeros = match[2];
|
|
1004
|
+
let numTrimmedByZeros = trimZeros(match[3]);
|
|
1005
|
+
const decimalAdjacentToLeadingZeros = sign ? (
|
|
1006
|
+
// 0., -00., 000.
|
|
1007
|
+
str[leadingZeros.length + 1] === "."
|
|
1008
|
+
) : str[leadingZeros.length] === ".";
|
|
1009
|
+
if (!options.leadingZeros && (leadingZeros.length > 1 || leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros)) {
|
|
1010
|
+
return str;
|
|
1011
|
+
} else {
|
|
1012
|
+
const num = Number(trimmedStr);
|
|
1013
|
+
const parsedStr = String(num);
|
|
1014
|
+
if (num === 0) return num;
|
|
1015
|
+
if (parsedStr.search(/[eE]/) !== -1) {
|
|
1016
|
+
if (options.eNotation) return num;
|
|
1017
|
+
else return str;
|
|
1018
|
+
} else if (trimmedStr.indexOf(".") !== -1) {
|
|
1019
|
+
if (parsedStr === "0") return num;
|
|
1020
|
+
else if (parsedStr === numTrimmedByZeros) return num;
|
|
1021
|
+
else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
|
|
1022
|
+
else return str;
|
|
1023
|
+
}
|
|
1024
|
+
let n2 = leadingZeros ? numTrimmedByZeros : trimmedStr;
|
|
1025
|
+
if (leadingZeros) {
|
|
1026
|
+
return n2 === parsedStr || sign + n2 === parsedStr ? num : str;
|
|
1027
|
+
} else {
|
|
1028
|
+
return n2 === parsedStr || n2 === sign + parsedStr ? num : str;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
} else {
|
|
1032
|
+
return str;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
var eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
1037
|
+
function resolveEnotation(str, trimmedStr, options) {
|
|
1038
|
+
if (!options.eNotation) return str;
|
|
1039
|
+
const notation = trimmedStr.match(eNotationRegx);
|
|
1040
|
+
if (notation) {
|
|
1041
|
+
let sign = notation[1] || "";
|
|
1042
|
+
const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
|
|
1043
|
+
const leadingZeros = notation[2];
|
|
1044
|
+
const eAdjacentToLeadingZeros = sign ? (
|
|
1045
|
+
// 0E.
|
|
1046
|
+
str[leadingZeros.length + 1] === eChar
|
|
1047
|
+
) : str[leadingZeros.length] === eChar;
|
|
1048
|
+
if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
|
|
1049
|
+
else if (leadingZeros.length === 1 && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
|
|
1050
|
+
return Number(trimmedStr);
|
|
1051
|
+
} else if (leadingZeros.length > 0) {
|
|
1052
|
+
if (options.leadingZeros && !eAdjacentToLeadingZeros) {
|
|
1053
|
+
trimmedStr = (notation[1] || "") + notation[3];
|
|
1054
|
+
return Number(trimmedStr);
|
|
1055
|
+
} else return str;
|
|
1056
|
+
} else {
|
|
1057
|
+
return Number(trimmedStr);
|
|
1058
|
+
}
|
|
1059
|
+
} else {
|
|
1060
|
+
return str;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
function trimZeros(numStr) {
|
|
1064
|
+
if (numStr && numStr.indexOf(".") !== -1) {
|
|
1065
|
+
numStr = numStr.replace(/0+$/, "");
|
|
1066
|
+
if (numStr === ".") numStr = "0";
|
|
1067
|
+
else if (numStr[0] === ".") numStr = "0" + numStr;
|
|
1068
|
+
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
|
|
1069
|
+
return numStr;
|
|
1070
|
+
}
|
|
1071
|
+
return numStr;
|
|
1072
|
+
}
|
|
1073
|
+
function parse_int(numStr, base) {
|
|
1074
|
+
if (parseInt) return parseInt(numStr, base);
|
|
1075
|
+
else if (Number.parseInt) return Number.parseInt(numStr, base);
|
|
1076
|
+
else if (window && window.parseInt) return window.parseInt(numStr, base);
|
|
1077
|
+
else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
1078
|
+
}
|
|
1079
|
+
function handleInfinity(str, num, options) {
|
|
1080
|
+
const isPositive = num === Infinity;
|
|
1081
|
+
switch (options.infinity.toLowerCase()) {
|
|
1082
|
+
case "null":
|
|
1083
|
+
return null;
|
|
1084
|
+
case "infinity":
|
|
1085
|
+
return num;
|
|
1086
|
+
// Return Infinity or -Infinity
|
|
1087
|
+
case "string":
|
|
1088
|
+
return isPositive ? "Infinity" : "-Infinity";
|
|
1089
|
+
case "original":
|
|
1090
|
+
default:
|
|
1091
|
+
return str;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/ignoreAttributes.js
|
|
1096
|
+
function getIgnoreAttributesFn(ignoreAttributes) {
|
|
1097
|
+
if (typeof ignoreAttributes === "function") {
|
|
1098
|
+
return ignoreAttributes;
|
|
1099
|
+
}
|
|
1100
|
+
if (Array.isArray(ignoreAttributes)) {
|
|
1101
|
+
return (attrName) => {
|
|
1102
|
+
for (const pattern of ignoreAttributes) {
|
|
1103
|
+
if (typeof pattern === "string" && attrName === pattern) {
|
|
1104
|
+
return true;
|
|
1105
|
+
}
|
|
1106
|
+
if (pattern instanceof RegExp && pattern.test(attrName)) {
|
|
1107
|
+
return true;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
return () => false;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// ../../node_modules/.pnpm/path-expression-matcher@1.2.1/node_modules/path-expression-matcher/src/Expression.js
|
|
1116
|
+
var Expression = class {
|
|
1117
|
+
/**
|
|
1118
|
+
* Create a new Expression
|
|
1119
|
+
* @param {string} pattern - Pattern string (e.g., "root.users.user", "..user[id]")
|
|
1120
|
+
* @param {Object} options - Configuration options
|
|
1121
|
+
* @param {string} options.separator - Path separator (default: '.')
|
|
1122
|
+
*/
|
|
1123
|
+
constructor(pattern, options = {}) {
|
|
1124
|
+
this.pattern = pattern;
|
|
1125
|
+
this.separator = options.separator || ".";
|
|
1126
|
+
this.segments = this._parse(pattern);
|
|
1127
|
+
this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
|
|
1128
|
+
this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
|
|
1129
|
+
this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Parse pattern string into segments
|
|
1133
|
+
* @private
|
|
1134
|
+
* @param {string} pattern - Pattern to parse
|
|
1135
|
+
* @returns {Array} Array of segment objects
|
|
1136
|
+
*/
|
|
1137
|
+
_parse(pattern) {
|
|
1138
|
+
const segments = [];
|
|
1139
|
+
let i2 = 0;
|
|
1140
|
+
let currentPart = "";
|
|
1141
|
+
while (i2 < pattern.length) {
|
|
1142
|
+
if (pattern[i2] === this.separator) {
|
|
1143
|
+
if (i2 + 1 < pattern.length && pattern[i2 + 1] === this.separator) {
|
|
1144
|
+
if (currentPart.trim()) {
|
|
1145
|
+
segments.push(this._parseSegment(currentPart.trim()));
|
|
1146
|
+
currentPart = "";
|
|
1147
|
+
}
|
|
1148
|
+
segments.push({ type: "deep-wildcard" });
|
|
1149
|
+
i2 += 2;
|
|
1150
|
+
} else {
|
|
1151
|
+
if (currentPart.trim()) {
|
|
1152
|
+
segments.push(this._parseSegment(currentPart.trim()));
|
|
1153
|
+
}
|
|
1154
|
+
currentPart = "";
|
|
1155
|
+
i2++;
|
|
1156
|
+
}
|
|
1157
|
+
} else {
|
|
1158
|
+
currentPart += pattern[i2];
|
|
1159
|
+
i2++;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (currentPart.trim()) {
|
|
1163
|
+
segments.push(this._parseSegment(currentPart.trim()));
|
|
1164
|
+
}
|
|
1165
|
+
return segments;
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Parse a single segment
|
|
1169
|
+
* @private
|
|
1170
|
+
* @param {string} part - Segment string (e.g., "user", "ns::user", "user[id]", "ns::user:first")
|
|
1171
|
+
* @returns {Object} Segment object
|
|
1172
|
+
*/
|
|
1173
|
+
_parseSegment(part) {
|
|
1174
|
+
const segment = { type: "tag" };
|
|
1175
|
+
let bracketContent = null;
|
|
1176
|
+
let withoutBrackets = part;
|
|
1177
|
+
const bracketMatch = part.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);
|
|
1178
|
+
if (bracketMatch) {
|
|
1179
|
+
withoutBrackets = bracketMatch[1] + bracketMatch[3];
|
|
1180
|
+
if (bracketMatch[2]) {
|
|
1181
|
+
const content = bracketMatch[2].slice(1, -1);
|
|
1182
|
+
if (content) {
|
|
1183
|
+
bracketContent = content;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
let namespace = void 0;
|
|
1188
|
+
let tagAndPosition = withoutBrackets;
|
|
1189
|
+
if (withoutBrackets.includes("::")) {
|
|
1190
|
+
const nsIndex = withoutBrackets.indexOf("::");
|
|
1191
|
+
namespace = withoutBrackets.substring(0, nsIndex).trim();
|
|
1192
|
+
tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
|
|
1193
|
+
if (!namespace) {
|
|
1194
|
+
throw new Error(`Invalid namespace in pattern: ${part}`);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
let tag = void 0;
|
|
1198
|
+
let positionMatch = null;
|
|
1199
|
+
if (tagAndPosition.includes(":")) {
|
|
1200
|
+
const colonIndex = tagAndPosition.lastIndexOf(":");
|
|
1201
|
+
const tagPart = tagAndPosition.substring(0, colonIndex).trim();
|
|
1202
|
+
const posPart = tagAndPosition.substring(colonIndex + 1).trim();
|
|
1203
|
+
const isPositionKeyword = ["first", "last", "odd", "even"].includes(posPart) || /^nth\(\d+\)$/.test(posPart);
|
|
1204
|
+
if (isPositionKeyword) {
|
|
1205
|
+
tag = tagPart;
|
|
1206
|
+
positionMatch = posPart;
|
|
1207
|
+
} else {
|
|
1208
|
+
tag = tagAndPosition;
|
|
1209
|
+
}
|
|
1210
|
+
} else {
|
|
1211
|
+
tag = tagAndPosition;
|
|
1212
|
+
}
|
|
1213
|
+
if (!tag) {
|
|
1214
|
+
throw new Error(`Invalid segment pattern: ${part}`);
|
|
1215
|
+
}
|
|
1216
|
+
segment.tag = tag;
|
|
1217
|
+
if (namespace) {
|
|
1218
|
+
segment.namespace = namespace;
|
|
1219
|
+
}
|
|
1220
|
+
if (bracketContent) {
|
|
1221
|
+
if (bracketContent.includes("=")) {
|
|
1222
|
+
const eqIndex = bracketContent.indexOf("=");
|
|
1223
|
+
segment.attrName = bracketContent.substring(0, eqIndex).trim();
|
|
1224
|
+
segment.attrValue = bracketContent.substring(eqIndex + 1).trim();
|
|
1225
|
+
} else {
|
|
1226
|
+
segment.attrName = bracketContent.trim();
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
if (positionMatch) {
|
|
1230
|
+
const nthMatch = positionMatch.match(/^nth\((\d+)\)$/);
|
|
1231
|
+
if (nthMatch) {
|
|
1232
|
+
segment.position = "nth";
|
|
1233
|
+
segment.positionValue = parseInt(nthMatch[1], 10);
|
|
1234
|
+
} else {
|
|
1235
|
+
segment.position = positionMatch;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
return segment;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Get the number of segments
|
|
1242
|
+
* @returns {number}
|
|
1243
|
+
*/
|
|
1244
|
+
get length() {
|
|
1245
|
+
return this.segments.length;
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Check if expression contains deep wildcard
|
|
1249
|
+
* @returns {boolean}
|
|
1250
|
+
*/
|
|
1251
|
+
hasDeepWildcard() {
|
|
1252
|
+
return this._hasDeepWildcard;
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Check if expression has attribute conditions
|
|
1256
|
+
* @returns {boolean}
|
|
1257
|
+
*/
|
|
1258
|
+
hasAttributeCondition() {
|
|
1259
|
+
return this._hasAttributeCondition;
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Check if expression has position selectors
|
|
1263
|
+
* @returns {boolean}
|
|
1264
|
+
*/
|
|
1265
|
+
hasPositionSelector() {
|
|
1266
|
+
return this._hasPositionSelector;
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Get string representation
|
|
1270
|
+
* @returns {string}
|
|
1271
|
+
*/
|
|
1272
|
+
toString() {
|
|
1273
|
+
return this.pattern;
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
// ../../node_modules/.pnpm/path-expression-matcher@1.2.1/node_modules/path-expression-matcher/src/Matcher.js
|
|
1278
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set(["push", "pop", "reset", "updateCurrent", "restore"]);
|
|
1279
|
+
var Matcher = class {
|
|
1280
|
+
/**
|
|
1281
|
+
* Create a new Matcher
|
|
1282
|
+
* @param {Object} options - Configuration options
|
|
1283
|
+
* @param {string} options.separator - Default path separator (default: '.')
|
|
1284
|
+
*/
|
|
1285
|
+
constructor(options = {}) {
|
|
1286
|
+
this.separator = options.separator || ".";
|
|
1287
|
+
this.path = [];
|
|
1288
|
+
this.siblingStacks = [];
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Push a new tag onto the path
|
|
1292
|
+
* @param {string} tagName - Name of the tag
|
|
1293
|
+
* @param {Object} attrValues - Attribute key-value pairs for current node (optional)
|
|
1294
|
+
* @param {string} namespace - Namespace for the tag (optional)
|
|
1295
|
+
*/
|
|
1296
|
+
push(tagName, attrValues = null, namespace = null) {
|
|
1297
|
+
this._pathStringCache = null;
|
|
1298
|
+
if (this.path.length > 0) {
|
|
1299
|
+
const prev = this.path[this.path.length - 1];
|
|
1300
|
+
prev.values = void 0;
|
|
1301
|
+
}
|
|
1302
|
+
const currentLevel = this.path.length;
|
|
1303
|
+
if (!this.siblingStacks[currentLevel]) {
|
|
1304
|
+
this.siblingStacks[currentLevel] = /* @__PURE__ */ new Map();
|
|
1305
|
+
}
|
|
1306
|
+
const siblings = this.siblingStacks[currentLevel];
|
|
1307
|
+
const siblingKey = namespace ? `${namespace}:${tagName}` : tagName;
|
|
1308
|
+
const counter = siblings.get(siblingKey) || 0;
|
|
1309
|
+
let position = 0;
|
|
1310
|
+
for (const count of siblings.values()) {
|
|
1311
|
+
position += count;
|
|
1312
|
+
}
|
|
1313
|
+
siblings.set(siblingKey, counter + 1);
|
|
1314
|
+
const node = {
|
|
1315
|
+
tag: tagName,
|
|
1316
|
+
position,
|
|
1317
|
+
counter
|
|
1318
|
+
};
|
|
1319
|
+
if (namespace !== null && namespace !== void 0) {
|
|
1320
|
+
node.namespace = namespace;
|
|
1321
|
+
}
|
|
1322
|
+
if (attrValues !== null && attrValues !== void 0) {
|
|
1323
|
+
node.values = attrValues;
|
|
1324
|
+
}
|
|
1325
|
+
this.path.push(node);
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Pop the last tag from the path
|
|
1329
|
+
* @returns {Object|undefined} The popped node
|
|
1330
|
+
*/
|
|
1331
|
+
pop() {
|
|
1332
|
+
if (this.path.length === 0) {
|
|
1333
|
+
return void 0;
|
|
1334
|
+
}
|
|
1335
|
+
this._pathStringCache = null;
|
|
1336
|
+
const node = this.path.pop();
|
|
1337
|
+
if (this.siblingStacks.length > this.path.length + 1) {
|
|
1338
|
+
this.siblingStacks.length = this.path.length + 1;
|
|
1339
|
+
}
|
|
1340
|
+
return node;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Update current node's attribute values
|
|
1344
|
+
* Useful when attributes are parsed after push
|
|
1345
|
+
* @param {Object} attrValues - Attribute values
|
|
1346
|
+
*/
|
|
1347
|
+
updateCurrent(attrValues) {
|
|
1348
|
+
if (this.path.length > 0) {
|
|
1349
|
+
const current = this.path[this.path.length - 1];
|
|
1350
|
+
if (attrValues !== null && attrValues !== void 0) {
|
|
1351
|
+
current.values = attrValues;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Get current tag name
|
|
1357
|
+
* @returns {string|undefined}
|
|
1358
|
+
*/
|
|
1359
|
+
getCurrentTag() {
|
|
1360
|
+
return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0;
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Get current namespace
|
|
1364
|
+
* @returns {string|undefined}
|
|
1365
|
+
*/
|
|
1366
|
+
getCurrentNamespace() {
|
|
1367
|
+
return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0;
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Get current node's attribute value
|
|
1371
|
+
* @param {string} attrName - Attribute name
|
|
1372
|
+
* @returns {*} Attribute value or undefined
|
|
1373
|
+
*/
|
|
1374
|
+
getAttrValue(attrName) {
|
|
1375
|
+
if (this.path.length === 0) return void 0;
|
|
1376
|
+
const current = this.path[this.path.length - 1];
|
|
1377
|
+
return current.values?.[attrName];
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Check if current node has an attribute
|
|
1381
|
+
* @param {string} attrName - Attribute name
|
|
1382
|
+
* @returns {boolean}
|
|
1383
|
+
*/
|
|
1384
|
+
hasAttr(attrName) {
|
|
1385
|
+
if (this.path.length === 0) return false;
|
|
1386
|
+
const current = this.path[this.path.length - 1];
|
|
1387
|
+
return current.values !== void 0 && attrName in current.values;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Get current node's sibling position (child index in parent)
|
|
1391
|
+
* @returns {number}
|
|
1392
|
+
*/
|
|
1393
|
+
getPosition() {
|
|
1394
|
+
if (this.path.length === 0) return -1;
|
|
1395
|
+
return this.path[this.path.length - 1].position ?? 0;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Get current node's repeat counter (occurrence count of this tag name)
|
|
1399
|
+
* @returns {number}
|
|
1400
|
+
*/
|
|
1401
|
+
getCounter() {
|
|
1402
|
+
if (this.path.length === 0) return -1;
|
|
1403
|
+
return this.path[this.path.length - 1].counter ?? 0;
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Get current node's sibling index (alias for getPosition for backward compatibility)
|
|
1407
|
+
* @returns {number}
|
|
1408
|
+
* @deprecated Use getPosition() or getCounter() instead
|
|
1409
|
+
*/
|
|
1410
|
+
getIndex() {
|
|
1411
|
+
return this.getPosition();
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Get current path depth
|
|
1415
|
+
* @returns {number}
|
|
1416
|
+
*/
|
|
1417
|
+
getDepth() {
|
|
1418
|
+
return this.path.length;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Get path as string
|
|
1422
|
+
* @param {string} separator - Optional separator (uses default if not provided)
|
|
1423
|
+
* @param {boolean} includeNamespace - Whether to include namespace in output (default: true)
|
|
1424
|
+
* @returns {string}
|
|
1425
|
+
*/
|
|
1426
|
+
toString(separator, includeNamespace = true) {
|
|
1427
|
+
const sep = separator || this.separator;
|
|
1428
|
+
const isDefault = sep === this.separator && includeNamespace === true;
|
|
1429
|
+
if (isDefault) {
|
|
1430
|
+
if (this._pathStringCache !== null && this._pathStringCache !== void 0) {
|
|
1431
|
+
return this._pathStringCache;
|
|
1432
|
+
}
|
|
1433
|
+
const result = this.path.map(
|
|
1434
|
+
(n2) => includeNamespace && n2.namespace ? `${n2.namespace}:${n2.tag}` : n2.tag
|
|
1435
|
+
).join(sep);
|
|
1436
|
+
this._pathStringCache = result;
|
|
1437
|
+
return result;
|
|
1438
|
+
}
|
|
1439
|
+
return this.path.map(
|
|
1440
|
+
(n2) => includeNamespace && n2.namespace ? `${n2.namespace}:${n2.tag}` : n2.tag
|
|
1441
|
+
).join(sep);
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Get path as array of tag names
|
|
1445
|
+
* @returns {string[]}
|
|
1446
|
+
*/
|
|
1447
|
+
toArray() {
|
|
1448
|
+
return this.path.map((n2) => n2.tag);
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Reset the path to empty
|
|
1452
|
+
*/
|
|
1453
|
+
reset() {
|
|
1454
|
+
this._pathStringCache = null;
|
|
1455
|
+
this.path = [];
|
|
1456
|
+
this.siblingStacks = [];
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Match current path against an Expression
|
|
1460
|
+
* @param {Expression} expression - The expression to match against
|
|
1461
|
+
* @returns {boolean} True if current path matches the expression
|
|
1462
|
+
*/
|
|
1463
|
+
matches(expression) {
|
|
1464
|
+
const segments = expression.segments;
|
|
1465
|
+
if (segments.length === 0) {
|
|
1466
|
+
return false;
|
|
1467
|
+
}
|
|
1468
|
+
if (expression.hasDeepWildcard()) {
|
|
1469
|
+
return this._matchWithDeepWildcard(segments);
|
|
1470
|
+
}
|
|
1471
|
+
return this._matchSimple(segments);
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Match simple path (no deep wildcards)
|
|
1475
|
+
* @private
|
|
1476
|
+
*/
|
|
1477
|
+
_matchSimple(segments) {
|
|
1478
|
+
if (this.path.length !== segments.length) {
|
|
1479
|
+
return false;
|
|
1480
|
+
}
|
|
1481
|
+
for (let i2 = 0; i2 < segments.length; i2++) {
|
|
1482
|
+
const segment = segments[i2];
|
|
1483
|
+
const node = this.path[i2];
|
|
1484
|
+
const isCurrentNode = i2 === this.path.length - 1;
|
|
1485
|
+
if (!this._matchSegment(segment, node, isCurrentNode)) {
|
|
1486
|
+
return false;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
return true;
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Match path with deep wildcards
|
|
1493
|
+
* @private
|
|
1494
|
+
*/
|
|
1495
|
+
_matchWithDeepWildcard(segments) {
|
|
1496
|
+
let pathIdx = this.path.length - 1;
|
|
1497
|
+
let segIdx = segments.length - 1;
|
|
1498
|
+
while (segIdx >= 0 && pathIdx >= 0) {
|
|
1499
|
+
const segment = segments[segIdx];
|
|
1500
|
+
if (segment.type === "deep-wildcard") {
|
|
1501
|
+
segIdx--;
|
|
1502
|
+
if (segIdx < 0) {
|
|
1503
|
+
return true;
|
|
1504
|
+
}
|
|
1505
|
+
const nextSeg = segments[segIdx];
|
|
1506
|
+
let found = false;
|
|
1507
|
+
for (let i2 = pathIdx; i2 >= 0; i2--) {
|
|
1508
|
+
const isCurrentNode = i2 === this.path.length - 1;
|
|
1509
|
+
if (this._matchSegment(nextSeg, this.path[i2], isCurrentNode)) {
|
|
1510
|
+
pathIdx = i2 - 1;
|
|
1511
|
+
segIdx--;
|
|
1512
|
+
found = true;
|
|
1513
|
+
break;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
if (!found) {
|
|
1517
|
+
return false;
|
|
1518
|
+
}
|
|
1519
|
+
} else {
|
|
1520
|
+
const isCurrentNode = pathIdx === this.path.length - 1;
|
|
1521
|
+
if (!this._matchSegment(segment, this.path[pathIdx], isCurrentNode)) {
|
|
1522
|
+
return false;
|
|
1523
|
+
}
|
|
1524
|
+
pathIdx--;
|
|
1525
|
+
segIdx--;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
return segIdx < 0;
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Match a single segment against a node
|
|
1532
|
+
* @private
|
|
1533
|
+
* @param {Object} segment - Segment from Expression
|
|
1534
|
+
* @param {Object} node - Node from path
|
|
1535
|
+
* @param {boolean} isCurrentNode - Whether this is the current (last) node
|
|
1536
|
+
* @returns {boolean}
|
|
1537
|
+
*/
|
|
1538
|
+
_matchSegment(segment, node, isCurrentNode) {
|
|
1539
|
+
if (segment.tag !== "*" && segment.tag !== node.tag) {
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
if (segment.namespace !== void 0) {
|
|
1543
|
+
if (segment.namespace !== "*" && segment.namespace !== node.namespace) {
|
|
1544
|
+
return false;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
if (segment.attrName !== void 0) {
|
|
1548
|
+
if (!isCurrentNode) {
|
|
1549
|
+
return false;
|
|
1550
|
+
}
|
|
1551
|
+
if (!node.values || !(segment.attrName in node.values)) {
|
|
1552
|
+
return false;
|
|
1553
|
+
}
|
|
1554
|
+
if (segment.attrValue !== void 0) {
|
|
1555
|
+
const actualValue = node.values[segment.attrName];
|
|
1556
|
+
if (String(actualValue) !== String(segment.attrValue)) {
|
|
1557
|
+
return false;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
if (segment.position !== void 0) {
|
|
1562
|
+
if (!isCurrentNode) {
|
|
1563
|
+
return false;
|
|
1564
|
+
}
|
|
1565
|
+
const counter = node.counter ?? 0;
|
|
1566
|
+
if (segment.position === "first" && counter !== 0) {
|
|
1567
|
+
return false;
|
|
1568
|
+
} else if (segment.position === "odd" && counter % 2 !== 1) {
|
|
1569
|
+
return false;
|
|
1570
|
+
} else if (segment.position === "even" && counter % 2 !== 0) {
|
|
1571
|
+
return false;
|
|
1572
|
+
} else if (segment.position === "nth") {
|
|
1573
|
+
if (counter !== segment.positionValue) {
|
|
1574
|
+
return false;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
return true;
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Create a snapshot of current state
|
|
1582
|
+
* @returns {Object} State snapshot
|
|
1583
|
+
*/
|
|
1584
|
+
snapshot() {
|
|
1585
|
+
return {
|
|
1586
|
+
path: this.path.map((node) => ({ ...node })),
|
|
1587
|
+
siblingStacks: this.siblingStacks.map((map) => new Map(map))
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Restore state from snapshot
|
|
1592
|
+
* @param {Object} snapshot - State snapshot
|
|
1593
|
+
*/
|
|
1594
|
+
restore(snapshot) {
|
|
1595
|
+
this._pathStringCache = null;
|
|
1596
|
+
this.path = snapshot.path.map((node) => ({ ...node }));
|
|
1597
|
+
this.siblingStacks = snapshot.siblingStacks.map((map) => new Map(map));
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Return a read-only view of this matcher.
|
|
1601
|
+
*
|
|
1602
|
+
* The returned object exposes all query/inspection methods but throws a
|
|
1603
|
+
* TypeError if any state-mutating method is called (`push`, `pop`, `reset`,
|
|
1604
|
+
* `updateCurrent`, `restore`). Property reads (e.g. `.path`, `.separator`)
|
|
1605
|
+
* are allowed but the returned arrays/objects are frozen so callers cannot
|
|
1606
|
+
* mutate internal state through them either.
|
|
1607
|
+
*
|
|
1608
|
+
* @returns {ReadOnlyMatcher} A proxy that forwards read operations and blocks writes.
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* const matcher = new Matcher();
|
|
1612
|
+
* matcher.push("root", {});
|
|
1613
|
+
*
|
|
1614
|
+
* const ro = matcher.readOnly();
|
|
1615
|
+
* ro.matches(expr); // ✓ works
|
|
1616
|
+
* ro.getCurrentTag(); // ✓ works
|
|
1617
|
+
* ro.push("child", {}); // ✗ throws TypeError
|
|
1618
|
+
* ro.reset(); // ✗ throws TypeError
|
|
1619
|
+
*/
|
|
1620
|
+
readOnly() {
|
|
1621
|
+
const self = this;
|
|
1622
|
+
return new Proxy(self, {
|
|
1623
|
+
get(target, prop, receiver) {
|
|
1624
|
+
if (MUTATING_METHODS.has(prop)) {
|
|
1625
|
+
return () => {
|
|
1626
|
+
throw new TypeError(
|
|
1627
|
+
`Cannot call '${prop}' on a read-only Matcher. Obtain a writable instance to mutate state.`
|
|
1628
|
+
);
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
const value = Reflect.get(target, prop, receiver);
|
|
1632
|
+
if (prop === "path" || prop === "siblingStacks") {
|
|
1633
|
+
return Object.freeze(
|
|
1634
|
+
Array.isArray(value) ? value.map(
|
|
1635
|
+
(item) => item instanceof Map ? Object.freeze(new Map(item)) : Object.freeze({ ...item })
|
|
1636
|
+
// freeze a copy of each node
|
|
1637
|
+
) : value
|
|
1638
|
+
);
|
|
1639
|
+
}
|
|
1640
|
+
if (typeof value === "function") {
|
|
1641
|
+
return value.bind(target);
|
|
1642
|
+
}
|
|
1643
|
+
return value;
|
|
1644
|
+
},
|
|
1645
|
+
// Prevent any property assignment on the read-only view
|
|
1646
|
+
set(_target, prop) {
|
|
1647
|
+
throw new TypeError(
|
|
1648
|
+
`Cannot set property '${String(prop)}' on a read-only Matcher.`
|
|
1649
|
+
);
|
|
1650
|
+
},
|
|
1651
|
+
// Prevent property deletion
|
|
1652
|
+
deleteProperty(_target, prop) {
|
|
1653
|
+
throw new TypeError(
|
|
1654
|
+
`Cannot delete property '${String(prop)}' from a read-only Matcher.`
|
|
1655
|
+
);
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
|
|
1662
|
+
function extractRawAttributes(prefixedAttrs, options) {
|
|
1663
|
+
if (!prefixedAttrs) return {};
|
|
1664
|
+
const attrs = options.attributesGroupName ? prefixedAttrs[options.attributesGroupName] : prefixedAttrs;
|
|
1665
|
+
if (!attrs) return {};
|
|
1666
|
+
const rawAttrs = {};
|
|
1667
|
+
for (const key in attrs) {
|
|
1668
|
+
if (key.startsWith(options.attributeNamePrefix)) {
|
|
1669
|
+
const rawName = key.substring(options.attributeNamePrefix.length);
|
|
1670
|
+
rawAttrs[rawName] = attrs[key];
|
|
1671
|
+
} else {
|
|
1672
|
+
rawAttrs[key] = attrs[key];
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
return rawAttrs;
|
|
1676
|
+
}
|
|
1677
|
+
function extractNamespace(rawTagName) {
|
|
1678
|
+
if (!rawTagName || typeof rawTagName !== "string") return void 0;
|
|
1679
|
+
const colonIndex = rawTagName.indexOf(":");
|
|
1680
|
+
if (colonIndex !== -1 && colonIndex > 0) {
|
|
1681
|
+
const ns = rawTagName.substring(0, colonIndex);
|
|
1682
|
+
if (ns !== "xmlns") {
|
|
1683
|
+
return ns;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
return void 0;
|
|
1687
|
+
}
|
|
1688
|
+
var OrderedObjParser = class {
|
|
1689
|
+
constructor(options) {
|
|
1690
|
+
this.options = options;
|
|
1691
|
+
this.currentNode = null;
|
|
1692
|
+
this.tagsNodeStack = [];
|
|
1693
|
+
this.docTypeEntities = {};
|
|
1694
|
+
this.lastEntities = {
|
|
1695
|
+
"apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
1696
|
+
"gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
|
|
1697
|
+
"lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
|
|
1698
|
+
"quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
|
|
1699
|
+
};
|
|
1700
|
+
this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
|
|
1701
|
+
this.htmlEntities = {
|
|
1702
|
+
"space": { regex: /&(nbsp|#160);/g, val: " " },
|
|
1703
|
+
// "lt" : { regex: /&(lt|#60);/g, val: "<" },
|
|
1704
|
+
// "gt" : { regex: /&(gt|#62);/g, val: ">" },
|
|
1705
|
+
// "amp" : { regex: /&(amp|#38);/g, val: "&" },
|
|
1706
|
+
// "quot" : { regex: /&(quot|#34);/g, val: "\"" },
|
|
1707
|
+
// "apos" : { regex: /&(apos|#39);/g, val: "'" },
|
|
1708
|
+
"cent": { regex: /&(cent|#162);/g, val: "\xA2" },
|
|
1709
|
+
"pound": { regex: /&(pound|#163);/g, val: "\xA3" },
|
|
1710
|
+
"yen": { regex: /&(yen|#165);/g, val: "\xA5" },
|
|
1711
|
+
"euro": { regex: /&(euro|#8364);/g, val: "\u20AC" },
|
|
1712
|
+
"copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
|
|
1713
|
+
"reg": { regex: /&(reg|#174);/g, val: "\xAE" },
|
|
1714
|
+
"inr": { regex: /&(inr|#8377);/g, val: "\u20B9" },
|
|
1715
|
+
"num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => fromCodePoint(str, 10, "&#") },
|
|
1716
|
+
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => fromCodePoint(str, 16, "&#x") }
|
|
1717
|
+
};
|
|
1718
|
+
this.addExternalEntities = addExternalEntities;
|
|
1719
|
+
this.parseXml = parseXml;
|
|
1720
|
+
this.parseTextData = parseTextData;
|
|
1721
|
+
this.resolveNameSpace = resolveNameSpace;
|
|
1722
|
+
this.buildAttributesMap = buildAttributesMap;
|
|
1723
|
+
this.isItStopNode = isItStopNode;
|
|
1724
|
+
this.replaceEntitiesValue = replaceEntitiesValue;
|
|
1725
|
+
this.readStopNodeData = readStopNodeData;
|
|
1726
|
+
this.saveTextToParentTag = saveTextToParentTag;
|
|
1727
|
+
this.addChild = addChild;
|
|
1728
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
|
|
1729
|
+
this.entityExpansionCount = 0;
|
|
1730
|
+
this.currentExpandedLength = 0;
|
|
1731
|
+
this.matcher = new Matcher();
|
|
1732
|
+
this.readonlyMatcher = this.matcher.readOnly();
|
|
1733
|
+
this.isCurrentNodeStopNode = false;
|
|
1734
|
+
if (this.options.stopNodes && this.options.stopNodes.length > 0) {
|
|
1735
|
+
this.stopNodeExpressions = [];
|
|
1736
|
+
for (let i2 = 0; i2 < this.options.stopNodes.length; i2++) {
|
|
1737
|
+
const stopNodeExp = this.options.stopNodes[i2];
|
|
1738
|
+
if (typeof stopNodeExp === "string") {
|
|
1739
|
+
this.stopNodeExpressions.push(new Expression(stopNodeExp));
|
|
1740
|
+
} else if (stopNodeExp instanceof Expression) {
|
|
1741
|
+
this.stopNodeExpressions.push(stopNodeExp);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
function addExternalEntities(externalEntities) {
|
|
1748
|
+
const entKeys = Object.keys(externalEntities);
|
|
1749
|
+
for (let i2 = 0; i2 < entKeys.length; i2++) {
|
|
1750
|
+
const ent = entKeys[i2];
|
|
1751
|
+
const escaped = ent.replace(/[.\-+*:]/g, "\\.");
|
|
1752
|
+
this.lastEntities[ent] = {
|
|
1753
|
+
regex: new RegExp("&" + escaped + ";", "g"),
|
|
1754
|
+
val: externalEntities[ent]
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
1759
|
+
if (val !== void 0) {
|
|
1760
|
+
if (this.options.trimValues && !dontTrim) {
|
|
1761
|
+
val = val.trim();
|
|
1762
|
+
}
|
|
1763
|
+
if (val.length > 0) {
|
|
1764
|
+
if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
|
|
1765
|
+
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
1766
|
+
const newval = this.options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
|
|
1767
|
+
if (newval === null || newval === void 0) {
|
|
1768
|
+
return val;
|
|
1769
|
+
} else if (typeof newval !== typeof val || newval !== val) {
|
|
1770
|
+
return newval;
|
|
1771
|
+
} else if (this.options.trimValues) {
|
|
1772
|
+
return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
|
|
1773
|
+
} else {
|
|
1774
|
+
const trimmedVal = val.trim();
|
|
1775
|
+
if (trimmedVal === val) {
|
|
1776
|
+
return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
|
|
1777
|
+
} else {
|
|
1778
|
+
return val;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
function resolveNameSpace(tagname) {
|
|
1785
|
+
if (this.options.removeNSPrefix) {
|
|
1786
|
+
const tags = tagname.split(":");
|
|
1787
|
+
const prefix = tagname.charAt(0) === "/" ? "/" : "";
|
|
1788
|
+
if (tags[0] === "xmlns") {
|
|
1789
|
+
return "";
|
|
1790
|
+
}
|
|
1791
|
+
if (tags.length === 2) {
|
|
1792
|
+
tagname = prefix + tags[1];
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
return tagname;
|
|
1796
|
+
}
|
|
1797
|
+
var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
1798
|
+
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
1799
|
+
if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
1800
|
+
const matches = getAllMatches(attrStr, attrsRegx);
|
|
1801
|
+
const len = matches.length;
|
|
1802
|
+
const attrs = {};
|
|
1803
|
+
const rawAttrsForMatcher = {};
|
|
1804
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
1805
|
+
const attrName = this.resolveNameSpace(matches[i2][1]);
|
|
1806
|
+
const oldVal = matches[i2][4];
|
|
1807
|
+
if (attrName.length && oldVal !== void 0) {
|
|
1808
|
+
let parsedVal = oldVal;
|
|
1809
|
+
if (this.options.trimValues) {
|
|
1810
|
+
parsedVal = parsedVal.trim();
|
|
1811
|
+
}
|
|
1812
|
+
parsedVal = this.replaceEntitiesValue(parsedVal, tagName, this.readonlyMatcher);
|
|
1813
|
+
rawAttrsForMatcher[attrName] = parsedVal;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
if (Object.keys(rawAttrsForMatcher).length > 0 && typeof jPath === "object" && jPath.updateCurrent) {
|
|
1817
|
+
jPath.updateCurrent(rawAttrsForMatcher);
|
|
1818
|
+
}
|
|
1819
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
1820
|
+
const attrName = this.resolveNameSpace(matches[i2][1]);
|
|
1821
|
+
const jPathStr = this.options.jPath ? jPath.toString() : this.readonlyMatcher;
|
|
1822
|
+
if (this.ignoreAttributesFn(attrName, jPathStr)) {
|
|
1823
|
+
continue;
|
|
1824
|
+
}
|
|
1825
|
+
let oldVal = matches[i2][4];
|
|
1826
|
+
let aName = this.options.attributeNamePrefix + attrName;
|
|
1827
|
+
if (attrName.length) {
|
|
1828
|
+
if (this.options.transformAttributeName) {
|
|
1829
|
+
aName = this.options.transformAttributeName(aName);
|
|
1830
|
+
}
|
|
1831
|
+
aName = sanitizeName(aName, this.options);
|
|
1832
|
+
if (oldVal !== void 0) {
|
|
1833
|
+
if (this.options.trimValues) {
|
|
1834
|
+
oldVal = oldVal.trim();
|
|
1835
|
+
}
|
|
1836
|
+
oldVal = this.replaceEntitiesValue(oldVal, tagName, this.readonlyMatcher);
|
|
1837
|
+
const jPathOrMatcher = this.options.jPath ? jPath.toString() : this.readonlyMatcher;
|
|
1838
|
+
const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPathOrMatcher);
|
|
1839
|
+
if (newVal === null || newVal === void 0) {
|
|
1840
|
+
attrs[aName] = oldVal;
|
|
1841
|
+
} else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
|
|
1842
|
+
attrs[aName] = newVal;
|
|
1843
|
+
} else {
|
|
1844
|
+
attrs[aName] = parseValue(
|
|
1845
|
+
oldVal,
|
|
1846
|
+
this.options.parseAttributeValue,
|
|
1847
|
+
this.options.numberParseOptions
|
|
1848
|
+
);
|
|
1849
|
+
}
|
|
1850
|
+
} else if (this.options.allowBooleanAttributes) {
|
|
1851
|
+
attrs[aName] = true;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
if (!Object.keys(attrs).length) {
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1858
|
+
if (this.options.attributesGroupName) {
|
|
1859
|
+
const attrCollection = {};
|
|
1860
|
+
attrCollection[this.options.attributesGroupName] = attrs;
|
|
1861
|
+
return attrCollection;
|
|
1862
|
+
}
|
|
1863
|
+
return attrs;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
var parseXml = function(xmlData) {
|
|
1867
|
+
xmlData = xmlData.replace(/\r\n?/g, "\n");
|
|
1868
|
+
const xmlObj = new XmlNode("!xml");
|
|
1869
|
+
let currentNode = xmlObj;
|
|
1870
|
+
let textData = "";
|
|
1871
|
+
this.matcher.reset();
|
|
1872
|
+
this.entityExpansionCount = 0;
|
|
1873
|
+
this.currentExpandedLength = 0;
|
|
1874
|
+
const docTypeReader = new DocTypeReader(this.options.processEntities);
|
|
1875
|
+
for (let i2 = 0; i2 < xmlData.length; i2++) {
|
|
1876
|
+
const ch = xmlData[i2];
|
|
1877
|
+
if (ch === "<") {
|
|
1878
|
+
if (xmlData[i2 + 1] === "/") {
|
|
1879
|
+
const closeIndex = findClosingIndex(xmlData, ">", i2, "Closing Tag is not closed.");
|
|
1880
|
+
let tagName = xmlData.substring(i2 + 2, closeIndex).trim();
|
|
1881
|
+
if (this.options.removeNSPrefix) {
|
|
1882
|
+
const colonIndex = tagName.indexOf(":");
|
|
1883
|
+
if (colonIndex !== -1) {
|
|
1884
|
+
tagName = tagName.substr(colonIndex + 1);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
tagName = transformTagName(this.options.transformTagName, tagName, "", this.options).tagName;
|
|
1888
|
+
if (currentNode) {
|
|
1889
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
1890
|
+
}
|
|
1891
|
+
const lastTagName = this.matcher.getCurrentTag();
|
|
1892
|
+
if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
1893
|
+
throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
|
|
1894
|
+
}
|
|
1895
|
+
if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
|
|
1896
|
+
this.matcher.pop();
|
|
1897
|
+
this.tagsNodeStack.pop();
|
|
1898
|
+
}
|
|
1899
|
+
this.matcher.pop();
|
|
1900
|
+
this.isCurrentNodeStopNode = false;
|
|
1901
|
+
currentNode = this.tagsNodeStack.pop();
|
|
1902
|
+
textData = "";
|
|
1903
|
+
i2 = closeIndex;
|
|
1904
|
+
} else if (xmlData[i2 + 1] === "?") {
|
|
1905
|
+
let tagData = readTagExp(xmlData, i2, false, "?>");
|
|
1906
|
+
if (!tagData) throw new Error("Pi Tag is not closed.");
|
|
1907
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
1908
|
+
if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) {
|
|
1909
|
+
} else {
|
|
1910
|
+
const childNode = new XmlNode(tagData.tagName);
|
|
1911
|
+
childNode.add(this.options.textNodeName, "");
|
|
1912
|
+
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
|
|
1913
|
+
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName);
|
|
1914
|
+
}
|
|
1915
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, i2);
|
|
1916
|
+
}
|
|
1917
|
+
i2 = tagData.closeIndex + 1;
|
|
1918
|
+
} else if (xmlData.substr(i2 + 1, 3) === "!--") {
|
|
1919
|
+
const endIndex = findClosingIndex(xmlData, "-->", i2 + 4, "Comment is not closed.");
|
|
1920
|
+
if (this.options.commentPropName) {
|
|
1921
|
+
const comment = xmlData.substring(i2 + 4, endIndex - 2);
|
|
1922
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
1923
|
+
currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
|
|
1924
|
+
}
|
|
1925
|
+
i2 = endIndex;
|
|
1926
|
+
} else if (xmlData.substr(i2 + 1, 2) === "!D") {
|
|
1927
|
+
const result = docTypeReader.readDocType(xmlData, i2);
|
|
1928
|
+
this.docTypeEntities = result.entities;
|
|
1929
|
+
i2 = result.i;
|
|
1930
|
+
} else if (xmlData.substr(i2 + 1, 2) === "![") {
|
|
1931
|
+
const closeIndex = findClosingIndex(xmlData, "]]>", i2, "CDATA is not closed.") - 2;
|
|
1932
|
+
const tagExp = xmlData.substring(i2 + 9, closeIndex);
|
|
1933
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
1934
|
+
let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
|
|
1935
|
+
if (val == void 0) val = "";
|
|
1936
|
+
if (this.options.cdataPropName) {
|
|
1937
|
+
currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
|
|
1938
|
+
} else {
|
|
1939
|
+
currentNode.add(this.options.textNodeName, val);
|
|
1940
|
+
}
|
|
1941
|
+
i2 = closeIndex + 2;
|
|
1942
|
+
} else {
|
|
1943
|
+
let result = readTagExp(xmlData, i2, this.options.removeNSPrefix);
|
|
1944
|
+
if (!result) {
|
|
1945
|
+
const context = xmlData.substring(Math.max(0, i2 - 50), Math.min(xmlData.length, i2 + 50));
|
|
1946
|
+
throw new Error(`readTagExp returned undefined at position ${i2}. Context: "${context}"`);
|
|
1947
|
+
}
|
|
1948
|
+
let tagName = result.tagName;
|
|
1949
|
+
const rawTagName = result.rawTagName;
|
|
1950
|
+
let tagExp = result.tagExp;
|
|
1951
|
+
let attrExpPresent = result.attrExpPresent;
|
|
1952
|
+
let closeIndex = result.closeIndex;
|
|
1953
|
+
({ tagName, tagExp } = transformTagName(this.options.transformTagName, tagName, tagExp, this.options));
|
|
1954
|
+
if (this.options.strictReservedNames && (tagName === this.options.commentPropName || tagName === this.options.cdataPropName || tagName === this.options.textNodeName || tagName === this.options.attributesGroupName)) {
|
|
1955
|
+
throw new Error(`Invalid tag name: ${tagName}`);
|
|
1956
|
+
}
|
|
1957
|
+
if (currentNode && textData) {
|
|
1958
|
+
if (currentNode.tagname !== "!xml") {
|
|
1959
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher, false);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
const lastTag = currentNode;
|
|
1963
|
+
if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
|
|
1964
|
+
currentNode = this.tagsNodeStack.pop();
|
|
1965
|
+
this.matcher.pop();
|
|
1966
|
+
}
|
|
1967
|
+
let isSelfClosing = false;
|
|
1968
|
+
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
1969
|
+
isSelfClosing = true;
|
|
1970
|
+
if (tagName[tagName.length - 1] === "/") {
|
|
1971
|
+
tagName = tagName.substr(0, tagName.length - 1);
|
|
1972
|
+
tagExp = tagName;
|
|
1973
|
+
} else {
|
|
1974
|
+
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
1975
|
+
}
|
|
1976
|
+
attrExpPresent = tagName !== tagExp;
|
|
1977
|
+
}
|
|
1978
|
+
let prefixedAttrs = null;
|
|
1979
|
+
let rawAttrs = {};
|
|
1980
|
+
let namespace = void 0;
|
|
1981
|
+
namespace = extractNamespace(rawTagName);
|
|
1982
|
+
if (tagName !== xmlObj.tagname) {
|
|
1983
|
+
this.matcher.push(tagName, {}, namespace);
|
|
1984
|
+
}
|
|
1985
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
1986
|
+
prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
|
|
1987
|
+
if (prefixedAttrs) {
|
|
1988
|
+
rawAttrs = extractRawAttributes(prefixedAttrs, this.options);
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
if (tagName !== xmlObj.tagname) {
|
|
1992
|
+
this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher);
|
|
1993
|
+
}
|
|
1994
|
+
const startIndex = i2;
|
|
1995
|
+
if (this.isCurrentNodeStopNode) {
|
|
1996
|
+
let tagContent = "";
|
|
1997
|
+
if (isSelfClosing) {
|
|
1998
|
+
i2 = result.closeIndex;
|
|
1999
|
+
} else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
2000
|
+
i2 = result.closeIndex;
|
|
2001
|
+
} else {
|
|
2002
|
+
const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
|
|
2003
|
+
if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
|
|
2004
|
+
i2 = result2.i;
|
|
2005
|
+
tagContent = result2.tagContent;
|
|
2006
|
+
}
|
|
2007
|
+
const childNode = new XmlNode(tagName);
|
|
2008
|
+
if (prefixedAttrs) {
|
|
2009
|
+
childNode[":@"] = prefixedAttrs;
|
|
2010
|
+
}
|
|
2011
|
+
childNode.add(this.options.textNodeName, tagContent);
|
|
2012
|
+
this.matcher.pop();
|
|
2013
|
+
this.isCurrentNodeStopNode = false;
|
|
2014
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
2015
|
+
} else {
|
|
2016
|
+
if (isSelfClosing) {
|
|
2017
|
+
({ tagName, tagExp } = transformTagName(this.options.transformTagName, tagName, tagExp, this.options));
|
|
2018
|
+
const childNode = new XmlNode(tagName);
|
|
2019
|
+
if (prefixedAttrs) {
|
|
2020
|
+
childNode[":@"] = prefixedAttrs;
|
|
2021
|
+
}
|
|
2022
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
2023
|
+
this.matcher.pop();
|
|
2024
|
+
this.isCurrentNodeStopNode = false;
|
|
2025
|
+
} else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
2026
|
+
const childNode = new XmlNode(tagName);
|
|
2027
|
+
if (prefixedAttrs) {
|
|
2028
|
+
childNode[":@"] = prefixedAttrs;
|
|
2029
|
+
}
|
|
2030
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
2031
|
+
this.matcher.pop();
|
|
2032
|
+
this.isCurrentNodeStopNode = false;
|
|
2033
|
+
i2 = result.closeIndex;
|
|
2034
|
+
continue;
|
|
2035
|
+
} else {
|
|
2036
|
+
const childNode = new XmlNode(tagName);
|
|
2037
|
+
if (this.tagsNodeStack.length > this.options.maxNestedTags) {
|
|
2038
|
+
throw new Error("Maximum nested tags exceeded");
|
|
2039
|
+
}
|
|
2040
|
+
this.tagsNodeStack.push(currentNode);
|
|
2041
|
+
if (prefixedAttrs) {
|
|
2042
|
+
childNode[":@"] = prefixedAttrs;
|
|
2043
|
+
}
|
|
2044
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
2045
|
+
currentNode = childNode;
|
|
2046
|
+
}
|
|
2047
|
+
textData = "";
|
|
2048
|
+
i2 = closeIndex;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
} else {
|
|
2052
|
+
textData += xmlData[i2];
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
return xmlObj.child;
|
|
2056
|
+
};
|
|
2057
|
+
function addChild(currentNode, childNode, matcher, startIndex) {
|
|
2058
|
+
if (!this.options.captureMetaData) startIndex = void 0;
|
|
2059
|
+
const jPathOrMatcher = this.options.jPath ? matcher.toString() : matcher;
|
|
2060
|
+
const result = this.options.updateTag(childNode.tagname, jPathOrMatcher, childNode[":@"]);
|
|
2061
|
+
if (result === false) {
|
|
2062
|
+
} else if (typeof result === "string") {
|
|
2063
|
+
childNode.tagname = result;
|
|
2064
|
+
currentNode.addChild(childNode, startIndex);
|
|
2065
|
+
} else {
|
|
2066
|
+
currentNode.addChild(childNode, startIndex);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
function replaceEntitiesValue(val, tagName, jPath) {
|
|
2070
|
+
const entityConfig = this.options.processEntities;
|
|
2071
|
+
if (!entityConfig || !entityConfig.enabled) {
|
|
2072
|
+
return val;
|
|
2073
|
+
}
|
|
2074
|
+
if (entityConfig.allowedTags) {
|
|
2075
|
+
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
2076
|
+
const allowed = Array.isArray(entityConfig.allowedTags) ? entityConfig.allowedTags.includes(tagName) : entityConfig.allowedTags(tagName, jPathOrMatcher);
|
|
2077
|
+
if (!allowed) {
|
|
2078
|
+
return val;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
if (entityConfig.tagFilter) {
|
|
2082
|
+
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
2083
|
+
if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) {
|
|
2084
|
+
return val;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
for (const entityName of Object.keys(this.docTypeEntities)) {
|
|
2088
|
+
const entity = this.docTypeEntities[entityName];
|
|
2089
|
+
const matches = val.match(entity.regx);
|
|
2090
|
+
if (matches) {
|
|
2091
|
+
this.entityExpansionCount += matches.length;
|
|
2092
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
2093
|
+
throw new Error(
|
|
2094
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2097
|
+
const lengthBefore = val.length;
|
|
2098
|
+
val = val.replace(entity.regx, entity.val);
|
|
2099
|
+
if (entityConfig.maxExpandedLength) {
|
|
2100
|
+
this.currentExpandedLength += val.length - lengthBefore;
|
|
2101
|
+
if (this.currentExpandedLength > entityConfig.maxExpandedLength) {
|
|
2102
|
+
throw new Error(
|
|
2103
|
+
`Total expanded content size exceeded: ${this.currentExpandedLength} > ${entityConfig.maxExpandedLength}`
|
|
2104
|
+
);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
for (const entityName of Object.keys(this.lastEntities)) {
|
|
2110
|
+
const entity = this.lastEntities[entityName];
|
|
2111
|
+
const matches = val.match(entity.regex);
|
|
2112
|
+
if (matches) {
|
|
2113
|
+
this.entityExpansionCount += matches.length;
|
|
2114
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
2115
|
+
throw new Error(
|
|
2116
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
val = val.replace(entity.regex, entity.val);
|
|
2121
|
+
}
|
|
2122
|
+
if (val.indexOf("&") === -1) return val;
|
|
2123
|
+
if (this.options.htmlEntities) {
|
|
2124
|
+
for (const entityName of Object.keys(this.htmlEntities)) {
|
|
2125
|
+
const entity = this.htmlEntities[entityName];
|
|
2126
|
+
const matches = val.match(entity.regex);
|
|
2127
|
+
if (matches) {
|
|
2128
|
+
this.entityExpansionCount += matches.length;
|
|
2129
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
2130
|
+
throw new Error(
|
|
2131
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
val = val.replace(entity.regex, entity.val);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
val = val.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
2139
|
+
return val;
|
|
2140
|
+
}
|
|
2141
|
+
function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
|
|
2142
|
+
if (textData) {
|
|
2143
|
+
if (isLeafNode === void 0) isLeafNode = parentNode.child.length === 0;
|
|
2144
|
+
textData = this.parseTextData(
|
|
2145
|
+
textData,
|
|
2146
|
+
parentNode.tagname,
|
|
2147
|
+
matcher,
|
|
2148
|
+
false,
|
|
2149
|
+
parentNode[":@"] ? Object.keys(parentNode[":@"]).length !== 0 : false,
|
|
2150
|
+
isLeafNode
|
|
2151
|
+
);
|
|
2152
|
+
if (textData !== void 0 && textData !== "")
|
|
2153
|
+
parentNode.add(this.options.textNodeName, textData);
|
|
2154
|
+
textData = "";
|
|
2155
|
+
}
|
|
2156
|
+
return textData;
|
|
2157
|
+
}
|
|
2158
|
+
function isItStopNode(stopNodeExpressions, matcher) {
|
|
2159
|
+
if (!stopNodeExpressions || stopNodeExpressions.length === 0) return false;
|
|
2160
|
+
for (let i2 = 0; i2 < stopNodeExpressions.length; i2++) {
|
|
2161
|
+
if (matcher.matches(stopNodeExpressions[i2])) {
|
|
2162
|
+
return true;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
return false;
|
|
2166
|
+
}
|
|
2167
|
+
function tagExpWithClosingIndex(xmlData, i2, closingChar = ">") {
|
|
2168
|
+
let attrBoundary;
|
|
2169
|
+
let tagExp = "";
|
|
2170
|
+
for (let index = i2; index < xmlData.length; index++) {
|
|
2171
|
+
let ch = xmlData[index];
|
|
2172
|
+
if (attrBoundary) {
|
|
2173
|
+
if (ch === attrBoundary) attrBoundary = "";
|
|
2174
|
+
} else if (ch === '"' || ch === "'") {
|
|
2175
|
+
attrBoundary = ch;
|
|
2176
|
+
} else if (ch === closingChar[0]) {
|
|
2177
|
+
if (closingChar[1]) {
|
|
2178
|
+
if (xmlData[index + 1] === closingChar[1]) {
|
|
2179
|
+
return {
|
|
2180
|
+
data: tagExp,
|
|
2181
|
+
index
|
|
2182
|
+
};
|
|
2183
|
+
}
|
|
2184
|
+
} else {
|
|
2185
|
+
return {
|
|
2186
|
+
data: tagExp,
|
|
2187
|
+
index
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
} else if (ch === " ") {
|
|
2191
|
+
ch = " ";
|
|
2192
|
+
}
|
|
2193
|
+
tagExp += ch;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
function findClosingIndex(xmlData, str, i2, errMsg) {
|
|
2197
|
+
const closingIndex = xmlData.indexOf(str, i2);
|
|
2198
|
+
if (closingIndex === -1) {
|
|
2199
|
+
throw new Error(errMsg);
|
|
2200
|
+
} else {
|
|
2201
|
+
return closingIndex + str.length - 1;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
function readTagExp(xmlData, i2, removeNSPrefix, closingChar = ">") {
|
|
2205
|
+
const result = tagExpWithClosingIndex(xmlData, i2 + 1, closingChar);
|
|
2206
|
+
if (!result) return;
|
|
2207
|
+
let tagExp = result.data;
|
|
2208
|
+
const closeIndex = result.index;
|
|
2209
|
+
const separatorIndex = tagExp.search(/\s/);
|
|
2210
|
+
let tagName = tagExp;
|
|
2211
|
+
let attrExpPresent = true;
|
|
2212
|
+
if (separatorIndex !== -1) {
|
|
2213
|
+
tagName = tagExp.substring(0, separatorIndex);
|
|
2214
|
+
tagExp = tagExp.substring(separatorIndex + 1).trimStart();
|
|
2215
|
+
}
|
|
2216
|
+
const rawTagName = tagName;
|
|
2217
|
+
if (removeNSPrefix) {
|
|
2218
|
+
const colonIndex = tagName.indexOf(":");
|
|
2219
|
+
if (colonIndex !== -1) {
|
|
2220
|
+
tagName = tagName.substr(colonIndex + 1);
|
|
2221
|
+
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
return {
|
|
2225
|
+
tagName,
|
|
2226
|
+
tagExp,
|
|
2227
|
+
closeIndex,
|
|
2228
|
+
attrExpPresent,
|
|
2229
|
+
rawTagName
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
function readStopNodeData(xmlData, tagName, i2) {
|
|
2233
|
+
const startIndex = i2;
|
|
2234
|
+
let openTagCount = 1;
|
|
2235
|
+
for (; i2 < xmlData.length; i2++) {
|
|
2236
|
+
if (xmlData[i2] === "<") {
|
|
2237
|
+
if (xmlData[i2 + 1] === "/") {
|
|
2238
|
+
const closeIndex = findClosingIndex(xmlData, ">", i2, `${tagName} is not closed`);
|
|
2239
|
+
let closeTagName = xmlData.substring(i2 + 2, closeIndex).trim();
|
|
2240
|
+
if (closeTagName === tagName) {
|
|
2241
|
+
openTagCount--;
|
|
2242
|
+
if (openTagCount === 0) {
|
|
2243
|
+
return {
|
|
2244
|
+
tagContent: xmlData.substring(startIndex, i2),
|
|
2245
|
+
i: closeIndex
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
i2 = closeIndex;
|
|
2250
|
+
} else if (xmlData[i2 + 1] === "?") {
|
|
2251
|
+
const closeIndex = findClosingIndex(xmlData, "?>", i2 + 1, "StopNode is not closed.");
|
|
2252
|
+
i2 = closeIndex;
|
|
2253
|
+
} else if (xmlData.substr(i2 + 1, 3) === "!--") {
|
|
2254
|
+
const closeIndex = findClosingIndex(xmlData, "-->", i2 + 3, "StopNode is not closed.");
|
|
2255
|
+
i2 = closeIndex;
|
|
2256
|
+
} else if (xmlData.substr(i2 + 1, 2) === "![") {
|
|
2257
|
+
const closeIndex = findClosingIndex(xmlData, "]]>", i2, "StopNode is not closed.") - 2;
|
|
2258
|
+
i2 = closeIndex;
|
|
2259
|
+
} else {
|
|
2260
|
+
const tagData = readTagExp(xmlData, i2, ">");
|
|
2261
|
+
if (tagData) {
|
|
2262
|
+
const openTagName = tagData && tagData.tagName;
|
|
2263
|
+
if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
|
|
2264
|
+
openTagCount++;
|
|
2265
|
+
}
|
|
2266
|
+
i2 = tagData.closeIndex;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
function parseValue(val, shouldParse, options) {
|
|
2273
|
+
if (shouldParse && typeof val === "string") {
|
|
2274
|
+
const newval = val.trim();
|
|
2275
|
+
if (newval === "true") return true;
|
|
2276
|
+
else if (newval === "false") return false;
|
|
2277
|
+
else return toNumber(val, options);
|
|
2278
|
+
} else {
|
|
2279
|
+
if (isExist(val)) {
|
|
2280
|
+
return val;
|
|
2281
|
+
} else {
|
|
2282
|
+
return "";
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
function fromCodePoint(str, base, prefix) {
|
|
2287
|
+
const codePoint = Number.parseInt(str, base);
|
|
2288
|
+
if (codePoint >= 0 && codePoint <= 1114111) {
|
|
2289
|
+
return String.fromCodePoint(codePoint);
|
|
2290
|
+
} else {
|
|
2291
|
+
return prefix + str + ";";
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
function transformTagName(fn, tagName, tagExp, options) {
|
|
2295
|
+
if (fn) {
|
|
2296
|
+
const newTagName = fn(tagName);
|
|
2297
|
+
if (tagExp === tagName) {
|
|
2298
|
+
tagExp = newTagName;
|
|
2299
|
+
}
|
|
2300
|
+
tagName = newTagName;
|
|
2301
|
+
}
|
|
2302
|
+
tagName = sanitizeName(tagName, options);
|
|
2303
|
+
return { tagName, tagExp };
|
|
2304
|
+
}
|
|
2305
|
+
function sanitizeName(name, options) {
|
|
2306
|
+
if (criticalProperties.includes(name)) {
|
|
2307
|
+
throw new Error(`[SECURITY] Invalid name: "${name}" is a reserved JavaScript keyword that could cause prototype pollution`);
|
|
2308
|
+
} else if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
|
|
2309
|
+
return options.onDangerousProperty(name);
|
|
2310
|
+
}
|
|
2311
|
+
return name;
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/xmlparser/node2json.js
|
|
2315
|
+
var METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
|
|
2316
|
+
function stripAttributePrefix(attrs, prefix) {
|
|
2317
|
+
if (!attrs || typeof attrs !== "object") return {};
|
|
2318
|
+
if (!prefix) return attrs;
|
|
2319
|
+
const rawAttrs = {};
|
|
2320
|
+
for (const key in attrs) {
|
|
2321
|
+
if (key.startsWith(prefix)) {
|
|
2322
|
+
const rawName = key.substring(prefix.length);
|
|
2323
|
+
rawAttrs[rawName] = attrs[key];
|
|
2324
|
+
} else {
|
|
2325
|
+
rawAttrs[key] = attrs[key];
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
return rawAttrs;
|
|
2329
|
+
}
|
|
2330
|
+
function prettify(node, options, matcher, readonlyMatcher) {
|
|
2331
|
+
return compress(node, options, matcher, readonlyMatcher);
|
|
2332
|
+
}
|
|
2333
|
+
function compress(arr, options, matcher, readonlyMatcher) {
|
|
2334
|
+
let text;
|
|
2335
|
+
const compressedObj = {};
|
|
2336
|
+
for (let i2 = 0; i2 < arr.length; i2++) {
|
|
2337
|
+
const tagObj = arr[i2];
|
|
2338
|
+
const property = propName(tagObj);
|
|
2339
|
+
if (property !== void 0 && property !== options.textNodeName) {
|
|
2340
|
+
const rawAttrs = stripAttributePrefix(
|
|
2341
|
+
tagObj[":@"] || {},
|
|
2342
|
+
options.attributeNamePrefix
|
|
2343
|
+
);
|
|
2344
|
+
matcher.push(property, rawAttrs);
|
|
2345
|
+
}
|
|
2346
|
+
if (property === options.textNodeName) {
|
|
2347
|
+
if (text === void 0) text = tagObj[property];
|
|
2348
|
+
else text += "" + tagObj[property];
|
|
2349
|
+
} else if (property === void 0) {
|
|
2350
|
+
continue;
|
|
2351
|
+
} else if (tagObj[property]) {
|
|
2352
|
+
let val = compress(tagObj[property], options, matcher, readonlyMatcher);
|
|
2353
|
+
const isLeaf = isLeafTag(val, options);
|
|
2354
|
+
if (tagObj[":@"]) {
|
|
2355
|
+
assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
|
|
2356
|
+
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
|
|
2357
|
+
val = val[options.textNodeName];
|
|
2358
|
+
} else if (Object.keys(val).length === 0) {
|
|
2359
|
+
if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
2360
|
+
else val = "";
|
|
2361
|
+
}
|
|
2362
|
+
if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof val === "object" && val !== null) {
|
|
2363
|
+
val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
|
|
2364
|
+
}
|
|
2365
|
+
if (compressedObj[property] !== void 0 && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
|
|
2366
|
+
if (!Array.isArray(compressedObj[property])) {
|
|
2367
|
+
compressedObj[property] = [compressedObj[property]];
|
|
2368
|
+
}
|
|
2369
|
+
compressedObj[property].push(val);
|
|
2370
|
+
} else {
|
|
2371
|
+
const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() : readonlyMatcher;
|
|
2372
|
+
if (options.isArray(property, jPathOrMatcher, isLeaf)) {
|
|
2373
|
+
compressedObj[property] = [val];
|
|
2374
|
+
} else {
|
|
2375
|
+
compressedObj[property] = val;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
if (property !== void 0 && property !== options.textNodeName) {
|
|
2379
|
+
matcher.pop();
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
if (typeof text === "string") {
|
|
2384
|
+
if (text.length > 0) compressedObj[options.textNodeName] = text;
|
|
2385
|
+
} else if (text !== void 0) compressedObj[options.textNodeName] = text;
|
|
2386
|
+
return compressedObj;
|
|
2387
|
+
}
|
|
2388
|
+
function propName(obj) {
|
|
2389
|
+
const keys = Object.keys(obj);
|
|
2390
|
+
for (let i2 = 0; i2 < keys.length; i2++) {
|
|
2391
|
+
const key = keys[i2];
|
|
2392
|
+
if (key !== ":@") return key;
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
function assignAttributes(obj, attrMap, readonlyMatcher, options) {
|
|
2396
|
+
if (attrMap) {
|
|
2397
|
+
const keys = Object.keys(attrMap);
|
|
2398
|
+
const len = keys.length;
|
|
2399
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
2400
|
+
const atrrName = keys[i2];
|
|
2401
|
+
const rawAttrName = atrrName.startsWith(options.attributeNamePrefix) ? atrrName.substring(options.attributeNamePrefix.length) : atrrName;
|
|
2402
|
+
const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() + "." + rawAttrName : readonlyMatcher;
|
|
2403
|
+
if (options.isArray(atrrName, jPathOrMatcher, true, true)) {
|
|
2404
|
+
obj[atrrName] = [attrMap[atrrName]];
|
|
2405
|
+
} else {
|
|
2406
|
+
obj[atrrName] = attrMap[atrrName];
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
function isLeafTag(obj, options) {
|
|
2412
|
+
const { textNodeName } = options;
|
|
2413
|
+
const propCount = Object.keys(obj).length;
|
|
2414
|
+
if (propCount === 0) {
|
|
2415
|
+
return true;
|
|
2416
|
+
}
|
|
2417
|
+
if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
|
|
2418
|
+
return true;
|
|
2419
|
+
}
|
|
2420
|
+
return false;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
// ../../node_modules/.pnpm/fast-xml-parser@5.5.8/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
|
|
2424
|
+
var XMLParser = class {
|
|
2425
|
+
constructor(options) {
|
|
2426
|
+
this.externalEntities = {};
|
|
2427
|
+
this.options = buildOptions(options);
|
|
2428
|
+
}
|
|
2429
|
+
/**
|
|
2430
|
+
* Parse XML dats to JS object
|
|
2431
|
+
* @param {string|Uint8Array} xmlData
|
|
2432
|
+
* @param {boolean|Object} validationOption
|
|
2433
|
+
*/
|
|
2434
|
+
parse(xmlData, validationOption) {
|
|
2435
|
+
if (typeof xmlData !== "string" && xmlData.toString) {
|
|
2436
|
+
xmlData = xmlData.toString();
|
|
2437
|
+
} else if (typeof xmlData !== "string") {
|
|
2438
|
+
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
2439
|
+
}
|
|
2440
|
+
if (validationOption) {
|
|
2441
|
+
if (validationOption === true) validationOption = {};
|
|
2442
|
+
const result = validate(xmlData, validationOption);
|
|
2443
|
+
if (result !== true) {
|
|
2444
|
+
throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
const orderedObjParser = new OrderedObjParser(this.options);
|
|
2448
|
+
orderedObjParser.addExternalEntities(this.externalEntities);
|
|
2449
|
+
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
2450
|
+
if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
|
|
2451
|
+
else return prettify(orderedResult, this.options, orderedObjParser.matcher, orderedObjParser.readonlyMatcher);
|
|
2452
|
+
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Add Entity which is not by default supported by this library
|
|
2455
|
+
* @param {string} key
|
|
2456
|
+
* @param {string} value
|
|
2457
|
+
*/
|
|
2458
|
+
addEntity(key, value) {
|
|
2459
|
+
if (value.indexOf("&") !== -1) {
|
|
2460
|
+
throw new Error("Entity value can't have '&'");
|
|
2461
|
+
} else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
|
|
2462
|
+
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
|
|
2463
|
+
} else if (value === "&") {
|
|
2464
|
+
throw new Error("An entity with value '&' is not permitted");
|
|
2465
|
+
} else {
|
|
2466
|
+
this.externalEntities[key] = value;
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
/**
|
|
2470
|
+
* Returns a Symbol that can be used to access the metadata
|
|
2471
|
+
* property on a node.
|
|
2472
|
+
*
|
|
2473
|
+
* If Symbol is not available in the environment, an ordinary property is used
|
|
2474
|
+
* and the name of the property is here returned.
|
|
2475
|
+
*
|
|
2476
|
+
* The XMLMetaData property is only present when `captureMetaData`
|
|
2477
|
+
* is true in the options.
|
|
2478
|
+
*/
|
|
2479
|
+
static getMetaDataSymbol() {
|
|
2480
|
+
return XmlNode.getMetaDataSymbol();
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2484
|
+
// ../../node_modules/.pnpm/@aws-sdk+xml-builder@3.972.16/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js
|
|
2485
|
+
var parser = new XMLParser({
|
|
2486
|
+
attributeNamePrefix: "",
|
|
2487
|
+
processEntities: {
|
|
2488
|
+
enabled: true,
|
|
2489
|
+
maxTotalExpansions: Infinity
|
|
2490
|
+
},
|
|
2491
|
+
htmlEntities: true,
|
|
2492
|
+
ignoreAttributes: false,
|
|
2493
|
+
ignoreDeclaration: true,
|
|
2494
|
+
parseTagValue: false,
|
|
2495
|
+
trimValues: false,
|
|
2496
|
+
tagValueProcessor: (_, val) => val.trim() === "" && val.includes("\n") ? "" : void 0,
|
|
2497
|
+
maxNestedTags: Infinity
|
|
2498
|
+
});
|
|
2499
|
+
parser.addEntity("#xD", "\r");
|
|
2500
|
+
parser.addEntity("#10", "\n");
|
|
2501
|
+
function parseXML(xmlString) {
|
|
2502
|
+
return parser.parse(xmlString, true);
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
// ../../node_modules/.pnpm/@aws-sdk+core@3.973.26/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js
|
|
2506
|
+
var XmlShapeDeserializer = class extends SerdeContextConfig {
|
|
2507
|
+
settings;
|
|
2508
|
+
stringDeserializer;
|
|
2509
|
+
constructor(settings) {
|
|
2510
|
+
super();
|
|
2511
|
+
this.settings = settings;
|
|
2512
|
+
this.stringDeserializer = new FromStringShapeDeserializer(settings);
|
|
2513
|
+
}
|
|
2514
|
+
setSerdeContext(serdeContext) {
|
|
2515
|
+
this.serdeContext = serdeContext;
|
|
2516
|
+
this.stringDeserializer.setSerdeContext(serdeContext);
|
|
2517
|
+
}
|
|
2518
|
+
read(schema, bytes, key) {
|
|
2519
|
+
const ns = NormalizedSchema.of(schema);
|
|
2520
|
+
const memberSchemas = ns.getMemberSchemas();
|
|
2521
|
+
const isEventPayload = ns.isStructSchema() && ns.isMemberSchema() && !!Object.values(memberSchemas).find((memberNs) => {
|
|
2522
|
+
return !!memberNs.getMemberTraits().eventPayload;
|
|
2523
|
+
});
|
|
2524
|
+
if (isEventPayload) {
|
|
2525
|
+
const output = {};
|
|
2526
|
+
const memberName = Object.keys(memberSchemas)[0];
|
|
2527
|
+
const eventMemberSchema = memberSchemas[memberName];
|
|
2528
|
+
if (eventMemberSchema.isBlobSchema()) {
|
|
2529
|
+
output[memberName] = bytes;
|
|
2530
|
+
} else {
|
|
2531
|
+
output[memberName] = this.read(memberSchemas[memberName], bytes);
|
|
2532
|
+
}
|
|
2533
|
+
return output;
|
|
2534
|
+
}
|
|
2535
|
+
const xmlString = (this.serdeContext?.utf8Encoder ?? toUtf8)(bytes);
|
|
2536
|
+
const parsedObject = this.parseXml(xmlString);
|
|
2537
|
+
return this.readSchema(schema, key ? parsedObject[key] : parsedObject);
|
|
2538
|
+
}
|
|
2539
|
+
readSchema(_schema, value) {
|
|
2540
|
+
const ns = NormalizedSchema.of(_schema);
|
|
2541
|
+
if (ns.isUnitSchema()) {
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
const traits = ns.getMergedTraits();
|
|
2545
|
+
if (ns.isListSchema() && !Array.isArray(value)) {
|
|
2546
|
+
return this.readSchema(ns, [value]);
|
|
2547
|
+
}
|
|
2548
|
+
if (value == null) {
|
|
2549
|
+
return value;
|
|
2550
|
+
}
|
|
2551
|
+
if (typeof value === "object") {
|
|
2552
|
+
const flat = !!traits.xmlFlattened;
|
|
2553
|
+
if (ns.isListSchema()) {
|
|
2554
|
+
const listValue = ns.getValueSchema();
|
|
2555
|
+
const buffer2 = [];
|
|
2556
|
+
const sourceKey = listValue.getMergedTraits().xmlName ?? "member";
|
|
2557
|
+
const source = flat ? value : (value[0] ?? value)[sourceKey];
|
|
2558
|
+
if (source == null) {
|
|
2559
|
+
return buffer2;
|
|
2560
|
+
}
|
|
2561
|
+
const sourceArray = Array.isArray(source) ? source : [source];
|
|
2562
|
+
for (const v2 of sourceArray) {
|
|
2563
|
+
buffer2.push(this.readSchema(listValue, v2));
|
|
2564
|
+
}
|
|
2565
|
+
return buffer2;
|
|
2566
|
+
}
|
|
2567
|
+
const buffer = {};
|
|
2568
|
+
if (ns.isMapSchema()) {
|
|
2569
|
+
const keyNs = ns.getKeySchema();
|
|
2570
|
+
const memberNs = ns.getValueSchema();
|
|
2571
|
+
let entries;
|
|
2572
|
+
if (flat) {
|
|
2573
|
+
entries = Array.isArray(value) ? value : [value];
|
|
2574
|
+
} else {
|
|
2575
|
+
entries = Array.isArray(value.entry) ? value.entry : [value.entry];
|
|
2576
|
+
}
|
|
2577
|
+
const keyProperty = keyNs.getMergedTraits().xmlName ?? "key";
|
|
2578
|
+
const valueProperty = memberNs.getMergedTraits().xmlName ?? "value";
|
|
2579
|
+
for (const entry of entries) {
|
|
2580
|
+
const key = entry[keyProperty];
|
|
2581
|
+
const value2 = entry[valueProperty];
|
|
2582
|
+
buffer[key] = this.readSchema(memberNs, value2);
|
|
2583
|
+
}
|
|
2584
|
+
return buffer;
|
|
2585
|
+
}
|
|
2586
|
+
if (ns.isStructSchema()) {
|
|
2587
|
+
const union = ns.isUnionSchema();
|
|
2588
|
+
let unionSerde;
|
|
2589
|
+
if (union) {
|
|
2590
|
+
unionSerde = new UnionSerde(value, buffer);
|
|
2591
|
+
}
|
|
2592
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
2593
|
+
const memberTraits = memberSchema.getMergedTraits();
|
|
2594
|
+
const xmlObjectKey = !memberTraits.httpPayload ? memberSchema.getMemberTraits().xmlName ?? memberName : memberTraits.xmlName ?? memberSchema.getName();
|
|
2595
|
+
if (union) {
|
|
2596
|
+
unionSerde.mark(xmlObjectKey);
|
|
2597
|
+
}
|
|
2598
|
+
if (value[xmlObjectKey] != null) {
|
|
2599
|
+
buffer[memberName] = this.readSchema(memberSchema, value[xmlObjectKey]);
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
if (union) {
|
|
2603
|
+
unionSerde.writeUnknown();
|
|
2604
|
+
}
|
|
2605
|
+
return buffer;
|
|
2606
|
+
}
|
|
2607
|
+
if (ns.isDocumentSchema()) {
|
|
2608
|
+
return value;
|
|
2609
|
+
}
|
|
2610
|
+
throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
|
|
2611
|
+
}
|
|
2612
|
+
if (ns.isListSchema()) {
|
|
2613
|
+
return [];
|
|
2614
|
+
}
|
|
2615
|
+
if (ns.isMapSchema() || ns.isStructSchema()) {
|
|
2616
|
+
return {};
|
|
2617
|
+
}
|
|
2618
|
+
return this.stringDeserializer.read(ns, value);
|
|
2619
|
+
}
|
|
2620
|
+
parseXml(xml) {
|
|
2621
|
+
if (xml.length) {
|
|
2622
|
+
let parsedObj;
|
|
2623
|
+
try {
|
|
2624
|
+
parsedObj = parseXML(xml);
|
|
2625
|
+
} catch (e2) {
|
|
2626
|
+
if (e2 && typeof e2 === "object") {
|
|
2627
|
+
Object.defineProperty(e2, "$responseBodyText", {
|
|
2628
|
+
value: xml
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2631
|
+
throw e2;
|
|
2632
|
+
}
|
|
2633
|
+
const textNodeName = "#text";
|
|
2634
|
+
const key = Object.keys(parsedObj)[0];
|
|
2635
|
+
const parsedObjToReturn = parsedObj[key];
|
|
2636
|
+
if (parsedObjToReturn[textNodeName]) {
|
|
2637
|
+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
|
2638
|
+
delete parsedObjToReturn[textNodeName];
|
|
2639
|
+
}
|
|
2640
|
+
return getValueFromTextNode(parsedObjToReturn);
|
|
2641
|
+
}
|
|
2642
|
+
return {};
|
|
2643
|
+
}
|
|
2644
|
+
};
|
|
2645
|
+
|
|
2646
|
+
// ../../node_modules/.pnpm/@aws-sdk+core@3.973.26/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/QueryShapeSerializer.js
|
|
2647
|
+
var QueryShapeSerializer = class extends SerdeContextConfig {
|
|
2648
|
+
settings;
|
|
2649
|
+
buffer;
|
|
2650
|
+
constructor(settings) {
|
|
2651
|
+
super();
|
|
2652
|
+
this.settings = settings;
|
|
2653
|
+
}
|
|
2654
|
+
write(schema, value, prefix = "") {
|
|
2655
|
+
if (this.buffer === void 0) {
|
|
2656
|
+
this.buffer = "";
|
|
2657
|
+
}
|
|
2658
|
+
const ns = NormalizedSchema.of(schema);
|
|
2659
|
+
if (prefix && !prefix.endsWith(".")) {
|
|
2660
|
+
prefix += ".";
|
|
2661
|
+
}
|
|
2662
|
+
if (ns.isBlobSchema()) {
|
|
2663
|
+
if (typeof value === "string" || value instanceof Uint8Array) {
|
|
2664
|
+
this.writeKey(prefix);
|
|
2665
|
+
this.writeValue((this.serdeContext?.base64Encoder ?? toBase64)(value));
|
|
2666
|
+
}
|
|
2667
|
+
} else if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isStringSchema()) {
|
|
2668
|
+
if (value != null) {
|
|
2669
|
+
this.writeKey(prefix);
|
|
2670
|
+
this.writeValue(String(value));
|
|
2671
|
+
} else if (ns.isIdempotencyToken()) {
|
|
2672
|
+
this.writeKey(prefix);
|
|
2673
|
+
this.writeValue(v4());
|
|
2674
|
+
}
|
|
2675
|
+
} else if (ns.isBigIntegerSchema()) {
|
|
2676
|
+
if (value != null) {
|
|
2677
|
+
this.writeKey(prefix);
|
|
2678
|
+
this.writeValue(String(value));
|
|
2679
|
+
}
|
|
2680
|
+
} else if (ns.isBigDecimalSchema()) {
|
|
2681
|
+
if (value != null) {
|
|
2682
|
+
this.writeKey(prefix);
|
|
2683
|
+
this.writeValue(value instanceof NumericValue ? value.string : String(value));
|
|
2684
|
+
}
|
|
2685
|
+
} else if (ns.isTimestampSchema()) {
|
|
2686
|
+
if (value instanceof Date) {
|
|
2687
|
+
this.writeKey(prefix);
|
|
2688
|
+
const format = determineTimestampFormat(ns, this.settings);
|
|
2689
|
+
switch (format) {
|
|
2690
|
+
case 5:
|
|
2691
|
+
this.writeValue(value.toISOString().replace(".000Z", "Z"));
|
|
2692
|
+
break;
|
|
2693
|
+
case 6:
|
|
2694
|
+
this.writeValue(dateToUtcString(value));
|
|
2695
|
+
break;
|
|
2696
|
+
case 7:
|
|
2697
|
+
this.writeValue(String(value.getTime() / 1e3));
|
|
2698
|
+
break;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
} else if (ns.isDocumentSchema()) {
|
|
2702
|
+
if (Array.isArray(value)) {
|
|
2703
|
+
this.write(64 | 15, value, prefix);
|
|
2704
|
+
} else if (value instanceof Date) {
|
|
2705
|
+
this.write(4, value, prefix);
|
|
2706
|
+
} else if (value instanceof Uint8Array) {
|
|
2707
|
+
this.write(21, value, prefix);
|
|
2708
|
+
} else if (value && typeof value === "object") {
|
|
2709
|
+
this.write(128 | 15, value, prefix);
|
|
2710
|
+
} else {
|
|
2711
|
+
this.writeKey(prefix);
|
|
2712
|
+
this.writeValue(String(value));
|
|
2713
|
+
}
|
|
2714
|
+
} else if (ns.isListSchema()) {
|
|
2715
|
+
if (Array.isArray(value)) {
|
|
2716
|
+
if (value.length === 0) {
|
|
2717
|
+
if (this.settings.serializeEmptyLists) {
|
|
2718
|
+
this.writeKey(prefix);
|
|
2719
|
+
this.writeValue("");
|
|
2720
|
+
}
|
|
2721
|
+
} else {
|
|
2722
|
+
const member = ns.getValueSchema();
|
|
2723
|
+
const flat = this.settings.flattenLists || ns.getMergedTraits().xmlFlattened;
|
|
2724
|
+
let i2 = 1;
|
|
2725
|
+
for (const item of value) {
|
|
2726
|
+
if (item == null) {
|
|
2727
|
+
continue;
|
|
2728
|
+
}
|
|
2729
|
+
const traits = member.getMergedTraits();
|
|
2730
|
+
const suffix = this.getKey("member", traits.xmlName, traits.ec2QueryName);
|
|
2731
|
+
const key = flat ? `${prefix}${i2}` : `${prefix}${suffix}.${i2}`;
|
|
2732
|
+
this.write(member, item, key);
|
|
2733
|
+
++i2;
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
} else if (ns.isMapSchema()) {
|
|
2738
|
+
if (value && typeof value === "object") {
|
|
2739
|
+
const keySchema = ns.getKeySchema();
|
|
2740
|
+
const memberSchema = ns.getValueSchema();
|
|
2741
|
+
const flat = ns.getMergedTraits().xmlFlattened;
|
|
2742
|
+
let i2 = 1;
|
|
2743
|
+
for (const [k2, v2] of Object.entries(value)) {
|
|
2744
|
+
if (v2 == null) {
|
|
2745
|
+
continue;
|
|
2746
|
+
}
|
|
2747
|
+
const keyTraits = keySchema.getMergedTraits();
|
|
2748
|
+
const keySuffix = this.getKey("key", keyTraits.xmlName, keyTraits.ec2QueryName);
|
|
2749
|
+
const key = flat ? `${prefix}${i2}.${keySuffix}` : `${prefix}entry.${i2}.${keySuffix}`;
|
|
2750
|
+
const valTraits = memberSchema.getMergedTraits();
|
|
2751
|
+
const valueSuffix = this.getKey("value", valTraits.xmlName, valTraits.ec2QueryName);
|
|
2752
|
+
const valueKey = flat ? `${prefix}${i2}.${valueSuffix}` : `${prefix}entry.${i2}.${valueSuffix}`;
|
|
2753
|
+
this.write(keySchema, k2, key);
|
|
2754
|
+
this.write(memberSchema, v2, valueKey);
|
|
2755
|
+
++i2;
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
} else if (ns.isStructSchema()) {
|
|
2759
|
+
if (value && typeof value === "object") {
|
|
2760
|
+
let didWriteMember = false;
|
|
2761
|
+
for (const [memberName, member] of ns.structIterator()) {
|
|
2762
|
+
if (value[memberName] == null && !member.isIdempotencyToken()) {
|
|
2763
|
+
continue;
|
|
2764
|
+
}
|
|
2765
|
+
const traits = member.getMergedTraits();
|
|
2766
|
+
const suffix = this.getKey(memberName, traits.xmlName, traits.ec2QueryName, "struct");
|
|
2767
|
+
const key = `${prefix}${suffix}`;
|
|
2768
|
+
this.write(member, value[memberName], key);
|
|
2769
|
+
didWriteMember = true;
|
|
2770
|
+
}
|
|
2771
|
+
if (!didWriteMember && ns.isUnionSchema()) {
|
|
2772
|
+
const { $unknown } = value;
|
|
2773
|
+
if (Array.isArray($unknown)) {
|
|
2774
|
+
const [k2, v2] = $unknown;
|
|
2775
|
+
const key = `${prefix}${k2}`;
|
|
2776
|
+
this.write(15, v2, key);
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
} else if (ns.isUnitSchema()) {
|
|
2781
|
+
} else {
|
|
2782
|
+
throw new Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${ns.getName(true)}`);
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
flush() {
|
|
2786
|
+
if (this.buffer === void 0) {
|
|
2787
|
+
throw new Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");
|
|
2788
|
+
}
|
|
2789
|
+
const str = this.buffer;
|
|
2790
|
+
delete this.buffer;
|
|
2791
|
+
return str;
|
|
2792
|
+
}
|
|
2793
|
+
getKey(memberName, xmlName, ec2QueryName, keySource) {
|
|
2794
|
+
const { ec2, capitalizeKeys } = this.settings;
|
|
2795
|
+
if (ec2 && ec2QueryName) {
|
|
2796
|
+
return ec2QueryName;
|
|
2797
|
+
}
|
|
2798
|
+
const key = xmlName ?? memberName;
|
|
2799
|
+
if (capitalizeKeys && keySource === "struct") {
|
|
2800
|
+
return key[0].toUpperCase() + key.slice(1);
|
|
2801
|
+
}
|
|
2802
|
+
return key;
|
|
2803
|
+
}
|
|
2804
|
+
writeKey(key) {
|
|
2805
|
+
if (key.endsWith(".")) {
|
|
2806
|
+
key = key.slice(0, key.length - 1);
|
|
2807
|
+
}
|
|
2808
|
+
this.buffer += `&${extendedEncodeURIComponent(key)}=`;
|
|
2809
|
+
}
|
|
2810
|
+
writeValue(value) {
|
|
2811
|
+
this.buffer += extendedEncodeURIComponent(value);
|
|
2812
|
+
}
|
|
2813
|
+
};
|
|
2814
|
+
|
|
2815
|
+
// ../../node_modules/.pnpm/@aws-sdk+core@3.973.26/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js
|
|
2816
|
+
var AwsQueryProtocol = class extends RpcProtocol {
|
|
2817
|
+
options;
|
|
2818
|
+
serializer;
|
|
2819
|
+
deserializer;
|
|
2820
|
+
mixin = new ProtocolLib();
|
|
2821
|
+
constructor(options) {
|
|
2822
|
+
super({
|
|
2823
|
+
defaultNamespace: options.defaultNamespace,
|
|
2824
|
+
errorTypeRegistries: options.errorTypeRegistries
|
|
2825
|
+
});
|
|
2826
|
+
this.options = options;
|
|
2827
|
+
const settings = {
|
|
2828
|
+
timestampFormat: {
|
|
2829
|
+
useTrait: true,
|
|
2830
|
+
default: 5
|
|
2831
|
+
},
|
|
2832
|
+
httpBindings: false,
|
|
2833
|
+
xmlNamespace: options.xmlNamespace,
|
|
2834
|
+
serviceNamespace: options.defaultNamespace,
|
|
2835
|
+
serializeEmptyLists: true
|
|
2836
|
+
};
|
|
2837
|
+
this.serializer = new QueryShapeSerializer(settings);
|
|
2838
|
+
this.deserializer = new XmlShapeDeserializer(settings);
|
|
2839
|
+
}
|
|
2840
|
+
getShapeId() {
|
|
2841
|
+
return "aws.protocols#awsQuery";
|
|
2842
|
+
}
|
|
2843
|
+
setSerdeContext(serdeContext) {
|
|
2844
|
+
this.serializer.setSerdeContext(serdeContext);
|
|
2845
|
+
this.deserializer.setSerdeContext(serdeContext);
|
|
2846
|
+
}
|
|
2847
|
+
getPayloadCodec() {
|
|
2848
|
+
throw new Error("AWSQuery protocol has no payload codec.");
|
|
2849
|
+
}
|
|
2850
|
+
async serializeRequest(operationSchema, input, context) {
|
|
2851
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
2852
|
+
if (!request.path.endsWith("/")) {
|
|
2853
|
+
request.path += "/";
|
|
2854
|
+
}
|
|
2855
|
+
Object.assign(request.headers, {
|
|
2856
|
+
"content-type": `application/x-www-form-urlencoded`
|
|
2857
|
+
});
|
|
2858
|
+
if (deref(operationSchema.input) === "unit" || !request.body) {
|
|
2859
|
+
request.body = "";
|
|
2860
|
+
}
|
|
2861
|
+
const action = operationSchema.name.split("#")[1] ?? operationSchema.name;
|
|
2862
|
+
request.body = `Action=${action}&Version=${this.options.version}` + request.body;
|
|
2863
|
+
if (request.body.endsWith("&")) {
|
|
2864
|
+
request.body = request.body.slice(-1);
|
|
2865
|
+
}
|
|
2866
|
+
return request;
|
|
2867
|
+
}
|
|
2868
|
+
async deserializeResponse(operationSchema, context, response) {
|
|
2869
|
+
const deserializer = this.deserializer;
|
|
2870
|
+
const ns = NormalizedSchema.of(operationSchema.output);
|
|
2871
|
+
const dataObject = {};
|
|
2872
|
+
if (response.statusCode >= 300) {
|
|
2873
|
+
const bytes2 = await collectBody(response.body, context);
|
|
2874
|
+
if (bytes2.byteLength > 0) {
|
|
2875
|
+
Object.assign(dataObject, await deserializer.read(15, bytes2));
|
|
2876
|
+
}
|
|
2877
|
+
await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
|
|
2878
|
+
}
|
|
2879
|
+
for (const header in response.headers) {
|
|
2880
|
+
const value = response.headers[header];
|
|
2881
|
+
delete response.headers[header];
|
|
2882
|
+
response.headers[header.toLowerCase()] = value;
|
|
2883
|
+
}
|
|
2884
|
+
const shortName = operationSchema.name.split("#")[1] ?? operationSchema.name;
|
|
2885
|
+
const awsQueryResultKey = ns.isStructSchema() && this.useNestedResult() ? shortName + "Result" : void 0;
|
|
2886
|
+
const bytes = await collectBody(response.body, context);
|
|
2887
|
+
if (bytes.byteLength > 0) {
|
|
2888
|
+
Object.assign(dataObject, await deserializer.read(ns, bytes, awsQueryResultKey));
|
|
2889
|
+
}
|
|
2890
|
+
const output = {
|
|
2891
|
+
$metadata: this.deserializeMetadata(response),
|
|
2892
|
+
...dataObject
|
|
2893
|
+
};
|
|
2894
|
+
return output;
|
|
2895
|
+
}
|
|
2896
|
+
useNestedResult() {
|
|
2897
|
+
return true;
|
|
2898
|
+
}
|
|
2899
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
2900
|
+
const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
|
|
2901
|
+
this.mixin.compose(this.compositeErrorRegistry, errorIdentifier, this.options.defaultNamespace);
|
|
2902
|
+
const errorData = this.loadQueryError(dataObject) ?? {};
|
|
2903
|
+
const message = this.loadQueryErrorMessage(dataObject);
|
|
2904
|
+
errorData.message = message;
|
|
2905
|
+
errorData.Error = {
|
|
2906
|
+
Type: errorData.Type,
|
|
2907
|
+
Code: errorData.Code,
|
|
2908
|
+
Message: message
|
|
2909
|
+
};
|
|
2910
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
|
|
2911
|
+
const ns = NormalizedSchema.of(errorSchema);
|
|
2912
|
+
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
2913
|
+
const exception = new ErrorCtor(message);
|
|
2914
|
+
const output = {
|
|
2915
|
+
Type: errorData.Error.Type,
|
|
2916
|
+
Code: errorData.Error.Code,
|
|
2917
|
+
Error: errorData.Error
|
|
2918
|
+
};
|
|
2919
|
+
for (const [name, member] of ns.structIterator()) {
|
|
2920
|
+
const target = member.getMergedTraits().xmlName ?? name;
|
|
2921
|
+
const value = errorData[target] ?? dataObject[target];
|
|
2922
|
+
output[name] = this.deserializer.readSchema(member, value);
|
|
2923
|
+
}
|
|
2924
|
+
throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
|
|
2925
|
+
$fault: ns.getMergedTraits().error,
|
|
2926
|
+
message
|
|
2927
|
+
}, output), dataObject);
|
|
2928
|
+
}
|
|
2929
|
+
loadQueryErrorCode(output, data) {
|
|
2930
|
+
const code = (data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error)?.Code;
|
|
2931
|
+
if (code !== void 0) {
|
|
2932
|
+
return code;
|
|
2933
|
+
}
|
|
2934
|
+
if (output.statusCode == 404) {
|
|
2935
|
+
return "NotFound";
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
loadQueryError(data) {
|
|
2939
|
+
return data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error;
|
|
2940
|
+
}
|
|
2941
|
+
loadQueryErrorMessage(data) {
|
|
2942
|
+
const errorData = this.loadQueryError(data);
|
|
2943
|
+
return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";
|
|
2944
|
+
}
|
|
2945
|
+
getDefaultContentType() {
|
|
2946
|
+
return "application/x-www-form-urlencoded";
|
|
2947
|
+
}
|
|
2948
|
+
};
|
|
2949
|
+
|
|
2950
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/endpoint/ruleset.js
|
|
2951
|
+
var F = "required";
|
|
2952
|
+
var G = "type";
|
|
2953
|
+
var H = "fn";
|
|
2954
|
+
var I = "argv";
|
|
2955
|
+
var J = "ref";
|
|
2956
|
+
var a = false;
|
|
2957
|
+
var b = true;
|
|
2958
|
+
var c = "booleanEquals";
|
|
2959
|
+
var d = "stringEquals";
|
|
2960
|
+
var e = "sigv4";
|
|
2961
|
+
var f = "sts";
|
|
2962
|
+
var g = "us-east-1";
|
|
2963
|
+
var h = "endpoint";
|
|
2964
|
+
var i = "https://sts.{Region}.{PartitionResult#dnsSuffix}";
|
|
2965
|
+
var j = "tree";
|
|
2966
|
+
var k = "error";
|
|
2967
|
+
var l = "getAttr";
|
|
2968
|
+
var m = { [F]: false, [G]: "string" };
|
|
2969
|
+
var n = { [F]: true, default: false, [G]: "boolean" };
|
|
2970
|
+
var o = { [J]: "Endpoint" };
|
|
2971
|
+
var p = { [H]: "isSet", [I]: [{ [J]: "Region" }] };
|
|
2972
|
+
var q = { [J]: "Region" };
|
|
2973
|
+
var r = { [H]: "aws.partition", [I]: [q], assign: "PartitionResult" };
|
|
2974
|
+
var s = { [J]: "UseFIPS" };
|
|
2975
|
+
var t = { [J]: "UseDualStack" };
|
|
2976
|
+
var u = {
|
|
2977
|
+
url: "https://sts.amazonaws.com",
|
|
2978
|
+
properties: { authSchemes: [{ name: e, signingName: f, signingRegion: g }] },
|
|
2979
|
+
headers: {}
|
|
2980
|
+
};
|
|
2981
|
+
var v = {};
|
|
2982
|
+
var w = { conditions: [{ [H]: d, [I]: [q, "aws-global"] }], [h]: u, [G]: h };
|
|
2983
|
+
var x = { [H]: c, [I]: [s, true] };
|
|
2984
|
+
var y = { [H]: c, [I]: [t, true] };
|
|
2985
|
+
var z = { [H]: l, [I]: [{ [J]: "PartitionResult" }, "supportsFIPS"] };
|
|
2986
|
+
var A = { [J]: "PartitionResult" };
|
|
2987
|
+
var B = { [H]: c, [I]: [true, { [H]: l, [I]: [A, "supportsDualStack"] }] };
|
|
2988
|
+
var C = [{ [H]: "isSet", [I]: [o] }];
|
|
2989
|
+
var D = [x];
|
|
2990
|
+
var E = [y];
|
|
2991
|
+
var _data = {
|
|
2992
|
+
version: "1.0",
|
|
2993
|
+
parameters: { Region: m, UseDualStack: n, UseFIPS: n, Endpoint: m, UseGlobalEndpoint: n },
|
|
2994
|
+
rules: [
|
|
2995
|
+
{
|
|
2996
|
+
conditions: [
|
|
2997
|
+
{ [H]: c, [I]: [{ [J]: "UseGlobalEndpoint" }, b] },
|
|
2998
|
+
{ [H]: "not", [I]: C },
|
|
2999
|
+
p,
|
|
3000
|
+
r,
|
|
3001
|
+
{ [H]: c, [I]: [s, a] },
|
|
3002
|
+
{ [H]: c, [I]: [t, a] }
|
|
3003
|
+
],
|
|
3004
|
+
rules: [
|
|
3005
|
+
{ conditions: [{ [H]: d, [I]: [q, "ap-northeast-1"] }], endpoint: u, [G]: h },
|
|
3006
|
+
{ conditions: [{ [H]: d, [I]: [q, "ap-south-1"] }], endpoint: u, [G]: h },
|
|
3007
|
+
{ conditions: [{ [H]: d, [I]: [q, "ap-southeast-1"] }], endpoint: u, [G]: h },
|
|
3008
|
+
{ conditions: [{ [H]: d, [I]: [q, "ap-southeast-2"] }], endpoint: u, [G]: h },
|
|
3009
|
+
w,
|
|
3010
|
+
{ conditions: [{ [H]: d, [I]: [q, "ca-central-1"] }], endpoint: u, [G]: h },
|
|
3011
|
+
{ conditions: [{ [H]: d, [I]: [q, "eu-central-1"] }], endpoint: u, [G]: h },
|
|
3012
|
+
{ conditions: [{ [H]: d, [I]: [q, "eu-north-1"] }], endpoint: u, [G]: h },
|
|
3013
|
+
{ conditions: [{ [H]: d, [I]: [q, "eu-west-1"] }], endpoint: u, [G]: h },
|
|
3014
|
+
{ conditions: [{ [H]: d, [I]: [q, "eu-west-2"] }], endpoint: u, [G]: h },
|
|
3015
|
+
{ conditions: [{ [H]: d, [I]: [q, "eu-west-3"] }], endpoint: u, [G]: h },
|
|
3016
|
+
{ conditions: [{ [H]: d, [I]: [q, "sa-east-1"] }], endpoint: u, [G]: h },
|
|
3017
|
+
{ conditions: [{ [H]: d, [I]: [q, g] }], endpoint: u, [G]: h },
|
|
3018
|
+
{ conditions: [{ [H]: d, [I]: [q, "us-east-2"] }], endpoint: u, [G]: h },
|
|
3019
|
+
{ conditions: [{ [H]: d, [I]: [q, "us-west-1"] }], endpoint: u, [G]: h },
|
|
3020
|
+
{ conditions: [{ [H]: d, [I]: [q, "us-west-2"] }], endpoint: u, [G]: h },
|
|
3021
|
+
{
|
|
3022
|
+
endpoint: {
|
|
3023
|
+
url: i,
|
|
3024
|
+
properties: { authSchemes: [{ name: e, signingName: f, signingRegion: "{Region}" }] },
|
|
3025
|
+
headers: v
|
|
3026
|
+
},
|
|
3027
|
+
[G]: h
|
|
3028
|
+
}
|
|
3029
|
+
],
|
|
3030
|
+
[G]: j
|
|
3031
|
+
},
|
|
3032
|
+
{
|
|
3033
|
+
conditions: C,
|
|
3034
|
+
rules: [
|
|
3035
|
+
{ conditions: D, error: "Invalid Configuration: FIPS and custom endpoint are not supported", [G]: k },
|
|
3036
|
+
{ conditions: E, error: "Invalid Configuration: Dualstack and custom endpoint are not supported", [G]: k },
|
|
3037
|
+
{ endpoint: { url: o, properties: v, headers: v }, [G]: h }
|
|
3038
|
+
],
|
|
3039
|
+
[G]: j
|
|
3040
|
+
},
|
|
3041
|
+
{
|
|
3042
|
+
conditions: [p],
|
|
3043
|
+
rules: [
|
|
3044
|
+
{
|
|
3045
|
+
conditions: [r],
|
|
3046
|
+
rules: [
|
|
3047
|
+
{
|
|
3048
|
+
conditions: [x, y],
|
|
3049
|
+
rules: [
|
|
3050
|
+
{
|
|
3051
|
+
conditions: [{ [H]: c, [I]: [b, z] }, B],
|
|
3052
|
+
rules: [
|
|
3053
|
+
{
|
|
3054
|
+
endpoint: {
|
|
3055
|
+
url: "https://sts-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",
|
|
3056
|
+
properties: v,
|
|
3057
|
+
headers: v
|
|
3058
|
+
},
|
|
3059
|
+
[G]: h
|
|
3060
|
+
}
|
|
3061
|
+
],
|
|
3062
|
+
[G]: j
|
|
3063
|
+
},
|
|
3064
|
+
{ error: "FIPS and DualStack are enabled, but this partition does not support one or both", [G]: k }
|
|
3065
|
+
],
|
|
3066
|
+
[G]: j
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
conditions: D,
|
|
3070
|
+
rules: [
|
|
3071
|
+
{
|
|
3072
|
+
conditions: [{ [H]: c, [I]: [z, b] }],
|
|
3073
|
+
rules: [
|
|
3074
|
+
{
|
|
3075
|
+
conditions: [{ [H]: d, [I]: [{ [H]: l, [I]: [A, "name"] }, "aws-us-gov"] }],
|
|
3076
|
+
endpoint: { url: "https://sts.{Region}.amazonaws.com", properties: v, headers: v },
|
|
3077
|
+
[G]: h
|
|
3078
|
+
},
|
|
3079
|
+
{
|
|
3080
|
+
endpoint: {
|
|
3081
|
+
url: "https://sts-fips.{Region}.{PartitionResult#dnsSuffix}",
|
|
3082
|
+
properties: v,
|
|
3083
|
+
headers: v
|
|
3084
|
+
},
|
|
3085
|
+
[G]: h
|
|
3086
|
+
}
|
|
3087
|
+
],
|
|
3088
|
+
[G]: j
|
|
3089
|
+
},
|
|
3090
|
+
{ error: "FIPS is enabled but this partition does not support FIPS", [G]: k }
|
|
3091
|
+
],
|
|
3092
|
+
[G]: j
|
|
3093
|
+
},
|
|
3094
|
+
{
|
|
3095
|
+
conditions: E,
|
|
3096
|
+
rules: [
|
|
3097
|
+
{
|
|
3098
|
+
conditions: [B],
|
|
3099
|
+
rules: [
|
|
3100
|
+
{
|
|
3101
|
+
endpoint: {
|
|
3102
|
+
url: "https://sts.{Region}.{PartitionResult#dualStackDnsSuffix}",
|
|
3103
|
+
properties: v,
|
|
3104
|
+
headers: v
|
|
3105
|
+
},
|
|
3106
|
+
[G]: h
|
|
3107
|
+
}
|
|
3108
|
+
],
|
|
3109
|
+
[G]: j
|
|
3110
|
+
},
|
|
3111
|
+
{ error: "DualStack is enabled but this partition does not support DualStack", [G]: k }
|
|
3112
|
+
],
|
|
3113
|
+
[G]: j
|
|
3114
|
+
},
|
|
3115
|
+
w,
|
|
3116
|
+
{ endpoint: { url: i, properties: v, headers: v }, [G]: h }
|
|
3117
|
+
],
|
|
3118
|
+
[G]: j
|
|
3119
|
+
}
|
|
3120
|
+
],
|
|
3121
|
+
[G]: j
|
|
3122
|
+
},
|
|
3123
|
+
{ error: "Invalid Configuration: Missing Region", [G]: k }
|
|
3124
|
+
]
|
|
3125
|
+
};
|
|
3126
|
+
var ruleSet = _data;
|
|
3127
|
+
|
|
3128
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/endpoint/endpointResolver.js
|
|
3129
|
+
var cache = new EndpointCache({
|
|
3130
|
+
size: 50,
|
|
3131
|
+
params: ["Endpoint", "Region", "UseDualStack", "UseFIPS", "UseGlobalEndpoint"]
|
|
3132
|
+
});
|
|
3133
|
+
var defaultEndpointResolver = (endpointParams, context = {}) => {
|
|
3134
|
+
return cache.get(endpointParams, () => resolveEndpoint(ruleSet, {
|
|
3135
|
+
endpointParams,
|
|
3136
|
+
logger: context.logger
|
|
3137
|
+
}));
|
|
3138
|
+
};
|
|
3139
|
+
customEndpointFunctions.aws = awsEndpointFunctions;
|
|
3140
|
+
|
|
3141
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/models/STSServiceException.js
|
|
3142
|
+
var STSServiceException = class _STSServiceException extends ServiceException {
|
|
3143
|
+
constructor(options) {
|
|
3144
|
+
super(options);
|
|
3145
|
+
Object.setPrototypeOf(this, _STSServiceException.prototype);
|
|
3146
|
+
}
|
|
3147
|
+
};
|
|
3148
|
+
|
|
3149
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/models/errors.js
|
|
3150
|
+
var ExpiredTokenException = class _ExpiredTokenException extends STSServiceException {
|
|
3151
|
+
name = "ExpiredTokenException";
|
|
3152
|
+
$fault = "client";
|
|
3153
|
+
constructor(opts) {
|
|
3154
|
+
super({
|
|
3155
|
+
name: "ExpiredTokenException",
|
|
3156
|
+
$fault: "client",
|
|
3157
|
+
...opts
|
|
3158
|
+
});
|
|
3159
|
+
Object.setPrototypeOf(this, _ExpiredTokenException.prototype);
|
|
3160
|
+
}
|
|
3161
|
+
};
|
|
3162
|
+
var MalformedPolicyDocumentException = class _MalformedPolicyDocumentException extends STSServiceException {
|
|
3163
|
+
name = "MalformedPolicyDocumentException";
|
|
3164
|
+
$fault = "client";
|
|
3165
|
+
constructor(opts) {
|
|
3166
|
+
super({
|
|
3167
|
+
name: "MalformedPolicyDocumentException",
|
|
3168
|
+
$fault: "client",
|
|
3169
|
+
...opts
|
|
3170
|
+
});
|
|
3171
|
+
Object.setPrototypeOf(this, _MalformedPolicyDocumentException.prototype);
|
|
3172
|
+
}
|
|
3173
|
+
};
|
|
3174
|
+
var PackedPolicyTooLargeException = class _PackedPolicyTooLargeException extends STSServiceException {
|
|
3175
|
+
name = "PackedPolicyTooLargeException";
|
|
3176
|
+
$fault = "client";
|
|
3177
|
+
constructor(opts) {
|
|
3178
|
+
super({
|
|
3179
|
+
name: "PackedPolicyTooLargeException",
|
|
3180
|
+
$fault: "client",
|
|
3181
|
+
...opts
|
|
3182
|
+
});
|
|
3183
|
+
Object.setPrototypeOf(this, _PackedPolicyTooLargeException.prototype);
|
|
3184
|
+
}
|
|
3185
|
+
};
|
|
3186
|
+
var RegionDisabledException = class _RegionDisabledException extends STSServiceException {
|
|
3187
|
+
name = "RegionDisabledException";
|
|
3188
|
+
$fault = "client";
|
|
3189
|
+
constructor(opts) {
|
|
3190
|
+
super({
|
|
3191
|
+
name: "RegionDisabledException",
|
|
3192
|
+
$fault: "client",
|
|
3193
|
+
...opts
|
|
3194
|
+
});
|
|
3195
|
+
Object.setPrototypeOf(this, _RegionDisabledException.prototype);
|
|
3196
|
+
}
|
|
3197
|
+
};
|
|
3198
|
+
var IDPRejectedClaimException = class _IDPRejectedClaimException extends STSServiceException {
|
|
3199
|
+
name = "IDPRejectedClaimException";
|
|
3200
|
+
$fault = "client";
|
|
3201
|
+
constructor(opts) {
|
|
3202
|
+
super({
|
|
3203
|
+
name: "IDPRejectedClaimException",
|
|
3204
|
+
$fault: "client",
|
|
3205
|
+
...opts
|
|
3206
|
+
});
|
|
3207
|
+
Object.setPrototypeOf(this, _IDPRejectedClaimException.prototype);
|
|
3208
|
+
}
|
|
3209
|
+
};
|
|
3210
|
+
var InvalidIdentityTokenException = class _InvalidIdentityTokenException extends STSServiceException {
|
|
3211
|
+
name = "InvalidIdentityTokenException";
|
|
3212
|
+
$fault = "client";
|
|
3213
|
+
constructor(opts) {
|
|
3214
|
+
super({
|
|
3215
|
+
name: "InvalidIdentityTokenException",
|
|
3216
|
+
$fault: "client",
|
|
3217
|
+
...opts
|
|
3218
|
+
});
|
|
3219
|
+
Object.setPrototypeOf(this, _InvalidIdentityTokenException.prototype);
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3222
|
+
var IDPCommunicationErrorException = class _IDPCommunicationErrorException extends STSServiceException {
|
|
3223
|
+
name = "IDPCommunicationErrorException";
|
|
3224
|
+
$fault = "client";
|
|
3225
|
+
constructor(opts) {
|
|
3226
|
+
super({
|
|
3227
|
+
name: "IDPCommunicationErrorException",
|
|
3228
|
+
$fault: "client",
|
|
3229
|
+
...opts
|
|
3230
|
+
});
|
|
3231
|
+
Object.setPrototypeOf(this, _IDPCommunicationErrorException.prototype);
|
|
3232
|
+
}
|
|
3233
|
+
};
|
|
3234
|
+
|
|
3235
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/schemas/schemas_0.js
|
|
3236
|
+
var _A = "Arn";
|
|
3237
|
+
var _AKI = "AccessKeyId";
|
|
3238
|
+
var _AR = "AssumeRole";
|
|
3239
|
+
var _ARI = "AssumedRoleId";
|
|
3240
|
+
var _ARR = "AssumeRoleRequest";
|
|
3241
|
+
var _ARRs = "AssumeRoleResponse";
|
|
3242
|
+
var _ARU = "AssumedRoleUser";
|
|
3243
|
+
var _ARWWI = "AssumeRoleWithWebIdentity";
|
|
3244
|
+
var _ARWWIR = "AssumeRoleWithWebIdentityRequest";
|
|
3245
|
+
var _ARWWIRs = "AssumeRoleWithWebIdentityResponse";
|
|
3246
|
+
var _Au = "Audience";
|
|
3247
|
+
var _C = "Credentials";
|
|
3248
|
+
var _CA = "ContextAssertion";
|
|
3249
|
+
var _DS = "DurationSeconds";
|
|
3250
|
+
var _E = "Expiration";
|
|
3251
|
+
var _EI = "ExternalId";
|
|
3252
|
+
var _ETE = "ExpiredTokenException";
|
|
3253
|
+
var _IDPCEE = "IDPCommunicationErrorException";
|
|
3254
|
+
var _IDPRCE = "IDPRejectedClaimException";
|
|
3255
|
+
var _IITE = "InvalidIdentityTokenException";
|
|
3256
|
+
var _K = "Key";
|
|
3257
|
+
var _MPDE = "MalformedPolicyDocumentException";
|
|
3258
|
+
var _P = "Policy";
|
|
3259
|
+
var _PA = "PolicyArns";
|
|
3260
|
+
var _PAr = "ProviderArn";
|
|
3261
|
+
var _PC = "ProvidedContexts";
|
|
3262
|
+
var _PCLT = "ProvidedContextsListType";
|
|
3263
|
+
var _PCr = "ProvidedContext";
|
|
3264
|
+
var _PDT = "PolicyDescriptorType";
|
|
3265
|
+
var _PI = "ProviderId";
|
|
3266
|
+
var _PPS = "PackedPolicySize";
|
|
3267
|
+
var _PPTLE = "PackedPolicyTooLargeException";
|
|
3268
|
+
var _Pr = "Provider";
|
|
3269
|
+
var _RA = "RoleArn";
|
|
3270
|
+
var _RDE = "RegionDisabledException";
|
|
3271
|
+
var _RSN = "RoleSessionName";
|
|
3272
|
+
var _SAK = "SecretAccessKey";
|
|
3273
|
+
var _SFWIT = "SubjectFromWebIdentityToken";
|
|
3274
|
+
var _SI = "SourceIdentity";
|
|
3275
|
+
var _SN = "SerialNumber";
|
|
3276
|
+
var _ST = "SessionToken";
|
|
3277
|
+
var _T = "Tags";
|
|
3278
|
+
var _TC = "TokenCode";
|
|
3279
|
+
var _TTK = "TransitiveTagKeys";
|
|
3280
|
+
var _Ta = "Tag";
|
|
3281
|
+
var _V = "Value";
|
|
3282
|
+
var _WIT = "WebIdentityToken";
|
|
3283
|
+
var _a = "arn";
|
|
3284
|
+
var _aKST = "accessKeySecretType";
|
|
3285
|
+
var _aQE = "awsQueryError";
|
|
3286
|
+
var _c = "client";
|
|
3287
|
+
var _cTT = "clientTokenType";
|
|
3288
|
+
var _e = "error";
|
|
3289
|
+
var _hE = "httpError";
|
|
3290
|
+
var _m = "message";
|
|
3291
|
+
var _pDLT = "policyDescriptorListType";
|
|
3292
|
+
var _s = "smithy.ts.sdk.synthetic.com.amazonaws.sts";
|
|
3293
|
+
var _tLT = "tagListType";
|
|
3294
|
+
var n0 = "com.amazonaws.sts";
|
|
3295
|
+
var _s_registry = TypeRegistry.for(_s);
|
|
3296
|
+
var STSServiceException$ = [-3, _s, "STSServiceException", 0, [], []];
|
|
3297
|
+
_s_registry.registerError(STSServiceException$, STSServiceException);
|
|
3298
|
+
var n0_registry = TypeRegistry.for(n0);
|
|
3299
|
+
var ExpiredTokenException$ = [
|
|
3300
|
+
-3,
|
|
3301
|
+
n0,
|
|
3302
|
+
_ETE,
|
|
3303
|
+
{ [_aQE]: [`ExpiredTokenException`, 400], [_e]: _c, [_hE]: 400 },
|
|
3304
|
+
[_m],
|
|
3305
|
+
[0]
|
|
3306
|
+
];
|
|
3307
|
+
n0_registry.registerError(ExpiredTokenException$, ExpiredTokenException);
|
|
3308
|
+
var IDPCommunicationErrorException$ = [
|
|
3309
|
+
-3,
|
|
3310
|
+
n0,
|
|
3311
|
+
_IDPCEE,
|
|
3312
|
+
{ [_aQE]: [`IDPCommunicationError`, 400], [_e]: _c, [_hE]: 400 },
|
|
3313
|
+
[_m],
|
|
3314
|
+
[0]
|
|
3315
|
+
];
|
|
3316
|
+
n0_registry.registerError(IDPCommunicationErrorException$, IDPCommunicationErrorException);
|
|
3317
|
+
var IDPRejectedClaimException$ = [
|
|
3318
|
+
-3,
|
|
3319
|
+
n0,
|
|
3320
|
+
_IDPRCE,
|
|
3321
|
+
{ [_aQE]: [`IDPRejectedClaim`, 403], [_e]: _c, [_hE]: 403 },
|
|
3322
|
+
[_m],
|
|
3323
|
+
[0]
|
|
3324
|
+
];
|
|
3325
|
+
n0_registry.registerError(IDPRejectedClaimException$, IDPRejectedClaimException);
|
|
3326
|
+
var InvalidIdentityTokenException$ = [
|
|
3327
|
+
-3,
|
|
3328
|
+
n0,
|
|
3329
|
+
_IITE,
|
|
3330
|
+
{ [_aQE]: [`InvalidIdentityToken`, 400], [_e]: _c, [_hE]: 400 },
|
|
3331
|
+
[_m],
|
|
3332
|
+
[0]
|
|
3333
|
+
];
|
|
3334
|
+
n0_registry.registerError(InvalidIdentityTokenException$, InvalidIdentityTokenException);
|
|
3335
|
+
var MalformedPolicyDocumentException$ = [
|
|
3336
|
+
-3,
|
|
3337
|
+
n0,
|
|
3338
|
+
_MPDE,
|
|
3339
|
+
{ [_aQE]: [`MalformedPolicyDocument`, 400], [_e]: _c, [_hE]: 400 },
|
|
3340
|
+
[_m],
|
|
3341
|
+
[0]
|
|
3342
|
+
];
|
|
3343
|
+
n0_registry.registerError(MalformedPolicyDocumentException$, MalformedPolicyDocumentException);
|
|
3344
|
+
var PackedPolicyTooLargeException$ = [
|
|
3345
|
+
-3,
|
|
3346
|
+
n0,
|
|
3347
|
+
_PPTLE,
|
|
3348
|
+
{ [_aQE]: [`PackedPolicyTooLarge`, 400], [_e]: _c, [_hE]: 400 },
|
|
3349
|
+
[_m],
|
|
3350
|
+
[0]
|
|
3351
|
+
];
|
|
3352
|
+
n0_registry.registerError(PackedPolicyTooLargeException$, PackedPolicyTooLargeException);
|
|
3353
|
+
var RegionDisabledException$ = [
|
|
3354
|
+
-3,
|
|
3355
|
+
n0,
|
|
3356
|
+
_RDE,
|
|
3357
|
+
{ [_aQE]: [`RegionDisabledException`, 403], [_e]: _c, [_hE]: 403 },
|
|
3358
|
+
[_m],
|
|
3359
|
+
[0]
|
|
3360
|
+
];
|
|
3361
|
+
n0_registry.registerError(RegionDisabledException$, RegionDisabledException);
|
|
3362
|
+
var errorTypeRegistries = [_s_registry, n0_registry];
|
|
3363
|
+
var accessKeySecretType = [0, n0, _aKST, 8, 0];
|
|
3364
|
+
var clientTokenType = [0, n0, _cTT, 8, 0];
|
|
3365
|
+
var AssumedRoleUser$ = [3, n0, _ARU, 0, [_ARI, _A], [0, 0], 2];
|
|
3366
|
+
var AssumeRoleRequest$ = [
|
|
3367
|
+
3,
|
|
3368
|
+
n0,
|
|
3369
|
+
_ARR,
|
|
3370
|
+
0,
|
|
3371
|
+
[_RA, _RSN, _PA, _P, _DS, _T, _TTK, _EI, _SN, _TC, _SI, _PC],
|
|
3372
|
+
[0, 0, () => policyDescriptorListType, 0, 1, () => tagListType, 64 | 0, 0, 0, 0, 0, () => ProvidedContextsListType],
|
|
3373
|
+
2
|
|
3374
|
+
];
|
|
3375
|
+
var AssumeRoleResponse$ = [
|
|
3376
|
+
3,
|
|
3377
|
+
n0,
|
|
3378
|
+
_ARRs,
|
|
3379
|
+
0,
|
|
3380
|
+
[_C, _ARU, _PPS, _SI],
|
|
3381
|
+
[[() => Credentials$, 0], () => AssumedRoleUser$, 1, 0]
|
|
3382
|
+
];
|
|
3383
|
+
var AssumeRoleWithWebIdentityRequest$ = [
|
|
3384
|
+
3,
|
|
3385
|
+
n0,
|
|
3386
|
+
_ARWWIR,
|
|
3387
|
+
0,
|
|
3388
|
+
[_RA, _RSN, _WIT, _PI, _PA, _P, _DS],
|
|
3389
|
+
[0, 0, [() => clientTokenType, 0], 0, () => policyDescriptorListType, 0, 1],
|
|
3390
|
+
3
|
|
3391
|
+
];
|
|
3392
|
+
var AssumeRoleWithWebIdentityResponse$ = [
|
|
3393
|
+
3,
|
|
3394
|
+
n0,
|
|
3395
|
+
_ARWWIRs,
|
|
3396
|
+
0,
|
|
3397
|
+
[_C, _SFWIT, _ARU, _PPS, _Pr, _Au, _SI],
|
|
3398
|
+
[[() => Credentials$, 0], 0, () => AssumedRoleUser$, 1, 0, 0, 0]
|
|
3399
|
+
];
|
|
3400
|
+
var Credentials$ = [
|
|
3401
|
+
3,
|
|
3402
|
+
n0,
|
|
3403
|
+
_C,
|
|
3404
|
+
0,
|
|
3405
|
+
[_AKI, _SAK, _ST, _E],
|
|
3406
|
+
[0, [() => accessKeySecretType, 0], 0, 4],
|
|
3407
|
+
4
|
|
3408
|
+
];
|
|
3409
|
+
var PolicyDescriptorType$ = [3, n0, _PDT, 0, [_a], [0]];
|
|
3410
|
+
var ProvidedContext$ = [3, n0, _PCr, 0, [_PAr, _CA], [0, 0]];
|
|
3411
|
+
var Tag$ = [3, n0, _Ta, 0, [_K, _V], [0, 0], 2];
|
|
3412
|
+
var policyDescriptorListType = [1, n0, _pDLT, 0, () => PolicyDescriptorType$];
|
|
3413
|
+
var ProvidedContextsListType = [1, n0, _PCLT, 0, () => ProvidedContext$];
|
|
3414
|
+
var tagKeyListType = 64 | 0;
|
|
3415
|
+
var tagListType = [1, n0, _tLT, 0, () => Tag$];
|
|
3416
|
+
var AssumeRole$ = [9, n0, _AR, 0, () => AssumeRoleRequest$, () => AssumeRoleResponse$];
|
|
3417
|
+
var AssumeRoleWithWebIdentity$ = [
|
|
3418
|
+
9,
|
|
3419
|
+
n0,
|
|
3420
|
+
_ARWWI,
|
|
3421
|
+
0,
|
|
3422
|
+
() => AssumeRoleWithWebIdentityRequest$,
|
|
3423
|
+
() => AssumeRoleWithWebIdentityResponse$
|
|
3424
|
+
];
|
|
3425
|
+
|
|
3426
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.shared.js
|
|
3427
|
+
var getRuntimeConfig = (config) => {
|
|
3428
|
+
return {
|
|
3429
|
+
apiVersion: "2011-06-15",
|
|
3430
|
+
base64Decoder: config?.base64Decoder ?? fromBase64,
|
|
3431
|
+
base64Encoder: config?.base64Encoder ?? toBase64,
|
|
3432
|
+
disableHostPrefix: config?.disableHostPrefix ?? false,
|
|
3433
|
+
endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
|
|
3434
|
+
extensions: config?.extensions ?? [],
|
|
3435
|
+
httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultSTSHttpAuthSchemeProvider,
|
|
3436
|
+
httpAuthSchemes: config?.httpAuthSchemes ?? [
|
|
3437
|
+
{
|
|
3438
|
+
schemeId: "aws.auth#sigv4",
|
|
3439
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
|
|
3440
|
+
signer: new AwsSdkSigV4Signer()
|
|
3441
|
+
},
|
|
3442
|
+
{
|
|
3443
|
+
schemeId: "smithy.api#noAuth",
|
|
3444
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
|
|
3445
|
+
signer: new NoAuthSigner()
|
|
3446
|
+
}
|
|
3447
|
+
],
|
|
3448
|
+
logger: config?.logger ?? new NoOpLogger(),
|
|
3449
|
+
protocol: config?.protocol ?? AwsQueryProtocol,
|
|
3450
|
+
protocolSettings: config?.protocolSettings ?? {
|
|
3451
|
+
defaultNamespace: "com.amazonaws.sts",
|
|
3452
|
+
errorTypeRegistries,
|
|
3453
|
+
xmlNamespace: "https://sts.amazonaws.com/doc/2011-06-15/",
|
|
3454
|
+
version: "2011-06-15",
|
|
3455
|
+
serviceTarget: "AWSSecurityTokenServiceV20110615"
|
|
3456
|
+
},
|
|
3457
|
+
serviceId: config?.serviceId ?? "STS",
|
|
3458
|
+
urlParser: config?.urlParser ?? parseUrl,
|
|
3459
|
+
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
|
|
3460
|
+
utf8Encoder: config?.utf8Encoder ?? toUtf8
|
|
3461
|
+
};
|
|
3462
|
+
};
|
|
3463
|
+
|
|
3464
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.js
|
|
3465
|
+
var getRuntimeConfig2 = (config) => {
|
|
3466
|
+
emitWarningIfUnsupportedVersion2(process.version);
|
|
3467
|
+
const defaultsMode = resolveDefaultsModeConfig(config);
|
|
3468
|
+
const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
|
|
3469
|
+
const clientSharedValues = getRuntimeConfig(config);
|
|
3470
|
+
emitWarningIfUnsupportedVersion(process.version);
|
|
3471
|
+
const loaderConfig = {
|
|
3472
|
+
profile: config?.profile,
|
|
3473
|
+
logger: clientSharedValues.logger
|
|
3474
|
+
};
|
|
3475
|
+
return {
|
|
3476
|
+
...clientSharedValues,
|
|
3477
|
+
...config,
|
|
3478
|
+
runtime: "node",
|
|
3479
|
+
defaultsMode,
|
|
3480
|
+
authSchemePreference: config?.authSchemePreference ?? loadConfig(NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
|
|
3481
|
+
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
|
|
3482
|
+
defaultUserAgentProvider: config?.defaultUserAgentProvider ?? createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: package_default.version }),
|
|
3483
|
+
httpAuthSchemes: config?.httpAuthSchemes ?? [
|
|
3484
|
+
{
|
|
3485
|
+
schemeId: "aws.auth#sigv4",
|
|
3486
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4") || (async (idProps) => await config.credentialDefaultProvider(idProps?.__config || {})()),
|
|
3487
|
+
signer: new AwsSdkSigV4Signer()
|
|
3488
|
+
},
|
|
3489
|
+
{
|
|
3490
|
+
schemeId: "smithy.api#noAuth",
|
|
3491
|
+
identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
|
|
3492
|
+
signer: new NoAuthSigner()
|
|
3493
|
+
}
|
|
3494
|
+
],
|
|
3495
|
+
maxAttempts: config?.maxAttempts ?? loadConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
|
|
3496
|
+
region: config?.region ?? loadConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
|
|
3497
|
+
requestHandler: NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
|
|
3498
|
+
retryMode: config?.retryMode ?? loadConfig({
|
|
3499
|
+
...NODE_RETRY_MODE_CONFIG_OPTIONS,
|
|
3500
|
+
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE
|
|
3501
|
+
}, config),
|
|
3502
|
+
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
|
|
3503
|
+
streamCollector: config?.streamCollector ?? streamCollector,
|
|
3504
|
+
useDualstackEndpoint: config?.useDualstackEndpoint ?? loadConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
3505
|
+
useFipsEndpoint: config?.useFipsEndpoint ?? loadConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
|
|
3506
|
+
userAgentAppId: config?.userAgentAppId ?? loadConfig(NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
|
|
3507
|
+
};
|
|
3508
|
+
};
|
|
3509
|
+
|
|
3510
|
+
// ../../node_modules/.pnpm/@aws-sdk+region-config-resolver@3.972.10/node_modules/@aws-sdk/region-config-resolver/dist-es/regionConfig/stsRegionDefaultResolver.js
|
|
3511
|
+
function stsRegionDefaultResolver(loaderConfig = {}) {
|
|
3512
|
+
return loadConfig({
|
|
3513
|
+
...NODE_REGION_CONFIG_OPTIONS,
|
|
3514
|
+
async default() {
|
|
3515
|
+
if (!warning.silence) {
|
|
3516
|
+
console.warn("@aws-sdk - WARN - default STS region of us-east-1 used. See @aws-sdk/credential-providers README and set a region explicitly.");
|
|
3517
|
+
}
|
|
3518
|
+
return "us-east-1";
|
|
3519
|
+
}
|
|
3520
|
+
}, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig });
|
|
3521
|
+
}
|
|
3522
|
+
var warning = {
|
|
3523
|
+
silence: false
|
|
3524
|
+
};
|
|
3525
|
+
|
|
3526
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/auth/httpAuthExtensionConfiguration.js
|
|
3527
|
+
var getHttpAuthExtensionConfiguration = (runtimeConfig) => {
|
|
3528
|
+
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
|
|
3529
|
+
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
|
|
3530
|
+
let _credentials = runtimeConfig.credentials;
|
|
3531
|
+
return {
|
|
3532
|
+
setHttpAuthScheme(httpAuthScheme) {
|
|
3533
|
+
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
|
|
3534
|
+
if (index === -1) {
|
|
3535
|
+
_httpAuthSchemes.push(httpAuthScheme);
|
|
3536
|
+
} else {
|
|
3537
|
+
_httpAuthSchemes.splice(index, 1, httpAuthScheme);
|
|
3538
|
+
}
|
|
3539
|
+
},
|
|
3540
|
+
httpAuthSchemes() {
|
|
3541
|
+
return _httpAuthSchemes;
|
|
3542
|
+
},
|
|
3543
|
+
setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
|
|
3544
|
+
_httpAuthSchemeProvider = httpAuthSchemeProvider;
|
|
3545
|
+
},
|
|
3546
|
+
httpAuthSchemeProvider() {
|
|
3547
|
+
return _httpAuthSchemeProvider;
|
|
3548
|
+
},
|
|
3549
|
+
setCredentials(credentials) {
|
|
3550
|
+
_credentials = credentials;
|
|
3551
|
+
},
|
|
3552
|
+
credentials() {
|
|
3553
|
+
return _credentials;
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
};
|
|
3557
|
+
var resolveHttpAuthRuntimeConfig = (config) => {
|
|
3558
|
+
return {
|
|
3559
|
+
httpAuthSchemes: config.httpAuthSchemes(),
|
|
3560
|
+
httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
|
|
3561
|
+
credentials: config.credentials()
|
|
3562
|
+
};
|
|
3563
|
+
};
|
|
3564
|
+
|
|
3565
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeExtensions.js
|
|
3566
|
+
var resolveRuntimeExtensions = (runtimeConfig, extensions) => {
|
|
3567
|
+
const extensionConfiguration = Object.assign(getAwsRegionExtensionConfiguration(runtimeConfig), getDefaultExtensionConfiguration(runtimeConfig), getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
|
|
3568
|
+
extensions.forEach((extension) => extension.configure(extensionConfiguration));
|
|
3569
|
+
return Object.assign(runtimeConfig, resolveAwsRegionExtensionConfiguration(extensionConfiguration), resolveDefaultRuntimeConfig(extensionConfiguration), resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
|
|
3570
|
+
};
|
|
3571
|
+
|
|
3572
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/STSClient.js
|
|
3573
|
+
var STSClient = class extends Client {
|
|
3574
|
+
config;
|
|
3575
|
+
constructor(...[configuration]) {
|
|
3576
|
+
const _config_0 = getRuntimeConfig2(configuration || {});
|
|
3577
|
+
super(_config_0);
|
|
3578
|
+
this.initConfig = _config_0;
|
|
3579
|
+
const _config_1 = resolveClientEndpointParameters(_config_0);
|
|
3580
|
+
const _config_2 = resolveUserAgentConfig(_config_1);
|
|
3581
|
+
const _config_3 = resolveRetryConfig(_config_2);
|
|
3582
|
+
const _config_4 = resolveRegionConfig(_config_3);
|
|
3583
|
+
const _config_5 = resolveHostHeaderConfig(_config_4);
|
|
3584
|
+
const _config_6 = resolveEndpointConfig(_config_5);
|
|
3585
|
+
const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
|
|
3586
|
+
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
|
|
3587
|
+
this.config = _config_8;
|
|
3588
|
+
this.middlewareStack.use(getSchemaSerdePlugin(this.config));
|
|
3589
|
+
this.middlewareStack.use(getUserAgentPlugin(this.config));
|
|
3590
|
+
this.middlewareStack.use(getRetryPlugin(this.config));
|
|
3591
|
+
this.middlewareStack.use(getContentLengthPlugin(this.config));
|
|
3592
|
+
this.middlewareStack.use(getHostHeaderPlugin(this.config));
|
|
3593
|
+
this.middlewareStack.use(getLoggerPlugin(this.config));
|
|
3594
|
+
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
|
|
3595
|
+
this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
|
|
3596
|
+
httpAuthSchemeParametersProvider: defaultSTSHttpAuthSchemeParametersProvider,
|
|
3597
|
+
identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
|
|
3598
|
+
"aws.auth#sigv4": config.credentials
|
|
3599
|
+
})
|
|
3600
|
+
}));
|
|
3601
|
+
this.middlewareStack.use(getHttpSigningPlugin(this.config));
|
|
3602
|
+
}
|
|
3603
|
+
destroy() {
|
|
3604
|
+
super.destroy();
|
|
3605
|
+
}
|
|
3606
|
+
};
|
|
3607
|
+
|
|
3608
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/commands/AssumeRoleCommand.js
|
|
3609
|
+
var AssumeRoleCommand = class extends Command.classBuilder().ep(commonParams).m(function(Command2, cs, config, o2) {
|
|
3610
|
+
return [getEndpointPlugin(config, Command2.getEndpointParameterInstructions())];
|
|
3611
|
+
}).s("AWSSecurityTokenServiceV20110615", "AssumeRole", {}).n("STSClient", "AssumeRoleCommand").sc(AssumeRole$).build() {
|
|
3612
|
+
};
|
|
3613
|
+
|
|
3614
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/commands/AssumeRoleWithWebIdentityCommand.js
|
|
3615
|
+
var AssumeRoleWithWebIdentityCommand = class extends Command.classBuilder().ep(commonParams).m(function(Command2, cs, config, o2) {
|
|
3616
|
+
return [getEndpointPlugin(config, Command2.getEndpointParameterInstructions())];
|
|
3617
|
+
}).s("AWSSecurityTokenServiceV20110615", "AssumeRoleWithWebIdentity", {}).n("STSClient", "AssumeRoleWithWebIdentityCommand").sc(AssumeRoleWithWebIdentity$).build() {
|
|
3618
|
+
};
|
|
3619
|
+
|
|
3620
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/STS.js
|
|
3621
|
+
var commands = {
|
|
3622
|
+
AssumeRoleCommand,
|
|
3623
|
+
AssumeRoleWithWebIdentityCommand
|
|
3624
|
+
};
|
|
3625
|
+
var STS = class extends STSClient {
|
|
3626
|
+
};
|
|
3627
|
+
createAggregatedClient(commands, STS);
|
|
3628
|
+
|
|
3629
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/defaultStsRoleAssumers.js
|
|
3630
|
+
var getAccountIdFromAssumedRoleUser = (assumedRoleUser) => {
|
|
3631
|
+
if (typeof assumedRoleUser?.Arn === "string") {
|
|
3632
|
+
const arnComponents = assumedRoleUser.Arn.split(":");
|
|
3633
|
+
if (arnComponents.length > 4 && arnComponents[4] !== "") {
|
|
3634
|
+
return arnComponents[4];
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
return void 0;
|
|
3638
|
+
};
|
|
3639
|
+
var resolveRegion = async (_region, _parentRegion, credentialProviderLogger, loaderConfig = {}) => {
|
|
3640
|
+
const region = typeof _region === "function" ? await _region() : _region;
|
|
3641
|
+
const parentRegion = typeof _parentRegion === "function" ? await _parentRegion() : _parentRegion;
|
|
3642
|
+
let stsDefaultRegion = "";
|
|
3643
|
+
const resolvedRegion = region ?? parentRegion ?? (stsDefaultRegion = await stsRegionDefaultResolver(loaderConfig)());
|
|
3644
|
+
credentialProviderLogger?.debug?.("@aws-sdk/client-sts::resolveRegion", "accepting first of:", `${region} (credential provider clientConfig)`, `${parentRegion} (contextual client)`, `${stsDefaultRegion} (STS default: AWS_REGION, profile region, or us-east-1)`);
|
|
3645
|
+
return resolvedRegion;
|
|
3646
|
+
};
|
|
3647
|
+
var getDefaultRoleAssumer = (stsOptions, STSClient2) => {
|
|
3648
|
+
let stsClient;
|
|
3649
|
+
let closureSourceCreds;
|
|
3650
|
+
return async (sourceCreds, params) => {
|
|
3651
|
+
closureSourceCreds = sourceCreds;
|
|
3652
|
+
if (!stsClient) {
|
|
3653
|
+
const { logger = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
3654
|
+
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
3655
|
+
logger,
|
|
3656
|
+
profile
|
|
3657
|
+
});
|
|
3658
|
+
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
3659
|
+
stsClient = new STSClient2({
|
|
3660
|
+
...stsOptions,
|
|
3661
|
+
userAgentAppId,
|
|
3662
|
+
profile,
|
|
3663
|
+
credentialDefaultProvider: () => async () => closureSourceCreds,
|
|
3664
|
+
region: resolvedRegion,
|
|
3665
|
+
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
3666
|
+
logger
|
|
3667
|
+
});
|
|
3668
|
+
}
|
|
3669
|
+
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
|
|
3670
|
+
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
|
|
3671
|
+
throw new Error(`Invalid response from STS.assumeRole call with role ${params.RoleArn}`);
|
|
3672
|
+
}
|
|
3673
|
+
const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
|
|
3674
|
+
const credentials = {
|
|
3675
|
+
accessKeyId: Credentials.AccessKeyId,
|
|
3676
|
+
secretAccessKey: Credentials.SecretAccessKey,
|
|
3677
|
+
sessionToken: Credentials.SessionToken,
|
|
3678
|
+
expiration: Credentials.Expiration,
|
|
3679
|
+
...Credentials.CredentialScope && { credentialScope: Credentials.CredentialScope },
|
|
3680
|
+
...accountId && { accountId }
|
|
3681
|
+
};
|
|
3682
|
+
setCredentialFeature(credentials, "CREDENTIALS_STS_ASSUME_ROLE", "i");
|
|
3683
|
+
return credentials;
|
|
3684
|
+
};
|
|
3685
|
+
};
|
|
3686
|
+
var getDefaultRoleAssumerWithWebIdentity = (stsOptions, STSClient2) => {
|
|
3687
|
+
let stsClient;
|
|
3688
|
+
return async (params) => {
|
|
3689
|
+
if (!stsClient) {
|
|
3690
|
+
const { logger = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
3691
|
+
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
3692
|
+
logger,
|
|
3693
|
+
profile
|
|
3694
|
+
});
|
|
3695
|
+
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
3696
|
+
stsClient = new STSClient2({
|
|
3697
|
+
...stsOptions,
|
|
3698
|
+
userAgentAppId,
|
|
3699
|
+
profile,
|
|
3700
|
+
region: resolvedRegion,
|
|
3701
|
+
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
3702
|
+
logger
|
|
3703
|
+
});
|
|
3704
|
+
}
|
|
3705
|
+
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
|
|
3706
|
+
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
|
|
3707
|
+
throw new Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${params.RoleArn}`);
|
|
3708
|
+
}
|
|
3709
|
+
const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
|
|
3710
|
+
const credentials = {
|
|
3711
|
+
accessKeyId: Credentials.AccessKeyId,
|
|
3712
|
+
secretAccessKey: Credentials.SecretAccessKey,
|
|
3713
|
+
sessionToken: Credentials.SessionToken,
|
|
3714
|
+
expiration: Credentials.Expiration,
|
|
3715
|
+
...Credentials.CredentialScope && { credentialScope: Credentials.CredentialScope },
|
|
3716
|
+
...accountId && { accountId }
|
|
3717
|
+
};
|
|
3718
|
+
if (accountId) {
|
|
3719
|
+
setCredentialFeature(credentials, "RESOLVED_ACCOUNT_ID", "T");
|
|
3720
|
+
}
|
|
3721
|
+
setCredentialFeature(credentials, "CREDENTIALS_STS_ASSUME_ROLE_WEB_ID", "k");
|
|
3722
|
+
return credentials;
|
|
3723
|
+
};
|
|
3724
|
+
};
|
|
3725
|
+
var isH2 = (requestHandler) => {
|
|
3726
|
+
return requestHandler?.metadata?.handlerProtocol === "h2";
|
|
3727
|
+
};
|
|
3728
|
+
|
|
3729
|
+
// ../../node_modules/.pnpm/@aws-sdk+nested-clients@3.996.18_aws-crt@1.30.0/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/defaultRoleAssumers.js
|
|
3730
|
+
var getCustomizableStsClientCtor = (baseCtor, customizations) => {
|
|
3731
|
+
if (!customizations)
|
|
3732
|
+
return baseCtor;
|
|
3733
|
+
else
|
|
3734
|
+
return class CustomizableSTSClient extends baseCtor {
|
|
3735
|
+
constructor(config) {
|
|
3736
|
+
super(config);
|
|
3737
|
+
for (const customization of customizations) {
|
|
3738
|
+
this.middlewareStack.use(customization);
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
};
|
|
3742
|
+
};
|
|
3743
|
+
var getDefaultRoleAssumer2 = (stsOptions = {}, stsPlugins) => getDefaultRoleAssumer(stsOptions, getCustomizableStsClientCtor(STSClient, stsPlugins));
|
|
3744
|
+
var getDefaultRoleAssumerWithWebIdentity2 = (stsOptions = {}, stsPlugins) => getDefaultRoleAssumerWithWebIdentity(stsOptions, getCustomizableStsClientCtor(STSClient, stsPlugins));
|
|
3745
|
+
var decorateDefaultCredentialProvider = (provider) => (input) => provider({
|
|
3746
|
+
roleAssumer: getDefaultRoleAssumer2(input),
|
|
3747
|
+
roleAssumerWithWebIdentity: getDefaultRoleAssumerWithWebIdentity2(input),
|
|
3748
|
+
...input
|
|
3749
|
+
});
|
|
3750
|
+
export {
|
|
3751
|
+
Command as $Command,
|
|
3752
|
+
AssumeRole$,
|
|
3753
|
+
AssumeRoleCommand,
|
|
3754
|
+
AssumeRoleRequest$,
|
|
3755
|
+
AssumeRoleResponse$,
|
|
3756
|
+
AssumeRoleWithWebIdentity$,
|
|
3757
|
+
AssumeRoleWithWebIdentityCommand,
|
|
3758
|
+
AssumeRoleWithWebIdentityRequest$,
|
|
3759
|
+
AssumeRoleWithWebIdentityResponse$,
|
|
3760
|
+
AssumedRoleUser$,
|
|
3761
|
+
Credentials$,
|
|
3762
|
+
ExpiredTokenException,
|
|
3763
|
+
ExpiredTokenException$,
|
|
3764
|
+
IDPCommunicationErrorException,
|
|
3765
|
+
IDPCommunicationErrorException$,
|
|
3766
|
+
IDPRejectedClaimException,
|
|
3767
|
+
IDPRejectedClaimException$,
|
|
3768
|
+
InvalidIdentityTokenException,
|
|
3769
|
+
InvalidIdentityTokenException$,
|
|
3770
|
+
MalformedPolicyDocumentException,
|
|
3771
|
+
MalformedPolicyDocumentException$,
|
|
3772
|
+
PackedPolicyTooLargeException,
|
|
3773
|
+
PackedPolicyTooLargeException$,
|
|
3774
|
+
PolicyDescriptorType$,
|
|
3775
|
+
ProvidedContext$,
|
|
3776
|
+
RegionDisabledException,
|
|
3777
|
+
RegionDisabledException$,
|
|
3778
|
+
STS,
|
|
3779
|
+
STSClient,
|
|
3780
|
+
STSServiceException,
|
|
3781
|
+
STSServiceException$,
|
|
3782
|
+
Tag$,
|
|
3783
|
+
Client as __Client,
|
|
3784
|
+
decorateDefaultCredentialProvider,
|
|
3785
|
+
errorTypeRegistries,
|
|
3786
|
+
getDefaultRoleAssumer2 as getDefaultRoleAssumer,
|
|
3787
|
+
getDefaultRoleAssumerWithWebIdentity2 as getDefaultRoleAssumerWithWebIdentity
|
|
3788
|
+
};
|