PromiseWrapper
public final class PromiseWrapper : WebcomWrapper, Equatable, CustomDebugStringConvertible
The type that wraps AuthenticationService
in order to enrich it with a PromiseKit-based API.
See also the documentation section of WebcomWrapper
for the corresponding wrapped type.
To use this type, import the following dependency in your code:
import WebcomPromises
-
Declaration
Swift
public let wrapped: AuthenticationService
-
The authentication details of the currently authenticated user.
This property returns a promise which is rejected when there is currently no authenticated user.
Declaration
Swift
public var authenticationDetails: Promise<AuthenticationDetails.PromiseWrapper> { get }
-
Continues an authentication process initialized with
initializeAuthentication(with:context:)
.Declaration
Swift
public func continueAuthentication() -> Promise<AuthenticationDetails.PromiseWrapper>
Return Value
A promise representing the authenticated user details.
-
Authenticates the current user.
This method is only available for single-step authentication methods, that is methods which do not need user interaction driven by the application once started. All available methods, except
AuthenticationMethodInternal
, are eligible. Although it requires user interaction,AuthenticationMethodOAuth2
is well eligible since that interaction is driven by aASWebAuthenticationSession
, not by the application.For multi-step methods, use
initializeAuthentication(with:context:)
andcontinueAuthentication()
.Declaration
Swift
public func authenticate(with method: AuthenticationSingleStepMethod, context: Context = .new) -> Promise<AuthenticationDetails.PromiseWrapper>
Parameters
method
The single-step authentication method to use for the authentication process.
context
The context to use for the authentication process.
Return Value
A promise representing the authenticated user details.
-
Unauthenticates the current user.
This method succeeds when there is currently no authenticated user.
Declaration
Swift
public func unauthenticate() -> Promise<Void>
Return Value
A promise with a void value.
-
Detaches the current identity from the current user account.
In order to succeed, this sensitive operation requires a fresh enough authentication token. If the token is too old, then the operation will fail and the user will need to authenticate again before retrying the operation.
If the current identity is the last one of the user account, that account is destroyed, as the
destroyAccount()
method would do.Declaration
Swift
public func detachCurrentIdentity() -> Promise<Void>
Return Value
A promise with a void value.
-
Destroys the account of the current user.
In order to succeed, this sensitive operation requires a fresh enough authentication token. If the token is too old, then the operation will fail and the user will need to authenticate again before retrying the operation.
Calling this method does not remove any application-specific data stored using the
DatasyncService
. This also does not log-out the user, since any valid authentication token issued by the back-end remains valid until its expiration date.Declaration
Swift
public func destroyAccount() -> Promise<Void>
Return Value
A promise with a void value.