From d192e61d29e5895953c5a47bd791ae218a2bfbee Mon Sep 17 00:00:00 2001 From: Herman van Hazendonk Date: Fri, 26 Mar 2021 14:50:20 +0100 Subject: [PATCH] Add additional bank configuration items For prettier generation of bank letters and other bits used in examples: Expand the bank config to include: * "bankFullName" used in the INI letter's which are sent to the bank. * "bankShortName" used in the filename for the generated letters and in other places if needed. * "languageCode" used for determining which template to use for the bank (currently "en" and "de" are supported). * "storageLocation" can be used to specify a local or network path where to store downloaded files. * In bankLetter.js: Use the current script folder as output for the bank's letter in HTML format instead of the user/os homedir folder. Signed-off-by: Herman van Hazendonk --- examples/bankLetter.js | 7 +- examples/config/config.json | 6 +- ...n.json => config.production.testbank.json} | 6 +- ...config.production.testbank.testentity.json | 12 ++ lib/Client.js | 14 +- templates/ini_fr.hbs | 164 ++++++++++++++++++ 6 files changed, 200 insertions(+), 9 deletions(-) rename examples/config/{config.production.json => config.production.testbank.json} (56%) create mode 100644 examples/config/config.production.testbank.testentity.json create mode 100644 templates/ini_fr.hbs diff --git a/examples/bankLetter.js b/examples/bankLetter.js index 8f7fee0..3963e35 100755 --- a/examples/bankLetter.js +++ b/examples/bankLetter.js @@ -9,10 +9,9 @@ const os = require('os'); const config = require('./loadConfig')(); const client = require('./getClient')(config); -const bankName = config.bankName; -const languageCode = config.languageCode; -const template = fs.readFileSync('../templates/ini_'+config.languageCode+'.hbs', { encoding: 'utf8 '}); -const bankLetterFile = path.join(os.homedir(), 'bankLetter_'+languageCode+'.html'); +const bankName = client.bankName; +const template = fs.readFileSync("../templates/ini_"+client.languageCode+".hbs", { encoding: 'utf8'}); +const bankLetterFile = path.join("./", "bankLetter_"+client.bankShortName+"_"+client.languageCode+".html"); const letter = new ebics.BankLetter({ client, bankName, template }); diff --git a/examples/config/config.json b/examples/config/config.json index 44e3369..a91252f 100644 --- a/examples/config/config.json +++ b/examples/config/config.json @@ -5,6 +5,8 @@ "hostId": "MyHostIdTest", "passphrase": "MyPasswordTest", "keyStoragePath": "./keys-test", - "bankName":"Test Bank", - "languageCode":"en" + "bankName":"Test Bank Full Name", + "bankShortName":"TESTBANKSHORT", + "languageCode":"en", + "storageLocation":"\\\\myserver\\Share\\Folder\\BankName\\Test\\" } diff --git a/examples/config/config.production.json b/examples/config/config.production.testbank.json similarity index 56% rename from examples/config/config.production.json rename to examples/config/config.production.testbank.json index 1bb31fa..b94996a 100644 --- a/examples/config/config.production.json +++ b/examples/config/config.production.testbank.json @@ -5,6 +5,8 @@ "hostId": "MyHostIdProduction", "passphrase": "MyPasswordProduction", "keyStoragePath": "./keys-prod", - "bankName":"Production Bank", - "languageCode":"en" + "bankName":"Production Bank Full Name", + "bankShortName":"PRODBANKSHORT", + "languageCode":"en", + "storageLocation":"\\\\myserver\\Share\\Folder\\BankName\\Production\\" } diff --git a/examples/config/config.production.testbank.testentity.json b/examples/config/config.production.testbank.testentity.json new file mode 100644 index 0000000..b94996a --- /dev/null +++ b/examples/config/config.production.testbank.testentity.json @@ -0,0 +1,12 @@ +{ + "url": "https://ebics.server", + "partnerId": "EBICS ParnerID Production", + "userId": "MyUserIdProduction", + "hostId": "MyHostIdProduction", + "passphrase": "MyPasswordProduction", + "keyStoragePath": "./keys-prod", + "bankName":"Production Bank Full Name", + "bankShortName":"PRODBANKSHORT", + "languageCode":"en", + "storageLocation":"\\\\myserver\\Share\\Folder\\BankName\\Production\\" +} diff --git a/lib/Client.js b/lib/Client.js index 3140b10..4a829f1 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -46,6 +46,10 @@ const stringifyKeys = (keys) => { * @property {string} passphrase - passphrase for keys encryption * @property {KeyStorage} keyStorage - keyStorage implementation * @property {object} [tracesStorage] - traces (logs) storage implementation + * @property {string} bankName - Full name of the bank to be used in the bank INI letters. + * @property {string} bankShortName - Short name of the bank to be used in folders, filenames etc. + * @property {string} languageCode - Language code to be used in the bank INI letters ("de", "en" and "fr" are currently supported). + * @property {string} storageLocation - Location where to store the files that are downloaded. This can be a network share for example. */ @@ -62,6 +66,10 @@ module.exports = class Client { passphrase, keyStorage, tracesStorage, + bankName, + bankShortName, + languageCode, + storageLocation, }) { if (!url) throw new Error('EBICS URL is required'); @@ -83,7 +91,11 @@ module.exports = class Client { this.hostId = hostId; this.keyStorage = keyStorage; this.keyEncryptor = defaultKeyEncryptor({ passphrase }); - this.tracesStorage = tracesStorage || null; + this.tracesStorage = tracesStorage || null; + this.bankName = bankName || "Dummy Bank Full Name", + this.bankShortName = bankShortName || "BANKSHORTCODE", + this.languageCode = languageCode || "en", + this.storageLocation = storageLocation || null, } async send(order) { diff --git a/templates/ini_fr.hbs b/templates/ini_fr.hbs new file mode 100644 index 0000000..5967b31 --- /dev/null +++ b/templates/ini_fr.hbs @@ -0,0 +1,164 @@ + + + + + + + EBICS ini + + + +
+

Lettre d'initialisation pour clés électroniques bancaires (INI)

+ + + + + + + + + + + + + + + + + + + + + +
Date{{ today }}
Heure{{ now }}
Banque{{ bankName }}
ID Utilisateur{{ userId }}
ID Partenaire{{ partnerId }}
+

Clé publique (Public Key) pour la signature électronique (A006)

+

Exposant ({{ keyExponentBits A006 }} Bit):

+

+ {{ keyExponent A006 }} +

+

Modulo ({{ keyModulusBits A006 }} Bit):

+

+ {{ keyModulus A006 }} +

+

Hash (SHA-256):

+

+ {{ sha256 A006 }} +

+

Je confirme par la présente la clé publique ci-dessus pour ma signature électronique.

+
+
+
+
+ + + + + + + + + + + +
___________________________________________________________________________
Lieu/DateNom/EntrepriseSignature
+
+
+

Lettre d'initialisation pour clés électroniques bancaires (HIA) - Page 1/2

+ + + + + + + + + + + + + + + + + + + + + +
Date{{ today }}
Heure{{ now }}
Banque{{ bankName }}
ID Utilisateur{{ userId }}
ID Partenaire{{ partnerId }}
+
+

Clé d'identification publique (X002)

+

Exposant ({{ keyExponentBits X002 }} Bit):

+

+ {{ keyExponent X002 }} +

+

Modulo ({{ keyModulusBits X002 }} Bit):

+

+ {{ keyModulus X002 }} +

+

Hash (SHA-256):

+

+ {{ sha256 X002 }} +

+

Suite à la page 2 ...

+
+

Lettre d'initialisation pour clés électroniques bancaires (HIA) - Page 2/2

+ + + + + + + + + + + + + + + + + + + + + +
Date{{ today }}
Heure{{ now }}
Banque{{ bankName }}
ID Utilisateur{{ userId }}
ID Partenaire{{ partnerId }}
+
+
+

Clé de chiffrement publique (E002)

+

Exposant ({{ keyExponentBits E002 }} Bit):

+

+ {{ keyExponent E002 }} +

+

Modulo ({{ keyModulusBits E002 }} Bit):

+

+ {{ keyModulus E002 }} +

+

Hash (SHA-256):

+

+ {{ sha256 E002 }} +

+

Je confirme par la présente les clés publiques ci-dessus.

+
+
+
+
+ + + + + + + + + + + +
___________________________________________________________________________
Lieu/DateNom/EntrepriseSignature
+
+ + +