@hawcx/react-native-sdk 1.0.1
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.
- package/CHANGELOG.md +10 -0
- package/HawcxReactNative.podspec +25 -0
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/docs/RELEASE.md +119 -0
- package/example/README.md +59 -0
- package/example/android/app/build.gradle +126 -0
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +10 -0
- package/example/android/app/src/debug/AndroidManifest.xml +9 -0
- package/example/android/app/src/main/AndroidManifest.xml +27 -0
- package/example/android/app/src/main/java/com/hawcx/example/MainActivity.kt +22 -0
- package/example/android/app/src/main/java/com/hawcx/example/MainApplication.kt +45 -0
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +3 -0
- package/example/android/app/src/main/res/values/styles.xml +9 -0
- package/example/android/build.gradle +23 -0
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/example/android/gradle.properties +41 -0
- package/example/android/gradlew +249 -0
- package/example/android/gradlew.bat +92 -0
- package/example/android/local.properties +2 -0
- package/example/android/settings.gradle +4 -0
- package/example/app.json +4 -0
- package/example/babel.config.js +3 -0
- package/example/e2e/README.md +17 -0
- package/example/e2e/hawcx-login.yaml +14 -0
- package/example/index.js +5 -0
- package/example/ios/.xcode.env +11 -0
- package/example/ios/HawcxExampleApp/AppDelegate.h +6 -0
- package/example/ios/HawcxExampleApp/AppDelegate.mm +31 -0
- package/example/ios/HawcxExampleApp/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/example/ios/HawcxExampleApp/Images.xcassets/Contents.json +6 -0
- package/example/ios/HawcxExampleApp/Info.plist +55 -0
- package/example/ios/HawcxExampleApp/LaunchScreen.storyboard +47 -0
- package/example/ios/HawcxExampleApp/PrivacyInfo.xcprivacy +37 -0
- package/example/ios/HawcxExampleApp/main.m +10 -0
- package/example/ios/HawcxExampleApp.xcodeproj/project.pbxproj +704 -0
- package/example/ios/HawcxExampleApp.xcodeproj/project.xcworkspace/xcuserdata/agambhullar.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/HawcxExampleApp.xcodeproj/xcshareddata/xcschemes/HawcxExampleApp.xcscheme +90 -0
- package/example/ios/HawcxExampleApp.xcodeproj/xcuserdata/agambhullar.xcuserdatad/xcschemes/xcschememanagement.plist +16 -0
- package/example/ios/HawcxExampleApp.xcworkspace/contents.xcworkspacedata +10 -0
- package/example/ios/HawcxExampleAppTests/HawcxExampleAppTests.m +66 -0
- package/example/ios/HawcxExampleAppTests/Info.plist +24 -0
- package/example/ios/Podfile +55 -0
- package/example/ios/Podfile.lock +1290 -0
- package/example/metro.config.js +16 -0
- package/example/package-lock.json +13220 -0
- package/example/package.json +30 -0
- package/example/src/App.tsx +552 -0
- package/example/src/hawcx.config.ts +41 -0
- package/example/tsconfig.json +8 -0
- package/ios/Frameworks/.keep +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/Info.plist +44 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/HawcxFramework +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Headers/HawcxFramework.h +16 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Info.plist +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios.abi.json +9794 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios.private.swiftinterface +302 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios.swiftinterface +302 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64/HawcxFramework.framework/Modules/module.modulemap +6 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/HawcxFramework +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Headers/HawcxFramework.h +16 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Info.plist +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.abi.json +9794 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +302 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftinterface +302 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.abi.json +9794 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +302 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +302 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/Modules/module.modulemap +6 -0
- package/ios/Frameworks/HawcxFramework.xcframework/ios-arm64_x86_64-simulator/HawcxFramework.framework/_CodeSignature/CodeResources +234 -0
- package/ios/HawcxReactNative.m +51 -0
- package/ios/HawcxReactNative.swift +311 -0
- package/lib/commonjs/index.js +404 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +375 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/__tests__/index.test.d.ts +2 -0
- package/lib/typescript/__tests__/index.test.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +151 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +72 -0
- package/react_mobile_sdk_plan.md +240 -0
- package/src/__tests__/index.test.ts +163 -0
- package/src/index.ts +518 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>files</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Headers/HawcxFramework.h</key>
|
|
8
|
+
<data>
|
|
9
|
+
65ppmxWQowIIpsD6Dbo6JYwpvy4=
|
|
10
|
+
</data>
|
|
11
|
+
<key>Info.plist</key>
|
|
12
|
+
<data>
|
|
13
|
+
g1//TaKOyxUHqz6i0YUtEuqDlfU=
|
|
14
|
+
</data>
|
|
15
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
|
|
16
|
+
<data>
|
|
17
|
+
2vb14nlsVADWVRdsReo6rRqxMvI=
|
|
18
|
+
</data>
|
|
19
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
|
|
20
|
+
<data>
|
|
21
|
+
UqYujBasAE3VG/DYFaFrq0lslwA=
|
|
22
|
+
</data>
|
|
23
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
|
|
24
|
+
<data>
|
|
25
|
+
rjL37aIMuKyKFzQYtwUV9QOAl+c=
|
|
26
|
+
</data>
|
|
27
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
|
|
28
|
+
<data>
|
|
29
|
+
UqYujBasAE3VG/DYFaFrq0lslwA=
|
|
30
|
+
</data>
|
|
31
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
|
|
32
|
+
<data>
|
|
33
|
+
bt8mX2lcbHPBOo0bxVUOjaVgLjU=
|
|
34
|
+
</data>
|
|
35
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
|
36
|
+
<data>
|
|
37
|
+
2vb14nlsVADWVRdsReo6rRqxMvI=
|
|
38
|
+
</data>
|
|
39
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
|
40
|
+
<data>
|
|
41
|
+
4YhotBH4lqEojRu3JFHpfOFqxRE=
|
|
42
|
+
</data>
|
|
43
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
|
44
|
+
<data>
|
|
45
|
+
f9lwwPxBh1DCgPhcTiVJQN0hSm0=
|
|
46
|
+
</data>
|
|
47
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
|
|
48
|
+
<data>
|
|
49
|
+
4YhotBH4lqEojRu3JFHpfOFqxRE=
|
|
50
|
+
</data>
|
|
51
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
|
52
|
+
<data>
|
|
53
|
+
DdGIOyw6IDYsHGVE77jk0adq78s=
|
|
54
|
+
</data>
|
|
55
|
+
<key>Modules/module.modulemap</key>
|
|
56
|
+
<data>
|
|
57
|
+
dTbMgmavSSqq7+vEIKxNxZgqowg=
|
|
58
|
+
</data>
|
|
59
|
+
</dict>
|
|
60
|
+
<key>files2</key>
|
|
61
|
+
<dict>
|
|
62
|
+
<key>Headers/HawcxFramework.h</key>
|
|
63
|
+
<dict>
|
|
64
|
+
<key>hash2</key>
|
|
65
|
+
<data>
|
|
66
|
+
anqsDH5zu3X1Tl7abUg2usmH/tMXgCO1T2xMJ5pMdVo=
|
|
67
|
+
</data>
|
|
68
|
+
</dict>
|
|
69
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
|
|
70
|
+
<dict>
|
|
71
|
+
<key>hash2</key>
|
|
72
|
+
<data>
|
|
73
|
+
ZkOsJmUe2aeB5WD1GuZUdld9lUE3ylj3a/SsUvg6dQc=
|
|
74
|
+
</data>
|
|
75
|
+
</dict>
|
|
76
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
|
|
77
|
+
<dict>
|
|
78
|
+
<key>hash2</key>
|
|
79
|
+
<data>
|
|
80
|
+
Mv7Xrct4p8akiY5ZVmrLXbdqvhQEIMA3h8ehioROiLw=
|
|
81
|
+
</data>
|
|
82
|
+
</dict>
|
|
83
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
|
|
84
|
+
<dict>
|
|
85
|
+
<key>hash2</key>
|
|
86
|
+
<data>
|
|
87
|
+
/pK33dHfZ0UPBSuO5lmNiaDINHH+cdjX/PqYzDuOESY=
|
|
88
|
+
</data>
|
|
89
|
+
</dict>
|
|
90
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
|
|
91
|
+
<dict>
|
|
92
|
+
<key>hash2</key>
|
|
93
|
+
<data>
|
|
94
|
+
Mv7Xrct4p8akiY5ZVmrLXbdqvhQEIMA3h8ehioROiLw=
|
|
95
|
+
</data>
|
|
96
|
+
</dict>
|
|
97
|
+
<key>Modules/HawcxFramework.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
|
|
98
|
+
<dict>
|
|
99
|
+
<key>hash2</key>
|
|
100
|
+
<data>
|
|
101
|
+
dtWY1lx1DxCL5PG02nV2ZwOkmr3BwkXgOVu0wHTH9pU=
|
|
102
|
+
</data>
|
|
103
|
+
</dict>
|
|
104
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
|
105
|
+
<dict>
|
|
106
|
+
<key>hash2</key>
|
|
107
|
+
<data>
|
|
108
|
+
ZkOsJmUe2aeB5WD1GuZUdld9lUE3ylj3a/SsUvg6dQc=
|
|
109
|
+
</data>
|
|
110
|
+
</dict>
|
|
111
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
|
112
|
+
<dict>
|
|
113
|
+
<key>hash2</key>
|
|
114
|
+
<data>
|
|
115
|
+
Fg34/gBtUToEiZMqugJ5SsP/FHmt5fjllutl/Ig+xV0=
|
|
116
|
+
</data>
|
|
117
|
+
</dict>
|
|
118
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
|
119
|
+
<dict>
|
|
120
|
+
<key>hash2</key>
|
|
121
|
+
<data>
|
|
122
|
+
cadox45FINAKfq6kYeuF+yayrcUbKvDf98XqCO5JbTI=
|
|
123
|
+
</data>
|
|
124
|
+
</dict>
|
|
125
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
|
|
126
|
+
<dict>
|
|
127
|
+
<key>hash2</key>
|
|
128
|
+
<data>
|
|
129
|
+
Fg34/gBtUToEiZMqugJ5SsP/FHmt5fjllutl/Ig+xV0=
|
|
130
|
+
</data>
|
|
131
|
+
</dict>
|
|
132
|
+
<key>Modules/HawcxFramework.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
|
133
|
+
<dict>
|
|
134
|
+
<key>hash2</key>
|
|
135
|
+
<data>
|
|
136
|
+
AGsl2o2bYvclbHv6dwoT18TizzEuPzGfx5AaYc8hWfk=
|
|
137
|
+
</data>
|
|
138
|
+
</dict>
|
|
139
|
+
<key>Modules/module.modulemap</key>
|
|
140
|
+
<dict>
|
|
141
|
+
<key>hash2</key>
|
|
142
|
+
<data>
|
|
143
|
+
W9eUM/2p5vduDchoWa60u3tCtbiN5hO+kK1pnYGWvIs=
|
|
144
|
+
</data>
|
|
145
|
+
</dict>
|
|
146
|
+
</dict>
|
|
147
|
+
<key>rules</key>
|
|
148
|
+
<dict>
|
|
149
|
+
<key>^.*</key>
|
|
150
|
+
<true/>
|
|
151
|
+
<key>^.*\.lproj/</key>
|
|
152
|
+
<dict>
|
|
153
|
+
<key>optional</key>
|
|
154
|
+
<true/>
|
|
155
|
+
<key>weight</key>
|
|
156
|
+
<real>1000</real>
|
|
157
|
+
</dict>
|
|
158
|
+
<key>^.*\.lproj/locversion.plist$</key>
|
|
159
|
+
<dict>
|
|
160
|
+
<key>omit</key>
|
|
161
|
+
<true/>
|
|
162
|
+
<key>weight</key>
|
|
163
|
+
<real>1100</real>
|
|
164
|
+
</dict>
|
|
165
|
+
<key>^Base\.lproj/</key>
|
|
166
|
+
<dict>
|
|
167
|
+
<key>weight</key>
|
|
168
|
+
<real>1010</real>
|
|
169
|
+
</dict>
|
|
170
|
+
<key>^version.plist$</key>
|
|
171
|
+
<true/>
|
|
172
|
+
</dict>
|
|
173
|
+
<key>rules2</key>
|
|
174
|
+
<dict>
|
|
175
|
+
<key>.*\.dSYM($|/)</key>
|
|
176
|
+
<dict>
|
|
177
|
+
<key>weight</key>
|
|
178
|
+
<real>11</real>
|
|
179
|
+
</dict>
|
|
180
|
+
<key>^(.*/)?\.DS_Store$</key>
|
|
181
|
+
<dict>
|
|
182
|
+
<key>omit</key>
|
|
183
|
+
<true/>
|
|
184
|
+
<key>weight</key>
|
|
185
|
+
<real>2000</real>
|
|
186
|
+
</dict>
|
|
187
|
+
<key>^.*</key>
|
|
188
|
+
<true/>
|
|
189
|
+
<key>^.*\.lproj/</key>
|
|
190
|
+
<dict>
|
|
191
|
+
<key>optional</key>
|
|
192
|
+
<true/>
|
|
193
|
+
<key>weight</key>
|
|
194
|
+
<real>1000</real>
|
|
195
|
+
</dict>
|
|
196
|
+
<key>^.*\.lproj/locversion.plist$</key>
|
|
197
|
+
<dict>
|
|
198
|
+
<key>omit</key>
|
|
199
|
+
<true/>
|
|
200
|
+
<key>weight</key>
|
|
201
|
+
<real>1100</real>
|
|
202
|
+
</dict>
|
|
203
|
+
<key>^Base\.lproj/</key>
|
|
204
|
+
<dict>
|
|
205
|
+
<key>weight</key>
|
|
206
|
+
<real>1010</real>
|
|
207
|
+
</dict>
|
|
208
|
+
<key>^Info\.plist$</key>
|
|
209
|
+
<dict>
|
|
210
|
+
<key>omit</key>
|
|
211
|
+
<true/>
|
|
212
|
+
<key>weight</key>
|
|
213
|
+
<real>20</real>
|
|
214
|
+
</dict>
|
|
215
|
+
<key>^PkgInfo$</key>
|
|
216
|
+
<dict>
|
|
217
|
+
<key>omit</key>
|
|
218
|
+
<true/>
|
|
219
|
+
<key>weight</key>
|
|
220
|
+
<real>20</real>
|
|
221
|
+
</dict>
|
|
222
|
+
<key>^embedded\.provisionprofile$</key>
|
|
223
|
+
<dict>
|
|
224
|
+
<key>weight</key>
|
|
225
|
+
<real>20</real>
|
|
226
|
+
</dict>
|
|
227
|
+
<key>^version\.plist$</key>
|
|
228
|
+
<dict>
|
|
229
|
+
<key>weight</key>
|
|
230
|
+
<real>20</real>
|
|
231
|
+
</dict>
|
|
232
|
+
</dict>
|
|
233
|
+
</dict>
|
|
234
|
+
</plist>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#if __has_include(<React/RCTBridgeModule.h>)
|
|
2
|
+
#import <React/RCTBridgeModule.h>
|
|
3
|
+
#import <React/RCTEventEmitter.h>
|
|
4
|
+
|
|
5
|
+
@interface RCT_EXTERN_MODULE(HawcxReactNative, RCTEventEmitter)
|
|
6
|
+
|
|
7
|
+
RCT_EXTERN_METHOD(initialize:(NSDictionary *)config
|
|
8
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
9
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
10
|
+
|
|
11
|
+
RCT_EXTERN_METHOD(authenticate:(NSString *)userId
|
|
12
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
13
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
14
|
+
|
|
15
|
+
RCT_EXTERN_METHOD(submitOtp:(NSString *)otp
|
|
16
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
17
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
18
|
+
|
|
19
|
+
RCT_EXTERN_METHOD(getDeviceDetails:(RCTPromiseResolveBlock)resolve
|
|
20
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
21
|
+
|
|
22
|
+
RCT_EXTERN_METHOD(webLogin:(NSString *)pin
|
|
23
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
24
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
25
|
+
|
|
26
|
+
RCT_EXTERN_METHOD(webApprove:(NSString *)token
|
|
27
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
28
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
29
|
+
|
|
30
|
+
RCT_EXTERN_METHOD(setApnsDeviceToken:(NSString *)tokenBase64
|
|
31
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
32
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
33
|
+
|
|
34
|
+
RCT_EXTERN_METHOD(userDidAuthenticate:(RCTPromiseResolveBlock)resolve
|
|
35
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
36
|
+
|
|
37
|
+
RCT_EXTERN_METHOD(handlePushNotification:(NSDictionary *)payload
|
|
38
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
39
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
40
|
+
|
|
41
|
+
RCT_EXTERN_METHOD(approvePushRequest:(NSString *)requestId
|
|
42
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
43
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
44
|
+
|
|
45
|
+
RCT_EXTERN_METHOD(declinePushRequest:(NSString *)requestId
|
|
46
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
47
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
48
|
+
|
|
49
|
+
@end
|
|
50
|
+
|
|
51
|
+
#endif
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import HawcxFramework
|
|
3
|
+
|
|
4
|
+
#if canImport(React)
|
|
5
|
+
import React
|
|
6
|
+
|
|
7
|
+
@objc(HawcxReactNative)
|
|
8
|
+
class HawcxReactNative: RCTEventEmitter {
|
|
9
|
+
private let authEventName = "hawcx.auth.event"
|
|
10
|
+
private let sessionEventName = "hawcx.session.event"
|
|
11
|
+
private let pushEventName = "hawcx.push.event"
|
|
12
|
+
private var hawcxSDK: HawcxSDK?
|
|
13
|
+
private var authCallbackProxy: AuthCallbackProxy?
|
|
14
|
+
private var sessionCallbackProxy: SessionCallbackProxy?
|
|
15
|
+
private var pushDelegateProxy: PushDelegateProxy?
|
|
16
|
+
|
|
17
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
18
|
+
true
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override func supportedEvents() -> [String]! {
|
|
24
|
+
[authEventName, sessionEventName, pushEventName]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@objc
|
|
28
|
+
func initialize(_ config: NSDictionary,
|
|
29
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
30
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
31
|
+
guard let projectApiKey = config["projectApiKey"] as? String, !projectApiKey.isEmpty else {
|
|
32
|
+
reject("hawcx.config", "projectApiKey is required", nil)
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var oauthConfig: HawcxOAuthConfig?
|
|
37
|
+
if let oauthDict = config["oauthConfig"] as? [String: Any] {
|
|
38
|
+
do {
|
|
39
|
+
oauthConfig = try makeOAuthConfig(from: oauthDict)
|
|
40
|
+
} catch {
|
|
41
|
+
reject("hawcx.config", error.localizedDescription, error)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
DispatchQueue.main.async {
|
|
47
|
+
self.hawcxSDK = HawcxSDK(projectApiKey: projectApiKey, oauthConfig: oauthConfig)
|
|
48
|
+
self.authCallbackProxy = AuthCallbackProxy(emitter: self)
|
|
49
|
+
self.sessionCallbackProxy = SessionCallbackProxy(emitter: self)
|
|
50
|
+
let pushDelegate = PushDelegateProxy(emitter: self)
|
|
51
|
+
self.pushDelegateProxy = pushDelegate
|
|
52
|
+
self.hawcxSDK?.pushAuthDelegate = pushDelegate
|
|
53
|
+
resolve(nil)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@objc
|
|
58
|
+
func authenticate(_ userId: NSString,
|
|
59
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
60
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
61
|
+
guard let sdk = hawcxSDK else {
|
|
62
|
+
reject("hawcx.sdk", "initialize must be called before authenticate", nil)
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let trimmed = userId.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
67
|
+
guard !trimmed.isEmpty else {
|
|
68
|
+
reject("hawcx.input", "userid cannot be empty", nil)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
guard let callback = authCallbackProxy else {
|
|
73
|
+
reject("hawcx.sdk", "Auth callback not configured", nil)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
DispatchQueue.main.async {
|
|
78
|
+
sdk.authenticateV5(userid: trimmed, callback: callback)
|
|
79
|
+
resolve(nil)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@objc
|
|
84
|
+
func submitOtp(_ otp: NSString,
|
|
85
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
86
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
87
|
+
guard let sdk = hawcxSDK else {
|
|
88
|
+
reject("hawcx.sdk", "initialize must be called before submitOtp", nil)
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
let trimmed = otp.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
92
|
+
guard !trimmed.isEmpty else {
|
|
93
|
+
reject("hawcx.input", "otp cannot be empty", nil)
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
DispatchQueue.main.async {
|
|
97
|
+
sdk.submitOtpV5(otp: trimmed)
|
|
98
|
+
resolve(nil)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@objc
|
|
103
|
+
func getDeviceDetails(_ resolve: @escaping RCTPromiseResolveBlock,
|
|
104
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
105
|
+
guard let sdk = hawcxSDK else {
|
|
106
|
+
reject("hawcx.sdk", "initialize must be called before getDeviceDetails", nil)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
guard let callback = sessionCallbackProxy else {
|
|
110
|
+
reject("hawcx.sdk", "Session callback not configured", nil)
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
DispatchQueue.main.async {
|
|
114
|
+
sdk.getDeviceDetails(callback: callback)
|
|
115
|
+
resolve(nil)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@objc
|
|
120
|
+
func webLogin(_ pin: NSString,
|
|
121
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
122
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
123
|
+
guard let sdk = hawcxSDK else {
|
|
124
|
+
reject("hawcx.sdk", "initialize must be called before webLogin", nil)
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
guard let callback = sessionCallbackProxy else {
|
|
128
|
+
reject("hawcx.sdk", "Session callback not configured", nil)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
let trimmed = pin.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
132
|
+
guard !trimmed.isEmpty else {
|
|
133
|
+
reject("hawcx.input", "pin cannot be empty", nil)
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
DispatchQueue.main.async {
|
|
137
|
+
sdk.webLogin(pin: trimmed, callback: callback)
|
|
138
|
+
resolve(nil)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@objc
|
|
143
|
+
func webApprove(_ token: NSString,
|
|
144
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
145
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
146
|
+
guard let sdk = hawcxSDK else {
|
|
147
|
+
reject("hawcx.sdk", "initialize must be called before webApprove", nil)
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
guard let callback = sessionCallbackProxy else {
|
|
151
|
+
reject("hawcx.sdk", "Session callback not configured", nil)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
let trimmed = token.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
155
|
+
guard !trimmed.isEmpty else {
|
|
156
|
+
reject("hawcx.input", "token cannot be empty", nil)
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
DispatchQueue.main.async {
|
|
160
|
+
sdk.webApprove(token: trimmed, callback: callback)
|
|
161
|
+
resolve(nil)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
fileprivate func emitAuthEvent(_ body: [String: Any]) {
|
|
166
|
+
sendEvent(withName: authEventName, body: body)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
fileprivate func emitSessionEvent(_ body: [String: Any]) {
|
|
170
|
+
sendEvent(withName: sessionEventName, body: body)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
fileprivate func emitPushEvent(_ body: [String: Any]) {
|
|
174
|
+
sendEvent(withName: pushEventName, body: body)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private func makeOAuthConfig(from dict: [String: Any]) throws -> HawcxOAuthConfig {
|
|
178
|
+
guard
|
|
179
|
+
let endpointString = dict["tokenEndpoint"] as? String,
|
|
180
|
+
let endpointURL = URL(string: endpointString),
|
|
181
|
+
let clientId = dict["clientId"] as? String,
|
|
182
|
+
let publicKeyPem = dict["publicKeyPem"] as? String,
|
|
183
|
+
!clientId.isEmpty,
|
|
184
|
+
!publicKeyPem.isEmpty
|
|
185
|
+
else {
|
|
186
|
+
throw HawcxReactNativeError.invalidOAuthConfig
|
|
187
|
+
}
|
|
188
|
+
return HawcxOAuthConfig(tokenEndpoint: endpointURL, clientId: clientId, publicKeyPem: publicKeyPem)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private enum HawcxReactNativeError: LocalizedError {
|
|
193
|
+
case invalidOAuthConfig
|
|
194
|
+
|
|
195
|
+
var errorDescription: String? {
|
|
196
|
+
switch self {
|
|
197
|
+
case .invalidOAuthConfig:
|
|
198
|
+
return "oauthConfig must include tokenEndpoint, clientId, and publicKeyPem"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private final class AuthCallbackProxy: NSObject, AuthV5Callback {
|
|
204
|
+
weak var emitter: HawcxReactNative?
|
|
205
|
+
|
|
206
|
+
init(emitter: HawcxReactNative) {
|
|
207
|
+
self.emitter = emitter
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
func onOtpRequired() {
|
|
211
|
+
emitter?.emitAuthEvent(["type": "otp_required"])
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
func onAuthSuccess(accessToken: String?, refreshToken: String?, isLoginFlow: Bool) {
|
|
215
|
+
var payload: [String: Any] = [
|
|
216
|
+
"isLoginFlow": isLoginFlow
|
|
217
|
+
]
|
|
218
|
+
|
|
219
|
+
if let accessToken {
|
|
220
|
+
payload["accessToken"] = accessToken
|
|
221
|
+
}
|
|
222
|
+
if let refreshToken {
|
|
223
|
+
payload["refreshToken"] = refreshToken
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
emitter?.emitAuthEvent(["type": "auth_success", "payload": payload])
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
func onError(errorCode: AuthV5ErrorCode, errorMessage: String) {
|
|
230
|
+
let payload: [String: Any] = [
|
|
231
|
+
"code": errorCode.rawValue,
|
|
232
|
+
"message": errorMessage
|
|
233
|
+
]
|
|
234
|
+
emitter?.emitAuthEvent(["type": "auth_error", "payload": payload])
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private final class SessionCallbackProxy: NSObject, DevSessionCallback, WebLoginCallback {
|
|
239
|
+
weak var emitter: HawcxReactNative?
|
|
240
|
+
|
|
241
|
+
init(emitter: HawcxReactNative) {
|
|
242
|
+
self.emitter = emitter
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
func onSuccess() {
|
|
246
|
+
emitter?.emitSessionEvent(["type": "session_success"])
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
func showError() {
|
|
250
|
+
emitter?.emitSessionEvent([
|
|
251
|
+
"type": "session_error",
|
|
252
|
+
"payload": [
|
|
253
|
+
"code": "session_error",
|
|
254
|
+
"message": "Failed to fetch device session"
|
|
255
|
+
]
|
|
256
|
+
])
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
func showError(webLoginErrorCode: WebLoginErrorCode, errorMessage: String) {
|
|
260
|
+
emitter?.emitSessionEvent([
|
|
261
|
+
"type": "session_error",
|
|
262
|
+
"payload": [
|
|
263
|
+
"code": webLoginErrorCode.rawValue,
|
|
264
|
+
"message": errorMessage
|
|
265
|
+
]
|
|
266
|
+
])
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private final class PushDelegateProxy: NSObject, HawcxPushAuthDelegate {
|
|
271
|
+
weak var emitter: HawcxReactNative?
|
|
272
|
+
|
|
273
|
+
init(emitter: HawcxReactNative) {
|
|
274
|
+
self.emitter = emitter
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
func hawcx(didReceiveLoginRequest requestId: String, details: PushLoginRequestDetails) {
|
|
278
|
+
var payload: [String: Any] = [
|
|
279
|
+
"requestId": requestId,
|
|
280
|
+
"ipAddress": details.ipAddress,
|
|
281
|
+
"deviceInfo": details.deviceInfo,
|
|
282
|
+
"timestamp": details.timestamp
|
|
283
|
+
]
|
|
284
|
+
if let location = details.location {
|
|
285
|
+
payload["location"] = location
|
|
286
|
+
}
|
|
287
|
+
emitter?.emitPushEvent(["type": "push_login_request", "payload": payload])
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
func hawcx(failedToFetchLoginRequestDetails error: Error) {
|
|
291
|
+
emitter?.emitPushEvent([
|
|
292
|
+
"type": "push_error",
|
|
293
|
+
"payload": [
|
|
294
|
+
"code": "push_error",
|
|
295
|
+
"message": error.localizedDescription
|
|
296
|
+
]
|
|
297
|
+
])
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#else
|
|
302
|
+
|
|
303
|
+
@objc(HawcxReactNative)
|
|
304
|
+
class HawcxReactNative: NSObject {
|
|
305
|
+
override init() {
|
|
306
|
+
super.init()
|
|
307
|
+
assertionFailure("React Native dependency not detected. Link React-Core before using HawcxReactNative.")
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
#endif
|