num-client
Advanced tools
Comparing version 1.0.29 to 1.0.30
import { Context, NumLocation, UserVariable } from './context'; | ||
import { DoHResolver } from './dnsclient'; | ||
import { NumProtocolErrorCode } from './exceptions'; | ||
import { NumUri, PositiveInteger } from './numuri'; | ||
@@ -18,14 +19,2 @@ import { ResourceLoader } from './resourceloader'; | ||
} | ||
export declare enum NumProtocolErrorCode { | ||
errorCreatingContext = "ERROR_CREATING_CONTEXT", | ||
compactSchemaError = "COMPACT_SCHEMA_ERROR", | ||
localeFileNotFoundError = "LOCALE_FILE_NOT_FOUND_ERROR", | ||
noUnpackerConfigFileFound = "NO_UNPACKER_CONFIG_FILE_FOUND", | ||
expandedSchemaError = "EXPANDED_SCHEMA_ERROR", | ||
moduleConfigFileNotFound = "MODULE_CONFIG_FILE_NOT_FOUND", | ||
tooManyRedirects = "TOO_MANY_REDIRECTS", | ||
internalError = "INTERNAL_ERROR", | ||
noModlRecordFound = "NO_MODL_RECORD_FOUND", | ||
schemaNotFound = "SCHEMA_NOT_FOUND" | ||
} | ||
export interface CallbackHandler { | ||
@@ -32,0 +21,0 @@ setLocation(l: NumLocation): void; |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -55,3 +42,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultCallbackHandler = exports.createDefaultCallbackHandler = exports.NumProtocolErrorCode = exports.lookup = exports.createClient = void 0; | ||
exports.DefaultCallbackHandler = exports.createDefaultCallbackHandler = exports.lookup = exports.createClient = void 0; | ||
var ajv_1 = __importDefault(require("ajv")); | ||
@@ -80,15 +67,2 @@ var ajv_formats_1 = __importDefault(require("ajv-formats")); | ||
}; | ||
var NumProtocolErrorCode; | ||
(function (NumProtocolErrorCode) { | ||
NumProtocolErrorCode["errorCreatingContext"] = "ERROR_CREATING_CONTEXT"; | ||
NumProtocolErrorCode["compactSchemaError"] = "COMPACT_SCHEMA_ERROR"; | ||
NumProtocolErrorCode["localeFileNotFoundError"] = "LOCALE_FILE_NOT_FOUND_ERROR"; | ||
NumProtocolErrorCode["noUnpackerConfigFileFound"] = "NO_UNPACKER_CONFIG_FILE_FOUND"; | ||
NumProtocolErrorCode["expandedSchemaError"] = "EXPANDED_SCHEMA_ERROR"; | ||
NumProtocolErrorCode["moduleConfigFileNotFound"] = "MODULE_CONFIG_FILE_NOT_FOUND"; | ||
NumProtocolErrorCode["tooManyRedirects"] = "TOO_MANY_REDIRECTS"; | ||
NumProtocolErrorCode["internalError"] = "INTERNAL_ERROR"; | ||
NumProtocolErrorCode["noModlRecordFound"] = "NO_MODL_RECORD_FOUND"; | ||
NumProtocolErrorCode["schemaNotFound"] = "SCHEMA_NOT_FOUND"; | ||
})(NumProtocolErrorCode = exports.NumProtocolErrorCode || (exports.NumProtocolErrorCode = {})); | ||
exports.createDefaultCallbackHandler = function () { return new DefaultCallbackHandler(); }; | ||
@@ -138,11 +112,2 @@ var DEFAULT_LOCALES_BASE_URL = new URL('https://modules.numprotocol.com/1/locales/'); | ||
}); | ||
var NumProtocolException = (function (_super) { | ||
__extends(NumProtocolException, _super); | ||
function NumProtocolException(errorCode, message) { | ||
var _this = _super.call(this, message) || this; | ||
_this.errorCode = errorCode; | ||
return _this; | ||
} | ||
return NumProtocolException; | ||
}(Error)); | ||
var DefaultCallbackHandler = (function () { | ||
@@ -177,3 +142,4 @@ function DefaultCallbackHandler() { | ||
function NumClientImpl(resolvers) { | ||
this.dnsServices = resolvers ? dnsservices_1.createDnsServices(DNS_REQUEST_TIMEOUT_MS, resolvers) : dnsservices_1.createDnsServices(DNS_REQUEST_TIMEOUT_MS, DEFAULT_RESOLVERS); | ||
this.dnsServices = | ||
resolvers && resolvers.length > 0 ? dnsservices_1.createDnsServices(DNS_REQUEST_TIMEOUT_MS, resolvers) : dnsservices_1.createDnsServices(DNS_REQUEST_TIMEOUT_MS, DEFAULT_RESOLVERS); | ||
this.modlServices = modlservices_1.createModlServices(); | ||
@@ -206,3 +172,3 @@ this.resourceLoader = resourceloader_1.createResourceLoader(); | ||
var err = e; | ||
throw new NumProtocolException(NumProtocolErrorCode.errorCreatingContext, err.message); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.errorCreatingContext, err.message); | ||
} | ||
@@ -238,7 +204,7 @@ }; | ||
case 4: | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(NumProtocolErrorCode.noModlRecordFound); | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(exceptions_1.NumProtocolErrorCode.noModlRecordFound); | ||
return [2, null]; | ||
case 5: | ||
e_1 = _a.sent(); | ||
if (e_1 instanceof NumProtocolException) { | ||
if (e_1 instanceof exceptions_1.NumProtocolException) { | ||
loglevel_1.default.error("NumProtocolException: " + e_1.errorCode + " : " + e_1.message); | ||
@@ -252,3 +218,3 @@ handler === null || handler === void 0 ? void 0 : handler.setErrorCode(e_1.errorCode); | ||
ctx.location = context_1.NumLocation.none; | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(NumProtocolErrorCode.tooManyRedirects); | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(exceptions_1.NumProtocolErrorCode.tooManyRedirects); | ||
return [2, null]; | ||
@@ -260,5 +226,20 @@ } | ||
} | ||
else if (e_1 instanceof exceptions_1.NumLookupEmptyResult) { | ||
loglevel_1.default.warn('Empty result'); | ||
ctx.result = null; | ||
ctx.location = context_1.NumLocation.none; | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(exceptions_1.NumProtocolErrorCode.noModlRecordFound); | ||
return [2, null]; | ||
} | ||
else if (e_1 instanceof exceptions_1.NumLookupBadDoHResponse) { | ||
loglevel_1.default.warn('Bad DoH Service'); | ||
ctx.location = context_1.NumLocation.none; | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(exceptions_1.NumProtocolErrorCode.badDoHResponse); | ||
return [2, null]; | ||
} | ||
else if (e_1 instanceof Error) { | ||
loglevel_1.default.warn("Unhandled exception: " + e_1.message); | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(NumProtocolErrorCode.internalError); | ||
ctx.location = context_1.NumLocation.none; | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(exceptions_1.NumProtocolErrorCode.noModlRecordFound); | ||
handler === null || handler === void 0 ? void 0 : handler.setErrorCode(exceptions_1.NumProtocolErrorCode.internalError); | ||
return [2, null]; | ||
@@ -297,3 +278,3 @@ } | ||
e_2 = _a.sent(); | ||
if (e_2 instanceof NumProtocolException) { | ||
if (e_2 instanceof exceptions_1.NumProtocolException) { | ||
if (handler) { | ||
@@ -310,3 +291,3 @@ loglevel_1.default.error("NumProtocolException: " + e_2.errorCode + " : " + e_2.message); | ||
if (handler) { | ||
handler.setErrorCode(NumProtocolErrorCode.tooManyRedirects); | ||
handler.setErrorCode(exceptions_1.NumProtocolErrorCode.tooManyRedirects); | ||
} | ||
@@ -322,3 +303,3 @@ return [2, null]; | ||
if (handler) { | ||
handler.setErrorCode(NumProtocolErrorCode.internalError); | ||
handler.setErrorCode(exceptions_1.NumProtocolErrorCode.internalError); | ||
} | ||
@@ -399,3 +380,3 @@ return [2, null]; | ||
if (!(_a.sent())) { | ||
throw new NumProtocolException(NumProtocolErrorCode.compactSchemaError, 'The record does not match the compact schema'); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.compactSchemaError, 'The record does not match the compact schema'); | ||
} | ||
@@ -410,3 +391,3 @@ return [3, 4]; | ||
if (!localeFile) { | ||
throw new NumProtocolException(NumProtocolErrorCode.localeFileNotFoundError, "Unable to locate a locale file using " + JSON.stringify(userVariables)); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.localeFileNotFoundError, "Unable to locate a locale file using " + JSON.stringify(userVariables)); | ||
} | ||
@@ -423,3 +404,3 @@ if (!(moduleConfig.schemaMapUrl && moduleConfig.processingChain.unpack)) return [3, 7]; | ||
loglevel_1.default.error("Unable to load schema map defined in " + JSON.stringify(moduleConfig)); | ||
throw new NumProtocolException(NumProtocolErrorCode.noUnpackerConfigFileFound, "Could not load the configure Unpacker config file: " + moduleConfig.schemaMapUrl); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.noUnpackerConfigFileFound, "Could not load the configure Unpacker config file: " + moduleConfig.schemaMapUrl); | ||
} | ||
@@ -432,3 +413,3 @@ _a.label = 7; | ||
if (!(_a.sent())) { | ||
throw new NumProtocolException(NumProtocolErrorCode.expandedSchemaError, 'The record does not match the expanded schema'); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.expandedSchemaError, 'The record does not match the expanded schema'); | ||
} | ||
@@ -442,3 +423,3 @@ return [3, 10]; | ||
loglevel_1.default.error('No module config file available.'); | ||
throw new NumProtocolException(NumProtocolErrorCode.moduleConfigFileNotFound, "Unable to load the module config file for module " + moduleNumber.n + " "); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.moduleConfigFileNotFound, "Unable to load the module config file for module " + moduleNumber.n + " "); | ||
case 12: return [3, 14]; | ||
@@ -528,3 +509,3 @@ case 13: | ||
loglevel_1.default.error(msg); | ||
throw new NumProtocolException(NumProtocolErrorCode.schemaNotFound, msg); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.schemaNotFound, msg); | ||
} | ||
@@ -536,3 +517,3 @@ _a.label = 2; | ||
loglevel_1.default.error(msg); | ||
throw new NumProtocolException(NumProtocolErrorCode.schemaNotFound, msg); | ||
throw new exceptions_1.NumProtocolException(exceptions_1.NumProtocolErrorCode.schemaNotFound, msg); | ||
} | ||
@@ -539,0 +520,0 @@ if (existingSchema(json)) { |
@@ -133,3 +133,3 @@ "use strict"; | ||
if (attempts === 0) { | ||
return [2, Promise.resolve('')]; | ||
throw new exceptions_1.NumLookupEmptyResult(); | ||
} | ||
@@ -148,5 +148,8 @@ question = new dnsclient_1.Question(query, 'TXT', checkDnsSecValidity); | ||
if (e && typeof e === 'object') { | ||
if ((e.status && e.status !== 0) || e.message === 'Found spf' || e.message === 'Found CNAME') { | ||
return Promise.resolve(''); | ||
if (e.status && e.status !== 0) { | ||
throw new exceptions_1.NumLookupBadDoHResponse(); | ||
} | ||
if (e.message === 'Found spf' || e.message === 'Found CNAME') { | ||
throw new exceptions_1.NumLookupEmptyResult(); | ||
} | ||
} | ||
@@ -171,4 +174,4 @@ loglevel_1.default.info("The current resolver failed so disable it for a while: " + _this.dnsClients[dohIndex].getResolver().name); | ||
if (!this.dnsClients[dohIndex].getResolver().isActive()) { | ||
loglevel_1.default.info("Can't find an active resolver so re-using this one: " + this.dnsClients[dohIndex].getResolver().name); | ||
this.dnsClients[dohIndex].getResolver().activeFrom = Date.now(); | ||
loglevel_1.default.info("Can't find an active resolver so aborting."); | ||
throw new exceptions_1.NumLookupBadDoHResponse(); | ||
} | ||
@@ -175,0 +178,0 @@ return dohIndex; |
@@ -42,1 +42,24 @@ export declare class NumException extends Error { | ||
} | ||
export declare class NumLookupEmptyResult extends NumException { | ||
constructor(msg?: string); | ||
} | ||
export declare class NumLookupBadDoHResponse extends NumException { | ||
constructor(msg?: string); | ||
} | ||
export declare enum NumProtocolErrorCode { | ||
errorCreatingContext = "ERROR_CREATING_CONTEXT", | ||
compactSchemaError = "COMPACT_SCHEMA_ERROR", | ||
localeFileNotFoundError = "LOCALE_FILE_NOT_FOUND_ERROR", | ||
noUnpackerConfigFileFound = "NO_UNPACKER_CONFIG_FILE_FOUND", | ||
expandedSchemaError = "EXPANDED_SCHEMA_ERROR", | ||
moduleConfigFileNotFound = "MODULE_CONFIG_FILE_NOT_FOUND", | ||
tooManyRedirects = "TOO_MANY_REDIRECTS", | ||
internalError = "INTERNAL_ERROR", | ||
noModlRecordFound = "NO_MODL_RECORD_FOUND", | ||
schemaNotFound = "SCHEMA_NOT_FOUND", | ||
badDoHResponse = "DOH_SERVICE_ERROR" | ||
} | ||
export declare class NumProtocolException extends NumException { | ||
readonly errorCode: NumProtocolErrorCode; | ||
constructor(errorCode: NumProtocolErrorCode, message: string); | ||
} |
@@ -16,7 +16,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NumLookupRedirect = exports.RelativePathException = exports.NumMaximumRedirectsExceededException = exports.RrSetIncompleteException = exports.RrSetHeaderFormatException = exports.InvalidDnsResponseException = exports.BadDnsStatusException = exports.NumInvalidRedirectException = exports.NumNotImplementedException = exports.NumInvalidDnsQueryException = exports.NumBadUrlException = exports.NumInvalidParameterException = exports.NumException = void 0; | ||
exports.NumProtocolException = exports.NumProtocolErrorCode = exports.NumLookupBadDoHResponse = exports.NumLookupEmptyResult = exports.NumLookupRedirect = exports.RelativePathException = exports.NumMaximumRedirectsExceededException = exports.RrSetIncompleteException = exports.RrSetHeaderFormatException = exports.InvalidDnsResponseException = exports.BadDnsStatusException = exports.NumInvalidRedirectException = exports.NumNotImplementedException = exports.NumInvalidDnsQueryException = exports.NumBadUrlException = exports.NumInvalidParameterException = exports.NumException = void 0; | ||
var NumException = (function (_super) { | ||
__extends(NumException, _super); | ||
function NumException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumException.prototype); | ||
return _this; | ||
} | ||
@@ -29,3 +31,5 @@ return NumException; | ||
function NumInvalidParameterException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumInvalidParameterException.prototype); | ||
return _this; | ||
} | ||
@@ -40,2 +44,3 @@ return NumInvalidParameterException; | ||
_this.cause = cause; | ||
Object.setPrototypeOf(_this, NumBadUrlException.prototype); | ||
return _this; | ||
@@ -49,3 +54,5 @@ } | ||
function NumInvalidDnsQueryException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumInvalidDnsQueryException.prototype); | ||
return _this; | ||
} | ||
@@ -58,3 +65,5 @@ return NumInvalidDnsQueryException; | ||
function NumNotImplementedException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumNotImplementedException.prototype); | ||
return _this; | ||
} | ||
@@ -67,3 +76,5 @@ return NumNotImplementedException; | ||
function NumInvalidRedirectException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumInvalidRedirectException.prototype); | ||
return _this; | ||
} | ||
@@ -78,2 +89,3 @@ return NumInvalidRedirectException; | ||
_this.status = status; | ||
Object.setPrototypeOf(_this, BadDnsStatusException.prototype); | ||
return _this; | ||
@@ -87,3 +99,5 @@ } | ||
function InvalidDnsResponseException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, InvalidDnsResponseException.prototype); | ||
return _this; | ||
} | ||
@@ -96,3 +110,5 @@ return InvalidDnsResponseException; | ||
function RrSetHeaderFormatException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, RrSetHeaderFormatException.prototype); | ||
return _this; | ||
} | ||
@@ -105,3 +121,5 @@ return RrSetHeaderFormatException; | ||
function RrSetIncompleteException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, RrSetIncompleteException.prototype); | ||
return _this; | ||
} | ||
@@ -114,3 +132,5 @@ return RrSetIncompleteException; | ||
function NumMaximumRedirectsExceededException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumMaximumRedirectsExceededException.prototype); | ||
return _this; | ||
} | ||
@@ -123,3 +143,5 @@ return NumMaximumRedirectsExceededException; | ||
function RelativePathException(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, RelativePathException.prototype); | ||
return _this; | ||
} | ||
@@ -132,3 +154,5 @@ return RelativePathException; | ||
function NumLookupRedirect(msg) { | ||
return _super.call(this, msg) || this; | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumLookupRedirect.prototype); | ||
return _this; | ||
} | ||
@@ -138,2 +162,47 @@ return NumLookupRedirect; | ||
exports.NumLookupRedirect = NumLookupRedirect; | ||
var NumLookupEmptyResult = (function (_super) { | ||
__extends(NumLookupEmptyResult, _super); | ||
function NumLookupEmptyResult(msg) { | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumLookupEmptyResult.prototype); | ||
return _this; | ||
} | ||
return NumLookupEmptyResult; | ||
}(NumException)); | ||
exports.NumLookupEmptyResult = NumLookupEmptyResult; | ||
var NumLookupBadDoHResponse = (function (_super) { | ||
__extends(NumLookupBadDoHResponse, _super); | ||
function NumLookupBadDoHResponse(msg) { | ||
var _this = _super.call(this, msg) || this; | ||
Object.setPrototypeOf(_this, NumLookupBadDoHResponse.prototype); | ||
return _this; | ||
} | ||
return NumLookupBadDoHResponse; | ||
}(NumException)); | ||
exports.NumLookupBadDoHResponse = NumLookupBadDoHResponse; | ||
var NumProtocolErrorCode; | ||
(function (NumProtocolErrorCode) { | ||
NumProtocolErrorCode["errorCreatingContext"] = "ERROR_CREATING_CONTEXT"; | ||
NumProtocolErrorCode["compactSchemaError"] = "COMPACT_SCHEMA_ERROR"; | ||
NumProtocolErrorCode["localeFileNotFoundError"] = "LOCALE_FILE_NOT_FOUND_ERROR"; | ||
NumProtocolErrorCode["noUnpackerConfigFileFound"] = "NO_UNPACKER_CONFIG_FILE_FOUND"; | ||
NumProtocolErrorCode["expandedSchemaError"] = "EXPANDED_SCHEMA_ERROR"; | ||
NumProtocolErrorCode["moduleConfigFileNotFound"] = "MODULE_CONFIG_FILE_NOT_FOUND"; | ||
NumProtocolErrorCode["tooManyRedirects"] = "TOO_MANY_REDIRECTS"; | ||
NumProtocolErrorCode["internalError"] = "INTERNAL_ERROR"; | ||
NumProtocolErrorCode["noModlRecordFound"] = "NO_MODL_RECORD_FOUND"; | ||
NumProtocolErrorCode["schemaNotFound"] = "SCHEMA_NOT_FOUND"; | ||
NumProtocolErrorCode["badDoHResponse"] = "DOH_SERVICE_ERROR"; | ||
})(NumProtocolErrorCode = exports.NumProtocolErrorCode || (exports.NumProtocolErrorCode = {})); | ||
var NumProtocolException = (function (_super) { | ||
__extends(NumProtocolException, _super); | ||
function NumProtocolException(errorCode, message) { | ||
var _this = _super.call(this, message) || this; | ||
_this.errorCode = errorCode; | ||
Object.setPrototypeOf(_this, NumProtocolException.prototype); | ||
return _this; | ||
} | ||
return NumProtocolException; | ||
}(NumException)); | ||
exports.NumProtocolException = NumProtocolException; | ||
//# sourceMappingURL=exceptions.js.map |
@@ -1,3 +0,4 @@ | ||
import { createClient, DefaultCallbackHandler, lookup, NumClient, NumProtocolErrorCode } from './client'; | ||
import { createClient, createDefaultCallbackHandler, DefaultCallbackHandler, lookup, NumClient } from './client'; | ||
import { createDnsClient, DoHResolver } from './dnsclient'; | ||
import { NumProtocolErrorCode } from './exceptions'; | ||
import { createDomainLookupGenerator, createEmailLookupGenerator, createTNUMLookupGenerator, createUrlLookupGenerator, normaliseDomainName, normalisePath, setenvDomainLookups, transformBranch } from './lookupgenerators'; | ||
@@ -22,2 +23,2 @@ import { createModuleDnsQueries, ModuleDnsQueries } from './modulednsqueries'; | ||
export { DoHResolver, createDnsClient }; | ||
export { resolvePath, ResourceLoader, normalisePath, createModuleDnsQueries, ModuleDnsQueries, transformBranch, normaliseDomainName, createTNUMLookupGenerator, createDomainLookupGenerator, createEmailLookupGenerator, createUrlLookupGenerator, setenvDomainLookups, }; | ||
export { resolvePath, ResourceLoader, normalisePath, createModuleDnsQueries, ModuleDnsQueries, transformBranch, normaliseDomainName, createTNUMLookupGenerator, createDomainLookupGenerator, createEmailLookupGenerator, createUrlLookupGenerator, setenvDomainLookups, createDefaultCallbackHandler, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setenvDomainLookups = exports.createUrlLookupGenerator = exports.createEmailLookupGenerator = exports.createDomainLookupGenerator = exports.createTNUMLookupGenerator = exports.normaliseDomainName = exports.transformBranch = exports.createModuleDnsQueries = exports.normalisePath = exports.resolvePath = exports.createDnsClient = exports.DoHResolver = exports.lookup = exports.DefaultCallbackHandler = exports.NumProtocolErrorCode = exports.createClient = exports.MODULE_10 = exports.MODULE_9 = exports.MODULE_8 = exports.MODULE_7 = exports.MODULE_6 = exports.MODULE_5 = exports.MODULE_4 = exports.MODULE_3 = exports.MODULE_2 = exports.MODULE_1 = exports.MODULE_0 = exports.buildNumUri = exports.UrlPath = exports.UrlUserInfo = exports.Hostname = exports.PositiveInteger = exports.NumUri = exports.parseNumUri = void 0; | ||
exports.createDefaultCallbackHandler = exports.setenvDomainLookups = exports.createUrlLookupGenerator = exports.createEmailLookupGenerator = exports.createDomainLookupGenerator = exports.createTNUMLookupGenerator = exports.normaliseDomainName = exports.transformBranch = exports.createModuleDnsQueries = exports.normalisePath = exports.resolvePath = exports.createDnsClient = exports.DoHResolver = exports.lookup = exports.DefaultCallbackHandler = exports.NumProtocolErrorCode = exports.createClient = exports.MODULE_10 = exports.MODULE_9 = exports.MODULE_8 = exports.MODULE_7 = exports.MODULE_6 = exports.MODULE_5 = exports.MODULE_4 = exports.MODULE_3 = exports.MODULE_2 = exports.MODULE_1 = exports.MODULE_0 = exports.buildNumUri = exports.UrlPath = exports.UrlUserInfo = exports.Hostname = exports.PositiveInteger = exports.NumUri = exports.parseNumUri = void 0; | ||
var client_1 = require("./client"); | ||
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } }); | ||
Object.defineProperty(exports, "createDefaultCallbackHandler", { enumerable: true, get: function () { return client_1.createDefaultCallbackHandler; } }); | ||
Object.defineProperty(exports, "DefaultCallbackHandler", { enumerable: true, get: function () { return client_1.DefaultCallbackHandler; } }); | ||
Object.defineProperty(exports, "lookup", { enumerable: true, get: function () { return client_1.lookup; } }); | ||
Object.defineProperty(exports, "NumProtocolErrorCode", { enumerable: true, get: function () { return client_1.NumProtocolErrorCode; } }); | ||
var dnsclient_1 = require("./dnsclient"); | ||
Object.defineProperty(exports, "createDnsClient", { enumerable: true, get: function () { return dnsclient_1.createDnsClient; } }); | ||
Object.defineProperty(exports, "DoHResolver", { enumerable: true, get: function () { return dnsclient_1.DoHResolver; } }); | ||
var exceptions_1 = require("./exceptions"); | ||
Object.defineProperty(exports, "NumProtocolErrorCode", { enumerable: true, get: function () { return exceptions_1.NumProtocolErrorCode; } }); | ||
var lookupgenerators_1 = require("./lookupgenerators"); | ||
@@ -13,0 +15,0 @@ Object.defineProperty(exports, "createDomainLookupGenerator", { enumerable: true, get: function () { return lookupgenerators_1.createDomainLookupGenerator; } }); |
@@ -13,21 +13,23 @@ "use strict"; | ||
var DEFAULT_RESOLVERS = [ | ||
new dnsclient_1.DoHResolver('BAD1', 'https://jhsgfdjhsgdkweg32767236eddghagsf.com/dns-query'), | ||
new dnsclient_1.DoHResolver('BAD2', 'https://jhsgfdjhsgdkweg32767236eddghagsf.com/dns-query'), | ||
new dnsclient_1.DoHResolver('BAD3', 'https://jhsgfdjhsgdkweg32767236eddghagsf.com/dns-query'), | ||
new dnsclient_1.DoHResolver('Cloudflare', 'https://cloudflare-dns.com/dns-query'), | ||
]; | ||
var handler = client_1.createDefaultCallbackHandler(); | ||
var numUri = _1.parseNumUri('aviva.co.uk:1'); | ||
var client = client_1.createClient(DEFAULT_RESOLVERS); | ||
client.setenv('prod'); | ||
loglevel_1.default.setLevel('debug'); | ||
loglevel_1.default.setLevel('info'); | ||
var ctx = client.createContext(numUri); | ||
client | ||
.retrieveNumRecord(ctx) | ||
.retrieveNumRecord(ctx, handler) | ||
.then(function (result) { | ||
loglevel_1.default.info(result); | ||
loglevel_1.default.info(handler); | ||
}, function (err) { | ||
loglevel_1.default.error(err); | ||
loglevel_1.default.info(handler); | ||
}) | ||
.catch(function (e) { | ||
loglevel_1.default.error(e); | ||
loglevel_1.default.info(handler); | ||
}); | ||
//# sourceMappingURL=scratch.js.map |
{ | ||
"name": "num-client", | ||
"version": "1.0.29", | ||
"version": "1.0.30", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
530230
3000