Files
luos/workflow/public_html/lib/js/restclient-min.js

1 line
12 KiB
JavaScript
Raw Normal View History

var RCBase64={keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t,r,s,i,o,n,a,h="",u=0;for(e=this.utf8_encode(e);u<e.length;)t=e.charCodeAt(u++),r=e.charCodeAt(u++),s=e.charCodeAt(u++),i=t>>2,o=(3&t)<<4|r>>4,n=(15&r)<<2|s>>6,a=63&s,isNaN(r)?n=a=64:isNaN(s)&&(a=64),h=h+this.keyStr.charAt(i)+this.keyStr.charAt(o)+this.keyStr.charAt(n)+this.keyStr.charAt(a);return h},decode:function(e){var t,r,s,i,o,n,a,h="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)i=this.keyStr.indexOf(e.charAt(u++)),o=this.keyStr.indexOf(e.charAt(u++)),n=this.keyStr.indexOf(e.charAt(u++)),a=this.keyStr.indexOf(e.charAt(u++)),t=i<<2|o>>4,r=(15&o)<<4|n>>2,s=(3&n)<<6|a,h+=String.fromCharCode(t),64!==n&&(h+=String.fromCharCode(r)),64!==a&&(h+=String.fromCharCode(s));return h=this.utf8_decode(h)},utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t,r,s="";for(t=0;t<e.length;t++)r=e.charCodeAt(t),128>r?s+=String.fromCharCode(r):r>127&&2048>r?(s+=String.fromCharCode(192|r>>6),s+=String.fromCharCode(128|63&r)):(s+=String.fromCharCode(224|r>>12),s+=String.fromCharCode(128|63&r>>6),s+=String.fromCharCode(128|63&r));return s},utf8_decode:function(e){for(var t="",r=0,s=0,i=0,o=0;r<e.length;)s=e.charCodeAt(r),128>s?(t+=String.fromCharCode(s),r++):s>191&&224>s?(i=e.charCodeAt(r+1),t+=String.fromCharCode((31&s)<<6|63&i),r+=2):(i=e.charCodeAt(r+1),o=e.charCodeAt(r+2),t+=String.fromCharCode((15&s)<<12|(63&i)<<6|63&o),r+=3);return t}},RestClient;if(RestClient=function(){this.VERSION="0.1.4",this.authorization={},this.server={},this.response={},this.headers={},this.accessToken={},this.autoUseRefreshToken=!0,this.autoStoreAccessToken=!0,this.authorizationType="none",this.contentType="application/json",this.sendOAuthBearerAuthorization=!1,this.dataType="json",this.oauth2NeedsAuthorization=!0,this.expiredAccessTokenMessage="",this.restfulBehavior=!0,this.backupAJAXURL=null,this.RESTMethods={create:"POST",read:"GET",update:"PUT","delete":"DELETE"},this.OAUTH2GrantTypes={code:"authorization_code",implicit:"token",user:"password",client:"client_credentials",refresh:"refresh_token"},RestClient.prototype.initObject.call(this)},RestClient.prototype.HTTP_SUCCESS=200,RestClient.prototype.HTTP_BAD_REQUEST=400,RestClient.prototype.HTTP_UNAUTHORIZED=401,RestClient.prototype.OAUTH2_INVALID_GRANT="invalid_grant",RestClient.prototype.initObject=function(){this.authorization={},this.server={},this.response={},this.headers={},this.accessToken={},this.autoUseRefreshToken=!0,this.autoStoreAccessToken=!0,this.authorizationType="none",this.contentType="application/json",this.sendOAuthBearerAuthorization=!1,this.oauth2NeedsAuthorization=!0,this.dataType="json",this.expiredAccessTokenMessage="The access token provided has expired."},RestClient.prototype.setUseRefreshTokenAutomatically=function(e){return _.isBoolean(e)&&(this.autoUseRefreshToken=e),this},RestClient.prototype.setStoreAccessTokenAutomatically=function(e){return _.isBoolean(e)&&(this.autoStoreAccessToken=e),this},RestClient.prototype.setAuthorizationType=function(e){var t={none:1,basic:1,oauth2:1};return t[e]&&(this.authorizationType=e),this},RestClient.prototype.setContentType=function(e){return this.contentType=e,this},RestClient.prototype.setSendBearerAuthorization=function(e){return _.isBoolean(e)&&(this.sendOAuthBearerAuthorization=e),this},RestClient.prototype.setOAuth2NeedsAuthorization=function(e){return _.isBoolean(e)&&(this.oauth2NeedsAuthorization=e),this},RestClient.prototype.setDataType=function(e){var t={json:"application/json",plain:"text/plain",form:"application/x-www-form-urlencoded",html:"text/html"};return t[e]&&(this.dataType=e,this.contentType=t[e]),this},RestClient.prototype.setAccessTokenExpiredMessage=function(e){return this.expiredAccessTokenMessage=e,this},RestClient.prototype.getVersion=function(){return this.VERSION},RestClient.prototype.setClient=function(e,t,r){return this.authorization.client_id=e,this.authorization.client_secret=t,this.authorization.client_url="undefined"!==r?r:null,this},RestClient.prototype.setGrantType=function(e,t){