From 298aba26f4e0b9bf1e5a131a145afd31d81e15e6 Mon Sep 17 00:00:00 2001 From: Tristan Edwards Date: Thu, 9 May 2019 12:17:01 +0200 Subject: [PATCH 1/3] Support Safello redirect URLs When the user buys bitcoin through Safello, they will be redirected to the Yoti app to verify their identity. Previously, when the process was done, they would be redirected to a browser window to continue their purchase, but since bluewallet has a `bluewallet://` redirect URI associated to its app ID, we can redirect them back to the app with a `safello-state-token` query parameter appended to the URI instead. Bluewallet then simply needs to check if that query parameter is present, and if so, open a new WebView with the same Safello URL + `stateToken=xxx` in order to resume the user's session. This way, the whole buying process can take place inside Bluewallet's app, which is a clear improvement in terms of user experience. --- App.js | 21 +++++++++++++++++++++ screen/wallets/buyBitcoin.js | 24 +++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/App.js b/App.js index 72a17defe..7b2f419a8 100644 --- a/App.js +++ b/App.js @@ -95,6 +95,12 @@ export default class App extends React.Component { return isValidLightningInvoice; } + isSafelloRedirect(event) { + let urlObject = url.parse(event.url, true) // eslint-disable-line + + return !!urlObject.query["safello-state-token"] + } + handleOpenURL = event => { if (event.url === null) { return; @@ -122,6 +128,21 @@ export default class App extends React.Component { }, }), ); + } else if (this.isSafelloRedirect(event)) { + let urlObject = url.parse(event.url, true) // eslint-disable-line + + const safelloStateToken = urlObject.query["safello-state-token"] + + this.navigator && + this.navigator.dispatch( + NavigationActions.navigate({ + routeName: "BuyBitcoin", + params: { + uri: event.url, + safelloStateToken, + }, + }), + ) } else { let urlObject = url.parse(event.url, true); // eslint-disable-line console.log('parsed', urlObject); diff --git a/screen/wallets/buyBitcoin.js b/screen/wallets/buyBitcoin.js index 764203961..d5b274987 100644 --- a/screen/wallets/buyBitcoin.js +++ b/screen/wallets/buyBitcoin.js @@ -63,7 +63,29 @@ export default class BuyBitcoin extends Component { return ; } - return