xml-toolkit 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/index.js +10 -7
- package/lib/NamespacePrefixesMap.js +57 -0
- package/lib/XMLMarshaller.js +369 -0
- package/lib/XMLSchema.js +103 -0
- package/lib/XMLSchemata.js +143 -0
- package/package.json +6 -3
- package/test/20040.wsdl +1812 -0
- package/test/commons/dom-gosuslugi-ru-smev3-common.xsd +465 -0
- package/test/dom-gosuslugi-ru-smev3-debt-responses.xsd +776 -0
- package/test/sign.xsd +71 -0
- package/test/test.js +161 -2
package/test/sign.xsd
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2000/09/xmldsig#">
|
|
2
|
+
<xsd:element name="Signature" type="ds:DSSignatureType"/>
|
|
3
|
+
<xsd:complexType name="DSSignatureType">
|
|
4
|
+
<xsd:sequence>
|
|
5
|
+
<xsd:element minOccurs="0" ref="ds:KeyInfo"/>
|
|
6
|
+
<xsd:element ref="ds:SignedInfo"/>
|
|
7
|
+
<xsd:element ref="ds:SignatureValue"/>
|
|
8
|
+
</xsd:sequence>
|
|
9
|
+
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
|
|
10
|
+
</xsd:complexType>
|
|
11
|
+
<xsd:element name="SignatureValue" type="xsd:base64Binary"/>
|
|
12
|
+
<xsd:element name="SignedInfo" type="ds:DSSignedInfoType"/>
|
|
13
|
+
<xsd:complexType name="DSSignedInfoType">
|
|
14
|
+
<xsd:sequence>
|
|
15
|
+
<xsd:element ref="ds:CanonicalizationMethod"/>
|
|
16
|
+
<xsd:element ref="ds:SignatureMethod"/>
|
|
17
|
+
<xsd:element maxOccurs="unbounded" ref="ds:Reference"/>
|
|
18
|
+
</xsd:sequence>
|
|
19
|
+
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
|
|
20
|
+
</xsd:complexType>
|
|
21
|
+
<xsd:element name="CanonicalizationMethod" type="ds:DSCanonicalizationMethodType"/>
|
|
22
|
+
<xsd:complexType mixed="true" name="DSCanonicalizationMethodType">
|
|
23
|
+
<xsd:sequence>
|
|
24
|
+
<xsd:any maxOccurs="unbounded" minOccurs="0" namespace="##any"/>
|
|
25
|
+
</xsd:sequence>
|
|
26
|
+
<xsd:attribute default="http://www.w3.org/2001/10/xml-exc-c14n#" name="Algorithm" type="xsd:anyURI" use="optional"/>
|
|
27
|
+
</xsd:complexType>
|
|
28
|
+
<xsd:element name="SignatureMethod" type="ds:DSSignatureMethodType"/>
|
|
29
|
+
<xsd:complexType mixed="true" name="DSSignatureMethodType">
|
|
30
|
+
<xsd:attribute default="http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411" name="Algorithm" type="xsd:anyURI" use="optional"/>
|
|
31
|
+
</xsd:complexType>
|
|
32
|
+
<xsd:element name="Reference" type="ds:DSReferenceType"/>
|
|
33
|
+
<xsd:complexType name="DSReferenceType">
|
|
34
|
+
<xsd:sequence>
|
|
35
|
+
<xsd:element minOccurs="0" ref="ds:Transforms"/>
|
|
36
|
+
<xsd:element ref="ds:DigestMethod"/>
|
|
37
|
+
<xsd:element ref="ds:DigestValue"/>
|
|
38
|
+
</xsd:sequence>
|
|
39
|
+
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
|
|
40
|
+
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
|
|
41
|
+
<xsd:attribute name="Type" type="xsd:anyURI" use="optional"/>
|
|
42
|
+
</xsd:complexType>
|
|
43
|
+
<xsd:element name="Transforms" type="ds:DSTransformsType"/>
|
|
44
|
+
<xsd:complexType name="DSTransformsType">
|
|
45
|
+
<xsd:sequence>
|
|
46
|
+
<xsd:element maxOccurs="unbounded" ref="ds:Transform"/>
|
|
47
|
+
</xsd:sequence>
|
|
48
|
+
</xsd:complexType>
|
|
49
|
+
<xsd:element name="Transform" type="ds:DSTransformType"/>
|
|
50
|
+
<xsd:complexType mixed="true" name="DSTransformType">
|
|
51
|
+
<xsd:attribute default="http://www.w3.org/2000/09/xmldsig#enveloped-signature" name="Algorithm" type="xsd:anyURI" use="optional"/>
|
|
52
|
+
</xsd:complexType>
|
|
53
|
+
<xsd:element name="DigestMethod" type="ds:DSDigestMethodType"/>
|
|
54
|
+
<xsd:complexType mixed="true" name="DSDigestMethodType">
|
|
55
|
+
<xsd:attribute default="http://www.w3.org/2001/04/xmldsig-more#gostr3411" name="Algorithm" type="xsd:anyURI" use="optional"/>
|
|
56
|
+
</xsd:complexType>
|
|
57
|
+
<xsd:element name="DigestValue" type="xsd:base64Binary"/>
|
|
58
|
+
<xsd:element name="KeyInfo" type="ds:DSKeyInfoType"/>
|
|
59
|
+
<xsd:complexType mixed="true" name="DSKeyInfoType">
|
|
60
|
+
<xsd:sequence>
|
|
61
|
+
<xsd:element ref="ds:X509Data"/>
|
|
62
|
+
</xsd:sequence>
|
|
63
|
+
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
|
|
64
|
+
</xsd:complexType>
|
|
65
|
+
<xsd:element name="X509Data" type="ds:DSX509DataType"/>
|
|
66
|
+
<xsd:complexType name="DSX509DataType">
|
|
67
|
+
<xsd:sequence maxOccurs="unbounded">
|
|
68
|
+
<xsd:element name="X509Certificate" type="xsd:base64Binary"/>
|
|
69
|
+
</xsd:sequence>
|
|
70
|
+
</xsd:complexType>
|
|
71
|
+
</xsd:schema>
|
package/test/test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require ('fs')
|
|
2
2
|
const assert = require ('assert')
|
|
3
|
-
const {XMLReader, SAXEvent, XMLLexer, AttributesMap, XMLNode} = require ('../')
|
|
3
|
+
const {XMLReader, SAXEvent, XMLLexer, AttributesMap, XMLNode, XMLSchemata} = require ('../')
|
|
4
4
|
|
|
5
5
|
async function test_001_lexer_sync (fn) {
|
|
6
6
|
|
|
@@ -100,6 +100,163 @@ console.log (xml)
|
|
|
100
100
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
async function test_004_schemata (fn) {
|
|
104
|
+
|
|
105
|
+
let xs = await XMLSchemata.fromFile ('test/dom-gosuslugi-ru-smev3-debt-responses.xsd')
|
|
106
|
+
/*
|
|
107
|
+
const localName = 'ImportDebtRequestsRequest'
|
|
108
|
+
|
|
109
|
+
const s = xs.getSchemaByLocalName (localName)
|
|
110
|
+
|
|
111
|
+
const o = s.get (localName)
|
|
112
|
+
|
|
113
|
+
const nspm = xs.getNamespacePrefixesMap (o)
|
|
114
|
+
*/
|
|
115
|
+
console.log (xs.stringify ({
|
|
116
|
+
"ExportDebtRequestsResponse": {
|
|
117
|
+
"request-data": {
|
|
118
|
+
"request-id": "bac4c940-6ad3-11eb-9439-0242ac130002",
|
|
119
|
+
"request-number": "022021173",
|
|
120
|
+
"applicant-info": {
|
|
121
|
+
"firstname": "Иван",
|
|
122
|
+
"lastname": "Иванов",
|
|
123
|
+
"middlename": "Иванович",
|
|
124
|
+
"snils": "11111111145",
|
|
125
|
+
"document": {
|
|
126
|
+
"type": "1",
|
|
127
|
+
"series": "1234",
|
|
128
|
+
"number": "123456"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"housing-fund-object": {
|
|
132
|
+
"house-id": "e786b770-28e6-4557-8dde-86e8e347587e",
|
|
133
|
+
"address-details": "кв. 27",
|
|
134
|
+
"fias-house-id": "497cdeef-0388-466b-a063-36f51d94800c",
|
|
135
|
+
"address": "153045, Ивановская обл, г. Иваново, ул. 3 Июня, д. 14"
|
|
136
|
+
},
|
|
137
|
+
"period": {
|
|
138
|
+
"start-date": "2018-02-01",
|
|
139
|
+
"end-date": new Date ()
|
|
140
|
+
},
|
|
141
|
+
"organization": {
|
|
142
|
+
"organization-root-id": "6eef689e-48bb-4eb0-9c11-18b6db9909b7",
|
|
143
|
+
"name": "Администрация г. Иваново",
|
|
144
|
+
"tel": "+7(4932)32-80-83"
|
|
145
|
+
},
|
|
146
|
+
"executor-info": {
|
|
147
|
+
"id": "84b12e02-6ad8-11eb-9439-0242ac130002",
|
|
148
|
+
"fio": "Четвертак Иван Иванович"
|
|
149
|
+
},
|
|
150
|
+
"status": "PROCESSED",
|
|
151
|
+
"result": 4,
|
|
152
|
+
"creation-date": "2021-02-04",
|
|
153
|
+
"sent-date": "2021-02-04",
|
|
154
|
+
"response-date": "2021-02-08",
|
|
155
|
+
"subrequest": {
|
|
156
|
+
"organization": {
|
|
157
|
+
"organization-root-id": "ad50290c-6ad9-11eb-9439-0242ac130002",
|
|
158
|
+
"name": "УК ООО \"ГУЖФ\"",
|
|
159
|
+
"tel": "8-800-200-50-58"
|
|
160
|
+
},
|
|
161
|
+
"response": {
|
|
162
|
+
"type": "PROVIDED",
|
|
163
|
+
"has-debt": true,
|
|
164
|
+
"debt-info": [
|
|
165
|
+
{
|
|
166
|
+
"person": {
|
|
167
|
+
"firstname": "Петр",
|
|
168
|
+
"lastname": "Петров",
|
|
169
|
+
"middlename": "Петрович",
|
|
170
|
+
"snils": "11111111146",
|
|
171
|
+
"document": {
|
|
172
|
+
"type": "1",
|
|
173
|
+
"series": "1235",
|
|
174
|
+
"number": "123455"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"person": {
|
|
180
|
+
"firstname": "Сидор",
|
|
181
|
+
"lastname": "Сидоров",
|
|
182
|
+
"middlename": "Сидорович",
|
|
183
|
+
"snils": "11111111146",
|
|
184
|
+
"document": {
|
|
185
|
+
"type": "1",
|
|
186
|
+
"series": "1235",
|
|
187
|
+
"number": "123455"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"executor-info": {
|
|
193
|
+
"id": "38a794b8-6ada-11eb-9439-0242ac130002",
|
|
194
|
+
"fio": "Герасимова Ольга Ивановна"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}))
|
|
201
|
+
|
|
202
|
+
//getNamespacePrefixesMap
|
|
203
|
+
/*
|
|
204
|
+
console.log (xs.get ('urn:dom.gosuslugi.ru/debt-requests/1.0.0').get ('ImportDebtRequestsRequest').complexType.complexContent.extension)
|
|
205
|
+
|
|
206
|
+
console.log (xs.get ('urn:dom.gosuslugi.ru/common/1.2.0').get ('BaseRequestType').sequence )
|
|
207
|
+
|
|
208
|
+
console.log (xs.get ('urn:dom.gosuslugi.ru/debt-requests/1.0.0').get ('ActionType').restriction)
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function test_005_schemata (fn) {
|
|
214
|
+
|
|
215
|
+
const xs = await XMLSchemata.fromFile ('test/20040.wsdl')
|
|
216
|
+
|
|
217
|
+
const data = {
|
|
218
|
+
|
|
219
|
+
"AppData": {
|
|
220
|
+
"info": {
|
|
221
|
+
"person": {
|
|
222
|
+
"fNameCiv": "ППП",
|
|
223
|
+
"iNameCiv": "ППП",
|
|
224
|
+
"mNameCiv": null,
|
|
225
|
+
"docDatCiv": "1973-03-01"
|
|
226
|
+
},
|
|
227
|
+
"snils": "022-114-680 91",
|
|
228
|
+
"document": {
|
|
229
|
+
"codeKind": "01",
|
|
230
|
+
"numDoc": "999999",
|
|
231
|
+
"seriesDoc": "9999",
|
|
232
|
+
"dateDoc": "2022-03-05"
|
|
233
|
+
},
|
|
234
|
+
"startDate": "2021-08-01",
|
|
235
|
+
"endDate": "2022-01-31T00:00:00",
|
|
236
|
+
"child": {
|
|
237
|
+
"fNameCiv": "ООО",
|
|
238
|
+
"iNameCiv": "ООО",
|
|
239
|
+
"mNameCiv": null,
|
|
240
|
+
"docDatCiv": "2022-02-08"
|
|
241
|
+
},
|
|
242
|
+
"childDocument": {
|
|
243
|
+
"codeKind": "03",
|
|
244
|
+
"numDoc": "333333",
|
|
245
|
+
"seriesDoc": "333333333",
|
|
246
|
+
"dateDoc": "2022-03-01"
|
|
247
|
+
},
|
|
248
|
+
"childSnils": "109-598-827 12"
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
}, {info} = data.AppData
|
|
253
|
+
|
|
254
|
+
const m = xs.createMarshaller ('AppDataChildDotation', 'http://smev.gosuslugi.ru/rev111111')
|
|
255
|
+
|
|
256
|
+
console.log (m.stringify ({info}, 'AppData'))
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
|
|
103
260
|
async function main () {
|
|
104
261
|
|
|
105
262
|
// await test_001_lexer_sync ('E05a.xml')
|
|
@@ -113,7 +270,9 @@ async function main () {
|
|
|
113
270
|
// await test_003_emitter_sync ('param_types.xml')
|
|
114
271
|
// await test_003_emitter_sync ('not-sa01.xml')
|
|
115
272
|
// await test_003_emitter_sync ('ent.xml')
|
|
116
|
-
await test_003_emitter_sync ('soap.xml')
|
|
273
|
+
// await test_003_emitter_sync ('soap.xml')
|
|
274
|
+
await test_004_schemata ()
|
|
275
|
+
await test_005_schemata ()
|
|
117
276
|
|
|
118
277
|
}
|
|
119
278
|
|