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

kogitte

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kogitte

OAuth2 session manager

latest
Source
npmnpm
Version
5.1.3
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Kogitte

ci npm

OAuth2 session manager

This package supports/uses only the password and refresh flow!

Setup & Build

Install all dependencies:

npm install

Build:

npm run build

Usage

Initial configuration:

import { AuthConfig } from "kogitte";

AuthConfig.init({
    // Required
    clientId: "clientId",
    tokenUrl: "tokenUrl",
    logoutUrl: "logoutUrl",

    // Optional
    localStorageKey: "localStorageKey",
    onSessionExpire: () => { ... }
});

Session Manager

Login:

Requests the access and the refresh token from the configured token URL and saves this data in the local storage.

import { UserSessionManager } from "kogitte";

new UserSessionManager().login("username", "password", "optional captcha response");

Optionally a captcha response can be provided. This data is sent with the login in the captcha parameter.

Logout:

Sends an authorized POST request to the configured URL and removes afterwards the session in the local storage.

import { UserSessionManager } from "kogitte";

new UserSessionManager().logout("optional data");

Optionally data can be provided. This data is sent in the request body.

Get current session:

Gets the data from the local storage and checks if the access token is still valid. Is this not the case, a refresh attempt is made. If this fails the saved session gets removed. Is the token still valid or the refreshment succeeded, the current session gets returned.

import { UserSessionManager } from "kogitte";

new UserSessionManager().getCurrentSession();

Session exists:

Checks if a session is stored in the local storage.

import { UserSessionManager } from "kogitte";

new UserSessionManager().sessionExists();

FAQs

Package last updated on 10 Feb 2022

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