GoogleOauth2.0 First implementation

First try for GoogleOauth2.0
This commit is contained in:
Georg Reisinger
2018-10-26 14:02:15 +02:00
parent 216a04e233
commit b171f1646c
1880 changed files with 912953 additions and 7 deletions

20
express-server/node_modules/gcp-metadata/LICENSE generated vendored Normal file
View 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.

46
express-server/node_modules/gcp-metadata/README.md generated vendored Normal file
View File

@ -0,0 +1,46 @@
# gcp-metadata
> Get the metadata from a Google Cloud Platform environment.
[![NPM Version][npm-image]][npm-url]
[![CircleCI][circleimg]][circle]
[![codecov][codecov-image]][codecov-url]
```sh
$ npm install --save gcp-metadata
```
```js
const gcpMetadata = require('gcp-metadata');
```
#### Check to see if the metadata server is available
```js
const isAvailable = await gcpMetadata.isAvailable();
```
#### 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
```
[circle]: https://circleci.com/gh/stephenplusplus/gcp-metadata
[circleimg]: https://circleci.com/gh/stephenplusplus/gcp-metadata.svg?style=shield
[codecov-image]: https://codecov.io/gh/stephenplusplus/gcp-metadata/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/stephenplusplus/gcp-metadata
[npm-image]: https://img.shields.io/npm/v/gcp-metadata.svg
[npm-url]: https://www.npmjs.com/package/gcp-metadata

View 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>;

View File

@ -0,0 +1,160 @@
"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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, 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 _a;
var axios_1 = __importDefault(require("axios"));
var extend_1 = __importDefault(require("extend"));
var rax = __importStar(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_1.default(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();
// Failure to resolve the metadata service means that it is not available.
if (err_1.code && (err_1.code === 'ENOTFOUND' || err_1.code === 'ENOENT')) {
return [2 /*return*/, false];
}
// Throw unexpected errors.
throw err_1;
case 3: return [2 /*return*/];
}
});
});
}
exports.isAvailable = isAvailable;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA2E;AAC3E,kDAA4B;AAC5B,+CAAmC;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,EA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O,KAAK,EAAC;qBACd;oBACD,2BAA2B;oBAC3B,MAAM,KAAG,CAAC;;;;;CAEb;AAfD,kCAeC"}

97
express-server/node_modules/gcp-metadata/package.json generated vendored Normal file
View File

@ -0,0 +1,97 @@
{
"_from": "gcp-metadata@^0.7.0",
"_id": "gcp-metadata@0.7.0",
"_inBundle": false,
"_integrity": "sha512-ffjC09amcDWjh3VZdkDngIo7WoluyC5Ag9PAYxZbmQLOLNI8lvPtoKTSCyU54j2gwy5roZh6sSMTfkY2ct7K3g==",
"_location": "/gcp-metadata",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "gcp-metadata@^0.7.0",
"name": "gcp-metadata",
"escapedName": "gcp-metadata",
"rawSpec": "^0.7.0",
"saveSpec": null,
"fetchSpec": "^0.7.0"
},
"_requiredBy": [
"/google-auth-library"
],
"_resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.7.0.tgz",
"_shasum": "6c35dbb52bda32a427bb9c98f54237ddd1b5406f",
"_spec": "gcp-metadata@^0.7.0",
"_where": "C:\\Users\\Georg\\GitHub\\SmartShopper\\express-server\\node_modules\\google-auth-library",
"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/mocha": "^5.2.4",
"@types/ncp": "^2.0.1",
"@types/nock": "^9.1.3",
"@types/node": "^10.1.0",
"@types/pify": "^3.0.2",
"@types/tmp": "0.0.33",
"assert-rejects": "^0.1.1",
"codecov": "^3.0.2",
"gts": "^0.7.0",
"hard-rejection": "^1.0.0",
"mocha": "^5.2.0",
"ncp": "^2.0.0",
"nock": "^9.2.6",
"nyc": "^12.0.0",
"pify": "^3.0.0",
"source-map-support": "^0.5.6",
"tmp": "0.0.33",
"typescript": "^2.8.3"
},
"engines": {
"node": ">=4"
},
"files": [
"build/src"
],
"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-only": "npm run compile",
"test": "npm run test-only",
"test-only": "nyc mocha build/test"
},
"types": "./build/src/index.d.ts",
"version": "0.7.0"
}