// Copyright Abridged, Inc. 2021,2024. All Rights Reserved. // Node module: @collabland/api-security // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {UserAuthorization} from '@collabland/models'; import {BindingKey} from '@loopback/core'; import {UserProfile} from '@loopback/security'; /** * Information about a tenant in the multi-tenancy environment */ export interface Tenant { id: string; [attribute: string]: unknown; } /** * Options to generate an oAuth2 access token for Discord interactions */ export type OAuth2AccessTokenOptions = { /** * Client application id */ clientId: string; /** * User id */ userId: string; /** * A list of scopes */ scopes: string[]; /** * TTL in seconds */ ttl?: number; /** * Id token - Discord interaction token */ idToken?: string; idRefreshToken?: string; /** * User profile */ userProfile?: UserProfile; /** * If the access token should include the refresh token */ includesRefreshToken?: boolean; }; /** * Generate an oAuth2 access token for Discord interactions */ export interface OAuth2Helper { /** * Generate an oAuth2 access token for Discord interactions * @param options */ generateAccessToken(options: OAuth2AccessTokenOptions): Promise<{ accessToken: string; refreshToken?: string; }>; /** * Authorize a user for a client application * @param currentUser * @param clientId * @param authorizedScopes */ authorize( currentUser: UserProfile, clientId: string, authorizedScopes: string[], ): Promise; } export const OAUTH2_HELPER = BindingKey.create( 'services.OAuth2Helper', );