@insomnia-labs/fan-passport-auth
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

ICC Fan Passport Auth

The fan-passport-auth library provides a class, ICCPassportAuth, that provides a set of utilities for managing ICC tokens and authentication for the fan passport application. It facilitates secure communication between the main ICC applications and the ICC Fan Passport application by handling user authentication tokens. It exposes methods to encryption users access token, decrypt the access token, and revoke the users access token.

Installation

To install the package, run the following command in your project directory:

npm i @insomnia-labs/fan-passport-auth

Usage

Initializing the Authentication Class

Import the ICCPassportAuth class from the package and initialize it with the desired environment.

import { ICCPassportAuth } from 'fan-passport-auth';

// Initialize with production environment
const auth = new ICCPassportAuth("production"); 

Encrypting a Token

Use the encryptToken method to encrypt a user's volt token. This token can then be included in URLs for redirecting users to the fan passport application.

async function encryptUserToken() {
  const encryptedToken = await auth.encryptToken({
    token: "userVoltTokenHere",
    name: "Samuel Olamide",
    email: "samuel.olamide@domain.com",
  });

  console.log("Encrypted Token:", encryptedToken);
}
encryptUserToken();

Validating an Encrypted Token

After encrypting a token, use validateToken to validate the encrypted token and optionally create a user instance on the application.

async function validateUserToken(encryptedToken) {
  const accessToken = await auth.validateToken(encryptedToken);

  console.log("Access Token:", accessToken);
}

Revoking an Access Token

To log a user out and invalidate their session, use the revokeAccessToken method.

async function revokeUserAccessToken(token) {
  const response = await auth.revokeAccessToken(token);

  console.log("Revoke Response:", response); // { statusCode: 200, message: 'Logged out successfully.' }
}

Support

For issues or feature requests, please reach out to the insomnia team.

Readme

Keywords

none

Package Sidebar

Install

npm i @insomnia-labs/fan-passport-auth

Weekly Downloads

91

Version

2.0.7

License

ISC

Unpacked Size

27.4 kB

Total Files

9

Last publish

Collaborators

  • goldin
  • mubarakbello
  • bilo.eth
  • hashcode