From 32768cda664c176f8b70b689e5cd4e38de8ea700 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 13:41:34 -0700 Subject: [PATCH] [oauth-app] Move to examples and convert to vite (#260) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [oauth-app] Move to examples and convert to vite (#6504) All CRA removed from workspaces! 🎉 GitOrigin-RevId: ebdcec569f5f95f98b2f7281561b4b0de1fe8ca4 * [js] Resolve dep warnings (#6506) GitOrigin-RevId: ed8d59e4ff7f6ecad65239b036a19a85298f6146 * Update package.json to new concurrency (#6519) GitOrigin-RevId: f4993ca59d270f75447aa5840e83ba6357847361 * add job permissions * [oauth-app] Remove private dep * update permissions * fix permissions * fix dep --------- Co-authored-by: Corey Martin Co-authored-by: Rohan Ramakrishnan --- .github/workflows/create-release-pr.yaml | 4 +- .github/workflows/test-release-sync.yaml | 8 + apps/examples/oauth-app/.eslintrc.js | 13 + .../examples/oauth-app}/README.md | 0 apps/examples/oauth-app/index.html | 33 + apps/examples/oauth-app/package.json | 43 + .../examples/oauth-app}/public/favicon.ico | Bin .../examples/oauth-app}/public/logo192.png | Bin .../examples/oauth-app}/public/logo512.png | Bin .../examples/oauth-app}/public/manifest.json | 0 .../examples/oauth-app}/public/robots.txt | 0 .../examples/oauth-app}/src/App.css | 0 .../examples/oauth-app}/src/App.tsx | 0 apps/examples/oauth-app/src/Root.tsx | 14 + .../oauth-app}/src/auth/AuthContext.ts | 0 .../oauth-app}/src/auth/AuthProvider.tsx | 4 +- .../oauth-app}/src/auth/RequireAuth.tsx | 12 +- .../oauth-app}/src/auth/oauthProvider.ts | 0 .../oauth-app/src/components/Button.tsx | 5 + .../oauth-app}/src/components/Dashboard.tsx | 10 +- .../oauth-app}/src/components/Table.tsx | 0 .../oauth-app/src/components/router.tsx | 24 + .../oauth-app}/src/hooks/useAccountInfo.tsx | 4 +- .../examples/oauth-app}/src/index.css | 0 .../examples/oauth-app}/src/index.tsx | 16 +- .../LightsparkClientContext.ts | 4 +- .../LightsparkClientProvider.tsx | 8 +- .../oauth-app}/src/pages/DashboardPage.tsx | 19 +- .../oauth-app}/src/pages/LoginPage.tsx | 19 +- .../oauth-app}/src/reportWebVitals.ts | 2 +- apps/examples/oauth-app/src/routes.tsx | 7 + apps/examples/oauth-app/tsconfig-eslint.json | 12 + apps/examples/oauth-app/tsconfig.json | 12 + apps/examples/oauth-app/vite.config.ts | 7 + .../react-wallet-app/src/react-app-env.d.ts | 1 - apps/examples/react-wallet-app/vite.config.ts | 3 +- apps/examples/settings.json | 11 + .../streaming-wallet-extension/package.json | 3 +- .../src/react-app-env.d.ts | 1 - .../streaming-wallet-extension/vite.config.ts | 3 +- .../examples/wallet-node-scripts/package.json | 1 + package.json | 4 +- packages/core/src/crypto/SigningKey.ts | 1 - packages/eslint-config/package.json | 7 +- .../examples/oauth-example/package-lock.json | 16071 ---------------- .../examples/oauth-example/package.json | 50 - .../examples/oauth-example/public/index.html | 43 - .../oauth-example/src/components/Button.tsx | 39 - .../src/components/CurrencyAmount.tsx | 117 - .../oauth-example/src/icons/BitcoinB.tsx | 20 - .../examples/oauth-example/src/icons/Icon.tsx | 121 - .../oauth-example/src/icons/Satoshi.tsx | 28 - .../examples/oauth-example/src/logo.svg | 1 - .../oauth-example/src/react-app-env.d.ts | 1 - .../oauth-example/src/routes/index.tsx | 15 - .../examples/oauth-example/src/setupTests.ts | 5 - .../oauth-example/src/utils/currency.ts | 480 - .../examples/oauth-example/tsconfig.json | 20 - packages/lightspark-sdk/package.json | 1 + packages/ui/package.json | 2 + packages/ui/router.tsx | 28 +- packages/uma/package.json | 1 - packages/vite/package.json | 1 + packages/wallet-sdk/package.json | 2 + yarn.lock | 1696 +- 65 files changed, 770 insertions(+), 18287 deletions(-) create mode 100644 apps/examples/oauth-app/.eslintrc.js rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/README.md (100%) create mode 100644 apps/examples/oauth-app/index.html create mode 100644 apps/examples/oauth-app/package.json rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/public/favicon.ico (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/public/logo192.png (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/public/logo512.png (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/public/manifest.json (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/public/robots.txt (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/App.css (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/App.tsx (100%) create mode 100644 apps/examples/oauth-app/src/Root.tsx rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/auth/AuthContext.ts (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/auth/AuthProvider.tsx (89%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/auth/RequireAuth.tsx (61%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/auth/oauthProvider.ts (100%) create mode 100644 apps/examples/oauth-app/src/components/Button.tsx rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/components/Dashboard.tsx (94%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/components/Table.tsx (100%) create mode 100644 apps/examples/oauth-app/src/components/router.tsx rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/hooks/useAccountInfo.tsx (84%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/index.css (100%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/index.tsx (60%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/lightsparkclient/LightsparkClientContext.ts (63%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/lightsparkclient/LightsparkClientProvider.tsx (80%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/pages/DashboardPage.tsx (78%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/pages/LoginPage.tsx (75%) rename {packages/lightspark-sdk/examples/oauth-example => apps/examples/oauth-app}/src/reportWebVitals.ts (88%) create mode 100644 apps/examples/oauth-app/src/routes.tsx create mode 100644 apps/examples/oauth-app/tsconfig-eslint.json create mode 100644 apps/examples/oauth-app/tsconfig.json create mode 100644 apps/examples/oauth-app/vite.config.ts delete mode 100644 apps/examples/react-wallet-app/src/react-app-env.d.ts create mode 100644 apps/examples/settings.json delete mode 100644 apps/examples/streaming-wallet-extension/src/react-app-env.d.ts delete mode 100644 packages/lightspark-sdk/examples/oauth-example/package-lock.json delete mode 100644 packages/lightspark-sdk/examples/oauth-example/package.json delete mode 100644 packages/lightspark-sdk/examples/oauth-example/public/index.html delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/components/Button.tsx delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/components/CurrencyAmount.tsx delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/icons/BitcoinB.tsx delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/icons/Icon.tsx delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/icons/Satoshi.tsx delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/logo.svg delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/react-app-env.d.ts delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/routes/index.tsx delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/setupTests.ts delete mode 100644 packages/lightspark-sdk/examples/oauth-example/src/utils/currency.ts delete mode 100644 packages/lightspark-sdk/examples/oauth-example/tsconfig.json diff --git a/.github/workflows/create-release-pr.yaml b/.github/workflows/create-release-pr.yaml index 72bd40028..b52c7b37b 100644 --- a/.github/workflows/create-release-pr.yaml +++ b/.github/workflows/create-release-pr.yaml @@ -13,7 +13,9 @@ jobs: create-release-pr: name: Create or update release PR runs-on: ubuntu-latest - + permissions: + contents: write + pull-requests: write steps: - name: Save branch name output shell: bash diff --git a/.github/workflows/test-release-sync.yaml b/.github/workflows/test-release-sync.yaml index b7908738e..1fa3b7de8 100644 --- a/.github/workflows/test-release-sync.yaml +++ b/.github/workflows/test-release-sync.yaml @@ -15,6 +15,9 @@ jobs: if: github.head_ref != 'changeset-release/main' name: "Update lock file for PRs before checks and build" runs-on: "ubuntu-22.04" + permissions: + contents: write + pull-requests: write outputs: VERIFIED_LOCK_COMMIT: ${{ steps.sync-lock-file.outputs.VERIFIED_LOCK_COMMIT }} steps: @@ -162,6 +165,9 @@ jobs: release: name: Release needs: ["checks", "build"] + permissions: + contents: write + pull-requests: write if: "success() && github.event_name == 'push'" runs-on: ubuntu-latest environment: npm @@ -261,6 +267,8 @@ jobs: if: "github.event_name == 'push'" runs-on: ubuntu-latest environment: npm + permissions: + contents: write steps: - name: Checkout Repo uses: actions/checkout@v3 diff --git a/apps/examples/oauth-app/.eslintrc.js b/apps/examples/oauth-app/.eslintrc.js new file mode 100644 index 000000000..11d349a5d --- /dev/null +++ b/apps/examples/oauth-app/.eslintrc.js @@ -0,0 +1,13 @@ +module.exports = { + extends: ["@lightsparkdev/eslint-config/react-app"], + + overrides: [ + { + files: ["**/*.ts?(x)"], + parserOptions: { + /* Allow linting for ts files outside src with tsconfig-eslint: */ + project: ["./tsconfig.json", "./tsconfig-eslint.json"], + }, + }, + ], +}; diff --git a/packages/lightspark-sdk/examples/oauth-example/README.md b/apps/examples/oauth-app/README.md similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/README.md rename to apps/examples/oauth-app/README.md diff --git a/apps/examples/oauth-app/index.html b/apps/examples/oauth-app/index.html new file mode 100644 index 000000000..e06eff1f7 --- /dev/null +++ b/apps/examples/oauth-app/index.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + Lightspark OAuth Demo + + + +
+ + + diff --git a/apps/examples/oauth-app/package.json b/apps/examples/oauth-app/package.json new file mode 100644 index 000000000..bcb8258ee --- /dev/null +++ b/apps/examples/oauth-app/package.json @@ -0,0 +1,43 @@ +{ + "name": "@lightsparkdev/oauth-app", + "version": "0.0.0", + "private": true, + "dependencies": { + "@emotion/css": "^11.11.0", + "@emotion/react": "^11.11.0", + "@emotion/styled": "^11.11.0", + "@lightsparkdev/lightspark-sdk": "1.0.6", + "@lightsparkdev/oauth": "*", + "@lightsparkdev/ui": "*", + "qrcode.react": "^3.1.0", + "react": "^18.2.0", + "react-dom": "^18.1.0", + "react-router-dom": "6.11.2", + "web-vitals": "^3.3.0" + }, + "devDependencies": { + "@lightsparkdev/eslint-config": "*", + "@lightsparkdev/tsconfig": "*", + "@types/jest": "^29.5.3", + "@types/node": "^20.2.5", + "@types/react": "^18.2.12", + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^4.0.1", + "eslint": "^8.3.0", + "eslint-watch": "^8.0.0", + "tsc-absolute": "^1.0.1", + "typescript": "^4.9.5", + "vite": "^4.3.9" + }, + "scripts": { + "start": "yarn vite", + "build": "yarn tsc && yarn vite build", + "clean": "rm -rf .turbo && rm -rf dist", + "lint:fix": "eslint --fix .", + "lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color", + "lint": "eslint .", + "test": "echo \"TODO\"", + "types:watch": "tsc-absolute --watch", + "types": "tsc" + } +} diff --git a/packages/lightspark-sdk/examples/oauth-example/public/favicon.ico b/apps/examples/oauth-app/public/favicon.ico similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/public/favicon.ico rename to apps/examples/oauth-app/public/favicon.ico diff --git a/packages/lightspark-sdk/examples/oauth-example/public/logo192.png b/apps/examples/oauth-app/public/logo192.png similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/public/logo192.png rename to apps/examples/oauth-app/public/logo192.png diff --git a/packages/lightspark-sdk/examples/oauth-example/public/logo512.png b/apps/examples/oauth-app/public/logo512.png similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/public/logo512.png rename to apps/examples/oauth-app/public/logo512.png diff --git a/packages/lightspark-sdk/examples/oauth-example/public/manifest.json b/apps/examples/oauth-app/public/manifest.json similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/public/manifest.json rename to apps/examples/oauth-app/public/manifest.json diff --git a/packages/lightspark-sdk/examples/oauth-example/public/robots.txt b/apps/examples/oauth-app/public/robots.txt similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/public/robots.txt rename to apps/examples/oauth-app/public/robots.txt diff --git a/packages/lightspark-sdk/examples/oauth-example/src/App.css b/apps/examples/oauth-app/src/App.css similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/src/App.css rename to apps/examples/oauth-app/src/App.css diff --git a/packages/lightspark-sdk/examples/oauth-example/src/App.tsx b/apps/examples/oauth-app/src/App.tsx similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/src/App.tsx rename to apps/examples/oauth-app/src/App.tsx diff --git a/apps/examples/oauth-app/src/Root.tsx b/apps/examples/oauth-app/src/Root.tsx new file mode 100644 index 000000000..475c6e5cb --- /dev/null +++ b/apps/examples/oauth-app/src/Root.tsx @@ -0,0 +1,14 @@ +import { Route, Routes } from "react-router-dom"; +import { MainRoutes } from "./routes"; +import DashboardPage from "./pages/DashboardPage"; +import LoginPage from "./pages/LoginPage"; + +export function Root() { + return ( + + } /> + } /> + } /> + + ); +} diff --git a/packages/lightspark-sdk/examples/oauth-example/src/auth/AuthContext.ts b/apps/examples/oauth-app/src/auth/AuthContext.ts similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/src/auth/AuthContext.ts rename to apps/examples/oauth-app/src/auth/AuthContext.ts diff --git a/packages/lightspark-sdk/examples/oauth-example/src/auth/AuthProvider.tsx b/apps/examples/oauth-app/src/auth/AuthProvider.tsx similarity index 89% rename from packages/lightspark-sdk/examples/oauth-example/src/auth/AuthProvider.tsx rename to apps/examples/oauth-app/src/auth/AuthProvider.tsx index e3660d35d..4ccbf7d0e 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/auth/AuthProvider.tsx +++ b/apps/examples/oauth-app/src/auth/AuthProvider.tsx @@ -1,7 +1,7 @@ import { OAuthProvider as LsOauthProvider } from "@lightsparkdev/oauth"; import React, { useState } from "react"; -import { useLightsparkClient } from "../lightsparkclient/LightsparkClientProvider"; -import AuthContextType from "./AuthContext"; +import { useLightsparkClient } from "src/lightsparkclient/LightsparkClientProvider"; +import type AuthContextType from "./AuthContext"; import { OAuthProvider } from "./oauthProvider"; const AuthContext = React.createContext(null!); diff --git a/packages/lightspark-sdk/examples/oauth-example/src/auth/RequireAuth.tsx b/apps/examples/oauth-app/src/auth/RequireAuth.tsx similarity index 61% rename from packages/lightspark-sdk/examples/oauth-example/src/auth/RequireAuth.tsx rename to apps/examples/oauth-app/src/auth/RequireAuth.tsx index 87c397b4f..41b4b233c 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/auth/RequireAuth.tsx +++ b/apps/examples/oauth-app/src/auth/RequireAuth.tsx @@ -1,16 +1,20 @@ -import { Navigate, useLocation } from "react-router-dom"; +import { useLocation } from "react-router-dom"; import { useAuth } from "./AuthProvider"; +import { Navigate } from "src/components/router"; +import { MainRoutes } from "src/routes"; function RequireAuth({ children }: { children: JSX.Element }) { - let auth = useAuth(); - let location = useLocation(); + const auth = useAuth(); + const location = useLocation(); if (!auth.isAuthorized()) { // Redirect them to the /login page, but save the current location they were // trying to go to when they were redirected. This allows us to send them // along to that page after they login, which is a nicer user experience // than dropping them off on the home page. - return ; + return ( + + ); } return children; diff --git a/packages/lightspark-sdk/examples/oauth-example/src/auth/oauthProvider.ts b/apps/examples/oauth-app/src/auth/oauthProvider.ts similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/src/auth/oauthProvider.ts rename to apps/examples/oauth-app/src/auth/oauthProvider.ts diff --git a/apps/examples/oauth-app/src/components/Button.tsx b/apps/examples/oauth-app/src/components/Button.tsx new file mode 100644 index 000000000..dd0fbd989 --- /dev/null +++ b/apps/examples/oauth-app/src/components/Button.tsx @@ -0,0 +1,5 @@ +/* eslint-disable-next-line no-restricted-imports -- only use with typesafe routes */ +import { Button as ButtonBase } from "@lightsparkdev/ui/components"; +import { type RoutesType } from "src/routes"; + +export const Button = ButtonBase; diff --git a/packages/lightspark-sdk/examples/oauth-example/src/components/Dashboard.tsx b/apps/examples/oauth-app/src/components/Dashboard.tsx similarity index 94% rename from packages/lightspark-sdk/examples/oauth-example/src/components/Dashboard.tsx rename to apps/examples/oauth-app/src/components/Dashboard.tsx index 487042e03..8af6b3148 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/components/Dashboard.tsx +++ b/apps/examples/oauth-app/src/components/Dashboard.tsx @@ -1,12 +1,12 @@ import styled from "@emotion/styled"; -import { Maybe } from "@lightsparkdev/core"; +import { type Maybe } from "@lightsparkdev/core"; import { - CurrencyAmount as CurrencyAmountType, + type CurrencyAmount as CurrencyAmountType, CurrencyUnit, - SingleNodeDashboard, - Transaction, + type SingleNodeDashboard, + type Transaction, } from "@lightsparkdev/lightspark-sdk"; -import CurrencyAmount from "./CurrencyAmount"; +import { CurrencyAmount } from "@lightsparkdev/ui/components"; import { Table, Td, Th, Tr } from "./Table"; const Dashboard = ({ data }: { data: SingleNodeDashboard }) => { diff --git a/packages/lightspark-sdk/examples/oauth-example/src/components/Table.tsx b/apps/examples/oauth-app/src/components/Table.tsx similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/src/components/Table.tsx rename to apps/examples/oauth-app/src/components/Table.tsx diff --git a/apps/examples/oauth-app/src/components/router.tsx b/apps/examples/oauth-app/src/components/router.tsx new file mode 100644 index 000000000..b909a9916 --- /dev/null +++ b/apps/examples/oauth-app/src/components/router.tsx @@ -0,0 +1,24 @@ +/* eslint-disable no-restricted-imports -- only allow in this file */ +import { + Link as LinkBase, + Navigate as NavigateBase, + replaceParams as replaceParamsBase, + useCurrentRoute as useCurrentRouteBase, + useFindMatchingRoute as useFindMatchingRouteBase, + useMatchRoute as useMatchRouteBase, + useMatchRoutes as useMatchRoutesBase, + useNavigate as useNavigateBase, + type LinkProps as LinkPropsBase, +} from "@lightsparkdev/ui/router"; +import type { RoutesType } from "src/routes"; +/* eslint-enable no-restricted-imports */ + +export const replaceParams = replaceParamsBase; +export const Link = LinkBase; +export const Navigate = NavigateBase; +export const useNavigate = useNavigateBase; +export const useMatchRoutes = useMatchRoutesBase; +export const useFindMatchingRoute = useFindMatchingRouteBase; +export const useMatchRoute = useMatchRouteBase; +export const useCurrentRoute = useCurrentRouteBase; +export type LinkProps = LinkPropsBase; diff --git a/packages/lightspark-sdk/examples/oauth-example/src/hooks/useAccountInfo.tsx b/apps/examples/oauth-app/src/hooks/useAccountInfo.tsx similarity index 84% rename from packages/lightspark-sdk/examples/oauth-example/src/hooks/useAccountInfo.tsx rename to apps/examples/oauth-app/src/hooks/useAccountInfo.tsx index fd8646480..1eb9db7a7 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/hooks/useAccountInfo.tsx +++ b/apps/examples/oauth-app/src/hooks/useAccountInfo.tsx @@ -1,6 +1,6 @@ -import { Account } from "@lightsparkdev/lightspark-sdk"; +import { type Account } from "@lightsparkdev/lightspark-sdk"; import { useEffect, useState } from "react"; -import { useLightsparkClient } from "../lightsparkclient/LightsparkClientProvider"; +import { useLightsparkClient } from "src/lightsparkclient/LightsparkClientProvider"; const useAccountInfo = () => { const clientProvider = useLightsparkClient(); diff --git a/packages/lightspark-sdk/examples/oauth-example/src/index.css b/apps/examples/oauth-app/src/index.css similarity index 100% rename from packages/lightspark-sdk/examples/oauth-example/src/index.css rename to apps/examples/oauth-app/src/index.css diff --git a/packages/lightspark-sdk/examples/oauth-example/src/index.tsx b/apps/examples/oauth-app/src/index.tsx similarity index 60% rename from packages/lightspark-sdk/examples/oauth-example/src/index.tsx rename to apps/examples/oauth-app/src/index.tsx index 20babb195..7675e17cc 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/index.tsx +++ b/apps/examples/oauth-app/src/index.tsx @@ -1,19 +1,27 @@ import React from "react"; import ReactDOM from "react-dom/client"; import { BrowserRouter } from "react-router-dom"; +import { GlobalStyles } from "@lightsparkdev/ui/styles/global"; import App from "./App"; import "./index.css"; import reportWebVitals from "./reportWebVitals"; -import routes from "./routes"; +import { Root } from "./Root"; +import { ThemeProvider } from "@emotion/react"; +import { themes } from "@lightsparkdev/ui/styles/colors"; const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement ); root.render( - - {routes} - + + + + + + + + ); diff --git a/packages/lightspark-sdk/examples/oauth-example/src/lightsparkclient/LightsparkClientContext.ts b/apps/examples/oauth-app/src/lightsparkclient/LightsparkClientContext.ts similarity index 63% rename from packages/lightspark-sdk/examples/oauth-example/src/lightsparkclient/LightsparkClientContext.ts rename to apps/examples/oauth-app/src/lightsparkclient/LightsparkClientContext.ts index 4721b2cd8..d20e453d3 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/lightsparkclient/LightsparkClientContext.ts +++ b/apps/examples/oauth-app/src/lightsparkclient/LightsparkClientContext.ts @@ -1,5 +1,5 @@ -import { AuthProvider } from "@lightsparkdev/core"; -import { LightsparkClient } from "@lightsparkdev/lightspark-sdk"; +import { type AuthProvider } from "@lightsparkdev/core"; +import { type LightsparkClient } from "@lightsparkdev/lightspark-sdk"; interface LightsparkClientContextType { getClient: () => LightsparkClient; diff --git a/packages/lightspark-sdk/examples/oauth-example/src/lightsparkclient/LightsparkClientProvider.tsx b/apps/examples/oauth-app/src/lightsparkclient/LightsparkClientProvider.tsx similarity index 80% rename from packages/lightspark-sdk/examples/oauth-example/src/lightsparkclient/LightsparkClientProvider.tsx rename to apps/examples/oauth-app/src/lightsparkclient/LightsparkClientProvider.tsx index 09d02995b..7a28b5220 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/lightsparkclient/LightsparkClientProvider.tsx +++ b/apps/examples/oauth-app/src/lightsparkclient/LightsparkClientProvider.tsx @@ -1,9 +1,9 @@ -import { AuthProvider } from "@lightsparkdev/core"; +import { type AuthProvider } from "@lightsparkdev/core"; import { LightsparkClient } from "@lightsparkdev/lightspark-sdk"; import React, { useState } from "react"; -import LightsparkClientContextType from "./LightsparkClientContext"; +import type LightsparkClientContextType from "./LightsparkClientContext"; -let LightsparkClientContext = React.createContext( +const LightsparkClientContext = React.createContext( null! ); @@ -37,7 +37,7 @@ function LightsparkClientProvider({ children }: { children: React.ReactNode }) { } }; - let value = { getClient, setAuthProvider, isAuthenticated }; + const value = { getClient, setAuthProvider, isAuthenticated }; return ( diff --git a/packages/lightspark-sdk/examples/oauth-example/src/pages/DashboardPage.tsx b/apps/examples/oauth-app/src/pages/DashboardPage.tsx similarity index 78% rename from packages/lightspark-sdk/examples/oauth-example/src/pages/DashboardPage.tsx rename to apps/examples/oauth-app/src/pages/DashboardPage.tsx index a4bc26eff..acfba1f1f 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/pages/DashboardPage.tsx +++ b/apps/examples/oauth-app/src/pages/DashboardPage.tsx @@ -1,15 +1,15 @@ import styled from "@emotion/styled"; import { BitcoinNetwork, - SingleNodeDashboard, + type SingleNodeDashboard, } from "@lightsparkdev/lightspark-sdk"; import { useEffect, useState } from "react"; -import { useAuth } from "../auth/AuthProvider"; -import RequireAuth from "../auth/RequireAuth"; -import { Button } from "../components/Button"; -import Dashboard from "../components/Dashboard"; -import useAccountInfo from "../hooks/useAccountInfo"; -import { useLightsparkClient } from "../lightsparkclient/LightsparkClientProvider"; +import { useAuth } from "src/auth/AuthProvider"; +import RequireAuth from "src/auth/RequireAuth"; +import Dashboard from "src/components/Dashboard"; +import useAccountInfo from "src/hooks/useAccountInfo"; +import { useLightsparkClient } from "src/lightsparkclient/LightsparkClientProvider"; +import { Button } from "src/components/Button"; function DashboardPage() { const [loading, setLoading] = useState(true); @@ -47,12 +47,11 @@ function DashboardPage() {
+ />
diff --git a/packages/lightspark-sdk/examples/oauth-example/src/pages/LoginPage.tsx b/apps/examples/oauth-app/src/pages/LoginPage.tsx similarity index 75% rename from packages/lightspark-sdk/examples/oauth-example/src/pages/LoginPage.tsx rename to apps/examples/oauth-app/src/pages/LoginPage.tsx index abe8a46fa..d5d06437e 100644 --- a/packages/lightspark-sdk/examples/oauth-example/src/pages/LoginPage.tsx +++ b/apps/examples/oauth-app/src/pages/LoginPage.tsx @@ -1,8 +1,10 @@ import styled from "@emotion/styled"; import { useEffect } from "react"; -import { useLocation, useNavigate } from "react-router-dom"; -import { useAuth } from "../auth/AuthProvider"; -import { Button } from "../components/Button"; +import { useLocation } from "react-router-dom"; +import { useAuth } from "src/auth/AuthProvider"; +import { Button } from "src/components/Button"; +import { useNavigate } from "src/components/router"; +import { MainRoutes } from "src/routes"; const LoginPage = () => { const navigate = useNavigate(); @@ -12,12 +14,11 @@ const LoginPage = () => { useEffect(() => { if (window.location.search.includes("code")) { const queryString = window.location.search.substring(1); // includes '?' - const path = ["/oauth", queryString].join("#"); - navigate(path); + navigate(MainRoutes.Oauth, { query: queryString }); } auth.checkAuth().then((isAuthorized: boolean) => { if (isAuthorized) { - navigate("/"); + navigate(MainRoutes.Base); } }); }, [auth, navigate]); @@ -32,16 +33,14 @@ const LoginPage = () => { // when they get to the protected page and click the back button, they // won't end up back on the login page, which is also really nice for the // user experience. - navigate(from, { replace: true }); + navigate(from, undefined, { replace: true }); }); } return ( Log into your Lightspark account to continue - +