New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@mitreka/auth

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mitreka/auth

Mitreka Authentication

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Mitreka Authentication

Usage:

Login
import { createAuth } from "@mitreka/auth";
import type { AccessToken, Authentication, TokenPair } from "@mitreka/types";

const USER_ID = "<UserID>";
const PASSWORD = "<Password>";
const PUBLIC_KEY = "<YourPublicKey>";
const AUTH_SERVICE_ENDPOINT = "<YourAuthServiceEndpoint>";

const login = async() => {
  try {
    const Auth: Authentication = await createAuth({
      public: {
        key: PUBLIC_KEY
      },
      url: AUTH_SERVICE_ENDPOINT
    });
    const tokenPair: TokenPair = await Auth.login(USER_ID, PASSWORD);
    const session: AccessToken = await Auth.verifyToken(tokenPair.access_token);
    
    console.log(session); // Login success
  } catch (err: any) {
    // Handle error
  }
}
Refresh Token
import { createAuth } from "@mitreka/auth";
import type { AccessToken, Authentication, TokenPair } from "@mitreka/types";

const PUBLIC_KEY = "<YourPublicKey>";
const AUTH_SERVICE_ENDPOINT = "<YourAuthServiceEndpoint>";
const REFRESH_TOKEN = "<YourRefreshToken>";

const refreshToken = async() => {
  try {
    const Auth: Authentication = await createAuth({
      public: {
        key: PUBLIC_KEY
      },
      url: AUTH_SERVICE_ENDPOINT
    });
    const tokenPair: TokenPair = await Auth.refreshToken(REFRESH_TOKEN);
    const session: AccessToken = await Auth.verifyToken(tokenPair.access_token);

    console.log(authSession); // Refresh success
  } catch (err: any) {
    // Handle error
  }
}
Refresh Token with Role ID

Sometime we need to change the user role by default

import { createAuth } from "@mitreka/auth";
import type { AccessToken, Authentication, TokenPair } from "@mitreka/types";

const PUBLIC_KEY = "<PublicKey>";
const AUTH_SERVICE_ENDPOINT = "<AuthServiceEndpoint>";
const REFRESH_TOKEN = "<RefreshToken>";
const ROLE_ID = "<RoleID>";

const refreshToken = async() => {
  try {
    const Auth: Authentication = await createAuth({
      public: {
        key: PUBLIC_KEY
      },
      url: AUTH_SERVICE_ENDPOINT
    });
    const tokenPair: TokenPair = await Auth.refreshToken(REFRESH_TOKEN, {
      role_id: ROLE_ID
    });
    const session: AccessToken = await Auth.verifyToken(tokenPair.access_token);

    console.log(authSession); // Refresh success
  } catch (err: any) {
    // Handle error
  }
}

Keywords

auth

FAQs

Package last updated on 19 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts