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

@json-rpc-tools/router

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@json-rpc-tools/router - npm Package Compare versions

Comparing version 1.5.6 to 1.5.7

4

dist/cjs/router.js

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

this.getTrailingWildcardRoutes().forEach(route => {
if (method.startsWith(route)) {
if (method.startsWith(route.replace("*", ""))) {
target = this.map[route];

@@ -31,3 +31,3 @@ }

this.getLeadingWildcardRoutes().forEach(route => {
if (method.endsWith(route)) {
if (method.endsWith(route.replace("*", ""))) {
target = this.map[route];

@@ -34,0 +34,0 @@ }

@@ -16,2 +16,2 @@ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("JsonRpcRouter",[],r):"object"==typeof exports?exports.JsonRpcRouter=r():e.JsonRpcRouter=r()}(this,(function(){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=6)}([function(e,r,t){"use strict";t.r(r),t.d(r,"__extends",(function(){return o})),t.d(r,"__assign",(function(){return i})),t.d(r,"__rest",(function(){return u})),t.d(r,"__decorate",(function(){return c})),t.d(r,"__param",(function(){return s})),t.d(r,"__metadata",(function(){return a})),t.d(r,"__awaiter",(function(){return f})),t.d(r,"__generator",(function(){return d})),t.d(r,"__createBinding",(function(){return l})),t.d(r,"__exportStar",(function(){return R})),t.d(r,"__values",(function(){return p})),t.d(r,"__read",(function(){return _})),t.d(r,"__spread",(function(){return v})),t.d(r,"__spreadArrays",(function(){return E})),t.d(r,"__await",(function(){return y})),t.d(r,"__asyncGenerator",(function(){return O})),t.d(r,"__asyncDelegator",(function(){return h})),t.d(r,"__asyncValues",(function(){return b})),t.d(r,"__makeTemplateObject",(function(){return g})),t.d(r,"__importStar",(function(){return S})),t.d(r,"__importDefault",(function(){return m})),t.d(r,"__classPrivateFieldGet",(function(){return P})),t.d(r,"__classPrivateFieldSet",(function(){return I}));

***************************************************************************** */
var n=function(e,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};function o(e,r){function t(){this.constructor=e}n(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}var i=function(){return(i=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function u(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}function c(e,r,t,n){var o,i=arguments.length,u=i<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,r,t,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(u=(i<3?o(u):i>3?o(r,t,u):o(r,t))||u);return i>3&&u&&Object.defineProperty(r,t,u),u}function s(e,r){return function(t,n){r(t,n,e)}}function a(e,r){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,r)}function f(e,r,t,n){return new(t||(t=Promise))((function(o,i){function u(e){try{s(n.next(e))}catch(e){i(e)}}function c(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(u,c)}s((n=n.apply(e,r||[])).next())}))}function d(e,r){var t,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;u;)try{if(t=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=r.call(e,u)}catch(e){i=[6,e],n=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function l(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]}function R(e,r){for(var t in e)"default"===t||r.hasOwnProperty(t)||(r[t]=e[t])}function p(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,i=t.call(e),u=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}function v(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(_(arguments[r]));return e}function E(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var n=Array(e),o=0;for(r=0;r<t;r++)for(var i=arguments[r],u=0,c=i.length;u<c;u++,o++)n[o]=i[u];return n}function y(e){return this instanceof y?(this.v=e,this):new y(e)}function O(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=t.apply(e,r||[]),i=[];return n={},u("next"),u("throw"),u("return"),n[Symbol.asyncIterator]=function(){return this},n;function u(e){o[e]&&(n[e]=function(r){return new Promise((function(t,n){i.push([e,r,t,n])>1||c(e,r)}))})}function c(e,r){try{(t=o[e](r)).value instanceof y?Promise.resolve(t.value.v).then(s,a):f(i[0][2],t)}catch(e){f(i[0][3],e)}var t}function s(e){c("next",e)}function a(e){c("throw",e)}function f(e,r){e(r),i.shift(),i.length&&c(i[0][0],i[0][1])}}function h(e){var r,t;return r={},n("next"),n("throw",(function(e){throw e})),n("return"),r[Symbol.iterator]=function(){return this},r;function n(n,o){r[n]=e[n]?function(r){return(t=!t)?{value:y(e[n](r)),done:"return"===n}:o?o(r):r}:o}}function b(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,t=e[Symbol.asyncIterator];return t?t.call(e):(e=p(e),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(t){r[t]=e[t]&&function(r){return new Promise((function(n,o){(function(e,r,t,n){Promise.resolve(n).then((function(r){e({value:r,done:t})}),r)})(n,o,(r=e[t](r)).done,r.value)}))}}}function g(e,r){return Object.defineProperty?Object.defineProperty(e,"raw",{value:r}):e.raw=r,e}function S(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function m(e){return e&&e.__esModule?e:{default:e}}function P(e,r){if(!r.has(e))throw new TypeError("attempted to get private field on non-instance");return r.get(e)}function I(e,r,t){if(!r.has(e))throw new TypeError("attempted to set private field on non-instance");return r.set(e,t),t}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.STANDARD_ERROR_MAP=r.SERVER_ERROR_CODE_RANGE=r.RESERVED_ERROR_CODES=r.SERVER_ERROR=r.INTERNAL_ERROR=r.INVALID_PARAMS=r.METHOD_NOT_FOUND=r.INVALID_REQUEST=r.PARSE_ERROR=void 0,r.PARSE_ERROR="PARSE_ERROR",r.INVALID_REQUEST="INVALID_REQUEST",r.METHOD_NOT_FOUND="METHOD_NOT_FOUND",r.INVALID_PARAMS="INVALID_PARAMS",r.INTERNAL_ERROR="INTERNAL_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.RESERVED_ERROR_CODES=[-32700,-32600,-32601,-32602,-32603],r.SERVER_ERROR_CODE_RANGE=[-32e3,-32099],r.STANDARD_ERROR_MAP={[r.PARSE_ERROR]:{code:-32700,message:"Parse error"},[r.INVALID_REQUEST]:{code:-32600,message:"Invalid Request"},[r.METHOD_NOT_FOUND]:{code:-32601,message:"Method not found"},[r.INVALID_PARAMS]:{code:-32602,message:"Invalid params"},[r.INTERNAL_ERROR]:{code:-32603,message:"Internal error"},[r.SERVER_ERROR]:{code:-32e3,message:"Server error"}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IEvents=void 0;r.IEvents=class{}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IJsonRpcProvider=r.IBaseJsonRpcProvider=r.IJsonRpcConnection=void 0;const n=t(2);class o extends n.IEvents{constructor(e){super()}}r.IJsonRpcConnection=o;class i extends n.IEvents{constructor(){super()}}r.IBaseJsonRpcProvider=i;r.IJsonRpcProvider=class extends i{constructor(e){super()}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.JsonRpcRouter=void 0;const n=t(7);class o{constructor(e){this.routes=e,this.routes=e,this.map=this.register(e)}isSupported(e){return void 0!==this.getRouteTarget(e)}getRouteTarget(e){let r;const t=this.map[e];if(t&&(r=t),void 0===r&&this.getTrailingWildcardRoutes().forEach(t=>{e.startsWith(t)&&(r=this.map[t])}),void 0===r&&this.getLeadingWildcardRoutes().forEach(t=>{e.endsWith(t)&&(r=this.map[t])}),void 0===r){const e=this.map["*"];void 0!==e&&(r=this.map[e])}return r}getLeadingWildcardRoutes(){return Object.keys(this.map).filter(n.isValidLeadingWildcardRoute)}getTrailingWildcardRoutes(){return Object.keys(this.map).filter(n.isValidTrailingWildcardRoute)}register(e){const r={};return Object.keys(e).forEach(t=>{e[t].forEach(e=>{if(!n.isValidRoute(e))throw new Error("Route is invalid: "+e);if(void 0!==r[e])throw new Error(`Route already registred for route ${e} by provider ${r[e]} conflicting with provider ${t}`);r[e]=t})}),r}}r.JsonRpcRouter=o,r.default=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateJsonRpcError=r.getErrorByCode=r.getError=r.isValidErrorCode=r.isReservedErrorCode=r.isServerErrorCode=void 0;const n=t(1);function o(e){return e<=n.SERVER_ERROR_CODE_RANGE[0]&&e>=n.SERVER_ERROR_CODE_RANGE[1]}function i(e){return n.RESERVED_ERROR_CODES.includes(e)}function u(e){return o(e)||i(e)}function c(e){const r=Object.values(n.STANDARD_ERROR_MAP).find(r=>r.code===e);return r||n.STANDARD_ERROR_MAP[n.INTERNAL_ERROR]}r.isServerErrorCode=o,r.isReservedErrorCode=i,r.isValidErrorCode=u,r.getError=function(e){return Object.keys(n.STANDARD_ERROR_MAP).includes(e)?n.STANDARD_ERROR_MAP[e]:n.STANDARD_ERROR_MAP[n.INTERNAL_ERROR]},r.getErrorByCode=c,r.validateJsonRpcError=function(e){if(void 0===e.error.code)return{valid:!1,error:"Missing code for JSON-RPC error"};if(void 0===e.error.message)return{valid:!1,error:"Missing message for JSON-RPC error"};if(!u(e.error.code))return{valid:!1,error:"Invalid error code for JSON-RPC error code: "+e.error.code};if(i(e.error.code)){const r=c(e.error.code);if(r.message!==n.STANDARD_ERROR_MAP[n.INTERNAL_ERROR].message&&e.error.message===r.message)return{valid:!1,error:"Invalid error message for JSON-RPC error code: "+e.error.code}}return{valid:!0}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=t(0),o=n.__importDefault(t(4));n.__exportStar(t(4),r),r.default=o.default},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=t(0);n.__exportStar(t(1),r),n.__exportStar(t(5),r),n.__exportStar(t(8),r),n.__exportStar(t(9),r),n.__exportStar(t(10),r),n.__exportStar(t(18),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatErrorMessage=r.formatJsonRpcError=r.formatJsonRpcResult=r.formatJsonRpcRequest=r.payloadId=void 0;const n=t(5),o=t(1);function i(){return Date.now()*Math.pow(10,3)+Math.floor(Math.random()*Math.pow(10,3))}function u(e){if(void 0===e)return n.getError(o.INTERNAL_ERROR);if("string"==typeof e&&(e=Object.assign(Object.assign({},n.getError(o.SERVER_ERROR)),{message:e})),n.isReservedErrorCode(e.code)&&(e=n.getErrorByCode(e.code)),!n.isServerErrorCode(e.code))throw new Error("Error code is not in server code range");return e}r.payloadId=i,r.formatJsonRpcRequest=function(e,r,t){return{id:t||i(),jsonrpc:"2.0",method:e,params:r}},r.formatJsonRpcResult=function(e,r){return{id:e,jsonrpc:"2.0",result:r}},r.formatJsonRpcError=function(e,r){return{id:e,jsonrpc:"2.0",error:u(r)}},r.formatErrorMessage=u},function(e,r,t){"use strict";function n(e){return"*"===e}function o(e){return!!n(e)||!!e.includes("*")&&(2===e.split("*").length&&1===e.split("*").filter(e=>""===e.trim()).length)}Object.defineProperty(r,"__esModule",{value:!0}),r.isValidTrailingWildcardRoute=r.isValidLeadingWildcardRoute=r.isValidWildcardRoute=r.isValidDefaultRoute=r.isValidRoute=void 0,r.isValidRoute=function(e){return e.includes("*")?o(e):!/\W/g.test(e)},r.isValidDefaultRoute=n,r.isValidWildcardRoute=o,r.isValidLeadingWildcardRoute=function(e){return!n(e)&&o(e)&&!e.split("*")[0].trim()},r.isValidTrailingWildcardRoute=function(e){return!n(e)&&o(e)&&!e.split("*")[1].trim()}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});t(0).__exportStar(t(11),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=t(0);n.__exportStar(t(12),r),n.__exportStar(t(13),r),n.__exportStar(t(2),r),n.__exportStar(t(14),r),n.__exportStar(t(3),r),n.__exportStar(t(15),r),n.__exportStar(t(16),r),n.__exportStar(t(17),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IBlockchainProvider=r.IBlockchainAuthenticator=r.IPendingRequests=void 0;const n=t(2),o=t(3);r.IPendingRequests=class{constructor(e){this.storage=e}};class i extends n.IEvents{constructor(e){super(),this.config=e}}r.IBlockchainAuthenticator=i;class u extends o.IJsonRpcProvider{constructor(e,r){super(e)}}r.IBlockchainProvider=u},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IMultiServiceProvider=void 0;const n=t(3);class o extends n.IBaseJsonRpcProvider{constructor(e){super(),this.config=e}}r.IMultiServiceProvider=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IJsonRpcRouter=void 0;r.IJsonRpcRouter=class{constructor(e){this.routes=e}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IJsonRpcValidator=void 0;r.IJsonRpcValidator=class{constructor(e){this.schemas=e}}},function(e,r,t){"use strict";function n(e){return"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}Object.defineProperty(r,"__esModule",{value:!0}),r.isJsonRpcValidationInvalid=r.isJsonRpcError=r.isJsonRpcResult=r.isJsonRpcResponse=r.isJsonRpcRequest=r.isJsonRpcPayload=void 0,r.isJsonRpcPayload=n,r.isJsonRpcRequest=function(e){return n(e)&&"method"in e},r.isJsonRpcResponse=function(e){return n(e)&&("result"in e||"error"in e)},r.isJsonRpcResult=function(e){return"result"in e},r.isJsonRpcError=function(e){return"error"in e},r.isJsonRpcValidationInvalid=function(e){return"error"in e&&!1===e.valid}}])}));
var n=function(e,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};function o(e,r){function t(){this.constructor=e}n(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}var i=function(){return(i=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function u(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}function c(e,r,t,n){var o,i=arguments.length,u=i<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,r,t,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(u=(i<3?o(u):i>3?o(r,t,u):o(r,t))||u);return i>3&&u&&Object.defineProperty(r,t,u),u}function s(e,r){return function(t,n){r(t,n,e)}}function a(e,r){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,r)}function f(e,r,t,n){return new(t||(t=Promise))((function(o,i){function u(e){try{s(n.next(e))}catch(e){i(e)}}function c(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(u,c)}s((n=n.apply(e,r||[])).next())}))}function d(e,r){var t,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;u;)try{if(t=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=r.call(e,u)}catch(e){i=[6,e],n=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function l(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]}function R(e,r){for(var t in e)"default"===t||r.hasOwnProperty(t)||(r[t]=e[t])}function p(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,i=t.call(e),u=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}function v(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(_(arguments[r]));return e}function E(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var n=Array(e),o=0;for(r=0;r<t;r++)for(var i=arguments[r],u=0,c=i.length;u<c;u++,o++)n[o]=i[u];return n}function y(e){return this instanceof y?(this.v=e,this):new y(e)}function O(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=t.apply(e,r||[]),i=[];return n={},u("next"),u("throw"),u("return"),n[Symbol.asyncIterator]=function(){return this},n;function u(e){o[e]&&(n[e]=function(r){return new Promise((function(t,n){i.push([e,r,t,n])>1||c(e,r)}))})}function c(e,r){try{(t=o[e](r)).value instanceof y?Promise.resolve(t.value.v).then(s,a):f(i[0][2],t)}catch(e){f(i[0][3],e)}var t}function s(e){c("next",e)}function a(e){c("throw",e)}function f(e,r){e(r),i.shift(),i.length&&c(i[0][0],i[0][1])}}function h(e){var r,t;return r={},n("next"),n("throw",(function(e){throw e})),n("return"),r[Symbol.iterator]=function(){return this},r;function n(n,o){r[n]=e[n]?function(r){return(t=!t)?{value:y(e[n](r)),done:"return"===n}:o?o(r):r}:o}}function b(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,t=e[Symbol.asyncIterator];return t?t.call(e):(e=p(e),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(t){r[t]=e[t]&&function(r){return new Promise((function(n,o){(function(e,r,t,n){Promise.resolve(n).then((function(r){e({value:r,done:t})}),r)})(n,o,(r=e[t](r)).done,r.value)}))}}}function g(e,r){return Object.defineProperty?Object.defineProperty(e,"raw",{value:r}):e.raw=r,e}function S(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function m(e){return e&&e.__esModule?e:{default:e}}function P(e,r){if(!r.has(e))throw new TypeError("attempted to get private field on non-instance");return r.get(e)}function I(e,r,t){if(!r.has(e))throw new TypeError("attempted to set private field on non-instance");return r.set(e,t),t}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.STANDARD_ERROR_MAP=r.SERVER_ERROR_CODE_RANGE=r.RESERVED_ERROR_CODES=r.SERVER_ERROR=r.INTERNAL_ERROR=r.INVALID_PARAMS=r.METHOD_NOT_FOUND=r.INVALID_REQUEST=r.PARSE_ERROR=void 0,r.PARSE_ERROR="PARSE_ERROR",r.INVALID_REQUEST="INVALID_REQUEST",r.METHOD_NOT_FOUND="METHOD_NOT_FOUND",r.INVALID_PARAMS="INVALID_PARAMS",r.INTERNAL_ERROR="INTERNAL_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.RESERVED_ERROR_CODES=[-32700,-32600,-32601,-32602,-32603],r.SERVER_ERROR_CODE_RANGE=[-32e3,-32099],r.STANDARD_ERROR_MAP={[r.PARSE_ERROR]:{code:-32700,message:"Parse error"},[r.INVALID_REQUEST]:{code:-32600,message:"Invalid Request"},[r.METHOD_NOT_FOUND]:{code:-32601,message:"Method not found"},[r.INVALID_PARAMS]:{code:-32602,message:"Invalid params"},[r.INTERNAL_ERROR]:{code:-32603,message:"Internal error"},[r.SERVER_ERROR]:{code:-32e3,message:"Server error"}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IEvents=void 0;r.IEvents=class{}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IJsonRpcProvider=r.IBaseJsonRpcProvider=r.IJsonRpcConnection=void 0;const n=t(2);class o extends n.IEvents{constructor(e){super()}}r.IJsonRpcConnection=o;class i extends n.IEvents{constructor(){super()}}r.IBaseJsonRpcProvider=i;r.IJsonRpcProvider=class extends i{constructor(e){super()}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.JsonRpcRouter=void 0;const n=t(7);class o{constructor(e){this.routes=e,this.routes=e,this.map=this.register(e)}isSupported(e){return void 0!==this.getRouteTarget(e)}getRouteTarget(e){let r;const t=this.map[e];if(t&&(r=t),void 0===r&&this.getTrailingWildcardRoutes().forEach(t=>{e.startsWith(t.replace("*",""))&&(r=this.map[t])}),void 0===r&&this.getLeadingWildcardRoutes().forEach(t=>{e.endsWith(t.replace("*",""))&&(r=this.map[t])}),void 0===r){const e=this.map["*"];void 0!==e&&(r=this.map[e])}return r}getLeadingWildcardRoutes(){return Object.keys(this.map).filter(n.isValidLeadingWildcardRoute)}getTrailingWildcardRoutes(){return Object.keys(this.map).filter(n.isValidTrailingWildcardRoute)}register(e){const r={};return Object.keys(e).forEach(t=>{e[t].forEach(e=>{if(!n.isValidRoute(e))throw new Error("Route is invalid: "+e);if(void 0!==r[e])throw new Error(`Route already registred for route ${e} by provider ${r[e]} conflicting with provider ${t}`);r[e]=t})}),r}}r.JsonRpcRouter=o,r.default=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateJsonRpcError=r.getErrorByCode=r.getError=r.isValidErrorCode=r.isReservedErrorCode=r.isServerErrorCode=void 0;const n=t(1);function o(e){return e<=n.SERVER_ERROR_CODE_RANGE[0]&&e>=n.SERVER_ERROR_CODE_RANGE[1]}function i(e){return n.RESERVED_ERROR_CODES.includes(e)}function u(e){return o(e)||i(e)}function c(e){const r=Object.values(n.STANDARD_ERROR_MAP).find(r=>r.code===e);return r||n.STANDARD_ERROR_MAP[n.INTERNAL_ERROR]}r.isServerErrorCode=o,r.isReservedErrorCode=i,r.isValidErrorCode=u,r.getError=function(e){return Object.keys(n.STANDARD_ERROR_MAP).includes(e)?n.STANDARD_ERROR_MAP[e]:n.STANDARD_ERROR_MAP[n.INTERNAL_ERROR]},r.getErrorByCode=c,r.validateJsonRpcError=function(e){if(void 0===e.error.code)return{valid:!1,error:"Missing code for JSON-RPC error"};if(void 0===e.error.message)return{valid:!1,error:"Missing message for JSON-RPC error"};if(!u(e.error.code))return{valid:!1,error:"Invalid error code for JSON-RPC error code: "+e.error.code};if(i(e.error.code)){const r=c(e.error.code);if(r.message!==n.STANDARD_ERROR_MAP[n.INTERNAL_ERROR].message&&e.error.message===r.message)return{valid:!1,error:"Invalid error message for JSON-RPC error code: "+e.error.code}}return{valid:!0}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=t(0),o=n.__importDefault(t(4));n.__exportStar(t(4),r),r.default=o.default},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=t(0);n.__exportStar(t(1),r),n.__exportStar(t(5),r),n.__exportStar(t(8),r),n.__exportStar(t(9),r),n.__exportStar(t(10),r),n.__exportStar(t(18),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.formatErrorMessage=r.formatJsonRpcError=r.formatJsonRpcResult=r.formatJsonRpcRequest=r.payloadId=void 0;const n=t(5),o=t(1);function i(){return Date.now()*Math.pow(10,3)+Math.floor(Math.random()*Math.pow(10,3))}function u(e){if(void 0===e)return n.getError(o.INTERNAL_ERROR);if("string"==typeof e&&(e=Object.assign(Object.assign({},n.getError(o.SERVER_ERROR)),{message:e})),n.isReservedErrorCode(e.code)&&(e=n.getErrorByCode(e.code)),!n.isServerErrorCode(e.code))throw new Error("Error code is not in server code range");return e}r.payloadId=i,r.formatJsonRpcRequest=function(e,r,t){return{id:t||i(),jsonrpc:"2.0",method:e,params:r}},r.formatJsonRpcResult=function(e,r){return{id:e,jsonrpc:"2.0",result:r}},r.formatJsonRpcError=function(e,r){return{id:e,jsonrpc:"2.0",error:u(r)}},r.formatErrorMessage=u},function(e,r,t){"use strict";function n(e){return"*"===e}function o(e){return!!n(e)||!!e.includes("*")&&(2===e.split("*").length&&1===e.split("*").filter(e=>""===e.trim()).length)}Object.defineProperty(r,"__esModule",{value:!0}),r.isValidTrailingWildcardRoute=r.isValidLeadingWildcardRoute=r.isValidWildcardRoute=r.isValidDefaultRoute=r.isValidRoute=void 0,r.isValidRoute=function(e){return e.includes("*")?o(e):!/\W/g.test(e)},r.isValidDefaultRoute=n,r.isValidWildcardRoute=o,r.isValidLeadingWildcardRoute=function(e){return!n(e)&&o(e)&&!e.split("*")[0].trim()},r.isValidTrailingWildcardRoute=function(e){return!n(e)&&o(e)&&!e.split("*")[1].trim()}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});t(0).__exportStar(t(11),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=t(0);n.__exportStar(t(12),r),n.__exportStar(t(13),r),n.__exportStar(t(2),r),n.__exportStar(t(14),r),n.__exportStar(t(3),r),n.__exportStar(t(15),r),n.__exportStar(t(16),r),n.__exportStar(t(17),r)},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IBlockchainProvider=r.IBlockchainAuthenticator=r.IPendingRequests=void 0;const n=t(2),o=t(3);r.IPendingRequests=class{constructor(e){this.storage=e}};class i extends n.IEvents{constructor(e){super(),this.config=e}}r.IBlockchainAuthenticator=i;class u extends o.IJsonRpcProvider{constructor(e,r){super(e)}}r.IBlockchainProvider=u},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IMultiServiceProvider=void 0;const n=t(3);class o extends n.IBaseJsonRpcProvider{constructor(e){super(),this.config=e}}r.IMultiServiceProvider=o},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IJsonRpcRouter=void 0;r.IJsonRpcRouter=class{constructor(e){this.routes=e}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IJsonRpcValidator=void 0;r.IJsonRpcValidator=class{constructor(e){this.schemas=e}}},function(e,r,t){"use strict";function n(e){return"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}Object.defineProperty(r,"__esModule",{value:!0}),r.isJsonRpcValidationInvalid=r.isJsonRpcError=r.isJsonRpcResult=r.isJsonRpcResponse=r.isJsonRpcRequest=r.isJsonRpcPayload=void 0,r.isJsonRpcPayload=n,r.isJsonRpcRequest=function(e){return n(e)&&"method"in e},r.isJsonRpcResponse=function(e){return n(e)&&("result"in e||"error"in e)},r.isJsonRpcResult=function(e){return"result"in e},r.isJsonRpcError=function(e){return"error"in e},r.isJsonRpcValidationInvalid=function(e){return"error"in e&&!1===e.valid}}])}));
{
"name": "@json-rpc-tools/router",
"description": "Router for JSON-RPC",
"version": "1.5.6",
"version": "1.5.7",
"author": "Pedro Gomes <github.com/pedrouid>",

@@ -37,4 +37,4 @@ "homepage": "https://github.com/pedrouid/json-rpc-tools/",

"dependencies": {
"@json-rpc-tools/utils": "^1.5.6",
"@json-rpc-tools/validator": "^1.5.6",
"@json-rpc-tools/utils": "^1.5.7",
"@json-rpc-tools/validator": "^1.5.7",
"lodash.difference": "^4.5.0"

@@ -41,0 +41,0 @@ },

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