Skip to content

Commit e251cc0

Browse files
authored
Merge pull request #88 from node-ebics/update-deps
Update deps
2 parents f3bd654 + 8da1045 commit e251cc0

File tree

8 files changed

+205
-152
lines changed

8 files changed

+205
-152
lines changed

CHANGELOG.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
### Changelog
22

3+
#### [v4.0.0](https://github.com/node-ebics/node-ebics-client/compare/v3.0.0...v0.4.0)
4+
5+
- Add CI [`#75`](https://github.com/node-ebics/node-ebics-client/pull/75)
6+
7+
- feat: update dependencies [`a03ec22`](https://github.com/node-ebics/node-ebics-client/commit/a03ec2283fdd3dcf750c5ed448f0195d92c5c9f0)
8+
- chore: Update dev dependency libxmljs [`3a8dc1d`](https://github.com/node-ebics/node-ebics-client/commit/3a8dc1da0bac20a6f25a687da0a783f3b52d5163)
9+
- feat: replace <request> with <rock-req> [`b6b2751`](https://github.com/node-ebics/node-ebics-client/commit/b6b27516d5854b38dcdbe56f23967001f844e631)
10+
11+
### [v3.0.0](https://github.com/node-ebics/node-ebics-client/compare/v0.2.1...v3.0.0)
12+
13+
> 4 August 2022
14+
15+
- Update LICENSE [`7520a56`](https://github.com/node-ebics/node-ebics-client/commit/7520a56be8ba446d3466c6dc9202b1d65ea3396f)
16+
- changelog [`fe0f585`](https://github.com/node-ebics/node-ebics-client/commit/fe0f585b277c390415841a343aa86d4533997057)
17+
- chore: update license in package.json, bump version [`b46b214`](https://github.com/node-ebics/node-ebics-client/commit/b46b214e57cf1b4e30455da306b26b3a06dc8a5f)
18+
319
#### [v0.2.1](https://github.com/node-ebics/node-ebics-client/compare/v0.2.0...v0.2.1)
420

521
> 30 March 2021
@@ -84,38 +100,43 @@
84100

85101
#### [v0.1.1](https://github.com/node-ebics/node-ebics-client/compare/v0.1.0...v0.1.1)
86102

87-
> 5 November 2019
103+
> 7 November 2019
88104
89105
- chore: update license [`9aabe93`](https://github.com/node-ebics/node-ebics-client/commit/9aabe933e91b506ea38820b952ce8e5e58b4c2ff)
90106

91-
#### [v0.1.0](https://github.com/node-ebics/node-ebics-client/compare/v0.0.8...v0.1.0)
107+
#### [v0.1.0](https://github.com/node-ebics/node-ebics-client/compare/v0.0.36...v0.1.0)
92108

93109
> 5 November 2019
94110
95111
- Feat: handle unsual exponent migrate to node-forge [`#16`](https://github.com/node-ebics/node-ebics-client/pull/16)
96112
- Add order generation tests and fix linting [`#15`](https://github.com/node-ebics/node-ebics-client/pull/15)
97113
- test script run mocha [`#14`](https://github.com/node-ebics/node-ebics-client/pull/14)
114+
- chore: readme maintenance [`#11`](https://github.com/node-ebics/node-ebics-client/pull/11)
115+
- Provide examples [`#10`](https://github.com/node-ebics/node-ebics-client/pull/10)
116+
- * Add Z53 order type [`#7`](https://github.com/node-ebics/node-ebics-client/pull/7)
117+
- remove eCollect from constant and minor verbose error handeling [`#2`](https://github.com/node-ebics/node-ebics-client/pull/2)
118+
- add iso pain format XCT order type [`#1`](https://github.com/node-ebics/node-ebics-client/pull/1)
119+
- remove eCollect from constant and minor verbose error handaling [`#4`](https://github.com/node-ebics/node-ebics-client/pull/4)
120+
- add iso pain format XCT order type [`#5`](https://github.com/node-ebics/node-ebics-client/pull/5)
121+
- Fix parsing of the bank keys in the HPB response [`#3`](https://github.com/node-ebics/node-ebics-client/pull/3)
98122

99123
- feat: prepare order generation tests [`e40f79c`](https://github.com/node-ebics/node-ebics-client/commit/e40f79cee68a194272c93f07e763175b213a77a1)
100-
- chore: cleanup [`0c01420`](https://github.com/node-ebics/node-ebics-client/commit/0c01420c1e14992a4169098ccd47cd196b899f06)
124+
- Major changes. Separating responsibilities. Orders builder, serializer. [`ff9a3a1`](https://github.com/node-ebics/node-ebics-client/commit/ff9a3a16b47d0a25674134c875bfd651995837e4)
125+
- code optimization [`1876360`](https://github.com/node-ebics/node-ebics-client/commit/187636019c290d757aca77d4c14fb4f2519acd38)
101126

102127
#### [v0.0.36](https://github.com/node-ebics/node-ebics-client/compare/v0.0.35...v0.0.36)
103128

104-
> 1 June 2018
129+
> 7 November 2019
105130
106131
- various modular fixes [`8492d94`](https://github.com/node-ebics/node-ebics-client/commit/8492d940542f61b17aa3a2da7de23f6539ffaad5)
107132

108-
#### [v0.0.35](https://github.com/node-ebics/node-ebics-client/compare/v0.0.3...v0.0.35)
109-
110-
> 31 May 2018
133+
#### [v0.0.35](https://github.com/node-ebics/node-ebics-client/compare/v0.0.8...v0.0.35)
111134

112-
- update License to GPL v3 [`babcf76`](https://github.com/node-ebics/node-ebics-client/commit/babcf76b61af6eb737ab291a301e71bb84621820)
113-
- Add MGF1.js file - mask generation utility class [`7e6e2ff`](https://github.com/node-ebics/node-ebics-client/commit/7e6e2ff142688b0c453369fa7137b49e8b89cd81)
114-
- Add sign, _emsaPSS and _modPowe methods in Key.js file [`5ace213`](https://github.com/node-ebics/node-ebics-client/commit/5ace2137231af9a3563ab31fa0f70fbdf4b148cb)
135+
> 7 November 2019
115136
116137
#### [v0.0.8](https://github.com/node-ebics/node-ebics-client/compare/v0.0.7...v0.0.8)
117138

118-
> 8 October 2019
139+
> 7 November 2019
119140
120141
- chore: readme maintenance [`#11`](https://github.com/node-ebics/node-ebics-client/pull/11)
121142
- Provide examples [`#10`](https://github.com/node-ebics/node-ebics-client/pull/10)
@@ -126,7 +147,7 @@
126147

127148
#### [v0.0.7](https://github.com/node-ebics/node-ebics-client/compare/v0.0.6...v0.0.7)
128149

129-
> 2 August 2019
150+
> 7 November 2019
130151
131152
- * Add Z53 order type [`#7`](https://github.com/node-ebics/node-ebics-client/pull/7)
132153
- remove eCollect from constant and minor verbose error handeling [`#2`](https://github.com/node-ebics/node-ebics-client/pull/2)
@@ -138,7 +159,7 @@
138159

139160
#### [v0.0.6](https://github.com/node-ebics/node-ebics-client/compare/v0.0.5...v0.0.6)
140161

141-
> 24 July 2019
162+
> 7 November 2019
142163
143164
- remove eCollect from constant and minor verbose error handaling [`#4`](https://github.com/node-ebics/node-ebics-client/pull/4)
144165
- add iso pain format XCT order type [`#5`](https://github.com/node-ebics/node-ebics-client/pull/5)
@@ -148,24 +169,24 @@
148169

149170
#### [v0.0.5](https://github.com/node-ebics/node-ebics-client/compare/v0.0.4...v0.0.5)
150171

151-
> 28 June 2019
172+
> 7 November 2019
152173
153174
- Fix parsing of the bank keys in the HPB response [`#3`](https://github.com/node-ebics/node-ebics-client/pull/3)
154175

155176
- tc for bank keys parsing error [`c571ef1`](https://github.com/node-ebics/node-ebics-client/commit/c571ef181bca2e0cbec70bc6df53c706acd6c829)
156177
- #2 corrected bank keys parsing [`5f0b6cd`](https://github.com/node-ebics/node-ebics-client/commit/5f0b6cd3747c4613920d2f71f3c04ce13225d397)
157178

158-
#### [v0.0.4](https://github.com/node-ebics/node-ebics-client/compare/v0.0.36...v0.0.4)
179+
#### [v0.0.4](https://github.com/node-ebics/node-ebics-client/compare/v0.0.3...v0.0.4)
159180

160181
> 3 September 2018
161182
162183
- Major changes. Separating responsibilities. Orders builder, serializer. [`ff9a3a1`](https://github.com/node-ebics/node-ebics-client/commit/ff9a3a16b47d0a25674134c875bfd651995837e4)
163184
- code optimization [`1876360`](https://github.com/node-ebics/node-ebics-client/commit/187636019c290d757aca77d4c14fb4f2519acd38)
164-
- client and order optimization [`9454992`](https://github.com/node-ebics/node-ebics-client/commit/945499290a8698aed504b573019de2c23148006a)
185+
- various modular fixes [`8492d94`](https://github.com/node-ebics/node-ebics-client/commit/8492d940542f61b17aa3a2da7de23f6539ffaad5)
165186

166187
#### v0.0.3
167188

168-
> 17 May 2018
189+
> 7 November 2019
169190
170191
- initial commit [`1f947ff`](https://github.com/node-ebics/node-ebics-client/commit/1f947ff1480c522f89fa1f547581b55e2378d920)
171192
- Initial commit [`cd37de3`](https://github.com/node-ebics/node-ebics-client/commit/cd37de3895e32a61798c79ce3a6447e2f269019d)

lib/Client.js

Lines changed: 69 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const $request = require('request');
3+
const rock = require('rock-req');
44

55
const constants = require('./consts');
66
const Keys = require('./keymanagers/Keys');
@@ -52,7 +52,6 @@ const stringifyKeys = (keys) => {
5252
* @property {string} storageLocation - Location where to store the files that are downloaded. This can be a network share for example.
5353
*/
5454

55-
5655
module.exports = class Client {
5756
/**
5857
*Creates an instance of Client.
@@ -71,18 +70,17 @@ module.exports = class Client {
7170
languageCode,
7271
storageLocation,
7372
}) {
74-
if (!url)
75-
throw new Error('EBICS URL is required');
76-
if (!partnerId)
77-
throw new Error('partnerId is required');
78-
if (!userId)
79-
throw new Error('userId is required');
80-
if (!hostId)
81-
throw new Error('hostId is required');
82-
if (!passphrase)
83-
throw new Error('passphrase is required');
84-
85-
if (!keyStorage || typeof keyStorage.read !== 'function' || typeof keyStorage.write !== 'function')
73+
if (!url) throw new Error('EBICS URL is required');
74+
if (!partnerId) throw new Error('partnerId is required');
75+
if (!userId) throw new Error('userId is required');
76+
if (!hostId) throw new Error('hostId is required');
77+
if (!passphrase) throw new Error('passphrase is required');
78+
79+
if (
80+
!keyStorage
81+
|| typeof keyStorage.read !== 'function'
82+
|| typeof keyStorage.write !== 'function'
83+
)
8684
throw new Error('keyStorage implementation missing or wrong');
8785

8886
this.url = url;
@@ -99,17 +97,25 @@ module.exports = class Client {
9997
}
10098

10199
async send(order) {
102-
const isInObject = ('operation' in order);
100+
const isInObject = 'operation' in order;
103101

104102
if (!isInObject) throw new Error('Operation for the order needed');
105103

106-
if (order.operation.toUpperCase() === constants.orderOperations.ini) return this.initialization(order);
104+
if (order.operation.toUpperCase() === constants.orderOperations.ini)
105+
return this.initialization(order);
107106

108107
const keys = await this.keys();
109-
if (keys === null) throw new Error('No keys provided. Can not send the order or any other order for that matter.');
110-
111-
if (order.operation.toUpperCase() === constants.orderOperations.upload) return this.upload(order);
112-
if (order.operation.toUpperCase() === constants.orderOperations.download) return this.download(order);
108+
if (keys === null)
109+
throw new Error(
110+
'No keys provided. Can not send the order or any other order for that matter.',
111+
);
112+
113+
if (order.operation.toUpperCase() === constants.orderOperations.upload)
114+
return this.upload(order);
115+
if (
116+
order.operation.toUpperCase() === constants.orderOperations.download
117+
)
118+
return this.download(order);
113119

114120
throw new Error('Wrong order operation provided');
115121
}
@@ -118,8 +124,7 @@ module.exports = class Client {
118124
const keys = await this.keys();
119125
if (keys === null) await this._generateKeys();
120126

121-
if (this.tracesStorage)
122-
this.tracesStorage.new().ofType('ORDER.INI');
127+
if (this.tracesStorage) this.tracesStorage.new().ofType('ORDER.INI');
123128
const res = await this.ebicsRequest(order);
124129
const xml = res.orderData();
125130

@@ -132,7 +137,9 @@ module.exports = class Client {
132137

133138
technicalCode: returnedTechnicalCode,
134139
technicalCodeSymbol: res.technicalSymbol(),
135-
technicalCodeShortText: res.technicalShortText(returnedTechnicalCode),
140+
technicalCodeShortText: res.technicalShortText(
141+
returnedTechnicalCode,
142+
),
136143
technicalCodeMeaning: res.technicalMeaning(returnedTechnicalCode),
137144

138145
businessCode: returnedBusinessCode,
@@ -167,7 +174,9 @@ module.exports = class Client {
167174

168175
technicalCode: returnedTechnicalCode,
169176
technicalCodeSymbol: res.technicalSymbol(),
170-
technicalCodeShortText: res.technicalShortText(returnedTechnicalCode),
177+
technicalCodeShortText: res.technicalShortText(
178+
returnedTechnicalCode,
179+
),
171180
technicalCodeMeaning: res.technicalMeaning(returnedTechnicalCode),
172181

173182
businessCode: returnedBusinessCode,
@@ -178,8 +187,7 @@ module.exports = class Client {
178187
}
179188

180189
async upload(order) {
181-
if (this.tracesStorage)
182-
this.tracesStorage.new().ofType('ORDER.UPLOAD');
190+
if (this.tracesStorage) this.tracesStorage.new().ofType('ORDER.UPLOAD');
183191
let res = await this.ebicsRequest(order);
184192
const transactionId = res.transactionId();
185193
const orderId = res.orderId();
@@ -197,32 +205,46 @@ module.exports = class Client {
197205
return new Promise(async (resolve, reject) => {
198206
const { version } = order;
199207
const keys = await this.keys();
200-
const r = signer.version(version).sign((await serializer.use(order, this)).toXML(), keys.x());
208+
const r = signer
209+
.version(version)
210+
.sign((await serializer.use(order, this)).toXML(), keys.x());
201211

202212
if (this.tracesStorage)
203-
this.tracesStorage.label(`REQUEST.${order.orderDetails.OrderType}`).data(r).persist();
204-
205-
$request.post({
206-
url: this.url,
207-
body: r,
208-
headers: { 'content-type': 'text/xml;charset=UTF-8' },
209-
}, (err, res, data) => {
210-
if (err) reject(err);
211-
212-
const ebicsResponse = response.version(version)(data, keys);
213-
214-
if (this.tracesStorage)
215-
this.tracesStorage.label(`RESPONSE.${order.orderDetails.OrderType}`).connect().data(ebicsResponse.toXML()).persist();
216-
217-
resolve(ebicsResponse);
218-
});
213+
this.tracesStorage
214+
.label(`REQUEST.${order.orderDetails.OrderType}`)
215+
.data(r)
216+
.persist();
217+
218+
rock.post(
219+
this.url,
220+
{
221+
body: r,
222+
headers: { 'content-type': 'text/xml;charset=UTF-8' },
223+
},
224+
(err, res, data) => {
225+
if (err) reject(err);
226+
227+
const ebicsResponse = response.version(version)(data, keys);
228+
229+
if (this.tracesStorage)
230+
this.tracesStorage
231+
.label(`RESPONSE.${order.orderDetails.OrderType}`)
232+
.connect()
233+
.data(ebicsResponse.toXML())
234+
.persist();
235+
236+
resolve(ebicsResponse);
237+
},
238+
);
219239
});
220240
}
221241

222242
async signOrder(order) {
223243
const { version } = order;
224244
const keys = await this.keys();
225-
return signer.version(version).sign((await serializer.use(order, this)).toXML(), keys.x());
245+
return signer
246+
.version(version)
247+
.sign((await serializer.use(order, this)).toXML(), keys.x());
226248
}
227249

228250
async keys() {
@@ -253,6 +275,8 @@ module.exports = class Client {
253275
}
254276

255277
_writeKeys(keysObject) {
256-
return this.keyStorage.write(this.keyEncryptor.encrypt(stringifyKeys(keysObject.keys)));
278+
return this.keyStorage.write(
279+
this.keyEncryptor.encrypt(stringifyKeys(keysObject.keys)),
280+
);
257281
}
258282
};

lib/middleware/signer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
"use strict";
1+
'use strict';
22

3-
const H004Signer = require("../orders/H004/signer");
3+
const H004Signer = require('../orders/H004/signer');
44

55
module.exports = {
66
version(v) {
7-
if (v.toUpperCase() === "H004") return H004Signer;
7+
if (v.toUpperCase() === 'H004') return H004Signer;
88

9-
throw Error("Error from middleware/signer.js: Invalid version number");
9+
throw Error('Error from middleware/signer.js: Invalid version number');
1010
},
1111
};

0 commit comments

Comments
 (0)