mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-27 23:40:18 +00:00
push all website files
This commit is contained in:
377
website/functions/node_modules/google-auto-auth/index.js
generated
vendored
Normal file
377
website/functions/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
website/functions/node_modules/google-auto-auth/license
generated
vendored
Normal file
20
website/functions/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.
|
80
website/functions/node_modules/google-auto-auth/package.json
generated
vendored
Normal file
80
website/functions/node_modules/google-auto-auth/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"_from": "google-auto-auth@^0.10.0",
|
||||
"_id": "google-auto-auth@0.10.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-iIqSbY7Ypd32mnHGbYctp80vZzXoDlvI9gEfvtl3kmyy5HzOcrZCIGCBdSlIzRsg7nHpQiHE3Zl6Ycur6TSodQ==",
|
||||
"_location": "/google-auto-auth",
|
||||
"_phantomChildren": {},
|
||||
"_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": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\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
website/functions/node_modules/google-auto-auth/readme.md
generated
vendored
Normal file
283
website/functions/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