UNPKG

@n8n-plus/n8n-plus

Version:

n8n Workflow Automation Tool (plus edition)

46 lines (45 loc) 2.53 kB
import type { CreateApiKeyRequestDto, UpdateApiKeyRequestDto } from '@n8n/api-types'; import type { AuthenticatedRequest, User } from '@n8n/db'; import { ApiKey, ApiKeyRepository, UserRepository } from '@n8n/db'; import type { ApiKeyScope, AuthPrincipal } from '@n8n/permissions'; import type { EntityManager } from '@n8n/typeorm'; import type { NextFunction, Request, Response } from 'express'; import type { OpenAPIV3 } from 'openapi-types'; import { JwtService } from './jwt.service'; import { LastActiveAtService } from './last-active-at.service'; import { EventService } from '../events/event.service'; export declare class PublicApiKeyService { private readonly apiKeyRepository; private readonly userRepository; private readonly jwtService; private readonly eventService; private readonly lastActiveAtService; constructor(apiKeyRepository: ApiKeyRepository, userRepository: UserRepository, jwtService: JwtService, eventService: EventService, lastActiveAtService: LastActiveAtService); createPublicApiKeyForUser(user: User, { label, expiresAt, scopes }: CreateApiKeyRequestDto): Promise<ApiKey>; getRedactedApiKeysForUser(user: User): Promise<{ apiKey: string; expiresAt: number | null; user: User; userId: string; label: string; scopes: ApiKeyScope[]; audience: import("n8n-workflow").ApiKeyAudience; id: string; generateId(): void; createdAt: Date; updatedAt: Date; setUpdateDate(): void; }[]>; deleteApiKeyForUser(user: User, apiKeyId: string): Promise<void>; deleteAllApiKeysForUser(user: User, tx?: EntityManager): Promise<import("@n8n/typeorm").DeleteResult[]>; updateApiKeyForUser(user: User, apiKeyId: string, { label, scopes }: UpdateApiKeyRequestDto): Promise<void>; private getUserForApiKey; redactApiKey(apiKey: string): string; getAuthMiddleware(version: string): (req: AuthenticatedRequest, _scopes: unknown, schema: OpenAPIV3.ApiKeySecurityScheme) => Promise<boolean>; private generateApiKey; private getApiKeyExpiration; apiKeyHasValidScopesForRole(role: AuthPrincipal, apiKeyScopes: ApiKeyScope[]): boolean; apiKeyHasValidScopes(apiKey: string, endpointScope: ApiKeyScope): Promise<boolean>; getApiKeyScopeMiddleware(endpointScope: ApiKeyScope): (req: Request, res: Response, next: NextFunction) => Promise<void>; removeOwnerOnlyScopesFromApiKeys(user: User, tx?: EntityManager): Promise<import("@n8n/typeorm").UpdateResult[]>; }