@authhero/saml 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/saml.mjs CHANGED
@@ -1,2196 +1,1725 @@
1
- var oe = Object.defineProperty;
2
- var ae = (t, e, n) => e in t ? oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var A = (t, e, n) => ae(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { z as i } from "@hono/zod-openapi";
5
- const N = i.object({ "#text": i.string() }), le = i.object({
6
- "#text": i.string(),
7
- "@_xmlns:saml": i.string().optional()
8
- }), ue = i.object({
9
- "samlp:AuthnRequest": i.object({
10
- "saml:Issuer": le,
11
- "@_xmlns:samlp": i.string(),
12
- "@_xmlns:saml": i.string().optional(),
13
- "@_ForceAuthn": i.string().transform((t) => t.toLowerCase() === "true").optional(),
14
- "@_ID": i.string(),
15
- "@_IssueInstant": i.string().datetime(),
16
- "@_Destination": i.string().url(),
17
- "@_AssertionConsumerServiceURL": i.string().url().optional(),
18
- "@_ProtocolBinding": i.string().optional(),
19
- "@_Version": i.string()
20
- })
21
- }), Mt = i.array(
22
- i.object({
23
- ":@": i.object({
24
- "@_xmlns": i.string(),
25
- "@_entityID": i.string()
26
- }),
27
- EntityDescriptor: i.array(
28
- i.object({
29
- ":@": i.object({
30
- "@_protocolSupportEnumeration": i.string()
31
- }),
32
- IDPSSODescriptor: i.array(
33
- i.union([
34
- i.object({
35
- KeyDescriptor: i.array(
36
- i.object({
37
- KeyInfo: i.array(
38
- i.object({
39
- X509Data: i.array(
40
- i.object({
41
- X509Certificate: i.array(N)
42
- })
43
- )
44
- })
45
- ),
46
- ":@": i.object({
47
- "@_xmlns": i.string()
48
- })
49
- })
50
- ),
51
- ":@": i.object({
52
- "@_use": i.string()
53
- })
54
- }),
55
- i.object({
56
- SingleLogoutService: i.array(i.object({})),
57
- ":@": i.object({
58
- "@_Binding": i.string(),
59
- "@_Location": i.string()
60
- })
61
- }),
62
- i.object({
63
- NameIDFormat: i.array(N)
64
- }),
65
- i.object({
66
- SingleSignOnService: i.array(i.object({})),
67
- ":@": i.object({
68
- "@_Binding": i.string(),
69
- "@_Location": i.string()
70
- })
71
- }),
72
- i.object({
73
- Attribute: i.array(i.object({})),
74
- ":@": i.object({
75
- "@_Name": i.string(),
76
- "@_NameFormat": i.string(),
77
- "@_FriendlyName": i.string(),
78
- "@_xmlns": i.string()
79
- })
80
- })
81
- ])
82
- )
83
- })
84
- )
85
- })
86
- ), ce = i.object({
87
- "saml:Attribute": i.array(
88
- i.object({
89
- "saml:AttributeValue": i.array(
90
- i.object({
91
- "#text": i.string()
92
- })
93
- ),
94
- ":@": i.object({
95
- "@_xmlns:xs": i.string().optional(),
96
- "@_xmlns:xsi": i.string(),
97
- "@_xsi:type": i.string()
98
- }).optional()
99
- })
100
- ),
101
- ":@": i.object({
102
- "@_Name": i.string(),
103
- "@_NameFormat": i.string(),
104
- "@_FriendlyName": i.string().optional()
105
- })
106
- }), de = i.object({
107
- "ds:Transform": i.array(i.any()),
108
- ":@": i.object({
109
- "@_Algorithm": i.string()
110
- })
111
- }), X = i.object({
112
- "ds:Signature": i.array(
113
- i.union([
114
- i.object({
115
- "ds:SignedInfo": i.array(
116
- i.union([
117
- i.object({
118
- "ds:CanonicalizationMethod": i.array(
119
- i.object({
120
- ":@": i.object({
121
- "@_Algorithm": i.string()
122
- })
123
- })
124
- )
125
- }),
126
- i.object({
127
- "ds:SignatureMethod": i.array(
128
- i.object({
129
- ":@": i.object({
130
- "@_Algorithm": i.string()
131
- })
132
- })
133
- )
134
- }),
135
- i.object({
136
- "ds:Reference": i.array(
137
- i.union([
138
- i.object({
139
- "ds:Transforms": i.array(de)
140
- }),
141
- i.object({
142
- "ds:DigestMethod": i.array(
143
- i.object({
144
- ":@": i.object({
145
- "@_Algorithm": i.string()
146
- })
147
- })
148
- )
149
- }),
150
- i.object({ "ds:DigestValue": i.array(N) })
151
- ])
152
- ),
153
- ":@": i.object({
154
- "@_URI": i.string().optional()
155
- }).optional()
156
- })
157
- ])
158
- )
159
- }),
160
- i.object({
161
- "ds:SignatureValue": i.array(N)
162
- }),
163
- i.object({
164
- "ds:KeyInfo": i.array(
165
- i.union([
166
- i.object({
167
- "ds:KeyValue": i.array(
168
- i.object({
169
- "ds:RSAKeyValue": i.array(
170
- i.union([
171
- i.object({
172
- "ds:Modulus": i.array(N)
173
- }),
174
- i.object({
175
- "ds:Exponent": i.array(N)
176
- })
177
- ])
178
- )
179
- })
180
- )
181
- }),
182
- i.object({
183
- "ds:X509Data": i.array(
184
- i.object({
185
- "ds:X509Certificate": i.array(N)
186
- })
187
- )
188
- }),
189
- // Support KeyInfo with both KeyValue and X509Data
190
- i.object({
191
- "ds:KeyValue": i.array(
192
- i.object({
193
- "ds:RSAKeyValue": i.array(
194
- i.union([
195
- i.object({
196
- "ds:Modulus": i.array(N)
197
- }),
198
- i.object({
199
- "ds:Exponent": i.array(N)
200
- })
201
- ])
202
- )
203
- })
204
- ),
205
- "ds:X509Data": i.array(
206
- i.object({
207
- "ds:X509Certificate": i.array(N)
208
- })
209
- )
210
- })
211
- ])
212
- )
213
- })
214
- ])
215
- ),
216
- ":@": i.object({
217
- "@_xmlns:ds": i.string().optional()
218
- }).optional()
219
- }), jt = i.array(
220
- i.object({
221
- "samlp:Response": i.array(
222
- i.union([
223
- i.object({
224
- "saml:Issuer": i.array(N)
225
- }),
226
- X,
227
- i.object({
228
- "samlp:Status": i.array(
229
- i.object({
230
- "samlp:StatusCode": i.array(N),
231
- ":@": i.object({
232
- "@_Value": i.string()
233
- })
234
- })
235
- )
236
- }),
237
- i.object({
238
- "saml:Assertion": i.array(
239
- i.union([
240
- i.object({
241
- "saml:Issuer": i.array(N)
242
- }),
243
- X,
244
- i.object({
245
- "saml:Subject": i.array(
246
- i.union([
247
- i.object({
248
- "saml:NameID": i.array(N),
249
- ":@": i.object({
250
- "@_Format": i.string()
251
- })
252
- }),
253
- i.object({
254
- "saml:SubjectConfirmation": i.array(
255
- i.object({
256
- "saml:SubjectConfirmationData": i.array(i.any()),
257
- ":@": i.object({
258
- "@_InResponseTo": i.string(),
259
- "@_NotOnOrAfter": i.string(),
260
- "@_Recipient": i.string()
261
- })
262
- })
263
- ),
264
- ":@": i.object({
265
- "@_Method": i.string()
266
- })
267
- })
268
- ])
269
- )
270
- }),
271
- i.object({
272
- "saml:Conditions": i.array(
273
- i.object({
274
- "saml:AudienceRestriction": i.array(
275
- i.object({
276
- "saml:Audience": i.array(N)
277
- })
278
- )
279
- })
280
- ),
281
- ":@": i.object({
282
- "@_NotBefore": i.string(),
283
- "@_NotOnOrAfter": i.string()
284
- })
285
- }),
286
- i.object({
287
- "saml:AuthnStatement": i.array(
288
- i.object({
289
- "saml:AuthnContext": i.array(
290
- i.object({
291
- "saml:AuthnContextClassRef": i.array(N)
292
- })
293
- )
294
- })
295
- ),
296
- ":@": i.object({
297
- "@_AuthnInstant": i.string(),
298
- "@_SessionIndex": i.string(),
299
- "@_SessionNotOnOrAfter": i.string()
300
- })
301
- }),
302
- i.object({
303
- "saml:AttributeStatement": i.array(ce)
304
- })
305
- ])
306
- ),
307
- ":@": i.object({
308
- "@_xmlns": i.string(),
309
- "@_ID": i.string(),
310
- "@_IssueInstant": i.string(),
311
- "@_Version": i.string()
312
- })
313
- })
314
- ])
315
- ),
316
- ":@": i.object({
317
- "@_xmlns:samlp": i.string(),
318
- "@_xmlns:saml": i.string(),
319
- "@_Destination": i.string(),
320
- "@_ID": i.string(),
321
- "@_InResponseTo": i.string(),
322
- "@_IssueInstant": i.string(),
323
- "@_Version": i.string()
324
- })
325
- })
326
- );
327
- var Z = {}, P = {};
328
- (function(t) {
329
- const e = ":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", n = e + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", s = "[" + e + "][" + n + "]*", r = new RegExp("^" + s + "$"), o = function(u, f) {
330
- const d = [];
331
- let h = f.exec(u);
332
- for (; h; ) {
333
- const m = [];
334
- m.startIndex = f.lastIndex - h[0].length;
335
- const b = h.length;
336
- for (let y = 0; y < b; y++)
337
- m.push(h[y]);
338
- d.push(m), h = f.exec(u);
339
- }
340
- return d;
341
- }, a = function(u) {
342
- const f = r.exec(u);
343
- return !(f === null || typeof f > "u");
344
- };
345
- t.isExist = function(u) {
346
- return typeof u < "u";
347
- }, t.isEmptyObject = function(u) {
348
- return Object.keys(u).length === 0;
349
- }, t.merge = function(u, f, d) {
350
- if (f) {
351
- const h = Object.keys(f), m = h.length;
352
- for (let b = 0; b < m; b++)
353
- d === "strict" ? u[h[b]] = [f[h[b]]] : u[h[b]] = f[h[b]];
354
- }
355
- }, t.getValue = function(u) {
356
- return t.isExist(u) ? u : "";
357
- };
358
- const c = [
359
- // '__proto__',
360
- // 'constructor',
361
- // 'prototype',
362
- "hasOwnProperty",
363
- "toString",
364
- "valueOf",
365
- "__defineGetter__",
366
- "__defineSetter__",
367
- "__lookupGetter__",
368
- "__lookupSetter__"
369
- ], l = ["__proto__", "constructor", "prototype"];
370
- t.isName = a, t.getAllMatches = o, t.nameRegexp = s, t.DANGEROUS_PROPERTY_NAMES = c, t.criticalProperties = l;
371
- })(P);
372
- const V = P, fe = {
373
- allowBooleanAttributes: !1,
374
- //A tag can have attributes without any value
375
- unpairedTags: []
1
+ import { z as e } from "@hono/zod-openapi";
2
+ //#region \0rolldown/runtime.js
3
+ var t = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), n = e.object({ "#text": e.string() }), r = e.object({
4
+ "#text": e.string(),
5
+ "@_xmlns:saml": e.string().optional()
6
+ }), i = e.object({ "samlp:AuthnRequest": e.object({
7
+ "saml:Issuer": r,
8
+ "@_xmlns:samlp": e.string(),
9
+ "@_xmlns:saml": e.string().optional(),
10
+ "@_ForceAuthn": e.string().transform((e) => e.toLowerCase() === "true").optional(),
11
+ "@_ID": e.string(),
12
+ "@_IssueInstant": e.string().datetime(),
13
+ "@_Destination": e.string().url(),
14
+ "@_AssertionConsumerServiceURL": e.string().url().optional(),
15
+ "@_ProtocolBinding": e.string().optional(),
16
+ "@_Version": e.string()
17
+ }) }), a = e.array(e.object({
18
+ ":@": e.object({
19
+ "@_xmlns": e.string(),
20
+ "@_entityID": e.string()
21
+ }),
22
+ EntityDescriptor: e.array(e.object({
23
+ ":@": e.object({ "@_protocolSupportEnumeration": e.string() }),
24
+ IDPSSODescriptor: e.array(e.union([
25
+ e.object({
26
+ KeyDescriptor: e.array(e.object({
27
+ KeyInfo: e.array(e.object({ X509Data: e.array(e.object({ X509Certificate: e.array(n) })) })),
28
+ ":@": e.object({ "@_xmlns": e.string() })
29
+ })),
30
+ ":@": e.object({ "@_use": e.string() })
31
+ }),
32
+ e.object({
33
+ SingleLogoutService: e.array(e.object({})),
34
+ ":@": e.object({
35
+ "@_Binding": e.string(),
36
+ "@_Location": e.string()
37
+ })
38
+ }),
39
+ e.object({ NameIDFormat: e.array(n) }),
40
+ e.object({
41
+ SingleSignOnService: e.array(e.object({})),
42
+ ":@": e.object({
43
+ "@_Binding": e.string(),
44
+ "@_Location": e.string()
45
+ })
46
+ }),
47
+ e.object({
48
+ Attribute: e.array(e.object({})),
49
+ ":@": e.object({
50
+ "@_Name": e.string(),
51
+ "@_NameFormat": e.string(),
52
+ "@_FriendlyName": e.string(),
53
+ "@_xmlns": e.string()
54
+ })
55
+ })
56
+ ]))
57
+ }))
58
+ })), o = e.object({
59
+ "saml:Attribute": e.array(e.object({
60
+ "saml:AttributeValue": e.array(e.object({ "#text": e.string() })),
61
+ ":@": e.object({
62
+ "@_xmlns:xs": e.string().optional(),
63
+ "@_xmlns:xsi": e.string(),
64
+ "@_xsi:type": e.string()
65
+ }).optional()
66
+ })),
67
+ ":@": e.object({
68
+ "@_Name": e.string(),
69
+ "@_NameFormat": e.string(),
70
+ "@_FriendlyName": e.string().optional()
71
+ })
72
+ }), s = e.object({
73
+ "ds:Transform": e.array(e.any()),
74
+ ":@": e.object({ "@_Algorithm": e.string() })
75
+ }), c = e.object({
76
+ "ds:Signature": e.array(e.union([
77
+ e.object({ "ds:SignedInfo": e.array(e.union([
78
+ e.object({ "ds:CanonicalizationMethod": e.array(e.object({ ":@": e.object({ "@_Algorithm": e.string() }) })) }),
79
+ e.object({ "ds:SignatureMethod": e.array(e.object({ ":@": e.object({ "@_Algorithm": e.string() }) })) }),
80
+ e.object({
81
+ "ds:Reference": e.array(e.union([
82
+ e.object({ "ds:Transforms": e.array(s) }),
83
+ e.object({ "ds:DigestMethod": e.array(e.object({ ":@": e.object({ "@_Algorithm": e.string() }) })) }),
84
+ e.object({ "ds:DigestValue": e.array(n) })
85
+ ])),
86
+ ":@": e.object({ "@_URI": e.string().optional() }).optional()
87
+ })
88
+ ])) }),
89
+ e.object({ "ds:SignatureValue": e.array(n) }),
90
+ e.object({ "ds:KeyInfo": e.array(e.union([
91
+ e.object({ "ds:KeyValue": e.array(e.object({ "ds:RSAKeyValue": e.array(e.union([e.object({ "ds:Modulus": e.array(n) }), e.object({ "ds:Exponent": e.array(n) })])) })) }),
92
+ e.object({ "ds:X509Data": e.array(e.object({ "ds:X509Certificate": e.array(n) })) }),
93
+ e.object({
94
+ "ds:KeyValue": e.array(e.object({ "ds:RSAKeyValue": e.array(e.union([e.object({ "ds:Modulus": e.array(n) }), e.object({ "ds:Exponent": e.array(n) })])) })),
95
+ "ds:X509Data": e.array(e.object({ "ds:X509Certificate": e.array(n) }))
96
+ })
97
+ ])) })
98
+ ])),
99
+ ":@": e.object({ "@_xmlns:ds": e.string().optional() }).optional()
100
+ }), l = e.array(e.object({
101
+ "samlp:Response": e.array(e.union([
102
+ e.object({ "saml:Issuer": e.array(n) }),
103
+ c,
104
+ e.object({ "samlp:Status": e.array(e.object({
105
+ "samlp:StatusCode": e.array(n),
106
+ ":@": e.object({ "@_Value": e.string() })
107
+ })) }),
108
+ e.object({
109
+ "saml:Assertion": e.array(e.union([
110
+ e.object({ "saml:Issuer": e.array(n) }),
111
+ c,
112
+ e.object({ "saml:Subject": e.array(e.union([e.object({
113
+ "saml:NameID": e.array(n),
114
+ ":@": e.object({ "@_Format": e.string() })
115
+ }), e.object({
116
+ "saml:SubjectConfirmation": e.array(e.object({
117
+ "saml:SubjectConfirmationData": e.array(e.any()),
118
+ ":@": e.object({
119
+ "@_InResponseTo": e.string(),
120
+ "@_NotOnOrAfter": e.string(),
121
+ "@_Recipient": e.string()
122
+ })
123
+ })),
124
+ ":@": e.object({ "@_Method": e.string() })
125
+ })])) }),
126
+ e.object({
127
+ "saml:Conditions": e.array(e.object({ "saml:AudienceRestriction": e.array(e.object({ "saml:Audience": e.array(n) })) })),
128
+ ":@": e.object({
129
+ "@_NotBefore": e.string(),
130
+ "@_NotOnOrAfter": e.string()
131
+ })
132
+ }),
133
+ e.object({
134
+ "saml:AuthnStatement": e.array(e.object({ "saml:AuthnContext": e.array(e.object({ "saml:AuthnContextClassRef": e.array(n) })) })),
135
+ ":@": e.object({
136
+ "@_AuthnInstant": e.string(),
137
+ "@_SessionIndex": e.string(),
138
+ "@_SessionNotOnOrAfter": e.string()
139
+ })
140
+ }),
141
+ e.object({ "saml:AttributeStatement": e.array(o) })
142
+ ])),
143
+ ":@": e.object({
144
+ "@_xmlns": e.string(),
145
+ "@_ID": e.string(),
146
+ "@_IssueInstant": e.string(),
147
+ "@_Version": e.string()
148
+ })
149
+ })
150
+ ])),
151
+ ":@": e.object({
152
+ "@_xmlns:samlp": e.string(),
153
+ "@_xmlns:saml": e.string(),
154
+ "@_Destination": e.string(),
155
+ "@_ID": e.string(),
156
+ "@_InResponseTo": e.string(),
157
+ "@_IssueInstant": e.string(),
158
+ "@_Version": e.string()
159
+ })
160
+ })), u = /* @__PURE__ */ t(((e) => {
161
+ var t = "[: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][: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\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*", n = /* @__PURE__ */ RegExp("^[: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][: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\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");
162
+ e.isExist = function(e) {
163
+ return e !== void 0;
164
+ }, e.isEmptyObject = function(e) {
165
+ return Object.keys(e).length === 0;
166
+ }, e.merge = function(e, t, n) {
167
+ if (t) {
168
+ let r = Object.keys(t), i = r.length;
169
+ for (let a = 0; a < i; a++) n === "strict" ? e[r[a]] = [t[r[a]]] : e[r[a]] = t[r[a]];
170
+ }
171
+ }, e.getValue = function(t) {
172
+ return e.isExist(t) ? t : "";
173
+ }, e.isName = function(e) {
174
+ return n.exec(e) != null;
175
+ }, e.getAllMatches = function(e, t) {
176
+ let n = [], r = t.exec(e);
177
+ for (; r;) {
178
+ let i = [];
179
+ i.startIndex = t.lastIndex - r[0].length;
180
+ let a = r.length;
181
+ for (let e = 0; e < a; e++) i.push(r[e]);
182
+ n.push(i), r = t.exec(e);
183
+ }
184
+ return n;
185
+ }, e.nameRegexp = t, e.DANGEROUS_PROPERTY_NAMES = [
186
+ "hasOwnProperty",
187
+ "toString",
188
+ "valueOf",
189
+ "__defineGetter__",
190
+ "__defineSetter__",
191
+ "__lookupGetter__",
192
+ "__lookupSetter__"
193
+ ], e.criticalProperties = [
194
+ "__proto__",
195
+ "constructor",
196
+ "prototype"
197
+ ];
198
+ })), d = /* @__PURE__ */ t(((e) => {
199
+ var t = u(), n = {
200
+ allowBooleanAttributes: !1,
201
+ unpairedTags: []
202
+ };
203
+ e.validate = function(e, t) {
204
+ t = Object.assign({}, n, t);
205
+ let o = [], s = !1, l = !1;
206
+ e[0] === "" && (e = e.substr(1));
207
+ for (let n = 0; n < e.length; n++) if (e[n] === "<" && e[n + 1] === "?") {
208
+ if (n += 2, n = i(e, n), n.err) return n;
209
+ } else if (e[n] === "<") {
210
+ let u = n;
211
+ if (n++, e[n] === "!") {
212
+ n = a(e, n);
213
+ continue;
214
+ } else {
215
+ let f = !1;
216
+ e[n] === "/" && (f = !0, n++);
217
+ let h = "";
218
+ for (; n < e.length && e[n] !== ">" && e[n] !== " " && e[n] !== " " && e[n] !== "\n" && e[n] !== "\r"; n++) h += e[n];
219
+ if (h = h.trim(), h[h.length - 1] === "/" && (h = h.substring(0, h.length - 1), n--), !g(h)) {
220
+ let t;
221
+ return t = h.trim().length === 0 ? "Invalid space after '<'." : "Tag '" + h + "' is an invalid name.", m("InvalidTag", t, _(e, n));
222
+ }
223
+ let v = c(e, n);
224
+ if (v === !1) return m("InvalidAttr", "Attributes for '" + h + "' have open quote.", _(e, n));
225
+ let y = v.value;
226
+ if (n = v.index, y[y.length - 1] === "/") {
227
+ let r = n - y.length;
228
+ y = y.substring(0, y.length - 1);
229
+ let i = d(y, t);
230
+ if (i === !0) s = !0;
231
+ else return m(i.err.code, i.err.msg, _(e, r + i.err.line));
232
+ } else if (f) {
233
+ if (!v.tagClosed) return m("InvalidTag", "Closing tag '" + h + "' doesn't have proper closing.", _(e, n));
234
+ if (y.trim().length > 0) return m("InvalidTag", "Closing tag '" + h + "' can't have attributes or invalid starting.", _(e, u));
235
+ if (o.length === 0) return m("InvalidTag", "Closing tag '" + h + "' has not been opened.", _(e, u));
236
+ {
237
+ let t = o.pop();
238
+ if (h !== t.tagName) {
239
+ let n = _(e, t.tagStartPos);
240
+ return m("InvalidTag", "Expected closing tag '" + t.tagName + "' (opened in line " + n.line + ", col " + n.col + ") instead of closing tag '" + h + "'.", _(e, u));
241
+ }
242
+ o.length == 0 && (l = !0);
243
+ }
244
+ } else {
245
+ let r = d(y, t);
246
+ if (r !== !0) return m(r.err.code, r.err.msg, _(e, n - y.length + r.err.line));
247
+ if (l === !0) return m("InvalidXml", "Multiple possible root nodes found.", _(e, n));
248
+ t.unpairedTags.indexOf(h) !== -1 || o.push({
249
+ tagName: h,
250
+ tagStartPos: u
251
+ }), s = !0;
252
+ }
253
+ for (n++; n < e.length; n++) if (e[n] === "<") if (e[n + 1] === "!") {
254
+ n++, n = a(e, n);
255
+ continue;
256
+ } else if (e[n + 1] === "?") {
257
+ if (n = i(e, ++n), n.err) return n;
258
+ } else break;
259
+ else if (e[n] === "&") {
260
+ let t = p(e, n);
261
+ if (t == -1) return m("InvalidChar", "char '&' is not expected.", _(e, n));
262
+ n = t;
263
+ } else if (l === !0 && !r(e[n])) return m("InvalidXml", "Extra text at the end", _(e, n));
264
+ e[n] === "<" && n--;
265
+ }
266
+ } else {
267
+ if (r(e[n])) continue;
268
+ return m("InvalidChar", "char '" + e[n] + "' is not expected.", _(e, n));
269
+ }
270
+ return s ? o.length == 1 ? m("InvalidTag", "Unclosed tag '" + o[0].tagName + "'.", _(e, o[0].tagStartPos)) : o.length > 0 ? m("InvalidXml", "Invalid '" + JSON.stringify(o.map((e) => e.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", {
271
+ line: 1,
272
+ col: 1
273
+ }) : !0 : m("InvalidXml", "Start tag expected.", 1);
274
+ };
275
+ function r(e) {
276
+ return e === " " || e === " " || e === "\n" || e === "\r";
277
+ }
278
+ function i(e, t) {
279
+ let n = t;
280
+ for (; t < e.length; t++) if (e[t] == "?" || e[t] == " ") {
281
+ let r = e.substr(n, t - n);
282
+ if (t > 5 && r === "xml") return m("InvalidXml", "XML declaration allowed only at the start of the document.", _(e, t));
283
+ if (e[t] == "?" && e[t + 1] == ">") {
284
+ t++;
285
+ break;
286
+ } else continue;
287
+ }
288
+ return t;
289
+ }
290
+ function a(e, t) {
291
+ if (e.length > t + 5 && e[t + 1] === "-" && e[t + 2] === "-") {
292
+ for (t += 3; t < e.length; t++) if (e[t] === "-" && e[t + 1] === "-" && e[t + 2] === ">") {
293
+ t += 2;
294
+ break;
295
+ }
296
+ } else if (e.length > t + 8 && e[t + 1] === "D" && e[t + 2] === "O" && e[t + 3] === "C" && e[t + 4] === "T" && e[t + 5] === "Y" && e[t + 6] === "P" && e[t + 7] === "E") {
297
+ let n = 1;
298
+ for (t += 8; t < e.length; t++) if (e[t] === "<") n++;
299
+ else if (e[t] === ">" && (n--, n === 0)) break;
300
+ } else if (e.length > t + 9 && e[t + 1] === "[" && e[t + 2] === "C" && e[t + 3] === "D" && e[t + 4] === "A" && e[t + 5] === "T" && e[t + 6] === "A" && e[t + 7] === "[") {
301
+ for (t += 8; t < e.length; t++) if (e[t] === "]" && e[t + 1] === "]" && e[t + 2] === ">") {
302
+ t += 2;
303
+ break;
304
+ }
305
+ }
306
+ return t;
307
+ }
308
+ var o = "\"", s = "'";
309
+ function c(e, t) {
310
+ let n = "", r = "", i = !1;
311
+ for (; t < e.length; t++) {
312
+ if (e[t] === o || e[t] === s) r === "" ? r = e[t] : r !== e[t] || (r = "");
313
+ else if (e[t] === ">" && r === "") {
314
+ i = !0;
315
+ break;
316
+ }
317
+ n += e[t];
318
+ }
319
+ return r === "" ? {
320
+ value: n,
321
+ index: t,
322
+ tagClosed: i
323
+ } : !1;
324
+ }
325
+ var l = /* @__PURE__ */ RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?", "g");
326
+ function d(e, n) {
327
+ let r = t.getAllMatches(e, l), i = {};
328
+ for (let e = 0; e < r.length; e++) {
329
+ if (r[e][1].length === 0) return m("InvalidAttr", "Attribute '" + r[e][2] + "' has no space in starting.", v(r[e]));
330
+ if (r[e][3] !== void 0 && r[e][4] === void 0) return m("InvalidAttr", "Attribute '" + r[e][2] + "' is without value.", v(r[e]));
331
+ if (r[e][3] === void 0 && !n.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + r[e][2] + "' is not allowed.", v(r[e]));
332
+ let t = r[e][2];
333
+ if (!h(t)) return m("InvalidAttr", "Attribute '" + t + "' is an invalid name.", v(r[e]));
334
+ if (!i.hasOwnProperty(t)) i[t] = 1;
335
+ else return m("InvalidAttr", "Attribute '" + t + "' is repeated.", v(r[e]));
336
+ }
337
+ return !0;
338
+ }
339
+ function f(e, t) {
340
+ let n = /\d/;
341
+ for (e[t] === "x" && (t++, n = /[\da-fA-F]/); t < e.length; t++) {
342
+ if (e[t] === ";") return t;
343
+ if (!e[t].match(n)) break;
344
+ }
345
+ return -1;
346
+ }
347
+ function p(e, t) {
348
+ if (t++, e[t] === ";") return -1;
349
+ if (e[t] === "#") return t++, f(e, t);
350
+ let n = 0;
351
+ for (; t < e.length; t++, n++) if (!(e[t].match(/\w/) && n < 20)) {
352
+ if (e[t] === ";") break;
353
+ return -1;
354
+ }
355
+ return t;
356
+ }
357
+ function m(e, t, n) {
358
+ return { err: {
359
+ code: e,
360
+ msg: t,
361
+ line: n.line || n,
362
+ col: n.col
363
+ } };
364
+ }
365
+ function h(e) {
366
+ return t.isName(e);
367
+ }
368
+ function g(e) {
369
+ return t.isName(e);
370
+ }
371
+ function _(e, t) {
372
+ let n = e.substring(0, t).split(/\r?\n/);
373
+ return {
374
+ line: n.length,
375
+ col: n[n.length - 1].length + 1
376
+ };
377
+ }
378
+ function v(e) {
379
+ return e.startIndex + e[1].length;
380
+ }
381
+ })), f = /* @__PURE__ */ t(((e) => {
382
+ var { DANGEROUS_PROPERTY_NAMES: t, criticalProperties: n } = u(), r = (e) => t.includes(e) ? "__" + e : e, i = {
383
+ preserveOrder: !1,
384
+ attributeNamePrefix: "@_",
385
+ attributesGroupName: !1,
386
+ textNodeName: "#text",
387
+ ignoreAttributes: !0,
388
+ removeNSPrefix: !1,
389
+ allowBooleanAttributes: !1,
390
+ parseTagValue: !0,
391
+ parseAttributeValue: !1,
392
+ trimValues: !0,
393
+ cdataPropName: !1,
394
+ numberParseOptions: {
395
+ hex: !0,
396
+ leadingZeros: !0,
397
+ eNotation: !0
398
+ },
399
+ tagValueProcessor: function(e, t) {
400
+ return t;
401
+ },
402
+ attributeValueProcessor: function(e, t) {
403
+ return t;
404
+ },
405
+ stopNodes: [],
406
+ alwaysCreateTextNode: !1,
407
+ isArray: () => !1,
408
+ commentPropName: !1,
409
+ unpairedTags: [],
410
+ processEntities: !0,
411
+ htmlEntities: !1,
412
+ ignoreDeclaration: !1,
413
+ ignorePiTags: !1,
414
+ transformTagName: !1,
415
+ transformAttributeName: !1,
416
+ updateTag: function(e, t, n) {
417
+ return e;
418
+ },
419
+ captureMetaData: !1,
420
+ maxNestedTags: 100,
421
+ strictReservedNames: !0,
422
+ onDangerousProperty: r
423
+ };
424
+ function a(e, r) {
425
+ if (typeof e != "string") return;
426
+ let i = e.toLowerCase();
427
+ if (t.some((e) => i === e.toLowerCase()) || n.some((e) => i === e.toLowerCase())) throw Error(`[SECURITY] Invalid ${r}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);
428
+ }
429
+ function o(e) {
430
+ return typeof e == "boolean" ? {
431
+ enabled: e,
432
+ maxEntitySize: 1e4,
433
+ maxExpansionDepth: 10,
434
+ maxTotalExpansions: 1e3,
435
+ maxExpandedLength: 1e5,
436
+ allowedTags: null,
437
+ tagFilter: null
438
+ } : typeof e == "object" && e ? {
439
+ enabled: e.enabled !== !1,
440
+ maxEntitySize: Math.max(1, e.maxEntitySize ?? 1e4),
441
+ maxExpansionDepth: Math.max(1, e.maxExpansionDepth ?? 1e4),
442
+ maxTotalExpansions: Math.max(1, e.maxTotalExpansions ?? Infinity),
443
+ maxExpandedLength: Math.max(1, e.maxExpandedLength ?? 1e5),
444
+ maxEntityCount: Math.max(1, e.maxEntityCount ?? 1e3),
445
+ allowedTags: e.allowedTags ?? null,
446
+ tagFilter: e.tagFilter ?? null
447
+ } : o(!0);
448
+ }
449
+ e.buildOptions = function(e) {
450
+ let t = Object.assign({}, i, e), n = [
451
+ {
452
+ value: t.attributeNamePrefix,
453
+ name: "attributeNamePrefix"
454
+ },
455
+ {
456
+ value: t.attributesGroupName,
457
+ name: "attributesGroupName"
458
+ },
459
+ {
460
+ value: t.textNodeName,
461
+ name: "textNodeName"
462
+ },
463
+ {
464
+ value: t.cdataPropName,
465
+ name: "cdataPropName"
466
+ },
467
+ {
468
+ value: t.commentPropName,
469
+ name: "commentPropName"
470
+ }
471
+ ];
472
+ for (let { value: e, name: t } of n) e && a(e, t);
473
+ return t.onDangerousProperty === null && (t.onDangerousProperty = r), t.processEntities = o(t.processEntities), t;
474
+ }, e.defaultOptions = i;
475
+ })), p = /* @__PURE__ */ t(((e, t) => {
476
+ t.exports = class {
477
+ constructor(e) {
478
+ this.tagname = e, this.child = [], this[":@"] = {};
479
+ }
480
+ add(e, t) {
481
+ e === "__proto__" && (e = "#__proto__"), this.child.push({ [e]: t });
482
+ }
483
+ addChild(e) {
484
+ e.tagname === "__proto__" && (e.tagname = "#__proto__"), e[":@"] && Object.keys(e[":@"]).length > 0 ? this.child.push({
485
+ [e.tagname]: e.child,
486
+ ":@": e[":@"]
487
+ }) : this.child.push({ [e.tagname]: e.child });
488
+ }
489
+ };
490
+ })), m = /* @__PURE__ */ t(((e, t) => {
491
+ var n = u(), r = class {
492
+ constructor(e) {
493
+ this.suppressValidationErr = !e, this.options = e || {};
494
+ }
495
+ readDocType(e, t) {
496
+ let n = Object.create(null), r = 0;
497
+ if (e[t + 3] === "O" && e[t + 4] === "C" && e[t + 5] === "T" && e[t + 6] === "Y" && e[t + 7] === "P" && e[t + 8] === "E") {
498
+ t += 9;
499
+ let i = 1, o = !1, s = !1, c = "";
500
+ for (; t < e.length; t++) if (e[t] === "<" && !s) {
501
+ if (o && a(e, "!ENTITY", t)) {
502
+ t += 7;
503
+ let i, a;
504
+ if ([i, a, t] = this.readEntityExp(e, t + 1, this.suppressValidationErr), a.indexOf("&") === -1) {
505
+ if (this.options.enabled !== !1 && this.options.maxEntityCount != null && r >= this.options.maxEntityCount) throw Error(`Entity count (${r + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`);
506
+ let e = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
507
+ n[i] = {
508
+ regx: RegExp(`&${e};`, "g"),
509
+ val: a
510
+ }, r++;
511
+ }
512
+ } else if (o && a(e, "!ELEMENT", t)) {
513
+ t += 8;
514
+ let { index: n } = this.readElementExp(e, t + 1);
515
+ t = n;
516
+ } else if (o && a(e, "!ATTLIST", t)) t += 8;
517
+ else if (o && a(e, "!NOTATION", t)) {
518
+ t += 9;
519
+ let { index: n } = this.readNotationExp(e, t + 1, this.suppressValidationErr);
520
+ t = n;
521
+ } else if (a(e, "!--", t)) s = !0;
522
+ else throw Error("Invalid DOCTYPE");
523
+ i++, c = "";
524
+ } else if (e[t] === ">") {
525
+ if (s ? e[t - 1] === "-" && e[t - 2] === "-" && (s = !1, i--) : i--, i === 0) break;
526
+ } else e[t] === "[" ? o = !0 : c += e[t];
527
+ if (i !== 0) throw Error("Unclosed DOCTYPE");
528
+ } else throw Error("Invalid Tag instead of DOCTYPE");
529
+ return {
530
+ entities: n,
531
+ i: t
532
+ };
533
+ }
534
+ readEntityExp(e, t) {
535
+ t = i(e, t);
536
+ let n = "";
537
+ for (; t < e.length && !/\s/.test(e[t]) && e[t] !== "\"" && e[t] !== "'";) n += e[t], t++;
538
+ if (o(n), t = i(e, t), !this.suppressValidationErr) {
539
+ if (e.substring(t, t + 6).toUpperCase() === "SYSTEM") throw Error("External entities are not supported");
540
+ if (e[t] === "%") throw Error("Parameter entities are not supported");
541
+ }
542
+ let r = "";
543
+ if ([t, r] = this.readIdentifierVal(e, t, "entity"), this.options.enabled !== !1 && this.options.maxEntitySize != null && r.length > this.options.maxEntitySize) throw Error(`Entity "${n}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);
544
+ return t--, [
545
+ n,
546
+ r,
547
+ t
548
+ ];
549
+ }
550
+ readNotationExp(e, t) {
551
+ t = i(e, t);
552
+ let n = "";
553
+ for (; t < e.length && !/\s/.test(e[t]);) n += e[t], t++;
554
+ !this.suppressValidationErr && o(n), t = i(e, t);
555
+ let r = e.substring(t, t + 6).toUpperCase();
556
+ if (!this.suppressValidationErr && r !== "SYSTEM" && r !== "PUBLIC") throw Error(`Expected SYSTEM or PUBLIC, found "${r}"`);
557
+ t += r.length, t = i(e, t);
558
+ let a = null, s = null;
559
+ if (r === "PUBLIC") [t, a] = this.readIdentifierVal(e, t, "publicIdentifier"), t = i(e, t), (e[t] === "\"" || e[t] === "'") && ([t, s] = this.readIdentifierVal(e, t, "systemIdentifier"));
560
+ else if (r === "SYSTEM" && ([t, s] = this.readIdentifierVal(e, t, "systemIdentifier"), !this.suppressValidationErr && !s)) throw Error("Missing mandatory system identifier for SYSTEM notation");
561
+ return {
562
+ notationName: n,
563
+ publicIdentifier: a,
564
+ systemIdentifier: s,
565
+ index: --t
566
+ };
567
+ }
568
+ readIdentifierVal(e, t, n) {
569
+ let r = "", i = e[t];
570
+ if (i !== "\"" && i !== "'") throw Error(`Expected quoted string, found "${i}"`);
571
+ for (t++; t < e.length && e[t] !== i;) r += e[t], t++;
572
+ if (e[t] !== i) throw Error(`Unterminated ${n} value`);
573
+ return t++, [t, r];
574
+ }
575
+ readElementExp(e, t) {
576
+ t = i(e, t);
577
+ let r = "";
578
+ for (; t < e.length && !/\s/.test(e[t]);) r += e[t], t++;
579
+ if (!this.suppressValidationErr && !n.isName(r)) throw Error(`Invalid element name: "${r}"`);
580
+ t = i(e, t);
581
+ let o = "";
582
+ if (e[t] === "E" && a(e, "MPTY", t)) t += 4;
583
+ else if (e[t] === "A" && a(e, "NY", t)) t += 2;
584
+ else if (e[t] === "(") {
585
+ for (t++; t < e.length && e[t] !== ")";) o += e[t], t++;
586
+ if (e[t] !== ")") throw Error("Unterminated content model");
587
+ } else if (!this.suppressValidationErr) throw Error(`Invalid Element Expression, found "${e[t]}"`);
588
+ return {
589
+ elementName: r,
590
+ contentModel: o.trim(),
591
+ index: t
592
+ };
593
+ }
594
+ readAttlistExp(e, t) {
595
+ t = i(e, t);
596
+ let n = "";
597
+ for (; t < e.length && !/\s/.test(e[t]);) n += e[t], t++;
598
+ o(n), t = i(e, t);
599
+ let r = "";
600
+ for (; t < e.length && !/\s/.test(e[t]);) r += e[t], t++;
601
+ if (!o(r)) throw Error(`Invalid attribute name: "${r}"`);
602
+ t = i(e, t);
603
+ let a = "";
604
+ if (e.substring(t, t + 8).toUpperCase() === "NOTATION") {
605
+ if (a = "NOTATION", t += 8, t = i(e, t), e[t] !== "(") throw Error(`Expected '(', found "${e[t]}"`);
606
+ t++;
607
+ let n = [];
608
+ for (; t < e.length && e[t] !== ")";) {
609
+ let r = "";
610
+ for (; t < e.length && e[t] !== "|" && e[t] !== ")";) r += e[t], t++;
611
+ if (r = r.trim(), !o(r)) throw Error(`Invalid notation name: "${r}"`);
612
+ n.push(r), e[t] === "|" && (t++, t = i(e, t));
613
+ }
614
+ if (e[t] !== ")") throw Error("Unterminated list of notations");
615
+ t++, a += " (" + n.join("|") + ")";
616
+ } else {
617
+ for (; t < e.length && !/\s/.test(e[t]);) a += e[t], t++;
618
+ if (!this.suppressValidationErr && ![
619
+ "CDATA",
620
+ "ID",
621
+ "IDREF",
622
+ "IDREFS",
623
+ "ENTITY",
624
+ "ENTITIES",
625
+ "NMTOKEN",
626
+ "NMTOKENS"
627
+ ].includes(a.toUpperCase())) throw Error(`Invalid attribute type: "${a}"`);
628
+ }
629
+ t = i(e, t);
630
+ let s = "";
631
+ return e.substring(t, t + 8).toUpperCase() === "#REQUIRED" ? (s = "#REQUIRED", t += 8) : e.substring(t, t + 7).toUpperCase() === "#IMPLIED" ? (s = "#IMPLIED", t += 7) : [t, s] = this.readIdentifierVal(e, t, "ATTLIST"), {
632
+ elementName: n,
633
+ attributeName: r,
634
+ attributeType: a,
635
+ defaultValue: s,
636
+ index: t
637
+ };
638
+ }
639
+ }, i = (e, t) => {
640
+ for (; t < e.length && /\s/.test(e[t]);) t++;
641
+ return t;
642
+ };
643
+ function a(e, t, n) {
644
+ for (let r = 0; r < t.length; r++) if (t[r] !== e[n + r + 1]) return !1;
645
+ return !0;
646
+ }
647
+ function o(e) {
648
+ if (n.isName(e)) return e;
649
+ throw Error(`Invalid entity name ${e}`);
650
+ }
651
+ t.exports = r;
652
+ })), h = /* @__PURE__ */ t(((e, t) => {
653
+ var n = /^[-+]?0x[a-fA-F0-9]+$/, r = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, i = {
654
+ hex: !0,
655
+ leadingZeros: !0,
656
+ decimalPoint: ".",
657
+ eNotation: !0
658
+ };
659
+ function a(e, t = {}) {
660
+ if (t = Object.assign({}, i, t), !e || typeof e != "string") return e;
661
+ let a = e.trim();
662
+ if (t.skipLike !== void 0 && t.skipLike.test(a)) return e;
663
+ if (e === "0") return 0;
664
+ if (t.hex && n.test(a)) return s(a, 16);
665
+ if (a.search(/[eE]/) !== -1) {
666
+ let n = a.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);
667
+ if (n) {
668
+ if (t.leadingZeros) a = (n[1] || "") + n[3];
669
+ else if (!(n[2] === "0" && n[3][0] === ".")) return e;
670
+ return t.eNotation ? Number(a) : e;
671
+ } else return e;
672
+ } else {
673
+ let n = r.exec(a);
674
+ if (n) {
675
+ let r = n[1], i = n[2], s = o(n[3]);
676
+ if (!t.leadingZeros && i.length > 0 && r && a[2] !== "." || !t.leadingZeros && i.length > 0 && !r && a[1] !== ".") return e;
677
+ if (t.leadingZeros && i === e) return 0;
678
+ {
679
+ let n = Number(a), o = "" + n;
680
+ return o.search(/[eE]/) === -1 ? a.indexOf(".") === -1 ? i ? s === o || r + s === o ? n : e : a === o || a === r + o ? n : e : o === "0" && s === "" || o === s || r && o === "-" + s ? n : e : t.eNotation ? n : e;
681
+ }
682
+ } else return e;
683
+ }
684
+ }
685
+ function o(e) {
686
+ return e && e.indexOf(".") !== -1 ? (e = e.replace(/0+$/, ""), e === "." ? e = "0" : e[0] === "." ? e = "0" + e : e[e.length - 1] === "." && (e = e.substr(0, e.length - 1)), e) : e;
687
+ }
688
+ function s(e, t) {
689
+ if (parseInt) return parseInt(e, t);
690
+ if (Number.parseInt) return Number.parseInt(e, t);
691
+ if (window && window.parseInt) return window.parseInt(e, t);
692
+ throw Error("parseInt, Number.parseInt, window.parseInt are not supported");
693
+ }
694
+ t.exports = a;
695
+ })), g = /* @__PURE__ */ t(((e, t) => {
696
+ function n(e) {
697
+ return typeof e == "function" ? e : Array.isArray(e) ? (t) => {
698
+ for (let n of e) if (typeof n == "string" && t === n || n instanceof RegExp && n.test(t)) return !0;
699
+ } : () => !1;
700
+ }
701
+ t.exports = n;
702
+ })), _ = /* @__PURE__ */ t(((e, t) => {
703
+ var n = u(), r = p(), i = m(), a = h(), o = g(), s = class {
704
+ constructor(e) {
705
+ if (this.options = e, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
706
+ apos: {
707
+ regex: /&(apos|#39|#x27);/g,
708
+ val: "'"
709
+ },
710
+ gt: {
711
+ regex: /&(gt|#62|#x3E);/g,
712
+ val: ">"
713
+ },
714
+ lt: {
715
+ regex: /&(lt|#60|#x3C);/g,
716
+ val: "<"
717
+ },
718
+ quot: {
719
+ regex: /&(quot|#34|#x22);/g,
720
+ val: "\""
721
+ }
722
+ }, this.ampEntity = {
723
+ regex: /&(amp|#38|#x26);/g,
724
+ val: "&"
725
+ }, this.htmlEntities = {
726
+ space: {
727
+ regex: /&(nbsp|#160);/g,
728
+ val: " "
729
+ },
730
+ cent: {
731
+ regex: /&(cent|#162);/g,
732
+ val: "¢"
733
+ },
734
+ pound: {
735
+ regex: /&(pound|#163);/g,
736
+ val: "£"
737
+ },
738
+ yen: {
739
+ regex: /&(yen|#165);/g,
740
+ val: "¥"
741
+ },
742
+ euro: {
743
+ regex: /&(euro|#8364);/g,
744
+ val: "€"
745
+ },
746
+ copyright: {
747
+ regex: /&(copy|#169);/g,
748
+ val: "©"
749
+ },
750
+ reg: {
751
+ regex: /&(reg|#174);/g,
752
+ val: "®"
753
+ },
754
+ inr: {
755
+ regex: /&(inr|#8377);/g,
756
+ val: "₹"
757
+ },
758
+ num_dec: {
759
+ regex: /&#([0-9]{1,7});/g,
760
+ val: (e, t) => O(t, 10, "&#")
761
+ },
762
+ num_hex: {
763
+ regex: /&#x([0-9a-fA-F]{1,6});/g,
764
+ val: (e, t) => O(t, 16, "&#x")
765
+ }
766
+ }, this.addExternalEntities = c, this.parseXml = v, this.parseTextData = l, this.resolveNameSpace = d, this.buildAttributesMap = _, this.isItStopNode = S, this.replaceEntitiesValue = b, this.readStopNodeData = E, this.saveTextToParentTag = x, this.addChild = y, this.ignoreAttributesFn = o(this.options.ignoreAttributes), this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) {
767
+ this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set();
768
+ for (let e = 0; e < this.options.stopNodes.length; e++) {
769
+ let t = this.options.stopNodes[e];
770
+ typeof t == "string" && (t.startsWith("*.") ? this.stopNodesWildcard.add(t.substring(2)) : this.stopNodesExact.add(t));
771
+ }
772
+ }
773
+ }
774
+ };
775
+ function c(e) {
776
+ let t = Object.keys(e);
777
+ for (let n = 0; n < t.length; n++) {
778
+ let r = t[n], i = r.replace(/[.\-+*:]/g, "\\.");
779
+ this.lastEntities[r] = {
780
+ regex: RegExp("&" + i + ";", "g"),
781
+ val: e[r]
782
+ };
783
+ }
784
+ }
785
+ function l(e, t, n, r, i, a, o) {
786
+ if (e !== void 0 && (this.options.trimValues && !r && (e = e.trim()), e.length > 0)) {
787
+ o || (e = this.replaceEntitiesValue(e, t, n));
788
+ let r = this.options.tagValueProcessor(t, e, n, i, a);
789
+ return r == null ? e : typeof r != typeof e || r !== e ? r : this.options.trimValues || e.trim() === e ? D(e, this.options.parseTagValue, this.options.numberParseOptions) : e;
790
+ }
791
+ }
792
+ function d(e) {
793
+ if (this.options.removeNSPrefix) {
794
+ let t = e.split(":"), n = e.charAt(0) === "/" ? "/" : "";
795
+ if (t[0] === "xmlns") return "";
796
+ t.length === 2 && (e = n + t[1]);
797
+ }
798
+ return e;
799
+ }
800
+ var f = /* @__PURE__ */ RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
801
+ function _(e, t, r) {
802
+ if (this.options.ignoreAttributes !== !0 && typeof e == "string") {
803
+ let i = n.getAllMatches(e, f), a = i.length, o = {};
804
+ for (let e = 0; e < a; e++) {
805
+ let n = this.resolveNameSpace(i[e][1]);
806
+ if (this.ignoreAttributesFn(n, t)) continue;
807
+ let a = i[e][4], s = this.options.attributeNamePrefix + n;
808
+ if (n.length) if (this.options.transformAttributeName && (s = this.options.transformAttributeName(s)), s = k(s, this.options), a !== void 0) {
809
+ this.options.trimValues && (a = a.trim()), a = this.replaceEntitiesValue(a, r, t);
810
+ let e = this.options.attributeValueProcessor(n, a, t);
811
+ e == null ? o[s] = a : typeof e != typeof a || e !== a ? o[s] = e : o[s] = D(a, this.options.parseAttributeValue, this.options.numberParseOptions);
812
+ } else this.options.allowBooleanAttributes && (o[s] = !0);
813
+ }
814
+ if (!Object.keys(o).length) return;
815
+ if (this.options.attributesGroupName) {
816
+ let e = {};
817
+ return e[this.options.attributesGroupName] = o, e;
818
+ }
819
+ return o;
820
+ }
821
+ }
822
+ var v = function(e) {
823
+ e = e.replace(/\r\n?/g, "\n");
824
+ let t = new r("!xml"), n = t, a = "", o = "";
825
+ this.entityExpansionCount = 0, this.currentExpandedLength = 0;
826
+ let s = new i(this.options.processEntities);
827
+ for (let i = 0; i < e.length; i++) if (e[i] === "<") if (e[i + 1] === "/") {
828
+ let t = w(e, ">", i, "Closing Tag is not closed."), r = e.substring(i + 2, t).trim();
829
+ if (this.options.removeNSPrefix) {
830
+ let e = r.indexOf(":");
831
+ e !== -1 && (r = r.substr(e + 1));
832
+ }
833
+ this.options.transformTagName && (r = this.options.transformTagName(r)), n && (a = this.saveTextToParentTag(a, n, o));
834
+ let s = o.substring(o.lastIndexOf(".") + 1);
835
+ if (r && this.options.unpairedTags.indexOf(r) !== -1) throw Error(`Unpaired tag can not be used as closing tag: </${r}>`);
836
+ let c = 0;
837
+ s && this.options.unpairedTags.indexOf(s) !== -1 ? (c = o.lastIndexOf(".", o.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : c = o.lastIndexOf("."), o = o.substring(0, c), n = this.tagsNodeStack.pop(), a = "", i = t;
838
+ } else if (e[i + 1] === "?") {
839
+ let t = T(e, i, !1, "?>");
840
+ if (!t) throw Error("Pi Tag is not closed.");
841
+ if (a = this.saveTextToParentTag(a, n, o), !(this.options.ignoreDeclaration && t.tagName === "?xml" || this.options.ignorePiTags)) {
842
+ let e = new r(t.tagName);
843
+ e.add(this.options.textNodeName, ""), t.tagName !== t.tagExp && t.attrExpPresent && (e[":@"] = this.buildAttributesMap(t.tagExp, o, t.tagName)), this.addChild(n, e, o, i);
844
+ }
845
+ i = t.closeIndex + 1;
846
+ } else if (e.substr(i + 1, 3) === "!--") {
847
+ let t = w(e, "-->", i + 4, "Comment is not closed.");
848
+ if (this.options.commentPropName) {
849
+ let r = e.substring(i + 4, t - 2);
850
+ a = this.saveTextToParentTag(a, n, o), n.add(this.options.commentPropName, [{ [this.options.textNodeName]: r }]);
851
+ }
852
+ i = t;
853
+ } else if (e.substr(i + 1, 2) === "!D") {
854
+ let t = s.readDocType(e, i);
855
+ this.docTypeEntities = t.entities, i = t.i;
856
+ } else if (e.substr(i + 1, 2) === "![") {
857
+ let t = w(e, "]]>", i, "CDATA is not closed.") - 2, r = e.substring(i + 9, t);
858
+ a = this.saveTextToParentTag(a, n, o);
859
+ let s = this.parseTextData(r, n.tagname, o, !0, !1, !0, !0);
860
+ s ??= "", this.options.cdataPropName ? n.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r }]) : n.add(this.options.textNodeName, s), i = t + 2;
861
+ } else {
862
+ let s = T(e, i, this.options.removeNSPrefix), c = s.tagName, l = s.rawTagName, u = s.tagExp, d = s.attrExpPresent, f = s.closeIndex;
863
+ if (this.options.transformTagName) {
864
+ let e = this.options.transformTagName(c);
865
+ u === c && (u = e), c = e;
866
+ }
867
+ if (this.options.strictReservedNames && (c === this.options.commentPropName || c === this.options.cdataPropName || c === this.options.textNodeName || c === this.options.attributesGroupName)) throw Error(`Invalid tag name: ${c}`);
868
+ n && a && n.tagname !== "!xml" && (a = this.saveTextToParentTag(a, n, o, !1));
869
+ let p = n;
870
+ p && this.options.unpairedTags.indexOf(p.tagname) !== -1 && (n = this.tagsNodeStack.pop(), o = o.substring(0, o.lastIndexOf("."))), c !== t.tagname && (o += o ? "." + c : c);
871
+ let m = i;
872
+ if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, o, c)) {
873
+ let t = "";
874
+ if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) c[c.length - 1] === "/" ? (c = c.substr(0, c.length - 1), o = o.substr(0, o.length - 1), u = c) : u = u.substr(0, u.length - 1), i = s.closeIndex;
875
+ else if (this.options.unpairedTags.indexOf(c) !== -1) i = s.closeIndex;
876
+ else {
877
+ let n = this.readStopNodeData(e, l, f + 1);
878
+ if (!n) throw Error(`Unexpected end of ${l}`);
879
+ i = n.i, t = n.tagContent;
880
+ }
881
+ let a = new r(c);
882
+ c !== u && d && (a[":@"] = this.buildAttributesMap(u, o, c)), t &&= this.parseTextData(t, c, o, !0, d, !0, !0), o = o.substr(0, o.lastIndexOf(".")), a.add(this.options.textNodeName, t), this.addChild(n, a, o, m);
883
+ } else {
884
+ if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) {
885
+ if (c[c.length - 1] === "/" ? (c = c.substr(0, c.length - 1), o = o.substr(0, o.length - 1), u = c) : u = u.substr(0, u.length - 1), this.options.transformTagName) {
886
+ let e = this.options.transformTagName(c);
887
+ u === c && (u = e), c = e;
888
+ }
889
+ let e = new r(c);
890
+ c !== u && d && (e[":@"] = this.buildAttributesMap(u, o, c)), this.addChild(n, e, o, m), o = o.substr(0, o.lastIndexOf("."));
891
+ } else if (this.options.unpairedTags.indexOf(c) !== -1) {
892
+ let e = new r(c);
893
+ c !== u && d && (e[":@"] = this.buildAttributesMap(u, o)), this.addChild(n, e, o, m), o = o.substr(0, o.lastIndexOf(".")), i = s.closeIndex;
894
+ continue;
895
+ } else {
896
+ let e = new r(c);
897
+ if (this.tagsNodeStack.length > this.options.maxNestedTags) throw Error("Maximum nested tags exceeded");
898
+ this.tagsNodeStack.push(n), c !== u && d && (e[":@"] = this.buildAttributesMap(u, o, c)), this.addChild(n, e, o), n = e;
899
+ }
900
+ a = "", i = f;
901
+ }
902
+ }
903
+ else a += e[i];
904
+ return t.child;
905
+ };
906
+ function y(e, t, n, r) {
907
+ this.options.captureMetaData || (r = void 0);
908
+ let i = this.options.updateTag(t.tagname, n, t[":@"]);
909
+ i === !1 || (typeof i == "string" && (t.tagname = i), e.addChild(t, r));
910
+ }
911
+ var b = function(e, t, n) {
912
+ if (e.indexOf("&") === -1) return e;
913
+ let r = this.options.processEntities;
914
+ if (!r.enabled || r.allowedTags && !r.allowedTags.includes(t) || r.tagFilter && !r.tagFilter(t, n)) return e;
915
+ for (let t in this.docTypeEntities) {
916
+ let n = this.docTypeEntities[t], i = e.match(n.regx);
917
+ if (i) {
918
+ if (this.entityExpansionCount += i.length, r.maxTotalExpansions && this.entityExpansionCount > r.maxTotalExpansions) throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);
919
+ let t = e.length;
920
+ if (e = e.replace(n.regx, n.val), r.maxExpandedLength && (this.currentExpandedLength += e.length - t, this.currentExpandedLength > r.maxExpandedLength)) throw Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${r.maxExpandedLength}`);
921
+ }
922
+ }
923
+ if (e.indexOf("&") === -1) return e;
924
+ for (let t of Object.keys(this.lastEntities)) {
925
+ let n = this.lastEntities[t], i = e.match(n.regex);
926
+ if (i && (this.entityExpansionCount += i.length, r.maxTotalExpansions && this.entityExpansionCount > r.maxTotalExpansions)) throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);
927
+ e = e.replace(n.regex, n.val);
928
+ }
929
+ if (e.indexOf("&") === -1) return e;
930
+ if (this.options.htmlEntities) for (let t of Object.keys(this.htmlEntities)) {
931
+ let n = this.htmlEntities[t], i = e.match(n.regex);
932
+ if (i && (this.entityExpansionCount += i.length, r.maxTotalExpansions && this.entityExpansionCount > r.maxTotalExpansions)) throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);
933
+ e = e.replace(n.regex, n.val);
934
+ }
935
+ return e = e.replace(this.ampEntity.regex, this.ampEntity.val), e;
936
+ };
937
+ function x(e, t, n, r) {
938
+ return e &&= (r === void 0 && (r = t.child.length === 0), e = this.parseTextData(e, t.tagname, n, !1, t[":@"] ? Object.keys(t[":@"]).length !== 0 : !1, r), e !== void 0 && e !== "" && t.add(this.options.textNodeName, e), ""), e;
939
+ }
940
+ function S(e, t, n, r) {
941
+ return !!(t && t.has(r) || e && e.has(n));
942
+ }
943
+ function C(e, t, n = ">") {
944
+ let r, i = "";
945
+ for (let a = t; a < e.length; a++) {
946
+ let t = e[a];
947
+ if (r) t === r && (r = "");
948
+ else if (t === "\"" || t === "'") r = t;
949
+ else if (t === n[0]) if (n[1]) {
950
+ if (e[a + 1] === n[1]) return {
951
+ data: i,
952
+ index: a
953
+ };
954
+ } else return {
955
+ data: i,
956
+ index: a
957
+ };
958
+ else t === " " && (t = " ");
959
+ i += t;
960
+ }
961
+ }
962
+ function w(e, t, n, r) {
963
+ let i = e.indexOf(t, n);
964
+ if (i === -1) throw Error(r);
965
+ return i + t.length - 1;
966
+ }
967
+ function T(e, t, n, r = ">") {
968
+ let i = C(e, t + 1, r);
969
+ if (!i) return;
970
+ let a = i.data, o = i.index, s = a.search(/\s/), c = a, l = !0;
971
+ s !== -1 && (c = a.substring(0, s), a = a.substring(s + 1).trimStart());
972
+ let u = c;
973
+ if (n) {
974
+ let e = c.indexOf(":");
975
+ e !== -1 && (c = c.substr(e + 1), l = c !== i.data.substr(e + 1));
976
+ }
977
+ return {
978
+ tagName: c,
979
+ tagExp: a,
980
+ closeIndex: o,
981
+ attrExpPresent: l,
982
+ rawTagName: u
983
+ };
984
+ }
985
+ function E(e, t, n) {
986
+ let r = n, i = 1;
987
+ for (; n < e.length; n++) if (e[n] === "<") if (e[n + 1] === "/") {
988
+ let a = w(e, ">", n, `${t} is not closed`);
989
+ if (e.substring(n + 2, a).trim() === t && (i--, i === 0)) return {
990
+ tagContent: e.substring(r, n),
991
+ i: a
992
+ };
993
+ n = a;
994
+ } else if (e[n + 1] === "?") n = w(e, "?>", n + 1, "StopNode is not closed.");
995
+ else if (e.substr(n + 1, 3) === "!--") n = w(e, "-->", n + 3, "StopNode is not closed.");
996
+ else if (e.substr(n + 1, 2) === "![") n = w(e, "]]>", n, "StopNode is not closed.") - 2;
997
+ else {
998
+ let r = T(e, n, ">");
999
+ r && ((r && r.tagName) === t && r.tagExp[r.tagExp.length - 1] !== "/" && i++, n = r.closeIndex);
1000
+ }
1001
+ }
1002
+ function D(e, t, r) {
1003
+ if (t && typeof e == "string") {
1004
+ let t = e.trim();
1005
+ return t === "true" ? !0 : t === "false" ? !1 : a(e, r);
1006
+ } else if (n.isExist(e)) return e;
1007
+ else return "";
1008
+ }
1009
+ function O(e, t, n) {
1010
+ let r = Number.parseInt(e, t);
1011
+ return r >= 0 && r <= 1114111 ? String.fromCodePoint(r) : n + e + ";";
1012
+ }
1013
+ function k(e, t) {
1014
+ if (n.criticalProperties.includes(e)) throw Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);
1015
+ return n.DANGEROUS_PROPERTY_NAMES.includes(e) ? t.onDangerousProperty(e) : e;
1016
+ }
1017
+ t.exports = s;
1018
+ })), v = /* @__PURE__ */ t(((e) => {
1019
+ function t(e, t) {
1020
+ return n(e, t);
1021
+ }
1022
+ function n(e, t, o) {
1023
+ let s, c = {};
1024
+ for (let l = 0; l < e.length; l++) {
1025
+ let u = e[l], d = r(u), f = "";
1026
+ if (f = o === void 0 ? d : o + "." + d, d === t.textNodeName) s === void 0 ? s = u[d] : s += "" + u[d];
1027
+ else if (d === void 0) continue;
1028
+ else if (u[d]) {
1029
+ let e = n(u[d], t, f), r = a(e, t);
1030
+ u[":@"] ? i(e, u[":@"], f, t) : Object.keys(e).length === 1 && e[t.textNodeName] !== void 0 && !t.alwaysCreateTextNode ? e = e[t.textNodeName] : Object.keys(e).length === 0 && (t.alwaysCreateTextNode ? e[t.textNodeName] = "" : e = ""), c[d] !== void 0 && c.hasOwnProperty(d) ? (Array.isArray(c[d]) || (c[d] = [c[d]]), c[d].push(e)) : t.isArray(d, f, r) ? c[d] = [e] : c[d] = e;
1031
+ }
1032
+ }
1033
+ return typeof s == "string" ? s.length > 0 && (c[t.textNodeName] = s) : s !== void 0 && (c[t.textNodeName] = s), c;
1034
+ }
1035
+ function r(e) {
1036
+ let t = Object.keys(e);
1037
+ for (let e = 0; e < t.length; e++) {
1038
+ let n = t[e];
1039
+ if (n !== ":@") return n;
1040
+ }
1041
+ }
1042
+ function i(e, t, n, r) {
1043
+ if (t) {
1044
+ let i = Object.keys(t), a = i.length;
1045
+ for (let o = 0; o < a; o++) {
1046
+ let a = i[o];
1047
+ r.isArray(a, n + "." + a, !0, !0) ? e[a] = [t[a]] : e[a] = t[a];
1048
+ }
1049
+ }
1050
+ }
1051
+ function a(e, t) {
1052
+ let { textNodeName: n } = t, r = Object.keys(e).length;
1053
+ return !!(r === 0 || r === 1 && (e[n] || typeof e[n] == "boolean" || e[n] === 0));
1054
+ }
1055
+ e.prettify = t;
1056
+ })), y = /* @__PURE__ */ t(((e, t) => {
1057
+ var { buildOptions: n } = f(), r = _(), { prettify: i } = v(), a = d();
1058
+ t.exports = class {
1059
+ constructor(e) {
1060
+ this.externalEntities = {}, this.options = n(e);
1061
+ }
1062
+ parse(e, t) {
1063
+ if (typeof e != "string") if (e.toString) e = e.toString();
1064
+ else throw Error("XML data is accepted in String or Bytes[] form.");
1065
+ if (t) {
1066
+ t === !0 && (t = {});
1067
+ let n = a.validate(e, t);
1068
+ if (n !== !0) throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`);
1069
+ }
1070
+ let n = new r(this.options);
1071
+ n.addExternalEntities(this.externalEntities);
1072
+ let o = n.parseXml(e);
1073
+ return this.options.preserveOrder || o === void 0 ? o : i(o, this.options);
1074
+ }
1075
+ addEntity(e, t) {
1076
+ if (t.indexOf("&") !== -1) throw Error("Entity value can't have '&'");
1077
+ if (e.indexOf("&") !== -1 || e.indexOf(";") !== -1) throw Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
1078
+ if (t === "&") throw Error("An entity with value '&' is not permitted");
1079
+ this.externalEntities[e] = t;
1080
+ }
1081
+ };
1082
+ })), b = /* @__PURE__ */ t(((e, t) => {
1083
+ var n = "\n";
1084
+ function r(e, t) {
1085
+ let r = "";
1086
+ return t.format && t.indentBy.length > 0 && (r = n), i(e, t, "", r);
1087
+ }
1088
+ function i(e, t, n, r) {
1089
+ let l = "", u = !1;
1090
+ if (!Array.isArray(e)) {
1091
+ if (e != null) {
1092
+ let n = e.toString();
1093
+ return n = c(n, t), n;
1094
+ }
1095
+ return "";
1096
+ }
1097
+ for (let d = 0; d < e.length; d++) {
1098
+ let f = e[d], p = a(f);
1099
+ if (p === void 0) continue;
1100
+ let m = "";
1101
+ if (m = n.length === 0 ? p : `${n}.${p}`, p === t.textNodeName) {
1102
+ let e = f[p];
1103
+ s(m, t) || (e = t.tagValueProcessor(p, e), e = c(e, t)), u && (l += r), l += e, u = !1;
1104
+ continue;
1105
+ } else if (p === t.cdataPropName) {
1106
+ u && (l += r), l += `<![CDATA[${f[p][0][t.textNodeName]}]]>`, u = !1;
1107
+ continue;
1108
+ } else if (p === t.commentPropName) {
1109
+ l += r + `<!--${f[p][0][t.textNodeName]}-->`, u = !0;
1110
+ continue;
1111
+ } else if (p[0] === "?") {
1112
+ let e = o(f[":@"], t), n = p === "?xml" ? "" : r, i = f[p][0][t.textNodeName];
1113
+ i = i.length === 0 ? "" : " " + i, l += n + `<${p}${i}${e}?>`, u = !0;
1114
+ continue;
1115
+ }
1116
+ let h = r;
1117
+ h !== "" && (h += t.indentBy);
1118
+ let g = r + `<${p}${o(f[":@"], t)}`, _ = i(f[p], t, m, h);
1119
+ t.unpairedTags.indexOf(p) === -1 ? (!_ || _.length === 0) && t.suppressEmptyNode ? l += g + "/>" : _ && _.endsWith(">") ? l += g + `>${_}${r}</${p}>` : (l += g + ">", _ && r !== "" && (_.includes("/>") || _.includes("</")) ? l += r + t.indentBy + _ + r : l += _, l += `</${p}>`) : t.suppressUnpairedNode ? l += g + ">" : l += g + "/>", u = !0;
1120
+ }
1121
+ return l;
1122
+ }
1123
+ function a(e) {
1124
+ let t = Object.keys(e);
1125
+ for (let n = 0; n < t.length; n++) {
1126
+ let r = t[n];
1127
+ if (Object.prototype.hasOwnProperty.call(e, r) && r !== ":@") return r;
1128
+ }
1129
+ }
1130
+ function o(e, t) {
1131
+ let n = "";
1132
+ if (e && !t.ignoreAttributes) for (let r in e) {
1133
+ if (!Object.prototype.hasOwnProperty.call(e, r)) continue;
1134
+ let i = t.attributeValueProcessor(r, e[r]);
1135
+ i = c(i, t), i === !0 && t.suppressBooleanAttributes ? n += ` ${r.substr(t.attributeNamePrefix.length)}` : n += ` ${r.substr(t.attributeNamePrefix.length)}="${i}"`;
1136
+ }
1137
+ return n;
1138
+ }
1139
+ function s(e, t) {
1140
+ e = e.substr(0, e.length - t.textNodeName.length - 1);
1141
+ let n = e.substr(e.lastIndexOf(".") + 1);
1142
+ for (let r in t.stopNodes) if (t.stopNodes[r] === e || t.stopNodes[r] === "*." + n) return !0;
1143
+ return !1;
1144
+ }
1145
+ function c(e, t) {
1146
+ if (e && e.length > 0 && t.processEntities) for (let n = 0; n < t.entities.length; n++) {
1147
+ let r = t.entities[n];
1148
+ e = e.replace(r.regex, r.val);
1149
+ }
1150
+ return e;
1151
+ }
1152
+ t.exports = r;
1153
+ })), x = /* @__PURE__ */ t(((e, t) => {
1154
+ var n = b(), r = g(), i = {
1155
+ attributeNamePrefix: "@_",
1156
+ attributesGroupName: !1,
1157
+ textNodeName: "#text",
1158
+ ignoreAttributes: !0,
1159
+ cdataPropName: !1,
1160
+ format: !1,
1161
+ indentBy: " ",
1162
+ suppressEmptyNode: !1,
1163
+ suppressUnpairedNode: !0,
1164
+ suppressBooleanAttributes: !0,
1165
+ tagValueProcessor: function(e, t) {
1166
+ return t;
1167
+ },
1168
+ attributeValueProcessor: function(e, t) {
1169
+ return t;
1170
+ },
1171
+ preserveOrder: !1,
1172
+ commentPropName: !1,
1173
+ unpairedTags: [],
1174
+ entities: [
1175
+ {
1176
+ regex: /* @__PURE__ */ RegExp("&", "g"),
1177
+ val: "&amp;"
1178
+ },
1179
+ {
1180
+ regex: /* @__PURE__ */ RegExp(">", "g"),
1181
+ val: "&gt;"
1182
+ },
1183
+ {
1184
+ regex: /* @__PURE__ */ RegExp("<", "g"),
1185
+ val: "&lt;"
1186
+ },
1187
+ {
1188
+ regex: /* @__PURE__ */ RegExp("'", "g"),
1189
+ val: "&apos;"
1190
+ },
1191
+ {
1192
+ regex: /* @__PURE__ */ RegExp("\"", "g"),
1193
+ val: "&quot;"
1194
+ }
1195
+ ],
1196
+ processEntities: !0,
1197
+ stopNodes: [],
1198
+ oneListGroup: !1
1199
+ };
1200
+ function a(e) {
1201
+ this.options = Object.assign({}, i, e), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
1202
+ return !1;
1203
+ } : (this.ignoreAttributesFn = r(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = c), this.processTextOrObjNode = o, this.options.format ? (this.indentate = s, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() {
1204
+ return "";
1205
+ }, this.tagEndChar = ">", this.newLine = "");
1206
+ }
1207
+ a.prototype.build = function(e) {
1208
+ return this.options.preserveOrder ? n(e, this.options) : (Array.isArray(e) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (e = { [this.options.arrayNodeName]: e }), this.j2x(e, 0, []).val);
1209
+ }, a.prototype.j2x = function(e, t, n) {
1210
+ let r = "", i = "", a = n.join(".");
1211
+ for (let o in e) if (Object.prototype.hasOwnProperty.call(e, o)) if (e[o] === void 0) this.isAttribute(o) && (i += "");
1212
+ else if (e[o] === null) this.isAttribute(o) || o === this.options.cdataPropName ? i += "" : o[0] === "?" ? i += this.indentate(t) + "<" + o + "?" + this.tagEndChar : i += this.indentate(t) + "<" + o + "/" + this.tagEndChar;
1213
+ else if (e[o] instanceof Date) i += this.buildTextValNode(e[o], o, "", t);
1214
+ else if (typeof e[o] != "object") {
1215
+ let n = this.isAttribute(o);
1216
+ if (n && !this.ignoreAttributesFn(n, a)) r += this.buildAttrPairStr(n, "" + e[o]);
1217
+ else if (!n) if (o === this.options.textNodeName) {
1218
+ let t = this.options.tagValueProcessor(o, "" + e[o]);
1219
+ i += this.replaceEntitiesValue(t);
1220
+ } else i += this.buildTextValNode(e[o], o, "", t);
1221
+ } else if (Array.isArray(e[o])) {
1222
+ let r = e[o].length, a = "", s = "";
1223
+ for (let c = 0; c < r; c++) {
1224
+ let r = e[o][c];
1225
+ if (r !== void 0) if (r === null) o[0] === "?" ? i += this.indentate(t) + "<" + o + "?" + this.tagEndChar : i += this.indentate(t) + "<" + o + "/" + this.tagEndChar;
1226
+ else if (typeof r == "object") if (this.options.oneListGroup) {
1227
+ let e = this.j2x(r, t + 1, n.concat(o));
1228
+ a += e.val, this.options.attributesGroupName && r.hasOwnProperty(this.options.attributesGroupName) && (s += e.attrStr);
1229
+ } else a += this.processTextOrObjNode(r, o, t, n);
1230
+ else if (this.options.oneListGroup) {
1231
+ let e = this.options.tagValueProcessor(o, r);
1232
+ e = this.replaceEntitiesValue(e), a += e;
1233
+ } else a += this.buildTextValNode(r, o, "", t);
1234
+ }
1235
+ this.options.oneListGroup && (a = this.buildObjectNode(a, o, s, t)), i += a;
1236
+ } else if (this.options.attributesGroupName && o === this.options.attributesGroupName) {
1237
+ let t = Object.keys(e[o]), n = t.length;
1238
+ for (let i = 0; i < n; i++) r += this.buildAttrPairStr(t[i], "" + e[o][t[i]]);
1239
+ } else i += this.processTextOrObjNode(e[o], o, t, n);
1240
+ return {
1241
+ attrStr: r,
1242
+ val: i
1243
+ };
1244
+ }, a.prototype.buildAttrPairStr = function(e, t) {
1245
+ return t = this.options.attributeValueProcessor(e, "" + t), t = this.replaceEntitiesValue(t), this.options.suppressBooleanAttributes && t === "true" ? " " + e : " " + e + "=\"" + t + "\"";
1246
+ };
1247
+ function o(e, t, n, r) {
1248
+ let i = this.j2x(e, n + 1, r.concat(t));
1249
+ return e[this.options.textNodeName] !== void 0 && Object.keys(e).length === 1 ? this.buildTextValNode(e[this.options.textNodeName], t, i.attrStr, n) : this.buildObjectNode(i.val, t, i.attrStr, n);
1250
+ }
1251
+ a.prototype.buildObjectNode = function(e, t, n, r) {
1252
+ if (e === "") return t[0] === "?" ? this.indentate(r) + "<" + t + n + "?" + this.tagEndChar : this.indentate(r) + "<" + t + n + this.closeTag(t) + this.tagEndChar;
1253
+ {
1254
+ let i = "</" + t + this.tagEndChar, a = "";
1255
+ return t[0] === "?" && (a = "?", i = ""), (n || n === "") && e.indexOf("<") === -1 ? this.indentate(r) + "<" + t + n + a + ">" + e + i : this.options.commentPropName !== !1 && t === this.options.commentPropName && a.length === 0 ? this.indentate(r) + `<!--${e}-->` + this.newLine : this.indentate(r) + "<" + t + n + a + this.tagEndChar + e + this.indentate(r) + i;
1256
+ }
1257
+ }, a.prototype.closeTag = function(e) {
1258
+ let t = "";
1259
+ return this.options.unpairedTags.indexOf(e) === -1 ? t = this.options.suppressEmptyNode ? "/" : `></${e}` : this.options.suppressUnpairedNode || (t = "/"), t;
1260
+ }, a.prototype.buildTextValNode = function(e, t, n, r) {
1261
+ if (this.options.cdataPropName !== !1 && t === this.options.cdataPropName) return this.indentate(r) + `<![CDATA[${e}]]>` + this.newLine;
1262
+ if (this.options.commentPropName !== !1 && t === this.options.commentPropName) return this.indentate(r) + `<!--${e}-->` + this.newLine;
1263
+ if (t[0] === "?") return this.indentate(r) + "<" + t + n + "?" + this.tagEndChar;
1264
+ {
1265
+ let i = this.options.tagValueProcessor(t, e);
1266
+ return i = this.replaceEntitiesValue(i), i === "" ? this.indentate(r) + "<" + t + n + this.closeTag(t) + this.tagEndChar : this.indentate(r) + "<" + t + n + ">" + i + "</" + t + this.tagEndChar;
1267
+ }
1268
+ }, a.prototype.replaceEntitiesValue = function(e) {
1269
+ if (e && e.length > 0 && this.options.processEntities) for (let t = 0; t < this.options.entities.length; t++) {
1270
+ let n = this.options.entities[t];
1271
+ e = e.replace(n.regex, n.val);
1272
+ }
1273
+ return e;
1274
+ };
1275
+ function s(e) {
1276
+ return this.options.indentBy.repeat(e);
1277
+ }
1278
+ function c(e) {
1279
+ return e.startsWith(this.options.attributeNamePrefix) && e !== this.options.textNodeName ? e.substr(this.attrPrefixLen) : !1;
1280
+ }
1281
+ t.exports = a;
1282
+ })), S = (/* @__PURE__ */ t(((e, t) => {
1283
+ var n = d();
1284
+ t.exports = {
1285
+ XMLParser: y(),
1286
+ XMLValidator: n,
1287
+ XMLBuilder: x()
1288
+ };
1289
+ })))(), C = class {
1290
+ alphabet;
1291
+ padding;
1292
+ decodeMap = /* @__PURE__ */ new Map();
1293
+ constructor(e, t) {
1294
+ if (e.length !== 32) throw Error("Invalid alphabet");
1295
+ if (this.alphabet = e, this.padding = t?.padding ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1) throw Error("Invalid padding");
1296
+ for (let t = 0; t < e.length; t++) this.decodeMap.set(e[t], t);
1297
+ }
1298
+ encode(e, t) {
1299
+ let n = "", r = 0, i = 0;
1300
+ for (let t = 0; t < e.length; t++) for (r = r << 8 | e[t], i += 8; i >= 5;) i -= 5, n += this.alphabet[r >> i & 31];
1301
+ if (i > 0 && (n += this.alphabet[r << 5 - i & 31]), t?.includePadding ?? !0) {
1302
+ let e = (8 - n.length % 8) % 8;
1303
+ for (let t = 0; t < e; t++) n += "=";
1304
+ }
1305
+ return n;
1306
+ }
1307
+ decode(e, t) {
1308
+ let n = t?.strict ?? !0, r = Math.ceil(e.length / 8), i = [];
1309
+ for (let t = 0; t < r; t++) {
1310
+ let a = 0, o = [];
1311
+ for (let i = 0; i < 8; i++) {
1312
+ let s = e[t * 8 + i];
1313
+ if (s === "=") {
1314
+ if (t + 1 !== r) throw Error(`Invalid character: ${s}`);
1315
+ a += 1;
1316
+ continue;
1317
+ }
1318
+ if (s === void 0) {
1319
+ if (n) throw Error("Invalid data");
1320
+ a += 1;
1321
+ continue;
1322
+ }
1323
+ let c = this.decodeMap.get(s) ?? null;
1324
+ if (c === null) throw Error(`Invalid character: ${s}`);
1325
+ o.push(c);
1326
+ }
1327
+ if (a === 8 || a === 7 || a === 5 || a === 2) throw Error("Invalid padding");
1328
+ let s = (o[0] << 3) + (o[1] >> 2);
1329
+ if (i.push(s), a < 6) {
1330
+ let e = ((o[1] & 3) << 6) + (o[2] << 1) + (o[3] >> 4);
1331
+ i.push(e);
1332
+ }
1333
+ if (a < 4) {
1334
+ let e = ((o[3] & 255) << 4) + (o[4] >> 1);
1335
+ i.push(e);
1336
+ }
1337
+ if (a < 3) {
1338
+ let e = ((o[4] & 1) << 7) + (o[5] << 2) + (o[6] >> 3);
1339
+ i.push(e);
1340
+ }
1341
+ if (a < 1) {
1342
+ let e = ((o[6] & 7) << 5) + o[7];
1343
+ i.push(e);
1344
+ }
1345
+ }
1346
+ return Uint8Array.from(i);
1347
+ }
376
1348
  };
377
- Z.validate = function(t, e) {
378
- e = Object.assign({}, fe, e);
379
- const n = [];
380
- let s = !1, r = !1;
381
- t[0] === "\uFEFF" && (t = t.substr(1));
382
- for (let o = 0; o < t.length; o++)
383
- if (t[o] === "<" && t[o + 1] === "?") {
384
- if (o += 2, o = U(t, o), o.err) return o;
385
- } else if (t[o] === "<") {
386
- let a = o;
387
- if (o++, t[o] === "!") {
388
- o = k(t, o);
389
- continue;
390
- } else {
391
- let c = !1;
392
- t[o] === "/" && (c = !0, o++);
393
- let l = "";
394
- for (; o < t.length && t[o] !== ">" && t[o] !== " " && t[o] !== " " && t[o] !== `
395
- ` && t[o] !== "\r"; o++)
396
- l += t[o];
397
- if (l = l.trim(), l[l.length - 1] === "/" && (l = l.substring(0, l.length - 1), o--), !Ee(l)) {
398
- let d;
399
- return l.trim().length === 0 ? d = "Invalid space after '<'." : d = "Tag '" + l + "' is an invalid name.", p("InvalidTag", d, w(t, o));
400
- }
401
- const u = pe(t, o);
402
- if (u === !1)
403
- return p("InvalidAttr", "Attributes for '" + l + "' have open quote.", w(t, o));
404
- let f = u.value;
405
- if (o = u.index, f[f.length - 1] === "/") {
406
- const d = o - f.length;
407
- f = f.substring(0, f.length - 1);
408
- const h = G(f, e);
409
- if (h === !0)
410
- s = !0;
411
- else
412
- return p(h.err.code, h.err.msg, w(t, d + h.err.line));
413
- } else if (c)
414
- if (u.tagClosed) {
415
- if (f.trim().length > 0)
416
- return p("InvalidTag", "Closing tag '" + l + "' can't have attributes or invalid starting.", w(t, a));
417
- if (n.length === 0)
418
- return p("InvalidTag", "Closing tag '" + l + "' has not been opened.", w(t, a));
419
- {
420
- const d = n.pop();
421
- if (l !== d.tagName) {
422
- let h = w(t, d.tagStartPos);
423
- return p(
424
- "InvalidTag",
425
- "Expected closing tag '" + d.tagName + "' (opened in line " + h.line + ", col " + h.col + ") instead of closing tag '" + l + "'.",
426
- w(t, a)
427
- );
428
- }
429
- n.length == 0 && (r = !0);
430
- }
431
- } else return p("InvalidTag", "Closing tag '" + l + "' doesn't have proper closing.", w(t, o));
432
- else {
433
- const d = G(f, e);
434
- if (d !== !0)
435
- return p(d.err.code, d.err.msg, w(t, o - f.length + d.err.line));
436
- if (r === !0)
437
- return p("InvalidXml", "Multiple possible root nodes found.", w(t, o));
438
- e.unpairedTags.indexOf(l) !== -1 || n.push({ tagName: l, tagStartPos: a }), s = !0;
439
- }
440
- for (o++; o < t.length; o++)
441
- if (t[o] === "<")
442
- if (t[o + 1] === "!") {
443
- o++, o = k(t, o);
444
- continue;
445
- } else if (t[o + 1] === "?") {
446
- if (o = U(t, ++o), o.err) return o;
447
- } else
448
- break;
449
- else if (t[o] === "&") {
450
- const d = Ne(t, o);
451
- if (d == -1)
452
- return p("InvalidChar", "char '&' is not expected.", w(t, o));
453
- o = d;
454
- } else if (r === !0 && !B(t[o]))
455
- return p("InvalidXml", "Extra text at the end", w(t, o));
456
- t[o] === "<" && o--;
457
- }
458
- } else {
459
- if (B(t[o]))
460
- continue;
461
- return p("InvalidChar", "char '" + t[o] + "' is not expected.", w(t, o));
462
- }
463
- if (s) {
464
- if (n.length == 1)
465
- return p("InvalidTag", "Unclosed tag '" + n[0].tagName + "'.", w(t, n[0].tagStartPos));
466
- if (n.length > 0)
467
- return p("InvalidXml", "Invalid '" + JSON.stringify(n.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
468
- } else return p("InvalidXml", "Start tag expected.", 1);
469
- return !0;
1349
+ new C("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), new C("0123456789ABCDEFGHIJKLMNOPQRSTUV");
1350
+ //#endregion
1351
+ //#region ../../node_modules/.pnpm/oslo@1.2.1/node_modules/oslo/dist/encoding/base64.js
1352
+ var w = class {
1353
+ alphabet;
1354
+ padding;
1355
+ decodeMap = /* @__PURE__ */ new Map();
1356
+ constructor(e, t) {
1357
+ if (e.length !== 64) throw Error("Invalid alphabet");
1358
+ if (this.alphabet = e, this.padding = t?.padding ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1) throw Error("Invalid padding");
1359
+ for (let t = 0; t < e.length; t++) this.decodeMap.set(e[t], t);
1360
+ }
1361
+ encode(e, t) {
1362
+ let n = "", r = 0, i = 0;
1363
+ for (let t = 0; t < e.length; t++) for (r = r << 8 | e[t], i += 8; i >= 6;) i += -6, n += this.alphabet[r >> i & 63];
1364
+ if (i > 0 && (n += this.alphabet[r << 6 - i & 63]), t?.includePadding ?? !0) {
1365
+ let e = (4 - n.length % 4) % 4;
1366
+ for (let t = 0; t < e; t++) n += "=";
1367
+ }
1368
+ return n;
1369
+ }
1370
+ decode(e, t) {
1371
+ let n = t?.strict ?? !0, r = Math.ceil(e.length / 4), i = [];
1372
+ for (let t = 0; t < r; t++) {
1373
+ let a = 0, o = 0;
1374
+ for (let i = 0; i < 4; i++) {
1375
+ let s = e[t * 4 + i];
1376
+ if (s === "=") {
1377
+ if (t + 1 !== r) throw Error(`Invalid character: ${s}`);
1378
+ a += 1;
1379
+ continue;
1380
+ }
1381
+ if (s === void 0) {
1382
+ if (n) throw Error("Invalid data");
1383
+ a += 1;
1384
+ continue;
1385
+ }
1386
+ let c = this.decodeMap.get(s) ?? null;
1387
+ if (c === null) throw Error(`Invalid character: ${s}`);
1388
+ o += c << 6 * (3 - i);
1389
+ }
1390
+ i.push(o >> 16 & 255), a < 2 && i.push(o >> 8 & 255), a < 1 && i.push(o & 255);
1391
+ }
1392
+ return Uint8Array.from(i);
1393
+ }
1394
+ }, T = new w("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
1395
+ new w("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
1396
+ //#endregion
1397
+ //#region ../../node_modules/.pnpm/nanoid@5.1.11/node_modules/nanoid/url-alphabet/index.js
1398
+ var E = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D = (e = 21) => {
1399
+ let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
1400
+ for (; e--;) t += E[n[e] & 63];
1401
+ return t;
470
1402
  };
471
- function B(t) {
472
- return t === " " || t === " " || t === `
473
- ` || t === "\r";
1403
+ //#endregion
1404
+ //#region src/helpers.ts
1405
+ async function O(e) {
1406
+ let t = new DecompressionStream("deflate-raw"), n = new Uint8Array(e), r = new Blob([n]).stream().pipeThrough(t);
1407
+ return new Uint8Array(await new Response(r).arrayBuffer());
474
1408
  }
475
- function U(t, e) {
476
- const n = e;
477
- for (; e < t.length; e++)
478
- if (t[e] == "?" || t[e] == " ") {
479
- const s = t.substr(n, e - n);
480
- if (e > 5 && s === "xml")
481
- return p("InvalidXml", "XML declaration allowed only at the start of the document.", w(t, e));
482
- if (t[e] == "?" && t[e + 1] == ">") {
483
- e++;
484
- break;
485
- } else
486
- continue;
487
- }
488
- return e;
1409
+ async function k(e) {
1410
+ let t = await T.decode(e.replace(/ /g, "+"));
1411
+ try {
1412
+ let e = await O(t);
1413
+ return new TextDecoder().decode(e);
1414
+ } catch (e) {
1415
+ return console.warn("Decompression failed, assuming data is not compressed:", e), new TextDecoder().decode(t);
1416
+ }
489
1417
  }
490
- function k(t, e) {
491
- if (t.length > e + 5 && t[e + 1] === "-" && t[e + 2] === "-") {
492
- for (e += 3; e < t.length; e++)
493
- if (t[e] === "-" && t[e + 1] === "-" && t[e + 2] === ">") {
494
- e += 2;
495
- break;
496
- }
497
- } else if (t.length > e + 8 && t[e + 1] === "D" && t[e + 2] === "O" && t[e + 3] === "C" && t[e + 4] === "T" && t[e + 5] === "Y" && t[e + 6] === "P" && t[e + 7] === "E") {
498
- let n = 1;
499
- for (e += 8; e < t.length; e++)
500
- if (t[e] === "<")
501
- n++;
502
- else if (t[e] === ">" && (n--, n === 0))
503
- break;
504
- } else if (t.length > e + 9 && t[e + 1] === "[" && t[e + 2] === "C" && t[e + 3] === "D" && t[e + 4] === "A" && t[e + 5] === "T" && t[e + 6] === "A" && t[e + 7] === "[") {
505
- for (e += 8; e < t.length; e++)
506
- if (t[e] === "]" && t[e + 1] === "]" && t[e + 2] === ">") {
507
- e += 2;
508
- break;
509
- }
510
- }
511
- return e;
1418
+ async function A(e) {
1419
+ let t = await k(e), n = new S.XMLParser({
1420
+ attributeNamePrefix: "@_",
1421
+ alwaysCreateTextNode: !0,
1422
+ ignoreAttributes: !1
1423
+ }).parse(t);
1424
+ return i.parse(n);
512
1425
  }
513
- const he = '"', ge = "'";
514
- function pe(t, e) {
515
- let n = "", s = "", r = !1;
516
- for (; e < t.length; e++) {
517
- if (t[e] === he || t[e] === ge)
518
- s === "" ? s = t[e] : s !== t[e] || (s = "");
519
- else if (t[e] === ">" && s === "") {
520
- r = !0;
521
- break;
522
- }
523
- n += t[e];
524
- }
525
- return s !== "" ? !1 : {
526
- value: n,
527
- index: e,
528
- tagClosed: r
529
- };
1426
+ function j(e) {
1427
+ let t = e.certificates.map((e) => ({
1428
+ "@_use": "signing",
1429
+ KeyInfo: {
1430
+ "@_xmlns": "http://www.w3.org/2000/09/xmldsig#",
1431
+ X509Data: { X509Certificate: e }
1432
+ }
1433
+ })), n = { EntityDescriptor: {
1434
+ "@_entityID": e.entityId,
1435
+ "@_xmlns": "urn:oasis:names:tc:SAML:2.0:metadata",
1436
+ IDPSSODescriptor: {
1437
+ "@_protocolSupportEnumeration": "urn:oasis:names:tc:SAML:2.0:protocol",
1438
+ KeyDescriptor: t,
1439
+ SingleLogoutService: [{
1440
+ "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
1441
+ "@_Location": e.singleLogoutServiceUrl
1442
+ }, {
1443
+ "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
1444
+ "@_Location": e.singleLogoutServiceUrl
1445
+ }],
1446
+ NameIDFormat: [
1447
+ "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
1448
+ "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
1449
+ "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
1450
+ ],
1451
+ SingleSignOnService: [{
1452
+ "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
1453
+ "@_Location": e.assertionConsumerServiceUrl
1454
+ }, {
1455
+ "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
1456
+ "@_Location": e.assertionConsumerServiceUrl
1457
+ }],
1458
+ Attribute: [
1459
+ {
1460
+ "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",
1461
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1462
+ "@_FriendlyName": "E-Mail Address",
1463
+ "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1464
+ },
1465
+ {
1466
+ "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",
1467
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1468
+ "@_FriendlyName": "Given Name",
1469
+ "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1470
+ },
1471
+ {
1472
+ "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
1473
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1474
+ "@_FriendlyName": "Name",
1475
+ "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1476
+ },
1477
+ {
1478
+ "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",
1479
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1480
+ "@_FriendlyName": "Surname",
1481
+ "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1482
+ },
1483
+ {
1484
+ "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
1485
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1486
+ "@_FriendlyName": "Name ID",
1487
+ "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1488
+ }
1489
+ ]
1490
+ }
1491
+ } };
1492
+ return new S.XMLBuilder({
1493
+ ignoreAttributes: !1,
1494
+ suppressEmptyNode: !0,
1495
+ preserveOrder: !1,
1496
+ format: !0,
1497
+ attributeNamePrefix: "@_"
1498
+ }).build(n);
530
1499
  }
531
- const me = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
532
- function G(t, e) {
533
- const n = V.getAllMatches(t, me), s = {};
534
- for (let r = 0; r < n.length; r++) {
535
- if (n[r][1].length === 0)
536
- return p("InvalidAttr", "Attribute '" + n[r][2] + "' has no space in starting.", C(n[r]));
537
- if (n[r][3] !== void 0 && n[r][4] === void 0)
538
- return p("InvalidAttr", "Attribute '" + n[r][2] + "' is without value.", C(n[r]));
539
- if (n[r][3] === void 0 && !e.allowBooleanAttributes)
540
- return p("InvalidAttr", "boolean attribute '" + n[r][2] + "' is not allowed.", C(n[r]));
541
- const o = n[r][2];
542
- if (!we(o))
543
- return p("InvalidAttr", "Attribute '" + o + "' is an invalid name.", C(n[r]));
544
- if (!s.hasOwnProperty(o))
545
- s[o] = 1;
546
- else
547
- return p("InvalidAttr", "Attribute '" + o + "' is repeated.", C(n[r]));
548
- }
549
- return !0;
1500
+ async function M(e, t) {
1501
+ let n = e.notBefore || (/* @__PURE__ */ new Date()).toISOString(), r = e.notAfter || new Date(new Date(n).getTime() + 600 * 1e3).toISOString(), i = e.issueInstant || n, a = e.sessionNotOnOrAfter || r, o = e.responseId || `_${D()}`, s = e.assertionId || `_${D()}`, c = [{
1502
+ "samlp:Response": [
1503
+ { "saml:Issuer": [{ "#text": e.issuer }] },
1504
+ { "samlp:Status": [{
1505
+ "samlp:StatusCode": [],
1506
+ ":@": { "@_Value": "urn:oasis:names:tc:SAML:2.0:status:Success" }
1507
+ }] },
1508
+ {
1509
+ "saml:Assertion": [
1510
+ { "saml:Issuer": [{ "#text": e.issuer }] },
1511
+ { "saml:Subject": [{
1512
+ "saml:NameID": [{ "#text": e.email }],
1513
+ ":@": { "@_Format": "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" }
1514
+ }, {
1515
+ "saml:SubjectConfirmation": [{
1516
+ "saml:SubjectConfirmationData": [],
1517
+ ":@": {
1518
+ "@_InResponseTo": e.inResponseTo,
1519
+ "@_NotOnOrAfter": r,
1520
+ "@_Recipient": e.destination
1521
+ }
1522
+ }],
1523
+ ":@": { "@_Method": "urn:oasis:names:tc:SAML:2.0:cm:bearer" }
1524
+ }] },
1525
+ {
1526
+ "saml:Conditions": [{ "saml:AudienceRestriction": [{ "saml:Audience": [{ "#text": e.audience }] }] }],
1527
+ ":@": {
1528
+ "@_NotBefore": n,
1529
+ "@_NotOnOrAfter": r
1530
+ }
1531
+ },
1532
+ {
1533
+ "saml:AuthnStatement": [{ "saml:AuthnContext": [{ "saml:AuthnContextClassRef": [{ "#text": "urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified" }] }] }],
1534
+ ":@": {
1535
+ "@_AuthnInstant": i,
1536
+ "@_SessionIndex": e.sessionIndex,
1537
+ "@_SessionNotOnOrAfter": a
1538
+ }
1539
+ },
1540
+ { "saml:AttributeStatement": [
1541
+ {
1542
+ "saml:Attribute": [{
1543
+ "saml:AttributeValue": [{ "#text": e.userId }],
1544
+ ":@": {
1545
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1546
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1547
+ "@_xsi:type": "xs:string"
1548
+ }
1549
+ }],
1550
+ ":@": {
1551
+ "@_FriendlyName": "persistent",
1552
+ "@_Name": "id",
1553
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
1554
+ }
1555
+ },
1556
+ {
1557
+ "saml:Attribute": [{
1558
+ "saml:AttributeValue": [{ "#text": e.email }],
1559
+ ":@": {
1560
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1561
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1562
+ "@_xsi:type": "xs:string"
1563
+ }
1564
+ }],
1565
+ ":@": {
1566
+ "@_Name": "email",
1567
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1568
+ }
1569
+ },
1570
+ {
1571
+ "saml:Attribute": [{
1572
+ "saml:AttributeValue": [{ "#text": "manage-account" }],
1573
+ ":@": {
1574
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1575
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1576
+ "@_xsi:type": "xs:string"
1577
+ }
1578
+ }],
1579
+ ":@": {
1580
+ "@_Name": "Role",
1581
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1582
+ }
1583
+ },
1584
+ {
1585
+ "saml:Attribute": [{
1586
+ "saml:AttributeValue": [{ "#text": "default-roles-master" }],
1587
+ ":@": {
1588
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1589
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1590
+ "@_xsi:type": "xs:string"
1591
+ }
1592
+ }],
1593
+ ":@": {
1594
+ "@_Name": "Role",
1595
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1596
+ }
1597
+ },
1598
+ {
1599
+ "saml:Attribute": [{
1600
+ "saml:AttributeValue": [{ "#text": "offline_access" }],
1601
+ ":@": {
1602
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1603
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1604
+ "@_xsi:type": "xs:string"
1605
+ }
1606
+ }],
1607
+ ":@": {
1608
+ "@_Name": "Role",
1609
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1610
+ }
1611
+ },
1612
+ {
1613
+ "saml:Attribute": [{
1614
+ "saml:AttributeValue": [{ "#text": "view-profile" }],
1615
+ ":@": {
1616
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1617
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1618
+ "@_xsi:type": "xs:string"
1619
+ }
1620
+ }],
1621
+ ":@": {
1622
+ "@_Name": "Role",
1623
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1624
+ }
1625
+ },
1626
+ {
1627
+ "saml:Attribute": [{
1628
+ "saml:AttributeValue": [{ "#text": "uma_authorization" }],
1629
+ ":@": {
1630
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1631
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1632
+ "@_xsi:type": "xs:string"
1633
+ }
1634
+ }],
1635
+ ":@": {
1636
+ "@_Name": "Role",
1637
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1638
+ }
1639
+ },
1640
+ {
1641
+ "saml:Attribute": [{
1642
+ "saml:AttributeValue": [{ "#text": "manage-account-links" }],
1643
+ ":@": {
1644
+ "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1645
+ "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1646
+ "@_xsi:type": "xs:string"
1647
+ }
1648
+ }],
1649
+ ":@": {
1650
+ "@_Name": "Role",
1651
+ "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1652
+ }
1653
+ }
1654
+ ] }
1655
+ ],
1656
+ ":@": {
1657
+ "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion",
1658
+ "@_ID": s,
1659
+ "@_IssueInstant": i,
1660
+ "@_Version": "2.0"
1661
+ }
1662
+ }
1663
+ ],
1664
+ ":@": {
1665
+ "@_xmlns:samlp": "urn:oasis:names:tc:SAML:2.0:protocol",
1666
+ "@_xmlns:saml": "urn:oasis:names:tc:SAML:2.0:assertion",
1667
+ "@_Destination": e.destination,
1668
+ "@_ID": o,
1669
+ "@_InResponseTo": e.inResponseTo,
1670
+ "@_IssueInstant": i,
1671
+ "@_Version": "2.0"
1672
+ }
1673
+ }], l = new S.XMLBuilder({
1674
+ ignoreAttributes: !1,
1675
+ suppressEmptyNode: !0,
1676
+ preserveOrder: !0
1677
+ }).build(c);
1678
+ return e.signature && t && (l = await t.signSAML(l, e.signature.privateKeyPem, e.signature.cert)), e.encode === !1 ? l : btoa(l);
550
1679
  }
551
- function be(t, e) {
552
- let n = /\d/;
553
- for (t[e] === "x" && (e++, n = /[\da-fA-F]/); e < t.length; e++) {
554
- if (t[e] === ";")
555
- return e;
556
- if (!t[e].match(n))
557
- break;
558
- }
559
- return -1;
560
- }
561
- function Ne(t, e) {
562
- if (e++, t[e] === ";")
563
- return -1;
564
- if (t[e] === "#")
565
- return e++, be(t, e);
566
- let n = 0;
567
- for (; e < t.length; e++, n++)
568
- if (!(t[e].match(/\w/) && n < 20)) {
569
- if (t[e] === ";")
570
- break;
571
- return -1;
572
- }
573
- return e;
574
- }
575
- function p(t, e, n) {
576
- return {
577
- err: {
578
- code: t,
579
- msg: e,
580
- line: n.line || n,
581
- col: n.col
582
- }
583
- };
584
- }
585
- function we(t) {
586
- return V.isName(t);
587
- }
588
- function Ee(t) {
589
- return V.isName(t);
590
- }
591
- function w(t, e) {
592
- const n = t.substring(0, e).split(/\r?\n/);
593
- return {
594
- line: n.length,
595
- // column number is last line's length + 1, because column numbering starts at 1:
596
- col: n[n.length - 1].length + 1
597
- };
598
- }
599
- function C(t) {
600
- return t.startIndex + t[1].length;
601
- }
602
- var F = {};
603
- const { DANGEROUS_PROPERTY_NAMES: q, criticalProperties: ye } = P, W = (t) => q.includes(t) ? "__" + t : t, H = {
604
- preserveOrder: !1,
605
- attributeNamePrefix: "@_",
606
- attributesGroupName: !1,
607
- textNodeName: "#text",
608
- ignoreAttributes: !0,
609
- removeNSPrefix: !1,
610
- // remove NS from tag name or attribute name if true
611
- allowBooleanAttributes: !1,
612
- //a tag can have attributes without any value
613
- //ignoreRootElement : false,
614
- parseTagValue: !0,
615
- parseAttributeValue: !1,
616
- trimValues: !0,
617
- //Trim string values of tag and attributes
618
- cdataPropName: !1,
619
- numberParseOptions: {
620
- hex: !0,
621
- leadingZeros: !0,
622
- eNotation: !0
623
- },
624
- tagValueProcessor: function(t, e) {
625
- return e;
626
- },
627
- attributeValueProcessor: function(t, e) {
628
- return e;
629
- },
630
- stopNodes: [],
631
- //nested tags will not be parsed even for errors
632
- alwaysCreateTextNode: !1,
633
- isArray: () => !1,
634
- commentPropName: !1,
635
- unpairedTags: [],
636
- processEntities: !0,
637
- htmlEntities: !1,
638
- ignoreDeclaration: !1,
639
- ignorePiTags: !1,
640
- transformTagName: !1,
641
- transformAttributeName: !1,
642
- updateTag: function(t, e, n) {
643
- return t;
644
- },
645
- // skipEmptyListItem: false
646
- captureMetaData: !1,
647
- maxNestedTags: 100,
648
- strictReservedNames: !0,
649
- onDangerousProperty: W
650
- };
651
- function xe(t, e) {
652
- if (typeof t != "string")
653
- return;
654
- const n = t.toLowerCase();
655
- if (q.some((s) => n === s.toLowerCase()))
656
- throw new Error(
657
- `[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`
658
- );
659
- if (ye.some((s) => n === s.toLowerCase()))
660
- throw new Error(
661
- `[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`
662
- );
663
- }
664
- function Q(t) {
665
- return typeof t == "boolean" ? {
666
- enabled: t,
667
- // true or false
668
- maxEntitySize: 1e4,
669
- maxExpansionDepth: 10,
670
- maxTotalExpansions: 1e3,
671
- maxExpandedLength: 1e5,
672
- allowedTags: null,
673
- tagFilter: null
674
- } : typeof t == "object" && t !== null ? {
675
- enabled: t.enabled !== !1,
676
- maxEntitySize: Math.max(1, t.maxEntitySize ?? 1e4),
677
- maxExpansionDepth: Math.max(1, t.maxExpansionDepth ?? 1e4),
678
- maxTotalExpansions: Math.max(1, t.maxTotalExpansions ?? 1 / 0),
679
- maxExpandedLength: Math.max(1, t.maxExpandedLength ?? 1e5),
680
- maxEntityCount: Math.max(1, t.maxEntityCount ?? 1e3),
681
- allowedTags: t.allowedTags ?? null,
682
- tagFilter: t.tagFilter ?? null
683
- } : Q(!0);
684
- }
685
- const Ae = function(t) {
686
- const e = Object.assign({}, H, t), n = [
687
- { value: e.attributeNamePrefix, name: "attributeNamePrefix" },
688
- { value: e.attributesGroupName, name: "attributesGroupName" },
689
- { value: e.textNodeName, name: "textNodeName" },
690
- { value: e.cdataPropName, name: "cdataPropName" },
691
- { value: e.commentPropName, name: "commentPropName" }
692
- ];
693
- for (const { value: s, name: r } of n)
694
- s && xe(s, r);
695
- return e.onDangerousProperty === null && (e.onDangerousProperty = W), e.processEntities = Q(e.processEntities), e;
696
- };
697
- F.buildOptions = Ae;
698
- F.defaultOptions = H;
699
- class _e {
700
- constructor(e) {
701
- this.tagname = e, this.child = [], this[":@"] = {};
702
- }
703
- add(e, n) {
704
- e === "__proto__" && (e = "#__proto__"), this.child.push({ [e]: n });
705
- }
706
- addChild(e) {
707
- e.tagname === "__proto__" && (e.tagname = "#__proto__"), e[":@"] && Object.keys(e[":@"]).length > 0 ? this.child.push({ [e.tagname]: e.child, ":@": e[":@"] }) : this.child.push({ [e.tagname]: e.child });
708
- }
709
- }
710
- var Se = _e;
711
- const D = P;
712
- let Te = class {
713
- constructor(e) {
714
- this.suppressValidationErr = !e, this.options = e || {};
715
- }
716
- readDocType(e, n) {
717
- const s = /* @__PURE__ */ Object.create(null);
718
- let r = 0;
719
- if (e[n + 3] === "O" && e[n + 4] === "C" && e[n + 5] === "T" && e[n + 6] === "Y" && e[n + 7] === "P" && e[n + 8] === "E") {
720
- n = n + 9;
721
- let o = 1, a = !1, c = !1, l = "";
722
- for (; n < e.length; n++)
723
- if (e[n] === "<" && !c) {
724
- if (a && _(e, "!ENTITY", n)) {
725
- n += 7;
726
- let u, f;
727
- if ([u, f, n] = this.readEntityExp(e, n + 1, this.suppressValidationErr), f.indexOf("&") === -1) {
728
- if (this.options.enabled !== !1 && this.options.maxEntityCount != null && r >= this.options.maxEntityCount)
729
- throw new Error(
730
- `Entity count (${r + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
731
- );
732
- const d = u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
733
- s[u] = {
734
- regx: RegExp(`&${d};`, "g"),
735
- val: f
736
- }, r++;
737
- }
738
- } else if (a && _(e, "!ELEMENT", n)) {
739
- n += 8;
740
- const { index: u } = this.readElementExp(e, n + 1);
741
- n = u;
742
- } else if (a && _(e, "!ATTLIST", n))
743
- n += 8;
744
- else if (a && _(e, "!NOTATION", n)) {
745
- n += 9;
746
- const { index: u } = this.readNotationExp(e, n + 1, this.suppressValidationErr);
747
- n = u;
748
- } else if (_(e, "!--", n))
749
- c = !0;
750
- else
751
- throw new Error("Invalid DOCTYPE");
752
- o++, l = "";
753
- } else if (e[n] === ">") {
754
- if (c ? e[n - 1] === "-" && e[n - 2] === "-" && (c = !1, o--) : o--, o === 0)
755
- break;
756
- } else e[n] === "[" ? a = !0 : l += e[n];
757
- if (o !== 0)
758
- throw new Error("Unclosed DOCTYPE");
759
- } else
760
- throw new Error("Invalid Tag instead of DOCTYPE");
761
- return { entities: s, i: n };
762
- }
763
- readEntityExp(e, n) {
764
- n = E(e, n);
765
- let s = "";
766
- for (; n < e.length && !/\s/.test(e[n]) && e[n] !== '"' && e[n] !== "'"; )
767
- s += e[n], n++;
768
- if (O(s), n = E(e, n), !this.suppressValidationErr) {
769
- if (e.substring(n, n + 6).toUpperCase() === "SYSTEM")
770
- throw new Error("External entities are not supported");
771
- if (e[n] === "%")
772
- throw new Error("Parameter entities are not supported");
773
- }
774
- let r = "";
775
- if ([n, r] = this.readIdentifierVal(e, n, "entity"), this.options.enabled !== !1 && this.options.maxEntitySize != null && r.length > this.options.maxEntitySize)
776
- throw new Error(
777
- `Entity "${s}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
778
- );
779
- return n--, [s, r, n];
780
- }
781
- readNotationExp(e, n) {
782
- n = E(e, n);
783
- let s = "";
784
- for (; n < e.length && !/\s/.test(e[n]); )
785
- s += e[n], n++;
786
- !this.suppressValidationErr && O(s), n = E(e, n);
787
- const r = e.substring(n, n + 6).toUpperCase();
788
- if (!this.suppressValidationErr && r !== "SYSTEM" && r !== "PUBLIC")
789
- throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);
790
- n += r.length, n = E(e, n);
791
- let o = null, a = null;
792
- if (r === "PUBLIC")
793
- [n, o] = this.readIdentifierVal(e, n, "publicIdentifier"), n = E(e, n), (e[n] === '"' || e[n] === "'") && ([n, a] = this.readIdentifierVal(e, n, "systemIdentifier"));
794
- else if (r === "SYSTEM" && ([n, a] = this.readIdentifierVal(e, n, "systemIdentifier"), !this.suppressValidationErr && !a))
795
- throw new Error("Missing mandatory system identifier for SYSTEM notation");
796
- return { notationName: s, publicIdentifier: o, systemIdentifier: a, index: --n };
797
- }
798
- readIdentifierVal(e, n, s) {
799
- let r = "";
800
- const o = e[n];
801
- if (o !== '"' && o !== "'")
802
- throw new Error(`Expected quoted string, found "${o}"`);
803
- for (n++; n < e.length && e[n] !== o; )
804
- r += e[n], n++;
805
- if (e[n] !== o)
806
- throw new Error(`Unterminated ${s} value`);
807
- return n++, [n, r];
808
- }
809
- readElementExp(e, n) {
810
- n = E(e, n);
811
- let s = "";
812
- for (; n < e.length && !/\s/.test(e[n]); )
813
- s += e[n], n++;
814
- if (!this.suppressValidationErr && !D.isName(s))
815
- throw new Error(`Invalid element name: "${s}"`);
816
- n = E(e, n);
817
- let r = "";
818
- if (e[n] === "E" && _(e, "MPTY", n))
819
- n += 4;
820
- else if (e[n] === "A" && _(e, "NY", n))
821
- n += 2;
822
- else if (e[n] === "(") {
823
- for (n++; n < e.length && e[n] !== ")"; )
824
- r += e[n], n++;
825
- if (e[n] !== ")")
826
- throw new Error("Unterminated content model");
827
- } else if (!this.suppressValidationErr)
828
- throw new Error(`Invalid Element Expression, found "${e[n]}"`);
829
- return {
830
- elementName: s,
831
- contentModel: r.trim(),
832
- index: n
833
- };
834
- }
835
- readAttlistExp(e, n) {
836
- n = E(e, n);
837
- let s = "";
838
- for (; n < e.length && !/\s/.test(e[n]); )
839
- s += e[n], n++;
840
- O(s), n = E(e, n);
841
- let r = "";
842
- for (; n < e.length && !/\s/.test(e[n]); )
843
- r += e[n], n++;
844
- if (!O(r))
845
- throw new Error(`Invalid attribute name: "${r}"`);
846
- n = E(e, n);
847
- let o = "";
848
- if (e.substring(n, n + 8).toUpperCase() === "NOTATION") {
849
- if (o = "NOTATION", n += 8, n = E(e, n), e[n] !== "(")
850
- throw new Error(`Expected '(', found "${e[n]}"`);
851
- n++;
852
- let c = [];
853
- for (; n < e.length && e[n] !== ")"; ) {
854
- let l = "";
855
- for (; n < e.length && e[n] !== "|" && e[n] !== ")"; )
856
- l += e[n], n++;
857
- if (l = l.trim(), !O(l))
858
- throw new Error(`Invalid notation name: "${l}"`);
859
- c.push(l), e[n] === "|" && (n++, n = E(e, n));
860
- }
861
- if (e[n] !== ")")
862
- throw new Error("Unterminated list of notations");
863
- n++, o += " (" + c.join("|") + ")";
864
- } else {
865
- for (; n < e.length && !/\s/.test(e[n]); )
866
- o += e[n], n++;
867
- const c = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
868
- if (!this.suppressValidationErr && !c.includes(o.toUpperCase()))
869
- throw new Error(`Invalid attribute type: "${o}"`);
870
- }
871
- n = E(e, n);
872
- let a = "";
873
- return e.substring(n, n + 8).toUpperCase() === "#REQUIRED" ? (a = "#REQUIRED", n += 8) : e.substring(n, n + 7).toUpperCase() === "#IMPLIED" ? (a = "#IMPLIED", n += 7) : [n, a] = this.readIdentifierVal(e, n, "ATTLIST"), {
874
- elementName: s,
875
- attributeName: r,
876
- attributeType: o,
877
- defaultValue: a,
878
- index: n
879
- };
880
- }
881
- };
882
- const E = (t, e) => {
883
- for (; e < t.length && /\s/.test(t[e]); )
884
- e++;
885
- return e;
886
- };
887
- function _(t, e, n) {
888
- for (let s = 0; s < e.length; s++)
889
- if (e[s] !== t[n + s + 1]) return !1;
890
- return !0;
891
- }
892
- function O(t) {
893
- if (D.isName(t))
894
- return t;
895
- throw new Error(`Invalid entity name ${t}`);
896
- }
897
- var Ie = Te;
898
- const Ce = /^[-+]?0x[a-fA-F0-9]+$/, Oe = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, Pe = {
899
- hex: !0,
900
- // oct: false,
901
- leadingZeros: !0,
902
- decimalPoint: ".",
903
- eNotation: !0
904
- //skipLike: /regex/
905
- };
906
- function Le(t, e = {}) {
907
- if (e = Object.assign({}, Pe, e), !t || typeof t != "string") return t;
908
- let n = t.trim();
909
- if (e.skipLike !== void 0 && e.skipLike.test(n)) return t;
910
- if (t === "0") return 0;
911
- if (e.hex && Ce.test(n))
912
- return je(n, 16);
913
- if (n.search(/[eE]/) !== -1) {
914
- const s = n.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);
915
- if (s) {
916
- if (e.leadingZeros)
917
- n = (s[1] || "") + s[3];
918
- else if (!(s[2] === "0" && s[3][0] === ".")) return t;
919
- return e.eNotation ? Number(n) : t;
920
- } else
921
- return t;
922
- } else {
923
- const s = Oe.exec(n);
924
- if (s) {
925
- const r = s[1], o = s[2];
926
- let a = Me(s[3]);
927
- if (!e.leadingZeros && o.length > 0 && r && n[2] !== ".") return t;
928
- if (!e.leadingZeros && o.length > 0 && !r && n[1] !== ".") return t;
929
- if (e.leadingZeros && o === t) return 0;
930
- {
931
- const c = Number(n), l = "" + c;
932
- return l.search(/[eE]/) !== -1 ? e.eNotation ? c : t : n.indexOf(".") !== -1 ? l === "0" && a === "" || l === a || r && l === "-" + a ? c : t : o ? a === l || r + a === l ? c : t : n === l || n === r + l ? c : t;
933
- }
934
- } else
935
- return t;
936
- }
937
- }
938
- function Me(t) {
939
- return t && t.indexOf(".") !== -1 && (t = t.replace(/0+$/, ""), t === "." ? t = "0" : t[0] === "." ? t = "0" + t : t[t.length - 1] === "." && (t = t.substr(0, t.length - 1))), t;
940
- }
941
- function je(t, e) {
942
- if (parseInt) return parseInt(t, e);
943
- if (Number.parseInt) return Number.parseInt(t, e);
944
- if (window && window.parseInt) return window.parseInt(t, e);
945
- throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
946
- }
947
- var ve = Le;
948
- function $e(t) {
949
- return typeof t == "function" ? t : Array.isArray(t) ? (e) => {
950
- for (const n of t)
951
- if (typeof n == "string" && e === n || n instanceof RegExp && n.test(e))
952
- return !0;
953
- } : () => !1;
954
- }
955
- var ee = $e;
956
- const L = P, I = Se, Ve = Ie, Fe = ve, Re = ee;
957
- let Xe = class {
958
- constructor(e) {
959
- if (this.options = e, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
960
- apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
961
- gt: { regex: /&(gt|#62|#x3E);/g, val: ">" },
962
- lt: { regex: /&(lt|#60|#x3C);/g, val: "<" },
963
- quot: { regex: /&(quot|#34|#x22);/g, val: '"' }
964
- }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = {
965
- space: { regex: /&(nbsp|#160);/g, val: " " },
966
- // "lt" : { regex: /&(lt|#60);/g, val: "<" },
967
- // "gt" : { regex: /&(gt|#62);/g, val: ">" },
968
- // "amp" : { regex: /&(amp|#38);/g, val: "&" },
969
- // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
970
- // "apos" : { regex: /&(apos|#39);/g, val: "'" },
971
- cent: { regex: /&(cent|#162);/g, val: "¢" },
972
- pound: { regex: /&(pound|#163);/g, val: "£" },
973
- yen: { regex: /&(yen|#165);/g, val: "¥" },
974
- euro: { regex: /&(euro|#8364);/g, val: "€" },
975
- copyright: { regex: /&(copy|#169);/g, val: "©" },
976
- reg: { regex: /&(reg|#174);/g, val: "®" },
977
- inr: { regex: /&(inr|#8377);/g, val: "₹" },
978
- num_dec: { regex: /&#([0-9]{1,7});/g, val: (n, s) => Y(s, 10, "&#") },
979
- num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (n, s) => Y(s, 16, "&#x") }
980
- }, this.addExternalEntities = Be, this.parseXml = Ke, this.parseTextData = Ue, this.resolveNameSpace = ke, this.buildAttributesMap = Ye, this.isItStopNode = qe, this.replaceEntitiesValue = Je, this.readStopNodeData = He, this.saveTextToParentTag = Ze, this.addChild = ze, this.ignoreAttributesFn = Re(this.options.ignoreAttributes), this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) {
981
- this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set();
982
- for (let n = 0; n < this.options.stopNodes.length; n++) {
983
- const s = this.options.stopNodes[n];
984
- typeof s == "string" && (s.startsWith("*.") ? this.stopNodesWildcard.add(s.substring(2)) : this.stopNodesExact.add(s));
985
- }
986
- }
987
- }
988
- };
989
- function Be(t) {
990
- const e = Object.keys(t);
991
- for (let n = 0; n < e.length; n++) {
992
- const s = e[n], r = s.replace(/[.\-+*:]/g, "\\.");
993
- this.lastEntities[s] = {
994
- regex: new RegExp("&" + r + ";", "g"),
995
- val: t[s]
996
- };
997
- }
998
- }
999
- function Ue(t, e, n, s, r, o, a) {
1000
- if (t !== void 0 && (this.options.trimValues && !s && (t = t.trim()), t.length > 0)) {
1001
- a || (t = this.replaceEntitiesValue(t, e, n));
1002
- const c = this.options.tagValueProcessor(e, t, n, r, o);
1003
- return c == null ? t : typeof c != typeof t || c !== t ? c : this.options.trimValues ? v(t, this.options.parseTagValue, this.options.numberParseOptions) : t.trim() === t ? v(t, this.options.parseTagValue, this.options.numberParseOptions) : t;
1004
- }
1005
- }
1006
- function ke(t) {
1007
- if (this.options.removeNSPrefix) {
1008
- const e = t.split(":"), n = t.charAt(0) === "/" ? "/" : "";
1009
- if (e[0] === "xmlns")
1010
- return "";
1011
- e.length === 2 && (t = n + e[1]);
1012
- }
1013
- return t;
1014
- }
1015
- const Ge = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
1016
- function Ye(t, e, n) {
1017
- if (this.options.ignoreAttributes !== !0 && typeof t == "string") {
1018
- const s = L.getAllMatches(t, Ge), r = s.length, o = {};
1019
- for (let a = 0; a < r; a++) {
1020
- const c = this.resolveNameSpace(s[a][1]);
1021
- if (this.ignoreAttributesFn(c, e))
1022
- continue;
1023
- let l = s[a][4], u = this.options.attributeNamePrefix + c;
1024
- if (c.length)
1025
- if (this.options.transformAttributeName && (u = this.options.transformAttributeName(u)), u = Qe(u, this.options), l !== void 0) {
1026
- this.options.trimValues && (l = l.trim()), l = this.replaceEntitiesValue(l, n, e);
1027
- const f = this.options.attributeValueProcessor(c, l, e);
1028
- f == null ? o[u] = l : typeof f != typeof l || f !== l ? o[u] = f : o[u] = v(
1029
- l,
1030
- this.options.parseAttributeValue,
1031
- this.options.numberParseOptions
1032
- );
1033
- } else this.options.allowBooleanAttributes && (o[u] = !0);
1034
- }
1035
- if (!Object.keys(o).length)
1036
- return;
1037
- if (this.options.attributesGroupName) {
1038
- const a = {};
1039
- return a[this.options.attributesGroupName] = o, a;
1040
- }
1041
- return o;
1042
- }
1043
- }
1044
- const Ke = function(t) {
1045
- t = t.replace(/\r\n?/g, `
1046
- `);
1047
- const e = new I("!xml");
1048
- let n = e, s = "", r = "";
1049
- this.entityExpansionCount = 0, this.currentExpandedLength = 0;
1050
- const o = new Ve(this.options.processEntities);
1051
- for (let a = 0; a < t.length; a++)
1052
- if (t[a] === "<")
1053
- if (t[a + 1] === "/") {
1054
- const l = S(t, ">", a, "Closing Tag is not closed.");
1055
- let u = t.substring(a + 2, l).trim();
1056
- if (this.options.removeNSPrefix) {
1057
- const h = u.indexOf(":");
1058
- h !== -1 && (u = u.substr(h + 1));
1059
- }
1060
- this.options.transformTagName && (u = this.options.transformTagName(u)), n && (s = this.saveTextToParentTag(s, n, r));
1061
- const f = r.substring(r.lastIndexOf(".") + 1);
1062
- if (u && this.options.unpairedTags.indexOf(u) !== -1)
1063
- throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);
1064
- let d = 0;
1065
- f && this.options.unpairedTags.indexOf(f) !== -1 ? (d = r.lastIndexOf(".", r.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : d = r.lastIndexOf("."), r = r.substring(0, d), n = this.tagsNodeStack.pop(), s = "", a = l;
1066
- } else if (t[a + 1] === "?") {
1067
- let l = j(t, a, !1, "?>");
1068
- if (!l) throw new Error("Pi Tag is not closed.");
1069
- if (s = this.saveTextToParentTag(s, n, r), !(this.options.ignoreDeclaration && l.tagName === "?xml" || this.options.ignorePiTags)) {
1070
- const u = new I(l.tagName);
1071
- u.add(this.options.textNodeName, ""), l.tagName !== l.tagExp && l.attrExpPresent && (u[":@"] = this.buildAttributesMap(l.tagExp, r, l.tagName)), this.addChild(n, u, r, a);
1072
- }
1073
- a = l.closeIndex + 1;
1074
- } else if (t.substr(a + 1, 3) === "!--") {
1075
- const l = S(t, "-->", a + 4, "Comment is not closed.");
1076
- if (this.options.commentPropName) {
1077
- const u = t.substring(a + 4, l - 2);
1078
- s = this.saveTextToParentTag(s, n, r), n.add(this.options.commentPropName, [{ [this.options.textNodeName]: u }]);
1079
- }
1080
- a = l;
1081
- } else if (t.substr(a + 1, 2) === "!D") {
1082
- const l = o.readDocType(t, a);
1083
- this.docTypeEntities = l.entities, a = l.i;
1084
- } else if (t.substr(a + 1, 2) === "![") {
1085
- const l = S(t, "]]>", a, "CDATA is not closed.") - 2, u = t.substring(a + 9, l);
1086
- s = this.saveTextToParentTag(s, n, r);
1087
- let f = this.parseTextData(u, n.tagname, r, !0, !1, !0, !0);
1088
- f == null && (f = ""), this.options.cdataPropName ? n.add(this.options.cdataPropName, [{ [this.options.textNodeName]: u }]) : n.add(this.options.textNodeName, f), a = l + 2;
1089
- } else {
1090
- let l = j(t, a, this.options.removeNSPrefix), u = l.tagName;
1091
- const f = l.rawTagName;
1092
- let d = l.tagExp, h = l.attrExpPresent, m = l.closeIndex;
1093
- if (this.options.transformTagName) {
1094
- const g = this.options.transformTagName(u);
1095
- d === u && (d = g), u = g;
1096
- }
1097
- if (this.options.strictReservedNames && (u === this.options.commentPropName || u === this.options.cdataPropName || u === this.options.textNodeName || u === this.options.attributesGroupName))
1098
- throw new Error(`Invalid tag name: ${u}`);
1099
- n && s && n.tagname !== "!xml" && (s = this.saveTextToParentTag(s, n, r, !1));
1100
- const b = n;
1101
- b && this.options.unpairedTags.indexOf(b.tagname) !== -1 && (n = this.tagsNodeStack.pop(), r = r.substring(0, r.lastIndexOf("."))), u !== e.tagname && (r += r ? "." + u : u);
1102
- const y = a;
1103
- if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, r, u)) {
1104
- let g = "";
1105
- if (d.length > 0 && d.lastIndexOf("/") === d.length - 1)
1106
- u[u.length - 1] === "/" ? (u = u.substr(0, u.length - 1), r = r.substr(0, r.length - 1), d = u) : d = d.substr(0, d.length - 1), a = l.closeIndex;
1107
- else if (this.options.unpairedTags.indexOf(u) !== -1)
1108
- a = l.closeIndex;
1109
- else {
1110
- const M = this.readStopNodeData(t, f, m + 1);
1111
- if (!M) throw new Error(`Unexpected end of ${f}`);
1112
- a = M.i, g = M.tagContent;
1113
- }
1114
- const T = new I(u);
1115
- u !== d && h && (T[":@"] = this.buildAttributesMap(d, r, u)), g && (g = this.parseTextData(g, u, r, !0, h, !0, !0)), r = r.substr(0, r.lastIndexOf(".")), T.add(this.options.textNodeName, g), this.addChild(n, T, r, y);
1116
- } else {
1117
- if (d.length > 0 && d.lastIndexOf("/") === d.length - 1) {
1118
- if (u[u.length - 1] === "/" ? (u = u.substr(0, u.length - 1), r = r.substr(0, r.length - 1), d = u) : d = d.substr(0, d.length - 1), this.options.transformTagName) {
1119
- const T = this.options.transformTagName(u);
1120
- d === u && (d = T), u = T;
1121
- }
1122
- const g = new I(u);
1123
- u !== d && h && (g[":@"] = this.buildAttributesMap(d, r, u)), this.addChild(n, g, r, y), r = r.substr(0, r.lastIndexOf("."));
1124
- } else if (this.options.unpairedTags.indexOf(u) !== -1) {
1125
- const g = new I(u);
1126
- u !== d && h && (g[":@"] = this.buildAttributesMap(d, r)), this.addChild(n, g, r, y), r = r.substr(0, r.lastIndexOf(".")), a = l.closeIndex;
1127
- continue;
1128
- } else {
1129
- const g = new I(u);
1130
- if (this.tagsNodeStack.length > this.options.maxNestedTags)
1131
- throw new Error("Maximum nested tags exceeded");
1132
- this.tagsNodeStack.push(n), u !== d && h && (g[":@"] = this.buildAttributesMap(d, r, u)), this.addChild(n, g, r), n = g;
1133
- }
1134
- s = "", a = m;
1135
- }
1136
- }
1137
- else
1138
- s += t[a];
1139
- return e.child;
1140
- };
1141
- function ze(t, e, n, s) {
1142
- this.options.captureMetaData || (s = void 0);
1143
- const r = this.options.updateTag(e.tagname, n, e[":@"]);
1144
- r === !1 || (typeof r == "string" && (e.tagname = r), t.addChild(e, s));
1145
- }
1146
- const Je = function(t, e, n) {
1147
- if (t.indexOf("&") === -1)
1148
- return t;
1149
- const s = this.options.processEntities;
1150
- if (!s.enabled || s.allowedTags && !s.allowedTags.includes(e) || s.tagFilter && !s.tagFilter(e, n))
1151
- return t;
1152
- for (let r in this.docTypeEntities) {
1153
- const o = this.docTypeEntities[r], a = t.match(o.regx);
1154
- if (a) {
1155
- if (this.entityExpansionCount += a.length, s.maxTotalExpansions && this.entityExpansionCount > s.maxTotalExpansions)
1156
- throw new Error(
1157
- `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`
1158
- );
1159
- const c = t.length;
1160
- if (t = t.replace(o.regx, o.val), s.maxExpandedLength && (this.currentExpandedLength += t.length - c, this.currentExpandedLength > s.maxExpandedLength))
1161
- throw new Error(
1162
- `Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`
1163
- );
1164
- }
1165
- }
1166
- if (t.indexOf("&") === -1) return t;
1167
- for (const r of Object.keys(this.lastEntities)) {
1168
- const o = this.lastEntities[r], a = t.match(o.regex);
1169
- if (a && (this.entityExpansionCount += a.length, s.maxTotalExpansions && this.entityExpansionCount > s.maxTotalExpansions))
1170
- throw new Error(
1171
- `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`
1172
- );
1173
- t = t.replace(o.regex, o.val);
1174
- }
1175
- if (t.indexOf("&") === -1) return t;
1176
- if (this.options.htmlEntities)
1177
- for (const r of Object.keys(this.htmlEntities)) {
1178
- const o = this.htmlEntities[r], a = t.match(o.regex);
1179
- if (a && (this.entityExpansionCount += a.length, s.maxTotalExpansions && this.entityExpansionCount > s.maxTotalExpansions))
1180
- throw new Error(
1181
- `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`
1182
- );
1183
- t = t.replace(o.regex, o.val);
1184
- }
1185
- return t = t.replace(this.ampEntity.regex, this.ampEntity.val), t;
1186
- };
1187
- function Ze(t, e, n, s) {
1188
- return t && (s === void 0 && (s = e.child.length === 0), t = this.parseTextData(
1189
- t,
1190
- e.tagname,
1191
- n,
1192
- !1,
1193
- e[":@"] ? Object.keys(e[":@"]).length !== 0 : !1,
1194
- s
1195
- ), t !== void 0 && t !== "" && e.add(this.options.textNodeName, t), t = ""), t;
1196
- }
1197
- function qe(t, e, n, s) {
1198
- return !!(e && e.has(s) || t && t.has(n));
1199
- }
1200
- function We(t, e, n = ">") {
1201
- let s, r = "";
1202
- for (let o = e; o < t.length; o++) {
1203
- let a = t[o];
1204
- if (s)
1205
- a === s && (s = "");
1206
- else if (a === '"' || a === "'")
1207
- s = a;
1208
- else if (a === n[0])
1209
- if (n[1]) {
1210
- if (t[o + 1] === n[1])
1211
- return {
1212
- data: r,
1213
- index: o
1214
- };
1215
- } else
1216
- return {
1217
- data: r,
1218
- index: o
1219
- };
1220
- else a === " " && (a = " ");
1221
- r += a;
1222
- }
1223
- }
1224
- function S(t, e, n, s) {
1225
- const r = t.indexOf(e, n);
1226
- if (r === -1)
1227
- throw new Error(s);
1228
- return r + e.length - 1;
1229
- }
1230
- function j(t, e, n, s = ">") {
1231
- const r = We(t, e + 1, s);
1232
- if (!r) return;
1233
- let o = r.data;
1234
- const a = r.index, c = o.search(/\s/);
1235
- let l = o, u = !0;
1236
- c !== -1 && (l = o.substring(0, c), o = o.substring(c + 1).trimStart());
1237
- const f = l;
1238
- if (n) {
1239
- const d = l.indexOf(":");
1240
- d !== -1 && (l = l.substr(d + 1), u = l !== r.data.substr(d + 1));
1241
- }
1242
- return {
1243
- tagName: l,
1244
- tagExp: o,
1245
- closeIndex: a,
1246
- attrExpPresent: u,
1247
- rawTagName: f
1248
- };
1249
- }
1250
- function He(t, e, n) {
1251
- const s = n;
1252
- let r = 1;
1253
- for (; n < t.length; n++)
1254
- if (t[n] === "<")
1255
- if (t[n + 1] === "/") {
1256
- const o = S(t, ">", n, `${e} is not closed`);
1257
- if (t.substring(n + 2, o).trim() === e && (r--, r === 0))
1258
- return {
1259
- tagContent: t.substring(s, n),
1260
- i: o
1261
- };
1262
- n = o;
1263
- } else if (t[n + 1] === "?")
1264
- n = S(t, "?>", n + 1, "StopNode is not closed.");
1265
- else if (t.substr(n + 1, 3) === "!--")
1266
- n = S(t, "-->", n + 3, "StopNode is not closed.");
1267
- else if (t.substr(n + 1, 2) === "![")
1268
- n = S(t, "]]>", n, "StopNode is not closed.") - 2;
1269
- else {
1270
- const o = j(t, n, ">");
1271
- o && ((o && o.tagName) === e && o.tagExp[o.tagExp.length - 1] !== "/" && r++, n = o.closeIndex);
1272
- }
1273
- }
1274
- function v(t, e, n) {
1275
- if (e && typeof t == "string") {
1276
- const s = t.trim();
1277
- return s === "true" ? !0 : s === "false" ? !1 : Fe(t, n);
1278
- } else
1279
- return L.isExist(t) ? t : "";
1280
- }
1281
- function Y(t, e, n) {
1282
- const s = Number.parseInt(t, e);
1283
- return s >= 0 && s <= 1114111 ? String.fromCodePoint(s) : n + t + ";";
1284
- }
1285
- function Qe(t, e) {
1286
- if (L.criticalProperties.includes(t))
1287
- throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);
1288
- return L.DANGEROUS_PROPERTY_NAMES.includes(t) ? e.onDangerousProperty(t) : t;
1289
- }
1290
- var De = Xe, te = {};
1291
- function et(t, e) {
1292
- return ne(t, e);
1293
- }
1294
- function ne(t, e, n) {
1295
- let s;
1296
- const r = {};
1297
- for (let o = 0; o < t.length; o++) {
1298
- const a = t[o], c = tt(a);
1299
- let l = "";
1300
- if (n === void 0 ? l = c : l = n + "." + c, c === e.textNodeName)
1301
- s === void 0 ? s = a[c] : s += "" + a[c];
1302
- else {
1303
- if (c === void 0)
1304
- continue;
1305
- if (a[c]) {
1306
- let u = ne(a[c], e, l);
1307
- const f = st(u, e);
1308
- a[":@"] ? nt(u, a[":@"], l, e) : Object.keys(u).length === 1 && u[e.textNodeName] !== void 0 && !e.alwaysCreateTextNode ? u = u[e.textNodeName] : Object.keys(u).length === 0 && (e.alwaysCreateTextNode ? u[e.textNodeName] = "" : u = ""), r[c] !== void 0 && r.hasOwnProperty(c) ? (Array.isArray(r[c]) || (r[c] = [r[c]]), r[c].push(u)) : e.isArray(c, l, f) ? r[c] = [u] : r[c] = u;
1309
- }
1310
- }
1311
- }
1312
- return typeof s == "string" ? s.length > 0 && (r[e.textNodeName] = s) : s !== void 0 && (r[e.textNodeName] = s), r;
1313
- }
1314
- function tt(t) {
1315
- const e = Object.keys(t);
1316
- for (let n = 0; n < e.length; n++) {
1317
- const s = e[n];
1318
- if (s !== ":@") return s;
1319
- }
1320
- }
1321
- function nt(t, e, n, s) {
1322
- if (e) {
1323
- const r = Object.keys(e), o = r.length;
1324
- for (let a = 0; a < o; a++) {
1325
- const c = r[a];
1326
- s.isArray(c, n + "." + c, !0, !0) ? t[c] = [e[c]] : t[c] = e[c];
1327
- }
1328
- }
1329
- }
1330
- function st(t, e) {
1331
- const { textNodeName: n } = e, s = Object.keys(t).length;
1332
- return !!(s === 0 || s === 1 && (t[n] || typeof t[n] == "boolean" || t[n] === 0));
1333
- }
1334
- te.prettify = et;
1335
- const { buildOptions: rt } = F, it = De, { prettify: ot } = te, at = Z;
1336
- let lt = class {
1337
- constructor(e) {
1338
- this.externalEntities = {}, this.options = rt(e);
1339
- }
1340
- /**
1341
- * Parse XML dats to JS object
1342
- * @param {string|Buffer} xmlData
1343
- * @param {boolean|Object} validationOption
1344
- */
1345
- parse(e, n) {
1346
- if (typeof e != "string") if (e.toString)
1347
- e = e.toString();
1348
- else
1349
- throw new Error("XML data is accepted in String or Bytes[] form.");
1350
- if (n) {
1351
- n === !0 && (n = {});
1352
- const o = at.validate(e, n);
1353
- if (o !== !0)
1354
- throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`);
1355
- }
1356
- const s = new it(this.options);
1357
- s.addExternalEntities(this.externalEntities);
1358
- const r = s.parseXml(e);
1359
- return this.options.preserveOrder || r === void 0 ? r : ot(r, this.options);
1360
- }
1361
- /**
1362
- * Add Entity which is not by default supported by this library
1363
- * @param {string} key
1364
- * @param {string} value
1365
- */
1366
- addEntity(e, n) {
1367
- if (n.indexOf("&") !== -1)
1368
- throw new Error("Entity value can't have '&'");
1369
- if (e.indexOf("&") !== -1 || e.indexOf(";") !== -1)
1370
- throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
1371
- if (n === "&")
1372
- throw new Error("An entity with value '&' is not permitted");
1373
- this.externalEntities[e] = n;
1374
- }
1375
- };
1376
- var ut = lt;
1377
- const ct = `
1378
- `;
1379
- function dt(t, e) {
1380
- let n = "";
1381
- return e.format && e.indentBy.length > 0 && (n = ct), se(t, e, "", n);
1382
- }
1383
- function se(t, e, n, s) {
1384
- let r = "", o = !1;
1385
- if (!Array.isArray(t)) {
1386
- if (t != null) {
1387
- let a = t.toString();
1388
- return a = $(a, e), a;
1389
- }
1390
- return "";
1391
- }
1392
- for (let a = 0; a < t.length; a++) {
1393
- const c = t[a], l = ft(c);
1394
- if (l === void 0) continue;
1395
- let u = "";
1396
- if (n.length === 0 ? u = l : u = `${n}.${l}`, l === e.textNodeName) {
1397
- let b = c[l];
1398
- ht(u, e) || (b = e.tagValueProcessor(l, b), b = $(b, e)), o && (r += s), r += b, o = !1;
1399
- continue;
1400
- } else if (l === e.cdataPropName) {
1401
- o && (r += s), r += `<![CDATA[${c[l][0][e.textNodeName]}]]>`, o = !1;
1402
- continue;
1403
- } else if (l === e.commentPropName) {
1404
- r += s + `<!--${c[l][0][e.textNodeName]}-->`, o = !0;
1405
- continue;
1406
- } else if (l[0] === "?") {
1407
- const b = K(c[":@"], e), y = l === "?xml" ? "" : s;
1408
- let g = c[l][0][e.textNodeName];
1409
- g = g.length !== 0 ? " " + g : "", r += y + `<${l}${g}${b}?>`, o = !0;
1410
- continue;
1411
- }
1412
- let f = s;
1413
- f !== "" && (f += e.indentBy);
1414
- const d = K(c[":@"], e), h = s + `<${l}${d}`, m = se(c[l], e, u, f);
1415
- e.unpairedTags.indexOf(l) !== -1 ? e.suppressUnpairedNode ? r += h + ">" : r += h + "/>" : (!m || m.length === 0) && e.suppressEmptyNode ? r += h + "/>" : m && m.endsWith(">") ? r += h + `>${m}${s}</${l}>` : (r += h + ">", m && s !== "" && (m.includes("/>") || m.includes("</")) ? r += s + e.indentBy + m + s : r += m, r += `</${l}>`), o = !0;
1416
- }
1417
- return r;
1418
- }
1419
- function ft(t) {
1420
- const e = Object.keys(t);
1421
- for (let n = 0; n < e.length; n++) {
1422
- const s = e[n];
1423
- if (Object.prototype.hasOwnProperty.call(t, s) && s !== ":@")
1424
- return s;
1425
- }
1426
- }
1427
- function K(t, e) {
1428
- let n = "";
1429
- if (t && !e.ignoreAttributes)
1430
- for (let s in t) {
1431
- if (!Object.prototype.hasOwnProperty.call(t, s)) continue;
1432
- let r = e.attributeValueProcessor(s, t[s]);
1433
- r = $(r, e), r === !0 && e.suppressBooleanAttributes ? n += ` ${s.substr(e.attributeNamePrefix.length)}` : n += ` ${s.substr(e.attributeNamePrefix.length)}="${r}"`;
1434
- }
1435
- return n;
1436
- }
1437
- function ht(t, e) {
1438
- t = t.substr(0, t.length - e.textNodeName.length - 1);
1439
- let n = t.substr(t.lastIndexOf(".") + 1);
1440
- for (let s in e.stopNodes)
1441
- if (e.stopNodes[s] === t || e.stopNodes[s] === "*." + n) return !0;
1442
- return !1;
1443
- }
1444
- function $(t, e) {
1445
- if (t && t.length > 0 && e.processEntities)
1446
- for (let n = 0; n < e.entities.length; n++) {
1447
- const s = e.entities[n];
1448
- t = t.replace(s.regex, s.val);
1449
- }
1450
- return t;
1451
- }
1452
- var gt = dt;
1453
- const pt = gt, mt = ee, bt = {
1454
- attributeNamePrefix: "@_",
1455
- attributesGroupName: !1,
1456
- textNodeName: "#text",
1457
- ignoreAttributes: !0,
1458
- cdataPropName: !1,
1459
- format: !1,
1460
- indentBy: " ",
1461
- suppressEmptyNode: !1,
1462
- suppressUnpairedNode: !0,
1463
- suppressBooleanAttributes: !0,
1464
- tagValueProcessor: function(t, e) {
1465
- return e;
1466
- },
1467
- attributeValueProcessor: function(t, e) {
1468
- return e;
1469
- },
1470
- preserveOrder: !1,
1471
- commentPropName: !1,
1472
- unpairedTags: [],
1473
- entities: [
1474
- { regex: new RegExp("&", "g"), val: "&amp;" },
1475
- //it must be on top
1476
- { regex: new RegExp(">", "g"), val: "&gt;" },
1477
- { regex: new RegExp("<", "g"), val: "&lt;" },
1478
- { regex: new RegExp("'", "g"), val: "&apos;" },
1479
- { regex: new RegExp('"', "g"), val: "&quot;" }
1480
- ],
1481
- processEntities: !0,
1482
- stopNodes: [],
1483
- // transformTagName: false,
1484
- // transformAttributeName: false,
1485
- oneListGroup: !1
1486
- };
1487
- function x(t) {
1488
- this.options = Object.assign({}, bt, t), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
1489
- return !1;
1490
- } : (this.ignoreAttributesFn = mt(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Et), this.processTextOrObjNode = Nt, this.options.format ? (this.indentate = wt, this.tagEndChar = `>
1491
- `, this.newLine = `
1492
- `) : (this.indentate = function() {
1493
- return "";
1494
- }, this.tagEndChar = ">", this.newLine = "");
1495
- }
1496
- x.prototype.build = function(t) {
1497
- return this.options.preserveOrder ? pt(t, this.options) : (Array.isArray(t) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t = {
1498
- [this.options.arrayNodeName]: t
1499
- }), this.j2x(t, 0, []).val);
1500
- };
1501
- x.prototype.j2x = function(t, e, n) {
1502
- let s = "", r = "";
1503
- const o = n.join(".");
1504
- for (let a in t)
1505
- if (Object.prototype.hasOwnProperty.call(t, a))
1506
- if (typeof t[a] > "u")
1507
- this.isAttribute(a) && (r += "");
1508
- else if (t[a] === null)
1509
- this.isAttribute(a) || a === this.options.cdataPropName ? r += "" : a[0] === "?" ? r += this.indentate(e) + "<" + a + "?" + this.tagEndChar : r += this.indentate(e) + "<" + a + "/" + this.tagEndChar;
1510
- else if (t[a] instanceof Date)
1511
- r += this.buildTextValNode(t[a], a, "", e);
1512
- else if (typeof t[a] != "object") {
1513
- const c = this.isAttribute(a);
1514
- if (c && !this.ignoreAttributesFn(c, o))
1515
- s += this.buildAttrPairStr(c, "" + t[a]);
1516
- else if (!c)
1517
- if (a === this.options.textNodeName) {
1518
- let l = this.options.tagValueProcessor(a, "" + t[a]);
1519
- r += this.replaceEntitiesValue(l);
1520
- } else
1521
- r += this.buildTextValNode(t[a], a, "", e);
1522
- } else if (Array.isArray(t[a])) {
1523
- const c = t[a].length;
1524
- let l = "", u = "";
1525
- for (let f = 0; f < c; f++) {
1526
- const d = t[a][f];
1527
- if (!(typeof d > "u")) if (d === null)
1528
- a[0] === "?" ? r += this.indentate(e) + "<" + a + "?" + this.tagEndChar : r += this.indentate(e) + "<" + a + "/" + this.tagEndChar;
1529
- else if (typeof d == "object")
1530
- if (this.options.oneListGroup) {
1531
- const h = this.j2x(d, e + 1, n.concat(a));
1532
- l += h.val, this.options.attributesGroupName && d.hasOwnProperty(this.options.attributesGroupName) && (u += h.attrStr);
1533
- } else
1534
- l += this.processTextOrObjNode(d, a, e, n);
1535
- else if (this.options.oneListGroup) {
1536
- let h = this.options.tagValueProcessor(a, d);
1537
- h = this.replaceEntitiesValue(h), l += h;
1538
- } else
1539
- l += this.buildTextValNode(d, a, "", e);
1540
- }
1541
- this.options.oneListGroup && (l = this.buildObjectNode(l, a, u, e)), r += l;
1542
- } else if (this.options.attributesGroupName && a === this.options.attributesGroupName) {
1543
- const c = Object.keys(t[a]), l = c.length;
1544
- for (let u = 0; u < l; u++)
1545
- s += this.buildAttrPairStr(c[u], "" + t[a][c[u]]);
1546
- } else
1547
- r += this.processTextOrObjNode(t[a], a, e, n);
1548
- return { attrStr: s, val: r };
1549
- };
1550
- x.prototype.buildAttrPairStr = function(t, e) {
1551
- return e = this.options.attributeValueProcessor(t, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + t : " " + t + '="' + e + '"';
1552
- };
1553
- function Nt(t, e, n, s) {
1554
- const r = this.j2x(t, n + 1, s.concat(e));
1555
- return t[this.options.textNodeName] !== void 0 && Object.keys(t).length === 1 ? this.buildTextValNode(t[this.options.textNodeName], e, r.attrStr, n) : this.buildObjectNode(r.val, e, r.attrStr, n);
1556
- }
1557
- x.prototype.buildObjectNode = function(t, e, n, s) {
1558
- if (t === "")
1559
- return e[0] === "?" ? this.indentate(s) + "<" + e + n + "?" + this.tagEndChar : this.indentate(s) + "<" + e + n + this.closeTag(e) + this.tagEndChar;
1560
- {
1561
- let r = "</" + e + this.tagEndChar, o = "";
1562
- return e[0] === "?" && (o = "?", r = ""), (n || n === "") && t.indexOf("<") === -1 ? this.indentate(s) + "<" + e + n + o + ">" + t + r : this.options.commentPropName !== !1 && e === this.options.commentPropName && o.length === 0 ? this.indentate(s) + `<!--${t}-->` + this.newLine : this.indentate(s) + "<" + e + n + o + this.tagEndChar + t + this.indentate(s) + r;
1563
- }
1564
- };
1565
- x.prototype.closeTag = function(t) {
1566
- let e = "";
1567
- return this.options.unpairedTags.indexOf(t) !== -1 ? this.options.suppressUnpairedNode || (e = "/") : this.options.suppressEmptyNode ? e = "/" : e = `></${t}`, e;
1568
- };
1569
- x.prototype.buildTextValNode = function(t, e, n, s) {
1570
- if (this.options.cdataPropName !== !1 && e === this.options.cdataPropName)
1571
- return this.indentate(s) + `<![CDATA[${t}]]>` + this.newLine;
1572
- if (this.options.commentPropName !== !1 && e === this.options.commentPropName)
1573
- return this.indentate(s) + `<!--${t}-->` + this.newLine;
1574
- if (e[0] === "?")
1575
- return this.indentate(s) + "<" + e + n + "?" + this.tagEndChar;
1576
- {
1577
- let r = this.options.tagValueProcessor(e, t);
1578
- return r = this.replaceEntitiesValue(r), r === "" ? this.indentate(s) + "<" + e + n + this.closeTag(e) + this.tagEndChar : this.indentate(s) + "<" + e + n + ">" + r + "</" + e + this.tagEndChar;
1579
- }
1580
- };
1581
- x.prototype.replaceEntitiesValue = function(t) {
1582
- if (t && t.length > 0 && this.options.processEntities)
1583
- for (let e = 0; e < this.options.entities.length; e++) {
1584
- const n = this.options.entities[e];
1585
- t = t.replace(n.regex, n.val);
1586
- }
1587
- return t;
1588
- };
1589
- function wt(t) {
1590
- return this.options.indentBy.repeat(t);
1591
- }
1592
- function Et(t) {
1593
- return t.startsWith(this.options.attributeNamePrefix) && t !== this.options.textNodeName ? t.substr(this.attrPrefixLen) : !1;
1594
- }
1595
- var yt = x;
1596
- const xt = ut, At = yt;
1597
- var R = {
1598
- XMLParser: xt,
1599
- XMLBuilder: At
1600
- };
1601
- class re {
1602
- constructor(e, n) {
1603
- A(this, "alphabet");
1604
- A(this, "padding");
1605
- A(this, "decodeMap", /* @__PURE__ */ new Map());
1606
- if (e.length !== 32)
1607
- throw new Error("Invalid alphabet");
1608
- if (this.alphabet = e, this.padding = (n == null ? void 0 : n.padding) ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1)
1609
- throw new Error("Invalid padding");
1610
- for (let s = 0; s < e.length; s++)
1611
- this.decodeMap.set(e[s], s);
1612
- }
1613
- encode(e, n) {
1614
- let s = "", r = 0, o = 0;
1615
- for (let c = 0; c < e.length; c++)
1616
- for (r = r << 8 | e[c], o += 8; o >= 5; )
1617
- o -= 5, s += this.alphabet[r >> o & 31];
1618
- if (o > 0 && (s += this.alphabet[r << 5 - o & 31]), (n == null ? void 0 : n.includePadding) ?? !0) {
1619
- const c = (8 - s.length % 8) % 8;
1620
- for (let l = 0; l < c; l++)
1621
- s += "=";
1622
- }
1623
- return s;
1624
- }
1625
- decode(e, n) {
1626
- const s = (n == null ? void 0 : n.strict) ?? !0, r = Math.ceil(e.length / 8), o = [];
1627
- for (let a = 0; a < r; a++) {
1628
- let c = 0;
1629
- const l = [];
1630
- for (let f = 0; f < 8; f++) {
1631
- const d = e[a * 8 + f];
1632
- if (d === "=") {
1633
- if (a + 1 !== r)
1634
- throw new Error(`Invalid character: ${d}`);
1635
- c += 1;
1636
- continue;
1637
- }
1638
- if (d === void 0) {
1639
- if (s)
1640
- throw new Error("Invalid data");
1641
- c += 1;
1642
- continue;
1643
- }
1644
- const h = this.decodeMap.get(d) ?? null;
1645
- if (h === null)
1646
- throw new Error(`Invalid character: ${d}`);
1647
- l.push(h);
1648
- }
1649
- if (c === 8 || c === 7 || c === 5 || c === 2)
1650
- throw new Error("Invalid padding");
1651
- const u = (l[0] << 3) + (l[1] >> 2);
1652
- if (o.push(u), c < 6) {
1653
- const f = ((l[1] & 3) << 6) + (l[2] << 1) + (l[3] >> 4);
1654
- o.push(f);
1655
- }
1656
- if (c < 4) {
1657
- const f = ((l[3] & 255) << 4) + (l[4] >> 1);
1658
- o.push(f);
1659
- }
1660
- if (c < 3) {
1661
- const f = ((l[4] & 1) << 7) + (l[5] << 2) + (l[6] >> 3);
1662
- o.push(f);
1663
- }
1664
- if (c < 1) {
1665
- const f = ((l[6] & 7) << 5) + l[7];
1666
- o.push(f);
1667
- }
1668
- }
1669
- return Uint8Array.from(o);
1670
- }
1671
- }
1672
- new re("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
1673
- new re("0123456789ABCDEFGHIJKLMNOPQRSTUV");
1674
- class ie {
1675
- constructor(e, n) {
1676
- A(this, "alphabet");
1677
- A(this, "padding");
1678
- A(this, "decodeMap", /* @__PURE__ */ new Map());
1679
- if (e.length !== 64)
1680
- throw new Error("Invalid alphabet");
1681
- if (this.alphabet = e, this.padding = (n == null ? void 0 : n.padding) ?? "=", this.alphabet.includes(this.padding) || this.padding.length !== 1)
1682
- throw new Error("Invalid padding");
1683
- for (let s = 0; s < e.length; s++)
1684
- this.decodeMap.set(e[s], s);
1685
- }
1686
- encode(e, n) {
1687
- let s = "", r = 0, o = 0;
1688
- for (let c = 0; c < e.length; c++)
1689
- for (r = r << 8 | e[c], o += 8; o >= 6; )
1690
- o += -6, s += this.alphabet[r >> o & 63];
1691
- if (o > 0 && (s += this.alphabet[r << 6 - o & 63]), (n == null ? void 0 : n.includePadding) ?? !0) {
1692
- const c = (4 - s.length % 4) % 4;
1693
- for (let l = 0; l < c; l++)
1694
- s += "=";
1695
- }
1696
- return s;
1697
- }
1698
- decode(e, n) {
1699
- const s = (n == null ? void 0 : n.strict) ?? !0, r = Math.ceil(e.length / 4), o = [];
1700
- for (let a = 0; a < r; a++) {
1701
- let c = 0, l = 0;
1702
- for (let u = 0; u < 4; u++) {
1703
- const f = e[a * 4 + u];
1704
- if (f === "=") {
1705
- if (a + 1 !== r)
1706
- throw new Error(`Invalid character: ${f}`);
1707
- c += 1;
1708
- continue;
1709
- }
1710
- if (f === void 0) {
1711
- if (s)
1712
- throw new Error("Invalid data");
1713
- c += 1;
1714
- continue;
1715
- }
1716
- const d = this.decodeMap.get(f) ?? null;
1717
- if (d === null)
1718
- throw new Error(`Invalid character: ${f}`);
1719
- l += d << 6 * (3 - u);
1720
- }
1721
- o.push(l >> 16 & 255), c < 2 && o.push(l >> 8 & 255), c < 1 && o.push(l & 255);
1722
- }
1723
- return Uint8Array.from(o);
1724
- }
1725
- }
1726
- const _t = new ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
1727
- new ie("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
1728
- let St = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", z = (t = 21) => {
1729
- let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
1730
- for (; t--; )
1731
- e += St[n[t] & 63];
1732
- return e;
1733
- };
1734
- async function Tt(t) {
1735
- const e = new DecompressionStream("deflate-raw"), n = new Uint8Array(t), s = new Blob([n]).stream().pipeThrough(e);
1736
- return new Uint8Array(await new Response(s).arrayBuffer());
1737
- }
1738
- async function It(t) {
1739
- const e = await _t.decode(t.replace(/ /g, "+"));
1740
- try {
1741
- const n = await Tt(e);
1742
- return new TextDecoder().decode(n);
1743
- } catch (n) {
1744
- return console.warn(
1745
- "Decompression failed, assuming data is not compressed:",
1746
- n
1747
- ), new TextDecoder().decode(e);
1748
- }
1749
- }
1750
- async function Ft(t) {
1751
- const e = await It(t), s = new R.XMLParser({
1752
- attributeNamePrefix: "@_",
1753
- alwaysCreateTextNode: !0,
1754
- ignoreAttributes: !1
1755
- }).parse(e);
1756
- return ue.parse(s);
1757
- }
1758
- function Rt(t) {
1759
- const e = t.certificates.map((r) => ({
1760
- "@_use": "signing",
1761
- KeyInfo: {
1762
- "@_xmlns": "http://www.w3.org/2000/09/xmldsig#",
1763
- X509Data: {
1764
- X509Certificate: r
1765
- }
1766
- }
1767
- })), n = {
1768
- EntityDescriptor: {
1769
- "@_entityID": t.entityId,
1770
- "@_xmlns": "urn:oasis:names:tc:SAML:2.0:metadata",
1771
- IDPSSODescriptor: {
1772
- "@_protocolSupportEnumeration": "urn:oasis:names:tc:SAML:2.0:protocol",
1773
- KeyDescriptor: e,
1774
- SingleLogoutService: [
1775
- {
1776
- "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
1777
- "@_Location": t.singleLogoutServiceUrl
1778
- },
1779
- {
1780
- "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
1781
- "@_Location": t.singleLogoutServiceUrl
1782
- }
1783
- ],
1784
- NameIDFormat: [
1785
- "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
1786
- "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
1787
- "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
1788
- ],
1789
- SingleSignOnService: [
1790
- {
1791
- "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
1792
- "@_Location": t.assertionConsumerServiceUrl
1793
- },
1794
- {
1795
- "@_Binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
1796
- "@_Location": t.assertionConsumerServiceUrl
1797
- }
1798
- ],
1799
- Attribute: [
1800
- {
1801
- "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",
1802
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1803
- "@_FriendlyName": "E-Mail Address",
1804
- "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1805
- },
1806
- {
1807
- "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",
1808
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1809
- "@_FriendlyName": "Given Name",
1810
- "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1811
- },
1812
- {
1813
- "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
1814
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1815
- "@_FriendlyName": "Name",
1816
- "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1817
- },
1818
- {
1819
- "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",
1820
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1821
- "@_FriendlyName": "Surname",
1822
- "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1823
- },
1824
- {
1825
- "@_Name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
1826
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
1827
- "@_FriendlyName": "Name ID",
1828
- "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion"
1829
- }
1830
- ]
1831
- }
1832
- }
1833
- };
1834
- return new R.XMLBuilder({
1835
- ignoreAttributes: !1,
1836
- suppressEmptyNode: !0,
1837
- preserveOrder: !1,
1838
- format: !0,
1839
- attributeNamePrefix: "@_"
1840
- }).build(n);
1841
- }
1842
- async function Xt(t, e) {
1843
- const n = t.notBefore || (/* @__PURE__ */ new Date()).toISOString(), s = t.notAfter || new Date(new Date(n).getTime() + 10 * 60 * 1e3).toISOString(), r = t.issueInstant || n, o = t.sessionNotOnOrAfter || s, a = t.responseId || `_${z()}`, c = t.assertionId || `_${z()}`, l = [
1844
- {
1845
- "samlp:Response": [
1846
- {
1847
- "saml:Issuer": [{ "#text": t.issuer }]
1848
- },
1849
- {
1850
- "samlp:Status": [
1851
- {
1852
- "samlp:StatusCode": [],
1853
- ":@": { "@_Value": "urn:oasis:names:tc:SAML:2.0:status:Success" }
1854
- }
1855
- ]
1856
- },
1857
- {
1858
- "saml:Assertion": [
1859
- {
1860
- "saml:Issuer": [
1861
- {
1862
- "#text": t.issuer
1863
- }
1864
- ]
1865
- },
1866
- {
1867
- "saml:Subject": [
1868
- {
1869
- "saml:NameID": [{ "#text": t.email }],
1870
- ":@": {
1871
- "@_Format": "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
1872
- }
1873
- },
1874
- {
1875
- "saml:SubjectConfirmation": [
1876
- {
1877
- "saml:SubjectConfirmationData": [],
1878
- ":@": {
1879
- "@_InResponseTo": t.inResponseTo,
1880
- "@_NotOnOrAfter": s,
1881
- "@_Recipient": t.destination
1882
- }
1883
- }
1884
- ],
1885
- ":@": { "@_Method": "urn:oasis:names:tc:SAML:2.0:cm:bearer" }
1886
- }
1887
- ]
1888
- },
1889
- {
1890
- "saml:Conditions": [
1891
- {
1892
- "saml:AudienceRestriction": [
1893
- {
1894
- "saml:Audience": [
1895
- {
1896
- "#text": t.audience
1897
- }
1898
- ]
1899
- }
1900
- ]
1901
- }
1902
- ],
1903
- ":@": {
1904
- "@_NotBefore": n,
1905
- "@_NotOnOrAfter": s
1906
- }
1907
- },
1908
- {
1909
- "saml:AuthnStatement": [
1910
- {
1911
- "saml:AuthnContext": [
1912
- {
1913
- "saml:AuthnContextClassRef": [
1914
- {
1915
- "#text": "urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"
1916
- }
1917
- ]
1918
- }
1919
- ]
1920
- }
1921
- ],
1922
- ":@": {
1923
- "@_AuthnInstant": r,
1924
- "@_SessionIndex": t.sessionIndex,
1925
- "@_SessionNotOnOrAfter": o
1926
- }
1927
- },
1928
- {
1929
- "saml:AttributeStatement": [
1930
- {
1931
- "saml:Attribute": [
1932
- {
1933
- "saml:AttributeValue": [
1934
- {
1935
- "#text": t.userId
1936
- }
1937
- ],
1938
- ":@": {
1939
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1940
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1941
- "@_xsi:type": "xs:string"
1942
- }
1943
- }
1944
- ],
1945
- ":@": {
1946
- "@_FriendlyName": "persistent",
1947
- "@_Name": "id",
1948
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
1949
- }
1950
- },
1951
- {
1952
- "saml:Attribute": [
1953
- {
1954
- "saml:AttributeValue": [
1955
- {
1956
- "#text": t.email
1957
- }
1958
- ],
1959
- ":@": {
1960
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1961
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1962
- "@_xsi:type": "xs:string"
1963
- }
1964
- }
1965
- ],
1966
- ":@": {
1967
- "@_Name": "email",
1968
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1969
- }
1970
- },
1971
- {
1972
- "saml:Attribute": [
1973
- {
1974
- "saml:AttributeValue": [
1975
- {
1976
- "#text": "manage-account"
1977
- }
1978
- ],
1979
- ":@": {
1980
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
1981
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
1982
- "@_xsi:type": "xs:string"
1983
- }
1984
- }
1985
- ],
1986
- ":@": {
1987
- "@_Name": "Role",
1988
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
1989
- }
1990
- },
1991
- {
1992
- "saml:Attribute": [
1993
- {
1994
- "saml:AttributeValue": [
1995
- {
1996
- "#text": "default-roles-master"
1997
- }
1998
- ],
1999
- ":@": {
2000
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
2001
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
2002
- "@_xsi:type": "xs:string"
2003
- }
2004
- }
2005
- ],
2006
- ":@": {
2007
- "@_Name": "Role",
2008
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
2009
- }
2010
- },
2011
- {
2012
- "saml:Attribute": [
2013
- {
2014
- "saml:AttributeValue": [
2015
- {
2016
- "#text": "offline_access"
2017
- }
2018
- ],
2019
- ":@": {
2020
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
2021
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
2022
- "@_xsi:type": "xs:string"
2023
- }
2024
- }
2025
- ],
2026
- ":@": {
2027
- "@_Name": "Role",
2028
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
2029
- }
2030
- },
2031
- {
2032
- "saml:Attribute": [
2033
- {
2034
- "saml:AttributeValue": [
2035
- {
2036
- "#text": "view-profile"
2037
- }
2038
- ],
2039
- ":@": {
2040
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
2041
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
2042
- "@_xsi:type": "xs:string"
2043
- }
2044
- }
2045
- ],
2046
- ":@": {
2047
- "@_Name": "Role",
2048
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
2049
- }
2050
- },
2051
- {
2052
- "saml:Attribute": [
2053
- {
2054
- "saml:AttributeValue": [
2055
- {
2056
- "#text": "uma_authorization"
2057
- }
2058
- ],
2059
- ":@": {
2060
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
2061
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
2062
- "@_xsi:type": "xs:string"
2063
- }
2064
- }
2065
- ],
2066
- ":@": {
2067
- "@_Name": "Role",
2068
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
2069
- }
2070
- },
2071
- {
2072
- "saml:Attribute": [
2073
- {
2074
- "saml:AttributeValue": [
2075
- {
2076
- "#text": "manage-account-links"
2077
- }
2078
- ],
2079
- ":@": {
2080
- "@_xmlns:xs": "http://www.w3.org/2001/XMLSchema",
2081
- "@_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
2082
- "@_xsi:type": "xs:string"
2083
- }
2084
- }
2085
- ],
2086
- ":@": {
2087
- "@_Name": "Role",
2088
- "@_NameFormat": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
2089
- }
2090
- }
2091
- ]
2092
- }
2093
- ],
2094
- ":@": {
2095
- "@_xmlns": "urn:oasis:names:tc:SAML:2.0:assertion",
2096
- "@_ID": c,
2097
- "@_IssueInstant": r,
2098
- "@_Version": "2.0"
2099
- }
2100
- }
2101
- ],
2102
- ":@": {
2103
- "@_xmlns:samlp": "urn:oasis:names:tc:SAML:2.0:protocol",
2104
- "@_xmlns:saml": "urn:oasis:names:tc:SAML:2.0:assertion",
2105
- "@_Destination": t.destination,
2106
- "@_ID": a,
2107
- "@_InResponseTo": t.inResponseTo,
2108
- "@_IssueInstant": r,
2109
- "@_Version": "2.0"
2110
- }
2111
- }
2112
- ];
2113
- let f = new R.XMLBuilder({
2114
- ignoreAttributes: !1,
2115
- suppressEmptyNode: !0,
2116
- preserveOrder: !0
2117
- }).build(l);
2118
- return t.signature && e && (f = await e.signSAML(
2119
- f,
2120
- t.signature.privateKeyPem,
2121
- t.signature.cert
2122
- )), t.encode === !1 ? f : btoa(f);
2123
- }
2124
- const Ct = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", Ot = "http://www.w3.org/2001/04/xmlenc#sha256", J = "http://www.w3.org/2001/10/xml-exc-c14n#";
2125
- class Bt {
2126
- async signSAML(e, n, s) {
2127
- var r;
2128
- try {
2129
- const o = await import("xml-crypto"), a = o.SignedXml || ((r = o.default) == null ? void 0 : r.SignedXml);
2130
- if (!a)
2131
- throw new Error("SignedXml not found in xml-crypto module");
2132
- const c = new a({ privateKey: n, publicCert: s });
2133
- c.canonicalizationAlgorithm = J, c.addReference({
2134
- xpath: "(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",
2135
- digestAlgorithm: Ot,
2136
- transforms: [
2137
- "http://www.w3.org/2000/09/xmldsig#enveloped-signature",
2138
- J
2139
- ]
2140
- }), c.signatureAlgorithm = Ct;
2141
- const l = s.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
2142
- return c.keyInfoProvider = {
2143
- getKeyInfo: () => `<X509Data><X509Certificate>${l}</X509Certificate></X509Data>`
2144
- }, c.computeSignature(e, {
2145
- // according to:
2146
- // https://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd
2147
- // Assertion's ds:Signature must be after Assertion/Issuer
2148
- location: {
2149
- reference: "/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",
2150
- action: "after"
2151
- }
2152
- }), c.getSignedXml();
2153
- } catch (o) {
2154
- throw new Error(
2155
- `Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${o}`
2156
- );
2157
- }
2158
- }
2159
- }
2160
- class Ut {
2161
- constructor(e) {
2162
- this.signUrl = e;
2163
- }
2164
- async signSAML(e, n, s) {
2165
- const r = await fetch(this.signUrl, {
2166
- method: "POST",
2167
- headers: {
2168
- "Content-Type": "application/json"
2169
- },
2170
- body: JSON.stringify({
2171
- xmlContent: e,
2172
- privateKey: n,
2173
- publicCert: s
2174
- })
2175
- });
2176
- if (!r.ok)
2177
- throw new Error(
2178
- `Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`
2179
- );
2180
- return await r.text();
2181
- }
2182
- }
2183
- export {
2184
- Ut as HttpSamlSigner,
2185
- Bt as LocalSamlSigner,
2186
- Rt as createSamlMetadata,
2187
- Xt as createSamlResponse,
2188
- X as dsSignatureSchema,
2189
- It as inflateDecompress,
2190
- Tt as inflateRaw,
2191
- Ft as parseSamlRequestQuery,
2192
- le as samlIssuerSchema,
2193
- Mt as samlMetadataResponseSchema,
2194
- ue as samlRequestSchema,
2195
- jt as samlResponseJsonSchema
1680
+ //#endregion
1681
+ //#region src/signers/local.ts
1682
+ var N = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", P = "http://www.w3.org/2001/04/xmlenc#sha256", F = "http://www.w3.org/2001/10/xml-exc-c14n#", I = class {
1683
+ async signSAML(e, t, n) {
1684
+ try {
1685
+ let r = await import("xml-crypto"), i = r.SignedXml || r.default?.SignedXml;
1686
+ if (!i) throw Error("SignedXml not found in xml-crypto module");
1687
+ let a = new i({
1688
+ privateKey: t,
1689
+ publicCert: n
1690
+ });
1691
+ a.canonicalizationAlgorithm = F, a.addReference({
1692
+ xpath: "(/*[local-name()='Response']/*[local-name()='Assertion'])[1]",
1693
+ digestAlgorithm: P,
1694
+ transforms: ["http://www.w3.org/2000/09/xmldsig#enveloped-signature", F]
1695
+ }), a.signatureAlgorithm = N;
1696
+ let o = n.replace(/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/g, "").replace(/\s/g, "");
1697
+ return a.keyInfoProvider = { getKeyInfo: () => `<X509Data><X509Certificate>${o}</X509Certificate></X509Data>` }, a.computeSignature(e, { location: {
1698
+ reference: "/*[local-name()='Response']/*[local-name()='Assertion']/*[local-name()='Issuer']",
1699
+ action: "after"
1700
+ } }), a.getSignedXml();
1701
+ } catch (e) {
1702
+ throw Error(`Failed to sign SAML locally. Make sure xml-crypto is installed. Error: ${e}`);
1703
+ }
1704
+ }
1705
+ }, L = class {
1706
+ signUrl;
1707
+ constructor(e) {
1708
+ this.signUrl = e;
1709
+ }
1710
+ async signSAML(e, t, n) {
1711
+ let r = await fetch(this.signUrl, {
1712
+ method: "POST",
1713
+ headers: { "Content-Type": "application/json" },
1714
+ body: JSON.stringify({
1715
+ xmlContent: e,
1716
+ privateKey: t,
1717
+ publicCert: n
1718
+ })
1719
+ });
1720
+ if (!r.ok) throw Error(`Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`);
1721
+ return await r.text();
1722
+ }
2196
1723
  };
1724
+ //#endregion
1725
+ export { L as HttpSamlSigner, I as LocalSamlSigner, j as createSamlMetadata, M as createSamlResponse, c as dsSignatureSchema, k as inflateDecompress, O as inflateRaw, A as parseSamlRequestQuery, r as samlIssuerSchema, a as samlMetadataResponseSchema, i as samlRequestSchema, l as samlResponseJsonSchema };