UNPKG

@tmlmobilidade/interfaces

Version:

This package provides SDK-style connectors for interacting with databases (e.g., stops, plans, rides, alerts) and external providers (e.g., authentication, storage). It simplifies data access and integration across projects.

48 lines (47 loc) 1.71 kB
import { CreateUserDto, LoginDto, Permission, Session } from '@tmlmobilidade/types'; declare class AuthProvider { private static _instance; /** * Return the instance of the AuthProvider. */ static getInstance(): Promise<AuthProvider>; /** * Get Permissions * * @param session_token - The session token * @param scope - The scope to check * @param action - The action to check * @returns The permissions that the user has */ getPermission<T>(session_token: string, scope: string, action: string): Promise<Permission<T>>; /** * Gets a user by their session token * * @param session_token - The session token to look up * @returns The user associated with the session token * @throws {HttpException} * - UNAUTHORIZED if session not found * - UNAUTHORIZED if user not found */ getUser(session_token: string): Promise<import("mongodb").WithId<import("@tmlmobilidade/types").User>>; /** * Login a user * * @param username - The username of the user * @param password_hash - The password hash of the user, already hashed with bcrypt in client * @returns The newly created session for the logged in user * @throws {HttpException} * - UNAUTHORIZED if user not found or password is incorrect * - INTERNAL_SERVER_ERROR if login fails */ login(dto: LoginDto): Promise<Session>; /** * Logout a user * * @param session_token - The session token to logout */ logout(session_token: string): Promise<void>; register(createUserDto: CreateUserDto): Promise<void>; } export declare const authProvider: AuthProvider; export {};