UNPKG

axiodb

Version:

The Pure JavaScript Alternative to SQLite. Embedded NoSQL database for Node.js with MongoDB-style queries, zero native dependencies, built-in InMemoryCache, and web GUI. Perfect for desktop apps, CLI tools, and embedded systems. No compilation, no platfor

39 lines (38 loc) 1.62 kB
/** * Controller class for handling key generation and verification operations. * * This class provides functionality for generating session keys using JWT (JSON Web Token) * and verifying those keys for authentication purposes. * * @class KeyController */ export default class KeyController { private readonly Generationkey; constructor(Generationkey: string); /** * Generates a session key using JWT for authentication purposes. * * This method creates a new JWT token with default server key parameters * including issuer, reason, audience, expiration time, and timestamp. * The token is encrypted using the specified rounds of encryption. * * @returns {Promise<string | any>} A promise that resolves to a response object containing * the generated session key or an error object in case of failure. * The response includes status code, message, and the originSessionKey. * * @example * const keyController = new KeyController(); * const response = await keyController.generateKey(); * // response = { statusCode: 200, message: "Key Generated Successfully", data: { originSessionKey: "jwt-token" } } */ generateKey(): Promise<string | any>; /** * Verifies the provided API key. * * @param {string} key - The API key to verify * @returns {Promise<string | any>} A response object containing status code and message * - If key is valid: Status 200 with success message * - If key is invalid: Status 401 with error message */ verifyKey(key: string): Promise<string | any>; }