Code Monkey home page Code Monkey logo

aa-central-registry's Introduction

aa-central-registry

The package facilitates the integration with Account Aggregator Central Registry Hosted by Sahamati.

The client supports the generation of the auth token, fetch of entities like FIP, FIU and AA.

Badges

MIT License

Environment Vars

Following env vars nned to be set for the package to work.

  • CR_BASE_URL: Base URl of the central registry provided by Sahamati.
  • CR_CLIENT_ID: Client Id obtained when you are onboarded.
  • CR_CLIENT_SECRET: Client secret obtained when you are onboarded.
  • CR_TOKEN_BASE_URL: Base Url of the token service provided by Sahamati.

Installation

npm i @s25digital/aa-central-registry

Usage

import getCRClient from "@s25digital/aa-central-registry";

const client = getCRClient();

// get a token from registry
const token = await client.getToken();

// get Entity List
const AAList = await client.getAA();

const FIPList = await client.getFIP();

const FIUList = await client.getFIU();

// get Entity Information by Id
const AA = await client.getAAById("id");

const FIP = await client.getFIPById("id");

const FIU = await client.getFIUById("id");

Using a cache

The package implements an in memory cache to store the token. You can replace this in memory cache by implementing a custom cachee with a specific interface mentioned below.

interface ICache {
  set(key: string, value: string): Promise<boolean>;
  get(key: string): Promise<string>;
  remove(key: string): Promise<boolean>;
}

Once a cache is created, you can pass it on while creating a CR Client.

const client = getCRClient({
  cache: myCustomCache
});

Verification of token

The package also includes a function to verify th tokn. The keys are fetched from the certs endpoint of the service and verified using thee jsonwebtoken package.

import getCRClient from "@s25digital/aa-central-registry";

const client = getCRClient();

const res = await client.verifyToken("JWT TOkEN HERE");

console.log(res);

/*
{
  isVerified: true, 
  payload: {...}
}
*/

Resources

The package is developed and maintained by S25Digital Studio

aa-central-registry's People

Contributors

dependabot[bot] avatar singhs020 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.