nepse_client.token_manager

Token management for NEPSE API authentication.

This module handles automatic token generation, refresh, and validation for both synchronous and asynchronous clients.

Classes

AsyncTokenManager

Asynchronous token manager.

TokenManager

Synchronous token manager.

TokenParser

Parse authentication tokens using WebAssembly module.

class nepse_client.token_manager.TokenManager[source]

Bases: _TokenManagerBase

Synchronous token manager.

Manages authentication tokens for synchronous NEPSE client, automatically refreshing tokens when they expire.

__init__(nepse)[source]

Initialize synchronous token manager.

getAccessToken()[source]

Get valid access token, refreshing if necessary.

Return type:

str

Returns:

Valid access token

getRefreshToken()[source]

Get valid refresh token, refreshing if necessary.

Return type:

str

Returns:

Valid refresh token

update()[source]

Fetch and update authentication tokens.

Return type:

None

class nepse_client.token_manager.AsyncTokenManager[source]

Bases: _TokenManagerBase

Asynchronous token manager.

Manages authentication tokens for asynchronous NEPSE client, with support for concurrent token refresh operations.

__init__(nepse)[source]

Initialize asynchronous token manager.

async getAccessToken()[source]

Get valid access token, refreshing if necessary.

Return type:

str

Returns:

Valid access token

async getRefreshToken()[source]

Get valid refresh token, refreshing if necessary.

Return type:

str

Returns:

Valid refresh token

async update()[source]

Fetch and update authentication tokens asynchronously.

Return type:

None

class nepse_client.token_manager.TokenParser[source]

Bases: object

Parse authentication tokens using WebAssembly module.

This class uses a WASM module to decode and parse the authentication tokens returned by the NEPSE API.

__init__()[source]

Initialize token parser with WASM runtime.

parse_token_response(token_response)[source]

Parse access and refresh tokens from API response.

Parameters:

token_response (dict) – Raw token response from API

Return type:

tuple[str, str]

Returns:

Tuple of (access_token, refresh_token)