Interface IAccountApi
- Namespace
- VpnHood.AppLib.Api
- Assembly
- VpnHood.AppLib.Api.dll
Represents the app's API for the person's account: the sign-in, the account, and its deletion.
public interface IAccountApi
Remarks
Where the app has no account backend, Get(CancellationToken) and GetPasswordResetUrl(CancellationToken) return null, and the other calls fail. A failure comes as IAppApi describes, in process and over HTTP.
Methods
Delete(CancellationToken)
Deletes the person's account, and signs the device out.
Task Delete(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once the account is deleted and the device signed out.
Remarks
A store subscription stays: only the person can cancel it, in the store. A later sign-in tries to restore it, and the Restore action tries again.
Exceptions
- NotSupportedException
A premium code waits to be uploaded, and the account backend keeps no codes on the account.
- InvalidOperationException
The account's refresh found no current VPN profile, or several and none selected.
- ApiException
The account backend refused the request; or, over HTTP, the app failed with an exception of a type the transport does not rebuild, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
Get(CancellationToken)
Gets the signed-in person's account.
Task<Account?> Get(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<Account>
A task whose result is the account, or null where nobody is signed in or the app has no account backend.
Remarks
It reads the account backend where nothing is cached, or where the cached account has expired by its subscription's or its premium code's expiry, unless an earlier read is still within the retry interval; then it gives the cached account.
Exceptions
- NotSupportedException
A premium code waits to be uploaded, and the account backend keeps no codes on the account.
- InvalidOperationException
The account's refresh found no current VPN profile, or several and none selected.
- ApiException
The account backend refused the request; or, over HTTP, the app failed with an exception of a type the transport does not rebuild, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
GetPasswordResetUrl(CancellationToken)
Gets the account website's page for a forgotten password, as the password form asks when it opens.
Task<Uri?> GetPasswordResetUrl(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<Uri>
A task whose result is the page, or null where the app has no account backend or the backend has no such page; the form offers its link only with a page.
Exceptions
- ApiException
Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
Refresh(CancellationToken)
Reads the account again from the account backend, with its premium code and subscription.
Task Refresh(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- NotSupportedException
A premium code waits to be uploaded, and the account backend keeps no codes on the account.
- InvalidOperationException
The account's refresh found no current VPN profile, or several and none selected.
- ApiException
The account backend refused the request; or, over HTTP, the app failed with an exception of a type the transport does not rebuild, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.
SignIn(SignInOptions, CancellationToken)
Signs the person in, or answers a sign-in's second step with TwoFactorCode.
Task<SignInResult> SignIn(SignInOptions signInOptions, CancellationToken cancellationToken)
Parameters
signInOptionsSignInOptionsThe sign-in method, with its credentials or the second step's code.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<SignInResult>
A task whose result is what the sign-in accomplished.
Remarks
A result whose State is not SignedIn signed nobody in: the call
is repeated with the code. A NewBackupCode is shown to the person once. A method that
shows a window needs the app's, and fails without it, as the app's UiContextNotAvailableException.
Exceptions
- AuthenticationException
The account backend refused the sign-in.
- InvalidOperationException
The provider cannot sign in now, or the account's refresh after it found no current VPN profile, or several and none selected.
- ArgumentException
The sign-in options do not fit the method.
- NotSupportedException
The app offers no such sign-in method, or the method's provider does not take the request.
- ApiException
The account backend refused the request; or, over HTTP, the app failed with an exception of a type the transport does not rebuild, or answered with an error it does not name.
- OperationCanceledException
The person canceled the sign-in; or
cancellationTokenwas canceled.
SignOut(CancellationToken)
Signs the person out.
Task SignOut(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- NotSupportedException
A premium code waits to be uploaded, and the account backend keeps no codes on the account.
- InvalidOperationException
The account's refresh found no current VPN profile, or several and none selected.
- ApiException
The account backend refused the request; or, over HTTP, the app failed with an exception of a type the transport does not rebuild, or answered with an error it does not name.
- OperationCanceledException
cancellationTokenwas canceled: over HTTP always, in process where the call honours it.