@frankieone/one-sdk 1.0.0-beta → 1.1.0-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 (275) hide show
  1. package/dist/commit.txt +2 -2
  2. package/dist/esm/features.config.d.ts +39 -0
  3. package/dist/esm/features.config.d.ts.map +1 -0
  4. package/dist/esm/features.config.js +38 -0
  5. package/dist/esm/features.config.js.map +1 -0
  6. package/dist/esm/modules/biometrics/vendors/Incode/index.d.ts +1 -1
  7. package/dist/esm/modules/biometrics/vendors/Incode/index.d.ts.map +1 -1
  8. package/dist/esm/modules/biometrics/vendors/Incode/index.js +15 -1
  9. package/dist/esm/modules/biometrics/vendors/Incode/index.js.map +1 -1
  10. package/dist/esm/modules/biometrics/vendors/OcrLabs/index.d.ts +1 -1
  11. package/dist/esm/modules/biometrics/vendors/OcrLabs/index.d.ts.map +1 -1
  12. package/dist/esm/modules/biometrics/vendors/OcrLabs/index.js +3 -27
  13. package/dist/esm/modules/biometrics/vendors/OcrLabs/index.js.map +1 -1
  14. package/dist/esm/modules/biometrics/vendors/Onfido/index.d.ts +1 -1
  15. package/dist/esm/modules/biometrics/vendors/Onfido/index.d.ts.map +1 -1
  16. package/dist/esm/modules/biometrics/vendors/Onfido/index.js +9 -9
  17. package/dist/esm/modules/biometrics/vendors/Onfido/index.js.map +1 -1
  18. package/dist/esm/modules/biometrics/vendors/dummy-biometrics/index.d.ts +1 -1
  19. package/dist/esm/modules/common/errors/{OneSDKError.d.ts → OneSDKError.class.d.ts} +1 -1
  20. package/dist/esm/modules/common/errors/OneSDKError.class.d.ts.map +1 -0
  21. package/dist/esm/modules/common/errors/{OneSDKError.js → OneSDKError.class.js} +1 -1
  22. package/dist/esm/modules/common/errors/OneSDKError.class.js.map +1 -0
  23. package/dist/esm/modules/common/index.d.ts +1 -1
  24. package/dist/esm/modules/common/index.d.ts.map +1 -1
  25. package/dist/esm/modules/common/index.js +1 -1
  26. package/dist/esm/modules/common/index.js.map +1 -1
  27. package/dist/esm/modules/common/modules/HOF.d.ts +2 -2
  28. package/dist/esm/modules/common/modules/HOF.js +1 -1
  29. package/dist/esm/modules/common/modules/error.d.ts +2 -2
  30. package/dist/esm/modules/common/modules/error.js +2 -2
  31. package/dist/esm/modules/common/modules/error.js.map +1 -1
  32. package/dist/esm/modules/common/modules/eventHub/index.d.ts +2 -2
  33. package/dist/esm/modules/common/modules/eventHub/index.d.ts.map +1 -1
  34. package/dist/esm/modules/common/modules/eventHub/index.js +59 -12
  35. package/dist/esm/modules/common/modules/eventHub/index.js.map +1 -1
  36. package/dist/esm/modules/common/modules/eventHub/types.d.ts +11 -8
  37. package/dist/esm/modules/common/modules/eventHub/types.d.ts.map +1 -1
  38. package/dist/esm/modules/common/modules/eventHub/windowEventHub.d.ts +13 -0
  39. package/dist/esm/modules/common/modules/eventHub/windowEventHub.d.ts.map +1 -0
  40. package/dist/esm/modules/common/modules/eventHub/windowEventHub.js +39 -0
  41. package/dist/esm/modules/common/modules/eventHub/windowEventHub.js.map +1 -0
  42. package/dist/esm/modules/common/modules/vendorLoading.d.ts +10 -10
  43. package/dist/esm/modules/common/modules/vendorLoading.d.ts.map +1 -1
  44. package/dist/esm/modules/common/modules/vendorLoading.js +2 -2
  45. package/dist/esm/modules/common/modules/vendorLoading.js.map +1 -1
  46. package/dist/esm/modules/common/types/oneSDKModules/{BaseParameters.d.ts → baseParameters.types.d.ts} +1 -1
  47. package/dist/esm/modules/common/types/oneSDKModules/baseParameters.types.d.ts.map +1 -0
  48. package/dist/esm/modules/common/types/oneSDKModules/{BaseParameters.js → baseParameters.types.js} +1 -1
  49. package/dist/esm/modules/common/types/oneSDKModules/baseParameters.types.js.map +1 -0
  50. package/dist/esm/modules/common/types/oneSDKModules/definition.types.d.ts +15 -3
  51. package/dist/esm/modules/common/types/oneSDKModules/definition.types.d.ts.map +1 -1
  52. package/dist/esm/modules/common/types/oneSDKModules/index.d.ts +2 -2
  53. package/dist/esm/modules/common/types/oneSDKModules/index.d.ts.map +1 -1
  54. package/dist/esm/modules/common/types/oneSDKModules/index.js +2 -2
  55. package/dist/esm/modules/common/types/oneSDKModules/index.js.map +1 -1
  56. package/dist/esm/modules/common/types/oneSDKModules/initialiseFunction.d.ts +4 -4
  57. package/dist/esm/modules/common/types/oneSDKModules/initialiseFunction.d.ts.map +1 -1
  58. package/dist/esm/modules/common/types/oneSDKModules/initialiseFunction.js.map +1 -1
  59. package/dist/esm/modules/common/types/oneSDKModules/{TypeSystem.d.ts → typeSystem.types.d.ts} +1 -1
  60. package/dist/esm/modules/common/types/oneSDKModules/typeSystem.types.d.ts.map +1 -0
  61. package/dist/esm/modules/common/types/oneSDKModules/typeSystem.types.js +2 -0
  62. package/dist/esm/modules/common/types/oneSDKModules/typeSystem.types.js.map +1 -0
  63. package/dist/esm/modules/common/types/recipeConfiguration.types.d.ts +5 -11
  64. package/dist/esm/modules/common/types/recipeConfiguration.types.d.ts.map +1 -1
  65. package/dist/esm/modules/common/vendors/incode/index.d.ts +2 -1
  66. package/dist/esm/modules/common/vendors/incode/index.d.ts.map +1 -1
  67. package/dist/esm/modules/common/vendors/incode/index.js +2 -4
  68. package/dist/esm/modules/common/vendors/incode/index.js.map +1 -1
  69. package/dist/esm/modules/common/vendors/incode/startCamera.d.ts +1 -1
  70. package/dist/esm/modules/common/vendors/incode/startCamera.d.ts.map +1 -1
  71. package/dist/esm/modules/common/vendors/incode/startCamera.js +24 -2
  72. package/dist/esm/modules/common/vendors/incode/startCamera.js.map +1 -1
  73. package/dist/esm/modules/common/vendors/smart-ui/promisifySmartUI.d.ts +13 -0
  74. package/dist/esm/modules/common/vendors/smart-ui/promisifySmartUI.d.ts.map +1 -0
  75. package/dist/esm/modules/common/vendors/smart-ui/promisifySmartUI.js +30 -0
  76. package/dist/esm/modules/common/vendors/smart-ui/promisifySmartUI.js.map +1 -0
  77. package/dist/esm/modules/common/vendors/smart-ui/useSmartUI.d.ts +35 -0
  78. package/dist/esm/modules/common/vendors/smart-ui/useSmartUI.d.ts.map +1 -0
  79. package/dist/esm/modules/common/vendors/smart-ui/useSmartUI.js +60 -0
  80. package/dist/esm/modules/common/vendors/smart-ui/useSmartUI.js.map +1 -0
  81. package/dist/esm/modules/config/modules.d.ts +4 -2
  82. package/dist/esm/modules/config/modules.d.ts.map +1 -1
  83. package/dist/esm/modules/config/modules.js +9 -7
  84. package/dist/esm/modules/config/modules.js.map +1 -1
  85. package/dist/esm/modules/idv/actions/mount.d.ts +14 -0
  86. package/dist/esm/modules/idv/actions/mount.d.ts.map +1 -0
  87. package/dist/esm/modules/idv/actions/mount.js +67 -0
  88. package/dist/esm/modules/idv/actions/mount.js.map +1 -0
  89. package/dist/esm/modules/idv/definition.types.d.ts +2 -1
  90. package/dist/esm/modules/idv/definition.types.d.ts.map +1 -1
  91. package/dist/esm/modules/idv/{events.d.ts → events.types.d.ts} +1 -1
  92. package/dist/esm/modules/idv/events.types.d.ts.map +1 -0
  93. package/dist/esm/modules/idv/events.types.js +2 -0
  94. package/dist/esm/modules/idv/events.types.js.map +1 -0
  95. package/dist/esm/modules/idv/index.d.ts.map +1 -1
  96. package/dist/esm/modules/idv/index.js +19 -73
  97. package/dist/esm/modules/idv/index.js.map +1 -1
  98. package/dist/esm/modules/idv/vendors/Incode/index.d.ts +5 -6
  99. package/dist/esm/modules/idv/vendors/Incode/index.d.ts.map +1 -1
  100. package/dist/esm/modules/idv/vendors/Incode/index.js +6 -5
  101. package/dist/esm/modules/idv/vendors/Incode/index.js.map +1 -1
  102. package/dist/esm/modules/idv/vendors/Mastercard/index.d.ts +5 -5
  103. package/dist/esm/modules/idv/vendors/Mastercard/index.d.ts.map +1 -1
  104. package/dist/esm/modules/idv/vendors/Mastercard/index.js +11 -12
  105. package/dist/esm/modules/idv/vendors/Mastercard/index.js.map +1 -1
  106. package/dist/esm/modules/idv/vendors/OcrLabs/endFlow.js +1 -1
  107. package/dist/esm/modules/idv/vendors/OcrLabs/endFlow.js.map +1 -1
  108. package/dist/esm/modules/idv/vendors/OcrLabs/index.d.ts +3 -2
  109. package/dist/esm/modules/idv/vendors/OcrLabs/index.d.ts.map +1 -1
  110. package/dist/esm/modules/idv/vendors/OcrLabs/startDummyFlow.d.ts +2 -2
  111. package/dist/esm/modules/idv/vendors/OcrLabs/startDummyFlow.d.ts.map +1 -1
  112. package/dist/esm/modules/idv/vendors/OcrLabs/startDummyFlow.js +2 -2
  113. package/dist/esm/modules/idv/vendors/OcrLabs/startDummyFlow.js.map +1 -1
  114. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.d.ts +7 -5
  115. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.d.ts.map +1 -1
  116. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.js +1 -1
  117. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.js.map +1 -1
  118. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframeEventListener.d.ts +11 -5
  119. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframeEventListener.d.ts.map +1 -1
  120. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframeEventListener.js +9 -4
  121. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframeEventListener.js.map +1 -1
  122. package/dist/esm/modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.d.ts +8 -4
  123. package/dist/esm/modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.d.ts.map +1 -1
  124. package/dist/esm/modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.js +58 -46
  125. package/dist/esm/modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.js.map +1 -1
  126. package/dist/esm/modules/idv/vendors/common/iframeUtils/updateIndividualModuleState.d.ts +12 -0
  127. package/dist/esm/modules/idv/vendors/common/iframeUtils/updateIndividualModuleState.d.ts.map +1 -0
  128. package/dist/esm/modules/idv/vendors/common/iframeUtils/updateIndividualModuleState.js +34 -0
  129. package/dist/esm/modules/idv/vendors/common/iframeUtils/updateIndividualModuleState.js.map +1 -0
  130. package/dist/esm/modules/index.d.ts +7 -7
  131. package/dist/esm/modules/index.d.ts.map +1 -1
  132. package/dist/esm/modules/index.js +16 -11
  133. package/dist/esm/modules/index.js.map +1 -1
  134. package/dist/esm/modules/individual/actions/search.d.ts +3 -3
  135. package/dist/esm/modules/individual/actions/search.d.ts.map +1 -1
  136. package/dist/esm/modules/individual/actions/search.js +8 -8
  137. package/dist/esm/modules/individual/actions/search.js.map +1 -1
  138. package/dist/esm/modules/individual/actions/submit.d.ts +11 -8
  139. package/dist/esm/modules/individual/actions/submit.d.ts.map +1 -1
  140. package/dist/esm/modules/individual/actions/submit.js +41 -20
  141. package/dist/esm/modules/individual/actions/submit.js.map +1 -1
  142. package/dist/esm/modules/individual/definition.d.ts +13 -13
  143. package/dist/esm/modules/individual/definition.d.ts.map +1 -1
  144. package/dist/esm/modules/individual/index.d.ts +3 -3
  145. package/dist/esm/modules/individual/index.js +23 -23
  146. package/dist/esm/modules/meta.json +1 -1
  147. package/dist/esm/modules/ocr/actions/mount.d.ts +9 -4
  148. package/dist/esm/modules/ocr/actions/mount.d.ts.map +1 -1
  149. package/dist/esm/modules/ocr/actions/mount.js +54 -32
  150. package/dist/esm/modules/ocr/actions/mount.js.map +1 -1
  151. package/dist/esm/modules/ocr/actions/start.d.ts +1 -0
  152. package/dist/esm/modules/ocr/actions/start.d.ts.map +1 -1
  153. package/dist/esm/modules/ocr/actions/start.js +85 -69
  154. package/dist/esm/modules/ocr/actions/start.js.map +1 -1
  155. package/dist/esm/modules/ocr/definition.d.ts +21 -9
  156. package/dist/esm/modules/ocr/definition.d.ts.map +1 -1
  157. package/dist/esm/modules/ocr/index.d.ts.map +1 -1
  158. package/dist/esm/modules/ocr/index.js +6 -4
  159. package/dist/esm/modules/ocr/index.js.map +1 -1
  160. package/dist/esm/modules/ocr/vendors/Incode/index.d.ts +13 -2
  161. package/dist/esm/modules/ocr/vendors/Incode/index.d.ts.map +1 -1
  162. package/dist/esm/modules/ocr/vendors/Incode/index.js +13 -18
  163. package/dist/esm/modules/ocr/vendors/Incode/index.js.map +1 -1
  164. package/dist/esm/modules/ocr/vendors/Onfido/index.d.ts +13 -2
  165. package/dist/esm/modules/ocr/vendors/Onfido/index.d.ts.map +1 -1
  166. package/dist/esm/modules/ocr/vendors/Onfido/index.js +17 -20
  167. package/dist/esm/modules/ocr/vendors/Onfido/index.js.map +1 -1
  168. package/dist/esm/modules/ocr/vendors/common/initProcess.d.ts +20 -9
  169. package/dist/esm/modules/ocr/vendors/common/initProcess.d.ts.map +1 -1
  170. package/dist/esm/modules/ocr/vendors/common/initProcess.js +52 -17
  171. package/dist/esm/modules/ocr/vendors/common/initProcess.js.map +1 -1
  172. package/dist/esm/modules/ocr/vendors/common/mutationObserver.d.ts +2 -2
  173. package/dist/esm/modules/ocr/vendors/common/mutationObserver.d.ts.map +1 -1
  174. package/dist/esm/modules/ocr/vendors/common/mutationObserver.js +2 -2
  175. package/dist/esm/modules/ocr/vendors/common/mutationObserver.js.map +1 -1
  176. package/dist/esm/modules/ocr/vendors/dummy-ocr/index.d.ts +13 -2
  177. package/dist/esm/modules/ocr/vendors/dummy-ocr/index.d.ts.map +1 -1
  178. package/dist/esm/modules/sdk/devTools/attachDevTools.d.ts +22 -0
  179. package/dist/esm/modules/sdk/devTools/attachDevTools.d.ts.map +1 -0
  180. package/dist/esm/modules/sdk/devTools/attachDevTools.js +38 -0
  181. package/dist/esm/modules/sdk/devTools/attachDevTools.js.map +1 -0
  182. package/dist/esm/modules/sdk/index.d.ts +2 -2
  183. package/dist/esm/modules/sdk/index.d.ts.map +1 -1
  184. package/dist/esm/modules/sdk/index.js +17 -13
  185. package/dist/esm/modules/sdk/index.js.map +1 -1
  186. package/dist/esm/modules/sdk/initialisation/componentLoader.d.ts +147 -36
  187. package/dist/esm/modules/sdk/initialisation/componentLoader.d.ts.map +1 -1
  188. package/dist/esm/modules/sdk/initialisation/componentLoader.js +14 -11
  189. package/dist/esm/modules/sdk/initialisation/componentLoader.js.map +1 -1
  190. package/dist/esm/modules/sdk/initialisation/sharedDependencies.d.ts +4 -4
  191. package/dist/esm/modules/sdk/initialisation/sharedDependencies.js +26 -26
  192. package/dist/esm/modules/sdk/initialisation/sharedDependencies.js.map +1 -1
  193. package/dist/esm/modules/sdk/types/oneSDKParameters.d.ts +5 -4
  194. package/dist/esm/modules/sdk/types/oneSDKParameters.d.ts.map +1 -1
  195. package/dist/esm/modules/sdk/types/oneSDKParameters.js.map +1 -1
  196. package/dist/esm/modules/session/SessionContext.d.ts +1 -1
  197. package/dist/esm/modules/session/SessionContext.js +6 -6
  198. package/dist/esm/modules/smart-ui/definition.d.ts +50 -0
  199. package/dist/esm/modules/smart-ui/definition.d.ts.map +1 -0
  200. package/dist/esm/modules/smart-ui/definition.js +2 -0
  201. package/dist/esm/modules/smart-ui/definition.js.map +1 -0
  202. package/dist/esm/modules/smart-ui/implementations/legacy/i18n.json +6 -0
  203. package/dist/esm/modules/smart-ui/implementations/legacy/index.d.ts +54 -0
  204. package/dist/esm/modules/smart-ui/implementations/legacy/index.d.ts.map +1 -0
  205. package/dist/esm/modules/smart-ui/implementations/legacy/index.js +75 -0
  206. package/dist/esm/modules/smart-ui/implementations/legacy/index.js.map +1 -0
  207. package/dist/esm/modules/smart-ui/implementations/legacy/loadSmartUI.d.ts +9 -0
  208. package/dist/esm/modules/smart-ui/implementations/legacy/loadSmartUI.d.ts.map +1 -0
  209. package/dist/esm/modules/smart-ui/implementations/legacy/loadSmartUI.js +42 -0
  210. package/dist/esm/modules/smart-ui/implementations/legacy/loadSmartUI.js.map +1 -0
  211. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIEvents.types.d.ts +23 -0
  212. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIEvents.types.d.ts.map +1 -0
  213. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIEvents.types.js +2 -0
  214. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIEvents.types.js.map +1 -0
  215. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIOptions.types.d.ts +76 -0
  216. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIOptions.types.d.ts.map +1 -0
  217. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIOptions.types.js +2 -0
  218. package/dist/esm/modules/smart-ui/implementations/legacy/smartUIOptions.types.js.map +1 -0
  219. package/dist/esm/modules/smart-ui/index.d.ts +4 -0
  220. package/dist/esm/modules/smart-ui/index.d.ts.map +1 -0
  221. package/dist/esm/modules/smart-ui/index.js +26 -0
  222. package/dist/esm/modules/smart-ui/index.js.map +1 -0
  223. package/dist/esm/modules/smart-ui/validateConfiguration.d.ts +6 -0
  224. package/dist/esm/modules/smart-ui/validateConfiguration.d.ts.map +1 -0
  225. package/dist/esm/modules/smart-ui/validateConfiguration.js +10 -0
  226. package/dist/esm/modules/smart-ui/validateConfiguration.js.map +1 -0
  227. package/dist/esm/modules/types.d.ts +16 -16
  228. package/dist/esm/modules/types.d.ts.map +1 -1
  229. package/dist/esm/modules/types.js +4 -4
  230. package/dist/esm/modules/types.js.map +1 -1
  231. package/dist/release.txt +2 -2
  232. package/dist/umd/biometrics-dummy.js +1 -1
  233. package/dist/umd/biometrics-incode.js +1 -1
  234. package/dist/umd/biometrics-incode.js.map +1 -1
  235. package/dist/umd/biometrics-ocrlabs.js +1 -1
  236. package/dist/umd/biometrics-ocrlabs.js.map +1 -1
  237. package/dist/umd/biometrics-onfido.js +1 -1
  238. package/dist/umd/biometrics-onfido.js.map +1 -1
  239. package/dist/umd/device-sardine.js +1 -1
  240. package/dist/umd/idv-incode.js +1 -1
  241. package/dist/umd/idv-incode.js.map +1 -1
  242. package/dist/umd/idv-mastercard.js +1 -1
  243. package/dist/umd/idv-mastercard.js.map +1 -1
  244. package/dist/umd/idv-ocrlabs.js +1 -1
  245. package/dist/umd/idv-ocrlabs.js.map +1 -1
  246. package/dist/umd/ocr-dummy.js +1 -1
  247. package/dist/umd/ocr-dummy.js.map +1 -1
  248. package/dist/umd/ocr-incode.js +1 -1
  249. package/dist/umd/ocr-incode.js.map +1 -1
  250. package/dist/umd/ocr-onfido.js +1 -1
  251. package/dist/umd/ocr-onfido.js.map +1 -1
  252. package/dist/umd/oneSdk.umd.js +1 -1
  253. package/dist/umd/oneSdk.umd.js.map +1 -1
  254. package/dist/umd/smartui-legacy.js +2 -0
  255. package/dist/umd/smartui-legacy.js.map +1 -0
  256. package/dist/version.txt +2 -2
  257. package/package.json +1 -1
  258. package/dist/esm/modules/common/errors/OneSDKError.d.ts.map +0 -1
  259. package/dist/esm/modules/common/errors/OneSDKError.js.map +0 -1
  260. package/dist/esm/modules/common/types/oneSDKModules/BaseParameters.d.ts.map +0 -1
  261. package/dist/esm/modules/common/types/oneSDKModules/BaseParameters.js.map +0 -1
  262. package/dist/esm/modules/common/types/oneSDKModules/TypeSystem.d.ts.map +0 -1
  263. package/dist/esm/modules/common/types/oneSDKModules/TypeSystem.js +0 -2
  264. package/dist/esm/modules/common/types/oneSDKModules/TypeSystem.js.map +0 -1
  265. package/dist/esm/modules/idv/events.d.ts.map +0 -1
  266. package/dist/esm/modules/idv/events.js +0 -2
  267. package/dist/esm/modules/idv/events.js.map +0 -1
  268. package/dist/esm/modules/ocr/vendors/common/mutation-observer.d.ts +0 -4
  269. package/dist/esm/modules/ocr/vendors/common/mutation-observer.d.ts.map +0 -1
  270. package/dist/esm/modules/ocr/vendors/common/mutation-observer.js +0 -21
  271. package/dist/esm/modules/ocr/vendors/common/mutation-observer.js.map +0 -1
  272. package/dist/esm/modules/ocr/vendors/common/status-evaluators.d.ts +0 -18
  273. package/dist/esm/modules/ocr/vendors/common/status-evaluators.d.ts.map +0 -1
  274. package/dist/esm/modules/ocr/vendors/common/status-evaluators.js +0 -11
  275. package/dist/esm/modules/ocr/vendors/common/status-evaluators.js.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[9],{97624:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>u});var i=t(10573),o=t(77836),r=t(33415),c=t(51682),s=t(99434),a=t(36932),d=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function c(e){try{a(i.next(e))}catch(e){r(e)}}function s(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,s)}a((i=i.apply(e,n||[])).next())}))};const u=(0,s.J)("onfido",((e,n)=>d(void 0,void 0,void 0,(function*(){let t=!1;const{frankieClient:o,recipe:r}=e,{biometrics:{provider:s}}=r,{mountElement:u,eventHub:b}=n,p=new a.Bv(o),y=yield(0,i.e)(p,b);if(!y)return;v(b);const{token:h}=y,k=(0,c.init)({token:h,containerEl:u,steps:[{type:"face",options:{requestedVariant:"motion",motionFallbackVariant:"onfido"===s.name&&s.fallback}}],useModal:!0,isModalOpen:!0,disableAnalytics:!0,disableAnalyticsCookies:!0,onComplete:()=>d(void 0,void 0,void 0,(function*(){t||(t=!0,yield l({idvClient:p,recipe:r,eventHub:b}),yield f({instance:k,recipe:r,eventHub:b}))})),onError:e=>d(void 0,void 0,void 0,(function*(){m({error:e,recipe:r,eventHub:b}),yield f({instance:k,recipe:r,eventHub:b})})),onUserExit:e=>d(void 0,void 0,void 0,(function*(){b.emit("detection_failed",{message:e}),yield f({instance:k,recipe:r,eventHub:b})})),onModalRequestClose:()=>d(void 0,void 0,void 0,(function*(){b.emit("detection_failed",{message:null}),yield f({instance:k,recipe:r,eventHub:b})}))});return{}})))),v=e=>{const n=document.querySelector("body");new MutationObserver(((n,t)=>{var i;for(const o of n){const n=null===(i=o.addedNodes)||void 0===i?void 0:i[0];(null==n?void 0:n.classList.contains("onfido-sdk-ui-Theme-portal"))&&(e.emit("ready",{domElement:n}),t.disconnect())}})).observe(n,{childList:!0,subtree:!0})},l=({idvClient:e,recipe:n,eventHub:t})=>d(void 0,void 0,void 0,(function*(){const i=(0,o.q)(n);t.emit("detection_complete");try{yield(0,r.g)({idvClient:e,recipe:n,eventHub:t})}catch(e){const{message:n=""}=e;t.emit("error",i("INIT_PROCESS",{message:n}))}})),m=({error:e,recipe:n,eventHub:t})=>{const i=(0,o.q)(n),{message:r=""}=e;t.emit("error",i("DEFAULT",{message:r}))},f=({instance:e,recipe:n,eventHub:t})=>d(void 0,void 0,void 0,(function*(){const i=(0,o.q)(n);try{yield e.safeTearDown(),t.emit("session_closed")}catch(e){const{message:n=""}=e;t.emit("error",i("DEFAULT",{message:n}))}}))},10573:(e,n,t)=>{t.d(n,{e:()=>i});const i=(e,n)=>{return t=void 0,i=void 0,r=function*(){try{const{entityId:t,token:i,vendorParameters:o}=yield e.getToken();return n.emit("session_data_generated",{session:{entityId:t,token:i,vendorParameters:o}}),{entityId:t,token:i,vendorParameters:o}}catch(e){const{code:t=null,message:i=""}=e;return n.emit("session_data_failed_loading",{code:t,message:i}),null}},new((o=void 0)||(o=Promise))((function(e,n){function c(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(n){var t;n.done?e(n.value):(t=n.value,t instanceof o?t:new o((function(e){e(t)}))).then(c,s)}a((r=r.apply(t,i||[])).next())}));var t,i,o,r}},77836:(e,n,t)=>{t.d(n,{q:()=>r});var i=t(96834),o=t(36932);const r=e=>{const{biometrics:{provider:{name:n}}}=e;return(e,...t)=>{return new i.OneSDKError((r=n,{DEFAULT:`Error from vendor SDK '${r}'`,INIT_PROCESS:"Error from biometrics submission",[o.ck.PROVIDER_OFFLINE]:`Error initialising biometrics check with '${r}'. The service doesn't appear to be available.`,[o.ck.WAITING_DOC_UPLOAD]:`Error initialising biometrics check with '${r}'. You might need to run the 'ocr' component before running 'biometrics'.`,[o.ck.WAITING_SELFIE_UPLOAD]:`Error initialising biometrics check with '${r}'. You might need to capture selfie before running 'biometrics'.`})[e],t);var r}}},33415:(e,n,t)=>{t.d(n,{g:()=>r});var i=t(77836),o=t(36932);const r=({idvClient:e,recipe:n,eventHub:t})=>{return r=void 0,c=void 0,a=function*(){const{biometrics:{is_synchronous:r}}=n,c=(0,i.q)(n),{checkStatus:s,ocrDocument:a}=yield e.initProcess({isSynchronous:!!r});(0,o.b9)(s)||(0,o.KM)(s)?t.emit("error",c(s)):t.emit(r?"results":"processing",{checkStatus:s,document:a,entityId:e.entityId})},new((s=void 0)||(s=Promise))((function(e,n){function t(e){try{o(a.next(e))}catch(e){n(e)}}function i(e){try{o(a.throw(e))}catch(e){n(e)}}function o(n){var o;n.done?e(n.value):(o=n.value,o instanceof s?o:new s((function(e){e(o)}))).then(t,i)}o((a=a.apply(r,c||[])).next())}));var r,c,s,a}}}]);
1
+ "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[9],{97624:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>u});var i=t(10573),o=t(77836),r=t(33415),c=t(51682),s=t(99434),a=t(36932),d=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function c(e){try{a(i.next(e))}catch(e){r(e)}}function s(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,s)}a((i=i.apply(e,n||[])).next())}))};const u=(0,s.J)("onfido",((e,n)=>d(void 0,void 0,void 0,(function*(){let t=!1;const{frankieClient:o,recipe:r}=e,{biometrics:{provider:s}}=r,{mountElement:u,eventHub:b}=n,p=new a.Bv(o),y=yield(0,i.e)(p,b);if(!y)return;v(b);const{token:h}=y,k=(0,c.init)({token:h,containerEl:u,steps:[{type:"face",options:{requestedVariant:"motion",motionFallbackVariant:"onfido"===s.name&&s.fallback}}],useModal:!0,isModalOpen:!0,disableAnalytics:!0,disableAnalyticsCookies:!0,onComplete:()=>d(void 0,void 0,void 0,(function*(){t||(t=!0,yield l({idvClient:p,recipe:r,eventHub:b}),yield f({instance:k,recipe:r,eventHub:b}))})),onError:e=>d(void 0,void 0,void 0,(function*(){m({error:e,recipe:r,eventHub:b}),yield f({instance:k,recipe:r,eventHub:b})})),onUserExit:e=>d(void 0,void 0,void 0,(function*(){b.emit("detection_failed",{message:e}),yield f({instance:k,recipe:r,eventHub:b})})),onModalRequestClose:()=>d(void 0,void 0,void 0,(function*(){b.emit("detection_failed",{message:null}),yield f({instance:k,recipe:r,eventHub:b})}))});return{}})))),v=e=>{const n=document.querySelector("body");new MutationObserver(((n,t)=>{var i;for(const o of n){const n=null===(i=o.addedNodes)||void 0===i?void 0:i[0];(null==n?void 0:n.classList.contains("onfido-sdk-ui-Theme-portal"))&&(e.emit("ready",{domElement:n}),t.disconnect())}})).observe(n,{childList:!0,subtree:!0})},l=({idvClient:e,recipe:n,eventHub:t})=>d(void 0,void 0,void 0,(function*(){const i=(0,o.q)(n);t.emit("detection_complete");try{yield(0,r.g)({idvClient:e,recipe:n,eventHub:t})}catch(e){const{message:n=""}=e;t.emit("error",i("INIT_PROCESS",{message:n}))}})),m=({error:e,recipe:n,eventHub:t})=>{const i=(0,o.q)(n),{message:r=""}=e;t.emit("error",i("DEFAULT",{message:r}))},f=({instance:e,recipe:n,eventHub:t})=>d(void 0,void 0,void 0,(function*(){const i=(0,o.q)(n);try{yield e.safeTearDown(),t.emit("session_closed")}catch(e){const{message:n=""}=e;t.emit("error",i("DEFAULT",{message:n}))}}))},10573:(e,n,t)=>{t.d(n,{e:()=>i});const i=(e,n)=>{return t=void 0,i=void 0,r=function*(){try{const{entityId:t,token:i,vendorParameters:o}=yield e.getToken();return n.emit("session_data_generated",{session:{entityId:t,token:i,vendorParameters:o}}),{entityId:t,token:i,vendorParameters:o}}catch(e){const{code:t=null,message:i=""}=e;return n.emit("session_data_failed_loading",{code:t,message:i}),null}},new((o=void 0)||(o=Promise))((function(e,n){function c(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(n){var t;n.done?e(n.value):(t=n.value,t instanceof o?t:new o((function(e){e(t)}))).then(c,s)}a((r=r.apply(t,i||[])).next())}));var t,i,o,r}},77836:(e,n,t)=>{t.d(n,{q:()=>r});var i=t(77494),o=t(36932);const r=e=>{const{biometrics:{provider:{name:n}}}=e;return(e,...t)=>{return new i.OneSDKError((r=n,{DEFAULT:`Error from vendor SDK '${r}'`,INIT_PROCESS:"Error from biometrics submission",[o.ck.PROVIDER_OFFLINE]:`Error initialising biometrics check with '${r}'. The service doesn't appear to be available.`,[o.ck.WAITING_DOC_UPLOAD]:`Error initialising biometrics check with '${r}'. You might need to run the 'ocr' component before running 'biometrics'.`,[o.ck.WAITING_SELFIE_UPLOAD]:`Error initialising biometrics check with '${r}'. You might need to capture selfie before running 'biometrics'.`})[e],t);var r}}},33415:(e,n,t)=>{t.d(n,{g:()=>r});var i=t(77836),o=t(36932);const r=({idvClient:e,recipe:n,eventHub:t})=>{return r=void 0,c=void 0,a=function*(){const{biometrics:{is_synchronous:r}}=n,c=(0,i.q)(n),{checkStatus:s,ocrDocument:a}=yield e.initProcess({isSynchronous:!!r});(0,o.b9)(s)||(0,o.KM)(s)?t.emit("error",c(s)):t.emit(r?"results":"processing",{checkStatus:s,document:a,entityId:e.entityId})},new((s=void 0)||(s=Promise))((function(e,n){function t(e){try{o(a.next(e))}catch(e){n(e)}}function i(e){try{o(a.throw(e))}catch(e){n(e)}}function o(n){var o;n.done?e(n.value):(o=n.value,o instanceof s?o:new s((function(e){e(o)}))).then(t,i)}o((a=a.apply(r,c||[])).next())}));var r,c,s,a}}}]);
2
2
  //# sourceMappingURL=biometrics-onfido.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"biometrics-onfido.js","mappings":"2eAiBO,MAAMA,GAAa,OACxB,UACA,CACEC,EACAC,IACG,OAAD,6BACF,IAAIC,GAAiB,EACrB,MAAM,cAAEC,EAAa,OAAEC,GAAWJ,GAC1BK,YAAY,SAAEC,IAAeF,GAC/B,aAAEG,EAAY,SAAEC,GAAaP,EAC7BQ,EAAY,IAAIC,EAAA,GAAUP,GAG1BQ,QAAmB,EAAAC,EAAA,GAAcH,EAAWD,GAElD,IAAKG,EAAY,OAEj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EAC7E,CAAC,KAAUgE,uBAAwB,6CAA6ChE,sEAajCa,GAAO6C,GAlBhC,IAAC1D,CAkBuC,CAC7D,C,6DCjBI,MAAMkD,EAAc,EACvB/C,YAAWL,SAAQI,eAKlB,O,OAAD,E,OAAA,E,EAAA,YACF,MAAQH,YAAckE,eAAgBC,IAAoBpE,EACpDmD,GAAgB,OAASnD,IACzB,YACJqE,EAAW,YACXC,SACQjE,EAAU+C,YAAY,CAAEgB,gBAAiBA,KAC/C,QAAsBC,KAAgB,QAAcA,GACtDjE,EAAS4B,KAAK,QAASmB,EAAekB,IAEtCjE,EAAS4B,KAAKoC,EAAgB,UAAY,aAAc,CACtDC,cACAjC,SAAUkC,EACVhB,SAAUjD,EAAUiD,UAG1B,E,YAhBI,K,6QAgBH,C","sources":["webpack://OneSdk/./modules/biometrics/vendors/Onfido/index.ts","webpack://OneSdk/./modules/biometrics/vendors/common/createSession.ts","webpack://OneSdk/./modules/biometrics/vendors/common/errors.ts","webpack://OneSdk/./modules/biometrics/vendors/common/initProcess.ts"],"sourcesContent":["import type { BiometricsModule } from '@module/biometrics';\nimport type { Events } from '@module/biometrics/events';\nimport { createSession } from '@module/biometrics/vendors/common/createSession';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport { initProcess } from '@module/biometrics/vendors/common/initProcess';\nimport type {\n SdkError,\n SdkHandle,\n UserExitCode,\n} from '@module/biometrics/vendors/Onfido/onfido-sdk-ui';\nimport { init } from '@module/biometrics/vendors/Onfido/onfido-sdk-ui';\nimport type { EventHub } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport type { InjectedState } from '@module/common/types';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport const initialise = defineWrapper<BiometricsModule>(\n 'onfido',\n async (\n shared: InjectedState,\n options: BiometricsModule['wrapperOptions'],\n ) => {\n let runOnceAlready = false;\n const { frankieClient, recipe } = shared;\n const { biometrics: { provider } } = recipe;\n const { mountElement, eventHub } = options;\n const idvClient = new IDVClient(frankieClient);\n\n // generate onfido sdk token from backend\n const idvSession = await createSession(idvClient, eventHub);\n // terminate initialising if session failed\n if (!idvSession) return;\n\n observeModalReady(eventHub);\n\n // initialise onfido instance\n const { token } = idvSession;\n const Onfido: SdkHandle = init({\n token,\n containerEl: mountElement,\n steps: [\n {\n type: 'face',\n options: {\n requestedVariant: 'motion',\n motionFallbackVariant: provider.name === 'onfido' && provider.fallback,\n },\n },\n ],\n useModal: true,\n isModalOpen: true,\n disableAnalytics: true,\n disableAnalyticsCookies: true,\n onComplete: async (): Promise<void> => {\n if (!runOnceAlready) {\n runOnceAlready = true;\n await handleComplete({ idvClient, recipe, eventHub });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n }\n },\n onError: async (error: SdkError): Promise<void> => {\n handleError({ error, recipe, eventHub });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n },\n onUserExit: async (error: UserExitCode) => {\n eventHub.emit('detection_failed', {\n message: error,\n });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n },\n onModalRequestClose: async () => {\n eventHub.emit('detection_failed', {\n message: null,\n });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n },\n });\n return {};\n },\n);\n\nconst observeModalReady = (eventHub: EventHub<Events>): void => {\n // Select the target node\n const targetNode = document.querySelector('body');\n // Create an observer instance\n const observer = new MutationObserver((\n mutations: MutationRecord[],\n observer: MutationObserver,\n ) => {\n for (const mutation of mutations) {\n const mutationElement = mutation.addedNodes?.[0] as HTMLElement;\n if (mutationElement?.classList.contains('onfido-sdk-ui-Theme-portal')) {\n eventHub.emit('ready', { domElement: mutationElement });\n // stop observing\n observer.disconnect();\n }\n }\n });\n // Options for the observer (which mutations to observe)\n const config = { childList: true, subtree: true };\n // Start observing the target node for specified mutations\n observer.observe(targetNode, config);\n};\n\nconst handleComplete = async ({ idvClient, recipe, eventHub }: {\n idvClient: IDVClient;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n },\n): Promise<void> => {\n const errorMessages = mkErrors(recipe);\n eventHub.emit('detection_complete');\n try {\n await initProcess({ idvClient, recipe, eventHub });\n } catch (error) {\n const { message = '' } = error;\n eventHub.emit('error', errorMessages('INIT_PROCESS', { message }));\n }\n};\n\nconst handleError = ({ error, recipe, eventHub }: {\n error: SdkError;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n },\n): void => {\n const errorMessages = mkErrors(recipe);\n const { message = '' } = error;\n eventHub.emit('error', errorMessages('DEFAULT', { message }));\n};\n\n// destroy onfido instance\nconst removeVendorSdk = async ({ instance, recipe, eventHub }: {\n instance: SdkHandle;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n },\n): Promise<void> => {\n const errorMessages = mkErrors(recipe);\n try {\n await instance.safeTearDown();\n eventHub.emit('session_closed');\n } catch (error) {\n const { message = '' } = error;\n eventHub.emit('error', errorMessages('DEFAULT', { message }));\n }\n};\n","import type { Events } from '@module/biometrics/events';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { _DictionaryWrite } from '@types';\n\n/**\n * Creates a session by obtaining an entity ID, token, and vendor parameters from an IDVClient.\n * It will also emit 'session_data_generated' event to the provided event hub.\n * This function won't throw errors. Instead, it will emit 'session_data_failed_loading' and return null.\n *\n * @param idvClient - The IDVClient instance used to obtain the session data.\n * @param eventHub - The EventHub instance for emitting session-related events.\n * @returns A Promise that resolves with an object containing entityId, token, and vendorParameters upon success, or null if a session couldn't be created\n */\nexport const createSession = async <T extends _DictionaryWrite<unknown>>(\n idvClient: IDVClient,\n eventHub: EventHub<Events>,\n): Promise<{ entityId: string; token: string; vendorParameters: T } | null> => {\n try {\n const { entityId, token, vendorParameters } = await idvClient.getToken<T>();\n eventHub.emit('session_data_generated', {\n session: { entityId, token, vendorParameters },\n });\n return { entityId, token, vendorParameters };\n } catch (error) {\n const { code = null, message = '' } = error;\n eventHub.emit('session_data_failed_loading', { code, message });\n return null;\n }\n};\n","import { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport type ErrorMessages = Record<\n 'DEFAULT' | 'INIT_PROCESS' | Extract<IDVStatus, 'PROVIDER_OFFLINE' | 'WAITING_DOC_UPLOAD' | 'WAITING_SELFIE_UPLOAD'>,\n string\n>;\n\nconst mkErrorMessages = (provider: string): ErrorMessages => ({\n DEFAULT: `Error from vendor SDK '${provider}'`,\n INIT_PROCESS: 'Error from biometrics submission',\n [IDVStatus.PROVIDER_OFFLINE]: `Error initialising biometrics check with '${provider}'. The service doesn't appear to be available.`,\n [IDVStatus.WAITING_DOC_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to run the 'ocr' component before running 'biometrics'.`,\n [IDVStatus.WAITING_SELFIE_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to capture selfie before running 'biometrics'.`,\n});\n\nexport const mkErrors = (recipe: RecipeParsed) => {\n const {\n biometrics: {\n provider: {\n name,\n },\n },\n } = recipe;\n\n return (type: keyof ErrorMessages, ...payload: unknown[]) => {\n return new OneSDKError(mkErrorMessages(name)[type], payload);\n };\n \n};\n","import type { Events } from '@module/biometrics/events';\nimport type { ErrorMessages } from '@module/biometrics/vendors/common/errors';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport {\n isErrorStatus,\n isInputRequiredStatus,\n} from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport const initProcess = async (\n { idvClient, recipe, eventHub }: {\n idvClient: IDVClient;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n },\n) => {\n const { biometrics: { is_synchronous: isSynchronous } } = recipe;\n const errorMessages = mkErrors(recipe);\n const {\n checkStatus,\n ocrDocument,\n } = await idvClient.initProcess({ isSynchronous: !!isSynchronous });\n if (isInputRequiredStatus(checkStatus) || isErrorStatus(checkStatus)) {\n eventHub.emit('error', errorMessages((checkStatus as keyof ErrorMessages)));\n } else {\n eventHub.emit(isSynchronous ? 'results' : 'processing', {\n checkStatus,\n document: ocrDocument,\n entityId: idvClient.entityId,\n });\n }\n};\n"],"names":["initialise","shared","options","runOnceAlready","frankieClient","recipe","biometrics","provider","mountElement","eventHub","idvClient","IDVClient","idvSession","createSession","observeModalReady","token","Onfido","init","containerEl","steps","type","requestedVariant","motionFallbackVariant","name","fallback","useModal","isModalOpen","disableAnalytics","disableAnalyticsCookies","onComplete","handleComplete","removeVendorSdk","instance","onError","error","handleError","onUserExit","emit","message","onModalRequestClose","targetNode","document","querySelector","MutationObserver","mutations","observer","mutation","mutationElement","addedNodes","classList","contains","domElement","disconnect","observe","childList","subtree","errorMessages","initProcess","safeTearDown","entityId","vendorParameters","getToken","session","code","mkErrors","payload","OneSDKError","DEFAULT","INIT_PROCESS","PROVIDER_OFFLINE","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","is_synchronous","isSynchronous","checkStatus","ocrDocument"],"sourceRoot":""}
1
+ {"version":3,"file":"biometrics-onfido.js","mappings":"2eAaO,MAAMA,GAAa,OACxB,UACA,CAAOC,EAAuBC,IAAgD,OAAD,6BAC3E,IAAIC,GAAiB,EACrB,MAAM,cAAEC,EAAa,OAAEC,GAAWJ,GAEhCK,YAAY,SAAEC,IACZF,GACE,aAAEG,EAAY,SAAEC,GAAaP,EAC7BQ,EAAY,IAAIC,EAAA,GAAUP,GAG1BQ,QAAmB,EAAAC,EAAA,GAAcH,EAAWD,GAElD,IAAKG,EAAY,OAEjBE,EAAkBL,GAGlB,MAAM,MAAEM,GAAUH,EACZI,GAAoB,IAAAC,MAAK,CAC7BF,QACAG,YAAaV,EACbW,MAAO,CACL,CACEC,KAAM,OACNlB,QAAS,CACPmB,iBAAkB,SAClBC,sBAAyC,WAAlBf,EAASgB,MAAqBhB,EAASiB,YAIpEC,UAAU,EACV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AgB,OAASnD,IACzB,YACJqE,EAAW,YACXC,SACQjE,EAAU+C,YAAY,CAAEgB,gBAAiBA,KAC/C,QAAsBC,KAAgB,QAAcA,GACtDjE,EAAS4B,KAAK,QAASmB,EAAekB,IAEtCjE,EAAS4B,KAAKoC,EAAgB,UAAY,aAAc,CACtDC,cACAjC,SAAUkC,EACVhB,SAAUjD,EAAUiD,UAG1B,E,YAhBI,K,6QAgBH,C","sources":["webpack://OneSdk/./modules/biometrics/vendors/Onfido/index.ts","webpack://OneSdk/./modules/biometrics/vendors/common/createSession.ts","webpack://OneSdk/./modules/biometrics/vendors/common/errors.ts","webpack://OneSdk/./modules/biometrics/vendors/common/initProcess.ts"],"sourcesContent":["import type { BiometricsModule } from '@module/biometrics';\nimport type { Events } from '@module/biometrics/events';\nimport { createSession } from '@module/biometrics/vendors/common/createSession';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport { initProcess } from '@module/biometrics/vendors/common/initProcess';\nimport type { SdkError, SdkHandle, UserExitCode } from '@module/biometrics/vendors/Onfido/onfido-sdk-ui';\nimport { init } from '@module/biometrics/vendors/Onfido/onfido-sdk-ui';\nimport type { EventHub } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport type { InjectedState } from '@module/common/types';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport const initialise = defineWrapper<BiometricsModule>(\n 'onfido',\n async (shared: InjectedState, options: BiometricsModule['wrapperOptions']) => {\n let runOnceAlready = false;\n const { frankieClient, recipe } = shared;\n const {\n biometrics: { provider },\n } = recipe;\n const { mountElement, eventHub } = options;\n const idvClient = new IDVClient(frankieClient);\n\n // generate onfido sdk token from backend\n const idvSession = await createSession(idvClient, eventHub);\n // terminate initialising if session failed\n if (!idvSession) return;\n\n observeModalReady(eventHub);\n\n // initialise onfido instance\n const { token } = idvSession;\n const Onfido: SdkHandle = init({\n token,\n containerEl: mountElement,\n steps: [\n {\n type: 'face',\n options: {\n requestedVariant: 'motion',\n motionFallbackVariant: provider.name === 'onfido' && provider.fallback,\n },\n },\n ],\n useModal: true,\n isModalOpen: true,\n disableAnalytics: true,\n disableAnalyticsCookies: true,\n onComplete: async (): Promise<void> => {\n if (runOnceAlready) return;\n runOnceAlready = true;\n await handleComplete({ idvClient, recipe, eventHub });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n },\n onError: async (error: SdkError): Promise<void> => {\n handleError({ error, recipe, eventHub });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n },\n onUserExit: async (error: UserExitCode) => {\n eventHub.emit('detection_failed', {\n message: error,\n });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n },\n onModalRequestClose: async () => {\n eventHub.emit('detection_failed', {\n message: null,\n });\n await removeVendorSdk({ instance: Onfido, recipe, eventHub });\n },\n });\n return {};\n },\n);\n\nconst observeModalReady = (eventHub: EventHub<Events>): void => {\n // Select the target node\n const targetNode = document.querySelector('body');\n // Create an observer instance\n const observer = new MutationObserver((mutations: MutationRecord[], observer: MutationObserver) => {\n for (const mutation of mutations) {\n const mutationElement = mutation.addedNodes?.[0] as HTMLElement;\n if (mutationElement?.classList.contains('onfido-sdk-ui-Theme-portal')) {\n eventHub.emit('ready', { domElement: mutationElement });\n // stop observing\n observer.disconnect();\n }\n }\n });\n // Options for the observer (which mutations to observe)\n const config = { childList: true, subtree: true };\n // Start observing the target node for specified mutations\n observer.observe(targetNode, config);\n};\n\nconst handleComplete = async ({\n idvClient,\n recipe,\n eventHub,\n}: {\n idvClient: IDVClient;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n}): Promise<void> => {\n const errorMessages = mkErrors(recipe);\n eventHub.emit('detection_complete');\n try {\n await initProcess({ idvClient, recipe, eventHub });\n } catch (error) {\n const { message = '' } = error;\n eventHub.emit('error', errorMessages('INIT_PROCESS', { message }));\n }\n};\n\nconst handleError = ({\n error,\n recipe,\n eventHub,\n}: {\n error: SdkError;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n}): void => {\n const errorMessages = mkErrors(recipe);\n const { message = '' } = error;\n eventHub.emit('error', errorMessages('DEFAULT', { message }));\n};\n\n// destroy onfido instance\nconst removeVendorSdk = async ({\n instance,\n recipe,\n eventHub,\n}: {\n instance: SdkHandle;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n}): Promise<void> => {\n const errorMessages = mkErrors(recipe);\n try {\n await instance.safeTearDown();\n eventHub.emit('session_closed');\n } catch (error) {\n const { message = '' } = error;\n eventHub.emit('error', errorMessages('DEFAULT', { message }));\n }\n};\n","import type { Events } from '@module/biometrics/events';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { _DictionaryWrite } from '@types';\n\n/**\n * Creates a session by obtaining an entity ID, token, and vendor parameters from an IDVClient.\n * It will also emit 'session_data_generated' event to the provided event hub.\n * This function won't throw errors. Instead, it will emit 'session_data_failed_loading' and return null.\n *\n * @param idvClient - The IDVClient instance used to obtain the session data.\n * @param eventHub - The EventHub instance for emitting session-related events.\n * @returns A Promise that resolves with an object containing entityId, token, and vendorParameters upon success, or null if a session couldn't be created\n */\nexport const createSession = async <T extends _DictionaryWrite<unknown>>(\n idvClient: IDVClient,\n eventHub: EventHub<Events>,\n): Promise<{ entityId: string; token: string; vendorParameters: T } | null> => {\n try {\n const { entityId, token, vendorParameters } = await idvClient.getToken<T>();\n eventHub.emit('session_data_generated', {\n session: { entityId, token, vendorParameters },\n });\n return { entityId, token, vendorParameters };\n } catch (error) {\n const { code = null, message = '' } = error;\n eventHub.emit('session_data_failed_loading', { code, message });\n return null;\n }\n};\n","import { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport type ErrorMessages = Record<\n 'DEFAULT' | 'INIT_PROCESS' | Extract<IDVStatus, 'PROVIDER_OFFLINE' | 'WAITING_DOC_UPLOAD' | 'WAITING_SELFIE_UPLOAD'>,\n string\n>;\n\nconst mkErrorMessages = (provider: string): ErrorMessages => ({\n DEFAULT: `Error from vendor SDK '${provider}'`,\n INIT_PROCESS: 'Error from biometrics submission',\n [IDVStatus.PROVIDER_OFFLINE]: `Error initialising biometrics check with '${provider}'. The service doesn't appear to be available.`,\n [IDVStatus.WAITING_DOC_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to run the 'ocr' component before running 'biometrics'.`,\n [IDVStatus.WAITING_SELFIE_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to capture selfie before running 'biometrics'.`,\n});\n\nexport const mkErrors = (recipe: RecipeParsed) => {\n const {\n biometrics: {\n provider: {\n name,\n },\n },\n } = recipe;\n\n return (type: keyof ErrorMessages, ...payload: unknown[]) => {\n return new OneSDKError(mkErrorMessages(name)[type], payload);\n };\n \n};\n","import type { Events } from '@module/biometrics/events';\nimport type { ErrorMessages } from '@module/biometrics/vendors/common/errors';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport {\n isErrorStatus,\n isInputRequiredStatus,\n} from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport const initProcess = async (\n { idvClient, recipe, eventHub }: {\n idvClient: IDVClient;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n },\n) => {\n const { biometrics: { is_synchronous: isSynchronous } } = recipe;\n const errorMessages = mkErrors(recipe);\n const {\n checkStatus,\n ocrDocument,\n } = await idvClient.initProcess({ isSynchronous: !!isSynchronous });\n if (isInputRequiredStatus(checkStatus) || isErrorStatus(checkStatus)) {\n eventHub.emit('error', errorMessages((checkStatus as keyof ErrorMessages)));\n } else {\n eventHub.emit(isSynchronous ? 'results' : 'processing', {\n checkStatus,\n document: ocrDocument,\n entityId: idvClient.entityId,\n });\n }\n};\n"],"names":["initialise","shared","options","runOnceAlready","frankieClient","recipe","biometrics","provider","mountElement","eventHub","idvClient","IDVClient","idvSession","createSession","observeModalReady","token","Onfido","init","containerEl","steps","type","requestedVariant","motionFallbackVariant","name","fallback","useModal","isModalOpen","disableAnalytics","disableAnalyticsCookies","onComplete","handleComplete","removeVendorSdk","instance","onError","error","handleError","onUserExit","emit","message","onModalRequestClose","targetNode","document","querySelector","MutationObserver","mutations","observer","mutation","mutationElement","addedNodes","classList","contains","domElement","disconnect","observe","childList","subtree","errorMessages","initProcess","safeTearDown","entityId","vendorParameters","getToken","session","code","mkErrors","payload","OneSDKError","DEFAULT","INIT_PROCESS","PROVIDER_OFFLINE","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","is_synchronous","isSynchronous","checkStatus","ocrDocument"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[513],{36661:(e,n,i)=>{i.r(n),i.d(n,{initialise:()=>d});var t=i(72045),s=i(1604),o=i(96834),r=i(99434),c=i(21633),a=function(e,n,i,t){return new(i||(i=Promise))((function(s,o){function r(e){try{a(t.next(e))}catch(e){o(e)}}function c(e){try{a(t.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?s(e.value):(n=e.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,c)}a((t=t.apply(e,n||[])).next())}))};const d=(0,r.J)("sardine",((e,n)=>a(void 0,void 0,void 0,(function*(){const i=yield function(e){var n;return a(this,void 0,void 0,(function*(){return{customerID:null!==(n=e.session.customerChildID)&&void 0!==n?n:e.session.customerID,frankieClientID:e.recipe.deviceCharacteristics.provider.clientID,vendorSessionID:(0,t.Z)(),environment:e.recipe.deviceCharacteristics.provider.environment}}))}(e);n.eventHub.emit("session_data_generated",{session:i});const r=yield function(e,n,i){return a(this,void 0,void 0,(function*(){const e=i.environment,t=function(e){return"production"===e?"api.sardine.ai":"api.sandbox.sardine.ai"}(e),r=`https://${t}/assets/loader.min.js`;try{s.z.string().refine((e=>c.Z8.includes(e)),{message:`Activity Type should be one of the following: [${c.Z8.join(", ")}]`}).parse(n.activityType)}catch(e){throw new o.OneSDKError(e.issues[0].message,{receivedActivityType:n.activityType})}yield(0,o.loadAsyncAsset)(r);const a=window._Sardine.createContext({clientId:i.frankieClientID,sessionKey:i.vendorSessionID,environment:e,parentElement:document.body,flow:n.activityType,onDeviceResponse:function(e){n.eventHub.emit("device_characteristics_extracted",{deviceCharacteristics:e})}});return{set(e,i){const t=u[e];t&&(a.updateConfig({[t]:i}),n.eventHub.emit("value_set",{key:e,value:i}))}}}))}(0,n,i);return r})))),u={entityId:"userIdHash",activityType:"flow"}}}]);
1
+ "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[513],{36661:(e,n,i)=>{i.r(n),i.d(n,{initialise:()=>d});var t=i(72045),s=i(1604),o=i(77494),r=i(99434),c=i(21633),a=function(e,n,i,t){return new(i||(i=Promise))((function(s,o){function r(e){try{a(t.next(e))}catch(e){o(e)}}function c(e){try{a(t.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?s(e.value):(n=e.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,c)}a((t=t.apply(e,n||[])).next())}))};const d=(0,r.J)("sardine",((e,n)=>a(void 0,void 0,void 0,(function*(){const i=yield function(e){var n;return a(this,void 0,void 0,(function*(){return{customerID:null!==(n=e.session.customerChildID)&&void 0!==n?n:e.session.customerID,frankieClientID:e.recipe.deviceCharacteristics.provider.clientID,vendorSessionID:(0,t.Z)(),environment:e.recipe.deviceCharacteristics.provider.environment}}))}(e);n.eventHub.emit("session_data_generated",{session:i});const r=yield function(e,n,i){return a(this,void 0,void 0,(function*(){const e=i.environment,t=function(e){return"production"===e?"api.sardine.ai":"api.sandbox.sardine.ai"}(e),r=`https://${t}/assets/loader.min.js`;try{s.z.string().refine((e=>c.Z8.includes(e)),{message:`Activity Type should be one of the following: [${c.Z8.join(", ")}]`}).parse(n.activityType)}catch(e){throw new o.OneSDKError(e.issues[0].message,{receivedActivityType:n.activityType})}yield(0,o.loadAsyncAsset)(r);const a=window._Sardine.createContext({clientId:i.frankieClientID,sessionKey:i.vendorSessionID,environment:e,parentElement:document.body,flow:n.activityType,onDeviceResponse:function(e){n.eventHub.emit("device_characteristics_extracted",{deviceCharacteristics:e})}});return{set(e,i){const t=u[e];t&&(a.updateConfig({[t]:i}),n.eventHub.emit("value_set",{key:e,value:i}))}}}))}(0,n,i);return r})))),u={entityId:"userIdHash",activityType:"flow"}}}]);
2
2
  //# sourceMappingURL=device-sardine.js.map
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[737],{9283:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>i});const i=(0,n(19648).g)({vendor:"incode",dummyOptions:{title:"Incode IDV Dummy iframe",loadedPayload:"loaded",successPayload:{workflow:"INCODE_COMPLETE"}},eventOptions:{emitOnLoad:!0,mapMessageToEvent(e,t){const n=t.data,{workflow:i}=n;"INCODE_COMPLETE"===i&&e.emit("success",{sessionKey:"interviewId"})}}})},50750:(e,t,n)=>{n.d(t,{z:()=>a});var i=n(96834),o=n(36932);function a(e){const{eventHub:t,results:n,entityId:a}=e;switch(n.checkStatus){case o.ck.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:a});break;case o.ck.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:a});break;case o.ck.INTERRUPTED:case o.ck.INCOMPLETE:case o.ck.DOCUMENTS_INVALID:case o.ck.WAITING_DOC_UPLOAD:case o.ck.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:a},n.checkStatus);break;case o.ck.PROVIDER_OFFLINE:case o.ck.AWAITING_CONSENT:{const e=n.checkStatus===o.ck.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.ck.PROVIDER_OFFLINE}`:"Consent was not provided to the IDV Api. We can't continue.";t.emit("error",new i.OneSDKError(e,{errorStatus:n.checkStatus}))}break;case o.ck.CHECK_PROCESSING:t.emit("processing",{checkStatus:n.checkStatus,entityId:a});break;default:{const e=`Unexpected IDV status: ${n.checkStatus}`;t.emit("warning",{message:e,payload:n})}}}},85730:(e,t,n)=>{n.d(t,{E:()=>c,V:()=>a});var i=n(1306),o=n(96834);function a(e,t){const n=document.createElement("iframe"),a=function(e,t){const n=(0,o.mkEventHub)();return t.emitOnLoad&&(e.onload=()=>n.emit("loaded")),window.addEventListener("message",(i=>{i.source===e.contentWindow&&t.mapMessageToEvent(n,i,e)}),!1),(0,o.mkEventListener)(n)}(n,t.iframeMessagingOptions);return Object.assign(n.style,{border:0,margin:0,padding:0,width:"100%",height:"100%",fontSize:"100%",font:"inherit",verticalAlign:"baseline"}),n.allow="camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;",e.mode.is(i.Z.DUMMY)?n.srcdoc=function(e){const t=(e={})=>`window.parent.postMessage(${JSON.stringify(e)}, "*")`,n=e.loadedPayload?`setTimeout(() => ${t(e.loadedPayload)}, DUMMY_LOAD_DELAY)`:"",i=t(e.successPayload);return`<body style="background-color: white">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${n};\n function cancelClicked() {\n ${t(e.errorPayload)};\n }\n function completeClicked() {\n ${i};\n }\n <\/script>\n <h1>${e.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a "detection_complete" event</li>\n <li>Will trigger api calls, which will then emit the "results" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a "detection_failed" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id="actions-container">\n <button onclick="completeClicked()">Simulate Completion</button>\n <button onclick="cancelClicked()">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`}(t.dummyModeOptions):n.src=t.vendorParameters.tokenURL,{iframe:n,iframeListener:a}}function c(e){e.iframe.srcdoc="",e.internalEventHub.off(),e.iframe.remove()}},19648:(e,t,n)=>{n.d(t,{g:()=>r});var i=n(99434),o=n(50750),a=n(8707),c=n(85730),s=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function c(e){try{r(i.next(e))}catch(e){a(e)}}function s(e){try{r(i.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}r((i=i.apply(e,t||[])).next())}))};const r=e=>{const{dummyOptions:t,eventOptions:n,vendor:r}=e;return(0,i.J)(r,((e,i)=>s(void 0,void 0,void 0,(function*(){const{localEventHub:l}=e,{vendorParameters:d,idvClient:u,entityId:m}=yield(0,a.W)(e),{iframe:f,iframeListener:h}=(0,c.V)(e,{vendorParameters:d,dummyModeOptions:t,iframeMessagingOptions:n});h.on("success",(({checkId:t,sessionKey:n})=>s(void 0,void 0,void 0,(function*(){(0,c.E)({internalEventHub:h,iframe:f}),l.emit("detection_complete");const i=yield u.initProcess({isSynchronous:!0,vendorParameters:{checkId:null!=t?t:d[n]}});try{const t=e.oneSdkInstance.individual();yield t.search()}catch(e){const t="Error updating individual state. Check error events from module 'individual' for more details.This isn't related to IDV capture.";l.emit("warning",{message:t,payload:e})}(0,o.z)({eventHub:l,results:i,entityId:m})})))),h.on("error",(e=>{(0,c.E)({internalEventHub:h,iframe:f}),l.emit("detection_failed",{message:`Error from ${r}: ${e.message}`,payload:e.payload})})),h.on("loaded",(()=>{l.emit("ready",{domElement:f})}));const{mountElement:v}=i;v.appendChild(f)}))))}},8707:(e,t,n)=>{n.d(t,{W:()=>a});var i=n(36932),o=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function c(e){try{r(i.next(e))}catch(e){a(e)}}function s(e){try{r(i.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}r((i=i.apply(e,t||[])).next())}))};function a(e){return o(this,void 0,void 0,(function*(){const{localEventHub:t,frankieClient:n}=e;try{const o=new i.Bv(n),{vendorParameters:a,entityId:c}=yield o.getToken({relayState:e.relayState});return t.emit("session_data_generated",{session:Object.assign(Object.assign({},a),{entityId:c})}),{vendorParameters:a,idvClient:o,entityId:c}}catch(e){throw t.emit("session_data_failed_loading"),e}}))}}}]);
1
+ "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[737],{9283:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>i});const i=(0,n(19648).g)({vendor:"incode",dummyOptions:{title:"Incode IDV Dummy iframe",loadedPayload:"loaded",successPayload:{workflow:"INCODE_COMPLETE"}},eventOptions:{emitOnLoad:!0,mapMessageToEvent({targetEventHub:e,message:t,vendorParameters:n}){const i=t.data,{workflow:o}=i;if("INCODE_COMPLETE"===o){const t=n.interviewId;e.emit("success",{vendorParameters:{checkId:t}})}}}})},50750:(e,t,n)=>{n.d(t,{z:()=>r});var i=n(77494),o=n(36932);function r(e){const{eventHub:t,results:n,entityId:r}=e;switch(n.checkStatus){case o.ck.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:r});break;case o.ck.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:r});break;case o.ck.INTERRUPTED:case o.ck.INCOMPLETE:case o.ck.DOCUMENTS_INVALID:case o.ck.WAITING_DOC_UPLOAD:case o.ck.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:r},n.checkStatus);break;case o.ck.PROVIDER_OFFLINE:case o.ck.AWAITING_CONSENT:{const e=n.checkStatus===o.ck.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.ck.PROVIDER_OFFLINE}`:"Consent was not provided to the IDV Api. We can't continue.";t.emit("error",new i.OneSDKError(e,{errorStatus:n.checkStatus}))}break;case o.ck.CHECK_PROCESSING:t.emit("processing",{checkStatus:n.checkStatus,entityId:r});break;default:{const e=`Unexpected IDV status: ${n.checkStatus}`;t.emit("warning",{message:e,payload:n})}}}},85730:(e,t,n)=>{n.d(t,{E:()=>a,V:()=>r});var i=n(1306),o=n(77494);function r(e,t){const n=document.createElement("iframe"),r=function(e,t){const n=(0,o.mkEventHub)();return t.emitOnLoad&&(e.onload=()=>n.emit("loaded")),window.addEventListener("message",(i=>{i.source===e.contentWindow&&t.mapMessageToEvent({targetEventHub:n,message:i,iframeElement:e,vendorParameters:t.vendorParameters})}),!1),(0,o.mkEventListener)(n)}(n,t.iframeMessagingOptions);return Object.assign(n.style,{border:0,margin:0,padding:0,width:"100%",height:"100%",fontSize:"100%",font:"inherit",verticalAlign:"baseline"}),n.allow="camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;",e.mode.is(i.Z.DUMMY)?n.srcdoc=function(e){const t=(e={})=>`window.parent.postMessage(${JSON.stringify(e)}, "*")`,n=e.loadedPayload?`setTimeout(() => ${t(e.loadedPayload)}, DUMMY_LOAD_DELAY)`:"",i=t(e.successPayload);return`<body style="background-color: white">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${n};\n function cancelClicked() {\n ${t(e.errorPayload)};\n }\n function completeClicked() {\n ${i};\n }\n <\/script>\n <h1>${e.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a "detection_complete" event</li>\n <li>Will trigger api calls, which will then emit the "results" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a "detection_failed" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id="actions-container">\n <button onclick="completeClicked()">Simulate Completion</button>\n <button onclick="cancelClicked()">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`}(t.dummyModeOptions):n.src=t.vendorParameters.tokenURL,{iframe:n,iframeListener:r}}function a(e){e.iframe.srcdoc="",e.internalEventHub.off(),e.iframe.remove()}},19648:(e,t,n)=>{n.d(t,{g:()=>m});var i=n(41183),o=n(77494),r=n(99434),a=n(23851),s=n(28018),c=n(50750),d=n(8707),l=n(85730),u=function(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}))};const m=e=>{var t;const{dummyOptions:n,eventOptions:m,vendor:v}=e,p=null!==(t=i.Z.modules.idv.containsReviewScreen[v])&&void 0!==t&&t;return(0,r.J)(v,((e,t)=>u(void 0,void 0,void 0,(function*(){var i;const{localEventHub:r,recipe:f}=e,{mountElement:g}=t,h=null===(i=f.idv.provideReviewScreen)||void 0===i||i,k=!p&&h,E=(0,a.e)(),{vendorParameters:y,idvClient:I,entityId:w}=yield(0,d.W)(e),{iframe:O,iframeListener:b}=(0,l.V)(e,{vendorParameters:y,dummyModeOptions:n,iframeMessagingOptions:Object.assign(Object.assign({},m),{vendorParameters:y})});b.on("success",(({vendorParameters:e})=>u(void 0,void 0,void 0,(function*(){(0,l.E)({internalEventHub:b,iframe:O}),k?r.emit("info",{message:"Data extraction completed. Now executing user review using smart ui."}):r.emit("detection_complete"),r.emit("loading",!0,{message:"Retrieving IDV results"});try{const t=yield I.initProcess({isSynchronous:!0,vendorParameters:e});(0,c.z)({eventHub:E,results:t,entityId:w})}catch(e){r.emit("error",new o.OneSDKError("Failed initiating IDV processing",e)),r.emit("loading",!1,{message:"Failed retrieving IDV results"})}})))),b.on("error",(e=>{(0,l.E)({internalEventHub:b,iframe:O}),r.emit("detection_failed",{message:`Error from ${v}: ${e.message}`,payload:e.payload}),r.emit("loading",!1,{message:`Vendor '${v}' detection has failed`})})),b.on("loaded",(()=>{r.emit("ready",{domElement:O}),r.emit("loading",!1,{message:`Vendor '${v}' screen has loaded`})})),E.on("results",(0,s.e)(Object.assign(Object.assign({},e),{mountElement:g,shouldAttachSmartUI:k}))),E.on(["input_required","processing","error"],(()=>r.emit("loading",!1,{message:"Completed process unsuccessfully"}))),E.map(["input_required","processing","error","warning"],r),g.appendChild(O)}))))}},8707:(e,t,n)=>{n.d(t,{W:()=>r});var i=n(36932),o=function(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}))};function r(e){return o(this,void 0,void 0,(function*(){const{localEventHub:t,frankieClient:n}=e;try{const o=new i.Bv(n),{vendorParameters:r,entityId:a}=yield o.getToken({relayState:e.relayState});return t.emit("session_data_generated",{session:Object.assign(Object.assign({},r),{entityId:a})}),{vendorParameters:r,idvClient:o,entityId:a}}catch(e){throw t.emit("session_data_failed_loading"),e}}))}}}]);
2
2
  //# sourceMappingURL=idv-incode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"idv-incode.js","mappings":"gIAQO,MAAMA,GAAa,E,SAAA,GAAuB,CAC/CC,OAAQ,SACRC,aAAc,CACZC,MAAO,0BACPC,cAAe,SACfC,eAAgB,CACdC,SAAU,oBAGdC,aAAc,CACZC,YAAY,EACZ,iBAAAC,CACEC,EACAC,GAEA,MAAMC,EAAUD,EAAME,MAChB,SAAEP,GAAaM,EAGJ,oBAAbN,GAGFI,EAASI,KAAK,UAAW,CAAEC,WAAY,eAE3C,I,6DCxBG,SAASC,EAAwBC,GAKtC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,IAEE,MAAM6E,EAAatD,EAAYuD,eAAeD,mBACxCA,EAAWE,Q,CACjB,MAAOC,GAEP,MAAM/D,EACJ,mIAGFsD,EAAcxE,KAAK,UAAW,CAC5BF,QAASoB,EACTI,QAAS2D,G,EAIb,OAAwB,CACtBrF,SAAU4E,EACVpE,UACAC,YAEJ,MAIAsB,EAAe+C,GAAG,SAAUQ,KAE1B,OAAQ,CAAEf,iBAAkBxC,EAAgBF,WAE5C+C,EAAcxE,KAAK,mBAAoB,CACrCF,QAAS,cAAcX,MAAW+F,EAAMpF,UACxCwB,QAAS4D,EAAM5D,SACf,IAKJK,EAAe+C,GAAG,UAAU,KAC1BF,EAAcxE,KAAK,QAAS,CAAEmF,WAAY1D,GAAS,IAMrD,MAAM,aAAE2D,GAAiBjF,EACzBiF,EAAaC,YAAY5D,EAC3B,KAAE,C,uVCpGG,SAAe6D,EACpBnF,G,yCAEA,MAAQqE,cAAe5E,EAAQ,cAAE2F,GAAkBpF,EACnD,IACE,MAAMsE,EAAY,IAAI,KAAUc,IAG1B,iBAAExB,EAAgB,SAAE1D,SAAmBoE,EAAUe,SAA2B,CAChFC,WAAYtF,EAAQsF,aAMtB,OAFA7F,EAASI,KAAK,yBAA0B,CAAE0F,QAAS,OAAF,wBAAO3B,GAAgB,CAAE1D,eAEnE,CAAE0D,mBAAkBU,YAAWpE,W,CACtC,MAAO4E,GAEP,MADArF,EAASI,KAAK,+BACRiF,C,CAEV,G","sources":["webpack://OneSdk/./modules/idv/vendors/Incode/index.ts","webpack://OneSdk/./modules/idv/vendors/common/checkStatusEventMapping.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframe.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframeEventListener.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createDummyIframeTemplate.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.ts","webpack://OneSdk/./modules/idv/vendors/common/initialiseSession.ts"],"sourcesContent":["import type { EventHub } from '@module/common';\nimport type { OneSDKError } from '@module/common';\n\nimport {\n defineIframeIDVWrapper,\n} from '../common/iframeUtils/defineIframeIDVWrapper';\n\n\nexport const initialise = defineIframeIDVWrapper({\n vendor: 'incode',\n dummyOptions: {\n title: `Incode IDV Dummy iframe`,\n loadedPayload: 'loaded',\n successPayload: {\n workflow: 'INCODE_COMPLETE',\n } as MessageData,\n },\n eventOptions: {\n emitOnLoad: true,\n mapMessageToEvent(\n eventHub: EventHub<IFrameEvents>,\n event: MessageEvent<string>,\n ) {\n const message = event.data as unknown as MessageData;\n const { workflow } = message;\n\n // Note that Incode does not have an Error workflow\n if (workflow === 'INCODE_COMPLETE') {\n // Incode iframe does not provide checkId\n // use \"interviewId\" as a session key for backend fetching results\n eventHub.emit('success', { sessionKey: 'interviewId' });\n }\n },\n },\n});\n\ntype IFrameEvents = {\n success: [{ sessionKey: 'interviewId' }];\n error: [OneSDKError];\n};\n\ntype MessageData = { workflow: 'INCODE_COMPLETE' };\n","import type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport type { Document } from '../../../common/shared/models/Document';\n\n/** Interpret results from initProcess endpoint and emit appropriate events */\nexport function checkStatusEventMapping(options: {\n eventHub: IDVEventHub;\n results: { checkStatus: IDVStatus; ocrDocument?: Document };\n entityId: string;\n}) {\n const { eventHub, results, entityId } = options;\n switch (results.checkStatus) {\n case IDVStatus.COMPLETE:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: results.ocrDocument,\n entityId,\n });\n }\n break;\n case IDVStatus.FAILED:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: null,\n entityId,\n });\n }\n break;\n case IDVStatus.INTERRUPTED:\n case IDVStatus.INCOMPLETE:\n case IDVStatus.DOCUMENTS_INVALID:\n case IDVStatus.WAITING_DOC_UPLOAD:\n case IDVStatus.WAITING_SELFIE_UPLOAD:\n {\n eventHub.emit('input_required', { entityId }, results.checkStatus);\n }\n break;\n case IDVStatus.PROVIDER_OFFLINE:\n case IDVStatus.AWAITING_CONSENT:\n {\n const errorMessage =\n results.checkStatus === IDVStatus.PROVIDER_OFFLINE\n ? `Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${IDVStatus.PROVIDER_OFFLINE}`\n : \"Consent was not provided to the IDV Api. We can't continue.\";\n eventHub.emit(\n 'error',\n new OneSDKError(errorMessage, {\n errorStatus: results.checkStatus,\n }),\n );\n }\n break;\n case IDVStatus.CHECK_PROCESSING:\n {\n eventHub.emit('processing', { checkStatus: results.checkStatus, entityId });\n }\n break;\n default: {\n const errorMessage = `Unexpected IDV status: ${results.checkStatus}`;\n eventHub.emit('warning', {\n message: errorMessage,\n payload: results,\n });\n }\n }\n}\ntype IDVEventHub = EventHub<IDVModule['moduleEvents']>;\n","import type { EventListener } from '@module/common';\nimport type { OneSDKError } from '@module/common';\nimport type { InjectedState } from '@module/common/types';\nimport { SdkModes } from '@module/sdk/types';\n\n\nimport { createDummyHTML } from './createDummyIframeTemplate';\nimport {\n createIframeEventListener,\n} from './createIframeEventListener';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type {\n IframeMessagingOptions,\n} from './createIframeEventListener';\n\n/**\n * Generic events definition for an Iframe\n * All IDV iframes need to find ways to implement these events, where the payload is optional and may differ per vendor\n **/\nexport type IFrameEvents = {\n loaded: [unknown?];\n success: [unknown?];\n error: [OneSDKError<Record<string, unknown>>];\n};\n\n/**\n * Create and return an iframe element configured according to globalState and vendorParameters returned from api\n *\n * When the vendor is exposed inside an iframe, the generic solution is to listen for messages posted to the window object of the iframe. \"Messages\" are equivalent to \"events\".\n * The message's contents will differ per vendor, but we're expected to figure out a way to convert those messages into OneSDK events for \"loaded\", \"success\" and \"error\".\n *\n * @param globalState The global state of the OneSDK. The object provided to all components automatically\n * @param options The options to configure the iframe with\n * @param options.vendorParameters The parameters returned from the api to configure the iframe with\n * @param options.dummyModeOptions The options to configure the iframe with when in dummy mode\n * @param options.iframeMessagingOptions The options to configure an event hub to respond to iframe messages\n * @returns The iframe element\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild when the iframe fails to be appended to the DOM\n */\nexport function createIframe<E extends IFrameEvents, D>(\n globalState: InjectedState,\n options: CreateIframeOptions<E, D>,\n): { iframe: HTMLIFrameElement; iframeListener: EventListener<IFrameEvents> } {\n const iframe = document.createElement('iframe');\n const iframeListener = createIframeEventListener(iframe, options.iframeMessagingOptions);\n // Styling reset based on https://www.easeout.co/blog/2020-06-16-css-resets-normalizing/\n Object.assign(iframe.style, {\n border: 0,\n margin: 0,\n padding: 0,\n width: '100%',\n height: '100%',\n fontSize: '100%',\n font: 'inherit',\n verticalAlign: 'baseline',\n });\n iframe.allow = 'camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;';\n const isDummy = globalState.mode.is(SdkModes.DUMMY);\n\n if (isDummy) {\n iframe.srcdoc = createDummyHTML(options.dummyModeOptions);\n } else {\n iframe.src = options.vendorParameters.tokenURL;\n }\n\n return { iframe, iframeListener };\n}\n\nexport type CreateIframeOptions<E extends IFrameEvents = IFrameEvents, D = unknown> = {\n vendorParameters: { tokenURL: string };\n dummyModeOptions: DummyHTMLOptions;\n iframeMessagingOptions: IframeMessagingOptions<E, D>;\n};\n\n/**\n * Cleanup\n */\nexport function cleanup(dependencies: {\n internalEventHub: EventListener;\n iframe: HTMLIFrameElement;\n}) {\n dependencies.iframe.srcdoc = '';\n dependencies.internalEventHub.off();\n dependencies.iframe.remove();\n}\n","import { EventHub, EventListener, mkEventHub, mkEventListener } from \"@module/common\";\nimport { IFrameEvents } from \"./createIframe\";\n\n/**\n * Create a new eventListener that will listen for messages from the provided iframe and callback\n * @param iframe the iframe to listen for messages from\n * @param options callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n * @returns an event hub that will listen for messages from the iframe\n */\nexport function createIframeEventListener<E extends IFrameEvents, D>(\n iframe: HTMLIFrameElement,\n options: IframeMessagingOptions<E, D>\n): EventListener<IFrameEvents> {\n const iframeEventListener = mkEventHub<IFrameEvents>();\n\n if (options.emitOnLoad) iframe.onload = () => iframeEventListener.emit(\"loaded\");\n // Listen for messages from the provided iframe only. Logic for mapping messages to events is provided by the onIframeMessageReceived callback\n window.addEventListener(\n \"message\",\n (message) => {\n const originatesFromIframe = message.source === iframe.contentWindow;\n if (originatesFromIframe) options.mapMessageToEvent(iframeEventListener, message, iframe);\n },\n false\n );\n return mkEventListener(iframeEventListener);\n}\n/**\n * Callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n *\n * This function's exclusive responsibility is to interpret iframe messages and reemit them to the targetEventHub. It might as well\n *\n * The first type parameter defines the payload of the events\n * The second type parameter defines the iframe message data type\n * @param targetEventHub the event hub to reemit the event to\n * @param message the message event received from the iframe\n * @param iframeElement (optional) the iframe element itself, used to access the iframe, if required. ie: using iframe.onLoad to emit \"loaded\"\n * @returns void\n */\nexport type IframeMessagingOptions<E extends IFrameEvents = IFrameEvents, MessageType = unknown> = {\n mapMessageToEvent: (\n targetEventHub: EventHub<E>,\n message: MessageEvent<MessageType>,\n iframeElement?: HTMLIFrameElement\n ) => void;\n emitOnLoad: boolean;\n};\n","/* eslint-disable @typescript-eslint/ban-types */\n\n/**\n * DUMMY implementation of the iframe contents\n * Ensure to emit messages where data is tagged with a type (see more below)\n */\nexport function createDummyHTML(dummyModeOptions: DummyHTMLOptions) {\n const stringifyPostMessage = (message: unknown = {}) => `window.parent.postMessage(${JSON.stringify(message)}, \"*\")`;\n // Some vendors won't emit a \"loaded\" event.\n // The option emitOnLoad will cause the capture of the loaded event to happen somewhere else.\n // That means the dummy iframe doesn't need to emit it\n // If emitOnLoad is false, then the dummy iframe needs to emit the loaded event\n // In this case it will wait a predefined amount of time to emulate the \"loading\" period, and them emit the \"loaded\" message\n const onLoadedAction = dummyModeOptions.loadedPayload\n ? `setTimeout(() => ${stringifyPostMessage(dummyModeOptions.loadedPayload)}, DUMMY_LOAD_DELAY)`\n : \"\";\n const onCompletedAction = stringifyPostMessage(dummyModeOptions.successPayload);\n const onErrorAction = stringifyPostMessage(dummyModeOptions.errorPayload);\n\n return `<body style=\"background-color: white\">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${onLoadedAction};\n function cancelClicked() {\n ${onErrorAction};\n }\n function completeClicked() {\n ${onCompletedAction};\n }\n </script>\n <h1>${dummyModeOptions.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a \"detection_complete\" event</li>\n <li>Will trigger api calls, which will then emit the \"results\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a \"detection_failed\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id=\"actions-container\">\n <button onclick=\"completeClicked()\">Simulate Completion</button>\n <button onclick=\"cancelClicked()\">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`;\n}\n/** Options for the contents of the Iframe when in dummy mode */\nexport type DummyHTMLOptions = {\n loadedPayload?: unknown;\n successPayload?: unknown;\n errorPayload?: unknown;\n title: string;\n};\n","import { defineWrapper } from '@module/common/modules/defineModule';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport { checkStatusEventMapping } from '../checkStatusEventMapping';\nimport { initialiseIDVSession } from '../initialiseSession';\n\nimport { cleanup, createIframe } from './createIframe';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type { IframeMessagingOptions } from './createIframeEventListener';\n\n/**\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild\n * @emits AxiosError when HTTP requests fail\n */\n\nexport const defineIframeIDVWrapper = (wrapperOptions: Options) => {\n const { dummyOptions, eventOptions, vendor } = wrapperOptions;\n\n return defineWrapper<IDVModule>(vendor, async (globalState, options) => {\n // load mastercard token/iframe url from IDVClient\n const { localEventHub } = globalState;\n\n /*-------- 0) FETCH SESSION DATA */\n type VendorParameters = { tokenURL: string; interviewId: string };\n const {\n vendorParameters,\n idvClient,\n entityId,\n } = await initialiseIDVSession<VendorParameters>(globalState);\n\n /*-------- 1) CREATE IFRAME */\n const { iframe, iframeListener } = createIframe(globalState, {\n vendorParameters,\n dummyModeOptions: dummyOptions,\n iframeMessagingOptions: eventOptions,\n });\n\n /**\n * -------- 2) MAP EVENTS\n * Event listener for the \"success\" event on the iframe.\n * This event is emitted when the detection is successfully completed,\n * triggering checks and running cleanup.\n *\n * @param {Object} params - Parameters received from the iframe event.\n * @param {string} params.checkId - The ID generated from the provider for\n * backend to fetch the results (if available).\n * Use case: VendorSDK -> OneSDK -> Backend\n * @param {string} params.sessionKey - The session key used by\n * backend and obtained earlier from vendorParameters (if available).\n * Use case: VendorParameters -> OneSDK -> Backend\n */\n iframeListener.on('success', async ({ checkId, sessionKey }: Partial<{\n checkId: string;\n sessionKey: string;\n }>) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n\n localEventHub.emit('detection_complete');\n\n // Initialize the IDV process with provided parameters\n const results = await idvClient.initProcess({\n isSynchronous: true,\n vendorParameters: {\n checkId: checkId ?? vendorParameters[sessionKey],\n },\n });\n\n try {\n // Update local state for the individual before emitting events for results\n const individual = globalState.oneSdkInstance.individual();\n await individual.search();\n } catch (e) {\n // Handle errors during individual state update\n const errorMessage =\n `Error updating individual state. ` +\n `Check error events from module 'individual' for more details.` +\n `This isn't related to IDV capture.`;\n localEventHub.emit('warning', {\n message: errorMessage,\n payload: e,\n });\n }\n // Map check status events with the localEventHub\n checkStatusEventMapping({\n eventHub: localEventHub,\n results,\n entityId,\n });\n });\n\n // iframe \"ERROR\"\n // emits \"detection_failed\" and runs cleanup\n iframeListener.on('error', (error) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // TODO: figure out better error message and reason\n localEventHub.emit('detection_failed', {\n message: `Error from ${vendor}: ${error.message}`,\n payload: error.payload,\n });\n });\n\n // iframe \"LOOADED\"\n // emits \"ready\"\n iframeListener.on('loaded', () => {\n localEventHub.emit('ready', { domElement: iframe });\n });\n\n /*-------- 3) MOUNT IFRAME */\n\n // Inject iframe in the provider DOM container\n const { mountElement } = options;\n mountElement.appendChild(iframe);\n });\n};\ntype Options = {\n vendor: IDVModule['vendorName'];\n dummyOptions: DummyHTMLOptions;\n eventOptions: IframeMessagingOptions;\n};\n","import { FrankieApiClient } from '@module/frankie-client';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport { IDVEventHub } from '@module/idv/definition.types';\nimport { Dictionary } from '@types';\n\n/**\n * Helper that initialises a session with the IDV api\n * @param options Options object\n * @param options.eventHub eventHub to emit events to\n * @param options.frankieClient authenticated frankie client\n * @returns A promise of { idvClient, entityId, vendorParameters }\n * @throws Error if the session data could not be loaded\n * @emits \"session_data_generated\" with the session data\n * @emits \"session_data_failed_loading\", when session generation fails\n **/\nexport async function initialiseIDVSession<VendorParameters extends Dictionary<unknown>>(\n options: CreateIDVSessionOptions,\n) {\n const { localEventHub: eventHub, frankieClient } = options;\n try {\n const idvClient = new IDVClient(frankieClient);\n // Vendors some times generate a token and an url to be used in an iframe\n // During the same call, if the entity doesn't exist yet, Frankie cretes one and returns the new entity id\n const { vendorParameters, entityId } = await idvClient.getToken<VendorParameters>({\n relayState: options.relayState,\n });\n // TODO: Add entity id to the individual module and trigger a reload of the entity data\n // Emit session_data_generated for information purposes only. This has no functionality\n eventHub.emit('session_data_generated', { session: { ...vendorParameters, entityId } });\n\n return { vendorParameters, idvClient, entityId };\n } catch (e) {\n eventHub.emit('session_data_failed_loading');\n throw e;\n }\n}\nexport type CreateIDVSessionOptions = {\n localEventHub: IDVEventHub;\n frankieClient: FrankieApiClient;\n relayState?: string;\n};\n"],"names":["initialise","vendor","dummyOptions","title","loadedPayload","successPayload","workflow","eventOptions","emitOnLoad","mapMessageToEvent","eventHub","event","message","data","emit","sessionKey","checkStatusEventMapping","options","results","entityId","checkStatus","COMPLETE","document","ocrDocument","FAILED","INTERRUPTED","INCOMPLETE","DOCUMENTS_INVALID","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","PROVIDER_OFFLINE","AWAITING_CONSENT","errorMessage","OneSDKError","errorStatus","CHECK_PROCESSING","payload","createIframe","globalState","iframe","createElement","iframeListener","iframeEventListener","mkEventHub","onload","window","addEventListener","source","contentWindow","mkEventListener","createIframeEventListener","iframeMessagingOptions","Object","assign","style","border","margin","padding","width","height","fontSize","font","verticalAlign","allow","mode","is","DUMMY","srcdoc","dummyModeOptions","stringifyPostMessage","JSON","stringify","onLoadedAction","onCompletedAction","errorPayload","createDummyHTML","src","vendorParameters","tokenURL","cleanup","dependencies","internalEventHub","off","remove","defineIframeIDVWrapper","wrapperOptions","localEventHub","idvClient","on","checkId","initProcess","isSynchronous","individual","oneSdkInstance","search","e","error","domElement","mountElement","appendChild","initialiseIDVSession","frankieClient","getToken","relayState","session"],"sourceRoot":""}
1
+ {"version":3,"file":"idv-incode.js","mappings":"gIAEO,MAAMA,GAAa,E,SAAA,GAAuB,CAC/CC,OAAQ,SACRC,aAAc,CACZC,MAAO,0BACPC,cAAe,SACfC,eAAgB,CACdC,SAAU,oBAGdC,aAAc,CACZC,YAAY,EACZ,iBAAAC,EAAkB,eAAEC,EAAc,QAAEC,EAAO,iBAAEC,IAC3C,MAAMC,EAAcF,EAAQG,MACtB,SAAER,GAAaO,EAGrB,GAAiB,oBAAbP,EAAgC,CAGlC,MAAMS,EAAUH,EAAiBI,YACjCN,EAAeO,KAAK,UAAW,CAAEL,iBAAkB,CAAEG,Y,C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AQ,cAAE2F,GAAkB5F,EACnD,IACE,MAAMiF,EAAY,IAAI,KAAUW,IAG1B,iBAAEnG,EAAgB,SAAEU,SAAmB8E,EAAUY,SAA2B,CAChFC,WAAY9F,EAAQ8F,aAMtB,OAFA7F,EAASH,KAAK,yBAA0B,CAAEiG,QAAS,OAAF,wBAAOtG,GAAgB,CAAEU,eAEnE,CAAEV,mBAAkBwF,YAAW9E,W,CACtC,MAAOkF,GAEP,MADApF,EAASH,KAAK,+BACRuF,C,CAEV,G","sources":["webpack://OneSdk/./modules/idv/vendors/Incode/index.ts","webpack://OneSdk/./modules/idv/vendors/common/checkStatusEventMapping.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframe.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframeEventListener.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createDummyIframeTemplate.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.ts","webpack://OneSdk/./modules/idv/vendors/common/initialiseSession.ts"],"sourcesContent":["import { defineIframeIDVWrapper } from '../common/iframeUtils/defineIframeIDVWrapper';\n\nexport const initialise = defineIframeIDVWrapper({\n vendor: 'incode',\n dummyOptions: {\n title: `Incode IDV Dummy iframe`,\n loadedPayload: 'loaded',\n successPayload: {\n workflow: 'INCODE_COMPLETE',\n } as MessageData,\n },\n eventOptions: {\n emitOnLoad: true,\n mapMessageToEvent({ targetEventHub, message, vendorParameters }) {\n const messageData = message.data as MessageData;\n const { workflow } = messageData;\n\n // Note that Incode does not have an Error workflow\n if (workflow === 'INCODE_COMPLETE') {\n // Incode iframe does not provide checkId\n // use \"interviewId\" as a session key for backend fetching results\n const checkId = vendorParameters.interviewId as string;\n targetEventHub.emit('success', { vendorParameters: { checkId } });\n }\n },\n },\n});\n\ntype MessageData = { workflow: 'INCODE_COMPLETE' };\n","import type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport type { Document } from '../../../common/shared/models/Document';\n\n/** Interpret results from initProcess endpoint and emit appropriate events */\nexport function checkStatusEventMapping(options: {\n eventHub: IDVEventHub;\n results: { checkStatus: IDVStatus; ocrDocument?: Document };\n entityId: string;\n}) {\n const { eventHub, results, entityId } = options;\n switch (results.checkStatus) {\n case IDVStatus.COMPLETE:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: results.ocrDocument,\n entityId,\n });\n }\n break;\n case IDVStatus.FAILED:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: null,\n entityId,\n });\n }\n break;\n case IDVStatus.INTERRUPTED:\n case IDVStatus.INCOMPLETE:\n case IDVStatus.DOCUMENTS_INVALID:\n case IDVStatus.WAITING_DOC_UPLOAD:\n case IDVStatus.WAITING_SELFIE_UPLOAD:\n {\n eventHub.emit('input_required', { entityId }, results.checkStatus);\n }\n break;\n case IDVStatus.PROVIDER_OFFLINE:\n case IDVStatus.AWAITING_CONSENT:\n {\n const errorMessage =\n results.checkStatus === IDVStatus.PROVIDER_OFFLINE\n ? `Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${IDVStatus.PROVIDER_OFFLINE}`\n : \"Consent was not provided to the IDV Api. We can't continue.\";\n eventHub.emit(\n 'error',\n new OneSDKError(errorMessage, {\n errorStatus: results.checkStatus,\n }),\n );\n }\n break;\n case IDVStatus.CHECK_PROCESSING:\n {\n eventHub.emit('processing', { checkStatus: results.checkStatus, entityId });\n }\n break;\n default: {\n const errorMessage = `Unexpected IDV status: ${results.checkStatus}`;\n eventHub.emit('warning', {\n message: errorMessage,\n payload: results,\n });\n }\n }\n}\ntype IDVEventHub = EventHub<IDVModule['moduleEvents']>;\n","import type { EventListener } from '@module/common';\nimport type { InjectedState } from '@module/common/types';\nimport { SdkModes } from '@module/sdk/types';\n\nimport { createDummyHTML } from './createDummyIframeTemplate';\nimport { createIframeEventListener } from './createIframeEventListener';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type { IframeMessagingOptions } from './createIframeEventListener';\nimport type { OneSDKError } from '../../../../common';\n\n/**\n * Generic events definition for an Iframe\n * All IDV iframes need to find ways to implement these events, where the payload is optional and may differ per vendor\n **/\nexport type IFrameEvents = {\n loaded: [unknown?];\n success: [{ vendorParameters: Record<string, unknown> }?];\n error: [OneSDKError<Record<string, unknown>>];\n};\n\n/**\n * Create and return an iframe element configured according to globalState and vendorParameters returned from api\n *\n * When the vendor is exposed inside an iframe, the generic solution is to listen for messages posted to the window object of the iframe. \"Messages\" are equivalent to \"events\".\n * The message's contents will differ per vendor, but we're expected to figure out a way to convert those messages into OneSDK events for \"loaded\", \"success\" and \"error\".\n *\n * @param globalState The global state of the OneSDK. The object provided to all components automatically\n * @param options The options to configure the iframe with\n * @param options.vendorParameters The parameters returned from the api to configure the iframe with\n * @param options.dummyModeOptions The options to configure the iframe with when in dummy mode\n * @param options.iframeMessagingOptions The options to configure an event hub to respond to iframe messages\n * @returns The iframe element\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild when the iframe fails to be appended to the DOM\n */\nexport function createIframe(\n globalState: InjectedState,\n options: CreateIframeOptions,\n): { iframe: HTMLIFrameElement; iframeListener: EventListener<IFrameEvents> } {\n const iframe = document.createElement('iframe');\n const iframeListener = createIframeEventListener(iframe, options.iframeMessagingOptions);\n // Styling reset based on https://www.easeout.co/blog/2020-06-16-css-resets-normalizing/\n Object.assign(iframe.style, {\n border: 0,\n margin: 0,\n padding: 0,\n width: '100%',\n height: '100%',\n fontSize: '100%',\n font: 'inherit',\n verticalAlign: 'baseline',\n });\n iframe.allow = 'camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;';\n const isDummy = globalState.mode.is(SdkModes.DUMMY);\n\n if (isDummy) {\n iframe.srcdoc = createDummyHTML(options.dummyModeOptions);\n } else {\n iframe.src = options.vendorParameters.tokenURL;\n }\n\n return { iframe, iframeListener };\n}\nexport type CreateIframeOptions = {\n vendorParameters: { tokenURL: string };\n dummyModeOptions: DummyHTMLOptions;\n iframeMessagingOptions: IframeMessagingOptions;\n};\n\n/**\n * Cleanup\n */\nexport function cleanup(dependencies: { internalEventHub: EventListener; iframe: HTMLIFrameElement }) {\n dependencies.iframe.srcdoc = '';\n dependencies.internalEventHub.off();\n dependencies.iframe.remove();\n}\n","import type { EventHub, EventListener } from '@module/common';\nimport { mkEventHub, mkEventListener } from '@module/common';\n\nimport type { IFrameEvents } from './createIframe';\n\n/**\n * Create a new eventListener that will listen for messages from the provided iframe and callback\n * @param iframe the iframe to listen for messages from\n * @param options callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n * @returns an event hub that will listen for messages from the iframe\n */\nexport function createIframeEventListener(\n iframe: HTMLIFrameElement,\n options: IframeMessagingOptions,\n): EventListener<IFrameEvents> {\n const iframeEventListener = mkEventHub<IFrameEvents>();\n\n if (options.emitOnLoad) iframe.onload = () => iframeEventListener.emit('loaded');\n // Listen for messages from the provided iframe only. Logic for mapping messages to events is provided by the onIframeMessageReceived callback\n window.addEventListener(\n 'message',\n (message) => {\n const originatesFromIframe = message.source === iframe.contentWindow;\n if (originatesFromIframe)\n options.mapMessageToEvent({\n targetEventHub: iframeEventListener,\n message,\n iframeElement: iframe,\n vendorParameters: options.vendorParameters,\n });\n },\n false,\n );\n return mkEventListener(iframeEventListener);\n}\n/**\n * Callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n *\n * This function's exclusive responsibility is to interpret iframe messages and reemit them to the targetEventHub. It might as well\n *\n * The first type parameter defines the payload of the events\n * The second type parameter defines the iframe message data type\n * @param targetEventHub the event hub to reemit the event to\n * @param message the message event received from the iframe\n * @param iframeElement (optional) the iframe element itself, used to access the iframe, if required. ie: using iframe.onLoad to emit \"loaded\"\n * @returns void\n */\nexport type IframeMessagingOptions = {\n mapMessageToEvent: (ops: {\n targetEventHub: EventHub<IFrameEvents>;\n message: MessageEvent<unknown>;\n iframeElement?: HTMLIFrameElement;\n vendorParameters?: Record<string, unknown>;\n }) => void;\n emitOnLoad: boolean;\n vendorParameters?: Record<string, unknown>;\n};\n","/* eslint-disable @typescript-eslint/ban-types */\n\n/**\n * DUMMY implementation of the iframe contents\n * Ensure to emit messages where data is tagged with a type (see more below)\n */\nexport function createDummyHTML(dummyModeOptions: DummyHTMLOptions) {\n const stringifyPostMessage = (message: unknown = {}) => `window.parent.postMessage(${JSON.stringify(message)}, \"*\")`;\n // Some vendors won't emit a \"loaded\" event.\n // The option emitOnLoad will cause the capture of the loaded event to happen somewhere else.\n // That means the dummy iframe doesn't need to emit it\n // If emitOnLoad is false, then the dummy iframe needs to emit the loaded event\n // In this case it will wait a predefined amount of time to emulate the \"loading\" period, and them emit the \"loaded\" message\n const onLoadedAction = dummyModeOptions.loadedPayload\n ? `setTimeout(() => ${stringifyPostMessage(dummyModeOptions.loadedPayload)}, DUMMY_LOAD_DELAY)`\n : \"\";\n const onCompletedAction = stringifyPostMessage(dummyModeOptions.successPayload);\n const onErrorAction = stringifyPostMessage(dummyModeOptions.errorPayload);\n\n return `<body style=\"background-color: white\">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${onLoadedAction};\n function cancelClicked() {\n ${onErrorAction};\n }\n function completeClicked() {\n ${onCompletedAction};\n }\n </script>\n <h1>${dummyModeOptions.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a \"detection_complete\" event</li>\n <li>Will trigger api calls, which will then emit the \"results\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a \"detection_failed\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id=\"actions-container\">\n <button onclick=\"completeClicked()\">Simulate Completion</button>\n <button onclick=\"cancelClicked()\">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`;\n}\n/** Options for the contents of the Iframe when in dummy mode */\nexport type DummyHTMLOptions = {\n loadedPayload?: unknown;\n successPayload?: unknown;\n errorPayload?: unknown;\n title: string;\n};\n","import features from '@feature-flags';\nimport { OneSDKError } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport { mkEventHub } from '@module/common/modules/eventHub';\nimport { useSmartUIToReviewResults } from '@module/common/vendors/smart-ui/useSmartUI';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport { checkStatusEventMapping } from '../checkStatusEventMapping';\nimport { initialiseIDVSession } from '../initialiseSession';\n\nimport { cleanup, createIframe } from './createIframe';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type { IframeMessagingOptions } from './createIframeEventListener';\nimport type { Events } from '../../../events.types';\n/**\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild\n * @emits AxiosError when HTTP requests fail\n */\n\nexport const defineIframeIDVWrapper = (wrapperOptions: Options) => {\n const { dummyOptions, eventOptions, vendor } = wrapperOptions;\n const containsReviewScreen = features.modules.idv.containsReviewScreen[vendor] ?? false;\n\n return defineWrapper<IDVModule>(vendor, async (sharedDependencies, options) => {\n // load mastercard token/iframe url from IDVClient\n const { localEventHub, recipe } = sharedDependencies;\n const { mountElement } = options;\n // For smart ui to be included after the \"results\" event, the recipe configuration provideReviewScreen must not be false\n // and the vendor must be configured with containsReviewScreen = false, meaning it doesn't already provide one internally\n // * Smart UI is not displayed for vendors which already have a review screen\n const recipeProvideReviewScreen = recipe.idv.provideReviewScreen ?? true;\n const includeSmartUI = !containsReviewScreen && recipeProvideReviewScreen;\n\n const privateEventHub = mkEventHub<Events>();\n\n /*-------- 0) FETCH SESSION DATA */\n type VendorParameters = { tokenURL: string };\n const { vendorParameters, idvClient, entityId } = await initialiseIDVSession<VendorParameters>(sharedDependencies);\n\n /*-------- 1) CREATE IFRAME */\n const { iframe, iframeListener } = createIframe(sharedDependencies, {\n vendorParameters,\n dummyModeOptions: dummyOptions,\n iframeMessagingOptions: {\n ...eventOptions,\n vendorParameters,\n },\n });\n\n /*-------- 2) MAP EVENTS */\n\n // 2.0) Iframe events -> localEventHub and privateEventHub\n // iframe \"SUCCESS\"\n // emits \"detection_complete\", trigger checks and runs cleanup\n iframeListener.on('success', async ({ vendorParameters }) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // \"detection_complete\" is only emitted when vendors already have a review screen\n // this event is only emitted after the review screen. When includeSmartUI is true\n // it only happens after the \"results\" event and the following smart ui\n if (!includeSmartUI) localEventHub.emit('detection_complete');\n // If not emitting \"detection_complete\" here, emit an \"info\" event instead\n else {\n localEventHub.emit('info', {\n message: 'Data extraction completed. Now executing user review using smart ui.',\n });\n }\n\n localEventHub.emit('loading', true, { message: 'Retrieving IDV results' });\n\n try {\n const results = await idvClient.initProcess({\n isSynchronous: true,\n vendorParameters,\n });\n\n checkStatusEventMapping({\n eventHub: privateEventHub,\n results,\n entityId,\n });\n } catch (e) {\n localEventHub.emit('error', new OneSDKError('Failed initiating IDV processing', e));\n localEventHub.emit('loading', false, { message: 'Failed retrieving IDV results' });\n }\n });\n\n // iframe \"ERROR\"\n // emits \"detection_failed\" and runs cleanup\n iframeListener.on('error', (error) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // TODO: figure out better error message and reason\n localEventHub.emit('detection_failed', {\n message: `Error from ${vendor}: ${error.message}`,\n payload: error.payload,\n });\n localEventHub.emit('loading', false, { message: `Vendor '${vendor}' detection has failed` });\n });\n\n // iframe \"LOOADED\"\n // emits \"ready\"\n iframeListener.on('loaded', () => {\n localEventHub.emit('ready', { domElement: iframe });\n localEventHub.emit('loading', false, { message: `Vendor '${vendor}' screen has loaded` });\n });\n\n // 2.1) Status events (privateEventHub) -> localEventHub\n\n // If includeSmartUI is true, instead of emitting 'results' event with the idv results\n // first mount the smart ui to the same mountElement and only when smart ui emits a 'results' event\n // then emit 'results' too\n privateEventHub.on(\n 'results',\n useSmartUIToReviewResults({\n ...sharedDependencies,\n mountElement,\n shouldAttachSmartUI: includeSmartUI,\n }),\n );\n // For each final event that's not a result emit a 'loading' false event\n privateEventHub.on(['input_required', 'processing', 'error'], () =>\n localEventHub.emit('loading', false, { message: 'Completed process unsuccessfully' }),\n );\n // all other events should be reemitted as is\n privateEventHub.map(['input_required', 'processing', 'error', 'warning'], localEventHub);\n\n /*-------- 3) MOUNT IFRAME */\n\n // Inject iframe in the provider DOM container\n mountElement.appendChild(iframe);\n });\n};\ntype Options = {\n vendor: IDVModule['vendorName'];\n /** Options for auto generating UI for the dummy mode */\n dummyOptions: DummyHTMLOptions;\n /** Options for mapping iframe messages into OneSDK eventhub events */\n eventOptions: IframeMessagingOptions;\n};\n","import { FrankieApiClient } from '@module/frankie-client';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport { IDVEventHub } from '@module/idv/definition.types';\nimport { Dictionary } from '@types';\n\n/**\n * Helper that initialises a session with the IDV api\n * @param options Options object\n * @param options.eventHub eventHub to emit events to\n * @param options.frankieClient authenticated frankie client\n * @returns A promise of { idvClient, entityId, vendorParameters }\n * @throws Error if the session data could not be loaded\n * @emits \"session_data_generated\" with the session data\n * @emits \"session_data_failed_loading\", when session generation fails\n **/\nexport async function initialiseIDVSession<VendorParameters extends Dictionary<unknown>>(\n options: CreateIDVSessionOptions,\n) {\n const { localEventHub: eventHub, frankieClient } = options;\n try {\n const idvClient = new IDVClient(frankieClient);\n // Vendors some times generate a token and an url to be used in an iframe\n // During the same call, if the entity doesn't exist yet, Frankie cretes one and returns the new entity id\n const { vendorParameters, entityId } = await idvClient.getToken<VendorParameters>({\n relayState: options.relayState,\n });\n // TODO: Add entity id to the individual module and trigger a reload of the entity data\n // Emit session_data_generated for information purposes only. This has no functionality\n eventHub.emit('session_data_generated', { session: { ...vendorParameters, entityId } });\n\n return { vendorParameters, idvClient, entityId };\n } catch (e) {\n eventHub.emit('session_data_failed_loading');\n throw e;\n }\n}\nexport type CreateIDVSessionOptions = {\n localEventHub: IDVEventHub;\n frankieClient: FrankieApiClient;\n relayState?: string;\n};\n"],"names":["initialise","vendor","dummyOptions","title","loadedPayload","successPayload","workflow","eventOptions","emitOnLoad","mapMessageToEvent","targetEventHub","message","vendorParameters","messageData","data","checkId","interviewId","emit","checkStatusEventMapping","options","eventHub","results","entityId","checkStatus","COMPLETE","document","ocrDocument","FAILED","INTERRUPTED","INCOMPLETE","DOCUMENTS_INVALID","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","PROVIDER_OFFLINE","AWAITING_CONSENT","errorMessage","OneSDKError","errorStatus","CHECK_PROCESSING","payload","createIframe","globalState","iframe","createElement","iframeListener","iframeEventListener","mkEventHub","onload","window","addEventListener","source","contentWindow","iframeElement","mkEventListener","createIframeEventListener","iframeMessagingOptions","Object","assign","style","border","margin","padding","width","height","fontSize","font","verticalAlign","allow","mode","is","DUMMY","srcdoc","dummyModeOptions","stringifyPostMessage","JSON","stringify","onLoadedAction","onCompletedAction","errorPayload","createDummyHTML","src","tokenURL","cleanup","dependencies","internalEventHub","off","remove","defineIframeIDVWrapper","wrapperOptions","containsReviewScreen","modules","idv","sharedDependencies","localEventHub","recipe","mountElement","recipeProvideReviewScreen","provideReviewScreen","includeSmartUI","privateEventHub","idvClient","on","initProcess","isSynchronous","e","error","domElement","shouldAttachSmartUI","map","appendChild","initialiseIDVSession","frankieClient","getToken","relayState","session"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[521],{46664:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>o});var i=n(96834);const o=(0,n(19648).g)({vendor:"mastercard",dummyOptions:{title:"Mastercard IDV Dummy iframe",loadedPayload:JSON.stringify({payload:{value:"loaded"}}),successPayload:JSON.stringify({payload:{value:"success"},checkId:"random-execution-id"}),errorPayload:JSON.stringify({payload:{value:"error",metainfo:{msg:"Dummy error from Mastercard"}}})},eventOptions:{emitOnLoad:!1,mapMessageToEvent(e,t){const n=JSON.parse(t.data),o=n.payload;e.emit("info",{message:`Received message ${o.value}`,payload:n}),"loaded"===o.value?e.emit("loaded"):"success"===o.value?e.emit("success",{checkId:n.workflowExecutionId}):"error"===o.value?e.emit("error",new i.OneSDKError(o.metainfo.msg,o.metainfo)):e.emit("warning",{message:`Unexpected message ${o.value}`,payload:n})}}})},50750:(e,t,n)=>{n.d(t,{z:()=>a});var i=n(96834),o=n(36932);function a(e){const{eventHub:t,results:n,entityId:a}=e;switch(n.checkStatus){case o.ck.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:a});break;case o.ck.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:a});break;case o.ck.INTERRUPTED:case o.ck.INCOMPLETE:case o.ck.DOCUMENTS_INVALID:case o.ck.WAITING_DOC_UPLOAD:case o.ck.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:a},n.checkStatus);break;case o.ck.PROVIDER_OFFLINE:case o.ck.AWAITING_CONSENT:{const e=n.checkStatus===o.ck.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.ck.PROVIDER_OFFLINE}`:"Consent was not provided to the IDV Api. We can't continue.";t.emit("error",new i.OneSDKError(e,{errorStatus:n.checkStatus}))}break;case o.ck.CHECK_PROCESSING:t.emit("processing",{checkStatus:n.checkStatus,entityId:a});break;default:{const e=`Unexpected IDV status: ${n.checkStatus}`;t.emit("warning",{message:e,payload:n})}}}},85730:(e,t,n)=>{n.d(t,{E:()=>r,V:()=>a});var i=n(1306),o=n(96834);function a(e,t){const n=document.createElement("iframe"),a=function(e,t){const n=(0,o.mkEventHub)();return t.emitOnLoad&&(e.onload=()=>n.emit("loaded")),window.addEventListener("message",(i=>{i.source===e.contentWindow&&t.mapMessageToEvent(n,i,e)}),!1),(0,o.mkEventListener)(n)}(n,t.iframeMessagingOptions);return Object.assign(n.style,{border:0,margin:0,padding:0,width:"100%",height:"100%",fontSize:"100%",font:"inherit",verticalAlign:"baseline"}),n.allow="camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;",e.mode.is(i.Z.DUMMY)?n.srcdoc=function(e){const t=(e={})=>`window.parent.postMessage(${JSON.stringify(e)}, "*")`,n=e.loadedPayload?`setTimeout(() => ${t(e.loadedPayload)}, DUMMY_LOAD_DELAY)`:"",i=t(e.successPayload);return`<body style="background-color: white">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${n};\n function cancelClicked() {\n ${t(e.errorPayload)};\n }\n function completeClicked() {\n ${i};\n }\n <\/script>\n <h1>${e.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a "detection_complete" event</li>\n <li>Will trigger api calls, which will then emit the "results" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a "detection_failed" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id="actions-container">\n <button onclick="completeClicked()">Simulate Completion</button>\n <button onclick="cancelClicked()">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`}(t.dummyModeOptions):n.src=t.vendorParameters.tokenURL,{iframe:n,iframeListener:a}}function r(e){e.iframe.srcdoc="",e.internalEventHub.off(),e.iframe.remove()}},19648:(e,t,n)=>{n.d(t,{g:()=>s});var i=n(99434),o=n(50750),a=n(8707),r=n(85730),c=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function c(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,c)}s((i=i.apply(e,t||[])).next())}))};const s=e=>{const{dummyOptions:t,eventOptions:n,vendor:s}=e;return(0,i.J)(s,((e,i)=>c(void 0,void 0,void 0,(function*(){const{localEventHub:d}=e,{vendorParameters:l,idvClient:u,entityId:m}=yield(0,a.W)(e),{iframe:f,iframeListener:v}=(0,r.V)(e,{vendorParameters:l,dummyModeOptions:t,iframeMessagingOptions:n});v.on("success",(({checkId:t,sessionKey:n})=>c(void 0,void 0,void 0,(function*(){(0,r.E)({internalEventHub:v,iframe:f}),d.emit("detection_complete");const i=yield u.initProcess({isSynchronous:!0,vendorParameters:{checkId:null!=t?t:l[n]}});try{const t=e.oneSdkInstance.individual();yield t.search()}catch(e){const t="Error updating individual state. Check error events from module 'individual' for more details.This isn't related to IDV capture.";d.emit("warning",{message:t,payload:e})}(0,o.z)({eventHub:d,results:i,entityId:m})})))),v.on("error",(e=>{(0,r.E)({internalEventHub:v,iframe:f}),d.emit("detection_failed",{message:`Error from ${s}: ${e.message}`,payload:e.payload})})),v.on("loaded",(()=>{d.emit("ready",{domElement:f})}));const{mountElement:p}=i;p.appendChild(f)}))))}},8707:(e,t,n)=>{n.d(t,{W:()=>a});var i=n(36932),o=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function c(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,c)}s((i=i.apply(e,t||[])).next())}))};function a(e){return o(this,void 0,void 0,(function*(){const{localEventHub:t,frankieClient:n}=e;try{const o=new i.Bv(n),{vendorParameters:a,entityId:r}=yield o.getToken({relayState:e.relayState});return t.emit("session_data_generated",{session:Object.assign(Object.assign({},a),{entityId:r})}),{vendorParameters:a,idvClient:o,entityId:r}}catch(e){throw t.emit("session_data_failed_loading"),e}}))}}}]);
1
+ "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[521],{46664:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>a});var i=n(77494);const a=(0,n(19648).g)({vendor:"mastercard",dummyOptions:{title:"Mastercard IDV Dummy iframe",loadedPayload:JSON.stringify({payload:{value:"loaded"}}),successPayload:JSON.stringify({payload:{value:"success"},checkId:"random-execution-id"}),errorPayload:JSON.stringify({payload:{value:"error",metainfo:{msg:"Dummy error from Mastercard"}}})},eventOptions:{emitOnLoad:!1,mapMessageToEvent({targetEventHub:e,message:t}){const n=JSON.parse(t.data),a=n.payload;if(e.emit("info",{message:`Received message ${a.value}`,payload:n}),"loaded"===a.value)e.emit("loaded");else if("success"===a.value){const t=n.workflowExecutionId;e.emit("success",{vendorParameters:{checkId:t}})}else"error"===a.value?e.emit("error",new i.OneSDKError(a.metainfo.msg,a.metainfo)):e.emit("warning",{message:`Unexpected message ${a.value}`,payload:n})}}})},50750:(e,t,n)=>{n.d(t,{z:()=>o});var i=n(77494),a=n(36932);function o(e){const{eventHub:t,results:n,entityId:o}=e;switch(n.checkStatus){case a.ck.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:o});break;case a.ck.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:o});break;case a.ck.INTERRUPTED:case a.ck.INCOMPLETE:case a.ck.DOCUMENTS_INVALID:case a.ck.WAITING_DOC_UPLOAD:case a.ck.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:o},n.checkStatus);break;case a.ck.PROVIDER_OFFLINE:case a.ck.AWAITING_CONSENT:{const e=n.checkStatus===a.ck.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${a.ck.PROVIDER_OFFLINE}`:"Consent was not provided to the IDV Api. We can't continue.";t.emit("error",new i.OneSDKError(e,{errorStatus:n.checkStatus}))}break;case a.ck.CHECK_PROCESSING:t.emit("processing",{checkStatus:n.checkStatus,entityId:o});break;default:{const e=`Unexpected IDV status: ${n.checkStatus}`;t.emit("warning",{message:e,payload:n})}}}},85730:(e,t,n)=>{n.d(t,{E:()=>r,V:()=>o});var i=n(1306),a=n(77494);function o(e,t){const n=document.createElement("iframe"),o=function(e,t){const n=(0,a.mkEventHub)();return t.emitOnLoad&&(e.onload=()=>n.emit("loaded")),window.addEventListener("message",(i=>{i.source===e.contentWindow&&t.mapMessageToEvent({targetEventHub:n,message:i,iframeElement:e,vendorParameters:t.vendorParameters})}),!1),(0,a.mkEventListener)(n)}(n,t.iframeMessagingOptions);return Object.assign(n.style,{border:0,margin:0,padding:0,width:"100%",height:"100%",fontSize:"100%",font:"inherit",verticalAlign:"baseline"}),n.allow="camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;",e.mode.is(i.Z.DUMMY)?n.srcdoc=function(e){const t=(e={})=>`window.parent.postMessage(${JSON.stringify(e)}, "*")`,n=e.loadedPayload?`setTimeout(() => ${t(e.loadedPayload)}, DUMMY_LOAD_DELAY)`:"",i=t(e.successPayload);return`<body style="background-color: white">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${n};\n function cancelClicked() {\n ${t(e.errorPayload)};\n }\n function completeClicked() {\n ${i};\n }\n <\/script>\n <h1>${e.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a "detection_complete" event</li>\n <li>Will trigger api calls, which will then emit the "results" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a "detection_failed" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id="actions-container">\n <button onclick="completeClicked()">Simulate Completion</button>\n <button onclick="cancelClicked()">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`}(t.dummyModeOptions):n.src=t.vendorParameters.tokenURL,{iframe:n,iframeListener:o}}function r(e){e.iframe.srcdoc="",e.internalEventHub.off(),e.iframe.remove()}},19648:(e,t,n)=>{n.d(t,{g:()=>m});var i=n(41183),a=n(77494),o=n(99434),r=n(23851),s=n(28018),c=n(50750),l=n(8707),d=n(85730),u=function(e,t,n,i){return new(n||(n=Promise))((function(a,o){function r(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}c((i=i.apply(e,t||[])).next())}))};const m=e=>{var t;const{dummyOptions:n,eventOptions:m,vendor:v}=e,p=null!==(t=i.Z.modules.idv.containsReviewScreen[v])&&void 0!==t&&t;return(0,o.J)(v,((e,t)=>u(void 0,void 0,void 0,(function*(){var i;const{localEventHub:o,recipe:f}=e,{mountElement:g}=t,h=null===(i=f.idv.provideReviewScreen)||void 0===i||i,y=!p&&h,k=(0,r.e)(),{vendorParameters:E,idvClient:I,entityId:O}=yield(0,l.W)(e),{iframe:w,iframeListener:b}=(0,d.V)(e,{vendorParameters:E,dummyModeOptions:n,iframeMessagingOptions:Object.assign(Object.assign({},m),{vendorParameters:E})});b.on("success",(({vendorParameters:e})=>u(void 0,void 0,void 0,(function*(){(0,d.E)({internalEventHub:b,iframe:w}),y?o.emit("info",{message:"Data extraction completed. Now executing user review using smart ui."}):o.emit("detection_complete"),o.emit("loading",!0,{message:"Retrieving IDV results"});try{const t=yield I.initProcess({isSynchronous:!0,vendorParameters:e});(0,c.z)({eventHub:k,results:t,entityId:O})}catch(e){o.emit("error",new a.OneSDKError("Failed initiating IDV processing",e)),o.emit("loading",!1,{message:"Failed retrieving IDV results"})}})))),b.on("error",(e=>{(0,d.E)({internalEventHub:b,iframe:w}),o.emit("detection_failed",{message:`Error from ${v}: ${e.message}`,payload:e.payload}),o.emit("loading",!1,{message:`Vendor '${v}' detection has failed`})})),b.on("loaded",(()=>{o.emit("ready",{domElement:w}),o.emit("loading",!1,{message:`Vendor '${v}' screen has loaded`})})),k.on("results",(0,s.e)(Object.assign(Object.assign({},e),{mountElement:g,shouldAttachSmartUI:y}))),k.on(["input_required","processing","error"],(()=>o.emit("loading",!1,{message:"Completed process unsuccessfully"}))),k.map(["input_required","processing","error","warning"],o),g.appendChild(w)}))))}},8707:(e,t,n)=>{n.d(t,{W:()=>o});var i=n(36932),a=function(e,t,n,i){return new(n||(n=Promise))((function(a,o){function r(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}c((i=i.apply(e,t||[])).next())}))};function o(e){return a(this,void 0,void 0,(function*(){const{localEventHub:t,frankieClient:n}=e;try{const a=new i.Bv(n),{vendorParameters:o,entityId:r}=yield a.getToken({relayState:e.relayState});return t.emit("session_data_generated",{session:Object.assign(Object.assign({},o),{entityId:r})}),{vendorParameters:o,idvClient:a,entityId:r}}catch(e){throw t.emit("session_data_failed_loading"),e}}))}}}]);
2
2
  //# sourceMappingURL=idv-mastercard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"idv-mastercard.js","mappings":"gJAQO,MAAMA,GAAa,E,SAAA,GAAuB,CAC/CC,OAAQ,aACRC,aAAc,CACZC,MAAO,8BAEPC,cAAeC,KAAKC,UAAU,CAAEC,QAAS,CAAEC,MAAO,YAClDC,eAAgBJ,KAAKC,UAAU,CAC7BC,QAAS,CAAEC,MAAO,WAClBE,QAAS,wBAEXC,aAAcN,KAAKC,UAAU,CAC3BC,QAAS,CACPC,MAAO,QACPI,SAAU,CAAEC,IAAK,mCAIvBC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,OAFA3F,EAASK,KAAK,yBAA0B,CAAEuF,QAAS,OAAF,wBAAO3B,GAAgB,CAAErD,eAEnE,CAAEqD,mBAAkBU,YAAW/D,W,CACtC,MAAOuE,GAEP,MADAnF,EAASK,KAAK,+BACR8E,C,CAEV,G","sources":["webpack://OneSdk/./modules/idv/vendors/Mastercard/index.ts","webpack://OneSdk/./modules/idv/vendors/common/checkStatusEventMapping.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframe.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframeEventListener.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createDummyIframeTemplate.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.ts","webpack://OneSdk/./modules/idv/vendors/common/initialiseSession.ts"],"sourcesContent":["import { OneSDKError } from '@module/common';\nimport type { EventHub } from '@module/common';\n\nimport {\n defineIframeIDVWrapper,\n} from '../common/iframeUtils/defineIframeIDVWrapper';\n\n\nexport const initialise = defineIframeIDVWrapper({\n vendor: 'mastercard',\n dummyOptions: {\n title: `Mastercard IDV Dummy iframe`,\n // Mastercard transmits their message data as a stringified JSON\n loadedPayload: JSON.stringify({ payload: { value: 'loaded' } }),\n successPayload: JSON.stringify({\n payload: { value: 'success' },\n checkId: 'random-execution-id',\n }),\n errorPayload: JSON.stringify({\n payload: {\n value: 'error',\n metainfo: { msg: 'Dummy error from Mastercard' },\n },\n }),\n },\n eventOptions: {\n // Since mastercard emits its own \"loaded\" event, we don't need to react to iframe.onload event\n emitOnLoad: false,\n mapMessageToEvent(\n eventHub: EventHub<IFrameEvents>,\n event: MessageEvent<string>,\n ) {\n // Mastercard transmits their message data as a stringified JSON\n const messageData: MessageData = JSON.parse(event.data);\n const payload = messageData.payload;\n\n eventHub.emit('info', {\n message: `Received message ${payload.value}`,\n payload: messageData,\n });\n if (payload.value === 'loaded') eventHub.emit('loaded');\n else if (payload.value === 'success') eventHub.emit('success', { checkId: messageData.workflowExecutionId });\n else if (payload.value === 'error')\n eventHub.emit('error', new OneSDKError(payload.metainfo.msg, payload.metainfo));\n else\n eventHub.emit('warning', {\n message: `Unexpected message ${(payload as Payload).value}`,\n payload: messageData,\n });\n },\n },\n});\n\ntype IFrameEvents = {\n loaded: [];\n success: [{ checkId: string }];\n error: [OneSDKError<MetaInfo>];\n};\n\ntype MetaInfo = { msg: string } & Record<string, unknown>;\ntype Payload = { value: 'loaded' } | { value: 'success' } | {\n value: 'error';\n metainfo: MetaInfo;\n};\ntype MessageData = { payload: Payload; workflowExecutionId: string };\n","import type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport type { Document } from '../../../common/shared/models/Document';\n\n/** Interpret results from initProcess endpoint and emit appropriate events */\nexport function checkStatusEventMapping(options: {\n eventHub: IDVEventHub;\n results: { checkStatus: IDVStatus; ocrDocument?: Document };\n entityId: string;\n}) {\n const { eventHub, results, entityId } = options;\n switch (results.checkStatus) {\n case IDVStatus.COMPLETE:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: results.ocrDocument,\n entityId,\n });\n }\n break;\n case IDVStatus.FAILED:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: null,\n entityId,\n });\n }\n break;\n case IDVStatus.INTERRUPTED:\n case IDVStatus.INCOMPLETE:\n case IDVStatus.DOCUMENTS_INVALID:\n case IDVStatus.WAITING_DOC_UPLOAD:\n case IDVStatus.WAITING_SELFIE_UPLOAD:\n {\n eventHub.emit('input_required', { entityId }, results.checkStatus);\n }\n break;\n case IDVStatus.PROVIDER_OFFLINE:\n case IDVStatus.AWAITING_CONSENT:\n {\n const errorMessage =\n results.checkStatus === IDVStatus.PROVIDER_OFFLINE\n ? `Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${IDVStatus.PROVIDER_OFFLINE}`\n : \"Consent was not provided to the IDV Api. We can't continue.\";\n eventHub.emit(\n 'error',\n new OneSDKError(errorMessage, {\n errorStatus: results.checkStatus,\n }),\n );\n }\n break;\n case IDVStatus.CHECK_PROCESSING:\n {\n eventHub.emit('processing', { checkStatus: results.checkStatus, entityId });\n }\n break;\n default: {\n const errorMessage = `Unexpected IDV status: ${results.checkStatus}`;\n eventHub.emit('warning', {\n message: errorMessage,\n payload: results,\n });\n }\n }\n}\ntype IDVEventHub = EventHub<IDVModule['moduleEvents']>;\n","import type { EventListener } from '@module/common';\nimport type { OneSDKError } from '@module/common';\nimport type { InjectedState } from '@module/common/types';\nimport { SdkModes } from '@module/sdk/types';\n\n\nimport { createDummyHTML } from './createDummyIframeTemplate';\nimport {\n createIframeEventListener,\n} from './createIframeEventListener';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type {\n IframeMessagingOptions,\n} from './createIframeEventListener';\n\n/**\n * Generic events definition for an Iframe\n * All IDV iframes need to find ways to implement these events, where the payload is optional and may differ per vendor\n **/\nexport type IFrameEvents = {\n loaded: [unknown?];\n success: [unknown?];\n error: [OneSDKError<Record<string, unknown>>];\n};\n\n/**\n * Create and return an iframe element configured according to globalState and vendorParameters returned from api\n *\n * When the vendor is exposed inside an iframe, the generic solution is to listen for messages posted to the window object of the iframe. \"Messages\" are equivalent to \"events\".\n * The message's contents will differ per vendor, but we're expected to figure out a way to convert those messages into OneSDK events for \"loaded\", \"success\" and \"error\".\n *\n * @param globalState The global state of the OneSDK. The object provided to all components automatically\n * @param options The options to configure the iframe with\n * @param options.vendorParameters The parameters returned from the api to configure the iframe with\n * @param options.dummyModeOptions The options to configure the iframe with when in dummy mode\n * @param options.iframeMessagingOptions The options to configure an event hub to respond to iframe messages\n * @returns The iframe element\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild when the iframe fails to be appended to the DOM\n */\nexport function createIframe<E extends IFrameEvents, D>(\n globalState: InjectedState,\n options: CreateIframeOptions<E, D>,\n): { iframe: HTMLIFrameElement; iframeListener: EventListener<IFrameEvents> } {\n const iframe = document.createElement('iframe');\n const iframeListener = createIframeEventListener(iframe, options.iframeMessagingOptions);\n // Styling reset based on https://www.easeout.co/blog/2020-06-16-css-resets-normalizing/\n Object.assign(iframe.style, {\n border: 0,\n margin: 0,\n padding: 0,\n width: '100%',\n height: '100%',\n fontSize: '100%',\n font: 'inherit',\n verticalAlign: 'baseline',\n });\n iframe.allow = 'camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;';\n const isDummy = globalState.mode.is(SdkModes.DUMMY);\n\n if (isDummy) {\n iframe.srcdoc = createDummyHTML(options.dummyModeOptions);\n } else {\n iframe.src = options.vendorParameters.tokenURL;\n }\n\n return { iframe, iframeListener };\n}\n\nexport type CreateIframeOptions<E extends IFrameEvents = IFrameEvents, D = unknown> = {\n vendorParameters: { tokenURL: string };\n dummyModeOptions: DummyHTMLOptions;\n iframeMessagingOptions: IframeMessagingOptions<E, D>;\n};\n\n/**\n * Cleanup\n */\nexport function cleanup(dependencies: {\n internalEventHub: EventListener;\n iframe: HTMLIFrameElement;\n}) {\n dependencies.iframe.srcdoc = '';\n dependencies.internalEventHub.off();\n dependencies.iframe.remove();\n}\n","import { EventHub, EventListener, mkEventHub, mkEventListener } from \"@module/common\";\nimport { IFrameEvents } from \"./createIframe\";\n\n/**\n * Create a new eventListener that will listen for messages from the provided iframe and callback\n * @param iframe the iframe to listen for messages from\n * @param options callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n * @returns an event hub that will listen for messages from the iframe\n */\nexport function createIframeEventListener<E extends IFrameEvents, D>(\n iframe: HTMLIFrameElement,\n options: IframeMessagingOptions<E, D>\n): EventListener<IFrameEvents> {\n const iframeEventListener = mkEventHub<IFrameEvents>();\n\n if (options.emitOnLoad) iframe.onload = () => iframeEventListener.emit(\"loaded\");\n // Listen for messages from the provided iframe only. Logic for mapping messages to events is provided by the onIframeMessageReceived callback\n window.addEventListener(\n \"message\",\n (message) => {\n const originatesFromIframe = message.source === iframe.contentWindow;\n if (originatesFromIframe) options.mapMessageToEvent(iframeEventListener, message, iframe);\n },\n false\n );\n return mkEventListener(iframeEventListener);\n}\n/**\n * Callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n *\n * This function's exclusive responsibility is to interpret iframe messages and reemit them to the targetEventHub. It might as well\n *\n * The first type parameter defines the payload of the events\n * The second type parameter defines the iframe message data type\n * @param targetEventHub the event hub to reemit the event to\n * @param message the message event received from the iframe\n * @param iframeElement (optional) the iframe element itself, used to access the iframe, if required. ie: using iframe.onLoad to emit \"loaded\"\n * @returns void\n */\nexport type IframeMessagingOptions<E extends IFrameEvents = IFrameEvents, MessageType = unknown> = {\n mapMessageToEvent: (\n targetEventHub: EventHub<E>,\n message: MessageEvent<MessageType>,\n iframeElement?: HTMLIFrameElement\n ) => void;\n emitOnLoad: boolean;\n};\n","/* eslint-disable @typescript-eslint/ban-types */\n\n/**\n * DUMMY implementation of the iframe contents\n * Ensure to emit messages where data is tagged with a type (see more below)\n */\nexport function createDummyHTML(dummyModeOptions: DummyHTMLOptions) {\n const stringifyPostMessage = (message: unknown = {}) => `window.parent.postMessage(${JSON.stringify(message)}, \"*\")`;\n // Some vendors won't emit a \"loaded\" event.\n // The option emitOnLoad will cause the capture of the loaded event to happen somewhere else.\n // That means the dummy iframe doesn't need to emit it\n // If emitOnLoad is false, then the dummy iframe needs to emit the loaded event\n // In this case it will wait a predefined amount of time to emulate the \"loading\" period, and them emit the \"loaded\" message\n const onLoadedAction = dummyModeOptions.loadedPayload\n ? `setTimeout(() => ${stringifyPostMessage(dummyModeOptions.loadedPayload)}, DUMMY_LOAD_DELAY)`\n : \"\";\n const onCompletedAction = stringifyPostMessage(dummyModeOptions.successPayload);\n const onErrorAction = stringifyPostMessage(dummyModeOptions.errorPayload);\n\n return `<body style=\"background-color: white\">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${onLoadedAction};\n function cancelClicked() {\n ${onErrorAction};\n }\n function completeClicked() {\n ${onCompletedAction};\n }\n </script>\n <h1>${dummyModeOptions.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a \"detection_complete\" event</li>\n <li>Will trigger api calls, which will then emit the \"results\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a \"detection_failed\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id=\"actions-container\">\n <button onclick=\"completeClicked()\">Simulate Completion</button>\n <button onclick=\"cancelClicked()\">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`;\n}\n/** Options for the contents of the Iframe when in dummy mode */\nexport type DummyHTMLOptions = {\n loadedPayload?: unknown;\n successPayload?: unknown;\n errorPayload?: unknown;\n title: string;\n};\n","import { defineWrapper } from '@module/common/modules/defineModule';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport { checkStatusEventMapping } from '../checkStatusEventMapping';\nimport { initialiseIDVSession } from '../initialiseSession';\n\nimport { cleanup, createIframe } from './createIframe';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type { IframeMessagingOptions } from './createIframeEventListener';\n\n/**\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild\n * @emits AxiosError when HTTP requests fail\n */\n\nexport const defineIframeIDVWrapper = (wrapperOptions: Options) => {\n const { dummyOptions, eventOptions, vendor } = wrapperOptions;\n\n return defineWrapper<IDVModule>(vendor, async (globalState, options) => {\n // load mastercard token/iframe url from IDVClient\n const { localEventHub } = globalState;\n\n /*-------- 0) FETCH SESSION DATA */\n type VendorParameters = { tokenURL: string; interviewId: string };\n const {\n vendorParameters,\n idvClient,\n entityId,\n } = await initialiseIDVSession<VendorParameters>(globalState);\n\n /*-------- 1) CREATE IFRAME */\n const { iframe, iframeListener } = createIframe(globalState, {\n vendorParameters,\n dummyModeOptions: dummyOptions,\n iframeMessagingOptions: eventOptions,\n });\n\n /**\n * -------- 2) MAP EVENTS\n * Event listener for the \"success\" event on the iframe.\n * This event is emitted when the detection is successfully completed,\n * triggering checks and running cleanup.\n *\n * @param {Object} params - Parameters received from the iframe event.\n * @param {string} params.checkId - The ID generated from the provider for\n * backend to fetch the results (if available).\n * Use case: VendorSDK -> OneSDK -> Backend\n * @param {string} params.sessionKey - The session key used by\n * backend and obtained earlier from vendorParameters (if available).\n * Use case: VendorParameters -> OneSDK -> Backend\n */\n iframeListener.on('success', async ({ checkId, sessionKey }: Partial<{\n checkId: string;\n sessionKey: string;\n }>) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n\n localEventHub.emit('detection_complete');\n\n // Initialize the IDV process with provided parameters\n const results = await idvClient.initProcess({\n isSynchronous: true,\n vendorParameters: {\n checkId: checkId ?? vendorParameters[sessionKey],\n },\n });\n\n try {\n // Update local state for the individual before emitting events for results\n const individual = globalState.oneSdkInstance.individual();\n await individual.search();\n } catch (e) {\n // Handle errors during individual state update\n const errorMessage =\n `Error updating individual state. ` +\n `Check error events from module 'individual' for more details.` +\n `This isn't related to IDV capture.`;\n localEventHub.emit('warning', {\n message: errorMessage,\n payload: e,\n });\n }\n // Map check status events with the localEventHub\n checkStatusEventMapping({\n eventHub: localEventHub,\n results,\n entityId,\n });\n });\n\n // iframe \"ERROR\"\n // emits \"detection_failed\" and runs cleanup\n iframeListener.on('error', (error) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // TODO: figure out better error message and reason\n localEventHub.emit('detection_failed', {\n message: `Error from ${vendor}: ${error.message}`,\n payload: error.payload,\n });\n });\n\n // iframe \"LOOADED\"\n // emits \"ready\"\n iframeListener.on('loaded', () => {\n localEventHub.emit('ready', { domElement: iframe });\n });\n\n /*-------- 3) MOUNT IFRAME */\n\n // Inject iframe in the provider DOM container\n const { mountElement } = options;\n mountElement.appendChild(iframe);\n });\n};\ntype Options = {\n vendor: IDVModule['vendorName'];\n dummyOptions: DummyHTMLOptions;\n eventOptions: IframeMessagingOptions;\n};\n","import { FrankieApiClient } from '@module/frankie-client';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport { IDVEventHub } from '@module/idv/definition.types';\nimport { Dictionary } from '@types';\n\n/**\n * Helper that initialises a session with the IDV api\n * @param options Options object\n * @param options.eventHub eventHub to emit events to\n * @param options.frankieClient authenticated frankie client\n * @returns A promise of { idvClient, entityId, vendorParameters }\n * @throws Error if the session data could not be loaded\n * @emits \"session_data_generated\" with the session data\n * @emits \"session_data_failed_loading\", when session generation fails\n **/\nexport async function initialiseIDVSession<VendorParameters extends Dictionary<unknown>>(\n options: CreateIDVSessionOptions,\n) {\n const { localEventHub: eventHub, frankieClient } = options;\n try {\n const idvClient = new IDVClient(frankieClient);\n // Vendors some times generate a token and an url to be used in an iframe\n // During the same call, if the entity doesn't exist yet, Frankie cretes one and returns the new entity id\n const { vendorParameters, entityId } = await idvClient.getToken<VendorParameters>({\n relayState: options.relayState,\n });\n // TODO: Add entity id to the individual module and trigger a reload of the entity data\n // Emit session_data_generated for information purposes only. This has no functionality\n eventHub.emit('session_data_generated', { session: { ...vendorParameters, entityId } });\n\n return { vendorParameters, idvClient, entityId };\n } catch (e) {\n eventHub.emit('session_data_failed_loading');\n throw e;\n }\n}\nexport type CreateIDVSessionOptions = {\n localEventHub: IDVEventHub;\n frankieClient: FrankieApiClient;\n relayState?: string;\n};\n"],"names":["initialise","vendor","dummyOptions","title","loadedPayload","JSON","stringify","payload","value","successPayload","checkId","errorPayload","metainfo","msg","eventOptions","emitOnLoad","mapMessageToEvent","eventHub","event","messageData","parse","data","emit","message","workflowExecutionId","OneSDKError","checkStatusEventMapping","options","results","entityId","checkStatus","COMPLETE","document","ocrDocument","FAILED","INTERRUPTED","INCOMPLETE","DOCUMENTS_INVALID","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","PROVIDER_OFFLINE","AWAITING_CONSENT","errorMessage","errorStatus","CHECK_PROCESSING","createIframe","globalState","iframe","createElement","iframeListener","iframeEventListener","mkEventHub","onload","window","addEventListener","source","contentWindow","mkEventListener","createIframeEventListener","iframeMessagingOptions","Object","assign","style","border","margin","padding","width","height","fontSize","font","verticalAlign","allow","mode","is","DUMMY","srcdoc","dummyModeOptions","stringifyPostMessage","onLoadedAction","onCompletedAction","createDummyHTML","src","vendorParameters","tokenURL","cleanup","dependencies","internalEventHub","off","remove","defineIframeIDVWrapper","wrapperOptions","localEventHub","idvClient","on","sessionKey","initProcess","isSynchronous","individual","oneSdkInstance","search","e","error","domElement","mountElement","appendChild","initialiseIDVSession","frankieClient","getToken","relayState","session"],"sourceRoot":""}
1
+ {"version":3,"file":"idv-mastercard.js","mappings":"gJAGO,MAAMA,GAAa,E,SAAA,GAAuB,CAC/CC,OAAQ,aACRC,aAAc,CACZC,MAAO,8BAEPC,cAAeC,KAAKC,UAAU,CAAEC,QAAS,CAAEC,MAAO,YAClDC,eAAgBJ,KAAKC,UAAU,CAC7BC,QAAS,CAAEC,MAAO,WAClBE,QAAS,wBAEXC,aAAcN,KAAKC,UAAU,CAC3BC,QAAS,CACPC,MAAO,QACPI,SAAU,CAAEC,IAAK,mCAIvBC,aAAc,CAEZC,YAAY,EACZ,iBAAAC,EAAkB,eAAEC,EAAc,QAAEC,IAElC,MAAMC,EAA2Bd,KAAKe,MAAMF,EAAQG,MAC9Cd,EAAUY,EAAYZ,QAG5B,GADAU,EAAeK,KAAK,OAAQ,CAAEJ,QAAS,oBAAoBX,EAAQC,QAASD,QAASY,IAC/D,WAAlBZ,EAAQC,MAAoBS,EAAeK,KAAK,eAC/C,GAAsB,YAAlBf,EAAQC,MAAqB,CACpC,MAAME,EAAUS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,EAAgBE,GAAG,CAAC,iBAAkB,aAAc,UAAU,IAC5DR,EAAc1E,KAAK,WAAW,EAAO,CAAEJ,QAAS,uCAGlDoF,EAAgBS,IAAI,CAAC,iBAAkB,aAAc,QAAS,WAAYf,GAK1EE,EAAac,YAAYhE,EAC3B,KAAE,C,uVCrHG,SAAeiE,EACpBtF,G,yCAEA,MAAQqE,cAAepE,EAAQ,cAAEsF,GAAkBvF,EACnD,IACE,MAAM4E,EAAY,IAAI,KAAUW,IAG1B,iBAAE1F,EAAgB,SAAEM,SAAmByE,EAAUY,SAA2B,CAChFC,WAAYzF,EAAQyF,aAMtB,OAFAxF,EAASN,KAAK,yBAA0B,CAAE+F,QAAS,OAAF,wBAAO7F,GAAgB,CAAEM,eAEnE,CAAEN,mBAAkB+E,YAAWzE,W,CACtC,MAAO6E,GAEP,MADA/E,EAASN,KAAK,+BACRqF,C,CAEV,G","sources":["webpack://OneSdk/./modules/idv/vendors/Mastercard/index.ts","webpack://OneSdk/./modules/idv/vendors/common/checkStatusEventMapping.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframe.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createIframeEventListener.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/createDummyIframeTemplate.ts","webpack://OneSdk/./modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.ts","webpack://OneSdk/./modules/idv/vendors/common/initialiseSession.ts"],"sourcesContent":["import { OneSDKError } from '../../../common';\nimport { defineIframeIDVWrapper } from '../common/iframeUtils/defineIframeIDVWrapper';\n\nexport const initialise = defineIframeIDVWrapper({\n vendor: 'mastercard',\n dummyOptions: {\n title: `Mastercard IDV Dummy iframe`,\n // Mastercard transmits their message data as a stringified JSON\n loadedPayload: JSON.stringify({ payload: { value: 'loaded' } }),\n successPayload: JSON.stringify({\n payload: { value: 'success' },\n checkId: 'random-execution-id',\n }),\n errorPayload: JSON.stringify({\n payload: {\n value: 'error',\n metainfo: { msg: 'Dummy error from Mastercard' },\n },\n }),\n },\n eventOptions: {\n // Since mastercard emits its own \"loaded\" event, we don't need to react to iframe.onload event\n emitOnLoad: false,\n mapMessageToEvent({ targetEventHub, message }) {\n // Mastercard transmits their message data as a stringified JSON\n const messageData: MessageData = JSON.parse(message.data as string);\n const payload = messageData.payload;\n\n targetEventHub.emit('info', { message: `Received message ${payload.value}`, payload: messageData });\n if (payload.value === 'loaded') targetEventHub.emit('loaded');\n else if (payload.value === 'success') {\n const checkId = messageData.workflowExecutionId;\n targetEventHub.emit('success', { vendorParameters: { checkId } });\n } else if (payload.value === 'error')\n targetEventHub.emit('error', new OneSDKError(payload.metainfo.msg, payload.metainfo));\n else\n targetEventHub.emit('warning', {\n message: `Unexpected message ${(payload as Payload).value}`,\n payload: messageData,\n });\n },\n },\n});\n\ntype MetaInfo = { msg: string } & Record<string, unknown>;\ntype Payload = { value: 'loaded' } | { value: 'success' } | { value: 'error'; metainfo: MetaInfo };\ntype MessageData = { payload: Payload; workflowExecutionId: string };\n","import type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport type { Document } from '../../../common/shared/models/Document';\n\n/** Interpret results from initProcess endpoint and emit appropriate events */\nexport function checkStatusEventMapping(options: {\n eventHub: IDVEventHub;\n results: { checkStatus: IDVStatus; ocrDocument?: Document };\n entityId: string;\n}) {\n const { eventHub, results, entityId } = options;\n switch (results.checkStatus) {\n case IDVStatus.COMPLETE:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: results.ocrDocument,\n entityId,\n });\n }\n break;\n case IDVStatus.FAILED:\n {\n eventHub.emit('results', {\n checkStatus: results.checkStatus,\n document: null,\n entityId,\n });\n }\n break;\n case IDVStatus.INTERRUPTED:\n case IDVStatus.INCOMPLETE:\n case IDVStatus.DOCUMENTS_INVALID:\n case IDVStatus.WAITING_DOC_UPLOAD:\n case IDVStatus.WAITING_SELFIE_UPLOAD:\n {\n eventHub.emit('input_required', { entityId }, results.checkStatus);\n }\n break;\n case IDVStatus.PROVIDER_OFFLINE:\n case IDVStatus.AWAITING_CONSENT:\n {\n const errorMessage =\n results.checkStatus === IDVStatus.PROVIDER_OFFLINE\n ? `Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${IDVStatus.PROVIDER_OFFLINE}`\n : \"Consent was not provided to the IDV Api. We can't continue.\";\n eventHub.emit(\n 'error',\n new OneSDKError(errorMessage, {\n errorStatus: results.checkStatus,\n }),\n );\n }\n break;\n case IDVStatus.CHECK_PROCESSING:\n {\n eventHub.emit('processing', { checkStatus: results.checkStatus, entityId });\n }\n break;\n default: {\n const errorMessage = `Unexpected IDV status: ${results.checkStatus}`;\n eventHub.emit('warning', {\n message: errorMessage,\n payload: results,\n });\n }\n }\n}\ntype IDVEventHub = EventHub<IDVModule['moduleEvents']>;\n","import type { EventListener } from '@module/common';\nimport type { InjectedState } from '@module/common/types';\nimport { SdkModes } from '@module/sdk/types';\n\nimport { createDummyHTML } from './createDummyIframeTemplate';\nimport { createIframeEventListener } from './createIframeEventListener';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type { IframeMessagingOptions } from './createIframeEventListener';\nimport type { OneSDKError } from '../../../../common';\n\n/**\n * Generic events definition for an Iframe\n * All IDV iframes need to find ways to implement these events, where the payload is optional and may differ per vendor\n **/\nexport type IFrameEvents = {\n loaded: [unknown?];\n success: [{ vendorParameters: Record<string, unknown> }?];\n error: [OneSDKError<Record<string, unknown>>];\n};\n\n/**\n * Create and return an iframe element configured according to globalState and vendorParameters returned from api\n *\n * When the vendor is exposed inside an iframe, the generic solution is to listen for messages posted to the window object of the iframe. \"Messages\" are equivalent to \"events\".\n * The message's contents will differ per vendor, but we're expected to figure out a way to convert those messages into OneSDK events for \"loaded\", \"success\" and \"error\".\n *\n * @param globalState The global state of the OneSDK. The object provided to all components automatically\n * @param options The options to configure the iframe with\n * @param options.vendorParameters The parameters returned from the api to configure the iframe with\n * @param options.dummyModeOptions The options to configure the iframe with when in dummy mode\n * @param options.iframeMessagingOptions The options to configure an event hub to respond to iframe messages\n * @returns The iframe element\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild when the iframe fails to be appended to the DOM\n */\nexport function createIframe(\n globalState: InjectedState,\n options: CreateIframeOptions,\n): { iframe: HTMLIFrameElement; iframeListener: EventListener<IFrameEvents> } {\n const iframe = document.createElement('iframe');\n const iframeListener = createIframeEventListener(iframe, options.iframeMessagingOptions);\n // Styling reset based on https://www.easeout.co/blog/2020-06-16-css-resets-normalizing/\n Object.assign(iframe.style, {\n border: 0,\n margin: 0,\n padding: 0,\n width: '100%',\n height: '100%',\n fontSize: '100%',\n font: 'inherit',\n verticalAlign: 'baseline',\n });\n iframe.allow = 'camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;';\n const isDummy = globalState.mode.is(SdkModes.DUMMY);\n\n if (isDummy) {\n iframe.srcdoc = createDummyHTML(options.dummyModeOptions);\n } else {\n iframe.src = options.vendorParameters.tokenURL;\n }\n\n return { iframe, iframeListener };\n}\nexport type CreateIframeOptions = {\n vendorParameters: { tokenURL: string };\n dummyModeOptions: DummyHTMLOptions;\n iframeMessagingOptions: IframeMessagingOptions;\n};\n\n/**\n * Cleanup\n */\nexport function cleanup(dependencies: { internalEventHub: EventListener; iframe: HTMLIFrameElement }) {\n dependencies.iframe.srcdoc = '';\n dependencies.internalEventHub.off();\n dependencies.iframe.remove();\n}\n","import type { EventHub, EventListener } from '@module/common';\nimport { mkEventHub, mkEventListener } from '@module/common';\n\nimport type { IFrameEvents } from './createIframe';\n\n/**\n * Create a new eventListener that will listen for messages from the provided iframe and callback\n * @param iframe the iframe to listen for messages from\n * @param options callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n * @returns an event hub that will listen for messages from the iframe\n */\nexport function createIframeEventListener(\n iframe: HTMLIFrameElement,\n options: IframeMessagingOptions,\n): EventListener<IFrameEvents> {\n const iframeEventListener = mkEventHub<IFrameEvents>();\n\n if (options.emitOnLoad) iframe.onload = () => iframeEventListener.emit('loaded');\n // Listen for messages from the provided iframe only. Logic for mapping messages to events is provided by the onIframeMessageReceived callback\n window.addEventListener(\n 'message',\n (message) => {\n const originatesFromIframe = message.source === iframe.contentWindow;\n if (originatesFromIframe)\n options.mapMessageToEvent({\n targetEventHub: iframeEventListener,\n message,\n iframeElement: iframe,\n vendorParameters: options.vendorParameters,\n });\n },\n false,\n );\n return mkEventListener(iframeEventListener);\n}\n/**\n * Callback to call when a message is received (second argument) and reemit event to the targetEventHub, provided as the first argument\n *\n * This function's exclusive responsibility is to interpret iframe messages and reemit them to the targetEventHub. It might as well\n *\n * The first type parameter defines the payload of the events\n * The second type parameter defines the iframe message data type\n * @param targetEventHub the event hub to reemit the event to\n * @param message the message event received from the iframe\n * @param iframeElement (optional) the iframe element itself, used to access the iframe, if required. ie: using iframe.onLoad to emit \"loaded\"\n * @returns void\n */\nexport type IframeMessagingOptions = {\n mapMessageToEvent: (ops: {\n targetEventHub: EventHub<IFrameEvents>;\n message: MessageEvent<unknown>;\n iframeElement?: HTMLIFrameElement;\n vendorParameters?: Record<string, unknown>;\n }) => void;\n emitOnLoad: boolean;\n vendorParameters?: Record<string, unknown>;\n};\n","/* eslint-disable @typescript-eslint/ban-types */\n\n/**\n * DUMMY implementation of the iframe contents\n * Ensure to emit messages where data is tagged with a type (see more below)\n */\nexport function createDummyHTML(dummyModeOptions: DummyHTMLOptions) {\n const stringifyPostMessage = (message: unknown = {}) => `window.parent.postMessage(${JSON.stringify(message)}, \"*\")`;\n // Some vendors won't emit a \"loaded\" event.\n // The option emitOnLoad will cause the capture of the loaded event to happen somewhere else.\n // That means the dummy iframe doesn't need to emit it\n // If emitOnLoad is false, then the dummy iframe needs to emit the loaded event\n // In this case it will wait a predefined amount of time to emulate the \"loading\" period, and them emit the \"loaded\" message\n const onLoadedAction = dummyModeOptions.loadedPayload\n ? `setTimeout(() => ${stringifyPostMessage(dummyModeOptions.loadedPayload)}, DUMMY_LOAD_DELAY)`\n : \"\";\n const onCompletedAction = stringifyPostMessage(dummyModeOptions.successPayload);\n const onErrorAction = stringifyPostMessage(dummyModeOptions.errorPayload);\n\n return `<body style=\"background-color: white\">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${onLoadedAction};\n function cancelClicked() {\n ${onErrorAction};\n }\n function completeClicked() {\n ${onCompletedAction};\n }\n </script>\n <h1>${dummyModeOptions.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a \"detection_complete\" event</li>\n <li>Will trigger api calls, which will then emit the \"results\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a \"detection_failed\" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id=\"actions-container\">\n <button onclick=\"completeClicked()\">Simulate Completion</button>\n <button onclick=\"cancelClicked()\">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`;\n}\n/** Options for the contents of the Iframe when in dummy mode */\nexport type DummyHTMLOptions = {\n loadedPayload?: unknown;\n successPayload?: unknown;\n errorPayload?: unknown;\n title: string;\n};\n","import features from '@feature-flags';\nimport { OneSDKError } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport { mkEventHub } from '@module/common/modules/eventHub';\nimport { useSmartUIToReviewResults } from '@module/common/vendors/smart-ui/useSmartUI';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport { checkStatusEventMapping } from '../checkStatusEventMapping';\nimport { initialiseIDVSession } from '../initialiseSession';\n\nimport { cleanup, createIframe } from './createIframe';\n\nimport type { DummyHTMLOptions } from './createDummyIframeTemplate';\nimport type { IframeMessagingOptions } from './createIframeEventListener';\nimport type { Events } from '../../../events.types';\n/**\n * @emits HierarchyRequestError https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild\n * @emits AxiosError when HTTP requests fail\n */\n\nexport const defineIframeIDVWrapper = (wrapperOptions: Options) => {\n const { dummyOptions, eventOptions, vendor } = wrapperOptions;\n const containsReviewScreen = features.modules.idv.containsReviewScreen[vendor] ?? false;\n\n return defineWrapper<IDVModule>(vendor, async (sharedDependencies, options) => {\n // load mastercard token/iframe url from IDVClient\n const { localEventHub, recipe } = sharedDependencies;\n const { mountElement } = options;\n // For smart ui to be included after the \"results\" event, the recipe configuration provideReviewScreen must not be false\n // and the vendor must be configured with containsReviewScreen = false, meaning it doesn't already provide one internally\n // * Smart UI is not displayed for vendors which already have a review screen\n const recipeProvideReviewScreen = recipe.idv.provideReviewScreen ?? true;\n const includeSmartUI = !containsReviewScreen && recipeProvideReviewScreen;\n\n const privateEventHub = mkEventHub<Events>();\n\n /*-------- 0) FETCH SESSION DATA */\n type VendorParameters = { tokenURL: string };\n const { vendorParameters, idvClient, entityId } = await initialiseIDVSession<VendorParameters>(sharedDependencies);\n\n /*-------- 1) CREATE IFRAME */\n const { iframe, iframeListener } = createIframe(sharedDependencies, {\n vendorParameters,\n dummyModeOptions: dummyOptions,\n iframeMessagingOptions: {\n ...eventOptions,\n vendorParameters,\n },\n });\n\n /*-------- 2) MAP EVENTS */\n\n // 2.0) Iframe events -> localEventHub and privateEventHub\n // iframe \"SUCCESS\"\n // emits \"detection_complete\", trigger checks and runs cleanup\n iframeListener.on('success', async ({ vendorParameters }) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // \"detection_complete\" is only emitted when vendors already have a review screen\n // this event is only emitted after the review screen. When includeSmartUI is true\n // it only happens after the \"results\" event and the following smart ui\n if (!includeSmartUI) localEventHub.emit('detection_complete');\n // If not emitting \"detection_complete\" here, emit an \"info\" event instead\n else {\n localEventHub.emit('info', {\n message: 'Data extraction completed. Now executing user review using smart ui.',\n });\n }\n\n localEventHub.emit('loading', true, { message: 'Retrieving IDV results' });\n\n try {\n const results = await idvClient.initProcess({\n isSynchronous: true,\n vendorParameters,\n });\n\n checkStatusEventMapping({\n eventHub: privateEventHub,\n results,\n entityId,\n });\n } catch (e) {\n localEventHub.emit('error', new OneSDKError('Failed initiating IDV processing', e));\n localEventHub.emit('loading', false, { message: 'Failed retrieving IDV results' });\n }\n });\n\n // iframe \"ERROR\"\n // emits \"detection_failed\" and runs cleanup\n iframeListener.on('error', (error) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // TODO: figure out better error message and reason\n localEventHub.emit('detection_failed', {\n message: `Error from ${vendor}: ${error.message}`,\n payload: error.payload,\n });\n localEventHub.emit('loading', false, { message: `Vendor '${vendor}' detection has failed` });\n });\n\n // iframe \"LOOADED\"\n // emits \"ready\"\n iframeListener.on('loaded', () => {\n localEventHub.emit('ready', { domElement: iframe });\n localEventHub.emit('loading', false, { message: `Vendor '${vendor}' screen has loaded` });\n });\n\n // 2.1) Status events (privateEventHub) -> localEventHub\n\n // If includeSmartUI is true, instead of emitting 'results' event with the idv results\n // first mount the smart ui to the same mountElement and only when smart ui emits a 'results' event\n // then emit 'results' too\n privateEventHub.on(\n 'results',\n useSmartUIToReviewResults({\n ...sharedDependencies,\n mountElement,\n shouldAttachSmartUI: includeSmartUI,\n }),\n );\n // For each final event that's not a result emit a 'loading' false event\n privateEventHub.on(['input_required', 'processing', 'error'], () =>\n localEventHub.emit('loading', false, { message: 'Completed process unsuccessfully' }),\n );\n // all other events should be reemitted as is\n privateEventHub.map(['input_required', 'processing', 'error', 'warning'], localEventHub);\n\n /*-------- 3) MOUNT IFRAME */\n\n // Inject iframe in the provider DOM container\n mountElement.appendChild(iframe);\n });\n};\ntype Options = {\n vendor: IDVModule['vendorName'];\n /** Options for auto generating UI for the dummy mode */\n dummyOptions: DummyHTMLOptions;\n /** Options for mapping iframe messages into OneSDK eventhub events */\n eventOptions: IframeMessagingOptions;\n};\n","import { FrankieApiClient } from '@module/frankie-client';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport { IDVEventHub } from '@module/idv/definition.types';\nimport { Dictionary } from '@types';\n\n/**\n * Helper that initialises a session with the IDV api\n * @param options Options object\n * @param options.eventHub eventHub to emit events to\n * @param options.frankieClient authenticated frankie client\n * @returns A promise of { idvClient, entityId, vendorParameters }\n * @throws Error if the session data could not be loaded\n * @emits \"session_data_generated\" with the session data\n * @emits \"session_data_failed_loading\", when session generation fails\n **/\nexport async function initialiseIDVSession<VendorParameters extends Dictionary<unknown>>(\n options: CreateIDVSessionOptions,\n) {\n const { localEventHub: eventHub, frankieClient } = options;\n try {\n const idvClient = new IDVClient(frankieClient);\n // Vendors some times generate a token and an url to be used in an iframe\n // During the same call, if the entity doesn't exist yet, Frankie cretes one and returns the new entity id\n const { vendorParameters, entityId } = await idvClient.getToken<VendorParameters>({\n relayState: options.relayState,\n });\n // TODO: Add entity id to the individual module and trigger a reload of the entity data\n // Emit session_data_generated for information purposes only. This has no functionality\n eventHub.emit('session_data_generated', { session: { ...vendorParameters, entityId } });\n\n return { vendorParameters, idvClient, entityId };\n } catch (e) {\n eventHub.emit('session_data_failed_loading');\n throw e;\n }\n}\nexport type CreateIDVSessionOptions = {\n localEventHub: IDVEventHub;\n frankieClient: FrankieApiClient;\n relayState?: string;\n};\n"],"names":["initialise","vendor","dummyOptions","title","loadedPayload","JSON","stringify","payload","value","successPayload","checkId","errorPayload","metainfo","msg","eventOptions","emitOnLoad","mapMessageToEvent","targetEventHub","message","messageData","parse","data","emit","workflowExecutionId","vendorParameters","OneSDKError","checkStatusEventMapping","options","eventHub","results","entityId","checkStatus","COMPLETE","document","ocrDocument","FAILED","INTERRUPTED","INCOMPLETE","DOCUMENTS_INVALID","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","PROVIDER_OFFLINE","AWAITING_CONSENT","errorMessage","errorStatus","CHECK_PROCESSING","createIframe","globalState","iframe","createElement","iframeListener","iframeEventListener","mkEventHub","onload","window","addEventListener","source","contentWindow","iframeElement","mkEventListener","createIframeEventListener","iframeMessagingOptions","Object","assign","style","border","margin","padding","width","height","fontSize","font","verticalAlign","allow","mode","is","DUMMY","srcdoc","dummyModeOptions","stringifyPostMessage","onLoadedAction","onCompletedAction","createDummyHTML","src","tokenURL","cleanup","dependencies","internalEventHub","off","remove","defineIframeIDVWrapper","wrapperOptions","containsReviewScreen","modules","idv","sharedDependencies","localEventHub","recipe","mountElement","recipeProvideReviewScreen","provideReviewScreen","includeSmartUI","privateEventHub","idvClient","on","initProcess","isSynchronous","e","error","domElement","shouldAttachSmartUI","map","appendChild","initialiseIDVSession","frankieClient","getToken","relayState","session"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[933],{72900:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>y});var i=t(99434),o=t(64794);class r extends o.W{retrieveAndDelete(e){return n=this,t=void 0,o=function*(){const n=`/data/v1/key-value/${e}`;return this.frankie.get(n,{params:{delete:!0}}).then((e=>e.data))},new((i=void 0)||(i=Promise))((function(e,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i((function(e){e(t)}))).then(c,a)}s((o=o.apply(n,t||[])).next())}));var n,t,i,o}}var c=t(36932),a=t(50750),s=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function c(e){try{s(i.next(e))}catch(e){r(e)}}function a(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}))};function l(e){return`sessionId:${e}:idv_action_details`}var d=t(97356),u=t(8707),f=t(34861),v=t(85730),m=t(96834);function h(...e){return n=this,t=void 0,o=function*(){const[n]=e,{mode:t,session:i,localEventHub:o}=n,r=n.recipe.idv.provider,c=null==r?void 0:r.redirect_uri;try{const{vendorParameters:o}=yield(0,u.W)({frankieClient:n.frankieClient,localEventHub:n.localEventHub,relayState:JSON.stringify({redirect_uri:null!=c?c:window.location.href,sessionId:i.sessionId})});t.is(d.j8.DUMMY)?function(...e){const[n,t]=e,{mountElement:i}=t,{session:o,localEventHub:r}=n,{iframe:c,iframeListener:a}=(0,v.V)(n,{dummyModeOptions:{title:"OCRLabs",errorPayload:{type:"error"},successPayload:{type:"success"},loadedPayload:{type:"loaded"}},iframeMessagingOptions:{emitOnLoad:!1,mapMessageToEvent:(e,n)=>{const{data:t}=n,{type:i}=t;e.emit(i)}},vendorParameters:{tokenURL:"https://not-used.com"}}),s=new f.m,d=l(o.sessionId),u=n.recipe.idv.provider,m=null==u?void 0:u.redirect_uri,h=()=>{m?location.href=m:location.reload()};a.on("success",(()=>{s.store(d,{workflow:"IDV_SUCCESS"}),(0,v.E)({iframe:c,internalEventHub:a}),h()})),a.on("error",(()=>{s.store(d,{workflow:"IDV_ERROR"}),(0,v.E)({iframe:c,internalEventHub:a}),h()})),a.on("loaded",(()=>{r.emit("ready",{domElement:c})})),i.appendChild(c)}(...e):n.frankieClient.redirect(new URL(o.tokenURL))}catch(e){o.emit("error",new m.OneSDKError("Failed initialising a new idv flow",e))}},new((i=void 0)||(i=Promise))((function(e,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i((function(e){e(t)}))).then(c,a)}s((o=o.apply(n,t||[])).next())}));var n,t,i,o}var p=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function c(e){try{s(i.next(e))}catch(e){r(e)}}function a(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}))};const y=(0,i.J)("ocrlabs",((e,n)=>p(void 0,void 0,void 0,(function*(){const t=yield function(e){var n;return p(this,void 0,void 0,(function*(){const{frankieClient:t,session:i}=e,o=new r(t),c=l(i.sessionId);try{const e=yield o.retrieveAndDelete(c),t=null===(n=null==e?void 0:e.value)||void 0===n?void 0:n.workflow;if("IDV_ERROR"===t)return"fail";if("IDV_SUCCESS"===t)return"success";throw new Error("Invalid action")}catch(e){return"new"}}))}(e),{localEventHub:i,session:o}=e;i.on("results",(()=>o.unpersist())),i.on("processing",(()=>o.unpersist())),i.on("error",(()=>o.unpersist())),"success"===t?yield function(e){return s(this,void 0,void 0,(function*(){const{localEventHub:n,frankieClient:t}=e;n.emit("detection_complete");const i=new c.Bv(t),o=yield i.initProcess({isSynchronous:!0});try{const n=e.oneSdkInstance.individual();yield n.search()}catch(e){const t="Error updating individual state. Check error events from module 'individual' for more details.This isn't related to IDV capture.";n.emit("warning",{message:t,payload:e})}const r=t.entityId;(0,a.z)({eventHub:n,results:o,entityId:r})}))}(e):"fail"===t?yield function(e){return s(this,void 0,void 0,(function*(){const{localEventHub:n}=e;n.emit("detection_failed",{message:"User flow was unsuccessful"})}))}(e):yield h(e,n)}))))},50750:(e,n,t)=>{t.d(n,{z:()=>r});var i=t(96834),o=t(36932);function r(e){const{eventHub:n,results:t,entityId:r}=e;switch(t.checkStatus){case o.ck.COMPLETE:n.emit("results",{checkStatus:t.checkStatus,document:t.ocrDocument,entityId:r});break;case o.ck.FAILED:n.emit("results",{checkStatus:t.checkStatus,document:null,entityId:r});break;case o.ck.INTERRUPTED:case o.ck.INCOMPLETE:case o.ck.DOCUMENTS_INVALID:case o.ck.WAITING_DOC_UPLOAD:case o.ck.WAITING_SELFIE_UPLOAD:n.emit("input_required",{entityId:r},t.checkStatus);break;case o.ck.PROVIDER_OFFLINE:case o.ck.AWAITING_CONSENT:{const e=t.checkStatus===o.ck.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.ck.PROVIDER_OFFLINE}`:"Consent was not provided to the IDV Api. We can't continue.";n.emit("error",new i.OneSDKError(e,{errorStatus:t.checkStatus}))}break;case o.ck.CHECK_PROCESSING:n.emit("processing",{checkStatus:t.checkStatus,entityId:r});break;default:{const e=`Unexpected IDV status: ${t.checkStatus}`;n.emit("warning",{message:e,payload:t})}}}},85730:(e,n,t)=>{t.d(n,{E:()=>c,V:()=>r});var i=t(1306),o=t(96834);function r(e,n){const t=document.createElement("iframe"),r=function(e,n){const t=(0,o.mkEventHub)();return n.emitOnLoad&&(e.onload=()=>t.emit("loaded")),window.addEventListener("message",(i=>{i.source===e.contentWindow&&n.mapMessageToEvent(t,i,e)}),!1),(0,o.mkEventListener)(t)}(t,n.iframeMessagingOptions);return Object.assign(t.style,{border:0,margin:0,padding:0,width:"100%",height:"100%",fontSize:"100%",font:"inherit",verticalAlign:"baseline"}),t.allow="camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;",e.mode.is(i.Z.DUMMY)?t.srcdoc=function(e){const n=(e={})=>`window.parent.postMessage(${JSON.stringify(e)}, "*")`,t=e.loadedPayload?`setTimeout(() => ${n(e.loadedPayload)}, DUMMY_LOAD_DELAY)`:"",i=n(e.successPayload);return`<body style="background-color: white">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${t};\n function cancelClicked() {\n ${n(e.errorPayload)};\n }\n function completeClicked() {\n ${i};\n }\n <\/script>\n <h1>${e.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a "detection_complete" event</li>\n <li>Will trigger api calls, which will then emit the "results" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a "detection_failed" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id="actions-container">\n <button onclick="completeClicked()">Simulate Completion</button>\n <button onclick="cancelClicked()">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`}(n.dummyModeOptions):t.src=n.vendorParameters.tokenURL,{iframe:t,iframeListener:r}}function c(e){e.iframe.srcdoc="",e.internalEventHub.off(),e.iframe.remove()}},8707:(e,n,t)=>{t.d(n,{W:()=>r});var i=t(36932),o=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function c(e){try{s(i.next(e))}catch(e){r(e)}}function a(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}))};function r(e){return o(this,void 0,void 0,(function*(){const{localEventHub:n,frankieClient:t}=e;try{const o=new i.Bv(t),{vendorParameters:r,entityId:c}=yield o.getToken({relayState:e.relayState});return n.emit("session_data_generated",{session:Object.assign(Object.assign({},r),{entityId:c})}),{vendorParameters:r,idvClient:o,entityId:c}}catch(e){throw n.emit("session_data_failed_loading"),e}}))}}}]);
1
+ "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[933],{72900:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>y});var i=t(99434),o=t(64794);class r extends o.W{retrieveAndDelete(e){return n=this,t=void 0,o=function*(){const n=`/data/v1/key-value/${e}`;return this.frankie.get(n,{params:{delete:!0}}).then((e=>e.data))},new((i=void 0)||(i=Promise))((function(e,r){function a(e){try{s(o.next(e))}catch(e){r(e)}}function c(e){try{s(o.throw(e))}catch(e){r(e)}}function s(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,c)}s((o=o.apply(n,t||[])).next())}));var n,t,i,o}}var a=t(36932),c=t(50750),s=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function a(e){try{s(i.next(e))}catch(e){r(e)}}function c(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}s((i=i.apply(e,n||[])).next())}))};function l(e){return`sessionId:${e}:idv_action_details`}var d=t(71497),u=t(8707),f=t(34861),m=t(85730),v=t(77494);function h(...e){return n=this,t=void 0,o=function*(){const[n]=e,{mode:t,session:i,localEventHub:o}=n,r=n.recipe.idv.provider,a=null==r?void 0:r.redirect_uri;try{const{vendorParameters:o}=yield(0,u.W)({frankieClient:n.frankieClient,localEventHub:n.localEventHub,relayState:JSON.stringify({redirect_uri:null!=a?a:window.location.href,sessionId:i.sessionId})});t.is(d.j8.DUMMY)?function(...e){const[n,t]=e,{mountElement:i}=t,{session:o,localEventHub:r}=n,{iframe:a,iframeListener:c}=(0,m.V)(n,{dummyModeOptions:{title:"OCRLabs",errorPayload:{type:"error"},successPayload:{type:"success"},loadedPayload:{type:"loaded"}},iframeMessagingOptions:{emitOnLoad:!1,mapMessageToEvent:({message:e,targetEventHub:n})=>{const{data:t}=e,{type:i}=t;n.emit(i)}},vendorParameters:{tokenURL:"https://not-used.com"}}),s=new f.m,d=l(o.sessionId),u=n.recipe.idv.provider,v=null==u?void 0:u.redirect_uri,h=()=>{v?location.href=v:location.reload()};c.on("success",(()=>{s.store(d,{workflow:"IDV_SUCCESS"}),(0,m.E)({iframe:a,internalEventHub:c}),h()})),c.on("error",(()=>{s.store(d,{workflow:"IDV_ERROR"}),(0,m.E)({iframe:a,internalEventHub:c}),h()})),c.on("loaded",(()=>{r.emit("ready",{domElement:a})})),i.appendChild(a)}(...e):n.frankieClient.redirect(new URL(o.tokenURL))}catch(e){o.emit("error",new v.OneSDKError("Failed initialising a new idv flow",e))}},new((i=void 0)||(i=Promise))((function(e,r){function a(e){try{s(o.next(e))}catch(e){r(e)}}function c(e){try{s(o.throw(e))}catch(e){r(e)}}function s(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,c)}s((o=o.apply(n,t||[])).next())}));var n,t,i,o}var p=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function a(e){try{s(i.next(e))}catch(e){r(e)}}function c(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}s((i=i.apply(e,n||[])).next())}))};const y=(0,i.J)("ocrlabs",((e,n)=>p(void 0,void 0,void 0,(function*(){const t=yield function(e){var n;return p(this,void 0,void 0,(function*(){const{frankieClient:t,session:i}=e,o=new r(t),a=l(i.sessionId);try{const e=yield o.retrieveAndDelete(a),t=null===(n=null==e?void 0:e.value)||void 0===n?void 0:n.workflow;if("IDV_ERROR"===t)return"fail";if("IDV_SUCCESS"===t)return"success";throw new Error("Invalid action")}catch(e){return"new"}}))}(e),{localEventHub:i,session:o}=e;i.on("results",(()=>o.unpersist())),i.on("processing",(()=>o.unpersist())),i.on("error",(()=>o.unpersist())),"success"===t?yield function(e){return s(this,void 0,void 0,(function*(){const{localEventHub:n,frankieClient:t}=e;n.emit("detection_complete");const i=new a.Bv(t),o=yield i.initProcess({isSynchronous:!0});try{const n=e.oneSdkInstance.individual();yield n.search()}catch(e){const t="Error updating data for the individual. Check error events from module 'individual' for more details.This isn't related to IDV capture.";n.emit("warning",{message:t,payload:e})}const r=t.entityId;(0,c.z)({eventHub:n,results:o,entityId:r})}))}(e):"fail"===t?yield function(e){return s(this,void 0,void 0,(function*(){const{localEventHub:n}=e;n.emit("detection_failed",{message:"User flow was unsuccessful"})}))}(e):yield h(e,n)}))))},50750:(e,n,t)=>{t.d(n,{z:()=>r});var i=t(77494),o=t(36932);function r(e){const{eventHub:n,results:t,entityId:r}=e;switch(t.checkStatus){case o.ck.COMPLETE:n.emit("results",{checkStatus:t.checkStatus,document:t.ocrDocument,entityId:r});break;case o.ck.FAILED:n.emit("results",{checkStatus:t.checkStatus,document:null,entityId:r});break;case o.ck.INTERRUPTED:case o.ck.INCOMPLETE:case o.ck.DOCUMENTS_INVALID:case o.ck.WAITING_DOC_UPLOAD:case o.ck.WAITING_SELFIE_UPLOAD:n.emit("input_required",{entityId:r},t.checkStatus);break;case o.ck.PROVIDER_OFFLINE:case o.ck.AWAITING_CONSENT:{const e=t.checkStatus===o.ck.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.ck.PROVIDER_OFFLINE}`:"Consent was not provided to the IDV Api. We can't continue.";n.emit("error",new i.OneSDKError(e,{errorStatus:t.checkStatus}))}break;case o.ck.CHECK_PROCESSING:n.emit("processing",{checkStatus:t.checkStatus,entityId:r});break;default:{const e=`Unexpected IDV status: ${t.checkStatus}`;n.emit("warning",{message:e,payload:t})}}}},85730:(e,n,t)=>{t.d(n,{E:()=>a,V:()=>r});var i=t(1306),o=t(77494);function r(e,n){const t=document.createElement("iframe"),r=function(e,n){const t=(0,o.mkEventHub)();return n.emitOnLoad&&(e.onload=()=>t.emit("loaded")),window.addEventListener("message",(i=>{i.source===e.contentWindow&&n.mapMessageToEvent({targetEventHub:t,message:i,iframeElement:e,vendorParameters:n.vendorParameters})}),!1),(0,o.mkEventListener)(t)}(t,n.iframeMessagingOptions);return Object.assign(t.style,{border:0,margin:0,padding:0,width:"100%",height:"100%",fontSize:"100%",font:"inherit",verticalAlign:"baseline"}),t.allow="camera;fullscreen;accelerometer;gyroscope;magnetometer;geolocation;microphone;",e.mode.is(i.Z.DUMMY)?t.srcdoc=function(e){const n=(e={})=>`window.parent.postMessage(${JSON.stringify(e)}, "*")`,t=e.loadedPayload?`setTimeout(() => ${n(e.loadedPayload)}, DUMMY_LOAD_DELAY)`:"",i=n(e.successPayload);return`<body style="background-color: white">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n ${t};\n function cancelClicked() {\n ${n(e.errorPayload)};\n }\n function completeClicked() {\n ${i};\n }\n <\/script>\n <h1>${e.title}</h1>\n <p>This is a mocked replacement for the actual screen the IDV vendor will provide.</p>\n <p>\n By clicking the buttons below we will mimick the two possible outcomes for IDV vendor screens\n <ol>\n <li>\n A successful capture of the ID Document and Facial scan\n <ol>\n <li>Will emit a "detection_complete" event</li>\n <li>Will trigger api calls, which will then emit the "results" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n <li>\n An error or a use drop out\n <ol>\n <li>Will emit a "detection_failed" event</li>\n <li>Will unmount this iframe</li>\n </ol>\n </li>\n </ol>\n </p>\n <div id="actions-container">\n <button onclick="completeClicked()">Simulate Completion</button>\n <button onclick="cancelClicked()">Simulate Exit/Error</button>\n </div>\n <style>\n #actions-container {\n max-width: 400px;\n }\n button {\n display: block;\n width: 100%;\n height: 40px;\n margin: 10px 0;\n }\n </style>\n </body>`}(n.dummyModeOptions):t.src=n.vendorParameters.tokenURL,{iframe:t,iframeListener:r}}function a(e){e.iframe.srcdoc="",e.internalEventHub.off(),e.iframe.remove()}},8707:(e,n,t)=>{t.d(n,{W:()=>r});var i=t(36932),o=function(e,n,t,i){return new(t||(t=Promise))((function(o,r){function a(e){try{s(i.next(e))}catch(e){r(e)}}function c(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}s((i=i.apply(e,n||[])).next())}))};function r(e){return o(this,void 0,void 0,(function*(){const{localEventHub:n,frankieClient:t}=e;try{const o=new i.Bv(t),{vendorParameters:r,entityId:a}=yield o.getToken({relayState:e.relayState});return n.emit("session_data_generated",{session:Object.assign(Object.assign({},r),{entityId:a})}),{vendorParameters:r,idvClient:o,entityId:a}}catch(e){throw n.emit("session_data_failed_loading"),e}}))}}}]);
2
2
  //# sourceMappingURL=idv-ocrlabs.js.map