import Box from "@mui/material/Box"; import Paper from "@mui/material/Paper"; import Stack from "@mui/material/Stack"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; import React, { FC } from "react"; import DeviceCredentialsTable from "../components/DeviceCredentialsTable"; import { Session, User, WebAuthnCreationOptions, WebAuthnRequestOptions, } from "../types"; import WebAuthnAuthenticateButton from "./WebAuthnAuthenticateButton"; import WebAuthnRegisterButton from "./WebAuthnRegisterButton"; export type SessionDeviceCredentialsProps = { csrfToken: string; user: User; session: Session; webAuthnCreationOptions: WebAuthnCreationOptions; webAuthnRequestOptions: WebAuthnRequestOptions; webAuthnUrl: string; }; export const SessionDeviceCredentials: FC = ({ csrfToken, user, session, webAuthnCreationOptions, webAuthnRequestOptions, webAuthnUrl, }) => { const currentSessionDeviceCredentialIds = []; const otherDeviceCredentialIds = []; user?.deviceCredentialIds?.forEach((id) => { if (session?.deviceCredentials?.find((cred) => cred?.id === id)) { currentSessionDeviceCredentialIds.push(id); } else { otherDeviceCredentialIds.push(id); } }); return ( <> Current Session Device Credentials {otherDeviceCredentialIds?.length > 0 ? ( <> Other Device Credentials ) : ( <> )} ); }; export default SessionDeviceCredentials;