/*! * @package @coolgk/utils * @version 3.1.4 * @link https://github.com/coolgk/node-utils * @license MIT * @author Daniel Gong * * Copyright (c) 2017 Daniel Gong . All rights reserved. * Licensed under the MIT License. */ /*! * Copyright (c) 2017 Daniel Gong . All rights reserved. * Licensed under the MIT License. */ import { Cache, ICacheClient } from '@coolgk/cache'; export interface IConfig { readonly token: string; readonly expiry?: number; readonly prefix?: string; } export interface ITokenConfigWithCache extends IConfig { readonly cache: Cache; } export interface ITokenConfig extends IConfig { readonly redisClient: ICacheClient; } export interface ITokenValues { [field: string]: any; } export { ICacheClient as IRedisClient }; export declare const DEFAULT_PREFIX = "token"; export declare enum TokenError { INVALID_TOKEN = "INVALID_TOKEN", RESERVED_NAME = "RESERVED_NAME", EXPIRED_TOKEN = "EXPIRED_TOKEN", } export declare class Token { private _token; private _cache; private _expiry; private _name; private _prefix; constructor(options: ITokenConfig | ITokenConfigWithCache); renew(expiry?: number): Promise; set(name: string, value: any): Promise; verify(): Promise; get(name: string): Promise; destroy(): Promise; delete(name: string): Promise; getAll(): Promise; setToken(token: string): void; } export default Token;