@lightsparkdev/lightspark-sdk 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/dist/{Withdrawal-17e1c8af.d.ts → Withdrawal-ebb4865c.d.ts} +393 -377
- package/dist/{chunk-N27QHRE4.js → chunk-XFOVS6EY.js} +56 -40
- package/dist/index.cjs +25 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/objects/index.cjs +24 -8
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +1 -1
- package/package.json +7 -2
- package/src/client.ts +0 -1
- package/src/objects/Account.ts +2 -2
- package/src/objects/Entity.ts +10 -2
- package/src/objects/Invoice.ts +1 -1
- package/src/objects/InvoiceData.ts +10 -1
- package/src/objects/LightningTransaction.ts +1 -1
- package/src/objects/LightsparkNodeStatus.ts +2 -0
- package/src/objects/OutgoingPayment.ts +1 -1
- package/src/objects/PaymentRequest.ts +1 -1
- package/src/objects/PaymentRequestData.ts +1 -1
- package/src/objects/Transaction.ts +1 -1
- package/src/objects/WebhookEventType.ts +10 -0
- package/src/objects/WithdrawalRequest.ts +12 -0
- package/.fossa.yml +0 -6
- package/.prettierrc +0 -1
- package/.turbo/turbo-build.log +0 -19
- package/.turbo/turbo-lint.log +0 -3
- package/dist/chunk-AGEUDR2V.js +0 -4498
- package/dist/client-3bba3f64.d.ts +0 -1302
- package/examples/node-scripts/authHelpers.ts +0 -20
- package/examples/node-scripts/createInvoice.ts +0 -64
- package/examples/node-scripts/example.ts +0 -288
- package/examples/node-scripts/getAccountDashboard.ts +0 -24
- package/examples/node-scripts/getNodeChannels.ts +0 -34
- package/examples/node-scripts/internalAuthHelpers.ts +0 -26
- package/examples/node-scripts/internal_example.ts +0 -296
- package/examples/node-scripts/package-lock.json +0 -887
- package/examples/node-scripts/package.json +0 -22
- package/examples/node-scripts/prettyPrintJsonForDocs.ts +0 -62
- package/examples/node-scripts/tsconfig.json +0 -27
- package/examples/oauth-example/README.md +0 -19
- package/examples/oauth-example/package-lock.json +0 -16071
- package/examples/oauth-example/package.json +0 -50
- package/examples/oauth-example/public/favicon.ico +0 -0
- package/examples/oauth-example/public/index.html +0 -43
- package/examples/oauth-example/public/logo192.png +0 -0
- package/examples/oauth-example/public/logo512.png +0 -0
- package/examples/oauth-example/public/manifest.json +0 -25
- package/examples/oauth-example/public/robots.txt +0 -3
- package/examples/oauth-example/src/App.css +0 -7
- package/examples/oauth-example/src/App.test.tsx +0 -12
- package/examples/oauth-example/src/App.tsx +0 -16
- package/examples/oauth-example/src/auth/AuthContext.ts +0 -8
- package/examples/oauth-example/src/auth/AuthProvider.tsx +0 -44
- package/examples/oauth-example/src/auth/RequireAuth.tsx +0 -19
- package/examples/oauth-example/src/auth/oauthProvider.ts +0 -35
- package/examples/oauth-example/src/components/Button.tsx +0 -39
- package/examples/oauth-example/src/components/CurrencyAmount.tsx +0 -117
- package/examples/oauth-example/src/components/Dashboard.tsx +0 -158
- package/examples/oauth-example/src/components/Table.tsx +0 -22
- package/examples/oauth-example/src/hooks/useAccountInfo.tsx +0 -31
- package/examples/oauth-example/src/icons/BitcoinB.tsx +0 -20
- package/examples/oauth-example/src/icons/Icon.tsx +0 -121
- package/examples/oauth-example/src/icons/Satoshi.tsx +0 -28
- package/examples/oauth-example/src/index.css +0 -13
- package/examples/oauth-example/src/index.tsx +0 -23
- package/examples/oauth-example/src/lightsparkclient/LightsparkClientContext.ts +0 -10
- package/examples/oauth-example/src/lightsparkclient/LightsparkClientProvider.tsx +0 -53
- package/examples/oauth-example/src/logo.svg +0 -1
- package/examples/oauth-example/src/pages/DashboardPage.tsx +0 -71
- package/examples/oauth-example/src/pages/LoginPage.tsx +0 -63
- package/examples/oauth-example/src/react-app-env.d.ts +0 -1
- package/examples/oauth-example/src/reportWebVitals.ts +0 -15
- package/examples/oauth-example/src/routes/index.tsx +0 -15
- package/examples/oauth-example/src/setupTests.ts +0 -5
- package/examples/oauth-example/src/utils/currency.ts +0 -483
- package/examples/oauth-example/tsconfig.json +0 -20
- package/examples/streaming-wallet-extension/.fossa.yml +0 -6
- package/examples/streaming-wallet-extension/README.md +0 -17
- package/examples/streaming-wallet-extension/craco.config.js +0 -58
- package/examples/streaming-wallet-extension/package-lock.json +0 -18260
- package/examples/streaming-wallet-extension/package.json +0 -77
- package/examples/streaming-wallet-extension/public/index.html +0 -24
- package/examples/streaming-wallet-extension/public/lightspark_full.png +0 -0
- package/examples/streaming-wallet-extension/public/lightspark_icon_circle.png +0 -0
- package/examples/streaming-wallet-extension/public/manifest.json +0 -43
- package/examples/streaming-wallet-extension/public/robots.txt +0 -3
- package/examples/streaming-wallet-extension/src/App.css +0 -53
- package/examples/streaming-wallet-extension/src/App.tsx +0 -425
- package/examples/streaming-wallet-extension/src/auth/AccountStorage.ts +0 -28
- package/examples/streaming-wallet-extension/src/auth/DemoAccountProvider.ts +0 -99
- package/examples/streaming-wallet-extension/src/auth/StreamingDemoCredentials.ts +0 -10
- package/examples/streaming-wallet-extension/src/background/PaymentStrategy.ts +0 -36
- package/examples/streaming-wallet-extension/src/background/PlaybackRange.ts +0 -31
- package/examples/streaming-wallet-extension/src/background/StreamingInvoiceHolder.ts +0 -33
- package/examples/streaming-wallet-extension/src/background/TransactionObserver.ts +0 -66
- package/examples/streaming-wallet-extension/src/background/VideoPlaybackRanges.ts +0 -38
- package/examples/streaming-wallet-extension/src/background/VideoProgressCache.ts +0 -87
- package/examples/streaming-wallet-extension/src/background/background.ts +0 -145
- package/examples/streaming-wallet-extension/src/background/messageHandling.ts +0 -185
- package/examples/streaming-wallet-extension/src/common/datetimes.ts +0 -28
- package/examples/streaming-wallet-extension/src/common/settings.ts +0 -12
- package/examples/streaming-wallet-extension/src/common/storage.ts +0 -8
- package/examples/streaming-wallet-extension/src/common/streamingTabs.ts +0 -27
- package/examples/streaming-wallet-extension/src/common/types.tsx +0 -23
- package/examples/streaming-wallet-extension/src/components/CirclePlusIcon.tsx +0 -19
- package/examples/streaming-wallet-extension/src/components/CurrencyAmount.tsx +0 -110
- package/examples/streaming-wallet-extension/src/components/CurrencyAmountRaw.tsx +0 -195
- package/examples/streaming-wallet-extension/src/components/LeftArrow.tsx +0 -21
- package/examples/streaming-wallet-extension/src/components/Loading.tsx +0 -151
- package/examples/streaming-wallet-extension/src/components/StreamingTransactionChip.tsx +0 -95
- package/examples/streaming-wallet-extension/src/components/TransactionRow.tsx +0 -93
- package/examples/streaming-wallet-extension/src/contentscript/content.ts +0 -123
- package/examples/streaming-wallet-extension/src/contentscript/lightsparkDemoDom.tsx +0 -113
- package/examples/streaming-wallet-extension/src/contentscript/videoElementParsers.ts +0 -92
- package/examples/streaming-wallet-extension/src/index.css +0 -16
- package/examples/streaming-wallet-extension/src/index.tsx +0 -11
- package/examples/streaming-wallet-extension/src/lightsparkClientProvider.tsx +0 -26
- package/examples/streaming-wallet-extension/src/react-app-env.d.ts +0 -1
- package/examples/streaming-wallet-extension/src/types/Messages.ts +0 -17
- package/examples/streaming-wallet-extension/tsconfig.json +0 -20
- package/tsconfig.json +0 -5
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import styled from "@emotion/styled/macro";
|
|
2
|
-
import { useLayoutEffect, useState } from "react";
|
|
3
|
-
|
|
4
|
-
const rootFontSizePx = 12;
|
|
5
|
-
|
|
6
|
-
function isString(str: unknown): str is string {
|
|
7
|
-
return typeof str === "string";
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Component = () => JSX.Element;
|
|
11
|
-
|
|
12
|
-
type IconMap = {
|
|
13
|
-
[key: string]: Component;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const iconMap: IconMap = {};
|
|
17
|
-
|
|
18
|
-
async function loadIcon(iconName: string) {
|
|
19
|
-
let IconComp;
|
|
20
|
-
try {
|
|
21
|
-
({ default: IconComp } = await import(
|
|
22
|
-
// this can't be a variable only, needs to have some string constraints:
|
|
23
|
-
`./${iconName}.tsx`
|
|
24
|
-
));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
throw new Error(`Icon ${iconName} not found`);
|
|
27
|
-
}
|
|
28
|
-
iconMap[iconName] = IconComp as Component;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type IconProps = {
|
|
32
|
-
className?: string;
|
|
33
|
-
name: string;
|
|
34
|
-
width: number;
|
|
35
|
-
mr?: number;
|
|
36
|
-
ml?: number;
|
|
37
|
-
verticalAlign?: "middle" | "top" | "bottom" | "super" | number;
|
|
38
|
-
color?: string;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const defaultProps = {
|
|
42
|
-
verticalAlign: "middle" as const,
|
|
43
|
-
mr: 0,
|
|
44
|
-
ml: 0,
|
|
45
|
-
color: undefined,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export function Icon({
|
|
49
|
-
className,
|
|
50
|
-
name,
|
|
51
|
-
width,
|
|
52
|
-
mr = defaultProps.mr,
|
|
53
|
-
ml = defaultProps.ml,
|
|
54
|
-
verticalAlign = defaultProps.verticalAlign,
|
|
55
|
-
color = defaultProps.color,
|
|
56
|
-
}: IconProps) {
|
|
57
|
-
const [, setLoading] = useState(false);
|
|
58
|
-
|
|
59
|
-
const IconComponent = iconMap[name] || null;
|
|
60
|
-
|
|
61
|
-
useLayoutEffect(() => {
|
|
62
|
-
(async () => {
|
|
63
|
-
if (!iconMap[name]) {
|
|
64
|
-
setLoading(true);
|
|
65
|
-
await loadIcon(name);
|
|
66
|
-
setLoading(false);
|
|
67
|
-
}
|
|
68
|
-
})();
|
|
69
|
-
}, [name]);
|
|
70
|
-
|
|
71
|
-
// Assume width is px relative to the root font size but specify in ems to preserve scale for larger font sizes
|
|
72
|
-
const w = parseFloat((width / rootFontSizePx).toFixed(2));
|
|
73
|
-
const mrRems = parseFloat((mr / rootFontSizePx).toFixed(2));
|
|
74
|
-
const mlRems = parseFloat((ml / rootFontSizePx).toFixed(2));
|
|
75
|
-
const va =
|
|
76
|
-
typeof verticalAlign === "string"
|
|
77
|
-
? verticalAlign
|
|
78
|
-
: parseFloat((verticalAlign / rootFontSizePx).toFixed(2));
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<IconContainer
|
|
82
|
-
className={className}
|
|
83
|
-
w={w}
|
|
84
|
-
mr={mrRems}
|
|
85
|
-
ml={mlRems}
|
|
86
|
-
verticalAlign={va}
|
|
87
|
-
fontColor={color}
|
|
88
|
-
>
|
|
89
|
-
{IconComponent ? <IconComponent /> : null}
|
|
90
|
-
</IconContainer>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
Icon.defaultProps = defaultProps;
|
|
95
|
-
|
|
96
|
-
type IconContainerProps = {
|
|
97
|
-
w: number;
|
|
98
|
-
mr: number;
|
|
99
|
-
ml: number;
|
|
100
|
-
verticalAlign: string | number;
|
|
101
|
-
fontColor?: string;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const IconContainer = styled.span<IconContainerProps>`
|
|
105
|
-
pointer-events: none;
|
|
106
|
-
display: inline-flex;
|
|
107
|
-
${({ mr, ml, w }) => `
|
|
108
|
-
width: ${w}em;
|
|
109
|
-
${mr ? `margin-right: ${mr}em;` : ""}
|
|
110
|
-
${ml ? `margin-left: ${ml}em;` : ""}
|
|
111
|
-
`}
|
|
112
|
-
|
|
113
|
-
vertical-align: ${({ verticalAlign }) =>
|
|
114
|
-
isString(verticalAlign) ? verticalAlign : `${verticalAlign}em`};
|
|
115
|
-
|
|
116
|
-
${({ fontColor, theme }) => `
|
|
117
|
-
& svg {
|
|
118
|
-
color: ${fontColor || "inherit"};
|
|
119
|
-
}
|
|
120
|
-
`}
|
|
121
|
-
`;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Copyright ©, 2022, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
-
|
|
3
|
-
function Satoshi() {
|
|
4
|
-
return (
|
|
5
|
-
<svg
|
|
6
|
-
width="100%"
|
|
7
|
-
viewBox="0 0 26 41"
|
|
8
|
-
fill="none"
|
|
9
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
-
>
|
|
11
|
-
<path d="M0 11.2142H26" stroke="currentColor" strokeWidth="3.71429" />
|
|
12
|
-
<path
|
|
13
|
-
d="M13 5.64284V0.0714111"
|
|
14
|
-
stroke="currentColor"
|
|
15
|
-
strokeWidth="3.71429"
|
|
16
|
-
/>
|
|
17
|
-
<path
|
|
18
|
-
d="M13 40.9286V35.3572"
|
|
19
|
-
stroke="currentColor"
|
|
20
|
-
strokeWidth="3.71429"
|
|
21
|
-
/>
|
|
22
|
-
<path d="M0 20.5H26" stroke="currentColor" strokeWidth="3.71429" />
|
|
23
|
-
<path d="M0 29.7858H26" stroke="currentColor" strokeWidth="3.71429" />
|
|
24
|
-
</svg>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default Satoshi;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
|
4
|
-
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
|
5
|
-
sans-serif;
|
|
6
|
-
-webkit-font-smoothing: antialiased;
|
|
7
|
-
-moz-osx-font-smoothing: grayscale;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
code {
|
|
11
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
|
12
|
-
monospace;
|
|
13
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactDOM from "react-dom/client";
|
|
3
|
-
import { BrowserRouter } from "react-router-dom";
|
|
4
|
-
import App from "./App";
|
|
5
|
-
import "./index.css";
|
|
6
|
-
import reportWebVitals from "./reportWebVitals";
|
|
7
|
-
import routes from "./routes";
|
|
8
|
-
|
|
9
|
-
const root = ReactDOM.createRoot(
|
|
10
|
-
document.getElementById("root") as HTMLElement
|
|
11
|
-
);
|
|
12
|
-
root.render(
|
|
13
|
-
<React.StrictMode>
|
|
14
|
-
<BrowserRouter basename={process.env.PUBLIC_URL}>
|
|
15
|
-
<App>{routes}</App>
|
|
16
|
-
</BrowserRouter>
|
|
17
|
-
</React.StrictMode>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
// If you want to start measuring performance in your app, pass a function
|
|
21
|
-
// to log results (for example: reportWebVitals(console.log))
|
|
22
|
-
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
23
|
-
reportWebVitals();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AuthProvider } from "@lightsparkdev/core";
|
|
2
|
-
import { LightsparkClient } from "@lightsparkdev/lightspark-sdk";
|
|
3
|
-
|
|
4
|
-
interface LightsparkClientContextType {
|
|
5
|
-
getClient: () => LightsparkClient;
|
|
6
|
-
setAuthProvider: (provider: AuthProvider) => void;
|
|
7
|
-
isAuthenticated: () => Promise<boolean>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default LightsparkClientContextType;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { AuthProvider } from "@lightsparkdev/core";
|
|
2
|
-
import { LightsparkClient } from "@lightsparkdev/lightspark-sdk";
|
|
3
|
-
import React, { useState } from "react";
|
|
4
|
-
import LightsparkClientContextType from "./LightsparkClientContext";
|
|
5
|
-
|
|
6
|
-
let LightsparkClientContext = React.createContext<LightsparkClientContextType>(
|
|
7
|
-
null!
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
function LightsparkClientProvider({ children }: { children: React.ReactNode }) {
|
|
11
|
-
const [client, setClient] = useState<LightsparkClient | null>(null);
|
|
12
|
-
|
|
13
|
-
const getClient = () => {
|
|
14
|
-
if (!client) {
|
|
15
|
-
throw new Error(
|
|
16
|
-
"LightsparkClient not initialized. Set an auth provider before using the client."
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return client;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const isAuthenticated = () => {
|
|
24
|
-
if (!client) {
|
|
25
|
-
return Promise.resolve(false);
|
|
26
|
-
}
|
|
27
|
-
return client.isAuthorized();
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const setAuthProvider = (authProvider: AuthProvider) => {
|
|
31
|
-
if (!client) {
|
|
32
|
-
setClient(
|
|
33
|
-
new LightsparkClient(authProvider, "api.dev.dev.sparkinfra.net")
|
|
34
|
-
);
|
|
35
|
-
} else {
|
|
36
|
-
client.setAuthProvider(authProvider);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
let value = { getClient, setAuthProvider, isAuthenticated };
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<LightsparkClientContext.Provider value={value}>
|
|
44
|
-
{children}
|
|
45
|
-
</LightsparkClientContext.Provider>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function useLightsparkClient() {
|
|
50
|
-
return React.useContext(LightsparkClientContext);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default LightsparkClientProvider;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import styled from "@emotion/styled";
|
|
2
|
-
import { BitcoinNetwork, WalletDashboard } from "@lightsparkdev/lightspark-sdk";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { useAuth } from "../auth/AuthProvider";
|
|
5
|
-
import RequireAuth from "../auth/RequireAuth";
|
|
6
|
-
import { Button } from "../components/Button";
|
|
7
|
-
import Dashboard from "../components/Dashboard";
|
|
8
|
-
import useAccountInfo from "../hooks/useAccountInfo";
|
|
9
|
-
import { useLightsparkClient } from "../lightsparkclient/LightsparkClientProvider";
|
|
10
|
-
|
|
11
|
-
function DashboardPage() {
|
|
12
|
-
const [loading, setLoading] = useState<boolean>(true);
|
|
13
|
-
const { account, nodeId } = useAccountInfo();
|
|
14
|
-
const clientProvider = useLightsparkClient();
|
|
15
|
-
const [dashboard, setDashboard] = useState<WalletDashboard>();
|
|
16
|
-
const auth = useAuth();
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!account || !nodeId) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const client = clientProvider.getClient();
|
|
23
|
-
client
|
|
24
|
-
.getSingleNodeDashboard(nodeId, BitcoinNetwork.REGTEST)
|
|
25
|
-
.then((dashboard) => {
|
|
26
|
-
setDashboard(dashboard);
|
|
27
|
-
})
|
|
28
|
-
.catch((err) => {
|
|
29
|
-
console.log(err);
|
|
30
|
-
})
|
|
31
|
-
.finally(() => {
|
|
32
|
-
setLoading(false);
|
|
33
|
-
});
|
|
34
|
-
}, [account, clientProvider, nodeId]);
|
|
35
|
-
|
|
36
|
-
let content;
|
|
37
|
-
if (loading) {
|
|
38
|
-
content = <div>Loading...</div>;
|
|
39
|
-
} else if (!dashboard) {
|
|
40
|
-
content = <div>Something went wrong :-(</div>;
|
|
41
|
-
} else {
|
|
42
|
-
content = (
|
|
43
|
-
<div>
|
|
44
|
-
<Header>
|
|
45
|
-
<Button
|
|
46
|
-
primary
|
|
47
|
-
onClick={() => {
|
|
48
|
-
auth.signout();
|
|
49
|
-
}}
|
|
50
|
-
>
|
|
51
|
-
Sign out
|
|
52
|
-
</Button>
|
|
53
|
-
</Header>
|
|
54
|
-
<Dashboard data={dashboard} />
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return <RequireAuth>{content}</RequireAuth>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const Header = styled.div`
|
|
63
|
-
display: flex;
|
|
64
|
-
justify-content: end;
|
|
65
|
-
align-items: center;
|
|
66
|
-
width: 100%;
|
|
67
|
-
max-width: 800px;
|
|
68
|
-
padding: 16px;
|
|
69
|
-
`;
|
|
70
|
-
|
|
71
|
-
export default DashboardPage;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import styled from "@emotion/styled";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useLocation, useNavigate } from "react-router-dom";
|
|
4
|
-
import { useAuth } from "../auth/AuthProvider";
|
|
5
|
-
import { Button } from "../components/Button";
|
|
6
|
-
|
|
7
|
-
const LoginPage = () => {
|
|
8
|
-
const navigate = useNavigate();
|
|
9
|
-
const location = useLocation();
|
|
10
|
-
const auth = useAuth();
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (window.location.search.includes("code")) {
|
|
14
|
-
const queryString = window.location.search.substring(1); // includes '?'
|
|
15
|
-
const path = ["/oauth", queryString].join("#");
|
|
16
|
-
navigate(path);
|
|
17
|
-
}
|
|
18
|
-
auth.checkAuth().then((isAuthorized: boolean) => {
|
|
19
|
-
if (isAuthorized) {
|
|
20
|
-
navigate("/");
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}, [auth, navigate]);
|
|
24
|
-
|
|
25
|
-
const from = location.state?.from?.pathname || "/";
|
|
26
|
-
|
|
27
|
-
function handleLogin() {
|
|
28
|
-
auth.signin(() => {
|
|
29
|
-
// Send them back to the page they tried to visit when they were
|
|
30
|
-
// redirected to the login page. Use { replace: true } so we don't create
|
|
31
|
-
// another entry in the history stack for the login page. This means that
|
|
32
|
-
// when they get to the protected page and click the back button, they
|
|
33
|
-
// won't end up back on the login page, which is also really nice for the
|
|
34
|
-
// user experience.
|
|
35
|
-
navigate(from, { replace: true });
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Container>
|
|
41
|
-
<Description>Log into your Lightspark account to continue</Description>
|
|
42
|
-
<Button primary onClick={handleLogin}>
|
|
43
|
-
Login
|
|
44
|
-
</Button>
|
|
45
|
-
</Container>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const Description = styled.p`
|
|
50
|
-
font-size: 20px;
|
|
51
|
-
text-align: center;
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
const Container = styled.div`
|
|
55
|
-
display: flex;
|
|
56
|
-
flex-direction: column;
|
|
57
|
-
align-items: center;
|
|
58
|
-
justify-content: center;
|
|
59
|
-
margin: auto;
|
|
60
|
-
height: 100vh;
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
export default LoginPage;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="react-scripts" />
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReportHandler } from "web-vitals";
|
|
2
|
-
|
|
3
|
-
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
|
-
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
5
|
-
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
6
|
-
getCLS(onPerfEntry);
|
|
7
|
-
getFID(onPerfEntry);
|
|
8
|
-
getFCP(onPerfEntry);
|
|
9
|
-
getLCP(onPerfEntry);
|
|
10
|
-
getTTFB(onPerfEntry);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default reportWebVitals;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Route, Routes } from "react-router-dom";
|
|
2
|
-
import DashboardPage from "../pages/DashboardPage";
|
|
3
|
-
import LoginPage from "../pages/LoginPage";
|
|
4
|
-
|
|
5
|
-
const routes = (
|
|
6
|
-
<>
|
|
7
|
-
<Routes>
|
|
8
|
-
<Route path="/" element={<DashboardPage />} />
|
|
9
|
-
<Route path="/login" element={<LoginPage />} />
|
|
10
|
-
<Route path="/oauth" element={<LoginPage />} />
|
|
11
|
-
</Routes>
|
|
12
|
-
</>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export default routes;
|