@hawcx/react-native-sdk 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/README.md +2 -2
  3. package/android/build.gradle +145 -0
  4. package/android/consumer-rules.pro +2 -0
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/gradlew +185 -0
  9. package/android/gradlew.bat +89 -0
  10. package/android/libs/hawcx-5.1.2.aar +0 -0
  11. package/android/settings.gradle +53 -0
  12. package/android/src/main/AndroidManifest.xml +4 -0
  13. package/android/src/main/java/com/hawcx/reactnative/AuthCallbackProxy.kt +53 -0
  14. package/android/src/main/java/com/hawcx/reactnative/HawcxEventDispatcher.kt +43 -0
  15. package/android/src/main/java/com/hawcx/reactnative/HawcxReactNativeLogger.kt +19 -0
  16. package/android/src/main/java/com/hawcx/reactnative/HawcxReactNativeModule.kt +387 -0
  17. package/android/src/main/java/com/hawcx/reactnative/HawcxReactNativePackage.kt +16 -0
  18. package/android/src/main/java/com/hawcx/reactnative/PushDelegateProxy.kt +31 -0
  19. package/android/src/main/java/com/hawcx/reactnative/SessionCallbackProxy.kt +35 -0
  20. package/example/ios/HawcxExampleApp.xcodeproj/project.xcworkspace/xcuserdata/agambhullar.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  21. package/example/ios/Podfile.lock +2 -2
  22. package/example/package-lock.json +3 -3
  23. package/example/package.json +1 -1
  24. package/ios/Frameworks/HawcxFramework.xcframework/Info.plist +5 -5
  25. package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/HawcxFramework +0 -0
  26. package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios.abi.json +18 -1
  27. package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/HawcxFramework +0 -0
  28. package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.abi.json +18 -1
  29. package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.abi.json +18 -1
  30. package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/_CodeSignature/CodeResources +8 -8
  31. package/lib/commonjs/index.js +1 -1
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/module/index.js +1 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/typescript/index.d.ts.map +1 -1
  36. package/package.json +2 -1
  37. package/src/index.ts +5 -3
package/CHANGELOG.md CHANGED
@@ -1,9 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## [1.0.3] - YYYY-MM-DD
3
+ ## [1.0.5] - YYYY-MM-DD
4
4
  - TODO: add release notes
5
5
 
6
- ## [1.0.2] - YYYY-MM-DD
6
+ ## [1.0.4] - 2025-11-28
7
+ - Include Android sources in npm package and clarify linking error message.
8
+
9
+ ## [1.0.3] - 2025-11-19
10
+ - TODO: add release notes
11
+
12
+ ## [1.0.2] - 2025-11-18
7
13
  - OAuth flow update
8
14
  - Android release prep
9
15
 
package/README.md CHANGED
@@ -11,7 +11,7 @@ Official React Native bindings for the Hawcx V5 mobile authentication platform.
11
11
  ## Installation
12
12
 
13
13
  ```bash
14
- npm install @hawcx/react-native-sdk
14
+ npm install @hawcx/react-native-sdk@1.0.4
15
15
  # or yarn add @hawcx/react-native-sdk
16
16
  ```
17
17
 
@@ -27,7 +27,7 @@ Open the workspace (`ios/*.xcworkspace`) in Xcode when you need to run on a devi
27
27
 
28
28
  ### Android
29
29
 
30
- No manual steps are required—Gradle picks up the bundled `hawcx-*.aar`. Make sure the Android SDK is installed and `ANDROID_HOME`/`adb` are on your path, then run `npm run android`.
30
+ No manual steps are required—Gradle picks up the bundled `hawcx-*.aar`. Make sure the Android SDK is installed and `ANDROID_HOME`/`adb` are on your path, then run `npm run android`. If you upgrade from an older package version, run `cd android && ./gradlew clean` once before rebuilding so React Native re-links the native module.
31
31
 
32
32
  ## Quick Start
33
33
 
@@ -0,0 +1,145 @@
1
+ buildscript {
2
+ ext {
3
+ androidGradlePluginVersion = '8.5.2'
4
+ kotlinVersion = '2.0.0'
5
+ }
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+ dependencies {
11
+ classpath("com.android.tools.build:gradle:$androidGradlePluginVersion")
12
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
13
+ }
14
+ }
15
+
16
+ apply plugin: 'com.android.library'
17
+ apply plugin: 'org.jetbrains.kotlin.android'
18
+ apply plugin: 'maven-publish'
19
+
20
+ def safeExtGet(prop, fallback) {
21
+ return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
22
+ }
23
+
24
+ group = 'com.hawcx.reactnative'
25
+ version = project.findProperty('HAWCX_REACT_NATIVE_ANDROID_VERSION') ?: '1.0.5'
26
+
27
+ repositories {
28
+ mavenCentral()
29
+ google()
30
+ maven { url "$rootDir/../node_modules/react-native/android" }
31
+ maven { url "$rootDir/../node_modules/jsc-android/dist" }
32
+ maven {
33
+ url "https://raw.githubusercontent.com/hawcx/hawcx_android_sdk/main/maven"
34
+ credentials {
35
+ username System.getenv("HAWCX_MAVEN_USER") ?: System.getenv("GITHUB_USER") ?: ""
36
+ password System.getenv("HAWCX_MAVEN_TOKEN") ?: System.getenv("GITHUB_TOKEN") ?: ""
37
+ }
38
+ authentication {
39
+ basic(BasicAuthentication)
40
+ }
41
+ content {
42
+ includeGroup "api.hawcx"
43
+ }
44
+ metadataSources {
45
+ mavenPom()
46
+ artifact()
47
+ }
48
+ }
49
+ def localMavenRepo = new File(rootDir, "../../prod_android/hawcx_android_sdk/maven")
50
+ if (localMavenRepo.exists()) {
51
+ maven {
52
+ url localMavenRepo.toURI()
53
+ content {
54
+ includeGroup "api.hawcx"
55
+ }
56
+ metadataSources {
57
+ mavenPom()
58
+ artifact()
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ android {
65
+ namespace 'com.hawcx.reactnative'
66
+ compileSdkVersion safeExtGet('compileSdkVersion', 34)
67
+
68
+ defaultConfig {
69
+ minSdkVersion safeExtGet('minSdkVersion', 26)
70
+ targetSdkVersion safeExtGet('targetSdkVersion', 34)
71
+ consumerProguardFiles 'consumer-rules.pro'
72
+ }
73
+
74
+ buildFeatures {
75
+ buildConfig = true
76
+ }
77
+
78
+ compileOptions {
79
+ sourceCompatibility JavaVersion.VERSION_17
80
+ targetCompatibility JavaVersion.VERSION_17
81
+ }
82
+
83
+ kotlinOptions {
84
+ jvmTarget = '17'
85
+ }
86
+
87
+ lint {
88
+ abortOnError = true
89
+ textReport = true
90
+ textOutput = file("${project.buildDir}/reports/lint-results.txt")
91
+ htmlReport = true
92
+ htmlOutput = file("${project.buildDir}/reports/lint-results.html")
93
+ }
94
+
95
+ publishing {
96
+ singleVariant('release') {
97
+ withSourcesJar()
98
+ }
99
+ }
100
+ }
101
+
102
+ afterEvaluate {
103
+ publishing {
104
+ publications {
105
+ release(MavenPublication) {
106
+ from components.release
107
+ groupId = 'com.hawcx'
108
+ artifactId = 'react-native-hawcx'
109
+ version = project.version
110
+ pom {
111
+ name = 'Hawcx React Native SDK - Android'
112
+ description = 'React Native bridge for the Hawcx Android SDK.'
113
+ url = 'https://github.com/hawcx/react-native-sdk'
114
+ licenses {
115
+ license {
116
+ name = 'MIT'
117
+ url = 'https://opensource.org/licenses/MIT'
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ dependencies {
127
+ api("api.hawcx:hawcx:1.0.5")
128
+ def reactNativeVersion = safeExtGet('reactNativeAndroidVersion', '0.73.9')
129
+ implementation "com.facebook.react:react-android:$reactNativeVersion"
130
+ implementation 'androidx.annotation:annotation:1.8.1'
131
+ implementation 'androidx.appcompat:appcompat:1.7.0'
132
+ implementation 'androidx.core:core-ktx:1.13.1'
133
+ implementation 'com.google.android.material:material:1.12.0'
134
+ implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05'
135
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
136
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
137
+ implementation 'com.squareup.retrofit2:retrofit:2.10.0'
138
+ implementation 'com.squareup.retrofit2:converter-gson:2.10.0'
139
+ implementation 'com.squareup.okhttp3:okhttp:4.12.0'
140
+ implementation 'com.squareup.okhttp3:logging-interceptor:4.11.0'
141
+ implementation 'com.google.code.gson:gson:2.11.0'
142
+ implementation 'com.google.android.gms:play-services-tasks:18.2.0'
143
+ implementation 'com.google.android.gms:play-services-location:21.3.0'
144
+ implementation 'org.bouncycastle:bcprov-jdk15to18:1.78.1'
145
+ }
@@ -0,0 +1,2 @@
1
+ # Keep classes that React Native autolinking expects
2
+ -keep class com.hawcx.reactnative.** { *; }
@@ -0,0 +1,6 @@
1
+ #Thu Jun 20 01:28:42 IST 2024
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
5
+ zipStoreBase=GRADLE_USER_HOME
6
+ zipStorePath=wrapper/dists
@@ -0,0 +1,5 @@
1
+ # Project-wide Gradle settings.
2
+ org.gradle.jvmargs=-Xmx4g -Dkotlin.daemon.jvm.options=-Xmx2g
3
+ android.useAndroidX=true
4
+ android.enableJetifier=true
5
+ kotlin.code.style=official
@@ -0,0 +1,185 @@
1
+ #!/usr/bin/env sh
2
+
3
+ #
4
+ # Copyright 2015 the original author or authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ ##############################################################################
20
+ ##
21
+ ## Gradle start up script for UN*X
22
+ ##
23
+ ##############################################################################
24
+
25
+ # Attempt to set APP_HOME
26
+ # Resolve links: $0 may be a link
27
+ PRG="$0"
28
+ # Need this for relative symlinks.
29
+ while [ -h "$PRG" ] ; do
30
+ ls=`ls -ld "$PRG"`
31
+ link=`expr "$ls" : '.*-> \(.*\)$'`
32
+ if expr "$link" : '/.*' > /dev/null; then
33
+ PRG="$link"
34
+ else
35
+ PRG=`dirname "$PRG"`"/$link"
36
+ fi
37
+ done
38
+ SAVED="`pwd`"
39
+ cd "`dirname \"$PRG\"`/" >/dev/null
40
+ APP_HOME="`pwd -P`"
41
+ cd "$SAVED" >/dev/null
42
+
43
+ APP_NAME="Gradle"
44
+ APP_BASE_NAME=`basename "$0"`
45
+
46
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48
+
49
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
50
+ MAX_FD="maximum"
51
+
52
+ warn () {
53
+ echo "$*"
54
+ }
55
+
56
+ die () {
57
+ echo
58
+ echo "$*"
59
+ echo
60
+ exit 1
61
+ }
62
+
63
+ # OS specific support (must be 'true' or 'false').
64
+ cygwin=false
65
+ msys=false
66
+ darwin=false
67
+ nonstop=false
68
+ case "`uname`" in
69
+ CYGWIN* )
70
+ cygwin=true
71
+ ;;
72
+ Darwin* )
73
+ darwin=true
74
+ ;;
75
+ MINGW* )
76
+ msys=true
77
+ ;;
78
+ NONSTOP* )
79
+ nonstop=true
80
+ ;;
81
+ esac
82
+
83
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84
+
85
+
86
+ # Determine the Java command to use to start the JVM.
87
+ if [ -n "$JAVA_HOME" ] ; then
88
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89
+ # IBM's JDK on AIX uses strange locations for the executables
90
+ JAVACMD="$JAVA_HOME/jre/sh/java"
91
+ else
92
+ JAVACMD="$JAVA_HOME/bin/java"
93
+ fi
94
+ if [ ! -x "$JAVACMD" ] ; then
95
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96
+
97
+ Please set the JAVA_HOME variable in your environment to match the
98
+ location of your Java installation."
99
+ fi
100
+ else
101
+ JAVACMD="java"
102
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103
+
104
+ Please set the JAVA_HOME variable in your environment to match the
105
+ location of your Java installation."
106
+ fi
107
+
108
+ # Increase the maximum file descriptors if we can.
109
+ if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110
+ MAX_FD_LIMIT=`ulimit -H -n`
111
+ if [ $? -eq 0 ] ; then
112
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113
+ MAX_FD="$MAX_FD_LIMIT"
114
+ fi
115
+ ulimit -n $MAX_FD
116
+ if [ $? -ne 0 ] ; then
117
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
118
+ fi
119
+ else
120
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121
+ fi
122
+ fi
123
+
124
+ # For Darwin, add options to specify how the application appears in the dock
125
+ if $darwin; then
126
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127
+ fi
128
+
129
+ # For Cygwin or MSYS, switch paths to Windows format before running java
130
+ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133
+
134
+ JAVACMD=`cygpath --unix "$JAVACMD"`
135
+
136
+ # We build the pattern for arguments to be converted via cygpath
137
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138
+ SEP=""
139
+ for dir in $ROOTDIRSRAW ; do
140
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
141
+ SEP="|"
142
+ done
143
+ OURCYGPATTERN="(^($ROOTDIRS))"
144
+ # Add a user-defined pattern to the cygpath arguments
145
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147
+ fi
148
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
149
+ i=0
150
+ for arg in "$@" ; do
151
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153
+
154
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156
+ else
157
+ eval `echo args$i`="\"$arg\""
158
+ fi
159
+ i=`expr $i + 1`
160
+ done
161
+ case $i in
162
+ 0) set -- ;;
163
+ 1) set -- "$args0" ;;
164
+ 2) set -- "$args0" "$args1" ;;
165
+ 3) set -- "$args0" "$args1" "$args2" ;;
166
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172
+ esac
173
+ fi
174
+
175
+ # Escape application args
176
+ save () {
177
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178
+ echo " "
179
+ }
180
+ APP_ARGS=`save "$@"`
181
+
182
+ # Collect all arguments for the java command, following the shell quoting and substitution rules
183
+ eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184
+
185
+ exec "$JAVACMD" "$@"
@@ -0,0 +1,89 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
17
+ @if "%DEBUG%" == "" @echo off
18
+ @rem ##########################################################################
19
+ @rem
20
+ @rem Gradle startup script for Windows
21
+ @rem
22
+ @rem ##########################################################################
23
+
24
+ @rem Set local scope for the variables with windows NT shell
25
+ if "%OS%"=="Windows_NT" setlocal
26
+
27
+ set DIRNAME=%~dp0
28
+ if "%DIRNAME%" == "" set DIRNAME=.
29
+ set APP_BASE_NAME=%~n0
30
+ set APP_HOME=%DIRNAME%
31
+
32
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34
+
35
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37
+
38
+ @rem Find java.exe
39
+ if defined JAVA_HOME goto findJavaFromJavaHome
40
+
41
+ set JAVA_EXE=java.exe
42
+ %JAVA_EXE% -version >NUL 2>&1
43
+ if "%ERRORLEVEL%" == "0" goto execute
44
+
45
+ echo.
46
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47
+ echo.
48
+ echo Please set the JAVA_HOME variable in your environment to match the
49
+ echo location of your Java installation.
50
+
51
+ goto fail
52
+
53
+ :findJavaFromJavaHome
54
+ set JAVA_HOME=%JAVA_HOME:"=%
55
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56
+
57
+ if exist "%JAVA_EXE%" goto execute
58
+
59
+ echo.
60
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61
+ echo.
62
+ echo Please set the JAVA_HOME variable in your environment to match the
63
+ echo location of your Java installation.
64
+
65
+ goto fail
66
+
67
+ :execute
68
+ @rem Setup the command line
69
+
70
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71
+
72
+
73
+ @rem Execute Gradle
74
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75
+
76
+ :end
77
+ @rem End local scope for the variables with windows NT shell
78
+ if "%ERRORLEVEL%"=="0" goto mainEnd
79
+
80
+ :fail
81
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82
+ rem the _cmd.exe /c_ return code!
83
+ if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84
+ exit /b 1
85
+
86
+ :mainEnd
87
+ if "%OS%"=="Windows_NT" endlocal
88
+
89
+ :omega
Binary file
@@ -0,0 +1,53 @@
1
+ import org.gradle.authentication.http.BasicAuthentication
2
+
3
+ pluginManagement {
4
+ repositories {
5
+ google()
6
+ mavenCentral()
7
+ gradlePluginPortal()
8
+ }
9
+ }
10
+
11
+ dependencyResolutionManagement {
12
+ repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
13
+ repositories {
14
+ google()
15
+ mavenCentral()
16
+ def hawcxMavenUser = System.getenv("HAWCX_MAVEN_USER") ?: System.getenv("GITHUB_USER")
17
+ def hawcxMavenToken = System.getenv("HAWCX_MAVEN_TOKEN") ?: System.getenv("GITHUB_TOKEN")
18
+ def localMavenDir = file("${rootDir}/../../prod_android/hawcx_android_sdk/maven")
19
+ if (hawcxMavenUser && hawcxMavenToken) {
20
+ maven {
21
+ url = uri("https://raw.githubusercontent.com/hawcx/hawcx_android_sdk/main/maven")
22
+ content {
23
+ includeGroup("api.hawcx")
24
+ }
25
+ credentials {
26
+ username = hawcxMavenUser
27
+ password = hawcxMavenToken
28
+ }
29
+ authentication {
30
+ create("basic", BasicAuthentication)
31
+ }
32
+ metadataSources {
33
+ mavenPom()
34
+ artifact()
35
+ }
36
+ }
37
+ }
38
+ if (localMavenDir.exists()) {
39
+ maven {
40
+ url = localMavenDir.toURI()
41
+ content {
42
+ includeGroup("api.hawcx")
43
+ }
44
+ metadataSources {
45
+ mavenPom()
46
+ artifact()
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ rootProject.name = "hawcxreactnative"
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <application />
4
+ </manifest>
@@ -0,0 +1,53 @@
1
+ package com.hawcx.reactnative
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.hawcx.utils.AuthV5Callback
5
+ import com.hawcx.utils.AuthV5ErrorCode
6
+
7
+ internal class AuthCallbackProxy(
8
+ private val dispatcher: HawcxEventDispatcher
9
+ ) : AuthV5Callback {
10
+
11
+ override fun onOtpRequired() {
12
+ dispatcher.emitAuthEvent("otp_required")
13
+ }
14
+
15
+ override fun onAuthSuccess(accessToken: String, refreshToken: String, isLoginFlow: Boolean) {
16
+ val payload = Arguments.createMap().apply {
17
+ putBoolean("isLoginFlow", isLoginFlow)
18
+ if (accessToken.isNotBlank()) {
19
+ putString("accessToken", accessToken)
20
+ }
21
+ if (refreshToken.isNotBlank()) {
22
+ putString("refreshToken", refreshToken)
23
+ }
24
+ }
25
+ dispatcher.emitAuthEvent("auth_success", payload)
26
+ }
27
+
28
+ override fun onError(errorCode: AuthV5ErrorCode, errorMessage: String) {
29
+ val payload = Arguments.createMap().apply {
30
+ putString("code", errorCode.name)
31
+ putString("message", errorMessage)
32
+ }
33
+ dispatcher.emitAuthEvent("auth_error", payload)
34
+ }
35
+
36
+ override fun onAuthorizationCode(code: String, expiresIn: Int?) {
37
+ val payload = Arguments.createMap().apply {
38
+ putString("code", code)
39
+ expiresIn?.let { putInt("expiresIn", it) }
40
+ }
41
+ dispatcher.emitAuthEvent("authorization_code", payload)
42
+ }
43
+
44
+ override fun onAdditionalVerificationRequired(sessionId: String, detail: String?) {
45
+ val payload = Arguments.createMap().apply {
46
+ putString("sessionId", sessionId)
47
+ if (!detail.isNullOrBlank()) {
48
+ putString("detail", detail)
49
+ }
50
+ }
51
+ dispatcher.emitAuthEvent("additional_verification_required", payload)
52
+ }
53
+ }
@@ -0,0 +1,43 @@
1
+ package com.hawcx.reactnative
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.WritableMap
6
+ import com.facebook.react.modules.core.DeviceEventManagerModule
7
+
8
+ internal class HawcxEventDispatcher(
9
+ private val reactContext: ReactApplicationContext
10
+ ) {
11
+
12
+ fun emitAuthEvent(type: String, payload: WritableMap? = null) {
13
+ emitEvent(AUTH_EVENT_NAME, type, payload)
14
+ }
15
+
16
+ fun emitSessionEvent(type: String, payload: WritableMap? = null) {
17
+ emitEvent(SESSION_EVENT_NAME, type, payload)
18
+ }
19
+
20
+ fun emitPushEvent(type: String, payload: WritableMap? = null) {
21
+ emitEvent(PUSH_EVENT_NAME, type, payload)
22
+ }
23
+
24
+ private fun emitEvent(eventName: String, type: String, payload: WritableMap?) {
25
+ val map = Arguments.createMap().apply {
26
+ putString("type", type)
27
+ if (payload != null) {
28
+ putMap("payload", payload)
29
+ }
30
+ }
31
+ runCatching {
32
+ if (reactContext.hasActiveCatalystInstance()) {
33
+ reactContext
34
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
35
+ .emit(eventName, map)
36
+ } else {
37
+ HawcxReactNativeLogger.w("Dropping $eventName because Catalyst instance is not ready")
38
+ }
39
+ }.onFailure { error ->
40
+ HawcxReactNativeLogger.w("Failed to emit $eventName", error)
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,19 @@
1
+ package com.hawcx.reactnative
2
+
3
+ import android.util.Log
4
+
5
+ internal object HawcxReactNativeLogger {
6
+ const val TAG = "HawcxReactNative"
7
+
8
+ fun d(message: String) {
9
+ Log.d(TAG, message)
10
+ }
11
+
12
+ fun i(message: String) {
13
+ Log.i(TAG, message)
14
+ }
15
+
16
+ fun w(message: String, throwable: Throwable? = null) {
17
+ Log.w(TAG, message, throwable)
18
+ }
19
+ }