src/pyams_security/resources/js/authomatic.min.js
changeset 0 f04e1d0a0723
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_security/resources/js/authomatic.min.js	Thu Feb 19 10:53:29 2015 +0100
@@ -0,0 +1,1 @@
+(function(){var l,k,z,C,w,u,b,t,q,d,s,y,g,c,o,m,A,x,v,n,i,h,f,e,a,r=[].slice,j=function(D,E){return function(){return D.apply(E,arguments)}},p={}.hasOwnProperty,B=function(G,E){for(var D in E){if(p.call(E,D)){G[D]=E[D]}}function F(){this.constructor=G}F.prototype=E.prototype;G.prototype=new F();G.__super__=E.prototype;return G};l=jQuery;o=0;c={logging:true,popupWidth:800,popupHeight:600,popupLinkSelector:"a.authomatic",popupFormSelector:"form.authomatic",popupFormValidator:function(D){return true},backend:null,forceBackend:false,substitute:{},params:{},headers:{},body:"",jsonpCallbackPrefix:"authomaticJsonpCallback",onPopupInvalid:null,onPopupOpen:null,onLoginComplete:null,onBackendStart:null,onBackendComplete:null,onAccessSuccess:null,onAccessComplete:null};m=function(){var D,E;D=1<=arguments.length?r.call(arguments,0):[];if(c.logging&&((typeof console!=="undefined"&&console!==null?(E=console.log)!=null?E.apply:void 0:void 0)!=null)){return typeof console!=="undefined"&&console!==null?console.log.apply(console,["Authomatic:"].concat(r.call(D))):void 0}};A=function(E){var D,I,G,H,F;F=c.popupWidth;D=c.popupHeight;H=(screen.height/2)-(D/2);I=(screen.width/2)-(F/2);G="width="+F+",height="+D+",top="+H+",left="+I;m("Opening popup:",E);if(typeof c.onPopupOpen==="function"){c.onPopupOpen(E)}return window.open(E,"",G)};x=function(D){var K,F,L,J,G,I,H,E;L={};H=D.split("&");for(G=0,I=H.length;G<I;G++){K=H[G];E=K.split("="),F=E[0],J=E[1];J=decodeURIComponent(J);if(L.hasOwnProperty(F)){if(Array.isArray(L[F])){L[F].push(J)}else{L[F]=[L[F],J]}}else{L[F]=J}}return L};v=function(G){var E,D,F;m("parseUrl",G);D=G.indexOf("?");if(D>=0){F=G.substring(0,D);E=G.substring(D+1)}else{F=G}return{url:F,query:E,params:E?x(E):void 0}};s=function(E){var I,D,G,F,H;I=decodeURIComponent(E).split("\n");F=I[1];H=F.split("-"),G=H[0],D=H[1];return{id:parseInt(I[0]),typeId:F,type:parseInt(G),subtype:parseInt(D),rest:I.slice(2)}};g=function(E){var D,F,G;G=s(E),F=G.type,D=G.subtype;if(F===1){if(D===2){return C}else{return t}}else{if(F===2){if(D===6){return w}else{if(D===9){return b}else{if(D===14){return d}else{if(D===12||D===15){return z}else{return q}}}}}else{return z}}};y=function(E,D){return E.replace(/{([^}]*)}/g,function(H,F){var L,K,J,G,I;K=D;I=F.split(".");for(J=0,G=I.length;J<G;J++){L=I[J];K=K[L]}return K})};window.authomatic=new (k=(function(){function D(){}D.prototype.setup=function(E){l.extend(c,E);return m("Setting up authomatic to:",c)};D.prototype.popupInit=function(){l(c.popupLinkSelector).click(function(E){E.preventDefault();return A(l(this).attr("href"))});return l(c.popupFormSelector).submit(function(G){var E,F;G.preventDefault();E=l(this);F=E.attr("action")+"?"+E.serialize();if(c.popupFormValidator(E)){return A(F)}else{return typeof c.onPopupInvalid==="function"?c.onPopupInvalid(E):void 0}})};D.prototype.loginComplete=function(E,G){var F;F=l.extend(true,{},E);m("Login procedure complete",F);G();return c.onLoginComplete(F)};D.prototype.access=function(I,G,F){var K,H,J,E;if(F==null){F={}}H={onBackendStart:null,onBackendComplete:null,onAccessSuccess:null,onAccessComplete:null};E={};l.extend(E,c,H,F);G=y(G,E.substitute);m("access options",E,c);if(E.forceBackend){K=z}else{K=g(I)}J=new K(F.backend,I,G,E);m("Instantiating provider:",J);return J.access()};return D})());z=(function(){D.prototype._x_jsonpCallbackParamName="callback";function D(H,G,F,E){var I;this.backend=H;this.credentials=G;this.options=E;this.access=j(this.access,this);this.contactProvider=j(this.contactProvider,this);this.contactBackend=j(this.contactBackend,this);this.backendRequestType="auto";this.jsonpRequest=false;this.jsonpCallbackName=""+c.jsonpCallbackPrefix+o;this.deserializedCredentials=s(this.credentials);this.providerID=this.deserializedCredentials.id;this.providerType=this.deserializedCredentials.type;this.credentialsRest=this.deserializedCredentials.rest;I=v(F);this.url=I.url;this.params={};l.extend(this.params,I.params,this.options.params)}D.prototype.contactBackend=function(G){var F,E;if(this.jsonpRequest&&this.options.method===!"GET"){this.backendRequestType="fetch"}F={type:this.backendRequestType,credentials:this.credentials,url:this.url,method:this.options.method,body:this.options.body,params:JSON.stringify(this.params),headers:JSON.stringify(this.options.headers)};if(typeof c.onBackendStart==="function"){c.onBackendStart(F)}if(typeof(E=this.options).onBackendStart==="function"){E.onBackendStart(F)}m("Contacting backend at "+this.options.backend+".",F);return l.get(this.options.backend,F,G)};D.prototype.contactProvider=function(G){var K,H,J,E,M,I,F,L=this;F=G.url,E=G.method,I=G.params,H=G.headers,K=G.body;M={type:E,data:I,headers:H,complete:[(function(N,O){return m("Request complete.",O,N)}),c.onAccessComplete,this.options.onAccessComplete],success:[(function(N){return m("Request successful.",N)}),c.onAccessSuccess,this.options.onAccessSuccess],error:function(N,P,O){if(N.state()==="rejected"){if(L.options.method==="GET"){m("Cross domain request failed! trying JSONP request.");L.jsonpRequest=true}else{L.backendRequestType="fetch"}return L.access()}}};if(this.jsonpRequest){J={jsonpCallback:this.jsonpCallbackName,jsonp:this._x_jsonpCallbackParamName,cache:true,dataType:"jsonp",error:function(N,P,O){return m("JSONP failed! State:",N.state())}};l.extend(M,J);m("Contacting provider with JSONP request.",F,M)}else{m("Contacting provider with cross domain request",F,M)}return l.ajax(F,M)};D.prototype.access=function(){var F,E=this;F=function(L,M,K){var G,I,J,H;if(typeof c.onBackendComplete==="function"){c.onBackendComplete(L,M,K)}if(typeof(I=E.options).onBackendComplete==="function"){I.onBackendComplete(L,M,K)}G=K!=null?K.getResponseHeader("Authomatic-Response-To"):void 0;if(G==="fetch"){m("Fetch data returned from backend.",K.getResponseHeader("content-type"),L);if(typeof c.onAccessSuccess==="function"){c.onAccessSuccess(L)}if(typeof(J=E.options).onAccessSuccess==="function"){J.onAccessSuccess(L)}if(typeof c.onAccessComplete==="function"){c.onAccessComplete(K,M)}return typeof(H=E.options).onAccessComplete==="function"?H.onAccessComplete(K,M):void 0}else{if(G==="elements"){m("Request elements data returned from backend.",L);return E.contactProvider(L)}}};if(this.jsonpRequest){o+=1}return this.contactBackend(F)};return D})();t=(function(E){B(D,E);function D(){this.contactProvider=j(this.contactProvider,this);this.access=j(this.access,this);n=D.__super__.constructor.apply(this,arguments);return n}D.prototype.access=function(){this.jsonpRequest=true;this.params[this._x_jsonpCallbackParamName]=this.jsonpCallbackName;return D.__super__.access.call(this)};D.prototype.contactProvider=function(F){delete F.params.callback;return D.__super__.contactProvider.call(this,F)};return D})(z);C=(function(D){B(E,D);function E(){i=E.__super__.constructor.apply(this,arguments);return i}E.prototype._x_jsonpCallbackParamName="jsoncallback";return E})(t);q=(function(E){B(D,E);D.prototype._x_accessToken="access_token";D.prototype._x_bearer="Bearer";function D(){var F,G;F=1<=arguments.length?r.call(arguments,0):[];this.access=j(this.access,this);this.handleTokenType=j(this.handleTokenType,this);D.__super__.constructor.apply(this,F);G=this.credentialsRest,this.accessToken=G[0],this.refreshToken=G[1],this.expirationTime=G[2],this.tokenType=G[3];this.handleTokenType()}D.prototype.handleTokenType=function(){if(this.tokenType==="1"){return this.options.headers.Authorization=""+this._x_bearer+" "+this.accessToken}else{return this.params[this._x_accessToken]=this.accessToken}};D.prototype.access=function(){var F;if(this.backendRequestType==="fetch"){return D.__super__.access.call(this)}else{F={url:this.url,method:this.options.method,params:this.params,headers:this.options.headers,body:this.options.body};return this.contactProvider(F)}};return D})(z);w=(function(E){B(D,E);function D(){h=D.__super__.constructor.apply(this,arguments);return h}D.prototype._x_accessToken="oauth_token";return D})(q);u=(function(D){B(E,D);function E(){f=E.__super__.constructor.apply(this,arguments);return f}E.prototype._x_bearer="OAuth";return E})(q);b=(function(E){B(D,E);function D(){e=D.__super__.constructor.apply(this,arguments);return e}D.prototype._x_accessToken="oauth2_access_token";return D})(q);d=(function(D){B(E,D);function E(){this.handleTokenType=j(this.handleTokenType,this);a=E.__super__.constructor.apply(this,arguments);return a}E.prototype.handleTokenType=function(){if(this.tokenType==="1"){this.options.headers.Authorization=""+this._x_bearer+" "+this.accessToken}return this.params[this._x_accessToken]=this.accessToken};return E})(q)}).call(this);
\ No newline at end of file