Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

SKU credential (in VPN) should be cached indefinitely until redeemed or expired #7196

Closed
bsclifton opened this issue Apr 3, 2023 · 2 comments · Fixed by #7253
Closed

SKU credential (in VPN) should be cached indefinitely until redeemed or expired #7196

bsclifton opened this issue Apr 3, 2023 · 2 comments · Fixed by #7253

Comments

@bsclifton
Copy link
Member

Description:

This is the iOS version of brave/brave-browser#29345 - which fixed for Desktop/Android.

Basically, when a person enables VPN by visiting account.brave.com the time-limited credentials v2 are used. Through the SKU SDK, the prepare_credentials_presentation is called and a credential is presented. We're already parsing this partly because we need to get the expiration date.

Besides storing expiration date, we should also store the credential until it gets redeemed (or it expires). If Guardian's API has a service outage when we are requesting subscriber credentials, I don't believe we are retrying. If we try to call prepare_credentials_presentation again, it'll report that the user is out of credentials and ultimately they have to wait until the next day

@bsclifton
Copy link
Member Author

bsclifton commented Apr 3, 2023

Solution for Desktop/Android one here:
brave/brave-core#17789

One thought which might help keep implementation clean (kudos to @simonhong):
Just like how we cache the subscriber credentials, we also cache the SKU credential until it's redeemed. On Desktop/Android, the cached value being persisted to disk (which has subscriber credential) is a dictionary (base::Value::Dict).

  • After SKU SDK present is called (but BEFORE subscriber credentials issued), this has two values (expiration and skus_credential)
  • After subscriber credentials are redeemed, a new empty dictionary is created and only the new fields are written (expiration, credential)

@Uni-verse
Copy link
Contributor

Verified on iPhone X running iOS 16.3.1 using version 1.50 (23.4.27.20)

Using Test Plan in #7253 (comment)

  • Ensured purchasing VPN from account.brave.com works and VPN connection is establish.
  • Ensured disabling and then re-enabling VPN is successful
  • Ensured changing region in VPN settings is successful and connection is updated.
Example Example Example Example Example Example
IMG_3059 IMG_3060 IMG_3061 IMG_3062 IMG_3063 IMG_3064

# for free to subscribe to this conversation on GitHub. Already have an account? #.