@google/earthengine 0.1.386 → 0.1.389
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/browser.js +173 -264
- package/build/ee_api_js.js +279 -279
- package/build/ee_api_js_debug.js +151 -242
- package/build/ee_api_js_npm.js +173 -264
- package/build/main.js +173 -264
- package/package.json +1 -1
- package/src/apiclient.js +43 -40
- package/src/data.js +7 -6
- package/src/examples/Demos/TerrainVisualization.js +1 -2
- package/.tmp/BUILD +0 -699
- package/.tmp/METADATA +0 -23
- package/.tmp/VERSION_BUILD +0 -47
package/package.json
CHANGED
package/src/apiclient.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
goog.module('ee.apiclient');
|
|
5
5
|
goog.module.declareLegacyNamespace();
|
|
6
6
|
|
|
7
|
-
const GoogConst = goog.require('goog.string.Const');
|
|
8
7
|
const Throttle = goog.require('goog.async.Throttle');
|
|
9
8
|
const Uri = goog.require('goog.Uri');
|
|
10
9
|
const XhrIo = goog.require('goog.net.XhrIo');
|
|
@@ -25,7 +24,7 @@ const {trustedResourceUrl} = goog.require('safevalues');
|
|
|
25
24
|
/** @namespace */
|
|
26
25
|
const apiclient = {};
|
|
27
26
|
|
|
28
|
-
const API_CLIENT_VERSION = '0.1.
|
|
27
|
+
const API_CLIENT_VERSION = '0.1.389';
|
|
29
28
|
|
|
30
29
|
exports.VERSION = apiVersion.VERSION;
|
|
31
30
|
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
|
|
@@ -533,7 +532,6 @@ apiclient.setAuthToken = function(
|
|
|
533
532
|
}
|
|
534
533
|
} else {
|
|
535
534
|
apiclient.ensureAuthLibLoaded_(function() {
|
|
536
|
-
goog.global['gapi']['client']['setToken'](tokenObject);
|
|
537
535
|
if (callback) {
|
|
538
536
|
callback();
|
|
539
537
|
}
|
|
@@ -560,7 +558,6 @@ apiclient.refreshAuthToken = function(success, error, onImmediateFailed) {
|
|
|
560
558
|
// Set up auth options.
|
|
561
559
|
const authArgs = {
|
|
562
560
|
'client_id': String(apiclient.authClientId_),
|
|
563
|
-
'immediate': true,
|
|
564
561
|
'scope': apiclient.authScopes_.join(' '),
|
|
565
562
|
'plugin_name': 'earthengine',
|
|
566
563
|
};
|
|
@@ -576,7 +573,6 @@ apiclient.refreshAuthToken = function(success, error, onImmediateFailed) {
|
|
|
576
573
|
// Refresh the library auth token and handle error propagation.
|
|
577
574
|
apiclient.ensureAuthLibLoaded_(function() {
|
|
578
575
|
try {
|
|
579
|
-
goog.global['gapi']['client']['setToken'](result);
|
|
580
576
|
apiclient.handleAuthResult_(success, error, result);
|
|
581
577
|
} catch (e) {
|
|
582
578
|
error(e.toString());
|
|
@@ -595,8 +591,8 @@ apiclient.refreshAuthToken = function(success, error, onImmediateFailed) {
|
|
|
595
591
|
|
|
596
592
|
/**
|
|
597
593
|
* Sets the current OAuth token refresher. By default, automatically set to
|
|
598
|
-
*
|
|
599
|
-
* token refreshing.
|
|
594
|
+
* Google Identity Services' callback triggered by `requestAccessToken()` after
|
|
595
|
+
* the auth library loads. Set to null to disable token refreshing.
|
|
600
596
|
*
|
|
601
597
|
* @param {?function(!apiclient.AuthArgs, function(!apiclient.AuthResponse))}
|
|
602
598
|
* refresher A function that takes as input 1) auth arguments and
|
|
@@ -1120,50 +1116,50 @@ apiclient.handleResponse_ = function(
|
|
|
1120
1116
|
|
|
1121
1117
|
|
|
1122
1118
|
/**
|
|
1123
|
-
* Ensures that the Google
|
|
1119
|
+
* Ensures that the Google Identity Services (GIS) libraries are loaded.
|
|
1124
1120
|
* @param {function()} callback The function to call when the library is ready.
|
|
1125
1121
|
* @private
|
|
1126
1122
|
*/
|
|
1127
1123
|
apiclient.ensureAuthLibLoaded_ = function(callback) {
|
|
1128
1124
|
const done = function() {
|
|
1129
|
-
// Speed up auth request by using CORS instead of an iframe.
|
|
1130
|
-
goog.global['gapi']['config']['update']('client/cors', true);
|
|
1131
1125
|
if (!apiclient.authTokenRefresher_) {
|
|
1132
|
-
apiclient.setAuthTokenRefresher(
|
|
1126
|
+
apiclient.setAuthTokenRefresher(function(authArgs, refresherCallback) {
|
|
1127
|
+
/** @type {!TokenClient} */
|
|
1128
|
+
const tokenClient =
|
|
1129
|
+
goog.global['google']['accounts']['oauth2']['initTokenClient']({
|
|
1130
|
+
'client_id': authArgs.client_id,
|
|
1131
|
+
'callback': refresherCallback,
|
|
1132
|
+
'scope': authArgs.scope,
|
|
1133
|
+
});
|
|
1134
|
+
tokenClient.requestAccessToken();
|
|
1135
|
+
});
|
|
1133
1136
|
}
|
|
1134
1137
|
callback();
|
|
1135
1138
|
};
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
typeof goog.global['gapi']['auth2']['authorize'] === 'function') {
|
|
1139
|
-
done();
|
|
1140
|
-
} else {
|
|
1141
|
-
// The library is not loaded; load it now.
|
|
1142
|
-
let callbackName = Date.now().toString(36);
|
|
1143
|
-
while (callbackName in goog.global) {
|
|
1144
|
-
callbackName += '_';
|
|
1145
|
-
}
|
|
1146
|
-
goog.global[callbackName] = function() {
|
|
1147
|
-
delete goog.global[callbackName];
|
|
1139
|
+
const loadGis = function() {
|
|
1140
|
+
if (goog.isObject(goog.global['default_gsi'])) {
|
|
1148
1141
|
done();
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1142
|
+
} else {
|
|
1143
|
+
jsloader
|
|
1144
|
+
.safeLoad(trustedResourceUrl`https://accounts.google.com/gsi/client`)
|
|
1145
|
+
.addCallback(done);
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
loadGis();
|
|
1154
1149
|
};
|
|
1155
1150
|
|
|
1156
1151
|
|
|
1157
1152
|
/**
|
|
1158
|
-
* Handles the result of
|
|
1159
|
-
*
|
|
1153
|
+
* Handles the result of an AuthResponse, storing the auth token on success and
|
|
1154
|
+
* setting up a refresh timeout.
|
|
1160
1155
|
*
|
|
1161
1156
|
* @param {function()|undefined} success The function to call if token refresh
|
|
1162
1157
|
* succeeds.
|
|
1163
1158
|
* @param {function(string)|undefined} error The function to call if auth fails,
|
|
1164
1159
|
* passing the error message.
|
|
1165
|
-
* @param {!apiclient.AuthResponse} result The result object produced by
|
|
1166
|
-
*
|
|
1160
|
+
* @param {!apiclient.AuthResponse} result The result object produced by a token
|
|
1161
|
+
* refresher such as Google Identity Services' callback triggered by
|
|
1162
|
+
* `requestAccessToken()`.
|
|
1167
1163
|
* @private
|
|
1168
1164
|
*/
|
|
1169
1165
|
apiclient.handleAuthResult_ = function(success, error, result) {
|
|
@@ -1547,13 +1543,6 @@ apiclient.CLOUD_PLATFORM_SCOPE_ =
|
|
|
1547
1543
|
apiclient.DEFAULT_AUTH_SCOPES_ =
|
|
1548
1544
|
[apiclient.AUTH_SCOPE_, apiclient.CLOUD_PLATFORM_SCOPE_];
|
|
1549
1545
|
|
|
1550
|
-
/**
|
|
1551
|
-
* The URL of the Google APIs Client Library.
|
|
1552
|
-
* @private @const {!GoogConst}
|
|
1553
|
-
*/
|
|
1554
|
-
apiclient.AUTH_LIBRARY_URL_ = GoogConst.from(
|
|
1555
|
-
'https://apis.google.com/js/client.js?onload=%{onload}');
|
|
1556
|
-
|
|
1557
1546
|
|
|
1558
1547
|
/**
|
|
1559
1548
|
* The OAuth scope for Cloud Storage.
|
|
@@ -1676,7 +1665,8 @@ apiclient.AuthArgs = class {
|
|
|
1676
1665
|
this.client_id;
|
|
1677
1666
|
|
|
1678
1667
|
/**
|
|
1679
|
-
* @
|
|
1668
|
+
* @deprecated Immediate field is unused.
|
|
1669
|
+
* @export {boolean|undefined}
|
|
1680
1670
|
*/
|
|
1681
1671
|
this.immediate;
|
|
1682
1672
|
|
|
@@ -1687,6 +1677,19 @@ apiclient.AuthArgs = class {
|
|
|
1687
1677
|
}
|
|
1688
1678
|
};
|
|
1689
1679
|
|
|
1680
|
+
/**
|
|
1681
|
+
* A token client to provide access tokens. For details, see
|
|
1682
|
+
* https://developers.google.com/identity/oauth2/web/reference/js-reference#TokenClient.
|
|
1683
|
+
* @record @struct
|
|
1684
|
+
*/
|
|
1685
|
+
class TokenClient {
|
|
1686
|
+
constructor() {
|
|
1687
|
+
/**
|
|
1688
|
+
* @export {function():void}
|
|
1689
|
+
*/
|
|
1690
|
+
this.requestAccessToken;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1690
1693
|
|
|
1691
1694
|
/**
|
|
1692
1695
|
* The result of a token refresh. Passed by the token refresher to the callback
|
package/src/data.js
CHANGED
|
@@ -195,13 +195,14 @@ ee.data.authenticate = function(
|
|
|
195
195
|
* @export
|
|
196
196
|
*/
|
|
197
197
|
ee.data.authenticateViaPopup = function(opt_success, opt_error) {
|
|
198
|
-
|
|
199
|
-
{
|
|
198
|
+
const tokenClient =
|
|
199
|
+
goog.global['google']['accounts']['oauth2']['initTokenClient']({
|
|
200
200
|
'client_id': ee.apiclient.getAuthClientId(),
|
|
201
|
-
'
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
'callback':
|
|
202
|
+
goog.partial(ee.apiclient.handleAuthResult, opt_success, opt_error),
|
|
203
|
+
'scope': ee.apiclient.getAuthScopes().join(' '),
|
|
204
|
+
});
|
|
205
|
+
tokenClient.requestAccessToken();
|
|
205
206
|
};
|
|
206
207
|
|
|
207
208
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// a custom visualization of topography.
|
|
3
3
|
|
|
4
4
|
// Load a global elevation image.
|
|
5
|
-
var elev = ee.Image('USGS/GMTED2010');
|
|
5
|
+
var elev = ee.Image('USGS/GMTED2010').select('be75');
|
|
6
6
|
|
|
7
7
|
// Zoom to an area of interest.
|
|
8
8
|
Map.setCenter(-121.069, 50.709, 6);
|
|
@@ -44,4 +44,3 @@ var v = shade.divide(255);
|
|
|
44
44
|
// Note the cast to byte in order to export the image correctly.
|
|
45
45
|
var rgb = hs.addBands(v).hsvToRgb().multiply(255).byte();
|
|
46
46
|
Map.addLayer(rgb, {}, 'styled');
|
|
47
|
-
|