UNPKG

n8n

Version:

n8n Workflow Automation Tool

39 lines (38 loc) 2.57 kB
import type { Response } from 'express'; import type { ICredentialDataDecryptedObject, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; import type { CredentialsEntity } from '../../databases/entities/CredentialsEntity'; import { CredentialsRepository } from '../../databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '../../databases/repositories/sharedCredentials.repository'; import type { ICredentialsDb } from '../../Interfaces'; import type { OAuthRequest } from '../../requests'; import { CredentialsHelper } from '../../CredentialsHelper'; import { Logger } from '../../Logger'; import { ExternalHooks } from '../../ExternalHooks'; import { UrlService } from '../../services/url.service'; import { GlobalConfig } from '@n8n/config'; export interface CsrfStateParam { cid: string; token: string; } export declare abstract class AbstractOAuthController { protected readonly logger: Logger; protected readonly externalHooks: ExternalHooks; private readonly credentialsHelper; private readonly credentialsRepository; private readonly sharedCredentialsRepository; private readonly urlService; private readonly globalConfig; abstract oauthVersion: number; constructor(logger: Logger, externalHooks: ExternalHooks, credentialsHelper: CredentialsHelper, credentialsRepository: CredentialsRepository, sharedCredentialsRepository: SharedCredentialsRepository, urlService: UrlService, globalConfig: GlobalConfig); get baseUrl(): string; protected getCredential(req: OAuthRequest.OAuth2Credential.Auth): Promise<CredentialsEntity>; protected getAdditionalData(): Promise<IWorkflowExecuteAdditionalData>; protected getDecryptedData(credential: ICredentialsDb, additionalData: IWorkflowExecuteAdditionalData): Promise<ICredentialDataDecryptedObject>; protected applyDefaultsAndOverwrites<T>(credential: ICredentialsDb, decryptedData: ICredentialDataDecryptedObject, additionalData: IWorkflowExecuteAdditionalData): T; protected encryptAndSaveData(credential: ICredentialsDb, decryptedData: ICredentialDataDecryptedObject): Promise<void>; protected getCredentialWithoutUser(credentialId: string): Promise<ICredentialsDb | null>; createCsrfState(credentialsId: string): [string, string]; protected decodeCsrfState(encodedState: string): CsrfStateParam; protected verifyCsrfState(decrypted: ICredentialDataDecryptedObject, state: CsrfStateParam): boolean; protected renderCallbackError(res: Response, message: string, reason?: string): void; }