import type { CreateCredentialDto } from '@n8n/api-types';
import { Logger } from '@n8n/backend-common';
import { CredentialsEntity, SharedCredentials, CredentialsRepository, ProjectRepository, SharedCredentialsRepository, UserRepository } from '@n8n/db';
import type { User, ICredentialsDb } from '@n8n/db';
import { type Scope } from '@n8n/permissions';
import { type EntityManager, type FindOptionsRelations } from '@n8n/typeorm';
import { ErrorReporter } from 'n8n-core';
import type { ICredentialDataDecryptedObject, ICredentialsDecrypted, INodeProperties } from 'n8n-workflow';
import { CredentialTypes } from '../credential-types';
import { CredentialsHelper } from '../credentials-helper';
import { ExternalHooks } from '../external-hooks';
import { ExternalSecretsConfig } from '../modules/external-secrets.ee/external-secrets.config';
import { SecretsProviderAccessCheckService } from '../modules/external-secrets.ee/secret-provider-access-check.service.ee';
import type { CredentialRequest, ListQuery } from '../requests';
import { CredentialsTester } from '../services/credentials-tester.service';
import { OwnershipService } from '../services/ownership.service';
import { ProjectService } from '../services/project.service.ee';
import { RoleService } from '../services/role.service';
import { CredentialDependencyService } from './credential-dependency.service';
import { CredentialsFinderService } from './credentials-finder.service';
export type CredentialsGetSharedOptions = {
    allowGlobalScope: true;
    globalScope: Scope;
} | {
    allowGlobalScope: false;
};
export declare class CredentialsService {
    private readonly credentialsRepository;
    private readonly credentialDependencyService;
    private readonly sharedCredentialsRepository;
    private readonly ownershipService;
    private readonly logger;
    private readonly errorReporter;
    private readonly credentialsTester;
    private readonly externalHooks;
    private readonly credentialTypes;
    private readonly projectRepository;
    private readonly projectService;
    private readonly roleService;
    private readonly userRepository;
    private readonly credentialsFinderService;
    private readonly credentialsHelper;
    private readonly externalSecretsConfig;
    private readonly externalSecretsProviderAccessCheckService;
    constructor(credentialsRepository: CredentialsRepository, credentialDependencyService: CredentialDependencyService, sharedCredentialsRepository: SharedCredentialsRepository, ownershipService: OwnershipService, logger: Logger, errorReporter: ErrorReporter, credentialsTester: CredentialsTester, externalHooks: ExternalHooks, credentialTypes: CredentialTypes, projectRepository: ProjectRepository, projectService: ProjectService, roleService: RoleService, userRepository: UserRepository, credentialsFinderService: CredentialsFinderService, credentialsHelper: CredentialsHelper, externalSecretsConfig: ExternalSecretsConfig, externalSecretsProviderAccessCheckService: SecretsProviderAccessCheckService);
    private addGlobalCredentials;
    getMany(user: User, options: {
        listQueryOptions?: ListQuery.Options;
        includeScopes?: boolean;
        includeData: true;
        onlySharedWithMe?: boolean;
        includeGlobal?: boolean;
        filters?: {
            externalSecretsStore?: string;
        };
    }): Promise<Array<ICredentialsDecrypted<ICredentialDataDecryptedObject>>>;
    getMany(user: User, options?: {
        listQueryOptions?: ListQuery.Options;
        includeScopes?: boolean;
        includeData?: boolean;
        onlySharedWithMe?: boolean;
        includeGlobal?: boolean;
        filters?: {
            externalSecretsStore?: string;
        };
    }): Promise<CredentialsEntity[]>;
    private getManyForAdminUser;
    private getManyForMemberUser;
    private applyPersonalProjectFilter;
    private enrichCredentials;
    private populateSharedRelations;
    private addScopesToCredentials;
    private addDecryptedDataToCredentials;
    getCredentialsAUserCanUseInAWorkflow(user: User, options: {
        workflowId: string;
    } | {
        projectId: string;
    }): Promise<{
        id: string;
        name: string;
        type: string;
        scopes: Scope[];
        isManaged: boolean;
        isGlobal: boolean;
        isResolvable: boolean;
    }[]>;
    findAllGlobalCredentialIds(includeData?: boolean): Promise<CredentialsEntity[]>;
    findAllCredentialIdsForWorkflow(workflowId: string): Promise<CredentialsEntity[]>;
    findAllCredentialIdsForProject(projectId: string): Promise<CredentialsEntity[]>;
    getSharing(user: User, credentialId: string, globalScopes: Scope[], relations?: FindOptionsRelations<SharedCredentials>): Promise<SharedCredentials | null>;
    prepareUpdateData(user: User, data: CredentialRequest.CredentialProperties, existingCredential: CredentialsEntity): Promise<CredentialsEntity>;
    createEncryptedData(credential: {
        id: string | null;
        name: string;
        type: string;
        data: ICredentialDataDecryptedObject;
    }): ICredentialsDb;
    decrypt(credential: CredentialsEntity, includeRawData?: boolean): ICredentialDataDecryptedObject;
    update(credentialId: string, newCredentialData: ICredentialsDb, decryptedCredentialData?: ICredentialDataDecryptedObject): Promise<CredentialsEntity | null>;
    private resolveOwningProjectIdForNewCredential;
    save(credential: CredentialsEntity, encryptedData: ICredentialsDb, user: User, projectId: string, decryptedCredentialData?: ICredentialDataDecryptedObject): Promise<CredentialsEntity>;
    delete(user: User, credentialId: string): Promise<void>;
    test(userId: User['id'], credentials: ICredentialsDecrypted): Promise<import("n8n-workflow").INodeCredentialTestResult>;
    redact(data: ICredentialDataDecryptedObject, credential: CredentialsEntity): ICredentialDataDecryptedObject;
    private redactValues;
    private redactCollectionOption;
    private redactJsonLeaves;
    private mergeRedactedJsonLeaves;
    private unredactRestoreValues;
    getCredentialTypeProperties(credentialType: string): INodeProperties[];
    unredact(redactedData: ICredentialDataDecryptedObject, savedData: ICredentialDataDecryptedObject, props?: INodeProperties[]): ICredentialDataDecryptedObject;
    getOne(user: User, credentialId: string, includeDecryptedData: boolean): Promise<{
        name: string;
        type: string;
        shared: SharedCredentials[];
        isManaged: boolean;
        isGlobal: boolean;
        isResolvable: boolean;
        resolvableAllowFallback: boolean;
        resolverId: string | null;
        id: string;
        generateId(): void;
        createdAt: Date;
        updatedAt: Date;
        setUpdateDate(): void;
        data: ICredentialDataDecryptedObject;
    } | {
        name: string;
        type: string;
        shared: SharedCredentials[];
        isManaged: boolean;
        isGlobal: boolean;
        isResolvable: boolean;
        resolvableAllowFallback: boolean;
        resolverId: string | null;
        id: string;
        generateId(): void;
        createdAt: Date;
        updatedAt: Date;
        setUpdateDate(): void;
    }>;
    getCredentialScopes(user: User, credentialId: string): Promise<Scope[]>;
    transferAll(fromProjectId: string, toProjectId: string, trx?: EntityManager): Promise<void>;
    replaceCredentialContentsForSharee(user: User, credential: CredentialsEntity, decryptedData: ICredentialDataDecryptedObject, mergedCredentials: ICredentialsDecrypted): Promise<void>;
    createUnmanagedCredential(dto: CreateCredentialDto, user: User): Promise<{
        scopes: Scope[];
        name: string;
        data: string;
        type: string;
        isManaged: boolean;
        isGlobal: boolean;
        isResolvable: boolean;
        resolvableAllowFallback: boolean;
        resolverId: string | null;
        id: string;
        generateId(): void;
        createdAt: Date;
        updatedAt: Date;
        setUpdateDate(): void;
    }>;
    checkCredentialData(type: string, data: ICredentialDataDecryptedObject, user: User, projectId: string): Promise<void>;
    private validateOAuthCredentialUrls;
    createManagedCredential(dto: CreateCredentialDto, user: User): Promise<{
        scopes: Scope[];
        name: string;
        data: string;
        type: string;
        isManaged: boolean;
        isGlobal: boolean;
        isResolvable: boolean;
        resolvableAllowFallback: boolean;
        resolverId: string | null;
        id: string;
        generateId(): void;
        createdAt: Date;
        updatedAt: Date;
        setUpdateDate(): void;
    }>;
    private createCredential;
}
