Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[multi-device] Handle incoming pairing authorisation message #430

Merged

Conversation

sachaaaaa
Copy link

@sachaaaaa sachaaaaa commented Aug 23, 2019

The control flow starts at the bottom of the diff and splits in 3.

  • the authorisation is a pairing request (primary device side)
  • the authorisation is addressed to us (secondary device side)
  • the authorisation is a pairing grant (third-party contact)

The authorisation is saved only if valid.

Note:
Whisper.events are used to propagate events across the application:

  • secondaryDeviceRegistration event: we (the secondary device) have received the grant authorisation from the primary device. This makes the UI transition from the registration page to the inbox page.
  • devicePairingRequestReceived event: we (the primary device) have received a pairing authorisation request. This will trigger the UI to prompt the user to accept the pairing if the pairing modal window is open, otherwise it's ignored.

@sachaaaaa sachaaaaa force-pushed the handle_incoming_authorisation branch from d63762a to 6ab05e2 Compare August 23, 2019 06:32
Copy link

@BeaudanBrown BeaudanBrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Immaculate

Copy link

@Mikunj Mikunj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor things

return true;
},
async handlePairingRequest(pairingRequest) {
if (!this.validateAuthorisation(pairingRequest)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this function async? In this case it would always be true and continue even on invalid requests

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye good catch

if (!this.validateAuthorisation(pairingRequest)) {
return;
}
window.libloki.storage.savePairingAuthorisation(pairingRequest);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to await this incase it fails somehow? or is it fine as is?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaner to wait :)

);
},
async handleAuthorisationForSelf(pairingAuthorisation) {
if (!this.validateAuthorisation(pairingAuthorisation)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing asap

} else {
window.log.warn('Unimplemented pairing authorisation message type');
}
},
async handleAuthorisationForContact(pairingAuthorisation) {
if (!this.validateAuthorisation(pairingAuthorisation)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing asap

Co-Authored-By: Mikunj Varsani <Mikunj@users.noreply.github.com>
Copy link

@Mikunj Mikunj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sachaaaaa sachaaaaa merged commit 5eab209 into oxen-io:multi-device Aug 26, 2019
@sachaaaaa sachaaaaa deleted the handle_incoming_authorisation branch August 27, 2019 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants