firebase-tools 13.20.0 → 13.20.1
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/lib/apiv2.js
CHANGED
|
@@ -34,7 +34,9 @@ function setAccessToken(token = "") {
|
|
|
34
34
|
}
|
|
35
35
|
exports.setAccessToken = setAccessToken;
|
|
36
36
|
async function getAccessToken() {
|
|
37
|
-
|
|
37
|
+
const valid = auth.haveValidTokens(refreshToken, []);
|
|
38
|
+
const usingADC = !auth.loggedIn();
|
|
39
|
+
if (accessToken && (valid || usingADC)) {
|
|
38
40
|
return accessToken;
|
|
39
41
|
}
|
|
40
42
|
const data = await auth.getAccessToken(refreshToken, []);
|
|
@@ -295,6 +297,11 @@ class Client {
|
|
|
295
297
|
}
|
|
296
298
|
this.logResponse(res, body, options);
|
|
297
299
|
if (res.status >= 400) {
|
|
300
|
+
if (res.status === 401 && this.opts.auth) {
|
|
301
|
+
logger_1.logger.debug("Got a 401 Unauthenticated error for a call that required authentication. Refreshing tokens.");
|
|
302
|
+
setAccessToken();
|
|
303
|
+
setAccessToken(await getAccessToken());
|
|
304
|
+
}
|
|
298
305
|
if ((_a = options.retryCodes) === null || _a === void 0 ? void 0 : _a.includes(res.status)) {
|
|
299
306
|
const err = (0, responseToError_1.responseToError)({ statusCode: res.status }, body) || undefined;
|
|
300
307
|
if (operation.retry(err)) {
|
package/lib/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
|
|
3
|
+
exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.haveValidTokens = exports.loggedIn = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const FormData = require("form-data");
|
|
6
6
|
const http = require("http");
|
|
@@ -394,6 +394,10 @@ function findAccountByEmail(email) {
|
|
|
394
394
|
return getAllAccounts().find((a) => a.user.email === email);
|
|
395
395
|
}
|
|
396
396
|
exports.findAccountByEmail = findAccountByEmail;
|
|
397
|
+
function loggedIn() {
|
|
398
|
+
return !!lastAccessToken;
|
|
399
|
+
}
|
|
400
|
+
exports.loggedIn = loggedIn;
|
|
397
401
|
function haveValidTokens(refreshToken, authScopes) {
|
|
398
402
|
var _a;
|
|
399
403
|
if (!(lastAccessToken === null || lastAccessToken === void 0 ? void 0 : lastAccessToken.access_token)) {
|
|
@@ -407,8 +411,16 @@ function haveValidTokens(refreshToken, authScopes) {
|
|
|
407
411
|
const newScopesJSON = JSON.stringify(authScopes.sort());
|
|
408
412
|
const hasSameScopes = oldScopesJSON === newScopesJSON;
|
|
409
413
|
const isExpired = ((lastAccessToken === null || lastAccessToken === void 0 ? void 0 : lastAccessToken.expires_at) || 0) < Date.now() + FIFTEEN_MINUTES_IN_MS;
|
|
410
|
-
|
|
414
|
+
const valid = hasTokens && hasSameScopes && !isExpired;
|
|
415
|
+
if (hasTokens) {
|
|
416
|
+
logger_1.logger.debug(`Checked if tokens are valid: ${valid}, expires at: ${lastAccessToken === null || lastAccessToken === void 0 ? void 0 : lastAccessToken.expires_at}`);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
logger_1.logger.debug("No OAuth tokens found");
|
|
420
|
+
}
|
|
421
|
+
return valid;
|
|
411
422
|
}
|
|
423
|
+
exports.haveValidTokens = haveValidTokens;
|
|
412
424
|
function deleteAccount(account) {
|
|
413
425
|
const defaultAccount = getGlobalDefaultAccount();
|
|
414
426
|
if (account.user.email === (defaultAccount === null || defaultAccount === void 0 ? void 0 : defaultAccount.user.email)) {
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeGraphQL = void 0;
|
|
3
|
+
exports.executeGraphQL = exports.dataconnectDataplaneClient = exports.DATACONNECT_API_VERSION = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
exports.DATACONNECT_API_VERSION = "v1beta";
|
|
7
|
+
function dataconnectDataplaneClient() {
|
|
8
|
+
return new apiv2_1.Client({
|
|
9
|
+
urlPrefix: (0, api_1.dataconnectOrigin)(),
|
|
10
|
+
apiVersion: exports.DATACONNECT_API_VERSION,
|
|
11
|
+
auth: true,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.dataconnectDataplaneClient = dataconnectDataplaneClient;
|
|
15
|
+
async function executeGraphQL(client, servicePath, body) {
|
|
16
|
+
const res = await client.post(`${servicePath}:executeGraphql`, body, { resolveOnHTTPError: true });
|
|
14
17
|
return res;
|
|
15
18
|
}
|
|
16
19
|
exports.executeGraphQL = executeGraphQL;
|
|
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
48
48
|
},
|
|
49
49
|
dataconnect: process.platform === "darwin"
|
|
50
50
|
? {
|
|
51
|
-
version: "1.4.
|
|
51
|
+
version: "1.4.3",
|
|
52
52
|
expectedSize: 25125632,
|
|
53
|
-
expectedChecksum: "
|
|
53
|
+
expectedChecksum: "1edc7180b101b1b3653429ecb8312d2d",
|
|
54
54
|
}
|
|
55
55
|
: process.platform === "win32"
|
|
56
56
|
? {
|
|
57
|
-
version: "1.4.
|
|
57
|
+
version: "1.4.3",
|
|
58
58
|
expectedSize: 25548800,
|
|
59
|
-
expectedChecksum: "
|
|
59
|
+
expectedChecksum: "16b31831577778e8842c8715f35b4faa",
|
|
60
60
|
}
|
|
61
61
|
: {
|
|
62
|
-
version: "1.4.
|
|
62
|
+
version: "1.4.3",
|
|
63
63
|
expectedSize: 25034904,
|
|
64
|
-
expectedChecksum: "
|
|
64
|
+
expectedChecksum: "c959f7bd2ed3221c509cb7ad22956de3",
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
exports.DownloadDetails = {
|