From a2b4f76c94e7fda3f122adf721e0a12d9a0e9164 Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Thu, 12 Sep 2024 09:51:20 -0400 Subject: [PATCH] Remove package `@resin.io/valid-email` Change-type: patch --- npm-shrinkwrap.json | 9 --------- package.json | 1 - src/utils/validation.ts | 9 ++++++--- typings/resin.io/index.d.ts | 18 ------------------ 4 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 typings/resin.io/index.d.ts diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e7dc62fe3b..282dd056e0 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -15,7 +15,6 @@ "@balena/env-parsing": "^1.1.8", "@balena/es-version": "^1.0.1", "@oclif/core": "^4.0.8", - "@resin.io/valid-email": "^0.1.0", "@sentry/node": "^6.16.1", "balena-config-json": "^4.2.0", "balena-device-init": "^7.0.1", @@ -2562,14 +2561,6 @@ "resolved": "https://registry.npmjs.org/@resin.io/types-home-or-tmp/-/types-home-or-tmp-3.0.0.tgz", "integrity": "sha1-PsiRM0Nv7msb7jkC8fluJgXXnU0=" }, - "node_modules/@resin.io/valid-email": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@resin.io/valid-email/-/valid-email-0.1.0.tgz", - "integrity": "sha1-DnUwmoQ8AUqAqhSC+WmQYvL6UV0=", - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/@ronomon/direct-io": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@ronomon/direct-io/-/direct-io-3.0.1.tgz", diff --git a/package.json b/package.json index ac2813040f..acad6a23a8 100644 --- a/package.json +++ b/package.json @@ -196,7 +196,6 @@ "@balena/env-parsing": "^1.1.8", "@balena/es-version": "^1.0.1", "@oclif/core": "^4.0.8", - "@resin.io/valid-email": "^0.1.0", "@sentry/node": "^6.16.1", "balena-config-json": "^4.2.0", "balena-device-init": "^7.0.1", diff --git a/src/utils/validation.ts b/src/utils/validation.ts index 891ec39bd2..4f2af76ba2 100644 --- a/src/utils/validation.ts +++ b/src/utils/validation.ts @@ -13,10 +13,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - -import validEmail = require('@resin.io/valid-email'); import { ExpectedError } from '../errors'; +// Sufficiently good email regex in order not to bring in another dependency. +const isValidEmail = (email: string): boolean => { + return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); +}; + const APPNAME_REGEX = new RegExp(/^[a-zA-Z0-9_-]+$/); // An regex to detect an IP address, from https://www.regular-expressions.info/ip.html const IP_REGEX = new RegExp( @@ -26,7 +29,7 @@ const DOTLOCAL_REGEX = new RegExp(/^([a-zA-Z0-9-]+\.)+local$/); const UUID_REGEX = new RegExp(/^[0-9a-f]+$/); export function validateEmail(input: string) { - if (!validEmail(input)) { + if (!isValidEmail(input)) { return 'Email is not valid'; } diff --git a/typings/resin.io/index.d.ts b/typings/resin.io/index.d.ts deleted file mode 100644 index 919313fdb8..0000000000 --- a/typings/resin.io/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * Copyright 2019 Balena Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -declare module '@resin.io/valid-email';