UNPKG

@wristband/nestjs-auth

Version:

SDK for integrating your NestJS application with Wristband. Handles user authentication, session management, and token management.

59 lines (58 loc) 2.47 kB
import { DynamicModule } from '@nestjs/common'; import { WristbandAuthAsyncOptions } from '../types/auth.types'; /** * The WristbandExpressAuthModule is a dynamic NestJS module that integrates the Wristband Authentication Service * for NestJS/Express-based applications. It allows for the configuration and injection of the * `WristbandExpressAuthService`, enabling authentication functionality within the application. * * Usage: * - Call `forRootAsync` with configuration options and a token name to set up the module. * - The module exports the `WristbandExpressAuthService` with the specified token, making it available across the app. * * Example: * * ```typescript * import { ConfigModule } from '@nestjs/config'; * import { WristbandExpressAuthModule } from '@wristband/nestjs-auth'; * * WristbandExpressAuthModule.forRootAsync({ * imports: [ConfigModule], * useFactory: (configService: ConfigService) => ({ * clientId: configService.get('WRISTBAND_CLIENT_ID'), * clientSecret: configService.get('WRISTBAND_CLIENT_SECRET'), * // ... other config * }), * inject: [ConfigService], * }, 'MyWristbandAuth'); * ``` * * For static configuration: * * ```typescript * import { ConfigModule } from '@nestjs/config'; * import { WristbandExpressAuthModule } from '@wristband/nestjs-auth'; * * WristbandExpressAuthModule.forRootAsync({ * useFactory: () => ({ * clientId: 'your-client-id', * clientSecret: 'your-client-secret', * // ... other config * }), * }, 'MyWristbandAuth'); * ``` * * This module is designed to be globally available, ensuring the `WristbandExpressAuthService` can be easily injected * and used across different modules in the application. Multiple instances of this SDK can be injected into the same * application, if required. */ export declare class WristbandExpressAuthModule { /** * Configures and initializes the WristbandExpressAuthModule with async configuration. * * @param {WristbandAuthAsyncOptions} options - Configuration options including useFactory, inject, and imports * @param {string} token - Token name used to identify the service instance. Required for multi-instance support. * @returns {DynamicModule} - A NestJS DynamicModule that provides and exports the `WristbandExpressAuthService` * with the specified token. */ static forRootAsync(options: WristbandAuthAsyncOptions, token?: string): DynamicModule; }