14 lines
416 B
TypeScript
14 lines
416 B
TypeScript
import { createHash } from "node:crypto";
|
|
|
|
export function normalizePairingCode(code: string): string {
|
|
return code.trim().toUpperCase();
|
|
}
|
|
|
|
export function hashPairingCode(code: string): string {
|
|
return createHash("sha256").update(normalizePairingCode(code)).digest("hex");
|
|
}
|
|
|
|
export function isPairingExpired(expiresAt: Date, now: Date = new Date()): boolean {
|
|
return expiresAt.getTime() <= now.getTime();
|
|
}
|