UNPKG

@checkfirst/nestjs-outlook

Version:

An opinionated NestJS module for Microsoft Outlook integration that provides easy access to Microsoft Graph API for emails, calendars, and more.

49 lines (48 loc) 2.61 kB
import { EventEmitter2 } from '@nestjs/event-emitter'; import { TokenResponse } from '../../interfaces/outlook/token-response.interface'; import { CalendarService } from '../calendar/calendar.service'; import { EmailService } from '../email/email.service'; import { MicrosoftOutlookConfig } from '../../interfaces/config/outlook-config.interface'; import { MicrosoftCsrfTokenRepository } from '../../repositories/microsoft-csrf-token.repository'; import { StateObject } from '../../interfaces/microsoft-auth/state-object.interface'; import { PermissionScope } from '../../enums/permission-scope.enum'; import { Repository } from 'typeorm'; import { MicrosoftUser } from '../../entities/microsoft-user.entity'; export declare class MicrosoftAuthService { private readonly eventEmitter; private readonly calendarService; private readonly emailService; private readonly microsoftConfig; private readonly csrfTokenRepository; private readonly microsoftUserRepository; private readonly logger; private readonly clientId; private readonly clientSecret; private readonly tenantId; private readonly redirectUri; private readonly tokenEndpoint; private readonly requiredScopes; private readonly defaultScopes; private readonly CSRF_TOKEN_EXPIRY; private subscriptionInProgress; constructor(eventEmitter: EventEmitter2, calendarService: CalendarService, emailService: EmailService, microsoftConfig: MicrosoftOutlookConfig, csrfTokenRepository: MicrosoftCsrfTokenRepository, microsoftUserRepository: Repository<MicrosoftUser>); private mapToMicrosoftScopes; private buildRedirectUri; cleanupExpiredTokens(): Promise<void>; private generateCsrfToken; parseState(state: string): StateObject | null; validateCsrfToken(token: string, timestamp?: number): Promise<string | null>; getLoginUrl(userId: string, scopes?: PermissionScope[]): Promise<string>; private saveMicrosoftUser; private getMicrosoftUserTokenInfo; getUserAccessTokenByExternalUserId(externalUserId: string): Promise<string>; getUserAccessTokenByUserId(internalUserId: number | string): Promise<string>; private processTokenInfo; exchangeCodeForToken(code: string, state: string): Promise<TokenResponse>; private setupSubscriptions; refreshAccessToken(refreshToken: string, userId: number): Promise<string>; revokeRefreshToken(refreshToken: string): Promise<void>; private hasCalendarSubscriptionPermission; private hasEmailSubscriptionPermission; isTokenExpired(tokenExpiry: Date, bufferMinutes?: number): boolean; }