import { UserInfo } from './UserInfo'
import { v4 } from 'uuid';

class UserInfoParser {

    /**
     * 获取用户域信息
     * @param userDomain
     * @param userToken
     */
    parse(kongUserInfoBase64: string): UserInfo {
        if (this.isEmpty(kongUserInfoBase64)) {
            return undefined;
        }
        const jsonString = Buffer.from(kongUserInfoBase64, 'base64').toString()
        return JSON.parse(jsonString)
    }

    private isEmpty(params): boolean {
        return (!params || params.toString().trim().length == 0)
    }
}

export default new UserInfoParser()

