Page MenuHomePhabricator

D9093.id30925.diff
No OneTemporary

D9093.id30925.diff

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<?string>();
+
+ 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 (
<View style={styles.container}>
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<?string>();
+
+ 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 (
<div className={css.qrContainer}>
<div className={css.title}>Log in to Comm</div>

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 4:11 PM (21 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2601577
Default Alt Text
D9093.id30925.diff (2 KB)

Event Timeline