Core Components
HawcxInitializer
async init(apiKey, apiEndpoint?)
async init(apiKey, apiEndpoint?)
Initializes the Hawcx Smart Connect SDK. This must be called before any other SDK methods.Parameters:
apiKey
(string): Your Hawcx API Key.apiEndpoint
(string, optional): The base URL for the Hawcx API. Defaults to the production endpoint if not provided.
HawcxAuthInstance
An instance of the Hawcx Smart Connect SDK, with methods like
authenticate
and verify
.HawcxInitializer.getInstance()
HawcxInitializer.getInstance()
Gets current SDK instanceReturns: SDK instance
Smart Connect Authentication Methods
async authenticate(email)
async authenticate(email)
Initiates the Smart Connect authentication process for a user with the given email address. This revolutionary method intelligently handles both new user registrations and existing user sign-ins through a single, unified interface. Smart Connect automatically determines the user context and whether OTP verification is needed.Parameters:
email
(string): The user’s email address.
AuthenticationResponse
The response object from the Smart Connect authentication attempt.
async verify({ deviceToken, otp, userid })
async verify({ deviceToken, otp, userid })
Verifies a One-Time Password (OTP) that was sent to the user after Smart Connect determined verification was needed (when
authenticate
returned "OTP_NEEDED"
status).Parameters:-
params
(object): An object containing the verification details.
VerificationResponse
The response object from the OTP verification attempt.
async initiateQrLogin({ onPinReady, onSuccess, onError, timeout? })
async initiateQrLogin({ onPinReady, onSuccess, onError, timeout? })
Initiates a QR code-based login flow powered by Smart Connect. This method enables seamless cross-platform authentication where users can scan a QR code with their registered mobile app. The function manages the complete lifecycle of the QR session with intelligent authentication handling.Parameters:
-
callbacks
(object): An object containing the callback functions and configuration for the Smart Connect QR flow.
Promise<void>
This method returns a Promise that resolves when the Smart Connect QR flow has been initiated. The results of the operation (PIN, success, or error) are delivered through the callback functions.
Response Object
All Smart Connect authentication methods return anAuthResponse
object:
Status Codes
General & Initialization
Code | Description |
---|---|
SUCCESS | The operation was successful. |
NOT_INITIALIZED | SDK has not been initialized. HawcxInitializer.init() must be called first. |
INITIALIZATION_FAILED | The SDK failed to initialize, possibly due to an invalid API key or network issue. |
CLIENT_ERROR | An unexpected client-side error occurred during an operation. |
Smart Connect Email & OTP Flow
Code | Description |
---|---|
INVALID_EMAIL | The provided email address is not in a valid format. |
USER_NOT_FOUND | The email address is not registered in the system. |
INVALID_OTP | The One-Time Password provided by the user is incorrect. |
VERIFICATION_FAILED | The OTP verification process failed for a reason other than an invalid OTP. |
MISSING_USERNAME | The userid (email) was not provided to the function requiring it. |
Smart Connect QR Code Flow
Code | Description |
---|---|
QR_TIMEOUT | The QR code was not scanned within the allowed time limit (default 2 minutes). |
QR_CREATE_FAILED | Failed to create a new QR session on the server. |
POLLING_FAILED | The periodic check for a successful scan failed, possibly due to a server-side issue. |
POLLING_ERROR | An unexpected client-side error occurred while checking for a scan status. |
QR_INIT_FAILED | The QR login process could not be started due to a critical client-side error. |
Code Examples
Initialize Smart Connect SDK
Initialize Smart Connect SDK
Smart Connect Authentication
Smart Connect Authentication
User Verification
User Verification
Smart Connect QR Code Login
Smart Connect QR Code Login