diff --git a/lib/components/secondary-device-qr-auth-context-provider.react.js b/lib/components/secondary-device-qr-auth-context-provider.react.js --- a/lib/components/secondary-device-qr-auth-context-provider.react.js +++ b/lib/components/secondary-device-qr-auth-context-provider.react.js @@ -22,6 +22,7 @@ type QRAuthBackupData, } from '../types/tunnelbroker/qr-code-auth-message-types.js'; import { getContentSigningKey } from '../utils/crypto-utils.js'; +import { getMessageForException } from '../utils/errors.js'; type Props = { +children: React.Node, @@ -72,6 +73,7 @@ removeListener, socketState, sendMessageToDevice, + confirmMessageToTunnelbroker, } = useTunnelbroker(); const identityContext = React.useContext(IdentityClientContext); @@ -185,6 +187,15 @@ qrCodeAuthMessage; setPrimaryDeviceID(receivedPrimaryDeviceID); + try { + await confirmMessageToTunnelbroker(message.messageID); + } catch (e) { + console.error( + 'Error while confirming DEVICE_LIST_UPDATE_SUCCESS', + getMessageForException(e), + ); + } + await performLogIn(userID); setUnauthorizedDeviceID(null); }, @@ -195,6 +206,7 @@ performLogIn, setUnauthorizedDeviceID, parseTunnelbrokerQRAuthMessage, + confirmMessageToTunnelbroker, ], ); diff --git a/lib/tunnelbroker/tunnelbroker-context.js b/lib/tunnelbroker/tunnelbroker-context.js --- a/lib/tunnelbroker/tunnelbroker-context.js +++ b/lib/tunnelbroker/tunnelbroker-context.js @@ -19,6 +19,7 @@ } from '../shared/timeouts.js'; import { isWebPlatform } from '../types/device-types.js'; import type { MessageSentStatus } from '../types/tunnelbroker/device-to-tunnelbroker-request-status-types.js'; +import type { MessageReceiveConfirmation } from '../types/tunnelbroker/message-receive-confirmation-types.js'; import type { MessageToDeviceRequest } from '../types/tunnelbroker/message-to-device-request-types.js'; import type { MessageToTunnelbrokerRequest } from '../types/tunnelbroker/message-to-tunnelbroker-request-types.js'; import { @@ -77,6 +78,7 @@ +removeListener: (listener: TunnelbrokerSocketListener) => void, +socketState: TunnelbrokerSocketState, +setUnauthorizedDeviceID: (unauthorizedDeviceID: ?string) => void, + +confirmMessageToTunnelbroker: (messageID: string) => void, }; const TunnelbrokerContext: React.Context = @@ -482,6 +484,17 @@ socket.current?.send(message); }, []); + const confirmMessageToTunnelbroker = React.useCallback( + (messageID: string) => { + const confirmation: MessageReceiveConfirmation = { + type: deviceToTunnelbrokerMessageTypes.MESSAGE_RECEIVE_CONFIRMATION, + messageIDs: [messageID], + }; + socket.current?.send(JSON.stringify(confirmation)); + }, + [], + ); + const value: TunnelbrokerContextType = React.useMemo( () => ({ sendMessageToDevice, @@ -491,6 +504,7 @@ addListener, removeListener, setUnauthorizedDeviceID, + confirmMessageToTunnelbroker, }), [ sendMessageToDevice, @@ -499,6 +513,7 @@ socketState, addListener, removeListener, + confirmMessageToTunnelbroker, ], );