UNPKG

@restnfeel/agentc-starter-kit

Version:

한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템

50 lines (42 loc) 1.24 kB
import { UserRole } from "./roles"; export interface InviteTokenPayload { email: string; role: UserRole; siteIds?: string[]; invitedBy: string; expiresAt: Date; } export function generateInviteToken(payload: InviteTokenPayload): string { // In a real implementation, this would use JWT or a secure token generation library // For now, we'll create a simple base64 encoded token const tokenData = { ...payload, timestamp: Date.now(), type: "invitation", }; return Buffer.from(JSON.stringify(tokenData)).toString("base64"); } export function verifyInviteToken(token: string): InviteTokenPayload | null { try { const decoded = Buffer.from(token, "base64").toString("utf-8"); const tokenData = JSON.parse(decoded); if (tokenData.type !== "invitation") { return null; } // Check if token has expired const expiresAt = new Date(tokenData.expiresAt); if (expiresAt < new Date()) { return null; } return { email: tokenData.email, role: tokenData.role, siteIds: tokenData.siteIds, invitedBy: tokenData.invitedBy, expiresAt, }; } catch (error) { console.error("Token verification error:", error); return null; } }