Firebase Update
This commit is contained in:
377
express-server/node_modules/google-auto-auth/index.js
generated
vendored
Normal file
377
express-server/node_modules/google-auto-auth/index.js
generated
vendored
Normal file
@ -0,0 +1,377 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var crypto = require('crypto');
|
||||
var fs = require('fs');
|
||||
var GoogleAuth = require('google-auth-library').GoogleAuth;
|
||||
var gcpMetadata = require('gcp-metadata');
|
||||
var path = require('path');
|
||||
var request = require('request');
|
||||
|
||||
class Auth {
|
||||
constructor(config) {
|
||||
this.authClientPromise = null;
|
||||
this.authClient = null;
|
||||
this.googleAuthClient = null;
|
||||
this.config = config || {};
|
||||
this.credentials = null;
|
||||
this.environment = {};
|
||||
this.jwtClient = null;
|
||||
this.projectId = this.config.projectId;
|
||||
this.token = this.config.token;
|
||||
}
|
||||
|
||||
authorizeRequest (reqOpts, callback) {
|
||||
this.getToken((err, token) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
var authorizedReqOpts = Object.assign({}, reqOpts, {
|
||||
headers: Object.assign({}, reqOpts.headers, {
|
||||
Authorization: `Bearer ${token}`
|
||||
})
|
||||
});
|
||||
|
||||
callback(null, authorizedReqOpts);
|
||||
});
|
||||
}
|
||||
|
||||
getAuthClient (callback) {
|
||||
if (this.authClient) {
|
||||
// This code works around an issue with context loss with async-listener.
|
||||
// Strictly speaking, this should not be necessary as the call to
|
||||
// authClientPromise.then(..) below would resolve to the same value.
|
||||
// However, async-listener defaults to resuming the `then` callbacks with
|
||||
// the context at the point of resolution rather than the context from the
|
||||
// point where the `then` callback was added. In this case, the promise
|
||||
// will be resolved on the very first incoming http request, and that
|
||||
// context will become sticky (will be restored by async-listener) around
|
||||
// the `then` callbacks for all subsequent requests.
|
||||
//
|
||||
// This breaks APM tools like Stackdriver Trace & others and tools like
|
||||
// long stack traces (they will provide an incorrect stack trace).
|
||||
//
|
||||
// NOTE: this doesn't solve the problem generally. Any request concurrent
|
||||
// to the first call to this function, before the promise resolves, will
|
||||
// still lose context. We don't have a better solution at the moment :(.
|
||||
return setImmediate(callback.bind(null, null, this.authClient));
|
||||
}
|
||||
|
||||
var createAuthClientPromise = (resolve, reject) => {
|
||||
var config = this.config;
|
||||
var keyFile = config.keyFilename || config.keyFile;
|
||||
|
||||
this.googleAuthClient = new GoogleAuth();
|
||||
|
||||
var addScope = (err, authClient, projectId) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
|
||||
if (!config.scopes || config.scopes.length === 0) {
|
||||
var scopeError = new Error('Scopes are required for this request.');
|
||||
scopeError.code = 'MISSING_SCOPE';
|
||||
reject(scopeError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
authClient.scopes = config.scopes;
|
||||
this.authClient = authClient;
|
||||
this.projectId = config.projectId || projectId || authClient.projectId;
|
||||
|
||||
if (!this.projectId) {
|
||||
this.googleAuthClient.getDefaultProjectId((err, projectId) => {
|
||||
// Ignore error, since the user might not require a project ID.
|
||||
|
||||
if (projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
resolve(authClient);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(authClient);
|
||||
};
|
||||
|
||||
if (config.credentials) {
|
||||
try {
|
||||
var client = this.googleAuthClient.fromJSON(config.credentials);
|
||||
addScope(null, client);
|
||||
} catch (e) {
|
||||
addScope(e);
|
||||
}
|
||||
} else if (keyFile) {
|
||||
keyFile = path.resolve(process.cwd(), keyFile);
|
||||
|
||||
fs.readFile(keyFile, (err, contents) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var client = this.googleAuthClient.fromJSON(JSON.parse(contents));
|
||||
addScope(null, client);
|
||||
} catch(e) {
|
||||
// @TODO Find a better way to do this.
|
||||
// Ref: https://github.com/googleapis/nodejs-storage/issues/147
|
||||
// Ref: https://github.com/google/google-auth-library-nodejs/issues/313
|
||||
var client = this.googleAuthClient.fromJSON({
|
||||
type: 'jwt-pem-p12',
|
||||
client_email: config.email,
|
||||
private_key: keyFile
|
||||
});
|
||||
delete client.key;
|
||||
client.keyFile = keyFile;
|
||||
this.jwtClient = client;
|
||||
addScope(null, client);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.googleAuthClient.getApplicationDefault(addScope);
|
||||
}
|
||||
};
|
||||
|
||||
if (!this.authClientPromise) {
|
||||
this.authClientPromise = new Promise(createAuthClientPromise);
|
||||
}
|
||||
|
||||
this.authClientPromise.then((authClient) => {
|
||||
callback(null, authClient);
|
||||
// The return null is needed to avoid a spurious warning if the user is
|
||||
// using bluebird.
|
||||
// See: https://github.com/stephenplusplus/google-auto-auth/issues/28
|
||||
return null;
|
||||
}).catch(callback);
|
||||
}
|
||||
|
||||
getCredentials (callback) {
|
||||
if (this.credentials) {
|
||||
setImmediate(() => {
|
||||
callback(null, this.credentials);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.getAuthClient((err) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
this.googleAuthClient.getCredentials((err, credentials) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
this.credentials = credentials;
|
||||
|
||||
if (this.jwtClient) {
|
||||
this.jwtClient.authorize(err => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
this.credentials.private_key = this.jwtClient.key;
|
||||
|
||||
callback(null, this.credentials);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, this.credentials);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getEnvironment (callback) {
|
||||
async.parallel([
|
||||
cb => this.isAppEngine(cb),
|
||||
cb => this.isCloudFunction(cb),
|
||||
cb => this.isComputeEngine(cb),
|
||||
cb => this.isContainerEngine(cb)
|
||||
], () => {
|
||||
callback(null, this.environment);
|
||||
});
|
||||
}
|
||||
|
||||
getProjectId (callback) {
|
||||
if (this.projectId) {
|
||||
setImmediate(() => {
|
||||
callback(null, this.projectId);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.getAuthClient(err => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, this.projectId);
|
||||
});
|
||||
}
|
||||
|
||||
getToken (callback) {
|
||||
if (this.token) {
|
||||
setImmediate(callback, null, this.token);
|
||||
return;
|
||||
}
|
||||
|
||||
this.getAuthClient((err, client) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
client.getAccessToken(callback);
|
||||
});
|
||||
}
|
||||
|
||||
isAppEngine (callback) {
|
||||
setImmediate(() => {
|
||||
var env = this.environment;
|
||||
|
||||
if (typeof env.IS_APP_ENGINE === 'undefined') {
|
||||
env.IS_APP_ENGINE = !!(process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME);
|
||||
}
|
||||
|
||||
callback(null, env.IS_APP_ENGINE);
|
||||
});
|
||||
}
|
||||
|
||||
isCloudFunction (callback) {
|
||||
setImmediate(() => {
|
||||
var env = this.environment;
|
||||
|
||||
if (typeof env.IS_CLOUD_FUNCTION === 'undefined') {
|
||||
env.IS_CLOUD_FUNCTION = !!process.env.FUNCTION_NAME;
|
||||
}
|
||||
|
||||
callback(null, env.IS_CLOUD_FUNCTION);
|
||||
});
|
||||
}
|
||||
|
||||
isComputeEngine (callback) {
|
||||
var env = this.environment;
|
||||
|
||||
if (typeof env.IS_COMPUTE_ENGINE !== 'undefined') {
|
||||
setImmediate(() => {
|
||||
callback(null, env.IS_COMPUTE_ENGINE);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
request('http://metadata.google.internal', (err, res) => {
|
||||
env.IS_COMPUTE_ENGINE = !err && res.headers['metadata-flavor'] === 'Google';
|
||||
|
||||
callback(null, env.IS_COMPUTE_ENGINE);
|
||||
});
|
||||
}
|
||||
|
||||
isContainerEngine (callback) {
|
||||
var env = this.environment;
|
||||
|
||||
if (typeof env.IS_CONTAINER_ENGINE !== 'undefined') {
|
||||
setImmediate(() => {
|
||||
callback(null, env.IS_CONTAINER_ENGINE);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
gcpMetadata.instance('/attributes/cluster-name')
|
||||
.then(() => {
|
||||
env.IS_CONTAINER_ENGINE = true;
|
||||
callback(null, env.IS_CONTAINER_ENGINE);
|
||||
})
|
||||
.catch(() => {
|
||||
env.IS_CONTAINER_ENGINE = false
|
||||
callback(null, env.IS_CONTAINER_ENGINE);
|
||||
});
|
||||
}
|
||||
|
||||
sign (data, callback) {
|
||||
this.getCredentials((err, credentials) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (credentials.private_key) {
|
||||
this._signWithPrivateKey(data, callback);
|
||||
} else {
|
||||
this._signWithApi(data, callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// `this.getCredentials()` will always have been run by this time
|
||||
_signWithApi (data, callback) {
|
||||
if (!this.projectId) {
|
||||
callback(new Error('Cannot sign data without a project ID.'));
|
||||
return;
|
||||
}
|
||||
|
||||
var client_email = this.credentials.client_email;
|
||||
|
||||
if (!client_email) {
|
||||
callback(new Error('Cannot sign data without `client_email`.'));
|
||||
return;
|
||||
}
|
||||
|
||||
var idString = `projects/${this.projectId}/serviceAccounts/${client_email}`;
|
||||
|
||||
var reqOpts = {
|
||||
method: 'POST',
|
||||
uri: `https://iam.googleapis.com/v1/${idString}:signBlob`,
|
||||
json: {
|
||||
bytesToSign: Buffer.from(data).toString('base64')
|
||||
}
|
||||
};
|
||||
|
||||
this.authorizeRequest(reqOpts, (err, authorizedReqOpts) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
request(authorizedReqOpts, function (err, resp, body) {
|
||||
var response = resp.toJSON();
|
||||
|
||||
if (!err && response.statusCode < 200 || response.statusCode >= 400) {
|
||||
if (typeof response.body === 'object') {
|
||||
var apiError = response.body.error;
|
||||
err = new Error(apiError.message);
|
||||
Object.assign(err, apiError);
|
||||
} else {
|
||||
err = new Error(response.body);
|
||||
err.code = response.statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
callback(err, body && body.signature);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// `this.getCredentials()` will always have been run by this time
|
||||
_signWithPrivateKey (data, callback) {
|
||||
var sign = crypto.createSign('RSA-SHA256');
|
||||
sign.update(data);
|
||||
callback(null, sign.sign(this.credentials.private_key, 'base64'));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = config => {
|
||||
return new Auth(config);
|
||||
};
|
20
express-server/node_modules/google-auto-auth/license
generated
vendored
Normal file
20
express-server/node_modules/google-auto-auth/license
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Stephen Sawchuk
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/LICENSE
generated
vendored
Normal file
20
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Stephen Sawchuk
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
35
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/README.md
generated
vendored
Normal file
35
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/README.md
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
# gcp-metadata
|
||||
> Get the metadata from a Google Cloud Platform environment
|
||||
|
||||
[![codecov][codecov-image]][codecov-url]
|
||||
|
||||
```sh
|
||||
$ npm install --save gcp-metadata
|
||||
```
|
||||
```js
|
||||
const gcpMetadata = require('gcp-metadata');
|
||||
```
|
||||
|
||||
#### Access all metadata
|
||||
```js
|
||||
const res = await gcpMetadata.instance();
|
||||
console.log(res.data); // ... All metadata properties
|
||||
```
|
||||
|
||||
#### Access specific properties
|
||||
```js
|
||||
const res = await gcpMetadata.instance('hostname');
|
||||
console.log(res.data) // ...All metadata properties
|
||||
```
|
||||
|
||||
#### Access specific properties with query parameters
|
||||
```js
|
||||
const res = await gcpMetadata.instance({
|
||||
property: 'tags',
|
||||
params: { alt: 'text' }
|
||||
});
|
||||
console.log(res.data) // ...Tags as newline-delimited list
|
||||
```
|
||||
|
||||
[codecov-image]: https://codecov.io/gh/stephenplusplus/gcp-metadata/branch/master/graph/badge.svg
|
||||
[codecov-url]: https://codecov.io/gh/stephenplusplus/gcp-metadata
|
20
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/build/src/index.d.ts
generated
vendored
Normal file
20
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/build/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
export declare const HOST_ADDRESS = "http://metadata.google.internal";
|
||||
export declare const BASE_PATH = "/computeMetadata/v1";
|
||||
export declare const BASE_URL: string;
|
||||
export declare const HEADER_NAME = "Metadata-Flavor";
|
||||
export declare const HEADER_VALUE = "Google";
|
||||
export declare const HEADERS: Readonly<{
|
||||
[HEADER_NAME]: string;
|
||||
}>;
|
||||
export declare type Options = AxiosRequestConfig & {
|
||||
[index: string]: {} | string | undefined;
|
||||
property?: string;
|
||||
uri?: string;
|
||||
};
|
||||
export declare function instance(options?: string | Options): Promise<AxiosResponse<any>>;
|
||||
export declare function project(options?: string | Options): Promise<AxiosResponse<any>>;
|
||||
/**
|
||||
* Determine if the metadata server is currently available.
|
||||
*/
|
||||
export declare function isAvailable(): Promise<boolean>;
|
145
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/build/src/index.js
generated
vendored
Normal file
145
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/build/src/index.js
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
"use strict";
|
||||
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 axios_1 = require("axios");
|
||||
var extend = require("extend");
|
||||
var rax = require("retry-axios");
|
||||
exports.HOST_ADDRESS = 'http://metadata.google.internal';
|
||||
exports.BASE_PATH = '/computeMetadata/v1';
|
||||
exports.BASE_URL = exports.HOST_ADDRESS + exports.BASE_PATH;
|
||||
exports.HEADER_NAME = 'Metadata-Flavor';
|
||||
exports.HEADER_VALUE = 'Google';
|
||||
exports.HEADERS = Object.freeze((_a = {}, _a[exports.HEADER_NAME] = exports.HEADER_VALUE, _a));
|
||||
// Accepts an options object passed from the user to the API. In the
|
||||
// previous version of the API, it referred to a `Request` options object.
|
||||
// Now it refers to an Axios Request Config object. This is here to help
|
||||
// ensure users don't pass invalid options when they upgrade from 0.4 to 0.5.
|
||||
function validate(options) {
|
||||
var vpairs = [
|
||||
{ invalid: 'uri', expected: 'url' }, { invalid: 'json', expected: 'data' },
|
||||
{ invalid: 'qs', expected: 'params' }
|
||||
];
|
||||
for (var _i = 0, vpairs_1 = vpairs; _i < vpairs_1.length; _i++) {
|
||||
var pair = vpairs_1[_i];
|
||||
if (options[pair.invalid]) {
|
||||
var e = "'" + pair.invalid + "' is not a valid configuration option. Please use '" + pair.expected + "' instead. This library is using Axios for requests. Please see https://github.com/axios/axios to learn more about the valid request options.";
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function metadataAccessor(type, options, noResponseRetries) {
|
||||
if (noResponseRetries === void 0) { noResponseRetries = 3; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var property, ax, baseOpts, reqOpts;
|
||||
return __generator(this, function (_a) {
|
||||
options = options || {};
|
||||
if (typeof options === 'string') {
|
||||
options = { property: options };
|
||||
}
|
||||
property = '';
|
||||
if (typeof options === 'object' && options.property) {
|
||||
property = '/' + options.property;
|
||||
}
|
||||
validate(options);
|
||||
ax = axios_1.default.create();
|
||||
rax.attach(ax);
|
||||
baseOpts = {
|
||||
url: exports.BASE_URL + "/" + type + property,
|
||||
headers: Object.assign({}, exports.HEADERS),
|
||||
raxConfig: { noResponseRetries: noResponseRetries, instance: ax }
|
||||
};
|
||||
reqOpts = extend(true, baseOpts, options);
|
||||
delete reqOpts.property;
|
||||
return [2 /*return*/, ax.request(reqOpts)
|
||||
.then(function (res) {
|
||||
// NOTE: node.js converts all incoming headers to lower case.
|
||||
if (res.headers[exports.HEADER_NAME.toLowerCase()] !== exports.HEADER_VALUE) {
|
||||
throw new Error("Invalid response from metadata service: incorrect " + exports.HEADER_NAME + " header.");
|
||||
}
|
||||
else if (!res.data) {
|
||||
throw new Error('Invalid response from the metadata service');
|
||||
}
|
||||
return res;
|
||||
})
|
||||
.catch(function (err) {
|
||||
if (err.response && err.response.status !== 200) {
|
||||
err.message = 'Unsuccessful response status code. ' + err.message;
|
||||
}
|
||||
throw err;
|
||||
})];
|
||||
});
|
||||
});
|
||||
}
|
||||
function instance(options) {
|
||||
return metadataAccessor('instance', options);
|
||||
}
|
||||
exports.instance = instance;
|
||||
function project(options) {
|
||||
return metadataAccessor('project', options);
|
||||
}
|
||||
exports.project = project;
|
||||
/**
|
||||
* Determine if the metadata server is currently available.
|
||||
*/
|
||||
function isAvailable() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
// Attempt to read instance metadata. As configured, this will
|
||||
// retry 3 times if there is a valid response, and fail fast
|
||||
// if there is an ETIMEDOUT or ENOTFOUND error.
|
||||
return [4 /*yield*/, metadataAccessor('instance', undefined, 0)];
|
||||
case 1:
|
||||
// Attempt to read instance metadata. As configured, this will
|
||||
// retry 3 times if there is a valid response, and fail fast
|
||||
// if there is an ETIMEDOUT or ENOTFOUND error.
|
||||
_a.sent();
|
||||
return [2 /*return*/, true];
|
||||
case 2:
|
||||
err_1 = _a.sent();
|
||||
return [2 /*return*/, false];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.isAvailable = isAvailable;
|
||||
var _a;
|
||||
//# sourceMappingURL=index.js.map
|
1
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/build/src/index.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/build/src/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA2E;AAC3E,+BAAiC;AACjC,iCAAmC;AAEtB,QAAA,YAAY,GAAG,iCAAiC,CAAC;AACjD,QAAA,SAAS,GAAG,qBAAqB,CAAC;AAClC,QAAA,QAAQ,GAAG,oBAAY,GAAG,iBAAS,CAAC;AACpC,QAAA,WAAW,GAAG,iBAAiB,CAAC;AAChC,QAAA,YAAY,GAAG,QAAQ,CAAC;AACxB,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,WAAE,GAAC,mBAAW,IAAG,oBAAY,MAAE,CAAC;AAKpE,qEAAqE;AACrE,0EAA0E;AAC1E,yEAAyE;AACzE,6EAA6E;AAC7E,kBAAkB,OAAgB;IAChC,IAAM,MAAM,GAAG;QACb,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAC,EAAE,EAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAC;QACtE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAC;KACpC,CAAC;IACF,GAAG,CAAC,CAAe,UAAM,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM;QAApB,IAAM,IAAI,eAAA;QACb,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAM,CAAC,GAAG,MACN,IAAI,CAAC,OAAO,2DACZ,IAAI,CAAC,QAAQ,kJAA+I,CAAC;YACjK,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;KACF;AACH,CAAC;AAED,0BACI,IAAY,EAAE,OAAwB,EAAE,iBAAqB;IAArB,kCAAA,EAAA,qBAAqB;;;;YAC/D,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;YACxB,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC;gBAChC,OAAO,GAAG,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC;YAChC,CAAC;YACG,QAAQ,GAAG,EAAE,CAAC;YAClB,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACpD,QAAQ,GAAG,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC;YACpC,CAAC;YACD,QAAQ,CAAC,OAAO,CAAC,CAAC;YACZ,EAAE,GAAG,eAAK,CAAC,MAAM,EAAE,CAAC;YAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACT,QAAQ,GAAG;gBACf,GAAG,EAAK,gBAAQ,SAAI,IAAI,GAAG,QAAU;gBACrC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAO,CAAC;gBACnC,SAAS,EAAE,EAAC,iBAAiB,mBAAA,EAAE,QAAQ,EAAE,EAAE,EAAC;aAC7C,CAAC;YACI,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAChD,OAAQ,OAA8B,CAAC,QAAQ,CAAC;YAChD,sBAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;qBACrB,IAAI,CAAC,UAAA,GAAG;oBACP,6DAA6D;oBAC7D,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,mBAAW,CAAC,WAAW,EAAE,CAAC,KAAK,oBAAY,CAAC,CAAC,CAAC;wBAC5D,MAAM,IAAI,KAAK,CAAC,uDACZ,mBAAW,aAAU,CAAC,CAAC;oBAC7B,CAAC;oBAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;wBACrB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;oBAChE,CAAC;oBACD,MAAM,CAAC,GAAG,CAAC;gBACb,CAAC,CAAC;qBACD,KAAK,CAAC,UAAC,GAAe;oBACrB,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC;wBAChD,GAAG,CAAC,OAAO,GAAG,qCAAqC,GAAG,GAAG,CAAC,OAAO,CAAC;oBACpE,CAAC;oBACD,MAAM,GAAG,CAAC;gBACZ,CAAC,CAAC,EAAC;;;CACR;AAED,kBAAyB,OAAwB;IAC/C,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAFD,4BAEC;AAED,iBAAwB,OAAwB;IAC9C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,0BAEC;AAED;;GAEG;AACH;;;;;;;oBAEI,8DAA8D;oBAC9D,4DAA4D;oBAC5D,+CAA+C;oBAC/C,qBAAM,gBAAgB,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,EAAA;;oBAHhD,8DAA8D;oBAC9D,4DAA4D;oBAC5D,+CAA+C;oBAC/C,SAAgD,CAAC;oBACjD,sBAAO,IAAI,EAAC;;;oBAEZ,sBAAO,KAAK,EAAC;;;;;CAEhB;AAVD,kCAUC"}
|
96
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/package.json
generated
vendored
Normal file
96
express-server/node_modules/google-auto-auth/node_modules/gcp-metadata/package.json
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
{
|
||||
"_from": "gcp-metadata@^0.6.1",
|
||||
"_id": "gcp-metadata@0.6.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-MSmczZctbz91AxCvqp9GHBoZOSbJKAICV7Ow/AIWSJZRrRchUd5NL1b2P4OfP+4m490BEUPhhARfpHdqCxuCvg==",
|
||||
"_location": "/google-auto-auth/gcp-metadata",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "gcp-metadata@^0.6.1",
|
||||
"name": "gcp-metadata",
|
||||
"escapedName": "gcp-metadata",
|
||||
"rawSpec": "^0.6.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.6.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/google-auto-auth",
|
||||
"/google-auto-auth/google-auth-library"
|
||||
],
|
||||
"_resolved": "http://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.6.3.tgz",
|
||||
"_shasum": "4550c08859c528b370459bd77a7187ea0bdbc4ab",
|
||||
"_spec": "gcp-metadata@^0.6.1",
|
||||
"_where": "D:\\Desktop\\Git\\Firebase\\SmartShopperFirebase\\node_modules\\google-auto-auth",
|
||||
"author": {
|
||||
"name": "Stephen Sawchuk"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stephenplusplus/gcp-metadata/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"extend": "^3.0.1",
|
||||
"retry-axios": "0.3.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Get the metadata from a Google Cloud Platform environment",
|
||||
"devDependencies": {
|
||||
"@types/extend": "^3.0.0",
|
||||
"@types/ncp": "^2.0.1",
|
||||
"@types/nock": "^9.1.2",
|
||||
"@types/node": "^8.0.31",
|
||||
"@types/pify": "^3.0.0",
|
||||
"@types/tmp": "0.0.33",
|
||||
"ava": "^0.25.0",
|
||||
"codecov": "^3.0.0",
|
||||
"gts": "^0.5.1",
|
||||
"ncp": "^2.0.0",
|
||||
"nock": "^9.1.6",
|
||||
"nyc": "^11.4.1",
|
||||
"pify": "^3.0.0",
|
||||
"tmp": "0.0.33",
|
||||
"typescript": "^2.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"build/src",
|
||||
"package.json"
|
||||
],
|
||||
"homepage": "https://github.com/stephenplusplus/gcp-metadata#readme",
|
||||
"keywords": [
|
||||
"google cloud platform",
|
||||
"google cloud",
|
||||
"google",
|
||||
"app engine",
|
||||
"compute engine",
|
||||
"metadata server",
|
||||
"metadata"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./build/src/index.js",
|
||||
"name": "gcp-metadata",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/stephenplusplus/gcp-metadata.git"
|
||||
},
|
||||
"scripts": {
|
||||
"check": "gts check",
|
||||
"clean": "gts clean",
|
||||
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
|
||||
"compile": "tsc -p .",
|
||||
"fix": "gts fix",
|
||||
"posttest": "npm run check",
|
||||
"prepare": "npm run compile",
|
||||
"pretest": "npm run compile",
|
||||
"test": "nyc ava build/test"
|
||||
},
|
||||
"types": "./build/src/index.d.ts",
|
||||
"version": "0.6.3"
|
||||
}
|
202
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/LICENSE
generated
vendored
Normal file
202
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2013 Google Inc.
|
||||
|
||||
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.
|
416
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/README.md
generated
vendored
Normal file
416
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/README.md
generated
vendored
Normal file
@ -0,0 +1,416 @@
|
||||
<img src="https://avatars0.githubusercontent.com/u/1342004?v=3&s=96" alt="Google Inc. logo" title="Google" align="right" height="96" width="96"/>
|
||||
|
||||
# Google Auth Library
|
||||
|
||||
[![Greenkeeper badge][greenkeeperimg]][greenkeeper]
|
||||
[![npm version][npmimg]][npm]
|
||||
[![CircleCI][circle-image]][circle-url]
|
||||
[![codecov][codecov-image]][codecov-url]
|
||||
[![Dependencies][david-dm-img]][david-dm]
|
||||
[![Known Vulnerabilities][snyk-image]][snyk-url]
|
||||
|
||||
This is Google's officially supported [node.js][node] client library for using OAuth 2.0 authorization and authentication with Google APIs.
|
||||
|
||||
## Installation
|
||||
This library is distributed on `npm`. To add it as a dependency, run the following command:
|
||||
|
||||
``` sh
|
||||
$ npm install google-auth-library
|
||||
```
|
||||
|
||||
## Upgrading to 1.x
|
||||
The `1.x` release includes a variety of bug fixes, new features, and breaking changes. Please take care, and see [the release notes](https://github.com/google/google-auth-library-nodejs/releases/tag/v1.0.0) for a list of breaking changes, and the upgrade guide.
|
||||
|
||||
## Ways to authenticate
|
||||
This library provides a variety of ways to authenticate to your Google services.
|
||||
- [Application Default Credentials](#choosing-the-correct-credential-type-automatically) - Use Application Default Credentials when you use a single identity for all users in your application. Especially useful for applications running on Google Cloud.
|
||||
- [OAuth 2](#oauth2) - Use OAuth2 when you need to perform actions on behalf of the end user.
|
||||
- [JSON Web Tokens](#json-web-tokens) - Use JWT when you are using a single identity for all users. Especially useful for server->server or server->API communication.
|
||||
- [Google Compute](#compute) - Directly use a service account on Google Cloud Platform. Useful for server->server or server->API communication.
|
||||
|
||||
## Application Default Credentials
|
||||
This library provides an implementation of [Application Default Credentials][] for Node.js. The [Application Default Credentials][] provide a simple way to get authorization credentials for use in calling Google APIs.
|
||||
|
||||
They are best suited for cases when the call needs to have the same identity and authorization level for the application independent of the user. This is the recommended approach to authorize calls to Cloud APIs, particularly when you're building an application that uses Google Cloud Platform.
|
||||
|
||||
#### Download your Service Account Credentials JSON file
|
||||
|
||||
To use `Application Default Credentials`, You first need to download a set of JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in the [Google Developers Console][devconsole] and select **Service account** from the **Add credentials** dropdown.
|
||||
|
||||
> This file is your *only copy* of these credentials. It should never be
|
||||
> committed with your source code, and should be stored securely.
|
||||
|
||||
Once downloaded, store the path to this file in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
|
||||
|
||||
#### Enable the API you want to use
|
||||
|
||||
Before making your API call, you must be sure the API you're calling has been enabled. Go to **APIs & Auth** > **APIs** in the [Google Developers Console][devconsole] and enable the APIs you'd like to call. For the example below, you must enable the `DNS API`.
|
||||
|
||||
|
||||
#### Choosing the correct credential type automatically
|
||||
|
||||
Rather than manually creating an OAuth2 client, JWT client, or Compute client, the auth library can create the correct credential type for you, depending upon the environment your code is running under.
|
||||
|
||||
For example, a JWT auth client will be created when your code is running on your local developer machine, and a Compute client will be created when the same code is running on Google Cloud Platform. If you need a specific set of scopes, you can pass those in the form of a string or an array into the `auth.getClient` method.
|
||||
|
||||
The code below shows how to retrieve a default credential type, depending upon the runtime environment.
|
||||
|
||||
```js
|
||||
const {auth} = require('google-auth-library');
|
||||
|
||||
/**
|
||||
* Acquire a client, and make a request to an API that's enabled by default.
|
||||
*/
|
||||
async function main() {
|
||||
const client = await auth.getClient({
|
||||
scopes: 'https://www.googleapis.com/auth/cloud-platform'
|
||||
});
|
||||
const projectId = await auth.getDefaultProjectId();
|
||||
const url = `https://www.googleapis.com/dns/v1/projects/${projectId}`;
|
||||
const res = await client.request({ url });
|
||||
console.log(res.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of specifying the type of client you'd like to use (JWT, OAuth2, etc)
|
||||
* this library will automatically choose the right client based on the environment.
|
||||
*/
|
||||
async function getADC() {
|
||||
// Acquire a client and the projectId based on the environment. This method looks
|
||||
// for the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS environment variables.
|
||||
const res = await auth.getApplicationDefault();
|
||||
let client = res.credential;
|
||||
|
||||
// The createScopedRequired method returns true when running on GAE or a local developer
|
||||
// machine. In that case, the desired scopes must be passed in manually. When the code is
|
||||
// running in GCE or a Managed VM, the scopes are pulled from the GCE metadata server.
|
||||
// See https://cloud.google.com/compute/docs/authentication for more information.
|
||||
if (client.createScopedRequired && client.createScopedRequired()) {
|
||||
// Scopes can be specified either as an array or as a single, space-delimited string.
|
||||
const scopes = ['https://www.googleapis.com/auth/cloud-platform'];
|
||||
client = client.createScoped(scopes);
|
||||
}
|
||||
return {
|
||||
client: client,
|
||||
projectId: res.projectId
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
```
|
||||
|
||||
## OAuth2
|
||||
|
||||
This library comes with an [OAuth2][oauth] client that allows you to retrieve an access token and refreshes the token and retry the request seamlessly if you also provide an `expiry_date` and the token is expired. The basics of Google's OAuth2 implementation is explained on [Google Authorization and Authentication documentation][authdocs].
|
||||
|
||||
In the following examples, you may need a `CLIENT_ID`, `CLIENT_SECRET` and `REDIRECT_URL`. You can find these pieces of information by going to the [Developer Console][devconsole], clicking your project > APIs & auth > credentials.
|
||||
|
||||
For more information about OAuth2 and how it works, [see here][oauth].
|
||||
|
||||
#### A complete OAuth2 example
|
||||
|
||||
Let's take a look at a complete example.
|
||||
|
||||
``` js
|
||||
const {OAuth2Client} = require('google-auth-library');
|
||||
const http = require('http');
|
||||
const url = require('url');
|
||||
const querystring = require('querystring');
|
||||
const opn = require('opn');
|
||||
|
||||
// Download your OAuth2 configuration from the Google
|
||||
const keys = require('./keys.json');
|
||||
|
||||
/**
|
||||
* Start by acquiring a pre-authenticated oAuth2 client.
|
||||
*/
|
||||
async function main() {
|
||||
try {
|
||||
const oAuth2Client = await getAuthenticatedClient();
|
||||
// Make a simple request to the Google Plus API using our pre-authenticated client. The `request()` method
|
||||
// takes an AxiosRequestConfig object. Visit https://github.com/axios/axios#request-config.
|
||||
const url = 'https://www.googleapis.com/plus/v1/people?query=pizza';
|
||||
const res = await oAuth2Client.request({url})
|
||||
console.log(res.data);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
process.exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new OAuth2Client, and go through the OAuth2 content
|
||||
* workflow. Return the full client to the callback.
|
||||
*/
|
||||
function getAuthenticatedClient() {
|
||||
return new Promise((resolve, reject) => {
|
||||
// create an oAuth client to authorize the API call. Secrets are kept in a `keys.json` file,
|
||||
// which should be downloaded from the Google Developers Console.
|
||||
const oAuth2Client = new OAuth2Client(
|
||||
keys.web.client_id,
|
||||
keys.web.client_secret,
|
||||
keys.web.redirect_uris[0]
|
||||
);
|
||||
|
||||
// Generate the url that will be used for the consent dialog.
|
||||
const authorizeUrl = oAuth2Client.generateAuthUrl({
|
||||
access_type: 'offline',
|
||||
scope: 'https://www.googleapis.com/auth/plus.me'
|
||||
});
|
||||
|
||||
// Open an http server to accept the oauth callback. In this simple example, the
|
||||
// only request to our webserver is to /oauth2callback?code=<code>
|
||||
const server = http.createServer(async (req, res) => {
|
||||
if (req.url.indexOf('/oauth2callback') > -1) {
|
||||
// acquire the code from the querystring, and close the web server.
|
||||
const qs = querystring.parse(url.parse(req.url).query);
|
||||
console.log(`Code is ${qs.code}`);
|
||||
res.end('Authentication successful! Please return to the console.');
|
||||
server.close();
|
||||
|
||||
// Now that we have the code, use that to acquire tokens.
|
||||
const r = await oAuth2Client.getToken(qs.code)
|
||||
// Make sure to set the credentials on the OAuth2 client.
|
||||
oAuth2Client.setCredentials(r.tokens);
|
||||
console.info('Tokens acquired.');
|
||||
resolve(oAuth2Client);
|
||||
}
|
||||
}).listen(3000, () => {
|
||||
// open the browser to the authorize url to start the workflow
|
||||
opn(authorizeUrl);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
#### Handling token events
|
||||
This library will automatically obtain an `access_token`, and automatically refresh the `access_token` if a `refresh_token` is present. The `refresh_token` is only returned on the [first authorization]((https://github.com/google/google-api-nodejs-client/issues/750#issuecomment-304521450), so if you want to make sure you store it safely. An easy way to make sure you always store the most recent tokens is to use the `tokens` event:
|
||||
|
||||
```js
|
||||
const client = await auth.getClient();
|
||||
|
||||
client.on('tokens', (tokens) => {
|
||||
if (tokens.refresh_token) {
|
||||
// store the refresh_token in my database!
|
||||
console.log(tokens.refresh_token);
|
||||
}
|
||||
console.log(tokens.access_token);
|
||||
});
|
||||
|
||||
const url = `https://www.googleapis.com/dns/v1/projects/${projectId}`;
|
||||
const res = await client.request({ url });
|
||||
// The `tokens` event would now be raised if this was the first request
|
||||
```
|
||||
|
||||
#### Retrieve access token
|
||||
With the code returned, you can ask for an access token as shown below:
|
||||
|
||||
``` js
|
||||
const tokens = await oauth2Client.getToken(code);
|
||||
// Now tokens contains an access_token and an optional refresh_token. Save them.
|
||||
oauth2Client.setCredentials(tokens);
|
||||
```
|
||||
|
||||
#### Manually refreshing access token
|
||||
If you need to manually refresh the `access_token` associated with your OAuth2 client, ensure the call to `generateAuthUrl` sets the `access_type` to `offline`. The refresh token will only be returned for the first authorization by the user. To force consent, set the `prompt` property to `consent`:
|
||||
|
||||
```js
|
||||
// Generate the url that will be used for the consent dialog.
|
||||
const authorizeUrl = oAuth2Client.generateAuthUrl({
|
||||
// To get a refresh token, you MUST set access_type to `offline`.
|
||||
access_type: 'offline',
|
||||
// set the appropriate scopes
|
||||
scope: 'https://www.googleapis.com/auth/plus.me',
|
||||
// A refresh token is only returned the first time the user
|
||||
// consents to providing access. For illustration purposes,
|
||||
// setting the prompt to 'consent' will force this consent
|
||||
// every time, forcing a refresh_token to be returned.
|
||||
prompt: 'consent'
|
||||
});
|
||||
```
|
||||
|
||||
If a refresh_token is set again on `OAuth2Client.credentials.refresh_token`, you can can `refreshAccessToken()`:
|
||||
|
||||
``` js
|
||||
const tokens = await oauth2Client.refreshAccessToken();
|
||||
// your access_token is now refreshed and stored in oauth2Client
|
||||
// store these new tokens in a safe place (e.g. database)
|
||||
```
|
||||
|
||||
#### Checking `access_token` information
|
||||
After obtaining and storing an `access_token`, at a later time you may want to go check the expiration date,
|
||||
original scopes, or audience for the token. To get the token info, you can use the `getTokenInfo` method:
|
||||
|
||||
```js
|
||||
// after acquiring an oAuth2Client...
|
||||
const tokenInfo = await oAuth2client.getTokenInfo('my-access-token');
|
||||
|
||||
// take a look at the scopes originally provisioned for the access token
|
||||
console.log(tokenInfo.scopes);
|
||||
```
|
||||
|
||||
This method will throw if the token is invalid.
|
||||
|
||||
#### OAuth2 with Installed Apps (Electron)
|
||||
If you're authenticating with OAuth2 from an installed application (like Electron), you may not want to embed your `client_secret` inside of the application sources. To work around this restriction, you can choose the `iOS` application type when creating your OAuth2 credentials in the [Google Developers console][devconsole]:
|
||||
|
||||
![application type][apptype]
|
||||
|
||||
If using the `iOS` type, when creating the OAuth2 client you won't need to pass a `client_secret` into the constructor:
|
||||
```js
|
||||
const oAuth2Client = new OAuth2Client({
|
||||
clientId: <your_client_id>,
|
||||
redirectUri: <your_redirect_uri>
|
||||
});
|
||||
```
|
||||
|
||||
## JSON Web Tokens
|
||||
The Google Developers Console provides a `.json` file that you can use to configure a JWT auth client and authenticate your requests, for example when using a service account.
|
||||
|
||||
``` js
|
||||
const {JWT} = require('google-auth-library');
|
||||
const keys = require('./jwt.keys.json');
|
||||
|
||||
async function main() {
|
||||
const client = new JWT(
|
||||
keys.client_email,
|
||||
null,
|
||||
keys.private_key,
|
||||
['https://www.googleapis.com/auth/cloud-platform'],
|
||||
);
|
||||
await client.authorize();
|
||||
const url = `https://www.googleapis.com/dns/v1/projects/${keys.project_id}`;
|
||||
const res = await client.request({url});
|
||||
console.log(res.data);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
||||
```
|
||||
|
||||
The parameters for the JWT auth client including how to use it with a `.pem` file are explained in [examples/jwt.js](examples/jwt.js).
|
||||
|
||||
#### Loading credentials from environment variables
|
||||
Instead of loading credentials from a key file, you can also provide them using an environment variable and the `GoogleAuth.fromJSON()` method. This is particularly convenient for systems that deploy directly from source control (Heroku, App Engine, etc).
|
||||
|
||||
Start by exporting your credentials:
|
||||
|
||||
```
|
||||
$ export CREDS='{
|
||||
"type": "service_account",
|
||||
"project_id": "your-project-id",
|
||||
"private_key_id": "your-private-key-id",
|
||||
"private_key": "your-private-key",
|
||||
"client_email": "your-client-email",
|
||||
"client_id": "your-client-id",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://accounts.google.com/o/oauth2/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "your-cert-url"
|
||||
}'
|
||||
```
|
||||
Now you can create a new client from the credentials:
|
||||
|
||||
```js
|
||||
const {auth} = require('google-auth-library');
|
||||
|
||||
// load the environment variable with our keys
|
||||
const keysEnvVar = process.env['CREDS'];
|
||||
if (!keysEnvVar) {
|
||||
throw new Error('The $CREDS environment variable was not found!');
|
||||
}
|
||||
const keys = JSON.parse(keysEnvVar);
|
||||
|
||||
async function main() {
|
||||
// load the JWT or UserRefreshClient from the keys
|
||||
const client = auth.fromJSON(keys);
|
||||
client.scopes = ['https://www.googleapis.com/auth/cloud-platform'];
|
||||
await client.authorize();
|
||||
const url = `https://www.googleapis.com/dns/v1/projects/${keys.project_id}`;
|
||||
const res = await client.request({url});
|
||||
console.log(res.data);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
```
|
||||
#### Using a Proxy
|
||||
You can use the following environment variables to proxy HTTP and HTTPS requests:
|
||||
|
||||
- `HTTP_PROXY` / `http_proxy`
|
||||
- `HTTPS_PROXY` / `https_proxy`
|
||||
|
||||
When HTTP_PROXY / http_proxy are set, they will be used to proxy non-SSL requests that do not have an explicit proxy configuration option present. Similarly, HTTPS_PROXY / https_proxy will be respected for SSL requests that do not have an explicit proxy configuration option. It is valid to define a proxy in one of the environment variables, but then override it for a specific request, using the proxy configuration option.
|
||||
|
||||
|
||||
## Compute
|
||||
If your application is running on Google Cloud Platform, you can authenticate using the default service account or by specifying a specific service account.
|
||||
|
||||
**Note**: In most cases, you will want to use [Application Default Credentials](choosing-the-correct-credential-type-automatically). Direct use of the `Compute` class is for very specific scenarios.
|
||||
|
||||
``` js
|
||||
const {Compute} = require('google-auth-library');
|
||||
|
||||
async function main() {
|
||||
const client = new Compute({
|
||||
// Specifying the service account email is optional.
|
||||
serviceAccountEmail: 'my-service-account@example.com'
|
||||
});
|
||||
const projectId = 'your-project-id';
|
||||
const url = `https://www.googleapis.com/dns/v1/projects/${project_id}`;
|
||||
const res = await client.request({url});
|
||||
console.log(res.data);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
||||
```
|
||||
|
||||
## Questions/problems?
|
||||
|
||||
* Ask your development related questions on [Stack Overflow][stackoverflow].
|
||||
* If you've found an bug/issue, please [file it on GitHub][bugs].
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING][contributing].
|
||||
|
||||
## License
|
||||
|
||||
This library is licensed under Apache 2.0. Full license text is available in [LICENSE][copying].
|
||||
|
||||
[apiexplorer]: https://developers.google.com/apis-explorer
|
||||
[Application Default Credentials]: https://developers.google.com/identity/protocols/application-default-credentials#callingnode
|
||||
[apptype]: https://user-images.githubusercontent.com/534619/36553844-3f9a863c-17b2-11e8-904a-29f6cd5f807a.png
|
||||
[authdocs]: https://developers.google.com/accounts/docs/OAuth2Login
|
||||
[axios]: https://github.com/axios/axios
|
||||
[axiosOpts]: https://github.com/axios/axios#request-config
|
||||
[bugs]: https://github.com/google/google-auth-library-nodejs/issues
|
||||
[circle-image]: https://circleci.com/gh/google/google-auth-library-nodejs.svg?style=svg
|
||||
[circle-url]: https://circleci.com/gh/google/google-auth-library-nodejs
|
||||
[codecov-image]: https://codecov.io/gh/google/google-auth-library-nodejs/branch/master/graph/badge.svg
|
||||
[codecov-url]: https://codecov.io/gh/google/google-auth-library-nodejs
|
||||
[contributing]: https://github.com/google/google-auth-library-nodejs/blob/master/.github/CONTRIBUTING.md
|
||||
[copying]: https://github.com/google/google-auth-library-nodejs/tree/master/LICENSE
|
||||
[david-dm-img]: https://david-dm.org/google/google-auth-library-nodejs/status.svg
|
||||
[david-dm]: https://david-dm.org/google/google-auth-library-nodejs
|
||||
[greenkeeperimg]: https://badges.greenkeeper.io/google/google-auth-library-nodejs.svg
|
||||
[greenkeeper]: https://greenkeeper.io/
|
||||
[node]: http://nodejs.org/
|
||||
[npmimg]: https://img.shields.io/npm/v/google-auth-library.svg
|
||||
[npm]: https://www.npmjs.org/package/google-auth-library
|
||||
[oauth]: https://developers.google.com/identity/protocols/OAuth2
|
||||
[snyk-image]: https://snyk.io/test/github/google/google-auth-library-nodejs/badge.svg
|
||||
[snyk-url]: https://snyk.io/test/github/google/google-auth-library-nodejs
|
||||
[stability]: http://nodejs.org/api/stream.html#stream_stream
|
||||
[stackoverflow]: http://stackoverflow.com/questions/tagged/google-auth-library-nodejs
|
||||
[stream]: http://nodejs.org/api/stream.html#stream_class_stream_readable
|
||||
[urlshort]: https://developers.google.com/url-shortener/
|
||||
[usingkeys]: https://developers.google.com/console/help/#UsingKeys
|
||||
[devconsole]: https://console.developer.google.com
|
||||
[oauth]: https://developers.google.com/accounts/docs/OAuth2
|
||||
[options]: https://github.com/google/google-auth-library-nodejs/tree/master#options
|
||||
[gcloud]: https://github.com/GoogleCloudPlatform/gcloud-node
|
||||
[cloudplatform]: https://developers.google.com/cloud/
|
||||
|
35
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/authclient.d.ts
generated
vendored
Normal file
35
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/authclient.d.ts
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { AxiosPromise, AxiosRequestConfig } from 'axios';
|
||||
import { EventEmitter } from 'events';
|
||||
import { DefaultTransporter } from '../transporters';
|
||||
import { Credentials } from './credentials';
|
||||
export declare interface AuthClient {
|
||||
on(event: 'tokens', listener: (tokens: Credentials) => void): this;
|
||||
}
|
||||
export declare abstract class AuthClient extends EventEmitter {
|
||||
transporter: DefaultTransporter;
|
||||
credentials: Credentials;
|
||||
/**
|
||||
* Provides an alternative Axios request implementation with auth credentials
|
||||
*/
|
||||
abstract request<T>(opts: AxiosRequestConfig): AxiosPromise<T>;
|
||||
/**
|
||||
* Sets the auth credentials.
|
||||
*/
|
||||
setCredentials(credentials: Credentials): void;
|
||||
}
|
47
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/authclient.js
generated
vendored
Normal file
47
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/authclient.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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"}
|
46
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/computeclient.d.ts
generated
vendored
Normal file
46
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/computeclient.d.ts
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
import { AxiosPromise, AxiosRequestConfig } from 'axios';
|
||||
import { GetTokenResponse, OAuth2Client, RefreshOptions } from './oauth2client';
|
||||
export interface ComputeOptions extends RefreshOptions {
|
||||
/**
|
||||
* The service account email to use, or 'default'. A Compute Engine instance
|
||||
* may have multiple service accounts.
|
||||
*/
|
||||
serviceAccountEmail?: string;
|
||||
}
|
||||
export declare class Compute extends OAuth2Client {
|
||||
private serviceAccountEmail;
|
||||
/**
|
||||
* Google Compute Engine service account credentials.
|
||||
*
|
||||
* Retrieve access token from the metadata server.
|
||||
* See: https://developers.google.com/compute/docs/authentication
|
||||
*/
|
||||
constructor(options?: ComputeOptions);
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createdScoped before use.
|
||||
* @return Boolean indicating if scope is required.
|
||||
*/
|
||||
createScopedRequired(): boolean;
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refreshToken Unused parameter
|
||||
*/
|
||||
protected refreshTokenNoCache(refreshToken?: string | null): Promise<GetTokenResponse>;
|
||||
protected requestAsync<T>(opts: AxiosRequestConfig, retry?: boolean): AxiosPromise<T>;
|
||||
}
|
187
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/computeclient.js
generated
vendored
Normal file
187
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/computeclient.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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;;;;;OAKG;IACH,iBAAY,OAA4B;QAA5B,wBAAA,EAAA,YAA4B;QAAxC,YACE,kBAAM,OAAO,CAAC,SAKf;QAJC,mEAAmE;QACnE,+CAA+C;QAC/C,KAAI,CAAC,WAAW,GAAG,EAAC,WAAW,EAAE,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAC,CAAC;QAC1E,KAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,SAAS,CAAC;;IACtE,CAAC;IAED;;;;OAIG;IACH,sCAAoB,GAApB;QACE,oEAAoE;QACpE,uEAAuE;QACvE,SAAS;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACa,qCAAmB,GAAnC,UAAoC,YACI;;;;;;wBAChC,GAAG,GAAG,IAAI,CAAC,QAAQ;4BACrB,KAAG,WAAW,CAAC,YAAY,GACf,WAAW,CAAC,SAAS,mCACrB,IAAI,CAAC,mBAAmB,WAAQ,CAAC;;;;wBAMzC,qBAAM,EAAE,CAAC,OAAO,CAAoB;gCACxC,GAAG,KAAA;gCACH,OAAO,YAAG,GAAC,WAAW,CAAC,WAAW,IAAG,QAAQ,KAAC;gCAC9C,SAAS,EAAE,EAAC,iBAAiB,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAC;6BACzC,CAAC,EAAA;;wBANnB,wEAAwE;wBACxE,gEAAgE;wBAChE,GAAG,GAAG,SAIa,CAAC;;;;wBAEpB,GAAC,CAAC,OAAO,GAAG,iCAAiC,CAAC;wBAC9C,MAAM,GAAC,CAAC;;wBAEJ,MAAM,GAAG,GAAG,CAAC,IAAmB,CAAC;wBACvC,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE;4BACnC,MAAM,CAAC,WAAW;gCACd,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;4BAC5D,OAAQ,MAA4B,CAAC,UAAU,CAAC;yBACjD;wBACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;wBAC5B,sBAAO,EAAC,MAAM,QAAA,EAAE,GAAG,KAAA,EAAC,EAAC;;;;KACtB;IAGS,8BAAY,GAAtB,UAA0B,IAAwB,EAAE,KAAa;QAAb,sBAAA,EAAA,aAAa;QAE/D,OAAO,iBAAM,YAAY,YAAI,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC;YAC/C,IAAM,GAAG,GAAI,CAAgB,CAAC,QAAQ,CAAC;YACvC,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE;gBACrB,IAAI,cAAc,GAAG,IAAI,CAAC;gBAC1B,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;oBACtB,cAAc;wBACV,wEAAwE;4BACxE,yFAAyF;4BACzF,wEAAwE,CAAC;iBAC9E;qBAAM,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;oBAC7B,cAAc;wBACV,uEAAuE;4BACvE,yFAAyF;4BACzF,gEAAgE,CAAC;iBACtE;gBACD,IAAI,cAAc,EAAE;oBAClB,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE;wBAC5B,cAAc,IAAI,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC;qBACnC;oBACD,IAAI,CAAC,EAAE;wBACL,CAAC,CAAC,OAAO,GAAG,cAAc,CAAC;qBAC5B;yBAAM;wBACL,CAAC,GAAG,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;wBAC7B,CAA2B,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;qBAC3D;iBACF;aACF;YACD,MAAM,CAAC,CAAC;QACV,CAAC,CAAC,CAAC;IACL,CAAC;IACH,cAAC;AAAD,CAAC,AAhGD,CAA6B,2BAAY,GAgGxC;AAhGY,0BAAO"}
|
42
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/credentials.d.ts
generated
vendored
Normal file
42
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/credentials.d.ts
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export interface Credentials {
|
||||
refresh_token?: string | null;
|
||||
expiry_date?: number | null;
|
||||
access_token?: string | null;
|
||||
token_type?: string | null;
|
||||
id_token?: string | null;
|
||||
}
|
||||
export interface CredentialRequest {
|
||||
refresh_token?: string;
|
||||
access_token?: string;
|
||||
token_type?: string;
|
||||
expires_in?: number;
|
||||
id_token?: string;
|
||||
}
|
||||
export interface JWTInput {
|
||||
type?: string;
|
||||
client_email?: string;
|
||||
private_key?: string;
|
||||
project_id?: string;
|
||||
client_id?: string;
|
||||
client_secret?: string;
|
||||
refresh_token?: string;
|
||||
}
|
||||
export interface CredentialBody {
|
||||
client_email?: string;
|
||||
private_key?: string;
|
||||
}
|
18
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/credentials.js
generated
vendored
Normal file
18
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/credentials.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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"}
|
24
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/envDetect.d.ts
generated
vendored
Normal file
24
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/envDetect.d.ts
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export declare enum GCPEnv {
|
||||
APP_ENGINE = "APP_ENGINE",
|
||||
KUBERNETES_ENGINE = "KUBERNETES_ENGINE",
|
||||
CLOUD_FUNCTIONS = "CLOUD_FUNCTIONS",
|
||||
COMPUTE_ENGINE = "COMPUTE_ENGINE",
|
||||
NONE = "NONE"
|
||||
}
|
||||
export declare function clear(): void;
|
||||
export declare function getEnv(): Promise<GCPEnv>;
|
139
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/envDetect.js
generated
vendored
Normal file
139
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/envDetect.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wDAA4C;AAE5C,IAAY,MAMX;AAND,WAAY,MAAM;IAChB,mCAAyB,CAAA;IACzB,iDAAuC,CAAA;IACvC,6CAAmC,CAAA;IACnC,2CAAiC,CAAA;IACjC,uBAAa,CAAA;AACf,CAAC,EANW,MAAM,GAAN,cAAM,KAAN,cAAM,QAMjB;AAED,IAAI,GAAqB,CAAC;AAE1B;IACE,GAAG,GAAG,SAAS,CAAC;AAClB,CAAC;AAFD,sBAEC;AAED;;;;;yBACM,CAAC,GAAG,EAAJ,wBAAI;yBACF,WAAW,EAAE,EAAb,wBAAa;oBACf,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC;;;yBACf,eAAe,EAAE,EAAjB,wBAAiB;oBAC1B,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC;;wBACpB,qBAAM,kBAAkB,EAAE,EAAA;;yBAA1B,SAA0B,EAA1B,wBAA0B;oBACnC,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC;;wBACtB,qBAAM,eAAe,EAAE,EAAA;;oBAA3B,IAAI,SAAuB,EAAE;wBAClC,GAAG,GAAG,MAAM,CAAC,cAAc,CAAC;qBAC7B;yBAAM;wBACL,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC;qBACnB;;wBAEH,sBAAO,GAAG,EAAC;;;;CACZ;AAfD,wBAeC;AAED;IACE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACpE,CAAC;AAED;IACE,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AACrC,CAAC;AAED;;;;;;;oBAEI,qBAAM,WAAW,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAA;;oBAArD,SAAqD,CAAC;oBACtD,sBAAO,IAAI,EAAC;;;oBAEZ,sBAAO,KAAK,EAAC;;;;;CAEhB;AAED;;;YACE,sBAAO,WAAW,CAAC,WAAW,EAAE,EAAC;;;CAClC"}
|
264
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/googleauth.d.ts
generated
vendored
Normal file
264
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/googleauth.d.ts
generated
vendored
Normal file
@ -0,0 +1,264 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import * as fs from 'fs';
|
||||
import * as http from 'http';
|
||||
import * as stream from 'stream';
|
||||
import { DefaultTransporter, Transporter } from '../transporters';
|
||||
import { Compute } from './computeclient';
|
||||
import { CredentialBody, JWTInput } from './credentials';
|
||||
import { GCPEnv } from './envDetect';
|
||||
import { JWT } from './jwtclient';
|
||||
import { OAuth2Client, RefreshOptions } from './oauth2client';
|
||||
import { UserRefreshClient } from './refreshclient';
|
||||
export interface ProjectIdCallback {
|
||||
(err?: Error | null, projectId?: string | null): void;
|
||||
}
|
||||
export interface CredentialCallback {
|
||||
(err: Error | null, result?: UserRefreshClient | JWT): void;
|
||||
}
|
||||
export interface ADCCallback {
|
||||
(err: Error | null, credential?: OAuth2Client, projectId?: string | null): void;
|
||||
}
|
||||
export interface ADCResponse {
|
||||
credential: OAuth2Client;
|
||||
projectId: string | null;
|
||||
}
|
||||
export interface GoogleAuthOptions {
|
||||
/**
|
||||
* Path to a .json, .pem, or .p12 key file
|
||||
*/
|
||||
keyFilename?: string;
|
||||
/**
|
||||
* Path to a .json, .pem, or .p12 key file
|
||||
*/
|
||||
keyFile?: string;
|
||||
/**
|
||||
* Object containing client_email and private_key properties
|
||||
*/
|
||||
credentials?: CredentialBody;
|
||||
/**
|
||||
* Required scopes for the desired API request
|
||||
*/
|
||||
scopes?: string | string[];
|
||||
/**
|
||||
* Your project ID.
|
||||
*/
|
||||
projectId?: string;
|
||||
}
|
||||
export declare class GoogleAuth {
|
||||
transporter?: Transporter;
|
||||
getProjectId: {
|
||||
(): Promise<string>;
|
||||
(callback: ProjectIdCallback): void;
|
||||
};
|
||||
/**
|
||||
* Caches a value indicating whether the auth layer is running on Google
|
||||
* Compute Engine.
|
||||
* @private
|
||||
*/
|
||||
private checkIsGCE?;
|
||||
readonly isGCE: boolean | undefined;
|
||||
private _getDefaultProjectIdPromise?;
|
||||
private _cachedProjectId?;
|
||||
jsonContent: JWTInput | null;
|
||||
cachedCredential: JWT | UserRefreshClient | Compute | null;
|
||||
private keyFilename?;
|
||||
private scopes?;
|
||||
/**
|
||||
* Export DefaultTransporter as a static property of the class.
|
||||
*/
|
||||
static DefaultTransporter: typeof DefaultTransporter;
|
||||
constructor(opts?: GoogleAuthOptions);
|
||||
/**
|
||||
* Obtains the default project ID for the application.
|
||||
* @param callback Optional callback
|
||||
* @returns Promise that resolves with project Id (if used without callback)
|
||||
*/
|
||||
getDefaultProjectId(): Promise<string>;
|
||||
getDefaultProjectId(callback: ProjectIdCallback): void;
|
||||
private getDefaultProjectIdAsync;
|
||||
/**
|
||||
* Obtains the default service-level credentials for the application.
|
||||
* @param callback Optional callback.
|
||||
* @returns Promise that resolves with the ADCResponse (if no callback was
|
||||
* passed).
|
||||
*/
|
||||
getApplicationDefault(): Promise<ADCResponse>;
|
||||
getApplicationDefault(callback: ADCCallback): void;
|
||||
getApplicationDefault(options: RefreshOptions): Promise<ADCResponse>;
|
||||
getApplicationDefault(options: RefreshOptions, callback: ADCCallback): void;
|
||||
private getApplicationDefaultAsync;
|
||||
/**
|
||||
* Determines whether the auth layer is running on Google Compute Engine.
|
||||
* @returns A promise that resolves with the boolean.
|
||||
* @api private
|
||||
*/
|
||||
_checkIsGCE(): Promise<boolean>;
|
||||
/**
|
||||
* Attempts to load default credentials from the environment variable path..
|
||||
* @returns Promise that resolves with the OAuth2Client or null.
|
||||
* @api private
|
||||
*/
|
||||
_tryGetApplicationCredentialsFromEnvironmentVariable(options?: RefreshOptions): Promise<JWT | UserRefreshClient | null>;
|
||||
/**
|
||||
* Attempts to load default credentials from a well-known file location
|
||||
* @return Promise that resolves with the OAuth2Client or null.
|
||||
* @api private
|
||||
*/
|
||||
_tryGetApplicationCredentialsFromWellKnownFile(options?: RefreshOptions): Promise<JWT | UserRefreshClient | null>;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
_getApplicationCredentialsFromFilePath(filePath: string, options?: RefreshOptions): Promise<JWT | UserRefreshClient>;
|
||||
/**
|
||||
* Create a credentials instance using the given input options.
|
||||
* @param json The input object.
|
||||
* @returns JWT or UserRefresh Client with data
|
||||
*/
|
||||
fromJSON(json: JWTInput, options?: RefreshOptions): JWT | UserRefreshClient;
|
||||
/**
|
||||
* Create a credentials instance using the given input stream.
|
||||
* @param inputStream The input stream.
|
||||
* @param callback Optional callback.
|
||||
*/
|
||||
fromStream(inputStream: stream.Readable): Promise<JWT | UserRefreshClient>;
|
||||
fromStream(inputStream: stream.Readable, callback: CredentialCallback): void;
|
||||
fromStream(inputStream: stream.Readable, options: RefreshOptions): Promise<JWT | UserRefreshClient>;
|
||||
fromStream(inputStream: stream.Readable, options: RefreshOptions, callback: CredentialCallback): void;
|
||||
private fromStreamAsync;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
fromAPIKey(apiKey: string, options?: RefreshOptions): JWT;
|
||||
/**
|
||||
* Determines whether the current operating system is Windows.
|
||||
* @api private
|
||||
*/
|
||||
private _isWindows;
|
||||
/**
|
||||
* Creates a file stream. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
_createReadStream(filePath: string): fs.ReadStream;
|
||||
/**
|
||||
* Gets the current operating system platform. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
_osPlatform(): NodeJS.Platform;
|
||||
/**
|
||||
* Determines whether a file exists. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
_fileExists(filePath: string): boolean;
|
||||
/**
|
||||
* Joins two parts of a path. Allows mocking.
|
||||
* @api private
|
||||
*/
|
||||
_pathJoin(item1: string, item2: string): string;
|
||||
/**
|
||||
* Allows mocking of the path to a well-known file.
|
||||
* @api private
|
||||
*/
|
||||
_mockWellKnownFilePath(filePath: string): string;
|
||||
private createError;
|
||||
/**
|
||||
* Run the Google Cloud SDK command that prints the default project ID
|
||||
*/
|
||||
private getDefaultServiceProjectId;
|
||||
/**
|
||||
* Loads the project id from environment variables.
|
||||
* @api private
|
||||
*/
|
||||
private getProductionProjectId;
|
||||
/**
|
||||
* Loads the project id from the GOOGLE_APPLICATION_CREDENTIALS json file.
|
||||
* @api private
|
||||
*/
|
||||
private getFileProjectId;
|
||||
/**
|
||||
* Gets the Compute Engine project ID if it can be inferred.
|
||||
*/
|
||||
private getGCEProjectId;
|
||||
/**
|
||||
* The callback function handles a credential object that contains the
|
||||
* client_email and private_key (if exists).
|
||||
* getCredentials checks for these values from the user JSON at first.
|
||||
* If it doesn't exist, and the environment is on GCE, it gets the
|
||||
* client_email from the cloud metadata server.
|
||||
* @param callback Callback that handles the credential object that contains
|
||||
* a client_email and optional private key, or the error.
|
||||
* returned
|
||||
*/
|
||||
getCredentials(): Promise<CredentialBody>;
|
||||
getCredentials(callback: (err: Error | null, credentials?: CredentialBody) => void): void;
|
||||
private getCredentialsAsync;
|
||||
/**
|
||||
* Automatically obtain a client based on the provided configuration. If no
|
||||
* options were passed, use Application Default Credentials.
|
||||
*/
|
||||
getClient(options?: GoogleAuthOptions): Promise<Compute | JWT | UserRefreshClient>;
|
||||
/**
|
||||
* Automatically obtain application default credentials, and return
|
||||
* an access token for making requests.
|
||||
*/
|
||||
getAccessToken(): Promise<string | null | undefined>;
|
||||
/**
|
||||
* Obtain the HTTP headers that will provide authorization for a given
|
||||
* request.
|
||||
*/
|
||||
getRequestHeaders(url?: string): Promise<http.IncomingHttpHeaders>;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
authorizeRequest(opts: {
|
||||
url?: string;
|
||||
uri?: string;
|
||||
headers?: http.IncomingHttpHeaders;
|
||||
}): Promise<{
|
||||
url?: string | undefined;
|
||||
uri?: string | undefined;
|
||||
headers?: http.IncomingHttpHeaders | undefined;
|
||||
}>;
|
||||
/**
|
||||
* Automatically obtain application default credentials, and make an
|
||||
* HTTP request using the given options.
|
||||
* @param opts Axios request options for the HTTP request.
|
||||
*/
|
||||
request<T = any>(opts: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
||||
/**
|
||||
* Determine the compute environment in which the code is running.
|
||||
*/
|
||||
getEnv(): Promise<GCPEnv>;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
sign(data: string): Promise<string>;
|
||||
}
|
||||
export interface SignBlobResponse {
|
||||
signature: string;
|
||||
}
|
815
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/googleauth.js
generated
vendored
Normal file
815
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/googleauth.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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
46
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/iam.d.ts
generated
vendored
Normal file
46
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/iam.d.ts
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export interface RequestMetadata {
|
||||
'x-goog-iam-authority-selector': string;
|
||||
'x-goog-iam-authorization-token': string;
|
||||
}
|
||||
export declare class IAMAuth {
|
||||
selector: string;
|
||||
token: string;
|
||||
/**
|
||||
* IAM credentials.
|
||||
*
|
||||
* @param selector the iam authority selector
|
||||
* @param token the token
|
||||
* @constructor
|
||||
*/
|
||||
constructor(selector: string, token: string);
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createdScoped before use.
|
||||
*
|
||||
* @return always false
|
||||
*/
|
||||
createScopedRequired(): boolean;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
getRequestMetadata(unusedUri: string | null, metadataFn: (err: Error | null, metadata?: RequestMetadata) => void): void;
|
||||
}
|
58
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/iam.js
generated
vendored
Normal file
58
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/iam.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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"}
|
66
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtaccess.d.ts
generated
vendored
Normal file
66
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtaccess.d.ts
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import * as stream from 'stream';
|
||||
import { JWTInput } from './credentials';
|
||||
import { RequestMetadataResponse } from './oauth2client';
|
||||
export declare class JWTAccess {
|
||||
email?: string | null;
|
||||
key?: string | null;
|
||||
projectId?: string;
|
||||
private cache;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
constructor(email?: string | null, key?: string | null);
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createdScoped before use.
|
||||
*
|
||||
* @return always false
|
||||
*/
|
||||
createScopedRequired(): boolean;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
getRequestMetadata(authURI: string, additionalClaims?: {
|
||||
[index: string]: string;
|
||||
}): RequestMetadataResponse;
|
||||
/**
|
||||
* Create a JWTAccess credentials instance using the given input options.
|
||||
* @param json The input object.
|
||||
*/
|
||||
fromJSON(json: JWTInput): void;
|
||||
/**
|
||||
* Create a JWTAccess credentials instance using the given input stream.
|
||||
* @param inputStream The input stream.
|
||||
* @param callback Optional callback.
|
||||
*/
|
||||
fromStream(inputStream: stream.Readable): Promise<void>;
|
||||
fromStream(inputStream: stream.Readable, callback: (err?: Error) => void): void;
|
||||
private fromStreamAsync;
|
||||
}
|
136
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtaccess.js
generated
vendored
Normal file
136
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtaccess.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,wCAAoB,GAApB;QACE,iDAAiD;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;OAOG;IACH,sCAAkB,GAAlB,UACI,OAAe,EACf,gBAA4C;QAC9C,IAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,WAAW,EAAE;YACf,OAAO,WAAW,CAAC;SACpB;QACD,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACpD,IAAM,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,CAAE,wBAAwB;QAEjD,+CAA+C;QAC/C,+BAA+B;QAC/B,iCAAiC;QACjC,IAAM,aAAa,GACf,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAA,EAAE,GAAG,KAAA,EAAC,CAAC;QAE/D,oEAAoE;QACpE,yBAAyB;QACzB,IAAI,gBAAgB,EAAE;YACpB,KAAK,IAAM,KAAK,IAAI,aAAa,EAAE;gBACjC,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;oBAC3B,MAAM,IAAI,KAAK,CAAC,UACZ,KAAK,2GAAwG,CAAC,CAAC;iBACpH;aACF;SACF;QAED,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;QAE/D,uCAAuC;QACvC,IAAM,SAAS,GACX,aAAG,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,EAAC,GAAG,EAAE,OAAO,EAAC,EAAE,OAAO,SAAA,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,EAAC,CAAC,CAAC;QAClE,IAAM,GAAG,GAAG,EAAC,OAAO,EAAE,EAAC,aAAa,EAAE,YAAU,SAAW,EAAC,EAAC,CAAC;QAC9D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,4BAAQ,GAAR,UAAS,IAAc;QACrB,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CACX,0EAA0E,CAAC,CAAC;SACjF;QACD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,MAAM,IAAI,KAAK,CACX,gEAAgE,CAAC,CAAC;SACvE;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,MAAM,IAAI,KAAK,CACX,+DAA+D,CAAC,CAAC;SACtE;QACD,2DAA2D;QAC3D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;IACnC,CAAC;IAUD,8BAAU,GAAV,UAAW,WAA4B,EAAE,QAAgC;QAEvE,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,QAAQ,EAAE,EAAV,CAAU,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACzE;aAAM;YACL,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;SAC1C;IACH,CAAC;IAEO,mCAAe,GAAvB,UAAwB,WAA4B;QAApD,iBAqBC;QApBC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,IAAI,CAAC,WAAW,EAAE;gBAChB,MAAM,CAAC,IAAI,KAAK,CACZ,qEAAqE,CAAC,CAAC,CAAC;aAC7E;YACD,IAAI,CAAC,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"}
|
111
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtclient.d.ts
generated
vendored
Normal file
111
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtclient.d.ts
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { GoogleToken } from 'gtoken';
|
||||
import * as stream from 'stream';
|
||||
import { CredentialBody, Credentials, JWTInput } from './credentials';
|
||||
import { GetTokenResponse, OAuth2Client, RefreshOptions, RequestMetadataResponse } from './oauth2client';
|
||||
export interface JWTOptions extends RefreshOptions {
|
||||
email?: string;
|
||||
keyFile?: string;
|
||||
key?: string;
|
||||
scopes?: string | string[];
|
||||
subject?: string;
|
||||
additionalClaims?: {};
|
||||
}
|
||||
export declare class JWT extends OAuth2Client {
|
||||
email?: string;
|
||||
keyFile?: string;
|
||||
key?: string;
|
||||
scopes?: string | string[];
|
||||
scope?: string;
|
||||
subject?: string;
|
||||
gtoken?: GoogleToken;
|
||||
additionalClaims?: {};
|
||||
private access?;
|
||||
/**
|
||||
* JWT service account credentials.
|
||||
*
|
||||
* Retrieve access token using gtoken.
|
||||
*
|
||||
* @param email service account email address.
|
||||
* @param keyFile path to private key file.
|
||||
* @param key value of key
|
||||
* @param scopes list of requested scopes or a single scope.
|
||||
* @param subject impersonated account's email address.
|
||||
*/
|
||||
constructor(options: JWTOptions);
|
||||
constructor(email?: string, keyFile?: string, key?: string, scopes?: string | string[], subject?: string);
|
||||
/**
|
||||
* Creates a copy of the credential with the specified scopes.
|
||||
* @param scopes List of requested scopes or a single scope.
|
||||
* @return The cloned instance.
|
||||
*/
|
||||
createScoped(scopes?: string | string[]): JWT;
|
||||
/**
|
||||
* Obtains the metadata to be sent with the request.
|
||||
*
|
||||
* @param url the URI being authorized.
|
||||
*/
|
||||
protected getRequestMetadataAsync(url?: string | null): Promise<RequestMetadataResponse>;
|
||||
/**
|
||||
* Indicates whether the credential requires scopes to be created by calling
|
||||
* createScoped before use.
|
||||
* @return false if createScoped does not need to be called.
|
||||
*/
|
||||
createScopedRequired(): boolean;
|
||||
/**
|
||||
* Get the initial access token using gToken.
|
||||
* @param callback Optional callback.
|
||||
* @returns Promise that resolves with credentials
|
||||
*/
|
||||
authorize(): Promise<Credentials>;
|
||||
authorize(callback: (err: Error | null, result?: Credentials) => void): void;
|
||||
private authorizeAsync;
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refreshToken ignored
|
||||
* @private
|
||||
*/
|
||||
protected refreshTokenNoCache(refreshToken?: string | null): Promise<GetTokenResponse>;
|
||||
/**
|
||||
* Create a gToken if it doesn't already exist.
|
||||
*/
|
||||
private createGToken;
|
||||
/**
|
||||
* Create a JWT credentials instance using the given input options.
|
||||
* @param json The input object.
|
||||
*/
|
||||
fromJSON(json: JWTInput): void;
|
||||
/**
|
||||
* Create a JWT credentials instance using the given input stream.
|
||||
* @param inputStream The input stream.
|
||||
* @param callback Optional callback.
|
||||
*/
|
||||
fromStream(inputStream: stream.Readable): Promise<void>;
|
||||
fromStream(inputStream: stream.Readable, callback: (err?: Error | null) => void): void;
|
||||
private fromStreamAsync;
|
||||
/**
|
||||
* Creates a JWT credentials instance using an API Key for authentication.
|
||||
* @param apiKey The API Key in string form.
|
||||
*/
|
||||
fromAPIKey(apiKey: string): void;
|
||||
/**
|
||||
* Using the key or keyFile on the JWT client, obtain an object that contains
|
||||
* the key and the client email.
|
||||
*/
|
||||
getCredentials(): Promise<CredentialBody>;
|
||||
}
|
306
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtclient.js
generated
vendored
Normal file
306
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/jwtclient.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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
150
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/loginticket.d.ts
generated
vendored
Normal file
150
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/loginticket.d.ts
generated
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export declare class LoginTicket {
|
||||
private envelope?;
|
||||
private payload?;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
constructor(env?: string, pay?: TokenPayload);
|
||||
getEnvelope(): string | undefined;
|
||||
getPayload(): TokenPayload | undefined;
|
||||
/**
|
||||
* Create a simple class to extract user ID from an ID Token
|
||||
*
|
||||
* @return The user ID
|
||||
*/
|
||||
getUserId(): string | null;
|
||||
/**
|
||||
* Returns attributes from the login ticket. This can contain
|
||||
* various information about the user session.
|
||||
*
|
||||
* @return The envelope and payload
|
||||
*/
|
||||
getAttributes(): {
|
||||
envelope: string | undefined;
|
||||
payload: TokenPayload | undefined;
|
||||
};
|
||||
}
|
||||
export interface TokenPayload {
|
||||
/**
|
||||
* The Issuer Identifier for the Issuer of the response. Always
|
||||
* https://accounts.google.com or accounts.google.com for Google ID tokens.
|
||||
*/
|
||||
iss: string;
|
||||
/**
|
||||
* Access token hash. Provides validation that the access token is tied to the
|
||||
* identity token. If the ID token is issued with an access token in the
|
||||
* server flow, this is always included. This can be used as an alternate
|
||||
* mechanism to protect against cross-site request forgery attacks, but if you
|
||||
* follow Step 1 and Step 3 it is not necessary to verify the access token.
|
||||
*/
|
||||
at_hash?: string;
|
||||
/**
|
||||
* True if the user's e-mail address has been verified; otherwise false.
|
||||
*/
|
||||
email_verified?: boolean;
|
||||
/**
|
||||
* An identifier for the user, unique among all Google accounts and never
|
||||
* reused. A Google account can have multiple emails at different points in
|
||||
* time, but the sub value is never changed. Use sub within your application
|
||||
* as the unique-identifier key for the user.
|
||||
*/
|
||||
sub: string;
|
||||
/**
|
||||
* The client_id of the authorized presenter. This claim is only needed when
|
||||
* the party requesting the ID token is not the same as the audience of the ID
|
||||
* token. This may be the case at Google for hybrid apps where a web
|
||||
* application and Android app have a different client_id but share the same
|
||||
* project.
|
||||
*/
|
||||
azp?: string;
|
||||
/**
|
||||
* The user's email address. This may not be unique and is not suitable for
|
||||
* use as a primary key. Provided only if your scope included the string
|
||||
* "email".
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* The URL of the user's profile page. Might be provided when:
|
||||
* - The request scope included the string "profile"
|
||||
* - The ID token is returned from a token refresh
|
||||
* - When profile claims are present, you can use them to update your app's
|
||||
* user records. Note that this claim is never guaranteed to be present.
|
||||
*/
|
||||
profile?: string;
|
||||
/**
|
||||
* The URL of the user's profile picture. Might be provided when:
|
||||
* - The request scope included the string "profile"
|
||||
* - The ID token is returned from a token refresh
|
||||
* - When picture claims are present, you can use them to update your app's
|
||||
* user records. Note that this claim is never guaranteed to be present.
|
||||
*/
|
||||
picture?: string;
|
||||
/**
|
||||
* The user's full name, in a displayable form. Might be provided when:
|
||||
* - The request scope included the string "profile"
|
||||
* - The ID token is returned from a token refresh
|
||||
* - When name claims are present, you can use them to update your app's user
|
||||
* records. Note that this claim is never guaranteed to be present.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* The user's given name, in a displayable form. Might be provided when:
|
||||
* - The request scope included the string "profile"
|
||||
* - The ID token is returned from a token refresh
|
||||
* - When name claims are present, you can use them to update your app's user
|
||||
* records. Note that this claim is never guaranteed to be present.
|
||||
*/
|
||||
given_name?: string;
|
||||
/**
|
||||
* The user's family name, in a displayable form. Might be provided when:
|
||||
* - The request scope included the string "profile"
|
||||
* - The ID token is returned from a token refresh
|
||||
* - When name claims are present, you can use them to update your app's user
|
||||
* records. Note that this claim is never guaranteed to be present.
|
||||
*/
|
||||
family_name?: string;
|
||||
/**
|
||||
* Identifies the audience that this ID token is intended for. It must be one
|
||||
* of the OAuth 2.0 client IDs of your application.
|
||||
*/
|
||||
aud: string;
|
||||
/**
|
||||
* The time the ID token was issued, represented in Unix time (integer
|
||||
* seconds).
|
||||
*/
|
||||
iat: number;
|
||||
/**
|
||||
* The time the ID token expires, represented in Unix time (integer seconds).
|
||||
*/
|
||||
exp: number;
|
||||
/**
|
||||
* The value of the nonce supplied by your app in the authentication request.
|
||||
* You should enforce protection against replay attacks by ensuring it is
|
||||
* presented only once.
|
||||
*/
|
||||
nonce?: string;
|
||||
/**
|
||||
* The hosted G Suite domain of the user. Provided only if the user belongs to
|
||||
* a hosted domain.
|
||||
*/
|
||||
hd?: string;
|
||||
}
|
60
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/loginticket.js
generated
vendored
Normal file
60
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/loginticket.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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"}
|
461
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/oauth2client.d.ts
generated
vendored
Normal file
461
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/oauth2client.d.ts
generated
vendored
Normal file
@ -0,0 +1,461 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { AxiosError, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import * as http from 'http';
|
||||
import { BodyResponseCallback } from './../transporters';
|
||||
import { AuthClient } from './authclient';
|
||||
import { Credentials } from './credentials';
|
||||
import { LoginTicket } from './loginticket';
|
||||
export declare enum CodeChallengeMethod {
|
||||
Plain = "plain",
|
||||
S256 = "S256"
|
||||
}
|
||||
export interface GetTokenOptions {
|
||||
code: string;
|
||||
codeVerifier?: string;
|
||||
/**
|
||||
* The client ID for your application. The value passed into the constructor
|
||||
* will be used if not provided. Must match any client_id option passed to
|
||||
* a corresponding call to generateAuthUrl.
|
||||
*/
|
||||
client_id?: string;
|
||||
/**
|
||||
* Determines where the API server redirects the user after the user
|
||||
* completes the authorization flow. The value passed into the constructor
|
||||
* will be used if not provided. Must match any redirect_uri option passed to
|
||||
* a corresponding call to generateAuthUrl.
|
||||
*/
|
||||
redirect_uri?: string;
|
||||
}
|
||||
export interface TokenInfo {
|
||||
/**
|
||||
* The application that is the intended user of the access token.
|
||||
*/
|
||||
aud: string;
|
||||
/**
|
||||
* This value lets you correlate profile information from multiple Google
|
||||
* APIs. It is only present in the response if you included the profile scope
|
||||
* in your request in step 1. The field value is an immutable identifier for
|
||||
* the logged-in user that can be used to create and manage user sessions in
|
||||
* your application. The identifier is the same regardless of which client ID
|
||||
* is used to retrieve it. This enables multiple applications in the same
|
||||
* organization to correlate profile information.
|
||||
*/
|
||||
user_id?: string;
|
||||
/**
|
||||
* An array of scopes that the user granted access to.
|
||||
*/
|
||||
scopes: string[];
|
||||
/**
|
||||
* The datetime when the token becomes invalid.
|
||||
*/
|
||||
expiry_date: number;
|
||||
/**
|
||||
* An identifier for the user, unique among all Google accounts and never
|
||||
* reused. A Google account can have multiple emails at different points in
|
||||
* time, but the sub value is never changed. Use sub within your application
|
||||
* as the unique-identifier key for the user.
|
||||
*/
|
||||
sub?: string;
|
||||
/**
|
||||
* The client_id of the authorized presenter. This claim is only needed when
|
||||
* the party requesting the ID token is not the same as the audience of the ID
|
||||
* token. This may be the case at Google for hybrid apps where a web
|
||||
* application and Android app have a different client_id but share the same
|
||||
* project.
|
||||
*/
|
||||
azp?: string;
|
||||
/**
|
||||
* Indicates whether your application can refresh access tokens
|
||||
* when the user is not present at the browser. Valid parameter values are
|
||||
* 'online', which is the default value, and 'offline'. Set the value to
|
||||
* 'offline' if your application needs to refresh access tokens when the user
|
||||
* is not present at the browser. This value instructs the Google
|
||||
* authorization server to return a refresh token and an access token the
|
||||
* first time that your application exchanges an authorization code for
|
||||
* tokens.
|
||||
*/
|
||||
access_type?: string;
|
||||
}
|
||||
export interface TokenInfoRequest {
|
||||
aud: string;
|
||||
user_id?: string;
|
||||
scope: string;
|
||||
expires_in: number;
|
||||
azp?: string;
|
||||
sub?: string;
|
||||
exp?: number;
|
||||
access_type?: string;
|
||||
}
|
||||
export interface GenerateAuthUrlOpts {
|
||||
/**
|
||||
* Recommended. Indicates whether your application can refresh access tokens
|
||||
* when the user is not present at the browser. Valid parameter values are
|
||||
* 'online', which is the default value, and 'offline'. Set the value to
|
||||
* 'offline' if your application needs to refresh access tokens when the user
|
||||
* is not present at the browser. This value instructs the Google
|
||||
* authorization server to return a refresh token and an access token the
|
||||
* first time that your application exchanges an authorization code for
|
||||
* tokens.
|
||||
*/
|
||||
access_type?: string;
|
||||
/**
|
||||
* The 'response_type' will always be set to 'CODE'.
|
||||
*/
|
||||
response_type?: string;
|
||||
/**
|
||||
* The client ID for your application. The value passed into the constructor
|
||||
* will be used if not provided. You can find this value in the API Console.
|
||||
*/
|
||||
client_id?: string;
|
||||
/**
|
||||
* Determines where the API server redirects the user after the user
|
||||
* completes the authorization flow. The value must exactly match one of the
|
||||
* 'redirect_uri' values listed for your project in the API Console. Note that
|
||||
* the http or https scheme, case, and trailing slash ('/') must all match.
|
||||
* The value passed into the constructor will be used if not provided.
|
||||
*/
|
||||
redirect_uri?: string;
|
||||
/**
|
||||
* Required. A space-delimited list of scopes that identify the resources that
|
||||
* your application could access on the user's behalf. These values inform the
|
||||
* consent screen that Google displays to the user. Scopes enable your
|
||||
* application to only request access to the resources that it needs while
|
||||
* also enabling users to control the amount of access that they grant to your
|
||||
* application. Thus, there is an inverse relationship between the number of
|
||||
* scopes requested and the likelihood of obtaining user consent. The
|
||||
* OAuth 2.0 API Scopes document provides a full list of scopes that you might
|
||||
* use to access Google APIs. We recommend that your application request
|
||||
* access to authorization scopes in context whenever possible. By requesting
|
||||
* access to user data in context, via incremental authorization, you help
|
||||
* users to more easily understand why your application needs the access it is
|
||||
* requesting.
|
||||
*/
|
||||
scope?: string[] | string;
|
||||
/**
|
||||
* Recommended. Specifies any string value that your application uses to
|
||||
* maintain state between your authorization request and the authorization
|
||||
* server's response. The server returns the exact value that you send as a
|
||||
* name=value pair in the hash (#) fragment of the 'redirect_uri' after the
|
||||
* user consents to or denies your application's access request. You can use
|
||||
* this parameter for several purposes, such as directing the user to the
|
||||
* correct resource in your application, sending nonces, and mitigating
|
||||
* cross-site request forgery. Since your redirect_uri can be guessed, using a
|
||||
* state value can increase your assurance that an incoming connection is the
|
||||
* result of an authentication request. If you generate a random string or
|
||||
* encode the hash of a cookie or another value that captures the client's
|
||||
* state, you can validate the response to additionally ensure that the
|
||||
* request and response originated in the same browser, providing protection
|
||||
* against attacks such as cross-site request forgery. See the OpenID Connect
|
||||
* documentation for an example of how to create and confirm a state token.
|
||||
*/
|
||||
state?: string;
|
||||
/**
|
||||
* Optional. Enables applications to use incremental authorization to request
|
||||
* access to additional scopes in context. If you set this parameter's value
|
||||
* to true and the authorization request is granted, then the new access token
|
||||
* will also cover any scopes to which the user previously granted the
|
||||
* application access. See the incremental authorization section for examples.
|
||||
*/
|
||||
include_granted_scopes?: boolean;
|
||||
/**
|
||||
* Optional. If your application knows which user is trying to authenticate,
|
||||
* it can use this parameter to provide a hint to the Google Authentication
|
||||
* Server. The server uses the hint to simplify the login flow either by
|
||||
* prefilling the email field in the sign-in form or by selecting the
|
||||
* appropriate multi-login session. Set the parameter value to an email
|
||||
* address or sub identifier, which is equivalent to the user's Google ID.
|
||||
*/
|
||||
login_hint?: string;
|
||||
/**
|
||||
* Optional. A space-delimited, case-sensitive list of prompts to present the
|
||||
* user. If you don't specify this parameter, the user will be prompted only
|
||||
* the first time your app requests access. Possible values are:
|
||||
*
|
||||
* 'none' - Donot display any authentication or consent screens. Must not be
|
||||
* specified with other values.
|
||||
* 'consent' - Prompt the user for consent.
|
||||
* 'select_account' - Prompt the user to select an account.
|
||||
*/
|
||||
prompt?: string;
|
||||
/**
|
||||
* Recommended. Specifies what method was used to encode a 'code_verifier'
|
||||
* that will be used during authorization code exchange. This parameter must
|
||||
* be used with the 'code_challenge' parameter. The value of the
|
||||
* 'code_challenge_method' defaults to "plain" if not present in the request
|
||||
* that includes a 'code_challenge'. The only supported values for this
|
||||
* parameter are "S256" or "plain".
|
||||
*/
|
||||
code_challenge_method?: CodeChallengeMethod;
|
||||
/**
|
||||
* Recommended. Specifies an encoded 'code_verifier' that will be used as a
|
||||
* server-side challenge during authorization code exchange. This parameter
|
||||
* must be used with the 'code_challenge' parameter described above.
|
||||
*/
|
||||
code_challenge?: string;
|
||||
}
|
||||
export interface AuthClientOpts {
|
||||
authBaseUrl?: string;
|
||||
tokenUrl?: string;
|
||||
}
|
||||
export interface GetTokenCallback {
|
||||
(err: AxiosError | null, token?: Credentials | null, res?: AxiosResponse | null): void;
|
||||
}
|
||||
export interface GetTokenResponse {
|
||||
tokens: Credentials;
|
||||
res: AxiosResponse | null;
|
||||
}
|
||||
export interface GetAccessTokenCallback {
|
||||
(err: AxiosError | null, token?: string | null, res?: AxiosResponse | null): void;
|
||||
}
|
||||
export interface GetAccessTokenResponse {
|
||||
token?: string | null;
|
||||
res?: AxiosResponse | null;
|
||||
}
|
||||
export interface RefreshAccessTokenCallback {
|
||||
(err: AxiosError | null, credentials?: Credentials | null, res?: AxiosResponse | null): void;
|
||||
}
|
||||
export interface RefreshAccessTokenResponse {
|
||||
credentials: Credentials;
|
||||
res: AxiosResponse | null;
|
||||
}
|
||||
export interface RequestMetadataResponse {
|
||||
headers: http.IncomingHttpHeaders;
|
||||
res?: AxiosResponse<void> | null;
|
||||
}
|
||||
export interface RequestMetadataCallback {
|
||||
(err: AxiosError | null, headers?: http.IncomingHttpHeaders, res?: AxiosResponse<void> | null): void;
|
||||
}
|
||||
export interface GetFederatedSignonCertsCallback {
|
||||
(err: AxiosError | null, certs?: any, response?: AxiosResponse<void> | null): void;
|
||||
}
|
||||
export interface FederatedSignonCertsResponse {
|
||||
certs: any;
|
||||
res?: AxiosResponse<void> | null;
|
||||
}
|
||||
export interface RevokeCredentialsResult {
|
||||
success: boolean;
|
||||
}
|
||||
export interface VerifyIdTokenOptions {
|
||||
idToken: string;
|
||||
audience: string | string[];
|
||||
maxExpiry?: number;
|
||||
}
|
||||
export interface OAuth2ClientOptions extends RefreshOptions {
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
redirectUri?: string;
|
||||
authBaseUrl?: string;
|
||||
tokenUrl?: string;
|
||||
}
|
||||
export interface RefreshOptions {
|
||||
eagerRefreshThresholdMillis?: number;
|
||||
}
|
||||
export declare class OAuth2Client extends AuthClient {
|
||||
private redirectUri?;
|
||||
private certificateCache;
|
||||
private certificateExpiry;
|
||||
protected refreshTokenPromises: Map<string, Promise<GetTokenResponse>>;
|
||||
protected authBaseUrl?: string;
|
||||
protected tokenUrl?: string;
|
||||
_clientId?: string;
|
||||
_clientSecret?: string;
|
||||
apiKey?: string;
|
||||
projectId?: string;
|
||||
eagerRefreshThresholdMillis: number;
|
||||
/**
|
||||
* Handles OAuth2 flow for Google APIs.
|
||||
*
|
||||
* @param clientId The authentication client ID.
|
||||
* @param clientSecret The authentication client secret.
|
||||
* @param redirectUri The URI to redirect to after completing the auth
|
||||
* request.
|
||||
* @param opts optional options for overriding the given parameters.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options?: OAuth2ClientOptions);
|
||||
constructor(clientId?: string, clientSecret?: string, redirectUri?: string, opts?: AuthClientOpts);
|
||||
protected static readonly GOOGLE_TOKEN_INFO_URL: string;
|
||||
/**
|
||||
* The base URL for auth endpoints.
|
||||
*/
|
||||
private static readonly GOOGLE_OAUTH2_AUTH_BASE_URL_;
|
||||
/**
|
||||
* The base endpoint for token retrieval.
|
||||
*/
|
||||
private static readonly GOOGLE_OAUTH2_TOKEN_URL_;
|
||||
/**
|
||||
* The base endpoint to revoke tokens.
|
||||
*/
|
||||
private static readonly GOOGLE_OAUTH2_REVOKE_URL_;
|
||||
/**
|
||||
* Google Sign on certificates.
|
||||
*/
|
||||
private static readonly GOOGLE_OAUTH2_FEDERATED_SIGNON_CERTS_URL_;
|
||||
/**
|
||||
* Clock skew - five minutes in seconds
|
||||
*/
|
||||
private static readonly CLOCK_SKEW_SECS_;
|
||||
/**
|
||||
* Max Token Lifetime is one day in seconds
|
||||
*/
|
||||
private static readonly MAX_TOKEN_LIFETIME_SECS_;
|
||||
/**
|
||||
* The allowed oauth token issuers.
|
||||
*/
|
||||
private static readonly ISSUERS_;
|
||||
/**
|
||||
* Generates URL for consent page landing.
|
||||
* @param opts Options.
|
||||
* @return URL to consent page.
|
||||
*/
|
||||
generateAuthUrl(opts?: GenerateAuthUrlOpts): string;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
generateCodeVerifier(): {
|
||||
codeVerifier: string;
|
||||
codeChallenge: string;
|
||||
};
|
||||
/**
|
||||
* Gets the access token for the given code.
|
||||
* @param code The authorization code.
|
||||
* @param callback Optional callback fn.
|
||||
*/
|
||||
getToken(code: string): Promise<GetTokenResponse>;
|
||||
getToken(options: GetTokenOptions): Promise<GetTokenResponse>;
|
||||
getToken(code: string, callback: GetTokenCallback): void;
|
||||
getToken(options: GetTokenOptions, callback: GetTokenCallback): void;
|
||||
private getTokenAsync;
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refresh_token Existing refresh token.
|
||||
* @private
|
||||
*/
|
||||
protected refreshToken(refreshToken?: string | null): Promise<GetTokenResponse>;
|
||||
protected refreshTokenNoCache(refreshToken?: string | null): Promise<GetTokenResponse>;
|
||||
/**
|
||||
* Retrieves the access token using refresh token
|
||||
*
|
||||
* @deprecated use getRequestMetadata instead.
|
||||
* @param callback callback
|
||||
*/
|
||||
refreshAccessToken(): Promise<RefreshAccessTokenResponse>;
|
||||
refreshAccessToken(callback: RefreshAccessTokenCallback): void;
|
||||
private refreshAccessTokenAsync;
|
||||
/**
|
||||
* Get a non-expired access token, after refreshing if necessary
|
||||
*
|
||||
* @param callback Callback to call with the access token
|
||||
*/
|
||||
getAccessToken(): Promise<GetAccessTokenResponse>;
|
||||
getAccessToken(callback: GetAccessTokenCallback): void;
|
||||
private getAccessTokenAsync;
|
||||
/**
|
||||
* getRequestMetadata obtains auth metadata to be used by requests.
|
||||
*
|
||||
* getRequestMetadata is the main authentication interface. It takes an
|
||||
* optional uri which when present is the endpoint being accessed, and a
|
||||
* callback func(err, metadata_obj, response) where metadata_obj contains
|
||||
* authorization metadata fields and response is an optional response object.
|
||||
*
|
||||
* In OAuth2Client, metadata_obj has the form.
|
||||
*
|
||||
* {Authorization: 'Bearer <access_token_value>'}
|
||||
*
|
||||
* @param url the Uri being authorized
|
||||
* @param callback the func described above
|
||||
*/
|
||||
getRequestMetadata(url?: string | null): Promise<RequestMetadataResponse>;
|
||||
getRequestMetadata(url: string | null, callback: RequestMetadataCallback): void;
|
||||
protected getRequestMetadataAsync(url?: string | null): Promise<RequestMetadataResponse>;
|
||||
/**
|
||||
* Revokes the access given to token.
|
||||
* @param token The existing token to be revoked.
|
||||
* @param callback Optional callback fn.
|
||||
*/
|
||||
revokeToken(token: string): AxiosPromise<RevokeCredentialsResult>;
|
||||
revokeToken(token: string, callback: BodyResponseCallback<RevokeCredentialsResult>): void;
|
||||
/**
|
||||
* Revokes access token and clears the credentials object
|
||||
* @param callback callback
|
||||
*/
|
||||
revokeCredentials(): AxiosPromise<RevokeCredentialsResult>;
|
||||
revokeCredentials(callback: BodyResponseCallback<RevokeCredentialsResult>): void;
|
||||
private revokeCredentialsAsync;
|
||||
/**
|
||||
* Provides a request implementation with OAuth 2.0 flow. If credentials have
|
||||
* a refresh_token, in cases of HTTP 401 and 403 responses, it automatically
|
||||
* asks for a new access token and replays the unsuccessful request.
|
||||
* @param opts Request options.
|
||||
* @param callback callback.
|
||||
* @return Request object
|
||||
*/
|
||||
request<T>(opts: AxiosRequestConfig): AxiosPromise<T>;
|
||||
request<T>(opts: AxiosRequestConfig, callback: BodyResponseCallback<T>): void;
|
||||
protected requestAsync<T>(opts: AxiosRequestConfig, retry?: boolean): Promise<AxiosResponse<T>>;
|
||||
/**
|
||||
* Verify id token is token by checking the certs and audience
|
||||
* @param options that contains all options.
|
||||
* @param callback Callback supplying GoogleLogin if successful
|
||||
*/
|
||||
verifyIdToken(options: VerifyIdTokenOptions): Promise<LoginTicket | null>;
|
||||
verifyIdToken(options: VerifyIdTokenOptions, callback: (err: Error | null, login?: LoginTicket | null) => void): void;
|
||||
private verifyIdTokenAsync;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
getTokenInfo(accessToken: string): Promise<TokenInfo>;
|
||||
/**
|
||||
* Gets federated sign-on certificates to use for verifying identity tokens.
|
||||
* Returns certs as array structure, where keys are key ids, and values
|
||||
* are PEM encoded certificates.
|
||||
* @param callback Callback supplying the certificates
|
||||
*/
|
||||
getFederatedSignonCerts(): Promise<FederatedSignonCertsResponse>;
|
||||
getFederatedSignonCerts(callback: GetFederatedSignonCertsCallback): void;
|
||||
getFederatedSignonCertsAsync(): Promise<FederatedSignonCertsResponse>;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
verifySignedJwtWithCerts(jwt: string, certs: {}, requiredAudience: string | string[], issuers?: string[], maxExpiry?: number): LoginTicket;
|
||||
/**
|
||||
* This is a utils method to decode a base64 string
|
||||
* @param b64String The string to base64 decode
|
||||
* @return The decoded string
|
||||
*/
|
||||
decodeBase64(b64String: string): string;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
protected isTokenExpiring(): boolean;
|
||||
}
|
753
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/oauth2client.js
generated
vendored
Normal file
753
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/oauth2client.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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
58
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/refreshclient.d.ts
generated
vendored
Normal file
58
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/refreshclient.d.ts
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import * as stream from 'stream';
|
||||
import { JWTInput } from './credentials';
|
||||
import { GetTokenResponse, OAuth2Client, RefreshOptions } from './oauth2client';
|
||||
export interface UserRefreshClientOptions extends RefreshOptions {
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
refreshToken?: string;
|
||||
}
|
||||
export declare class UserRefreshClient extends OAuth2Client {
|
||||
_refreshToken?: string | null;
|
||||
/**
|
||||
* User Refresh Token credentials.
|
||||
*
|
||||
* @param clientId The authentication client ID.
|
||||
* @param clientSecret The authentication client secret.
|
||||
* @param refreshToken The authentication refresh token.
|
||||
*/
|
||||
constructor(clientId?: string, clientSecret?: string, refreshToken?: string);
|
||||
constructor(options: UserRefreshClientOptions);
|
||||
constructor(clientId?: string, clientSecret?: string, refreshToken?: string);
|
||||
/**
|
||||
* Refreshes the access token.
|
||||
* @param refreshToken An ignored refreshToken..
|
||||
* @param callback Optional callback.
|
||||
*/
|
||||
protected refreshTokenNoCache(refreshToken?: string | null): Promise<GetTokenResponse>;
|
||||
/**
|
||||
* Create a UserRefreshClient credentials instance using the given input
|
||||
* options.
|
||||
* @param json The input object.
|
||||
*/
|
||||
fromJSON(json: JWTInput): void;
|
||||
/**
|
||||
* Create a UserRefreshClient credentials instance using the given input
|
||||
* stream.
|
||||
* @param inputStream The input stream.
|
||||
* @param callback Optional callback.
|
||||
*/
|
||||
fromStream(inputStream: stream.Readable): Promise<void>;
|
||||
fromStream(inputStream: stream.Readable, callback: (err?: Error) => void): void;
|
||||
private fromStreamAsync;
|
||||
}
|
160
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/refreshclient.js
generated
vendored
Normal file
160
express-server/node_modules/google-auto-auth/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
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/auth/refreshclient.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/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,CAAC,CAAC;YACvE,iBAAiB,CAAC,CAAC;YACnB;gBACE,QAAQ,EAAE,iBAAiB;gBAC3B,YAAY,cAAA;gBACZ,YAAY,cAAA;gBACZ,2BAA2B,6BAAA;aAC5B,CAAC;QACN,QAAA,kBAAM;YACJ,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,2BAA2B,EAAE,IAAI,CAAC,2BAA2B;SAC9D,CAAC,SAAC;QACH,KAAI,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC;;IACzC,CAAC;IAED;;;;OAIG;IACa,+CAAmB,GAAnC,UAAoC,YACI;;;gBACtC,sBAAO,iBAAM,mBAAmB,YAAC,IAAI,CAAC,aAAa,CAAC,EAAC;;;KACtD;IAED;;;;OAIG;IACH,oCAAQ,GAAR,UAAS,IAAc;QACrB,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CACX,8DAA8D,CAAC,CAAC;SACrE;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE;YACnC,MAAM,IAAI,KAAK,CACX,mEAAmE,CAAC,CAAC;SAC1E;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,MAAM,IAAI,KAAK,CACX,6DAA6D,CAAC,CAAC;SACpE;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,MAAM,IAAI,KAAK,CACX,iEAAiE,CAAC,CAAC;SACxE;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,MAAM,IAAI,KAAK,CACX,iEAAiE,CAAC,CAAC;SACxE;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,WAAW,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;IACtD,CAAC;IAWD,sCAAU,GAAV,UAAW,WAA4B,EAAE,QAAgC;QAEvE,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,QAAQ,EAAE,EAAV,CAAU,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACzE;aAAM;YACL,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;SAC1C;IACH,CAAC;IAEa,2CAAe,GAA7B,UAA8B,WAA4B;;;;gBACxD,sBAAO,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;wBACvC,IAAI,CAAC,WAAW,EAAE;4BAChB,OAAO,MAAM,CAAC,IAAI,KAAK,CACnB,0DAA0D,CAAC,CAAC,CAAC;yBAClE;wBACD,IAAI,CAAC,GAAG,EAAE,CAAC;wBACX,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;wBAChC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,UAAC,KAAK;4BAC3B,CAAC,IAAI,KAAK,CAAC;wBACb,CAAC,CAAC,CAAC;wBACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;4BACpB,IAAI;gCACF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gCAC3B,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gCACpB,OAAO,OAAO,EAAE,CAAC;6BAClB;4BAAC,OAAO,GAAG,EAAE;gCACZ,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;6BACpB;wBACH,CAAC,CAAC,CAAC;oBACL,CAAC,CAAC,EAAC;;;KACJ;IACH,wBAAC;AAAD,CAAC,AAtHD,CAAuC,2BAAY,GAsHlD;AAtHY,8CAAiB"}
|
26
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/index.d.ts
generated
vendored
Normal file
26
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
import { GoogleAuth } from './auth/googleauth';
|
||||
export { Compute } from './auth/computeclient';
|
||||
export { GoogleAuthOptions } from './auth/googleauth';
|
||||
export { IAMAuth } from './auth/iam';
|
||||
export { JWTAccess } from './auth/jwtaccess';
|
||||
export { JWT } from './auth/jwtclient';
|
||||
export { CodeChallengeMethod, OAuth2Client } from './auth/oauth2client';
|
||||
export { UserRefreshClient } from './auth/refreshclient';
|
||||
export { DefaultTransporter } from './transporters';
|
||||
declare const auth: GoogleAuth;
|
||||
export { auth, GoogleAuth };
|
37
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/index.js
generated
vendored
Normal file
37
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/index.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Copyright 2017 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 googleauth_1 = require("./auth/googleauth");
|
||||
exports.GoogleAuth = googleauth_1.GoogleAuth;
|
||||
var computeclient_1 = require("./auth/computeclient");
|
||||
exports.Compute = computeclient_1.Compute;
|
||||
var iam_1 = require("./auth/iam");
|
||||
exports.IAMAuth = iam_1.IAMAuth;
|
||||
var jwtaccess_1 = require("./auth/jwtaccess");
|
||||
exports.JWTAccess = jwtaccess_1.JWTAccess;
|
||||
var jwtclient_1 = require("./auth/jwtclient");
|
||||
exports.JWT = jwtclient_1.JWT;
|
||||
var oauth2client_1 = require("./auth/oauth2client");
|
||||
exports.CodeChallengeMethod = oauth2client_1.CodeChallengeMethod;
|
||||
exports.OAuth2Client = oauth2client_1.OAuth2Client;
|
||||
var refreshclient_1 = require("./auth/refreshclient");
|
||||
exports.UserRefreshClient = refreshclient_1.UserRefreshClient;
|
||||
var transporters_1 = require("./transporters");
|
||||
exports.DefaultTransporter = transporters_1.DefaultTransporter;
|
||||
var auth = new googleauth_1.GoogleAuth();
|
||||
exports.auth = auth;
|
||||
//# sourceMappingURL=index.js.map
|
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/index.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH,gDAA6C;AAY/B,qBAZN,uBAAU,CAYM;AAVxB,sDAA6C;AAArC,kCAAA,OAAO,CAAA;AAEf,kCAAmC;AAA3B,wBAAA,OAAO,CAAA;AACf,8CAA2C;AAAnC,gCAAA,SAAS,CAAA;AACjB,8CAAqC;AAA7B,0BAAA,GAAG,CAAA;AACX,oDAAsE;AAA9D,6CAAA,mBAAmB,CAAA;AAAE,sCAAA,YAAY,CAAA;AACzC,sDAAuD;AAA/C,4CAAA,iBAAiB,CAAA;AACzB,+CAAkD;AAA1C,4CAAA,kBAAkB,CAAA;AAE1B,IAAM,IAAI,GAAG,IAAI,uBAAU,EAAE,CAAC;AACtB,oBAAI"}
|
16
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/options.d.ts
generated
vendored
Normal file
16
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/options.d.ts
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
export declare function validate(options: any): void;
|
37
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/options.js
generated
vendored
Normal file
37
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/options.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2017 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 });
|
||||
// Accepts an options object passed from the user to the API. In the
|
||||
// previous version of the API, it referred to a `Request` options object.
|
||||
// Now it refers to an Axiox Request Config object. This is here to help
|
||||
// ensure users don't pass invalid options when they upgrade from 0.x to 1.x.
|
||||
// tslint:disable-next-line no-any
|
||||
function validate(options) {
|
||||
var vpairs = [
|
||||
{ invalid: 'uri', expected: 'url' }, { invalid: 'json', expected: 'data' },
|
||||
{ invalid: 'qs', expected: 'params' }
|
||||
];
|
||||
for (var _i = 0, vpairs_1 = vpairs; _i < vpairs_1.length; _i++) {
|
||||
var pair = vpairs_1[_i];
|
||||
if (options[pair.invalid]) {
|
||||
var e = "'" + pair.invalid + "' is not a valid configuration option. Please use '" + pair.expected + "' instead. This library is using Axios for requests. Please see https://github.com/axios/axios to learn more about the valid request options.";
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.validate = validate;
|
||||
//# sourceMappingURL=options.js.map
|
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/options.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/options.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,qEAAqE;AACrE,0EAA0E;AAC1E,yEAAyE;AACzE,6EAA6E;AAC7E,kCAAkC;AAClC,kBAAyB,OAAY;IACnC,IAAM,MAAM,GAAG;QACb,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAC,EAAE,EAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAC;QACtE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAC;KACpC,CAAC;IACF,KAAmB,UAAM,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM,EAAE;QAAtB,IAAM,IAAI,eAAA;QACb,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YACzB,IAAM,CAAC,GAAG,MACN,IAAI,CAAC,OAAO,2DACZ,IAAI,CAAC,QAAQ,kJAA+I,CAAC;YACjK,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;SACpB;KACF;AACH,CAAC;AAbD,4BAaC"}
|
20
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/pemverifier.d.ts
generated
vendored
Normal file
20
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/pemverifier.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import crypto from 'crypto';
|
||||
export declare class PemVerifier {
|
||||
verify(pubkey: string, data: string | Buffer, signature: string, encoding: crypto.HexBase64Latin1Encoding): boolean;
|
||||
}
|
33
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/pemverifier.js
generated
vendored
Normal file
33
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/pemverifier.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var crypto_1 = __importDefault(require("crypto"));
|
||||
var PemVerifier = /** @class */ (function () {
|
||||
function PemVerifier() {
|
||||
}
|
||||
PemVerifier.prototype.verify = function (pubkey, data, signature, encoding) {
|
||||
var verifier = crypto_1.default.createVerify('sha256');
|
||||
verifier.update(data);
|
||||
return verifier.verify(pubkey, signature, encoding);
|
||||
};
|
||||
return PemVerifier;
|
||||
}());
|
||||
exports.PemVerifier = PemVerifier;
|
||||
//# sourceMappingURL=pemverifier.js.map
|
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/pemverifier.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/pemverifier.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"pemverifier.js","sourceRoot":"","sources":["../../src/pemverifier.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAEH,kDAA4B;AAE5B;IAAA;IAQA,CAAC;IAPC,4BAAM,GAAN,UACI,MAAc,EAAE,IAAmB,EAAE,SAAiB,EACtD,QAAwC;QAC1C,IAAM,QAAQ,GAAG,gBAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC/C,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IACH,kBAAC;AAAD,CAAC,AARD,IAQC;AARY,kCAAW"}
|
51
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/transporters.d.ts
generated
vendored
Normal file
51
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/transporters.d.ts
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
import { AxiosError, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
export interface Transporter {
|
||||
request<T>(opts: AxiosRequestConfig): AxiosPromise<T>;
|
||||
request<T>(opts: AxiosRequestConfig, callback?: BodyResponseCallback<T>): void;
|
||||
request<T>(opts: AxiosRequestConfig, callback?: BodyResponseCallback<T>): AxiosPromise | void;
|
||||
}
|
||||
export interface BodyResponseCallback<T> {
|
||||
(err: Error | null, res?: AxiosResponse<T> | null): void;
|
||||
}
|
||||
export interface RequestError extends AxiosError {
|
||||
errors: Error[];
|
||||
}
|
||||
export declare class DefaultTransporter {
|
||||
/**
|
||||
* Default user agent.
|
||||
*/
|
||||
static readonly USER_AGENT: string;
|
||||
/**
|
||||
* Configures request options before making a request.
|
||||
* @param opts AxiosRequestConfig options.
|
||||
* @return Configured options.
|
||||
*/
|
||||
configure(opts?: AxiosRequestConfig): AxiosRequestConfig;
|
||||
/**
|
||||
* Makes a request using Axios with given options.
|
||||
* @param opts AxiosRequestConfig options.
|
||||
* @param callback optional callback that contains AxiosResponse object.
|
||||
* @return AxiosPromise, assuming no callback is passed.
|
||||
*/
|
||||
request<T>(opts: AxiosRequestConfig): AxiosPromise<T>;
|
||||
request<T>(opts: AxiosRequestConfig, callback?: BodyResponseCallback<T>): void;
|
||||
/**
|
||||
* Changes the error to include details from the body.
|
||||
*/
|
||||
private processError;
|
||||
}
|
123
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/transporters.js
generated
vendored
Normal file
123
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/transporters.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var axios_1 = __importDefault(require("axios"));
|
||||
var options_1 = require("./options");
|
||||
// tslint:disable-next-line no-var-requires
|
||||
var pkg = require('../../package.json');
|
||||
var PRODUCT_NAME = 'google-api-nodejs-client';
|
||||
/**
|
||||
* Axios will use XHR if it is available. In the case of Electron,
|
||||
* since XHR is there it will try to use that. This leads to OPTIONS
|
||||
* preflight requests which googleapis DOES NOT like. This line of
|
||||
* code pins the adapter to ensure it uses node.
|
||||
* https://github.com/google/google-api-nodejs-client/issues/1083
|
||||
*/
|
||||
axios_1.default.defaults.adapter = require('axios/lib/adapters/http');
|
||||
var DefaultTransporter = /** @class */ (function () {
|
||||
function DefaultTransporter() {
|
||||
}
|
||||
/**
|
||||
* Configures request options before making a request.
|
||||
* @param opts AxiosRequestConfig options.
|
||||
* @return Configured options.
|
||||
*/
|
||||
DefaultTransporter.prototype.configure = function (opts) {
|
||||
if (opts === void 0) { opts = {}; }
|
||||
// set transporter user agent
|
||||
opts.headers = opts.headers || {};
|
||||
var uaValue = opts.headers['User-Agent'];
|
||||
if (!uaValue) {
|
||||
opts.headers['User-Agent'] = DefaultTransporter.USER_AGENT;
|
||||
}
|
||||
else if (!uaValue.includes(PRODUCT_NAME + "/")) {
|
||||
opts.headers['User-Agent'] =
|
||||
uaValue + " " + DefaultTransporter.USER_AGENT;
|
||||
}
|
||||
return opts;
|
||||
};
|
||||
DefaultTransporter.prototype.request = function (opts, callback) {
|
||||
var _this = this;
|
||||
// ensure the user isn't passing in request-style options
|
||||
opts = this.configure(opts);
|
||||
try {
|
||||
options_1.validate(opts);
|
||||
}
|
||||
catch (e) {
|
||||
if (callback) {
|
||||
return callback(e);
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
axios_1.default(opts)
|
||||
.then(function (r) {
|
||||
callback(null, r);
|
||||
})
|
||||
.catch(function (e) {
|
||||
callback(_this.processError(e));
|
||||
});
|
||||
}
|
||||
else {
|
||||
return axios_1.default(opts).catch(function (e) {
|
||||
throw _this.processError(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Changes the error to include details from the body.
|
||||
*/
|
||||
DefaultTransporter.prototype.processError = function (e) {
|
||||
var res = e.response;
|
||||
var err = e;
|
||||
var body = res ? res.data : null;
|
||||
if (res && body && body.error && res.status !== 200) {
|
||||
if (typeof body.error === 'string') {
|
||||
err.message = body.error;
|
||||
err.code = res.status.toString();
|
||||
}
|
||||
else if (Array.isArray(body.error.errors)) {
|
||||
err.message =
|
||||
body.error.errors.map(function (err2) { return err2.message; }).join('\n');
|
||||
err.code = body.error.code;
|
||||
err.errors = body.error.errors;
|
||||
}
|
||||
else {
|
||||
err.message = body.error.message;
|
||||
err.code = body.error.code || res.status;
|
||||
}
|
||||
}
|
||||
else if (res && res.status >= 400) {
|
||||
// Consider all 4xx and 5xx responses errors.
|
||||
err.message = body;
|
||||
err.code = res.status.toString();
|
||||
}
|
||||
return err;
|
||||
};
|
||||
/**
|
||||
* Default user agent.
|
||||
*/
|
||||
DefaultTransporter.USER_AGENT = PRODUCT_NAME + "/" + pkg.version;
|
||||
return DefaultTransporter;
|
||||
}());
|
||||
exports.DefaultTransporter = DefaultTransporter;
|
||||
//# sourceMappingURL=transporters.js.map
|
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/transporters.js.map
generated
vendored
Normal file
1
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/build/src/transporters.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"transporters.js","sourceRoot":"","sources":["../../src/transporters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAEH,gDAAyF;AACzF,qCAAmC;AAEnC,2CAA2C;AAC3C,IAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC1C,IAAM,YAAY,GAAG,0BAA0B,CAAC;AAoBhD;;;;;;GAMG;AACH,eAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAE5D;IAAA;IAyFA,CAAC;IAnFC;;;;OAIG;IACH,sCAAS,GAAT,UAAU,IAA6B;QAA7B,qBAAA,EAAA,SAA6B;QACrC,6BAA6B;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QAClC,IAAM,OAAO,GAAW,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,EAAE;YACZ,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,CAAC,UAAU,CAAC;SAC5D;aAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAI,YAAY,MAAG,CAAC,EAAE;YAChD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;gBACnB,OAAO,SAAI,kBAAkB,CAAC,UAAY,CAAC;SACnD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAWD,oCAAO,GAAP,UAAW,IAAwB,EAAE,QAAkC;QAAvE,iBA2BC;QAzBC,yDAAyD;QACzD,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI;YACF,kBAAQ,CAAC,IAAI,CAAC,CAAC;SAChB;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,QAAQ,EAAE;gBACZ,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;aACpB;iBAAM;gBACL,MAAM,CAAC,CAAC;aACT;SACF;QAED,IAAI,QAAQ,EAAE;YACZ,eAAK,CAAC,IAAI,CAAC;iBACN,IAAI,CAAC,UAAA,CAAC;gBACL,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACpB,CAAC,CAAC;iBACD,KAAK,CAAC,UAAA,CAAC;gBACN,QAAQ,CAAC,KAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;SACR;aAAM;YACL,OAAO,eAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC;gBACxB,MAAM,KAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACK,yCAAY,GAApB,UAAqB,CAAa;QAChC,IAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC;QACvB,IAAM,GAAG,GAAG,CAAiB,CAAC;QAC9B,IAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACnC,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;YACnD,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;gBAClC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;gBACzB,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;aAClC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;gBAC3C,GAAG,CAAC,OAAO;oBACP,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,IAAW,IAAK,OAAA,IAAI,CAAC,OAAO,EAAZ,CAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC3B,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;aAChC;iBAAM;gBACL,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;gBACjC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC;aAC1C;SACF;aAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;YACnC,6CAA6C;YAC7C,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;YACnB,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;SAClC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAvFD;;OAEG;IACa,6BAAU,GAAM,YAAY,SAAI,GAAG,CAAC,OAAS,CAAC;IAqFhE,yBAAC;CAAA,AAzFD,IAyFC;AAzFY,gDAAkB"}
|
122
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/package.json
generated
vendored
Normal file
122
express-server/node_modules/google-auto-auth/node_modules/google-auth-library/package.json
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
{
|
||||
"_from": "google-auth-library@^1.3.1",
|
||||
"_id": "google-auth-library@1.6.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-jYiWC8NA9n9OtQM7ANn0Tk464do9yhKEtaJ72pKcaBiEwn4LwcGYIYOfwtfsSm3aur/ed3tlSxbmg24IAT6gAg==",
|
||||
"_location": "/google-auto-auth/google-auth-library",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "google-auth-library@^1.3.1",
|
||||
"name": "google-auth-library",
|
||||
"escapedName": "google-auth-library",
|
||||
"rawSpec": "^1.3.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.3.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/google-auto-auth"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-1.6.1.tgz",
|
||||
"_shasum": "9c73d831ad720c0c3048ab89d0ffdec714d07dd2",
|
||||
"_spec": "google-auth-library@^1.3.1",
|
||||
"_where": "D:\\Desktop\\Git\\Firebase\\SmartShopperFirebase\\node_modules\\google-auto-auth",
|
||||
"author": {
|
||||
"name": "Google Inc."
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/google/google-auth-library-nodejs/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"gcp-metadata": "^0.6.3",
|
||||
"gtoken": "^2.3.0",
|
||||
"jws": "^3.1.5",
|
||||
"lodash.isstring": "^4.0.1",
|
||||
"lru-cache": "^4.1.3",
|
||||
"retry-axios": "^0.3.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Google APIs Authentication Client Library for Node.js",
|
||||
"devDependencies": {
|
||||
"@justinbeckwith/typedoc": "^0.10.1",
|
||||
"@types/jws": "^3.1.0",
|
||||
"@types/lodash.isstring": "^4.0.3",
|
||||
"@types/lru-cache": "^4.1.0",
|
||||
"@types/mocha": "^5.2.1",
|
||||
"@types/mv": "^2.1.0",
|
||||
"@types/ncp": "^2.0.1",
|
||||
"@types/nock": "^9.1.3",
|
||||
"@types/node": "^10.3.0",
|
||||
"@types/pify": "^3.0.2",
|
||||
"@types/sinon": "^5.0.1",
|
||||
"@types/tmp": "^0.0.33",
|
||||
"clang-format": "^1.2.3",
|
||||
"codecov": "^3.0.2",
|
||||
"gh-pages": "^1.2.0",
|
||||
"gts": "^0.6.0",
|
||||
"js-green-licenses": "^0.5.0",
|
||||
"keypair": "^1.0.1",
|
||||
"mocha": "^5.2.0",
|
||||
"mv": "^2.1.1",
|
||||
"ncp": "^2.0.0",
|
||||
"nock": "^9.3.0",
|
||||
"nyc": "^12.0.2",
|
||||
"opn": "^5.3.0",
|
||||
"pify": "^3.0.0",
|
||||
"prettier": "^1.13.4",
|
||||
"sinon": "^5.0.10",
|
||||
"source-map-support": "^0.5.6",
|
||||
"tmp": "^0.0.33",
|
||||
"typescript": "~2.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"build/src",
|
||||
"package.json"
|
||||
],
|
||||
"homepage": "https://github.com/google/google-auth-library-nodejs#readme",
|
||||
"keywords": [
|
||||
"google",
|
||||
"api",
|
||||
"google apis",
|
||||
"client",
|
||||
"client library"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"main": "./build/src/index.js",
|
||||
"name": "google-auth-library",
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
"build/test"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/google/google-auth-library-nodejs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"check": "gts check",
|
||||
"clean": "gts clean",
|
||||
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
|
||||
"compile": "tsc -p .",
|
||||
"fix": "gts fix && npm run fix-samples",
|
||||
"fix-samples": "prettier --write --single-quote examples/*.js",
|
||||
"generate-docs": "typedoc --excludePrivate --excludeExternals --mode modules --out docs src && touch docs/.nojekyll",
|
||||
"license-check": "jsgl --local .",
|
||||
"posttest": "npm run check && npm run license-check",
|
||||
"prepare": "npm run compile",
|
||||
"pretest": "npm run compile",
|
||||
"publish-docs": "gh-pages --dotfiles --dist docs --remote upstream",
|
||||
"test": "npm run test-only",
|
||||
"test-only": "nyc mocha build/test --timeout 10000"
|
||||
},
|
||||
"types": "./build/src/index.d.ts",
|
||||
"version": "1.6.1"
|
||||
}
|
15
express-server/node_modules/google-auto-auth/node_modules/lru-cache/LICENSE
generated
vendored
Normal file
15
express-server/node_modules/google-auto-auth/node_modules/lru-cache/LICENSE
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
158
express-server/node_modules/google-auto-auth/node_modules/lru-cache/README.md
generated
vendored
Normal file
158
express-server/node_modules/google-auto-auth/node_modules/lru-cache/README.md
generated
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
# lru cache
|
||||
|
||||
A cache object that deletes the least-recently-used items.
|
||||
|
||||
[](https://travis-ci.org/isaacs/node-lru-cache) [](https://coveralls.io/github/isaacs/node-lru-cache)
|
||||
|
||||
## Installation:
|
||||
|
||||
```javascript
|
||||
npm install lru-cache --save
|
||||
```
|
||||
|
||||
## Usage:
|
||||
|
||||
```javascript
|
||||
var LRU = require("lru-cache")
|
||||
, options = { max: 500
|
||||
, length: function (n, key) { return n * 2 + key.length }
|
||||
, dispose: function (key, n) { n.close() }
|
||||
, maxAge: 1000 * 60 * 60 }
|
||||
, cache = LRU(options)
|
||||
, otherCache = LRU(50) // sets just the max size
|
||||
|
||||
cache.set("key", "value")
|
||||
cache.get("key") // "value"
|
||||
|
||||
// non-string keys ARE fully supported
|
||||
// but note that it must be THE SAME object, not
|
||||
// just a JSON-equivalent object.
|
||||
var someObject = { a: 1 }
|
||||
cache.set(someObject, 'a value')
|
||||
// Object keys are not toString()-ed
|
||||
cache.set('[object Object]', 'a different value')
|
||||
assert.equal(cache.get(someObject), 'a value')
|
||||
// A similar object with same keys/values won't work,
|
||||
// because it's a different object identity
|
||||
assert.equal(cache.get({ a: 1 }), undefined)
|
||||
|
||||
cache.reset() // empty the cache
|
||||
```
|
||||
|
||||
If you put more stuff in it, then items will fall out.
|
||||
|
||||
If you try to put an oversized thing in it, then it'll fall out right
|
||||
away.
|
||||
|
||||
## Options
|
||||
|
||||
* `max` The maximum size of the cache, checked by applying the length
|
||||
function to all values in the cache. Not setting this is kind of
|
||||
silly, since that's the whole purpose of this lib, but it defaults
|
||||
to `Infinity`.
|
||||
* `maxAge` Maximum age in ms. Items are not pro-actively pruned out
|
||||
as they age, but if you try to get an item that is too old, it'll
|
||||
drop it and return undefined instead of giving it to you.
|
||||
* `length` Function that is used to calculate the length of stored
|
||||
items. If you're storing strings or buffers, then you probably want
|
||||
to do something like `function(n, key){return n.length}`. The default is
|
||||
`function(){return 1}`, which is fine if you want to store `max`
|
||||
like-sized things. The item is passed as the first argument, and
|
||||
the key is passed as the second argumnet.
|
||||
* `dispose` Function that is called on items when they are dropped
|
||||
from the cache. This can be handy if you want to close file
|
||||
descriptors or do other cleanup tasks when items are no longer
|
||||
accessible. Called with `key, value`. It's called *before*
|
||||
actually removing the item from the internal cache, so if you want
|
||||
to immediately put it back in, you'll have to do that in a
|
||||
`nextTick` or `setTimeout` callback or it won't do anything.
|
||||
* `stale` By default, if you set a `maxAge`, it'll only actually pull
|
||||
stale items out of the cache when you `get(key)`. (That is, it's
|
||||
not pre-emptively doing a `setTimeout` or anything.) If you set
|
||||
`stale:true`, it'll return the stale value before deleting it. If
|
||||
you don't set this, then it'll return `undefined` when you try to
|
||||
get a stale entry, as if it had already been deleted.
|
||||
* `noDisposeOnSet` By default, if you set a `dispose()` method, then
|
||||
it'll be called whenever a `set()` operation overwrites an existing
|
||||
key. If you set this option, `dispose()` will only be called when a
|
||||
key falls out of the cache, not when it is overwritten.
|
||||
|
||||
## API
|
||||
|
||||
* `set(key, value, maxAge)`
|
||||
* `get(key) => value`
|
||||
|
||||
Both of these will update the "recently used"-ness of the key.
|
||||
They do what you think. `maxAge` is optional and overrides the
|
||||
cache `maxAge` option if provided.
|
||||
|
||||
If the key is not found, `get()` will return `undefined`.
|
||||
|
||||
The key and val can be any value.
|
||||
|
||||
* `peek(key)`
|
||||
|
||||
Returns the key value (or `undefined` if not found) without
|
||||
updating the "recently used"-ness of the key.
|
||||
|
||||
(If you find yourself using this a lot, you *might* be using the
|
||||
wrong sort of data structure, but there are some use cases where
|
||||
it's handy.)
|
||||
|
||||
* `del(key)`
|
||||
|
||||
Deletes a key out of the cache.
|
||||
|
||||
* `reset()`
|
||||
|
||||
Clear the cache entirely, throwing away all values.
|
||||
|
||||
* `has(key)`
|
||||
|
||||
Check if a key is in the cache, without updating the recent-ness
|
||||
or deleting it for being stale.
|
||||
|
||||
* `forEach(function(value,key,cache), [thisp])`
|
||||
|
||||
Just like `Array.prototype.forEach`. Iterates over all the keys
|
||||
in the cache, in order of recent-ness. (Ie, more recently used
|
||||
items are iterated over first.)
|
||||
|
||||
* `rforEach(function(value,key,cache), [thisp])`
|
||||
|
||||
The same as `cache.forEach(...)` but items are iterated over in
|
||||
reverse order. (ie, less recently used items are iterated over
|
||||
first.)
|
||||
|
||||
* `keys()`
|
||||
|
||||
Return an array of the keys in the cache.
|
||||
|
||||
* `values()`
|
||||
|
||||
Return an array of the values in the cache.
|
||||
|
||||
* `length`
|
||||
|
||||
Return total length of objects in cache taking into account
|
||||
`length` options function.
|
||||
|
||||
* `itemCount`
|
||||
|
||||
Return total quantity of objects currently in cache. Note, that
|
||||
`stale` (see options) items are returned as part of this item
|
||||
count.
|
||||
|
||||
* `dump()`
|
||||
|
||||
Return an array of the cache entries ready for serialization and usage
|
||||
with 'destinationCache.load(arr)`.
|
||||
|
||||
* `load(cacheEntriesArray)`
|
||||
|
||||
Loads another cache entries array, obtained with `sourceCache.dump()`,
|
||||
into the cache. The destination cache is reset before loading new entries
|
||||
|
||||
* `prune()`
|
||||
|
||||
Manually iterates over the entire cache proactively pruning old entries
|
468
express-server/node_modules/google-auto-auth/node_modules/lru-cache/index.js
generated
vendored
Normal file
468
express-server/node_modules/google-auto-auth/node_modules/lru-cache/index.js
generated
vendored
Normal file
@ -0,0 +1,468 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = LRUCache
|
||||
|
||||
// This will be a proper iterable 'Map' in engines that support it,
|
||||
// or a fakey-fake PseudoMap in older versions.
|
||||
var Map = require('pseudomap')
|
||||
var util = require('util')
|
||||
|
||||
// A linked list to keep track of recently-used-ness
|
||||
var Yallist = require('yallist')
|
||||
|
||||
// use symbols if possible, otherwise just _props
|
||||
var hasSymbol = typeof Symbol === 'function' && process.env._nodeLRUCacheForceNoSymbol !== '1'
|
||||
var makeSymbol
|
||||
if (hasSymbol) {
|
||||
makeSymbol = function (key) {
|
||||
return Symbol(key)
|
||||
}
|
||||
} else {
|
||||
makeSymbol = function (key) {
|
||||
return '_' + key
|
||||
}
|
||||
}
|
||||
|
||||
var MAX = makeSymbol('max')
|
||||
var LENGTH = makeSymbol('length')
|
||||
var LENGTH_CALCULATOR = makeSymbol('lengthCalculator')
|
||||
var ALLOW_STALE = makeSymbol('allowStale')
|
||||
var MAX_AGE = makeSymbol('maxAge')
|
||||
var DISPOSE = makeSymbol('dispose')
|
||||
var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet')
|
||||
var LRU_LIST = makeSymbol('lruList')
|
||||
var CACHE = makeSymbol('cache')
|
||||
|
||||
function naiveLength () { return 1 }
|
||||
|
||||
// lruList is a yallist where the head is the youngest
|
||||
// item, and the tail is the oldest. the list contains the Hit
|
||||
// objects as the entries.
|
||||
// Each Hit object has a reference to its Yallist.Node. This
|
||||
// never changes.
|
||||
//
|
||||
// cache is a Map (or PseudoMap) that matches the keys to
|
||||
// the Yallist.Node object.
|
||||
function LRUCache (options) {
|
||||
if (!(this instanceof LRUCache)) {
|
||||
return new LRUCache(options)
|
||||
}
|
||||
|
||||
if (typeof options === 'number') {
|
||||
options = { max: options }
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
options = {}
|
||||
}
|
||||
|
||||
var max = this[MAX] = options.max
|
||||
// Kind of weird to have a default max of Infinity, but oh well.
|
||||
if (!max ||
|
||||
!(typeof max === 'number') ||
|
||||
max <= 0) {
|
||||
this[MAX] = Infinity
|
||||
}
|
||||
|
||||
var lc = options.length || naiveLength
|
||||
if (typeof lc !== 'function') {
|
||||
lc = naiveLength
|
||||
}
|
||||
this[LENGTH_CALCULATOR] = lc
|
||||
|
||||
this[ALLOW_STALE] = options.stale || false
|
||||
this[MAX_AGE] = options.maxAge || 0
|
||||
this[DISPOSE] = options.dispose
|
||||
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
|
||||
this.reset()
|
||||
}
|
||||
|
||||
// resize the cache when the max changes.
|
||||
Object.defineProperty(LRUCache.prototype, 'max', {
|
||||
set: function (mL) {
|
||||
if (!mL || !(typeof mL === 'number') || mL <= 0) {
|
||||
mL = Infinity
|
||||
}
|
||||
this[MAX] = mL
|
||||
trim(this)
|
||||
},
|
||||
get: function () {
|
||||
return this[MAX]
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'allowStale', {
|
||||
set: function (allowStale) {
|
||||
this[ALLOW_STALE] = !!allowStale
|
||||
},
|
||||
get: function () {
|
||||
return this[ALLOW_STALE]
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'maxAge', {
|
||||
set: function (mA) {
|
||||
if (!mA || !(typeof mA === 'number') || mA < 0) {
|
||||
mA = 0
|
||||
}
|
||||
this[MAX_AGE] = mA
|
||||
trim(this)
|
||||
},
|
||||
get: function () {
|
||||
return this[MAX_AGE]
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
// resize the cache when the lengthCalculator changes.
|
||||
Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
|
||||
set: function (lC) {
|
||||
if (typeof lC !== 'function') {
|
||||
lC = naiveLength
|
||||
}
|
||||
if (lC !== this[LENGTH_CALCULATOR]) {
|
||||
this[LENGTH_CALCULATOR] = lC
|
||||
this[LENGTH] = 0
|
||||
this[LRU_LIST].forEach(function (hit) {
|
||||
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
|
||||
this[LENGTH] += hit.length
|
||||
}, this)
|
||||
}
|
||||
trim(this)
|
||||
},
|
||||
get: function () { return this[LENGTH_CALCULATOR] },
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'length', {
|
||||
get: function () { return this[LENGTH] },
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'itemCount', {
|
||||
get: function () { return this[LRU_LIST].length },
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
LRUCache.prototype.rforEach = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this[LRU_LIST].tail; walker !== null;) {
|
||||
var prev = walker.prev
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
|
||||
function forEachStep (self, fn, node, thisp) {
|
||||
var hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE]) {
|
||||
hit = undefined
|
||||
}
|
||||
}
|
||||
if (hit) {
|
||||
fn.call(thisp, hit.value, hit.key, self)
|
||||
}
|
||||
}
|
||||
|
||||
LRUCache.prototype.forEach = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this[LRU_LIST].head; walker !== null;) {
|
||||
var next = walker.next
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = next
|
||||
}
|
||||
}
|
||||
|
||||
LRUCache.prototype.keys = function () {
|
||||
return this[LRU_LIST].toArray().map(function (k) {
|
||||
return k.key
|
||||
}, this)
|
||||
}
|
||||
|
||||
LRUCache.prototype.values = function () {
|
||||
return this[LRU_LIST].toArray().map(function (k) {
|
||||
return k.value
|
||||
}, this)
|
||||
}
|
||||
|
||||
LRUCache.prototype.reset = function () {
|
||||
if (this[DISPOSE] &&
|
||||
this[LRU_LIST] &&
|
||||
this[LRU_LIST].length) {
|
||||
this[LRU_LIST].forEach(function (hit) {
|
||||
this[DISPOSE](hit.key, hit.value)
|
||||
}, this)
|
||||
}
|
||||
|
||||
this[CACHE] = new Map() // hash of items by key
|
||||
this[LRU_LIST] = new Yallist() // list of items in order of use recency
|
||||
this[LENGTH] = 0 // length of items in the list
|
||||
}
|
||||
|
||||
LRUCache.prototype.dump = function () {
|
||||
return this[LRU_LIST].map(function (hit) {
|
||||
if (!isStale(this, hit)) {
|
||||
return {
|
||||
k: hit.key,
|
||||
v: hit.value,
|
||||
e: hit.now + (hit.maxAge || 0)
|
||||
}
|
||||
}
|
||||
}, this).toArray().filter(function (h) {
|
||||
return h
|
||||
})
|
||||
}
|
||||
|
||||
LRUCache.prototype.dumpLru = function () {
|
||||
return this[LRU_LIST]
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
LRUCache.prototype.inspect = function (n, opts) {
|
||||
var str = 'LRUCache {'
|
||||
var extras = false
|
||||
|
||||
var as = this[ALLOW_STALE]
|
||||
if (as) {
|
||||
str += '\n allowStale: true'
|
||||
extras = true
|
||||
}
|
||||
|
||||
var max = this[MAX]
|
||||
if (max && max !== Infinity) {
|
||||
if (extras) {
|
||||
str += ','
|
||||
}
|
||||
str += '\n max: ' + util.inspect(max, opts)
|
||||
extras = true
|
||||
}
|
||||
|
||||
var maxAge = this[MAX_AGE]
|
||||
if (maxAge) {
|
||||
if (extras) {
|
||||
str += ','
|
||||
}
|
||||
str += '\n maxAge: ' + util.inspect(maxAge, opts)
|
||||
extras = true
|
||||
}
|
||||
|
||||
var lc = this[LENGTH_CALCULATOR]
|
||||
if (lc && lc !== naiveLength) {
|
||||
if (extras) {
|
||||
str += ','
|
||||
}
|
||||
str += '\n length: ' + util.inspect(this[LENGTH], opts)
|
||||
extras = true
|
||||
}
|
||||
|
||||
var didFirst = false
|
||||
this[LRU_LIST].forEach(function (item) {
|
||||
if (didFirst) {
|
||||
str += ',\n '
|
||||
} else {
|
||||
if (extras) {
|
||||
str += ',\n'
|
||||
}
|
||||
didFirst = true
|
||||
str += '\n '
|
||||
}
|
||||
var key = util.inspect(item.key).split('\n').join('\n ')
|
||||
var val = { value: item.value }
|
||||
if (item.maxAge !== maxAge) {
|
||||
val.maxAge = item.maxAge
|
||||
}
|
||||
if (lc !== naiveLength) {
|
||||
val.length = item.length
|
||||
}
|
||||
if (isStale(this, item)) {
|
||||
val.stale = true
|
||||
}
|
||||
|
||||
val = util.inspect(val, opts).split('\n').join('\n ')
|
||||
str += key + ' => ' + val
|
||||
})
|
||||
|
||||
if (didFirst || extras) {
|
||||
str += '\n'
|
||||
}
|
||||
str += '}'
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
LRUCache.prototype.set = function (key, value, maxAge) {
|
||||
maxAge = maxAge || this[MAX_AGE]
|
||||
|
||||
var now = maxAge ? Date.now() : 0
|
||||
var len = this[LENGTH_CALCULATOR](value, key)
|
||||
|
||||
if (this[CACHE].has(key)) {
|
||||
if (len > this[MAX]) {
|
||||
del(this, this[CACHE].get(key))
|
||||
return false
|
||||
}
|
||||
|
||||
var node = this[CACHE].get(key)
|
||||
var item = node.value
|
||||
|
||||
// dispose of the old one before overwriting
|
||||
// split out into 2 ifs for better coverage tracking
|
||||
if (this[DISPOSE]) {
|
||||
if (!this[NO_DISPOSE_ON_SET]) {
|
||||
this[DISPOSE](key, item.value)
|
||||
}
|
||||
}
|
||||
|
||||
item.now = now
|
||||
item.maxAge = maxAge
|
||||
item.value = value
|
||||
this[LENGTH] += len - item.length
|
||||
item.length = len
|
||||
this.get(key)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
var hit = new Entry(key, value, len, now, maxAge)
|
||||
|
||||
// oversized objects fall out of cache automatically.
|
||||
if (hit.length > this[MAX]) {
|
||||
if (this[DISPOSE]) {
|
||||
this[DISPOSE](key, value)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
this[LENGTH] += hit.length
|
||||
this[LRU_LIST].unshift(hit)
|
||||
this[CACHE].set(key, this[LRU_LIST].head)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
LRUCache.prototype.has = function (key) {
|
||||
if (!this[CACHE].has(key)) return false
|
||||
var hit = this[CACHE].get(key).value
|
||||
if (isStale(this, hit)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
LRUCache.prototype.get = function (key) {
|
||||
return get(this, key, true)
|
||||
}
|
||||
|
||||
LRUCache.prototype.peek = function (key) {
|
||||
return get(this, key, false)
|
||||
}
|
||||
|
||||
LRUCache.prototype.pop = function () {
|
||||
var node = this[LRU_LIST].tail
|
||||
if (!node) return null
|
||||
del(this, node)
|
||||
return node.value
|
||||
}
|
||||
|
||||
LRUCache.prototype.del = function (key) {
|
||||
del(this, this[CACHE].get(key))
|
||||
}
|
||||
|
||||
LRUCache.prototype.load = function (arr) {
|
||||
// reset the cache
|
||||
this.reset()
|
||||
|
||||
var now = Date.now()
|
||||
// A previous serialized cache has the most recent items first
|
||||
for (var l = arr.length - 1; l >= 0; l--) {
|
||||
var hit = arr[l]
|
||||
var expiresAt = hit.e || 0
|
||||
if (expiresAt === 0) {
|
||||
// the item was created without expiration in a non aged cache
|
||||
this.set(hit.k, hit.v)
|
||||
} else {
|
||||
var maxAge = expiresAt - now
|
||||
// dont add already expired items
|
||||
if (maxAge > 0) {
|
||||
this.set(hit.k, hit.v, maxAge)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LRUCache.prototype.prune = function () {
|
||||
var self = this
|
||||
this[CACHE].forEach(function (value, key) {
|
||||
get(self, key, false)
|
||||
})
|
||||
}
|
||||
|
||||
function get (self, key, doUse) {
|
||||
var node = self[CACHE].get(key)
|
||||
if (node) {
|
||||
var hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE]) hit = undefined
|
||||
} else {
|
||||
if (doUse) {
|
||||
self[LRU_LIST].unshiftNode(node)
|
||||
}
|
||||
}
|
||||
if (hit) hit = hit.value
|
||||
}
|
||||
return hit
|
||||
}
|
||||
|
||||
function isStale (self, hit) {
|
||||
if (!hit || (!hit.maxAge && !self[MAX_AGE])) {
|
||||
return false
|
||||
}
|
||||
var stale = false
|
||||
var diff = Date.now() - hit.now
|
||||
if (hit.maxAge) {
|
||||
stale = diff > hit.maxAge
|
||||
} else {
|
||||
stale = self[MAX_AGE] && (diff > self[MAX_AGE])
|
||||
}
|
||||
return stale
|
||||
}
|
||||
|
||||
function trim (self) {
|
||||
if (self[LENGTH] > self[MAX]) {
|
||||
for (var walker = self[LRU_LIST].tail;
|
||||
self[LENGTH] > self[MAX] && walker !== null;) {
|
||||
// We know that we're about to delete this one, and also
|
||||
// what the next least recently used key will be, so just
|
||||
// go ahead and set it now.
|
||||
var prev = walker.prev
|
||||
del(self, walker)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function del (self, node) {
|
||||
if (node) {
|
||||
var hit = node.value
|
||||
if (self[DISPOSE]) {
|
||||
self[DISPOSE](hit.key, hit.value)
|
||||
}
|
||||
self[LENGTH] -= hit.length
|
||||
self[CACHE].delete(hit.key)
|
||||
self[LRU_LIST].removeNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
// classy, since V8 prefers predictable objects.
|
||||
function Entry (key, value, length, now, maxAge) {
|
||||
this.key = key
|
||||
this.value = value
|
||||
this.length = length
|
||||
this.now = now
|
||||
this.maxAge = maxAge || 0
|
||||
}
|
71
express-server/node_modules/google-auto-auth/node_modules/lru-cache/package.json
generated
vendored
Normal file
71
express-server/node_modules/google-auto-auth/node_modules/lru-cache/package.json
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
"_from": "lru-cache@^4.1.3",
|
||||
"_id": "lru-cache@4.1.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
|
||||
"_location": "/google-auto-auth/lru-cache",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "lru-cache@^4.1.3",
|
||||
"name": "lru-cache",
|
||||
"escapedName": "lru-cache",
|
||||
"rawSpec": "^4.1.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.1.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/google-auto-auth/google-auth-library"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
|
||||
"_shasum": "8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd",
|
||||
"_spec": "lru-cache@^4.1.3",
|
||||
"_where": "D:\\Desktop\\Git\\Firebase\\SmartShopperFirebase\\node_modules\\google-auto-auth\\node_modules\\google-auth-library",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/node-lru-cache/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"pseudomap": "^1.0.2",
|
||||
"yallist": "^2.1.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "A cache object that deletes the least-recently-used items.",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"standard": "^12.0.1",
|
||||
"tap": "^12.1.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/node-lru-cache#readme",
|
||||
"keywords": [
|
||||
"mru",
|
||||
"lru",
|
||||
"cache"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "lru-cache",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/node-lru-cache.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coveragerport": "tap --coverage-report=html",
|
||||
"lintfix": "standard --fix test/*.js index.js",
|
||||
"postpublish": "git push origin --all; git push origin --tags",
|
||||
"posttest": "standard test/*.js index.js",
|
||||
"postversion": "npm publish --tag=legacy",
|
||||
"preversion": "npm test",
|
||||
"snap": "TAP_SNAPSHOT=1 tap test/*.js -J",
|
||||
"test": "tap test/*.js --100 -J"
|
||||
},
|
||||
"version": "4.1.5"
|
||||
}
|
15
express-server/node_modules/google-auto-auth/node_modules/yallist/LICENSE
generated
vendored
Normal file
15
express-server/node_modules/google-auto-auth/node_modules/yallist/LICENSE
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
204
express-server/node_modules/google-auto-auth/node_modules/yallist/README.md
generated
vendored
Normal file
204
express-server/node_modules/google-auto-auth/node_modules/yallist/README.md
generated
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
# yallist
|
||||
|
||||
Yet Another Linked List
|
||||
|
||||
There are many doubly-linked list implementations like it, but this
|
||||
one is mine.
|
||||
|
||||
For when an array would be too big, and a Map can't be iterated in
|
||||
reverse order.
|
||||
|
||||
|
||||
[](https://travis-ci.org/isaacs/yallist) [](https://coveralls.io/github/isaacs/yallist)
|
||||
|
||||
## basic usage
|
||||
|
||||
```javascript
|
||||
var yallist = require('yallist')
|
||||
var myList = yallist.create([1, 2, 3])
|
||||
myList.push('foo')
|
||||
myList.unshift('bar')
|
||||
// of course pop() and shift() are there, too
|
||||
console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']
|
||||
myList.forEach(function (k) {
|
||||
// walk the list head to tail
|
||||
})
|
||||
myList.forEachReverse(function (k, index, list) {
|
||||
// walk the list tail to head
|
||||
})
|
||||
var myDoubledList = myList.map(function (k) {
|
||||
return k + k
|
||||
})
|
||||
// now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']
|
||||
// mapReverse is also a thing
|
||||
var myDoubledListReverse = myList.mapReverse(function (k) {
|
||||
return k + k
|
||||
}) // ['foofoo', 6, 4, 2, 'barbar']
|
||||
|
||||
var reduced = myList.reduce(function (set, entry) {
|
||||
set += entry
|
||||
return set
|
||||
}, 'start')
|
||||
console.log(reduced) // 'startfoo123bar'
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
The whole API is considered "public".
|
||||
|
||||
Functions with the same name as an Array method work more or less the
|
||||
same way.
|
||||
|
||||
There's reverse versions of most things because that's the point.
|
||||
|
||||
### Yallist
|
||||
|
||||
Default export, the class that holds and manages a list.
|
||||
|
||||
Call it with either a forEach-able (like an array) or a set of
|
||||
arguments, to initialize the list.
|
||||
|
||||
The Array-ish methods all act like you'd expect. No magic length,
|
||||
though, so if you change that it won't automatically prune or add
|
||||
empty spots.
|
||||
|
||||
### Yallist.create(..)
|
||||
|
||||
Alias for Yallist function. Some people like factories.
|
||||
|
||||
#### yallist.head
|
||||
|
||||
The first node in the list
|
||||
|
||||
#### yallist.tail
|
||||
|
||||
The last node in the list
|
||||
|
||||
#### yallist.length
|
||||
|
||||
The number of nodes in the list. (Change this at your peril. It is
|
||||
not magic like Array length.)
|
||||
|
||||
#### yallist.toArray()
|
||||
|
||||
Convert the list to an array.
|
||||
|
||||
#### yallist.forEach(fn, [thisp])
|
||||
|
||||
Call a function on each item in the list.
|
||||
|
||||
#### yallist.forEachReverse(fn, [thisp])
|
||||
|
||||
Call a function on each item in the list, in reverse order.
|
||||
|
||||
#### yallist.get(n)
|
||||
|
||||
Get the data at position `n` in the list. If you use this a lot,
|
||||
probably better off just using an Array.
|
||||
|
||||
#### yallist.getReverse(n)
|
||||
|
||||
Get the data at position `n`, counting from the tail.
|
||||
|
||||
#### yallist.map(fn, thisp)
|
||||
|
||||
Create a new Yallist with the result of calling the function on each
|
||||
item.
|
||||
|
||||
#### yallist.mapReverse(fn, thisp)
|
||||
|
||||
Same as `map`, but in reverse.
|
||||
|
||||
#### yallist.pop()
|
||||
|
||||
Get the data from the list tail, and remove the tail from the list.
|
||||
|
||||
#### yallist.push(item, ...)
|
||||
|
||||
Insert one or more items to the tail of the list.
|
||||
|
||||
#### yallist.reduce(fn, initialValue)
|
||||
|
||||
Like Array.reduce.
|
||||
|
||||
#### yallist.reduceReverse
|
||||
|
||||
Like Array.reduce, but in reverse.
|
||||
|
||||
#### yallist.reverse
|
||||
|
||||
Reverse the list in place.
|
||||
|
||||
#### yallist.shift()
|
||||
|
||||
Get the data from the list head, and remove the head from the list.
|
||||
|
||||
#### yallist.slice([from], [to])
|
||||
|
||||
Just like Array.slice, but returns a new Yallist.
|
||||
|
||||
#### yallist.sliceReverse([from], [to])
|
||||
|
||||
Just like yallist.slice, but the result is returned in reverse.
|
||||
|
||||
#### yallist.toArray()
|
||||
|
||||
Create an array representation of the list.
|
||||
|
||||
#### yallist.toArrayReverse()
|
||||
|
||||
Create a reversed array representation of the list.
|
||||
|
||||
#### yallist.unshift(item, ...)
|
||||
|
||||
Insert one or more items to the head of the list.
|
||||
|
||||
#### yallist.unshiftNode(node)
|
||||
|
||||
Move a Node object to the front of the list. (That is, pull it out of
|
||||
wherever it lives, and make it the new head.)
|
||||
|
||||
If the node belongs to a different list, then that list will remove it
|
||||
first.
|
||||
|
||||
#### yallist.pushNode(node)
|
||||
|
||||
Move a Node object to the end of the list. (That is, pull it out of
|
||||
wherever it lives, and make it the new tail.)
|
||||
|
||||
If the node belongs to a list already, then that list will remove it
|
||||
first.
|
||||
|
||||
#### yallist.removeNode(node)
|
||||
|
||||
Remove a node from the list, preserving referential integrity of head
|
||||
and tail and other nodes.
|
||||
|
||||
Will throw an error if you try to have a list remove a node that
|
||||
doesn't belong to it.
|
||||
|
||||
### Yallist.Node
|
||||
|
||||
The class that holds the data and is actually the list.
|
||||
|
||||
Call with `var n = new Node(value, previousNode, nextNode)`
|
||||
|
||||
Note that if you do direct operations on Nodes themselves, it's very
|
||||
easy to get into weird states where the list is broken. Be careful :)
|
||||
|
||||
#### node.next
|
||||
|
||||
The next node in the list.
|
||||
|
||||
#### node.prev
|
||||
|
||||
The previous node in the list.
|
||||
|
||||
#### node.value
|
||||
|
||||
The data the node contains.
|
||||
|
||||
#### node.list
|
||||
|
||||
The list to which this node belongs. (Null if it does not belong to
|
||||
any list.)
|
7
express-server/node_modules/google-auto-auth/node_modules/yallist/iterator.js
generated
vendored
Normal file
7
express-server/node_modules/google-auto-auth/node_modules/yallist/iterator.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var Yallist = require('./yallist.js')
|
||||
|
||||
Yallist.prototype[Symbol.iterator] = function* () {
|
||||
for (let walker = this.head; walker; walker = walker.next) {
|
||||
yield walker.value
|
||||
}
|
||||
}
|
62
express-server/node_modules/google-auto-auth/node_modules/yallist/package.json
generated
vendored
Normal file
62
express-server/node_modules/google-auto-auth/node_modules/yallist/package.json
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"_from": "yallist@^2.1.2",
|
||||
"_id": "yallist@2.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
|
||||
"_location": "/google-auto-auth/yallist",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "yallist@^2.1.2",
|
||||
"name": "yallist",
|
||||
"escapedName": "yallist",
|
||||
"rawSpec": "^2.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/google-auto-auth/lru-cache"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||
"_shasum": "1c11f9218f076089a47dd512f93c6699a6a81d52",
|
||||
"_spec": "yallist@^2.1.2",
|
||||
"_where": "D:\\Desktop\\Git\\Firebase\\SmartShopperFirebase\\node_modules\\google-auto-auth\\node_modules\\lru-cache",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/yallist/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Yet Another Linked List",
|
||||
"devDependencies": {
|
||||
"tap": "^10.3.0"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"files": [
|
||||
"yallist.js",
|
||||
"iterator.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/yallist#readme",
|
||||
"license": "ISC",
|
||||
"main": "yallist.js",
|
||||
"name": "yallist",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/isaacs/yallist.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postpublish": "git push origin --all; git push origin --tags",
|
||||
"postversion": "npm publish",
|
||||
"preversion": "npm test",
|
||||
"test": "tap test/*.js --100"
|
||||
},
|
||||
"version": "2.1.2"
|
||||
}
|
370
express-server/node_modules/google-auto-auth/node_modules/yallist/yallist.js
generated
vendored
Normal file
370
express-server/node_modules/google-auto-auth/node_modules/yallist/yallist.js
generated
vendored
Normal file
@ -0,0 +1,370 @@
|
||||
module.exports = Yallist
|
||||
|
||||
Yallist.Node = Node
|
||||
Yallist.create = Yallist
|
||||
|
||||
function Yallist (list) {
|
||||
var self = this
|
||||
if (!(self instanceof Yallist)) {
|
||||
self = new Yallist()
|
||||
}
|
||||
|
||||
self.tail = null
|
||||
self.head = null
|
||||
self.length = 0
|
||||
|
||||
if (list && typeof list.forEach === 'function') {
|
||||
list.forEach(function (item) {
|
||||
self.push(item)
|
||||
})
|
||||
} else if (arguments.length > 0) {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
self.push(arguments[i])
|
||||
}
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
Yallist.prototype.removeNode = function (node) {
|
||||
if (node.list !== this) {
|
||||
throw new Error('removing node which does not belong to this list')
|
||||
}
|
||||
|
||||
var next = node.next
|
||||
var prev = node.prev
|
||||
|
||||
if (next) {
|
||||
next.prev = prev
|
||||
}
|
||||
|
||||
if (prev) {
|
||||
prev.next = next
|
||||
}
|
||||
|
||||
if (node === this.head) {
|
||||
this.head = next
|
||||
}
|
||||
if (node === this.tail) {
|
||||
this.tail = prev
|
||||
}
|
||||
|
||||
node.list.length--
|
||||
node.next = null
|
||||
node.prev = null
|
||||
node.list = null
|
||||
}
|
||||
|
||||
Yallist.prototype.unshiftNode = function (node) {
|
||||
if (node === this.head) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node)
|
||||
}
|
||||
|
||||
var head = this.head
|
||||
node.list = this
|
||||
node.next = head
|
||||
if (head) {
|
||||
head.prev = node
|
||||
}
|
||||
|
||||
this.head = node
|
||||
if (!this.tail) {
|
||||
this.tail = node
|
||||
}
|
||||
this.length++
|
||||
}
|
||||
|
||||
Yallist.prototype.pushNode = function (node) {
|
||||
if (node === this.tail) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node)
|
||||
}
|
||||
|
||||
var tail = this.tail
|
||||
node.list = this
|
||||
node.prev = tail
|
||||
if (tail) {
|
||||
tail.next = node
|
||||
}
|
||||
|
||||
this.tail = node
|
||||
if (!this.head) {
|
||||
this.head = node
|
||||
}
|
||||
this.length++
|
||||
}
|
||||
|
||||
Yallist.prototype.push = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
push(this, arguments[i])
|
||||
}
|
||||
return this.length
|
||||
}
|
||||
|
||||
Yallist.prototype.unshift = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
unshift(this, arguments[i])
|
||||
}
|
||||
return this.length
|
||||
}
|
||||
|
||||
Yallist.prototype.pop = function () {
|
||||
if (!this.tail) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.tail.value
|
||||
this.tail = this.tail.prev
|
||||
if (this.tail) {
|
||||
this.tail.next = null
|
||||
} else {
|
||||
this.head = null
|
||||
}
|
||||
this.length--
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.shift = function () {
|
||||
if (!this.head) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.head.value
|
||||
this.head = this.head.next
|
||||
if (this.head) {
|
||||
this.head.prev = null
|
||||
} else {
|
||||
this.tail = null
|
||||
}
|
||||
this.length--
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.forEach = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this.head, i = 0; walker !== null; i++) {
|
||||
fn.call(thisp, walker.value, i, this)
|
||||
walker = walker.next
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
||||
fn.call(thisp, walker.value, i, this)
|
||||
walker = walker.prev
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.get = function (n) {
|
||||
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.next
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.getReverse = function (n) {
|
||||
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.prev
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.map = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
var res = new Yallist()
|
||||
for (var walker = this.head; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this))
|
||||
walker = walker.next
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.mapReverse = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
var res = new Yallist()
|
||||
for (var walker = this.tail; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this))
|
||||
walker = walker.prev
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.reduce = function (fn, initial) {
|
||||
var acc
|
||||
var walker = this.head
|
||||
if (arguments.length > 1) {
|
||||
acc = initial
|
||||
} else if (this.head) {
|
||||
walker = this.head.next
|
||||
acc = this.head.value
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = 0; walker !== null; i++) {
|
||||
acc = fn(acc, walker.value, i)
|
||||
walker = walker.next
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
Yallist.prototype.reduceReverse = function (fn, initial) {
|
||||
var acc
|
||||
var walker = this.tail
|
||||
if (arguments.length > 1) {
|
||||
acc = initial
|
||||
} else if (this.tail) {
|
||||
walker = this.tail.prev
|
||||
acc = this.tail.value
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = this.length - 1; walker !== null; i--) {
|
||||
acc = fn(acc, walker.value, i)
|
||||
walker = walker.prev
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
Yallist.prototype.toArray = function () {
|
||||
var arr = new Array(this.length)
|
||||
for (var i = 0, walker = this.head; walker !== null; i++) {
|
||||
arr[i] = walker.value
|
||||
walker = walker.next
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
Yallist.prototype.toArrayReverse = function () {
|
||||
var arr = new Array(this.length)
|
||||
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
||||
arr[i] = walker.value
|
||||
walker = walker.prev
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
Yallist.prototype.slice = function (from, to) {
|
||||
to = to || this.length
|
||||
if (to < 0) {
|
||||
to += this.length
|
||||
}
|
||||
from = from || 0
|
||||
if (from < 0) {
|
||||
from += this.length
|
||||
}
|
||||
var ret = new Yallist()
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length
|
||||
}
|
||||
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
||||
walker = walker.next
|
||||
}
|
||||
for (; walker !== null && i < to; i++, walker = walker.next) {
|
||||
ret.push(walker.value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
Yallist.prototype.sliceReverse = function (from, to) {
|
||||
to = to || this.length
|
||||
if (to < 0) {
|
||||
to += this.length
|
||||
}
|
||||
from = from || 0
|
||||
if (from < 0) {
|
||||
from += this.length
|
||||
}
|
||||
var ret = new Yallist()
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length
|
||||
}
|
||||
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
||||
walker = walker.prev
|
||||
}
|
||||
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
||||
ret.push(walker.value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
Yallist.prototype.reverse = function () {
|
||||
var head = this.head
|
||||
var tail = this.tail
|
||||
for (var walker = head; walker !== null; walker = walker.prev) {
|
||||
var p = walker.prev
|
||||
walker.prev = walker.next
|
||||
walker.next = p
|
||||
}
|
||||
this.head = tail
|
||||
this.tail = head
|
||||
return this
|
||||
}
|
||||
|
||||
function push (self, item) {
|
||||
self.tail = new Node(item, self.tail, null, self)
|
||||
if (!self.head) {
|
||||
self.head = self.tail
|
||||
}
|
||||
self.length++
|
||||
}
|
||||
|
||||
function unshift (self, item) {
|
||||
self.head = new Node(item, null, self.head, self)
|
||||
if (!self.tail) {
|
||||
self.tail = self.head
|
||||
}
|
||||
self.length++
|
||||
}
|
||||
|
||||
function Node (value, prev, next, list) {
|
||||
if (!(this instanceof Node)) {
|
||||
return new Node(value, prev, next, list)
|
||||
}
|
||||
|
||||
this.list = list
|
||||
this.value = value
|
||||
|
||||
if (prev) {
|
||||
prev.next = this
|
||||
this.prev = prev
|
||||
} else {
|
||||
this.prev = null
|
||||
}
|
||||
|
||||
if (next) {
|
||||
next.prev = this
|
||||
this.next = next
|
||||
} else {
|
||||
this.next = null
|
||||
}
|
||||
}
|
88
express-server/node_modules/google-auto-auth/package.json
generated
vendored
Normal file
88
express-server/node_modules/google-auto-auth/package.json
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
{
|
||||
"_from": "google-auto-auth@^0.10.0",
|
||||
"_id": "google-auto-auth@0.10.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-iIqSbY7Ypd32mnHGbYctp80vZzXoDlvI9gEfvtl3kmyy5HzOcrZCIGCBdSlIzRsg7nHpQiHE3Zl6Ycur6TSodQ==",
|
||||
"_location": "/google-auto-auth",
|
||||
"_phantomChildren": {
|
||||
"axios": "0.18.0",
|
||||
"extend": "3.0.2",
|
||||
"gtoken": "2.3.0",
|
||||
"jws": "3.1.5",
|
||||
"lodash.isstring": "4.0.1",
|
||||
"pseudomap": "1.0.2",
|
||||
"retry-axios": "0.3.2"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "google-auto-auth@^0.10.0",
|
||||
"name": "google-auto-auth",
|
||||
"escapedName": "google-auto-auth",
|
||||
"rawSpec": "^0.10.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.10.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@google-cloud/common",
|
||||
"/gcs-resumable-upload"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/google-auto-auth/-/google-auto-auth-0.10.1.tgz",
|
||||
"_shasum": "68834a6f3da59a6cb27fce56f76e3d99ee49d0a2",
|
||||
"_spec": "google-auto-auth@^0.10.0",
|
||||
"_where": "D:\\Desktop\\Git\\Firebase\\SmartShopperFirebase\\node_modules\\@google-cloud\\common",
|
||||
"author": {
|
||||
"name": "Stephen Sawchuk",
|
||||
"email": "sawchuk@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stephenplusplus/google-auto-auth/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"async": "^2.3.0",
|
||||
"gcp-metadata": "^0.6.1",
|
||||
"google-auth-library": "^1.3.1",
|
||||
"request": "^2.79.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Making it as easy as possible to authenticate a Google API request",
|
||||
"devDependencies": {
|
||||
"mocha": "^5.0.0",
|
||||
"mockery": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/stephenplusplus/google-auto-auth#readme",
|
||||
"keywords": [
|
||||
"google",
|
||||
"authentication",
|
||||
"jwt",
|
||||
"service",
|
||||
"account",
|
||||
"googleapis",
|
||||
"gcloud",
|
||||
"cloud",
|
||||
"gce",
|
||||
"compute",
|
||||
"engine",
|
||||
"auth",
|
||||
"access",
|
||||
"token"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "google-auto-auth",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/stephenplusplus/google-auto-auth.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --timeout 0"
|
||||
},
|
||||
"version": "0.10.1"
|
||||
}
|
283
express-server/node_modules/google-auto-auth/readme.md
generated
vendored
Normal file
283
express-server/node_modules/google-auto-auth/readme.md
generated
vendored
Normal file
@ -0,0 +1,283 @@
|
||||
# google-auto-auth
|
||||
> Making it as easy as possible to authenticate a Google API request
|
||||
|
||||
```sh
|
||||
$ npm install --save google-auto-auth
|
||||
```
|
||||
```js
|
||||
var googleAuth = require('google-auto-auth');
|
||||
|
||||
// Create a client
|
||||
var auth = googleAuth();
|
||||
|
||||
auth.authorizeRequest({
|
||||
method: 'get',
|
||||
uri: 'https://www.googleapis.com/something'
|
||||
}, function (err, authorizedReqOpts) {
|
||||
/*
|
||||
authorizedReqOpts = {
|
||||
method: 'get',
|
||||
uri: 'https://www.googleapis.com/something',
|
||||
headers: {
|
||||
Authorization: 'Bearer {{token}}'
|
||||
}
|
||||
}
|
||||
*/
|
||||
});
|
||||
```
|
||||
|
||||
Or, just get an access token.
|
||||
```js
|
||||
auth.getToken(function (err, token) {
|
||||
/*
|
||||
token = 'access token'
|
||||
*/
|
||||
});
|
||||
```
|
||||
|
||||
<a name="automatic-if"></a>
|
||||
This works automatically **if**:
|
||||
|
||||
- your app runs on Google Cloud Platform
|
||||
- you are authenticated with the `gcloud` sdk
|
||||
- you have the path to a JSON key file as an environment variable named `GOOGLE_APPLICATION_CREDENTIALS`
|
||||
|
||||
If you do not meet those, you must provide a `keyFilename` or `credentials` object.
|
||||
|
||||
```js
|
||||
var googleAuth = require('google-auto-auth');
|
||||
|
||||
var authConfig = {};
|
||||
|
||||
// path to a key:
|
||||
authConfig.keyFilename = '/path/to/keyfile.json';
|
||||
|
||||
// or a credentials object:
|
||||
authConfig.credentials = {
|
||||
client_email: '...',
|
||||
private_key: '...'
|
||||
};
|
||||
|
||||
// Create a client
|
||||
var auth = googleAuth(authConfig);
|
||||
|
||||
auth.authorizeRequest({/*...*/}, function (err, authorizedReqOpts) {});
|
||||
auth.getToken(function (err, token) {});
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
#### googleAuth = require('google-auto-auth')
|
||||
|
||||
#### auth = googleAuth([authConfig])
|
||||
|
||||
##### authConfig
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
See the above section on Authentication. This object is necessary if automatic authentication is not available in your environment.
|
||||
|
||||
At a glance, the supported properties for this method are:
|
||||
|
||||
- `credentials` - Object containing `client_email` and `private_key` properties
|
||||
- `keyFilename` - Path to a .json, .pem, or .p12 key file
|
||||
- `projectId` - Your project ID
|
||||
- `scopes` - Required scopes for the desired API request
|
||||
- `token` - An access token. If provided, we'll use this instead of fetching a new one
|
||||
|
||||
#### auth.authorizeRequest(reqOpts, callback)
|
||||
|
||||
Extend an HTTP request object with an authorized header.
|
||||
|
||||
##### callback(err, authorizedReqOpts)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
An API error or an error if scopes are required for the request you're trying to make (check for err.code = `MISSING_SCOPE`). If you receive the missing scope error, provide the `authConfig.scopes` array with the necessary scope URLs for your request. There are examples of scopes that are required for some of the Google Cloud Platform services in the [gcloud-node Authentication Guide](https://googlecloudplatform.github.io/gcloud-node/#/authentication).
|
||||
|
||||
###### callback.authorizedReqOpts
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
The reqOpts object provided has been extended with a valid access token attached to the `headers.Authorization` value. E.g.: `headers.Authorization = 'Bearer y.2343...'`.
|
||||
|
||||
#### auth.getAuthClient(callback)
|
||||
|
||||
Get the auth client instance from [google-auth-library](http://gitnpm.com/googleauth).
|
||||
|
||||
##### callback(err, authClient)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
An error that occurred while trying to get an authorization client.
|
||||
|
||||
###### callback.authClient
|
||||
|
||||
- Type: [`google-auth-library`](http://gitnpm.com/googleauth)
|
||||
|
||||
The client instance from [google-auth-library](http://gitnpm.com/googleauth). This is the underlying object this library uses.
|
||||
|
||||
|
||||
#### auth.getCredentials(callback)
|
||||
|
||||
Get the `client_email` and `private_key` properties from an authorized client.
|
||||
|
||||
##### callback(err, credentials)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
An error that occurred while trying to get an authorization client.
|
||||
|
||||
###### callback.credentials
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
An object containing `client_email` and `private_key`.
|
||||
|
||||
|
||||
#### auth.getEnvironment(callback)
|
||||
|
||||
Determine if the environment the app is running in is a Google Compute Engine instance.
|
||||
|
||||
##### callback(err, environmentObject)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Null`
|
||||
|
||||
We won't return an error, but it's here for convention-sake.
|
||||
|
||||
###### callback.environmentObject
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
```js
|
||||
{
|
||||
IS_APP_ENGINE: Boolean,
|
||||
IS_CLOUD_FUNCTION: Boolean,
|
||||
IS_COMPUTE_ENGINE: Boolean,
|
||||
IS_CONTAINER_ENGINE: Boolean
|
||||
}
|
||||
```
|
||||
|
||||
If you've already run this function, the object will persist as `auth.environment`.
|
||||
|
||||
|
||||
#### auth.getProjectId(callback)
|
||||
|
||||
Get the project ID if it was auto-detected or parsed from the provided keyfile.
|
||||
|
||||
##### callback(err, projectId)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
An error that occurred while trying to get an authorization client.
|
||||
|
||||
###### callback.projectId
|
||||
|
||||
- Type: `string`
|
||||
|
||||
The project ID that was parsed from the provided key file or auto-detected from the environment.
|
||||
|
||||
|
||||
#### auth.getToken(callback)
|
||||
|
||||
Get an access token. The token will always be current. If necessary, background refreshes are handled automatically.
|
||||
|
||||
##### callback(err, token)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Error`
|
||||
|
||||
An API error or an error if scopes are required for the request you're trying to make (check for err.code = `MISSING_SCOPE`). If you receive the missing scope error, provide the `authConfig.scopes` array with the necessary scope URLs for your request.
|
||||
|
||||
###### callback.token
|
||||
|
||||
- Type: `String`
|
||||
|
||||
A current access token to be used during an API request. If you provided `authConfig.token`, this method simply returns the value you passed.
|
||||
|
||||
|
||||
#### auth.isAppEngine(callback)
|
||||
|
||||
Determine if the environment the app is running in is a Google App Engine instance.
|
||||
|
||||
##### callback(err, isAppEngine)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Null`
|
||||
|
||||
We won't return an error, but it's here for convention-sake.
|
||||
|
||||
###### callback.isAppEngine
|
||||
|
||||
- Type: `Boolean`
|
||||
|
||||
Whether the app is in App Engine or not.
|
||||
|
||||
|
||||
#### auth.isCloudFunction(callback)
|
||||
|
||||
Determine if the environment the app is running in is a Google Cloud Function.
|
||||
|
||||
##### callback(err, isCloudFunction)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Null`
|
||||
|
||||
We won't return an error, but it's here for convention-sake.
|
||||
|
||||
###### callback.isCloudFunction
|
||||
|
||||
- Type: `Boolean`
|
||||
|
||||
Whether the app is in a Cloud Function or not.
|
||||
|
||||
|
||||
#### auth.isComputeEngine(callback)
|
||||
|
||||
Determine if the environment the app is running in is a Google Compute Engine instance.
|
||||
|
||||
##### callback(err, isComputeEngine)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Null`
|
||||
|
||||
We won't return an error, but it's here for convention-sake.
|
||||
|
||||
###### callback.isComputeEngine
|
||||
|
||||
- Type: `Boolean`
|
||||
|
||||
Whether the app is in a Compute Engine instance or not.
|
||||
|
||||
|
||||
#### auth.isContainerEngine(callback)
|
||||
|
||||
Determine if the environment the app is running in is a Google Container Engine instance.
|
||||
|
||||
##### callback(err, isContainerEngine)
|
||||
|
||||
###### callback.err
|
||||
|
||||
- Type: `Null`
|
||||
|
||||
We won't return an error, but it's here for convention-sake.
|
||||
|
||||
###### callback.isContainerEngine
|
||||
|
||||
- Type: `Boolean`
|
||||
|
||||
Whether the app is in a Container Engine instance or not.
|
Reference in New Issue
Block a user