facecog-liveness-showcase 0.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.
Files changed (229) hide show
  1. package/.browserslistrc +15 -0
  2. package/.dockerignore +48 -0
  3. package/.editorconfig +16 -0
  4. package/.eslintrc.json +47 -0
  5. package/.vercelignore +7 -0
  6. package/.vscode/extensions.json +5 -0
  7. package/.vscode/settings.json +3 -0
  8. package/DOCKER.md +221 -0
  9. package/Dockerfile +33 -0
  10. package/README.md +268 -0
  11. package/angular.json +156 -0
  12. package/capacitor.config.ts +9 -0
  13. package/docker-compose.dev.yml +20 -0
  14. package/docker-compose.yml +18 -0
  15. package/ionic.config.json +7 -0
  16. package/jest.config.js +38 -0
  17. package/nginx.conf +50 -0
  18. package/package.json +131 -0
  19. package/patches/ng-packagr+20.3.2.patch +60 -0
  20. package/projects/facecog-liveness-verification/README.md +295 -0
  21. package/projects/facecog-liveness-verification/ng-package.json +7 -0
  22. package/projects/facecog-liveness-verification/package.json +48 -0
  23. package/projects/facecog-liveness-verification/scripts/build-with-wrapper-copy.js +38 -0
  24. package/projects/facecog-liveness-verification/scripts/copy-wrapper-after-ngc.js +35 -0
  25. package/projects/facecog-liveness-verification/sources/FaceLivenessReactWrapper.tsx +320 -0
  26. package/projects/facecog-liveness-verification/src/lib/components/aws-face-liveness/FaceLivenessReactWrapper.generated.d.ts +28 -0
  27. package/projects/facecog-liveness-verification/src/lib/components/aws-face-liveness/FaceLivenessReactWrapper.generated.js +247 -0
  28. package/projects/facecog-liveness-verification/src/lib/components/aws-face-liveness/FaceLivenessReactWrapper.generated.js.map +1 -0
  29. package/projects/facecog-liveness-verification/src/lib/components/aws-face-liveness/FaceLivenessReactWrapper.js.map +1 -0
  30. package/projects/facecog-liveness-verification/src/lib/components/aws-face-liveness/FaceLivenessReactWrapper.ts +5 -0
  31. package/projects/facecog-liveness-verification/src/lib/components/aws-face-liveness/aws-face-liveness.component.ts +500 -0
  32. package/projects/facecog-liveness-verification/src/lib/components/camera-permission/camera-permission.component.html +41 -0
  33. package/projects/facecog-liveness-verification/src/lib/components/camera-permission/camera-permission.component.scss +234 -0
  34. package/projects/facecog-liveness-verification/src/lib/components/camera-permission/camera-permission.component.spec.ts +158 -0
  35. package/projects/facecog-liveness-verification/src/lib/components/camera-permission/camera-permission.component.ts +58 -0
  36. package/projects/facecog-liveness-verification/src/lib/components/camera-verification/camera-verification.component.html +34 -0
  37. package/projects/facecog-liveness-verification/src/lib/components/camera-verification/camera-verification.component.ts +210 -0
  38. package/projects/facecog-liveness-verification/src/lib/components/dialogs/save-custom-pose-dialog.component.ts +174 -0
  39. package/projects/facecog-liveness-verification/src/lib/components/facetec-scan/facetec-scan.component.html +45 -0
  40. package/projects/facecog-liveness-verification/src/lib/components/facetec-scan/facetec-scan.component.scss +87 -0
  41. package/projects/facecog-liveness-verification/src/lib/components/facetec-scan/facetec-scan.component.ts +182 -0
  42. package/projects/facecog-liveness-verification/src/lib/components/intro/intro.component.html +394 -0
  43. package/projects/facecog-liveness-verification/src/lib/components/intro/intro.component.scss +1567 -0
  44. package/projects/facecog-liveness-verification/src/lib/components/intro/intro.component.spec.ts +699 -0
  45. package/projects/facecog-liveness-verification/src/lib/components/intro/intro.component.ts +721 -0
  46. package/projects/facecog-liveness-verification/src/lib/components/live-preview/live-preview.component.html +120 -0
  47. package/projects/facecog-liveness-verification/src/lib/components/live-preview/live-preview.component.scss +611 -0
  48. package/projects/facecog-liveness-verification/src/lib/components/live-preview/live-preview.component.spec.ts +605 -0
  49. package/projects/facecog-liveness-verification/src/lib/components/live-preview/live-preview.component.ts +524 -0
  50. package/projects/facecog-liveness-verification/src/lib/components/liveness-flow/liveness-flow.component.html +73 -0
  51. package/projects/facecog-liveness-verification/src/lib/components/liveness-flow/liveness-flow.component.scss +19 -0
  52. package/projects/facecog-liveness-verification/src/lib/components/liveness-flow/liveness-flow.component.spec.ts +673 -0
  53. package/projects/facecog-liveness-verification/src/lib/components/liveness-flow/liveness-flow.component.ts +963 -0
  54. package/projects/facecog-liveness-verification/src/lib/components/liveness-verification/liveness-verification.component.html +38 -0
  55. package/projects/facecog-liveness-verification/src/lib/components/liveness-verification/liveness-verification.component.scss +10 -0
  56. package/projects/facecog-liveness-verification/src/lib/components/liveness-verification/liveness-verification.component.ts +233 -0
  57. package/projects/facecog-liveness-verification/src/lib/components/pose-selection/pose-selection.component.html +17 -0
  58. package/projects/facecog-liveness-verification/src/lib/components/pose-selection/pose-selection.component.spec.ts +35 -0
  59. package/projects/facecog-liveness-verification/src/lib/components/pose-selection/pose-selection.component.ts +33 -0
  60. package/projects/facecog-liveness-verification/src/lib/components/processing/processing.component.html +17 -0
  61. package/projects/facecog-liveness-verification/src/lib/components/processing/processing.component.scss +156 -0
  62. package/projects/facecog-liveness-verification/src/lib/components/processing/processing.component.spec.ts +46 -0
  63. package/projects/facecog-liveness-verification/src/lib/components/processing/processing.component.ts +18 -0
  64. package/projects/facecog-liveness-verification/src/lib/components/verification-result/verification-result.component.html +190 -0
  65. package/projects/facecog-liveness-verification/src/lib/components/verification-result/verification-result.component.scss +534 -0
  66. package/projects/facecog-liveness-verification/src/lib/components/verification-result/verification-result.component.spec.ts +286 -0
  67. package/projects/facecog-liveness-verification/src/lib/components/verification-result/verification-result.component.ts +155 -0
  68. package/projects/facecog-liveness-verification/src/lib/interfaces/analyze-response.interface.ts +16 -0
  69. package/projects/facecog-liveness-verification/src/lib/interfaces/aws-face-liveness.interface.ts +46 -0
  70. package/projects/facecog-liveness-verification/src/lib/interfaces/backend-adapter.interface.ts +21 -0
  71. package/projects/facecog-liveness-verification/src/lib/interfaces/backend-http-client.interface.ts +93 -0
  72. package/projects/facecog-liveness-verification/src/lib/interfaces/backend-response.interface.ts +9 -0
  73. package/projects/facecog-liveness-verification/src/lib/interfaces/camera-provider.interface.ts +107 -0
  74. package/projects/facecog-liveness-verification/src/lib/interfaces/category-info.interface.ts +9 -0
  75. package/projects/facecog-liveness-verification/src/lib/interfaces/custom-pose-data.interface.ts +14 -0
  76. package/projects/facecog-liveness-verification/src/lib/interfaces/custom-pose-repository.interface.ts +48 -0
  77. package/projects/facecog-liveness-verification/src/lib/interfaces/custom-pose-response.interface.ts +14 -0
  78. package/projects/facecog-liveness-verification/src/lib/interfaces/index.ts +52 -0
  79. package/projects/facecog-liveness-verification/src/lib/interfaces/liveness-action-result.interface.ts +13 -0
  80. package/projects/facecog-liveness-verification/src/lib/interfaces/liveness-config.interface.ts +17 -0
  81. package/projects/facecog-liveness-verification/src/lib/interfaces/liveness-metadata.interface.ts +17 -0
  82. package/projects/facecog-liveness-verification/src/lib/interfaces/liveness-result.interface.ts +24 -0
  83. package/projects/facecog-liveness-verification/src/lib/interfaces/liveness-verification-config.interface.ts +41 -0
  84. package/projects/facecog-liveness-verification/src/lib/interfaces/multi-backend-analyze-response.interface.ts +21 -0
  85. package/projects/facecog-liveness-verification/src/lib/interfaces/multi-backend-liveness-result.interface.ts +14 -0
  86. package/projects/facecog-liveness-verification/src/lib/interfaces/pose-definition.interface.ts +35 -0
  87. package/projects/facecog-liveness-verification/src/lib/interfaces/pose-keypoint.interface.ts +12 -0
  88. package/projects/facecog-liveness-verification/src/lib/interfaces/pose-match-result.interface.ts +9 -0
  89. package/projects/facecog-liveness-verification/src/lib/interfaces/pose-verify-response.interface.ts +8 -0
  90. package/projects/facecog-liveness-verification/src/lib/interfaces/scan-results.interface.ts +29 -0
  91. package/projects/facecog-liveness-verification/src/lib/interfaces/verification-plan.interface.ts +42 -0
  92. package/projects/facecog-liveness-verification/src/lib/interfaces/verification-progress-event.interface.ts +12 -0
  93. package/projects/facecog-liveness-verification/src/lib/interfaces/verification-session.interface.ts +72 -0
  94. package/projects/facecog-liveness-verification/src/lib/interfaces/verification-step-change-event.interface.ts +11 -0
  95. package/projects/facecog-liveness-verification/src/lib/interfaces/video-recording.interface.ts +9 -0
  96. package/projects/facecog-liveness-verification/src/lib/liveness-verification.module.ts +123 -0
  97. package/projects/facecog-liveness-verification/src/lib/models/constants/aws-face-liveness-component.token.ts +23 -0
  98. package/projects/facecog-liveness-verification/src/lib/models/constants/category-info.constant.ts +14 -0
  99. package/projects/facecog-liveness-verification/src/lib/models/constants/default-liveness-config.constant.ts +18 -0
  100. package/projects/facecog-liveness-verification/src/lib/models/constants/index.ts +5 -0
  101. package/projects/facecog-liveness-verification/src/lib/models/constants/liveness-verification-config.token.ts +16 -0
  102. package/projects/facecog-liveness-verification/src/lib/models/constants/pose-definitions.constant.ts +377 -0
  103. package/projects/facecog-liveness-verification/src/lib/models/index.ts +5 -0
  104. package/projects/facecog-liveness-verification/src/lib/models/utils/index.ts +2 -0
  105. package/projects/facecog-liveness-verification/src/lib/models/utils/pose.utils.spec.ts +76 -0
  106. package/projects/facecog-liveness-verification/src/lib/models/utils/pose.utils.ts +59 -0
  107. package/projects/facecog-liveness-verification/src/lib/services/aws-face-liveness.service.ts +49 -0
  108. package/projects/facecog-liveness-verification/src/lib/services/backend-http.service.spec.ts +111 -0
  109. package/projects/facecog-liveness-verification/src/lib/services/backend-http.service.ts +130 -0
  110. package/projects/facecog-liveness-verification/src/lib/services/backends/azure-backend.service.spec.ts +69 -0
  111. package/projects/facecog-liveness-verification/src/lib/services/backends/azure-backend.service.ts +72 -0
  112. package/projects/facecog-liveness-verification/src/lib/services/backends/facetec-backend.service.spec.ts +24 -0
  113. package/projects/facecog-liveness-verification/src/lib/services/backends/facetec-backend.service.ts +35 -0
  114. package/projects/facecog-liveness-verification/src/lib/services/backends/mock-backend.service.spec.ts +36 -0
  115. package/projects/facecog-liveness-verification/src/lib/services/backends/mock-backend.service.ts +39 -0
  116. package/projects/facecog-liveness-verification/src/lib/services/backends/openpose-backend.service.spec.ts +81 -0
  117. package/projects/facecog-liveness-verification/src/lib/services/backends/openpose-backend.service.ts +72 -0
  118. package/projects/facecog-liveness-verification/src/lib/services/backends/rekognition-analysis-backend.service.spec.ts +69 -0
  119. package/projects/facecog-liveness-verification/src/lib/services/backends/rekognition-analysis-backend.service.ts +83 -0
  120. package/projects/facecog-liveness-verification/src/lib/services/camera.service.spec.ts +200 -0
  121. package/projects/facecog-liveness-verification/src/lib/services/camera.service.ts +155 -0
  122. package/projects/facecog-liveness-verification/src/lib/services/custom-poses-api.service.ts +117 -0
  123. package/projects/facecog-liveness-verification/src/lib/services/index.ts +18 -0
  124. package/projects/facecog-liveness-verification/src/lib/services/liveness-backend.service.spec.ts +103 -0
  125. package/projects/facecog-liveness-verification/src/lib/services/liveness-backend.service.ts +61 -0
  126. package/projects/facecog-liveness-verification/src/lib/services/liveness-config.service.spec.ts +109 -0
  127. package/projects/facecog-liveness-verification/src/lib/services/liveness-config.service.ts +70 -0
  128. package/projects/facecog-liveness-verification/src/lib/services/liveness-orchestrator.service.spec.ts +144 -0
  129. package/projects/facecog-liveness-verification/src/lib/services/liveness-orchestrator.service.ts +162 -0
  130. package/projects/facecog-liveness-verification/src/lib/services/pose-detection/hand-gesture-detection.service.ts +315 -0
  131. package/projects/facecog-liveness-verification/src/lib/services/pose-detection/index.ts +5 -0
  132. package/projects/facecog-liveness-verification/src/lib/services/pose-detection/openpose.service.ts +287 -0
  133. package/projects/facecog-liveness-verification/src/lib/services/pose-detection/pose-comparison.service.ts +353 -0
  134. package/projects/facecog-liveness-verification/src/lib/services/pose-detection/pose-matching.service.ts +2370 -0
  135. package/projects/facecog-liveness-verification/src/lib/services/pose-detection/reference-pose.service.ts +271 -0
  136. package/projects/facecog-liveness-verification/src/lib/services/pose-selection.service.spec.ts +183 -0
  137. package/projects/facecog-liveness-verification/src/lib/services/pose-selection.service.ts +179 -0
  138. package/projects/facecog-liveness-verification/src/lib/services/verification-api.service.spec.ts +159 -0
  139. package/projects/facecog-liveness-verification/src/lib/services/verification-api.service.ts +151 -0
  140. package/projects/facecog-liveness-verification/src/lib/services/verification-plan.service.spec.ts +184 -0
  141. package/projects/facecog-liveness-verification/src/lib/services/verification-plan.service.ts +94 -0
  142. package/projects/facecog-liveness-verification/src/lib/services/video-recorder.service.spec.ts +52 -0
  143. package/projects/facecog-liveness-verification/src/lib/services/video-recorder.service.ts +117 -0
  144. package/projects/facecog-liveness-verification/src/lib/types/detection-strategy.type.ts +5 -0
  145. package/projects/facecog-liveness-verification/src/lib/types/index.ts +7 -0
  146. package/projects/facecog-liveness-verification/src/lib/types/liveness-action.type.ts +31 -0
  147. package/projects/facecog-liveness-verification/src/lib/types/liveness-backend.type.ts +5 -0
  148. package/projects/facecog-liveness-verification/src/lib/types/pose-category.type.ts +5 -0
  149. package/projects/facecog-liveness-verification/src/lib/types/pose-difficulty.type.ts +5 -0
  150. package/projects/facecog-liveness-verification/src/lib/types/verification-flow-step.type.ts +5 -0
  151. package/projects/facecog-liveness-verification/src/lib/types/verification-step-kind.type.ts +4 -0
  152. package/projects/facecog-liveness-verification/src/public-api.ts +150 -0
  153. package/projects/facecog-liveness-verification/tsconfig.lib.json +20 -0
  154. package/projects/facecog-liveness-verification/tsconfig.lib.prod.json +11 -0
  155. package/projects/facecog-liveness-verification/tsconfig.spec.json +13 -0
  156. package/projects/facecog-liveness-verification/tsconfig.wrapper.json +15 -0
  157. package/projects/facecog-liveness-verification-test/src/app/app-routing.module.ts +22 -0
  158. package/projects/facecog-liveness-verification-test/src/app/app.component.html +3 -0
  159. package/projects/facecog-liveness-verification-test/src/app/app.component.scss +0 -0
  160. package/projects/facecog-liveness-verification-test/src/app/app.component.ts +11 -0
  161. package/projects/facecog-liveness-verification-test/src/app/app.module.ts +27 -0
  162. package/projects/facecog-liveness-verification-test/src/app/home/home-routing.module.ts +16 -0
  163. package/projects/facecog-liveness-verification-test/src/app/home/home.module.ts +19 -0
  164. package/projects/facecog-liveness-verification-test/src/app/home/home.page.html +39 -0
  165. package/projects/facecog-liveness-verification-test/src/app/home/home.page.scss +97 -0
  166. package/projects/facecog-liveness-verification-test/src/app/home/home.page.spec.ts +24 -0
  167. package/projects/facecog-liveness-verification-test/src/app/home/home.page.ts +92 -0
  168. package/projects/facecog-liveness-verification-test/src/app/home/verification-modal.component.ts +106 -0
  169. package/projects/facecog-liveness-verification-test/src/assets/fonts/gilroy/Gilroy-Bold_0.ttf +0 -0
  170. package/projects/facecog-liveness-verification-test/src/assets/fonts/gilroy/Gilroy-Medium_0.ttf +0 -0
  171. package/projects/facecog-liveness-verification-test/src/assets/fonts/gilroy/Gilroy-Regular_0.ttf +0 -0
  172. package/projects/facecog-liveness-verification-test/src/assets/fonts/gilroy/Gilroy-SemiBold_0.ttf +0 -0
  173. package/projects/facecog-liveness-verification-test/src/assets/fonts/gilroy/Gilroy-Thin_0.ttf +0 -0
  174. package/projects/facecog-liveness-verification-test/src/assets/icon/favicon.png +0 -0
  175. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Five_Fingers_Left.jpg +0 -0
  176. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Left_Palm.jpg +0 -0
  177. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Ok_Sign_Right.jpg +0 -0
  178. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Peace_Sign_Left.jpg +0 -0
  179. package/projects/facecog-liveness-verification-test/src/assets/images/poses/README.md +77 -0
  180. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Right_Palm.jpg +0 -0
  181. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Speak_Phrase.jpg +0 -0
  182. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Three_Fingers_Right.jpg +0 -0
  183. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Thumbs_Up_Left.jpg +0 -0
  184. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Thumbs_Up_Right.jpg +0 -0
  185. package/projects/facecog-liveness-verification-test/src/assets/images/poses/Wave_Right.jpg +0 -0
  186. package/projects/facecog-liveness-verification-test/src/assets/images/poses/blink.jpeg +0 -0
  187. package/projects/facecog-liveness-verification-test/src/assets/images/poses/blink_twice.jpeg +0 -0
  188. package/projects/facecog-liveness-verification-test/src/assets/images/poses/center_face.png +0 -0
  189. package/projects/facecog-liveness-verification-test/src/assets/images/poses/clap.jpeg +0 -0
  190. package/projects/facecog-liveness-verification-test/src/assets/images/poses/cover_mouth.png +0 -0
  191. package/projects/facecog-liveness-verification-test/src/assets/images/poses/cover_right_eye.png +0 -0
  192. package/projects/facecog-liveness-verification-test/src/assets/images/poses/cross_arms.png +0 -0
  193. package/projects/facecog-liveness-verification-test/src/assets/images/poses/face_straight.png +0 -0
  194. package/projects/facecog-liveness-verification-test/src/assets/images/poses/follow_dot.png +0 -0
  195. package/projects/facecog-liveness-verification-test/src/assets/images/poses/look_down.png +0 -0
  196. package/projects/facecog-liveness-verification-test/src/assets/images/poses/look_up.png +0 -0
  197. package/projects/facecog-liveness-verification-test/src/assets/images/poses/move_closer.png +0 -0
  198. package/projects/facecog-liveness-verification-test/src/assets/images/poses/nod.png +0 -0
  199. package/projects/facecog-liveness-verification-test/src/assets/images/poses/open_mouth.png +0 -0
  200. package/projects/facecog-liveness-verification-test/src/assets/images/poses/raise_eyebrow.png +0 -0
  201. package/projects/facecog-liveness-verification-test/src/assets/images/poses/rotate_face.jpeg +0 -0
  202. package/projects/facecog-liveness-verification-test/src/assets/images/poses/shake_head.jpeg +0 -0
  203. package/projects/facecog-liveness-verification-test/src/assets/images/poses/smile.png +0 -0
  204. package/projects/facecog-liveness-verification-test/src/assets/images/poses/tilt_left.png +0 -0
  205. package/projects/facecog-liveness-verification-test/src/assets/images/poses/tilt_right.png +0 -0
  206. package/projects/facecog-liveness-verification-test/src/assets/images/poses/touch_chin_left.jpg +0 -0
  207. package/projects/facecog-liveness-verification-test/src/assets/images/poses/touch_left_cheek.jpeg +0 -0
  208. package/projects/facecog-liveness-verification-test/src/assets/images/poses/touch_nose_right.png +0 -0
  209. package/projects/facecog-liveness-verification-test/src/assets/images/poses/touch_right_cheek.jpeg +0 -0
  210. package/projects/facecog-liveness-verification-test/src/assets/images/poses/turn_left.png +0 -0
  211. package/projects/facecog-liveness-verification-test/src/assets/images/poses/turn_right.png +0 -0
  212. package/projects/facecog-liveness-verification-test/src/assets/images/poses/wink.jpeg +0 -0
  213. package/projects/facecog-liveness-verification-test/src/assets/images/reference-pose.jpg +0 -0
  214. package/projects/facecog-liveness-verification-test/src/assets/shapes.svg +1 -0
  215. package/projects/facecog-liveness-verification-test/src/environments/environment.prod.ts +4 -0
  216. package/projects/facecog-liveness-verification-test/src/environments/environment.ts +17 -0
  217. package/projects/facecog-liveness-verification-test/src/global.scss +288 -0
  218. package/projects/facecog-liveness-verification-test/src/index.html +31 -0
  219. package/projects/facecog-liveness-verification-test/src/main.ts +6 -0
  220. package/projects/facecog-liveness-verification-test/src/polyfills.ts +55 -0
  221. package/projects/facecog-liveness-verification-test/src/theme/nextsapien-theme.scss +174 -0
  222. package/projects/facecog-liveness-verification-test/src/theme/variables.scss +2 -0
  223. package/projects/facecog-liveness-verification-test/src/zone-flags.ts +6 -0
  224. package/projects/facecog-liveness-verification-test/tsconfig.app.json +15 -0
  225. package/projects/facecog-liveness-verification-test/tsconfig.spec.json +14 -0
  226. package/setup-jest.ts +118 -0
  227. package/tsconfig.json +41 -0
  228. package/tsconfig.spec.json +15 -0
  229. package/vercel.json +24 -0
@@ -0,0 +1,500 @@
1
+ import {
2
+ Component,
3
+ ChangeDetectorRef,
4
+ ElementRef,
5
+ EventEmitter,
6
+ Input,
7
+ OnInit,
8
+ OnDestroy,
9
+ Output,
10
+ ViewChild,
11
+ AfterViewInit,
12
+ NgZone,
13
+ ViewEncapsulation
14
+ } from '@angular/core';
15
+ import { CommonModule } from '@angular/common';
16
+ import { IonicModule } from '@ionic/angular';
17
+ import { firstValueFrom } from 'rxjs';
18
+ import * as React from 'react';
19
+ import * as ReactDOM from 'react-dom/client';
20
+ import { AwsFaceLivenessService } from '../../services/aws-face-liveness.service';
21
+ import type { AwsFaceLivenessScanResult } from '../../interfaces/scan-results.interface';
22
+
23
+ /**
24
+ * AwsFaceLivenessComponent
25
+ *
26
+ * Angular wrapper for AWS Amplify FaceLivenessDetector React component.
27
+ * Handles real-time face liveness detection using AWS Rekognition.
28
+ *
29
+ * Used by LivenessFlowComponent when AWS_FACE_LIVENESS_COMPONENT is provided (default from lib).
30
+ */
31
+ @Component({
32
+ selector: 'facecog-aws-face-liveness',
33
+ standalone: true,
34
+ imports: [CommonModule, IonicModule],
35
+ encapsulation: ViewEncapsulation.None,
36
+ template: `
37
+ <div class="aws-face-liveness-container">
38
+ <div *ngIf="isLoading" class="loading-container">
39
+ <ion-spinner name="crescent" color="primary"></ion-spinner>
40
+ <p class="loading-text">{{ loadingMessage }}</p>
41
+ </div>
42
+
43
+ <div *ngIf="error && !isLoading" class="error-container">
44
+ <ion-icon name="alert-circle-outline" color="danger"></ion-icon>
45
+ <p class="error-text">{{ error }}</p>
46
+ <ion-button (click)="retry()" expand="block" color="primary">
47
+ Retry
48
+ </ion-button>
49
+ </div>
50
+
51
+ <div #reactContainer
52
+ class="react-container"
53
+ [style.display]="!isLoading && !error ? 'block' : 'none'">
54
+ </div>
55
+ </div>
56
+ `,
57
+ styles: [`
58
+ .aws-face-liveness-container {
59
+ display: flex;
60
+ flex-direction: column;
61
+ height: 100%;
62
+ width: 100%;
63
+ background: #1a1a2e;
64
+ position: relative;
65
+ }
66
+
67
+ .loading-container,
68
+ .error-container {
69
+ display: flex;
70
+ flex-direction: column;
71
+ align-items: center;
72
+ justify-content: center;
73
+ height: 100%;
74
+ padding: 20px;
75
+ text-align: center;
76
+ }
77
+
78
+ .loading-text,
79
+ .error-text {
80
+ color: #e0e0e0;
81
+ margin-top: 16px;
82
+ font-size: 16px;
83
+ }
84
+
85
+ .error-container ion-icon {
86
+ font-size: 64px;
87
+ }
88
+
89
+ .error-container ion-button {
90
+ margin-top: 20px;
91
+ max-width: 200px;
92
+ }
93
+
94
+ .react-container {
95
+ flex: 1;
96
+ width: 100%;
97
+ height: 100%;
98
+ min-height: 400px;
99
+ }
100
+
101
+ /* Amplify Liveness Detector overrides for Ionic modal context */
102
+ .face-liveness-container {
103
+ width: 100% !important;
104
+ height: 100% !important;
105
+ min-height: 400px;
106
+ overflow: auto !important;
107
+ }
108
+
109
+ [data-amplify-liveness-detector] {
110
+ width: 100% !important;
111
+ height: auto !important;
112
+ min-height: 400px;
113
+ overflow: visible !important;
114
+ }
115
+
116
+ [data-amplify-liveness-detector] > .amplify-flex {
117
+ width: 100% !important;
118
+ height: auto !important;
119
+ min-height: 400px;
120
+ flex-direction: column !important;
121
+ overflow: visible !important;
122
+ }
123
+
124
+ .amplify-liveness-oval-canvas {
125
+ width: 100% !important;
126
+ height: 100% !important;
127
+ }
128
+
129
+ .amplify-liveness-video-container,
130
+ .amplify-liveness-canvas-container,
131
+ [class*="VideoContainer"] {
132
+ width: 100% !important;
133
+ max-height: 70vh !important;
134
+ }
135
+
136
+ [class*="Instructions"],
137
+ [class*="Hint"] {
138
+ padding: 16px !important;
139
+ text-align: center !important;
140
+ }
141
+
142
+ .amplify-liveness-recording-icon-container {
143
+ position: fixed !important;
144
+ top: 20px !important;
145
+ right: 20px !important;
146
+ z-index: 10002 !important;
147
+ }
148
+
149
+ .amplify-view {
150
+ width: 100% !important;
151
+ height: auto !important;
152
+ overflow: visible !important;
153
+ }
154
+
155
+ /* Hide the cancel button — verification is mandatory */
156
+ .amplify-liveness-cancel-button,
157
+ button[class*="cancel" i],
158
+ button[class*="Cancel"],
159
+ [data-amplify-liveness-detector] button[class*="link"],
160
+ [data-amplify-liveness-detector] .amplify-button--link {
161
+ display: none !important;
162
+ }
163
+
164
+ /* Photosensitivity warning — high contrast styling */
165
+ [class*="PhotosensitiveWarning"],
166
+ [class*="photosensitive"],
167
+ [data-amplify-liveness-detector] [class*="Warning"] {
168
+ background: #2d1b4e !important;
169
+ border: 1px solid #7c4dff !important;
170
+ border-radius: 12px !important;
171
+ padding: 16px !important;
172
+ margin: 12px !important;
173
+ }
174
+
175
+ [class*="PhotosensitiveWarning"] *,
176
+ [class*="photosensitive"] *,
177
+ [data-amplify-liveness-detector] [class*="Warning"] * {
178
+ color: #e8d5ff !important;
179
+ }
180
+
181
+ [class*="PhotosensitiveWarning"] h2,
182
+ [class*="PhotosensitiveWarning"] [class*="heading"],
183
+ [class*="PhotosensitiveWarning"] [class*="Heading"] {
184
+ color: #fff !important;
185
+ font-weight: 700 !important;
186
+ }
187
+
188
+ /* Start video check button — prominent styling */
189
+ .amplify-button--primary,
190
+ [data-amplify-liveness-detector] button[class*="primary"] {
191
+ background: linear-gradient(135deg, #00b4d8, #0077b6) !important;
192
+ color: #fff !important;
193
+ font-weight: 600 !important;
194
+ font-size: 16px !important;
195
+ padding: 14px 28px !important;
196
+ border-radius: 12px !important;
197
+ border: none !important;
198
+ box-shadow: 0 4px 15px rgba(0, 119, 182, 0.4) !important;
199
+ text-transform: none !important;
200
+ letter-spacing: 0.3px !important;
201
+ }
202
+
203
+ .amplify-button--primary:hover,
204
+ [data-amplify-liveness-detector] button[class*="primary"]:hover {
205
+ background: linear-gradient(135deg, #0096c7, #005f8a) !important;
206
+ box-shadow: 0 6px 20px rgba(0, 119, 182, 0.5) !important;
207
+ }
208
+ `]
209
+ })
210
+ export class AwsFaceLivenessComponent implements OnInit, AfterViewInit, OnDestroy {
211
+ @ViewChild('reactContainer', { static: false }) reactContainer!: ElementRef<HTMLDivElement>;
212
+
213
+ @Input() region: string = 'us-east-1';
214
+ @Input() autoStart: boolean = true;
215
+ @Input() showCancelButton: boolean = true;
216
+
217
+ @Input() accessKeyId?: string;
218
+ @Input() secretAccessKey?: string;
219
+ @Input() sessionToken?: string;
220
+
221
+ @Input() identityPoolId?: string;
222
+ @Input() userPoolId?: string;
223
+ @Input() userPoolClientId?: string;
224
+
225
+ @Output() scanComplete = new EventEmitter<AwsFaceLivenessScanResult>();
226
+ @Output() scanCancelled = new EventEmitter<void>();
227
+
228
+ isLoading = true;
229
+ loadingMessage = 'Initializing AWS Face Liveness...';
230
+ error: string | null = null;
231
+
232
+ private sessionId: string = '';
233
+ private reactRoot: any = null;
234
+ private awsCredentials: { accessKeyId: string; secretAccessKey: string; region: string } | null = null;
235
+ private injectedStyleIds: string[] = [];
236
+
237
+ constructor(
238
+ private ngZone: NgZone,
239
+ private cdr: ChangeDetectorRef,
240
+ private awsFaceLivenessService: AwsFaceLivenessService
241
+ ) {}
242
+
243
+ ngOnInit(): void {
244
+ console.log('[AWS Face Liveness] ngOnInit - autoStart:', this.autoStart, 'region:', this.region);
245
+ this.injectAmplifyStyles();
246
+ }
247
+
248
+ ngAfterViewInit(): void {
249
+ console.log('[AWS Face Liveness] ngAfterViewInit - autoStart:', this.autoStart, 'reactContainer:', !!this.reactContainer);
250
+ if (this.autoStart) {
251
+ setTimeout(() => {
252
+ console.log('[AWS Face Liveness] Starting liveness check after delay');
253
+ this.startLivenessCheck();
254
+ }, 500);
255
+ }
256
+ }
257
+
258
+ ngOnDestroy(): void {
259
+ this.cleanup();
260
+ }
261
+
262
+ async startLivenessCheck(): Promise<void> {
263
+ console.log('[AWS Face Liveness] startLivenessCheck called');
264
+ try {
265
+ this.isLoading = true;
266
+ this.error = null;
267
+ this.cdr.detectChanges();
268
+
269
+ if (!this.accessKeyId || !this.secretAccessKey) {
270
+ this.loadingMessage = 'Fetching AWS credentials...';
271
+ this.cdr.detectChanges();
272
+ console.log('[AWS Face Liveness] Fetching credentials...');
273
+ const credentialsResponse = await this.awsFaceLivenessService.getCredentialsAsync();
274
+ console.log('[AWS Face Liveness] Credentials response:', credentialsResponse?.success);
275
+
276
+ if (!credentialsResponse.success) {
277
+ throw new Error(credentialsResponse.error || 'Failed to get AWS credentials');
278
+ }
279
+
280
+ this.awsCredentials = credentialsResponse.credentials;
281
+ this.region = this.awsCredentials.region;
282
+ }
283
+
284
+ this.loadingMessage = 'Creating liveness session...';
285
+ this.cdr.detectChanges();
286
+ console.log('[AWS Face Liveness] Creating session...');
287
+ const sessionResponse = await firstValueFrom(this.awsFaceLivenessService.createSession());
288
+ console.log('[AWS Face Liveness] Session response:', sessionResponse?.success, sessionResponse?.sessionId);
289
+
290
+ if (!sessionResponse || !sessionResponse.success) {
291
+ throw new Error(sessionResponse?.error || 'Failed to create liveness session');
292
+ }
293
+
294
+ this.sessionId = sessionResponse.sessionId;
295
+
296
+ this.loadingMessage = 'Starting camera...';
297
+ this.cdr.detectChanges();
298
+ console.log('[AWS Face Liveness] Rendering React component...');
299
+ await this.renderReactComponent();
300
+
301
+ this.isLoading = false;
302
+ this.cdr.detectChanges();
303
+ console.log('[AWS Face Liveness] React component rendered, loading complete');
304
+
305
+ } catch (error: any) {
306
+ console.error('[AWS Face Liveness] Error starting liveness check:', error);
307
+ this.error = error.message || 'Failed to start liveness check';
308
+ this.isLoading = false;
309
+ this.cdr.detectChanges();
310
+ }
311
+ }
312
+
313
+ private async renderReactComponent(): Promise<void> {
314
+ if (!this.reactContainer?.nativeElement) {
315
+ throw new Error('React container not found');
316
+ }
317
+
318
+ const mod = await import('./FaceLivenessReactWrapper');
319
+ const FaceLivenessReactWrapper = mod?.default;
320
+ if (!FaceLivenessReactWrapper) {
321
+ this.error = 'AWS Face Liveness wrapper failed to load.';
322
+ this.isLoading = false;
323
+ this.cdr.detectChanges();
324
+ return;
325
+ }
326
+
327
+ this.reactRoot = ReactDOM.createRoot(this.reactContainer.nativeElement);
328
+
329
+ const accessKey = this.accessKeyId || this.awsCredentials?.accessKeyId;
330
+ const secretKey = this.secretAccessKey || this.awsCredentials?.secretAccessKey;
331
+
332
+ this.reactRoot.render(
333
+ React.createElement(FaceLivenessReactWrapper, {
334
+ sessionId: this.sessionId,
335
+ region: this.region,
336
+ accessKeyId: accessKey,
337
+ secretAccessKey: secretKey,
338
+ sessionToken: this.sessionToken,
339
+ identityPoolId: this.identityPoolId,
340
+ userPoolId: this.userPoolId,
341
+ userPoolClientId: this.userPoolClientId,
342
+ enableVideoRecording: true,
343
+ onAnalysisComplete: (result: any) => {
344
+ this.ngZone.run(() => {
345
+ this.onAnalysisComplete(result);
346
+ });
347
+ },
348
+ onError: (error: Error) => {
349
+ this.ngZone.run(() => {
350
+ this.onError(error);
351
+ });
352
+ },
353
+ onUserCancel: () => {
354
+ this.cancel();
355
+ }
356
+ })
357
+ );
358
+ }
359
+
360
+ private async onAnalysisComplete(result: any): Promise<void> {
361
+ try {
362
+ this.isLoading = true;
363
+ this.loadingMessage = 'Verifying results...';
364
+ this.cdr.detectChanges();
365
+
366
+ const resultsResponse = await firstValueFrom(this.awsFaceLivenessService.getSessionResults(this.sessionId));
367
+
368
+ if (!resultsResponse) {
369
+ throw new Error('Failed to get liveness results');
370
+ }
371
+
372
+ this.scanComplete.emit({
373
+ success: resultsResponse.success && resultsResponse.isLive,
374
+ isLive: resultsResponse.isLive,
375
+ confidence: resultsResponse.confidence,
376
+ confidencePercent: resultsResponse.confidencePercent,
377
+ sessionId: this.sessionId,
378
+ metadata: resultsResponse.metadata,
379
+ error: resultsResponse.error,
380
+ videoBlob: result?.videoBlob,
381
+ startVideoCheckClickedAt: result?.startVideoCheckClickedAt,
382
+ recordingStartedAt: result?.recordingStartedAt,
383
+ });
384
+
385
+ } catch (error: any) {
386
+ this.scanComplete.emit({
387
+ success: false,
388
+ isLive: false,
389
+ confidence: 0,
390
+ confidencePercent: 0,
391
+ sessionId: this.sessionId,
392
+ error: error.message || 'Failed to get liveness results'
393
+ });
394
+ } finally {
395
+ this.isLoading = false;
396
+ this.cleanup();
397
+ this.cdr.detectChanges();
398
+ }
399
+ }
400
+
401
+ private onError(error: Error): void {
402
+ const errorMsg = error.message || 'Face liveness detection failed';
403
+ console.error('[AWS Face Liveness] onError:', errorMsg);
404
+ this.error = errorMsg;
405
+ this.isLoading = false;
406
+ this.cdr.detectChanges();
407
+
408
+ this.scanComplete.emit({
409
+ success: false,
410
+ isLive: false,
411
+ confidence: 0,
412
+ confidencePercent: 0,
413
+ sessionId: this.sessionId,
414
+ error: `Camera or liveness check failed: ${errorMsg}. Please check:\n• Camera is enabled in System Settings\n• Browser has camera permission\n• No other app is using the camera\n• Try using Chrome or Edge`,
415
+ });
416
+ }
417
+
418
+ retry(): void {
419
+ this.cleanup();
420
+ this.startLivenessCheck();
421
+ }
422
+
423
+ cancel(): void {
424
+ this.cleanup();
425
+ this.scanCancelled.emit();
426
+ }
427
+
428
+ private injectAmplifyStyles(): void {
429
+ const id = 'amplify-liveness-critical-styles';
430
+ if (document.getElementById(id)) return;
431
+
432
+ const style = document.createElement('style');
433
+ style.id = id;
434
+ style.textContent = `
435
+ /* Amplify Liveness theme variables */
436
+ [data-amplify-theme] {
437
+ --amplify-colors-background-primary: #fff;
438
+ --amplify-colors-background-secondary: #f5f5f5;
439
+ --amplify-colors-font-primary: #0d1926;
440
+ --amplify-colors-font-secondary: #304050;
441
+ --amplify-colors-brand-primary-10: #e8f0fe;
442
+ --amplify-colors-brand-primary-80: #047d95;
443
+ --amplify-colors-brand-primary-90: #036170;
444
+ --amplify-colors-brand-primary-100: #01424d;
445
+ --amplify-colors-border-primary: #c5c5c5;
446
+ --amplify-space-xs: 0.25rem;
447
+ --amplify-space-small: 0.5rem;
448
+ --amplify-space-medium: 1rem;
449
+ --amplify-space-large: 1.5rem;
450
+ --amplify-radii-small: 4px;
451
+ --amplify-radii-medium: 8px;
452
+ --amplify-font-sizes-small: 0.875rem;
453
+ --amplify-font-sizes-medium: 1rem;
454
+ --amplify-font-sizes-large: 1.25rem;
455
+ }
456
+
457
+ /* Ensure the liveness detector fills its container */
458
+ .liveness-detector { position: relative; width: 100%; height: 100%; }
459
+ .liveness-detector video { width: 100% !important; height: 100% !important; object-fit: cover; }
460
+
461
+ /* Amplify Liveness oval and canvas overlay */
462
+ .liveness-detector canvas {
463
+ position: absolute !important;
464
+ top: 0; left: 0;
465
+ width: 100% !important;
466
+ height: 100% !important;
467
+ z-index: 2;
468
+ }
469
+
470
+ /* Hint text styling */
471
+ [data-amplify-liveness-hint] {
472
+ position: absolute;
473
+ bottom: 20px;
474
+ left: 50%;
475
+ transform: translateX(-50%);
476
+ z-index: 10;
477
+ background: rgba(0,0,0,0.7);
478
+ color: #fff;
479
+ padding: 8px 16px;
480
+ border-radius: 8px;
481
+ font-size: 16px;
482
+ text-align: center;
483
+ }
484
+ `;
485
+ document.head.appendChild(style);
486
+ this.injectedStyleIds.push(id);
487
+ console.log('[AWS Face Liveness] Injected critical liveness styles');
488
+ }
489
+
490
+ private cleanup(): void {
491
+ if (this.reactRoot) {
492
+ try {
493
+ this.reactRoot.unmount();
494
+ } catch (e) {
495
+ // ignore
496
+ }
497
+ this.reactRoot = null;
498
+ }
499
+ }
500
+ }
@@ -0,0 +1,41 @@
1
+ <div class="camera-permission-wrapper">
2
+ <div class="permission-container">
3
+ <div class="content-wrapper">
4
+ <div class="icon-container">
5
+ <ion-icon name="camera" class="camera-icon"></ion-icon>
6
+ </div>
7
+
8
+ <ion-text class="permission-text">
9
+ <h2>Camera Access Required</h2>
10
+ <p>We need access to your camera to verify your identity through liveness detection.</p>
11
+
12
+ <div class="tips-container" *ngIf="poseSpecificMode">
13
+ <div class="tip-item blocking-notice">
14
+ <ion-icon name="lock-closed-outline"></ion-icon>
15
+ <span>This verification is required to continue using the app.</span>
16
+ </div>
17
+ <div class="tip-item">
18
+ <ion-icon name="sunny-outline"></ion-icon>
19
+ <span>Make sure you are in a well-lit environment for best results.</span>
20
+ </div>
21
+ <div class="tip-item">
22
+ <ion-icon name="person-outline"></ion-icon>
23
+ <span>Position your face clearly in the center of the camera.</span>
24
+ </div>
25
+ </div>
26
+
27
+ <p *ngIf="!poseSpecificMode">Your privacy is important to us. The camera feed will only be used for verification and will not be stored.</p>
28
+ </ion-text>
29
+
30
+ <div class="button-container">
31
+ <ion-button expand="block" (click)="requestPermission()">
32
+ Grant Access
33
+ </ion-button>
34
+
35
+ <button class="cancel-link" *ngIf="!hideCancel" (click)="onLater()">
36
+ Later
37
+ </button>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </div>