1
- /** remotestorage.js 0.14.1-pre , http://remotestorage.io, MIT-licensed **/
1
+ /** remotestorage.js 0.14.0 , http://remotestorage.io, MIT-licensed **/
2
2
define ( [ ] , function ( ) {
3
3
4
4
/** FILE: src/remotestorage.js **/
@@ -2155,11 +2155,11 @@ define([], function() {
2155
2155
/* global define */
2156
2156
/*!
2157
2157
* webfinger.js
2158
- * version 2.6.4
2158
+ * version 2.4.2
2159
2159
* http://github.com/silverbucket/webfinger.js
2160
2160
*
2161
2161
* Developed and Maintained by:
2162
- * Nick Jennings <[email protected] > 2012
2162
+ * Nick Jennings <[email protected] > 2012 - 2016
2163
2163
*
2164
2164
* webfinger.js is released under the AGPL (see LICENSE).
2165
2165
*
@@ -2172,11 +2172,10 @@ define([], function() {
2172
2172
*/
2173
2173
2174
2174
if ( typeof XMLHttpRequest === 'undefined' ) {
2175
- // XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
2176
- XMLHttpRequest = require ( 'xhr2' ) ;
2175
+ XMLHttpRequest = require ( 'xmlhttprequest' ) . XMLHttpRequest ;
2177
2176
}
2178
2177
2179
- ( function ( global ) {
2178
+ ( function ( undefined ) {
2180
2179
2181
2180
// URI to property name map
2182
2181
var LINK_URI_MAPS = {
@@ -2258,7 +2257,6 @@ if (typeof XMLHttpRequest === 'undefined') {
2258
2257
var self = this ;
2259
2258
2260
2259
var xhr = new XMLHttpRequest ( ) ;
2261
- xhr . timeout = this . config . request_timeout ;
2262
2260
2263
2261
function __processState ( ) {
2264
2262
if ( xhr . status === 200 ) {
@@ -2304,18 +2302,9 @@ if (typeof XMLHttpRequest === 'undefined') {
2304
2302
}
2305
2303
} ;
2306
2304
2307
- xhr . onload = function ( ) {
2305
+ xhr . onload = function ( a , b ) {
2308
2306
__processState ( ) ;
2309
- } ;
2310
-
2311
- xhr . ontimeout = function ( ) {
2312
- return errorHandler ( generateErrorObject ( {
2313
- message : 'request timed out' ,
2314
- url : url ,
2315
- status : xhr . status
2316
- } ) ) ;
2317
- } ;
2318
-
2307
+ }
2319
2308
xhr . open ( 'GET' , url , true ) ;
2320
2309
xhr . setRequestHeader ( 'Accept' , 'application/jrd+json, application/json' ) ;
2321
2310
xhr . send ( ) ;
@@ -2352,9 +2341,6 @@ if (typeof XMLHttpRequest === 'undefined') {
2352
2341
}
2353
2342
2354
2343
var links = parsedJRD . links ;
2355
- if ( ! Array . isArray ( links ) ) {
2356
- links = [ ] ;
2357
- }
2358
2344
var result = { // webfinger JRD - object, json, and our own indexing
2359
2345
object : parsedJRD ,
2360
2346
json : JRD ,
@@ -2402,7 +2388,7 @@ if (typeof XMLHttpRequest === 'undefined') {
2402
2388
var host = '' ;
2403
2389
if ( address . indexOf ( '://' ) > - 1 ) {
2404
2390
// other uri format
2405
- host = address . replace ( / / g, '' ) . split ( '/ ' ) [ 2 ] ;
2391
+ host = address . replace ( / / g, '' ) . split ( ':// ' ) [ 1 ] ;
2406
2392
} else {
2407
2393
// useraddress
2408
2394
host = address . replace ( / / g, '' ) . split ( '@' ) [ 1 ] ;
@@ -2489,24 +2475,17 @@ if (typeof XMLHttpRequest === 'undefined') {
2489
2475
}
2490
2476
} ;
2491
2477
2492
-
2493
-
2494
- // AMD support
2495
- if ( typeof define === 'function' && define . amd ) {
2496
- define ( [ ] , function ( ) { return WebFinger ; } ) ;
2497
- // CommonJS and Node.js module support.
2498
- } else if ( typeof exports !== 'undefined' ) {
2499
- // Support Node.js specific `module.exports` (which can be a function)
2500
- if ( typeof module !== 'undefined' && module . exports ) {
2501
- exports = module . exports = WebFinger ;
2502
- }
2503
- // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)
2504
- exports . WebFinger = WebFinger ;
2478
+ if ( typeof window === 'object' ) {
2479
+ window . WebFinger = WebFinger ;
2480
+ } else if ( typeof ( define ) === 'function' && define . amd ) {
2481
+ define ( [ ] , function ( ) { return WebFinger ; } ) ;
2505
2482
} else {
2506
- // browser <script> support
2507
- global . WebFinger = WebFinger ;
2483
+ try {
2484
+ module . exports = WebFinger ;
2485
+ } catch ( e ) { }
2508
2486
}
2509
- } ) ( this ) ;
2487
+ } ) ( ) ;
2488
+
2510
2489
2511
2490
2512
2491
/** FILE: src/authorize.js **/
@@ -6667,13 +6646,11 @@ Math.uuid = function (len, radix) {
6667
6646
var BASE_URL = 'https://www.googleapis.com' ;
6668
6647
var AUTH_URL = 'https://accounts.google.com/o/oauth2/auth' ;
6669
6648
var AUTH_SCOPE = 'https://www.googleapis.com/auth/drive' ;
6670
- var SETTINGS_KEY = 'remotestorage:googledrive' ;
6671
6649
6672
6650
var GD_DIR_MIME_TYPE = 'application/vnd.google-apps.folder' ;
6673
6651
var RS_DIR_MIME_TYPE = 'application/json; charset=UTF-8' ;
6674
6652
6675
6653
var isFolder = RemoteStorage . util . isFolder ;
6676
- var hasLocalStorage ;
6677
6654
6678
6655
function buildQueryString ( params ) {
6679
6656
return Object . keys ( params ) . map ( function ( key ) {
@@ -6733,67 +6710,22 @@ Math.uuid = function (len, radix) {
6733
6710
this . clientId = clientId ;
6734
6711
6735
6712
this . _fileIdCache = new Cache ( 60 * 5 ) ; // ids expire after 5 minutes (is this a good idea?)
6736
-
6737
- hasLocalStorage = RemoteStorage . util . localStorageAvailable ( ) ;
6738
-
6739
- if ( hasLocalStorage ) {
6740
- var settings ;
6741
- try {
6742
- settings = JSON . parse ( localStorage . getItem ( SETTINGS_KEY ) ) ;
6743
- } catch ( e ) { }
6744
- if ( settings ) {
6745
- this . configure ( settings ) ;
6746
- }
6747
- }
6748
-
6749
6713
} ;
6750
6714
6751
6715
RS . GoogleDrive . prototype = {
6752
6716
connected : false ,
6753
6717
online : true ,
6754
6718
6755
6719
configure : function ( settings ) { // Settings parameter compatible with WireClient
6756
- // We only update this.userAddress if settings.userAddress is set to a string or to null
6757
- if ( typeof settings . userAddress !== 'undefined' ) { this . userAddress = settings . userAddress ; }
6758
- // Same for this.token. If only one of these two is set, we leave the other one at its existing value
6759
- if ( typeof settings . token !== 'undefined' ) { this . token = settings . token ; }
6760
-
6761
- var writeSettingsToCache = function ( ) {
6762
- if ( hasLocalStorage ) {
6763
- localStorage . setItem ( SETTINGS_KEY , JSON . stringify ( {
6764
- userAddress : this . userAddress ,
6765
- token : this . token
6766
- } ) ) ;
6767
- }
6768
- } ;
6769
-
6770
- var handleError = function ( ) {
6771
- this . connected = false ;
6772
- delete this . token ;
6773
- if ( hasLocalStorage ) {
6774
- localStorage . removeItem ( SETTINGS_KEY ) ;
6775
- }
6776
- } ;
6777
-
6778
- if ( this . token ) {
6720
+ if ( settings . token ) {
6721
+ localStorage [ 'remotestorage:googledrive:token' ] = settings . token ;
6722
+ this . token = settings . token ;
6779
6723
this . connected = true ;
6780
-
6781
- if ( this . userAddress ) {
6782
- this . _emit ( 'connected' ) ;
6783
- writeSettingsToCache . apply ( this ) ;
6784
- } else {
6785
- this . info ( ) . then ( function ( info ) {
6786
- this . userAddress = info . user . emailAddress ;
6787
- this . rs . widget . view . setUserAddress ( this . userAddress ) ;
6788
- this . _emit ( 'connected' ) ;
6789
- writeSettingsToCache . apply ( this ) ;
6790
- } . bind ( this ) ) . catch ( function ( ) {
6791
- handleError . apply ( this ) ;
6792
- this . rs . _emit ( 'error' , new Error ( 'Could not fetch user info.' ) ) ;
6793
- } . bind ( this ) ) ;
6794
- }
6724
+ this . _emit ( 'connected' ) ;
6795
6725
} else {
6796
- handleError . apply ( this ) ;
6726
+ this . connected = false ;
6727
+ delete this . token ;
6728
+ delete localStorage [ 'remotestorage:googledrive:token' ] ;
6797
6729
}
6798
6730
} ,
6799
6731
@@ -6869,28 +6801,6 @@ Math.uuid = function (len, radix) {
6869
6801
} ) ;
6870
6802
} ,
6871
6803
6872
- /**
6873
- * Method: info
6874
- *
6875
- * Fetches the user's info from Google and returns a promise for it.
6876
- *
6877
- * Returns:
6878
- *
6879
- * A promise to the user's info
6880
- */
6881
- info : function ( ) {
6882
- var url = BASE_URL + '/drive/v2/about?fields=user' ;
6883
- // requesting user info(mainly for userAdress)
6884
- return this . _request ( 'GET' , url , { } ) . then ( function ( resp ) {
6885
- try {
6886
- var info = JSON . parse ( resp . responseText ) ;
6887
- return Promise . resolve ( info ) ;
6888
- } catch ( e ) {
6889
- return Promise . reject ( e ) ;
6890
- }
6891
- } ) ;
6892
- } ,
6893
-
6894
6804
_updateFile : function ( id , path , body , contentType , options ) {
6895
6805
var self = this ;
6896
6806
var metadata = {
@@ -7382,18 +7292,16 @@ Math.uuid = function (len, radix) {
7382
7292
this . _itemRefs = { } ;
7383
7293
this . _metadataCache = { } ;
7384
7294
7385
- hasLocalStorage = RemoteStorage . util . localStorageAvailable ( ) ;
7386
-
7387
7295
if ( hasLocalStorage ) {
7388
7296
var settings ;
7389
7297
try {
7390
- settings = JSON . parse ( localStorage . getItem ( SETTINGS_KEY ) ) ;
7298
+ settings = JSON . parse ( localStorage [ SETTINGS_KEY ] ) ;
7391
7299
} catch ( e ) { }
7392
7300
if ( settings ) {
7393
7301
this . configure ( settings ) ;
7394
7302
}
7395
7303
try {
7396
- this . _itemRefs = JSON . parse ( localStorage . getItem ( SETTINGS_KEY + ':shares' ) ) ;
7304
+ this . _itemRefs = JSON . parse ( localStorage [ SETTINGS_KEY + ':shares' ] ) ;
7397
7305
} catch ( e ) { }
7398
7306
}
7399
7307
if ( this . connected ) {
@@ -7431,40 +7339,23 @@ Math.uuid = function (len, radix) {
7431
7339
// Same for this.token. If only one of these two is set, we leave the other one at its existing value:
7432
7340
if ( typeof settings . token !== 'undefined' ) { this . token = settings . token ; }
7433
7341
7434
- var writeSettingsToCache = function ( ) {
7435
- if ( hasLocalStorage ) {
7436
- localStorage . setItem ( SETTINGS_KEY , JSON . stringify ( {
7437
- userAddress : this . userAddress ,
7438
- token : this . token
7439
- } ) ) ;
7440
- }
7441
- } ;
7442
-
7443
- var handleError = function ( ) {
7444
- this . connected = false ;
7445
- if ( hasLocalStorage ) {
7446
- localStorage . removeItem ( SETTINGS_KEY ) ;
7447
- }
7448
- } ;
7449
-
7450
7342
if ( this . token ) {
7451
7343
this . connected = true ;
7452
- if ( this . userAddress ) {
7453
- this . _emit ( 'connected' ) ;
7454
- writeSettingsToCache . apply ( this ) ;
7455
- } else {
7344
+ if ( ! this . userAddress ) {
7456
7345
this . info ( ) . then ( function ( info ) {
7457
- this . userAddress = info . email ;
7346
+ this . userAddress = info . display_name ;
7458
7347
this . rs . widget . view . setUserAddress ( this . userAddress ) ;
7459
7348
this . _emit ( 'connected' ) ;
7460
- writeSettingsToCache . apply ( this ) ;
7461
- } . bind ( this ) ) . catch ( function ( ) {
7462
- handleError . apply ( this ) ;
7463
- this . rs . _emit ( 'error' , new Error ( 'Could not fetch user info.' ) ) ;
7464
7349
} . bind ( this ) ) ;
7465
7350
}
7466
7351
} else {
7467
- handleError . apply ( this ) ;
7352
+ this . connected = false ;
7353
+ }
7354
+ if ( hasLocalStorage ) {
7355
+ localStorage [ SETTINGS_KEY ] = JSON . stringify ( {
7356
+ userAddress : this . userAddress ,
7357
+ token : this . token
7358
+ } ) ;
7468
7359
}
7469
7360
} ,
7470
7361
@@ -7762,7 +7653,7 @@ Math.uuid = function (len, radix) {
7762
7653
self . _itemRefs [ path ] = response . url ;
7763
7654
7764
7655
if ( hasLocalStorage ) {
7765
- localStorage . setItem ( SETTINGS_KEY + ':shares' , JSON . stringify ( self . _itemRefs ) ) ;
7656
+ localStorage [ SETTINGS_KEY + ':shares' ] = JSON . stringify ( self . _itemRefs ) ;
7766
7657
}
7767
7658
7768
7659
return Promise . resolve ( url ) ;
@@ -8154,6 +8045,7 @@ Math.uuid = function (len, radix) {
8154
8045
}
8155
8046
8156
8047
RS . Dropbox . _rs_init = function ( rs ) {
8048
+ hasLocalStorage = RemoteStorage . util . localStorageAvailable ( ) ;
8157
8049
if ( rs . apiKeys . dropbox ) {
8158
8050
rs . dropbox = new RS . Dropbox ( rs ) ;
8159
8051
}
@@ -8169,7 +8061,7 @@ Math.uuid = function (len, radix) {
8169
8061
RS . Dropbox . _rs_cleanup = function ( rs ) {
8170
8062
unHookIt ( rs ) ;
8171
8063
if ( hasLocalStorage ) {
8172
- localStorage . removeItem ( SETTINGS_KEY ) ;
8064
+ delete localStorage [ SETTINGS_KEY ] ;
8173
8065
}
8174
8066
rs . removeEventListener ( 'error' , onErrorCb ) ;
8175
8067
rs . setBackend ( undefined ) ;
0 commit comments