mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 14:22:33 +01:00
chore: prettier changes
This commit is contained in:
parent
d045d5be6c
commit
af2ef16c10
3 changed files with 94 additions and 96 deletions
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"printWidth": 100,
|
"printWidth": 80,
|
||||||
"trailingComma": "all",
|
"trailingComma": "all",
|
||||||
"tabWidth": 4,
|
"tabWidth": 4,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
|
|
110
package.json
110
package.json
|
@ -1,58 +1,58 @@
|
||||||
{
|
{
|
||||||
"name": "thunderhub",
|
"name": "thunderhub",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"build": "webpack --config webpack.development.js",
|
"build": "webpack --config webpack.development.js",
|
||||||
"start": "node dist/server",
|
"start": "node dist/server",
|
||||||
"dev": "nodemon dist/server"
|
"dev": "nodemon dist/server"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/apotdevin/thunderhub.git"
|
"url": "git+https://github.com/apotdevin/thunderhub.git"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/apotdevin/thunderhub/issues"
|
"url": "https://github.com/apotdevin/thunderhub/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/apotdevin/thunderhub#readme",
|
"homepage": "https://github.com/apotdevin/thunderhub#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/graphql-depth-limit": "^1.1.2",
|
"@types/graphql-depth-limit": "^1.1.2",
|
||||||
"@types/graphql-iso-date": "^3.3.3",
|
"@types/graphql-iso-date": "^3.3.3",
|
||||||
"@types/node-fetch": "^2.5.3",
|
"@types/node-fetch": "^2.5.3",
|
||||||
"@types/underscore": "^1.9.4",
|
"@types/underscore": "^1.9.4",
|
||||||
"apollo-server": "^2.9.7",
|
"apollo-server": "^2.9.7",
|
||||||
"base64url": "^3.0.1",
|
"base64url": "^3.0.1",
|
||||||
"date-fns": "^2.8.1",
|
"date-fns": "^2.8.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"graphql": "^14.5.8",
|
"graphql": "^14.5.8",
|
||||||
"graphql-depth-limit": "^1.1.0",
|
"graphql-depth-limit": "^1.1.0",
|
||||||
"graphql-iso-date": "^3.6.1",
|
"graphql-iso-date": "^3.6.1",
|
||||||
"graphql-rate-limit": "^2.0.1",
|
"graphql-rate-limit": "^2.0.1",
|
||||||
"ln-service": "^46.6.0",
|
"ln-service": "^46.6.0",
|
||||||
"underscore": "^1.9.1",
|
"underscore": "^1.9.1",
|
||||||
"winston": "^3.2.1"
|
"winston": "^3.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/webpack-env": "^1.14.1",
|
"@types/webpack-env": "^1.14.1",
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"husky": "^3.0.9",
|
"husky": "^3.0.9",
|
||||||
"prettier": "^1.18.2",
|
"prettier": "^1.18.2",
|
||||||
"pretty-quick": "^2.0.0",
|
"pretty-quick": "^2.0.0",
|
||||||
"ts-loader": "^6.2.1",
|
"ts-loader": "^6.2.1",
|
||||||
"typescript": "^3.6.4",
|
"typescript": "^3.6.4",
|
||||||
"webpack": "^4.41.2",
|
"webpack": "^4.41.2",
|
||||||
"webpack-cli": "^3.3.10",
|
"webpack-cli": "^3.3.10",
|
||||||
"webpack-merge": "^4.2.2",
|
"webpack-merge": "^4.2.2",
|
||||||
"webpack-node-externals": "^1.7.2"
|
"webpack-node-externals": "^1.7.2"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "pretty-quick"
|
"pre-commit": "pretty-quick"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +1,57 @@
|
||||||
import base64url from "base64url";
|
import base64url from 'base64url';
|
||||||
import { authenticatedLndGrpc } from "ln-service";
|
import { authenticatedLndGrpc } from 'ln-service';
|
||||||
|
|
||||||
export const getIp = (req: any) => {
|
export const getIp = (req: any) => {
|
||||||
if (!req || !req.headers) {
|
if (!req || !req.headers) {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
const forwarded = req.headers["x-forwarded-for"];
|
const forwarded = req.headers['x-forwarded-for'];
|
||||||
const before = forwarded
|
const before = forwarded ? forwarded.split(/, /)[0] : req.connection.remoteAddress;
|
||||||
? forwarded.split(/, /)[0]
|
const ip = process.env.NODE_ENV === 'development' ? '1.2.3.4' : before;
|
||||||
: req.connection.remoteAddress;
|
return ip;
|
||||||
const ip = process.env.NODE_ENV === "development" ? "1.2.3.4" : before;
|
|
||||||
return ip;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBase64CertfromDerFormat = (url: string) => {
|
export const getBase64CertfromDerFormat = (url: string) => {
|
||||||
if (!url) return null;
|
if (!url) return null;
|
||||||
|
|
||||||
const base64 = base64url.toBase64(url);
|
const base64 = base64url.toBase64(url);
|
||||||
|
|
||||||
const prefix = "-----BEGIN CERTIFICATE-----\n";
|
const prefix = '-----BEGIN CERTIFICATE-----\n';
|
||||||
const postfix = "-----END CERTIFICATE-----";
|
const postfix = '-----END CERTIFICATE-----';
|
||||||
const pem = base64.match(/.{0,64}/g) || [];
|
const pem = base64.match(/.{0,64}/g) || [];
|
||||||
const pemString = pem.join("\n");
|
const pemString = pem.join('\n');
|
||||||
const pemComplete = prefix + pemString + postfix;
|
const pemComplete = prefix + pemString + postfix;
|
||||||
const pemText = base64url.encode(pemComplete);
|
const pemText = base64url.encode(pemComplete);
|
||||||
|
|
||||||
return pemText;
|
return pemText;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAuthLnd = (auth: string) => {
|
export const getAuthLnd = (auth: string) => {
|
||||||
const url = new URL(auth);
|
const url = new URL(auth);
|
||||||
|
|
||||||
// console.log(url);
|
// console.log(url);
|
||||||
const encodedCert = url.searchParams.get("cert") || "";
|
const encodedCert = url.searchParams.get('cert') || '';
|
||||||
const encodedMacaroon = url.searchParams.get("macaroon") || "";
|
const encodedMacaroon = url.searchParams.get('macaroon') || '';
|
||||||
const socket = url.host;
|
const socket = url.host;
|
||||||
|
|
||||||
const cert = getBase64CertfromDerFormat(encodedCert);
|
const cert = getBase64CertfromDerFormat(encodedCert);
|
||||||
// const macaroon = base64url.toBase64(encodedMacaroon);
|
// const macaroon = base64url.toBase64(encodedMacaroon);
|
||||||
|
|
||||||
// const cert = base64url.toBase64(encodedCert);
|
// const cert = base64url.toBase64(encodedCert);
|
||||||
const macaroon = base64url.toBase64(encodedMacaroon);
|
const macaroon = base64url.toBase64(encodedMacaroon);
|
||||||
|
|
||||||
// console.log(encodedCert);
|
// console.log(encodedCert);
|
||||||
|
|
||||||
const params =
|
const params =
|
||||||
encodedCert !== ""
|
encodedCert !== ''
|
||||||
? {
|
? {
|
||||||
cert,
|
cert,
|
||||||
macaroon,
|
macaroon,
|
||||||
socket
|
socket,
|
||||||
}
|
}
|
||||||
: { macaroon, socket };
|
: { macaroon, socket };
|
||||||
|
|
||||||
const { lnd } = authenticatedLndGrpc(params);
|
const { lnd } = authenticatedLndGrpc(params);
|
||||||
|
|
||||||
return lnd;
|
return lnd;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue