Skip to content

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

License

Notifications You must be signed in to change notification settings

S25Digital/aa-central-registry

Repository files navigation

aa-central-registry

Overview

This library provides a set of functions to interact with a centralized registry service, handling authentication tokens, entity information, and token verification. It leverages JWT (JSON Web Token) for authentication, caching for performance optimization, and provides methods for managing secrets and entities.

Features

  • Authentication Token Generation: Generates and manages user and entity authentication tokens.
  • Secret Management: Resets and retrieves secrets for the registered entities.
  • Entity Information Retrieval: Fetches information for different entity types such as AA, FIP, and FIU.
  • Public Key Retrieval: Fetches public keys for token verification.
  • JWT Token Verification: Verifies tokens using RS256 encryption algorithm.

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_TOKEN_BASE_URL: Base Url of the token service provided by Sahamati.
  • CR_CLIENT_USERNAME: Username for User linked with the entity
  • CR_CLIENT_PASSWORD: password for User linked with the entity
  • CR_RESET_SECRET: Force-ful reset of the token

Installation

npm i @s25digital/aa-central-registry

Usage

  1. Setup CentralRegistry:

    import getCRClient, {getRedisCache} from "@s25digital/aa-central-registry";
    
    const cache = await getRedisCache("redis://localhost:6379");
    
    const centralRegistry = getCRClient({
     cache,
     loggerLevel: "silent"
    });
  2. Fetch Entity Information:

    const aaInfo = await centralRegistry.getAA();
    const fipInfo = await centralRegistry.getFIP();
    const fiuInfo = await centralRegistry.getFIU();
  3. Get Token:

    Retrieve the authentication token for the client entity.

    const tokenResponse = await centralRegistry.getToken();
  4. Verify Token:

    Verify the authenticity of a token.

    const verificationResponse = await centralRegistry.verifyToken("your-token-here");
  5. 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 cache 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
});

Methods

getToken()

Generates or retrieves an existing authentication token for the client entity.

getAA(), getFIP(), getFIU()

Retrieves information about specific entities (Account Aggregators, Financial Information Providers, or Financial Information Users).

verifyToken(token: string)

Verifies the given JWT token using the public key retrieved from the issuer.

Resources

The package is developed and maintained by S25Digital Studio

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published