import { JSONObject } from "kuzzle-sdk"; import { Token } from "../../model/security/token"; import { User } from "../../model/security/user"; import { ObjectRepository } from "../shared/ObjectRepository"; export declare class TokenRepository extends ObjectRepository { private tokenGracePeriod; private anonymousToken; constructor(opts?: JSONObject); init(): Promise; /** * Expires the given token immediately */ expire(token: Token): Promise; /** * We allow a grace period before expiring the token to allow * queued requests to execute, but we mark the token as "refreshed" to forbid * any refreshes on that token, to prevent token bombing * * @param user * @param requestToken * @param expiresIn - new token expiration delay */ refresh(user: User, token: Token, expiresIn: string): Promise; /** * @param user * @param options - { algorithm, expiresIn, bypassMaxTTL (false), type (authToken) } * * @returns {Promise.} { _id, jwt, userId, ttl, expiresAt } */ generateToken(user: User, { algorithm, expiresIn, bypassMaxTTL, type, singleUse, }?: { algorithm?: string; expiresIn?: string; bypassMaxTTL?: boolean; type?: string; singleUse?: boolean; }): Promise; /** * Persists a token in the cache * * @param encodedToken - Encoded token * @param userId - User ID * @param ttl - TTL in ms (-1 for infinite duration) */ persistForUser(encodedToken: string, userId: string, { ttl, singleUse, }: { ttl: number; singleUse: boolean; }): Promise; verifyToken(token: string): Promise; _verifyApiKey(decoded: any, token: string): Promise; removeTokenPrefix(token: string): string; loadForUser(userId: string, encodedToken: string): Promise; hydrate(userToken: any, data: any): Promise; serializeToDatabase(token: any): any; /** * Deletes tokens affiliated to the provided user identifier */ deleteByKuid(kuid: string, { keepApiKeys }?: { keepApiKeys?: boolean; }): Promise; /** * The repository main class refreshes automatically the TTL * of accessed entries, letting only unaccessed entries expire * * But tokens' TTL must remain the same than their expiration time, * refreshing a token entry has no meaning. * * So we need to override the TTL auto-refresh function to disable it */ refreshCacheTTL(): Promise; }