feat: migrate to validator from email-validator (#2059)
* refactor(adds package): this adds the validator package and removes email-validator from dependencys * refactor(auth.ts and email.ts): migrates from EmailValidator to validator
This commit is contained in:
@@ -60,7 +60,6 @@
|
||||
"dayjs": "1.11.7",
|
||||
"dns-caching": "^0.2.7",
|
||||
"email-templates": "12.0.1",
|
||||
"email-validator": "2.0.4",
|
||||
"express": "4.21.2",
|
||||
"express-openapi-validator": "4.13.8",
|
||||
"express-rate-limit": "6.7.0",
|
||||
@@ -107,6 +106,7 @@
|
||||
"typeorm": "0.3.12",
|
||||
"ua-parser-js": "^1.0.35",
|
||||
"undici": "^7.3.0",
|
||||
"validator": "^13.15.15",
|
||||
"web-push": "3.5.0",
|
||||
"wink-jaro-distance": "^2.0.0",
|
||||
"winston": "3.8.2",
|
||||
@@ -140,6 +140,7 @@
|
||||
"@types/secure-random-password": "0.2.1",
|
||||
"@types/semver": "7.3.13",
|
||||
"@types/swagger-ui-express": "4.1.3",
|
||||
"@types/validator": "^13.15.3",
|
||||
"@types/web-push": "3.3.2",
|
||||
"@types/xml2js": "0.4.11",
|
||||
"@types/yamljs": "0.2.31",
|
||||
|
||||
26
pnpm-lock.yaml
generated
26
pnpm-lock.yaml
generated
@@ -89,9 +89,6 @@ importers:
|
||||
email-templates:
|
||||
specifier: 12.0.1
|
||||
version: 12.0.1(@babel/core@7.24.7)(encoding@0.1.13)(handlebars@4.7.8)(mustache@4.2.0)(pug@3.0.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(underscore@1.13.7)
|
||||
email-validator:
|
||||
specifier: 2.0.4
|
||||
version: 2.0.4
|
||||
express:
|
||||
specifier: 4.21.2
|
||||
version: 4.21.2
|
||||
@@ -230,6 +227,9 @@ importers:
|
||||
undici:
|
||||
specifier: ^7.3.0
|
||||
version: 7.3.0
|
||||
validator:
|
||||
specifier: ^13.15.15
|
||||
version: 13.15.15
|
||||
web-push:
|
||||
specifier: 3.5.0
|
||||
version: 3.5.0
|
||||
@@ -324,6 +324,9 @@ importers:
|
||||
'@types/swagger-ui-express':
|
||||
specifier: 4.1.3
|
||||
version: 4.1.3
|
||||
'@types/validator':
|
||||
specifier: ^13.15.3
|
||||
version: 13.15.3
|
||||
'@types/web-push':
|
||||
specifier: 3.3.2
|
||||
version: 3.3.2
|
||||
@@ -3340,6 +3343,9 @@ packages:
|
||||
'@types/unist@2.0.10':
|
||||
resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==}
|
||||
|
||||
'@types/validator@13.15.3':
|
||||
resolution: {integrity: sha512-7bcUmDyS6PN3EuD9SlGGOxM77F8WLVsrwkxyWxKnxzmXoequ6c7741QBrANq6htVRGOITJ7z72mTP6Z4XyuG+Q==}
|
||||
|
||||
'@types/web-push@3.3.2':
|
||||
resolution: {integrity: sha512-JxWGVL/m7mWTIg4mRYO+A6s0jPmBkr4iJr39DqJpRJAc+jrPiEe1/asmkwerzRon8ZZDxaZJpsxpv0Z18Wo9gw==}
|
||||
|
||||
@@ -4735,10 +4741,6 @@ packages:
|
||||
resolution: {integrity: sha512-849pjBFVUAWWTa3HqhDjxlXHaSWmxf4CZOlZ9iVkrSAbQ8YCYi+7KiKqt35L6F20WhSViWX7lmMjno6zBv2rNQ==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
email-validator@2.0.4:
|
||||
resolution: {integrity: sha512-gYCwo7kh5S3IDyZPLZf6hSS0MnZT8QmJFqYvbqlDZSbwdZlY6QZWxJ4i/6UhITOJ4XzyI647Bm2MXKCLqnJ4nQ==}
|
||||
engines: {node: '>4.0'}
|
||||
|
||||
emoji-regex@10.3.0:
|
||||
resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==}
|
||||
|
||||
@@ -9049,6 +9051,10 @@ packages:
|
||||
validate-npm-package-license@3.0.4:
|
||||
resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==}
|
||||
|
||||
validator@13.15.15:
|
||||
resolution: {integrity: sha512-BgWVbCI72aIQy937xbawcs+hrVaN/CZ2UwutgaJ36hGqRrLNM+f5LUT/YPRbo8IV/ASeFzXszezV+y2+rq3l8A==}
|
||||
engines: {node: '>= 0.10'}
|
||||
|
||||
vary@1.1.2:
|
||||
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
@@ -13256,6 +13262,8 @@ snapshots:
|
||||
|
||||
'@types/unist@2.0.10': {}
|
||||
|
||||
'@types/validator@13.15.3': {}
|
||||
|
||||
'@types/web-push@3.3.2':
|
||||
dependencies:
|
||||
'@types/node': 22.10.5
|
||||
@@ -14937,8 +14945,6 @@ snapshots:
|
||||
- walrus
|
||||
- whiskers
|
||||
|
||||
email-validator@2.0.4: {}
|
||||
|
||||
emoji-regex@10.3.0: {}
|
||||
|
||||
emoji-regex@8.0.0: {}
|
||||
@@ -20048,6 +20054,8 @@ snapshots:
|
||||
spdx-correct: 3.2.0
|
||||
spdx-expression-parse: 3.0.1
|
||||
|
||||
validator@13.15.15: {}
|
||||
|
||||
vary@1.1.2: {}
|
||||
|
||||
verror@1.10.0:
|
||||
|
||||
@@ -7,8 +7,8 @@ import type { NotificationAgentEmail } from '@server/lib/settings';
|
||||
import { getSettings, NotificationAgentKey } from '@server/lib/settings';
|
||||
import logger from '@server/logger';
|
||||
import type { EmailOptions } from 'email-templates';
|
||||
import * as EmailValidator from 'email-validator';
|
||||
import path from 'path';
|
||||
import validator from 'validator';
|
||||
import { Notification, shouldSendAdminNotification } from '..';
|
||||
import type { NotificationAgent, NotificationPayload } from './agent';
|
||||
import { BaseAgent } from './agent';
|
||||
@@ -221,7 +221,7 @@ class EmailAgent
|
||||
this.getSettings(),
|
||||
payload.notifyUser.settings?.pgpKey
|
||||
);
|
||||
if (EmailValidator.validate(payload.notifyUser.email)) {
|
||||
if (validator.isEmail(payload.notifyUser.email)) {
|
||||
await email.send(
|
||||
this.buildMessage(
|
||||
type,
|
||||
@@ -283,7 +283,7 @@ class EmailAgent
|
||||
this.getSettings(),
|
||||
user.settings?.pgpKey
|
||||
);
|
||||
if (EmailValidator.validate(user.email)) {
|
||||
if (validator.isEmail(user.email)) {
|
||||
await email.send(
|
||||
this.buildMessage(type, payload, user.email, user.displayName)
|
||||
);
|
||||
|
||||
@@ -15,9 +15,9 @@ import { ApiError } from '@server/types/error';
|
||||
import { getAppVersion } from '@server/utils/appVersion';
|
||||
import { getHostname } from '@server/utils/getHostname';
|
||||
import axios from 'axios';
|
||||
import * as EmailValidator from 'email-validator';
|
||||
import { Router } from 'express';
|
||||
import net from 'net';
|
||||
import validator from 'validator';
|
||||
|
||||
const authRoutes = Router();
|
||||
|
||||
@@ -37,7 +37,7 @@ authRoutes.get('/me', isAuthenticated(), async (req, res) => {
|
||||
const settings = await getSettings();
|
||||
if (
|
||||
settings.notifications.agents.email.options.userEmailRequired &&
|
||||
!EmailValidator.validate(user.email)
|
||||
!validator.isEmail(user.email)
|
||||
) {
|
||||
user.warnings.push('userEmailRequired');
|
||||
logger.warn(`User ${user.username} has no valid email address`);
|
||||
|
||||
Reference in New Issue
Block a user