-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from bloqhouse/feat/rework
- Loading branch information
Showing
12 changed files
with
2,350 additions
and
819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- '8' | ||
- '9' | ||
- '10' | ||
- '12' | ||
- '14' | ||
script: | ||
- npm run test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,62 @@ | ||
# node-idin [](https://travis-ci.org/bloqhouse/node-idin) [](https://coveralls.io/github/bloqhouse/node-idin?branch=master) | ||
|
||
# node-idin [](https://travis-ci.com/bloqhouse/node-idin) [](https://coveralls.io/github/bloqhouse/node-idin?branch=master) | ||
|
||
Node.js Library for [iDIN](https://www.idin.nl/) | ||
|
||
|
||
|
||
Node-idin has 3 exportable methods. These methods accept two objects as parameters. | ||
Node.js Library for [iDIN](https://www.idin.nl/). You can find all the protocol documentation [here](https://betaalvereniging.atlassian.net/wiki/spaces/IIDIFMD/pages/588284049/iDIN+Merchant+Implemention+Guide+EN). | ||
Supporting Node 10+. | ||
|
||
|
||
|
||
## How to use | ||
|
||
Install the dep by: | ||
```bash | ||
yarn add node-idin | ||
``` | ||
|
||
Create a `NodeIdin` instance: | ||
|
||
1. `GeneralParameters` object which includes: | ||
```ts | ||
merchantId: string | ||
merchantSubId: string | ||
routingEndpoint: string // callback url | ||
routingCert: string | ||
publicKey: string | ||
publicKeyFingerprint: string | ||
privateKey: string | ||
const config = { | ||
merchantId: '35235', | ||
merchantSubId: '0', | ||
routingEndpoint: 'https://abnamro-test.bank-request.com/bvn-idx-bankid-rs/bankidGateway', | ||
routingCert: '-----BEGIN CERTIFICATE-----...', | ||
privateKey: '-----BEGIN RSA PRIVATE KEY-----...', | ||
publicKey: '-----BEGIN PUBLIC KEY-----...', | ||
publicKeyFingerprint: 'xekf2o3f...', | ||
} | ||
|
||
const idin = new NodeIdin(config); | ||
``` | ||
2. Specific object per method, more info in the table below. | ||
|
||
| Method | Specific object required | Description | | ||
|--|--|--| | ||
| getDirectoryResponse | Not required | Gets the different issuers (banks) available | | ||
| getTransactionResponse | { loa: string, merchantReturnUrl: string, idPrefix: string, requestedService: number, defaultLanguage: string, expirationPeriod: string, issuerId: string, transactionId: string } | Initial step to get the user's data. | | ||
| getStatusResponse | { transactionId: string } | Final data retrieval | | ||
Use the method you need: | ||
|
||
```ts | ||
const directory = await idin.getDirectory(); | ||
``` | ||
|
||
Example: | ||
```ts | ||
const transaction = await idin.getTransaction({ | ||
loa: 'loa3', | ||
merchantReturnUrl: 'https://...', | ||
idPrefix: 'RND', | ||
requestedService: '21968', | ||
defaultLanguage: 'en', | ||
expirationPeriod: 'PT5M', | ||
issuerId: 'randomId', | ||
transactionId: 'randomId#2', | ||
}); | ||
``` | ||
|
||
```ts | ||
try { | ||
const gParams: GeneralParameters = { | ||
merchantId: '35235', | ||
merchantSubId: '0', | ||
routingEndpoint: 'https://abnamro-test.bank-request.com/bvn-idx-bankid-rs/bankidGateway', | ||
routingCert: '-----BEGIN CERTIFICATE-----...', | ||
privateKey: '-----BEGIN RSA PRIVATE KEY-----...', | ||
publicKey: '-----BEGIN PUBLIC KEY-----...', | ||
publicKeyFingerprint: 'xekf2o3f...', | ||
}; | ||
const specificParams: StatusParameters = { | ||
transactionId: 'wefawef2', | ||
}; | ||
const data = await getStatusResponse(gParams, specificParams); | ||
console.log(data) | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
const status = await idin.getStatus({ transactionId: '92fo2k3qdd' }); | ||
``` | ||
|
||
## Notes | ||
|
||
- Read protocol documentation for a better understanding of the parameters. | ||
|
||
- This library does not fully implement the protocol and has some issues that still need to be addressed. Use at your own risk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// tslint:disable-next-line:no-reference | ||
/// <reference path="./index.d.ts" /> | ||
|
||
export * from './lib'; | ||
import NodeIdin from './lib'; | ||
export default NodeIdin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { checkParams } from './utils'; | ||
import getDirectory from './directory-protocol'; | ||
import getTransaction, { TransactionParams } from './transaction-protocol'; | ||
import getStatus, { StatusParameters } from './status-protocol'; | ||
import getDirectoryResponse from './directory-protocol'; | ||
import getTransactionResponse, { TransactionParams } from './transaction-protocol'; | ||
import getStatusResponse, { StatusParameters } from './status-protocol'; | ||
import { GeneralParameters } from './idin-protocol'; | ||
|
||
export function getDirectoryResponse(arg1: GeneralParameters) { | ||
checkParams('getDirectory', ...arguments); | ||
return getDirectory(arg1); | ||
} | ||
export default class NodeIdin { | ||
constructor( | ||
private config: GeneralParameters, | ||
) { } | ||
|
||
export function getStatusResponse(arg1: GeneralParameters, arg2: StatusParameters) { | ||
checkParams('getStatus', ...arguments); | ||
return getStatus(arg1, arg2); | ||
} | ||
public getDirectory() { | ||
return getDirectoryResponse(this.config); | ||
} | ||
|
||
export function getTransactionResponse(arg1: GeneralParameters, arg2: TransactionParams) { | ||
checkParams('getTransaction', ...arguments); | ||
return getTransaction(arg1, arg2); | ||
} | ||
public getTransaction(transactionConfig: TransactionParams) { | ||
return getTransactionResponse(this.config, transactionConfig); | ||
} | ||
|
||
export { GeneralParameters, TransactionParams, StatusParameters }; | ||
public getStatus(statusConfig: StatusParameters) { | ||
return getStatusResponse(this.config, statusConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.