From a44b655ba54c5606e46f9daafe86a15f906d7f1e Mon Sep 17 00:00:00 2001 From: Delivator Date: Wed, 14 Oct 2020 11:50:47 +0200 Subject: [PATCH 1/3] Installed punycode npm package --- packages/handshake-api/package-lock.json | 13 +++++++++++++ packages/handshake-api/package.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 packages/handshake-api/package-lock.json diff --git a/packages/handshake-api/package-lock.json b/packages/handshake-api/package-lock.json new file mode 100644 index 00000000..482f1d1f --- /dev/null +++ b/packages/handshake-api/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "handshake-api", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + } + } +} diff --git a/packages/handshake-api/package.json b/packages/handshake-api/package.json index d8db7d3f..1bd71cb3 100644 --- a/packages/handshake-api/package.json +++ b/packages/handshake-api/package.json @@ -6,7 +6,8 @@ "dependencies": { "express": "^4.17.1", "hs-client": "^0.0.9", - "node-cache": "^5.1.2" + "node-cache": "^5.1.2", + "punycode": "^2.1.1" }, "devDependencies": { "prettier": "^2.0.5" From a2265cdd79e6fabf14268cc077f755e249decabb Mon Sep 17 00:00:00 2001 From: Delivator Date: Wed, 14 Oct 2020 12:55:28 +0200 Subject: [PATCH 2/3] Converting hns domain to punycode (Fix for #458) --- packages/handshake-api/src/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/handshake-api/src/index.js b/packages/handshake-api/src/index.js index 72aa2234..8aedab06 100644 --- a/packages/handshake-api/src/index.js +++ b/packages/handshake-api/src/index.js @@ -1,4 +1,5 @@ const express = require("express"); +const punycode = require("punycode"); const NodeCache = require("node-cache"); const { NodeClient } = require("hs-client"); @@ -51,11 +52,12 @@ const getSkylinkFromRecord = (record) => { const resolveDomainHandler = async (req, res) => { try { - const records = await getDomainRecords(req.params.name); - if (!records) return res.status(404).send(`No records found for ${req.params.name}`); + const domain = punycode.toASCII(req.params.name); + const records = await getDomainRecords(domain); + if (!records) return res.status(404).send(`No records found for ${domain}`); const record = findSkylinkRecord(records); - if (!record) throw new Error(`No skylink found in dns records of ${req.params.name}`); + if (!record) throw new Error(`No skylink found in dns records of ${domain}`); const skylink = getSkylinkFromRecord(record); return res.json({ skylink }); From 3e1bf51c0b27f59203487564dca8d4b382b692e0 Mon Sep 17 00:00:00 2001 From: Delivator Date: Wed, 14 Oct 2020 14:21:35 +0200 Subject: [PATCH 3/3] Added punycode via yarn, removed npm package-lock --- packages/handshake-api/package-lock.json | 13 ------------- yarn.lock | 19 +------------------ 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 packages/handshake-api/package-lock.json diff --git a/packages/handshake-api/package-lock.json b/packages/handshake-api/package-lock.json deleted file mode 100644 index 482f1d1f..00000000 --- a/packages/handshake-api/package-lock.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "handshake-api", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - } - } -} diff --git a/yarn.lock b/yarn.lock index 51eed310..d7ab72ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5734,24 +5734,7 @@ eslint-plugin-react-hooks@^1.7.0: resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04" integrity sha512-iXTCFcOmlWvw4+TOE8CLWj6yX1GwzT0Y6cUfHHZqWnSk144VmVIRcVGtUAzrLES7C798lmvnt02C7rxaOX1HNA== -eslint-plugin-react@7.20.6: - version "7.20.6" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.20.6.tgz#4d7845311a93c463493ccfa0a19c9c5d0fd69f60" - integrity sha512-kidMTE5HAEBSLu23CUDvj8dc3LdBU0ri1scwHBZjI41oDv4tjsWZKU7MQccFzH1QYPYhsnTF2ovh7JlcIcmxgg== - dependencies: - array-includes "^3.1.1" - array.prototype.flatmap "^1.2.3" - doctrine "^2.1.0" - has "^1.0.3" - jsx-ast-utils "^2.4.1" - object.entries "^1.1.2" - object.fromentries "^2.0.2" - object.values "^1.1.1" - prop-types "^15.7.2" - resolve "^1.17.0" - string.prototype.matchall "^4.0.2" - -eslint-plugin-react@^7.20.6: +eslint-plugin-react@7.21.4, eslint-plugin-react@^7.20.6: version "7.21.4" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.21.4.tgz#31060b2e5ff82b12e24a3cc33edb7d12f904775c" integrity sha512-uHeQ8A0hg0ltNDXFu3qSfFqTNPXm1XithH6/SY318UX76CMj7Q599qWpgmMhVQyvhq36pm7qvoN3pb6/3jsTFg==