diff --git a/apps/console/src/app/api/signin/route.ts b/apps/console/src/app/api/signin/route.ts index 486b0327..c7b50549 100644 --- a/apps/console/src/app/api/signin/route.ts +++ b/apps/console/src/app/api/signin/route.ts @@ -1,9 +1,11 @@ import { NextRequest, NextResponse } from 'next/server'; -import { tap, justaname, Session } from '../../../../lib'; +import { justaname, Session, tap } from '../../../../lib'; import { SignInResponse } from '@justaname.id/sdk'; export const POST = async (req: NextRequest) => { const { message, signature } = await req.json(); + + console.log(message, signature); const session = await Session.fromRequest(req); let signInMessage: SignInResponse; @@ -13,21 +15,26 @@ export const POST = async (req: NextRequest) => { message, signature, nonce: session.nonce, - domain: process.env.DOMAIN + domain: process.env.DOMAIN, }); } catch (error) { - return tap(new NextResponse(error.message, { status: 422 }), res => session.clear(res)); + return tap(new NextResponse(error.message, { status: 422 }), (res) => + session.clear(res) + ); } const { data: fields, ens, success, error } = signInMessage; - if(!success) { - return tap(new NextResponse(error?.type || "something went wrong", { status: 422 }), res => session.clear(res)); + if (!success) { + return tap( + new NextResponse(error?.type || 'something went wrong', { status: 422 }), + (res) => session.clear(res) + ); } session.address = fields.address; session.chainId = fields.chainId; session.ens = ens; - return tap(new NextResponse(''), res => session.persist(res)); + return tap(new NextResponse(''), (res) => session.persist(res)); }; diff --git a/apps/console/src/components/sections/code/CodeSection/index.tsx b/apps/console/src/components/sections/code/CodeSection/index.tsx index fcca18df..0f94f11d 100644 --- a/apps/console/src/components/sections/code/CodeSection/index.tsx +++ b/apps/console/src/components/sections/code/CodeSection/index.tsx @@ -1,8 +1,8 @@ -import { a11yLight, CopyBlock } from 'react-code-blocks'; import { JustWeb3Context } from '@justweb3/widget'; -import { useContext, useMemo } from 'react'; +import React, { useContext, useMemo } from 'react'; import { useJustWeb3Theme } from '@justweb3/ui'; import { useConsole } from '../../../../providers/ConsoleProvider'; +import { Highlight, themes } from 'prism-react-renderer'; export const CodeSection: React.FC = () => { const { config } = useContext(JustWeb3Context); @@ -14,7 +14,7 @@ export const CodeSection: React.FC = () => { if (config.plugins?.find((p) => p.name === 'JustVerifiedPlugin')) { plugins.push( - `JustVerifiedPlugin([${justVerified.map((v) => `'${v}'`).join(', ')}])` + `JustVerifiedPlugin([${justVerified.map((v) => `${v}`).join(', ')}])` ); } @@ -22,8 +22,9 @@ export const CodeSection: React.FC = () => { plugins.push('EFPPlugin'); } - return `import '@rainbow-me/rainbowkit/styles.css' -import '@justweb3/widget/styles.css' + return ` +import '@rainbow-me/rainbowkit/styles.css'; +import '@justweb3/widget/styles.css'; import React from 'react'; import { getDefaultConfig, @@ -39,21 +40,14 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { - WagmiProvider -} from 'wagmi'; -import { - mainnet, - sepolia -} from 'wagmi/chains'; +import { WagmiProvider } from 'wagmi'; +import { mainnet, sepolia } from 'wagmi/chains'; import { JustWeb3Provider, JustWeb3ProviderConfig, JustWeb3Button } from '@justweb3/widget'; -import { - ConnectButton -} from '@rainbow-me/rainbowkit'; +import { ConnectButton } from '@rainbow-me/rainbowkit'; ${ config.plugins?.find((p) => p.name === 'JustVerifiedPlugin') ? "import { JustVerifiedPlugin } from '@justverified/plugin';" @@ -64,7 +58,7 @@ ${ ? "import { EFPPlugin } from '@justweb3/efp-plugin';" : '' } - + export const App: React.FC = () => { const { wallets } = getDefaultWallets(); @@ -85,6 +79,16 @@ export const App: React.FC = () => { const justweb3Config: JustWeb3ProviderConfig = ${JSON.stringify( { ...config, + networks: [ + { + chainId: 1, + providerUrl: ``, + }, + { + chainId: 11155111, + providerUrl: ``, + }, + ], dev: undefined, disableOverlay: undefined, plugins: plugins.length > 0 ? plugins : undefined, @@ -111,25 +115,57 @@ export const App: React.FC = () => { ); }; -export default App; - `; +export default App;`.trim(); }, [color, config, justVerified]); + const handleCopy = () => { + navigator.clipboard.writeText(code); + }; + return (
-

Code

- +
+

Code

+ +
+ + {({ className, style, tokens, getLineProps, getTokenProps }) => ( +
+            {tokens.map((line, i) => (
+              
+ + {i + 1} + + + {line.map((token, key) => ( + + ))} + +
+ ))} +
+ )} +
); }; diff --git a/apps/console/src/components/sections/customizer/PluginsSection/Verified/index.tsx b/apps/console/src/components/sections/customizer/PluginsSection/Verified/index.tsx index a1ae22a9..1c6ca75e 100644 --- a/apps/console/src/components/sections/customizer/PluginsSection/Verified/index.tsx +++ b/apps/console/src/components/sections/customizer/PluginsSection/Verified/index.tsx @@ -80,25 +80,35 @@ export const Verified = () => { }, [justVerified]); return ( - + + plugin.name === 'JustVerifiedPlugin' + ) + } + onClick={(e) => { + e.stopPropagation(); + }} + onCheckedChange={(checked) => { + handleJustVerifiedConfig(checked); + }} + style={{ + position: 'absolute', + right: 0, + top: '24px', + }} + />

JustVerified

- plugin.name === 'JustVerifiedPlugin' - ) - } - onClick={(e) => { - e.stopPropagation(); - }} - onCheckedChange={(checked) => { - handleJustVerifiedConfig(checked); - }} - />
diff --git a/demo/express-trial/.env.example b/demo/express-trial/.env.example deleted file mode 100644 index a7319491..00000000 --- a/demo/express-trial/.env.example +++ /dev/null @@ -1,6 +0,0 @@ -JUSTANAME_API_KEY=your_api_key -JUSTANAME_PROVIDER_URL=https://rpc.yourprovider.com -JUSTANAME_CHAIN_ID=your_chain_id -JUSTANAME_DOMAIN=yourwebsite -JUSTANAME_ORIGIN=yourwebsite.com -JUSTANAME_ENS_DOMAIN=yourens.eth \ No newline at end of file diff --git a/demo/react-trial/src/app/components/ClaimSubname.tsx b/demo/react-trial/src/app/components/ClaimSubname.tsx deleted file mode 100644 index 0738d7bf..00000000 --- a/demo/react-trial/src/app/components/ClaimSubname.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { useAddSubname, useIsSubnameAvailable } from '@justaname.id/react'; -import { useState } from 'react'; -import { useDebounce } from '@uidotdev/usehooks'; -import { ConnectButton } from '@rainbow-me/rainbowkit'; -import { useAccount } from 'wagmi'; - -export const AddSubname = () => { - const { isConnected } = useAccount(); - const [username, setUsername] = useState(''); - const debouncedUsername = useDebounce(username, 500); - const { isSubnameAvailable } = useIsSubnameAvailable({ - username: debouncedUsername, - }); - const { addSubname } = useAddSubname(); - - return ( -
-

Claim your subdomain

- - setUsername(e.target.value)} - placeholder="Enter a subdomain" - /> - -
- ); -}; diff --git a/demo/react-trial/src/app/components/Subname.tsx b/demo/react-trial/src/app/components/Subname.tsx deleted file mode 100644 index 72ee8971..00000000 --- a/demo/react-trial/src/app/components/Subname.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import React from 'react'; -import { useSubname, useUpdateSubname } from '@justaname.id/react'; - -export interface SubnameProps { - currentSubname: string; -} -export const Subname: React.FC = ({ currentSubname }) => { - const { subname } = useSubname({ - subname: currentSubname - }) - - const { - updateSubname - } = useUpdateSubname(); - - if (!subname) { - return

Loading...

- } - - return ( -
-

{subname?.subname}

- -

Data

- - - - - - - - - - { - subname.data.textRecords.map((record, index) => ( - - - - - )) - } - -
KeyValue
{record.key}{record.value}
- -
{ - e.preventDefault(); - const formData = new FormData(e.target as HTMLFormElement); - const key = formData.get('key') as string; - const value = formData.get('value') as string; - updateSubname({ - username: subname.username, - subname: subname.subname, - ...subname.data, - text: [ - ...subname.data.textRecords.filter(record => record.key !== key ).map((record)=>{ - return { - key: record.key, - value: record.value - } - }), - { - key, - value - } - ], - contentHash: subname.data.contentHash - }); - }}> - - - -
-
- ) -} \ No newline at end of file diff --git a/demo/server/.env.example b/demo/server/.env.example new file mode 100644 index 00000000..d0df3804 --- /dev/null +++ b/demo/server/.env.example @@ -0,0 +1,6 @@ +JUSTANAME_API_KEY= +JUSTANAME_PROVIDER_URL= +JUSTANAME_CHAIN_ID= +JUSTANAME_DOMAIN= +JUSTANAME_ORIGIN= +JUSTANAME_ENS_DOMAIN= \ No newline at end of file diff --git a/demo/express-trial/.eslintrc.json b/demo/server/.eslintrc.json similarity index 100% rename from demo/express-trial/.eslintrc.json rename to demo/server/.eslintrc.json diff --git a/demo/express-trial/.gitignore b/demo/server/.gitignore similarity index 100% rename from demo/express-trial/.gitignore rename to demo/server/.gitignore diff --git a/demo/express-trial/jest.config.ts b/demo/server/jest.config.ts similarity index 73% rename from demo/express-trial/jest.config.ts rename to demo/server/jest.config.ts index bea9d529..dbfe8e2d 100644 --- a/demo/express-trial/jest.config.ts +++ b/demo/server/jest.config.ts @@ -1,12 +1,12 @@ /* eslint-disable */ export default { - displayName: 'justaname-express-trial', + displayName: 'server', preset: '../../jest.preset.js', testEnvironment: 'node', transform: { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/apps/express-trial', + coverageDirectory: '../../coverage/apps/server', passWithNoTests: true, }; diff --git a/demo/express-trial/project.json b/demo/server/project.json similarity index 59% rename from demo/express-trial/project.json rename to demo/server/project.json index 9039387c..650039e6 100644 --- a/demo/express-trial/project.json +++ b/demo/server/project.json @@ -1,21 +1,21 @@ { - "name": "justaname-express-trial", + "name": "server", "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "demo/express-trial/src", + "sourceRoot": "demo/server/src", "projectType": "application", "targets": { "serve": { "executor": "@nx/js:node", "defaultConfiguration": "development", "options": { - "buildTarget": "justaname-express-trial:build" + "buildTarget": "server:build" }, "configurations": { "development": { - "buildTarget": "justaname-express-trial:build:development" + "buildTarget": "server:build:development" }, "production": { - "buildTarget": "justaname-express-trial:build:production" + "buildTarget": "server:build:production" } } }, @@ -26,10 +26,10 @@ "options": { "target": "node", "compiler": "tsc", - "outputPath": "dist/demo/express-trial", - "main": "demo/express-trial/src/main.ts", - "tsConfig": "demo/express-trial/tsconfig.app.json", - "webpackConfig": "demo/express-trial/webpack.config.js", + "outputPath": "dist/demo/server", + "main": "demo/server/src/main.ts", + "tsConfig": "demo/server/tsconfig.app.json", + "webpackConfig": "demo/server/webpack.config.js", "generatePackageJson": true }, "configurations": { diff --git a/demo/express-trial/src/assets/.gitkeep b/demo/server/src/assets/.gitkeep similarity index 100% rename from demo/express-trial/src/assets/.gitkeep rename to demo/server/src/assets/.gitkeep diff --git a/demo/express-trial/src/config.ts b/demo/server/src/config.ts similarity index 100% rename from demo/express-trial/src/config.ts rename to demo/server/src/config.ts diff --git a/demo/express-trial/src/main.ts b/demo/server/src/main.ts similarity index 100% rename from demo/express-trial/src/main.ts rename to demo/server/src/main.ts diff --git a/demo/express-trial/tsconfig.app.json b/demo/server/tsconfig.app.json similarity index 100% rename from demo/express-trial/tsconfig.app.json rename to demo/server/tsconfig.app.json diff --git a/demo/express-trial/tsconfig.json b/demo/server/tsconfig.json similarity index 100% rename from demo/express-trial/tsconfig.json rename to demo/server/tsconfig.json diff --git a/demo/express-trial/tsconfig.spec.json b/demo/server/tsconfig.spec.json similarity index 100% rename from demo/express-trial/tsconfig.spec.json rename to demo/server/tsconfig.spec.json diff --git a/demo/express-trial/webpack.config.js b/demo/server/webpack.config.js similarity index 100% rename from demo/express-trial/webpack.config.js rename to demo/server/webpack.config.js diff --git a/demo/with-privy/.env.example b/demo/with-privy/.env.example new file mode 100644 index 00000000..d79f1b59 --- /dev/null +++ b/demo/with-privy/.env.example @@ -0,0 +1,6 @@ +VITE_APP_BACKEND_URL= +VITE_APP_ORIGIN= +VITE_APP_DOMAIN= +VITE_APP_MAINNET_PROVIDER_URL= +VITE_APP_SEPOLIA_PROVIDER_URL= +VITE_APP_PRIVY_APP_ID= \ No newline at end of file diff --git a/demo/with-privy/src/app/app.tsx b/demo/with-privy/src/app/app.tsx index 842ccbbb..1a935975 100644 --- a/demo/with-privy/src/app/app.tsx +++ b/demo/with-privy/src/app/app.tsx @@ -1,9 +1,12 @@ -import { JustWeb3Provider, JustWeb3ProviderConfig } from '@justweb3/widget'; +import { + JustWeb3Button, + JustWeb3Provider, + JustWeb3ProviderConfig, +} from '@justweb3/widget'; import '@rainbow-me/rainbowkit/styles.css'; import { http } from 'wagmi'; import { mainnet, sepolia } from 'wagmi/chains'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { ChainId } from '@justaname.id/sdk'; import { PrivyProvider, usePrivy } from '@privy-io/react-auth'; import { createConfig, WagmiProvider } from '@privy-io/wagmi'; import { useEnsAuth } from '@justaname.id/react'; @@ -18,14 +21,12 @@ const JustaNameConfig: JustWeb3ProviderConfig = { backendUrl: import.meta.env.VITE_APP_BACKEND_URL, networks: [ { - chainId: parseInt(import.meta.env.VITE_APP_CHAIN_ID) as ChainId, - providerUrl: import.meta.env.VITE_APP_PROVIDER_URL, + chainId: 1, + providerUrl: import.meta.env.VITE_APP_MAINNET_PROVIDER_URL, }, - ], - ensDomains: [ { - ensDomain: import.meta.env.VITE_APP_ENS_DOMAIN, - chainId: parseInt(import.meta.env.VITE_APP_CHAIN_ID) as ChainId, + chainId: 11155111, + providerUrl: import.meta.env.VITE_APP_SEPOLIA_PROVIDER_URL, }, ], openOnWalletConnect: true, @@ -42,33 +43,17 @@ const Connect = () => { return (
- {/* If the user is not authenticated, show a login button */} - {/* If the user is authenticated, show the user object and a logout button */} - {ready && authenticated ? ( -
-