import { KyselyDB } from "../../../database/types/kysely.types";
import { EnvironmentService } from '../../../integrations/environment/environment.service';
import { DomainService } from '../../../integrations/environment/domain.service';
import { IntegrationRegistry } from '../registry/integration-registry';
import { IntegrationRepo } from '../repos/integration.repo';
import { IntegrationConnectionRepo } from '../repos/integration-connection.repo';
import { WorkspaceRepo } from "../../../database/repos/workspace/workspace.repo";
import { UserRepo } from "../../../database/repos/user/user.repo";
import { EncryptionService } from '../../../integrations/encryption/encryption.service';
import { IntegrationConnection } from "../../../database/types/entity.types";
import WorkspaceAbilityFactory from '../../casl/abilities/workspace-ability.factory';
import { IAuditService } from '../../../integrations/audit/audit.service';
import { RedisService } from '@nestjs-labs/nestjs-ioredis';
export type OAuthFlow = 'install' | 'connect';
export type OAuthStatePayload = {
    flow: OAuthFlow;
    integrationId: string | null;
    type: string;
    userId: string;
    workspaceId: string;
    returnUrl: string;
    returnPath: string;
    nonce: string;
    exp: number;
};
export declare class OAuthService {
    private readonly db;
    private readonly environmentService;
    private readonly domainService;
    private readonly registry;
    private readonly integrationRepo;
    private readonly connectionRepo;
    private readonly workspaceRepo;
    private readonly encryptionService;
    private readonly userRepo;
    private readonly workspaceAbility;
    private readonly auditService;
    private readonly redisService;
    private readonly logger;
    private readonly refreshLock;
    private readonly pendingRefreshes;
    constructor(db: KyselyDB, environmentService: EnvironmentService, domainService: DomainService, registry: IntegrationRegistry, integrationRepo: IntegrationRepo, connectionRepo: IntegrationConnectionRepo, workspaceRepo: WorkspaceRepo, encryptionService: EncryptionService, userRepo: UserRepo, workspaceAbility: WorkspaceAbilityFactory, auditService: IAuditService, redisService: RedisService);
    getAuthorizationUrl(integrationId: string, workspaceId: string, userId: string, returnPathOverride?: string): Promise<{
        authorizationUrl: string;
        type: string;
        nonce: string;
    }>;
    getInstallAuthorizationUrl(type: string, workspaceId: string, userId: string): Promise<{
        authorizationUrl: string;
        nonce: string;
    }>;
    verifySignedState(state: string): OAuthStatePayload | null;
    exchangeCodeForTokens(type: string, code: string, state: Pick<OAuthStatePayload, 'flow' | 'integrationId' | 'type' | 'userId' | 'workspaceId'>): Promise<IntegrationConnection>;
    private assertCanManageWorkspace;
    private completeInstall;
    private completeConnect;
    private storeConnection;
    private resolveAccount;
    private assertAccountNotLinkedElsewhere;
    getValidAccessToken(connection: IntegrationConnection): Promise<string>;
    private refreshForRequest;
    private usableAccessToken;
    refreshAccessToken(connection: IntegrationConnection): Promise<string>;
    private requestTokens;
    private postTokenRequest;
    buildCallbackUrl(type: string): string;
    private stateKey;
    private createSignedState;
    private getClientId;
    private getClientSecret;
    private requireEnv;
}
