feat: add isSyntheticEmail utility for detecting synthetic OAuth emails
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isSyntheticEmail } from '../is-synthetic-email'
|
||||
|
||||
describe('isSyntheticEmail', () => {
|
||||
it('returns true for vk.local domain', () => {
|
||||
expect(isSyntheticEmail('vk_12345@vk.local')).toBe(true)
|
||||
})
|
||||
|
||||
it('returns false for real email', () => {
|
||||
expect(isSyntheticEmail('user@gmail.com')).toBe(false)
|
||||
})
|
||||
|
||||
it('returns false for yandex email', () => {
|
||||
expect(isSyntheticEmail('user@yandex.ru')).toBe(false)
|
||||
})
|
||||
|
||||
it('returns false for empty string', () => {
|
||||
expect(isSyntheticEmail('')).toBe(false)
|
||||
})
|
||||
|
||||
it('returns false for email with vk.local as part of username', () => {
|
||||
expect(isSyntheticEmail('vk.local@gmail.com')).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
const SYNTHETIC_DOMAINS = ['vk.local']
|
||||
|
||||
export function isSyntheticEmail(email: string): boolean {
|
||||
return SYNTHETIC_DOMAINS.some((domain) => email.endsWith(`@${domain}`))
|
||||
}
|
||||
Reference in New Issue
Block a user