@point3/logto-module
Version:
포인트3 내부 logto Authentication 모듈입니다
49 lines (41 loc) • 1.1 kB
text/typescript
export class AccessToken {
static THRESHOLD_TIME = 1000 * 60 * 10; // 10분
accountId: string;
token: string;
expiresAt: Date;
constructor(accountId: string, token: string, expireInSeconds: number) {
this.accountId = accountId;
this.token = token;
this.expiresAt = new Date(
Date.now() + expireInSeconds * 1000 - AccessToken.THRESHOLD_TIME,
);
}
public isExpired(): boolean {
return this.expiresAt < new Date();
}
public toString(): string {
return `AccessToken{accountId: ${this.accountId}, expiresAt: ${this.expiresAt}}`;
}
}
export type AccessTokenPayload = {
jti: string;
sub: string;
iat: number;
exp: number;
scope: string;
client_id: string;
iss: string;
aud: string;
userRoles: string[];
clientId: string; // 이게 진짜임 ;;
managerId: string;
userScopes?: string[];
};
export type IdTokenPayload = {
sub: string;
email: string;
email_verified: boolean;
name: string;
phone_number: string;
username: string;
};