Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Hristov authored and Vladislav Hristov committed May 17, 2018
1 parent cd37de3 commit 1f947ff
Show file tree
Hide file tree
Showing 27 changed files with 1,502 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# @see editorconfig.org

root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
indent_size = 2

[*.js]
indent_size = 4

[*.tag]
indent_size = 2

[*.yml]
indent_size = 2

# Trailing whitespace is significant in markdown files.
[*.md]
trim_trailing_whitespace = false
max_line_length = 80

[Makefile]
indent_style = tab
indent_size = 4
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SERVER_PORT=3003

LOG_LEVEL=info
LOG_ENABLED=true
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
build/
static/
config/
src/vue-router-custom-components
src/directives/clickAway
34 changes: 34 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"extends": "airbnb",
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "script",
"ecmaFeatures": {
"modules": false
}
},
"rules": {
"max-len": 0,
"linebreak-style": 0,
"no-plusplus": [
2,
{
"allowForLoopAfterthoughts": true
}
],
"no-continue": 0,
"indent": [2, "tab"],
"no-tabs": 0,
"strict": [2, "safe"],
"curly": [2, "multi", "consistent"],
"import/no-extraneous-dependencies": 0,
"import/no-unresolved": 0,
"no-underscore-dangle": 0,
"no-param-reassign": 0,
"generator-star-spacing": 0,
"jsx-a11y/href-no-hash": "off"
}
}
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
npm-debug.log
node_modules
.DS_Store
*.local.json5
yarn.lock
/project.sublime-workspace
/public/css/style.css.map
/.idea
/.vscode
*.pid
/coverage
package-lock.json
*.key
*.html
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# node-ebics-client v0.0.3
---

Pure node.js ( >=8 ) implementation of the [EBICS](https://en.wikipedia.org/wiki/Electronic_Banking_Internet_Communication_Standard) (Electronic Banking Internet Communication).

The client is aimed to be 100% ISO 20022 complient, and supports complete initilizations process ( INI, HIA, HPB orders ) and HTML letter generation.

## Supported Banks
The client is tested and verified to work with the following banks:
* Credit Suisse
* Zürcher Kantonalbank
* Raiffeisenbank


## Inspiration

A lot of the concepts in this library are inspired from the [EPICS](https://github.com/railslove/epics) library.

## Copyright
Copyright (c) 2017 eCollect.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

const Client = require('./lib/Client');
module.exports = Client;
66 changes: 66 additions & 0 deletions lib/BankLetter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict';

const fs = require('fs');

const moment = require('moment');
const handlebars = require('handlebars');
const BN = require("bn.js");

module.exports = class BankLetter {
constructor(client, bankName) {
this.client = client;
this.bankName = bankName;
this.pathToTemplate = './app/ebics/ini.hbs';
};

_registerHelpers() {
handlebars.registerHelper("today", () => {
return moment().format('DD.MM.YYYY');
});

handlebars.registerHelper("now", () => {
return moment().format('HH:mm:ss');
});

handlebars.registerHelper("keyExponentBits", (k) => {
return Buffer.byteLength(new BN(k.key.keyPair.e).toBuffer()) * 8;
});

handlebars.registerHelper("keyModulusBits", (k) => {
return k.key.getKeySize();
// return Buffer.byteLength(new BN(k.key.keyPair.e).toBuffer()) * 8;
});

handlebars.registerHelper("keyExponent", (k) => {
return k.e();
});

handlebars.registerHelper("keyModulus", (k) => {
return k.n().toUpperCase().match(/.{1,2}/g).join(' ');
});

handlebars.registerHelper("sha256", (k) => {
const digest = Buffer(k.publicDigest(), 'base64').toString('HEX');

return digest.toUpperCase().match(/.{1,2}/g).join(' ');
});
};

generate() {
this._registerHelpers();

const str = fs.readFileSync(this.pathToTemplate).toString();
const templ = handlebars.compile(str);

const data = {
bankName : this.bankName,
userId : this.client.userId,
partnerId: this.client.partnerId,
A006 : this.client.a(),
X002 : this.client.x(),
E002 : this.client.e(),
};

return templ(data);
}
}

0 comments on commit 1f947ff

Please sign in to comment.