CombineWrapper
public final class CombineWrapper : WebcomWrapper, Equatable, CustomDebugStringConvertible
The type that wraps AuthenticationService
in order to enrich it with a Combine-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 WebcomCombine
-
Declaration
Swift
public let wrapped: AuthenticationService
-
The authentication details of the currently authenticated user.
This property is
nil
when there is currently no authenticated user.Declaration
Swift
public var authenticationDetails: AuthenticationDetails.CombineWrapper? { get }
-
Continues an authentication process initialized with
initializeAuthentication(with:context:)
.Declaration
Swift
public func continueAuthentication() -> WebcomFuture<AuthenticationDetails>
Return Value
A future with the authenticated user details.
-
continueAuthentication()
AsynchronousDeclaration
Swift
public func continueAuthentication() async throws -> AuthenticationDetails
-
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) -> WebcomFuture<AuthenticationDetails>
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 future with the authenticated user details.
-
authenticate(with:
Asynchronouscontext: ) Declaration
Swift
public func authenticate(with method: AuthenticationSingleStepMethod, context: Context = .new) async throws -> AuthenticationDetails
-
Unauthenticates the current user.
This method succeeds when there is currently no authenticated user.
Declaration
Swift
public func unauthenticate(session: URLSession? = nil, queue: DispatchQueue? = nil) -> WebcomFuture<Void>
Parameters
session
The session used to send the requests to the back-end. When
nil
, the default session of the application of this instance is used.Return Value
A future with a void value.
-
unauthenticate()
AsynchronousDeclaration
Swift
public func unauthenticate() async throws
-
Create a publisher that produces an
AuthenticationEvent
value each time the authentication state change or an authentication process fails. to subscribe to authentication state changes.Subscriptions made with the returned publisher must be stored explicitly to remain active, e.g. using the
AnyCancellable.store(in:)
method. Unlike callback-based subscriptions made with theAuthenticationService.subscribe(stores:file:line:queue:onEvent:onCompletion:)
method, these subscriptions are not stored implicitly.Declaration
Swift
public func eventPublisher(file: StaticString = #fileID, line: UInt = #line) -> AnyPublisher<AuthenticationEvent, Never>
Parameters
file
The file from which the method is called. This is used for debugging purposes.
line
The line from which the method is called. This is used for debugging purposes.
Return Value
A type-erased publisher that produces
AuthenticationEvent
values and never fails. -
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() -> WebcomFuture<Void>
Return Value
A future with a void value.
-
detachCurrentIdentity()
AsynchronousDeclaration
Swift
public func detachCurrentIdentity() async throws
-
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() -> WebcomFuture<Void>
Return Value
A future with a void value.
-
destroyAccount()
AsynchronousDeclaration
Swift
public func destroyAccount() async throws