npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@innocells/unnax-client

v1.0.60

Published

Unnax client for node

Downloads

19

Readme

unnax-client

Unnax SDK for JavaScript

Installation

You can install it directly from npm:

npm install @innocells/unnax-client --save

Initialization

init(request)

To initialize the unnax-client use the init() method passing the options object:

{
  apiCode:        Unnax client ApiCode (string)
  apiId:          Unnax client ApiId   (string)
  unnaxBaseUrl:   Unnax api endpoint (Unnax Environment) (string)
}

Initialization example:

 const UnnaxClient = require('@innocells/unnax-client').init({
  apiCode: "unnaxApiCode",
  apiId: "unnaxApiId",
  unnaxBaseUrl: "unnax api url base (integration environment unnax sample: https://integration.unnax.com)"
 });

Response:

Returns an instance of the unnax-client.

Methods

getWidgetHtml(request)

Returns the html code (so intended for web browsers) of the widget used to connect bank accounts.

Request object definition:

{
  requestCode:      Unique request code (string)   
  baseColor:        Base color for the widget (?string) (Default #0098C3)
  logoUrl:          Url for the application logo (?string)
  urlOk:            Redirect url for success bank login (?string)
  urlKo:            Redirect url for fails bank login (?string)
}

Request example:

  const widgetRequest = {
    baseColor: '#09D3C7',
    requestCode: '123456',
    logoUrl: 'https://www.jido.io/wp-content/uploads/2018/01/Jido-logo.png'
    urlOk: 'http://localhost:4000/loginOk',
    urlKo: 'http://localhost:4000/loginOk'
  };

  const widget = UnnaxClient.getWidgetHtml(widgetRequest);

Response:

HTML content for the widget. When the user finish the login process the unnax widget redirects to urlOk or urlKo.

getAvailableWebhooks()

Returns the list of available webhooks in Unnax.

Request example:

const response = await UnnaxClient.getAvailableWebhooks();

The returned object is an array of events:

[
	{
		"name": "Aml Check",
		"id": "aml_check",
		"description": "Triggered when an AML check completes"
	},
	{
		"name": "Fitnance Read",
		"id": "fitnance_read",
		"description": "Triggered when a fitnance read operation completes"
	}
  ...
]

getSubscribedWebhooks()

Returns an object with the currently subscribed events.

Request example:

const response = await UnnaxClient.getSubscribedWebhooks();

Response:

{
  count:      Number of subscribed webhooks.
  next:       Url to get the next page.
  previous:   Url to get the previous page. 
  results:    Array of subscribed events. Each event has an id, client ("email" or "callback") and target (email or callback url from site)
}

Response sample:

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 235,
      "client": "callback",
      "event": "event_credential_token_creation",
      "target": "https://mySite.com/response",
      "created_at": "2018-01-17T12:24:53Z",
      "updated_at": "2018-01-17T12:24:53Z"
    },
    {
      "id": 240,
      "client": "email",
      "event": "event_reader_lockstep_complete",
      "target": "[email protected]",
      "created_at": "2018-01-17T14:57:55Z",
      "updated_at": "2018-01-17T15:07:56Z"
    },
    ...
  ]
} 

subscribeWebHook(options)

This method is used to register a webhook event.

Request object definition:

{
   client:       Client type, either `email` or `callback`) (string)
   event:        Event id (returned from `getAvailableWebhooks()`) (string)
   target:       An email or callback url.
}

Request example:

  const request = { client: 'email', event: 'aml_check', target: '[email protected]' };
  const response = await UnnaxClient.SubscribeWebHook(request);

The response represents a new webhook subscription:

{
   id:           Webhook subscription id (number)
   client:       'email' or 'callback' (same as request.client) (string)
   event:        Event id (eventId returned in the getAvailableWebhooks() method) (string)
   target:       Target of webhook response. (url if the client is 'callback' or email if the client is 'email')
}

decryptData(data)

This method is used to decrypt the data received from the webhook (fitnance_read) callback.

Request object definition:

 data: string

Callback webhook definition object

Sample fitnance_reader callback:

  {
     service:            Service (example: 'reader') (string)
    triggered_event:    Event id (to receive the callback, you must to subscribe to an event) (string)
    environment:        Unnax environment (example: "unnax_integration")
    data:               Encrypted data received (i.e. all movements from a client bank account) (string)
    date:               Date time executed (string)
    response_id:        Response id (string),
    trace_identifier:   trace identifier (string)
  }

Sample request:

  const result = UnnaxClient.decryptData(request.body.data.data);  

launchTokenizedReader(request)

Launchs a request for tokenized readings (once the read finish unnax will launch a fitnance_read event and post the data to the target webhook subscription).

Request object definition:

{
 tokenKey:         Token_key created previously (callback of Credentials Tokenized Widget) (string), 
 tokenId:          Token_id created previously (callback of Credentials Tokenized Widget) (string), 
 requestCode:      RequestCode for reader (string), 
 startDate:        Movements since YYYY-MM-DD (string)
}  

Request example:

const request = {
    tokenKey: "lsFt7skxMaVfX4itYFB5sP8XVZLXoCVn",
    tokenId: "92",
    requestCode: "2AAsdfrA65_1",
    startDate : "2017-01-01"
}

const result = await UnnaxClient.launchTokenizedReader(request);

The response contains a job_id:

{
    "job_id": "rt_f586421f5e9c4f61b0f8882a220ddd77"
}

apiInit(requestCode)

Launchs a request for Login Bank by API

Request object definition:

 requestCode:         identifier for bank login (string)

Request example:

const request = 'requesBankLoginIdentifier'

const result = await UnnaxClient.apiInit(request);

The response contains a session ID sid and array of banks. Each bank contains login methods:

{
	"sid": "s_asdassdacegrthaf86a90aa6437da4f3",
	"banks": [
		{
			"id": 3,
			"name": "Banc Sabadell",
			"parameters": [
				{
					"name": "document_type",
					"label": "Tipo de documento",
					"type": "option",
					"optional": false,
					"fields": [
						{
							"name": "bso_id_number",
							"label": "Usuario (DNI)",
							"type": "text",
							"minLength": 0,
							"maxLength": 30
						},
						{
							"name": "bso_sec_card",
							"label": "Tarjeta secundaria",
							"type": "text",
							"minLength": 0,
							"maxLength": 30
						},
						{
							"name": "bso_nie",
							"label": "NIE",
							"type": "text",
							"minLength": 0,
							"maxLength": 30
						}
					]
				},
				{
					"name": "username",
					"label": "Usuario",
					"type": "text",
					"optional": false,
					"fields": [
						{
							"name": "username",
							"label": "Usuario",
							"type": "text",
							"minLength": 0,
							"maxLength": 20
						}
					]
				},
				{
					"name": "password",
					"label": "Contraseña",
					"type": "password",
					"optional": false,
					"fields": [
						{
							"name": "password",
							"label": "Contraseña",
							"type": "text",
							"minLength": 0,
							"maxLength": 20
						}
					]
				}
			]
		}]
}