/// <reference types="koa-bodyparser" />
import Application from "koa";
import { RouterContext } from "koa-router";
export declare class Token {
    private secret;
    private accessExp;
    private refreshExp;
    constructor(secret?: string, accessExp?: number, refreshExp?: number);
    /**
     * initApp
     */
    initApp(app: Application, secret?: string, accessExp?: number, refreshExp?: number): void;
    /**
     * 生成access_token
     * @param identity 标识位
     */
    createAccessToken(identity: string | number): string;
    /**
     * 生成refresh_token
     * @param identity 标识位
     */
    createRefreshToken(identity: string | number): string;
    /**
     * verifyToken 验证token
     * 若过期，抛出ExpiredTokenException
     * 若失效，抛出InvalidTokenException
     */
    verifyToken(token: string): any;
}
/**
 * jwt 的实例
 */
declare const jwt: Token;
/**
 * 颁发令牌
 * @param user 用户
 */
declare function getTokens(user: any): {
    accessToken: string;
    refreshToken: string;
};
/**
 * 守卫函数，用户登陆即可访问
 */
declare function loginRequired(ctx: RouterContext, next: () => Promise<any>): Promise<void>;
/**
 * 守卫函数，用户刷新令牌
 */
declare function refreshTokenRequired(ctx: RouterContext, next: () => Promise<any>): Promise<void>;
/**
 * 守卫函数，用于权限组鉴权
 */
declare function groupRequired(ctx: RouterContext, next: () => Promise<any>): Promise<void>;
/**
 * 守卫函数，非超级管理员不可访问
 */
declare function adminRequired(ctx: RouterContext, next: () => Promise<any>): Promise<void>;
export { jwt, getTokens, loginRequired, groupRequired, adminRequired, refreshTokenRequired };
