@regulaforensics/face-sdk 6.3.3-beta

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 (543) hide show
  1. package/README.md +23 -0
  2. package/RNFaceSDK.podspec +21 -0
  3. package/android/CVDFaceSDK.kt +34 -0
  4. package/android/build.gradle +48 -0
  5. package/android/cordova.gradle +18 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/com/regula/plugin/facesdk/Config.kt +165 -0
  8. package/android/src/main/java/com/regula/plugin/facesdk/JSONConstructor.kt +904 -0
  9. package/android/src/main/java/com/regula/plugin/facesdk/Main.kt +370 -0
  10. package/android/src/main/java/com/regula/plugin/facesdk/RNFaceApiModule.kt +54 -0
  11. package/android/src/main/java/com/regula/plugin/facesdk/RNFaceApiPackage.kt +11 -0
  12. package/android/src/main/java/com/regula/plugin/facesdk/Utils.kt +287 -0
  13. package/examples/capacitor/.browserslistrc +6 -0
  14. package/examples/capacitor/.eslintrc.js +17 -0
  15. package/examples/capacitor/README.md +27 -0
  16. package/examples/capacitor/android/app/build.gradle +54 -0
  17. package/examples/capacitor/android/app/capacitor.build.gradle +22 -0
  18. package/examples/capacitor/android/app/proguard-rules.pro +21 -0
  19. package/examples/capacitor/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +26 -0
  20. package/examples/capacitor/android/app/src/main/AndroidManifest.xml +43 -0
  21. package/examples/capacitor/android/app/src/main/java/com/regula/faceapi/MainActivity.java +5 -0
  22. package/examples/capacitor/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  23. package/examples/capacitor/android/app/src/main/res/drawable/splash.png +0 -0
  24. package/examples/capacitor/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
  25. package/examples/capacitor/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
  26. package/examples/capacitor/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
  27. package/examples/capacitor/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
  28. package/examples/capacitor/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
  29. package/examples/capacitor/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
  30. package/examples/capacitor/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
  31. package/examples/capacitor/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
  32. package/examples/capacitor/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
  33. package/examples/capacitor/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
  34. package/examples/capacitor/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  35. package/examples/capacitor/android/app/src/main/res/layout/activity_main.xml +12 -0
  36. package/examples/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  37. package/examples/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  38. package/examples/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  39. package/examples/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
  40. package/examples/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  41. package/examples/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  42. package/examples/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
  43. package/examples/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  44. package/examples/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  45. package/examples/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
  46. package/examples/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  47. package/examples/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  48. package/examples/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
  49. package/examples/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  50. package/examples/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  51. package/examples/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
  52. package/examples/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  53. package/examples/capacitor/android/app/src/main/res/values/ic_launcher_background.xml +4 -0
  54. package/examples/capacitor/android/app/src/main/res/values/strings.xml +7 -0
  55. package/examples/capacitor/android/app/src/main/res/values/styles.xml +22 -0
  56. package/examples/capacitor/android/app/src/main/res/xml/file_paths.xml +5 -0
  57. package/examples/capacitor/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +18 -0
  58. package/examples/capacitor/android/build.gradle +30 -0
  59. package/examples/capacitor/android/capacitor.settings.gradle +15 -0
  60. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  61. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  62. package/examples/capacitor/android/gradle.properties +22 -0
  63. package/examples/capacitor/android/gradlew +244 -0
  64. package/examples/capacitor/android/gradlew.bat +92 -0
  65. package/examples/capacitor/android/settings.gradle +5 -0
  66. package/examples/capacitor/android/variables.gradle +16 -0
  67. package/examples/capacitor/capacitor.config.ts +12 -0
  68. package/examples/capacitor/cypress/e2e/test.cy.ts +6 -0
  69. package/examples/capacitor/cypress/fixtures/example.json +5 -0
  70. package/examples/capacitor/cypress/support/commands.ts +37 -0
  71. package/examples/capacitor/cypress/support/e2e.ts +20 -0
  72. package/examples/capacitor/cypress.config.ts +10 -0
  73. package/examples/capacitor/index.html +106 -0
  74. package/examples/capacitor/ionic.config.json +7 -0
  75. package/examples/capacitor/ios/App/App/App.entitlements +5 -0
  76. package/examples/capacitor/ios/App/App/AppDelegate.swift +49 -0
  77. package/examples/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
  78. package/examples/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
  79. package/examples/capacitor/ios/App/App/Assets.xcassets/Contents.json +6 -0
  80. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
  81. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
  82. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
  83. package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
  84. package/examples/capacitor/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
  85. package/examples/capacitor/ios/App/App/Base.lproj/Main.storyboard +19 -0
  86. package/examples/capacitor/ios/App/App/Info.plist +53 -0
  87. package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +410 -0
  88. package/examples/capacitor/ios/App/App.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  89. package/examples/capacitor/ios/App/App.xcworkspace/contents.xcworkspacedata +10 -0
  90. package/examples/capacitor/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  91. package/examples/capacitor/ios/App/Podfile +27 -0
  92. package/examples/capacitor/package.json +64 -0
  93. package/examples/capacitor/public/assets/.gitkeep +0 -0
  94. package/examples/capacitor/public/assets/img/id.png +0 -0
  95. package/examples/capacitor/public/assets/img/portrait.png +0 -0
  96. package/examples/capacitor/public/favicon.png +0 -0
  97. package/examples/capacitor/public/manifest.json +21 -0
  98. package/examples/capacitor/src/App.test.tsx +8 -0
  99. package/examples/capacitor/src/App.tsx +42 -0
  100. package/examples/capacitor/src/components/ExploreContainer.css +24 -0
  101. package/examples/capacitor/src/components/ExploreContainer.tsx +14 -0
  102. package/examples/capacitor/src/main.tsx +11 -0
  103. package/examples/capacitor/src/pages/Home.tsx +159 -0
  104. package/examples/capacitor/src/setupTests.ts +14 -0
  105. package/examples/capacitor/src/theme/variables.css +242 -0
  106. package/examples/capacitor/src/vite-env.d.ts +1 -0
  107. package/examples/capacitor/tsconfig.json +21 -0
  108. package/examples/capacitor/tsconfig.node.json +9 -0
  109. package/examples/capacitor/vite.config.ts +16 -0
  110. package/examples/cordova/.vscode/launch.json +28 -0
  111. package/examples/cordova/config.xml +37 -0
  112. package/examples/cordova/jsconfig.json +1 -0
  113. package/examples/cordova/package.json +40 -0
  114. package/examples/cordova/www/css/index.css +107 -0
  115. package/examples/cordova/www/img/id.png +0 -0
  116. package/examples/cordova/www/img/logo.png +0 -0
  117. package/examples/cordova/www/img/portrait.png +0 -0
  118. package/examples/cordova/www/index.html +94 -0
  119. package/examples/cordova/www/js/index.js +154 -0
  120. package/examples/ionic/angular.json +187 -0
  121. package/examples/ionic/browserslist +12 -0
  122. package/examples/ionic/config.xml +114 -0
  123. package/examples/ionic/e2e/protractor.conf.js +28 -0
  124. package/examples/ionic/e2e/src/app.e2e-spec.ts +14 -0
  125. package/examples/ionic/e2e/src/app.po.ts +11 -0
  126. package/examples/ionic/e2e/tsconfig.json +13 -0
  127. package/examples/ionic/ionic.config.json +7 -0
  128. package/examples/ionic/karma.conf.js +31 -0
  129. package/examples/ionic/package.json +97 -0
  130. package/examples/ionic/resources/README.md +8 -0
  131. package/examples/ionic/resources/android/icon/drawable-hdpi-icon.png +0 -0
  132. package/examples/ionic/resources/android/icon/drawable-ldpi-icon.png +0 -0
  133. package/examples/ionic/resources/android/icon/drawable-mdpi-icon.png +0 -0
  134. package/examples/ionic/resources/android/icon/drawable-xhdpi-icon.png +0 -0
  135. package/examples/ionic/resources/android/icon/drawable-xxhdpi-icon.png +0 -0
  136. package/examples/ionic/resources/android/icon/drawable-xxxhdpi-icon.png +0 -0
  137. package/examples/ionic/resources/android/splash/drawable-land-hdpi-screen.png +0 -0
  138. package/examples/ionic/resources/android/splash/drawable-land-ldpi-screen.png +0 -0
  139. package/examples/ionic/resources/android/splash/drawable-land-mdpi-screen.png +0 -0
  140. package/examples/ionic/resources/android/splash/drawable-land-xhdpi-screen.png +0 -0
  141. package/examples/ionic/resources/android/splash/drawable-land-xxhdpi-screen.png +0 -0
  142. package/examples/ionic/resources/android/splash/drawable-land-xxxhdpi-screen.png +0 -0
  143. package/examples/ionic/resources/android/splash/drawable-port-hdpi-screen.png +0 -0
  144. package/examples/ionic/resources/android/splash/drawable-port-ldpi-screen.png +0 -0
  145. package/examples/ionic/resources/android/splash/drawable-port-mdpi-screen.png +0 -0
  146. package/examples/ionic/resources/android/splash/drawable-port-xhdpi-screen.png +0 -0
  147. package/examples/ionic/resources/android/splash/drawable-port-xxhdpi-screen.png +0 -0
  148. package/examples/ionic/resources/android/splash/drawable-port-xxxhdpi-screen.png +0 -0
  149. package/examples/ionic/resources/android/xml/network_security_config.xml +6 -0
  150. package/examples/ionic/resources/icon.png +0 -0
  151. package/examples/ionic/resources/ios/icon/icon-1024.png +0 -0
  152. package/examples/ionic/resources/ios/icon/icon-20.png +0 -0
  153. package/examples/ionic/resources/ios/icon/icon-20@2x.png +0 -0
  154. package/examples/ionic/resources/ios/icon/icon-20@3x.png +0 -0
  155. package/examples/ionic/resources/ios/icon/icon-24@2x.png +0 -0
  156. package/examples/ionic/resources/ios/icon/icon-27.5@2x.png +0 -0
  157. package/examples/ionic/resources/ios/icon/icon-29.png +0 -0
  158. package/examples/ionic/resources/ios/icon/icon-29@2x.png +0 -0
  159. package/examples/ionic/resources/ios/icon/icon-29@3x.png +0 -0
  160. package/examples/ionic/resources/ios/icon/icon-40.png +0 -0
  161. package/examples/ionic/resources/ios/icon/icon-40@2x.png +0 -0
  162. package/examples/ionic/resources/ios/icon/icon-40@3x.png +0 -0
  163. package/examples/ionic/resources/ios/icon/icon-44@2x.png +0 -0
  164. package/examples/ionic/resources/ios/icon/icon-50.png +0 -0
  165. package/examples/ionic/resources/ios/icon/icon-50@2x.png +0 -0
  166. package/examples/ionic/resources/ios/icon/icon-60.png +0 -0
  167. package/examples/ionic/resources/ios/icon/icon-60@2x.png +0 -0
  168. package/examples/ionic/resources/ios/icon/icon-60@3x.png +0 -0
  169. package/examples/ionic/resources/ios/icon/icon-72.png +0 -0
  170. package/examples/ionic/resources/ios/icon/icon-72@2x.png +0 -0
  171. package/examples/ionic/resources/ios/icon/icon-76.png +0 -0
  172. package/examples/ionic/resources/ios/icon/icon-76@2x.png +0 -0
  173. package/examples/ionic/resources/ios/icon/icon-83.5@2x.png +0 -0
  174. package/examples/ionic/resources/ios/icon/icon-86@2x.png +0 -0
  175. package/examples/ionic/resources/ios/icon/icon-98@2x.png +0 -0
  176. package/examples/ionic/resources/ios/icon/icon-small.png +0 -0
  177. package/examples/ionic/resources/ios/icon/icon-small@2x.png +0 -0
  178. package/examples/ionic/resources/ios/icon/icon-small@3x.png +0 -0
  179. package/examples/ionic/resources/ios/icon/icon.png +0 -0
  180. package/examples/ionic/resources/ios/icon/icon@2x.png +0 -0
  181. package/examples/ionic/resources/ios/splash/Default-2436h.png +0 -0
  182. package/examples/ionic/resources/ios/splash/Default-568h@2x~iphone.png +0 -0
  183. package/examples/ionic/resources/ios/splash/Default-667h.png +0 -0
  184. package/examples/ionic/resources/ios/splash/Default-736h.png +0 -0
  185. package/examples/ionic/resources/ios/splash/Default-Landscape-2436h.png +0 -0
  186. package/examples/ionic/resources/ios/splash/Default-Landscape-736h.png +0 -0
  187. package/examples/ionic/resources/ios/splash/Default-Landscape@2x~ipad.png +0 -0
  188. package/examples/ionic/resources/ios/splash/Default-Landscape@~ipadpro.png +0 -0
  189. package/examples/ionic/resources/ios/splash/Default-Landscape~ipad.png +0 -0
  190. package/examples/ionic/resources/ios/splash/Default-Portrait@2x~ipad.png +0 -0
  191. package/examples/ionic/resources/ios/splash/Default-Portrait@~ipadpro.png +0 -0
  192. package/examples/ionic/resources/ios/splash/Default-Portrait~ipad.png +0 -0
  193. package/examples/ionic/resources/ios/splash/Default@2x~iphone.png +0 -0
  194. package/examples/ionic/resources/ios/splash/Default@2x~universal~anyany.png +0 -0
  195. package/examples/ionic/resources/ios/splash/Default~iphone.png +0 -0
  196. package/examples/ionic/resources/splash.png +0 -0
  197. package/examples/ionic/src/app/app-routing.module.ts +15 -0
  198. package/examples/ionic/src/app/app.component.html +3 -0
  199. package/examples/ionic/src/app/app.component.scss +0 -0
  200. package/examples/ionic/src/app/app.component.spec.ts +47 -0
  201. package/examples/ionic/src/app/app.component.ts +27 -0
  202. package/examples/ionic/src/app/app.module.ts +23 -0
  203. package/examples/ionic/src/app/home/home.module.ts +29 -0
  204. package/examples/ionic/src/app/home/home.page.html +75 -0
  205. package/examples/ionic/src/app/home/home.page.scss +1 -0
  206. package/examples/ionic/src/app/home/home.page.spec.ts +24 -0
  207. package/examples/ionic/src/app/home/home.page.ts +166 -0
  208. package/examples/ionic/src/assets/icon/favicon.png +0 -0
  209. package/examples/ionic/src/assets/img/portrait.png +0 -0
  210. package/examples/ionic/src/assets/shapes.svg +1 -0
  211. package/examples/ionic/src/environments/environment.prod.ts +3 -0
  212. package/examples/ionic/src/environments/environment.ts +16 -0
  213. package/examples/ionic/src/global.scss +31 -0
  214. package/examples/ionic/src/index.html +25 -0
  215. package/examples/ionic/src/main.ts +12 -0
  216. package/examples/ionic/src/polyfills.ts +66 -0
  217. package/examples/ionic/src/test.ts +20 -0
  218. package/examples/ionic/src/theme/variables.scss +77 -0
  219. package/examples/ionic/src/zone-flags.ts +5 -0
  220. package/examples/ionic/tsconfig.app.json +14 -0
  221. package/examples/ionic/tsconfig.json +26 -0
  222. package/examples/ionic/tsconfig.spec.json +19 -0
  223. package/examples/ionic/tslint.json +88 -0
  224. package/examples/react-native/.vscode/launch.json +26 -0
  225. package/examples/react-native/.watchmanconfig +1 -0
  226. package/examples/react-native/App.tsx +206 -0
  227. package/examples/react-native/Gemfile +8 -0
  228. package/examples/react-native/Gemfile.lock +134 -0
  229. package/examples/react-native/android/app/build.gradle +123 -0
  230. package/examples/react-native/android/app/debug.keystore +0 -0
  231. package/examples/react-native/android/app/proguard-rules.pro +10 -0
  232. package/examples/react-native/android/app/src/debug/AndroidManifest.xml +9 -0
  233. package/examples/react-native/android/app/src/main/AndroidManifest.xml +27 -0
  234. package/examples/react-native/android/app/src/main/assets/.gitkeep +0 -0
  235. package/examples/react-native/android/app/src/main/java/com/regula/face/api/MainActivity.kt +22 -0
  236. package/examples/react-native/android/app/src/main/java/com/regula/face/api/MainApplication.kt +43 -0
  237. package/examples/react-native/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
  238. package/examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  239. package/examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  240. package/examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  241. package/examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  242. package/examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  243. package/examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  244. package/examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  245. package/examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  246. package/examples/react-native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  247. package/examples/react-native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  248. package/examples/react-native/android/app/src/main/res/values/strings.xml +3 -0
  249. package/examples/react-native/android/app/src/main/res/values/styles.xml +9 -0
  250. package/examples/react-native/android/build.gradle +21 -0
  251. package/examples/react-native/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  252. package/examples/react-native/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  253. package/examples/react-native/android/gradle.properties +39 -0
  254. package/examples/react-native/android/gradlew +249 -0
  255. package/examples/react-native/android/gradlew.bat +92 -0
  256. package/examples/react-native/android/settings.gradle +6 -0
  257. package/examples/react-native/images/portrait.png +0 -0
  258. package/examples/react-native/index.js +4 -0
  259. package/examples/react-native/ios/.xcode.env +11 -0
  260. package/examples/react-native/ios/FaceSDK/AppDelegate.h +6 -0
  261. package/examples/react-native/ios/FaceSDK/AppDelegate.mm +31 -0
  262. package/examples/react-native/ios/FaceSDK/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  263. package/examples/react-native/ios/FaceSDK/Images.xcassets/Contents.json +6 -0
  264. package/examples/react-native/ios/FaceSDK/Info.plist +51 -0
  265. package/examples/react-native/ios/FaceSDK/LaunchScreen.storyboard +47 -0
  266. package/examples/react-native/ios/FaceSDK/PrivacyInfo.xcprivacy +38 -0
  267. package/examples/react-native/ios/FaceSDK/main.m +10 -0
  268. package/examples/react-native/ios/FaceSDK.xcodeproj/project.pbxproj +719 -0
  269. package/examples/react-native/ios/FaceSDK.xcodeproj/xcshareddata/xcschemes/FaceSDK.xcscheme +88 -0
  270. package/examples/react-native/ios/FaceSDK.xcworkspace/contents.xcworkspacedata +10 -0
  271. package/examples/react-native/ios/FaceSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  272. package/examples/react-native/ios/FaceSDKTests/FaceSDKTests.m +66 -0
  273. package/examples/react-native/ios/FaceSDKTests/Info.plist +24 -0
  274. package/examples/react-native/ios/Podfile +40 -0
  275. package/examples/react-native/ios/Podfile.lock +1822 -0
  276. package/examples/react-native/ios/license/.gitkeep +0 -0
  277. package/examples/react-native/metro.config.js +15 -0
  278. package/examples/react-native/package-lock.json +13098 -0
  279. package/examples/react-native/package.json +42 -0
  280. package/ios/CVDFaceSDK.h +7 -0
  281. package/ios/CVDFaceSDK.m +34 -0
  282. package/ios/RFSWConfig.h +27 -0
  283. package/ios/RFSWConfig.m +189 -0
  284. package/ios/RFSWJSONConstructor.h +134 -0
  285. package/ios/RFSWJSONConstructor.m +977 -0
  286. package/ios/RFSWMain.h +23 -0
  287. package/ios/RFSWMain.m +352 -0
  288. package/ios/RNFaceSDK.h +8 -0
  289. package/ios/RNFaceSDK.m +42 -0
  290. package/ios-ci/.gitlab-ci.yml +41 -0
  291. package/ios-ci/.sample-env +22 -0
  292. package/ios-ci/README.md +97 -0
  293. package/ios-ci/RegulaDanger/Package.swift +34 -0
  294. package/ios-ci/RegulaDanger/Sources/RegulaDanger/RegulaDanger.swift +44 -0
  295. package/ios-ci/RegulaDanger/Tests/LinuxMain.swift +7 -0
  296. package/ios-ci/RegulaDanger/Tests/RegulaDangerTests/RegulaDangerTests.swift +15 -0
  297. package/ios-ci/RegulaDanger/Tests/RegulaDangerTests/XCTestManifests.swift +9 -0
  298. package/ios-ci/install.sh +9 -0
  299. package/ios-ci/ios_ci/__init__.py +8 -0
  300. package/ios-ci/ios_ci/cli.py +408 -0
  301. package/ios-ci/ios_ci/common/__init__.py +0 -0
  302. package/ios-ci/ios_ci/common/build_index.py +70 -0
  303. package/ios-ci/ios_ci/common/clean_cocoapod.sh +13 -0
  304. package/ios-ci/ios_ci/common/dependency.py +466 -0
  305. package/ios-ci/ios_ci/common/ftp.py +314 -0
  306. package/ios-ci/ios_ci/common/searchpod.sh +6 -0
  307. package/ios-ci/ios_ci/common/wait_for_cocopod.sh +21 -0
  308. package/ios-ci/ios_ci/inject.py +145 -0
  309. package/ios-ci/ios_ci/podspec/__init__.py +0 -0
  310. package/ios-ci/ios_ci/podspec/podspec.py +88 -0
  311. package/ios-ci/ios_ci/podspec/templates/BTDevice.podspec +17 -0
  312. package/ios-ci/ios_ci/podspec/templates/Core.podspec +17 -0
  313. package/ios-ci/ios_ci/podspec/templates/DocumentReader.podspec +19 -0
  314. package/ios-ci/ios_ci/podspec/templates/FaceCore.podspec +17 -0
  315. package/ios-ci/ios_ci/podspec/templates/FaceSDK.podspec +18 -0
  316. package/ios-ci/ios_ci/podspec/templates/IRS.podspec +17 -0
  317. package/ios-ci/ios_ci/podspec/templates/RegulaCommon.podspec +17 -0
  318. package/ios-ci/ios_ci/resolve_podfile_common.py +76 -0
  319. package/ios-ci/ios_ci/spm/AppleRootCA-G3.cer +0 -0
  320. package/ios-ci/ios_ci/spm/AppleWWDRCAG3.cer +0 -0
  321. package/ios-ci/ios_ci/spm/SwiftPackageGenerator+Common.sh +48 -0
  322. package/ios-ci/ios_ci/spm/SwiftPackageGenerator.sh +33 -0
  323. package/ios-ci/ios_ci/spm/XcodeSPMCollection.json +29 -0
  324. package/ios-ci/ios_ci/spm/__init__.py +0 -0
  325. package/ios-ci/ios_ci/spm/askpass.py +19 -0
  326. package/ios-ci/ios_ci/spm/spm.py +227 -0
  327. package/ios-ci/ios_ci/upload_build.py +158 -0
  328. package/ios-ci/ios_ci/version.py +14 -0
  329. package/ios-ci/poetry.lock +342 -0
  330. package/ios-ci/pyproject.toml +26 -0
  331. package/ios-ci/scripts.py +9 -0
  332. package/ios-ci/tests/__init__.py +0 -0
  333. package/ios-ci/tests/podspec/fixtures/BTDevice.podspec +17 -0
  334. package/ios-ci/tests/podspec/fixtures/BTDeviceBeta.podspec +17 -0
  335. package/ios-ci/tests/podspec/fixtures/DocumentReaderBeta_RegulaCommon_Beta.podspec +19 -0
  336. package/ios-ci/tests/podspec/fixtures/DocumentReaderBeta_RegulaCommon_Release.podspec +19 -0
  337. package/ios-ci/tests/podspec/fixtures/DocumentReaderFullRFID.podspec +17 -0
  338. package/ios-ci/tests/podspec/fixtures/DocumentReaderFullRFIDBeta.podspec +17 -0
  339. package/ios-ci/tests/podspec/fixtures/DocumentReader_RegulaCommon_Beta.podspec +19 -0
  340. package/ios-ci/tests/podspec/fixtures/DocumentReader_RegulaCommon_Release.podspec +19 -0
  341. package/ios-ci/tests/podspec/fixtures/FaceSDK.podspec +18 -0
  342. package/ios-ci/tests/podspec/fixtures/FaceSDKBeta.podspec +18 -0
  343. package/ios-ci/tests/podspec/fixtures/IRS.podspec +17 -0
  344. package/ios-ci/tests/podspec/fixtures/IRSBeta.podspec +17 -0
  345. package/ios-ci/tests/podspec/fixtures/RegulaCommon.podspec +17 -0
  346. package/ios-ci/tests/podspec/fixtures/RegulaCommonBeta.podspec +17 -0
  347. package/ios-ci/tests/podspec/test_podspec.py +188 -0
  348. package/ios-ci/tests/test_build_index.py +117 -0
  349. package/ios-ci/tests/test_dependency.py +139 -0
  350. package/ios-ci/tests/test_ios_ci.py +5 -0
  351. package/package.json +36 -0
  352. package/plugin.xml +48 -0
  353. package/www/capacitor/customization/camera_position.js +4 -0
  354. package/www/capacitor/customization/customization.js +66 -0
  355. package/www/capacitor/customization/customization_colors.js +233 -0
  356. package/www/capacitor/customization/customization_fonts.js +106 -0
  357. package/www/capacitor/customization/customization_images.js +129 -0
  358. package/www/capacitor/customization/font.js +23 -0
  359. package/www/capacitor/customization/screen_orientation.js +4 -0
  360. package/www/capacitor/detect_faces/detect_face_result.js +38 -0
  361. package/www/capacitor/detect_faces/detect_faces_attribute.js +15 -0
  362. package/www/capacitor/detect_faces/detect_faces_attribute_result.js +20 -0
  363. package/www/capacitor/detect_faces/detect_faces_backend_exception.js +23 -0
  364. package/www/capacitor/detect_faces/detect_faces_config.js +14 -0
  365. package/www/capacitor/detect_faces/detect_faces_exception.js +30 -0
  366. package/www/capacitor/detect_faces/detect_faces_request.js +67 -0
  367. package/www/capacitor/detect_faces/detect_faces_response.js +24 -0
  368. package/www/capacitor/detect_faces/detect_faces_scenario.js +10 -0
  369. package/www/capacitor/face_capture/face_capture_config.js +28 -0
  370. package/www/capacitor/face_capture/face_capture_exception.js +25 -0
  371. package/www/capacitor/face_capture/face_capture_image.js +26 -0
  372. package/www/capacitor/face_capture/face_capture_response.js +17 -0
  373. package/www/capacitor/image_params/output_image_crop.js +21 -0
  374. package/www/capacitor/image_params/output_image_params.js +9 -0
  375. package/www/capacitor/image_params/point.js +14 -0
  376. package/www/capacitor/image_params/rect.js +18 -0
  377. package/www/capacitor/image_params/size.js +9 -0
  378. package/www/capacitor/image_quality/image_quality_characteristic.js +24 -0
  379. package/www/capacitor/image_quality/image_quality_characteristic_name.js +58 -0
  380. package/www/capacitor/image_quality/image_quality_group.js +332 -0
  381. package/www/capacitor/image_quality/image_quality_range.js +26 -0
  382. package/www/capacitor/image_quality/image_quality_result.js +40 -0
  383. package/www/capacitor/index.js +219 -0
  384. package/www/capacitor/init/face_sdk_version.js +16 -0
  385. package/www/capacitor/init/init_config.js +9 -0
  386. package/www/capacitor/init/init_exception.js +29 -0
  387. package/www/capacitor/init/license_exception.js +29 -0
  388. package/www/capacitor/internal/bridge.js +39 -0
  389. package/www/capacitor/internal/cordova.js +17 -0
  390. package/www/capacitor/internal/webpack.config.js +11 -0
  391. package/www/capacitor/liveness/liveness_backend_exception.js +38 -0
  392. package/www/capacitor/liveness/liveness_config.js +54 -0
  393. package/www/capacitor/liveness/liveness_exception.js +35 -0
  394. package/www/capacitor/liveness/liveness_notification.js +34 -0
  395. package/www/capacitor/liveness/liveness_response.js +30 -0
  396. package/www/capacitor/match_faces/compared_face.js +21 -0
  397. package/www/capacitor/match_faces/compared_faces_pair.js +23 -0
  398. package/www/capacitor/match_faces/compared_faces_split.js +22 -0
  399. package/www/capacitor/match_faces/match_faces_backend_exception.js +14 -0
  400. package/www/capacitor/match_faces/match_faces_config.js +12 -0
  401. package/www/capacitor/match_faces/match_faces_detection.js +25 -0
  402. package/www/capacitor/match_faces/match_faces_detection_face.js +28 -0
  403. package/www/capacitor/match_faces/match_faces_exception.js +30 -0
  404. package/www/capacitor/match_faces/match_faces_image.js +25 -0
  405. package/www/capacitor/match_faces/match_faces_request.js +13 -0
  406. package/www/capacitor/match_faces/match_faces_response.js +28 -0
  407. package/www/capacitor/person_database/edit_group_persons_request.js +9 -0
  408. package/www/capacitor/person_database/image_upload.js +16 -0
  409. package/www/capacitor/person_database/pageable_item_list.js +22 -0
  410. package/www/capacitor/person_database/person.js +22 -0
  411. package/www/capacitor/person_database/person_database.js +145 -0
  412. package/www/capacitor/person_database/person_group.js +18 -0
  413. package/www/capacitor/person_database/person_image.js +22 -0
  414. package/www/capacitor/person_database/search_person.js +31 -0
  415. package/www/capacitor/person_database/search_person_detection.js +22 -0
  416. package/www/capacitor/person_database/search_person_image.js +26 -0
  417. package/www/capacitor/person_database/search_person_request.js +17 -0
  418. package/www/cordova.js +3738 -0
  419. package/www/react-native/customization/camera_position.js +4 -0
  420. package/www/react-native/customization/customization.js +66 -0
  421. package/www/react-native/customization/customization_colors.js +233 -0
  422. package/www/react-native/customization/customization_fonts.js +106 -0
  423. package/www/react-native/customization/customization_images.js +129 -0
  424. package/www/react-native/customization/font.js +23 -0
  425. package/www/react-native/customization/screen_orientation.js +4 -0
  426. package/www/react-native/detect_faces/detect_face_result.js +38 -0
  427. package/www/react-native/detect_faces/detect_faces_attribute.js +15 -0
  428. package/www/react-native/detect_faces/detect_faces_attribute_result.js +20 -0
  429. package/www/react-native/detect_faces/detect_faces_backend_exception.js +23 -0
  430. package/www/react-native/detect_faces/detect_faces_config.js +14 -0
  431. package/www/react-native/detect_faces/detect_faces_exception.js +30 -0
  432. package/www/react-native/detect_faces/detect_faces_request.js +67 -0
  433. package/www/react-native/detect_faces/detect_faces_response.js +24 -0
  434. package/www/react-native/detect_faces/detect_faces_scenario.js +10 -0
  435. package/www/react-native/face_capture/face_capture_config.js +28 -0
  436. package/www/react-native/face_capture/face_capture_exception.js +25 -0
  437. package/www/react-native/face_capture/face_capture_image.js +26 -0
  438. package/www/react-native/face_capture/face_capture_response.js +17 -0
  439. package/www/react-native/image_params/output_image_crop.js +21 -0
  440. package/www/react-native/image_params/output_image_params.js +9 -0
  441. package/www/react-native/image_params/point.js +14 -0
  442. package/www/react-native/image_params/rect.js +18 -0
  443. package/www/react-native/image_params/size.js +9 -0
  444. package/www/react-native/image_quality/image_quality_characteristic.js +24 -0
  445. package/www/react-native/image_quality/image_quality_characteristic_name.js +58 -0
  446. package/www/react-native/image_quality/image_quality_group.js +332 -0
  447. package/www/react-native/image_quality/image_quality_range.js +26 -0
  448. package/www/react-native/image_quality/image_quality_result.js +40 -0
  449. package/www/react-native/index.js +219 -0
  450. package/www/react-native/init/face_sdk_version.js +16 -0
  451. package/www/react-native/init/init_config.js +9 -0
  452. package/www/react-native/init/init_exception.js +29 -0
  453. package/www/react-native/init/license_exception.js +29 -0
  454. package/www/react-native/internal/bridge.js +39 -0
  455. package/www/react-native/liveness/liveness_backend_exception.js +38 -0
  456. package/www/react-native/liveness/liveness_config.js +54 -0
  457. package/www/react-native/liveness/liveness_exception.js +35 -0
  458. package/www/react-native/liveness/liveness_notification.js +34 -0
  459. package/www/react-native/liveness/liveness_response.js +30 -0
  460. package/www/react-native/match_faces/compared_face.js +21 -0
  461. package/www/react-native/match_faces/compared_faces_pair.js +23 -0
  462. package/www/react-native/match_faces/compared_faces_split.js +22 -0
  463. package/www/react-native/match_faces/match_faces_backend_exception.js +14 -0
  464. package/www/react-native/match_faces/match_faces_config.js +12 -0
  465. package/www/react-native/match_faces/match_faces_detection.js +25 -0
  466. package/www/react-native/match_faces/match_faces_detection_face.js +28 -0
  467. package/www/react-native/match_faces/match_faces_exception.js +30 -0
  468. package/www/react-native/match_faces/match_faces_image.js +25 -0
  469. package/www/react-native/match_faces/match_faces_request.js +13 -0
  470. package/www/react-native/match_faces/match_faces_response.js +28 -0
  471. package/www/react-native/person_database/edit_group_persons_request.js +9 -0
  472. package/www/react-native/person_database/image_upload.js +16 -0
  473. package/www/react-native/person_database/pageable_item_list.js +22 -0
  474. package/www/react-native/person_database/person.js +22 -0
  475. package/www/react-native/person_database/person_database.js +145 -0
  476. package/www/react-native/person_database/person_group.js +18 -0
  477. package/www/react-native/person_database/person_image.js +22 -0
  478. package/www/react-native/person_database/search_person.js +31 -0
  479. package/www/react-native/person_database/search_person_detection.js +22 -0
  480. package/www/react-native/person_database/search_person_image.js +26 -0
  481. package/www/react-native/person_database/search_person_request.js +17 -0
  482. package/www/types/customization/camera_position.d.ts +4 -0
  483. package/www/types/customization/customization.d.ts +24 -0
  484. package/www/types/customization/customization_colors.d.ts +31 -0
  485. package/www/types/customization/customization_fonts.d.ts +17 -0
  486. package/www/types/customization/customization_images.d.ts +18 -0
  487. package/www/types/customization/font.d.ts +14 -0
  488. package/www/types/customization/screen_orientation.d.ts +4 -0
  489. package/www/types/detect_faces/detect_face_result.d.ts +16 -0
  490. package/www/types/detect_faces/detect_faces_attribute.d.ts +15 -0
  491. package/www/types/detect_faces/detect_faces_attribute_result.d.ts +11 -0
  492. package/www/types/detect_faces/detect_faces_backend_exception.d.ts +15 -0
  493. package/www/types/detect_faces/detect_faces_config.d.ts +19 -0
  494. package/www/types/detect_faces/detect_faces_exception.d.ts +21 -0
  495. package/www/types/detect_faces/detect_faces_request.d.ts +27 -0
  496. package/www/types/detect_faces/detect_faces_response.d.ts +12 -0
  497. package/www/types/detect_faces/detect_faces_scenario.d.ts +10 -0
  498. package/www/types/face_capture/face_capture_config.d.ts +30 -0
  499. package/www/types/face_capture/face_capture_exception.d.ts +17 -0
  500. package/www/types/face_capture/face_capture_image.d.ts +15 -0
  501. package/www/types/face_capture/face_capture_response.d.ts +9 -0
  502. package/www/types/image_params/output_image_crop.d.ts +25 -0
  503. package/www/types/image_params/output_image_params.d.ts +13 -0
  504. package/www/types/image_params/point.d.ts +6 -0
  505. package/www/types/image_params/rect.d.ts +8 -0
  506. package/www/types/image_params/size.d.ts +6 -0
  507. package/www/types/image_quality/image_quality_characteristic.d.ts +4 -0
  508. package/www/types/image_quality/image_quality_characteristic_name.d.ts +58 -0
  509. package/www/types/image_quality/image_quality_group.d.ts +155 -0
  510. package/www/types/image_quality/image_quality_range.d.ts +8 -0
  511. package/www/types/image_quality/image_quality_result.d.ts +30 -0
  512. package/www/types/index.d.ts +159 -0
  513. package/www/types/init/face_sdk_version.d.ts +7 -0
  514. package/www/types/init/init_config.d.ts +7 -0
  515. package/www/types/init/init_exception.d.ts +20 -0
  516. package/www/types/init/license_exception.d.ts +21 -0
  517. package/www/types/liveness/liveness_backend_exception.d.ts +30 -0
  518. package/www/types/liveness/liveness_config.d.ts +56 -0
  519. package/www/types/liveness/liveness_exception.d.ts +26 -0
  520. package/www/types/liveness/liveness_notification.d.ts +28 -0
  521. package/www/types/liveness/liveness_response.d.ts +18 -0
  522. package/www/types/match_faces/compared_face.d.ts +11 -0
  523. package/www/types/match_faces/compared_faces_pair.d.ts +12 -0
  524. package/www/types/match_faces/compared_faces_split.d.ts +8 -0
  525. package/www/types/match_faces/match_faces_backend_exception.d.ts +6 -0
  526. package/www/types/match_faces/match_faces_config.d.ts +14 -0
  527. package/www/types/match_faces/match_faces_detection.d.ts +12 -0
  528. package/www/types/match_faces/match_faces_detection_face.d.ts +13 -0
  529. package/www/types/match_faces/match_faces_exception.d.ts +21 -0
  530. package/www/types/match_faces/match_faces_image.d.ts +16 -0
  531. package/www/types/match_faces/match_faces_request.d.ts +18 -0
  532. package/www/types/match_faces/match_faces_response.d.ts +12 -0
  533. package/www/types/person_database/edit_group_persons_request.d.ts +8 -0
  534. package/www/types/person_database/image_upload.d.ts +6 -0
  535. package/www/types/person_database/pageable_item_list.d.ts +7 -0
  536. package/www/types/person_database/person.d.ts +10 -0
  537. package/www/types/person_database/person_database.d.ts +92 -0
  538. package/www/types/person_database/person_group.d.ts +8 -0
  539. package/www/types/person_database/person_image.d.ts +10 -0
  540. package/www/types/person_database/search_person.d.ts +15 -0
  541. package/www/types/person_database/search_person_detection.d.ts +11 -0
  542. package/www/types/person_database/search_person_image.d.ts +12 -0
  543. package/www/types/person_database/search_person_request.d.ts +15 -0
@@ -0,0 +1,977 @@
1
+ #import "RFSWJSONConstructor.h"
2
+ @import FaceSDK.Private;
3
+ #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
4
+
5
+ @implementation RFSWJSONConstructor
6
+
7
+ #pragma mark - Utils
8
+
9
+ +(id)toSendable:(id)input {
10
+ if (!input || [input isEqual:[NSNull null]]) return nil;
11
+ if ([input isKindOfClass:[NSDictionary class]] || [input isKindOfClass:[NSArray class]])
12
+ return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:input
13
+ options:NSJSONWritingPrettyPrinted
14
+ error:nil]
15
+ encoding:NSUTF8StringEncoding];
16
+ return input;
17
+ }
18
+
19
+ +(id)convertArray:(NSArray*)input :(SEL)converter {
20
+ NSMutableArray* result = @[].mutableCopy;
21
+ for (id item in input)
22
+ [result addObject:[RFSWJSONConstructor performSelector:converter withObject:item]];
23
+ return result;
24
+ }
25
+
26
+ +(id)generateArray:(NSArray*)input :(SEL)toJson {
27
+ if (!input) return [NSNull null];
28
+ return [self convertArray:input :toJson];
29
+ }
30
+
31
+ +(id)arrayFromJSON:(NSArray*)input :(SEL)fromJson {
32
+ if (!input || [input isEqual:[NSNull null]]) return nil;
33
+ return [self convertArray:input :fromJson];
34
+ }
35
+
36
+ +(id)base64Decode:(NSString*)input {
37
+ if (!input || [input isEqual:[NSNull null]]) return nil;
38
+ if ([input hasPrefix:@"data"]) input = [input substringFromIndex:[input rangeOfString:@","].location + 1];
39
+ return [[NSData alloc] initWithBase64EncodedString:input options:0];
40
+ }
41
+
42
+ +(id)base64Encode:(NSData*)input {
43
+ if (!input) return [NSNull null];
44
+ return [input base64EncodedStringWithOptions:0];
45
+ }
46
+
47
+ +(id)imageWithBase64:(NSString*)input {
48
+ if (!input || [input isEqual:[NSNull null]]) return nil;
49
+ return [UIImage imageWithData:[self base64Decode:input]];
50
+ }
51
+
52
+ +(id)base64WithImage:(UIImage*)input {
53
+ if (!input) return [NSNull null];
54
+ return [self base64Encode: UIImagePNGRepresentation(input)];
55
+ }
56
+
57
+ #pragma mark - Config
58
+
59
+ +(id)fontFromJSON:(NSDictionary*)input {
60
+ return [UIFont fontWithName:input[@"name"]
61
+ size:[input[@"size"] integerValue]];
62
+ }
63
+
64
+ +(RFSLivenessStepSkip)livenessStepSkipFromJSON:(NSArray<NSNumber*>*)input {
65
+ // same as input.contains(1)
66
+ bool start = CFArrayContainsValue((__bridge CFArrayRef)input, CFRangeMake(0, input.count), (CFNumberRef)@0);
67
+ bool done = CFArrayContainsValue((__bridge CFArrayRef)input, CFRangeMake(0, input.count), (CFNumberRef)@1);
68
+
69
+ if (start && !done) return RFSLivenessStepSkipOnboarding;
70
+ if (done && !start) return RFSLivenessStepSkipSuccess;
71
+ if (start && done) return RFSLivenessStepSkipOnboarding | RFSLivenessStepSkipSuccess;
72
+
73
+ return RFSLivenessStepSkipNone;
74
+ }
75
+
76
+ +(NSArray<NSNumber*>*)generateLivenessStepSkip:(RFSLivenessStepSkip)input {
77
+ if(input == RFSLivenessStepSkipOnboarding) return @[@0];
78
+ if(input == RFSLivenessStepSkipSuccess) return @[@1];
79
+ if(input == (RFSLivenessStepSkipOnboarding | RFSLivenessStepSkipSuccess)) return @[@0, @1];
80
+ return @[];
81
+ }
82
+
83
+ +(id)colorWithInt:(NSNumber*)input {
84
+ if (!input || [input isEqual:[NSNull null]]) return nil;
85
+ // Convert hex int to hex string
86
+ NSInteger hexInt = [input integerValue];
87
+ NSString* numbers = @"0123456789ABCDEF";
88
+ NSString* hexString = @"";
89
+ while (hexInt>0){
90
+ int digit = hexInt % 16;
91
+ hexString = [NSString stringWithFormat:@"%@%@", [numbers substringWithRange:NSMakeRange(digit, 1)], hexString];
92
+ hexInt = hexInt/16;
93
+ }
94
+ // If we use int, then all the starting zeros are lost: 0x0F123456 == 0xF123456
95
+ if (hexString.length == 5 || hexString.length == 7)
96
+ hexString = [NSString stringWithFormat:@"0%@", hexString];
97
+ hexString = [NSString stringWithFormat:@"#%@", hexString];
98
+
99
+ // Convert hex string to UIColor
100
+ NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString];
101
+ CGFloat alpha, red, blue, green;
102
+ switch ([colorString length]) {
103
+ case 3: // #RGB
104
+ alpha = 1.0f;
105
+ red = [self colorComponentFrom: colorString start: 0 length: 1];
106
+ green = [self colorComponentFrom: colorString start: 1 length: 1];
107
+ blue = [self colorComponentFrom: colorString start: 2 length: 1];
108
+ break;
109
+ case 4: // #ARGB
110
+ alpha = [self colorComponentFrom: colorString start: 0 length: 1];
111
+ red = [self colorComponentFrom: colorString start: 1 length: 1];
112
+ green = [self colorComponentFrom: colorString start: 2 length: 1];
113
+ blue = [self colorComponentFrom: colorString start: 3 length: 1];
114
+ break;
115
+ case 6: // #RRGGBB
116
+ alpha = 1.0f;
117
+ red = [self colorComponentFrom: colorString start: 0 length: 2];
118
+ green = [self colorComponentFrom: colorString start: 2 length: 2];
119
+ blue = [self colorComponentFrom: colorString start: 4 length: 2];
120
+ break;
121
+ case 8: // #AARRGGBB
122
+ alpha = [self colorComponentFrom: colorString start: 0 length: 2];
123
+ red = [self colorComponentFrom: colorString start: 2 length: 2];
124
+ green = [self colorComponentFrom: colorString start: 4 length: 2];
125
+ blue = [self colorComponentFrom: colorString start: 6 length: 2];
126
+ break;
127
+ default:
128
+ [NSException raise:@"Invalid color value" format: @"Color value %@ is invalid. It should be a hex value of the form #RBG, #ARGB, #RRGGBB, or #AARRGGBB", hexString];
129
+ break;
130
+ }
131
+ return [UIColor colorWithRed:red green: green blue: blue alpha: alpha];
132
+ }
133
+
134
+ +(CGFloat)colorComponentFrom:(NSString*)string start:(NSUInteger)start length:(NSUInteger)length {
135
+ NSString *substring = [string substringWithRange: NSMakeRange(start, length)];
136
+ NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring];
137
+ unsigned hexComponent;
138
+ [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent];
139
+ return hexComponent / 255.0;
140
+ }
141
+
142
+ +(id)intWithColor:(UIColor*)input {
143
+ if (!input) return [NSNull null];
144
+
145
+ const CGFloat *components = CGColorGetComponents(input.CGColor);
146
+ CGFloat r = components[0];
147
+ CGFloat g = components[1];
148
+ CGFloat b = components[2];
149
+ CGFloat a = components[3];
150
+
151
+ NSString* hexString = [NSString stringWithFormat:@"#%02lX%02lX%02lX%02lX",
152
+ lroundf(a * 255),
153
+ lroundf(r * 255),
154
+ lroundf(g * 255),
155
+ lroundf(b * 255)];
156
+
157
+ unsigned int hexInt = 0;
158
+ NSScanner *scanner = [NSScanner scannerWithString:hexString];
159
+ [scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@"#"]];
160
+ [scanner scanHexInt:&hexInt];
161
+
162
+ return [NSNumber numberWithInteger:hexInt];
163
+ }
164
+
165
+ #pragma mark - Init
166
+
167
+ +(id)generateError:(NSError*)input {
168
+ if (!input) return [NSNull null];
169
+ NSMutableDictionary* result = @{
170
+ @"code":@(input.code),
171
+ @"underlyingError":[self generateUnderlyingError:input]
172
+ }.mutableCopy;
173
+ if (input.localizedDescription) result[@"message"] = input.localizedDescription;
174
+ return result;
175
+ }
176
+
177
+ +(id)generateUnderlyingError:(NSError*)input {
178
+ NSError* tempError = input.userInfo[NSUnderlyingErrorKey];
179
+ if (!tempError) return [NSNull null];
180
+ RFSBackendError* error = tempError.userInfo[NSUnderlyingErrorKey];
181
+ if (!error) return [NSNull null];
182
+ NSMutableDictionary* result = @{ @"code":@(error.code) }.mutableCopy;
183
+ if (error.userInfo[RFSBackendErrorOriginalMessageKey]) result[@"message"] =error.userInfo[RFSBackendErrorOriginalMessageKey];
184
+ return result;
185
+ }
186
+
187
+ +(id)faceSDKVersionFromJSON:(NSDictionary*)input {
188
+ if (!input || [input isEqual:[NSNull null]]) return nil;
189
+ RFSFaceSDKVersion* result = [RFSFaceSDKVersion new];
190
+
191
+ [result setValue:input[@"api"] forKey:@"api"];
192
+ [result setValue:input[@"core"] forKey:@"core"];
193
+ [result setValue:input[@"coreMode"] forKey:@"coreMode"];
194
+
195
+ return result;
196
+ }
197
+
198
+ +(id)generateFaceSDKVersion:(RFSFaceSDKVersion*)input {
199
+ if (!input) return [NSNull null];
200
+ NSMutableDictionary* result = @{}.mutableCopy;
201
+
202
+ if (input.api) result[@"api"] = input.api;
203
+ if (input.core) result[@"core"] = input.core;
204
+ if (input.coreMode) result[@"coreMode"] = input.coreMode;
205
+
206
+ return result;
207
+ }
208
+
209
+ +(id)generateInitCompletion:(BOOL)success :(NSError*)error {
210
+ return @{
211
+ @"success":@(success),
212
+ @"error":[self generateError:error]
213
+ };
214
+ }
215
+
216
+ +(id)initConfigFromJSON:(NSDictionary*)input {
217
+ if (!input || [input isEqual:[NSNull null]]) return nil;
218
+ return [RFSInitializationConfiguration configurationWithBuilder:^(RFSInitializationConfigurationBuilder * builder) {
219
+ [builder setLicenseData:[self base64Decode:input[@"license"]]];
220
+ if (input[@"licenseUpdate"]) [builder setLicenseUpdate:[input[@"licenseUpdate"] boolValue]];
221
+ }];
222
+ }
223
+
224
+ +(id)generateInitConfig:(RFSInitializationConfiguration*)input {
225
+ return @{
226
+ @"license":[self base64Encode:input.licenseData],
227
+ @"licenseUpdate":@(input.licenseUpdate)
228
+ };
229
+ }
230
+
231
+ +(id)generateVideoEncoderCompletion:(NSString*)transactionId :(BOOL)success {
232
+ NSMutableDictionary* result = @{
233
+ @"success":@(success)
234
+ }.mutableCopy;
235
+ if (transactionId) result[@"transactionId"] = transactionId;
236
+ return result;
237
+ }
238
+
239
+ #pragma mark - FaceCapture
240
+
241
+ +(id)faceCaptureImageFromJSON:(NSDictionary*)input {
242
+ if (!input) return nil;
243
+ RFSImage* result = [[RFSImage alloc] initWithImage:[self imageWithBase64:input[@"image"]]
244
+ type:[input[@"imageType"] integerValue]];
245
+ [result setValue:input[@"tag"] forKey:@"identifier"];
246
+ return result;
247
+ }
248
+
249
+ +(id)generateFaceCaptureImage:(RFSImage*)input {
250
+ if (!input) return [NSNull null];
251
+ return @{
252
+ @"imageType":@(input.imageType),
253
+ @"image":[self base64WithImage:input.image],
254
+ @"tag":input.identifier,
255
+ };
256
+ }
257
+
258
+ +(id)faceCaptureResponseFromJSON:(NSDictionary*)input {
259
+ return [[RFSFaceCaptureResponse alloc] performSelector:NSSelectorFromString(@"initWithImage:error:")
260
+ withObject:[self faceCaptureImageFromJSON:input[@"image"]]
261
+ withObject:nil];
262
+ }
263
+
264
+ +(id)generateFaceCaptureResponse:(RFSFaceCaptureResponse*)input {
265
+ return @{
266
+ @"image":[self generateFaceCaptureImage:input.image],
267
+ @"error":[self generateError:input.error]
268
+ };
269
+ }
270
+
271
+ #pragma mark - Liveness
272
+
273
+ +(id)livenessResponseFromJSON:(NSDictionary*)input {
274
+ RFSLivenessResponse* result = [RFSLivenessResponse alloc];
275
+ SEL sel = NSSelectorFromString(@"initWithTag:transactionId:estimatedAge:status:normalImage:scaledImage:error:");
276
+ IMP imp = [result methodForSelector:sel];
277
+ void (*func)(id, SEL, id, id, id, NSInteger, id, id, id) = (void *)imp;
278
+ func(result,
279
+ sel,
280
+ input[@"tag"],
281
+ input[@"transactionId"],
282
+ input[@"estimatedAge"],
283
+ [input[@"liveness"] integerValue],
284
+ [self imageWithBase64:input[@"image"]],
285
+ [self imageWithBase64:input[@"image"]],
286
+ nil);
287
+ return result;
288
+ }
289
+
290
+ +(id)generateLivenessResponse:(RFSLivenessResponse*)input {
291
+ if (!input) return [NSNull null];
292
+ NSMutableDictionary* result = @{
293
+ @"image":[self base64WithImage:input.image],
294
+ @"liveness":@(input.liveness),
295
+ @"error":[self generateError:input.error],
296
+ }.mutableCopy;
297
+ if (input.estimatedAge) result[@"estimatedAge"] = input.estimatedAge;
298
+ if (input.tag) result[@"tag"] = input.tag;
299
+ if (input.transactionId) result[@"transactionId"] = input.transactionId;
300
+ return result;
301
+ }
302
+
303
+ +(id)generateLivenessNotification:(RFSLivenessProcessStatus)status result:(RFSLivenessResponse*)response {
304
+ return @{
305
+ @"status":@(status),
306
+ @"result":[self generateLivenessResponse:response]
307
+ };
308
+ }
309
+
310
+ #pragma mark - MatchFaces
311
+
312
+ +(id)matchFacesImageFromJSON:(NSDictionary*)input {
313
+ bool detectAll = false;
314
+ if (input[@"detectAll"]) detectAll = input[@"detectAll"];
315
+ RFSMatchFacesImage* result = [[RFSMatchFacesImage alloc] initWithImage:[self imageWithBase64:input[@"image"]]
316
+ imageType:[input[@"imageType"] integerValue]
317
+ detectAll:detectAll];
318
+ if (input[@"identifier"]) [result setValue:input[@"identifier"] forKey:@"identifier"];
319
+ return result;
320
+ }
321
+
322
+ +(id)generateMatchFacesImage:(RFSMatchFacesImage*)input {
323
+ return @{
324
+ @"imageType":@(input.imageType),
325
+ @"image":[self base64WithImage:input.image],
326
+ @"detectAll":@(input.detectAll),
327
+ @"identifier":input.identifier
328
+ };
329
+ }
330
+
331
+ +(CGSize)sizeFromJSON:(NSDictionary*)input {
332
+ if (!input) return CGSizeZero;
333
+ return CGSizeMake([input[@"width"] floatValue],
334
+ [input[@"height"] floatValue]);
335
+ }
336
+
337
+ +(id)generateSize:(CGSize)input {
338
+ if (CGSizeEqualToSize(input, CGSizeZero)) return [NSNull null];
339
+ // this is default size that is created in sdk if you pass null
340
+ if (CGSizeEqualToSize(input, CGSizeMake(60, 80))) return [NSNull null];
341
+ return @{
342
+ @"width": @(input.width),
343
+ @"height":@(input.height)
344
+ };
345
+ }
346
+
347
+ +(id)outputImageCropFromJSON:(NSDictionary*)input {
348
+ if (!input || [input isEqual:[NSNull null]]) return nil;
349
+ bool returnOriginalRect = false;
350
+ if (input[@"returnOriginalRect"]) returnOriginalRect = [input[@"returnOriginalRect"] boolValue];
351
+ return [[RFSOutputImageCrop alloc] initWithType:[input[@"type"] integerValue]
352
+ size:[self sizeFromJSON:input[@"size"]]
353
+ padColor:[self colorWithInt:input[@"padColor"]]
354
+ returnOriginalRect:returnOriginalRect];
355
+ }
356
+
357
+ +(id)generateOutputImageCrop:(RFSOutputImageCrop*)input {
358
+ if (!input) return [NSNull null];
359
+ return @{
360
+ @"type": @(input.type),
361
+ @"size": [self generateSize:input.size],
362
+ @"padColor": [self intWithColor:input.padColor],
363
+ @"returnOriginalRect": @(input.returnOriginalRect)
364
+ };
365
+ }
366
+
367
+ +(id)outputImageParamsFromJSON:(NSDictionary*)input {
368
+ if (!input || [input isEqual:[NSNull null]]) return nil;
369
+ RFSOutputImageParams* result = [RFSOutputImageParams new];
370
+ result.backgroundColor = [self colorWithInt:input[@"backgroundColor"]];
371
+ result.crop = [self outputImageCropFromJSON:input[@"crop"]];
372
+ return result;
373
+ }
374
+
375
+ +(id)generateOutputImageParams:(RFSOutputImageParams*)input {
376
+ if (!input) return [NSNull null];
377
+ return @{
378
+ @"crop": [self generateOutputImageCrop:input.crop],
379
+ @"backgroundColor": [self intWithColor:input.backgroundColor],
380
+ };
381
+ }
382
+
383
+ +(id)matchFacesRequestFromJSON:(NSDictionary*)input {
384
+ RFSMatchFacesRequest* result = [[RFSMatchFacesRequest alloc] initWithImages:[self arrayFromJSON:input[@"images"] :@selector(matchFacesImageFromJSON:)]];
385
+ result.metadata = input[@"metadata"];
386
+ result.tag = input[@"tag"];
387
+ result.outputImageParams = [RFSWJSONConstructor outputImageParamsFromJSON:input[@"outputImageParams"]];
388
+ return result;
389
+ }
390
+
391
+ +(id)generateMatchFacesRequest:(RFSMatchFacesRequest*)input {
392
+ if (!input) return [NSNull null];
393
+ NSMutableDictionary* result = @{
394
+ @"images":[self generateArray:input.images :@selector(generateMatchFacesImage:)],
395
+ }.mutableCopy;
396
+ if (input.metadata) result[@"metadata"] = input.metadata;
397
+ if (input.tag) result[@"tag"] = input.tag;
398
+ if (input.outputImageParams) result[@"outputImageParams"] = [self generateOutputImageParams:input.outputImageParams];
399
+ return result;
400
+ }
401
+
402
+ +(id)pointFromJSON:(NSDictionary*)input {
403
+ return [[RFSPoint alloc] initWithX:[input[@"x"] floatValue]
404
+ y:[input[@"y"] floatValue]];
405
+ }
406
+
407
+ +(id)generatePoint:(RFSPoint*)input {
408
+ return @{
409
+ @"x":@(input.x),
410
+ @"y":@(input.y)
411
+ };
412
+ }
413
+
414
+ +(CGRect)rectFromJSON:(NSDictionary*)input {
415
+ if (!input) return CGRectNull;
416
+ return CGRectMake(
417
+ [input[@"left"] floatValue],
418
+ [input[@"top"] floatValue],
419
+ [input[@"right"] floatValue] - [input[@"left"] floatValue],
420
+ [input[@"bottom"] floatValue] - [input[@"top"] floatValue]);
421
+ }
422
+
423
+ +(id)generateRect:(CGRect)input {
424
+ if (CGRectEqualToRect(input, CGRectNull)) return [NSNull null];
425
+ return @{
426
+ @"top":@(input.origin.y),
427
+ @"left":@(input.origin.x),
428
+ @"bottom":@(input.origin.y+input.size.height),
429
+ @"right":@(input.origin.x+input.size.width)
430
+ };
431
+ }
432
+
433
+ +(id)matchFacesDetectionFaceFromJSON:(NSDictionary*)input {
434
+ if (!input || [input isEqual:[NSNull null]]) return nil;
435
+ return [[RFSMatchFacesDetectionFace alloc] initWithFaceIndex:input[@"faceIndex"]
436
+ landmarks:[self arrayFromJSON:input[@"landmarks"] :@selector(pointFromJSON:)]
437
+ faceRect:[self rectFromJSON:input[@"faceRect"]]
438
+ rotationAngle:input[@"rotationAngle"]
439
+ thumbnailImage:nil
440
+ crop:[self imageWithBase64:input[@"crop"]]
441
+ originalRect:[self rectFromJSON:input[@"originalRect"]]];
442
+ }
443
+
444
+ +(id)generateMatchFacesDetectionFace:(RFSMatchFacesDetectionFace*)input {
445
+ if (!input) return [NSNull null];
446
+ NSMutableDictionary* result = @{
447
+ @"faceIndex":input.faceIndex,
448
+ @"landmarks":[self generateArray:input.landmarks :@selector(generatePoint:)],
449
+ @"faceRect":[self generateRect:input.faceRect],
450
+ @"crop":[self base64WithImage:input.crop],
451
+ @"originalRect":[self generateRect:input.originalRect]
452
+ }.mutableCopy;
453
+ if (input.rotationAngle) result[@"rotationAngle"] = input.rotationAngle;
454
+ return result;
455
+ }
456
+
457
+ +(id)matchFacesDetectionFromJSON:(NSDictionary*)input {
458
+ RFSMatchFacesDetection* result = [RFSMatchFacesDetection alloc];
459
+ SEL sel = NSSelectorFromString(@"initWithImageIndex:image:faces:error:");
460
+ IMP imp = [result methodForSelector:sel];
461
+ void (*func)(id, SEL, id, id, id, id) = (void *)imp;
462
+ func(result,
463
+ sel,
464
+ input[@"imageIndex"],
465
+ [self matchFacesImageFromJSON:input[@"image"]],
466
+ [self arrayFromJSON:input[@"faces"] :@selector(matchFacesDetectionFaceFromJSON:)],
467
+ nil);
468
+ return result;
469
+ }
470
+
471
+ +(id)generateMatchFacesDetection:(RFSMatchFacesDetection*)input {
472
+ return @{
473
+ @"image":[self generateMatchFacesImage:input.image],
474
+ @"imageIndex":input.imageIndex,
475
+ @"faces":[self generateArray:input.faces :@selector(generateMatchFacesDetectionFace:)],
476
+ @"error":[self generateError:input.error]
477
+ };
478
+ }
479
+
480
+ +(id)comparedFaceFromJSON:(NSDictionary*)input {
481
+ return [[RFSMatchFacesComparedFace alloc] initWithImageIndex:input[@"imageIndex"]
482
+ image:[self matchFacesImageFromJSON:input[@"image"]]
483
+ faceIndex:input[@"faceIndex"]
484
+ face:[self matchFacesDetectionFaceFromJSON:input[@"face"]]];
485
+ }
486
+
487
+ +(id)generateComparedFace:(RFSMatchFacesComparedFace*)input {
488
+ NSMutableDictionary* result = @{
489
+ @"imageIndex":input.imageIndex,
490
+ @"image":[self generateMatchFacesImage:input.image],
491
+ @"face":[self generateMatchFacesDetectionFace:input.face]
492
+ }.mutableCopy;
493
+ if (input.faceIndex) result[@"faceIndex"] = input.faceIndex;
494
+ return result;
495
+ }
496
+
497
+ +(id)comparedFacesPairFromJSON:(NSDictionary*)input {
498
+ return [[RFSMatchFacesComparedFacesPair alloc] initWithFirst:[self comparedFaceFromJSON:input[@"first"]]
499
+ second:[self comparedFaceFromJSON:input[@"second"]]
500
+ score:input[@"score"]
501
+ similarity:input[@"similarity"]
502
+ error:nil];
503
+ }
504
+
505
+ +(id)generateComparedFacesPair:(RFSMatchFacesComparedFacesPair*)input {
506
+ NSMutableDictionary* result = @{
507
+ @"first":[self generateComparedFace:input.first],
508
+ @"second":[self generateComparedFace:input.second],
509
+ @"error":[self generateError:input.error]
510
+ }.mutableCopy;
511
+ if (input.score) result[@"score"] = input.score;
512
+ if (input.similarity) result[@"similarity"] = input.similarity;
513
+ return result;
514
+ }
515
+
516
+ +(id)matchFacesResponseFromJSON:(NSDictionary*)input {
517
+ RFSMatchFacesResponse* result = [RFSMatchFacesResponse alloc];
518
+ SEL sel = NSSelectorFromString(@"initWithResults:detections:error:");
519
+ IMP imp = [result methodForSelector:sel];
520
+ void (*func)(id, SEL, id, id, id) = (void *)imp;
521
+ func(result,
522
+ sel,
523
+ [self arrayFromJSON:input[@"results"] :@selector(comparedFacesPairFromJSON:)],
524
+ [self arrayFromJSON:input[@"detections"] :@selector(matchFacesDetectionFromJSON:)],
525
+ nil);
526
+ [result setValue:input[@"tag"] forKey:@"tag"];
527
+ return result;
528
+ }
529
+
530
+ +(id)generateMatchFacesResponse:(RFSMatchFacesResponse*)input {
531
+ NSMutableDictionary* result = @{
532
+ @"error":[self generateError:input.error],
533
+ @"results":[self generateArray:input.results :@selector(generateComparedFacesPair:)],
534
+ @"detections":[self generateArray:input.detections :@selector(generateMatchFacesDetection:)]
535
+ }.mutableCopy;
536
+ if (input.tag) result[@"tag"] = input.tag;
537
+ return result;
538
+ }
539
+
540
+ +(id)generateComparedFacesSplit:(RFSMatchFacesSimilarityThresholdSplit*)input {
541
+ return @{
542
+ @"matchedFaces":[self generateArray:input.matchedFaces :@selector(generateComparedFacesPair:)],
543
+ @"unmatchedFaces":[self generateArray:input.unmatchedFaces :@selector(generateComparedFacesPair:)],
544
+ };
545
+ }
546
+
547
+ #pragma mark - DetectFaces
548
+
549
+ +(id)imageQualityRangeFromJSON:(NSDictionary*)input {
550
+ if (!input || [input isEqual:[NSNull null]]) return nil;
551
+ NSArray* array = @[input[@"min"], input[@"max"]];
552
+ return [[RFSImageQualityRange alloc] performSelector:NSSelectorFromString(@"initWithRange:") withObject:array];
553
+ }
554
+
555
+ +(id)imageQualityRangeToArray:(RFSImageQualityRange*)input {
556
+ if (!input || [input isEqual:[NSNull null]]) return nil;
557
+ return @[input.min, input.max];
558
+ }
559
+
560
+ +(id)generateImageQualityRange:(RFSImageQualityRange*)input {
561
+ if (!input) return [NSNull null];
562
+ return @{
563
+ @"min":input.min,
564
+ @"max":input.max
565
+ };
566
+ }
567
+
568
+ +(id)imageQualityCharacteristicFromJSON:(NSDictionary*)input {
569
+ return [RFSWConfig imageQualityCharacteristicWithName:input[@"characteristicName"]
570
+ recommendedRange:[self imageQualityRangeToArray:[self imageQualityRangeFromJSON:input[@"recommendedRange"]]]
571
+ customRange:[self imageQualityRangeToArray:[self imageQualityRangeFromJSON:input[@"customRange"]]]
572
+ color:[self colorWithInt:input[@"color"]]];
573
+ }
574
+
575
+ +(id)generateImageQualityCharacteristic:(RFSImageQualityCharacteristic*)input {
576
+ NSMutableDictionary* result = @{
577
+ @"characteristicName":input.name
578
+ }.mutableCopy;
579
+ if(input.recommendedRange) result[@"recommendedRange"] = [self generateImageQualityRange:input.recommendedRange];
580
+ if(input.customRange) result[@"customRange"] = [self generateImageQualityRange:input.customRange];
581
+ if ([input isKindOfClass:[RFSImageQualityColorCharacteristic class]])
582
+ result[@"color"] = [self intWithColor:((RFSImageQualityColorCharacteristic*)input).color];
583
+
584
+ return result;;
585
+ }
586
+
587
+ +(id)detectFacesConfigFromJSON:(NSDictionary*)input {
588
+ if (!input || [input isEqual:[NSNull null]]) return nil;
589
+ RFSDetectFacesConfiguration* result = [RFSDetectFacesConfiguration new];
590
+
591
+ result.customQuality = [self arrayFromJSON:input[@"customQuality"] :@selector(imageQualityCharacteristicFromJSON:)];
592
+ result.outputImageParams = [self outputImageParamsFromJSON:input[@"outputImageParams"]];
593
+ if (input[@"onlyCentralFace"]) result.onlyCentralFace = [input[@"onlyCentralFace"] boolValue];
594
+ result.attributes = input[@"attributes"];
595
+
596
+ return result;
597
+ }
598
+
599
+ +(id)generateDetectFacesConfig:(RFSDetectFacesConfiguration*)input {
600
+ NSMutableDictionary* result = @{
601
+ @"onlyCentralFace":@(input.onlyCentralFace),
602
+ }.mutableCopy;
603
+ if (input.customQuality) result[@"customQuality"] = [self generateArray:input.customQuality :@selector(generateImageQualityCharacteristic:)];
604
+ if (input.outputImageParams) result[@"outputImageParams"] = [self generateOutputImageParams:input.outputImageParams];
605
+ if (input.attributes) result[@"attributes"] = input.attributes;
606
+
607
+ return result;;
608
+ }
609
+
610
+ +(id)detectFacesRequestFromJSON:(NSDictionary*)input {
611
+ UIImage* image = [self imageWithBase64:input[@"image"]];
612
+ if (input[@"scenario"] && ![input[@"scenario"] isEqual:[NSNull null]])
613
+ return [[RFSDetectFacesRequest alloc] performSelector:NSSelectorFromString(@"initImage:scenario:") withObject:image withObject:input[@"scenario"]];
614
+ RFSDetectFacesRequest* request = [[RFSDetectFacesRequest alloc] initWithImage:image configuration:[self detectFacesConfigFromJSON:input[@"configuration"]]];
615
+ request.tag = input[@"tag"];
616
+ return request;
617
+ }
618
+
619
+ +(id)generateDetectFacesRequest:(RFSDetectFacesRequest*)input {
620
+ NSMutableDictionary* result = @{
621
+ @"image":[self base64WithImage:input.image],
622
+ }.mutableCopy;
623
+ if (input.tag) result[@"tag"] = input.tag;
624
+ if (input.scenario) result[@"scenario"] = input.scenario;
625
+ if (input.configuration) result[@"configuration"] = [self generateDetectFacesConfig:input.configuration];
626
+
627
+ return result;;
628
+ }
629
+
630
+ +(id)imageQualityResultFromJSON:(NSDictionary*)input {
631
+ RFSImageQualityResult* result = [RFSImageQualityResult alloc];
632
+ SEL sel = NSSelectorFromString(@"initWithName:groupId:status:value:range:");
633
+ IMP imp = [result methodForSelector:sel];
634
+ void (*func)(id, SEL, id, NSInteger, NSInteger, id, id) = (void *)imp;
635
+ func(result,
636
+ sel,
637
+ input[@"name"],
638
+ [input[@"group"] integerValue],
639
+ [input[@"status"] integerValue],
640
+ input[@"value"],
641
+ [self imageQualityRangeFromJSON:input[@"range"]]);
642
+ return result;
643
+ }
644
+
645
+ +(id)generateImageQualityResult:(RFSImageQualityResult*)input {
646
+ return @{
647
+ @"name":input.name,
648
+ @"group":@(input.group),
649
+ @"status":@(input.status),
650
+ @"range":[self generateImageQualityRange:input.range],
651
+ @"value":input.value
652
+ };
653
+ }
654
+
655
+ +(id)detectFacesAttributeResultFromJSON:(NSDictionary*)input {
656
+ RFSDetectFacesAttributeResult* result = [RFSDetectFacesAttributeResult alloc];
657
+ SEL sel = NSSelectorFromString(@"initWith:confidence:value:range:");
658
+ IMP imp = [result methodForSelector:sel];
659
+ void (*func)(id, SEL, id, id, id, id) = (void *)imp;
660
+ func(result,
661
+ sel,
662
+ input[@"attribute"],
663
+ input[@"confidence"],
664
+ input[@"value"],
665
+ [self imageQualityRangeToArray:[self imageQualityRangeFromJSON:input[@"range"]]]);
666
+ return result;
667
+ }
668
+
669
+ +(id)generateDetectFacesAttributeResult:(RFSDetectFacesAttributeResult*)input {
670
+ NSMutableDictionary* result = @{
671
+ @"attribute":input.attribute,
672
+ @"range":[self generateImageQualityRange:input.range],
673
+ }.mutableCopy;
674
+ if (input.value) result[@"value"] = input.value;
675
+ if (input.confidence) result[@"confidence"] = input.confidence;
676
+ return result;
677
+ }
678
+
679
+ +(id)detectFaceResultFromJSON:(NSDictionary*)input {
680
+ RFSDetectFaceResult* result = [RFSDetectFaceResult alloc];
681
+ SEL sel = NSSelectorFromString(@"initWithQuality:attributes:cropImageData:faceRect:landmarks:originalRect:");
682
+ IMP imp = [result methodForSelector:sel];
683
+ void (*func)(id, SEL, id, id, id, CGRect, id, CGRect) = (void *)imp;
684
+ func(result,
685
+ sel,
686
+ [self arrayFromJSON:input[@"quality"] :@selector(imageQualityResultFromJSON:)],
687
+ [self arrayFromJSON:input[@"attributes"] :@selector(detectFacesAttributeResultFromJSON:)],
688
+ input[@"crop"],
689
+ [self rectFromJSON:input[@"faceRect"]],
690
+ [self arrayFromJSON:input[@"landmarks"] :@selector(pointFromJSON:)],
691
+ [self rectFromJSON:input[@"originalRect"]]);
692
+ return result;
693
+ }
694
+
695
+ +(id)generateDetectFaceResult:(RFSDetectFaceResult*)input {
696
+ if (!input) return [NSNull null];
697
+ return @{
698
+ @"quality":[self generateArray:input.quality :@selector(generateImageQualityResult:)],
699
+ @"attributes":[self generateArray:input.attributes :@selector(generateDetectFacesAttributeResult:)],
700
+ @"landmarks":[self generateArray:input.landmarks :@selector(generatePoint:)],
701
+ @"crop":[self base64WithImage:input.crop],
702
+ @"faceRect":[self generateRect:input.faceRect],
703
+ @"originalRect":[self generateRect:input.originalRect],
704
+ @"isQualityCompliant":@(input.isQualityCompliant)
705
+ };
706
+ }
707
+
708
+ +(id)detectFacesResponseFromJSON:(NSDictionary*)input {
709
+ RFSDetectFacesResponse* result = [RFSDetectFacesResponse alloc];
710
+ SEL sel = NSSelectorFromString(@"initWithDetections:scenario:error:");
711
+ IMP imp = [result methodForSelector:sel];
712
+ void (*func)(id, SEL, id, id, id) = (void *)imp;
713
+ func(result,
714
+ sel,
715
+ [self arrayFromJSON:input[@"allDetections"] :@selector(detectFaceResultFromJSON:)],
716
+ input[@"scenario"],
717
+ nil);
718
+ return result;
719
+ }
720
+
721
+ +(id)generateDetectFacesResponse:(RFSDetectFacesResponse*)input {
722
+ NSMutableDictionary* result = @{
723
+ @"detection":[self generateDetectFaceResult:input.detection],
724
+ @"error":[self generateError:input.error],
725
+ @"allDetections":[self generateArray:input.allDetections :@selector(generateDetectFaceResult:)]
726
+ }.mutableCopy;
727
+ if (input.scenario) result[@"scenario"] = input.scenario;
728
+ return result;
729
+ }
730
+
731
+ #pragma mark - PersonDatabase
732
+
733
+ +(id)generatePersonDBResponse:(id)data :(NSError*)error {
734
+ if (error) return @{ @"error": error.localizedDescription };
735
+ else return @{ @"data": data };
736
+ }
737
+
738
+ +(NSDateFormatter*)dateFromatter {
739
+ NSDateFormatter *dateFormatter = [NSDateFormatter new];
740
+ dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS";
741
+ return dateFormatter;
742
+ }
743
+
744
+ +(id)dateFromJSON:(NSString*)input {
745
+ return [self.dateFromatter dateFromString:input];
746
+ }
747
+
748
+ +(id)generateDate:(NSDate*)input {
749
+ return [self.dateFromatter stringFromDate:input];
750
+ }
751
+
752
+ +(id)personFromJSON:(NSDictionary*)input {
753
+ RFSPerson* result = [[RFSPerson alloc] performSelector:NSSelectorFromString(@"init")];
754
+ [result setValue:input[@"id"] forKey:@"itemId"];
755
+ [result setValue:input[@"metadata"] forKey:@"mutableMetadata"];
756
+ [result setValue:[self dateFromJSON:input[@"createdAt"]] forKey:@"createdAt"];
757
+ [result setValue:input[@"name"] forKey:@"name"];
758
+ [result setValue:input[@"groups"] forKey:@"groups"];
759
+ [result setValue:[self dateFromJSON:input[@"updatedAt"]] forKey:@"updatedAt"];
760
+ return result;
761
+ }
762
+
763
+ +(id)generatePerson:(RFSPerson*)input {
764
+ if (!input) return [NSNull null];
765
+ NSMutableDictionary* result = @{
766
+ @"updatedAt":[self generateDate:input.updatedAt],
767
+ @"createdAt":[self generateDate:input.createdAt]
768
+ }.mutableCopy;
769
+ if (input.name) result[@"name"] = input.name;
770
+ if (input.groups) result[@"groups"] = input.groups;
771
+ if (input.itemId) result[@"id"] = input.itemId;
772
+ if (input.metadata) result[@"metadata"] = input.metadata;
773
+ return result;
774
+ }
775
+
776
+ +(id)idFromJSON:(NSDictionary*)input {
777
+ return input[@"id"];
778
+ }
779
+
780
+ +(id)updatePersonFromJSON:(RFSPerson*)result :(NSDictionary*)json {
781
+ if (json[@"name"] && ![json[@"name"] isEqual:[NSNull null]]) result.name = json[@"name"];
782
+ if (json[@"metadata"] && ![json[@"metadata"] isEqual:[NSNull null]]) result.metadata = json[@"metadata"];
783
+ return result;
784
+ }
785
+
786
+ +(id)urlFromJSON:(NSString*)input {
787
+ if (!input || [input isEqual:[NSNull null]]) return nil;
788
+ return [NSURL URLWithString:input];
789
+ }
790
+
791
+ +(id)generateUrl:(NSURL*)input {
792
+ if (!input) return [NSNull null];
793
+ return input.absoluteString;
794
+ }
795
+
796
+ +(id)personImageFromJSON:(NSDictionary*)input {
797
+ RFSPersonImage* result = [[RFSPersonImage alloc] performSelector:NSSelectorFromString(@"init")];
798
+ [result setValue:input[@"id"] forKey:@"itemId"];
799
+ [result setValue:input[@"metadata"] forKey:@"metadata"];
800
+ [result setValue:[self dateFromJSON:input[@"createdAt"]] forKey:@"createdAt"];
801
+ [result setValue:[self urlFromJSON:input[@"url"]] forKey:@"url"];
802
+ [result setValue:input[@"path"] forKey:@"path"];
803
+ [result setValue:input[@"contentType"] forKey:@"contentType"];
804
+ return result;
805
+ }
806
+
807
+ +(id)generatePersonImage:(RFSPersonImage*)input {
808
+ if (!input) return [NSNull null];
809
+ NSMutableDictionary* result = @{
810
+ @"url":[self generateUrl:input.url],
811
+ @"createdAt":[self generateDate:input.createdAt]
812
+ }.mutableCopy;
813
+ if (input.path) result[@"path"] = input.path;
814
+ if (input.contentType) result[@"contentType"] = input.contentType;
815
+ if (input.itemId) result[@"id"] = input.itemId;
816
+ if (input.metadata) result[@"metadata"] = input.metadata;
817
+ return result;
818
+ }
819
+
820
+ +(id)imageUploadFromJSON:(NSDictionary*)input {
821
+ if (!input || [input isEqual:[NSNull null]]) return nil;
822
+ if (input[@"imageUrl"] && ![input[@"imageUrl"] isEqual:[NSNull null]]) return [[RFSImageUpload alloc] initWithImageURL:[self urlFromJSON:input[@"imageUrl"]]];
823
+ if (input[@"imageData"] && ![input[@"imageData"] isEqual:[NSNull null]]) return [[RFSImageUpload alloc] initWithImageData:[self base64Decode:input[@"imageData"]]];
824
+ return nil;
825
+ }
826
+
827
+ +(id)generateImageUpload:(RFSImageUpload*)input {
828
+ if (!input) return [NSNull null];
829
+ NSMutableDictionary* result = @{}.mutableCopy;
830
+ if (input.imageURL) result[@"imageUrl"] = [self generateUrl:input.imageURL];
831
+ if (input.imageData) result[@"imageData"] = [self base64Encode:input.imageData];
832
+ return result;
833
+ }
834
+
835
+ +(id)personGroupFromJSON:(NSDictionary*)input {
836
+ RFSPersonGroup* result = [[RFSPersonGroup alloc] performSelector:NSSelectorFromString(@"init")];
837
+ [result setValue:input[@"id"] forKey:@"itemId"];
838
+ [result setValue:input[@"metadata"] forKey:@"mutableMetadata"];
839
+ [result setValue:[self dateFromJSON:input[@"createdAt"]] forKey:@"createdAt"];
840
+ [result setValue:input[@"name"] forKey:@"name"];
841
+ return result;
842
+ }
843
+
844
+ +(id)generatePersonGroup:(RFSPersonGroup*)input {
845
+ if (!input) return [NSNull null];
846
+ NSMutableDictionary* result = @{
847
+ @"createdAt":[self generateDate:input.createdAt]
848
+ }.mutableCopy;
849
+ if (input.name) result[@"name"] = input.name;
850
+ if (input.itemId) result[@"id"] = input.itemId;
851
+ if (input.metadata) result[@"metadata"] = input.metadata;
852
+ return result;
853
+ }
854
+
855
+ +(id)updatePersonGroupFromJSON:(RFSPersonGroup*)result :(NSDictionary*)json {
856
+ if (json[@"name"] && ![json[@"name"] isEqual:[NSNull null]]) result.name = json[@"name"];
857
+ if (json[@"metadata"] && ![json[@"metadata"] isEqual:[NSNull null]]) result.metadata = json[@"metadata"];
858
+ return result;
859
+ }
860
+
861
+ +(id)editGroupPersonsRequestFromJSON:(NSDictionary*)input {
862
+ return [[RFSEditGroupPersonsRequest alloc] initWithPersonIdsToAdd:input[@"personIdsToAdd"]
863
+ personIdsToRemove:input[@"personIdsToRemove"]];
864
+ }
865
+
866
+ +(id)generateEditGroupPersonsRequest:(RFSEditGroupPersonsRequest*)input {
867
+ if (!input) return [NSNull null];
868
+ NSMutableDictionary* result = @{}.mutableCopy;
869
+ if (input.personIdsToAdd) result[@"personIdsToAdd"] = input.personIdsToAdd;
870
+ if (input.personIdsToRemove) result[@"personIdsToRemove"] = input.personIdsToRemove;
871
+ return result;
872
+ }
873
+
874
+ +(id)searchPersonRequestFromJSON:(NSDictionary*)input {
875
+ RFSSearchPersonRequest* result = [[RFSSearchPersonRequest alloc] initWithGroupIds:input[@"groupIdsForSearch"]
876
+ imageUpload:[self imageUploadFromJSON:input[@"imageUpload"]]];
877
+ result.threshold = input[@"threshold"];
878
+ result.limit = input[@"limit"];
879
+ if (input[@"detectAll"] && ![input[@"detectAll"] isEqual:[NSNull null]]) result.detectAll = input[@"detectAll"];
880
+ result.outputImageParams = [self outputImageParamsFromJSON:input[@"outputImageParams"]];
881
+ return result;
882
+ }
883
+
884
+ +(id)generateSearchPersonRequest:(RFSSearchPersonRequest*)input {
885
+ if (!input) return [NSNull null];
886
+ NSMutableDictionary* result = @{
887
+ @"imageUpload": [self generateImageUpload:input.imageUpload],
888
+ @"detectAll": @(input.detectAll)
889
+ }.mutableCopy;
890
+ if (input.threshold) result[@"threshold"] = input.threshold;
891
+ if (input.limit) result[@"limit"] = input.limit;
892
+ if (input.groupIdsForSearch) result[@"groupIdsForSearch"] = input.groupIdsForSearch;
893
+ if (input.outputImageParams) result[@"outputImageParams"] = [self generateOutputImageParams:input.outputImageParams];
894
+ return result;
895
+ }
896
+
897
+ +(id)searchPersonDetectionFromJSON:(NSDictionary*)input {
898
+ RFSSearchPersonDetection* result = [RFSSearchPersonDetection alloc];
899
+ SEL sel = NSSelectorFromString(@"initWithRoi:landmarks:crop:rotationAngle:");
900
+ IMP imp = [result methodForSelector:sel];
901
+ void (*func)(id, SEL, CGRect, id, id, id) = (void *)imp;
902
+ func(result,
903
+ sel,
904
+ [self rectFromJSON:input[@"rect"]],
905
+ [self arrayFromJSON:input[@"landmarks"] :@selector(pointFromJSON:)],
906
+ [self imageWithBase64:input[@"crop"]],
907
+ input[@"rotationAngle"]);
908
+ return result;
909
+ }
910
+
911
+ +(id)generateSearchPersonDetection:(RFSSearchPersonDetection*)input {
912
+ if (!input) return [NSNull null];
913
+ NSMutableDictionary* result = @{
914
+ @"landmarks":[self generateArray:input.landmarks :@selector(generatePoint:)],
915
+ @"rect":[self generateRect:input.rect],
916
+ @"crop":[self base64WithImage:input.crop],
917
+ }.mutableCopy;
918
+ if (input.rotationAngle) result[@"rotationAngle"] = input.rotationAngle;
919
+ return result;
920
+ }
921
+
922
+ +(id)searchPersonImageFromJSON:(NSDictionary*)input {
923
+ RFSSearchPersonImage* result = [[RFSSearchPersonImage alloc] performSelector:NSSelectorFromString(@"init")];
924
+ [result setValue:input[@"id"] forKey:@"itemId"];
925
+ [result setValue:input[@"metadata"] forKey:@"metadata"];
926
+ [result setValue:[self dateFromJSON:input[@"createdAt"]] forKey:@"createdAt"];
927
+ [result setValue:[self urlFromJSON:input[@"url"]] forKey:@"url"];
928
+ [result setValue:input[@"path"] forKey:@"path"];
929
+ [result setValue:input[@"contentType"] forKey:@"contentType"];
930
+ [result setValue:input[@"similarity"] forKey:@"similarity"];
931
+ [result setValue:input[@"distance"] forKey:@"distance"];
932
+ return result;
933
+ }
934
+
935
+ +(id)generateSearchPersonImage:(RFSSearchPersonImage*)input {
936
+ NSMutableDictionary* result = @{
937
+ @"url":[self generateUrl:input.url],
938
+ @"createdAt":[self generateDate:input.createdAt]
939
+ }.mutableCopy;
940
+ if (input.path) result[@"similarity"] = input.similarity;
941
+ if (input.path) result[@"distance"] = input.distance;
942
+ if (input.path) result[@"path"] = input.path;
943
+ if (input.contentType) result[@"contentType"] = input.contentType;
944
+ if (input.itemId) result[@"id"] = input.itemId;
945
+ if (input.metadata) result[@"metadata"] = input.metadata;
946
+ return result;
947
+ }
948
+
949
+ +(id)searchPersonFromJSON:(NSDictionary*)input {
950
+ RFSSearchPerson* result = [[RFSSearchPerson alloc] performSelector:NSSelectorFromString(@"init")];
951
+ [result setValue:input[@"id"] forKey:@"itemId"];
952
+ [result setValue:input[@"metadata"] forKey:@"mutableMetadata"];
953
+ [result setValue:[self dateFromJSON:input[@"createdAt"]] forKey:@"createdAt"];
954
+ [result setValue:input[@"name"] forKey:@"name"];
955
+ [result setValue:input[@"groups"] forKey:@"groups"];
956
+ [result setValue:[self dateFromJSON:input[@"updatedAt"]] forKey:@"updatedAt"];
957
+ [result setValue:[self arrayFromJSON:input[@"images"] :@selector(searchPersonImageFromJSON:)] forKey:@"images"];
958
+ [result setValue:[self searchPersonDetectionFromJSON:input[@"detection"]] forKey:@"detection"];
959
+ return result;
960
+ }
961
+
962
+ +(id)generateSearchPerson:(RFSSearchPerson*)input {
963
+ if (!input) return [NSNull null];
964
+ NSMutableDictionary* result = @{
965
+ @"detection":[self generateSearchPersonDetection:input.detection],
966
+ @"images":[self generateArray:input.images :@selector(generateSearchPersonImage:)],
967
+ @"updatedAt":[self generateDate:input.updatedAt],
968
+ @"createdAt":[self generateDate:input.createdAt]
969
+ }.mutableCopy;
970
+ if (input.name) result[@"name"] = input.name;
971
+ if (input.groups) result[@"groups"] = input.groups;
972
+ if (input.itemId) result[@"id"] = input.itemId;
973
+ if (input.metadata) result[@"metadata"] = input.metadata;
974
+ return result;
975
+ }
976
+
977
+ @end