@orbis-systems/orbis-api-client
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_Quotes=require("./categories/Quotes"),_Quotes2=_interopRequireDefault(_Quotes),_Research=require("./categories/Research"),_Research2=_interopRequireDefault(_Research),_User=require("./categories/User"),_User2=_interopRequireDefault(_User),_Options=require("./categories/Options"),_Options2=_interopRequireDefault(_Options),_Advisory=require("./categories/Advisory"),_Advisory2=_interopRequireDefault(_Advisory),_Watchlists=require("./categories/Watchlists"),_Watchlists2=_interopRequireDefault(_Watchlists),_ETFs=require("./categories/ETFs"),_ETFs2=_interopRequireDefault(_ETFs),_News=require("./categories/News"),_News2=_interopRequireDefault(_News),_CorporateActions=require("./categories/CorporateActions"),_CorporateActions2=_interopRequireDefault(_CorporateActions),_LocalStorage=require("./session_stores/LocalStorage"),_LocalStorage2=_interopRequireDefault(_LocalStorage),_axios=require("axios"),_axios2=_interopRequireDefault(_axios),_jsonwebtoken=require("jsonwebtoken"),_jsonwebtoken2=_interopRequireDefault(_jsonwebtoken);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _asyncToGenerator(a){return function(){var b=a.apply(this,arguments);return new Promise(function(a,c){function d(e,f){try{var g=b[e](f),h=g.value}catch(a){return void c(a)}return g.done?void a(h):Promise.resolve(h).then(function(a){d("next",a)},function(a){d("throw",a)})}return d("next")})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var APIClient=function(){function a(b){_classCallCheck(this,a),this.config=b,this.config.session_store||(this.config.session_store=_LocalStorage2.default),this.quotes=new _Quotes2.default(this),this.research=new _Research2.default(this),this.user=new _User2.default(this),this.options=new _Options2.default(this),this.advisory=new _Advisory2.default(this),this.watchlists=new _Watchlists2.default(this),this.etfs=new _ETFs2.default(this),this.news=new _News2.default(this),this.corporate_actions=new _CorporateActions2.default(this)}return _createClass(a,[{key:"login",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f,g,h,i,j;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=this.config.domain,e=this.config,f=e.session_store,g=e.token,h=e.cert,i=_jsonwebtoken2.default.sign({iss:g,sub:d},h,{algorithm:"ES512",expiresIn:"1h"}),a.prev=3,a.next=6,this.post("auth/v1/login",{username:b,password:c,signature:i});case 6:j=a.sent,f.set("sessionId",j.sessionId,60),a.next=13;break;case 10:throw a.prev=10,a.t0=a["catch"](3),Error(a.t0);case 13:case"end":return a.stop();}},a,this,[[3,10]])}));return function(){return a.apply(this,arguments)}}()},{key:"logout",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(){var b;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return b=this.config.session_store,a.prev=1,a.next=4,this.get("auth/v1/logout");case 4:a.next=9;break;case 6:throw a.prev=6,a.t0=a["catch"](1),Error(a.t0);case 9:return a.prev=9,b.set("sessionId",null,0),a.finish(9);case 12:case"end":return a.stop();}},a,this,[[1,6,9,12]])}));return function(){return a.apply(this,arguments)}}()},{key:"headers",value:function(){var a=this.config.domain;if(!this.hasSession())return console.log("No session"),{Referer:a};console.log("Has session");var b=this.config,c=b.session_store,d=b.cert,e=c.get("sessionId"),f=_jsonwebtoken2.default.sign({sub:e},d,{algorithm:"ES512",expiresIn:"5s"});return{Referer:a,Authorization:"Session "+Buffer.from(f).toString("base64")}}},{key:"hasSession",value:function(){return this.config.session_store.has("sessionId")}},{key:"post",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=this.config.base_url+b,e=this.headers(),a.next=4,_axios2.default.post(d,c,{headers:e});case 4:return f=a.sent,a.abrupt("return",f.data);case 6:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()},{key:"get",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=this.config.base_url+b,e=this.headers(),a.next=4,_axios2.default.get(d,{params:c,headers:e});case 4:return f=a.sent,a.abrupt("return",f.data);case 6:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()}]),a}();exports.default=APIClient; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_Quotes=require("./categories/Quotes"),_Quotes2=_interopRequireDefault(_Quotes),_Research=require("./categories/Research"),_Research2=_interopRequireDefault(_Research),_User=require("./categories/User"),_User2=_interopRequireDefault(_User),_Options=require("./categories/Options"),_Options2=_interopRequireDefault(_Options),_Advisory=require("./categories/Advisory"),_Advisory2=_interopRequireDefault(_Advisory),_Watchlists=require("./categories/Watchlists"),_Watchlists2=_interopRequireDefault(_Watchlists),_ETFs=require("./categories/ETFs"),_ETFs2=_interopRequireDefault(_ETFs),_News=require("./categories/News"),_News2=_interopRequireDefault(_News),_CorporateActions=require("./categories/CorporateActions"),_CorporateActions2=_interopRequireDefault(_CorporateActions),_LocalStorage=require("./session_stores/LocalStorage"),_LocalStorage2=_interopRequireDefault(_LocalStorage),_axios=require("axios"),_axios2=_interopRequireDefault(_axios),_jsonwebtoken=require("jsonwebtoken"),_jsonwebtoken2=_interopRequireDefault(_jsonwebtoken);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _asyncToGenerator(a){return function(){var b=a.apply(this,arguments);return new Promise(function(a,c){function d(e,f){try{var g=b[e](f),h=g.value}catch(a){return void c(a)}return g.done?void a(h):Promise.resolve(h).then(function(a){d("next",a)},function(a){d("throw",a)})}return d("next")})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}try{require("babel-core/register"),require("babel-polyfill")}catch(a){}var APIClient=function(){function a(b){_classCallCheck(this,a),this.config=b,this.config.session_store||(this.config.session_store=_LocalStorage2.default),this.quotes=new _Quotes2.default(this),this.research=new _Research2.default(this),this.user=new _User2.default(this),this.options=new _Options2.default(this),this.advisory=new _Advisory2.default(this),this.watchlists=new _Watchlists2.default(this),this.etfs=new _ETFs2.default(this),this.news=new _News2.default(this),this.corporate_actions=new _CorporateActions2.default(this)}return _createClass(a,[{key:"login",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f,g,h,i,j;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=this.config.domain,e=this.config,f=e.session_store,g=e.token,h=e.cert,i=_jsonwebtoken2.default.sign({iss:g,sub:d},h,{algorithm:"ES512",expiresIn:"1h"}),a.prev=3,a.next=6,this.post("auth/v1/login",{username:b,password:c,signature:i});case 6:j=a.sent,f.set("sessionId",j.sessionId,60),a.next=13;break;case 10:throw a.prev=10,a.t0=a["catch"](3),Error(a.t0);case 13:case"end":return a.stop();}},a,this,[[3,10]])}));return function(){return a.apply(this,arguments)}}()},{key:"logout",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(){var b;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return b=this.config.session_store,a.prev=1,a.next=4,this.get("auth/v1/logout");case 4:a.next=9;break;case 6:throw a.prev=6,a.t0=a["catch"](1),Error(a.t0);case 9:return a.prev=9,b.set("sessionId",null,0),a.finish(9);case 12:case"end":return a.stop();}},a,this,[[1,6,9,12]])}));return function(){return a.apply(this,arguments)}}()},{key:"headers",value:function(){var a=this.config.domain;if(!this.hasSession())return console.log("No session"),{Referer:a};console.log("Has session");var b=this.config,c=b.session_store,d=b.cert,e=c.get("sessionId"),f=_jsonwebtoken2.default.sign({sub:e},d,{algorithm:"ES512",expiresIn:"5s"});return{Referer:a,Authorization:"Session "+Buffer.from(f).toString("base64")}}},{key:"hasSession",value:function(){return this.config.session_store.has("sessionId")}},{key:"post",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=this.config.base_url+b,e=this.headers(),a.next=4,_axios2.default.post(d,c,{headers:e});case 4:return f=a.sent,a.abrupt("return",f.data);case 6:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()},{key:"get",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=this.config.base_url+b,e=this.headers(),a.next=4,_axios2.default.get(d,{params:c,headers:e});case 4:return f=a.sent,a.abrupt("return",f.data);case 6:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()}]),a}();exports.default=APIClient; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _APIClient=require("./APIClient"),_APIClient2=_interopRequireDefault(_APIClient);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}require("babel-core/register"),require("babel-polyfill"),module.exports=_APIClient2.default; | ||
"use strict";var _APIClient=require("./APIClient"),_APIClient2=_interopRequireDefault(_APIClient);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}module.exports=_APIClient2.default; |
{ | ||
"name": "@orbis-systems/orbis-api-client", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
Sorry, the diff of this file is too big to display
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
586474
13