This package provides the React Native wrapper for the Hawcx V5 mobile authentication framework. It reuses the production iOS implementation (dev_ios/ios_sdk/HawcxFramework) and exposes a typed JavaScript/TypeScript API for React Native applications.
src/– TypeScript entry point and public API surface.ios/– Native bridge sources (Swift) plus the Podspec that embedsHawcxFramework.android/– React Native Android bridge module (Gradle library) plus the bundled Hawcx SDK AAR.example/– Runnable React Native demo app using the SDK (npm install->npm run ios).react_mobile_sdk_plan.md– Detailed delivery plan and progress tracker. Always read and update this file when working on the SDK.
| Command | Description |
|---|---|
npm run clean |
Removes the build output under lib/. |
npm run lint |
Runs ESLint using the React Native + TypeScript rules. |
npm run typecheck |
Executes the TypeScript compiler in --noEmit mode. |
npm run build |
Builds distributable bundles via react-native-builder-bob. |
Note: Dependencies are declared in
package.jsonbut not yet installed. Install them once local tooling is in place (npm install).
android/hosts the Gradle-based library that React Native autolinks for Android builds. It already references the Hawcx Android SDK viaandroid/libs/hawcx-5.1.0.aarand exposes./gradlewhelpers for linting/publishing.- Run Gradle tasks from the repo root with
./gradlew -p android <task>(for example,./gradlew -p android :hawcxreactnative:lintRelease). The first invocation requires network/Gradle cache access for AGP + React Native dependencies. - The bridge mirrors the iOS surface:
initialize,authenticate, OTP/session helpers, push lifecycle (setApnsDeviceTokenon iOS,setFcmTokenon Android), and emits the samehawcx.*events for auth/session/push updates. - Android builds require
android/local.propertiespointing at your Android SDK (sdk.dir=/Users/<you>/Library/Android/sdk) and targetminSdkVersion26 to match the Hawcx AAR.
- Build the native Android SDK (
cd ~/dev_android/android_sdk && ./gradlew :app:assembleRelease). - Copy the generated
app/build/outputs/aar/hawcx-<version>.aarintoandroid/libs/, replacing the existing binary. - Update any documentation or release notes (e.g.,
react_mobile_sdk_plan.md,CHANGELOG.md) to reflect the new Hawcx SDK version.
import {
initialize,
authenticate,
submitOtp,
addAuthListener,
hawcxClient,
useHawcxAuth,
useHawcxWebLogin,
} from '@hawcx/react-native-sdk';
await initialize({ projectApiKey: 'YOUR_PROJECT_KEY' });
const subscription = addAuthListener(event => {
switch (event.type) {
case 'otp_required':
// show OTP UI
break;
case 'auth_success':
console.log('Login success', event.payload);
break;
case 'auth_error':
console.error('Auth failed', event.payload.message);
break;
}
});
await authenticate('[email protected]');
await submitOtp('123456');
subscription.remove();
// HawcxClient helper
const { promise } = hawcxClient.authenticate('[email protected]', {
onOtpRequired: () => console.log('show OTP UI'),
});
const result = await promise; // -> { accessToken?, refreshToken?, isLoginFlow }
// React hook example
function AuthScreen() {
const { state, authenticate, submitOtp } = useHawcxAuth();
const start = () => authenticate('[email protected]');
const sendOtp = (otp: string) => submitOtp(otp);
return null;
}
function WebLoginScreen() {
const { state, webLogin, webApprove, getDeviceDetails } = useHawcxWebLogin();
const validatePin = (pin: string) => webLogin(pin);
const approveSession = (token: string) => webApprove(token);
const refreshDevices = () => getDeviceDetails();
return null;
}cd example && npm installto bootstrap the sample app.- Edit
example/src/hawcx.config.tswith your project API key plus the OAuth client ID, token endpoint, and PEM fromdev_ios/ios_demo_dev, then runnpm run iosornpm run android. - Use
example/e2e/hawcx-login.yamlwith Maestro to drive a smoke test through OTP login. Adjust selectors to match your bundle ID and UI tweaks.
Review docs/RELEASE.md before publishing. In short:
- Run
npm run lint && npm run typecheck && npm test && npm run build. - Update
package.json+CHANGELOG.md. - Smoke test the example app.
npm publish --access publicandpod repo push trunk HawcxReactNative.podspec.- Tag the repo (
git tag vX.Y.Z && git push origin --tags).
- Follow
react_mobile_sdk_plan.mdPhase 1+ to implement the native bridge and JS API. - Keep this README updated with integration steps and release instructions as the SDK matures.