Class CoreSDK

Class CoreSDK#

Class Documentation#

class xbe.sdk.CoreSDK#

Provides a single interface for the SDK and management for the various service classes.

Public Functions

delegate void LoggedInUserChanged (User user)#

Callback when the LoggedInUser has changed.

Param user:

delegate void PushNotification (PushMessage message)#

Defines a callback function that will be notified when a new push notification arrives.

Param json:

The received push notification.

delegate Task<string> TotpChallengeCallback ()#

The callback function definition when an MFA (TOTP) challenge has been received and the application needs to respond.

Return:

The totp code to complete the multi-factor authentication challenge

CoreSDK (string instanceName, Configuration config, IAPIClient apiClient = null, ILogger logger = null)#

Initializes the SDK using the provided configuration. Do not reuse the same instance of Configuration from another instance of CoreSDK.

Param config:

The configuration to initialize the SDK with.

CoreSDK (Configuration config, IAPIClient apiClient = null, ILogger logger = null)

Initializes the SDK using the provided configuration. Do not reuse the same instance of Configuration from another instance of CoreSDK.

Param config:

The configuration to initialize the SDK with.

void Shutdown ()#

Stops any ongoing tasks and frees any memory used.

AuthMethod GetAuthMethod (string name)#

Returns the AuthMethod with the given name if available with the configured cluster. /summary>

param name:

The name of the auth method to retrieve.

T GetService<T> ()#

Convenience method for retrieving a service instance from the ServiceFactory.

Tparam T:

Subclass of ServiceBase.

Return:

An instance of the specified service.

void LoginLocal (User user = null)#

Performs local authentication without contacting the remote service. Intended for debugging and development purposes only.

Param user:

Uses a dummy user profile when null.

string GenerateUserJwtToken (ref User user)#
async Task Logout ()#

Clears any stored login and authentication information.

async Task ConnectOAuth (string id, string code, string verifier = null, string redirectUrl = null, bool force = false)#

Connects a third-party OAuth provider with the existing logged in user for the given token and provider type. /summary>

Param id:

The unique identifier of the OAuth provider type to log in with.

Param code:

The OAuth authorization code returned by the OAuth provider.

Param challenge:

The optional OAuth PKCE code verifier.

Param redirectUrl:

The optional callback URL that was used to generate the access token.

Param force:

Set to true to force the connection even if an existing connection exists on another account, otherwise set to false. Default is false.

async Task<string> RequestOAuth (string id, string state = null, string redirectUri = null, string scope = null)#

Requests the authorization request URI for the OAuth provider to redirect the client to.

Param id:

The unique identifier of the OAuth provider type to log in with.

Param redirectUri:

The optional callback URL that will be used in the request.

Param scope:

The optional scope to override the default with.

async Task LoginOAuth (string id, string code, string redirectUri = null, string verifier = null)#

Authenticates the user using the OAuth protocol for the given provider and authorization code.

Param id:

The unique identifier of the OAuth provider type to log in with.

Param code:

The OAuth 2.0 authorization code.

Param redirectUri:

The optional callback URL that was used to generate the access token.

Param verifier:

The optional OAuth 2.0 PKCE code verifier.

async Task LoginDevice (bool testNullPasswordForErr = false)#

Performs a user login using the unique identifier of the device.

Return:

Task with no return value

async Task LoginEmail (string email)#
async Task LoginEmail (string email, string code)
async Task LoginPassword (string username, string password)#

Performs a user login with the specified username and password.

Param username:

The unique name of the user to log in.

Param password:

The password of the user to log in.

Return:

Task with no return value

async Task LoginPhone (string phone)#
async Task LoginPhone (string phone, string code)
async Task LoginToken (string token)#

Performs a user login with the specified authentication token.

Param token:

The authentication token to log in with.

Return:

A task with no return value.

async Task<User> RegisterUser (User user)#

Registers the given user with the service and returns the newly created user object.

Param user:

The user data to register with the service

Return:

A task whose result is the newly created user

async Task<User> RegisterUserAndPassword (User user, string password)#

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.

Param user:

The user data to register with the service.

Param password:

Return:

A task whose result is the newly created user.

Public Members

Func<string> OnAuthChallenge = null#

Callback function used to notify the application that an authentication challenge has been requested.

Properties

IAPIClient APIClient { get; set; }#

The API Client used when making requests to the API back-end server.

Configuration Configuration { get; set; }#

The SDK configuration to use.

ConnectionStatus ConnectionStatus { get; set; }#

The current status of the SDK connection to the cluster.

string DeviceId { get; set; }#

The unique identifier of this device.

EntityWatchdog EntityWatchdog { get; set; }#

The instance of EntityWatchdog associated with this instance.

User LoggedInUser { get; set; }#

The currently logged in user, otherwise null.

LoginStatus LoginStatus { get; set; }#

The current status of the logged in user.

AuthToken LoggedInToken { get; set; }#

The authorization token of the currently logged in user, otherwise null.

PushNotification > PushListeners { get; set; }#

The list of callback delegates to notify when an unhandled push notification is received.

ServiceFactory ServiceFactory { get; set; }#

The ServiceFactory to use when performing operations with this instance of the SDK.

AuthMethod[] AuthMethods { get; set; }#

The list of available authentication methods supported by the backend cluster.