mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 14:22:33 +01:00
fix: ๐ logging and types
This commit is contained in:
parent
2797e6edf3
commit
4c74ed1536
7 changed files with 30 additions and 38 deletions
|
@ -167,14 +167,16 @@ export const readMacaroons = (macaroonPath: string): string | null => {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const adminExists = fs.existsSync(`${macaroonPath}admin.macaroon`);
|
const adminExists = fs.existsSync(`${macaroonPath}/admin.macaroon`);
|
||||||
|
|
||||||
if (!adminExists) {
|
if (!adminExists) {
|
||||||
logger.error(`No admin.macaroon file found at path: ${macaroonPath}`);
|
logger.error(
|
||||||
|
`No admin.macaroon file found at path: ${macaroonPath}/admin.macaroon`
|
||||||
|
);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const ssoAdmin = fs.readFileSync(`${macaroonPath}admin.macaroon`, 'hex');
|
const ssoAdmin = fs.readFileSync(`${macaroonPath}/admin.macaroon`, 'hex');
|
||||||
return ssoAdmin;
|
return ssoAdmin;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(
|
logger.error(
|
||||||
|
@ -219,7 +221,7 @@ export const readCookie = (cookieFile: string): string | null => {
|
||||||
const exists = fs.existsSync(cookieFile);
|
const exists = fs.existsSync(cookieFile);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
try {
|
try {
|
||||||
logger.info(`Found cookie at path ${cookieFile}`);
|
logger.verbose(`Found cookie at path ${cookieFile}`);
|
||||||
const cookie = fs.readFileSync(cookieFile, 'utf-8');
|
const cookie = fs.readFileSync(cookieFile, 'utf-8');
|
||||||
return cookie;
|
return cookie;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -16,9 +16,14 @@ export const getAuthToken = {
|
||||||
cookie: { type: GraphQLString },
|
cookie: { type: GraphQLString },
|
||||||
},
|
},
|
||||||
resolve: async (_: undefined, params: any, context: ContextType) => {
|
resolve: async (_: undefined, params: any, context: ContextType) => {
|
||||||
const { ip, secret } = context;
|
const { ip, secret, sso } = context;
|
||||||
await requestLimiter(ip, 'getAuthToken');
|
await requestLimiter(ip, 'getAuthToken');
|
||||||
|
|
||||||
|
if (!sso.host || !sso.macaroon) {
|
||||||
|
logger.warn('Host and macaroon are required for SSO');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!params.cookie) {
|
if (!params.cookie) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
"dev:compatible": "next",
|
"dev:compatible": "next",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "cross-env NODE_OPTIONS='--insecure-http-parser' next start",
|
"start": "cross-env NODE_OPTIONS='--insecure-http-parser' next start",
|
||||||
|
"start:two": "cross-env NODE_OPTIONS='--insecure-http-parser' next start -p 3001",
|
||||||
"start:compatible": "next start",
|
"start:compatible": "next start",
|
||||||
|
"start:compatible:two": "next start -p 3001",
|
||||||
"lint": "eslint */**/*.{js,ts,tsx} --quiet --fix",
|
"lint": "eslint */**/*.{js,ts,tsx} --quiet --fix",
|
||||||
"prettier": "prettier --write **/*.{ts,tsx,js,css,html}",
|
"prettier": "prettier --write **/*.{ts,tsx,js,css,html}",
|
||||||
"release": "standard-version",
|
"release": "standard-version",
|
||||||
|
|
|
@ -204,16 +204,13 @@ const BalanceView = () => {
|
||||||
)}
|
)}
|
||||||
{incoming && outgoing && amount && (
|
{incoming && outgoing && amount && (
|
||||||
<BalanceRoute
|
<BalanceRoute
|
||||||
{...{
|
incoming={incoming}
|
||||||
incoming,
|
outgoing={outgoing}
|
||||||
outgoing,
|
amount={amount}
|
||||||
amount,
|
maxFee={maxFee}
|
||||||
maxFee,
|
blocked={blocked}
|
||||||
auth,
|
setBlocked={() => setBlocked(true)}
|
||||||
blocked,
|
callback={() => handleReset('all')}
|
||||||
setBlocked: () => setBlocked(true),
|
|
||||||
callback: () => handleReset('all'),
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { useGetRoutesLazyQuery } from 'src/graphql/queries/__generated__/getRoutes.generated';
|
import { useGetRoutesLazyQuery } from 'src/graphql/queries/__generated__/getRoutes.generated';
|
||||||
import { usePayViaRouteMutation } from 'src/graphql/mutations/__generated__/payViaRoute.generated';
|
import { usePayViaRouteMutation } from 'src/graphql/mutations/__generated__/payViaRoute.generated';
|
||||||
|
import { useAccountState } from 'src/context/AccountContext';
|
||||||
import {
|
import {
|
||||||
SubCard,
|
SubCard,
|
||||||
Sub4Title,
|
Sub4Title,
|
||||||
|
@ -23,7 +24,6 @@ type BalancedRouteProps = {
|
||||||
outgoing: any;
|
outgoing: any;
|
||||||
amount: number;
|
amount: number;
|
||||||
maxFee?: number;
|
maxFee?: number;
|
||||||
auth: {};
|
|
||||||
blocked: boolean;
|
blocked: boolean;
|
||||||
setBlocked: () => void;
|
setBlocked: () => void;
|
||||||
callback: () => void;
|
callback: () => void;
|
||||||
|
@ -34,11 +34,12 @@ export const BalanceRoute = ({
|
||||||
outgoing,
|
outgoing,
|
||||||
amount,
|
amount,
|
||||||
maxFee,
|
maxFee,
|
||||||
auth,
|
|
||||||
blocked,
|
blocked,
|
||||||
setBlocked,
|
setBlocked,
|
||||||
callback,
|
callback,
|
||||||
}: BalancedRouteProps) => {
|
}: BalancedRouteProps) => {
|
||||||
|
const { auth } = useAccountState();
|
||||||
|
|
||||||
const [getRoute, { loading, data, called }] = useGetRoutesLazyQuery({
|
const [getRoute, { loading, data, called }] = useGetRoutesLazyQuery({
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
onError: error => {
|
onError: error => {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { useDecodeRequestQuery } from 'src/graphql/queries/__generated__/decodeRequest.generated';
|
import { useDecodeRequestQuery } from 'src/graphql/queries/__generated__/decodeRequest.generated';
|
||||||
import { useGetNodeQuery } from 'src/graphql/queries/__generated__/getNode.generated';
|
import { useGetNodeQuery } from 'src/graphql/queries/__generated__/getNode.generated';
|
||||||
|
import { useAccountState } from 'src/context/AccountContext';
|
||||||
import {
|
import {
|
||||||
SingleLine,
|
SingleLine,
|
||||||
SubTitle,
|
SubTitle,
|
||||||
|
@ -28,14 +29,10 @@ export const Centered = styled.div`
|
||||||
|
|
||||||
interface DecodeProps {
|
interface DecodeProps {
|
||||||
request: string;
|
request: string;
|
||||||
auth: {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RequestModal: React.FC<DecodeProps> = ({
|
export const RequestModal: React.FC<DecodeProps> = ({ children, request }) => {
|
||||||
children,
|
const { auth } = useAccountState();
|
||||||
request,
|
|
||||||
auth,
|
|
||||||
}) => {
|
|
||||||
const { data, loading, error } = useDecodeRequestQuery({
|
const { data, loading, error } = useDecodeRequestQuery({
|
||||||
variables: { auth, request },
|
variables: { auth, request },
|
||||||
});
|
});
|
||||||
|
@ -77,18 +74,17 @@ export const RequestModal: React.FC<DecodeProps> = ({
|
||||||
|
|
||||||
interface KeysendProps {
|
interface KeysendProps {
|
||||||
tokens: number;
|
tokens: number;
|
||||||
auth: {};
|
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
setTokens: (amount: number) => void;
|
setTokens: (amount: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const KeysendModal: React.FC<KeysendProps> = ({
|
export const KeysendModal: React.FC<KeysendProps> = ({
|
||||||
children,
|
children,
|
||||||
auth,
|
|
||||||
publicKey,
|
publicKey,
|
||||||
tokens,
|
tokens,
|
||||||
setTokens,
|
setTokens,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { auth } = useAccountState();
|
||||||
const { data, loading, error } = useGetNodeQuery({
|
const { data, loading, error } = useGetNodeQuery({
|
||||||
variables: { auth, publicKey },
|
variables: { auth, publicKey },
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { useAccountState } from 'src/context/AccountContext';
|
|
||||||
import { usePayInvoiceMutation } from 'src/graphql/mutations/__generated__/pay.generated';
|
import { usePayInvoiceMutation } from 'src/graphql/mutations/__generated__/pay.generated';
|
||||||
import {
|
import {
|
||||||
Sub4Title,
|
Sub4Title,
|
||||||
|
@ -24,7 +23,6 @@ export const PayCard = ({ setOpen }: { setOpen: () => void }) => {
|
||||||
const [tokens, setTokens] = useState<number>(0);
|
const [tokens, setTokens] = useState<number>(0);
|
||||||
const [modalType, setModalType] = useState('none');
|
const [modalType, setModalType] = useState('none');
|
||||||
|
|
||||||
const { auth } = useAccountState();
|
|
||||||
const { minorVersion } = useStatusState();
|
const { minorVersion } = useStatusState();
|
||||||
|
|
||||||
const canKeysend = minorVersion >= 9;
|
const canKeysend = minorVersion >= 9;
|
||||||
|
@ -76,20 +74,11 @@ export const PayCard = ({ setOpen }: { setOpen: () => void }) => {
|
||||||
|
|
||||||
const renderModal = () => {
|
const renderModal = () => {
|
||||||
if (modalType === 'request') {
|
if (modalType === 'request') {
|
||||||
return (
|
return <RequestModal request={request}>{renderButton()}</RequestModal>;
|
||||||
<RequestModal request={request} auth={auth}>
|
|
||||||
{renderButton()}
|
|
||||||
</RequestModal>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (modalType === 'keysend') {
|
if (modalType === 'keysend') {
|
||||||
return (
|
return (
|
||||||
<KeysendModal
|
<KeysendModal tokens={tokens} publicKey={request} setTokens={setTokens}>
|
||||||
tokens={tokens}
|
|
||||||
auth={auth}
|
|
||||||
publicKey={request}
|
|
||||||
setTokens={setTokens}
|
|
||||||
>
|
|
||||||
{renderButton()}
|
{renderButton()}
|
||||||
</KeysendModal>
|
</KeysendModal>
|
||||||
);
|
);
|
||||||
|
|
Loadingโฆ
Add table
Reference in a new issue