czech-data-box 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +16 -0
- package/.nvmrc +1 -0
- package/.prettierignore +1 -0
- package/.prettierrc.yaml +6 -0
- package/.vscode/launch.json +15 -0
- package/.vscode/settings.json +5 -0
- package/CHANGELOG.md +17 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +84 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/eslint.config.js +26 -0
- package/examples/db_login_with_certificate.js +27 -0
- package/examples/db_search.js +27 -0
- package/examples/dm_operations.js +58 -0
- package/package.json +57 -0
- package/resources/certs/cacert_postsignum_vca4.pem +44 -0
- package/resources/wsdl/ChangePassword.wsdl +84 -0
- package/resources/wsdl/ChangePasswordTypes.xsd +69 -0
- package/resources/wsdl/ExtWs.wsdl +65 -0
- package/resources/wsdl/dbTypes.xsd +1688 -0
- package/resources/wsdl/db_access.wsdl +197 -0
- package/resources/wsdl/db_manipulations.wsdl +598 -0
- package/resources/wsdl/db_search.wsdl +362 -0
- package/resources/wsdl/dmBaseTypes.xsd +1497 -0
- package/resources/wsdl/dm_VoDZ.wsdl +212 -0
- package/resources/wsdl/dm_info.wsdl +412 -0
- package/resources/wsdl/dm_operations.wsdl +242 -0
- package/src/index.js +4 -0
- package/src/lib/ISDSBox.js +309 -0
- package/src/lib/ISDSSentOutFiles.js +84 -0
- package/src/lib/ISDSSoapClient.js +201 -0
- package/src/lib/config.js +64 -0
- package/src/models/DataBox.js +142 -0
- package/src/models/DataMessage.js +153 -0
- package/src/models/DataMessageFile.js +69 -0
- package/src/models/DataMessageFiles.js +23 -0
- package/test/ISDSBox.test.js +129 -0
- package/test/ISDSSentOutFiles.test.js +124 -0
- package/test/ISDSSoapClient.test.js +81 -0
- package/test/communication_test.pdf +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<?xml version = '1.0' encoding = 'UTF-8'?>
|
|
2
|
+
<!-- *********************************************************************
|
|
3
|
+
|
|
4
|
+
verze: 3.04
|
|
5
|
+
klasifikace: Veřejný dokument
|
|
6
|
+
|
|
7
|
+
WSDL pro služby
|
|
8
|
+
1. Vytvoření/odeslání datové zprávy - CreateMessage
|
|
9
|
+
2. stažení kompletní přijaté zprávy v čitelné podobě - MessageDownload
|
|
10
|
+
3. stažení podepsané přijaté zprávy - SignedMessageDownload
|
|
11
|
+
4. stažení podepsané odeslané zprávy - SignedSentMessageDownload
|
|
12
|
+
5. vytvoření hromadné zprávy - CreateMultipleMessage
|
|
13
|
+
6. ověření zprávy - AuthenticateMessage
|
|
14
|
+
7. přepodepsání zprávy či doručenky - Re-signISDSDocument
|
|
15
|
+
|
|
16
|
+
Změny:
|
|
17
|
+
04.02.2009 verze 0.1
|
|
18
|
+
20.03.2009 verze 1.0 - formální úpravy vyhovující WS-I Basic Profile
|
|
19
|
+
08.04.2009 verze 1.2 - změna názvů WSDL, rozložení operací mezi WSDL
|
|
20
|
+
16.04.2009 verze 1.3 - přidána DummyOperation pro navazování a udržování spojení
|
|
21
|
+
03.06.2009 verze 2.0 - novela
|
|
22
|
+
01.10.2009 verze 2.5 - přidána WS CreateMultipleMessage
|
|
23
|
+
01.11.2009 verze 2.6 - komerční provoz
|
|
24
|
+
14.04.2010 verze 2.9 - přidána WS AuthenticateMessage
|
|
25
|
+
18.09.2010 verze 2.10 - změna URL v důsledku přechodu na Basic autentizaci
|
|
26
|
+
27.06.2012 verze 2.17 - přidána WS Re-signISDSDocument
|
|
27
|
+
18.09.2015 verze 2.21 - sjednocení verzí
|
|
28
|
+
14.10.2015 verze 2.22 - sjednocení verzí
|
|
29
|
+
31.01.2017 verze 2.26 - sjednocení verzí
|
|
30
|
+
21.11.2017 verze 2.27 - sjednocení verzí
|
|
31
|
+
02.09.2018 verze 2.30 - sjednocení verzí
|
|
32
|
+
04.09.2018 verze 2.31 - sjednocení verzí
|
|
33
|
+
27.07.2021 verze 2.33 - sjednocení verzí
|
|
34
|
+
25.04.2022 verze 2.35 - sjednocení verzí
|
|
35
|
+
|
|
36
|
+
31.10.2022 verze 3.03 - sjednocení verzí
|
|
37
|
+
20.10.2023 verze 3.04 - sjednocení verzí
|
|
38
|
+
|
|
39
|
+
************************************************************************ -->
|
|
40
|
+
|
|
41
|
+
<definitions name="ISDS_dmOperations" targetNamespace="http://isds.czechpoint.cz/v20"
|
|
42
|
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
|
43
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
44
|
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
|
45
|
+
xmlns:tns="http://isds.czechpoint.cz/v20">
|
|
46
|
+
|
|
47
|
+
<types>
|
|
48
|
+
<xs:schema targetNamespace="http://isds.czechpoint.cz/v20">
|
|
49
|
+
<xs:include schemaLocation="dmBaseTypes.xsd" />
|
|
50
|
+
</xs:schema>
|
|
51
|
+
</types>
|
|
52
|
+
|
|
53
|
+
<!-- ******************************************************************* -->
|
|
54
|
+
<message name="MessageCreateRequest">
|
|
55
|
+
<part name="parameter" element="tns:CreateMessage" />
|
|
56
|
+
</message>
|
|
57
|
+
<message name="MessageCreateResponse">
|
|
58
|
+
<part name="parameter" element="tns:CreateMessageResponse" />
|
|
59
|
+
</message>
|
|
60
|
+
|
|
61
|
+
<message name="MessageDownloadRequest">
|
|
62
|
+
<part name="parameter" element="tns:MessageDownload" />
|
|
63
|
+
</message>
|
|
64
|
+
<message name="MessageDownloadResponse">
|
|
65
|
+
<part name="parameter" element="tns:MessageDownloadResponse" />
|
|
66
|
+
</message>
|
|
67
|
+
|
|
68
|
+
<message name="SignedMessageDownloadRequest">
|
|
69
|
+
<part name="parameter" element="tns:SignedMessageDownload" />
|
|
70
|
+
</message>
|
|
71
|
+
<message name="SignedMessageDownloadResponse">
|
|
72
|
+
<part name="parameter" element="tns:SignedMessageDownloadResponse" />
|
|
73
|
+
</message>
|
|
74
|
+
|
|
75
|
+
<message name="SignedSentMessageDownloadRequest">
|
|
76
|
+
<part name="parameter" element="tns:SignedSentMessageDownload" />
|
|
77
|
+
</message>
|
|
78
|
+
<message name="SignedSentMessageDownloadResponse">
|
|
79
|
+
<part name="parameter" element="tns:SignedSentMessageDownloadResponse" />
|
|
80
|
+
</message>
|
|
81
|
+
|
|
82
|
+
<message name="DummyOperationRequest">
|
|
83
|
+
<part name="parameter" element="tns:DummyOperation" />
|
|
84
|
+
</message>
|
|
85
|
+
|
|
86
|
+
<message name="MultipleMessageCreateRequest">
|
|
87
|
+
<part name="parameter" element="tns:CreateMultipleMessage" />
|
|
88
|
+
</message>
|
|
89
|
+
<message name="MultipleMessageCreateResponse">
|
|
90
|
+
<part name="parameter" element="tns:CreateMultipleMessageResponse" />
|
|
91
|
+
</message>
|
|
92
|
+
|
|
93
|
+
<message name="AuthenticateMessageRequest">
|
|
94
|
+
<part name="parameter" element="tns:AuthenticateMessage" />
|
|
95
|
+
</message>
|
|
96
|
+
<message name="AuthenticateMessageResponse">
|
|
97
|
+
<part name="parameter" element="tns:AuthenticateMessageResponse" />
|
|
98
|
+
</message>
|
|
99
|
+
|
|
100
|
+
<message name="Re-signISDSDocumentRequest">
|
|
101
|
+
<part name="parameter" element="tns:Re-signISDSDocument" />
|
|
102
|
+
</message>
|
|
103
|
+
<message name="Re-signISDSDocumentResponse">
|
|
104
|
+
<part name="parameter" element="tns:Re-signISDSDocumentResponse" />
|
|
105
|
+
</message>
|
|
106
|
+
|
|
107
|
+
<!-- ******************************************************************* -->
|
|
108
|
+
<portType name="dmOperationsPortType">
|
|
109
|
+
|
|
110
|
+
<operation name="CreateMessage">
|
|
111
|
+
<input message="tns:MessageCreateRequest"/>
|
|
112
|
+
<output message="tns:MessageCreateResponse"/>
|
|
113
|
+
</operation>
|
|
114
|
+
|
|
115
|
+
<operation name="MessageDownload">
|
|
116
|
+
<input message="tns:MessageDownloadRequest"/>
|
|
117
|
+
<output message="tns:MessageDownloadResponse"/>
|
|
118
|
+
</operation>
|
|
119
|
+
|
|
120
|
+
<operation name="SignedMessageDownload">
|
|
121
|
+
<input message="tns:SignedMessageDownloadRequest"/>
|
|
122
|
+
<output message="tns:SignedMessageDownloadResponse"/>
|
|
123
|
+
</operation>
|
|
124
|
+
|
|
125
|
+
<operation name="SignedSentMessageDownload">
|
|
126
|
+
<input message="tns:SignedSentMessageDownloadRequest"/>
|
|
127
|
+
<output message="tns:SignedSentMessageDownloadResponse"/>
|
|
128
|
+
</operation>
|
|
129
|
+
|
|
130
|
+
<operation name="DummyOperation">
|
|
131
|
+
<input message="tns:DummyOperationRequest"/>
|
|
132
|
+
</operation>
|
|
133
|
+
|
|
134
|
+
<operation name="CreateMultipleMessage">
|
|
135
|
+
<input message="tns:MultipleMessageCreateRequest"/>
|
|
136
|
+
<output message="tns:MultipleMessageCreateResponse"/>
|
|
137
|
+
</operation>
|
|
138
|
+
|
|
139
|
+
<operation name="AuthenticateMessage">
|
|
140
|
+
<input message="tns:AuthenticateMessageRequest"/>
|
|
141
|
+
<output message="tns:AuthenticateMessageResponse"/>
|
|
142
|
+
</operation>
|
|
143
|
+
|
|
144
|
+
<operation name="Re-signISDSDocument">
|
|
145
|
+
<input message="tns:Re-signISDSDocumentRequest"/>
|
|
146
|
+
<output message="tns:Re-signISDSDocumentResponse"/>
|
|
147
|
+
</operation>
|
|
148
|
+
|
|
149
|
+
</portType>
|
|
150
|
+
|
|
151
|
+
<!-- ******************************************************************* -->
|
|
152
|
+
<binding name="dmOperationsBinding" type="tns:dmOperationsPortType">
|
|
153
|
+
|
|
154
|
+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
|
155
|
+
<operation name="CreateMessage">
|
|
156
|
+
<soap:operation soapAction="" />
|
|
157
|
+
<input>
|
|
158
|
+
<soap:body use="literal" />
|
|
159
|
+
</input>
|
|
160
|
+
<output >
|
|
161
|
+
<soap:body use="literal" />
|
|
162
|
+
</output>
|
|
163
|
+
</operation>
|
|
164
|
+
|
|
165
|
+
<operation name="MessageDownload">
|
|
166
|
+
<soap:operation soapAction="" />
|
|
167
|
+
<input>
|
|
168
|
+
<soap:body use="literal" />
|
|
169
|
+
</input>
|
|
170
|
+
<output>
|
|
171
|
+
<soap:body use="literal" />
|
|
172
|
+
</output>
|
|
173
|
+
</operation>
|
|
174
|
+
|
|
175
|
+
<operation name="SignedMessageDownload">
|
|
176
|
+
<soap:operation soapAction="" />
|
|
177
|
+
<input>
|
|
178
|
+
<soap:body use="literal" />
|
|
179
|
+
</input>
|
|
180
|
+
<output>
|
|
181
|
+
<soap:body use="literal" />
|
|
182
|
+
</output>
|
|
183
|
+
</operation>
|
|
184
|
+
|
|
185
|
+
<operation name="SignedSentMessageDownload">
|
|
186
|
+
<soap:operation soapAction="" />
|
|
187
|
+
<input>
|
|
188
|
+
<soap:body use="literal" />
|
|
189
|
+
</input>
|
|
190
|
+
<output>
|
|
191
|
+
<soap:body use="literal" />
|
|
192
|
+
</output>
|
|
193
|
+
</operation>
|
|
194
|
+
|
|
195
|
+
<operation name="DummyOperation">
|
|
196
|
+
<soap:operation soapAction="" />
|
|
197
|
+
<input>
|
|
198
|
+
<soap:body use="literal" />
|
|
199
|
+
</input>
|
|
200
|
+
</operation>
|
|
201
|
+
|
|
202
|
+
<operation name="CreateMultipleMessage">
|
|
203
|
+
<soap:operation soapAction="" />
|
|
204
|
+
<input>
|
|
205
|
+
<soap:body use="literal" />
|
|
206
|
+
</input>
|
|
207
|
+
<output >
|
|
208
|
+
<soap:body use="literal" />
|
|
209
|
+
</output>
|
|
210
|
+
</operation>
|
|
211
|
+
|
|
212
|
+
<operation name="AuthenticateMessage">
|
|
213
|
+
<soap:operation soapAction="" />
|
|
214
|
+
<input>
|
|
215
|
+
<soap:body use="literal" />
|
|
216
|
+
</input>
|
|
217
|
+
<output >
|
|
218
|
+
<soap:body use="literal" />
|
|
219
|
+
</output>
|
|
220
|
+
</operation>
|
|
221
|
+
|
|
222
|
+
<operation name="Re-signISDSDocument">
|
|
223
|
+
<soap:operation soapAction="" />
|
|
224
|
+
<input>
|
|
225
|
+
<soap:body use="literal" />
|
|
226
|
+
</input>
|
|
227
|
+
<output >
|
|
228
|
+
<soap:body use="literal" />
|
|
229
|
+
</output>
|
|
230
|
+
</operation>
|
|
231
|
+
|
|
232
|
+
</binding>
|
|
233
|
+
|
|
234
|
+
<!-- ******************************************************************* -->
|
|
235
|
+
<service name="dmOperationsWebService">
|
|
236
|
+
<port name="dmOperationsPortType" binding="tns:dmOperationsBinding">
|
|
237
|
+
<soap:address location="https://ws1.mojedatovaschranka.cz/DS/dz"/>
|
|
238
|
+
</port>
|
|
239
|
+
</service>
|
|
240
|
+
|
|
241
|
+
</definitions>
|
|
242
|
+
|
package/src/index.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import forge from 'node-forge';
|
|
2
|
+
|
|
3
|
+
import ISDSSentOutFiles from './ISDSSentOutFiles.js';
|
|
4
|
+
import ISDSSoapClient from './ISDSSoapClient.js';
|
|
5
|
+
import DataMessage from '../models/DataMessage.js';
|
|
6
|
+
import { getServiceWSDL, getServiceURL } from './config.js';
|
|
7
|
+
|
|
8
|
+
import { DEBUG } from './config.js';
|
|
9
|
+
|
|
10
|
+
class ISDSBox {
|
|
11
|
+
constructor(
|
|
12
|
+
loginType,
|
|
13
|
+
loginname,
|
|
14
|
+
password,
|
|
15
|
+
certfilename,
|
|
16
|
+
privateKey,
|
|
17
|
+
publicKey,
|
|
18
|
+
passPhrase,
|
|
19
|
+
pkcs12Certificate,
|
|
20
|
+
production = true,
|
|
21
|
+
debug = DEBUG,
|
|
22
|
+
) {
|
|
23
|
+
this.productionMode = production;
|
|
24
|
+
this.loginType = loginType;
|
|
25
|
+
this.loginName = loginname;
|
|
26
|
+
this.password = password;
|
|
27
|
+
this.certfilename = certfilename;
|
|
28
|
+
this.privateKey = privateKey;
|
|
29
|
+
this.publicKey = publicKey;
|
|
30
|
+
this.passPhrase = passPhrase;
|
|
31
|
+
this.pkcs12Certificate = pkcs12Certificate;
|
|
32
|
+
this.debug = debug;
|
|
33
|
+
|
|
34
|
+
this.initClients();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setProductionMode() {
|
|
38
|
+
this.productionMode = true;
|
|
39
|
+
this.initClients();
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setTestMode() {
|
|
44
|
+
this.productionMode = false;
|
|
45
|
+
this.initClients();
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setDebugMode() {
|
|
50
|
+
this.debug = true;
|
|
51
|
+
this.initClients();
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setPublicKey(cert) {
|
|
56
|
+
this.publicKey = cert;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setPrivateKey(pkey) {
|
|
61
|
+
this.privateKey = pkey;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setPassPhrase(passPhrase) {
|
|
66
|
+
this.passPhrase = passPhrase;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setPkcs12Certificate(pkcs12Certificate, passPhrase) {
|
|
71
|
+
const p12Der = forge.util.decode64(pkcs12Certificate);
|
|
72
|
+
const p12Asn1 = forge.asn1.fromDer(p12Der);
|
|
73
|
+
const p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, passPhrase);
|
|
74
|
+
|
|
75
|
+
let cert;
|
|
76
|
+
let key;
|
|
77
|
+
|
|
78
|
+
// Extract the key and certificate
|
|
79
|
+
for (const safeContents of p12.safeContents) {
|
|
80
|
+
for (const safeBag of safeContents.safeBags) {
|
|
81
|
+
if (safeBag.type === forge.pki.oids.certBag) {
|
|
82
|
+
cert = forge.pki.certificateToPem(safeBag.cert);
|
|
83
|
+
} else if (safeBag.type === forge.pki.oids.pkcs8ShroudedKeyBag) {
|
|
84
|
+
key = forge.pki.privateKeyToPem(safeBag.key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!cert || !key) {
|
|
90
|
+
throw new Error('Invalid PKCS12');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this.setPublicKey(cert).setPrivateKey(key).setPassPhrase(passPhrase);
|
|
94
|
+
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
loginWithUsernameAndPassword(loginName, password, productionMode = true) {
|
|
99
|
+
this.productionMode = productionMode;
|
|
100
|
+
this.loginType = 0;
|
|
101
|
+
this.loginName = loginName;
|
|
102
|
+
this.password = password;
|
|
103
|
+
this.initClients();
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
loginWithPkcs12Certificate(certFile, passPhrase, productionMode = true) {
|
|
108
|
+
this.productionMode = productionMode;
|
|
109
|
+
this.loginType = 1;
|
|
110
|
+
this.setPkcs12Certificate(certFile, passPhrase);
|
|
111
|
+
this.initClients();
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
initClients() {
|
|
116
|
+
if (this.debug === true) {
|
|
117
|
+
console.log('Service URLs:');
|
|
118
|
+
console.log(
|
|
119
|
+
'Operations Service URL:',
|
|
120
|
+
getServiceURL(0, this.loginType, this.productionMode),
|
|
121
|
+
);
|
|
122
|
+
console.log(
|
|
123
|
+
'Info Service URL:',
|
|
124
|
+
getServiceURL(1, this.loginType, this.productionMode),
|
|
125
|
+
);
|
|
126
|
+
console.log(
|
|
127
|
+
'Manipulations Service URL:',
|
|
128
|
+
getServiceURL(2, this.loginType, this.productionMode),
|
|
129
|
+
);
|
|
130
|
+
console.log(
|
|
131
|
+
'Access Service URL:',
|
|
132
|
+
getServiceURL(3, this.loginType, this.productionMode),
|
|
133
|
+
);
|
|
134
|
+
console.log(
|
|
135
|
+
'Search Service URL:',
|
|
136
|
+
getServiceURL(4, this.loginType, this.productionMode),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.operationsWS = new ISDSSoapClient(getServiceWSDL(0), {
|
|
141
|
+
login: this.loginName,
|
|
142
|
+
password: this.password,
|
|
143
|
+
location: getServiceURL(0, this.loginType, this.productionMode),
|
|
144
|
+
loginType: this.loginType,
|
|
145
|
+
privateKey: this.privateKey,
|
|
146
|
+
publicKey: this.publicKey,
|
|
147
|
+
passPhrase: this.passPhrase,
|
|
148
|
+
debug: this.debug,
|
|
149
|
+
});
|
|
150
|
+
this.infoWS = new ISDSSoapClient(getServiceWSDL(1), {
|
|
151
|
+
login: this.loginName,
|
|
152
|
+
password: this.password,
|
|
153
|
+
location: getServiceURL(1, this.loginType, this.productionMode),
|
|
154
|
+
loginType: this.loginType,
|
|
155
|
+
privateKey: this.privateKey,
|
|
156
|
+
publicKey: this.publicKey,
|
|
157
|
+
passPhrase: this.passPhrase,
|
|
158
|
+
debug: this.debug,
|
|
159
|
+
});
|
|
160
|
+
this.manipulationsWS = new ISDSSoapClient(getServiceWSDL(2), {
|
|
161
|
+
login: this.loginName,
|
|
162
|
+
password: this.password,
|
|
163
|
+
location: getServiceURL(2, this.loginType, this.productionMode),
|
|
164
|
+
loginType: this.loginType,
|
|
165
|
+
privateKey: this.privateKey,
|
|
166
|
+
publicKey: this.publicKey,
|
|
167
|
+
passPhrase: this.passPhrase,
|
|
168
|
+
debug: this.debug,
|
|
169
|
+
});
|
|
170
|
+
this.accessWS = new ISDSSoapClient(getServiceWSDL(3), {
|
|
171
|
+
login: this.loginName,
|
|
172
|
+
password: this.password,
|
|
173
|
+
location: getServiceURL(3, this.loginType, this.productionMode),
|
|
174
|
+
loginType: this.loginType,
|
|
175
|
+
privateKey: this.privateKey,
|
|
176
|
+
publicKey: this.publicKey,
|
|
177
|
+
passPhrase: this.passPhrase,
|
|
178
|
+
debug: this.debug,
|
|
179
|
+
});
|
|
180
|
+
this.searchWS = new ISDSSoapClient(getServiceWSDL(4), {
|
|
181
|
+
login: this.loginName,
|
|
182
|
+
password: this.password,
|
|
183
|
+
location: getServiceURL(4, this.loginType, this.productionMode),
|
|
184
|
+
loginType: this.loginType,
|
|
185
|
+
privateKey: this.privateKey,
|
|
186
|
+
publicKey: this.publicKey,
|
|
187
|
+
passPhrase: this.passPhrase,
|
|
188
|
+
debug: this.debug,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async createMessage(dataMessageParams, outFilesParams) {
|
|
193
|
+
console.log('Call CreateMessage');
|
|
194
|
+
|
|
195
|
+
// Validate the dataMessageParams
|
|
196
|
+
const requiredFields = ['dbIDRecipient', 'dmAnnotation'];
|
|
197
|
+
for (const field of requiredFields) {
|
|
198
|
+
if (!dataMessageParams[field]) {
|
|
199
|
+
throw new Error(`Missing required field: ${field}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Create the DataMessage envelope
|
|
204
|
+
const envelope = new DataMessage(dataMessageParams);
|
|
205
|
+
|
|
206
|
+
// Initialize the files array and add the files
|
|
207
|
+
const files = new ISDSSentOutFiles();
|
|
208
|
+
for (const file of outFilesParams) {
|
|
209
|
+
if (file.dmFilePath) {
|
|
210
|
+
const success = await files.addFileFromFilePath(
|
|
211
|
+
file.dmFilePath,
|
|
212
|
+
file.dmMimeType,
|
|
213
|
+
file.dmFileMetaType,
|
|
214
|
+
file.dmFileDescr,
|
|
215
|
+
);
|
|
216
|
+
if (!success) {
|
|
217
|
+
throw new Error(`Failed to add file from path: ${file.dmFilePath}`);
|
|
218
|
+
}
|
|
219
|
+
} else if (file.dmEncodedContent) {
|
|
220
|
+
await files.addFileFromMemory(
|
|
221
|
+
file.dmEncodedContent,
|
|
222
|
+
file.dmMimeType,
|
|
223
|
+
file.dmFileMetaType,
|
|
224
|
+
file.dmFileDescr,
|
|
225
|
+
);
|
|
226
|
+
} else {
|
|
227
|
+
throw new Error('File must have either path or base64Content');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Prepare the message creation input
|
|
232
|
+
const input = {
|
|
233
|
+
dmEnvelope: envelope.build(),
|
|
234
|
+
dmFiles: files.build(), // Ensure dmFiles is correctly structured as an array
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
if (this.debug === true) {
|
|
238
|
+
console.log('Final SOAP Request Body:', JSON.stringify(input, null, 2));
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
const result = await this.operationsWS.request('CreateMessage', input);
|
|
242
|
+
if (this.debug === true) {
|
|
243
|
+
console.log('Raw Result:', result);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return result;
|
|
247
|
+
} catch (error) {
|
|
248
|
+
console.error('Error in createMessage:', error.message);
|
|
249
|
+
throw new Error(error);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Finds a data box based on the provided input.
|
|
255
|
+
* @param {DataBox} dataBox - The DataBox instance with the search criteria.
|
|
256
|
+
* @returns {Promise<Object>} The search results.
|
|
257
|
+
* @throws {Error} If there is an error in the SOAP request.
|
|
258
|
+
*/
|
|
259
|
+
async findDataBox(dbOwnerInfo) {
|
|
260
|
+
console.log('Call FindDataBox');
|
|
261
|
+
const findInput = dbOwnerInfo.build();
|
|
262
|
+
try {
|
|
263
|
+
const result = await this.searchWS.request('FindDataBox', findInput);
|
|
264
|
+
if (this.debug === true) {
|
|
265
|
+
console.log('Raw Result:', result);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return result;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
console.error('Error in findDataBox:', error.message);
|
|
271
|
+
throw new Error(error);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async getOwnerInfoFromLogin() {
|
|
276
|
+
console.log('Call GetOwnerInfoFromLogin');
|
|
277
|
+
const input = { dbDummy: '' };
|
|
278
|
+
try {
|
|
279
|
+
const result = await this.accessWS.request(
|
|
280
|
+
'GetOwnerInfoFromLogin',
|
|
281
|
+
input,
|
|
282
|
+
);
|
|
283
|
+
if (this.debug === true) {
|
|
284
|
+
console.log('Raw Result:', result);
|
|
285
|
+
}
|
|
286
|
+
return result;
|
|
287
|
+
} catch (error) {
|
|
288
|
+
console.error('Error in getOwnerInfoFromLogin:', error.message);
|
|
289
|
+
throw new Error(error);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async getPasswordInfo() {
|
|
293
|
+
console.log('Call GetPasswordInfo');
|
|
294
|
+
const input = { dbDummy: '' };
|
|
295
|
+
try {
|
|
296
|
+
const result = await this.accessWS.request('GetPasswordInfo', input);
|
|
297
|
+
if (this.debug === true) {
|
|
298
|
+
console.log('Raw Result:', result);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return result;
|
|
302
|
+
} catch (error) {
|
|
303
|
+
console.error('Error in getPasswordInfo:', error.message);
|
|
304
|
+
throw new Error(error);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export default ISDSBox;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import DataMessageFile from '../models/DataMessageFile.js';
|
|
3
|
+
import DataMessageFiles from '../models/DataMessageFiles.js';
|
|
4
|
+
|
|
5
|
+
class ISDSSentOutFiles {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.dataMessageFiles = new DataMessageFiles();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
addFile(
|
|
11
|
+
encodedContent,
|
|
12
|
+
mimeType,
|
|
13
|
+
fileMetaType,
|
|
14
|
+
fileDescr,
|
|
15
|
+
fileGuid = null,
|
|
16
|
+
upFileGuid = null,
|
|
17
|
+
format = null,
|
|
18
|
+
) {
|
|
19
|
+
const file = new DataMessageFile();
|
|
20
|
+
file.setDmEncodedContent(encodedContent);
|
|
21
|
+
file.setDmMimeType(mimeType);
|
|
22
|
+
file.setDmFileMetaType(fileMetaType);
|
|
23
|
+
file.setDmFileDescr(fileDescr);
|
|
24
|
+
file.setDmFileGuid(fileGuid);
|
|
25
|
+
file.setDmUpFileGuid(upFileGuid);
|
|
26
|
+
file.setDmFormat(format);
|
|
27
|
+
|
|
28
|
+
this.dataMessageFiles.addFile(file);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async addFileFromMemory(
|
|
32
|
+
encodedContent,
|
|
33
|
+
mimeType,
|
|
34
|
+
fileMetaType,
|
|
35
|
+
fileDescr,
|
|
36
|
+
fileGuid = null,
|
|
37
|
+
upFileGuid = null,
|
|
38
|
+
format = null,
|
|
39
|
+
) {
|
|
40
|
+
this.addFile(
|
|
41
|
+
encodedContent,
|
|
42
|
+
mimeType,
|
|
43
|
+
fileMetaType,
|
|
44
|
+
fileDescr,
|
|
45
|
+
fileGuid,
|
|
46
|
+
upFileGuid,
|
|
47
|
+
format,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async addFileFromFilePath(
|
|
52
|
+
filePath,
|
|
53
|
+
mimeType,
|
|
54
|
+
fileMetaType,
|
|
55
|
+
fileDescr,
|
|
56
|
+
fileGuid = null,
|
|
57
|
+
upFileGuid = null,
|
|
58
|
+
format = null,
|
|
59
|
+
) {
|
|
60
|
+
if (!fs.existsSync(filePath)) {
|
|
61
|
+
console.error('File not found:', filePath);
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const fileContent = await fs.promises.readFile(filePath, {
|
|
65
|
+
encoding: 'base64',
|
|
66
|
+
});
|
|
67
|
+
this.addFile(
|
|
68
|
+
fileContent,
|
|
69
|
+
mimeType,
|
|
70
|
+
fileMetaType,
|
|
71
|
+
fileDescr,
|
|
72
|
+
fileGuid,
|
|
73
|
+
upFileGuid,
|
|
74
|
+
format,
|
|
75
|
+
);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
build() {
|
|
80
|
+
return this.dataMessageFiles.build();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default ISDSSentOutFiles;
|