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

@s25digital/aa-central-registry

v2.1.2

Published

A package to work with Sahamati Central Registry in AA ecosystem

Downloads

613

Readme

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