Class CoreSDK
Defined in File CoreSDK.h
Page Contents
Class Documentation
-
class CoreSDK
Provides a single interface for the SDK and management for the various service classes.
Public Types
-
typedef std::function<void(Object&)> PushNotificationCallback
Describes a callback function for receiving push notifications from the server.
- std::function< pplx::task< utility::string_t >)> TotpChallengeCallback
The callback function definition when an MFA (TOTP) challenge has been received and the application needs to respond.
Public Functions
Creates a new instance of
CoreSDK
using the provided configuration.- Parameters
config – The configuration to initialize the SDK with.
Creates a new instance of
CoreSDK
using the provided configuration and API client.- Parameters
config – The configuration to initialize the SDK with.
apiClient – The REST API client to use.
-
~CoreSDK()
Stops any ongoing tasks and frees any memory used.
-
inline std::shared_ptr<net::IApiClient> GetApiClient() const
Returns the underlying REST API client used by this instance of the SDK.
-
inline std::shared_ptr<Configuration> GetConfiguration() const
Returns the configuration associated with this instance.
-
inline ConnectionStatus GetConnectionStatus() const
Returns the current status of the SDK’s connection to the cluster.
-
inline LoginStatus GetLoginStatus() const
Returns the current status of the logged in user.
-
inline std::shared_ptr<ServiceFactory> GetServiceFactory() const
Returns the service factory used to perform all SDK service requests.
-
inline std::shared_ptr<utils::EntityWatchdogFactory> GetEntityWatchdogFactory() const
Returns the instance of
EntityWatchdogFactory
used to monitor entity updates.
- template<typename _ReturnType> inline __declspec (noinline) pplx
Creates a new asynchronous task that will be managed by the SDK.
-
std::vector<PushNotificationCallback>::const_iterator AddPushListener(PushNotificationCallback callback)
Registers the given callback function to be notified when a new push notification is received.
- Parameters
callback – The callback function to register.
- Returns
The iterator of the entry to use when unregistering the callback.
-
void RemovePushListener(std::vector<PushNotificationCallback>::const_iterator iter)
Removes the push notification callback with the given iterator.
- Parameters
iter – The iterator to unregister, was returned by the original call to AddPushListener.
Performs local authentication without contacting the remote service. Intended for debugging and development purposes only.
- Parameters
newUser – The new user information to use when registering the local account.
-
void LoginLocal(utility::string_t token)
Performs local authentication without contacting the remote service. This takes a provided JWT token, typically passed in via CLI args and decodes the payload to populate the loggedInUser data.
- Parameters
token – The provided authentication token that will be used to login.
-
pplx::task<void> Logout()
Disconnects from the remote server, clears any stored login and authentication information.
-
std::shared_ptr<models::User> GetLoggedInUser()
Returns the account data associated with the currently logged in user.
-
pplx::task<void> LoginDevice()
Performs a user login using the unique identifier of the device.
- Returns
A task with no return value.
-
pplx::task<void> LoginEmail(const utility::string_t &email)
Performs user login using simple e-mail verification. Call this function first with just the
id
to have a verification code sent to the user. Then call it again with the user providedcode
to finish the authentication process.- Parameters
id – The unique identifier of the user to send the e-mail verification code to.
- Returns
A task with no return value.
-
pplx::task<void> LoginEmail(const utility::string_t &email, const utility::string_t &code)
Performs user login using simple e-mail verification. Call this function first with just the
id
to have a verification code sent to the user. Then call it again with the user providedcode
to finish the authentication process.- Parameters
id – The unique identifier of the user to send the e-mail verification code to.
code – The verification code to authentication with.
- Returns
A task with no return value.
-
pplx::task<void> LoginPassword(const utility::string_t &username, const utility::string_t &password)
Performs a user login with the specified username and password.
- Parameters
username – The unique name of the user to log in.
password – The password of the user to log in.
- Returns
A task with no return value.
-
pplx::task<void> LoginPhone(const utility::string_t &email)
Performs user login using simple phone verification. Call this function first with just the
id
to have a verification code sent to the user. Then call it again with the user providedcode
to finish the authentication process.- Parameters
id – The unique identifier of the user to send the phone verification code to.
- Returns
A task with no return value.
-
pplx::task<void> LoginPhone(const utility::string_t &email, const utility::string_t &code)
Performs user login using simple phone verification. Call this function first with just the
id
to have a verification code sent to the user. Then call it again with the user providedcode
to finish the authentication process.- Parameters
id – The unique identifier of the user to send the phone verification code to.
code – The verification code to authentication with.
- Returns
A task with no return value.
-
pplx::task<void> LoginToken(const utility::string_t &token, bool newSession = false)
Performs a user login with the specified authentication token.
- Parameters
token – The authentication token to log in with.
newSession – Set to true to request a new authentication session, otherwise set to false. Default is false.
- Returns
A task with no return value.
Registers the given user with the service and returns the newly created user object.
- Parameters
user – The user data to register with the service.
- Returns
A task whose result is the newly created user.
Registers the given user with the service, creates a new password secret for the newly created account and then returns the newly created user object.
- Parameters
user – The user data to register with the service.
password – The password to create for the user.
- Returns
A task whose result is the newly created user.
-
void SetTotpChallengeCallback(TotpChallengeCallback callback)
Sets the callback to be notified when a TOTP challenge is requested during authentication.
-
typedef std::function<void(Object&)> PushNotificationCallback