Table of Contents:
- 1. What is NodeJs-SDK?
- 2. Supported Node.js Versions
- 3. How to use SDK
- 4. Extra functionality
- 5. How to run the example
This SDK provides tools for the integration of the Open Banking authorization flow into your NodeJs server application.
This repository contains two subfolders:
- /src contains the SDK source code
- /example contains an example of how to use the SDK
16.18.1 (NPM > 8.19.2)
First read through the Authorization part of API documentation.
Account-information API documentation: https://<sandbox_portal_host_of_the_bank>/api-documentation/account-info-ob
Payment-initiation API documentation: https://<sandbox_portal_host_of_the_bank>/api-documentation/payment-init-ob
Function: OpenBankingAuth(clientId, privateKey, certificateOrPublicKey, redirectUri, tokenEndpointUri, authEndpointUri, scope, issuer, jwksUri) - constructor
- clientId (e.g. myApp@account-info-ob)
- privateKey (your private key)
- certificateOrPublicKey (your certificate or public key which has to be uploaded on the developer portal)
- redirectUri (the OAuth2 callback URL of your application)
- tokenEndpointUri (token endpoint URL of OIDC server)
- authEndpointUri (authentication endpoint URL of OIDC server)
- scope (depends on API, read documentation)
- jwksUri (certs endpoint URL of OIDC server)
- issuer = (sandbox endpoint URL of OIDC server);
const OpenBankingAuth = require('../src/OpenBankingAuth').OpenBankingAuth;
...
const accountInfoAuth = new OpenBankingAuth(clientId, privateKey, certificateOrPublicKey, redirectUri, tokenEndpointUri, authEndpointUri, scope, issuer, jwksUri);
Function: getAccessToken():string
const accessToken = await accountInfoAuth.getAccessToken();
Function: generateAuthorizationUrl(intentId, state, nonce):string
- intentId (identification of previously created intent, e.g. ConsentId)
- state (random string)
- nonce (random string)
const authUrl = await accountInfoAuth.generateAuthorizationUrl(intentId, state, nonce);
Function: exchangeToken(code):object
- code (the authorization code received from the authorization server)
const newTokens = await accountInfoAuth.exchangeToken(code);
Function: createSignatureHeader(body):string
- body (intent, e.g. an account-request)
const xJwsSignature = await accountInfoAuth.createSignatureHeader(body);
Function: isTokenExpired(token [, expiredAfterSeconds]):boolean
- token (jwt)
- expiredAfterSeconds (number of seconds * 1000)
const isExpired = accountInfoAuth.isTokenExpired(token, 5000); // will token expire after five seconds?
Function: refreshToken(refreshToken):object
- refresh token
const newTokens = accountInfoAuth.refreshToken(refreshToken);
- Open
example/config/config.json
and replace settings with the correct values - Overwrite
example/config/privatekey.key
with your own private key. Filename must beprivatekey.key
- Overwrite
example/config/certificateOrPublicKey
with your own certificate or public key. Filename must becertificateOrPublicKey
- Run example
cd example
npm install
npm start
Open your browser and navigate to http://localhost:3000/account-info
or http://localhost:3000/payment-init
.