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

21
express-server/node_modules/google-p12-pem/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Ryan Seys
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.

68
express-server/node_modules/google-p12-pem/README.md generated vendored Normal file
View File

@ -0,0 +1,68 @@
# google-p12-pem
[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Dependency Status][david-image]][david-url]
[![devDependency Status][david-dev-image]][david-dev-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![Greenkeeper badge](https://badges.greenkeeper.io/google/google-p12-pem.svg)](https://greenkeeper.io/)
Convert Google `.p12` keys to `.pem` keys.
## Installation
``` sh
npm install google-p12-pem
```
## Usage
### async/await style
```js
const {getPem} = require('google-p12-pem');
async function foo() {
const pem = await getPem('/path/to/key.p12');
console.log(pem); // '-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAK...'
}
```
### promise style
```js
const {getPem} = require('google-p12-pem');
getPem('/path/to/key.p12')
.then(pem => {
console.log(pem); // '-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAK...'
})
.catch(err => {
console.error(err); // :(
});
```
### callback style
```js
const {getPem} = require('google-p12-pem');
getPem('/path/to/key.p12', function(err, pem) {
console.log(pem); // '-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAK...'
});
```
### CLI style
``` sh
gp12-pem myfile.p12 > output.pem
```
## License
[MIT](LICENSE)
[david-image]: https://david-dm.org/google/google-p12-pem.svg
[david-url]: https://david-dm.org/google/google-p12-pem
[david-dev-image]: https://david-dm.org/google/google-p12-pem/dev-status.svg
[david-dev-url]: https://david-dm.org/google/google-p12-pem?type=dev
[npm-image]: https://img.shields.io/npm/v/google-p12-pem.svg
[npm-url]: https://www.npmjs.com/package/google-p12-pem
[snyk-image]: https://snyk.io/test/github/google/google-p12-pem/badge.svg
[snyk-url]: https://snyk.io/test/github/google/google-p12-pem
[travis-image]: https://travis-ci.org/google/google-p12-pem.svg?branch=master
[travis-url]: https://travis-ci.org/google/google-p12-pem

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,20 @@
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var gp12 = require("../index");
var argv = process.argv;
var p12Path = argv[2];
if (!p12Path) {
console.error('Please specify a *.p12 file to convert.');
process.exit(1);
}
gp12.getPem(p12Path, function (err, pem) {
if (err) {
console.log(err);
process.exit(1);
}
else {
console.log(pem);
}
});
//# sourceMappingURL=gp12-pem.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"gp12-pem.js","sourceRoot":"","sources":["../../../src/bin/gp12-pem.ts"],"names":[],"mappings":";;;AACA,+BAAiC;AAEjC,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC1B,IAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAExB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACb,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,UAAC,GAAG,EAAE,GAAG;IAC5B,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACR,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,9 @@
/**
* Convert a .p12 file to .pem string
* @param filename The .p12 key filename.
* @param callback The callback function.
* @return A promise that resolves with the .pem private key
* if no callback provided.
*/
export declare function getPem(filename: string): Promise<string>;
export declare function getPem(filename: string, callback: (err: Error | null, pem: string | null) => void): void;

View File

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var forge = require("node-forge");
var pify = require("pify");
var readFile = pify(fs.readFile);
function getPem(filename, callback) {
if (callback) {
getPemAsync(filename)
.then(function (pem) { return callback(null, pem); })
.catch(function (err) { return callback(err, null); });
}
else {
return getPemAsync(filename);
}
}
exports.getPem = getPem;
function getPemAsync(filename) {
return readFile(filename, { encoding: 'base64' }).then(function (keyp12) {
return convertToPem(keyp12);
});
}
/**
* Converts a P12 in base64 encoding to a pem.
* @param p12base64 String containing base64 encoded p12.
* @returns a string containing the pem.
*/
function convertToPem(p12base64) {
var p12Der = forge.util.decode64(p12base64);
var p12Asn1 = forge.asn1.fromDer(p12Der);
var p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, 'notasecret');
var bags = p12.getBags({ friendlyName: 'privatekey' });
if (bags.friendlyName) {
var privateKey = bags.friendlyName[0].key;
var pem = forge.pki.privateKeyToPem(privateKey);
return pem.replace(/\r\n/g, '\n');
}
else {
throw new Error('Unable to get friendly name.');
}
}
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,uBAAyB;AACzB,kCAAoC;AACpC,2BAA6B;AAE7B,IAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAanC,gBACI,QAAgB,EAAE,QAAsD;IAE1E,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACb,WAAW,CAAC,QAAQ,CAAC;aAChB,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,EAAnB,CAAmB,CAAC;aAChC,KAAK,CAAC,UAAA,GAAG,IAAI,OAAA,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EAAnB,CAAmB,CAAC,CAAC;IACzC,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAVD,wBAUC;AAED,qBAAqB,QAAgB;IACnC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC,CAAC,IAAI,CAAC,UAAA,MAAM;QACzD,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,sBAAsB,SAAiB;IACrC,IAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC9C,IAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC/D,IAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,EAAC,YAAY,EAAE,YAAY,EAAC,CAAC,CAAC;IACvD,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACtB,IAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC5C,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}

View File

@ -0,0 +1,80 @@
{
"_from": "google-p12-pem@^1.0.0",
"_id": "google-p12-pem@1.0.2",
"_inBundle": false,
"_integrity": "sha512-+EuKr4CLlGsnXx4XIJIVkcKYrsa2xkAmCvxRhX2HsazJzUBAJ35wARGeApHUn4nNfPD03Vl057FskNr20VaCyg==",
"_location": "/google-p12-pem",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "google-p12-pem@^1.0.0",
"name": "google-p12-pem",
"escapedName": "google-p12-pem",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/gtoken"
],
"_resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-1.0.2.tgz",
"_shasum": "c8a3843504012283a0dbffc7430b7c753ecd4b07",
"_spec": "google-p12-pem@^1.0.0",
"_where": "C:\\Users\\Georg\\GitHub\\SmartShopper\\express-server\\node_modules\\gtoken",
"author": {
"name": "Ryan Seys"
},
"bin": {
"gp12-pem": "build/src/bin/gp12-pem.js"
},
"bugs": {
"url": "https://github.com/google/google-p12-pem/issues"
},
"bundleDependencies": false,
"dependencies": {
"node-forge": "^0.7.4",
"pify": "^3.0.0"
},
"deprecated": false,
"description": "Convert Google .p12 keys to .pem keys",
"devDependencies": {
"@types/mocha": "^2.2.48",
"@types/node": "^9.4.6",
"@types/node-forge": "^0.7.2",
"@types/pify": "^3.0.0",
"codecov": "^3.0.0",
"gts": "latest",
"js-green-licenses": "^0.5.0",
"mocha": "^5.0.2",
"nyc": "^11.4.1",
"typescript": "~2.7.2"
},
"files": [
"LICENSE",
"README.md",
"build/src"
],
"homepage": "https://github.com/google/google-p12-pem#readme",
"license": "MIT",
"main": "build/src/index.js",
"name": "google-p12-pem",
"repository": {
"type": "git",
"url": "git+https://github.com/google/google-p12-pem.git"
},
"scripts": {
"check": "gts check",
"clean": "gts clean",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
"compile": "tsc -p .",
"fix": "gts fix",
"license-check": "jsgl --local .",
"posttest": "npm run check && npm run license-check",
"prepare": "npm run compile",
"pretest": "npm run compile",
"test": "nyc mocha build/test"
},
"types": "./build/src/index.d.ts",
"version": "1.0.2"
}