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.
- 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.
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 entityCR_CLIENT_PASSWORD
: password for User linked with the entityCR_RESET_SECRET
: Force-ful reset of the token
npm i @s25digital/aa-central-registry
-
Setup CentralRegistry:
import getCRClient, {getRedisCache} from "@s25digital/aa-central-registry"; const cache = await getRedisCache("redis://localhost:6379"); const centralRegistry = getCRClient({ cache, loggerLevel: "silent" });
-
Fetch Entity Information:
const aaInfo = await centralRegistry.getAA(); const fipInfo = await centralRegistry.getFIP(); const fiuInfo = await centralRegistry.getFIU();
-
Get Token:
Retrieve the authentication token for the client entity.
const tokenResponse = await centralRegistry.getToken();
-
Verify Token:
Verify the authenticity of a token.
const verificationResponse = await centralRegistry.verifyToken("your-token-here");
-
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
});
Generates or retrieves an existing authentication token for the client entity.
Retrieves information about specific entities (Account Aggregators, Financial Information Providers, or Financial Information Users).
Verifies the given JWT token using the public key retrieved from the issuer.
The package is developed and maintained by S25Digital Studio