From 6a961b54cea93e88751519c3de0d9ea1a8d53377 Mon Sep 17 00:00:00 2001 From: Eli Frigo <4386738+EliTheCoder@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:17:24 -0600 Subject: [PATCH] fix: use userland module for `punycode` (#1596) * Use userland module for punycode The slash at the end is necessary to use the userland module * fix: Add @types/punycode as dev dependency --------- Co-authored-by: Eli Frigo --- package-lock.json | 13 +++++++++++++ package.json | 1 + src/connector.ts | 2 +- src/sender.ts | 2 +- test/unit/connector-test.js | 2 +- test/unit/instance-lookup-test.js | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e2232239b..8aa6acaea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ "@types/lru-cache": "^5.1.1", "@types/mocha": "^10.0.1", "@types/node": "^16.18.38", + "@types/punycode": "^2.1.3", "@types/sprintf-js": "^1.1.2", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", @@ -3289,6 +3290,12 @@ "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, + "node_modules/@types/punycode": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@types/punycode/-/punycode-2.1.3.tgz", + "integrity": "sha512-dFkH9Mz0yY5UfQVSrpj1grQyqRwe4TohTLlHFx4Gli8/fsaNyoOVUAsiEBZk5JBwbEJVZ49W6st8D5g6dRJb/w==", + "dev": true + }, "node_modules/@types/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", @@ -16232,6 +16239,12 @@ "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, + "@types/punycode": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@types/punycode/-/punycode-2.1.3.tgz", + "integrity": "sha512-dFkH9Mz0yY5UfQVSrpj1grQyqRwe4TohTLlHFx4Gli8/fsaNyoOVUAsiEBZk5JBwbEJVZ49W6st8D5g6dRJb/w==", + "dev": true + }, "@types/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", diff --git a/package.json b/package.json index 51794673e..b7f5db70b 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "@types/lru-cache": "^5.1.1", "@types/mocha": "^10.0.1", "@types/node": "^16.18.38", + "@types/punycode": "^2.1.3", "@types/sprintf-js": "^1.1.2", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", diff --git a/src/connector.ts b/src/connector.ts index fa1b9f4e3..f77edf025 100644 --- a/src/connector.ts +++ b/src/connector.ts @@ -1,7 +1,7 @@ import net from 'net'; import dns, { type LookupAddress } from 'dns'; -import * as punycode from 'punycode'; +import * as punycode from 'punycode/'; import { AbortSignal } from 'node-abort-controller'; import AbortError from './errors/abort-error'; diff --git a/src/sender.ts b/src/sender.ts index a33e2d741..bf50adf6a 100644 --- a/src/sender.ts +++ b/src/sender.ts @@ -1,7 +1,7 @@ import dgram from 'dgram'; import dns from 'dns'; import net from 'net'; -import * as punycode from 'punycode'; +import * as punycode from 'punycode/'; import { AbortSignal } from 'node-abort-controller'; import AbortError from './errors/abort-error'; diff --git a/test/unit/connector-test.js b/test/unit/connector-test.js index 973b8c06e..73cc9c957 100644 --- a/test/unit/connector-test.js +++ b/test/unit/connector-test.js @@ -1,6 +1,6 @@ const Mitm = require('mitm'); const sinon = require('sinon'); -const punycode = require('punycode'); +const punycode = require('punycode/'); const assert = require('chai').assert; const { AbortController } = require('node-abort-controller'); const AggregateError = require('es-aggregate-error'); diff --git a/test/unit/instance-lookup-test.js b/test/unit/instance-lookup-test.js index 339d8717a..e3a626acb 100644 --- a/test/unit/instance-lookup-test.js +++ b/test/unit/instance-lookup-test.js @@ -1,5 +1,5 @@ const sinon = require('sinon'); -const punycode = require('punycode'); +const punycode = require('punycode/'); const assert = require('chai').assert; const dgram = require('dgram'); const { AbortController } = require('node-abort-controller');