From 7dad7c878722be94e03808cef3af38d34019c623 Mon Sep 17 00:00:00 2001 From: Yago Perez Date: Wed, 2 Oct 2019 23:17:00 +0200 Subject: [PATCH 1/6] initialize.js --- examples/initialize.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 examples/initialize.js diff --git a/examples/initialize.js b/examples/initialize.js new file mode 100755 index 0000000..7087392 --- /dev/null +++ b/examples/initialize.js @@ -0,0 +1,32 @@ +#! /usr/bin/env node + +'use strict'; + +const ebics = require('../index'); + +const client = new ebics.Client({ + url: 'https://ebics.server', + partnerId: 'PARTNER', + userId: 'USER', + hostId: 'HOST', + passphrase: 'test', // keys-test will be encrypted with this keys + keyStorage: ebics.fsKeysStorage('./keys-test'), +}); + +// New keys will be generated and saved in ./keys-test +client.send(ebics.Orders.INI) + .then((resp) => { + console.log('Respose for INI order %j', resp); + return client.send(ebics.Orders.HIA); + }) + .then((resp) => { + console.log('Reponse for HIA order %j', resp); + if (resp.technicalCode !== '000000') + throw new Error('Something might went wrong'); + + console.log('Public keys should be sent to bank now. See examples/bankLetter.js'); + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); From ce6e58b3f33017967e5b26fe15a2c435012b8af6 Mon Sep 17 00:00:00 2001 From: Yago Perez Date: Wed, 2 Oct 2019 23:20:38 +0200 Subject: [PATCH 2/6] examples/bankLetter.js --- examples/bankLetter.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 examples/bankLetter.js diff --git a/examples/bankLetter.js b/examples/bankLetter.js new file mode 100755 index 0000000..b329bf2 --- /dev/null +++ b/examples/bankLetter.js @@ -0,0 +1,31 @@ +#! /usr/bin/env node + +'use strict'; + +const ebics = require('../index'); +const path = require('path'); +const fs = require('fs'); +const os = require('os'); + +const client = new ebics.Client({ + url: 'https://ebics.server', + partnerId: '', + userId: '', + hostId: '', + passphrase: 'test', // keys-test will be decrypted with this keys + keyStorage: ebics.fsKeysStorage('./keys-test'), +}); + +const bankName = 'Bank name'; +const template = fs.readFileSync('./templates/ini.hbs').toString(); +const letter = new ebics.BankLetter({ client, bankName, template }); +const bankLetterFile = path.join(os.homedir(), 'bankLetter.html'); + +letter.serialize(bankLetterFile) + .then(() => { + console.log('Send your bank the letter (%s)', bankLetterFile); + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); From 9e6c318372b7088860c272eb1822eff0253a37b3 Mon Sep 17 00:00:00 2001 From: Yago Perez Date: Wed, 2 Oct 2019 23:21:27 +0200 Subject: [PATCH 3/6] keys -> passphrase --- examples/bankLetter.js | 2 +- examples/initialize.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/bankLetter.js b/examples/bankLetter.js index b329bf2..543cee8 100755 --- a/examples/bankLetter.js +++ b/examples/bankLetter.js @@ -12,7 +12,7 @@ const client = new ebics.Client({ partnerId: '', userId: '', hostId: '', - passphrase: 'test', // keys-test will be decrypted with this keys + passphrase: 'test', // keys-test will be decrypted with this passphrase keyStorage: ebics.fsKeysStorage('./keys-test'), }); diff --git a/examples/initialize.js b/examples/initialize.js index 7087392..aade1eb 100755 --- a/examples/initialize.js +++ b/examples/initialize.js @@ -9,7 +9,7 @@ const client = new ebics.Client({ partnerId: 'PARTNER', userId: 'USER', hostId: 'HOST', - passphrase: 'test', // keys-test will be encrypted with this keys + passphrase: 'test', // keys-test will be encrypted with this passphrase keyStorage: ebics.fsKeysStorage('./keys-test'), }); From 5a63e19aab221de5320fbcabaccedb548974da0d Mon Sep 17 00:00:00 2001 From: Yago Perez Date: Wed, 2 Oct 2019 23:26:12 +0200 Subject: [PATCH 4/6] examples/save-bank-kesy.js --- examples/save-bank-kesy.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 examples/save-bank-kesy.js diff --git a/examples/save-bank-kesy.js b/examples/save-bank-kesy.js new file mode 100755 index 0000000..adffa8f --- /dev/null +++ b/examples/save-bank-kesy.js @@ -0,0 +1,30 @@ +#! /usr/bin/env node + +'use strict'; + +const ebics = require('../index'); + +const client = new ebics.Client({ + url: 'https://ebics.server', + partnerId: '', + userId: '', + hostId: '', + passphrase: 'test', // keys-test will be decrypted with this passphrase + keyStorage: ebics.fsKeysStorage('./keys-test'), +}); + +// Client keys must be already generated and send by letter. +// The bank should have enabled the user +client.send(ebics.Orders.HPB) + .then((resp) => { + console.log('Respose for HPB order %j', resp); + if (resp.technicalCode !== '000000') + throw new Error('Something went wrong'); + + console.log('Received bank keys: %j', resp.bankKeys); + return client.setBankKeys(resp.bankKeys); + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); From 166c61aec4a247d923de82278271ec02cbef815f Mon Sep 17 00:00:00 2001 From: Yago Perez Date: Wed, 2 Oct 2019 23:27:23 +0200 Subject: [PATCH 5/6] examples/send-hbt-order.js --- examples/send-hbt-order.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 examples/send-hbt-order.js diff --git a/examples/send-hbt-order.js b/examples/send-hbt-order.js new file mode 100755 index 0000000..ca5f86f --- /dev/null +++ b/examples/send-hbt-order.js @@ -0,0 +1,30 @@ +#! /usr/bin/env node + +'use strict'; + +const ebics = require('../index'); + +const client = new ebics.Client({ + url: 'https://ebics.server', + partnerId: '', + userId: '', + hostId: '', + passphrase: 'test', // keys-test will be decrypted with this passphrase + keyStorage: ebics.fsKeysStorage('./keys-test'), +}); + +// Client keys must be already generated and send by letter. +// The bank should have enabled the user +client.send(ebics.Orders.HTD) + .then((resp) => { + console.log('Respose for HTD order %j', resp); + if (resp.technicalCode !== '000000') + throw new Error('Something went wrong'); + + const data = Buffer.from(resp.orderData); + console.log(data.toString('utf8')); + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); From eb9fbf5834412fa44269f4205324558c14ddf80a Mon Sep 17 00:00:00 2001 From: Yago Perez Date: Thu, 3 Oct 2019 00:07:52 +0200 Subject: [PATCH 6/6] Change HBT order text --- examples/send-hbt-order.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/send-hbt-order.js b/examples/send-hbt-order.js index ca5f86f..02da48e 100755 --- a/examples/send-hbt-order.js +++ b/examples/send-hbt-order.js @@ -13,8 +13,7 @@ const client = new ebics.Client({ keyStorage: ebics.fsKeysStorage('./keys-test'), }); -// Client keys must be already generated and send by letter. -// The bank should have enabled the user +// The bank keys must have been already saved client.send(ebics.Orders.HTD) .then((resp) => { console.log('Respose for HTD order %j', resp);