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

@orbis-systems/orbis-api-client

Package Overview
Dependencies
Maintainers
4
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orbis-systems/orbis-api-client - npm Package Compare versions

Comparing version 4.2.2 to 4.2.3

.vscode/launch.json

2

dist/lib/APICategory.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_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}}(),_lodash=require("lodash");function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var APICategory=function(){function a(b){if(_classCallCheck(this,a),!b)throw new Error("[apiClient] required");this.client=b}return _createClass(a,[{key:"request",value:function(){return this.client.request(this.prepareRequest.apply(this,arguments))}},{key:"prepareRequest",value:function(a,b,c,d){var e=a.method,f=a.url;switch(d&&(e=d),"undefined"==typeof b?"undefined":_typeof(b)){case"string":case"number":return this.prepareBody(e,f+"/"+b,c);case"object":case"undefined":return(0,_lodash.isArray)(b)?this.prepareBody(e,f+"/"+b.join("/"),c):this.prepareBody(e,f,b||c);default:throw new SyntaxError;}}},{key:"prepareBody",value:function(a,b,c){return{method:a,params:"GET"===a?c:void 0,data:"GET"===a?void 0:c,endpoint:b}}}]),a}();exports.default=APICategory;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_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}}(),_lodash=require("lodash");function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var APICategory=function(){function a(b){if(_classCallCheck(this,a),!b)throw new Error("[apiClient] required");this.client=b}return _createClass(a,[{key:"request",value:function(){return this.client.request(this.prepareRequest.apply(this,arguments))}},{key:"prepareRequest",value:function(a,b,c,d,e){var f=a.method,g=a.url;switch(d&&(f=d),"undefined"==typeof b?"undefined":_typeof(b)){case"string":case"number":return this.prepareBody(f,g+"/"+b,c,e);case"object":case"undefined":return(0,_lodash.isArray)(b)?this.prepareBody(f,g+"/"+b.join("/"),c,e):this.prepareBody(f,g,b||c,e);default:throw new SyntaxError;}}},{key:"prepareBody",value:function(a,b,c,d){return{method:a,params:"GET"===a?c:void 0,data:"GET"===a?void 0:c,endpoint:b,headers:d}}}]),a}();exports.default=APICategory;

@@ -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}}(),_axios=require("axios"),_axios2=_interopRequireDefault(_axios),_base=require("base-64"),_base2=_interopRequireDefault(_base),_jsonwebtoken=require("jsonwebtoken"),_jsonwebtoken2=_interopRequireDefault(_jsonwebtoken),_LocalStorage=require("./session_stores/LocalStorage"),_LocalStorage2=_interopRequireDefault(_LocalStorage),_WSWrapper=require("./WSWrapper"),_WSWrapper2=_interopRequireDefault(_WSWrapper);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")}require("babel-core/register"),require("babel-polyfill");var APIClient=function(){function a(b){_classCallCheck(this,a),this.config=b,this.config.session_store||(this.config.session_store=_LocalStorage2.default)}return _createClass(a,[{key:"login",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f,g,h,i,j,k,l,m,n;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,d=this.config,e=d.domain,f=d.sign_url,g=d.base_url,h=d.session_store,i=e&&{Referer:e}||void 0,a.next=5,_axios2.default.post(f,{},{headers:i});case 5:return j=a.sent,k=j.data.signature,l={username:b,password:c,signature:k},a.next=10,_axios2.default.post(g+"/auth/v1/login",l,{headers:i});case 10:return m=a.sent,n=m.data.sessionId,a.next=14,h.set("sessionId",n,60);case 14:return a.abrupt("return",!0);case 17:throw a.prev=17,a.t0=a["catch"](0),this.logError(a.t0),a.t0;case 21:case"end":return a.stop();}},a,this,[[0,17]])}));return function(){return a.apply(this,arguments)}}()},{key:"logout",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,this.get("auth/v1/logout");case 3:return this.expireSession(),a.abrupt("return",!0);case 7:throw a.prev=7,a.t0=a["catch"](0),this.logError(a.t0),a.t0;case 11:case"end":return a.stop();}},a,this,[[0,7]])}));return function(){return a.apply(this,arguments)}}()},{key:"changePassword",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f,g,h;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,d=this.config,e=d.domain,f=d.base_url,g={currentPassword:b,newPassword:c},h=this.getHeaders(),e&&(h.Referer=e),a.next=7,_axios2.default.post(f+"/auth/v1/password/change",g,{headers:h});case 7:return a.abrupt("return",!0);case 10:throw a.prev=10,a.t0=a["catch"](0),this.logError(a.t0),a.t0;case 14:case"end":return a.stop();}},a,this,[[0,10]])}));return function(){return a.apply(this,arguments)}}()},{key:"getHeaders",value:function(){return this.hasSession()?{Authorization:"Session "+this.getToken()}:{}}},{key:"getToken",value:function(){var a=this.config.session_store,b=a.get("sessionId"),c=_jsonwebtoken2.default.sign({sub:b},"test",{expiresIn:"5s"});return _base2.default.encode(c)}},{key:"hasSession",value:function(){return this.config.session_store.has("sessionId")}},{key:"expireSession",value:function(){var a=this.config.session_store;a.set("sessionId",null,0)}},{key:"logError",value:function(a){console.error(a.name+": "+a.message,"\nResponse:",a.response,"\nRequest:",a.request)}},{key:"get",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this.request({method:"GET",endpoint:b,params:c});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()},{key:"post",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this.request({method:"POST",endpoint:b,data:c});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()},{key:"request",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h=b.endpoint,i=b.method,j=b.params,k=b.data;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c={method:i,params:j,data:k,headers:this.getHeaders()},d=this.config,e=d.base_url,f=d.onUnauthorized,a.prev=2,a.next=5,(0,_axios2.default)(e+"/"+h,c);case 5:return a.abrupt("return",a.sent.data);case 8:throw a.prev=8,a.t0=a["catch"](2),this.logError(a.t0),g=a.t0.response,g&&401===g.status&&f&&f(),a.t0;case 14:case"end":return a.stop();}},a,this,[[2,8]])}));return function(){return a.apply(this,arguments)}}()},{key:"websocket",value:function(a,b){var c=this,d=b.timeout,e=b.maxAttempts,f=b.onOpen,g=b.onMessage,h=b.onReconnect,i=b.onMaximum,j=b.onClose,k=b.onError,l=function(){return c.config.streaming_url+"/"+a+"?auth="+escape("Session "+c.getToken())},m=new _WSWrapper2.default(l(),{maxAttempts:e,timeout:d||5e3,onopen:f,onmessage:g,onmaximum:i,onerror:k,onclose:j,onreconnect:function(a){m.updateUrl(l()),h&&h(a)}});return m}}]),a}();exports.default=APIClient;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_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}}(),_axios=require("axios"),_axios2=_interopRequireDefault(_axios),_base=require("base-64"),_base2=_interopRequireDefault(_base),_jsonwebtoken=require("jsonwebtoken"),_jsonwebtoken2=_interopRequireDefault(_jsonwebtoken),_LocalStorage=require("./session_stores/LocalStorage"),_LocalStorage2=_interopRequireDefault(_LocalStorage),_WSWrapper=require("./WSWrapper"),_WSWrapper2=_interopRequireDefault(_WSWrapper);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")}require("babel-core/register"),require("babel-polyfill");var APIClient=function(){function a(b){_classCallCheck(this,a),this.config=b,this.config.session_store||(this.config.session_store=_LocalStorage2.default)}return _createClass(a,[{key:"login",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f,g,h,i,j,k,l,m,n;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,d=this.config,e=d.domain,f=d.sign_url,g=d.base_url,h=d.session_store,i=e&&{Referer:e}||void 0,a.next=5,_axios2.default.post(f,{},{headers:i});case 5:return j=a.sent,k=j.data.signature,l={username:b,password:c,signature:k},a.next=10,_axios2.default.post(g+"/auth/v1/login",l,{headers:i});case 10:return m=a.sent,n=m.data.sessionId,a.next=14,h.set("sessionId",n,60);case 14:return a.abrupt("return",!0);case 17:throw a.prev=17,a.t0=a["catch"](0),this.logError(a.t0),a.t0;case 21:case"end":return a.stop();}},a,this,[[0,17]])}));return function(){return a.apply(this,arguments)}}()},{key:"logout",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,this.get("auth/v1/logout");case 3:return this.expireSession(),a.abrupt("return",!0);case 7:throw a.prev=7,a.t0=a["catch"](0),this.logError(a.t0),a.t0;case 11:case"end":return a.stop();}},a,this,[[0,7]])}));return function(){return a.apply(this,arguments)}}()},{key:"changePassword",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c){var d,e,f,g,h;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,d=this.config,e=d.domain,f=d.base_url,g={currentPassword:b,newPassword:c},h=this.getHeaders(),e&&(h.Referer=e),a.next=7,_axios2.default.post(f+"/auth/v1/password/change",g,{headers:h});case 7:return a.abrupt("return",!0);case 10:throw a.prev=10,a.t0=a["catch"](0),this.logError(a.t0),a.t0;case 14:case"end":return a.stop();}},a,this,[[0,10]])}));return function(){return a.apply(this,arguments)}}()},{key:"getHeaders",value:function(){return this.hasSession()?{Authorization:"Session "+this.getToken()}:{}}},{key:"getToken",value:function(){var a=this.config.session_store,b=a.get("sessionId"),c=_jsonwebtoken2.default.sign({sub:b},"test",{expiresIn:"5s"});return _base2.default.encode(c)}},{key:"hasSession",value:function(){return this.config.session_store.has("sessionId")}},{key:"expireSession",value:function(){var a=this.config.session_store;a.set("sessionId",null,0)}},{key:"logError",value:function(a){console.error(a.name+": "+a.message,"\nResponse:",a.response,"\nRequest:",a.request)}},{key:"get",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c,d){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this.request({method:"GET",endpoint:b,params:c,headers:d});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()},{key:"post",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b,c,d){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this.request({method:"POST",endpoint:b,data:c,headers:d});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}}()},{key:"request",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h=b.endpoint,i=b.method,j=b.params,k=b.data,l=b.headers;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c={method:i,params:j,data:k,headers:_extends({},this.getHeaders(),l)},d=this.config,e=d.base_url,f=d.onUnauthorized,a.prev=2,a.next=5,(0,_axios2.default)(e+"/"+h,c);case 5:return a.abrupt("return",a.sent.data);case 8:throw a.prev=8,a.t0=a["catch"](2),this.logError(a.t0),g=a.t0.response,g&&401===g.status&&f&&f(),a.t0;case 14:case"end":return a.stop();}},a,this,[[2,8]])}));return function(){return a.apply(this,arguments)}}()},{key:"websocket",value:function(a,b){var c=this,d=b.timeout,e=b.maxAttempts,f=b.onOpen,g=b.onMessage,h=b.onReconnect,i=b.onMaximum,j=b.onClose,k=b.onError,l=function(){return c.config.streaming_url+"/"+a+"?auth="+escape("Session "+c.getToken())},m=new _WSWrapper2.default(l(),{maxAttempts:e,timeout:d||5e3,onopen:f,onmessage:g,onmaximum:i,onerror:k,onclose:j,onreconnect:function(a){m.updateUrl(l()),h&&h(a)}});return m}}]),a}();exports.default=APIClient;
{
"name": "@orbis-systems/orbis-api-client",
"version": "4.2.2",
"version": "4.2.3",
"description": "",

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

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import {

@@ -0,0 +0,0 @@ import APIClient, {

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

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