Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3370930
D9093.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9093.diff
View Options
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 = React.useCallback(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();
+ }, [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 = React.useCallback(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();
+ }, [generateQRCode]);
+
return (
<div className={css.qrContainer}>
<div className={css.title}>Log in to Comm</div>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 4:12 AM (20 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587817
Default Alt Text
D9093.diff (2 KB)
Attached To
Mode
D9093: [lib/web/native] Generate and encode an ephemeral AES-256 key in the QR code
Attached
Detach File
Event Timeline
Log In to Comment