diff --git a/lib/components/qr-auth-provider.react.js b/lib/components/qr-auth-provider.react.js --- a/lib/components/qr-auth-provider.react.js +++ b/lib/components/qr-auth-provider.react.js @@ -25,13 +25,13 @@ type Props = { +children: React.Node, - +onLoginError: (error: mixed) => void, + +onLogInError: (error: mixed) => void, +generateAESKey: () => Promise, - +composeTunnelbrokerMessage: ( + +composeTunnelbrokerQRAuthMessage: ( encryptionKey: string, payload: QRCodeAuthMessagePayload, ) => Promise, - +processTunnelbrokerMessage: ( + +parseTunnelbrokerQRAuthMessage: ( encryptionKey: string, message: QRCodeAuthMessage, ) => Promise, @@ -54,10 +54,10 @@ function QRAuthProvider(props: Props): React.Node { const { children, - onLoginError, + onLogInError, generateAESKey, - composeTunnelbrokerMessage, - processTunnelbrokerMessage, + composeTunnelbrokerQRAuthMessage, + parseTunnelbrokerQRAuthMessage, performBackupRestore, } = props; @@ -98,11 +98,11 @@ try { await logInSecondaryDevice(userID); } catch (err) { - onLoginError(err); + onLogInError(err); void generateQRCode(); } }, - [logInSecondaryDevice, onLoginError, generateQRCode], + [logInSecondaryDevice, onLogInError, generateQRCode], ); React.useEffect(() => { @@ -116,7 +116,7 @@ } void (async () => { - const message = await composeTunnelbrokerMessage(qrData?.aesKey, { + const message = await composeTunnelbrokerQRAuthMessage(qrData?.aesKey, { type: qrCodeAuthMessageTypes.SECONDARY_DEVICE_REGISTRATION_SUCCESS, requestBackupKeys: true, }); @@ -130,7 +130,7 @@ primaryDeviceID, qrData, socketState, - composeTunnelbrokerMessage, + composeTunnelbrokerQRAuthMessage, qrAuthFinished, ]); @@ -159,7 +159,7 @@ let qrCodeAuthMessage; try { - qrCodeAuthMessage = await processTunnelbrokerMessage( + qrCodeAuthMessage = await parseTunnelbrokerQRAuthMessage( qrData?.aesKey, innerMessage, ); @@ -202,7 +202,7 @@ qrData?.aesKey, performLogIn, setUnauthorizedDeviceID, - processTunnelbrokerMessage, + parseTunnelbrokerQRAuthMessage, performBackupRestore, ], ); diff --git a/native/qr-code/qr-code-utils.js b/native/qr-code/qr-code-utils.js --- a/native/qr-code/qr-code-utils.js +++ b/native/qr-code/qr-code-utils.js @@ -60,8 +60,8 @@ return Promise.resolve(payload); } -function handleSecondaryDeviceRegistrationError(error: mixed): void { - console.error('Secondary device registration error:', error); +function handleSecondaryDeviceLogInError(error: mixed): void { + console.error('Secondary device log in error:', error); const messageForException = getMessageForException(error); if ( messageForException === 'client_version_unsupported' || @@ -89,14 +89,14 @@ ); } -function generateQRAuthKey(): Promise { +function generateQRAuthAESKey(): Promise { return Promise.resolve(AES.generateKey()); } export { composeTunnelbrokerQRAuthMessage, parseTunnelbrokerQRAuthMessage, - handleSecondaryDeviceRegistrationError, + handleSecondaryDeviceLogInError, performBackupRestore, - generateQRAuthKey, + generateQRAuthAESKey, }; diff --git a/native/root.react.js b/native/root.react.js --- a/native/root.react.js +++ b/native/root.react.js @@ -79,10 +79,10 @@ import RootNavigator from './navigation/root-navigator.react.js'; import { composeTunnelbrokerQRAuthMessage, - handleSecondaryDeviceRegistrationError, + handleSecondaryDeviceLogInError, parseTunnelbrokerQRAuthMessage, performBackupRestore, - generateQRAuthKey, + generateQRAuthAESKey, } from './qr-code/qr-code-utils.js'; import ConnectivityUpdater from './redux/connectivity-updater.react.js'; import { DimensionsUpdater } from './redux/dimensions-updater.react.js'; @@ -318,11 +318,13 @@ diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -90,9 +90,9 @@ import { canonicalURLFromReduxState, navInfoFromURL } from './url-utils.js'; import { composeTunnelbrokerQRAuthMessage, - generateQRAuthKey, + generateQRAuthAESKey, parseTunnelbrokerQRAuthMessage, - useHandleSecondaryDeviceRegistrationError, + useHandleSecondaryDeviceLogInError, } from './utils/qr-code-utils.js'; import { useWebLock, TUNNELBROKER_LOCK_NAME } from './web-lock.js'; @@ -543,8 +543,8 @@ const secondaryTunnelbrokerConnection: SecondaryTunnelbrokerConnection = useOtherTabsTunnelbrokerConnection(); - const handleSecondaryDeviceRegistrationError = - useHandleSecondaryDeviceRegistrationError(); + const handleSecondaryDeviceLogInError = + useHandleSecondaryDeviceLogInError(); return ( @@ -555,10 +555,12 @@ > void { +function useHandleSecondaryDeviceLogInError(): (error: mixed) => void { const { pushModal } = useModalContext(); return React.useCallback( (error: mixed) => { - console.error('Secondary device registration error:', error); + console.error('Secondary device log in error:', error); const messageForException = getMessageForException(error); if ( messageForException === 'client_version_unsupported' || @@ -75,13 +75,13 @@ ); } -function generateQRAuthKey(): Promise { +function generateQRAuthAESKey(): Promise { return generateKeyCommon(crypto); } export { composeTunnelbrokerQRAuthMessage, parseTunnelbrokerQRAuthMessage, - useHandleSecondaryDeviceRegistrationError, - generateQRAuthKey, + useHandleSecondaryDeviceLogInError, + generateQRAuthAESKey, };