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