Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

num-client

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

num-client - npm Package Compare versions

Comparing version 0.1.34 to 0.1.35

1

dist/lookupgenerators.d.ts

@@ -20,4 +20,5 @@ import { NumUri, PositiveInteger } from './numuri';

export declare const createUrlLookupGenerator: (numUri: NumUri) => LookupGenerator;
export declare const createTNUMLookupGenerator: (numUri: NumUri) => LookupGenerator;
export declare const transformBranch: (s: string) => string;
export declare const normaliseDomainName: (domainName: string) => string;
export declare const normalisePath: (path: string) => string;

@@ -19,3 +19,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.normalisePath = exports.normaliseDomainName = exports.transformBranch = exports.createUrlLookupGenerator = exports.createEmailLookupGenerator = exports.createDomainLookupGenerator = exports.setenvDomainLookups = void 0;
exports.normalisePath = exports.normaliseDomainName = exports.transformBranch = exports.createTNUMLookupGenerator = exports.createUrlLookupGenerator = exports.createEmailLookupGenerator = exports.createDomainLookupGenerator = exports.setenvDomainLookups = void 0;
var loglevel_1 = __importDefault(require("loglevel"));

@@ -51,2 +51,3 @@ var punycode_1 = __importDefault(require("punycode"));

exports.createUrlLookupGenerator = function (numUri) { return new UrlLookupGenerator(numUri); };
exports.createTNUMLookupGenerator = function (numUri) { return new TNUMLookupGenerator(numUri); };
var BaseLookupGenerator = (function () {

@@ -253,2 +254,150 @@ function BaseLookupGenerator(numUri) {

}(BaseLookupGenerator));
var NO_COUNTRY_CODE_MSG = 'No Country code defined for ';
var TNUMLookupGenerator = (function (_super) {
__extends(TNUMLookupGenerator, _super);
function TNUMLookupGenerator(numUri) {
var _this = _super.call(this, numUri) || this;
var branch = exports.transformBranch(exports.normalisePath(numUri.path.s));
_this._branch = branch !== '' ? punycode_1.default.toASCII(branch) : branch;
if (_this._branch !== branch) {
loglevel_1.default.debug("Query " + _this._branch + " punycode " + branch);
}
_this._numUri = _this._numUri.withHost(new numuri_1.Hostname(exports.normaliseDomainName(numUri.host.s)));
if (!numuri_1.Hostname.isValidTNUM(_this._numUri.host.s)) {
throw new exceptions_1.NumInvalidParameterException('Domain name is invalid for TNUM');
}
return _this;
}
TNUMLookupGenerator.prototype.getPopulatorLocation = function (_moduleNumber) {
return null;
};
TNUMLookupGenerator.prototype.getIndependentLocation = function (moduleNumber) {
var result = this.getRootIndependentLocation(moduleNumber);
if (this._branch.length > 0) {
return this._branch + '.' + result;
}
return result;
};
TNUMLookupGenerator.prototype.getHostedLocation = function (moduleNumber) {
var result = this.getRootHostedLocation(moduleNumber);
if (this._branch.length > 0) {
return this._branch + '.' + result;
}
return result;
};
TNUMLookupGenerator.prototype.getRootIndependentLocation = function (moduleNumber) {
var countryCode = this.findCountryCode(this._numUri.host.s);
if (!countryCode) {
throw new exceptions_1.NumInvalidParameterException(NO_COUNTRY_CODE_MSG + this._numUri.host.s);
}
return "" + moduleNumber.n + _NUM + this.formatIndependentTNumDomain(countryCode, this._numUri.host.s) + "." + countryCode.dnsRoot + ".";
};
TNUMLookupGenerator.prototype.getRootHostedLocation = function (moduleNumber) {
var countryCode = this.findCountryCode(this._numUri.host.s);
if (!countryCode) {
throw new exceptions_1.NumInvalidParameterException(NO_COUNTRY_CODE_MSG + this._numUri.host.s);
}
if (MappingPattern.sds === countryCode.mappingPattern) {
return moduleNumber.n + "." + DNPREFIX + this.formatHostedTNumDomain(countryCode, this._numUri.host.s) + "." + countryCode.dnsRoot + ".";
}
else {
return moduleNumber.n + "." + DNPREFIX + this.formatHostedTNumDomain(countryCode, this._numUri.host.s) + "._t." + TLZ + ".";
}
};
TNUMLookupGenerator.prototype.getRootIndependentLocationNoModuleNumber = function (addTrailingDot) {
var countryCode = this.findCountryCode(this._numUri.host.s);
if (!countryCode) {
throw new exceptions_1.NumInvalidParameterException(NO_COUNTRY_CODE_MSG + this._numUri.host.s);
}
var result = "_num." + this.formatIndependentTNumDomain(countryCode, this._numUri.host.s) + "." + countryCode.dnsRoot;
if (addTrailingDot) {
return result + '.';
}
return result;
};
TNUMLookupGenerator.prototype.getRootHostedLocationNoModuleNumber = function (addTrailingDot) {
var result = this.getRootHostedLocation(numuri_1.MODULE_0).substr(2);
if (addTrailingDot) {
return result;
}
return result.substr(0, result.length - 1);
};
TNUMLookupGenerator.prototype.formatIndependentTNumDomain = function (code, domain) {
var noIntlPrefix = domain.substr(code.code.length);
var result = '';
switch (code.mappingPattern) {
case MappingPattern.bds:
result = this.mapBDS(noIntlPrefix);
result = reverse(result);
break;
case MappingPattern.sds:
result = this.mapSDS(noIntlPrefix);
break;
default:
throw new exceptions_1.NumInvalidParameterException("Bad enum value: " + code.mappingPattern);
}
return result;
};
TNUMLookupGenerator.prototype.formatHostedTNumDomain = function (code, domain) {
var noIntlPrefix = domain.substr(code.code.length);
var result = '';
switch (code.mappingPattern) {
case MappingPattern.bds:
result = this.mapBDS(noIntlPrefix);
result = reverse(result) + '.' + reverse(code.code.substr(1));
break;
case MappingPattern.sds:
result = this.mapSDS(noIntlPrefix);
break;
default:
throw new exceptions_1.NumInvalidParameterException("Bad enum value: " + code.mappingPattern);
}
return result;
};
TNUMLookupGenerator.prototype.mapBDS = function (noIntlPrefix) {
var result = '';
var count = 0;
var threes = 1;
var insertions = 0;
while (count < noIntlPrefix.length) {
result += noIntlPrefix.charAt(count);
if (threes % 3 === 0 && insertions < 2) {
result += '.';
insertions++;
}
count++;
threes++;
}
return result;
};
TNUMLookupGenerator.prototype.mapSDS = function (noIntlPrefix) {
return this.intersperseDots(reverse(noIntlPrefix));
};
TNUMLookupGenerator.prototype.intersperseDots = function (s) {
return s.split('').join('.');
};
TNUMLookupGenerator.prototype.findCountryCode = function (domain) {
return codes.find(function (cc) { return domain.startsWith(cc.code); });
};
return TNUMLookupGenerator;
}(BaseLookupGenerator));
var reverse = function (s) { return s.split('').reverse().join(''); };
var CountryCode = (function () {
function CountryCode(code, mappingPattern, dnsRoot) {
this.code = code;
this.mappingPattern = mappingPattern;
this.dnsRoot = dnsRoot;
}
return CountryCode;
}());
var MappingPattern;
(function (MappingPattern) {
MappingPattern[MappingPattern["bds"] = 0] = "bds";
MappingPattern[MappingPattern["sds"] = 1] = "sds";
})(MappingPattern || (MappingPattern = {}));
var codes = [
new CountryCode('+9999', MappingPattern.sds, '9.9.9.9.e164.arpa'),
new CountryCode('+44', MappingPattern.bds, '44.tnum.net'),
new CountryCode('+1', MappingPattern.bds, '44.tnum.net'),
];
//# sourceMappingURL=lookupgenerators.js.map

20

dist/modulednsqueries.js

@@ -7,5 +7,5 @@ "use strict";

exports.createModuleDnsQueries = void 0;
var loglevel_1 = __importDefault(require("loglevel"));
var exceptions_1 = require("./exceptions");
var lookupgenerators_1 = require("./lookupgenerators");
var loglevel_1 = __importDefault(require("loglevel"));
var numuri_1 = require("./numuri");

@@ -17,7 +17,15 @@ exports.createModuleDnsQueries = function (moduleId, numUri) { return new ModuleDnsQueriesImpl(moduleId, numUri); };

this.numUri = numUri;
var lookupGenerator = this.numUri.userinfo !== numuri_1.NO_USER_INFO
? lookupgenerators_1.createEmailLookupGenerator(this.numUri)
: this.numUri.protocol.startsWith('http')
? lookupgenerators_1.createUrlLookupGenerator(this.numUri)
: lookupgenerators_1.createDomainLookupGenerator(this.numUri);
var lookupGenerator;
if (this.numUri.userinfo !== numuri_1.NO_USER_INFO) {
lookupGenerator = lookupgenerators_1.createEmailLookupGenerator(this.numUri);
}
else if (this.numUri.protocol.startsWith('http')) {
lookupGenerator = lookupgenerators_1.createUrlLookupGenerator(this.numUri);
}
else if (numuri_1.Hostname.isValidTNUM(this.numUri.host.s)) {
lookupGenerator = lookupgenerators_1.createTNUMLookupGenerator(this.numUri);
}
else {
lookupGenerator = lookupgenerators_1.createDomainLookupGenerator(this.numUri);
}
this._independentRecordLocation = lookupGenerator.getIndependentLocation(this.moduleId);

@@ -24,0 +32,0 @@ this._rootIndependentRecordLocation = lookupGenerator.getRootIndependentLocation(this.moduleId);

@@ -36,2 +36,3 @@ export declare class NumUri {

static isValid(s: string): boolean;
static isValidTNUM(s: string): boolean;
}

@@ -38,0 +39,0 @@ export declare class UrlPath {

@@ -6,2 +6,3 @@ "use strict";

var DOMAIN_REGEX = new RegExp(/^(([^.\s\\\b]+?\.)*?([^!"#$%&'()*+,./:;<=>?@\[\]^_`{|}~\s\b]+?\.)([^!"#$%&'()*+,./:;<=>?@\[\]^_`{|}~\s\b]+?))\.??$/);
var TNUM_REGEX = new RegExp(/^\+\d{2,15}$/);
var USERINFO_REGEX = new RegExp(/^(?!\s)[^@\f\t\r\b\s\\]+$/);

@@ -105,5 +106,9 @@ var PATH_REGEX = new RegExp(/^(\/[^;,/\\?:@&=+$.#\s]+)*\/?$/);

Hostname.isValid = function (s) {
var matches = DOMAIN_REGEX.exec(s);
return s.length <= MAX_DOMAIN_NAME_LENGTH && matches !== null && matches.length > 0;
var domainMatches = DOMAIN_REGEX.exec(s);
return (s.length <= MAX_DOMAIN_NAME_LENGTH && domainMatches !== null && domainMatches.length > 0) || Hostname.isValidTNUM(s);
};
Hostname.isValidTNUM = function (s) {
var tnumMatches = TNUM_REGEX.exec(s);
return tnumMatches !== null && tnumMatches.length > 0;
};
return Hostname;

@@ -110,0 +115,0 @@ }());

{
"name": "num-client",
"version": "0.1.34",
"version": "0.1.35",
"description": "A NUM Protocol Client in TypeScript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc