rest-client-sdk
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -7,2 +7,5 @@ Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _urijs=require('urijs');var _urijs2=_interopRequireDefault(_urijs); | ||
AbstractClient=function(){ | ||
@@ -158,3 +161,3 @@ function AbstractClient(sdk){_classCallCheck(this,AbstractClient); | ||
default: | ||
throw new _Error.AccessDeniedError(body.error_description,response);} | ||
throw new _Error.AccessDeniedError(response,body.error_description);} | ||
@@ -191,9 +194,25 @@ } | ||
then(function(response){ | ||
if(response.status===401){ | ||
return _this4._manageAccessDenied(response,input,params); | ||
}else if(response.status===403){ | ||
throw new _Error.ForbiddenError('Forbidden acces: 403 found !',response); | ||
if(response.status<400){ | ||
return response; | ||
} | ||
return response; | ||
switch(true){ | ||
case response.status===401: | ||
return _this4._manageAccessDenied(response,input,params); | ||
case response.status===403: | ||
throw new _Error.ForbiddenError(response); | ||
case response.status===404: | ||
throw new _Error.ResourceNotFoundError(response); | ||
case response.status>=400&&response.status<500: | ||
throw new _Error.BadRequestError(response); | ||
case response.status>=500&&response.status<600: | ||
throw new _Error.InternalServerError(response); | ||
default: | ||
return new Error('Unexpected error, status code is '+response.status);} | ||
}); | ||
@@ -200,0 +219,0 @@ |
@@ -5,22 +5,67 @@ Object.defineProperty(exports,"__esModule",{value:true}); | ||
function HttpError(baseResponse,message){ | ||
this.name='BadRequestError'; | ||
this.message=message||'Bad request'; | ||
this.baseResponse=baseResponse; | ||
this.stack=new Error().stack; | ||
} | ||
HttpError.prototype=Object.create(Error.prototype); | ||
HttpError.prototype.constructor=HttpError; | ||
function BadRequestError(baseResponse,message){ | ||
this.name='BadRequestError'; | ||
this.message=message||'Bad request'; | ||
this.baseResponse=baseResponse; | ||
this.stack=new Error().stack; | ||
} | ||
BadRequestError.prototype=Object.create(HttpError.prototype); | ||
BadRequestError.prototype.constructor=BadRequestError; | ||
function AccessDeniedError(message,baseResponse){ | ||
this.name='AccessDeniedError'; | ||
this.message=message; | ||
this.message=message||'Access denied'; | ||
this.baseResponse=baseResponse; | ||
this.stack=new Error().stack; | ||
} | ||
AccessDeniedError.prototype=Object.create(Error.prototype); | ||
AccessDeniedError.prototype=Object.create(BadRequestError.prototype); | ||
AccessDeniedError.prototype.constructor=AccessDeniedError; | ||
function ForbiddenError(message,baseResponse){ | ||
this.name='ForbiddenError'; | ||
this.message=message; | ||
this.message=message||'Forbidden'; | ||
this.baseResponse=baseResponse; | ||
this.stack=new Error().stack; | ||
} | ||
ForbiddenError.prototype=Object.create(Error.prototype); | ||
ForbiddenError.prototype.constructor=ForbiddenError;exports. | ||
ForbiddenError.prototype=Object.create(BadRequestError.prototype); | ||
ForbiddenError.prototype.constructor=ForbiddenError; | ||
function ResourceNotFoundError(baseResponse,message){ | ||
this.name='ResourceNotFoundError'; | ||
this.message=message||'Resource is not found'; | ||
this.baseResponse=baseResponse; | ||
this.stack=new Error().stack; | ||
} | ||
ResourceNotFoundError.prototype=Object.create(BadRequestError.prototype); | ||
ResourceNotFoundError.prototype.constructor=ResourceNotFoundError; | ||
function InternalServerError(message,baseResponse){ | ||
this.name='InternalServerError'; | ||
this.message=message||'Internal server error'; | ||
this.baseResponse=baseResponse; | ||
this.stack=new Error().stack; | ||
} | ||
InternalServerError.prototype=Object.create(HttpError.prototype); | ||
InternalServerError.prototype.constructor=InternalServerError;exports. | ||
AccessDeniedError=AccessDeniedError;exports. | ||
ForbiddenError=ForbiddenError; | ||
ForbiddenError=ForbiddenError;exports. | ||
BadRequestError=BadRequestError;exports. | ||
ResourceNotFoundError=ResourceNotFoundError;exports. | ||
InternalServerError=InternalServerError; |
@@ -1,2 +0,2 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.TokenStorage=exports.ProvidedTokenGenerator=exports.PasswordGenerator=exports.ForbiddenError=exports.ClientCredentialsGenerator=exports.AbstractTokenGenerator=exports.AccessDeniedError=exports.AbstractClient=undefined;var _RestClientSdk=require('./RestClientSdk');var _RestClientSdk2=_interopRequireDefault(_RestClientSdk); | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.InternalServerError=exports.ResourceNotFoundError=exports.BadRequestError=exports.ForbiddenError=exports.AccessDeniedError=exports.TokenStorage=exports.ProvidedTokenGenerator=exports.PasswordGenerator=exports.ClientCredentialsGenerator=exports.AbstractTokenGenerator=exports.AbstractClient=undefined;var _RestClientSdk=require('./RestClientSdk');var _RestClientSdk2=_interopRequireDefault(_RestClientSdk); | ||
var _Error=require('./Error'); | ||
@@ -6,2 +6,5 @@ | ||
var _AbstractClient=require('./client/AbstractClient');var _AbstractClient2=_interopRequireDefault(_AbstractClient); | ||
@@ -17,8 +20,12 @@ var _TokenStorage=require('./TokenStorage');var _TokenStorage2=_interopRequireDefault(_TokenStorage); | ||
AbstractClient=_AbstractClient2.default;exports. | ||
AccessDeniedError=_Error.AccessDeniedError;exports. | ||
AbstractTokenGenerator=_AbstractTokenGenerator2.default;exports. | ||
ClientCredentialsGenerator=_ClientCredentialsGenerator2.default;exports. | ||
ForbiddenError=_Error.ForbiddenError;exports. | ||
PasswordGenerator=_PasswordGenerator2.default;exports. | ||
ProvidedTokenGenerator=_ProvidedTokenGenerator2.default;exports. | ||
TokenStorage=_TokenStorage2.default; | ||
TokenStorage=_TokenStorage2.default;exports. | ||
AccessDeniedError=_Error.AccessDeniedError;exports. | ||
ForbiddenError=_Error.ForbiddenError;exports. | ||
BadRequestError=_Error.BadRequestError;exports. | ||
ResourceNotFoundError=_Error.ResourceNotFoundError;exports. | ||
InternalServerError=_Error.InternalServerError; |
Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _urijs=require('urijs');var _urijs2=_interopRequireDefault(_urijs); | ||
var _AbstractTokenGenerator=require('./AbstractTokenGenerator');var _AbstractTokenGenerator2=_interopRequireDefault(_AbstractTokenGenerator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;} | ||
var _AbstractTokenGenerator=require('./AbstractTokenGenerator');var _AbstractTokenGenerator2=_interopRequireDefault(_AbstractTokenGenerator); | ||
var _decorator=require('../decorator');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;} | ||
@@ -8,3 +9,8 @@ var ERROR_CONFIG_EMPTY='TokenGenerator config must be set'; | ||
ClientCredentialsGenerator=function(_AbstractTokenGenerat){_inherits(ClientCredentialsGenerator,_AbstractTokenGenerat);function ClientCredentialsGenerator(){_classCallCheck(this,ClientCredentialsGenerator);return _possibleConstructorReturn(this,(ClientCredentialsGenerator.__proto__||Object.getPrototypeOf(ClientCredentialsGenerator)).apply(this,arguments));}_createClass(ClientCredentialsGenerator,[{key:'generateToken',value:function generateToken() | ||
ClientCredentialsGenerator=function(_AbstractTokenGenerat){_inherits(ClientCredentialsGenerator,_AbstractTokenGenerat); | ||
function ClientCredentialsGenerator(props){_classCallCheck(this,ClientCredentialsGenerator);var _this=_possibleConstructorReturn(this,(ClientCredentialsGenerator.__proto__||Object.getPrototypeOf(ClientCredentialsGenerator)).call(this, | ||
props)); | ||
_this.generateToken=(0,_decorator.memoizePromise)(_this.generateToken);return _this; | ||
}_createClass(ClientCredentialsGenerator,[{key:'generateToken',value:function generateToken() | ||
{var baseParameters=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{}; | ||
@@ -11,0 +17,0 @@ var parameters=baseParameters; |
Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _urijs=require('urijs');var _urijs2=_interopRequireDefault(_urijs); | ||
var _AbstractTokenGenerator=require('./AbstractTokenGenerator');var _AbstractTokenGenerator2=_interopRequireDefault(_AbstractTokenGenerator);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;} | ||
var _AbstractTokenGenerator=require('./AbstractTokenGenerator');var _AbstractTokenGenerator2=_interopRequireDefault(_AbstractTokenGenerator); | ||
var _decorator=require('../decorator');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;} | ||
@@ -12,3 +13,8 @@ var ERROR_CONFIG_EMPTY='TokenGenerator config must be set'; | ||
PasswordGenerator=function(_AbstractTokenGenerat){_inherits(PasswordGenerator,_AbstractTokenGenerat);function PasswordGenerator(){_classCallCheck(this,PasswordGenerator);return _possibleConstructorReturn(this,(PasswordGenerator.__proto__||Object.getPrototypeOf(PasswordGenerator)).apply(this,arguments));}_createClass(PasswordGenerator,[{key:'generateToken',value:function generateToken( | ||
PasswordGenerator=function(_AbstractTokenGenerat){_inherits(PasswordGenerator,_AbstractTokenGenerat); | ||
function PasswordGenerator(props){_classCallCheck(this,PasswordGenerator);var _this=_possibleConstructorReturn(this,(PasswordGenerator.__proto__||Object.getPrototypeOf(PasswordGenerator)).call(this, | ||
props)); | ||
_this._doFetch=(0,_decorator.memoizePromise)(_this._doFetch);return _this; | ||
}_createClass(PasswordGenerator,[{key:'generateToken',value:function generateToken( | ||
baseParameters){ | ||
@@ -15,0 +21,0 @@ var parameters=baseParameters; |
{ | ||
"name": "rest-client-sdk", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"description": "Rest Client SDK for API", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "src/index.js", | ||
"scripts": { | ||
@@ -10,0 +7,0 @@ "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
91453
47
1972
6