2
2
module . exports = {
3
3
oauthd_url : "https://oauth.io" ,
4
4
oauthd_api : "https://oauth.io/api" ,
5
- version : "web-0.2.2 " ,
5
+ version : "web-0.2.3 " ,
6
6
options : { }
7
7
} ;
8
8
@@ -158,7 +158,8 @@ module.exports = function(window, document, jQuery, navigator) {
158
158
return res ;
159
159
} ,
160
160
popup : function ( provider , opts , callback ) {
161
- var defer , frm , getMessage , res , url , wnd , wndTimeout , wnd_options , wnd_settings , _ref ;
161
+ var defer , frm , getMessage , gotmessage , interval , res , url , wnd , wndTimeout , wnd_options , wnd_settings , _ref ;
162
+ gotmessage = false ;
162
163
getMessage = function ( e ) {
163
164
if ( e . origin !== config . oauthd_base ) {
164
165
return ;
@@ -167,7 +168,8 @@ module.exports = function(window, document, jQuery, navigator) {
167
168
wnd . close ( ) ;
168
169
} catch ( _error ) { }
169
170
opts . data = e . data ;
170
- return oauthio . request . sendCallback ( opts , defer ) ;
171
+ oauthio . request . sendCallback ( opts , defer ) ;
172
+ return gotmessage = true ;
171
173
} ;
172
174
wnd = void 0 ;
173
175
frm = void 0 ;
@@ -301,6 +303,19 @@ module.exports = function(window, document, jQuery, navigator) {
301
303
wnd = window . open ( url , "Authorization" , wnd_options ) ;
302
304
if ( wnd ) {
303
305
wnd . focus ( ) ;
306
+ interval = window . setInterval ( function ( ) {
307
+ if ( wnd === null || wnd . closed ) {
308
+ window . clearInterval ( interval ) ;
309
+ if ( ! gotmessage ) {
310
+ if ( defer != null ) {
311
+ defer . reject ( new Error ( "The popup was closed" ) ) ;
312
+ }
313
+ if ( opts . callback && typeof opts . callback === "function" ) {
314
+ return opts . callback ( new Error ( "The popup was closed" ) ) ;
315
+ }
316
+ }
317
+ }
318
+ } , 500 ) ;
304
319
} else {
305
320
if ( defer != null ) {
306
321
defer . reject ( new Error ( "Could not open a popup" ) ) ;
0 commit comments