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.
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.
npm i @s25digital/aa-central-registry
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");
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
});
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: {...}
}
*/
The package is developed and maintained by S25Digital Studio