1.5.1 • Published 3 months ago

@s25digital/aa-central-registry v1.5.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

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

1.5.1

3 months ago

1.5.0

3 months ago

1.4.3

3 months ago

1.4.2

4 months ago

1.4.1

4 months ago

1.2.0

4 months ago

1.1.0

4 months ago

1.4.0

4 months ago

1.3.0

4 months ago

1.0.4

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.3

4 months ago

1.0.0

4 months ago