mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2025-08-15 12:15:36 +00:00
Compare commits
5 Commits
v0.1.0
...
feat/drop-
Author | SHA1 | Date | |
---|---|---|---|
|
df9c330411 | ||
|
2a17ff6056 | ||
|
33ac6ac60f | ||
|
e9f7c11bbb | ||
|
9aabe933e9 |
10
README.md
10
README.md
@@ -1,6 +1,13 @@
|
|||||||
# node-ebics-client
|
# node-ebics-client
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://travis-ci.org/eCollect/node-ebics-client" title="Build Status"><img src="https://travis-ci.org/eCollect/node-ebics-client.svg?branch=master" alt="Build Status" /></a>
|
<a href="https://travis-ci.org/eCollect/node-ebics-client" title="Build Status"><img src="https://travis-ci.org/eCollect/node-ebics-client.svg?branch=master" alt="Build Status" /></a>
|
||||||
|
<a href="https://www.npmjs.com/package/ebics-client" title="Build Status">
|
||||||
|
<img alt="ebics-client" src="https://img.shields.io/npm/v/ebics-client">
|
||||||
|
</a>
|
||||||
|
<a href="https://snyk.io/test/github/ecollect/node-ebics-client" title="Known Vulnerabilities">
|
||||||
|
<img src="https://snyk.io/test/github/ecollect/node-ebics-client/badge.svg" alt="Known Vulnerabilities">
|
||||||
|
</a>
|
||||||
|
<a href="/eCollect/node-ebics-client/blob/master/LICENSE" title="GPL-3.0"><img alt="GPL-3.0" src="https://img.shields.io/github/license/eCollect/node-ebics-client"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Pure node.js ( >=8 ) implementation of [EBICS](https://en.wikipedia.org/wiki/Electronic_Banking_Internet_Communication_Standard) ( Electronic Banking Internet Communication ).
|
Pure node.js ( >=8 ) implementation of [EBICS](https://en.wikipedia.org/wiki/Electronic_Banking_Internet_Communication_Standard) ( Electronic Banking Internet Communication ).
|
||||||
@@ -14,6 +21,7 @@ The client is currently tested and verified to work with the following banks:
|
|||||||
* [Credit Suisse (Schweiz) AG](https://www.credit-suisse.com/ch/en.html)
|
* [Credit Suisse (Schweiz) AG](https://www.credit-suisse.com/ch/en.html)
|
||||||
* [Zürcher Kantonalbank](https://www.zkb.ch/en/lg/ew.html)
|
* [Zürcher Kantonalbank](https://www.zkb.ch/en/lg/ew.html)
|
||||||
* [Raiffeisen Schweiz](https://www.raiffeisen.ch/rch/de.html)
|
* [Raiffeisen Schweiz](https://www.raiffeisen.ch/rch/de.html)
|
||||||
|
* [BW Bank](https://www.bw-bank.de/de/home.html)
|
||||||
|
|
||||||
|
|
||||||
## Inspiration
|
## Inspiration
|
||||||
@@ -24,3 +32,5 @@ The basic concept of this library was inspired by the [EPICS](https://github.com
|
|||||||
## Copyright
|
## Copyright
|
||||||
|
|
||||||
Copyright: eCollect AG, 2018-9.
|
Copyright: eCollect AG, 2018-9.
|
||||||
|
Licensed under the [GPLv3](LICENSE) license.
|
||||||
|
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const moment = require('moment');
|
|
||||||
const handlebars = require('handlebars');
|
const handlebars = require('handlebars');
|
||||||
const Crypto = require('./crypto/Crypto');
|
const Crypto = require('./crypto/Crypto');
|
||||||
|
const { date } = require('./utils.js');
|
||||||
// const BN = require('bn.js');
|
// const BN = require('bn.js');
|
||||||
|
|
||||||
const registerHelpers = () => {
|
const registerHelpers = () => {
|
||||||
handlebars.registerHelper('today', () => moment().format('DD.MM.YYYY'));
|
handlebars.registerHelper('today', () => date.toISODate(Date.now(), false));
|
||||||
|
|
||||||
handlebars.registerHelper('now', () => moment().format('HH:mm:ss'));
|
handlebars.registerHelper('now', () => date.toISOTime(Date.now(), false));
|
||||||
|
|
||||||
handlebars.registerHelper('keyExponentBits', k => Buffer.byteLength(k.e()) * 8);
|
handlebars.registerHelper('keyExponentBits', k => Buffer.byteLength(k.e()) * 8);
|
||||||
|
|
||||||
|
34
lib/utils.js
34
lib/utils.js
@@ -1,18 +1,46 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const prefixNumber = (n) => {
|
||||||
|
if (n < 10)
|
||||||
|
return `0${n}`;
|
||||||
|
return n.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
const date = {
|
||||||
|
getDateObject(d = Date.now()) {
|
||||||
|
const dateObject = new Date(d);
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
|
if (isNaN(dateObject))
|
||||||
|
throw new Error(`${d} is invalid date.`);
|
||||||
|
return dateObject;
|
||||||
|
},
|
||||||
|
toISODate(d = Date.now(), utc = true) {
|
||||||
|
const t = date.getDateObject(d);
|
||||||
|
if (utc)
|
||||||
|
return `${t.getUTCFullYear()}-${prefixNumber(t.getUTCMonth() + 1)}-${prefixNumber(t.getUTCDate())}`;
|
||||||
|
return `${t.getFullYear()}-${prefixNumber(t.getMonth() + 1)}-${prefixNumber(t.getDate())}`;
|
||||||
|
},
|
||||||
|
toISOTime(d = Date.now(), utc = true) {
|
||||||
|
const t = date.getDateObject(d);
|
||||||
|
if (utc)
|
||||||
|
return `${prefixNumber(t.getUTCHours())}:${prefixNumber(t.getUTCMinutes())}:${prefixNumber(t.getUTCSeconds())}`;
|
||||||
|
return `${prefixNumber(t.getHours())}:${prefixNumber(t.getMinutes())}:${prefixNumber(t.getSeconds())}`;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const dateRange = (start, end) => {
|
const dateRange = (start, end) => {
|
||||||
if (start && end)
|
if (start && end)
|
||||||
return {
|
return {
|
||||||
DateRange: {
|
DateRange: {
|
||||||
Start: start,
|
Start: date.toISODate(start),
|
||||||
End: end,
|
End: date.toISODate(end),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
dateRange,
|
dateRange,
|
||||||
|
date,
|
||||||
};
|
};
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ebics-client",
|
"name": "ebics-client",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "Node.js ISO 20022 Compliant EBICS Client",
|
"description": "Node.js ISO 20022 Compliant EBICS Client",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -28,12 +28,11 @@
|
|||||||
"url": "https://github.com/yagop"
|
"url": "https://github.com/yagop"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "GPLv3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bn.js": "^5.0.0",
|
"bn.js": "^5.0.0",
|
||||||
"handlebars": "^4.4.3",
|
"handlebars": "^4.4.3",
|
||||||
"js2xmlparser": "^4.0.0",
|
"js2xmlparser": "^4.0.0",
|
||||||
"moment": "^2.24.0",
|
|
||||||
"node-forge": "^0.9.1",
|
"node-forge": "^0.9.1",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"uuid": "^3.3.3",
|
"uuid": "^3.3.3",
|
||||||
|
29
test/unit/utils.js
Normal file
29
test/unit/utils.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
/* eslint-env node, mocha */
|
||||||
|
|
||||||
|
const { assert } = require('chai');
|
||||||
|
|
||||||
|
const utils = require('../../lib/utils');
|
||||||
|
|
||||||
|
describe('utils', () => {
|
||||||
|
describe('dateRange', () => {
|
||||||
|
describe('dateRange', () => {
|
||||||
|
it('should generate empty object with partial parameters', () => {
|
||||||
|
assert.isEmpty(utils.dateRange());
|
||||||
|
});
|
||||||
|
it('should throw with invalid date', () => {
|
||||||
|
assert.throws(() => utils.dateRange('2018-15-15', '2018-20-20'));
|
||||||
|
});
|
||||||
|
it('should work for valid string input', () => {
|
||||||
|
assert.containsAllDeepKeys(utils.dateRange('2018-01-15', '2018-01-20'), { DateRange: { Start: '2018-01-15', End: '2018-01-20' } });
|
||||||
|
});
|
||||||
|
it('should work for Date string input', () => {
|
||||||
|
assert.containsAllDeepKeys(utils.dateRange(new Date('2018-01-15'), new Date('2018-01-20')), { DateRange: { Start: '2018-01-15', End: '2018-01-20' } });
|
||||||
|
});
|
||||||
|
it('should work for timestamp string input', () => {
|
||||||
|
assert.containsAllDeepKeys(utils.dateRange(new Date('2018-01-15').getTime(), new Date('2018-01-20').getTime()), { DateRange: { Start: '2018-01-15', End: '2018-01-20' } });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user