Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat: current code

dextmorgn45ba3b91c2e4
diff --git a/next.config.js b/next.config.js
index 658404ac..eebdb225 100644
--- a/next.config.js
+++ b/next.config.js
@@ -1,4 +1,13 @@
/** @type {import('next').NextConfig} */
-const nextConfig = {};
+const nextConfig = {
+ images: {
+ remotePatterns: [
+ {
+ protocol: "https",
+ hostname: "**",
+ },
+ ],
+ },
+};
module.exports = nextConfig;
diff --git a/src/app/auth/callback/route.ts b/src/app/auth/callback/route.ts
new file mode 100644
index 00000000..1dea95e1
--- /dev/null
+++ b/src/app/auth/callback/route.ts
@@ -0,0 +1,30 @@
+import { NextResponse } from 'next/server'
+// The client you created from the Server-Side Auth instructions
+import { createClient } from '@/src/lib/supabase/server'
+
+export async function GET(request: Request) {
+ const { searchParams, origin } = new URL(request.url)
+ const code = searchParams.get('code')
+ // if "next" is in param, use it as the redirect URL
+ const next = searchParams.get('next') ?? '/'
+
+ if (code) {
+ const supabase = await createClient()
+ const { error } = await supabase.auth.exchangeCodeForSession(code)
+ if (!error) {
+ const forwardedHost = request.headers.get('x-forwarded-host') // original origin before load balancer
+ const isLocalEnv = process.env.NODE_ENV === 'development'
+ if (isLocalEnv) {
+ // we can be sure that there is no load balancer in between, so no need to watch for X-Forwarded-Host
+ return NextResponse.redirect(`${origin}${next}`)
+ } else if (forwardedHost) {
+ return NextResponse.redirect(`https://${forwardedHost}${next}`)
+ } else {
+ return NextResponse.redirect(`${origin}${next}`)
+ }
+ }
+ }
+
+ // return the user to an error page with instructions
+ return NextResponse.redirect(`${origin}/auth/auth-code-error`)
+}
\ No newline at end of file
diff --git a/src/app/auth/confirm/route.ts b/src/app/auth/confirm/route.ts
new file mode 100644
index 00000000..db1c675d
--- /dev/null
+++ b/src/app/auth/confirm/route.ts
@@ -0,0 +1,28 @@
+import { type EmailOtpType } from '@supabase/supabase-js'
+import { type NextRequest } from 'next/server'
+
+import { createClient } from '@/src/lib/supabase/server'
+import { redirect } from 'next/navigation'
+
+export async function GET(request: NextRequest) {
+ const { searchParams } = new URL(request.url)
+ const token_hash = searchParams.get('token_hash')
+ const type = searchParams.get('type') as EmailOtpType | null
+ const next = searchParams.get('next') ?? '/'
+
+ if (token_hash && type) {
+ const supabase = await createClient()
+
+ const { error } = await supabase.auth.verifyOtp({
+ type,
+ token_hash,
+ })
+ if (!error) {
+ // redirect user to specified redirect URL or root of app
+ redirect(next)
+ }
+ }
+
+ // redirect the user to an error page with some instructions
+ redirect('/error')
+}
\ No newline at end of file
diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx
index a2a34eea..3f5a66ea 100644
--- a/src/app/dashboard/layout.tsx
+++ b/src/app/dashboard/layout.tsx
@@ -1,10 +1,17 @@
import React from 'react'
+import { createClient } from "@/src/lib/supabase/server";
+import { redirect } from "next/navigation";
-const DashboardLayout = ({
+const DashboardLayout = async ({
children,
}: {
children: React.ReactNode;
}) => {
+ const supabase = await createClient()
+ const { data, error } = await supabase.auth.getUser()
+ if (error || !data?.user) {
+ redirect('/login')
+ }
return (
<div>
<div className="container mx-auto max-w-7xl pt-16 px-6 flex-grow">{children}</div>
diff --git a/src/app/investigations/[investigation_id]/data.js b/src/app/investigations/[investigation_id]/data.js
deleted file mode 100644
index 4fa52055..00000000
--- a/src/app/investigations/[investigation_id]/data.js
+++ /dev/null
@@ -1,26 +0,0 @@
-export const usernames = [
- "@cyberwarrior",
- "@net_hunter",
- "@reconmaster",
- "@pentest_guru",
- "@osint_seeker",
- "@hash_cracker"
-]
-
-export const countries = [
- "France",
- "Germany",
- "United States",
- "Netherlands",
- "Canada",
- "Sweden"
-]
-
-export const settings = [
- "socials",
- "emails",
- "ips",
- "account",
- "address",
- "relations"
-]
diff --git a/src/app/investigations/[investigation_id]/filters.tsx b/src/app/investigations/[investigation_id]/filters.tsx
deleted file mode 100644
index 3830f794..00000000
--- a/src/app/investigations/[investigation_id]/filters.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-"use client"
-import React from 'react'
-import { settings } from './data.js'
-import DisplaySelector from '@/src/components/investigations/display-selector';
-import { Skeleton, Text } from '@radix-ui/themes';
-import { useUsernames } from '@/src/lib/hooks/investigation/usernames';
-
-const Filters = ({ investigation_id }: { investigation_id: string }) => {
- const { usernames, isLoading } = useUsernames(investigation_id)
- return (
- <div className='flex flex-col gap-2'>
- <Text size={"2"}>Display</Text>
- <DisplaySelector values={settings} />
- <Text size={"2"}>Usernames</Text>
- <Skeleton loading={isLoading}>
- <DisplaySelector values={usernames?.map(({ username }) => username) || []} />
- </Skeleton>
- </div>
- )
-}
-
-export default Filters
\ No newline at end of file
diff --git a/src/app/investigations/[investigation_id]/individuals.tsx b/src/app/investigations/[investigation_id]/individuals.tsx
new file mode 100644
index 00000000..f1f299af
--- /dev/null
+++ b/src/app/investigations/[investigation_id]/individuals.tsx
@@ -0,0 +1,60 @@
+"use client"
+import React from 'react'
+import { Avatar, Box, Card, Flex, IconButton, Skeleton, Text } from '@radix-ui/themes';
+import { useIndividuals } from '@/src/lib/hooks/individuals/use-individuals';
+import { useInvestigationContext } from '@/src/components/contexts/investigation-provider';
+import { cn } from '@/src/lib/utils';
+import { Pencil1Icon } from '@radix-ui/react-icons';
+
+const Filters = ({ investigation_id }: { investigation_id: string }) => {
+ const { individuals, isLoading } = useIndividuals(investigation_id)
+ const { currentNode, setCurrentNode, handleOpenIndividualModal } = useInvestigationContext()
+
+ return (
+ <div className='flex flex-col gap-2'>
+ <Text size={"2"}>Profiles</Text>
+ <Flex direction={"column"} gap="3">
+ {isLoading && <>
+ <Skeleton height={"48px"} />
+ <Skeleton height={"48px"} />
+ <Skeleton height={"48px"} />
+ </>
+ }
+ {individuals?.map((individual: any) => (
+ <Box key={individual.id} maxWidth="240px">
+ <Card className={cn('relative group cursor-pointer border border-transparent hover:border-sky-400', currentNode === individual.id && 'border-sky-400')} onClick={() => setCurrentNode(individual.id)}>
+ <Flex gap="3" align="center">
+ <Avatar
+ size="3"
+ src={individual?.image_url}
+ radius="full"
+ fallback={individual?.full_name[0]}
+ />
+ <Box>
+ <Text as="div" size="2" weight="bold">
+ {individual.full_name}
+ </Text>
+ <Text as="div" size="2" color="gray">
+ {individual.notes}
+ </Text>
+ </Box>
+ </Flex>
+ <IconButton
+ className='!absolute !top-2 !right-2 !hidden group-hover:!block'
+ type="button"
+ variant="ghost"
+ size={"1"}
+ onClick={(e) => { e.stopPropagation(); handleOpenIndividualModal(individual.id) }}
+ aria-label={"Edit profile"}
+ >
+ <Pencil1Icon />
+ </IconButton>
+ </Card>
+ </Box>
+ ))}
+ </Flex>
+ </div >
+ )
+}
+
+export default Filters
\ No newline at end of file
diff --git a/src/app/investigations/[investigation_id]/layout.tsx b/src/app/investigations/[investigation_id]/layout.tsx
index c3e22d9e..f2945138 100644
--- a/src/app/investigations/[investigation_id]/layout.tsx
+++ b/src/app/investigations/[investigation_id]/layout.tsx
@@ -1,9 +1,12 @@
import { InvestigationProvider } from '@/src/components/contexts/investigation-provider';
import InvestigationLayout from '@/src/components/investigations/layout';
import { getInvestigation } from '@/src/lib/actions/investigations';
-import Filters from './filters';
+import Individuals from './individuals';
import { SearchProvider } from '@/src/components/contexts/search-context';
import { notFound } from 'next/navigation';
+import { createClient } from "@/src/lib/supabase/server";
+import { redirect } from "next/navigation";
+
const DashboardLayout = async ({
children,
params,
@@ -11,6 +14,11 @@ const DashboardLayout = async ({
children: React.ReactNode;
params: Promise<{ investigation_id: string }>
}) => {
+ const supabase = await createClient()
+ const { data, error: userError } = await supabase.auth.getUser()
+ if (userError || !data?.user) {
+ redirect('/login')
+ }
const { investigation_id } = await (params)
const { error } = await getInvestigation(investigation_id)
if (error) return notFound()
@@ -18,7 +26,7 @@ const DashboardLayout = async ({
return (
<InvestigationProvider>
<SearchProvider>
- <InvestigationLayout left={<Filters investigation_id={investigation_id} />}>
+ <InvestigationLayout left={<Individuals investigation_id={investigation_id} />}>
{children}
</InvestigationLayout>
</SearchProvider>
diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx
new file mode 100644
index 00000000..f5311226
--- /dev/null
+++ b/src/app/login/page.tsx
@@ -0,0 +1,17 @@
+import { LoginForm } from "@/src/components/login-form"
+import { createClient } from "@/src/lib/supabase/server"
+import { redirect } from "next/navigation"
+
+export default async function Page() {
+ const supabase = await createClient()
+ const { data, error } = await supabase.auth.getUser()
+ if (!error || data.user) {
+ redirect('/dashboard')
+ }
+
+ return (
+ <div className="flex h-screen w-full items-center justify-center px-4">
+ <LoginForm />
+ </div>
+ )
+}
\ No newline at end of file
diff --git a/src/components/breach.tsx b/src/components/breach.tsx
new file mode 100644
index 00000000..9fa78b7d
--- /dev/null
+++ b/src/components/breach.tsx
@@ -0,0 +1,110 @@
+"use client"
+
+import type React from "react"
+import * as Accordion from "@radix-ui/react-accordion"
+import { ChevronDownIcon } from "@radix-ui/react-icons"
+import Image from "next/image"
+
+type BreachData = {
+ Name: string
+ Title: string
+ Domain: string
+ BreachDate: string
+ AddedDate: string
+ ModifiedDate: string
+ PwnCount: number
+ Description: string
+ LogoPath: string
+ DataClasses: string[]
+ IsVerified: boolean
+ IsFabricated: boolean
+ IsSensitive: boolean
+ IsRetired: boolean
+ IsSpamList: boolean
+ IsMalware: boolean
+ IsSubscriptionFree: boolean
+ IsStealerLog: boolean
+}
+
+type BreachProps = {
+ breaches: BreachData[]
+}
+const Breaches: React.FC<BreachProps> = ({ breaches }) => {
+ return (
+ <Accordion.Root type="single" collapsible className="w-full mx-auto">
+ {breaches.map((breach) => (
+ <Accordion.Item
+ key={breach.Name}
+ value={breach.Name}
+ className="mt-2 border dark:border-gray-500/10 rounded-lg overflow-hidden"
+ >
+ <Accordion.Trigger className="flex items-center justify-between w-full p-2 text-left">
+ <div className="flex items-center space-x-4">
+ <Image
+ src={breach.LogoPath || "/placeholder.svg"}
+ alt={`${breach.Title} logo`}
+ width={40}
+ height={40}
+ className="rounded-full h-[40px] w-[40px]"
+ />
+ <div>
+ <h3 className="text-lg font-semibold">{breach.Title}</h3>
+ <p className="text-sm">{new Date(breach.BreachDate).toLocaleDateString()}</p>
+ </div>
+ </div>
+ <ChevronDownIcon
+ className="w-6 h-6 transition-transform duration-300 ease-in-out"
+ aria-hidden
+ />
+ </Accordion.Trigger>
+ <Accordion.Content className="p-6">
+ <div className="space-y-3">
+ <div>
+ <h4 className="text-sm font-semibold">Description:</h4>
+ <p className="text-sm opacity-60" dangerouslySetInnerHTML={{ __html: breach.Description }} />
+ </div>
+ <div>
+ <h4 className="text-sm font-semibold">Compromised Data:</h4>
+ <ul className="list-disc list-inside text-sm opacity-60">
+ {breach.DataClasses.map((dataClass) => (
+ <li key={dataClass}>{dataClass}</li>
+ ))}
+ </ul>
+ </div>
+ <div className="grid grid-cols-2 gap-4 text-sm">
+ <div>
+ <h4 className="font-semibold">Affected Accounts:</h4>
+ <p className="opacity-60">{breach.PwnCount.toLocaleString()}</p>
+ </div>
+ <div>
+ <h4 className="font-semibold">Domain:</h4>
+ <p className="opacity-60">{breach.Domain || "N/A"}</p>
+ </div>
+ <div>
+ <h4 className="font-semibold">Added Date:</h4>
+ <p className="opacity-60">{new Date(breach.AddedDate).toLocaleDateString()}</p>
+ </div>
+ <div>
+ <h4 className="font-semibold">Modified Date:</h4>
+ <p className="opacity-60">{new Date(breach.ModifiedDate).toLocaleDateString()}</p>
+ </div>
+ </div>
+ <div className="grid grid-cols-2 gap-2 text-sm">
+ {Object.entries(breach)
+ .filter(([key, value]) => typeof value === "boolean")
+ .map(([key, value]) => (
+ <div key={key} className="flex items-center">
+ <span className={`w-4 h-4 mr-2 rounded-full ${value ? "bg-green-500" : "bg-red-500"}`}></span>
+ <span className="opacity-60">{key.replace(/^Is/, "")}</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ </Accordion.Content>
+ </Accordion.Item>
+ ))}
+ </Accordion.Root>
+ )
+}
+
+export default Breaches
\ No newline at end of file
diff --git a/src/components/contexts/investigation-provider.tsx b/src/components/contexts/investigation-provider.tsx
index 868a938e..25100094 100644
--- a/src/components/contexts/investigation-provider.tsx
+++ b/src/components/contexts/investigation-provider.tsx
@@ -18,7 +18,9 @@ interface InvestigationContextType {
investigation: Investigation | null,
isLoadingInvestigation: boolean | undefined,
handleOpenIndividualModal: any,
- handleDeleteInvestigation: any
+ handleDeleteInvestigation: any,
+ currentNode: any,
+ setCurrentNode: any
}
const InvestigationContext = createContext<InvestigationContextType | undefined>(undefined);
@@ -32,6 +34,7 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch
const pathname = usePathname()
const searchParams = useSearchParams()
const [filters, setFilters] = useLocalStorage('filters', {});
+ const [currentNode, setCurrentNode] = useState<null | Node>(null)
const { investigation, isLoading: isLoadingInvestigation } = useInvestigation(investigation_id)
const [openSettingsModal, setOpenSettingsModal] = useState(false)
const { confirm } = useConfirm()
@@ -73,7 +76,7 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch
</div>
)
return (
- <InvestigationContext.Provider value={{ filters, setFilters, settings, setSettings, setOpenSettingsModal, investigation, isLoadingInvestigation, handleOpenIndividualModal, handleDeleteInvestigation }}>
+ <InvestigationContext.Provider value={{ filters, setFilters, settings, setSettings, setOpenSettingsModal, investigation, isLoadingInvestigation, handleOpenIndividualModal, handleDeleteInvestigation, currentNode, setCurrentNode }}>
{children}
<Dialog.Root open={openSettingsModal}>
<Dialog.Content maxWidth="450px">
diff --git a/src/components/contexts/search-context.tsx b/src/components/contexts/search-context.tsx
index 4f5eb2f6..b1cf2857 100644
--- a/src/components/contexts/search-context.tsx
+++ b/src/components/contexts/search-context.tsx
@@ -4,6 +4,7 @@ import { Button, Callout, Card, Dialog, Flex, Text, TextField } from "@radix-ui/
import { InfoCircledIcon } from "@radix-ui/react-icons";
import { investigateValue } from "@/src/lib/actions/search";
import { useParams } from "next/navigation";
+import Breaches from "../breach";
interface SearchContextType {
openSearchModal: boolean,
@@ -20,7 +21,7 @@ export const SearchProvider: React.FC<SearchProviderProps> = (props: any) => {
const [openSearchModal, setOpenSearchModal] = useState(false)
const { investigation_id } = useParams()
const [value, setValue] = useState<string | null>(null)
- const [results, setResults] = useState<null | any>(null)
+ const [results, setResults] = useState<null | any>()
const [isLoading, setIsLoading] = useState(false)
const [error, setError] = useState("")
@@ -63,40 +64,53 @@ export const SearchProvider: React.FC<SearchProviderProps> = (props: any) => {
<form onSubmit={onSubmitNewSearch}>
<Flex direction="column" gap="3">
<Card><Text weight={"regular"}>value: </Text><Text weight={"medium"}>"{value}"</Text></Card>
- <Callout.Root size="1">
+ {/* <Callout.Root size="1">
<Callout.Icon>
<InfoCircledIcon />
</Callout.Icon>
<Callout.Text>
This query may return some (a lot) or no results. Make sure you filter your results manually afterwards.
</Callout.Text>
- </Callout.Root>
+ </Callout.Root> */}
{error &&
<Callout.Root color="red" size="1">
<Callout.Icon>
<InfoCircledIcon />
</Callout.Icon>
<Callout.Text>
- This query may return some (a lot) or no results. Make sure you filter your results manually afterwards.
+ {JSON.stringify(error)}
</Callout.Text>
</Callout.Root>}
- {results &&
- <Callout.Root color="green" size="1">
+ {results && Array.isArray(results) ?
+ <>
+ <Callout.Root color="orange" size="1">
+ <Callout.Icon>
+ <InfoCircledIcon />
+ </Callout.Icon>
+ <Callout.Text>
+ "{value}" has appeared in {results.length} data breach(es). Here are the infos we have:
+ </Callout.Text>
+ </Callout.Root>
+ <Breaches breaches={results} />
+ </> : results && <Callout.Root color="green" size="1">
<Callout.Icon>
<InfoCircledIcon />
</Callout.Icon>
<Callout.Text>
- {JSON.stringify(results, null, 2)}
+ {JSON.stringify(results)}
</Callout.Text>
- </Callout.Root>}
+ </Callout.Root>
+ }
</Flex>
<Flex gap="3" mt="4" justify="end">
<Dialog.Close>
<Button variant="soft" color="gray">
- Cancel
+ Close
</Button>
</Dialog.Close>
- <Button autoFocus loading={isLoading} type="submit">Save</Button>
+ {!results &&
+ <Button autoFocus loading={isLoading} type="submit">Save</Button>
+ }
</Flex>
</form>
</Dialog.Content>
diff --git a/src/components/investigations/custom-edge.tsx b/src/components/investigations/custom-edge.tsx
index 6d2038dc..6eecfa1f 100644
--- a/src/components/investigations/custom-edge.tsx
+++ b/src/components/investigations/custom-edge.tsx
@@ -17,7 +17,7 @@ export default function CustomEdge(props: any) {
const { settings } = useInvestigationContext()
return (
<>
- <BaseEdge id={id} path={edgePath} />
+ <BaseEdge id={id} path={edgePath} style={style} />
<EdgeLabelRenderer>
{settings.showEdgeLabel &&
<Badge size={"1"} color={label === "relation" ? 'orange' : "blue"} style={{
diff --git a/src/components/investigations/display-selector.tsx b/src/components/investigations/display-selector.tsx
index 54f3c8d2..10b066c2 100644
--- a/src/components/investigations/display-selector.tsx
+++ b/src/components/investigations/display-selector.tsx
@@ -34,13 +34,13 @@ export default function DisplaySelector({ values }: { values: string[] }) {
layout
initial={false}
animate={{
- backgroundColor: isSelected ? "#2a1711" : "rgba(39, 39, 42, 0.5)",
+ backgroundColor: isSelected ? "#2a1711" : "rgba(39, 39, 42, 0.07)",
}}
whileHover={{
- backgroundColor: isSelected ? "#2a1711" : "rgba(39, 39, 42, 0.8)",
+ backgroundColor: isSelected ? "#2a1711" : "rgba(39, 39, 42, 0.07)",
}}
whileTap={{
- backgroundColor: isSelected ? "#1f1209" : "rgba(39, 39, 42, 0.9)",
+ backgroundColor: isSelected ? "#1f1209" : "rgba(39, 39, 42, 0.07)",
}}
transition={{
type: "spring",
@@ -53,8 +53,8 @@ export default function DisplaySelector({ values }: { values: string[] }) {
inline-flex items-center px-2 py-1 rounded-full text-xs font-medium
whitespace-nowrap overflow-hidden ring-1 ring-inset
${isSelected
- ? "text-[#ff9066] ring-[hsla(0,0%,100%,0.12)]"
- : "text-zinc-400 ring-[hsla(0,0%,100%,0.06)]"}
+ ? "text-[#ff9066] ring-[hsla(0, 0.00%, 100.00%, 0.32)]"
+ : "text-zinc-400 ring-[hsla(0, 0.00%, 100.00%, 0.33)]"}
`}
>
<motion.div
diff --git a/src/components/investigations/graph.tsx b/src/components/investigations/graph.tsx
index b7c201f0..75a9f14a 100644
--- a/src/components/investigations/graph.tsx
+++ b/src/components/investigations/graph.tsx
@@ -13,7 +13,9 @@ import {
ColorMode,
MiniMap,
Node,
- Edge
+ Edge,
+ useNodeConnections,
+ useInternalNode
} from '@xyflow/react';
import '@xyflow/react/dist/style.css';
import { supabase } from '@/src/lib/supabase/client';
@@ -30,6 +32,7 @@ import NewActions from './new-actions';
import { IconButton, Tooltip, Spinner, Card, Flex } from '@radix-ui/themes';
import { isNode, isEdge, getIncomers, getOutgoers } from "@xyflow/react";
import { EdgeBase } from '@xyflow/system';
+import { useInvestigationContext } from '../contexts/investigation-provider';
const nodeTypes = { individual: IndividualNode, phone: PhoneNode, ip: IpNode, email: EmailNode, social: SocialNode, address: AddressNode };
const edgeTypes = {
@@ -65,11 +68,11 @@ const getLayoutedElements = (nodes: any[], edges: any[], options: { direction: a
};
const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any, initialEdges: any, theme: ColorMode }) => {
- const { fitView, zoomIn, zoomOut, addNodes, getNodes, getEdges } = useReactFlow();
+ const { fitView, zoomIn, zoomOut, addNodes, getNodes, getEdges, setCenter, getNode, updateNode } = useReactFlow();
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
const [isLocked, setIsLocked] = useState(false)
- const [currentNode, setCurrentNode] = useState<null | Node>(null)
+ const { currentNode, setCurrentNode } = useInvestigationContext()
const ref = useRef(null);
const getAllIncomers = useCallback((node: any, nodes: any[], edges: EdgeBase[], prevIncomers = []) => {
const incomers = getIncomers(node, nodes, edges);
@@ -129,7 +132,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,
edges.map((edge) => ({
...edge,
animated: false,
- style: { ...edge.style, stroke: "#b1b1b7", opacity: 1 },
+ style: { ...edge.style, stroke: "#b1b1b750", opacity: 1 },
})),
)
return
@@ -156,14 +159,17 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,
)
setEdges((prevEdges) =>
prevEdges.map((edge) => {
- const animated =
+ const animatedIn =
incomerIds.has(edge.source) && (incomerIds.has(edge.target) || selectedNode.id === edge.target)
+ const animatedOut =
+ outgoerIds.has(edge.target) && (outgoerIds.has(edge.source) || selectedNode.id === edge.source)
+ const animated = animatedIn || animatedOut
return {
...edge,
animated,
style: {
...edge.style,
- stroke: animated ? "#3030e6" : "#b1b1b7",
+ stroke: animated ? "#00D3F2" : "#b1b1b750",
opacity: animated ? 1 : 0.25,
},
}
@@ -191,7 +197,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,
animated: false, // Désactive l'animation
style: {
...edge.style,
- stroke: "#b1b1b7",
+ stroke: "#b1b1b750",
opacity: 1,
},
})),
@@ -217,15 +223,24 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,
[setEdges],
);
-
const onNodeClick = useCallback(
(_: React.MouseEvent, node: Node) => {
- setCurrentNode(node)
- highlightPath(node)
+ setCurrentNode(node.id)
},
- [highlightPath],
+ [],
)
+ useEffect(() => {
+ resetNodeStyles()
+ if (currentNode) {
+ const internalNode = getNode(currentNode)
+ if (!internalNode) return
+ updateNode(internalNode.id, { ...internalNode, zIndex: 2000, style: { ...internalNode.style, opacity: 1 } })
+ setCenter(internalNode?.position.x + 100, internalNode?.position.y, { duration: 1000, zoom: 1.5 })
+ highlightPath(internalNode);
+ }
+ }, [currentNode, highlightPath, setCenter, resetNodeStyles]);
+
const onPaneClick = useCallback(
() => {
setCurrentNode(null)
@@ -289,7 +304,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,
{currentNode &&
<Card>
{/* @ts-ignore */}
- {currentNode?.data?.label}
+ {getNode(currentNode)?.data?.label}
</Card>}
</Flex>
</Panel>
diff --git a/src/components/investigations/individual-modal.tsx b/src/components/investigations/individual-modal.tsx
index 6ee25ee2..882c67ca 100644
--- a/src/components/investigations/individual-modal.tsx
+++ b/src/components/investigations/individual-modal.tsx
@@ -8,9 +8,6 @@ import {
Button,
Box,
Skeleton,
- Card,
- Inset,
- Separator,
Avatar,
Tabs,
IconButton,
@@ -19,13 +16,17 @@ import {
Badge,
Grid,
Link,
+ Callout,
} from "@radix-ui/themes"
import { usePathname, useRouter, useSearchParams } from "next/navigation"
import { useIndividual } from "@/src/lib/hooks/individuals/use-individual"
+import { useEmailsAndBreaches } from "@/src/lib/hooks/individuals/use-emails-breaches"
import { Pencil1Icon, Cross2Icon, PlusIcon, TrashIcon } from "@radix-ui/react-icons"
import { useRelations } from "@/src/lib/hooks/individuals/use-relations"
import { useInvestigationContext } from "../contexts/investigation-provider"
import { usePlatformIcons } from "@/src/lib/hooks/use-platform-icons"
+import Breaches from "../breach"
+import { supabase } from "@/src/lib/supabase/client"
const IndividualModal = () => {
const router = useRouter()
@@ -34,19 +35,20 @@ const IndividualModal = () => {
const individual_id = searchParams.get("individual_id")
const { handleOpenIndividualModal } = useInvestigationContext()
const { individual, isLoading } = useIndividual(individual_id)
+ const { emails, isLoading: isLoadingEmails } = useEmailsAndBreaches(individual_id)
const platformsIcons = usePlatformIcons("medium")
const { relations, isLoading: isLoadingRelations } = useRelations(individual_id)
const [editMode, setEditMode] = useState(false)
- const [emails, setEmails] = useState([""])
+ const [image, setImage] = useState<string | null>('')
const [phones, setPhones] = useState([""])
const [accounts, setAccounts] = useState([""])
const [ips, setIps] = useState([""])
useEffect(() => {
- setEmails(individual?.emails.map(({ email }: any) => email) || [""])
setPhones(individual?.phone_numbers.map(({ phone_number }: any) => phone_number) || [""])
setIps(individual?.ip_addresses.map(({ ip_address }: any) => ip_address) || [""])
setAccounts(individual?.social_accounts || [""])
+ setImage(individual?.image_url)
}, [individual])
const handleCloseModal = () => {
@@ -54,15 +56,12 @@ const IndividualModal = () => {
router.push(pathname)
}
- const handleSave = (event: React.FormEvent<HTMLFormElement>) => {
+ const handleSave = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
const formData = new FormData(event.currentTarget)
const formContent = Object.fromEntries(formData.entries())
- formContent.emails = emails as any
- formContent.phones = phones as any
- formContent.ip_addresses = ips as any
- formContent.accounts = accounts as any
- alert(JSON.stringify(formContent, null, 2))
+ const { data } = await supabase.from("individuals").update({ ...formContent, birth_date: null }).eq("id", individual_id).select("image_url").single()
+ setImage(data?.image_url)
setEditMode(false)
}
@@ -118,22 +117,22 @@ const IndividualModal = () => {
<Flex direction={"column"}>
<Avatar
size="9"
- src={individual?.image_url}
+ src={image || undefined}
fallback={individual?.full_name?.[0] || "?"}
radius="full"
/>
- {editMode && (
+ {/* {editMode && (
<Button type="button" size="1" variant="soft" style={{ marginTop: "8px" }}>
Change Photo
</Button>
- )}
+ )} */}
</Flex>
<Box style={{ flexGrow: 1 }}>
<Tabs.Root defaultValue="overview">
<Tabs.List className="!overflow-x-auto">
<Tabs.Trigger value="overview">Overview</Tabs.Trigger>
<Tabs.Trigger value="social_account">Social accounts<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={accounts?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{accounts?.length}</Badge></Spinner></Tabs.Trigger>
- <Tabs.Trigger value="emails">Emails<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={emails?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{emails?.length}</Badge></Spinner></Tabs.Trigger>
+ <Tabs.Trigger value="emails">Emails<Spinner className="ml-1" loading={isLoadingEmails}><Badge color={emails?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{emails?.length}</Badge></Spinner></Tabs.Trigger>
<Tabs.Trigger value="phone_numbers">Phone numbers<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={phones?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{phones?.length}</Badge></Spinner></Tabs.Trigger>
<Tabs.Trigger value="ip_addresses">IP addresses<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={ips?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{ips?.length}</Badge></Spinner></Tabs.Trigger>
<Tabs.Trigger value="relations">Relations<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={relations?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{relations?.length}</Badge></Spinner></Tabs.Trigger>
@@ -145,45 +144,29 @@ const IndividualModal = () => {
<Flex key={key} direction="column" gap="1">
<label className="capitalize-first">{key}</label>
<TextField.Root
+ type={key === "birth_date" ? "date" : "text"}
defaultValue={individual[key]}
placeholder={key}
name={key}
- disabled={!editMode}
+ disabled={key === "id" || key === "investigation_id" || !editMode}
/>
</Flex>
))}
</Flex>
</Tabs.Content>
<Tabs.Content value="emails">
- <Flex direction="column" gap="3" maxWidth={"420px"}>
+ <Flex direction="column" gap="3">
{emails.length === 0 && <Text className="italic opacity-60 text-sm">No email registered. Click on edit to add one.</Text>}
- {emails.map((email: string | number | undefined, index: React.Key | null | undefined) => (
- <Flex key={index} gap="2" align="center">
- <TextField.Root
- value={email}
- onChange={(e) => handleFieldChange(index as any, e.target.value, setEmails)}
- placeholder="Email"
- type="email"
- disabled={!editMode}
- style={{ flexGrow: 1 }}
- />
- {editMode && (
- <IconButton
- type="button"
- variant="ghost"
- onClick={() => handleRemoveField(index as any, setEmails)}
- aria-label="Remove email"
- >
- <TrashIcon />
- </IconButton>
- )}
+ {emails.map((email: any, index: number) => (
+ <Flex direction={"column"} key={index}>
+ <Callout.Root color={email.breaches.length > 0 ? "orange" : "green"} size="1">
+ <Callout.Text>
+ <Text weight={"bold"}>{email.email}</Text> {email.breaches.length === 0 ? " is not yet involved in a data breach." : ` was involved in ${email.breaches.length} data breach(es).`}
+ </Callout.Text>
+ </Callout.Root>
+ <Breaches breaches={email.breaches} />
</Flex>
))}
- {editMode && (
- <Button type="button" onClick={() => handleAddField(setEmails)} variant="soft">
- <PlusIcon /> Add Email
- </Button>
- )}
</Flex>
</Tabs.Content>
<Tabs.Content value="social_account">
@@ -316,8 +299,8 @@ const IndividualModal = () => {
</Flex>
</form>
</Skeleton>
- </Dialog.Content>
- </Dialog.Root>
+ </Dialog.Content >
+ </Dialog.Root >
)
}
diff --git a/src/components/investigations/nodes/individual.tsx b/src/components/investigations/nodes/individual.tsx
index 499a6f4e..6ed81212 100644
--- a/src/components/investigations/nodes/individual.tsx
+++ b/src/components/investigations/nodes/individual.tsx
@@ -2,7 +2,7 @@
import React, { memo } from 'react';
import { Handle, Position } from '@xyflow/react';
import { useInvestigationContext } from '../../contexts/investigation-provider';
-import { Avatar, Card, Box, Flex, Text, ContextMenu, Spinner, Badge, Tooltip, Code } from '@radix-ui/themes';
+import { Avatar, Card, Box, Flex, Text, ContextMenu, Spinner, Badge, Tooltip } from '@radix-ui/themes';
import { AtSignIcon, CameraIcon, FacebookIcon, InstagramIcon, LocateIcon, MessageCircleDashedIcon, PhoneIcon, SendIcon, UserIcon, MapPinHouseIcon, ZapIcon } from 'lucide-react';
import { NodeProvider, useNodeContext } from '../../contexts/node-context';
import { useSearchContext } from '../../contexts/search-context';
@@ -10,7 +10,7 @@ import { cn } from '@/src/lib/utils';
import { CopyButton } from '../../copy';
function Custom(props: any) {
- const { settings, handleOpenIndividualModal } = useInvestigationContext()
+ const { settings, handleOpenIndividualModal, currentNode } = useInvestigationContext()
const { setOpenAddNodeModal, handleDuplicateNode, handleDeleteNode, loading } = useNodeContext()
const { handleOpenSearchModal } = useSearchContext()
const { data } = props
@@ -19,7 +19,7 @@ function Custom(props: any) {
<ContextMenu.Root>
<ContextMenu.Trigger onContextMenu={(e) => { e.stopPropagation() }}>
<Box className={cn(loading ? "!opacity-40" : "!opacity-100")}>{settings.showNodeLabel ?
- <Card onDoubleClick={() => handleOpenIndividualModal(data.id)} className='!py-1'>
+ <Card onDoubleClick={() => handleOpenIndividualModal(data.id)} className={cn('!py-1 border border-transparent hover:border-sky-400', currentNode === data.id && "border-sky-400")}>
<Flex gap="2" align="center">
<Avatar
color='gray'
diff --git a/src/components/login-form.tsx b/src/components/login-form.tsx
new file mode 100644
index 00000000..12c5e38a
--- /dev/null
+++ b/src/components/login-form.tsx
@@ -0,0 +1,62 @@
+import Link from "next/link"
+
+import { Button, Card, TextField, Box, Text, Flex } from "@radix-ui/themes"
+import { login, signup, signInWithGithub } from '@/src/lib/actions/auth'
+
+export function LoginForm() {
+ return (
+ <Card className="mx-auto w-full max-w-md !p-6">
+ <Flex direction={"column"} gap="2">
+ <Text as="div" size="6" weight="bold">
+ Login
+ </Text>
+ <Text as="div" size="2" color="gray">
+ Login into your account or create a new one.
+ </Text>
+ </Flex>
+ <Flex direction={"column"} gap="3">
+ <form>
+ <Flex direction={"column"} gap="3">
+ <label htmlFor="email">
+ <Text as="div" size="2" mb="1" weight="bold">
+ Email
+ </Text>
+ <TextField.Root
+ id="email"
+ type="email"
+ name="email"
+ placeholder="[email protected]"
+ required
+ />
+ </label>
+ <label htmlFor="email">
+ <Text as="div" size="2" mb="1" weight="bold">
+ Password
+ </Text>
+ <TextField.Root id="password" name="password" placeholder="Your password" type="password" required />
+ </label>
+ <Link href="#" className="ml-auto inline-block text-sm underline">
+ Forgot your password?
+ </Link>
+ <Button formAction={login} type="submit" className="w-full mt-4">
+ Login
+ </Button>
+ </Flex>
+ </form>
+ <form>
+ <Flex direction={"column"} gap="3">
+ <Button formAction={signInWithGithub} variant="outline" className="w-full">
+ Login with Github
+ </Button>
+ </Flex>
+ </form>
+ </Flex>
+ <div className="mt-4 text-center text-sm">
+ Don&apos;t have an account?{" "}
+ <Button variant="ghost" formAction={signup}>
+ Sign up
+ </Button>
+ </div>
+ </Card >
+ )
+}
\ No newline at end of file
diff --git a/src/lib/hooks/individuals/use-emails-breaches.ts b/src/lib/hooks/individuals/use-emails-breaches.ts
new file mode 100644
index 00000000..577f5ede
--- /dev/null
+++ b/src/lib/hooks/individuals/use-emails-breaches.ts
@@ -0,0 +1,40 @@
+import { supabase } from "@/src/lib/supabase/client"
+import { useQuery } from "@supabase-cache-helpers/postgrest-swr"
+
+export function useEmailsAndBreaches(individualId: string | null | undefined) {
+ const { data: emails, error } = useQuery(
+ individualId ? supabase.from("individuals").select(`*, emails(*)`).eq("id", individualId).single() : null,
+ {
+ revalidateOnFocus: false,
+ revalidateOnReconnect: false,
+ },
+ )
+ console.log(emails)
+
+ const emailAddresses = emails?.emails?.map(({ email }: { email: string }) => email) || []
+
+ const { data: breaches, error: breachesError, mutate } = useQuery(
+ emailAddresses.length > 0
+ ? supabase.from("accounts_breaches").select(`account, breach:breach_id(raw_content)`).in("account", emailAddresses)
+ : null,
+ {
+ revalidateOnFocus: false,
+ revalidateOnReconnect: false,
+ },
+ )
+
+ const formattedData = emailAddresses.map((email: string) => ({
+ email,
+ breaches: breaches?.filter((breach: any) => breach.account === email).map((breach: any) => breach.breach.raw_content) || [],
+ }))
+
+ const isLoading = !emails && !error
+
+ return {
+ emails: formattedData,
+ isLoading,
+ refetch: mutate,
+ error: error || breachesError,
+ }
+}
+
diff --git a/src/lib/hooks/individuals/use-individuals.tsx b/src/lib/hooks/individuals/use-individuals.tsx
new file mode 100644
index 00000000..c7cc16c2
--- /dev/null
+++ b/src/lib/hooks/individuals/use-individuals.tsx
@@ -0,0 +1,25 @@
+import { supabase } from "@/src/lib/supabase/client";
+import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
+
+export function useIndividuals(investigationId: string | null | undefined) {
+ const { data: individuals, mutate, isLoading, error } = useQuery(Boolean(investigationId) ?
+ supabase
+ .from('individuals')
+ .select(`
+ *
+ `)
+ .eq("investigation_id", investigationId)
+ : null,
+ {
+ revalidateOnFocus: false,
+ revalidateOnReconnect: false,
+ }
+ );
+ return {
+ individuals: individuals || null,
+ isLoading,
+ refetch: mutate,
+ error: error
+ };
+}
+
diff --git a/styles/globals.css b/styles/globals.css
index a461c505..f1d8c73c 100644
--- a/styles/globals.css
+++ b/styles/globals.css
@@ -1 +1 @@
-@import "tailwindcss";
\ No newline at end of file
+@import "tailwindcss";