Repository navigation
Velt/improvements #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,13 +48,13 @@ export function useCurrentDocument(): CurrentDocument { | |
| localStorage.setItem('velt-demo-document-id', docId); | ||
| } else { | ||
| // 2. Check localStorage for existing document | ||
| const stored = localStorage.getItem('velt-demo-document-id'); | ||
| const stored = localStorage.getItem('velt-inline-comments-demo-doc-id'); | ||
| if (stored) { | ||
| docId = stored; | ||
| } else { | ||
| // 3. Generate new document ID | ||
| docId = `doc-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; | ||
| localStorage.setItem('velt-demo-document-id', docId); | ||
| localStorage.setItem('velt-inline-comments-demo-doc-id', docId); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: localStorage key mismatch causes document ID lossWhen a document ID comes from a URL parameter, it's stored using the old key |
||
| } | ||
|
|
||
| // Update URL with document ID for shareability | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,25 @@ | ||
| 'use client' | ||
|
|
||
| "use client"; | ||
| // [Velt] Provider + collaboration | ||
| import { VeltProvider } from "@veltdev/react"; | ||
| import { useVeltAuthProvider } from "@/components/velt/VeltInitializeUser"; | ||
| import { VeltCollaboration } from "@/components/velt/VeltCollaboration"; | ||
| import DocumentCanvas from '@/components/document/document-canvas' | ||
| import { VeltProvider } from '@veltdev/react' | ||
| import { VeltCollaboration } from '@/components/velt/VeltCollaboration' | ||
| import { AppProviders } from './userAuth/AppProviders' | ||
| import { useVeltAuthProvider } from '@/components/velt/VeltInitializeUser' | ||
|
|
||
| function VeltWrapper({ children }: { children: React.ReactNode }) { | ||
| const { authProvider } = useVeltAuthProvider() | ||
| // [Velt] Replace with your own API key from https://console.velt.dev | ||
| const NEXT_PUBLIC_VELT_API_KEY = "6xTcUFtlYAlCdh11zrKB"; | ||
|
|
||
| export default function Home() { | ||
| // [Velt] Auth provider (reads from app/userAuth/useAppUser) | ||
| const { authProvider } = useVeltAuthProvider(); | ||
|
|
||
| return ( | ||
| // [Velt] Wrap app with VeltProvider | ||
| <VeltProvider | ||
| apiKey={process.env.NEXT_PUBLIC_VELT_API_KEY || '6xTcUFtlYAlCdh11zrKB'} | ||
| apiKey={NEXT_PUBLIC_VELT_API_KEY} | ||
| authProvider={authProvider} | ||
| > | ||
| <VeltCollaboration /> | ||
| {children} | ||
| <DocumentCanvas /> | ||
| </VeltProvider> | ||
| ) | ||
| } | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
| <AppProviders> | ||
| <VeltWrapper> | ||
| <main className="flex h-screen w-screen"> | ||
| <DocumentCanvas /> | ||
| </main> | ||
| </VeltWrapper> | ||
| </AppProviders> | ||
| ) | ||
| } | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,22 @@ | ||
| 'use client'; | ||
| "use client"; | ||
| import { useEffect } from 'react'; | ||
| import { useSetDocuments } from '@veltdev/react'; | ||
| import { useCurrentDocument } from '@/app/document/useCurrentDocument'; | ||
| import { useAppUser } from '@/app/userAuth/useAppUser'; | ||
|
|
||
| export default function VeltInitializeDocument() { | ||
| const { documentId, documentName } = useCurrentDocument(); | ||
| const { user } = useAppUser(); | ||
|
|
||
| // [Velt] Get document setter hook | ||
| const { setDocuments } = useSetDocuments(); | ||
|
|
||
| // [Velt] Set document in Velt. This is the resource where all Velt collaboration data will be scoped. | ||
| useEffect(() => { | ||
| if (!user || !documentId || !documentName) return; | ||
| if (!documentId || !documentName) return; | ||
|
|
||
| setDocuments([ | ||
| { id: documentId, metadata: { documentName: documentName || 'Untitled' } }, | ||
| { id: documentId, metadata: { documentName: documentName } }, | ||
| ]); | ||
| }, [user, setDocuments, documentId, documentName]); | ||
| }, [setDocuments, documentId, documentName]); | ||
|
|
||
| return null; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| "use client"; | ||
| import { VeltWireframe } from '@veltdev/react'; | ||
| import VeltCommentBubbleWf from "./VeltCommentBubbleWf"; | ||
| import VeltCommentToolWf from "./VeltCommentToolWf"; | ||
| import VeltNotificationsToolWf from "./VeltNotificationsToolWf"; | ||
| import VeltSidebarButtonWf from "./VeltSidebarButtonWf"; | ||
| import "./styles.css"; | ||
|
|
||
| export function VeltCustomization() { | ||
|
|
||
| return ( | ||
| <VeltWireframe> | ||
| <VeltSidebarButtonWf /> | ||
| <VeltCommentToolWf /> | ||
| <VeltCommentBubbleWf /> | ||
| <VeltNotificationsToolWf /> | ||
| </VeltWireframe> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Hardcoded API credentials exposed in source code
The API key and auth token were changed from reading environment variables to hardcoded string values. The
VELT_AUTH_TOKEN(bd4d5226050470b6c658054fcdf1092a) is particularly sensitive as it's used to generate authentication tokens via the Velt API. Committing secrets to source control exposes them to anyone with repository access and makes credential rotation difficult.Additional Locations (1)
apps/react/comments/dashboard/inline-comments/dashboard-inline-comments-demo/app/page.tsx#L8-L9