5.1.3 • Published 2 years ago

kogitte v5.1.3

Weekly downloads
8
License
MPL-2.0
Repository
github
Last release
2 years ago

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();
5.1.3

2 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

4.1.0

3 years ago

4.0.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago