brave-ios icon indicating copy to clipboard operation
brave-ios copied to clipboard

Detect and store VPN state after sign-in

Open bsclifton opened this issue 2 years ago • 2 comments

Description:

Desktop is supporting VPN purchases using the account.brave.com website and (in browser) using the SKU SDK (see implementation in https://github.com/brave/brave-core/pull/10847; not merged yet).

The goal would be to:

  • have the account.brave.com page detect the APIs (this covered by https://github.com/brave/brave-ios/issues/4804)
  • when user purchases VPN on the website, the website will call these exposed APIs
  • a Chromium profile setting (skus.credential.has_vpn; in code as kSkusVPNHasCredential) gets set. See src/brave/components/brave_vpn/brave_vpn_service_desktop.cc in https://github.com/brave/brave-core/pull/10847 for an example

When this is set, we now can use the credential and authenticate with Guardian VPN.

Additional details:

  • there is a new 1.2 Guardian VPN API call created for GetSubscriberCredential on Desktop which can be seen here: https://github.com/brave/brave-core/blob/fce7128db24e80f348b29c54f0ba1a9e4387babd/components/brave_vpn/brave_vpn_service.cc#L204-L220 - we'll need to add it into our code (ex: in https://github.com/brave/brave-ios/tree/development/Client/Frontend/BraveVPN/GRDAPI)
  • When the Chromium profile value for skus.credential.has_vpn is set to true, we need to call this new Guardian API to get subscriber credentials using the desktop credentials delivered by the SKU service
  • If a profile has VPN purchased, we should consider the user as having purchased VPN in iOS. They should see the same options and UI that a person would if they did the In-App-Purchase. Even though a profile setting is being set, we should (in iOS) set another value so we know this user has used account.brave.com.
  • Having this stored value of the person DID at one time purchase VPN from account.brave.com would let us know that once the Chromium profile value has false for kSkusVPNHasCredential that the person either didn't renew their billing OR that they cancelled their subscription to the product. For this case, we may consider showing a special UI (like "Need to renew?" or similar). cc: @anthonypkeane @mattmcalister for what that experience might be like
  • If VPN is NOT purchased, we do NOT need to show a link to account.brave.com inside the app yet (ex: Desktop is linking to account.brave.com/plans and showing a link "Already purchased VPN?".) For iOS, we can consider In-App-Purchase as the primary way to get VPN. But we will explain to folks (via support, press release, etc) that they have the ability to visit account.brave.com to redeem something they purchased before.

Related issues:

iOS

Android

Desktop

bsclifton avatar Jan 05 '22 20:01 bsclifton

WIP happening with https://github.com/brave/brave-ios/pull/4952 - working through some more details before we revisit 😄

bsclifton avatar Mar 28 '22 17:03 bsclifton

Update: work continues on this branch https://github.com/brave/brave-ios/pull/5712 Previous pull request was stale, and the new one is based on the GuardianConnect framework integration which makes all api calls much easier for us

iccub avatar Jul 19 '22 13:07 iccub

Verified using version 1.44 (22.10.14.13) on the following device(s):

iPhone 12 running iOS 16.x iPhone XR running iOS 15.x iPhone X runnning iOS 14.x iPad running iOS 15.x

PASS - Test Scenario: Loading active credentials from Staging Brave Account

  1. Purchase VPN on account.bravesoftware.com
  2. Tap on refresh Brave VPN
  3. Confirm UI banner in subscriptions will show You have active credentials loaded
Example Example Example
IMG_0670 IMG_0671 IMG_0672
IMG_3916 IMG_3917 IMG_3921

Uni-verse avatar Oct 14 '22 14:10 Uni-verse