|
|
@ -2,9 +2,7 @@ import chalk from 'chalk'; |
|
|
|
import fetch from 'node-fetch'; |
|
|
|
import * as cfg from './cfg'; |
|
|
|
import { stringify as stringifyQuery } from 'querystring'; |
|
|
|
import _emailRegex from 'email-regex'; |
|
|
|
|
|
|
|
const emailRegex = _emailRegex({ exact: true }); |
|
|
|
import { validate } from 'email-validator'; |
|
|
|
|
|
|
|
function readEmail ({ invalid = false } = {}) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
@ -61,7 +59,7 @@ function sleep (ms) { |
|
|
|
|
|
|
|
async function register (url, { retryEmail = false } = {}) { |
|
|
|
const email = await readEmail({ invalid: retryEmail }); |
|
|
|
if (!emailRegex.test(email)) return register(url, { retryEmail: true }); |
|
|
|
if (!validate(email)) return register(url, { retryEmail: true }); |
|
|
|
|
|
|
|
const verificationToken = await getVerificationToken(url, email); |
|
|
|
|
|
|
|