From da75c042f6f3b35415cfd84c76f7410c0cb34909 Mon Sep 17 00:00:00 2001 From: Antoine Jackson Date: Mon, 4 Aug 2014 18:52:13 +0200 Subject: [PATCH] Added callbeck on unexpected popup close --- www/coffee/lib/oauth.coffee | 3 +++ www/dist/oauth.js | 8 ++++++++ www/dist/oauth.min.js | 2 +- www/js/lib/oauth.js | 8 ++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/www/coffee/lib/oauth.coffee b/www/coffee/lib/oauth.coffee index 21971c0..635b2e7 100644 --- a/www/coffee/lib/oauth.coffee +++ b/www/coffee/lib/oauth.coffee @@ -193,6 +193,9 @@ module.exports = (window, document, jQuery, navigator) -> opts.callback new Error("unable to receive token") defer?.reject new Error("unable to receive token") return + wnd.addEventListener "exit", () -> + defer?.reject new Error("The popup was closed") + opts.callback new Error("The popup was closed") if opts.callback and typeof opts.callback == "function" return defer?.promise() clearCache: (provider) -> diff --git a/www/dist/oauth.js b/www/dist/oauth.js index b0db776..1513a69 100644 --- a/www/dist/oauth.js +++ b/www/dist/oauth.js @@ -249,6 +249,14 @@ module.exports = function(window, document, jQuery, navigator) { } } }); + wnd.addEventListener("exit", function() { + if (defer != null) { + defer.reject(new Error("The popup was closed")); + } + if (opts.callback && typeof opts.callback === "function") { + return opts.callback(new Error("The popup was closed")); + } + }); return defer != null ? defer.promise() : void 0; }, clearCache: function(provider) { diff --git a/www/dist/oauth.min.js b/www/dist/oauth.min.js index b1e0214..991e9e4 100644 --- a/www/dist/oauth.min.js +++ b/www/dist/oauth.min.js @@ -1 +1 @@ -!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gb;b++)if(b in this&&this[b]===a)return b;return-1};c=a("../tools/url")(),b.exports=function(a,b,e,f,g){return{http:function(e){var f,h,i,j,k;i=function(){var e,f,g,h;if(h=k.oauthio.request||{},!h.cors){k.url=encodeURIComponent(k.url),"/"!==k.url[0]&&(k.url="/"+k.url),k.url=b.oauthd_url+"/request/"+k.oauthio.provider+k.url,k.headers=k.headers||{},k.headers.oauthio="k="+b.key,k.oauthio.tokens.oauth_token&&k.oauthio.tokens.oauth_token_secret&&(k.headers.oauthio+="&oauthv=1");for(f in k.oauthio.tokens)k.headers.oauthio+="&"+encodeURIComponent(f)+"="+encodeURIComponent(k.oauthio.tokens[f]);return delete k.oauthio,a.ajax(k)}if(k.oauthio.tokens){if(k.oauthio.tokens.access_token&&(k.oauthio.tokens.token=k.oauthio.tokens.access_token),k.url.match(/^[a-z]{2,16}:\/\//)||("/"!==k.url[0]&&(k.url="/"+k.url),k.url=h.url+k.url),k.url=c.replaceParam(k.url,k.oauthio.tokens,h.parameters),h.query){g=[];for(e in h.query)g.push(encodeURIComponent(e)+"="+encodeURIComponent(c.replaceParam(h.query[e],k.oauthio.tokens,h.parameters)));k.url+=d.call(k.url,"?")>=0?"&"+g:"?"+g}if(h.headers){k.headers=k.headers||{};for(e in h.headers)k.headers[e]=c.replaceParam(h.headers[e],k.oauthio.tokens,h.parameters)}return delete k.oauthio,a.ajax(k)}},k={},j=void 0;for(j in e)k[j]=e[j];return k.oauthio.request&&k.oauthio.request!==!0?i():(h={wait:!!k.oauthio.request},f=null!=a?a.Deferred():void 0,g.getDescription(k.oauthio.provider,h,function(a,b){return a?null!=f?f.reject(a):void 0:(k.oauthio.request=k.oauthio.tokens.oauth_token&&k.oauthio.tokens.oauth_token_secret?b.oauth1&&b.oauth1.request:b.oauth2&&b.oauth2.request,void(null!=f&&f.resolve()))}),null!=f?f.then(i):void 0)},http_me:function(c){var d,e,f,h,i;f=function(){var c,d,e,f;c=null!=a?a.Deferred():void 0,f=i.oauthio.request||{},i.url=b.oauthd_url+"/auth/"+i.oauthio.provider+"/me",i.headers=i.headers||{},i.headers.oauthio="k="+b.key,i.oauthio.tokens.oauth_token&&i.oauthio.tokens.oauth_token_secret&&(i.headers.oauthio+="&oauthv=1");for(d in i.oauthio.tokens)i.headers.oauthio+="&"+encodeURIComponent(d)+"="+encodeURIComponent(i.oauthio.tokens[d]);return delete i.oauthio,e=a.ajax(i),a.when(e).done(function(a){null!=c&&c.resolve(a.data)}).fail(function(a){a.responseJSON?null!=c&&c.reject(a.responseJSON.data):null!=c&&c.reject(new Error("An error occured while trying to access the resource"))}),null!=c?c.promise():void 0},i={};for(h in c)i[h]=c[h];return i.oauthio.request&&i.oauthio.request!==!0?f():(e={wait:!!i.oauthio.request},d=null!=a?a.Deferred():void 0,g.getDescription(i.oauthio.provider,e,function(a,b){return a?null!=d?d.reject(a):void 0:(i.oauthio.request=i.oauthio.tokens.oauth_token&&i.oauthio.tokens.oauth_token_secret?b.oauth1&&b.oauth1.request:b.oauth2&&b.oauth2.request,void(null!=d&&d.resolve()))}),null!=d?d.then(f):void 0)},mkHttp:function(a,b,c,d){var e;return e=this,function(f,g){var h,i;if(i={},"string"==typeof f){if("object"==typeof g)for(h in g)i[h]=g[h];i.url=f}else if("object"==typeof f)for(h in f)i[h]=f[h];return i.type=i.type||d,i.oauthio={provider:a,tokens:b,request:c},e.http(i)}},mkHttpMe:function(a,b,c,d){var e;return e=this,function(f){var g;return g={},g.type=g.type||d,g.oauthio={provider:a,tokens:b,request:c},g.data=g.data||{},g.data.filter=f?f.join(","):void 0,e.http_me(g)}},sendCallback:function(a,b){var c,d,g,h,i,j,k,l,m;c=this,d=void 0,h=void 0;try{d=JSON.parse(a.data)}catch(n){return g=n,null!=b&&b.reject(new Error("Error while parsing result")),a.callback(new Error("Error while parsing result"))}if(d&&d.provider){if(a.provider&&d.provider.toLowerCase()!==a.provider.toLowerCase())return h=new Error("Returned provider name does not match asked provider"),null!=b&&b.reject(h),a.callback&&"function"==typeof a.callback?a.callback(h):void 0;if("error"===d.status||"fail"===d.status)return h=new Error(d.message),h.body=d.data,null!=b&&b.reject(h),a.callback&&"function"==typeof a.callback?a.callback(h):void 0;if("success"!==d.status||!d.data)return h=new Error,h.body=d.data,null!=b&&b.reject(h),a.callback&&"function"==typeof a.callback?a.callback(h):void 0;if(!d.state||-1===e.indexOf(d.state))return null!=b&&b.reject(new Error("State is not matching")),a.callback&&"function"==typeof a.callback?a.callback(new Error("State is not matching")):void 0;if(a.provider||(d.data.provider=d.provider),l=d.data,f.cacheEnabled(a.cache)&&l&&f.storeCache(d.provider,l),k=l.request,delete l.request,m=void 0,l.access_token?m={access_token:l.access_token}:l.oauth_token&&l.oauth_token_secret&&(m={oauth_token:l.oauth_token,oauth_token_secret:l.oauth_token_secret}),!k)return null!=b&&b.resolve(l),a.callback&&"function"==typeof a.callback?a.callback(null,l):void 0;if(k.required)for(i in k.required)m[k.required[i]]=l[k.required[i]];return j=function(a){return c.mkHttp(d.provider,m,k,a)},l.get=j("GET"),l.post=j("POST"),l.put=j("PUT"),l.patch=j("PATCH"),l.del=j("DELETE"),l.me=c.mkHttpMe(d.provider,m,k,"GET"),null!=b&&b.resolve(l),a.callback&&"function"==typeof a.callback?a.callback(null,l):void 0}}}}},{"../tools/url":8}],4:[function(a){var b,c;c="undefined"!=typeof jQuery&&null!==jQuery?jQuery:void 0,(b=a("./lib/oauth")(window,document,c,navigator))(window||this)},{"./lib/oauth":2}],5:[function(a,b){b.exports={init:function(a,b){return this.config=b,this.cookies=a},tryCache:function(a,b,c){var d,e,f;if(this.cacheEnabled(c)){try{c=JSON.parse(window.localStorage.getItem("oauthio_provider_"+b))}catch(g){d=g,c=!1}if(c=c&&c.date>=(new Date).getTime()?c.value:!1,!c)return!1;c=decodeURIComponent(c)}if("string"==typeof c)try{c=JSON.parse(c)}catch(g){return d=g,!1}if("object"==typeof c){f={};for(e in c)"request"!==e&&"function"!=typeof c[e]&&(f[e]=c[e]);return a.create(b,f,c.request)}return!1},clearCache:function(a){var b,c,d;if(null!=a)return window.localStorage.removeItem("oauthio_provider_"+a);try{b=JSON.parse(window.localStorage.getItem("oauthio_cached_providers"))}catch(e){c=e,b={}}b=b||{};for(d in b)b[d]&&(b[d]=!1,window.localStorage.removeItem("oauthio_provider_"+d));return window.localStorage.setItem("oauthio_cached_providers",JSON.stringify(b))},storeCache:function(a,b){var c,d,e;e=1e3*b.expires_in-1e4||36e6,window.localStorage.setItem("oauthio_provider_"+a,JSON.stringify({value:encodeURIComponent(JSON.stringify(b)),date:(new Date).getTime()+e}));try{c=JSON.parse(window.localStorage.getItem("oauthio_cached_providers"))}catch(f){d=f,c={}}c=c||{},c[a]=!0,window.localStorage.setItem("oauthio_cached_providers",JSON.stringify(c))},cacheEnabled:function(a){return"undefined"==typeof a?this.config.options.cache:a}}},{}],6:[function(a,b){b.exports={init:function(a,b){return this.config=a,this.document=b},createCookie:function(a,b,c){var d;this.eraseCookie(a),d=new Date,d.setTime(d.getTime()+1e3*(c||1200)),c="; expires="+d.toGMTString(),this.document.cookie=a+"="+b+c+"; path=/"},readCookie:function(a){var b,c,d,e;for(e=a+"=",c=this.document.cookie.split(";"),d=0;d16&&(c=this.binb_sha1(c,8*a.length)),f=Array(16),g=Array(16),e=0;16>e;)f[e]=909522486^c[e],g[e]=1549556828^c[e],e++;return d=this.binb_sha1(f.concat(this.rstr2binb(b)),512+8*b.length),this.binb2rstr(this.binb_sha1(g.concat(d),672))},rstr2hex:function(a){var b,c,e,f,g;try{}catch(h){b=h,d=0}for(c=d?"0123456789ABCDEF":"0123456789abcdef",f="",g=void 0,e=0;e>>4&15)+c.charAt(15&g),e++;return f},rstr2b64:function(a){var b,d,e,f,g,h,i;try{}catch(j){b=j,c=""}for(h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g="",f=a.length,d=0;f>d;){for(i=a.charCodeAt(d)<<16|(f>d+1?a.charCodeAt(d+1)<<8:0)|(f>d+2?a.charCodeAt(d+2):0),e=0;4>e;)g+=8*d+6*e>8*a.length?c:h.charAt(i>>>6*(3-e)&63),e++;d+=3}return g},rstr2any:function(a,b){var c,d,e,f,g,h,i,j,k;for(d=b.length,j=Array(),f=void 0,h=void 0,k=void 0,i=void 0,c=Array(Math.ceil(a.length/2)),f=0;f0;){for(i=Array(),k=0,f=0;f0||h>0)&&(i[i.length]=h),f++;j[j.length]=k,c=i}for(g="",f=j.length-1;f>=0;)g+=b.charAt(j[f]),f--;for(e=Math.ceil(8*a.length/(Math.log(b.length)/Math.log(2))),f=g.length;e>f;)g=b[0]+g,f++;return g},str2rstr_utf8:function(a){var b,c,d,e;for(c="",b=-1,d=void 0,e=void 0;++b=55296&&56319>=d&&e>=56320&&57343>=e&&(d=65536+((1023&d)<<10)+(1023&e),b++),127>=d?c+=String.fromCharCode(d):2047>=d?c+=String.fromCharCode(192|d>>>6&31,128|63&d):65535>=d?c+=String.fromCharCode(224|d>>>12&15,128|d>>>6&63,128|63&d):2097151>=d&&(c+=String.fromCharCode(240|d>>>18&7,128|d>>>12&63,128|d>>>6&63,128|63&d));return c},str2rstr_utf16le:function(a){var b,c;for(c="",b=0;b>>8&255),b++;return c},str2rstr_utf16be:function(a){var b,c;for(c="",b=0;b>>8&255,255&a.charCodeAt(b)),b++;return c},rstr2binb:function(a){var b,c;for(c=Array(a.length>>2),b=0;b>5]|=(255&a.charCodeAt(b/8))<<24-b%32,b+=8;return c},binb2rstr:function(a){var b,c;for(c="",b=0;b<32*a.length;)c+=String.fromCharCode(a[b>>5]>>>24-b%32&255),b+=8;return c},binb_sha1:function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;for(a[b>>5]|=128<<24-b%32,a[(b+64>>9<<4)+15]=b,p=Array(80),c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=-1009589776,h=0;hi;)p[i]=16>i?a[h+i]:this.bit_rol(p[i-3]^p[i-8]^p[i-14]^p[i-16],1),o=this.safe_add(this.safe_add(this.bit_rol(c,5),this.sha1_ft(i,d,e,f)),this.safe_add(this.safe_add(g,p[i]),this.sha1_kt(i))),g=f,f=e,e=this.bit_rol(d,30),d=c,c=o,i++;c=this.safe_add(c,j),d=this.safe_add(d,k),e=this.safe_add(e,l),f=this.safe_add(f,m),g=this.safe_add(g,n),h+=16}return Array(c,d,e,f,g)},sha1_ft:function(a,b,c,d){return 20>a?b&c|~b&d:40>a?b^c^d:60>a?b&c|b&d|c&d:b^c^d},sha1_kt:function(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514},safe_add:function(a,b){var c,d;return c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16),d<<16|65535&c},bit_rol:function(a,b){return a<>>32-b},create_hash:function(){var a;return a=this.b64_sha1((new Date).getTime()+":"+Math.floor(9999999*Math.random())),a.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}}},{}],8:[function(a,b){b.exports=function(a){return{getAbsUrl:function(b){var c;return b.match(/^.{2,5}:\/\//)?b:"/"===b[0]?a.location.protocol+"//"+a.location.host+b:(c=a.location.protocol+"//"+a.location.host+a.location.pathname,"/"!==c[c.length-1]&&"#"!==b[0]?c+"/"+b:c+b)},replaceParam:function(a,b,c){return a=a.replace(/\{\{(.*?)\}\}/g,function(a,c){return b[c]||""}),c&&(a=a.replace(/\{(.*?)\}/g,function(a,b){return c[b]||""})),a}}}},{}]},{},[4]); \ No newline at end of file +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gb;b++)if(b in this&&this[b]===a)return b;return-1};c=a("../tools/url")(),b.exports=function(a,b,e,f,g){return{http:function(e){var f,h,i,j,k;i=function(){var e,f,g,h;if(h=k.oauthio.request||{},!h.cors){k.url=encodeURIComponent(k.url),"/"!==k.url[0]&&(k.url="/"+k.url),k.url=b.oauthd_url+"/request/"+k.oauthio.provider+k.url,k.headers=k.headers||{},k.headers.oauthio="k="+b.key,k.oauthio.tokens.oauth_token&&k.oauthio.tokens.oauth_token_secret&&(k.headers.oauthio+="&oauthv=1");for(f in k.oauthio.tokens)k.headers.oauthio+="&"+encodeURIComponent(f)+"="+encodeURIComponent(k.oauthio.tokens[f]);return delete k.oauthio,a.ajax(k)}if(k.oauthio.tokens){if(k.oauthio.tokens.access_token&&(k.oauthio.tokens.token=k.oauthio.tokens.access_token),k.url.match(/^[a-z]{2,16}:\/\//)||("/"!==k.url[0]&&(k.url="/"+k.url),k.url=h.url+k.url),k.url=c.replaceParam(k.url,k.oauthio.tokens,h.parameters),h.query){g=[];for(e in h.query)g.push(encodeURIComponent(e)+"="+encodeURIComponent(c.replaceParam(h.query[e],k.oauthio.tokens,h.parameters)));k.url+=d.call(k.url,"?")>=0?"&"+g:"?"+g}if(h.headers){k.headers=k.headers||{};for(e in h.headers)k.headers[e]=c.replaceParam(h.headers[e],k.oauthio.tokens,h.parameters)}return delete k.oauthio,a.ajax(k)}},k={},j=void 0;for(j in e)k[j]=e[j];return k.oauthio.request&&k.oauthio.request!==!0?i():(h={wait:!!k.oauthio.request},f=null!=a?a.Deferred():void 0,g.getDescription(k.oauthio.provider,h,function(a,b){return a?null!=f?f.reject(a):void 0:(k.oauthio.request=k.oauthio.tokens.oauth_token&&k.oauthio.tokens.oauth_token_secret?b.oauth1&&b.oauth1.request:b.oauth2&&b.oauth2.request,void(null!=f&&f.resolve()))}),null!=f?f.then(i):void 0)},http_me:function(c){var d,e,f,h,i;f=function(){var c,d,e,f;c=null!=a?a.Deferred():void 0,f=i.oauthio.request||{},i.url=b.oauthd_url+"/auth/"+i.oauthio.provider+"/me",i.headers=i.headers||{},i.headers.oauthio="k="+b.key,i.oauthio.tokens.oauth_token&&i.oauthio.tokens.oauth_token_secret&&(i.headers.oauthio+="&oauthv=1");for(d in i.oauthio.tokens)i.headers.oauthio+="&"+encodeURIComponent(d)+"="+encodeURIComponent(i.oauthio.tokens[d]);return delete i.oauthio,e=a.ajax(i),a.when(e).done(function(a){null!=c&&c.resolve(a.data)}).fail(function(a){a.responseJSON?null!=c&&c.reject(a.responseJSON.data):null!=c&&c.reject(new Error("An error occured while trying to access the resource"))}),null!=c?c.promise():void 0},i={};for(h in c)i[h]=c[h];return i.oauthio.request&&i.oauthio.request!==!0?f():(e={wait:!!i.oauthio.request},d=null!=a?a.Deferred():void 0,g.getDescription(i.oauthio.provider,e,function(a,b){return a?null!=d?d.reject(a):void 0:(i.oauthio.request=i.oauthio.tokens.oauth_token&&i.oauthio.tokens.oauth_token_secret?b.oauth1&&b.oauth1.request:b.oauth2&&b.oauth2.request,void(null!=d&&d.resolve()))}),null!=d?d.then(f):void 0)},mkHttp:function(a,b,c,d){var e;return e=this,function(f,g){var h,i;if(i={},"string"==typeof f){if("object"==typeof g)for(h in g)i[h]=g[h];i.url=f}else if("object"==typeof f)for(h in f)i[h]=f[h];return i.type=i.type||d,i.oauthio={provider:a,tokens:b,request:c},e.http(i)}},mkHttpMe:function(a,b,c,d){var e;return e=this,function(f){var g;return g={},g.type=g.type||d,g.oauthio={provider:a,tokens:b,request:c},g.data=g.data||{},g.data.filter=f?f.join(","):void 0,e.http_me(g)}},sendCallback:function(a,b){var c,d,g,h,i,j,k,l,m;c=this,d=void 0,h=void 0;try{d=JSON.parse(a.data)}catch(n){return g=n,null!=b&&b.reject(new Error("Error while parsing result")),a.callback(new Error("Error while parsing result"))}if(d&&d.provider){if(a.provider&&d.provider.toLowerCase()!==a.provider.toLowerCase())return h=new Error("Returned provider name does not match asked provider"),null!=b&&b.reject(h),a.callback&&"function"==typeof a.callback?a.callback(h):void 0;if("error"===d.status||"fail"===d.status)return h=new Error(d.message),h.body=d.data,null!=b&&b.reject(h),a.callback&&"function"==typeof a.callback?a.callback(h):void 0;if("success"!==d.status||!d.data)return h=new Error,h.body=d.data,null!=b&&b.reject(h),a.callback&&"function"==typeof a.callback?a.callback(h):void 0;if(!d.state||-1===e.indexOf(d.state))return null!=b&&b.reject(new Error("State is not matching")),a.callback&&"function"==typeof a.callback?a.callback(new Error("State is not matching")):void 0;if(a.provider||(d.data.provider=d.provider),l=d.data,f.cacheEnabled(a.cache)&&l&&f.storeCache(d.provider,l),k=l.request,delete l.request,m=void 0,l.access_token?m={access_token:l.access_token}:l.oauth_token&&l.oauth_token_secret&&(m={oauth_token:l.oauth_token,oauth_token_secret:l.oauth_token_secret}),!k)return null!=b&&b.resolve(l),a.callback&&"function"==typeof a.callback?a.callback(null,l):void 0;if(k.required)for(i in k.required)m[k.required[i]]=l[k.required[i]];return j=function(a){return c.mkHttp(d.provider,m,k,a)},l.get=j("GET"),l.post=j("POST"),l.put=j("PUT"),l.patch=j("PATCH"),l.del=j("DELETE"),l.me=c.mkHttpMe(d.provider,m,k,"GET"),null!=b&&b.resolve(l),a.callback&&"function"==typeof a.callback?a.callback(null,l):void 0}}}}},{"../tools/url":8}],4:[function(a){var b,c;c="undefined"!=typeof jQuery&&null!==jQuery?jQuery:void 0,(b=a("./lib/oauth")(window,document,c,navigator))(window||this)},{"./lib/oauth":2}],5:[function(a,b){b.exports={init:function(a,b){return this.config=b,this.cookies=a},tryCache:function(a,b,c){var d,e,f;if(this.cacheEnabled(c)){try{c=JSON.parse(window.localStorage.getItem("oauthio_provider_"+b))}catch(g){d=g,c=!1}if(c=c&&c.date>=(new Date).getTime()?c.value:!1,!c)return!1;c=decodeURIComponent(c)}if("string"==typeof c)try{c=JSON.parse(c)}catch(g){return d=g,!1}if("object"==typeof c){f={};for(e in c)"request"!==e&&"function"!=typeof c[e]&&(f[e]=c[e]);return a.create(b,f,c.request)}return!1},clearCache:function(a){var b,c,d;if(null!=a)return window.localStorage.removeItem("oauthio_provider_"+a);try{b=JSON.parse(window.localStorage.getItem("oauthio_cached_providers"))}catch(e){c=e,b={}}b=b||{};for(d in b)b[d]&&(b[d]=!1,window.localStorage.removeItem("oauthio_provider_"+d));return window.localStorage.setItem("oauthio_cached_providers",JSON.stringify(b))},storeCache:function(a,b){var c,d,e;e=1e3*b.expires_in-1e4||36e6,window.localStorage.setItem("oauthio_provider_"+a,JSON.stringify({value:encodeURIComponent(JSON.stringify(b)),date:(new Date).getTime()+e}));try{c=JSON.parse(window.localStorage.getItem("oauthio_cached_providers"))}catch(f){d=f,c={}}c=c||{},c[a]=!0,window.localStorage.setItem("oauthio_cached_providers",JSON.stringify(c))},cacheEnabled:function(a){return"undefined"==typeof a?this.config.options.cache:a}}},{}],6:[function(a,b){b.exports={init:function(a,b){return this.config=a,this.document=b},createCookie:function(a,b,c){var d;this.eraseCookie(a),d=new Date,d.setTime(d.getTime()+1e3*(c||1200)),c="; expires="+d.toGMTString(),this.document.cookie=a+"="+b+c+"; path=/"},readCookie:function(a){var b,c,d,e;for(e=a+"=",c=this.document.cookie.split(";"),d=0;d16&&(c=this.binb_sha1(c,8*a.length)),f=Array(16),g=Array(16),e=0;16>e;)f[e]=909522486^c[e],g[e]=1549556828^c[e],e++;return d=this.binb_sha1(f.concat(this.rstr2binb(b)),512+8*b.length),this.binb2rstr(this.binb_sha1(g.concat(d),672))},rstr2hex:function(a){var b,c,e,f,g;try{}catch(h){b=h,d=0}for(c=d?"0123456789ABCDEF":"0123456789abcdef",f="",g=void 0,e=0;e>>4&15)+c.charAt(15&g),e++;return f},rstr2b64:function(a){var b,d,e,f,g,h,i;try{}catch(j){b=j,c=""}for(h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g="",f=a.length,d=0;f>d;){for(i=a.charCodeAt(d)<<16|(f>d+1?a.charCodeAt(d+1)<<8:0)|(f>d+2?a.charCodeAt(d+2):0),e=0;4>e;)g+=8*d+6*e>8*a.length?c:h.charAt(i>>>6*(3-e)&63),e++;d+=3}return g},rstr2any:function(a,b){var c,d,e,f,g,h,i,j,k;for(d=b.length,j=Array(),f=void 0,h=void 0,k=void 0,i=void 0,c=Array(Math.ceil(a.length/2)),f=0;f0;){for(i=Array(),k=0,f=0;f0||h>0)&&(i[i.length]=h),f++;j[j.length]=k,c=i}for(g="",f=j.length-1;f>=0;)g+=b.charAt(j[f]),f--;for(e=Math.ceil(8*a.length/(Math.log(b.length)/Math.log(2))),f=g.length;e>f;)g=b[0]+g,f++;return g},str2rstr_utf8:function(a){var b,c,d,e;for(c="",b=-1,d=void 0,e=void 0;++b=55296&&56319>=d&&e>=56320&&57343>=e&&(d=65536+((1023&d)<<10)+(1023&e),b++),127>=d?c+=String.fromCharCode(d):2047>=d?c+=String.fromCharCode(192|d>>>6&31,128|63&d):65535>=d?c+=String.fromCharCode(224|d>>>12&15,128|d>>>6&63,128|63&d):2097151>=d&&(c+=String.fromCharCode(240|d>>>18&7,128|d>>>12&63,128|d>>>6&63,128|63&d));return c},str2rstr_utf16le:function(a){var b,c;for(c="",b=0;b>>8&255),b++;return c},str2rstr_utf16be:function(a){var b,c;for(c="",b=0;b>>8&255,255&a.charCodeAt(b)),b++;return c},rstr2binb:function(a){var b,c;for(c=Array(a.length>>2),b=0;b>5]|=(255&a.charCodeAt(b/8))<<24-b%32,b+=8;return c},binb2rstr:function(a){var b,c;for(c="",b=0;b<32*a.length;)c+=String.fromCharCode(a[b>>5]>>>24-b%32&255),b+=8;return c},binb_sha1:function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;for(a[b>>5]|=128<<24-b%32,a[(b+64>>9<<4)+15]=b,p=Array(80),c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=-1009589776,h=0;hi;)p[i]=16>i?a[h+i]:this.bit_rol(p[i-3]^p[i-8]^p[i-14]^p[i-16],1),o=this.safe_add(this.safe_add(this.bit_rol(c,5),this.sha1_ft(i,d,e,f)),this.safe_add(this.safe_add(g,p[i]),this.sha1_kt(i))),g=f,f=e,e=this.bit_rol(d,30),d=c,c=o,i++;c=this.safe_add(c,j),d=this.safe_add(d,k),e=this.safe_add(e,l),f=this.safe_add(f,m),g=this.safe_add(g,n),h+=16}return Array(c,d,e,f,g)},sha1_ft:function(a,b,c,d){return 20>a?b&c|~b&d:40>a?b^c^d:60>a?b&c|b&d|c&d:b^c^d},sha1_kt:function(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514},safe_add:function(a,b){var c,d;return c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16),d<<16|65535&c},bit_rol:function(a,b){return a<>>32-b},create_hash:function(){var a;return a=this.b64_sha1((new Date).getTime()+":"+Math.floor(9999999*Math.random())),a.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}}},{}],8:[function(a,b){b.exports=function(a){return{getAbsUrl:function(b){var c;return b.match(/^.{2,5}:\/\//)?b:"/"===b[0]?a.location.protocol+"//"+a.location.host+b:(c=a.location.protocol+"//"+a.location.host+a.location.pathname,"/"!==c[c.length-1]&&"#"!==b[0]?c+"/"+b:c+b)},replaceParam:function(a,b,c){return a=a.replace(/\{\{(.*?)\}\}/g,function(a,c){return b[c]||""}),c&&(a=a.replace(/\{(.*?)\}/g,function(a,b){return c[b]||""})),a}}}},{}]},{},[4]); \ No newline at end of file diff --git a/www/js/lib/oauth.js b/www/js/lib/oauth.js index 664b04c..b4388c3 100644 --- a/www/js/lib/oauth.js +++ b/www/js/lib/oauth.js @@ -240,6 +240,14 @@ module.exports = function(window, document, jQuery, navigator) { } } }); + wnd.addEventListener("exit", function() { + if (defer != null) { + defer.reject(new Error("The popup was closed")); + } + if (opts.callback && typeof opts.callback === "function") { + return opts.callback(new Error("The popup was closed")); + } + }); return defer != null ? defer.promise() : void 0; }, clearCache: function(provider) {