mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/RoboCommander.git
synced 2026-06-15 20:16:00 +00:00
Initial commit
This commit is contained in:
47
node_modules/google-auth-library/build/src/auth/authclient.js
generated
vendored
Normal file
47
node_modules/google-auth-library/build/src/auth/authclient.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2012 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var events_1 = require("events");
|
||||
var transporters_1 = require("../transporters");
|
||||
var AuthClient = /** @class */ (function (_super) {
|
||||
__extends(AuthClient, _super);
|
||||
function AuthClient() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.transporter = new transporters_1.DefaultTransporter();
|
||||
_this.credentials = {};
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Sets the auth credentials.
|
||||
*/
|
||||
AuthClient.prototype.setCredentials = function (credentials) {
|
||||
this.credentials = credentials;
|
||||
};
|
||||
return AuthClient;
|
||||
}(events_1.EventEmitter));
|
||||
exports.AuthClient = AuthClient;
|
||||
//# sourceMappingURL=authclient.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/authclient.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/authclient.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"authclient.js","sourceRoot":"","sources":["../../../src/auth/authclient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAGH,iCAAoC;AAEpC,gDAAmD;AAQnD;IAAyC,8BAAY;IAArD;QAAA,qEAeC;QAdC,iBAAW,GAAG,IAAI,iCAAkB,EAAE,CAAC;QACvC,iBAAW,GAAgB,EAAE,CAAC;;IAahC,CAAC;IANC;;OAEG;IACH,mCAAc,GAAd,UAAe,WAAwB;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IACH,iBAAC;AAAD,CAAC,AAfD,CAAyC,qBAAY,GAepD;AAfqB,gCAAU"}
|
||||
187
node_modules/google-auth-library/build/src/auth/computeclient.js
generated
vendored
Normal file
187
node_modules/google-auth-library/build/src/auth/computeclient.js
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2013 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var axios_1 = __importDefault(require("axios"));
|
||||
var gcpMetadata = __importStar(require("gcp-metadata"));
|
||||
var rax = __importStar(require("retry-axios"));
|
||||
var oauth2client_1 = require("./oauth2client");
|
||||
// Create a scoped axios instance that will retry 3 times by default
|
||||
var ax = axios_1.default.create();
|
||||
rax.attach(ax);
|
||||
var Compute = /** @class */ (function (_super) {
|
||||
__extends(Compute, _super);
|
||||
/**
|
||||
* Google Compute Engine service account credentials.
|
||||
*
|
||||
* Retrieve access token from the metadata server.
|
||||
* See: https://developers.google.com/compute/docs/authentication
|
||||
*/
|
||||
function Compute(options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
var _this = _super.call(this, options) || this;
|
||||
// Start with an expired refresh token, which will automatically be
|
||||
// refreshed before the first API call is made.
|
||||
_this.credentials = { expiry_date: 1, refresh_token: 'compute-placeholder' };
|
||||
_this.serviceAccountEmail = options.serviceAccountEmail || 'default';
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createdScoped before use.
|
||||
* @return Boolean indicating if scope is required.
|
||||
*/
|
||||
Compute.prototype.createScopedRequired = function () {
|
||||
// On compute engine, scopes are specified at the compute instance's
|
||||
// creation time, and cannot be changed. For this reason, always return
|
||||
// false.
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refreshToken Unused parameter
|
||||
*/
|
||||
Compute.prototype.refreshTokenNoCache = function (refreshToken) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, url, res, e_1, tokens;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
url = this.tokenUrl ||
|
||||
"" + gcpMetadata.HOST_ADDRESS + gcpMetadata.BASE_PATH + "/instance/service-accounts/" + this.serviceAccountEmail + "/token";
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, ax.request({
|
||||
url: url,
|
||||
headers: (_a = {}, _a[gcpMetadata.HEADER_NAME] = 'Google', _a),
|
||||
raxConfig: { noResponseRetries: 3, retry: 3, instance: ax }
|
||||
})];
|
||||
case 2:
|
||||
// TODO: In 2.0, we should remove the ability to configure the tokenUrl,
|
||||
// and switch this over to use the gcp-metadata package instead.
|
||||
res = _b.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
e_1 = _b.sent();
|
||||
e_1.message = 'Could not refresh access token.';
|
||||
throw e_1;
|
||||
case 4:
|
||||
tokens = res.data;
|
||||
if (res.data && res.data.expires_in) {
|
||||
tokens.expiry_date =
|
||||
((new Date()).getTime() + (res.data.expires_in * 1000));
|
||||
delete tokens.expires_in;
|
||||
}
|
||||
this.emit('tokens', tokens);
|
||||
return [2 /*return*/, { tokens: tokens, res: res }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Compute.prototype.requestAsync = function (opts, retry) {
|
||||
if (retry === void 0) { retry = false; }
|
||||
return _super.prototype.requestAsync.call(this, opts, retry).catch(function (e) {
|
||||
var res = e.response;
|
||||
if (res && res.status) {
|
||||
var helpfulMessage = null;
|
||||
if (res.status === 403) {
|
||||
helpfulMessage =
|
||||
'A Forbidden error was returned while attempting to retrieve an access ' +
|
||||
'token for the Compute Engine built-in service account. This may be because the Compute ' +
|
||||
'Engine instance does not have the correct permission scopes specified.';
|
||||
}
|
||||
else if (res.status === 404) {
|
||||
helpfulMessage =
|
||||
'A Not Found error was returned while attempting to retrieve an access' +
|
||||
'token for the Compute Engine built-in service account. This may be because the Compute ' +
|
||||
'Engine instance does not have any permission scopes specified.';
|
||||
}
|
||||
if (helpfulMessage) {
|
||||
if (e && e.message && !retry) {
|
||||
helpfulMessage += ' ' + e.message;
|
||||
}
|
||||
if (e) {
|
||||
e.message = helpfulMessage;
|
||||
}
|
||||
else {
|
||||
e = new Error(helpfulMessage);
|
||||
e.code = res.status.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
});
|
||||
};
|
||||
return Compute;
|
||||
}(oauth2client_1.OAuth2Client));
|
||||
exports.Compute = Compute;
|
||||
//# sourceMappingURL=computeclient.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/computeclient.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/computeclient.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"computeclient.js","sourceRoot":"","sources":["../../../src/auth/computeclient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAyF;AACzF,wDAA4C;AAC5C,+CAAmC;AAEnC,+CAA8E;AAU9E,oEAAoE;AACpE,IAAM,EAAE,GAAG,eAAK,CAAC,MAAM,EAAE,CAAC;AAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEf;IAA6B,2BAAY;IAGvC;;;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,2BAAY,GAgGxC;AAhGY,0BAAO"}
|
||||
18
node_modules/google-auth-library/build/src/auth/credentials.js
generated
vendored
Normal file
18
node_modules/google-auth-library/build/src/auth/credentials.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2014 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=credentials.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/credentials.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/credentials.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/auth/credentials.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
||||
139
node_modules/google-auth-library/build/src/auth/envDetect.js
generated
vendored
Normal file
139
node_modules/google-auth-library/build/src/auth/envDetect.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2018 Google LLC. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var gcpMetadata = __importStar(require("gcp-metadata"));
|
||||
var GCPEnv;
|
||||
(function (GCPEnv) {
|
||||
GCPEnv["APP_ENGINE"] = "APP_ENGINE";
|
||||
GCPEnv["KUBERNETES_ENGINE"] = "KUBERNETES_ENGINE";
|
||||
GCPEnv["CLOUD_FUNCTIONS"] = "CLOUD_FUNCTIONS";
|
||||
GCPEnv["COMPUTE_ENGINE"] = "COMPUTE_ENGINE";
|
||||
GCPEnv["NONE"] = "NONE";
|
||||
})(GCPEnv = exports.GCPEnv || (exports.GCPEnv = {}));
|
||||
var env;
|
||||
function clear() {
|
||||
env = undefined;
|
||||
}
|
||||
exports.clear = clear;
|
||||
function getEnv() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!!env) return [3 /*break*/, 6];
|
||||
if (!isAppEngine()) return [3 /*break*/, 1];
|
||||
env = GCPEnv.APP_ENGINE;
|
||||
return [3 /*break*/, 6];
|
||||
case 1:
|
||||
if (!isCloudFunction()) return [3 /*break*/, 2];
|
||||
env = GCPEnv.CLOUD_FUNCTIONS;
|
||||
return [3 /*break*/, 6];
|
||||
case 2: return [4 /*yield*/, isKubernetesEngine()];
|
||||
case 3:
|
||||
if (!_a.sent()) return [3 /*break*/, 4];
|
||||
env = GCPEnv.KUBERNETES_ENGINE;
|
||||
return [3 /*break*/, 6];
|
||||
case 4: return [4 /*yield*/, isComputeEngine()];
|
||||
case 5:
|
||||
if (_a.sent()) {
|
||||
env = GCPEnv.COMPUTE_ENGINE;
|
||||
}
|
||||
else {
|
||||
env = GCPEnv.NONE;
|
||||
}
|
||||
_a.label = 6;
|
||||
case 6: return [2 /*return*/, env];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.getEnv = getEnv;
|
||||
function isAppEngine() {
|
||||
return !!(process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME);
|
||||
}
|
||||
function isCloudFunction() {
|
||||
return !!process.env.FUNCTION_NAME;
|
||||
}
|
||||
function isKubernetesEngine() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var e_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, gcpMetadata.instance('attributes/cluster-name')];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, true];
|
||||
case 2:
|
||||
e_1 = _a.sent();
|
||||
return [2 /*return*/, false];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function isComputeEngine() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, gcpMetadata.isAvailable()];
|
||||
});
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=envDetect.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/envDetect.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/envDetect.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"envDetect.js","sourceRoot":"","sources":["../../../src/auth/envDetect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC;;;CAClC"}
|
||||
815
node_modules/google-auth-library/build/src/auth/googleauth.js
generated
vendored
Normal file
815
node_modules/google-auth-library/build/src/auth/googleauth.js
generated
vendored
Normal file
@@ -0,0 +1,815 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2014 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var child_process_1 = require("child_process");
|
||||
var crypto_1 = __importDefault(require("crypto"));
|
||||
var fs = __importStar(require("fs"));
|
||||
var gcpMetadata = __importStar(require("gcp-metadata"));
|
||||
var os_1 = __importDefault(require("os"));
|
||||
var path_1 = __importDefault(require("path"));
|
||||
var util_1 = __importDefault(require("util"));
|
||||
var transporters_1 = require("../transporters");
|
||||
var computeclient_1 = require("./computeclient");
|
||||
var envDetect_1 = require("./envDetect");
|
||||
var jwtclient_1 = require("./jwtclient");
|
||||
var refreshclient_1 = require("./refreshclient");
|
||||
var GoogleAuth = /** @class */ (function () {
|
||||
function GoogleAuth(opts) {
|
||||
// This shim is in place for compatibility with google-auto-auth.
|
||||
this.getProjectId = this.getDefaultProjectId;
|
||||
/**
|
||||
* Caches a value indicating whether the auth layer is running on Google
|
||||
* Compute Engine.
|
||||
* @private
|
||||
*/
|
||||
this.checkIsGCE = undefined;
|
||||
// To save the contents of the JSON credential file
|
||||
this.jsonContent = null;
|
||||
this.cachedCredential = null;
|
||||
opts = opts || {};
|
||||
this._cachedProjectId = opts.projectId || null;
|
||||
this.keyFilename = opts.keyFilename || opts.keyFile;
|
||||
this.scopes = opts.scopes;
|
||||
this.jsonContent = opts.credentials || null;
|
||||
}
|
||||
Object.defineProperty(GoogleAuth.prototype, "isGCE", {
|
||||
// Note: this properly is only public to satisify unit tests.
|
||||
// https://github.com/Microsoft/TypeScript/issues/5228
|
||||
get: function () {
|
||||
return this.checkIsGCE;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
GoogleAuth.prototype.getDefaultProjectId = function (callback) {
|
||||
if (callback) {
|
||||
this.getDefaultProjectIdAsync()
|
||||
.then(function (r) { return callback(null, r); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.getDefaultProjectIdAsync();
|
||||
}
|
||||
};
|
||||
GoogleAuth.prototype.getDefaultProjectIdAsync = function () {
|
||||
var _this = this;
|
||||
if (this._cachedProjectId) {
|
||||
return Promise.resolve(this._cachedProjectId);
|
||||
}
|
||||
// In implicit case, supports three environments. In order of precedence,
|
||||
// the implicit environments are:
|
||||
// - GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variable
|
||||
// - GOOGLE_APPLICATION_CREDENTIALS JSON file
|
||||
// - Cloud SDK: `gcloud config config-helper --format json`
|
||||
// - GCE project ID from metadata server)
|
||||
if (!this._getDefaultProjectIdPromise) {
|
||||
this._getDefaultProjectIdPromise =
|
||||
new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var projectId, _a, _b, _c, e_1;
|
||||
return __generator(this, function (_d) {
|
||||
switch (_d.label) {
|
||||
case 0:
|
||||
_d.trys.push([0, 7, , 8]);
|
||||
_c = this.getProductionProjectId();
|
||||
if (_c) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, this.getFileProjectId()];
|
||||
case 1:
|
||||
_c = (_d.sent());
|
||||
_d.label = 2;
|
||||
case 2:
|
||||
_b = _c;
|
||||
if (_b) return [3 /*break*/, 4];
|
||||
return [4 /*yield*/, this.getDefaultServiceProjectId()];
|
||||
case 3:
|
||||
_b = (_d.sent());
|
||||
_d.label = 4;
|
||||
case 4:
|
||||
_a = _b;
|
||||
if (_a) return [3 /*break*/, 6];
|
||||
return [4 /*yield*/, this.getGCEProjectId()];
|
||||
case 5:
|
||||
_a = (_d.sent());
|
||||
_d.label = 6;
|
||||
case 6:
|
||||
projectId = _a;
|
||||
this._cachedProjectId = projectId;
|
||||
resolve(projectId);
|
||||
return [3 /*break*/, 8];
|
||||
case 7:
|
||||
e_1 = _d.sent();
|
||||
reject(e_1);
|
||||
return [3 /*break*/, 8];
|
||||
case 8: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
}
|
||||
return this._getDefaultProjectIdPromise;
|
||||
};
|
||||
GoogleAuth.prototype.getApplicationDefault = function (optionsOrCallback, callback) {
|
||||
if (optionsOrCallback === void 0) { optionsOrCallback = {}; }
|
||||
var options;
|
||||
if (typeof optionsOrCallback === 'function') {
|
||||
callback = optionsOrCallback;
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
if (callback) {
|
||||
this.getApplicationDefaultAsync(options)
|
||||
.then(function (r) { return callback(null, r.credential, r.projectId); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.getApplicationDefaultAsync(options);
|
||||
}
|
||||
};
|
||||
GoogleAuth.prototype.getApplicationDefaultAsync = function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, credential, projectId, gce, e_2;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (!this.cachedCredential) return [3 /*break*/, 2];
|
||||
_a = {
|
||||
credential: this.cachedCredential
|
||||
};
|
||||
return [4 /*yield*/, this.getDefaultProjectIdAsync()];
|
||||
case 1: return [2 /*return*/, (_a.projectId = _b.sent(),
|
||||
_a)];
|
||||
case 2: return [4 /*yield*/, this._tryGetApplicationCredentialsFromEnvironmentVariable(options)];
|
||||
case 3:
|
||||
// Check for the existence of a local environment variable pointing to the
|
||||
// location of the credential file. This is typically used in local
|
||||
// developer scenarios.
|
||||
credential =
|
||||
_b.sent();
|
||||
if (!credential) return [3 /*break*/, 5];
|
||||
if (credential instanceof jwtclient_1.JWT) {
|
||||
credential.scopes = this.scopes;
|
||||
}
|
||||
this.cachedCredential = credential;
|
||||
return [4 /*yield*/, this.getDefaultProjectId()];
|
||||
case 4:
|
||||
projectId = _b.sent();
|
||||
return [2 /*return*/, { credential: credential, projectId: projectId }];
|
||||
case 5: return [4 /*yield*/, this._tryGetApplicationCredentialsFromWellKnownFile(options)];
|
||||
case 6:
|
||||
// Look in the well-known credential file location.
|
||||
credential =
|
||||
_b.sent();
|
||||
if (!credential) return [3 /*break*/, 8];
|
||||
if (credential instanceof jwtclient_1.JWT) {
|
||||
credential.scopes = this.scopes;
|
||||
}
|
||||
this.cachedCredential = credential;
|
||||
return [4 /*yield*/, this.getDefaultProjectId()];
|
||||
case 7:
|
||||
projectId = _b.sent();
|
||||
return [2 /*return*/, { credential: credential, projectId: projectId }];
|
||||
case 8:
|
||||
_b.trys.push([8, 13, , 14]);
|
||||
return [4 /*yield*/, this._checkIsGCE()];
|
||||
case 9:
|
||||
gce = _b.sent();
|
||||
if (!gce) return [3 /*break*/, 11];
|
||||
// For GCE, just return a default ComputeClient. It will take care of
|
||||
// the rest.
|
||||
this.cachedCredential = new computeclient_1.Compute(options);
|
||||
return [4 /*yield*/, this.getDefaultProjectId()];
|
||||
case 10:
|
||||
projectId = _b.sent();
|
||||
return [2 /*return*/, { projectId: projectId, credential: this.cachedCredential }];
|
||||
case 11:
|
||||
// We failed to find the default credentials. Bail out with an error.
|
||||
throw new Error('Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.');
|
||||
case 12: return [3 /*break*/, 14];
|
||||
case 13:
|
||||
e_2 = _b.sent();
|
||||
throw new Error('Unexpected error while acquiring application default credentials: ' +
|
||||
e_2.message);
|
||||
case 14: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Determines whether the auth layer is running on Google Compute Engine.
|
||||
* @returns A promise that resolves with the boolean.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._checkIsGCE = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (!(this.checkIsGCE === undefined)) return [3 /*break*/, 2];
|
||||
_a = this;
|
||||
return [4 /*yield*/, gcpMetadata.isAvailable()];
|
||||
case 1:
|
||||
_a.checkIsGCE = _b.sent();
|
||||
_b.label = 2;
|
||||
case 2: return [2 /*return*/, this.checkIsGCE];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Attempts to load default credentials from the environment variable path..
|
||||
* @returns Promise that resolves with the OAuth2Client or null.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._tryGetApplicationCredentialsFromEnvironmentVariable = function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var credentialsPath;
|
||||
return __generator(this, function (_a) {
|
||||
credentialsPath = process.env['GOOGLE_APPLICATION_CREDENTIALS'];
|
||||
if (!credentialsPath || credentialsPath.length === 0) {
|
||||
return [2 /*return*/, null];
|
||||
}
|
||||
try {
|
||||
return [2 /*return*/, this._getApplicationCredentialsFromFilePath(credentialsPath, options)];
|
||||
}
|
||||
catch (e) {
|
||||
throw this.createError('Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.', e);
|
||||
}
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Attempts to load default credentials from a well-known file location
|
||||
* @return Promise that resolves with the OAuth2Client or null.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._tryGetApplicationCredentialsFromWellKnownFile = function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var location, home;
|
||||
return __generator(this, function (_a) {
|
||||
location = null;
|
||||
if (this._isWindows()) {
|
||||
// Windows
|
||||
location = process.env['APPDATA'];
|
||||
}
|
||||
else {
|
||||
home = process.env['HOME'];
|
||||
if (home) {
|
||||
location = this._pathJoin(home, '.config');
|
||||
}
|
||||
}
|
||||
// If we found the root path, expand it.
|
||||
if (location) {
|
||||
location = this._pathJoin(location, 'gcloud');
|
||||
location =
|
||||
this._pathJoin(location, 'application_default_credentials.json');
|
||||
location = this._mockWellKnownFilePath(location);
|
||||
// Check whether the file exists.
|
||||
if (!this._fileExists(location)) {
|
||||
location = null;
|
||||
}
|
||||
}
|
||||
// The file does not exist.
|
||||
if (!location) {
|
||||
return [2 /*return*/, null];
|
||||
}
|
||||
// The file seems to exist. Try to use it.
|
||||
return [2 /*return*/, this._getApplicationCredentialsFromFilePath(location, options)];
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Attempts to load default credentials from a file at the given path..
|
||||
* @param filePath The path to the file to read.
|
||||
* @returns Promise that resolves with the OAuth2Client
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._getApplicationCredentialsFromFilePath = function (filePath, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var readStream;
|
||||
return __generator(this, function (_a) {
|
||||
// Make sure the path looks like a string.
|
||||
if (!filePath || filePath.length === 0) {
|
||||
throw new Error('The file path is invalid.');
|
||||
}
|
||||
// Make sure there is a file at the path. lstatSync will throw if there is
|
||||
// nothing there.
|
||||
try {
|
||||
// Resolve path to actual file in case of symlink. Expect a thrown error
|
||||
// if not resolvable.
|
||||
filePath = fs.realpathSync(filePath);
|
||||
if (!fs.lstatSync(filePath).isFile()) {
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
throw this.createError(util_1.default.format('The file at %s does not exist, or it is not a file.', filePath), err);
|
||||
}
|
||||
// Now open a read stream on the file, and parse it.
|
||||
try {
|
||||
readStream = this._createReadStream(filePath);
|
||||
return [2 /*return*/, this.fromStream(readStream, options)];
|
||||
}
|
||||
catch (err) {
|
||||
throw this.createError(util_1.default.format('Unable to read the file at %s.', filePath), err);
|
||||
}
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Create a credentials instance using the given input options.
|
||||
* @param json The input object.
|
||||
* @returns JWT or UserRefresh Client with data
|
||||
*/
|
||||
GoogleAuth.prototype.fromJSON = function (json, options) {
|
||||
var client;
|
||||
if (!json) {
|
||||
throw new Error('Must pass in a JSON object containing the Google auth settings.');
|
||||
}
|
||||
this.jsonContent = json;
|
||||
options = options || {};
|
||||
if (json.type === 'authorized_user') {
|
||||
client = new refreshclient_1.UserRefreshClient(options);
|
||||
}
|
||||
else {
|
||||
options.scopes = this.scopes;
|
||||
client = new jwtclient_1.JWT(options);
|
||||
}
|
||||
client.fromJSON(json);
|
||||
return client;
|
||||
};
|
||||
GoogleAuth.prototype.fromStream = function (inputStream, optionsOrCallback, callback) {
|
||||
if (optionsOrCallback === void 0) { optionsOrCallback = {}; }
|
||||
var options = {};
|
||||
if (typeof optionsOrCallback === 'function') {
|
||||
callback = optionsOrCallback;
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
if (callback) {
|
||||
this.fromStreamAsync(inputStream, options)
|
||||
.then(function (r) { return callback(null, r); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.fromStreamAsync(inputStream, options);
|
||||
}
|
||||
};
|
||||
GoogleAuth.prototype.fromStreamAsync = function (inputStream, options) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!inputStream) {
|
||||
throw new Error('Must pass in a stream containing the Google auth settings.');
|
||||
}
|
||||
var s = '';
|
||||
inputStream.setEncoding('utf8');
|
||||
inputStream.on('data', function (chunk) {
|
||||
s += chunk;
|
||||
});
|
||||
inputStream.on('end', function () {
|
||||
try {
|
||||
var data = JSON.parse(s);
|
||||
var r = _this.fromJSON(data, options);
|
||||
return resolve(r);
|
||||
}
|
||||
catch (err) {
|
||||
return reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Create a credentials instance using the given API key string.
|
||||
* @param apiKey The API key string
|
||||
* @param options An optional options object.
|
||||
* @returns A JWT loaded from the key
|
||||
*/
|
||||
GoogleAuth.prototype.fromAPIKey = function (apiKey, options) {
|
||||
options = options || {};
|
||||
var client = new jwtclient_1.JWT(options);
|
||||
client.fromAPIKey(apiKey);
|
||||
return client;
|
||||
};
|
||||
/**
|
||||
* Determines whether the current operating system is Windows.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._isWindows = function () {
|
||||
var sys = this._osPlatform();
|
||||
if (sys && sys.length >= 3) {
|
||||
if (sys.substring(0, 3).toLowerCase() === 'win') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Creates a file stream. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._createReadStream = function (filePath) {
|
||||
return fs.createReadStream(filePath);
|
||||
};
|
||||
/**
|
||||
* Gets the current operating system platform. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._osPlatform = function () {
|
||||
return os_1.default.platform();
|
||||
};
|
||||
/**
|
||||
* Determines whether a file exists. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._fileExists = function (filePath) {
|
||||
return fs.existsSync(filePath);
|
||||
};
|
||||
/**
|
||||
* Joins two parts of a path. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._pathJoin = function (item1, item2) {
|
||||
return path_1.default.join(item1, item2);
|
||||
};
|
||||
/**
|
||||
* Allows mocking of the path to a well-known file.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype._mockWellKnownFilePath = function (filePath) {
|
||||
return filePath;
|
||||
};
|
||||
// Creates an Error containing the given message, and includes the message
|
||||
// from the optional err passed in.
|
||||
GoogleAuth.prototype.createError = function (message, err) {
|
||||
var s = message || '';
|
||||
if (err) {
|
||||
var errorMessage = String(err);
|
||||
if (errorMessage && errorMessage.length > 0) {
|
||||
if (s.length > 0) {
|
||||
s += ' ';
|
||||
}
|
||||
s += errorMessage;
|
||||
}
|
||||
}
|
||||
return Error(s);
|
||||
};
|
||||
/**
|
||||
* Run the Google Cloud SDK command that prints the default project ID
|
||||
*/
|
||||
GoogleAuth.prototype.getDefaultServiceProjectId = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, new Promise(function (resolve) {
|
||||
child_process_1.exec('gcloud config config-helper --format json', function (err, stdout, stderr) {
|
||||
if (!err && stdout) {
|
||||
try {
|
||||
var projectId = JSON.parse(stdout).configuration.properties.core.project;
|
||||
resolve(projectId);
|
||||
return;
|
||||
}
|
||||
catch (e) {
|
||||
// ignore errors
|
||||
}
|
||||
}
|
||||
resolve(null);
|
||||
});
|
||||
})];
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Loads the project id from environment variables.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype.getProductionProjectId = function () {
|
||||
return process.env['GCLOUD_PROJECT'] || process.env['GOOGLE_CLOUD_PROJECT'];
|
||||
};
|
||||
/**
|
||||
* Loads the project id from the GOOGLE_APPLICATION_CREDENTIALS json file.
|
||||
* @api private
|
||||
*/
|
||||
GoogleAuth.prototype.getFileProjectId = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var r;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (this.cachedCredential) {
|
||||
// Try to read the project ID from the cached credentials file
|
||||
return [2 /*return*/, this.cachedCredential.projectId];
|
||||
}
|
||||
return [4 /*yield*/, this._tryGetApplicationCredentialsFromEnvironmentVariable()];
|
||||
case 1:
|
||||
r = _a.sent();
|
||||
if (r) {
|
||||
return [2 /*return*/, r.projectId];
|
||||
}
|
||||
else {
|
||||
return [2 /*return*/, null];
|
||||
}
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Gets the Compute Engine project ID if it can be inferred.
|
||||
*/
|
||||
GoogleAuth.prototype.getGCEProjectId = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var r, e_3;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, gcpMetadata.project('project-id')];
|
||||
case 1:
|
||||
r = _a.sent();
|
||||
return [2 /*return*/, r.data];
|
||||
case 2:
|
||||
e_3 = _a.sent();
|
||||
// Ignore any errors
|
||||
return [2 /*return*/, null];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
GoogleAuth.prototype.getCredentials = function (callback) {
|
||||
if (callback) {
|
||||
this.getCredentialsAsync().then(function (r) { return callback(null, r); }).catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.getCredentialsAsync();
|
||||
}
|
||||
};
|
||||
GoogleAuth.prototype.getCredentialsAsync = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var credential, isGCE, data;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (this.jsonContent) {
|
||||
credential = {
|
||||
client_email: this.jsonContent.client_email,
|
||||
private_key: this.jsonContent.private_key
|
||||
};
|
||||
return [2 /*return*/, credential];
|
||||
}
|
||||
return [4 /*yield*/, this._checkIsGCE()];
|
||||
case 1:
|
||||
isGCE = _a.sent();
|
||||
if (!isGCE) {
|
||||
throw new Error('Unknown error.');
|
||||
}
|
||||
return [4 /*yield*/, gcpMetadata.instance({ property: 'service-accounts/', params: { recursive: true } })];
|
||||
case 2:
|
||||
data = (_a.sent()).data;
|
||||
if (!data || !data.default || !data.default.email) {
|
||||
throw new Error('Failure from metadata server.');
|
||||
}
|
||||
return [2 /*return*/, { client_email: data.default.email }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Automatically obtain a client based on the provided configuration. If no
|
||||
* options were passed, use Application Default Credentials.
|
||||
*/
|
||||
GoogleAuth.prototype.getClient = function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, filePath, stream_1, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
if (options) {
|
||||
this.keyFilename =
|
||||
options.keyFilename || options.keyFile || this.keyFilename;
|
||||
this.scopes = options.scopes || this.scopes;
|
||||
this.jsonContent = options.credentials || this.jsonContent;
|
||||
}
|
||||
if (!!this.cachedCredential) return [3 /*break*/, 6];
|
||||
if (!this.jsonContent) return [3 /*break*/, 2];
|
||||
_a = this;
|
||||
return [4 /*yield*/, this.fromJSON(this.jsonContent)];
|
||||
case 1:
|
||||
_a.cachedCredential = _c.sent();
|
||||
return [3 /*break*/, 6];
|
||||
case 2:
|
||||
if (!this.keyFilename) return [3 /*break*/, 4];
|
||||
filePath = path_1.default.resolve(this.keyFilename);
|
||||
stream_1 = fs.createReadStream(filePath);
|
||||
_b = this;
|
||||
return [4 /*yield*/, this.fromStreamAsync(stream_1)];
|
||||
case 3:
|
||||
_b.cachedCredential = _c.sent();
|
||||
return [3 /*break*/, 6];
|
||||
case 4: return [4 /*yield*/, this.getApplicationDefaultAsync()];
|
||||
case 5:
|
||||
_c.sent();
|
||||
_c.label = 6;
|
||||
case 6: return [2 /*return*/, this.cachedCredential];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Automatically obtain application default credentials, and return
|
||||
* an access token for making requests.
|
||||
*/
|
||||
GoogleAuth.prototype.getAccessToken = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var client;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.getClient()];
|
||||
case 1:
|
||||
client = _a.sent();
|
||||
return [4 /*yield*/, client.getAccessToken()];
|
||||
case 2: return [2 /*return*/, (_a.sent()).token];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Obtain the HTTP headers that will provide authorization for a given
|
||||
* request.
|
||||
*/
|
||||
GoogleAuth.prototype.getRequestHeaders = function (url) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var client;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.getClient()];
|
||||
case 1:
|
||||
client = _a.sent();
|
||||
return [4 /*yield*/, client.getRequestMetadata(url)];
|
||||
case 2: return [2 /*return*/, (_a.sent()).headers];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Obtain credentials for a request, then attach the appropriate headers to
|
||||
* the request options.
|
||||
* @param opts Axios or Request options on which to attach the headers
|
||||
*/
|
||||
GoogleAuth.prototype.authorizeRequest = function (opts) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, client, headers;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
opts = opts || {};
|
||||
url = opts.url || opts.uri;
|
||||
return [4 /*yield*/, this.getClient()];
|
||||
case 1:
|
||||
client = _a.sent();
|
||||
return [4 /*yield*/, client.getRequestMetadata(url)];
|
||||
case 2:
|
||||
headers = (_a.sent()).headers;
|
||||
opts.headers = Object.assign(opts.headers || {}, headers);
|
||||
return [2 /*return*/, opts];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Automatically obtain application default credentials, and make an
|
||||
* HTTP request using the given options.
|
||||
* @param opts Axios request options for the HTTP request.
|
||||
*/
|
||||
// tslint:disable-next-line no-any
|
||||
GoogleAuth.prototype.request = function (opts) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var client;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.getClient()];
|
||||
case 1:
|
||||
client = _a.sent();
|
||||
return [2 /*return*/, client.request(opts)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Determine the compute environment in which the code is running.
|
||||
*/
|
||||
GoogleAuth.prototype.getEnv = function () {
|
||||
return envDetect_1.getEnv();
|
||||
};
|
||||
/**
|
||||
* Sign the given data with the current private key, or go out
|
||||
* to the IAM API to sign it.
|
||||
* @param data The data to be signed.
|
||||
*/
|
||||
GoogleAuth.prototype.sign = function (data) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var client, sign, projectId, creds, id, res;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.getClient()];
|
||||
case 1:
|
||||
client = _a.sent();
|
||||
if (client instanceof jwtclient_1.JWT && client.key) {
|
||||
sign = crypto_1.default.createSign('RSA-SHA256');
|
||||
sign.update(data);
|
||||
return [2 /*return*/, sign.sign(client.key, 'base64')];
|
||||
}
|
||||
return [4 /*yield*/, this.getProjectId()];
|
||||
case 2:
|
||||
projectId = _a.sent();
|
||||
if (!projectId) {
|
||||
throw new Error('Cannot sign data without a project ID.');
|
||||
}
|
||||
return [4 /*yield*/, this.getCredentials()];
|
||||
case 3:
|
||||
creds = _a.sent();
|
||||
if (!creds.client_email) {
|
||||
throw new Error('Cannot sign data without `client_email`.');
|
||||
}
|
||||
id = "projects/" + projectId + "/serviceAccounts/" + creds.client_email;
|
||||
return [4 /*yield*/, this.request({
|
||||
method: 'POST',
|
||||
url: "https://iam.googleapis.com/v1/" + id + ":signBlob",
|
||||
data: { bytesToSign: Buffer.from(data).toString('base64') }
|
||||
})];
|
||||
case 4:
|
||||
res = _a.sent();
|
||||
return [2 /*return*/, res.data.signature];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Export DefaultTransporter as a static property of the class.
|
||||
*/
|
||||
GoogleAuth.DefaultTransporter = transporters_1.DefaultTransporter;
|
||||
return GoogleAuth;
|
||||
}());
|
||||
exports.GoogleAuth = GoogleAuth;
|
||||
//# sourceMappingURL=googleauth.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/googleauth.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/googleauth.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
58
node_modules/google-auth-library/build/src/auth/iam.js
generated
vendored
Normal file
58
node_modules/google-auth-library/build/src/auth/iam.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2014 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var IAMAuth = /** @class */ (function () {
|
||||
/**
|
||||
* IAM credentials.
|
||||
*
|
||||
* @param selector the iam authority selector
|
||||
* @param token the token
|
||||
* @constructor
|
||||
*/
|
||||
function IAMAuth(selector, token) {
|
||||
this.selector = selector;
|
||||
this.token = token;
|
||||
this.selector = selector;
|
||||
this.token = token;
|
||||
}
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createdScoped before use.
|
||||
*
|
||||
* @return always false
|
||||
*/
|
||||
IAMAuth.prototype.createScopedRequired = function () {
|
||||
// IAM authorization does not use scopes.
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Pass the selector and token to the metadataFn callback.
|
||||
*
|
||||
* @param unused_uri is required of the credentials interface
|
||||
* @param metadataFn a callback invoked with object
|
||||
* containing request metadata.
|
||||
*/
|
||||
IAMAuth.prototype.getRequestMetadata = function (unusedUri, metadataFn) {
|
||||
metadataFn(null, {
|
||||
'x-goog-iam-authority-selector': this.selector,
|
||||
'x-goog-iam-authorization-token': this.token
|
||||
});
|
||||
};
|
||||
return IAMAuth;
|
||||
}());
|
||||
exports.IAMAuth = IAMAuth;
|
||||
//# sourceMappingURL=iam.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/iam.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/iam.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"iam.js","sourceRoot":"","sources":["../../../src/auth/iam.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAOH;IACE;;;;;;OAMG;IACH,iBAAmB,QAAgB,EAAS,KAAa;QAAtC,aAAQ,GAAR,QAAQ,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAQ;QACvD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACH,sCAAoB,GAApB;QACE,yCAAyC;QACzC,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACH,oCAAkB,GAAlB,UACI,SAAsB,EACtB,UAAiE;QACnE,UAAU,CAAC,IAAI,EAAE;YACf,+BAA+B,EAAE,IAAI,CAAC,QAAQ;YAC9C,gCAAgC,EAAE,IAAI,CAAC,KAAK;SAC7C,CAAC,CAAC;IACL,CAAC;IACH,cAAC;AAAD,CAAC,AAvCD,IAuCC;AAvCY,0BAAO"}
|
||||
136
node_modules/google-auth-library/build/src/auth/jwtaccess.js
generated
vendored
Normal file
136
node_modules/google-auth-library/build/src/auth/jwtaccess.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var jws_1 = __importDefault(require("jws"));
|
||||
var lru_cache_1 = __importDefault(require("lru-cache"));
|
||||
var JWTAccess = /** @class */ (function () {
|
||||
/**
|
||||
* JWTAccess service account credentials.
|
||||
*
|
||||
* Create a new access token by using the credential to create a new JWT token
|
||||
* that's recognized as the access token.
|
||||
*
|
||||
* @param email the service account email address.
|
||||
* @param key the private key that will be used to sign the token.
|
||||
*/
|
||||
function JWTAccess(email, key) {
|
||||
this.cache = lru_cache_1.default({ max: 500, maxAge: 60 * 60 * 1000 });
|
||||
this.email = email;
|
||||
this.key = key;
|
||||
}
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createdScoped before use.
|
||||
*
|
||||
* @return always false
|
||||
*/
|
||||
JWTAccess.prototype.createScopedRequired = function () {
|
||||
// JWT Header authentication does not use scopes.
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Get a non-expired access token, after refreshing if necessary.
|
||||
*
|
||||
* @param authURI The URI being authorized.
|
||||
* @param additionalClaims An object with a set of additional claims to
|
||||
* include in the payload.
|
||||
* @returns An object that includes the authorization header.
|
||||
*/
|
||||
JWTAccess.prototype.getRequestMetadata = function (authURI, additionalClaims) {
|
||||
var cachedToken = this.cache.get(authURI);
|
||||
if (cachedToken) {
|
||||
return cachedToken;
|
||||
}
|
||||
var iat = Math.floor(new Date().getTime() / 1000);
|
||||
var exp = iat + 3600; // 3600 seconds = 1 hour
|
||||
// The payload used for signed JWT headers has:
|
||||
// iss == sub == <client email>
|
||||
// aud == <the authorization uri>
|
||||
var defaultClaims = { iss: this.email, sub: this.email, aud: authURI, exp: exp, iat: iat };
|
||||
// if additionalClaims are provided, ensure they do not collide with
|
||||
// other required claims.
|
||||
if (additionalClaims) {
|
||||
for (var claim in defaultClaims) {
|
||||
if (additionalClaims[claim]) {
|
||||
throw new Error("The '" + claim + "' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.");
|
||||
}
|
||||
}
|
||||
}
|
||||
var payload = Object.assign(defaultClaims, additionalClaims);
|
||||
// Sign the jwt and add it to the cache
|
||||
var signedJWT = jws_1.default.sign({ header: { alg: 'RS256' }, payload: payload, secret: this.key });
|
||||
var res = { headers: { Authorization: "Bearer " + signedJWT } };
|
||||
this.cache.set(authURI, res);
|
||||
return res;
|
||||
};
|
||||
/**
|
||||
* Create a JWTAccess credentials instance using the given input options.
|
||||
* @param json The input object.
|
||||
*/
|
||||
JWTAccess.prototype.fromJSON = function (json) {
|
||||
if (!json) {
|
||||
throw new Error('Must pass in a JSON object containing the service account auth settings.');
|
||||
}
|
||||
if (!json.client_email) {
|
||||
throw new Error('The incoming JSON object does not contain a client_email field');
|
||||
}
|
||||
if (!json.private_key) {
|
||||
throw new Error('The incoming JSON object does not contain a private_key field');
|
||||
}
|
||||
// Extract the relevant information from the json key file.
|
||||
this.email = json.client_email;
|
||||
this.key = json.private_key;
|
||||
this.projectId = json.project_id;
|
||||
};
|
||||
JWTAccess.prototype.fromStream = function (inputStream, callback) {
|
||||
if (callback) {
|
||||
this.fromStreamAsync(inputStream).then(function (r) { return callback(); }).catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.fromStreamAsync(inputStream);
|
||||
}
|
||||
};
|
||||
JWTAccess.prototype.fromStreamAsync = function (inputStream) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!inputStream) {
|
||||
reject(new Error('Must pass in a stream containing the service account auth settings.'));
|
||||
}
|
||||
var s = '';
|
||||
inputStream.setEncoding('utf8');
|
||||
inputStream.on('data', function (chunk) {
|
||||
s += chunk;
|
||||
});
|
||||
inputStream.on('end', function () {
|
||||
try {
|
||||
var data = JSON.parse(s);
|
||||
_this.fromJSON(data);
|
||||
resolve();
|
||||
}
|
||||
catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return JWTAccess;
|
||||
}());
|
||||
exports.JWTAccess = JWTAccess;
|
||||
//# sourceMappingURL=jwtaccess.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/jwtaccess.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/jwtaccess.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jwtaccess.js","sourceRoot":"","sources":["../../../src/auth/jwtaccess.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAEH,4CAAsB;AACtB,wDAA4B;AAK5B;IAQE;;;;;;;;OAQG;IACH,mBAAY,KAAmB,EAAE,GAAiB;QAZ1C,UAAK,GACT,mBAAG,CAAkC,EAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAC,CAAC,CAAC;QAY3E,IAAI,CAAC,KA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AAC,GAAG,EAAE,CAAC;YACX,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAChC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,UAAC,KAAK;gBAC3B,CAAC,IAAI,KAAK,CAAC;YACb,CAAC,CAAC,CAAC;YACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;gBACpB,IAAI;oBACF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC3B,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACpB,OAAO,EAAE,CAAC;iBACX;gBAAC,OAAO,GAAG,EAAE;oBACZ,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACH,gBAAC;AAAD,CAAC,AA5ID,IA4IC;AA5IY,8BAAS"}
|
||||
306
node_modules/google-auth-library/build/src/auth/jwtclient.js
generated
vendored
Normal file
306
node_modules/google-auth-library/build/src/auth/jwtclient.js
generated
vendored
Normal file
@@ -0,0 +1,306 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2013 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var gtoken_1 = require("gtoken");
|
||||
var jwtaccess_1 = require("./jwtaccess");
|
||||
var oauth2client_1 = require("./oauth2client");
|
||||
var isString = require('lodash.isstring');
|
||||
var JWT = /** @class */ (function (_super) {
|
||||
__extends(JWT, _super);
|
||||
function JWT(optionsOrEmail, keyFile, key, scopes, subject) {
|
||||
var _this = this;
|
||||
var opts = (optionsOrEmail && typeof optionsOrEmail === 'object') ?
|
||||
optionsOrEmail :
|
||||
{ email: optionsOrEmail, keyFile: keyFile, key: key, scopes: scopes, subject: subject };
|
||||
_this = _super.call(this, { eagerRefreshThresholdMillis: opts.eagerRefreshThresholdMillis }) || this;
|
||||
_this.email = opts.email;
|
||||
_this.keyFile = opts.keyFile;
|
||||
_this.key = opts.key;
|
||||
_this.scopes = opts.scopes;
|
||||
_this.subject = opts.subject;
|
||||
_this.additionalClaims = opts.additionalClaims;
|
||||
_this.credentials = { refresh_token: 'jwt-placeholder', expiry_date: 1 };
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Creates a copy of the credential with the specified scopes.
|
||||
* @param scopes List of requested scopes or a single scope.
|
||||
* @return The cloned instance.
|
||||
*/
|
||||
JWT.prototype.createScoped = function (scopes) {
|
||||
return new JWT({
|
||||
email: this.email,
|
||||
keyFile: this.keyFile,
|
||||
key: this.key,
|
||||
scopes: scopes,
|
||||
subject: this.subject,
|
||||
additionalClaims: this.additionalClaims
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Obtains the metadata to be sent with the request.
|
||||
*
|
||||
* @param url the URI being authorized.
|
||||
*/
|
||||
JWT.prototype.getRequestMetadataAsync = function (url) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var tokens;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!(!this.apiKey && this.createScopedRequired() && url)) return [3 /*break*/, 4];
|
||||
if (!(this.additionalClaims && this.additionalClaims.target_audience)) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, this.refreshToken()];
|
||||
case 1:
|
||||
tokens = (_a.sent()).tokens;
|
||||
return [2 /*return*/, { headers: { Authorization: "Bearer " + tokens.id_token } }];
|
||||
case 2:
|
||||
// no scopes have been set, but a uri has been provided. Use JWTAccess
|
||||
// credentials.
|
||||
if (!this.access) {
|
||||
this.access = new jwtaccess_1.JWTAccess(this.email, this.key);
|
||||
}
|
||||
return [2 /*return*/, this.access.getRequestMetadata(url, this.additionalClaims)];
|
||||
case 3: return [3 /*break*/, 5];
|
||||
case 4: return [2 /*return*/, _super.prototype.getRequestMetadataAsync.call(this, url)];
|
||||
case 5: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createScoped before use.
|
||||
* @return false if createScoped does not need to be called.
|
||||
*/
|
||||
JWT.prototype.createScopedRequired = function () {
|
||||
// If scopes is null, always return true.
|
||||
if (this.scopes) {
|
||||
// For arrays, check the array length.
|
||||
if (this.scopes instanceof Array) {
|
||||
return this.scopes.length === 0;
|
||||
}
|
||||
// For others, convert to a string and check the length.
|
||||
return String(this.scopes).length === 0;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
JWT.prototype.authorize = function (callback) {
|
||||
if (callback) {
|
||||
this.authorizeAsync().then(function (r) { return callback(null, r); }).catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.authorizeAsync();
|
||||
}
|
||||
};
|
||||
JWT.prototype.authorizeAsync = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var result;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.refreshToken()];
|
||||
case 1:
|
||||
result = _a.sent();
|
||||
if (!result) {
|
||||
throw new Error('No result returned');
|
||||
}
|
||||
this.credentials = result.tokens;
|
||||
this.credentials.refresh_token = 'jwt-placeholder';
|
||||
this.key = this.gtoken.key;
|
||||
this.email = this.gtoken.iss;
|
||||
return [2 /*return*/, result.tokens];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refreshToken ignored
|
||||
* @private
|
||||
*/
|
||||
JWT.prototype.refreshTokenNoCache = function (refreshToken) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var gtoken, token, tokens;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
gtoken = this.createGToken();
|
||||
return [4 /*yield*/, gtoken.getToken()];
|
||||
case 1:
|
||||
token = _a.sent();
|
||||
tokens = {
|
||||
access_token: token,
|
||||
token_type: 'Bearer',
|
||||
expiry_date: gtoken.expiresAt,
|
||||
// tslint:disable-next-line no-any
|
||||
id_token: gtoken.rawToken.id_token
|
||||
};
|
||||
this.emit('tokens', tokens);
|
||||
return [2 /*return*/, { res: null, tokens: tokens }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Create a gToken if it doesn't already exist.
|
||||
*/
|
||||
JWT.prototype.createGToken = function () {
|
||||
if (!this.gtoken) {
|
||||
this.gtoken = new gtoken_1.GoogleToken({
|
||||
iss: this.email,
|
||||
sub: this.subject,
|
||||
scope: this.scopes,
|
||||
keyFile: this.keyFile,
|
||||
key: this.key,
|
||||
additionalClaims: this.additionalClaims
|
||||
});
|
||||
}
|
||||
return this.gtoken;
|
||||
};
|
||||
/**
|
||||
* Create a JWT credentials instance using the given input options.
|
||||
* @param json The input object.
|
||||
*/
|
||||
JWT.prototype.fromJSON = function (json) {
|
||||
if (!json) {
|
||||
throw new Error('Must pass in a JSON object containing the service account auth settings.');
|
||||
}
|
||||
if (!json.client_email) {
|
||||
throw new Error('The incoming JSON object does not contain a client_email field');
|
||||
}
|
||||
if (!json.private_key) {
|
||||
throw new Error('The incoming JSON object does not contain a private_key field');
|
||||
}
|
||||
// Extract the relevant information from the json key file.
|
||||
this.email = json.client_email;
|
||||
this.key = json.private_key;
|
||||
this.projectId = json.project_id;
|
||||
};
|
||||
JWT.prototype.fromStream = function (inputStream, callback) {
|
||||
if (callback) {
|
||||
this.fromStreamAsync(inputStream).then(function (r) { return callback(); }).catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.fromStreamAsync(inputStream);
|
||||
}
|
||||
};
|
||||
JWT.prototype.fromStreamAsync = function (inputStream) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!inputStream) {
|
||||
throw new Error('Must pass in a stream containing the service account auth settings.');
|
||||
}
|
||||
var s = '';
|
||||
inputStream.setEncoding('utf8');
|
||||
inputStream.on('data', function (chunk) {
|
||||
s += chunk;
|
||||
});
|
||||
inputStream.on('end', function () {
|
||||
try {
|
||||
var data = JSON.parse(s);
|
||||
_this.fromJSON(data);
|
||||
resolve();
|
||||
}
|
||||
catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Creates a JWT credentials instance using an API Key for authentication.
|
||||
* @param apiKey The API Key in string form.
|
||||
*/
|
||||
JWT.prototype.fromAPIKey = function (apiKey) {
|
||||
if (!isString(apiKey)) {
|
||||
throw new Error('Must provide an API Key string.');
|
||||
}
|
||||
this.apiKey = apiKey;
|
||||
};
|
||||
/**
|
||||
* Using the key or keyFile on the JWT client, obtain an object that contains
|
||||
* the key and the client email.
|
||||
*/
|
||||
JWT.prototype.getCredentials = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var gtoken, creds;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!this.key) return [3 /*break*/, 1];
|
||||
return [2 /*return*/, { private_key: this.key, client_email: this.email }];
|
||||
case 1:
|
||||
if (!this.keyFile) return [3 /*break*/, 3];
|
||||
gtoken = this.createGToken();
|
||||
return [4 /*yield*/, gtoken.getCredentials(this.keyFile)];
|
||||
case 2:
|
||||
creds = _a.sent();
|
||||
return [2 /*return*/, { private_key: creds.privateKey, client_email: creds.clientEmail }];
|
||||
case 3: throw new Error('A key or a keyFile must be provided to getCredentials.');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return JWT;
|
||||
}(oauth2client_1.OAuth2Client));
|
||||
exports.JWT = JWT;
|
||||
//# sourceMappingURL=jwtclient.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/jwtclient.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/jwtclient.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
60
node_modules/google-auth-library/build/src/auth/loginticket.js
generated
vendored
Normal file
60
node_modules/google-auth-library/build/src/auth/loginticket.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2014 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var LoginTicket = /** @class */ (function () {
|
||||
/**
|
||||
* Create a simple class to extract user ID from an ID Token
|
||||
*
|
||||
* @param {string} env Envelope of the jwt
|
||||
* @param {TokenPayload} pay Payload of the jwt
|
||||
* @constructor
|
||||
*/
|
||||
function LoginTicket(env, pay) {
|
||||
this.envelope = env;
|
||||
this.payload = pay;
|
||||
}
|
||||
LoginTicket.prototype.getEnvelope = function () {
|
||||
return this.envelope;
|
||||
};
|
||||
LoginTicket.prototype.getPayload = function () {
|
||||
return this.payload;
|
||||
};
|
||||
/**
|
||||
* Create a simple class to extract user ID from an ID Token
|
||||
*
|
||||
* @return The user ID
|
||||
*/
|
||||
LoginTicket.prototype.getUserId = function () {
|
||||
var payload = this.getPayload();
|
||||
if (payload && payload.sub) {
|
||||
return payload.sub;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/**
|
||||
* Returns attributes from the login ticket. This can contain
|
||||
* various information about the user session.
|
||||
*
|
||||
* @return The envelope and payload
|
||||
*/
|
||||
LoginTicket.prototype.getAttributes = function () {
|
||||
return { envelope: this.getEnvelope(), payload: this.getPayload() };
|
||||
};
|
||||
return LoginTicket;
|
||||
}());
|
||||
exports.LoginTicket = LoginTicket;
|
||||
//# sourceMappingURL=loginticket.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/loginticket.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/loginticket.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"loginticket.js","sourceRoot":"","sources":["../../../src/auth/loginticket.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH;IAIE;;;;;;OAMG;IACH,qBAAY,GAAY,EAAE,GAAkB;QAC1C,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;IACrB,CAAC;IAED,iCAAW,GAAX;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,gCAAU,GAAV;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,+BAAS,GAAT;QACE,IAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;YAC1B,OAAO,OAAO,CAAC,GAAG,CAAC;SACpB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,mCAAa,GAAb;QACE,OAAO,EAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,EAAC,CAAC;IACpE,CAAC;IACH,kBAAC;AAAD,CAAC,AA9CD,IA8CC;AA9CY,kCAAW"}
|
||||
753
node_modules/google-auth-library/build/src/auth/oauth2client.js
generated
vendored
Normal file
753
node_modules/google-auth-library/build/src/auth/oauth2client.js
generated
vendored
Normal file
@@ -0,0 +1,753 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2012 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var crypto_1 = __importDefault(require("crypto"));
|
||||
var querystring_1 = __importDefault(require("querystring"));
|
||||
var stream = __importStar(require("stream"));
|
||||
var pemverifier_1 = require("./../pemverifier");
|
||||
var authclient_1 = require("./authclient");
|
||||
var loginticket_1 = require("./loginticket");
|
||||
var CodeChallengeMethod;
|
||||
(function (CodeChallengeMethod) {
|
||||
CodeChallengeMethod["Plain"] = "plain";
|
||||
CodeChallengeMethod["S256"] = "S256";
|
||||
})(CodeChallengeMethod = exports.CodeChallengeMethod || (exports.CodeChallengeMethod = {}));
|
||||
var OAuth2Client = /** @class */ (function (_super) {
|
||||
__extends(OAuth2Client, _super);
|
||||
function OAuth2Client(optionsOrClientId, clientSecret, redirectUri, authClientOpts) {
|
||||
if (authClientOpts === void 0) { authClientOpts = {}; }
|
||||
var _this = _super.call(this) || this;
|
||||
_this.certificateCache = null;
|
||||
_this.certificateExpiry = null;
|
||||
_this.refreshTokenPromises = new Map();
|
||||
var opts = (optionsOrClientId && typeof optionsOrClientId === 'object') ?
|
||||
optionsOrClientId :
|
||||
{
|
||||
clientId: optionsOrClientId,
|
||||
clientSecret: clientSecret,
|
||||
redirectUri: redirectUri,
|
||||
tokenUrl: authClientOpts.tokenUrl,
|
||||
authBaseUrl: authClientOpts.authBaseUrl
|
||||
};
|
||||
_this._clientId = opts.clientId;
|
||||
_this._clientSecret = opts.clientSecret;
|
||||
_this.redirectUri = opts.redirectUri;
|
||||
_this.authBaseUrl = opts.authBaseUrl;
|
||||
_this.tokenUrl = opts.tokenUrl;
|
||||
_this.eagerRefreshThresholdMillis =
|
||||
opts.eagerRefreshThresholdMillis || 5 * 60 * 1000;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Generates URL for consent page landing.
|
||||
* @param opts Options.
|
||||
* @return URL to consent page.
|
||||
*/
|
||||
OAuth2Client.prototype.generateAuthUrl = function (opts) {
|
||||
if (opts === void 0) { opts = {}; }
|
||||
if (opts.code_challenge_method && !opts.code_challenge) {
|
||||
throw new Error('If a code_challenge_method is provided, code_challenge must be included.');
|
||||
}
|
||||
opts.response_type = opts.response_type || 'code';
|
||||
opts.client_id = opts.client_id || this._clientId;
|
||||
opts.redirect_uri = opts.redirect_uri || this.redirectUri;
|
||||
// Allow scopes to be passed either as array or a string
|
||||
if (opts.scope instanceof Array) {
|
||||
opts.scope = opts.scope.join(' ');
|
||||
}
|
||||
var rootUrl = this.authBaseUrl || OAuth2Client.GOOGLE_OAUTH2_AUTH_BASE_URL_;
|
||||
return rootUrl + '?' + querystring_1.default.stringify(opts);
|
||||
};
|
||||
/**
|
||||
* Convenience method to automatically generate a code_verifier, and it's
|
||||
* resulting SHA256. If used, this must be paired with a S256
|
||||
* code_challenge_method.
|
||||
*/
|
||||
OAuth2Client.prototype.generateCodeVerifier = function () {
|
||||
// base64 encoding uses 6 bits per character, and we want to generate128
|
||||
// characters. 6*128/8 = 96.
|
||||
var randomString = crypto_1.default.randomBytes(96).toString('base64');
|
||||
// The valid characters in the code_verifier are [A-Z]/[a-z]/[0-9]/
|
||||
// "-"/"."/"_"/"~". Base64 encoded strings are pretty close, so we're just
|
||||
// swapping out a few chars.
|
||||
var codeVerifier = randomString.replace(/\+/g, '~').replace(/=/g, '_').replace(/\//g, '-');
|
||||
// Generate the base64 encoded SHA256
|
||||
var unencodedCodeChallenge = crypto_1.default.createHash('sha256').update(codeVerifier).digest('base64');
|
||||
// We need to use base64UrlEncoding instead of standard base64
|
||||
var codeChallenge = unencodedCodeChallenge.split('=')[0]
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_');
|
||||
return { codeVerifier: codeVerifier, codeChallenge: codeChallenge };
|
||||
};
|
||||
OAuth2Client.prototype.getToken = function (codeOrOptions, callback) {
|
||||
var options = (typeof codeOrOptions === 'string') ?
|
||||
{ code: codeOrOptions } :
|
||||
codeOrOptions;
|
||||
if (callback) {
|
||||
this.getTokenAsync(options)
|
||||
.then(function (r) { return callback(null, r.tokens, r.res); })
|
||||
.catch(function (e) { return callback(e, null, e.response); });
|
||||
}
|
||||
else {
|
||||
return this.getTokenAsync(options);
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.getTokenAsync = function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, values, res, tokens;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
url = this.tokenUrl || OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_;
|
||||
values = {
|
||||
code: options.code,
|
||||
client_id: options.client_id || this._clientId,
|
||||
client_secret: this._clientSecret,
|
||||
redirect_uri: options.redirect_uri || this.redirectUri,
|
||||
grant_type: 'authorization_code',
|
||||
code_verifier: options.codeVerifier
|
||||
};
|
||||
return [4 /*yield*/, this.transporter.request({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: querystring_1.default.stringify(values),
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||
})];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
tokens = res.data;
|
||||
if (res.data && res.data.expires_in) {
|
||||
tokens.expiry_date =
|
||||
((new Date()).getTime() + (res.data.expires_in * 1000));
|
||||
delete tokens.expires_in;
|
||||
}
|
||||
this.emit('tokens', tokens);
|
||||
return [2 /*return*/, { tokens: tokens, res: res }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refresh_token Existing refresh token.
|
||||
* @private
|
||||
*/
|
||||
OAuth2Client.prototype.refreshToken = function (refreshToken) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var p;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
if (!refreshToken) {
|
||||
return [2 /*return*/, this.refreshTokenNoCache(refreshToken)];
|
||||
}
|
||||
// If a request to refresh using the same token has started,
|
||||
// return the same promise.
|
||||
if (this.refreshTokenPromises.has(refreshToken)) {
|
||||
return [2 /*return*/, this.refreshTokenPromises.get(refreshToken)];
|
||||
}
|
||||
p = this.refreshTokenNoCache(refreshToken)
|
||||
.then(function (r) {
|
||||
_this.refreshTokenPromises.delete(refreshToken);
|
||||
return r;
|
||||
})
|
||||
.catch(function (e) {
|
||||
_this.refreshTokenPromises.delete(refreshToken);
|
||||
throw e;
|
||||
});
|
||||
this.refreshTokenPromises.set(refreshToken, p);
|
||||
return [2 /*return*/, p];
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.refreshTokenNoCache = function (refreshToken) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, data, res, tokens;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
url = this.tokenUrl || OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_;
|
||||
data = {
|
||||
refresh_token: refreshToken,
|
||||
client_id: this._clientId,
|
||||
client_secret: this._clientSecret,
|
||||
grant_type: 'refresh_token'
|
||||
};
|
||||
return [4 /*yield*/, this.transporter.request({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: querystring_1.default.stringify(data),
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||
})];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
tokens = res.data;
|
||||
// TODO: de-duplicate this code from a few spots
|
||||
if (res.data && res.data.expires_in) {
|
||||
tokens.expiry_date =
|
||||
((new Date()).getTime() + (res.data.expires_in * 1000));
|
||||
delete tokens.expires_in;
|
||||
}
|
||||
this.emit('tokens', tokens);
|
||||
return [2 /*return*/, { tokens: tokens, res: res }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.refreshAccessToken = function (callback) {
|
||||
if (callback) {
|
||||
this.refreshAccessTokenAsync()
|
||||
.then(function (r) { return callback(null, r.credentials, r.res); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.refreshAccessTokenAsync();
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.refreshAccessTokenAsync = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var r, tokens;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!this.credentials.refresh_token) {
|
||||
throw new Error('No refresh token is set.');
|
||||
}
|
||||
return [4 /*yield*/, this.refreshToken(this.credentials.refresh_token)];
|
||||
case 1:
|
||||
r = _a.sent();
|
||||
tokens = r.tokens;
|
||||
tokens.refresh_token = this.credentials.refresh_token;
|
||||
this.credentials = tokens;
|
||||
return [2 /*return*/, { credentials: this.credentials, res: r.res }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.getAccessToken = function (callback) {
|
||||
if (callback) {
|
||||
this.getAccessTokenAsync()
|
||||
.then(function (r) { return callback(null, r.token, r.res); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.getAccessTokenAsync();
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.getAccessTokenAsync = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var shouldRefresh, r;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
shouldRefresh = !this.credentials.access_token || this.isTokenExpiring();
|
||||
if (!(shouldRefresh && this.credentials.refresh_token)) return [3 /*break*/, 2];
|
||||
if (!this.credentials.refresh_token) {
|
||||
throw new Error('No refresh token is set.');
|
||||
}
|
||||
return [4 /*yield*/, this.refreshAccessToken()];
|
||||
case 1:
|
||||
r = _a.sent();
|
||||
if (!r.credentials || (r.credentials && !r.credentials.access_token)) {
|
||||
throw new Error('Could not refresh access token.');
|
||||
}
|
||||
return [2 /*return*/, { token: r.credentials.access_token, res: r.res }];
|
||||
case 2: return [2 /*return*/, { token: this.credentials.access_token }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.getRequestMetadata = function (url, callback) {
|
||||
if (callback) {
|
||||
this.getRequestMetadataAsync(url)
|
||||
.then(function (r) { return callback(null, r.headers, r.res); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.getRequestMetadataAsync(url);
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.getRequestMetadataAsync = function (url) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var thisCreds, headers_1, r, tokens, err_1, e, credentials, headers;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
thisCreds = this.credentials;
|
||||
if (!thisCreds.access_token && !thisCreds.refresh_token && !this.apiKey) {
|
||||
throw new Error('No access, refresh token or API key is set.');
|
||||
}
|
||||
if (thisCreds.access_token && !this.isTokenExpiring()) {
|
||||
thisCreds.token_type = thisCreds.token_type || 'Bearer';
|
||||
headers_1 = {
|
||||
Authorization: thisCreds.token_type + ' ' + thisCreds.access_token
|
||||
};
|
||||
return [2 /*return*/, { headers: headers_1 }];
|
||||
}
|
||||
if (this.apiKey) {
|
||||
return [2 /*return*/, { headers: {} }];
|
||||
}
|
||||
r = null;
|
||||
tokens = null;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this.refreshToken(thisCreds.refresh_token)];
|
||||
case 2:
|
||||
r = _a.sent();
|
||||
tokens = r.tokens;
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
e = err_1;
|
||||
if (e.response &&
|
||||
(e.response.status === 403 || e.response.status === 404)) {
|
||||
e.message = 'Could not refresh access token.';
|
||||
}
|
||||
throw e;
|
||||
case 4:
|
||||
credentials = this.credentials;
|
||||
credentials.token_type = credentials.token_type || 'Bearer';
|
||||
tokens.refresh_token = credentials.refresh_token;
|
||||
this.credentials = tokens;
|
||||
headers = {
|
||||
Authorization: credentials.token_type + ' ' + tokens.access_token
|
||||
};
|
||||
return [2 /*return*/, { headers: headers, res: r.res }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.revokeToken = function (token, callback) {
|
||||
var opts = {
|
||||
url: OAuth2Client.GOOGLE_OAUTH2_REVOKE_URL_ + '?' +
|
||||
querystring_1.default.stringify({ token: token })
|
||||
};
|
||||
if (callback) {
|
||||
this.transporter.request(opts)
|
||||
.then(function (res) {
|
||||
callback(null, res);
|
||||
})
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.transporter.request(opts);
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.revokeCredentials = function (callback) {
|
||||
if (callback) {
|
||||
this.revokeCredentialsAsync()
|
||||
.then(function (res) { return callback(null, res); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.revokeCredentialsAsync();
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.revokeCredentialsAsync = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var token;
|
||||
return __generator(this, function (_a) {
|
||||
token = this.credentials.access_token;
|
||||
this.credentials = {};
|
||||
if (token) {
|
||||
return [2 /*return*/, this.revokeToken(token)];
|
||||
}
|
||||
else {
|
||||
throw new Error('No access token to revoke.');
|
||||
}
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.request = function (opts, callback) {
|
||||
if (callback) {
|
||||
this.requestAsync(opts).then(function (r) { return callback(null, r); }).catch(function (e) {
|
||||
var err = e;
|
||||
var body = err.response ? err.response.data : null;
|
||||
return callback(e, err.response);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this.requestAsync(opts);
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.requestAsync = function (opts, retry) {
|
||||
if (retry === void 0) { retry = false; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var r2, r, e_1, res, statusCode, mayRequireRefresh, isReadableStream, isAuthErr;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 3, , 6]);
|
||||
return [4 /*yield*/, this.getRequestMetadataAsync(opts.url)];
|
||||
case 1:
|
||||
r = _a.sent();
|
||||
if (r.headers && r.headers.Authorization) {
|
||||
opts.headers = opts.headers || {};
|
||||
opts.headers.Authorization = r.headers.Authorization;
|
||||
}
|
||||
if (this.apiKey) {
|
||||
opts.params = Object.assign(opts.params || {}, { key: this.apiKey });
|
||||
}
|
||||
return [4 /*yield*/, this.transporter.request(opts)];
|
||||
case 2:
|
||||
r2 = _a.sent();
|
||||
return [3 /*break*/, 6];
|
||||
case 3:
|
||||
e_1 = _a.sent();
|
||||
res = e_1.response;
|
||||
if (!res) return [3 /*break*/, 5];
|
||||
statusCode = res.status;
|
||||
mayRequireRefresh = this.credentials &&
|
||||
this.credentials.access_token && this.credentials.refresh_token &&
|
||||
!this.credentials.expiry_date;
|
||||
isReadableStream = res.config.data instanceof stream.Readable;
|
||||
isAuthErr = statusCode === 401 || statusCode === 403;
|
||||
if (!(!retry && isAuthErr && !isReadableStream && mayRequireRefresh)) return [3 /*break*/, 5];
|
||||
return [4 /*yield*/, this.refreshAccessTokenAsync()];
|
||||
case 4:
|
||||
_a.sent();
|
||||
return [2 /*return*/, this.requestAsync(opts, true)];
|
||||
case 5: throw e_1;
|
||||
case 6: return [2 /*return*/, r2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.verifyIdToken = function (options, callback) {
|
||||
// This function used to accept two arguments instead of an options object.
|
||||
// Check the types to help users upgrade with less pain.
|
||||
// This check can be removed after a 2.0 release.
|
||||
if (callback && typeof callback !== 'function') {
|
||||
throw new Error('This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.');
|
||||
}
|
||||
if (callback) {
|
||||
this.verifyIdTokenAsync(options)
|
||||
.then(function (r) { return callback(null, r); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.verifyIdTokenAsync(options);
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.verifyIdTokenAsync = function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var response, login;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!options.idToken) {
|
||||
throw new Error('The verifyIdToken method requires an ID Token');
|
||||
}
|
||||
return [4 /*yield*/, this.getFederatedSignonCertsAsync()];
|
||||
case 1:
|
||||
response = _a.sent();
|
||||
login = this.verifySignedJwtWithCerts(options.idToken, response.certs, options.audience, OAuth2Client.ISSUERS_, options.maxExpiry);
|
||||
return [2 /*return*/, login];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Obtains information about the provisioned access token. Especially useful
|
||||
* if you want to check the scopes that were provisioned to a given token.
|
||||
*
|
||||
* @param accessToken Required. The Access Token for which you want to get
|
||||
* user info.
|
||||
*/
|
||||
OAuth2Client.prototype.getTokenInfo = function (accessToken) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var data, info;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.transporter.request({
|
||||
method: 'GET',
|
||||
url: OAuth2Client.GOOGLE_TOKEN_INFO_URL,
|
||||
params: { access_token: accessToken }
|
||||
})];
|
||||
case 1:
|
||||
data = (_a.sent()).data;
|
||||
info = Object.assign({
|
||||
expiry_date: ((new Date()).getTime() + (data.expires_in * 1000)),
|
||||
scopes: data.scope.split(' ')
|
||||
}, data);
|
||||
delete info.expires_in;
|
||||
delete info.scope;
|
||||
return [2 /*return*/, info];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
OAuth2Client.prototype.getFederatedSignonCerts = function (callback) {
|
||||
if (callback) {
|
||||
this.getFederatedSignonCertsAsync()
|
||||
.then(function (r) { return callback(null, r.certs, r.res); })
|
||||
.catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.getFederatedSignonCertsAsync();
|
||||
}
|
||||
};
|
||||
OAuth2Client.prototype.getFederatedSignonCertsAsync = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var nowTime, res, e_2, cacheControl, cacheAge, pattern, regexResult, now;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
nowTime = (new Date()).getTime();
|
||||
if (this.certificateExpiry &&
|
||||
(nowTime < this.certificateExpiry.getTime())) {
|
||||
return [2 /*return*/, { certs: this.certificateCache }];
|
||||
}
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this.transporter.request({ url: OAuth2Client.GOOGLE_OAUTH2_FEDERATED_SIGNON_CERTS_URL_ })];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
e_2 = _a.sent();
|
||||
throw new Error('Failed to retrieve verification certificates: ' + e_2);
|
||||
case 4:
|
||||
cacheControl = res ? res.headers['cache-control'] : undefined;
|
||||
cacheAge = -1;
|
||||
if (cacheControl) {
|
||||
pattern = new RegExp('max-age=([0-9]*)');
|
||||
regexResult = pattern.exec(cacheControl);
|
||||
if (regexResult && regexResult.length === 2) {
|
||||
// Cache results with max-age (in seconds)
|
||||
cacheAge = Number(regexResult[1]) * 1000; // milliseconds
|
||||
}
|
||||
}
|
||||
now = new Date();
|
||||
this.certificateExpiry =
|
||||
cacheAge === -1 ? null : new Date(now.getTime() + cacheAge);
|
||||
this.certificateCache = res.data;
|
||||
return [2 /*return*/, { certs: res.data, res: res }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Verify the id token is signed with the correct certificate
|
||||
* and is from the correct audience.
|
||||
* @param jwt The jwt to verify (The ID Token in this case).
|
||||
* @param certs The array of certs to test the jwt against.
|
||||
* @param requiredAudience The audience to test the jwt against.
|
||||
* @param issuers The allowed issuers of the jwt (Optional).
|
||||
* @param maxExpiry The max expiry the certificate can be (Optional).
|
||||
* @return Returns a LoginTicket on verification.
|
||||
*/
|
||||
OAuth2Client.prototype.verifySignedJwtWithCerts = function (jwt, certs, requiredAudience, issuers, maxExpiry) {
|
||||
if (!maxExpiry) {
|
||||
maxExpiry = OAuth2Client.MAX_TOKEN_LIFETIME_SECS_;
|
||||
}
|
||||
var segments = jwt.split('.');
|
||||
if (segments.length !== 3) {
|
||||
throw new Error('Wrong number of segments in token: ' + jwt);
|
||||
}
|
||||
var signed = segments[0] + '.' + segments[1];
|
||||
var signature = segments[2];
|
||||
var envelope;
|
||||
var payload;
|
||||
try {
|
||||
envelope = JSON.parse(this.decodeBase64(segments[0]));
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error('Can\'t parse token envelope: ' + segments[0]);
|
||||
}
|
||||
if (!envelope) {
|
||||
throw new Error('Can\'t parse token envelope: ' + segments[0]);
|
||||
}
|
||||
try {
|
||||
payload = JSON.parse(this.decodeBase64(segments[1]));
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error('Can\'t parse token payload: ' + segments[0]);
|
||||
}
|
||||
if (!payload) {
|
||||
throw new Error('Can\'t parse token payload: ' + segments[1]);
|
||||
}
|
||||
if (!certs.hasOwnProperty(envelope.kid)) {
|
||||
// If this is not present, then there's no reason to attempt verification
|
||||
throw new Error('No pem found for envelope: ' + JSON.stringify(envelope));
|
||||
}
|
||||
// certs is a legit dynamic object
|
||||
// tslint:disable-next-line no-any
|
||||
var pem = certs[envelope.kid];
|
||||
var pemVerifier = new pemverifier_1.PemVerifier();
|
||||
var verified = pemVerifier.verify(pem, signed, signature, 'base64');
|
||||
if (!verified) {
|
||||
throw new Error('Invalid token signature: ' + jwt);
|
||||
}
|
||||
if (!payload.iat) {
|
||||
throw new Error('No issue time in token: ' + JSON.stringify(payload));
|
||||
}
|
||||
if (!payload.exp) {
|
||||
throw new Error('No expiration time in token: ' + JSON.stringify(payload));
|
||||
}
|
||||
var iat = Number(payload.iat);
|
||||
if (isNaN(iat))
|
||||
throw new Error('iat field using invalid format');
|
||||
var exp = Number(payload.exp);
|
||||
if (isNaN(exp))
|
||||
throw new Error('exp field using invalid format');
|
||||
var now = new Date().getTime() / 1000;
|
||||
if (exp >= now + maxExpiry) {
|
||||
throw new Error('Expiration time too far in future: ' + JSON.stringify(payload));
|
||||
}
|
||||
var earliest = iat - OAuth2Client.CLOCK_SKEW_SECS_;
|
||||
var latest = exp + OAuth2Client.CLOCK_SKEW_SECS_;
|
||||
if (now < earliest) {
|
||||
throw new Error('Token used too early, ' + now + ' < ' + earliest + ': ' +
|
||||
JSON.stringify(payload));
|
||||
}
|
||||
if (now > latest) {
|
||||
throw new Error('Token used too late, ' + now + ' > ' + latest + ': ' +
|
||||
JSON.stringify(payload));
|
||||
}
|
||||
if (issuers && issuers.indexOf(payload.iss) < 0) {
|
||||
throw new Error('Invalid issuer, expected one of [' + issuers + '], but got ' +
|
||||
payload.iss);
|
||||
}
|
||||
// Check the audience matches if we have one
|
||||
if (typeof requiredAudience !== 'undefined' && requiredAudience !== null) {
|
||||
var aud = payload.aud;
|
||||
var audVerified = false;
|
||||
// If the requiredAudience is an array, check if it contains token
|
||||
// audience
|
||||
if (requiredAudience.constructor === Array) {
|
||||
audVerified = (requiredAudience.indexOf(aud) > -1);
|
||||
}
|
||||
else {
|
||||
audVerified = (aud === requiredAudience);
|
||||
}
|
||||
if (!audVerified) {
|
||||
throw new Error('Wrong recipient, payload audience != requiredAudience');
|
||||
}
|
||||
}
|
||||
return new loginticket_1.LoginTicket(envelope, payload);
|
||||
};
|
||||
/**
|
||||
* This is a utils method to decode a base64 string
|
||||
* @param b64String The string to base64 decode
|
||||
* @return The decoded string
|
||||
*/
|
||||
OAuth2Client.prototype.decodeBase64 = function (b64String) {
|
||||
var buffer = new Buffer(b64String, 'base64');
|
||||
return buffer.toString('utf8');
|
||||
};
|
||||
/**
|
||||
* Returns true if a token is expired or will expire within
|
||||
* eagerRefreshThresholdMillismilliseconds.
|
||||
* If there is no expiry time, assumes the token is not expired or expiring.
|
||||
*/
|
||||
OAuth2Client.prototype.isTokenExpiring = function () {
|
||||
var expiryDate = this.credentials.expiry_date;
|
||||
return expiryDate ? expiryDate <=
|
||||
((new Date()).getTime() + this.eagerRefreshThresholdMillis) :
|
||||
false;
|
||||
};
|
||||
OAuth2Client.GOOGLE_TOKEN_INFO_URL = 'https://www.googleapis.com/oauth2/v3/tokeninfo';
|
||||
/**
|
||||
* The base URL for auth endpoints.
|
||||
*/
|
||||
OAuth2Client.GOOGLE_OAUTH2_AUTH_BASE_URL_ = 'https://accounts.google.com/o/oauth2/v2/auth';
|
||||
/**
|
||||
* The base endpoint for token retrieval.
|
||||
*/
|
||||
OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_ = 'https://www.googleapis.com/oauth2/v4/token';
|
||||
/**
|
||||
* The base endpoint to revoke tokens.
|
||||
*/
|
||||
OAuth2Client.GOOGLE_OAUTH2_REVOKE_URL_ = 'https://accounts.google.com/o/oauth2/revoke';
|
||||
/**
|
||||
* Google Sign on certificates.
|
||||
*/
|
||||
OAuth2Client.GOOGLE_OAUTH2_FEDERATED_SIGNON_CERTS_URL_ = 'https://www.googleapis.com/oauth2/v1/certs';
|
||||
/**
|
||||
* Clock skew - five minutes in seconds
|
||||
*/
|
||||
OAuth2Client.CLOCK_SKEW_SECS_ = 300;
|
||||
/**
|
||||
* Max Token Lifetime is one day in seconds
|
||||
*/
|
||||
OAuth2Client.MAX_TOKEN_LIFETIME_SECS_ = 86400;
|
||||
/**
|
||||
* The allowed oauth token issuers.
|
||||
*/
|
||||
OAuth2Client.ISSUERS_ = ['accounts.google.com', 'https://accounts.google.com'];
|
||||
return OAuth2Client;
|
||||
}(authclient_1.AuthClient));
|
||||
exports.OAuth2Client = OAuth2Client;
|
||||
//# sourceMappingURL=oauth2client.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/oauth2client.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/oauth2client.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
160
node_modules/google-auth-library/build/src/auth/refreshclient.js
generated
vendored
Normal file
160
node_modules/google-auth-library/build/src/auth/refreshclient.js
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var oauth2client_1 = require("./oauth2client");
|
||||
var UserRefreshClient = /** @class */ (function (_super) {
|
||||
__extends(UserRefreshClient, _super);
|
||||
function UserRefreshClient(optionsOrClientId, clientSecret, refreshToken, eagerRefreshThresholdMillis) {
|
||||
var _this = this;
|
||||
var opts = (optionsOrClientId && typeof optionsOrClientId === 'object') ?
|
||||
optionsOrClientId :
|
||||
{
|
||||
clientId: optionsOrClientId,
|
||||
clientSecret: clientSecret,
|
||||
refreshToken: refreshToken,
|
||||
eagerRefreshThresholdMillis: eagerRefreshThresholdMillis
|
||||
};
|
||||
_this = _super.call(this, {
|
||||
clientId: opts.clientId,
|
||||
clientSecret: opts.clientSecret,
|
||||
eagerRefreshThresholdMillis: opts.eagerRefreshThresholdMillis
|
||||
}) || this;
|
||||
_this._refreshToken = opts.refreshToken;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refreshToken An ignored refreshToken..
|
||||
* @param callback Optional callback.
|
||||
*/
|
||||
UserRefreshClient.prototype.refreshTokenNoCache = function (refreshToken) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, _super.prototype.refreshTokenNoCache.call(this, this._refreshToken)];
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Create a UserRefreshClient credentials instance using the given input
|
||||
* options.
|
||||
* @param json The input object.
|
||||
*/
|
||||
UserRefreshClient.prototype.fromJSON = function (json) {
|
||||
if (!json) {
|
||||
throw new Error('Must pass in a JSON object containing the user refresh token');
|
||||
}
|
||||
if (json.type !== 'authorized_user') {
|
||||
throw new Error('The incoming JSON object does not have the "authorized_user" type');
|
||||
}
|
||||
if (!json.client_id) {
|
||||
throw new Error('The incoming JSON object does not contain a client_id field');
|
||||
}
|
||||
if (!json.client_secret) {
|
||||
throw new Error('The incoming JSON object does not contain a client_secret field');
|
||||
}
|
||||
if (!json.refresh_token) {
|
||||
throw new Error('The incoming JSON object does not contain a refresh_token field');
|
||||
}
|
||||
this._clientId = json.client_id;
|
||||
this._clientSecret = json.client_secret;
|
||||
this._refreshToken = json.refresh_token;
|
||||
this.credentials.refresh_token = json.refresh_token;
|
||||
};
|
||||
UserRefreshClient.prototype.fromStream = function (inputStream, callback) {
|
||||
if (callback) {
|
||||
this.fromStreamAsync(inputStream).then(function (r) { return callback(); }).catch(callback);
|
||||
}
|
||||
else {
|
||||
return this.fromStreamAsync(inputStream);
|
||||
}
|
||||
};
|
||||
UserRefreshClient.prototype.fromStreamAsync = function (inputStream) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, new Promise(function (resolve, reject) {
|
||||
if (!inputStream) {
|
||||
return reject(new Error('Must pass in a stream containing the user refresh token.'));
|
||||
}
|
||||
var s = '';
|
||||
inputStream.setEncoding('utf8');
|
||||
inputStream.on('data', function (chunk) {
|
||||
s += chunk;
|
||||
});
|
||||
inputStream.on('end', function () {
|
||||
try {
|
||||
var data = JSON.parse(s);
|
||||
_this.fromJSON(data);
|
||||
return resolve();
|
||||
}
|
||||
catch (err) {
|
||||
return reject(err);
|
||||
}
|
||||
});
|
||||
})];
|
||||
});
|
||||
});
|
||||
};
|
||||
return UserRefreshClient;
|
||||
}(oauth2client_1.OAuth2Client));
|
||||
exports.UserRefreshClient = UserRefreshClient;
|
||||
//# sourceMappingURL=refreshclient.js.map
|
||||
1
node_modules/google-auth-library/build/src/auth/refreshclient.js.map
generated
vendored
Normal file
1
node_modules/google-auth-library/build/src/auth/refreshclient.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"refreshclient.js","sourceRoot":"","sources":["../../../src/auth/refreshclient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,+CAA8E;AAQ9E;IAAuC,qCAAY;IAgBjD,2BACI,iBAAmD,EACnD,YAAqB,EAAE,YAAqB,EAC5C,2BAAoC;QAHxC,iBAkBC;QAdC,IAAM,IAAI,GAAG,CAAC,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,QAAQ,CAAC,C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