diff --git a/CHANGELOG.md b/CHANGELOG.md index 915bb916..e5bfc515 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 7.1.2 +- Removed unused code which caused build issues on some environments + ## 7.1.0 - Throw `ResolutionErrorCode.InvalidDomainAddress` error if domain contains special characters diff --git a/package.json b/package.json index 80c934e7..3fe9fb6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@unstoppabledomains/resolution", - "version": "7.1.1", + "version": "7.1.2", "description": "Domain Resolution for blockchain domains", "main": "./build/index.js", "directories": { diff --git a/src/UdApi.ts b/src/UdApi.ts index e401ff4d..bc0e8471 100644 --- a/src/UdApi.ts +++ b/src/UdApi.ts @@ -1,6 +1,5 @@ import {toBech32Address} from './utils/znsUtils'; import {ResolutionError, ResolutionErrorCode} from './errors/resolutionError'; -import pckg from './package.json'; import {isValidTwitterSignature} from './utils/TwitterSignatureValidator'; import { CryptoRecords, @@ -32,8 +31,7 @@ export default class Udapi extends NamingService { this.url = api?.url || 'https://unstoppabledomains.com/api/v1'; const DefaultUserAgent = 'cross-fetch/3.1.4 (+https://github.com/lquixada/cross-fetch)'; - const version = pckg.version; - const CustomUserAgent = `${DefaultUserAgent} Resolution/${version}`; + const CustomUserAgent = `${DefaultUserAgent} Resolution`; this.headers = {'X-user-agent': CustomUserAgent}; this.network = api?.network || 1; } diff --git a/src/errors/configurationError.ts b/src/errors/configurationError.ts index 6577f94f..7959df93 100644 --- a/src/errors/configurationError.ts +++ b/src/errors/configurationError.ts @@ -16,7 +16,6 @@ export enum ConfigurationErrorCode { IncorrectProvider = 'IncorrectProvider', UnsupportedNetwork = 'UnsupportedNetwork', UnspecifiedUrl = 'UnspecifiedUrl', - DependencyMissing = 'DependencyMissing', NetworkConfigMissing = 'NetworkConfigMissing', CustomNetworkConfigMissing = 'CustomNetworkConfigMissing', InvalidConfigurationField = 'InvalidProxyReader', @@ -36,11 +35,6 @@ const HandlersByCode = { [ConfigurationErrorCode.UnspecifiedUrl]: (params: { method: ResolutionMethod; }) => `Unspecified url in Resolution ${params.method} configuration`, - [ConfigurationErrorCode.DependencyMissing]: (params: { - dependency: string; - version: string; - }) => - `Missing dependency for this functionality. Please install ${params.dependency} @ ${params.version} via npm or yarn`, [ConfigurationErrorCode.NetworkConfigMissing]: (params: { method: ResolutionMethod; config: string; diff --git a/src/package.json b/src/package.json deleted file mode 120000 index 4e26811d..00000000 --- a/src/package.json +++ /dev/null @@ -1 +0,0 @@ -../package.json \ No newline at end of file diff --git a/src/tests/requireOrFail.test.ts b/src/tests/requireOrFail.test.ts deleted file mode 100644 index 2e124dff..00000000 --- a/src/tests/requireOrFail.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {requireOrFail} from '../utils/requireOrFail'; - -describe('requireOrFail', () => { - it('should throw configuration error', () => { - expect(() => - requireOrFail('non-existent-module', 'requested-module', '1'), - ).toThrowError( - 'Missing dependency for this functionality. Please install requested-module @ 1 via npm or yarn', - ); - }); - - it('should succeed', () => { - const module = requireOrFail( - '../utils/requireOrFail', - 'require-or-fail', - '1', - ); - expect(module.requireOrFail).toEqual(requireOrFail); - }); -}); diff --git a/src/utils/requireOrFail.ts b/src/utils/requireOrFail.ts deleted file mode 100644 index 137b9ce9..00000000 --- a/src/utils/requireOrFail.ts +++ /dev/null @@ -1,26 +0,0 @@ -import ConfigurationError, { - ConfigurationErrorCode, -} from '../errors/configurationError'; - -/** - * Function tries to require module and throw error if module is not found. - * @param module - Module name or path - * @param dependencyName NPM name of the requested module - * @param allowedVersions Allowed versions of requested module - * @throws ConfigurationError - */ -export function requireOrFail( - module: string, - dependencyName: string, - allowedVersions: string, -): any { - try { - // eslint-disable-next-line @typescript-eslint/no-var-requires - return require(module); - } catch (e) { - throw new ConfigurationError(ConfigurationErrorCode.DependencyMissing, { - dependency: dependencyName, - version: allowedVersions, - }); - } -}