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

nordigen-cf-workers

v1.0.2

Published

Unofficial Cloudflare Workers API Library for Nordigen

Downloads

3

Readme

nordigen-cf-workers

Unofficial Cloudflare Workers API Library for Nordigen.

This is a fork from https://github.com/vantezzen/nordigen.

This library allows you to easily access the Nordigen Account Information API.

Please note that not every endpoint is implemented in this library. Feel free to contribute to this library to add any extra endpoints that you would like to use.

API Documentation: https://appelboomhd.github.io/nordigen-cf-workers NPM: https://www.npmjs.com/package/nordigen-cf-workers

Installation

Simply install the Library via NPM:

npm install nordigen-cf-workers

nordigen-cf-workers is built with TypeScript so you shouldn't need to install additional packages for type-support.

Usage

This library uses Promise-based methods for calling the API. It is kept very slim, so you want to handle error handling etc. yourself.

Here is an example flow on how you can access accounts using the library. This example follows the same steps as defined in Nordigen's API quickstart guide at https://nordigen.com/en/account_information_documenation/integration/quickstart_guide/.

import Nordigen from 'nordigen-cf-workers';

const nordigen = new Nordigen('secretId', 'secretKey');
await nordigen.generateToken()

// Please note that you might also define an endpoint URL if you do not use the default Nordigen API, e.g.
// const nordigen = new Nordigen('secretId', 'secretKey', 'https://ob.beta.nordigen.com/api');

// First, get a list of institutions (Banks) for the user
const institutions = await nordigen.getInstitutions('NL');

// Let the user pick their institution now. We will use the first institution in this example:
const institution = institutions[0];

// Optionally, you can create an end user agreement to define a custom history length. If you want to use the default length of 90 days, skip this step
const agreement = await nordigen.createEndUserAgreement({
  institutionId: institution.id,

  // The following arguments are completely *optional*. If you don't need them, don't define them

  // The length of the transaction history to be retrieved
  maxHistoricalDays: 60,

  // The length of time the end-user's access token is valid for
  accessValidForDays: 30,

  // The scope of the access token
  accessScope: [
    'balances',
    'details',
    'transactions'
  ]
 });

// Now we need to create a "requisition" which allows us to authenticate a user at their bank
const requisition = await nordigen.createRequisition({
  // The user needs to be redirected to their bank's website. After they are done they will be redirected back to your website.
  // This is why you will need to define a redirect URL here
  // PLEASE NOTE: Nordigen will automatically add "?ref={enduser_id}" to this callback URL so you won't need to add that yourself!
  redirect: `https://example.com/nordigen-callback`,

  // The id of the institution for which you want to create a requisition
  institutionId: institution.id

  // The following arguments are completely *optional*. If you don't need them, don't define them

  // You can define another unique ID here. This is the "reference" to this requisition
  reference: "demo_id",

  // Array of User agreements that we want to use
  agreement,

  // A language code that should be used. Otherwise, the user language will be used automatically. Format should be ISO 3166
  userLanguage: "EN/us",

  // Option to enable account selection view for the end user
  accountSelection: true
});

// Get link to authorize in the bank
// Authorize with your bank via this link, to gain access to account data
const link = requisition.link;

// requisition id is needed to get accountId in the next step
const requisitionId = requisition.id;

After successful authorization with a bank you can fetch your data (details, balances, transactions)

Fetching account metadata, balances, details and transactions

// As soon as the user comes back (e.g. being on the callback URL) we can get user information from our requsition.
const requsitionInfo = await nordigen.getRequisitionInfo(requisition.id);

// This will give you a list of account IDs the user has access to under requsitionInfo.accounts
// You may now allow the user to choose one of those accounts or loop through each account.
// We will continue with using only the first account.

// Let us get some more details about the user account
const details = await nordigen.getAccountDetails(requsitionInfo.accounts[0]);
// This info now includes the Account IBAN, owner name etc.

// We can also fetch the account balances
const balances = await nordigen.getAccountBalances(requsitionInfo.accounts[0]);

// ...or a list of transactions in our history timeframe
const transactions = await nordigen.getAccountTransactions(requsitionInfo.accounts[0]);

You can look at the API documentation or /src/lib/types for more information about the returned data

Make requests to other endpoints

// If you want to call an API endpoint not defined in the library (e.g. deleting an agreement), you can call the "makeRequest" method directly instead:
const response = await nordigen.makeRequest(
  // Relative path to the endpoint. You don't need the "https://ob.nordigen.com/api"
  "/agreements/enduser/MY_ID",

  // Optional HTTP method. This will default to "GET"
  "DELETE",

  // Optional HTTP body object. This will automatically be JSON encoded
  {
    // (This route doesn't require any body data)
  }
);

TODO

  • [ ] Implement option to re-use token in combination with refresh token (Durable objects or maybe environment variables)