Configurable Node.js module for TUPAS identification. Includes test configurations for Nordea, DanskeBank, Handelsbanken, OP, Aktia, Ålandsbanken, S-Pankki, Säästöpankki and POP Pankki.
Currently requires Express.
Made at Reaktor.
Apply for juicy positions at reaktor.fi/careers.
npm install tupas
Run tests with grunt.
var generalOptions = {
appHandler: app, // an Express application
hostUrl: 'http://domain.here.com:port[/path]', // required for return URLs, and binding to optional /path
};
var tupas = require('tupas').create(generalOptions);
var bankOptions = [
{
id: 'nordea',
imgPath: '/path/to/my/image.png',
vendorId: 'production id',
checksumKey: 'production key'
},
{
id: 'my-new-bank',
authUrl: "https://my.banks.url.com/tupas",
version: "0002",
keyVersion: "0001",
idType: "01",
imgPath: "/path/to/my/image.png",
number: "420",
vendorId: "xxxxxxx",
checksumKey: "xxxxxxx"
}
];
var tupas = require('tupas').create(generalOptions, bankOptions);
Options for banks:
id
- identifier for the bank (always use when configuring, seeconfig.json
for built-in options)authUrl
- url for the tupas authentication serviceversion
- A01Y_VERSkeyVersion
- A01Y_KEYVERSidType
- A01Y_IDTYPEimgPath
- path for the image used for the HTML formnumber
- bank number (e.g. 800 for DanskeBank)vendorId
- A01Y_RCVIDchecksumKey
- vendor specific key used in computing the MAC
var requestId = "12345678987654321234"; // used as A01Y_STAMP
var buttonHtml = tupas.tupasButton('nordea', 'FI', requestId);
...or if you just want the request parameters without generating any HTML:
var params = tupas.buildRequestParams('nordea', 'FI', requestId);
var banks = tupas.banks
// => ['danskebank', 'handelsbanken', 'nordea',
// 'op', 'aktia', 'alandsbanken', 'spankki',
// 'saastopankki', 'poppankki', 'my-new-bank']
The module binds paths /tupas/ok
(GET and POST), /tupas/cancel
(only GET)
and /tupas/reject
(only GET) to the given Express app for use as return urls.
Response handling is event based.
tupas.on('success', function (request, response) {
// Successful tupas authentication. Get auth data from request.query.
});
tupas.on('mac-check-failed', function (request, response) {
// Successful tupas authentication but the message was faulty.
});
tupas.on('cancel', function (request, response) {
// User cancelled authentication.
});
tupas.on('reject', function (request, response) {
// Authentication attempt was rejected by the bank.
});
See sample/app.js
for a simple usage example. Run the
sample app locally with node sample/start-sample.js
.