import type { Request } from 'express'; import { permissions } from '@balena/pinejs'; export interface ApiKeyOptions { apiKey?: string; name: string | null; description: string | null; expiryDate: string | null; tx?: Tx; } type ApiKeyActor = 'application' | 'device' | 'user'; export declare function getApiKeyOptsFromRequest(params: Dictionary, prefix?: string, mandatoryExpiryDate?: false): Pick; export declare function getApiKeyOptsFromRequest(params: Dictionary, prefix: string | undefined, mandatoryExpiryDate: true): NonNullableField, 'expiryDate'>; export declare function getApiKeyOptsFromRequest(params: Dictionary, prefix?: string, mandatoryExpiryDate?: boolean): Pick; export declare const createApiKey: (actorType: ApiKeyActor, roleName: string, req: Request, actorTypeID: number, options: ApiKeyOptions) => Promise; export declare const createProvisioningApiKey: (req: Request>, actorTypeID: number, options: ApiKeyOptions) => Promise; export declare const createDeviceApiKey: (req: Request>, actorTypeID: number, options: ApiKeyOptions) => Promise; export declare const createNamedUserApiKey: (req: Request>, actorTypeID: number, options: ApiKeyOptions) => Promise; /** * @deprecated this is a legacy api key for very old devices and should not be used any more */ export declare const createUserApiKey: (req: Request>, actorTypeID: number, options: ApiKeyOptions) => Promise; export type ApiKeyParameters = { actorType: (typeof supportedActorTypes)[number]; actorTypeId: number; roles: string[]; } & Pick; export declare const supportedActorTypes: readonly ["application", "user", "device"]; export declare const createGenericApiKey: (req: Request, { actorType, actorTypeId, roles, name, description, expiryDate, apiKey, }: ApiKeyParameters) => Promise; export declare const isApiKeyWithRole: import("../../infra/cache/multi-level-memoizee.js").MemoizedFn<(key: string, roleName: string, tx?: Tx) => Promise>; /** * Temporarily augments the request's api key with the specified permissions. * This will not have any effect if the request is not using an api key */ export declare const augmentReqApiKeyPermissions: (req: T, extraPermissions: string[], /** * When mutateRequestObject is * false: A new request object with augmented permissions is returned to be used for specific tasks, * while the rest of the code (eg: middleware & hooks) still runs with permissions the original request. * true: The permissions are augmented for the whole lifetime of the request. */ mutateRequestObject?: boolean) => T; export {};