mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2024-12-22 20:31:49 +00:00
Merge branch 'master' into herrie/additionalConfigItems
This commit is contained in:
commit
9ef50081ca
@ -28,6 +28,8 @@ The client is currently tested and verified to work with the following banks:
|
||||
* [Raiffeisen Schweiz](https://www.raiffeisen.ch/rch/de.html)
|
||||
* [BW Bank](https://www.bw-bank.de/de/home.html)
|
||||
* [Bank GPB International S.A.](https://gazprombank.lu/e-banking)
|
||||
* [Bank GPB AO](https://gazprombank.ru/)
|
||||
* [J.P. Morgan](https://www.jpmorgan.com/)
|
||||
|
||||
|
||||
## Inspiration
|
||||
|
@ -20,11 +20,22 @@ const getDefaultEnv = () => {
|
||||
return parArg || process.env.NODE_ENV;
|
||||
}
|
||||
|
||||
const loadConfig = (configDirectory = path.join(__dirname, './config'), env = getDefaultEnv()) => {
|
||||
console.log(`Loading config form ${configDirectory} with env set to ${env}.`);
|
||||
const getBankIdentifier = () => {
|
||||
const [,,,parArg] = process.argv;
|
||||
return parArg || "testbank";
|
||||
}
|
||||
|
||||
const getEntityIdentifier = () => {
|
||||
const [,,,,parArg] = process.argv;
|
||||
return parArg || ""
|
||||
}
|
||||
|
||||
const loadConfig = (configDirectory = path.join(__dirname, './config'), env = getDefaultEnv(), bank = getBankIdentifier(), entity = getEntityIdentifier()) => {
|
||||
entity ? console.log(`Loading config from ${configDirectory} with env set to ${env}, bank set to ${bank} and entity set to ${entity}.`) : console.log(`Loading config from ${configDirectory} with env set to ${env} and bank set to ${bank}.`);
|
||||
|
||||
global.entity = entity;
|
||||
const baseConfigFile = path.join(configDirectory, 'config.json');
|
||||
const envConfigFile = env ? path.join(configDirectory, `config.${env}.json`) : null;
|
||||
const envConfigFile = env ? entity ? path.join(configDirectory, `config.${env}.${bank}.${entity}.json`) : path.join(configDirectory, `config.${env}.${bank}.json`) : null;
|
||||
|
||||
return {
|
||||
...safeLoadJson(baseConfigFile),
|
||||
|
28
examples/send-c52-order-zipped.js
Normal file
28
examples/send-c52-order-zipped.js
Normal file
@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const client = require('./getClient')();
|
||||
const { Orders } = require('../index');
|
||||
|
||||
// The bank keys must have been already saved
|
||||
client.send(Orders.C52(null, null)) // startDate 'YYYY-MM-DD', endDate 'YYYY-MM-DD'
|
||||
.then((resp) => {
|
||||
console.log('Response for C52 order %j', resp);
|
||||
if (resp.technicalCode !== '000000')
|
||||
throw new Error('Something went wrong');
|
||||
|
||||
// Parsing and processing the CAMT052 file should happen somewhere here, ideally after saving it to disk
|
||||
const data = Buffer.from(resp.orderData);
|
||||
let distPath = "CAMT052.zip";
|
||||
const dstZip = fs.createWriteStream(distPath);
|
||||
dstZip.write(data);
|
||||
dstZip.end();
|
||||
})
|
||||
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
28
examples/send-c53-order-zipped.js
Normal file
28
examples/send-c53-order-zipped.js
Normal file
@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const client = require('./getClient')();
|
||||
const { Orders } = require('../index');
|
||||
|
||||
// The bank keys must have been already saved
|
||||
client.send(Orders.C53(null, null)) // startDate 'YYYY-MM-DD', endDate 'YYYY-MM-DD'
|
||||
.then((resp) => {
|
||||
console.log('Response for C53 order %j', resp);
|
||||
if (resp.technicalCode !== '000000')
|
||||
throw new Error('Something went wrong');
|
||||
|
||||
// Parsing and processing the CAMT053 file should happen somewhere here, ideally after saving it to disk
|
||||
const data = Buffer.from(resp.orderData);
|
||||
let distPath = "CAMT053.zip";
|
||||
const dstZip = fs.createWriteStream(distPath);
|
||||
dstZip.write(data);
|
||||
dstZip.end();
|
||||
})
|
||||
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
28
examples/send-g02-order-zipped.js
Normal file
28
examples/send-g02-order-zipped.js
Normal file
@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const client = require('./getClient')();
|
||||
const { Orders } = require('../index');
|
||||
|
||||
// The bank keys must have been already saved
|
||||
client.send(Orders.G02(null, null)) // startDate 'YYYY-MM-DD', endDate 'YYYY-MM-DD'
|
||||
.then((resp) => {
|
||||
console.log('Response for G02 order %j', resp);
|
||||
if (resp.technicalCode !== '000000')
|
||||
throw new Error('Something went wrong');
|
||||
|
||||
// Parsing and processing the G02 Pain.002.001.06 file should happen somewhere here, ideally after saving it to disk
|
||||
const data = Buffer.from(resp.orderData);
|
||||
let distPath = "G02.zip";
|
||||
const dstZip = fs.createWriteStream(distPath);
|
||||
dstZip.write(data);
|
||||
dstZip.end();
|
||||
})
|
||||
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
20
examples/send-g1r-order.js
Normal file
20
examples/send-g1r-order.js
Normal file
@ -0,0 +1,20 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const client = require('./getClient')();
|
||||
const { Orders } = require('../index');
|
||||
|
||||
// The bank keys must have been already saved
|
||||
const paymentFile = fs.readFileSync('RUB_PAYMENT.xml').toString();
|
||||
|
||||
client.send(Orders.G1R(paymentFile))
|
||||
.then((resp) => {
|
||||
console.log('Response for G1R order %j', resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
20
examples/send-g1v-order.js
Normal file
20
examples/send-g1v-order.js
Normal file
@ -0,0 +1,20 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const client = require('./getClient')();
|
||||
const { Orders } = require('../index');
|
||||
|
||||
// The bank keys must have been already saved
|
||||
const paymentFile = fs.readFileSync('FCY_PAYMENT.xml').toString();
|
||||
|
||||
client.send(Orders.G1V(paymentFile))
|
||||
.then((resp) => {
|
||||
console.log('Response for G1V order %j', resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
28
examples/send-g52-order-zipped.js
Normal file
28
examples/send-g52-order-zipped.js
Normal file
@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const client = require('./getClient')();
|
||||
const { Orders } = require('../index');
|
||||
|
||||
// The bank keys must have been already saved
|
||||
client.send(Orders.G52(null, null)) // startDate 'YYYY-MM-DD', endDate 'YYYY-MM-DD'
|
||||
.then((resp) => {
|
||||
console.log('Response for G52 order %j', resp);
|
||||
if (resp.technicalCode !== '000000')
|
||||
throw new Error('Something went wrong');
|
||||
|
||||
// Parsing and processing the CAMT052 file should happen somewhere here, ideally after saving it to disk
|
||||
const data = Buffer.from(resp.orderData);
|
||||
let distPath = "CAMT052-G52.zip";
|
||||
const dstZip = fs.createWriteStream(distPath);
|
||||
dstZip.write(data);
|
||||
dstZip.end();
|
||||
})
|
||||
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
28
examples/send-g53-order-zipped.js
Normal file
28
examples/send-g53-order-zipped.js
Normal file
@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const client = require('./getClient')();
|
||||
const { Orders } = require('../index');
|
||||
|
||||
// The bank keys must have been already saved
|
||||
client.send(Orders.G53(null, null)) // startDate 'YYYY-MM-DD', endDate 'YYYY-MM-DD'
|
||||
.then((resp) => {
|
||||
console.log('Response for G53 order %j', resp);
|
||||
if (resp.technicalCode !== '000000')
|
||||
throw new Error('Something went wrong');
|
||||
|
||||
// Parsing and processing the CAMT053 file should happen somewhere here, ideally after saving it to disk
|
||||
const data = Buffer.from(resp.orderData);
|
||||
let distPath = "CAMT053-G53.zip";
|
||||
const dstZip = fs.createWriteStream(distPath);
|
||||
dstZip.write(data);
|
||||
dstZip.end();
|
||||
})
|
||||
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
@ -67,12 +67,16 @@ module.exports = class Crypto {
|
||||
}
|
||||
|
||||
static sign(key, msg, salt = crypto.randomBytes(32)) {
|
||||
// console.log(key.d());
|
||||
const base = new BigNumber(emsaPSS(msg, salt));
|
||||
const power = new BigNumber(key.d());
|
||||
const mod = new BigNumber(key.n());
|
||||
const buffer = modPow(base, power, mod).toBEBuffer();
|
||||
|
||||
return (modPow(base, power, mod)).toBEBuffer().toString('base64');
|
||||
if (buffer.byteLength !== 257 || buffer[0] === 0x00)
|
||||
return buffer.slice(1).toString('base64');
|
||||
|
||||
// console.log('hex string of key starts with "00" and is 514 bytes long, fixing it to be 512 bytes long by stripping leading "00"');
|
||||
return buffer.toString('base64');
|
||||
}
|
||||
|
||||
static pad(d) {
|
||||
|
13
lib/predefinedOrders/G02.js
Normal file
13
lib/predefinedOrders/G02.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const utils = require('../utils');
|
||||
|
||||
module.exports = (start = null, end = null) => ({
|
||||
version: 'h004',
|
||||
orderDetails: {
|
||||
OrderType: 'G02',
|
||||
OrderAttribute: 'DZHNN',
|
||||
StandardOrderParams: utils.dateRange(start, end),
|
||||
},
|
||||
operation: 'download',
|
||||
});
|
8
lib/predefinedOrders/G1R.js
Normal file
8
lib/predefinedOrders/G1R.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = document => ({
|
||||
version: 'h004',
|
||||
orderDetails: { OrderType: 'G1R', OrderAttribute: 'DZHNN', StandardOrderParams: {} },
|
||||
operation: 'upload',
|
||||
document,
|
||||
});
|
8
lib/predefinedOrders/G1V.js
Normal file
8
lib/predefinedOrders/G1V.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = document => ({
|
||||
version: 'h004',
|
||||
orderDetails: { OrderType: 'G1V', OrderAttribute: 'DZHNN', StandardOrderParams: {} },
|
||||
operation: 'upload',
|
||||
document,
|
||||
});
|
13
lib/predefinedOrders/G52.js
Normal file
13
lib/predefinedOrders/G52.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const utils = require('../utils');
|
||||
|
||||
module.exports = (start = null, end = null) => ({
|
||||
version: 'h004',
|
||||
orderDetails: {
|
||||
OrderType: 'G52',
|
||||
OrderAttribute: 'DZHNN',
|
||||
StandardOrderParams: utils.dateRange(start, end),
|
||||
},
|
||||
operation: 'download',
|
||||
});
|
13
lib/predefinedOrders/G53.js
Normal file
13
lib/predefinedOrders/G53.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const utils = require('../utils');
|
||||
|
||||
module.exports = (start = null, end = null) => ({
|
||||
version: 'h004',
|
||||
orderDetails: {
|
||||
OrderType: 'G53',
|
||||
OrderAttribute: 'DZHNN',
|
||||
StandardOrderParams: utils.dateRange(start, end),
|
||||
},
|
||||
operation: 'download',
|
||||
});
|
@ -14,6 +14,8 @@ const CCS = require('./CCS');
|
||||
const XE3 = require('./XE3');
|
||||
const XCT = require('./XCT');
|
||||
const XG1 = require('./XG1');
|
||||
const G1V = require('./G1V');
|
||||
const G1R = require('./G1R');
|
||||
|
||||
const STA = require('./STA');
|
||||
const VMK = require('./VMK');
|
||||
@ -27,6 +29,9 @@ const Z53 = require('./Z53');
|
||||
const DKI = require('./DKI');
|
||||
const C52 = require('./C52');
|
||||
const C53 = require('./C53');
|
||||
const G52 = require('./G52');
|
||||
const G53 = require('./G53');
|
||||
const G02 = require('./G02');
|
||||
|
||||
module.exports = {
|
||||
INI,
|
||||
@ -44,6 +49,8 @@ module.exports = {
|
||||
XE3,
|
||||
XCT,
|
||||
XG1,
|
||||
G1V,
|
||||
G1R,
|
||||
|
||||
STA,
|
||||
VMK,
|
||||
@ -56,4 +63,7 @@ module.exports = {
|
||||
DKI,
|
||||
C52,
|
||||
C53,
|
||||
G52,
|
||||
G53,
|
||||
G02,
|
||||
};
|
||||
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ebics-client",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -4367,9 +4367,9 @@
|
||||
"integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ=="
|
||||
},
|
||||
"xmldom": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.3.0.tgz",
|
||||
"integrity": "sha512-z9s6k3wxE+aZHgXYxSTpGDo7BYOUfJsIRyoZiX6HTjwpwfS2wpQBQKa2fD+ShLyPkqDYo5ud7KitmLZ2Cd6r0g=="
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz",
|
||||
"integrity": "sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA=="
|
||||
},
|
||||
"xpath": {
|
||||
"version": "0.0.27",
|
||||
|
@ -51,6 +51,10 @@
|
||||
{
|
||||
"name": "chrwoizi",
|
||||
"url": "https://github.com/chrwoizi"
|
||||
},
|
||||
{
|
||||
"name": "Herrie",
|
||||
"url": "https://github.com/Herrie82"
|
||||
}
|
||||
],
|
||||
"license": "GPL-3.0-only",
|
||||
@ -61,7 +65,7 @@
|
||||
"request": "^2.88.2",
|
||||
"uuid": "^8.0.0",
|
||||
"xml-crypto": "^2.0.0",
|
||||
"xmldom": "^0.3.0",
|
||||
"xmldom": "^0.5.0",
|
||||
"xpath": "0.0.27"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user