mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-08 02:25:36 +08:00
personal waitlist link
This commit is contained in:
20
server/utils/waitlistReferrals.ts
Normal file
20
server/utils/waitlistReferrals.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { randomBytes } from 'node:crypto'
|
||||
|
||||
export const WAITLIST_REFERRAL_TOKEN_PATTERN = /^[A-F0-9]{8}$/
|
||||
|
||||
export function generateWaitlistReferralToken() {
|
||||
return randomBytes(4).toString('hex').toUpperCase()
|
||||
}
|
||||
|
||||
export function normalizeWaitlistReferralToken(value?: unknown) {
|
||||
if (typeof value !== 'string') {
|
||||
return null
|
||||
}
|
||||
|
||||
const token = value.trim().toUpperCase()
|
||||
if (!WAITLIST_REFERRAL_TOKEN_PATTERN.test(token)) {
|
||||
return null
|
||||
}
|
||||
|
||||
return token
|
||||
}
|
||||
Reference in New Issue
Block a user