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

jsonrpc-ts-client

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonrpc-ts-client - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

12

dist/jsonrpc-ts-client.cjs.development.js

@@ -1054,8 +1054,16 @@ 'use strict';

if (!hasProperties(v, "jsonrpc")) {
throw new InvalidJsonRpcResponseError("Invalid response " + JSON.stringify(v, undefined, 2));
throw new InvalidJsonRpcResponseError("Response should contain \"jsonrpc: \"2.0\"\"");
}
if (!hasProperties(v, "id")) {
throw new InvalidJsonRpcResponseError("Response must have an ID property (even if that ID is null)");
}
if (v.id === undefined) {
throw new InvalidJsonRpcResponseError("Response ID should be null rather than undefined");
}
if (hasProperties(v, "result", "error")) {
if (v.result && v.error) {
throw new InvalidJsonRpcResponseError("Result and error member should not exist together (https://www.jsonrpc.org/specification#5)");
throw new InvalidJsonRpcResponseError("Result and error member should not exist together");
}

@@ -1062,0 +1070,0 @@ }

2

dist/jsonrpc-ts-client.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("axios"),r=require("debug");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),o=e(r);function i(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)}))}}function u(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,s(t,r)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function s(t,r){return s=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},s(t,r)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,r,e){return h=f()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(t,n));return e&&s(o,e.prototype),o},h.apply(null,arguments)}function l(t){var r="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return h(t,arguments,c(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)},l(t)}var p=0;function d(t){return"__private_"+p+++"_"+t}function v(t,r){if(!Object.prototype.hasOwnProperty.call(t,r))throw new TypeError("attempted to use private field on non-instance");return t}var y={exports:{}};!function(t){var r=function(t){var r,e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{c({},"")}catch(t){c=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=Object.create((r&&r.prototype instanceof y?r:y).prototype),i=new F(n||[]);return o._invoke=function(t,r,e){var n=h;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw i;return S()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=L(a,e);if(u){if(u===v)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(n===h)throw n=d,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n=p;var c=f(t,r,e);if("normal"===c.type){if(n=e.done?d:l,c.arg===v)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n=d,e.method="throw",e.arg=c.arg)}}}(t,e,i),o}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var h="suspendedStart",l="suspendedYield",p="executing",d="completed",v={};function y(){}function w(){}function g(){}var m={};c(m,i,(function(){return this}));var b=Object.getPrototypeOf,x=b&&b(b(G([])));x&&x!==e&&n.call(x,i)&&(m=x);var O=g.prototype=y.prototype=Object.create(m);function j(t){["next","throw","return"].forEach((function(r){c(t,r,(function(t){return this._invoke(r,t)}))}))}function E(t,r){function e(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,h=s.value;return h&&"object"==typeof h&&n.call(h,"__await")?r.resolve(h.__await).then((function(t){e("next",t,a,u)}),(function(t){e("throw",t,a,u)})):r.resolve(h).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,u)}))}u(c.arg)}var o;this._invoke=function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}}function L(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,L(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function _(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function P(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function F(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function G(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return a.next=a}}return{next:S}}function S(){return{value:r,done:!0}}return w.prototype=g,c(O,"constructor",g),c(g,"constructor",w),w.displayName=c(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,c(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},t.awrap=function(t){return{__await:t}},j(E.prototype),c(E.prototype,a,(function(){return this})),t.AsyncIterator=E,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new E(s(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),c(O,u,"Generator"),c(O,i,(function(){return this})),c(O,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=G,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return u.type="throw",u.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),v},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),P(e),v}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;P(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:G(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),v}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}(y);var w=y.exports,g=function(){function t(){}var r=t.prototype;return r.map=function(t){switch(this.type){case"error":return new b(this.error);case"success":return new m(t(this.result))}},r.ap=function(t){switch(this.type){case"error":return new b(this.error);case"success":return t.isSuccess()?t.result(this.result):this.ap(t)}},r.isError=function(){return"error"===this.type},r.isSuccess=function(){return!this.isError()},r.onSuccess=function(t){return this.isSuccess()&&t(this.result),this},r.onError=function(t){return this.isError()&&t(this.error),this},r.unsafeCoerce=function(){if(this.isError())throw this.error;return this.result},t}(),m=function(t){function r(r){var e;return(e=t.call(this)||this).result=void 0,e.type="success",e.result=r,e}return u(r,t),r}(g),b=function(t){function r(r){var e;return(e=t.call(this)||this).error=void 0,e.type="error",e.error=r,e}return u(r,t),r}(g),x=function(t){return null!==t&&"object"==typeof t},O=function(t){for(var r=arguments.length,e=new Array(r>1?r-1:0),n=1;n<r;n++)e[n-1]=arguments[n];return!!t&&e.every((function(r){return Object.prototype.hasOwnProperty.call(t,r)}))},j=function(t){function r(r){return t.call(this,"Your server spec must conform to: https://www.jsonrpc.org/specification. "+r)||this}return u(r,t),r}(l(Error));function E(t){if(!x(t))throw new j("Response is not object, got: "+JSON.stringify(t,void 0,2));if(!O(t,"jsonrpc"))throw new j("Invalid response "+JSON.stringify(t,void 0,2));if(O(t,"result","error")&&t.result&&t.error)throw new j("Result and error member should not exist together (https://www.jsonrpc.org/specification#5)");if(O(t,"error")){if(!x(t.error))throw new j('"error" field should be object');if(!O(t.error,"code","message"))throw new j('invalid "error" field shape: '+JSON.stringify(t.error,void 0,2))}}function L(t){if(!Array.isArray(t))throw new j("Batch response should be an array");t.forEach(E)}var _=function(t,r,e){this.method=void 0,this.params=void 0,this.id=void 0,this.jsonrpc="2.0",this.method=t,this.params=r,this.id=e},P=function(t){return"error"in(r=t)&&null!==r.error?new b(t.error):new m(t.result);var r},F=o.default("jsonrpc-ts-client"),G=function(){function t(t){this.url=void 0,this.headers=void 0,this.idGeneratorFn=void 0,this.url=t.url,this.headers=t.headers,this.idGeneratorFn=t.idGeneratorFn,this.validate()}var r=t.prototype;return r.validate=function(){if(!this.url)throw new Error("no url set.")},r.merge=function(t){t.url&&(this.url=t.url),t.idGeneratorFn&&(this.idGeneratorFn=t.idGeneratorFn),t.headers&&(t.headers=this.headers),this.validate()},t}(),S=d("client"),R=d("buildAxiosClient"),N=function(){function t(t){Object.defineProperty(this,R,{value:k}),Object.defineProperty(this,S,{writable:!0,value:void 0}),this.config=void 0,this.config=new G(t),this.config.validate(),v(this,S)[S]=v(this,R)[R](this.config)}var r=t.prototype;return r.exec=function(){var t=a(w.mark((function t(r,e,n,o){var i,a,u,c,s,f;return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,o&&(this.config.merge(o),v(this,S)[S]=v(this,R)[R](this.config)),u=new _(r,e,n||(null==(i=(a=this.config).idGeneratorFn)?void 0:i.call(a))),t.next=5,v(this,S)[S]({method:"post",data:u});case 5:return E(s=(c=t.sent).data),F(c),f=P(s),t.abrupt("return",f);case 13:throw t.prev=13,t.t0=t.catch(0),F(t.t0),t.t0;case 17:case"end":return t.stop()}}),t,this,[[0,13]])})));return function(r,e,n,o){return t.apply(this,arguments)}}(),r.execBatch=function(){var t=a(w.mark((function t(r){var e,n,o,i,a=this;return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,e=r.map((function(t){return new _(t.method,t.params,t.id||(null==a.config.idGeneratorFn?void 0:a.config.idGeneratorFn()))})),t.next=4,v(this,S)[S]({method:"post",data:e});case 4:return L(o=(n=t.sent).data),F(n),i=o.map(P),t.abrupt("return",i);case 12:throw t.prev=12,t.t0=t.catch(0),F(t.t0),t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,12]])})));return function(r){return t.apply(this,arguments)}}(),t}();function k(t){return n.default.create({baseURL:t.url,headers:t.headers,validateStatus:function(){return!0}})}exports.JsonRpcClient=N,exports.JsonRpcConfig=G,exports.default=N;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("axios"),r=require("debug");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),o=e(r);function i(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)}))}}function u(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,s(t,r)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function s(t,r){return s=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},s(t,r)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,r,e){return h=f()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(t,n));return e&&s(o,e.prototype),o},h.apply(null,arguments)}function l(t){var r="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return h(t,arguments,c(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)},l(t)}var p=0;function d(t){return"__private_"+p+++"_"+t}function v(t,r){if(!Object.prototype.hasOwnProperty.call(t,r))throw new TypeError("attempted to use private field on non-instance");return t}var y={exports:{}};!function(t){var r=function(t){var r,e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{c({},"")}catch(t){c=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=Object.create((r&&r.prototype instanceof y?r:y).prototype),i=new F(n||[]);return o._invoke=function(t,r,e){var n=h;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw i;return R()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=L(a,e);if(u){if(u===v)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(n===h)throw n=d,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n=p;var c=f(t,r,e);if("normal"===c.type){if(n=e.done?d:l,c.arg===v)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n=d,e.method="throw",e.arg=c.arg)}}}(t,e,i),o}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var h="suspendedStart",l="suspendedYield",p="executing",d="completed",v={};function y(){}function w(){}function g(){}var m={};c(m,i,(function(){return this}));var b=Object.getPrototypeOf,x=b&&b(b(G([])));x&&x!==e&&n.call(x,i)&&(m=x);var O=g.prototype=y.prototype=Object.create(m);function j(t){["next","throw","return"].forEach((function(r){c(t,r,(function(t){return this._invoke(r,t)}))}))}function E(t,r){function e(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,h=s.value;return h&&"object"==typeof h&&n.call(h,"__await")?r.resolve(h.__await).then((function(t){e("next",t,a,u)}),(function(t){e("throw",t,a,u)})):r.resolve(h).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,u)}))}u(c.arg)}var o;this._invoke=function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}}function L(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,L(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function _(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function P(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function F(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function G(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return a.next=a}}return{next:R}}function R(){return{value:r,done:!0}}return w.prototype=g,c(O,"constructor",g),c(g,"constructor",w),w.displayName=c(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,c(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},t.awrap=function(t){return{__await:t}},j(E.prototype),c(E.prototype,a,(function(){return this})),t.AsyncIterator=E,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new E(s(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),c(O,u,"Generator"),c(O,i,(function(){return this})),c(O,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=G,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return u.type="throw",u.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),v},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),P(e),v}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;P(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:G(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),v}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}(y);var w=y.exports,g=function(){function t(){}var r=t.prototype;return r.map=function(t){switch(this.type){case"error":return new b(this.error);case"success":return new m(t(this.result))}},r.ap=function(t){switch(this.type){case"error":return new b(this.error);case"success":return t.isSuccess()?t.result(this.result):this.ap(t)}},r.isError=function(){return"error"===this.type},r.isSuccess=function(){return!this.isError()},r.onSuccess=function(t){return this.isSuccess()&&t(this.result),this},r.onError=function(t){return this.isError()&&t(this.error),this},r.unsafeCoerce=function(){if(this.isError())throw this.error;return this.result},t}(),m=function(t){function r(r){var e;return(e=t.call(this)||this).result=void 0,e.type="success",e.result=r,e}return u(r,t),r}(g),b=function(t){function r(r){var e;return(e=t.call(this)||this).error=void 0,e.type="error",e.error=r,e}return u(r,t),r}(g),x=function(t){return null!==t&&"object"==typeof t},O=function(t){for(var r=arguments.length,e=new Array(r>1?r-1:0),n=1;n<r;n++)e[n-1]=arguments[n];return!!t&&e.every((function(r){return Object.prototype.hasOwnProperty.call(t,r)}))},j=function(t){function r(r){return t.call(this,"Your server spec must conform to: https://www.jsonrpc.org/specification. "+r)||this}return u(r,t),r}(l(Error));function E(t){if(!x(t))throw new j("Response is not object, got: "+JSON.stringify(t,void 0,2));if(!O(t,"jsonrpc"))throw new j('Response should contain "jsonrpc: "2.0""');if(!O(t,"id"))throw new j("Response must have an ID property (even if that ID is null)");if(void 0===t.id)throw new j("Response ID should be null rather than undefined");if(O(t,"result","error")&&t.result&&t.error)throw new j("Result and error member should not exist together");if(O(t,"error")){if(!x(t.error))throw new j('"error" field should be object');if(!O(t.error,"code","message"))throw new j('invalid "error" field shape: '+JSON.stringify(t.error,void 0,2))}}function L(t){if(!Array.isArray(t))throw new j("Batch response should be an array");t.forEach(E)}var _=function(t,r,e){this.method=void 0,this.params=void 0,this.id=void 0,this.jsonrpc="2.0",this.method=t,this.params=r,this.id=e},P=function(t){return"error"in(r=t)&&null!==r.error?new b(t.error):new m(t.result);var r},F=o.default("jsonrpc-ts-client"),G=function(){function t(t){this.url=void 0,this.headers=void 0,this.idGeneratorFn=void 0,this.url=t.url,this.headers=t.headers,this.idGeneratorFn=t.idGeneratorFn,this.validate()}var r=t.prototype;return r.validate=function(){if(!this.url)throw new Error("no url set.")},r.merge=function(t){t.url&&(this.url=t.url),t.idGeneratorFn&&(this.idGeneratorFn=t.idGeneratorFn),t.headers&&(t.headers=this.headers),this.validate()},t}(),R=d("client"),S=d("buildAxiosClient"),k=function(){function t(t){Object.defineProperty(this,S,{value:N}),Object.defineProperty(this,R,{writable:!0,value:void 0}),this.config=void 0,this.config=new G(t),this.config.validate(),v(this,R)[R]=v(this,S)[S](this.config)}var r=t.prototype;return r.exec=function(){var t=a(w.mark((function t(r,e,n,o){var i,a,u,c,s,f;return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,o&&(this.config.merge(o),v(this,R)[R]=v(this,S)[S](this.config)),u=new _(r,e,n||(null==(i=(a=this.config).idGeneratorFn)?void 0:i.call(a))),t.next=5,v(this,R)[R]({method:"post",data:u});case 5:return E(s=(c=t.sent).data),F(c),f=P(s),t.abrupt("return",f);case 13:throw t.prev=13,t.t0=t.catch(0),F(t.t0),t.t0;case 17:case"end":return t.stop()}}),t,this,[[0,13]])})));return function(r,e,n,o){return t.apply(this,arguments)}}(),r.execBatch=function(){var t=a(w.mark((function t(r){var e,n,o,i,a=this;return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,e=r.map((function(t){return new _(t.method,t.params,t.id||(null==a.config.idGeneratorFn?void 0:a.config.idGeneratorFn()))})),t.next=4,v(this,R)[R]({method:"post",data:e});case 4:return L(o=(n=t.sent).data),F(n),i=o.map(P),t.abrupt("return",i);case 12:throw t.prev=12,t.t0=t.catch(0),F(t.t0),t.t0;case 16:case"end":return t.stop()}}),t,this,[[0,12]])})));return function(r){return t.apply(this,arguments)}}(),t}();function N(t){return n.default.create({baseURL:t.url,headers:t.headers,validateStatus:function(){return!0}})}exports.JsonRpcClient=k,exports.JsonRpcConfig=G,exports.default=k;
//# sourceMappingURL=jsonrpc-ts-client.cjs.production.min.js.map

@@ -1045,8 +1045,16 @@ import axios from 'axios';

if (!hasProperties(v, "jsonrpc")) {
throw new InvalidJsonRpcResponseError("Invalid response " + JSON.stringify(v, undefined, 2));
throw new InvalidJsonRpcResponseError("Response should contain \"jsonrpc: \"2.0\"\"");
}
if (!hasProperties(v, "id")) {
throw new InvalidJsonRpcResponseError("Response must have an ID property (even if that ID is null)");
}
if (v.id === undefined) {
throw new InvalidJsonRpcResponseError("Response ID should be null rather than undefined");
}
if (hasProperties(v, "result", "error")) {
if (v.result && v.error) {
throw new InvalidJsonRpcResponseError("Result and error member should not exist together (https://www.jsonrpc.org/specification#5)");
throw new InvalidJsonRpcResponseError("Result and error member should not exist together");
}

@@ -1053,0 +1061,0 @@ }

import { Either } from "./either";
export interface JsonRpcError {
jsonrpc: "2.0";
code: number;
message: string;
data?: any;
id: null | string | number;
}
export declare const isJsonRpcError: (v: object) => v is JsonRpcError;
interface IJsonRpcResponse {

@@ -9,0 +9,0 @@ jsonrpc: "2.0";

{
"version": "0.2.1",
"version": "0.2.2",
"license": "MIT",

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

@@ -5,11 +5,8 @@ import { Either, ErrorResponse, SuccessResponse } from "./either";

export interface JsonRpcError {
jsonrpc: "2.0";
code: number;
message: string;
data?: any;
id: null | string | number;
}
export const isJsonRpcError = (v: object): v is JsonRpcError => {
return hasProperties(v, "code", "message");
};
interface IJsonRpcResponse {

@@ -58,9 +55,19 @@ jsonrpc: "2.0";

throw new InvalidJsonRpcResponseError(
`Invalid response ${JSON.stringify(v, undefined, 2)}`
`Response should contain "jsonrpc: "2.0""`
);
}
if (!hasProperties(v, "id")) {
throw new InvalidJsonRpcResponseError(
`Response must have an ID property (even if that ID is null)`
);
}
if (v.id === undefined) {
throw new InvalidJsonRpcResponseError(
"Response ID should be null rather than undefined"
);
}
if (hasProperties(v, "result", "error")) {
if (v.result && v.error) {
throw new InvalidJsonRpcResponseError(
"Result and error member should not exist together (https://www.jsonrpc.org/specification#5)"
"Result and error member should not exist together"
);

@@ -67,0 +74,0 @@ }

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