diff --git a/package-lock.json b/package-lock.json index 47ca71b..5f8e4fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,9 @@ "": { "version": "0.1.0", "license": "AGPL-3.0-or-later", + "dependencies": { + "valid-url": "^1.0.9" + }, "devDependencies": { "chai": "^4.2.0", "license-check-and-add": "^3.0.4", @@ -1462,6 +1465,11 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "node_modules/valid-url": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", + "integrity": "sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA=" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -2769,6 +2777,11 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "valid-url": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", + "integrity": "sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA=" + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index a571453..5823047 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "version": "0.1.0", "description": "Decentralized OpenPGP Identity Proofs library in node", "main": "src/index.js", - "dependencies": {}, + "dependencies": { + "valid-url": "^1.0.9" + }, "devDependencies": { "chai": "^4.2.0", "license-check-and-add": "^3.0.4", diff --git a/src/index.js b/src/index.js index b562f92..7c80195 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,12 @@ -const verify = (url, fingerprint, opts) => { +const validUrl = require('valid-url') +const serviceprovidersList = require('./serviceproviders').serviceprovidersList +const verify = (uri, fingerprint, opts) => { + if !(validUrl.isUri(uri)) { + throw new Error('The provided URI was not valid') + } } exports.verify = verify exports.serviceproviders = require('./serviceproviders').serviceproviders -exports.serviceprovidersList = require('./serviceproviders').serviceprovidersList +exports.serviceprovidersList = serviceprovidersList