15 lines
436 B
JavaScript
15 lines
436 B
JavaScript
import { createHash } from 'node:crypto';
|
|
|
|
export function stableVeraeUserId(username) {
|
|
const n = String(username || '')
|
|
.trim()
|
|
.toLowerCase();
|
|
return `vu_${createHash('sha256').update(n).digest('hex').slice(0, 16)}`;
|
|
}
|
|
|
|
export function bindEmail(email) {
|
|
const veraeUsername = String(email || '')
|
|
.trim()
|
|
.toLowerCase();
|
|
return { veraeUserId: stableVeraeUserId(veraeUsername), veraeUsername, bound: true };
|
|
}
|