diff --git a/lib/facts/links.js b/lib/facts/links.js --- a/lib/facts/links.js +++ b/lib/facts/links.js @@ -6,7 +6,7 @@ } /* QR Code */ -function qrCodeLinkUrl(aes256Param: string, ed25519Param: string): string { +function qrCodeLinkUrl(aes256Param: Uint8Array, ed25519Param: string): string { const keys = { aes256: aes256Param, ed25519: ed25519Param, diff --git a/native/qr-code/qr-code-screen.react.js b/native/qr-code/qr-code-screen.react.js --- a/native/qr-code/qr-code-screen.react.js +++ b/native/qr-code/qr-code-screen.react.js @@ -9,16 +9,33 @@ import type { QRCodeSignInNavigationProp } from './qr-code-sign-in-navigator.react.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { useStyles } from '../themes/colors.js'; +import * as AES from '../utils/aes-crypto-module.js'; type QRCodeScreenProps = { +navigation: QRCodeSignInNavigationProp<'QRCodeScreen'>, +route: NavigationRoute<'QRCodeScreen'>, }; -const qrCodeValue = qrCodeLinkUrl('random_aes256_key', 'device_ed25519_key'); +const defaultDeviceEd25519Key = 'device_ed25519_key'; // eslint-disable-next-line no-unused-vars function QRCodeScreen(props: QRCodeScreenProps): React.Node { + const [qrCodeValue, setQrCodeValue] = React.useState(); + + const generateQRCode = async () => { + try { + const aes256Key: Uint8Array = await AES.generateKey(); + const url = qrCodeLinkUrl(aes256Key, defaultDeviceEd25519Key); + setQrCodeValue(url); + } catch (err) { + console.error('Failed to generate QR Code:', err); + } + }; + + React.useEffect(() => { + generateQRCode(); + }, []); + const styles = useStyles(unboundStyles); return ( diff --git a/web/account/qr-code-login.react.js b/web/account/qr-code-login.react.js --- a/web/account/qr-code-login.react.js +++ b/web/account/qr-code-login.react.js @@ -6,10 +6,27 @@ import { qrCodeLinkUrl } from 'lib/facts/links.js'; import css from './qr-code-login.css'; +import { generateKey } from '../media/aes-crypto-utils.js'; -const qrCodeValue = qrCodeLinkUrl('random_aes256_key', 'device_ed25519_key'); +const defaultDeviceEd25519Key = 'device_ed25519_key'; function QrCodeLogin(): React.Node { + const [qrCodeValue, setQrCodeValue] = React.useState(); + + const generateQRCode = async () => { + try { + const aes256Key: Uint8Array = await generateKey(); + const url = qrCodeLinkUrl(aes256Key, defaultDeviceEd25519Key); + setQrCodeValue(url); + } catch (err) { + console.error('Failed to generate QR Code:', err); + } + }; + + React.useEffect(() => { + generateQRCode(); + }, []); + return (
Log in to Comm