agentv 3.11.1 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +15 -12
  2. package/dist/{agentv-provider-MIDKLYIH-6LIYKQRP.js → agentv-provider-NFFLXG5M-TJAWCWCX.js} +1 -2
  3. package/dist/{chunk-CKMAM2GD.js → chunk-6H4IAXQH.js} +435 -198
  4. package/dist/chunk-6H4IAXQH.js.map +1 -0
  5. package/dist/{chunk-OYD2NB55.js → chunk-7OHZAFND.js} +120 -29
  6. package/dist/chunk-7OHZAFND.js.map +1 -0
  7. package/dist/{chunk-V2S5CZU3.js → chunk-DJU4C6NS.js} +914 -529
  8. package/dist/chunk-DJU4C6NS.js.map +1 -0
  9. package/dist/{chunk-BAUNAXHT.js → chunk-XOSNETAV.js} +1 -1
  10. package/dist/cli.js +4 -6
  11. package/dist/cli.js.map +1 -1
  12. package/dist/{dist-VUPMLHIV.js → dist-SMKOBBFB.js} +3 -8
  13. package/dist/{esm-OJ2BXJK4-YKEI3Z7E.js → esm-5Q4BZALM-5REQWAUV.js} +2 -3
  14. package/dist/{esm-OJ2BXJK4-YKEI3Z7E.js.map → esm-5Q4BZALM-5REQWAUV.js.map} +1 -1
  15. package/dist/{esm-UYZ3HJBU.js → esm-CZAWIY6F.js} +2 -2
  16. package/dist/index.js +4 -6
  17. package/dist/{interactive-FZJANO4A.js → interactive-RV664PCR.js} +4 -6
  18. package/dist/{interactive-FZJANO4A.js.map → interactive-RV664PCR.js.map} +1 -1
  19. package/dist/{otlp-json-file-exporter-VN67MK3S-RQIM6EHY.js → otlp-json-file-exporter-77FDBRSY-EZAPHWP6.js} +1 -2
  20. package/dist/{src-PXDA7QIS.js → src-ML4D2MC2.js} +2 -2
  21. package/package.json +1 -1
  22. package/dist/chunk-2QFWRIYL.js +0 -186
  23. package/dist/chunk-2QFWRIYL.js.map +0 -1
  24. package/dist/chunk-2RMPO6LY.js +0 -747
  25. package/dist/chunk-2RMPO6LY.js.map +0 -1
  26. package/dist/chunk-3Q7WIXT4.js +0 -4846
  27. package/dist/chunk-3Q7WIXT4.js.map +0 -1
  28. package/dist/chunk-73O2DCJP.js +0 -1274
  29. package/dist/chunk-73O2DCJP.js.map +0 -1
  30. package/dist/chunk-AUKF3Y3W.js +0 -212
  31. package/dist/chunk-AUKF3Y3W.js.map +0 -1
  32. package/dist/chunk-BRH7SIDP.js +0 -133
  33. package/dist/chunk-BRH7SIDP.js.map +0 -1
  34. package/dist/chunk-BXM4I3BM.js +0 -526
  35. package/dist/chunk-BXM4I3BM.js.map +0 -1
  36. package/dist/chunk-CKMAM2GD.js.map +0 -1
  37. package/dist/chunk-FHTURHTY.js +0 -546
  38. package/dist/chunk-FHTURHTY.js.map +0 -1
  39. package/dist/chunk-GJFXQQWG.js +0 -21
  40. package/dist/chunk-GJFXQQWG.js.map +0 -1
  41. package/dist/chunk-HKMLG4KF.js +0 -38
  42. package/dist/chunk-HKMLG4KF.js.map +0 -1
  43. package/dist/chunk-JGU3PVA4.js +0 -133
  44. package/dist/chunk-JGU3PVA4.js.map +0 -1
  45. package/dist/chunk-JK6V4KVD.js +0 -114
  46. package/dist/chunk-JK6V4KVD.js.map +0 -1
  47. package/dist/chunk-LHU5FGVZ.js +0 -4804
  48. package/dist/chunk-LHU5FGVZ.js.map +0 -1
  49. package/dist/chunk-OL2WGI6E.js +0 -149
  50. package/dist/chunk-OL2WGI6E.js.map +0 -1
  51. package/dist/chunk-ONETZL6N.js +0 -15
  52. package/dist/chunk-ONETZL6N.js.map +0 -1
  53. package/dist/chunk-OYD2NB55.js.map +0 -1
  54. package/dist/chunk-QV4UGEN6.js +0 -320
  55. package/dist/chunk-QV4UGEN6.js.map +0 -1
  56. package/dist/chunk-QXLDKGF3.js +0 -46
  57. package/dist/chunk-QXLDKGF3.js.map +0 -1
  58. package/dist/chunk-U6VEM66A.js +0 -63
  59. package/dist/chunk-U6VEM66A.js.map +0 -1
  60. package/dist/chunk-UALXHIMX.js +0 -48
  61. package/dist/chunk-UALXHIMX.js.map +0 -1
  62. package/dist/chunk-UGXG73VF.js +0 -55
  63. package/dist/chunk-UGXG73VF.js.map +0 -1
  64. package/dist/chunk-UHP5KEDL.js +0 -38
  65. package/dist/chunk-UHP5KEDL.js.map +0 -1
  66. package/dist/chunk-V2S5CZU3.js.map +0 -1
  67. package/dist/chunk-WVSXFZWP.js +0 -204
  68. package/dist/chunk-WVSXFZWP.js.map +0 -1
  69. package/dist/chunk-XSUMCWKO.js +0 -30
  70. package/dist/chunk-XSUMCWKO.js.map +0 -1
  71. package/dist/chunk-XUO7ZEHU.js +0 -181
  72. package/dist/chunk-XUO7ZEHU.js.map +0 -1
  73. package/dist/chunk-YSGUX5JT.js +0 -1002
  74. package/dist/chunk-YSGUX5JT.js.map +0 -1
  75. package/dist/dist-3PCP5TNF-RYMVLILE.js +0 -25785
  76. package/dist/dist-3PCP5TNF-RYMVLILE.js.map +0 -1
  77. package/dist/dist-BOIN5LC5-T5UWUK43.js +0 -76113
  78. package/dist/dist-BOIN5LC5-T5UWUK43.js.map +0 -1
  79. package/dist/dist-LXPDQOBI-4V5J2WDS.js +0 -13
  80. package/dist/dist-LXPDQOBI-4V5J2WDS.js.map +0 -1
  81. package/dist/dist-es-4WSJUIYR-XKIX65IH.js +0 -69
  82. package/dist/dist-es-4WSJUIYR-XKIX65IH.js.map +0 -1
  83. package/dist/dist-es-7K7MKRME-CCMAZOQC.js +0 -355
  84. package/dist/dist-es-7K7MKRME-CCMAZOQC.js.map +0 -1
  85. package/dist/dist-es-B2RTOKRI-VWZHK5RE.js +0 -191
  86. package/dist/dist-es-B2RTOKRI-VWZHK5RE.js.map +0 -1
  87. package/dist/dist-es-HHZ4FAXA-CRERHWKB.js +0 -164
  88. package/dist/dist-es-HHZ4FAXA-CRERHWKB.js.map +0 -1
  89. package/dist/dist-es-HVS3RPMX-AYJ3DW4L.js +0 -355
  90. package/dist/dist-es-HVS3RPMX-AYJ3DW4L.js.map +0 -1
  91. package/dist/dist-es-L6R4FPI5-IKIRYN45.js +0 -472
  92. package/dist/dist-es-L6R4FPI5-IKIRYN45.js.map +0 -1
  93. package/dist/dist-es-SRVEB5QV-Q4CTC2HX.js +0 -24
  94. package/dist/dist-es-TRIVUKV4-2J47CDXR.js +0 -85
  95. package/dist/dist-es-TRIVUKV4-2J47CDXR.js.map +0 -1
  96. package/dist/dist-es-UEEUAV34-IZQDTAMW.js +0 -16
  97. package/dist/esm-UYZ3HJBU.js.map +0 -1
  98. package/dist/event-streams-NZADSH5J-6MOSNEV3.js +0 -247
  99. package/dist/event-streams-NZADSH5J-6MOSNEV3.js.map +0 -1
  100. package/dist/loadSso-IQZ5NB6C-DZJTORO3.js +0 -738
  101. package/dist/loadSso-IQZ5NB6C-DZJTORO3.js.map +0 -1
  102. package/dist/multipart-parser-IPYBIGNL-LFMNMM6D.js +0 -387
  103. package/dist/multipart-parser-IPYBIGNL-LFMNMM6D.js.map +0 -1
  104. package/dist/otlp-json-file-exporter-VN67MK3S-RQIM6EHY.js.map +0 -1
  105. package/dist/signin-2ANR4DVS-K5VGBEJF.js +0 -556
  106. package/dist/signin-2ANR4DVS-K5VGBEJF.js.map +0 -1
  107. package/dist/simple-trace-file-exporter-XWZTIZR2-4JKATE5G.js +0 -10
  108. package/dist/simple-trace-file-exporter-XWZTIZR2-4JKATE5G.js.map +0 -1
  109. package/dist/src-SLOMUG7K-CV5JG263.js +0 -1408
  110. package/dist/src-SLOMUG7K-CV5JG263.js.map +0 -1
  111. package/dist/sso-oidc-HVCDATR2-CYP3BM5O.js +0 -708
  112. package/dist/sso-oidc-HVCDATR2-CYP3BM5O.js.map +0 -1
  113. package/dist/sts-X7JGSP4H-PDAAYDDH.js +0 -2917
  114. package/dist/sts-X7JGSP4H-PDAAYDDH.js.map +0 -1
  115. package/dist/undici-VAR2VUJI-6PAOUXZC.js +0 -23388
  116. package/dist/undici-VAR2VUJI-6PAOUXZC.js.map +0 -1
  117. /package/dist/{agentv-provider-MIDKLYIH-6LIYKQRP.js.map → agentv-provider-NFFLXG5M-TJAWCWCX.js.map} +0 -0
  118. /package/dist/{chunk-BAUNAXHT.js.map → chunk-XOSNETAV.js.map} +0 -0
  119. /package/dist/{dist-VUPMLHIV.js.map → dist-SMKOBBFB.js.map} +0 -0
  120. /package/dist/{dist-es-SRVEB5QV-Q4CTC2HX.js.map → esm-CZAWIY6F.js.map} +0 -0
  121. /package/dist/{dist-es-UEEUAV34-IZQDTAMW.js.map → otlp-json-file-exporter-77FDBRSY-EZAPHWP6.js.map} +0 -0
  122. /package/dist/{src-PXDA7QIS.js.map → src-ML4D2MC2.js.map} +0 -0
@@ -1,2917 +0,0 @@
1
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import {
3
- NODE_REGION_CONFIG_FILE_OPTIONS as NODE_REGION_CONFIG_FILE_OPTIONS2,
4
- NODE_REGION_CONFIG_OPTIONS as NODE_REGION_CONFIG_OPTIONS2
5
- } from "./chunk-GJFXQQWG.js";
6
- import {
7
- loadConfig as loadConfig2
8
- } from "./chunk-JGU3PVA4.js";
9
- import "./chunk-AUKF3Y3W.js";
10
- import {
11
- createAggregatedClient,
12
- package_default
13
- } from "./chunk-XUO7ZEHU.js";
14
- import {
15
- EndpointCache,
16
- NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS,
17
- NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,
18
- NoAuthSigner,
19
- customEndpointFunctions,
20
- getHttpHandlerExtensionConfiguration,
21
- resolveEndpoint,
22
- resolveHttpHandlerRuntimeConfig,
23
- resolveRegionConfig
24
- } from "./chunk-BXM4I3BM.js";
25
- import {
26
- AwsSdkSigV4Signer,
27
- Client,
28
- Command,
29
- DEFAULT_RETRY_MODE,
30
- DefaultIdentityProviderConfig,
31
- FromStringShapeDeserializer,
32
- Hash,
33
- HttpProtocol,
34
- NODE_APP_ID_CONFIG_OPTIONS,
35
- NODE_AUTH_SCHEME_PREFERENCE_OPTIONS,
36
- NODE_MAX_ATTEMPT_CONFIG_OPTIONS,
37
- NODE_REGION_CONFIG_FILE_OPTIONS,
38
- NODE_REGION_CONFIG_OPTIONS,
39
- NODE_RETRY_MODE_CONFIG_OPTIONS,
40
- NoOpLogger,
41
- NormalizedSchema,
42
- NumericValue,
43
- ProtocolLib,
44
- SerdeContextConfig,
45
- ServiceException,
46
- TypeRegistry,
47
- UnionSerde,
48
- awsEndpointFunctions,
49
- calculateBodyLength,
50
- collectBody,
51
- createDefaultUserAgentProvider,
52
- deref,
53
- determineTimestampFormat,
54
- emitWarningIfUnsupportedVersion,
55
- emitWarningIfUnsupportedVersion2,
56
- extendedEncodeURIComponent,
57
- getAwsRegionExtensionConfiguration,
58
- getContentLengthPlugin,
59
- getDefaultExtensionConfiguration,
60
- getEndpointPlugin,
61
- getHostHeaderPlugin,
62
- getHttpAuthSchemeEndpointRuleSetPlugin,
63
- getHttpSigningPlugin,
64
- getLoggerPlugin,
65
- getRecursionDetectionPlugin,
66
- getRetryPlugin,
67
- getSchemaSerdePlugin,
68
- getSmithyContext,
69
- getUserAgentPlugin,
70
- loadConfigsForDefaultMode,
71
- normalizeProvider,
72
- resolveAwsRegionExtensionConfiguration,
73
- resolveAwsSdkSigV4Config,
74
- resolveDefaultRuntimeConfig,
75
- resolveDefaultsModeConfig,
76
- resolveEndpointConfig,
77
- resolveHostHeaderConfig,
78
- resolveRetryConfig,
79
- resolveUserAgentConfig,
80
- toBase642,
81
- toUtf82,
82
- v4
83
- } from "./chunk-3Q7WIXT4.js";
84
- import "./chunk-QXLDKGF3.js";
85
- import {
86
- dateToUtcString,
87
- fromBase64,
88
- toBase64
89
- } from "./chunk-QV4UGEN6.js";
90
- import {
91
- HttpRequest
92
- } from "./chunk-U6VEM66A.js";
93
- import {
94
- NodeHttpHandler,
95
- streamCollector
96
- } from "./chunk-2RMPO6LY.js";
97
- import {
98
- setCredentialFeature
99
- } from "./chunk-ONETZL6N.js";
100
- import {
101
- fromUtf8,
102
- toUtf8
103
- } from "./chunk-HKMLG4KF.js";
104
- import {
105
- loadConfig,
106
- parseUrl
107
- } from "./chunk-OL2WGI6E.js";
108
- import "./chunk-XSUMCWKO.js";
109
- import "./chunk-WVSXFZWP.js";
110
- import "./chunk-UHP5KEDL.js";
111
- import "./chunk-UGXG73VF.js";
112
- import "./chunk-5H446C7X.js";
113
-
114
- // ../../packages/core/dist/sts-X7JGSP4H.js
115
- var RpcProtocol = class extends HttpProtocol {
116
- async serializeRequest(operationSchema, input, context) {
117
- const serializer = this.serializer;
118
- const query = {};
119
- const headers = {};
120
- const endpoint = await context.endpoint();
121
- const ns = NormalizedSchema.of(operationSchema?.input);
122
- const schema = ns.getSchema();
123
- let payload;
124
- const request = new HttpRequest({
125
- protocol: "",
126
- hostname: "",
127
- port: void 0,
128
- path: "/",
129
- fragment: void 0,
130
- query,
131
- headers,
132
- body: void 0
133
- });
134
- if (endpoint) {
135
- this.updateServiceEndpoint(request, endpoint);
136
- this.setHostPrefix(request, operationSchema, input);
137
- }
138
- const _input = {
139
- ...input
140
- };
141
- if (input) {
142
- const eventStreamMember = ns.getEventStreamMember();
143
- if (eventStreamMember) {
144
- if (_input[eventStreamMember]) {
145
- const initialRequest = {};
146
- for (const [memberName, memberSchema] of ns.structIterator()) {
147
- if (memberName !== eventStreamMember && _input[memberName]) {
148
- serializer.write(memberSchema, _input[memberName]);
149
- initialRequest[memberName] = serializer.flush();
150
- }
151
- }
152
- payload = await this.serializeEventStream({
153
- eventStream: _input[eventStreamMember],
154
- requestSchema: ns,
155
- initialRequest
156
- });
157
- }
158
- } else {
159
- serializer.write(schema, _input);
160
- payload = serializer.flush();
161
- }
162
- }
163
- request.headers = headers;
164
- request.query = query;
165
- request.body = payload;
166
- request.method = "POST";
167
- return request;
168
- }
169
- async deserializeResponse(operationSchema, context, response) {
170
- const deserializer = this.deserializer;
171
- const ns = NormalizedSchema.of(operationSchema.output);
172
- const dataObject = {};
173
- if (response.statusCode >= 300) {
174
- const bytes = await collectBody(response.body, context);
175
- if (bytes.byteLength > 0) {
176
- Object.assign(dataObject, await deserializer.read(15, bytes));
177
- }
178
- await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
179
- throw new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.");
180
- }
181
- for (const header in response.headers) {
182
- const value = response.headers[header];
183
- delete response.headers[header];
184
- response.headers[header.toLowerCase()] = value;
185
- }
186
- const eventStreamMember = ns.getEventStreamMember();
187
- if (eventStreamMember) {
188
- dataObject[eventStreamMember] = await this.deserializeEventStream({
189
- response,
190
- responseSchema: ns,
191
- initialResponseContainer: dataObject
192
- });
193
- } else {
194
- const bytes = await collectBody(response.body, context);
195
- if (bytes.byteLength > 0) {
196
- Object.assign(dataObject, await deserializer.read(ns, bytes));
197
- }
198
- }
199
- dataObject.$metadata = this.deserializeMetadata(response);
200
- return dataObject;
201
- }
202
- };
203
- var getValueFromTextNode = (obj) => {
204
- const textNodeName = "#text";
205
- for (const key in obj) {
206
- if (obj.hasOwnProperty(key) && obj[key][textNodeName] !== void 0) {
207
- obj[key] = obj[key][textNodeName];
208
- } else if (typeof obj[key] === "object" && obj[key] !== null) {
209
- obj[key] = getValueFromTextNode(obj[key]);
210
- }
211
- }
212
- return obj;
213
- };
214
- 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";
215
- var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
216
- var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
217
- var regexName = new RegExp("^" + nameRegexp + "$");
218
- function getAllMatches(string, regex) {
219
- const matches = [];
220
- let match = regex.exec(string);
221
- while (match) {
222
- const allmatches = [];
223
- allmatches.startIndex = regex.lastIndex - match[0].length;
224
- const len = match.length;
225
- for (let index = 0; index < len; index++) {
226
- allmatches.push(match[index]);
227
- }
228
- matches.push(allmatches);
229
- match = regex.exec(string);
230
- }
231
- return matches;
232
- }
233
- var isName = function(string) {
234
- const match = regexName.exec(string);
235
- return !(match === null || typeof match === "undefined");
236
- };
237
- function isExist(v2) {
238
- return typeof v2 !== "undefined";
239
- }
240
- var defaultOptions = {
241
- allowBooleanAttributes: false,
242
- //A tag can have attributes without any value
243
- unpairedTags: []
244
- };
245
- function validate(xmlData, options) {
246
- options = Object.assign({}, defaultOptions, options);
247
- const tags = [];
248
- let tagFound = false;
249
- let reachedRoot = false;
250
- if (xmlData[0] === "\uFEFF") {
251
- xmlData = xmlData.substr(1);
252
- }
253
- for (let i2 = 0; i2 < xmlData.length; i2++) {
254
- if (xmlData[i2] === "<" && xmlData[i2 + 1] === "?") {
255
- i2 += 2;
256
- i2 = readPI(xmlData, i2);
257
- if (i2.err) return i2;
258
- } else if (xmlData[i2] === "<") {
259
- let tagStartPos = i2;
260
- i2++;
261
- if (xmlData[i2] === "!") {
262
- i2 = readCommentAndCDATA(xmlData, i2);
263
- continue;
264
- } else {
265
- let closingTag = false;
266
- if (xmlData[i2] === "/") {
267
- closingTag = true;
268
- i2++;
269
- }
270
- let tagName = "";
271
- for (; i2 < xmlData.length && xmlData[i2] !== ">" && xmlData[i2] !== " " && xmlData[i2] !== " " && xmlData[i2] !== "\n" && xmlData[i2] !== "\r"; i2++) {
272
- tagName += xmlData[i2];
273
- }
274
- tagName = tagName.trim();
275
- if (tagName[tagName.length - 1] === "/") {
276
- tagName = tagName.substring(0, tagName.length - 1);
277
- i2--;
278
- }
279
- if (!validateTagName(tagName)) {
280
- let msg;
281
- if (tagName.trim().length === 0) {
282
- msg = "Invalid space after '<'.";
283
- } else {
284
- msg = "Tag '" + tagName + "' is an invalid name.";
285
- }
286
- return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i2));
287
- }
288
- const result = readAttributeStr(xmlData, i2);
289
- if (result === false) {
290
- return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i2));
291
- }
292
- let attrStr = result.value;
293
- i2 = result.index;
294
- if (attrStr[attrStr.length - 1] === "/") {
295
- const attrStrStart = i2 - attrStr.length;
296
- attrStr = attrStr.substring(0, attrStr.length - 1);
297
- const isValid = validateAttributeString(attrStr, options);
298
- if (isValid === true) {
299
- tagFound = true;
300
- } else {
301
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
302
- }
303
- } else if (closingTag) {
304
- if (!result.tagClosed) {
305
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i2));
306
- } else if (attrStr.trim().length > 0) {
307
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
308
- } else if (tags.length === 0) {
309
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
310
- } else {
311
- const otg = tags.pop();
312
- if (tagName !== otg.tagName) {
313
- let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
314
- return getErrorObject(
315
- "InvalidTag",
316
- "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
317
- getLineNumberForPosition(xmlData, tagStartPos)
318
- );
319
- }
320
- if (tags.length == 0) {
321
- reachedRoot = true;
322
- }
323
- }
324
- } else {
325
- const isValid = validateAttributeString(attrStr, options);
326
- if (isValid !== true) {
327
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i2 - attrStr.length + isValid.err.line));
328
- }
329
- if (reachedRoot === true) {
330
- return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i2));
331
- } else if (options.unpairedTags.indexOf(tagName) !== -1) {
332
- } else {
333
- tags.push({ tagName, tagStartPos });
334
- }
335
- tagFound = true;
336
- }
337
- for (i2++; i2 < xmlData.length; i2++) {
338
- if (xmlData[i2] === "<") {
339
- if (xmlData[i2 + 1] === "!") {
340
- i2++;
341
- i2 = readCommentAndCDATA(xmlData, i2);
342
- continue;
343
- } else if (xmlData[i2 + 1] === "?") {
344
- i2 = readPI(xmlData, ++i2);
345
- if (i2.err) return i2;
346
- } else {
347
- break;
348
- }
349
- } else if (xmlData[i2] === "&") {
350
- const afterAmp = validateAmpersand(xmlData, i2);
351
- if (afterAmp == -1)
352
- return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i2));
353
- i2 = afterAmp;
354
- } else {
355
- if (reachedRoot === true && !isWhiteSpace(xmlData[i2])) {
356
- return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i2));
357
- }
358
- }
359
- }
360
- if (xmlData[i2] === "<") {
361
- i2--;
362
- }
363
- }
364
- } else {
365
- if (isWhiteSpace(xmlData[i2])) {
366
- continue;
367
- }
368
- return getErrorObject("InvalidChar", "char '" + xmlData[i2] + "' is not expected.", getLineNumberForPosition(xmlData, i2));
369
- }
370
- }
371
- if (!tagFound) {
372
- return getErrorObject("InvalidXml", "Start tag expected.", 1);
373
- } else if (tags.length == 1) {
374
- return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
375
- } else if (tags.length > 0) {
376
- return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t2) => t2.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
377
- }
378
- return true;
379
- }
380
- function isWhiteSpace(char) {
381
- return char === " " || char === " " || char === "\n" || char === "\r";
382
- }
383
- function readPI(xmlData, i2) {
384
- const start = i2;
385
- for (; i2 < xmlData.length; i2++) {
386
- if (xmlData[i2] == "?" || xmlData[i2] == " ") {
387
- const tagname = xmlData.substr(start, i2 - start);
388
- if (i2 > 5 && tagname === "xml") {
389
- return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i2));
390
- } else if (xmlData[i2] == "?" && xmlData[i2 + 1] == ">") {
391
- i2++;
392
- break;
393
- } else {
394
- continue;
395
- }
396
- }
397
- }
398
- return i2;
399
- }
400
- function readCommentAndCDATA(xmlData, i2) {
401
- if (xmlData.length > i2 + 5 && xmlData[i2 + 1] === "-" && xmlData[i2 + 2] === "-") {
402
- for (i2 += 3; i2 < xmlData.length; i2++) {
403
- if (xmlData[i2] === "-" && xmlData[i2 + 1] === "-" && xmlData[i2 + 2] === ">") {
404
- i2 += 2;
405
- break;
406
- }
407
- }
408
- } 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") {
409
- let angleBracketsCount = 1;
410
- for (i2 += 8; i2 < xmlData.length; i2++) {
411
- if (xmlData[i2] === "<") {
412
- angleBracketsCount++;
413
- } else if (xmlData[i2] === ">") {
414
- angleBracketsCount--;
415
- if (angleBracketsCount === 0) {
416
- break;
417
- }
418
- }
419
- }
420
- } 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] === "[") {
421
- for (i2 += 8; i2 < xmlData.length; i2++) {
422
- if (xmlData[i2] === "]" && xmlData[i2 + 1] === "]" && xmlData[i2 + 2] === ">") {
423
- i2 += 2;
424
- break;
425
- }
426
- }
427
- }
428
- return i2;
429
- }
430
- var doubleQuote = '"';
431
- var singleQuote = "'";
432
- function readAttributeStr(xmlData, i2) {
433
- let attrStr = "";
434
- let startChar = "";
435
- let tagClosed = false;
436
- for (; i2 < xmlData.length; i2++) {
437
- if (xmlData[i2] === doubleQuote || xmlData[i2] === singleQuote) {
438
- if (startChar === "") {
439
- startChar = xmlData[i2];
440
- } else if (startChar !== xmlData[i2]) {
441
- } else {
442
- startChar = "";
443
- }
444
- } else if (xmlData[i2] === ">") {
445
- if (startChar === "") {
446
- tagClosed = true;
447
- break;
448
- }
449
- }
450
- attrStr += xmlData[i2];
451
- }
452
- if (startChar !== "") {
453
- return false;
454
- }
455
- return {
456
- value: attrStr,
457
- index: i2,
458
- tagClosed
459
- };
460
- }
461
- var validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
462
- function validateAttributeString(attrStr, options) {
463
- const matches = getAllMatches(attrStr, validAttrStrRegxp);
464
- const attrNames = {};
465
- for (let i2 = 0; i2 < matches.length; i2++) {
466
- if (matches[i2][1].length === 0) {
467
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i2][2] + "' has no space in starting.", getPositionFromMatch(matches[i2]));
468
- } else if (matches[i2][3] !== void 0 && matches[i2][4] === void 0) {
469
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i2][2] + "' is without value.", getPositionFromMatch(matches[i2]));
470
- } else if (matches[i2][3] === void 0 && !options.allowBooleanAttributes) {
471
- return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i2][2] + "' is not allowed.", getPositionFromMatch(matches[i2]));
472
- }
473
- const attrName = matches[i2][2];
474
- if (!validateAttrName(attrName)) {
475
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i2]));
476
- }
477
- if (!attrNames.hasOwnProperty(attrName)) {
478
- attrNames[attrName] = 1;
479
- } else {
480
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i2]));
481
- }
482
- }
483
- return true;
484
- }
485
- function validateNumberAmpersand(xmlData, i2) {
486
- let re = /\d/;
487
- if (xmlData[i2] === "x") {
488
- i2++;
489
- re = /[\da-fA-F]/;
490
- }
491
- for (; i2 < xmlData.length; i2++) {
492
- if (xmlData[i2] === ";")
493
- return i2;
494
- if (!xmlData[i2].match(re))
495
- break;
496
- }
497
- return -1;
498
- }
499
- function validateAmpersand(xmlData, i2) {
500
- i2++;
501
- if (xmlData[i2] === ";")
502
- return -1;
503
- if (xmlData[i2] === "#") {
504
- i2++;
505
- return validateNumberAmpersand(xmlData, i2);
506
- }
507
- let count = 0;
508
- for (; i2 < xmlData.length; i2++, count++) {
509
- if (xmlData[i2].match(/\w/) && count < 20)
510
- continue;
511
- if (xmlData[i2] === ";")
512
- break;
513
- return -1;
514
- }
515
- return i2;
516
- }
517
- function getErrorObject(code, message, lineNumber) {
518
- return {
519
- err: {
520
- code,
521
- msg: message,
522
- line: lineNumber.line || lineNumber,
523
- col: lineNumber.col
524
- }
525
- };
526
- }
527
- function validateAttrName(attrName) {
528
- return isName(attrName);
529
- }
530
- function validateTagName(tagname) {
531
- return isName(tagname);
532
- }
533
- function getLineNumberForPosition(xmlData, index) {
534
- const lines = xmlData.substring(0, index).split(/\r?\n/);
535
- return {
536
- line: lines.length,
537
- // column number is last line's length + 1, because column numbering starts at 1:
538
- col: lines[lines.length - 1].length + 1
539
- };
540
- }
541
- function getPositionFromMatch(match) {
542
- return match.startIndex + match[1].length;
543
- }
544
- var defaultOptions2 = {
545
- preserveOrder: false,
546
- attributeNamePrefix: "@_",
547
- attributesGroupName: false,
548
- textNodeName: "#text",
549
- ignoreAttributes: true,
550
- removeNSPrefix: false,
551
- // remove NS from tag name or attribute name if true
552
- allowBooleanAttributes: false,
553
- //a tag can have attributes without any value
554
- //ignoreRootElement : false,
555
- parseTagValue: true,
556
- parseAttributeValue: false,
557
- trimValues: true,
558
- //Trim string values of tag and attributes
559
- cdataPropName: false,
560
- numberParseOptions: {
561
- hex: true,
562
- leadingZeros: true,
563
- eNotation: true
564
- },
565
- tagValueProcessor: function(tagName, val) {
566
- return val;
567
- },
568
- attributeValueProcessor: function(attrName, val) {
569
- return val;
570
- },
571
- stopNodes: [],
572
- //nested tags will not be parsed even for errors
573
- alwaysCreateTextNode: false,
574
- isArray: () => false,
575
- commentPropName: false,
576
- unpairedTags: [],
577
- processEntities: true,
578
- htmlEntities: false,
579
- ignoreDeclaration: false,
580
- ignorePiTags: false,
581
- transformTagName: false,
582
- transformAttributeName: false,
583
- updateTag: function(tagName, jPath, attrs) {
584
- return tagName;
585
- },
586
- // skipEmptyListItem: false
587
- captureMetaData: false
588
- };
589
- function normalizeProcessEntities(value) {
590
- if (typeof value === "boolean") {
591
- return {
592
- enabled: value,
593
- // true or false
594
- maxEntitySize: 1e4,
595
- maxExpansionDepth: 10,
596
- maxTotalExpansions: 1e3,
597
- maxExpandedLength: 1e5,
598
- allowedTags: null,
599
- tagFilter: null
600
- };
601
- }
602
- if (typeof value === "object" && value !== null) {
603
- return {
604
- enabled: value.enabled !== false,
605
- // default true if not specified
606
- maxEntitySize: value.maxEntitySize ?? 1e4,
607
- maxExpansionDepth: value.maxExpansionDepth ?? 10,
608
- maxTotalExpansions: value.maxTotalExpansions ?? 1e3,
609
- maxExpandedLength: value.maxExpandedLength ?? 1e5,
610
- allowedTags: value.allowedTags ?? null,
611
- tagFilter: value.tagFilter ?? null
612
- };
613
- }
614
- return normalizeProcessEntities(true);
615
- }
616
- var buildOptions = function(options) {
617
- const built = Object.assign({}, defaultOptions2, options);
618
- built.processEntities = normalizeProcessEntities(built.processEntities);
619
- return built;
620
- };
621
- var METADATA_SYMBOL;
622
- if (typeof Symbol !== "function") {
623
- METADATA_SYMBOL = "@@xmlMetadata";
624
- } else {
625
- METADATA_SYMBOL = Symbol("XML Node Metadata");
626
- }
627
- var XmlNode = class {
628
- constructor(tagname) {
629
- this.tagname = tagname;
630
- this.child = [];
631
- this[":@"] = {};
632
- }
633
- add(key, val) {
634
- if (key === "__proto__") key = "#__proto__";
635
- this.child.push({ [key]: val });
636
- }
637
- addChild(node, startIndex) {
638
- if (node.tagname === "__proto__") node.tagname = "#__proto__";
639
- if (node[":@"] && Object.keys(node[":@"]).length > 0) {
640
- this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
641
- } else {
642
- this.child.push({ [node.tagname]: node.child });
643
- }
644
- if (startIndex !== void 0) {
645
- this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
646
- }
647
- }
648
- /** symbol used for metadata */
649
- static getMetaDataSymbol() {
650
- return METADATA_SYMBOL;
651
- }
652
- };
653
- var DocTypeReader = class {
654
- constructor(options) {
655
- this.suppressValidationErr = !options;
656
- this.options = options;
657
- }
658
- readDocType(xmlData, i2) {
659
- const entities = {};
660
- 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") {
661
- i2 = i2 + 9;
662
- let angleBracketsCount = 1;
663
- let hasBody = false, comment = false;
664
- let exp = "";
665
- for (; i2 < xmlData.length; i2++) {
666
- if (xmlData[i2] === "<" && !comment) {
667
- if (hasBody && hasSeq(xmlData, "!ENTITY", i2)) {
668
- i2 += 7;
669
- let entityName, val;
670
- [entityName, val, i2] = this.readEntityExp(xmlData, i2 + 1, this.suppressValidationErr);
671
- if (val.indexOf("&") === -1) {
672
- const escaped = entityName.replace(/[.\-+*:]/g, "\\.");
673
- entities[entityName] = {
674
- regx: RegExp(`&${escaped};`, "g"),
675
- val
676
- };
677
- }
678
- } else if (hasBody && hasSeq(xmlData, "!ELEMENT", i2)) {
679
- i2 += 8;
680
- const { index } = this.readElementExp(xmlData, i2 + 1);
681
- i2 = index;
682
- } else if (hasBody && hasSeq(xmlData, "!ATTLIST", i2)) {
683
- i2 += 8;
684
- } else if (hasBody && hasSeq(xmlData, "!NOTATION", i2)) {
685
- i2 += 9;
686
- const { index } = this.readNotationExp(xmlData, i2 + 1, this.suppressValidationErr);
687
- i2 = index;
688
- } else if (hasSeq(xmlData, "!--", i2)) comment = true;
689
- else throw new Error(`Invalid DOCTYPE`);
690
- angleBracketsCount++;
691
- exp = "";
692
- } else if (xmlData[i2] === ">") {
693
- if (comment) {
694
- if (xmlData[i2 - 1] === "-" && xmlData[i2 - 2] === "-") {
695
- comment = false;
696
- angleBracketsCount--;
697
- }
698
- } else {
699
- angleBracketsCount--;
700
- }
701
- if (angleBracketsCount === 0) {
702
- break;
703
- }
704
- } else if (xmlData[i2] === "[") {
705
- hasBody = true;
706
- } else {
707
- exp += xmlData[i2];
708
- }
709
- }
710
- if (angleBracketsCount !== 0) {
711
- throw new Error(`Unclosed DOCTYPE`);
712
- }
713
- } else {
714
- throw new Error(`Invalid Tag instead of DOCTYPE`);
715
- }
716
- return { entities, i: i2 };
717
- }
718
- readEntityExp(xmlData, i2) {
719
- i2 = skipWhitespace(xmlData, i2);
720
- let entityName = "";
721
- while (i2 < xmlData.length && !/\s/.test(xmlData[i2]) && xmlData[i2] !== '"' && xmlData[i2] !== "'") {
722
- entityName += xmlData[i2];
723
- i2++;
724
- }
725
- validateEntityName(entityName);
726
- i2 = skipWhitespace(xmlData, i2);
727
- if (!this.suppressValidationErr) {
728
- if (xmlData.substring(i2, i2 + 6).toUpperCase() === "SYSTEM") {
729
- throw new Error("External entities are not supported");
730
- } else if (xmlData[i2] === "%") {
731
- throw new Error("Parameter entities are not supported");
732
- }
733
- }
734
- let entityValue = "";
735
- [i2, entityValue] = this.readIdentifierVal(xmlData, i2, "entity");
736
- if (this.options.enabled !== false && this.options.maxEntitySize && entityValue.length > this.options.maxEntitySize) {
737
- throw new Error(
738
- `Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
739
- );
740
- }
741
- i2--;
742
- return [entityName, entityValue, i2];
743
- }
744
- readNotationExp(xmlData, i2) {
745
- i2 = skipWhitespace(xmlData, i2);
746
- let notationName = "";
747
- while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
748
- notationName += xmlData[i2];
749
- i2++;
750
- }
751
- !this.suppressValidationErr && validateEntityName(notationName);
752
- i2 = skipWhitespace(xmlData, i2);
753
- const identifierType = xmlData.substring(i2, i2 + 6).toUpperCase();
754
- if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
755
- throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
756
- }
757
- i2 += identifierType.length;
758
- i2 = skipWhitespace(xmlData, i2);
759
- let publicIdentifier = null;
760
- let systemIdentifier = null;
761
- if (identifierType === "PUBLIC") {
762
- [i2, publicIdentifier] = this.readIdentifierVal(xmlData, i2, "publicIdentifier");
763
- i2 = skipWhitespace(xmlData, i2);
764
- if (xmlData[i2] === '"' || xmlData[i2] === "'") {
765
- [i2, systemIdentifier] = this.readIdentifierVal(xmlData, i2, "systemIdentifier");
766
- }
767
- } else if (identifierType === "SYSTEM") {
768
- [i2, systemIdentifier] = this.readIdentifierVal(xmlData, i2, "systemIdentifier");
769
- if (!this.suppressValidationErr && !systemIdentifier) {
770
- throw new Error("Missing mandatory system identifier for SYSTEM notation");
771
- }
772
- }
773
- return { notationName, publicIdentifier, systemIdentifier, index: --i2 };
774
- }
775
- readIdentifierVal(xmlData, i2, type) {
776
- let identifierVal = "";
777
- const startChar = xmlData[i2];
778
- if (startChar !== '"' && startChar !== "'") {
779
- throw new Error(`Expected quoted string, found "${startChar}"`);
780
- }
781
- i2++;
782
- while (i2 < xmlData.length && xmlData[i2] !== startChar) {
783
- identifierVal += xmlData[i2];
784
- i2++;
785
- }
786
- if (xmlData[i2] !== startChar) {
787
- throw new Error(`Unterminated ${type} value`);
788
- }
789
- i2++;
790
- return [i2, identifierVal];
791
- }
792
- readElementExp(xmlData, i2) {
793
- i2 = skipWhitespace(xmlData, i2);
794
- let elementName = "";
795
- while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
796
- elementName += xmlData[i2];
797
- i2++;
798
- }
799
- if (!this.suppressValidationErr && !isName(elementName)) {
800
- throw new Error(`Invalid element name: "${elementName}"`);
801
- }
802
- i2 = skipWhitespace(xmlData, i2);
803
- let contentModel = "";
804
- if (xmlData[i2] === "E" && hasSeq(xmlData, "MPTY", i2)) i2 += 4;
805
- else if (xmlData[i2] === "A" && hasSeq(xmlData, "NY", i2)) i2 += 2;
806
- else if (xmlData[i2] === "(") {
807
- i2++;
808
- while (i2 < xmlData.length && xmlData[i2] !== ")") {
809
- contentModel += xmlData[i2];
810
- i2++;
811
- }
812
- if (xmlData[i2] !== ")") {
813
- throw new Error("Unterminated content model");
814
- }
815
- } else if (!this.suppressValidationErr) {
816
- throw new Error(`Invalid Element Expression, found "${xmlData[i2]}"`);
817
- }
818
- return {
819
- elementName,
820
- contentModel: contentModel.trim(),
821
- index: i2
822
- };
823
- }
824
- readAttlistExp(xmlData, i2) {
825
- i2 = skipWhitespace(xmlData, i2);
826
- let elementName = "";
827
- while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
828
- elementName += xmlData[i2];
829
- i2++;
830
- }
831
- validateEntityName(elementName);
832
- i2 = skipWhitespace(xmlData, i2);
833
- let attributeName = "";
834
- while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
835
- attributeName += xmlData[i2];
836
- i2++;
837
- }
838
- if (!validateEntityName(attributeName)) {
839
- throw new Error(`Invalid attribute name: "${attributeName}"`);
840
- }
841
- i2 = skipWhitespace(xmlData, i2);
842
- let attributeType = "";
843
- if (xmlData.substring(i2, i2 + 8).toUpperCase() === "NOTATION") {
844
- attributeType = "NOTATION";
845
- i2 += 8;
846
- i2 = skipWhitespace(xmlData, i2);
847
- if (xmlData[i2] !== "(") {
848
- throw new Error(`Expected '(', found "${xmlData[i2]}"`);
849
- }
850
- i2++;
851
- let allowedNotations = [];
852
- while (i2 < xmlData.length && xmlData[i2] !== ")") {
853
- let notation = "";
854
- while (i2 < xmlData.length && xmlData[i2] !== "|" && xmlData[i2] !== ")") {
855
- notation += xmlData[i2];
856
- i2++;
857
- }
858
- notation = notation.trim();
859
- if (!validateEntityName(notation)) {
860
- throw new Error(`Invalid notation name: "${notation}"`);
861
- }
862
- allowedNotations.push(notation);
863
- if (xmlData[i2] === "|") {
864
- i2++;
865
- i2 = skipWhitespace(xmlData, i2);
866
- }
867
- }
868
- if (xmlData[i2] !== ")") {
869
- throw new Error("Unterminated list of notations");
870
- }
871
- i2++;
872
- attributeType += " (" + allowedNotations.join("|") + ")";
873
- } else {
874
- while (i2 < xmlData.length && !/\s/.test(xmlData[i2])) {
875
- attributeType += xmlData[i2];
876
- i2++;
877
- }
878
- const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
879
- if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
880
- throw new Error(`Invalid attribute type: "${attributeType}"`);
881
- }
882
- }
883
- i2 = skipWhitespace(xmlData, i2);
884
- let defaultValue = "";
885
- if (xmlData.substring(i2, i2 + 8).toUpperCase() === "#REQUIRED") {
886
- defaultValue = "#REQUIRED";
887
- i2 += 8;
888
- } else if (xmlData.substring(i2, i2 + 7).toUpperCase() === "#IMPLIED") {
889
- defaultValue = "#IMPLIED";
890
- i2 += 7;
891
- } else {
892
- [i2, defaultValue] = this.readIdentifierVal(xmlData, i2, "ATTLIST");
893
- }
894
- return {
895
- elementName,
896
- attributeName,
897
- attributeType,
898
- defaultValue,
899
- index: i2
900
- };
901
- }
902
- };
903
- var skipWhitespace = (data, index) => {
904
- while (index < data.length && /\s/.test(data[index])) {
905
- index++;
906
- }
907
- return index;
908
- };
909
- function hasSeq(data, seq, i2) {
910
- for (let j2 = 0; j2 < seq.length; j2++) {
911
- if (seq[j2] !== data[i2 + j2 + 1]) return false;
912
- }
913
- return true;
914
- }
915
- function validateEntityName(name) {
916
- if (isName(name))
917
- return name;
918
- else
919
- throw new Error(`Invalid entity name ${name}`);
920
- }
921
- var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
922
- var numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
923
- var consider = {
924
- hex: true,
925
- // oct: false,
926
- leadingZeros: true,
927
- decimalPoint: ".",
928
- eNotation: true
929
- //skipLike: /regex/
930
- };
931
- function toNumber(str, options = {}) {
932
- options = Object.assign({}, consider, options);
933
- if (!str || typeof str !== "string") return str;
934
- let trimmedStr = str.trim();
935
- if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
936
- else if (str === "0") return 0;
937
- else if (options.hex && hexRegex.test(trimmedStr)) {
938
- return parse_int(trimmedStr, 16);
939
- } else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
940
- return resolveEnotation(str, trimmedStr, options);
941
- } else {
942
- const match = numRegex.exec(trimmedStr);
943
- if (match) {
944
- const sign = match[1] || "";
945
- const leadingZeros = match[2];
946
- let numTrimmedByZeros = trimZeros(match[3]);
947
- const decimalAdjacentToLeadingZeros = sign ? (
948
- // 0., -00., 000.
949
- str[leadingZeros.length + 1] === "."
950
- ) : str[leadingZeros.length] === ".";
951
- if (!options.leadingZeros && (leadingZeros.length > 1 || leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros)) {
952
- return str;
953
- } else {
954
- const num = Number(trimmedStr);
955
- const parsedStr = String(num);
956
- if (num === 0) return num;
957
- if (parsedStr.search(/[eE]/) !== -1) {
958
- if (options.eNotation) return num;
959
- else return str;
960
- } else if (trimmedStr.indexOf(".") !== -1) {
961
- if (parsedStr === "0") return num;
962
- else if (parsedStr === numTrimmedByZeros) return num;
963
- else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
964
- else return str;
965
- }
966
- let n2 = leadingZeros ? numTrimmedByZeros : trimmedStr;
967
- if (leadingZeros) {
968
- return n2 === parsedStr || sign + n2 === parsedStr ? num : str;
969
- } else {
970
- return n2 === parsedStr || n2 === sign + parsedStr ? num : str;
971
- }
972
- }
973
- } else {
974
- return str;
975
- }
976
- }
977
- }
978
- var eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
979
- function resolveEnotation(str, trimmedStr, options) {
980
- if (!options.eNotation) return str;
981
- const notation = trimmedStr.match(eNotationRegx);
982
- if (notation) {
983
- let sign = notation[1] || "";
984
- const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
985
- const leadingZeros = notation[2];
986
- const eAdjacentToLeadingZeros = sign ? (
987
- // 0E.
988
- str[leadingZeros.length + 1] === eChar
989
- ) : str[leadingZeros.length] === eChar;
990
- if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
991
- else if (leadingZeros.length === 1 && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
992
- return Number(trimmedStr);
993
- } else if (options.leadingZeros && !eAdjacentToLeadingZeros) {
994
- trimmedStr = (notation[1] || "") + notation[3];
995
- return Number(trimmedStr);
996
- } else return str;
997
- } else {
998
- return str;
999
- }
1000
- }
1001
- function trimZeros(numStr) {
1002
- if (numStr && numStr.indexOf(".") !== -1) {
1003
- numStr = numStr.replace(/0+$/, "");
1004
- if (numStr === ".") numStr = "0";
1005
- else if (numStr[0] === ".") numStr = "0" + numStr;
1006
- else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
1007
- return numStr;
1008
- }
1009
- return numStr;
1010
- }
1011
- function parse_int(numStr, base) {
1012
- if (parseInt) return parseInt(numStr, base);
1013
- else if (Number.parseInt) return Number.parseInt(numStr, base);
1014
- else if (window && window.parseInt) return window.parseInt(numStr, base);
1015
- else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
1016
- }
1017
- function getIgnoreAttributesFn(ignoreAttributes) {
1018
- if (typeof ignoreAttributes === "function") {
1019
- return ignoreAttributes;
1020
- }
1021
- if (Array.isArray(ignoreAttributes)) {
1022
- return (attrName) => {
1023
- for (const pattern of ignoreAttributes) {
1024
- if (typeof pattern === "string" && attrName === pattern) {
1025
- return true;
1026
- }
1027
- if (pattern instanceof RegExp && pattern.test(attrName)) {
1028
- return true;
1029
- }
1030
- }
1031
- };
1032
- }
1033
- return () => false;
1034
- }
1035
- var OrderedObjParser = class {
1036
- constructor(options) {
1037
- this.options = options;
1038
- this.currentNode = null;
1039
- this.tagsNodeStack = [];
1040
- this.docTypeEntities = {};
1041
- this.lastEntities = {
1042
- "apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
1043
- "gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
1044
- "lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
1045
- "quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
1046
- };
1047
- this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
1048
- this.htmlEntities = {
1049
- "space": { regex: /&(nbsp|#160);/g, val: " " },
1050
- // "lt" : { regex: /&(lt|#60);/g, val: "<" },
1051
- // "gt" : { regex: /&(gt|#62);/g, val: ">" },
1052
- // "amp" : { regex: /&(amp|#38);/g, val: "&" },
1053
- // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
1054
- // "apos" : { regex: /&(apos|#39);/g, val: "'" },
1055
- "cent": { regex: /&(cent|#162);/g, val: "\xA2" },
1056
- "pound": { regex: /&(pound|#163);/g, val: "\xA3" },
1057
- "yen": { regex: /&(yen|#165);/g, val: "\xA5" },
1058
- "euro": { regex: /&(euro|#8364);/g, val: "\u20AC" },
1059
- "copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
1060
- "reg": { regex: /&(reg|#174);/g, val: "\xAE" },
1061
- "inr": { regex: /&(inr|#8377);/g, val: "\u20B9" },
1062
- "num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => fromCodePoint(str, 10, "&#") },
1063
- "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => fromCodePoint(str, 16, "&#x") }
1064
- };
1065
- this.addExternalEntities = addExternalEntities;
1066
- this.parseXml = parseXml;
1067
- this.parseTextData = parseTextData;
1068
- this.resolveNameSpace = resolveNameSpace;
1069
- this.buildAttributesMap = buildAttributesMap;
1070
- this.isItStopNode = isItStopNode;
1071
- this.replaceEntitiesValue = replaceEntitiesValue;
1072
- this.readStopNodeData = readStopNodeData;
1073
- this.saveTextToParentTag = saveTextToParentTag;
1074
- this.addChild = addChild;
1075
- this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
1076
- this.entityExpansionCount = 0;
1077
- this.currentExpandedLength = 0;
1078
- if (this.options.stopNodes && this.options.stopNodes.length > 0) {
1079
- this.stopNodesExact = /* @__PURE__ */ new Set();
1080
- this.stopNodesWildcard = /* @__PURE__ */ new Set();
1081
- for (let i2 = 0; i2 < this.options.stopNodes.length; i2++) {
1082
- const stopNodeExp = this.options.stopNodes[i2];
1083
- if (typeof stopNodeExp !== "string") continue;
1084
- if (stopNodeExp.startsWith("*.")) {
1085
- this.stopNodesWildcard.add(stopNodeExp.substring(2));
1086
- } else {
1087
- this.stopNodesExact.add(stopNodeExp);
1088
- }
1089
- }
1090
- }
1091
- }
1092
- };
1093
- function addExternalEntities(externalEntities) {
1094
- const entKeys = Object.keys(externalEntities);
1095
- for (let i2 = 0; i2 < entKeys.length; i2++) {
1096
- const ent = entKeys[i2];
1097
- const escaped = ent.replace(/[.\-+*:]/g, "\\.");
1098
- this.lastEntities[ent] = {
1099
- regex: new RegExp("&" + escaped + ";", "g"),
1100
- val: externalEntities[ent]
1101
- };
1102
- }
1103
- }
1104
- function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
1105
- if (val !== void 0) {
1106
- if (this.options.trimValues && !dontTrim) {
1107
- val = val.trim();
1108
- }
1109
- if (val.length > 0) {
1110
- if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
1111
- const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);
1112
- if (newval === null || newval === void 0) {
1113
- return val;
1114
- } else if (typeof newval !== typeof val || newval !== val) {
1115
- return newval;
1116
- } else if (this.options.trimValues) {
1117
- return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
1118
- } else {
1119
- const trimmedVal = val.trim();
1120
- if (trimmedVal === val) {
1121
- return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
1122
- } else {
1123
- return val;
1124
- }
1125
- }
1126
- }
1127
- }
1128
- }
1129
- function resolveNameSpace(tagname) {
1130
- if (this.options.removeNSPrefix) {
1131
- const tags = tagname.split(":");
1132
- const prefix = tagname.charAt(0) === "/" ? "/" : "";
1133
- if (tags[0] === "xmlns") {
1134
- return "";
1135
- }
1136
- if (tags.length === 2) {
1137
- tagname = prefix + tags[1];
1138
- }
1139
- }
1140
- return tagname;
1141
- }
1142
- var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
1143
- function buildAttributesMap(attrStr, jPath, tagName) {
1144
- if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
1145
- const matches = getAllMatches(attrStr, attrsRegx);
1146
- const len = matches.length;
1147
- const attrs = {};
1148
- for (let i2 = 0; i2 < len; i2++) {
1149
- const attrName = this.resolveNameSpace(matches[i2][1]);
1150
- if (this.ignoreAttributesFn(attrName, jPath)) {
1151
- continue;
1152
- }
1153
- let oldVal = matches[i2][4];
1154
- let aName = this.options.attributeNamePrefix + attrName;
1155
- if (attrName.length) {
1156
- if (this.options.transformAttributeName) {
1157
- aName = this.options.transformAttributeName(aName);
1158
- }
1159
- if (aName === "__proto__") aName = "#__proto__";
1160
- if (oldVal !== void 0) {
1161
- if (this.options.trimValues) {
1162
- oldVal = oldVal.trim();
1163
- }
1164
- oldVal = this.replaceEntitiesValue(oldVal, tagName, jPath);
1165
- const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
1166
- if (newVal === null || newVal === void 0) {
1167
- attrs[aName] = oldVal;
1168
- } else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
1169
- attrs[aName] = newVal;
1170
- } else {
1171
- attrs[aName] = parseValue(
1172
- oldVal,
1173
- this.options.parseAttributeValue,
1174
- this.options.numberParseOptions
1175
- );
1176
- }
1177
- } else if (this.options.allowBooleanAttributes) {
1178
- attrs[aName] = true;
1179
- }
1180
- }
1181
- }
1182
- if (!Object.keys(attrs).length) {
1183
- return;
1184
- }
1185
- if (this.options.attributesGroupName) {
1186
- const attrCollection = {};
1187
- attrCollection[this.options.attributesGroupName] = attrs;
1188
- return attrCollection;
1189
- }
1190
- return attrs;
1191
- }
1192
- }
1193
- var parseXml = function(xmlData) {
1194
- xmlData = xmlData.replace(/\r\n?/g, "\n");
1195
- const xmlObj = new XmlNode("!xml");
1196
- let currentNode = xmlObj;
1197
- let textData = "";
1198
- let jPath = "";
1199
- this.entityExpansionCount = 0;
1200
- this.currentExpandedLength = 0;
1201
- const docTypeReader = new DocTypeReader(this.options.processEntities);
1202
- for (let i2 = 0; i2 < xmlData.length; i2++) {
1203
- const ch = xmlData[i2];
1204
- if (ch === "<") {
1205
- if (xmlData[i2 + 1] === "/") {
1206
- const closeIndex = findClosingIndex(xmlData, ">", i2, "Closing Tag is not closed.");
1207
- let tagName = xmlData.substring(i2 + 2, closeIndex).trim();
1208
- if (this.options.removeNSPrefix) {
1209
- const colonIndex = tagName.indexOf(":");
1210
- if (colonIndex !== -1) {
1211
- tagName = tagName.substr(colonIndex + 1);
1212
- }
1213
- }
1214
- if (this.options.transformTagName) {
1215
- tagName = this.options.transformTagName(tagName);
1216
- }
1217
- if (currentNode) {
1218
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1219
- }
1220
- const lastTagName = jPath.substring(jPath.lastIndexOf(".") + 1);
1221
- if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
1222
- throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
1223
- }
1224
- let propIndex = 0;
1225
- if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
1226
- propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
1227
- this.tagsNodeStack.pop();
1228
- } else {
1229
- propIndex = jPath.lastIndexOf(".");
1230
- }
1231
- jPath = jPath.substring(0, propIndex);
1232
- currentNode = this.tagsNodeStack.pop();
1233
- textData = "";
1234
- i2 = closeIndex;
1235
- } else if (xmlData[i2 + 1] === "?") {
1236
- let tagData = readTagExp(xmlData, i2, false, "?>");
1237
- if (!tagData) throw new Error("Pi Tag is not closed.");
1238
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1239
- if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) {
1240
- } else {
1241
- const childNode = new XmlNode(tagData.tagName);
1242
- childNode.add(this.options.textNodeName, "");
1243
- if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
1244
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
1245
- }
1246
- this.addChild(currentNode, childNode, jPath, i2);
1247
- }
1248
- i2 = tagData.closeIndex + 1;
1249
- } else if (xmlData.substr(i2 + 1, 3) === "!--") {
1250
- const endIndex = findClosingIndex(xmlData, "-->", i2 + 4, "Comment is not closed.");
1251
- if (this.options.commentPropName) {
1252
- const comment = xmlData.substring(i2 + 4, endIndex - 2);
1253
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1254
- currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
1255
- }
1256
- i2 = endIndex;
1257
- } else if (xmlData.substr(i2 + 1, 2) === "!D") {
1258
- const result = docTypeReader.readDocType(xmlData, i2);
1259
- this.docTypeEntities = result.entities;
1260
- i2 = result.i;
1261
- } else if (xmlData.substr(i2 + 1, 2) === "![") {
1262
- const closeIndex = findClosingIndex(xmlData, "]]>", i2, "CDATA is not closed.") - 2;
1263
- const tagExp = xmlData.substring(i2 + 9, closeIndex);
1264
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1265
- let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
1266
- if (val == void 0) val = "";
1267
- if (this.options.cdataPropName) {
1268
- currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
1269
- } else {
1270
- currentNode.add(this.options.textNodeName, val);
1271
- }
1272
- i2 = closeIndex + 2;
1273
- } else {
1274
- let result = readTagExp(xmlData, i2, this.options.removeNSPrefix);
1275
- let tagName = result.tagName;
1276
- const rawTagName = result.rawTagName;
1277
- let tagExp = result.tagExp;
1278
- let attrExpPresent = result.attrExpPresent;
1279
- let closeIndex = result.closeIndex;
1280
- if (this.options.transformTagName) {
1281
- const newTagName = this.options.transformTagName(tagName);
1282
- if (tagExp === tagName) {
1283
- tagExp = newTagName;
1284
- }
1285
- tagName = newTagName;
1286
- }
1287
- if (currentNode && textData) {
1288
- if (currentNode.tagname !== "!xml") {
1289
- textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
1290
- }
1291
- }
1292
- const lastTag = currentNode;
1293
- if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
1294
- currentNode = this.tagsNodeStack.pop();
1295
- jPath = jPath.substring(0, jPath.lastIndexOf("."));
1296
- }
1297
- if (tagName !== xmlObj.tagname) {
1298
- jPath += jPath ? "." + tagName : tagName;
1299
- }
1300
- const startIndex = i2;
1301
- if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, jPath, tagName)) {
1302
- let tagContent = "";
1303
- if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
1304
- if (tagName[tagName.length - 1] === "/") {
1305
- tagName = tagName.substr(0, tagName.length - 1);
1306
- jPath = jPath.substr(0, jPath.length - 1);
1307
- tagExp = tagName;
1308
- } else {
1309
- tagExp = tagExp.substr(0, tagExp.length - 1);
1310
- }
1311
- i2 = result.closeIndex;
1312
- } else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
1313
- i2 = result.closeIndex;
1314
- } else {
1315
- const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
1316
- if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
1317
- i2 = result2.i;
1318
- tagContent = result2.tagContent;
1319
- }
1320
- const childNode = new XmlNode(tagName);
1321
- if (tagName !== tagExp && attrExpPresent) {
1322
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1323
- }
1324
- if (tagContent) {
1325
- tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
1326
- }
1327
- jPath = jPath.substr(0, jPath.lastIndexOf("."));
1328
- childNode.add(this.options.textNodeName, tagContent);
1329
- this.addChild(currentNode, childNode, jPath, startIndex);
1330
- } else {
1331
- if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
1332
- if (tagName[tagName.length - 1] === "/") {
1333
- tagName = tagName.substr(0, tagName.length - 1);
1334
- jPath = jPath.substr(0, jPath.length - 1);
1335
- tagExp = tagName;
1336
- } else {
1337
- tagExp = tagExp.substr(0, tagExp.length - 1);
1338
- }
1339
- if (this.options.transformTagName) {
1340
- const newTagName = this.options.transformTagName(tagName);
1341
- if (tagExp === tagName) {
1342
- tagExp = newTagName;
1343
- }
1344
- tagName = newTagName;
1345
- }
1346
- const childNode = new XmlNode(tagName);
1347
- if (tagName !== tagExp && attrExpPresent) {
1348
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1349
- }
1350
- this.addChild(currentNode, childNode, jPath, startIndex);
1351
- jPath = jPath.substr(0, jPath.lastIndexOf("."));
1352
- } else {
1353
- const childNode = new XmlNode(tagName);
1354
- this.tagsNodeStack.push(currentNode);
1355
- if (tagName !== tagExp && attrExpPresent) {
1356
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1357
- }
1358
- this.addChild(currentNode, childNode, jPath, startIndex);
1359
- currentNode = childNode;
1360
- }
1361
- textData = "";
1362
- i2 = closeIndex;
1363
- }
1364
- }
1365
- } else {
1366
- textData += xmlData[i2];
1367
- }
1368
- }
1369
- return xmlObj.child;
1370
- };
1371
- function addChild(currentNode, childNode, jPath, startIndex) {
1372
- if (!this.options.captureMetaData) startIndex = void 0;
1373
- const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
1374
- if (result === false) {
1375
- } else if (typeof result === "string") {
1376
- childNode.tagname = result;
1377
- currentNode.addChild(childNode, startIndex);
1378
- } else {
1379
- currentNode.addChild(childNode, startIndex);
1380
- }
1381
- }
1382
- var replaceEntitiesValue = function(val, tagName, jPath) {
1383
- if (val.indexOf("&") === -1) {
1384
- return val;
1385
- }
1386
- const entityConfig = this.options.processEntities;
1387
- if (!entityConfig.enabled) {
1388
- return val;
1389
- }
1390
- if (entityConfig.allowedTags) {
1391
- if (!entityConfig.allowedTags.includes(tagName)) {
1392
- return val;
1393
- }
1394
- }
1395
- if (entityConfig.tagFilter) {
1396
- if (!entityConfig.tagFilter(tagName, jPath)) {
1397
- return val;
1398
- }
1399
- }
1400
- for (let entityName in this.docTypeEntities) {
1401
- const entity = this.docTypeEntities[entityName];
1402
- const matches = val.match(entity.regx);
1403
- if (matches) {
1404
- this.entityExpansionCount += matches.length;
1405
- if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
1406
- throw new Error(
1407
- `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
1408
- );
1409
- }
1410
- const lengthBefore = val.length;
1411
- val = val.replace(entity.regx, entity.val);
1412
- if (entityConfig.maxExpandedLength) {
1413
- this.currentExpandedLength += val.length - lengthBefore;
1414
- if (this.currentExpandedLength > entityConfig.maxExpandedLength) {
1415
- throw new Error(
1416
- `Total expanded content size exceeded: ${this.currentExpandedLength} > ${entityConfig.maxExpandedLength}`
1417
- );
1418
- }
1419
- }
1420
- }
1421
- }
1422
- if (val.indexOf("&") === -1) return val;
1423
- for (let entityName in this.lastEntities) {
1424
- const entity = this.lastEntities[entityName];
1425
- val = val.replace(entity.regex, entity.val);
1426
- }
1427
- if (val.indexOf("&") === -1) return val;
1428
- if (this.options.htmlEntities) {
1429
- for (let entityName in this.htmlEntities) {
1430
- const entity = this.htmlEntities[entityName];
1431
- val = val.replace(entity.regex, entity.val);
1432
- }
1433
- }
1434
- val = val.replace(this.ampEntity.regex, this.ampEntity.val);
1435
- return val;
1436
- };
1437
- function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
1438
- if (textData) {
1439
- if (isLeafNode === void 0) isLeafNode = currentNode.child.length === 0;
1440
- textData = this.parseTextData(
1441
- textData,
1442
- currentNode.tagname,
1443
- jPath,
1444
- false,
1445
- currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false,
1446
- isLeafNode
1447
- );
1448
- if (textData !== void 0 && textData !== "")
1449
- currentNode.add(this.options.textNodeName, textData);
1450
- textData = "";
1451
- }
1452
- return textData;
1453
- }
1454
- function isItStopNode(stopNodesExact, stopNodesWildcard, jPath, currentTagName) {
1455
- if (stopNodesWildcard && stopNodesWildcard.has(currentTagName)) return true;
1456
- if (stopNodesExact && stopNodesExact.has(jPath)) return true;
1457
- return false;
1458
- }
1459
- function tagExpWithClosingIndex(xmlData, i2, closingChar = ">") {
1460
- let attrBoundary;
1461
- let tagExp = "";
1462
- for (let index = i2; index < xmlData.length; index++) {
1463
- let ch = xmlData[index];
1464
- if (attrBoundary) {
1465
- if (ch === attrBoundary) attrBoundary = "";
1466
- } else if (ch === '"' || ch === "'") {
1467
- attrBoundary = ch;
1468
- } else if (ch === closingChar[0]) {
1469
- if (closingChar[1]) {
1470
- if (xmlData[index + 1] === closingChar[1]) {
1471
- return {
1472
- data: tagExp,
1473
- index
1474
- };
1475
- }
1476
- } else {
1477
- return {
1478
- data: tagExp,
1479
- index
1480
- };
1481
- }
1482
- } else if (ch === " ") {
1483
- ch = " ";
1484
- }
1485
- tagExp += ch;
1486
- }
1487
- }
1488
- function findClosingIndex(xmlData, str, i2, errMsg) {
1489
- const closingIndex = xmlData.indexOf(str, i2);
1490
- if (closingIndex === -1) {
1491
- throw new Error(errMsg);
1492
- } else {
1493
- return closingIndex + str.length - 1;
1494
- }
1495
- }
1496
- function readTagExp(xmlData, i2, removeNSPrefix, closingChar = ">") {
1497
- const result = tagExpWithClosingIndex(xmlData, i2 + 1, closingChar);
1498
- if (!result) return;
1499
- let tagExp = result.data;
1500
- const closeIndex = result.index;
1501
- const separatorIndex = tagExp.search(/\s/);
1502
- let tagName = tagExp;
1503
- let attrExpPresent = true;
1504
- if (separatorIndex !== -1) {
1505
- tagName = tagExp.substring(0, separatorIndex);
1506
- tagExp = tagExp.substring(separatorIndex + 1).trimStart();
1507
- }
1508
- const rawTagName = tagName;
1509
- if (removeNSPrefix) {
1510
- const colonIndex = tagName.indexOf(":");
1511
- if (colonIndex !== -1) {
1512
- tagName = tagName.substr(colonIndex + 1);
1513
- attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
1514
- }
1515
- }
1516
- return {
1517
- tagName,
1518
- tagExp,
1519
- closeIndex,
1520
- attrExpPresent,
1521
- rawTagName
1522
- };
1523
- }
1524
- function readStopNodeData(xmlData, tagName, i2) {
1525
- const startIndex = i2;
1526
- let openTagCount = 1;
1527
- for (; i2 < xmlData.length; i2++) {
1528
- if (xmlData[i2] === "<") {
1529
- if (xmlData[i2 + 1] === "/") {
1530
- const closeIndex = findClosingIndex(xmlData, ">", i2, `${tagName} is not closed`);
1531
- let closeTagName = xmlData.substring(i2 + 2, closeIndex).trim();
1532
- if (closeTagName === tagName) {
1533
- openTagCount--;
1534
- if (openTagCount === 0) {
1535
- return {
1536
- tagContent: xmlData.substring(startIndex, i2),
1537
- i: closeIndex
1538
- };
1539
- }
1540
- }
1541
- i2 = closeIndex;
1542
- } else if (xmlData[i2 + 1] === "?") {
1543
- const closeIndex = findClosingIndex(xmlData, "?>", i2 + 1, "StopNode is not closed.");
1544
- i2 = closeIndex;
1545
- } else if (xmlData.substr(i2 + 1, 3) === "!--") {
1546
- const closeIndex = findClosingIndex(xmlData, "-->", i2 + 3, "StopNode is not closed.");
1547
- i2 = closeIndex;
1548
- } else if (xmlData.substr(i2 + 1, 2) === "![") {
1549
- const closeIndex = findClosingIndex(xmlData, "]]>", i2, "StopNode is not closed.") - 2;
1550
- i2 = closeIndex;
1551
- } else {
1552
- const tagData = readTagExp(xmlData, i2, ">");
1553
- if (tagData) {
1554
- const openTagName = tagData && tagData.tagName;
1555
- if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
1556
- openTagCount++;
1557
- }
1558
- i2 = tagData.closeIndex;
1559
- }
1560
- }
1561
- }
1562
- }
1563
- }
1564
- function parseValue(val, shouldParse, options) {
1565
- if (shouldParse && typeof val === "string") {
1566
- const newval = val.trim();
1567
- if (newval === "true") return true;
1568
- else if (newval === "false") return false;
1569
- else return toNumber(val, options);
1570
- } else {
1571
- if (isExist(val)) {
1572
- return val;
1573
- } else {
1574
- return "";
1575
- }
1576
- }
1577
- }
1578
- function fromCodePoint(str, base, prefix) {
1579
- const codePoint = Number.parseInt(str, base);
1580
- if (codePoint >= 0 && codePoint <= 1114111) {
1581
- return String.fromCodePoint(codePoint);
1582
- } else {
1583
- return prefix + str + ";";
1584
- }
1585
- }
1586
- var METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
1587
- function prettify(node, options) {
1588
- return compress(node, options);
1589
- }
1590
- function compress(arr, options, jPath) {
1591
- let text;
1592
- const compressedObj = {};
1593
- for (let i2 = 0; i2 < arr.length; i2++) {
1594
- const tagObj = arr[i2];
1595
- const property = propName(tagObj);
1596
- let newJpath = "";
1597
- if (jPath === void 0) newJpath = property;
1598
- else newJpath = jPath + "." + property;
1599
- if (property === options.textNodeName) {
1600
- if (text === void 0) text = tagObj[property];
1601
- else text += "" + tagObj[property];
1602
- } else if (property === void 0) {
1603
- continue;
1604
- } else if (tagObj[property]) {
1605
- let val = compress(tagObj[property], options, newJpath);
1606
- const isLeaf = isLeafTag(val, options);
1607
- if (tagObj[METADATA_SYMBOL2] !== void 0) {
1608
- val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
1609
- }
1610
- if (tagObj[":@"]) {
1611
- assignAttributes(val, tagObj[":@"], newJpath, options);
1612
- } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
1613
- val = val[options.textNodeName];
1614
- } else if (Object.keys(val).length === 0) {
1615
- if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
1616
- else val = "";
1617
- }
1618
- if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
1619
- if (!Array.isArray(compressedObj[property])) {
1620
- compressedObj[property] = [compressedObj[property]];
1621
- }
1622
- compressedObj[property].push(val);
1623
- } else {
1624
- if (options.isArray(property, newJpath, isLeaf)) {
1625
- compressedObj[property] = [val];
1626
- } else {
1627
- compressedObj[property] = val;
1628
- }
1629
- }
1630
- }
1631
- }
1632
- if (typeof text === "string") {
1633
- if (text.length > 0) compressedObj[options.textNodeName] = text;
1634
- } else if (text !== void 0) compressedObj[options.textNodeName] = text;
1635
- return compressedObj;
1636
- }
1637
- function propName(obj) {
1638
- const keys = Object.keys(obj);
1639
- for (let i2 = 0; i2 < keys.length; i2++) {
1640
- const key = keys[i2];
1641
- if (key !== ":@") return key;
1642
- }
1643
- }
1644
- function assignAttributes(obj, attrMap, jpath, options) {
1645
- if (attrMap) {
1646
- const keys = Object.keys(attrMap);
1647
- const len = keys.length;
1648
- for (let i2 = 0; i2 < len; i2++) {
1649
- const atrrName = keys[i2];
1650
- if (options.isArray(atrrName, jpath + "." + atrrName, true, true)) {
1651
- obj[atrrName] = [attrMap[atrrName]];
1652
- } else {
1653
- obj[atrrName] = attrMap[atrrName];
1654
- }
1655
- }
1656
- }
1657
- }
1658
- function isLeafTag(obj, options) {
1659
- const { textNodeName } = options;
1660
- const propCount = Object.keys(obj).length;
1661
- if (propCount === 0) {
1662
- return true;
1663
- }
1664
- if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
1665
- return true;
1666
- }
1667
- return false;
1668
- }
1669
- var XMLParser = class {
1670
- constructor(options) {
1671
- this.externalEntities = {};
1672
- this.options = buildOptions(options);
1673
- }
1674
- /**
1675
- * Parse XML dats to JS object
1676
- * @param {string|Uint8Array} xmlData
1677
- * @param {boolean|Object} validationOption
1678
- */
1679
- parse(xmlData, validationOption) {
1680
- if (typeof xmlData !== "string" && xmlData.toString) {
1681
- xmlData = xmlData.toString();
1682
- } else if (typeof xmlData !== "string") {
1683
- throw new Error("XML data is accepted in String or Bytes[] form.");
1684
- }
1685
- if (validationOption) {
1686
- if (validationOption === true) validationOption = {};
1687
- const result = validate(xmlData, validationOption);
1688
- if (result !== true) {
1689
- throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
1690
- }
1691
- }
1692
- const orderedObjParser = new OrderedObjParser(this.options);
1693
- orderedObjParser.addExternalEntities(this.externalEntities);
1694
- const orderedResult = orderedObjParser.parseXml(xmlData);
1695
- if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
1696
- else return prettify(orderedResult, this.options);
1697
- }
1698
- /**
1699
- * Add Entity which is not by default supported by this library
1700
- * @param {string} key
1701
- * @param {string} value
1702
- */
1703
- addEntity(key, value) {
1704
- if (value.indexOf("&") !== -1) {
1705
- throw new Error("Entity value can't have '&'");
1706
- } else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
1707
- throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
1708
- } else if (value === "&") {
1709
- throw new Error("An entity with value '&' is not permitted");
1710
- } else {
1711
- this.externalEntities[key] = value;
1712
- }
1713
- }
1714
- /**
1715
- * Returns a Symbol that can be used to access the metadata
1716
- * property on a node.
1717
- *
1718
- * If Symbol is not available in the environment, an ordinary property is used
1719
- * and the name of the property is here returned.
1720
- *
1721
- * The XMLMetaData property is only present when `captureMetaData`
1722
- * is true in the options.
1723
- */
1724
- static getMetaDataSymbol() {
1725
- return XmlNode.getMetaDataSymbol();
1726
- }
1727
- };
1728
- var parser = new XMLParser({
1729
- attributeNamePrefix: "",
1730
- htmlEntities: true,
1731
- ignoreAttributes: false,
1732
- ignoreDeclaration: true,
1733
- parseTagValue: false,
1734
- trimValues: false,
1735
- tagValueProcessor: (_, val) => val.trim() === "" && val.includes("\n") ? "" : void 0
1736
- });
1737
- parser.addEntity("#xD", "\r");
1738
- parser.addEntity("#10", "\n");
1739
- function parseXML(xmlString) {
1740
- return parser.parse(xmlString, true);
1741
- }
1742
- var XmlShapeDeserializer = class extends SerdeContextConfig {
1743
- settings;
1744
- stringDeserializer;
1745
- constructor(settings) {
1746
- super();
1747
- this.settings = settings;
1748
- this.stringDeserializer = new FromStringShapeDeserializer(settings);
1749
- }
1750
- setSerdeContext(serdeContext) {
1751
- this.serdeContext = serdeContext;
1752
- this.stringDeserializer.setSerdeContext(serdeContext);
1753
- }
1754
- read(schema, bytes, key) {
1755
- const ns = NormalizedSchema.of(schema);
1756
- const memberSchemas = ns.getMemberSchemas();
1757
- const isEventPayload = ns.isStructSchema() && ns.isMemberSchema() && !!Object.values(memberSchemas).find((memberNs) => {
1758
- return !!memberNs.getMemberTraits().eventPayload;
1759
- });
1760
- if (isEventPayload) {
1761
- const output = {};
1762
- const memberName = Object.keys(memberSchemas)[0];
1763
- const eventMemberSchema = memberSchemas[memberName];
1764
- if (eventMemberSchema.isBlobSchema()) {
1765
- output[memberName] = bytes;
1766
- } else {
1767
- output[memberName] = this.read(memberSchemas[memberName], bytes);
1768
- }
1769
- return output;
1770
- }
1771
- const xmlString = (this.serdeContext?.utf8Encoder ?? toUtf82)(bytes);
1772
- const parsedObject = this.parseXml(xmlString);
1773
- return this.readSchema(schema, key ? parsedObject[key] : parsedObject);
1774
- }
1775
- readSchema(_schema, value) {
1776
- const ns = NormalizedSchema.of(_schema);
1777
- if (ns.isUnitSchema()) {
1778
- return;
1779
- }
1780
- const traits = ns.getMergedTraits();
1781
- if (ns.isListSchema() && !Array.isArray(value)) {
1782
- return this.readSchema(ns, [value]);
1783
- }
1784
- if (value == null) {
1785
- return value;
1786
- }
1787
- if (typeof value === "object") {
1788
- const sparse = !!traits.sparse;
1789
- const flat = !!traits.xmlFlattened;
1790
- if (ns.isListSchema()) {
1791
- const listValue = ns.getValueSchema();
1792
- const buffer2 = [];
1793
- const sourceKey = listValue.getMergedTraits().xmlName ?? "member";
1794
- const source = flat ? value : (value[0] ?? value)[sourceKey];
1795
- const sourceArray = Array.isArray(source) ? source : [source];
1796
- for (const v2 of sourceArray) {
1797
- if (v2 != null || sparse) {
1798
- buffer2.push(this.readSchema(listValue, v2));
1799
- }
1800
- }
1801
- return buffer2;
1802
- }
1803
- const buffer = {};
1804
- if (ns.isMapSchema()) {
1805
- const keyNs = ns.getKeySchema();
1806
- const memberNs = ns.getValueSchema();
1807
- let entries;
1808
- if (flat) {
1809
- entries = Array.isArray(value) ? value : [value];
1810
- } else {
1811
- entries = Array.isArray(value.entry) ? value.entry : [value.entry];
1812
- }
1813
- const keyProperty = keyNs.getMergedTraits().xmlName ?? "key";
1814
- const valueProperty = memberNs.getMergedTraits().xmlName ?? "value";
1815
- for (const entry of entries) {
1816
- const key = entry[keyProperty];
1817
- const value2 = entry[valueProperty];
1818
- if (value2 != null || sparse) {
1819
- buffer[key] = this.readSchema(memberNs, value2);
1820
- }
1821
- }
1822
- return buffer;
1823
- }
1824
- if (ns.isStructSchema()) {
1825
- const union = ns.isUnionSchema();
1826
- let unionSerde;
1827
- if (union) {
1828
- unionSerde = new UnionSerde(value, buffer);
1829
- }
1830
- for (const [memberName, memberSchema] of ns.structIterator()) {
1831
- const memberTraits = memberSchema.getMergedTraits();
1832
- const xmlObjectKey = !memberTraits.httpPayload ? memberSchema.getMemberTraits().xmlName ?? memberName : memberTraits.xmlName ?? memberSchema.getName();
1833
- if (union) {
1834
- unionSerde.mark(xmlObjectKey);
1835
- }
1836
- if (value[xmlObjectKey] != null) {
1837
- buffer[memberName] = this.readSchema(memberSchema, value[xmlObjectKey]);
1838
- }
1839
- }
1840
- if (union) {
1841
- unionSerde.writeUnknown();
1842
- }
1843
- return buffer;
1844
- }
1845
- if (ns.isDocumentSchema()) {
1846
- return value;
1847
- }
1848
- throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
1849
- }
1850
- if (ns.isListSchema()) {
1851
- return [];
1852
- }
1853
- if (ns.isMapSchema() || ns.isStructSchema()) {
1854
- return {};
1855
- }
1856
- return this.stringDeserializer.read(ns, value);
1857
- }
1858
- parseXml(xml) {
1859
- if (xml.length) {
1860
- let parsedObj;
1861
- try {
1862
- parsedObj = parseXML(xml);
1863
- } catch (e2) {
1864
- if (e2 && typeof e2 === "object") {
1865
- Object.defineProperty(e2, "$responseBodyText", {
1866
- value: xml
1867
- });
1868
- }
1869
- throw e2;
1870
- }
1871
- const textNodeName = "#text";
1872
- const key = Object.keys(parsedObj)[0];
1873
- const parsedObjToReturn = parsedObj[key];
1874
- if (parsedObjToReturn[textNodeName]) {
1875
- parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
1876
- delete parsedObjToReturn[textNodeName];
1877
- }
1878
- return getValueFromTextNode(parsedObjToReturn);
1879
- }
1880
- return {};
1881
- }
1882
- };
1883
- var QueryShapeSerializer = class extends SerdeContextConfig {
1884
- settings;
1885
- buffer;
1886
- constructor(settings) {
1887
- super();
1888
- this.settings = settings;
1889
- }
1890
- write(schema, value, prefix = "") {
1891
- if (this.buffer === void 0) {
1892
- this.buffer = "";
1893
- }
1894
- const ns = NormalizedSchema.of(schema);
1895
- if (prefix && !prefix.endsWith(".")) {
1896
- prefix += ".";
1897
- }
1898
- if (ns.isBlobSchema()) {
1899
- if (typeof value === "string" || value instanceof Uint8Array) {
1900
- this.writeKey(prefix);
1901
- this.writeValue((this.serdeContext?.base64Encoder ?? toBase642)(value));
1902
- }
1903
- } else if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isStringSchema()) {
1904
- if (value != null) {
1905
- this.writeKey(prefix);
1906
- this.writeValue(String(value));
1907
- } else if (ns.isIdempotencyToken()) {
1908
- this.writeKey(prefix);
1909
- this.writeValue(v4());
1910
- }
1911
- } else if (ns.isBigIntegerSchema()) {
1912
- if (value != null) {
1913
- this.writeKey(prefix);
1914
- this.writeValue(String(value));
1915
- }
1916
- } else if (ns.isBigDecimalSchema()) {
1917
- if (value != null) {
1918
- this.writeKey(prefix);
1919
- this.writeValue(value instanceof NumericValue ? value.string : String(value));
1920
- }
1921
- } else if (ns.isTimestampSchema()) {
1922
- if (value instanceof Date) {
1923
- this.writeKey(prefix);
1924
- const format = determineTimestampFormat(ns, this.settings);
1925
- switch (format) {
1926
- case 5:
1927
- this.writeValue(value.toISOString().replace(".000Z", "Z"));
1928
- break;
1929
- case 6:
1930
- this.writeValue(dateToUtcString(value));
1931
- break;
1932
- case 7:
1933
- this.writeValue(String(value.getTime() / 1e3));
1934
- break;
1935
- }
1936
- }
1937
- } else if (ns.isDocumentSchema()) {
1938
- if (Array.isArray(value)) {
1939
- this.write(64 | 15, value, prefix);
1940
- } else if (value instanceof Date) {
1941
- this.write(4, value, prefix);
1942
- } else if (value instanceof Uint8Array) {
1943
- this.write(21, value, prefix);
1944
- } else if (value && typeof value === "object") {
1945
- this.write(128 | 15, value, prefix);
1946
- } else {
1947
- this.writeKey(prefix);
1948
- this.writeValue(String(value));
1949
- }
1950
- } else if (ns.isListSchema()) {
1951
- if (Array.isArray(value)) {
1952
- if (value.length === 0) {
1953
- if (this.settings.serializeEmptyLists) {
1954
- this.writeKey(prefix);
1955
- this.writeValue("");
1956
- }
1957
- } else {
1958
- const member = ns.getValueSchema();
1959
- const flat = this.settings.flattenLists || ns.getMergedTraits().xmlFlattened;
1960
- let i2 = 1;
1961
- for (const item of value) {
1962
- if (item == null) {
1963
- continue;
1964
- }
1965
- const traits = member.getMergedTraits();
1966
- const suffix = this.getKey("member", traits.xmlName, traits.ec2QueryName);
1967
- const key = flat ? `${prefix}${i2}` : `${prefix}${suffix}.${i2}`;
1968
- this.write(member, item, key);
1969
- ++i2;
1970
- }
1971
- }
1972
- }
1973
- } else if (ns.isMapSchema()) {
1974
- if (value && typeof value === "object") {
1975
- const keySchema = ns.getKeySchema();
1976
- const memberSchema = ns.getValueSchema();
1977
- const flat = ns.getMergedTraits().xmlFlattened;
1978
- let i2 = 1;
1979
- for (const [k2, v2] of Object.entries(value)) {
1980
- if (v2 == null) {
1981
- continue;
1982
- }
1983
- const keyTraits = keySchema.getMergedTraits();
1984
- const keySuffix = this.getKey("key", keyTraits.xmlName, keyTraits.ec2QueryName);
1985
- const key = flat ? `${prefix}${i2}.${keySuffix}` : `${prefix}entry.${i2}.${keySuffix}`;
1986
- const valTraits = memberSchema.getMergedTraits();
1987
- const valueSuffix = this.getKey("value", valTraits.xmlName, valTraits.ec2QueryName);
1988
- const valueKey = flat ? `${prefix}${i2}.${valueSuffix}` : `${prefix}entry.${i2}.${valueSuffix}`;
1989
- this.write(keySchema, k2, key);
1990
- this.write(memberSchema, v2, valueKey);
1991
- ++i2;
1992
- }
1993
- }
1994
- } else if (ns.isStructSchema()) {
1995
- if (value && typeof value === "object") {
1996
- let didWriteMember = false;
1997
- for (const [memberName, member] of ns.structIterator()) {
1998
- if (value[memberName] == null && !member.isIdempotencyToken()) {
1999
- continue;
2000
- }
2001
- const traits = member.getMergedTraits();
2002
- const suffix = this.getKey(memberName, traits.xmlName, traits.ec2QueryName, "struct");
2003
- const key = `${prefix}${suffix}`;
2004
- this.write(member, value[memberName], key);
2005
- didWriteMember = true;
2006
- }
2007
- if (!didWriteMember && ns.isUnionSchema()) {
2008
- const { $unknown } = value;
2009
- if (Array.isArray($unknown)) {
2010
- const [k2, v2] = $unknown;
2011
- const key = `${prefix}${k2}`;
2012
- this.write(15, v2, key);
2013
- }
2014
- }
2015
- }
2016
- } else if (ns.isUnitSchema()) {
2017
- } else {
2018
- throw new Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${ns.getName(true)}`);
2019
- }
2020
- }
2021
- flush() {
2022
- if (this.buffer === void 0) {
2023
- throw new Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");
2024
- }
2025
- const str = this.buffer;
2026
- delete this.buffer;
2027
- return str;
2028
- }
2029
- getKey(memberName, xmlName, ec2QueryName, keySource) {
2030
- const { ec2, capitalizeKeys } = this.settings;
2031
- if (ec2 && ec2QueryName) {
2032
- return ec2QueryName;
2033
- }
2034
- const key = xmlName ?? memberName;
2035
- if (capitalizeKeys && keySource === "struct") {
2036
- return key[0].toUpperCase() + key.slice(1);
2037
- }
2038
- return key;
2039
- }
2040
- writeKey(key) {
2041
- if (key.endsWith(".")) {
2042
- key = key.slice(0, key.length - 1);
2043
- }
2044
- this.buffer += `&${extendedEncodeURIComponent(key)}=`;
2045
- }
2046
- writeValue(value) {
2047
- this.buffer += extendedEncodeURIComponent(value);
2048
- }
2049
- };
2050
- var AwsQueryProtocol = class extends RpcProtocol {
2051
- options;
2052
- serializer;
2053
- deserializer;
2054
- mixin = new ProtocolLib();
2055
- constructor(options) {
2056
- super({
2057
- defaultNamespace: options.defaultNamespace
2058
- });
2059
- this.options = options;
2060
- const settings = {
2061
- timestampFormat: {
2062
- useTrait: true,
2063
- default: 5
2064
- },
2065
- httpBindings: false,
2066
- xmlNamespace: options.xmlNamespace,
2067
- serviceNamespace: options.defaultNamespace,
2068
- serializeEmptyLists: true
2069
- };
2070
- this.serializer = new QueryShapeSerializer(settings);
2071
- this.deserializer = new XmlShapeDeserializer(settings);
2072
- }
2073
- getShapeId() {
2074
- return "aws.protocols#awsQuery";
2075
- }
2076
- setSerdeContext(serdeContext) {
2077
- this.serializer.setSerdeContext(serdeContext);
2078
- this.deserializer.setSerdeContext(serdeContext);
2079
- }
2080
- getPayloadCodec() {
2081
- throw new Error("AWSQuery protocol has no payload codec.");
2082
- }
2083
- async serializeRequest(operationSchema, input, context) {
2084
- const request = await super.serializeRequest(operationSchema, input, context);
2085
- if (!request.path.endsWith("/")) {
2086
- request.path += "/";
2087
- }
2088
- Object.assign(request.headers, {
2089
- "content-type": `application/x-www-form-urlencoded`
2090
- });
2091
- if (deref(operationSchema.input) === "unit" || !request.body) {
2092
- request.body = "";
2093
- }
2094
- const action = operationSchema.name.split("#")[1] ?? operationSchema.name;
2095
- request.body = `Action=${action}&Version=${this.options.version}` + request.body;
2096
- if (request.body.endsWith("&")) {
2097
- request.body = request.body.slice(-1);
2098
- }
2099
- return request;
2100
- }
2101
- async deserializeResponse(operationSchema, context, response) {
2102
- const deserializer = this.deserializer;
2103
- const ns = NormalizedSchema.of(operationSchema.output);
2104
- const dataObject = {};
2105
- if (response.statusCode >= 300) {
2106
- const bytes2 = await collectBody(response.body, context);
2107
- if (bytes2.byteLength > 0) {
2108
- Object.assign(dataObject, await deserializer.read(15, bytes2));
2109
- }
2110
- await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
2111
- }
2112
- for (const header in response.headers) {
2113
- const value = response.headers[header];
2114
- delete response.headers[header];
2115
- response.headers[header.toLowerCase()] = value;
2116
- }
2117
- const shortName = operationSchema.name.split("#")[1] ?? operationSchema.name;
2118
- const awsQueryResultKey = ns.isStructSchema() && this.useNestedResult() ? shortName + "Result" : void 0;
2119
- const bytes = await collectBody(response.body, context);
2120
- if (bytes.byteLength > 0) {
2121
- Object.assign(dataObject, await deserializer.read(ns, bytes, awsQueryResultKey));
2122
- }
2123
- const output = {
2124
- $metadata: this.deserializeMetadata(response),
2125
- ...dataObject
2126
- };
2127
- return output;
2128
- }
2129
- useNestedResult() {
2130
- return true;
2131
- }
2132
- async handleError(operationSchema, context, response, dataObject, metadata) {
2133
- const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
2134
- const errorData = this.loadQueryError(dataObject) ?? {};
2135
- const message = this.loadQueryErrorMessage(dataObject);
2136
- errorData.message = message;
2137
- errorData.Error = {
2138
- Type: errorData.Type,
2139
- Code: errorData.Code,
2140
- Message: message
2141
- };
2142
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
2143
- const ns = NormalizedSchema.of(errorSchema);
2144
- const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
2145
- const exception = new ErrorCtor(message);
2146
- const output = {
2147
- Type: errorData.Error.Type,
2148
- Code: errorData.Error.Code,
2149
- Error: errorData.Error
2150
- };
2151
- for (const [name, member] of ns.structIterator()) {
2152
- const target = member.getMergedTraits().xmlName ?? name;
2153
- const value = errorData[target] ?? dataObject[target];
2154
- output[name] = this.deserializer.readSchema(member, value);
2155
- }
2156
- throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
2157
- $fault: ns.getMergedTraits().error,
2158
- message
2159
- }, output), dataObject);
2160
- }
2161
- loadQueryErrorCode(output, data) {
2162
- const code = (data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error)?.Code;
2163
- if (code !== void 0) {
2164
- return code;
2165
- }
2166
- if (output.statusCode == 404) {
2167
- return "NotFound";
2168
- }
2169
- }
2170
- loadQueryError(data) {
2171
- return data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error;
2172
- }
2173
- loadQueryErrorMessage(data) {
2174
- const errorData = this.loadQueryError(data);
2175
- return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";
2176
- }
2177
- getDefaultContentType() {
2178
- return "application/x-www-form-urlencoded";
2179
- }
2180
- };
2181
- var defaultSTSHttpAuthSchemeParametersProvider = async (config, context, input) => {
2182
- return {
2183
- operation: getSmithyContext(context).operation,
2184
- region: await normalizeProvider(config.region)() || (() => {
2185
- throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
2186
- })()
2187
- };
2188
- };
2189
- function createAwsAuthSigv4HttpAuthOption(authParameters) {
2190
- return {
2191
- schemeId: "aws.auth#sigv4",
2192
- signingProperties: {
2193
- name: "sts",
2194
- region: authParameters.region
2195
- },
2196
- propertiesExtractor: (config, context) => ({
2197
- signingProperties: {
2198
- config,
2199
- context
2200
- }
2201
- })
2202
- };
2203
- }
2204
- function createSmithyApiNoAuthHttpAuthOption(authParameters) {
2205
- return {
2206
- schemeId: "smithy.api#noAuth"
2207
- };
2208
- }
2209
- var defaultSTSHttpAuthSchemeProvider = (authParameters) => {
2210
- const options = [];
2211
- switch (authParameters.operation) {
2212
- case "AssumeRoleWithWebIdentity": {
2213
- options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));
2214
- break;
2215
- }
2216
- default: {
2217
- options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
2218
- }
2219
- }
2220
- return options;
2221
- };
2222
- var resolveStsAuthConfig = (input) => Object.assign(input, {
2223
- stsClientCtor: STSClient
2224
- });
2225
- var resolveHttpAuthSchemeConfig = (config) => {
2226
- const config_0 = resolveStsAuthConfig(config);
2227
- const config_1 = resolveAwsSdkSigV4Config(config_0);
2228
- return Object.assign(config_1, {
2229
- authSchemePreference: normalizeProvider(config.authSchemePreference ?? [])
2230
- });
2231
- };
2232
- var resolveClientEndpointParameters = (options) => {
2233
- return Object.assign(options, {
2234
- useDualstackEndpoint: options.useDualstackEndpoint ?? false,
2235
- useFipsEndpoint: options.useFipsEndpoint ?? false,
2236
- useGlobalEndpoint: options.useGlobalEndpoint ?? false,
2237
- defaultSigningName: "sts"
2238
- });
2239
- };
2240
- var commonParams = {
2241
- UseGlobalEndpoint: { type: "builtInParams", name: "useGlobalEndpoint" },
2242
- UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
2243
- Endpoint: { type: "builtInParams", name: "endpoint" },
2244
- Region: { type: "builtInParams", name: "region" },
2245
- UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
2246
- };
2247
- var F = "required";
2248
- var G = "type";
2249
- var H = "fn";
2250
- var I = "argv";
2251
- var J = "ref";
2252
- var a = false;
2253
- var b = true;
2254
- var c = "booleanEquals";
2255
- var d = "stringEquals";
2256
- var e = "sigv4";
2257
- var f = "sts";
2258
- var g = "us-east-1";
2259
- var h = "endpoint";
2260
- var i = "https://sts.{Region}.{PartitionResult#dnsSuffix}";
2261
- var j = "tree";
2262
- var k = "error";
2263
- var l = "getAttr";
2264
- var m = { [F]: false, [G]: "string" };
2265
- var n = { [F]: true, "default": false, [G]: "boolean" };
2266
- var o = { [J]: "Endpoint" };
2267
- var p = { [H]: "isSet", [I]: [{ [J]: "Region" }] };
2268
- var q = { [J]: "Region" };
2269
- var r = { [H]: "aws.partition", [I]: [q], "assign": "PartitionResult" };
2270
- var s = { [J]: "UseFIPS" };
2271
- var t = { [J]: "UseDualStack" };
2272
- var u = { "url": "https://sts.amazonaws.com", "properties": { "authSchemes": [{ "name": e, "signingName": f, "signingRegion": g }] }, "headers": {} };
2273
- var v = {};
2274
- var w = { "conditions": [{ [H]: d, [I]: [q, "aws-global"] }], [h]: u, [G]: h };
2275
- var x = { [H]: c, [I]: [s, true] };
2276
- var y = { [H]: c, [I]: [t, true] };
2277
- var z = { [H]: l, [I]: [{ [J]: "PartitionResult" }, "supportsFIPS"] };
2278
- var A = { [J]: "PartitionResult" };
2279
- var B = { [H]: c, [I]: [true, { [H]: l, [I]: [A, "supportsDualStack"] }] };
2280
- var C = [{ [H]: "isSet", [I]: [o] }];
2281
- var D = [x];
2282
- var E = [y];
2283
- var _data = { version: "1.0", parameters: { Region: m, UseDualStack: n, UseFIPS: n, Endpoint: m, UseGlobalEndpoint: n }, rules: [{ conditions: [{ [H]: c, [I]: [{ [J]: "UseGlobalEndpoint" }, b] }, { [H]: "not", [I]: C }, p, r, { [H]: c, [I]: [s, a] }, { [H]: c, [I]: [t, a] }], rules: [{ conditions: [{ [H]: d, [I]: [q, "ap-northeast-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "ap-south-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "ap-southeast-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "ap-southeast-2"] }], endpoint: u, [G]: h }, w, { conditions: [{ [H]: d, [I]: [q, "ca-central-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "eu-central-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "eu-north-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "eu-west-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "eu-west-2"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "eu-west-3"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "sa-east-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, g] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "us-east-2"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "us-west-1"] }], endpoint: u, [G]: h }, { conditions: [{ [H]: d, [I]: [q, "us-west-2"] }], endpoint: u, [G]: h }, { endpoint: { url: i, properties: { authSchemes: [{ name: e, signingName: f, signingRegion: "{Region}" }] }, headers: v }, [G]: h }], [G]: j }, { conditions: C, rules: [{ conditions: D, error: "Invalid Configuration: FIPS and custom endpoint are not supported", [G]: k }, { conditions: E, error: "Invalid Configuration: Dualstack and custom endpoint are not supported", [G]: k }, { endpoint: { url: o, properties: v, headers: v }, [G]: h }], [G]: j }, { conditions: [p], rules: [{ conditions: [r], rules: [{ conditions: [x, y], rules: [{ conditions: [{ [H]: c, [I]: [b, z] }, B], rules: [{ endpoint: { url: "https://sts-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: v, headers: v }, [G]: h }], [G]: j }, { error: "FIPS and DualStack are enabled, but this partition does not support one or both", [G]: k }], [G]: j }, { conditions: D, rules: [{ conditions: [{ [H]: c, [I]: [z, b] }], rules: [{ conditions: [{ [H]: d, [I]: [{ [H]: l, [I]: [A, "name"] }, "aws-us-gov"] }], endpoint: { url: "https://sts.{Region}.amazonaws.com", properties: v, headers: v }, [G]: h }, { endpoint: { url: "https://sts-fips.{Region}.{PartitionResult#dnsSuffix}", properties: v, headers: v }, [G]: h }], [G]: j }, { error: "FIPS is enabled but this partition does not support FIPS", [G]: k }], [G]: j }, { conditions: E, rules: [{ conditions: [B], rules: [{ endpoint: { url: "https://sts.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: v, headers: v }, [G]: h }], [G]: j }, { error: "DualStack is enabled but this partition does not support DualStack", [G]: k }], [G]: j }, w, { endpoint: { url: i, properties: v, headers: v }, [G]: h }], [G]: j }], [G]: j }, { error: "Invalid Configuration: Missing Region", [G]: k }] };
2284
- var ruleSet = _data;
2285
- var cache = new EndpointCache({
2286
- size: 50,
2287
- params: ["Endpoint", "Region", "UseDualStack", "UseFIPS", "UseGlobalEndpoint"]
2288
- });
2289
- var defaultEndpointResolver = (endpointParams, context = {}) => {
2290
- return cache.get(endpointParams, () => resolveEndpoint(ruleSet, {
2291
- endpointParams,
2292
- logger: context.logger
2293
- }));
2294
- };
2295
- customEndpointFunctions.aws = awsEndpointFunctions;
2296
- var STSServiceException = class _STSServiceException extends ServiceException {
2297
- constructor(options) {
2298
- super(options);
2299
- Object.setPrototypeOf(this, _STSServiceException.prototype);
2300
- }
2301
- };
2302
- var ExpiredTokenException = class _ExpiredTokenException extends STSServiceException {
2303
- name = "ExpiredTokenException";
2304
- $fault = "client";
2305
- constructor(opts) {
2306
- super({
2307
- name: "ExpiredTokenException",
2308
- $fault: "client",
2309
- ...opts
2310
- });
2311
- Object.setPrototypeOf(this, _ExpiredTokenException.prototype);
2312
- }
2313
- };
2314
- var MalformedPolicyDocumentException = class _MalformedPolicyDocumentException extends STSServiceException {
2315
- name = "MalformedPolicyDocumentException";
2316
- $fault = "client";
2317
- constructor(opts) {
2318
- super({
2319
- name: "MalformedPolicyDocumentException",
2320
- $fault: "client",
2321
- ...opts
2322
- });
2323
- Object.setPrototypeOf(this, _MalformedPolicyDocumentException.prototype);
2324
- }
2325
- };
2326
- var PackedPolicyTooLargeException = class _PackedPolicyTooLargeException extends STSServiceException {
2327
- name = "PackedPolicyTooLargeException";
2328
- $fault = "client";
2329
- constructor(opts) {
2330
- super({
2331
- name: "PackedPolicyTooLargeException",
2332
- $fault: "client",
2333
- ...opts
2334
- });
2335
- Object.setPrototypeOf(this, _PackedPolicyTooLargeException.prototype);
2336
- }
2337
- };
2338
- var RegionDisabledException = class _RegionDisabledException extends STSServiceException {
2339
- name = "RegionDisabledException";
2340
- $fault = "client";
2341
- constructor(opts) {
2342
- super({
2343
- name: "RegionDisabledException",
2344
- $fault: "client",
2345
- ...opts
2346
- });
2347
- Object.setPrototypeOf(this, _RegionDisabledException.prototype);
2348
- }
2349
- };
2350
- var IDPRejectedClaimException = class _IDPRejectedClaimException extends STSServiceException {
2351
- name = "IDPRejectedClaimException";
2352
- $fault = "client";
2353
- constructor(opts) {
2354
- super({
2355
- name: "IDPRejectedClaimException",
2356
- $fault: "client",
2357
- ...opts
2358
- });
2359
- Object.setPrototypeOf(this, _IDPRejectedClaimException.prototype);
2360
- }
2361
- };
2362
- var InvalidIdentityTokenException = class _InvalidIdentityTokenException extends STSServiceException {
2363
- name = "InvalidIdentityTokenException";
2364
- $fault = "client";
2365
- constructor(opts) {
2366
- super({
2367
- name: "InvalidIdentityTokenException",
2368
- $fault: "client",
2369
- ...opts
2370
- });
2371
- Object.setPrototypeOf(this, _InvalidIdentityTokenException.prototype);
2372
- }
2373
- };
2374
- var IDPCommunicationErrorException = class _IDPCommunicationErrorException extends STSServiceException {
2375
- name = "IDPCommunicationErrorException";
2376
- $fault = "client";
2377
- constructor(opts) {
2378
- super({
2379
- name: "IDPCommunicationErrorException",
2380
- $fault: "client",
2381
- ...opts
2382
- });
2383
- Object.setPrototypeOf(this, _IDPCommunicationErrorException.prototype);
2384
- }
2385
- };
2386
- var _A = "Arn";
2387
- var _AKI = "AccessKeyId";
2388
- var _AR = "AssumeRole";
2389
- var _ARI = "AssumedRoleId";
2390
- var _ARR = "AssumeRoleRequest";
2391
- var _ARRs = "AssumeRoleResponse";
2392
- var _ARU = "AssumedRoleUser";
2393
- var _ARWWI = "AssumeRoleWithWebIdentity";
2394
- var _ARWWIR = "AssumeRoleWithWebIdentityRequest";
2395
- var _ARWWIRs = "AssumeRoleWithWebIdentityResponse";
2396
- var _Au = "Audience";
2397
- var _C = "Credentials";
2398
- var _CA = "ContextAssertion";
2399
- var _DS = "DurationSeconds";
2400
- var _E = "Expiration";
2401
- var _EI = "ExternalId";
2402
- var _ETE = "ExpiredTokenException";
2403
- var _IDPCEE = "IDPCommunicationErrorException";
2404
- var _IDPRCE = "IDPRejectedClaimException";
2405
- var _IITE = "InvalidIdentityTokenException";
2406
- var _K = "Key";
2407
- var _MPDE = "MalformedPolicyDocumentException";
2408
- var _P = "Policy";
2409
- var _PA = "PolicyArns";
2410
- var _PAr = "ProviderArn";
2411
- var _PC = "ProvidedContexts";
2412
- var _PCLT = "ProvidedContextsListType";
2413
- var _PCr = "ProvidedContext";
2414
- var _PDT = "PolicyDescriptorType";
2415
- var _PI = "ProviderId";
2416
- var _PPS = "PackedPolicySize";
2417
- var _PPTLE = "PackedPolicyTooLargeException";
2418
- var _Pr = "Provider";
2419
- var _RA = "RoleArn";
2420
- var _RDE = "RegionDisabledException";
2421
- var _RSN = "RoleSessionName";
2422
- var _SAK = "SecretAccessKey";
2423
- var _SFWIT = "SubjectFromWebIdentityToken";
2424
- var _SI = "SourceIdentity";
2425
- var _SN = "SerialNumber";
2426
- var _ST = "SessionToken";
2427
- var _T = "Tags";
2428
- var _TC = "TokenCode";
2429
- var _TTK = "TransitiveTagKeys";
2430
- var _Ta = "Tag";
2431
- var _V = "Value";
2432
- var _WIT = "WebIdentityToken";
2433
- var _a = "arn";
2434
- var _aKST = "accessKeySecretType";
2435
- var _aQE = "awsQueryError";
2436
- var _c = "client";
2437
- var _cTT = "clientTokenType";
2438
- var _e = "error";
2439
- var _hE = "httpError";
2440
- var _m = "message";
2441
- var _pDLT = "policyDescriptorListType";
2442
- var _s = "smithy.ts.sdk.synthetic.com.amazonaws.sts";
2443
- var _tLT = "tagListType";
2444
- var n0 = "com.amazonaws.sts";
2445
- var _s_registry = TypeRegistry.for(_s);
2446
- var STSServiceException$ = [-3, _s, "STSServiceException", 0, [], []];
2447
- _s_registry.registerError(STSServiceException$, STSServiceException);
2448
- var n0_registry = TypeRegistry.for(n0);
2449
- var ExpiredTokenException$ = [
2450
- -3,
2451
- n0,
2452
- _ETE,
2453
- { [_aQE]: [`ExpiredTokenException`, 400], [_e]: _c, [_hE]: 400 },
2454
- [_m],
2455
- [0]
2456
- ];
2457
- n0_registry.registerError(ExpiredTokenException$, ExpiredTokenException);
2458
- var IDPCommunicationErrorException$ = [
2459
- -3,
2460
- n0,
2461
- _IDPCEE,
2462
- { [_aQE]: [`IDPCommunicationError`, 400], [_e]: _c, [_hE]: 400 },
2463
- [_m],
2464
- [0]
2465
- ];
2466
- n0_registry.registerError(IDPCommunicationErrorException$, IDPCommunicationErrorException);
2467
- var IDPRejectedClaimException$ = [
2468
- -3,
2469
- n0,
2470
- _IDPRCE,
2471
- { [_aQE]: [`IDPRejectedClaim`, 403], [_e]: _c, [_hE]: 403 },
2472
- [_m],
2473
- [0]
2474
- ];
2475
- n0_registry.registerError(IDPRejectedClaimException$, IDPRejectedClaimException);
2476
- var InvalidIdentityTokenException$ = [
2477
- -3,
2478
- n0,
2479
- _IITE,
2480
- { [_aQE]: [`InvalidIdentityToken`, 400], [_e]: _c, [_hE]: 400 },
2481
- [_m],
2482
- [0]
2483
- ];
2484
- n0_registry.registerError(InvalidIdentityTokenException$, InvalidIdentityTokenException);
2485
- var MalformedPolicyDocumentException$ = [
2486
- -3,
2487
- n0,
2488
- _MPDE,
2489
- { [_aQE]: [`MalformedPolicyDocument`, 400], [_e]: _c, [_hE]: 400 },
2490
- [_m],
2491
- [0]
2492
- ];
2493
- n0_registry.registerError(MalformedPolicyDocumentException$, MalformedPolicyDocumentException);
2494
- var PackedPolicyTooLargeException$ = [
2495
- -3,
2496
- n0,
2497
- _PPTLE,
2498
- { [_aQE]: [`PackedPolicyTooLarge`, 400], [_e]: _c, [_hE]: 400 },
2499
- [_m],
2500
- [0]
2501
- ];
2502
- n0_registry.registerError(PackedPolicyTooLargeException$, PackedPolicyTooLargeException);
2503
- var RegionDisabledException$ = [
2504
- -3,
2505
- n0,
2506
- _RDE,
2507
- { [_aQE]: [`RegionDisabledException`, 403], [_e]: _c, [_hE]: 403 },
2508
- [_m],
2509
- [0]
2510
- ];
2511
- n0_registry.registerError(RegionDisabledException$, RegionDisabledException);
2512
- var errorTypeRegistries = [_s_registry, n0_registry];
2513
- var accessKeySecretType = [0, n0, _aKST, 8, 0];
2514
- var clientTokenType = [0, n0, _cTT, 8, 0];
2515
- var AssumedRoleUser$ = [3, n0, _ARU, 0, [_ARI, _A], [0, 0], 2];
2516
- var AssumeRoleRequest$ = [
2517
- 3,
2518
- n0,
2519
- _ARR,
2520
- 0,
2521
- [_RA, _RSN, _PA, _P, _DS, _T, _TTK, _EI, _SN, _TC, _SI, _PC],
2522
- [0, 0, () => policyDescriptorListType, 0, 1, () => tagListType, 64 | 0, 0, 0, 0, 0, () => ProvidedContextsListType],
2523
- 2
2524
- ];
2525
- var AssumeRoleResponse$ = [
2526
- 3,
2527
- n0,
2528
- _ARRs,
2529
- 0,
2530
- [_C, _ARU, _PPS, _SI],
2531
- [[() => Credentials$, 0], () => AssumedRoleUser$, 1, 0]
2532
- ];
2533
- var AssumeRoleWithWebIdentityRequest$ = [
2534
- 3,
2535
- n0,
2536
- _ARWWIR,
2537
- 0,
2538
- [_RA, _RSN, _WIT, _PI, _PA, _P, _DS],
2539
- [0, 0, [() => clientTokenType, 0], 0, () => policyDescriptorListType, 0, 1],
2540
- 3
2541
- ];
2542
- var AssumeRoleWithWebIdentityResponse$ = [
2543
- 3,
2544
- n0,
2545
- _ARWWIRs,
2546
- 0,
2547
- [_C, _SFWIT, _ARU, _PPS, _Pr, _Au, _SI],
2548
- [[() => Credentials$, 0], 0, () => AssumedRoleUser$, 1, 0, 0, 0]
2549
- ];
2550
- var Credentials$ = [
2551
- 3,
2552
- n0,
2553
- _C,
2554
- 0,
2555
- [_AKI, _SAK, _ST, _E],
2556
- [0, [() => accessKeySecretType, 0], 0, 4],
2557
- 4
2558
- ];
2559
- var PolicyDescriptorType$ = [3, n0, _PDT, 0, [_a], [0]];
2560
- var ProvidedContext$ = [3, n0, _PCr, 0, [_PAr, _CA], [0, 0]];
2561
- var Tag$ = [3, n0, _Ta, 0, [_K, _V], [0, 0], 2];
2562
- var policyDescriptorListType = [1, n0, _pDLT, 0, () => PolicyDescriptorType$];
2563
- var ProvidedContextsListType = [1, n0, _PCLT, 0, () => ProvidedContext$];
2564
- var tagKeyListType = 64 | 0;
2565
- var tagListType = [1, n0, _tLT, 0, () => Tag$];
2566
- var AssumeRole$ = [9, n0, _AR, 0, () => AssumeRoleRequest$, () => AssumeRoleResponse$];
2567
- var AssumeRoleWithWebIdentity$ = [
2568
- 9,
2569
- n0,
2570
- _ARWWI,
2571
- 0,
2572
- () => AssumeRoleWithWebIdentityRequest$,
2573
- () => AssumeRoleWithWebIdentityResponse$
2574
- ];
2575
- var getRuntimeConfig = (config) => {
2576
- return {
2577
- apiVersion: "2011-06-15",
2578
- base64Decoder: config?.base64Decoder ?? fromBase64,
2579
- base64Encoder: config?.base64Encoder ?? toBase64,
2580
- disableHostPrefix: config?.disableHostPrefix ?? false,
2581
- endpointProvider: config?.endpointProvider ?? defaultEndpointResolver,
2582
- extensions: config?.extensions ?? [],
2583
- httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultSTSHttpAuthSchemeProvider,
2584
- httpAuthSchemes: config?.httpAuthSchemes ?? [
2585
- {
2586
- schemeId: "aws.auth#sigv4",
2587
- identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
2588
- signer: new AwsSdkSigV4Signer()
2589
- },
2590
- {
2591
- schemeId: "smithy.api#noAuth",
2592
- identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
2593
- signer: new NoAuthSigner()
2594
- }
2595
- ],
2596
- logger: config?.logger ?? new NoOpLogger(),
2597
- protocol: config?.protocol ?? AwsQueryProtocol,
2598
- protocolSettings: config?.protocolSettings ?? {
2599
- defaultNamespace: "com.amazonaws.sts",
2600
- errorTypeRegistries,
2601
- xmlNamespace: "https://sts.amazonaws.com/doc/2011-06-15/",
2602
- version: "2011-06-15",
2603
- serviceTarget: "AWSSecurityTokenServiceV20110615"
2604
- },
2605
- serviceId: config?.serviceId ?? "STS",
2606
- urlParser: config?.urlParser ?? parseUrl,
2607
- utf8Decoder: config?.utf8Decoder ?? fromUtf8,
2608
- utf8Encoder: config?.utf8Encoder ?? toUtf8
2609
- };
2610
- };
2611
- var getRuntimeConfig2 = (config) => {
2612
- emitWarningIfUnsupportedVersion2(process.version);
2613
- const defaultsMode = resolveDefaultsModeConfig(config);
2614
- const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
2615
- const clientSharedValues = getRuntimeConfig(config);
2616
- emitWarningIfUnsupportedVersion(process.version);
2617
- const loaderConfig = {
2618
- profile: config?.profile,
2619
- logger: clientSharedValues.logger
2620
- };
2621
- return {
2622
- ...clientSharedValues,
2623
- ...config,
2624
- runtime: "node",
2625
- defaultsMode,
2626
- authSchemePreference: config?.authSchemePreference ?? loadConfig(NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),
2627
- bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
2628
- defaultUserAgentProvider: config?.defaultUserAgentProvider ?? createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: package_default.version }),
2629
- httpAuthSchemes: config?.httpAuthSchemes ?? [
2630
- {
2631
- schemeId: "aws.auth#sigv4",
2632
- identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4") || (async (idProps) => await config.credentialDefaultProvider(idProps?.__config || {})()),
2633
- signer: new AwsSdkSigV4Signer()
2634
- },
2635
- {
2636
- schemeId: "smithy.api#noAuth",
2637
- identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#noAuth") || (async () => ({})),
2638
- signer: new NoAuthSigner()
2639
- }
2640
- ],
2641
- maxAttempts: config?.maxAttempts ?? loadConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
2642
- region: config?.region ?? loadConfig(NODE_REGION_CONFIG_OPTIONS, { ...NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
2643
- requestHandler: NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
2644
- retryMode: config?.retryMode ?? loadConfig({
2645
- ...NODE_RETRY_MODE_CONFIG_OPTIONS,
2646
- default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE
2647
- }, config),
2648
- sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
2649
- streamCollector: config?.streamCollector ?? streamCollector,
2650
- useDualstackEndpoint: config?.useDualstackEndpoint ?? loadConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
2651
- useFipsEndpoint: config?.useFipsEndpoint ?? loadConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),
2652
- userAgentAppId: config?.userAgentAppId ?? loadConfig(NODE_APP_ID_CONFIG_OPTIONS, loaderConfig)
2653
- };
2654
- };
2655
- function stsRegionDefaultResolver(loaderConfig = {}) {
2656
- return loadConfig2({
2657
- ...NODE_REGION_CONFIG_OPTIONS2,
2658
- async default() {
2659
- if (!warning.silence) {
2660
- console.warn("@aws-sdk - WARN - default STS region of us-east-1 used. See @aws-sdk/credential-providers README and set a region explicitly.");
2661
- }
2662
- return "us-east-1";
2663
- }
2664
- }, { ...NODE_REGION_CONFIG_FILE_OPTIONS2, ...loaderConfig });
2665
- }
2666
- var warning = {
2667
- silence: false
2668
- };
2669
- var getHttpAuthExtensionConfiguration = (runtimeConfig) => {
2670
- const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
2671
- let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
2672
- let _credentials = runtimeConfig.credentials;
2673
- return {
2674
- setHttpAuthScheme(httpAuthScheme) {
2675
- const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
2676
- if (index === -1) {
2677
- _httpAuthSchemes.push(httpAuthScheme);
2678
- } else {
2679
- _httpAuthSchemes.splice(index, 1, httpAuthScheme);
2680
- }
2681
- },
2682
- httpAuthSchemes() {
2683
- return _httpAuthSchemes;
2684
- },
2685
- setHttpAuthSchemeProvider(httpAuthSchemeProvider) {
2686
- _httpAuthSchemeProvider = httpAuthSchemeProvider;
2687
- },
2688
- httpAuthSchemeProvider() {
2689
- return _httpAuthSchemeProvider;
2690
- },
2691
- setCredentials(credentials) {
2692
- _credentials = credentials;
2693
- },
2694
- credentials() {
2695
- return _credentials;
2696
- }
2697
- };
2698
- };
2699
- var resolveHttpAuthRuntimeConfig = (config) => {
2700
- return {
2701
- httpAuthSchemes: config.httpAuthSchemes(),
2702
- httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
2703
- credentials: config.credentials()
2704
- };
2705
- };
2706
- var resolveRuntimeExtensions = (runtimeConfig, extensions) => {
2707
- const extensionConfiguration = Object.assign(getAwsRegionExtensionConfiguration(runtimeConfig), getDefaultExtensionConfiguration(runtimeConfig), getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));
2708
- extensions.forEach((extension) => extension.configure(extensionConfiguration));
2709
- return Object.assign(runtimeConfig, resolveAwsRegionExtensionConfiguration(extensionConfiguration), resolveDefaultRuntimeConfig(extensionConfiguration), resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));
2710
- };
2711
- var STSClient = class extends Client {
2712
- config;
2713
- constructor(...[configuration]) {
2714
- const _config_0 = getRuntimeConfig2(configuration || {});
2715
- super(_config_0);
2716
- this.initConfig = _config_0;
2717
- const _config_1 = resolveClientEndpointParameters(_config_0);
2718
- const _config_2 = resolveUserAgentConfig(_config_1);
2719
- const _config_3 = resolveRetryConfig(_config_2);
2720
- const _config_4 = resolveRegionConfig(_config_3);
2721
- const _config_5 = resolveHostHeaderConfig(_config_4);
2722
- const _config_6 = resolveEndpointConfig(_config_5);
2723
- const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
2724
- const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
2725
- this.config = _config_8;
2726
- this.middlewareStack.use(getSchemaSerdePlugin(this.config));
2727
- this.middlewareStack.use(getUserAgentPlugin(this.config));
2728
- this.middlewareStack.use(getRetryPlugin(this.config));
2729
- this.middlewareStack.use(getContentLengthPlugin(this.config));
2730
- this.middlewareStack.use(getHostHeaderPlugin(this.config));
2731
- this.middlewareStack.use(getLoggerPlugin(this.config));
2732
- this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
2733
- this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
2734
- httpAuthSchemeParametersProvider: defaultSTSHttpAuthSchemeParametersProvider,
2735
- identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
2736
- "aws.auth#sigv4": config.credentials
2737
- })
2738
- }));
2739
- this.middlewareStack.use(getHttpSigningPlugin(this.config));
2740
- }
2741
- destroy() {
2742
- super.destroy();
2743
- }
2744
- };
2745
- var AssumeRoleCommand = class extends Command.classBuilder().ep(commonParams).m(function(Command2, cs, config, o2) {
2746
- return [getEndpointPlugin(config, Command2.getEndpointParameterInstructions())];
2747
- }).s("AWSSecurityTokenServiceV20110615", "AssumeRole", {}).n("STSClient", "AssumeRoleCommand").sc(AssumeRole$).build() {
2748
- };
2749
- var AssumeRoleWithWebIdentityCommand = class extends Command.classBuilder().ep(commonParams).m(function(Command2, cs, config, o2) {
2750
- return [getEndpointPlugin(config, Command2.getEndpointParameterInstructions())];
2751
- }).s("AWSSecurityTokenServiceV20110615", "AssumeRoleWithWebIdentity", {}).n("STSClient", "AssumeRoleWithWebIdentityCommand").sc(AssumeRoleWithWebIdentity$).build() {
2752
- };
2753
- var commands = {
2754
- AssumeRoleCommand,
2755
- AssumeRoleWithWebIdentityCommand
2756
- };
2757
- var STS = class extends STSClient {
2758
- };
2759
- createAggregatedClient(commands, STS);
2760
- var getAccountIdFromAssumedRoleUser = (assumedRoleUser) => {
2761
- if (typeof assumedRoleUser?.Arn === "string") {
2762
- const arnComponents = assumedRoleUser.Arn.split(":");
2763
- if (arnComponents.length > 4 && arnComponents[4] !== "") {
2764
- return arnComponents[4];
2765
- }
2766
- }
2767
- return void 0;
2768
- };
2769
- var resolveRegion = async (_region, _parentRegion, credentialProviderLogger, loaderConfig = {}) => {
2770
- const region = typeof _region === "function" ? await _region() : _region;
2771
- const parentRegion = typeof _parentRegion === "function" ? await _parentRegion() : _parentRegion;
2772
- let stsDefaultRegion = "";
2773
- const resolvedRegion = region ?? parentRegion ?? (stsDefaultRegion = await stsRegionDefaultResolver(loaderConfig)());
2774
- 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)`);
2775
- return resolvedRegion;
2776
- };
2777
- var getDefaultRoleAssumer = (stsOptions, STSClient2) => {
2778
- let stsClient;
2779
- let closureSourceCreds;
2780
- return async (sourceCreds, params) => {
2781
- closureSourceCreds = sourceCreds;
2782
- if (!stsClient) {
2783
- const { logger = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
2784
- const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
2785
- logger,
2786
- profile
2787
- });
2788
- const isCompatibleRequestHandler = !isH2(requestHandler);
2789
- stsClient = new STSClient2({
2790
- ...stsOptions,
2791
- userAgentAppId,
2792
- profile,
2793
- credentialDefaultProvider: () => async () => closureSourceCreds,
2794
- region: resolvedRegion,
2795
- requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
2796
- logger
2797
- });
2798
- }
2799
- const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
2800
- if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
2801
- throw new Error(`Invalid response from STS.assumeRole call with role ${params.RoleArn}`);
2802
- }
2803
- const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
2804
- const credentials = {
2805
- accessKeyId: Credentials.AccessKeyId,
2806
- secretAccessKey: Credentials.SecretAccessKey,
2807
- sessionToken: Credentials.SessionToken,
2808
- expiration: Credentials.Expiration,
2809
- ...Credentials.CredentialScope && { credentialScope: Credentials.CredentialScope },
2810
- ...accountId && { accountId }
2811
- };
2812
- setCredentialFeature(credentials, "CREDENTIALS_STS_ASSUME_ROLE", "i");
2813
- return credentials;
2814
- };
2815
- };
2816
- var getDefaultRoleAssumerWithWebIdentity = (stsOptions, STSClient2) => {
2817
- let stsClient;
2818
- return async (params) => {
2819
- if (!stsClient) {
2820
- const { logger = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
2821
- const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
2822
- logger,
2823
- profile
2824
- });
2825
- const isCompatibleRequestHandler = !isH2(requestHandler);
2826
- stsClient = new STSClient2({
2827
- ...stsOptions,
2828
- userAgentAppId,
2829
- profile,
2830
- region: resolvedRegion,
2831
- requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
2832
- logger
2833
- });
2834
- }
2835
- const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
2836
- if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
2837
- throw new Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${params.RoleArn}`);
2838
- }
2839
- const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
2840
- const credentials = {
2841
- accessKeyId: Credentials.AccessKeyId,
2842
- secretAccessKey: Credentials.SecretAccessKey,
2843
- sessionToken: Credentials.SessionToken,
2844
- expiration: Credentials.Expiration,
2845
- ...Credentials.CredentialScope && { credentialScope: Credentials.CredentialScope },
2846
- ...accountId && { accountId }
2847
- };
2848
- if (accountId) {
2849
- setCredentialFeature(credentials, "RESOLVED_ACCOUNT_ID", "T");
2850
- }
2851
- setCredentialFeature(credentials, "CREDENTIALS_STS_ASSUME_ROLE_WEB_ID", "k");
2852
- return credentials;
2853
- };
2854
- };
2855
- var isH2 = (requestHandler) => {
2856
- return requestHandler?.metadata?.handlerProtocol === "h2";
2857
- };
2858
- var getCustomizableStsClientCtor = (baseCtor, customizations) => {
2859
- if (!customizations)
2860
- return baseCtor;
2861
- else
2862
- return class CustomizableSTSClient extends baseCtor {
2863
- constructor(config) {
2864
- super(config);
2865
- for (const customization of customizations) {
2866
- this.middlewareStack.use(customization);
2867
- }
2868
- }
2869
- };
2870
- };
2871
- var getDefaultRoleAssumer2 = (stsOptions = {}, stsPlugins) => getDefaultRoleAssumer(stsOptions, getCustomizableStsClientCtor(STSClient, stsPlugins));
2872
- var getDefaultRoleAssumerWithWebIdentity2 = (stsOptions = {}, stsPlugins) => getDefaultRoleAssumerWithWebIdentity(stsOptions, getCustomizableStsClientCtor(STSClient, stsPlugins));
2873
- var decorateDefaultCredentialProvider = (provider) => (input) => provider({
2874
- roleAssumer: getDefaultRoleAssumer2(input),
2875
- roleAssumerWithWebIdentity: getDefaultRoleAssumerWithWebIdentity2(input),
2876
- ...input
2877
- });
2878
- export {
2879
- Command as $Command,
2880
- AssumeRole$,
2881
- AssumeRoleCommand,
2882
- AssumeRoleRequest$,
2883
- AssumeRoleResponse$,
2884
- AssumeRoleWithWebIdentity$,
2885
- AssumeRoleWithWebIdentityCommand,
2886
- AssumeRoleWithWebIdentityRequest$,
2887
- AssumeRoleWithWebIdentityResponse$,
2888
- AssumedRoleUser$,
2889
- Credentials$,
2890
- ExpiredTokenException,
2891
- ExpiredTokenException$,
2892
- IDPCommunicationErrorException,
2893
- IDPCommunicationErrorException$,
2894
- IDPRejectedClaimException,
2895
- IDPRejectedClaimException$,
2896
- InvalidIdentityTokenException,
2897
- InvalidIdentityTokenException$,
2898
- MalformedPolicyDocumentException,
2899
- MalformedPolicyDocumentException$,
2900
- PackedPolicyTooLargeException,
2901
- PackedPolicyTooLargeException$,
2902
- PolicyDescriptorType$,
2903
- ProvidedContext$,
2904
- RegionDisabledException,
2905
- RegionDisabledException$,
2906
- STS,
2907
- STSClient,
2908
- STSServiceException,
2909
- STSServiceException$,
2910
- Tag$,
2911
- Client as __Client,
2912
- decorateDefaultCredentialProvider,
2913
- errorTypeRegistries,
2914
- getDefaultRoleAssumer2 as getDefaultRoleAssumer,
2915
- getDefaultRoleAssumerWithWebIdentity2 as getDefaultRoleAssumerWithWebIdentity
2916
- };
2917
- //# sourceMappingURL=sts-X7JGSP4H-PDAAYDDH.js.map