@acceleratxr/core_sdk / CoreSDK
Class: CoreSDK#
Hierarchy#
CoreSDK
Index#
Constructors#
Properties#
Accessors#
Methods#
Constructors#
constructor#
+ new CoreSDK(config: any, client?: ApiClient): CoreSDK
Defined in src/CoreSDK.ts:80
Initializes the SDK using the provided configuration.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
any |
The configuration to initialize the SDK with. |
|
- |
Returns: CoreSDK
Properties#
_serviceFactory#
• Private _serviceFactory: ServiceFactory
Defined in src/CoreSDK.ts:72
apiClient#
• apiClient: ApiClient
Defined in src/CoreSDK.ts:31
The API Client used when making requests to the API backend server.
config#
• config: Configuration
Defined in src/CoreSDK.ts:36
The SDK configuration to use.
loggedInProfile#
• loggedInProfile: Profile | undefined
Defined in src/CoreSDK.ts:49
The currently logged in social profile, otherwise undefined.
loggedInToken#
• loggedInToken: string | undefined
Defined in src/CoreSDK.ts:59
The authentication token of the currently logged in user, otherwise undefined.
loggedInUser#
• loggedInUser: User | undefined
Defined in src/CoreSDK.ts:54
The currently logged in user, otherwise undefined.
onAuthChallenge#
• Optional onAuthChallenge: undefined | () => string | Promise<string> = undefined
Defined in src/CoreSDK.ts:65
Callback function used to notify the application that an authentication challenge has been requested.
refreshTimer#
• Private Optional refreshTimer: NodeJS.Timeout = undefined
Defined in src/CoreSDK.ts:70
The interval handle used to refresh the access credentials.
Accessors#
authMethods#
• get authMethods(): AuthMethod[]
Defined in src/CoreSDK.ts:74
Returns: AuthMethod[]
deviceId#
• get deviceId(): string
Defined in src/CoreSDK.ts:42
The unique device identifier. This is generated at random each startup. It is recommended that you store the initial value in permanent storage and then set the stored value at application startup.
Returns: string
serviceFactory#
• get serviceFactory(): ServiceFactory
Defined in src/CoreSDK.ts:78
Returns: ServiceFactory
Methods#
connectOAuth#
▸ connectOAuth(id: string, code: string, verifier?: undefined | string, redirectUrl?: undefined | string, force?: undefined | false | true): Promise<void>
Defined in src/CoreSDK.ts:297
Connects a third-party OAuth provider with the existing logged in user for the given token and provider type.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
string |
The unique identifier of the OAuth provider type to log in with. |
|
string |
The OAuth authorization code returned by the OAuth provider. |
|
undefined | string |
- |
|
undefined | string |
The optional callback URL that was used to generate the access token. |
|
undefined | false | true |
Set to |
Returns: Promise<void>
finishLogin#
▸ PrivatefinishLogin(): Promise<void>
Defined in src/CoreSDK.ts:144
Call this after a successful login to automatically retrieve user data, social profile and other needed data for the user’s session.
Returns: Promise<void>
getAuthMethod#
▸ getAuthMethod(name: string): AuthMethod | undefined
Defined in src/CoreSDK.ts:136
Returns the AuthMethod with the given name if available with the configured cluster.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
string |
The name of the auth method to retrieve. |
Returns: AuthMethod | undefined
getDevicePassword#
▸ PrivategetDevicePassword(): string
Defined in src/CoreSDK.ts:262
Generates a new password based upon deviceId.
Returns: string
init#
▸ init(): Promise<void>
Defined in src/CoreSDK.ts:101
Initializes this SDK using the provided configuration.
Returns: Promise<void>
loginDevice#
▸ loginDevice(): Promise<void>
Defined in src/CoreSDK.ts:309
Performs a user login using the unique identifier of the device.
Returns: Promise<void>
loginEmail#
▸ loginEmail(id: string, code?: undefined | string): Promise<void>
Defined in src/CoreSDK.ts:343
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 provided code to finish
the authentication process.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
string |
The unique identifier of the user to send the e-mail verification code to. |
|
undefined | string |
The verification code to authentication with. |
Returns: Promise<void>
loginLocal#
▸ loginLocal(user: any | undefined): void
Defined in src/CoreSDK.ts:233
Performs local authentication without contacting the remote service. Intended for debugging and development purposes only.
Parameters:#
Name |
Type |
Default value |
|---|---|---|
|
any | undefined |
undefined |
Returns: void
loginOAuth#
▸ loginOAuth(id: string, code: string, redirectUri?: undefined | string, verifier?: undefined | string): Promise<void>
Defined in src/CoreSDK.ts:383
Authenticates the user using the OAuth protocol for the given provider and authorization code.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
string |
The unique identifier of the OAuth provider type to log in with. |
|
string |
The OAuth 2.0 authorization code. |
|
undefined | string |
The optional callback URL that was used to generate the access token. |
|
undefined | string |
The optional OAuth 2.0 PKCE code verifier. |
Returns: Promise<void>
loginPassword#
▸ loginPassword(username: string, password: string): Promise<void>
Defined in src/CoreSDK.ts:430
Performs a user login with the specified username and password.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
string |
The unique name of the user to log in. |
|
string |
The password of the user to log in. |
Returns: Promise<void>
loginPhone#
▸ loginPhone(id: string, code?: undefined | string): Promise<void>
Defined in src/CoreSDK.ts:454
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 provided code to finish
the authentication process.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
string |
The unique identifier of the user to send the phone verification code to. |
|
undefined | string |
The verification code to authentication with. |
Returns: Promise<void>
loginToken#
▸ loginToken(token: string, newSession: boolean): Promise<void>
Defined in src/CoreSDK.ts:474
Performs a user login using the specified authentication token.
Parameters:#
Name |
Type |
Default value |
Description |
|---|---|---|---|
|
string |
- |
The authentication token to login with. |
|
boolean |
false |
- |
Returns: Promise<void>
logout#
▸ logout(): void
Defined in src/CoreSDK.ts:519
Clears any stored login and authentication information.
Returns: void
ping#
▸ ping(): Promise<number>
Defined in src/CoreSDK.ts:536
Attempts to contact the backend cluster and return the round-trip time of the request.
Returns: Promise<number>
A positive number representing the round-trip time to the background cluster, otherwise a negative number if an error occurred.
processAuthToken#
▸ PrivateprocessAuthToken(authToken: AuthToken): Promise<void>
Defined in src/CoreSDK.ts:179
Call this after performing an authentication request to process the auth token.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
The auth token to process. |
Returns: Promise<void>
refreshToken#
▸ refreshToken(): Promise<void>
Defined in src/CoreSDK.ts:213
Call this after performing an authentication request to process the auth token.
Returns: Promise<void>
registerUser#
▸ registerUser(user: User, profile?: Profile): Promise<User>
Defined in src/CoreSDK.ts:553
Registers the given user with the service and returns the newly created user object.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
The user data to register with the service. |
|
|
The optional social profile data to register with the service. |
Returns: Promise<User>
A promise whose result is the newly created user.
registerUserAndPassword#
▸ registerUserAndPassword(user: User, password: string, profile?: Profile): Promise<User>
Defined in src/CoreSDK.ts:598
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:#
Name |
Type |
Description |
|---|---|---|
|
The user data to register with the service. |
|
|
string |
The password to create for the user. |
|
The optional social profile data to register with the service. |
Returns: Promise<User>
A promise whose result is the newly created user.
requestOAuth#
▸ requestOAuth(id: string, state?: undefined | string, redirectUri?: undefined | string, scope?: undefined | string): Promise<string>
Defined in src/CoreSDK.ts:366
Requests the authorization request URI for the OAuth provider to redirect the client to.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
string |
The unique identifier of the OAuth provider type to log in with. |
|
undefined | string |
- |
|
undefined | string |
The optional callback URL that will be used in the request. |
|
undefined | string |
The optional scope to override the defualt with. |
Returns: Promise<string>
setupRefreshTimer#
▸ PrivatesetupRefreshTimer(authInfo: AuthToken): void
Defined in src/CoreSDK.ts:622
Sets up an timer to refresh the access token at a given interval using the provided access token.
Parameters:#
Name |
Type |
Description |
|---|---|---|
|
The information regarding the authenticated session. |
Returns: void
shutdown#
▸ shutdown(): void
Defined in src/CoreSDK.ts:127
Stops any ongoing tasks and frees any memory used.
Returns: void