@frankieone/one-sdk 1.7.2 → 1.7.3-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/dist/commit.txt +1 -1
  2. package/dist/esm/modules/biometrics/definition.d.ts +3 -3
  3. package/dist/esm/modules/biometrics/events.d.ts +2 -2
  4. package/dist/esm/modules/biometrics/index.d.ts +1 -1
  5. package/dist/esm/modules/biometrics/index.d.ts.map +1 -1
  6. package/dist/esm/modules/biometrics/index.js +12 -6
  7. package/dist/esm/modules/biometrics/index.js.map +1 -1
  8. package/dist/esm/modules/biometrics/parseConfiguration.d.ts +1 -1
  9. package/dist/esm/modules/biometrics/vendors/Incode/index.d.ts +3 -3
  10. package/dist/esm/modules/biometrics/vendors/OcrLabs/index.d.ts +2 -2
  11. package/dist/esm/modules/biometrics/vendors/Onfido/index.d.ts +5 -5
  12. package/dist/esm/modules/biometrics/vendors/common/createSession.d.ts +4 -4
  13. package/dist/esm/modules/biometrics/vendors/common/errors.d.ts +3 -3
  14. package/dist/esm/modules/biometrics/vendors/common/initProcess.d.ts +4 -4
  15. package/dist/esm/modules/biometrics/vendors/dummy-biometrics/index.d.ts +2 -2
  16. package/dist/esm/modules/business/actions/emitEvents.d.ts +2 -2
  17. package/dist/esm/modules/business/actions/search.d.ts +3 -3
  18. package/dist/esm/modules/business/actions/upload.d.ts +4 -4
  19. package/dist/esm/modules/business/definition.d.ts +4 -4
  20. package/dist/esm/modules/business/events.d.ts +1 -1
  21. package/dist/esm/modules/common/modules/HOF.d.ts +1 -1
  22. package/dist/esm/modules/common/modules/ReactiveStore.d.ts +1 -1
  23. package/dist/esm/modules/common/modules/defineModule.d.ts +1 -1
  24. package/dist/esm/modules/common/modules/error.d.ts +1 -1
  25. package/dist/esm/modules/common/modules/eventHub/index.d.ts.map +1 -1
  26. package/dist/esm/modules/common/modules/eventHub/index.js +14 -6
  27. package/dist/esm/modules/common/modules/eventHub/index.js.map +1 -1
  28. package/dist/esm/modules/common/modules/eventHub/types.d.ts +2 -2
  29. package/dist/esm/modules/common/modules/eventHub/windowEventHub.d.ts +1 -1
  30. package/dist/esm/modules/common/modules/eventHub/windowEventHub.d.ts.map +1 -1
  31. package/dist/esm/modules/common/modules/eventHub/windowEventHub.js +4 -2
  32. package/dist/esm/modules/common/modules/eventHub/windowEventHub.js.map +1 -1
  33. package/dist/esm/modules/common/modules/objectUtils.d.ts +1 -1
  34. package/dist/esm/modules/common/modules/vendorLoading.d.ts +4 -4
  35. package/dist/esm/modules/common/shared/models/DeviceCheck.d.ts +1 -1
  36. package/dist/esm/modules/common/shared/models/UBOData.d.ts +3 -3
  37. package/dist/esm/modules/common/types/Accessors.d.ts +1 -1
  38. package/dist/esm/modules/common/types/oneSDKModules/baseParameters.types.d.ts +6 -6
  39. package/dist/esm/modules/common/types/oneSDKModules/contextObject.d.ts +1 -1
  40. package/dist/esm/modules/common/types/oneSDKModules/definition.types.d.ts +2 -2
  41. package/dist/esm/modules/common/types/oneSDKModules/initialiseFunction.d.ts +2 -2
  42. package/dist/esm/modules/common/types/oneSDKModules/typeSystem.types.d.ts +1 -1
  43. package/dist/esm/modules/common/types/oneSDKVendorWrappers/initialiseFunction.d.ts +1 -1
  44. package/dist/esm/modules/common/types/recipeConfiguration.types.d.ts +5 -5
  45. package/dist/esm/modules/common/vendors/form/promisifyForm.d.ts +2 -2
  46. package/dist/esm/modules/common/vendors/form/useForm.d.ts +4 -4
  47. package/dist/esm/modules/common/vendors/incode/createEventHandlers.d.ts +4 -4
  48. package/dist/esm/modules/common/vendors/incode/index.d.ts +1 -1
  49. package/dist/esm/modules/common/vendors/incode/startCamera.d.ts +3 -3
  50. package/dist/esm/modules/common/vendors/onfido/index.d.ts +3 -3
  51. package/dist/esm/modules/common/vendors/onfido/onfido.types.d.ts +1 -1
  52. package/dist/esm/modules/config/modules.d.ts +18 -18
  53. package/dist/esm/modules/device/definition.d.ts +2 -2
  54. package/dist/esm/modules/device/events.d.ts +1 -1
  55. package/dist/esm/modules/device/index.d.ts +4 -4
  56. package/dist/esm/modules/device/index.d.ts.map +1 -1
  57. package/dist/esm/modules/device/index.js +19 -16
  58. package/dist/esm/modules/device/index.js.map +1 -1
  59. package/dist/esm/modules/device/parseConfiguration.d.ts +1 -1
  60. package/dist/esm/modules/device/vendors/Sardine.d.ts +6 -6
  61. package/dist/esm/modules/device/vendors/Threatmetrix/index.d.ts +4 -4
  62. package/dist/esm/modules/exports.d.ts +1 -1
  63. package/dist/esm/modules/features.config.d.ts +1 -1
  64. package/dist/esm/modules/federation/definition.d.ts +2 -2
  65. package/dist/esm/modules/federation/index.d.ts +2 -2
  66. package/dist/esm/modules/federation/index.d.ts.map +1 -1
  67. package/dist/esm/modules/federation/index.js +15 -14
  68. package/dist/esm/modules/federation/index.js.map +1 -1
  69. package/dist/esm/modules/federation/parseConfiguration.d.ts +1 -1
  70. package/dist/esm/modules/federation/vendors/Singpass.d.ts +5 -5
  71. package/dist/esm/modules/form/definition.d.ts +7 -7
  72. package/dist/esm/modules/form/events.d.ts +3 -3
  73. package/dist/esm/modules/form/index.d.ts.map +1 -1
  74. package/dist/esm/modules/form/index.js +5 -3
  75. package/dist/esm/modules/form/index.js.map +1 -1
  76. package/dist/esm/modules/form/validateConfiguration.d.ts +1 -1
  77. package/dist/esm/modules/form/vendors/formio/formioSdk.d.ts +1 -1
  78. package/dist/esm/modules/form/vendors/formio/index.d.ts +3 -3
  79. package/dist/esm/modules/form/vendors/formio/transformers/assignFormioDataToIndividualModule.d.ts +1 -1
  80. package/dist/esm/modules/form/vendors/formio/transformers/assignIndividualDataToFormioSdk.d.ts +1 -1
  81. package/dist/esm/modules/form/vendors/legacy/index.d.ts +5 -5
  82. package/dist/esm/modules/form/vendors/legacy/legacyUIEvents.types.d.ts +5 -5
  83. package/dist/esm/modules/form/vendors/legacy/loadLegacyUI.d.ts +3 -3
  84. package/dist/esm/modules/form/vendors/react/App.d.ts +2 -2
  85. package/dist/esm/modules/form/vendors/react/appConfig.type.d.ts +2 -2
  86. package/dist/esm/modules/form/vendors/react/components/base/SharedInput/Input.d.ts +1 -1
  87. package/dist/esm/modules/form/vendors/react/components/view/ActionFormField/ActionFormField.js +2 -2
  88. package/dist/esm/modules/form/vendors/react/components/view/ActionFormField/ActionFormField.js.map +1 -1
  89. package/dist/esm/modules/form/vendors/react/components/view/FrankieAddress/FrankieAddress.js +2 -2
  90. package/dist/esm/modules/form/vendors/react/components/view/FrankieAddress/FrankieAddress.js.map +1 -1
  91. package/dist/esm/modules/form/vendors/react/components/view/FrankieFormMapper/FrankieFormMapper.d.ts +1 -1
  92. package/dist/esm/modules/form/vendors/react/constants/form.const.d.ts +1 -0
  93. package/dist/esm/modules/form/vendors/react/constants/form.const.d.ts.map +1 -1
  94. package/dist/esm/modules/form/vendors/react/constants/form.const.js +1 -0
  95. package/dist/esm/modules/form/vendors/react/constants/form.const.js.map +1 -1
  96. package/dist/esm/modules/form/vendors/react/constants/icons.d.ts +62 -62
  97. package/dist/esm/modules/form/vendors/react/constants/icons.d.ts.map +1 -1
  98. package/dist/esm/modules/form/vendors/react/constants/icons.js +74 -62
  99. package/dist/esm/modules/form/vendors/react/constants/icons.js.map +1 -1
  100. package/dist/esm/modules/form/vendors/react/constants/layoutMapper.const.d.ts +7 -7
  101. package/dist/esm/modules/form/vendors/react/constants/staticScreenMapper.const.d.ts +3 -3
  102. package/dist/esm/modules/form/vendors/react/features/Consent/Consent.d.ts.map +1 -1
  103. package/dist/esm/modules/form/vendors/react/features/Consent/Consent.js +31 -14
  104. package/dist/esm/modules/form/vendors/react/features/Consent/Consent.js.map +1 -1
  105. package/dist/esm/modules/form/vendors/react/features/Consent/hostedBusinessConsent.config.d.ts +1 -1
  106. package/dist/esm/modules/form/vendors/react/features/DocUpload/FileUploader/Main.d.ts +1 -1
  107. package/dist/esm/modules/form/vendors/react/features/DocUpload/FileUploader/Progress.d.ts +1 -1
  108. package/dist/esm/modules/form/vendors/react/features/DocUpload/FileUploader/Review.d.ts +1 -1
  109. package/dist/esm/modules/form/vendors/react/features/DocUpload/FileUploader/index.d.ts +1 -1
  110. package/dist/esm/modules/form/vendors/react/features/IdPreps/driversLicense.config.d.ts +1 -1
  111. package/dist/esm/modules/form/vendors/react/features/IdPreps/mediCare.config.d.ts +1 -1
  112. package/dist/esm/modules/form/vendors/react/features/IdPreps/passport.config.d.ts +1 -1
  113. package/dist/esm/modules/form/vendors/react/features/IdSelection/idSelection.config.d.ts +6 -6
  114. package/dist/esm/modules/form/vendors/react/features/IdSelection/idSelection.const.d.ts +4 -4
  115. package/dist/esm/modules/form/vendors/react/features/IdSelection/manualIdSelection.config.d.ts +47 -47
  116. package/dist/esm/modules/form/vendors/react/features/PersonalDetails/PersonalDetails.js +1 -1
  117. package/dist/esm/modules/form/vendors/react/features/PersonalDetails/PersonalDetails.js.map +1 -1
  118. package/dist/esm/modules/form/vendors/react/features/PersonalDetails/personalDetails.config.d.ts +392 -392
  119. package/dist/esm/modules/form/vendors/react/features/Review/Review.d.ts.map +1 -1
  120. package/dist/esm/modules/form/vendors/react/features/Review/Review.js +5 -0
  121. package/dist/esm/modules/form/vendors/react/features/Review/Review.js.map +1 -1
  122. package/dist/esm/modules/form/vendors/react/features/Review/review.config.d.ts.map +1 -1
  123. package/dist/esm/modules/form/vendors/react/features/Review/review.config.js +0 -1
  124. package/dist/esm/modules/form/vendors/react/features/Review/review.config.js.map +1 -1
  125. package/dist/esm/modules/form/vendors/react/features/ReviewDocument/ReviewDocument.d.ts.map +1 -1
  126. package/dist/esm/modules/form/vendors/react/features/ReviewDocument/ReviewDocument.js +3 -2
  127. package/dist/esm/modules/form/vendors/react/features/ReviewDocument/ReviewDocument.js.map +1 -1
  128. package/dist/esm/modules/form/vendors/react/features/Welcome/hostedBusinessWelcome.config.d.ts +1 -1
  129. package/dist/esm/modules/form/vendors/react/features/Welcome/manualWelcome.config.d.ts +4 -4
  130. package/dist/esm/modules/form/vendors/react/features/Welcome/welcome.config.d.ts +1 -1
  131. package/dist/esm/modules/form/vendors/react/hooks/useConfigFactory.hooks.js +1 -1
  132. package/dist/esm/modules/form/vendors/react/hooks/useConfigFactory.hooks.js.map +1 -1
  133. package/dist/esm/modules/form/vendors/react/hooks/useConsents.hook.d.ts +6 -0
  134. package/dist/esm/modules/form/vendors/react/hooks/useConsents.hook.d.ts.map +1 -0
  135. package/dist/esm/modules/form/vendors/react/hooks/useConsents.hook.js +44 -0
  136. package/dist/esm/modules/form/vendors/react/hooks/useConsents.hook.js.map +1 -0
  137. package/dist/esm/modules/form/vendors/react/hooks/useEventContext.d.ts +3 -3
  138. package/dist/esm/modules/form/vendors/react/hooks/useFormMapper.hook.d.ts +526 -526
  139. package/dist/esm/modules/form/vendors/react/hooks/useManualConfigFactory.hook.js +1 -1
  140. package/dist/esm/modules/form/vendors/react/hooks/useManualConfigFactory.hook.js.map +1 -1
  141. package/dist/esm/modules/form/vendors/react/hooks/useManualWrapperFactory.hook.d.ts +829 -1
  142. package/dist/esm/modules/form/vendors/react/hooks/useManualWrapperFactory.hook.d.ts.map +1 -1
  143. package/dist/esm/modules/form/vendors/react/hooks/useManualWrapperFactory.hook.js +11 -2
  144. package/dist/esm/modules/form/vendors/react/hooks/useManualWrapperFactory.hook.js.map +1 -1
  145. package/dist/esm/modules/form/vendors/react/hooks/usePersonalDetailsUpdateFactory.hook.d.ts +1 -1
  146. package/dist/esm/modules/form/vendors/react/hooks/usePersonalDetailsUpdateFactory.hook.js +1 -1
  147. package/dist/esm/modules/form/vendors/react/hooks/usePersonalDetailsUpdateFactory.hook.js.map +1 -1
  148. package/dist/esm/modules/form/vendors/react/hooks/useReviewUpdateFactory.hook.d.ts +6 -6
  149. package/dist/esm/modules/form/vendors/react/index.d.ts +4 -4
  150. package/dist/esm/modules/form/vendors/react/model/address.model.d.ts +2 -2
  151. package/dist/esm/modules/form/vendors/react/model/googleAddress.model.d.ts +1 -1
  152. package/dist/esm/modules/form/vendors/react/model/idDetails.model.d.ts +1 -1
  153. package/dist/esm/modules/form/vendors/react/model/personalDetails.model.d.ts +1 -1
  154. package/dist/esm/modules/form/vendors/react/model/review.model.d.ts +2 -2
  155. package/dist/esm/modules/form/vendors/react/types/pages.type.d.ts +1 -1
  156. package/dist/esm/modules/form/vendors/react/utils/layout.util.d.ts +1 -1
  157. package/dist/esm/modules/form/vendors/react/utils/object.util.d.ts +2 -2
  158. package/dist/esm/modules/form/vendors/react/utils/object.util.js +1 -1
  159. package/dist/esm/modules/form/vendors/react/utils/object.util.js.map +1 -1
  160. package/dist/esm/modules/frankie-client/ClientsDictionary.d.ts +1 -1
  161. package/dist/esm/modules/frankie-client/DummyFrankieApiClient.d.ts +1 -1
  162. package/dist/esm/modules/frankie-client/FrankieApiClient.d.ts +2 -2
  163. package/dist/esm/modules/frankie-client/clients/ApplicantClient.d.ts +4 -4
  164. package/dist/esm/modules/frankie-client/clients/BusinessClient.d.ts +1 -1
  165. package/dist/esm/modules/frankie-client/clients/FederationClient.d.ts +1 -1
  166. package/dist/esm/modules/frankie-client/clients/IDVClient.d.ts +2 -2
  167. package/dist/esm/modules/frankie-client/clients/OCRClient.d.ts +1 -1
  168. package/dist/esm/modules/frankie-client/clients/SupportingDocumentsClient.d.ts +3 -3
  169. package/dist/esm/modules/frankie-client/clients/TelemetryEventsClient.d.ts +1 -1
  170. package/dist/esm/modules/frankie-client/index.d.ts +1 -1
  171. package/dist/esm/modules/frankie-client/mocks/federation/index.d.ts +1 -1
  172. package/dist/esm/modules/frankie-client/mocks/idvAndBiometrics/idvSubmission.d.ts +4 -4
  173. package/dist/esm/modules/frankie-client/mocks/individual/loadIndividual.d.ts +1 -1
  174. package/dist/esm/modules/frankie-client/mocks/individual/resolveDocumentData.d.ts +2 -2
  175. package/dist/esm/modules/frankie-client/mocks/individual/resolveIndividualData.d.ts +3 -3
  176. package/dist/esm/modules/frankie-client/mocks/ocr/ocrSubmission.d.ts +1 -1
  177. package/dist/esm/modules/frankie-client/mocks/options/simplified/idvFlow.d.ts +4 -4
  178. package/dist/esm/modules/frankie-client/mocks/options/simplified/ocrFlow.d.ts +4 -4
  179. package/dist/esm/modules/frankie-client/mocks/options/simplified/preloadedIndividual.d.ts +5 -5
  180. package/dist/esm/modules/frankie-client/mocks/storage/mockStorage.d.ts +1 -1
  181. package/dist/esm/modules/idv/actions/mount.d.ts +3 -3
  182. package/dist/esm/modules/idv/definition.types.d.ts +8 -8
  183. package/dist/esm/modules/idv/events.types.d.ts +5 -5
  184. package/dist/esm/modules/idv/index.d.ts.map +1 -1
  185. package/dist/esm/modules/idv/index.js +9 -5
  186. package/dist/esm/modules/idv/index.js.map +1 -1
  187. package/dist/esm/modules/idv/parseConfiguration.d.ts +1 -1
  188. package/dist/esm/modules/idv/vendors/Incode/index.d.ts +5 -5
  189. package/dist/esm/modules/idv/vendors/Mastercard/index.d.ts +2 -2
  190. package/dist/esm/modules/idv/vendors/OcrLabs/endFlow.d.ts +4 -4
  191. package/dist/esm/modules/idv/vendors/OcrLabs/index.d.ts +3 -3
  192. package/dist/esm/modules/idv/vendors/OcrLabs/startDummyFlow.d.ts +2 -2
  193. package/dist/esm/modules/idv/vendors/OcrLabs/startFlow.d.ts +2 -2
  194. package/dist/esm/modules/idv/vendors/Onfido/index.d.ts +4 -4
  195. package/dist/esm/modules/idv/vendors/common/checkStatusEventMapping.d.ts +3 -3
  196. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.d.ts +2 -2
  197. package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframeEventListener.d.ts +1 -1
  198. package/dist/esm/modules/idv/vendors/common/iframeUtils/defineIframeIDVWrapper.d.ts +7 -7
  199. package/dist/esm/modules/idv/vendors/common/iframeUtils/updateIndividualModuleState.d.ts +3 -3
  200. package/dist/esm/modules/idv/vendors/common/initialiseSession.d.ts +4 -4
  201. package/dist/esm/modules/idv/vendors/common/windowUtils/createWindow.d.ts +1 -1
  202. package/dist/esm/modules/index.d.ts +4 -4
  203. package/dist/esm/modules/individual/actions/addReference.d.ts +3 -3
  204. package/dist/esm/modules/individual/actions/addresses.d.ts +2 -2
  205. package/dist/esm/modules/individual/actions/consents.d.ts +1 -1
  206. package/dist/esm/modules/individual/actions/documents.d.ts +2 -2
  207. package/dist/esm/modules/individual/actions/email.d.ts +2 -2
  208. package/dist/esm/modules/individual/actions/emitEvents.d.ts +3 -3
  209. package/dist/esm/modules/individual/actions/phoneNumber.d.ts +2 -2
  210. package/dist/esm/modules/individual/actions/profileType.d.ts +2 -2
  211. package/dist/esm/modules/individual/actions/search.d.ts +3 -3
  212. package/dist/esm/modules/individual/actions/submit.d.ts +5 -5
  213. package/dist/esm/modules/individual/definition.d.ts +8 -8
  214. package/dist/esm/modules/individual/events.d.ts +1 -1
  215. package/dist/esm/modules/meta.json +1 -1
  216. package/dist/esm/modules/ocr/actions/mount.d.ts +4 -4
  217. package/dist/esm/modules/ocr/actions/start.d.ts +7 -7
  218. package/dist/esm/modules/ocr/definition.d.ts +5 -5
  219. package/dist/esm/modules/ocr/events.d.ts +2 -2
  220. package/dist/esm/modules/ocr/index.d.ts +11 -11
  221. package/dist/esm/modules/ocr/index.d.ts.map +1 -1
  222. package/dist/esm/modules/ocr/index.js +6 -3
  223. package/dist/esm/modules/ocr/index.js.map +1 -1
  224. package/dist/esm/modules/ocr/vendors/Incode/index.d.ts +3 -3
  225. package/dist/esm/modules/ocr/vendors/Onfido/index.d.ts +2 -2
  226. package/dist/esm/modules/ocr/vendors/common/createSession.d.ts +4 -4
  227. package/dist/esm/modules/ocr/vendors/common/initProcess.d.ts +2 -2
  228. package/dist/esm/modules/ocr/vendors/common/mutationObserver.d.ts +2 -2
  229. package/dist/esm/modules/ocr/vendors/common/statusEvaluators.d.ts +5 -5
  230. package/dist/esm/modules/ocr/vendors/dummy-ocr/index.d.ts +3 -3
  231. package/dist/esm/modules/sdk/initialisation/componentLoader.d.ts +2 -2
  232. package/dist/esm/modules/sdk/initialisation/configurationParser.d.ts +1 -1
  233. package/dist/esm/modules/sdk/initialisation/sharedDependencies.d.ts +4 -4
  234. package/dist/esm/modules/sdk/initialisation/sharedDependencies.d.ts.map +1 -1
  235. package/dist/esm/modules/sdk/initialisation/sharedDependencies.js +20 -8
  236. package/dist/esm/modules/sdk/initialisation/sharedDependencies.js.map +1 -1
  237. package/dist/esm/modules/sdk/types/globalEvents.d.ts +2 -2
  238. package/dist/esm/modules/sdk/types/oneSDK.d.ts +5 -5
  239. package/dist/esm/modules/sdk/types/oneSDKParameters.d.ts +2 -2
  240. package/dist/esm/modules/session/SessionContext.d.ts +1 -1
  241. package/dist/esm/modules/session/definition.d.ts +3 -3
  242. package/dist/esm/modules/session/index.d.ts +5 -5
  243. package/dist/esm/modules/session/index.d.ts.map +1 -1
  244. package/dist/esm/modules/session/index.js +24 -16
  245. package/dist/esm/modules/session/index.js.map +1 -1
  246. package/dist/esm/modules/session/types/module.d.ts +1 -1
  247. package/dist/esm/modules/types.d.ts +13 -13
  248. package/dist/esm/modules/workflow/definition.types.d.ts +1 -1
  249. package/dist/esm/modules/workflow/index.d.ts +1 -1
  250. package/dist/version.txt +0 -1
  251. package/package.json +8 -5
  252. package/dist/esm/node_modules/@reduxjs/toolkit/dist/uncheckedindexed.d.ts +0 -6
  253. package/dist/esm/node_modules/@reduxjs/toolkit/dist/uncheckedindexed.d.ts.map +0 -1
  254. package/dist/umd/080b774e0f4f9c679e85.svg +0 -45
  255. package/dist/umd/0c9574c81d7d87e9ccd3.svg +0 -34
  256. package/dist/umd/0cd8e74f8a68e0b1ae14.svg +0 -3
  257. package/dist/umd/10183d99573bcd186235.svg +0 -5
  258. package/dist/umd/124.js +0 -2
  259. package/dist/umd/124.js.map +0 -1
  260. package/dist/umd/1c9c1ef03c6dd661b89b.woff +0 -0
  261. package/dist/umd/1df3f35eac93c61986b1.svg +0 -60
  262. package/dist/umd/1f76ff5e84787152adc5.svg +0 -50
  263. package/dist/umd/2451ce2859277292a2a3.svg +0 -4
  264. package/dist/umd/24c67c1821feba22f3f7.svg +0 -5
  265. package/dist/umd/2546128ef2e2d56276b7.svg +0 -5
  266. package/dist/umd/26a8e1ce5e5578874420.woff2 +0 -0
  267. package/dist/umd/2f32844e02839dd608a4.svg +0 -4
  268. package/dist/umd/329d07fd3f40d3967c81.svg +0 -4
  269. package/dist/umd/32cb4eea6ca1acb9f788.svg +0 -45
  270. package/dist/umd/3443b53b9b1a00c340f7.svg +0 -27
  271. package/dist/umd/34fe2370aa5e73787795.svg +0 -30
  272. package/dist/umd/36ddfb506829cb8cde72.svg +0 -113
  273. package/dist/umd/396cc7cc5e61acfa8fc8.svg +0 -15
  274. package/dist/umd/3a660ff8435efa515e98.svg +0 -4
  275. package/dist/umd/3b687e48c6bb765ed976.svg +0 -5
  276. package/dist/umd/3d245ccf2dde73ceca07.svg +0 -114
  277. package/dist/umd/42caa2dd6b4f0de68157.svg +0 -51
  278. package/dist/umd/463e54e898297e314139.svg +0 -81
  279. package/dist/umd/4ac349963383ebda508b.svg +0 -50
  280. package/dist/umd/4db0db393dfe2f9f90c1.svg +0 -60
  281. package/dist/umd/4ee01199f6f6b7e6fb24.svg +0 -195
  282. package/dist/umd/4ff338b86cdba19934cf.svg +0 -86
  283. package/dist/umd/58b74e594849c43b2248.woff2 +0 -0
  284. package/dist/umd/5c23763467ce9cfda119.svg +0 -41
  285. package/dist/umd/5ddf80d7ddb1d1c5a0bc.woff +0 -0
  286. package/dist/umd/6375eb14534238c06a4b.svg +0 -27
  287. package/dist/umd/6558f8e71743e073c18b.svg +0 -3
  288. package/dist/umd/67cbc8178ea76ef0d8b4.svg +0 -4
  289. package/dist/umd/6c874e1a72a4fa9eeed8.woff2 +0 -0
  290. package/dist/umd/71b71503b4f733079331.svg +0 -3
  291. package/dist/umd/7f6d57b96337c21c053d.woff +0 -0
  292. package/dist/umd/8053f51266aa9d864691.svg +0 -4
  293. package/dist/umd/80929602ea97f94dc18c.svg +0 -65
  294. package/dist/umd/8a06059b84b1aa2bf661.svg +0 -29
  295. package/dist/umd/8f10666ff21ef0238370.svg +0 -13
  296. package/dist/umd/949.js +0 -3
  297. package/dist/umd/949.js.LICENSE.txt +0 -60
  298. package/dist/umd/949.js.map +0 -1
  299. package/dist/umd/9d49ce231cb895b6ef29.svg +0 -50
  300. package/dist/umd/9dee3446081d7d47623b.svg +0 -4
  301. package/dist/umd/a96ec21d243a49916487.svg +0 -47
  302. package/dist/umd/ac457c4800183645b1ad.svg +0 -45
  303. package/dist/umd/af823d3a76ce1e2e36af.woff +0 -0
  304. package/dist/umd/aff615d38d2fce3f82b2.svg +0 -83
  305. package/dist/umd/bc42b55176ae1021b9e4.svg +0 -80
  306. package/dist/umd/biometrics-dummy.js +0 -2
  307. package/dist/umd/biometrics-dummy.js.map +0 -1
  308. package/dist/umd/biometrics-incode.js +0 -2
  309. package/dist/umd/biometrics-incode.js.map +0 -1
  310. package/dist/umd/biometrics-ocrlabs.js +0 -2
  311. package/dist/umd/biometrics-ocrlabs.js.map +0 -1
  312. package/dist/umd/biometrics-onfido.js +0 -2
  313. package/dist/umd/biometrics-onfido.js.map +0 -1
  314. package/dist/umd/c0dede047f9a2b7c1309.svg +0 -51
  315. package/dist/umd/c16900512bb2f899c7eb.svg +0 -5
  316. package/dist/umd/c7a05c7d7d1f9347ae1b.svg +0 -53
  317. package/dist/umd/ce5b46abe62641bddb20.svg +0 -5
  318. package/dist/umd/d15d58eb544d245877e2.svg +0 -16
  319. package/dist/umd/d216030199c873b0bf41.woff2 +0 -0
  320. package/dist/umd/d563d85c23bcbd268d5e.svg +0 -30
  321. package/dist/umd/d70a547a409868c43a95.svg +0 -43
  322. package/dist/umd/d9ed930ae3bb52f2abe1.svg +0 -4
  323. package/dist/umd/dc45d5d9fb4b8959e156.svg +0 -24
  324. package/dist/umd/dd199fa4125e4ebef289.svg +0 -67
  325. package/dist/umd/dddc2581e578cfb3b997.svg +0 -195
  326. package/dist/umd/device-sardine.js +0 -2
  327. package/dist/umd/device-sardine.js.map +0 -1
  328. package/dist/umd/device-threatmetrix.js +0 -2
  329. package/dist/umd/device-threatmetrix.js.map +0 -1
  330. package/dist/umd/df83da88c151bcf97231.svg +0 -45
  331. package/dist/umd/e7ac03e5736bea4d6346.svg +0 -53
  332. package/dist/umd/e84075ff43e508e4fbd5.svg +0 -5
  333. package/dist/umd/e85b9f93aac09995bad2.svg +0 -80
  334. package/dist/umd/ef3c33f0d919896ee0bf.svg +0 -25
  335. package/dist/umd/f22fe25046b4ca4a969a.svg +0 -65
  336. package/dist/umd/f4a5163b8f91c2c66892.svg +0 -4
  337. package/dist/umd/f670207e1feb7ec4f6d4.svg +0 -5
  338. package/dist/umd/f75020be237d9de68d86.svg +0 -192
  339. package/dist/umd/fc7c8869af28cb1b9c21.svg +0 -5
  340. package/dist/umd/fdb0a109281e6c12eff6.svg +0 -75
  341. package/dist/umd/form-formio.js +0 -2
  342. package/dist/umd/form-formio.js.map +0 -1
  343. package/dist/umd/form-legacy.js +0 -2
  344. package/dist/umd/form-legacy.js.map +0 -1
  345. package/dist/umd/form-react.js +0 -2
  346. package/dist/umd/form-react.js.map +0 -1
  347. package/dist/umd/idv-incode.js +0 -2
  348. package/dist/umd/idv-incode.js.map +0 -1
  349. package/dist/umd/idv-mastercard.js +0 -2
  350. package/dist/umd/idv-mastercard.js.map +0 -1
  351. package/dist/umd/idv-ocrlabs.js +0 -2
  352. package/dist/umd/idv-ocrlabs.js.map +0 -1
  353. package/dist/umd/idv-onfido.js +0 -2
  354. package/dist/umd/idv-onfido.js.map +0 -1
  355. package/dist/umd/ocr-dummy.js +0 -2
  356. package/dist/umd/ocr-dummy.js.map +0 -1
  357. package/dist/umd/ocr-incode.js +0 -2
  358. package/dist/umd/ocr-incode.js.map +0 -1
  359. package/dist/umd/ocr-onfido.js +0 -2
  360. package/dist/umd/ocr-onfido.js.map +0 -1
  361. package/dist/umd/oneSdk.umd.js +0 -3
  362. package/dist/umd/oneSdk.umd.js.LICENSE.txt +0 -8
  363. package/dist/umd/oneSdk.umd.js.map +0 -1
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[689],{5251:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>o});var i=n(4334);const o=(0,n(2103).s)({vendor:"incode",dummyOptions:{title:"Incode IDV Dummy iframe",loadedPayload:"loaded",successPayload:{workflow:"INCODE_COMPLETE"},errorPayload:{workflow:"INCODE_ERROR"}},eventOptions:{emitOnLoad:!0,mapMessageToEvent({targetEventHub:e,message:t,vendorParameters:n}){const o=t.data,{workflow:r}=o;if("INCODE_COMPLETE"===r){const t=n.interviewId;e.emit("success",{vendorParameters:{checkId:t}})}else"INCODE_ERROR"===r&&e.emit("error",new i.OneSDKError(r,{message:"Dummy error from Incode"}))}}})},1144:(e,t,n)=>{n.d(t,{N:()=>r});var i=n(4334),o=n(9188);function r(e){const{eventHub:t,results:n,entityId:r}=e;switch(n.checkStatus){case o.Yt.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:r});break;case o.Yt.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:r});break;case o.Yt.INTERRUPTED:case o.Yt.INCOMPLETE:case o.Yt.DOCUMENTS_INVALID:case o.Yt.WAITING_DOC_UPLOAD:case o.Yt.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:r},n.checkStatus);break;case o.Yt.PROVIDER_OFFLINE:case o.Yt.AWAITING_CONSENT:{const e=n.checkStatus===o.Yt.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.Yt.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.Yt.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})}}}},5353:(e,t,n)=>{n.d(t,{t:()=>a,h:()=>r});var i=n(1031),o=n(4334);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,{position:"absolute",top:0,left:0,right:0,bottom:0,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.t.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()}},2103:(e,t,n)=>{n.d(t,{s:()=>u});var i=n(591),o=n(4334),r=n(5473),a=n(486),s=n(846),c=n(1144),d=n(9221),l=n(5353),m=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 u=e=>{const{dummyOptions:t,eventOptions:n,vendor:u}=e,v=(0,i.T)("modules.idv.containsReviewScreen")[u];return(0,r.f)(u,((e,r)=>m(void 0,void 0,void 0,(function*(){var f;const{localEventHub:p,recipe:g}=e,{mountElement:h}=r;p.emit("loading",!0,{message:`Loading IDV vendor '${u}'`});const E=null!==(f=g.idv.provideReviewScreen)&&void 0!==f?f:(0,i.T)("recipeDefaults.idv.provideReviewScreen"),y=!v&&E,I=(0,a.y)(),{vendorParameters:w,idvClient:O,entityId:k}=yield(0,d.N)(e),{iframe:D,iframeListener:b}=(0,l.h)(e,{vendorParameters:w,dummyModeOptions:t,iframeMessagingOptions:Object.assign(Object.assign({},n),{vendorParameters:w})});b.on("success",(e=>m(void 0,[e],void 0,(function*({vendorParameters:e}){y?p.emit("info",{message:"Data extraction completed. Now executing user review using form."}):p.emit("detection_complete"),p.emit("loading",!0,{message:"Retrieving IDV results"});try{const t=yield O.initProcess({isSynchronous:!0,vendorParameters:e});(0,c.N)({eventHub:I,results:t,entityId:k}),(0,l.t)({internalEventHub:b,iframe:D})}catch(e){p.emit("error",new o.OneSDKError("Failed initiating IDV processing",e)),p.emit("loading",!1,{message:"Failed retrieving IDV results"})}})))),b.on("error",(e=>{(0,l.t)({internalEventHub:b,iframe:D}),p.emit("detection_failed",{message:`Error from ${u}: ${e.message}`,payload:e.payload}),p.emit("loading",!1,{message:`Vendor '${u}' detection has failed`})})),b.on("loaded",(()=>{p.emit("ready",{domElement:D}),p.emit("loading",!1,{message:`Vendor '${u}' screen has loaded`})})),I.on("results",(0,s.n)(Object.assign(Object.assign({},e),{mountElement:h,attachForm:y}))),I.on(["input_required","processing","error"],(()=>p.emit("loading",!1,{message:"Completed process unsuccessfully"}))),I.map(["input_required","processing","error","warning"],p),h.appendChild(D)}))))}},9221:(e,t,n)=>{n.d(t,{N:()=>r});var i=n(9188),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.Ns(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
- //# sourceMappingURL=idv-incode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"idv-incode.js","mappings":"8IAIO,MAAMA,GAAa,E,QAAA,GAAuB,CAC/CC,OAAQ,SACRC,aAAc,CACZC,MAAO,0BACPC,cAAe,SACfC,eAAgB,CACdC,SAAU,mBAEZC,aAAc,CACZD,SAAU,iBAGdE,aAAc,CACZC,YAAY,EACZ,iBAAAC,EAAkB,eAAEC,EAAc,QAAEC,EAAO,iBAAEC,IAC3C,MAAMC,EAAcF,EAAQG,MACtB,SAAET,GAAaQ,EAGrB,GAAiB,oBAAbR,EAAgC,CAGlC,MAAMU,EAAUH,EAAiBI,YACjCN,EAAeO,KAAK,UAAW,CAAEL,iBAAkB,CAAEG,YACvD,KAAwB,iBAAbV,GACTK,EAAeO,KACb,QACA,IAAI,EAAAC,YAAYb,EAAU,CAAEM,QAAS,4BAG3C,I,0DC1B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ACA,aACA,QACA,WACCf,GAKHE,EAAac,YAAYrE,EAC3B,KAAE,C,sVCrIG,SAAesE,EACpB5F,G,yCAEA,MAAQ2E,cAAe1E,EAAQ,cAAE4F,GAAkB7F,EACnD,IACE,MAAMmF,EAAY,IAAI,KAAUU,IAG1B,iBAAErG,EAAgB,SAAEW,SAAmBgF,EAAUW,SAA2B,CAChFC,WAAY/F,EAAQ+F,aAMtB,OAFA9F,EAASJ,KAAK,yBAA0B,CAAEmG,QAAS,OAAF,wBAAOxG,GAAgB,CAAEW,eAEnE,CAAEX,mBAAkB2F,YAAWhF,WACxC,CAAE,MAAOoF,GAEP,MADAtF,EAASJ,KAAK,+BACR0F,CACR,CACF,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 { OneSDKError } from '@module/common';\n\nimport { 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 errorPayload: {\n workflow: 'INCODE_ERROR',\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 } else if (workflow === 'INCODE_ERROR') {\n targetEventHub.emit(\n 'error',\n new OneSDKError(workflow, { message: 'Dummy error from Incode' }),\n );\n }\n },\n },\n});\n\ntype MessageData = { workflow: 'INCODE_COMPLETE' | 'INCODE_ERROR' };\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 position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\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 = {\n vendorParameters: { tokenURL: string };\n dummyModeOptions: DummyHTMLOptions;\n iframeMessagingOptions: IframeMessagingOptions;\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 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 { feat } from '@feature-flags';\nimport { OneSDKError } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport { mkEventHub } from '@module/common/modules/eventHub';\nimport {\n useFormToReviewResults,\n} from '@module/common/vendors/form/useForm';\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/**\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 = feat(`modules.idv.containsReviewScreen`)[vendor];\n\n return defineWrapper<IDVModule>(vendor, async (\n sharedDependencies,\n options,\n ) => {\n // load mastercard token/iframe url from IDVClient\n const { localEventHub, recipe } = sharedDependencies;\n const { mountElement } = options;\n localEventHub.emit('loading', true, { message: `Loading IDV vendor '${vendor}'` });\n // For Form component to be included after the \"results\" event, the recipe\n // 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 // Form is not displayed for vendors which already have a review screen\n const recipeProvideReviewScreen = recipe.idv.provideReviewScreen ?? feat('recipeDefaults.idv.provideReviewScreen');\n const attachForm = !containsReviewScreen && recipeProvideReviewScreen;\n\n const privateEventHub = mkEventHub<Events>();\n\n /*-------- 0) FETCH SESSION DATA */\n type VendorParameters = { tokenURL: string };\n const {\n vendorParameters,\n idvClient,\n entityId,\n } = 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 // \"detection_complete\" is only emitted when vendors already have a review screen\n // this event is only emitted after the review screen. When includeForm is true\n // it only happens after the \"results\" event and the following Form review\n if (!attachForm) 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 form.`,\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 cleanup({ internalEventHub: iframeListener, iframe });\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 includeForm is true, instead of emitting 'results' event with the idv results\n // first mount the Form to the same mountElement and only when Form emits a 'results' event\n // then emit 'results' too\n privateEventHub.on(\n 'results',\n useFormToReviewResults({\n ...sharedDependencies,\n mountElement,\n attachForm: attachForm,\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([\n 'input_required',\n 'processing',\n 'error',\n 'warning',\n ], 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","errorPayload","eventOptions","emitOnLoad","mapMessageToEvent","targetEventHub","message","vendorParameters","messageData","data","checkId","interviewId","emit","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","payload","createIframe","globalState","iframe","createElement","iframeListener","iframeEventListener","mkEventHub","onload","window","addEventListener","source","contentWindow","iframeElement","mkEventListener","createIframeEventListener","iframeMessagingOptions","Object","assign","style","position","top","left","right","bottom","border","margin","padding","width","height","fontSize","font","verticalAlign","allow","mode","is","DUMMY","srcdoc","dummyModeOptions","stringifyPostMessage","JSON","stringify","onLoadedAction","onCompletedAction","createDummyHTML","src","tokenURL","cleanup","dependencies","internalEventHub","off","remove","defineIframeIDVWrapper","wrapperOptions","containsReviewScreen","sharedDependencies","localEventHub","recipe","mountElement","recipeProvideReviewScreen","idv","provideReviewScreen","attachForm","privateEventHub","idvClient","on","initProcess","isSynchronous","e","error","domElement","map","appendChild","initialiseIDVSession","frankieClient","getToken","relayState","session"],"sourceRoot":""}
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[663],{6729:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>o});var i=n(4334);const o=(0,n(2103).s)({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),o=n.payload;if(e.emit("info",{message:`Received message ${o.value}`,payload:n}),"loaded"===o.value)e.emit("loaded");else if("success"===o.value){const t=n.workflowExecutionId;e.emit("success",{vendorParameters:{checkId:t}})}else"error"===o.value?e.emit("error",new i.OneSDKError(o.metainfo.msg,o.metainfo)):e.emit("warning",{message:`Unexpected message ${o.value}`,payload:n})}}})},1144:(e,t,n)=>{n.d(t,{N:()=>a});var i=n(4334),o=n(9188);function a(e){const{eventHub:t,results:n,entityId:a}=e;switch(n.checkStatus){case o.Yt.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:a});break;case o.Yt.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:a});break;case o.Yt.INTERRUPTED:case o.Yt.INCOMPLETE:case o.Yt.DOCUMENTS_INVALID:case o.Yt.WAITING_DOC_UPLOAD:case o.Yt.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:a},n.checkStatus);break;case o.Yt.PROVIDER_OFFLINE:case o.Yt.AWAITING_CONSENT:{const e=n.checkStatus===o.Yt.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.Yt.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.Yt.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})}}}},5353:(e,t,n)=>{n.d(t,{t:()=>r,h:()=>a});var i=n(1031),o=n(4334);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({targetEventHub:n,message:i,iframeElement:e,vendorParameters:t.vendorParameters})}),!1),(0,o.mkEventListener)(n)}(n,t.iframeMessagingOptions);return Object.assign(n.style,{position:"absolute",top:0,left:0,right:0,bottom:0,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.t.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()}},2103:(e,t,n)=>{n.d(t,{s:()=>u});var i=n(591),o=n(4334),a=n(5473),r=n(486),s=n(846),c=n(1144),l=n(9221),d=n(5353),m=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(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(r,s)}c((i=i.apply(e,t||[])).next())}))};const u=e=>{const{dummyOptions:t,eventOptions:n,vendor:u}=e,v=(0,i.T)("modules.idv.containsReviewScreen")[u];return(0,a.f)(u,((e,a)=>m(void 0,void 0,void 0,(function*(){var p;const{localEventHub:f,recipe:g}=e,{mountElement:h}=a;f.emit("loading",!0,{message:`Loading IDV vendor '${u}'`});const y=null!==(p=g.idv.provideReviewScreen)&&void 0!==p?p:(0,i.T)("recipeDefaults.idv.provideReviewScreen"),E=!v&&y,w=(0,r.y)(),{vendorParameters:I,idvClient:O,entityId:k}=yield(0,l.N)(e),{iframe:b,iframeListener:D}=(0,d.h)(e,{vendorParameters:I,dummyModeOptions:t,iframeMessagingOptions:Object.assign(Object.assign({},n),{vendorParameters:I})});D.on("success",(e=>m(void 0,[e],void 0,(function*({vendorParameters:e}){E?f.emit("info",{message:"Data extraction completed. Now executing user review using form."}):f.emit("detection_complete"),f.emit("loading",!0,{message:"Retrieving IDV results"});try{const t=yield O.initProcess({isSynchronous:!0,vendorParameters:e});(0,c.N)({eventHub:w,results:t,entityId:k}),(0,d.t)({internalEventHub:D,iframe:b})}catch(e){f.emit("error",new o.OneSDKError("Failed initiating IDV processing",e)),f.emit("loading",!1,{message:"Failed retrieving IDV results"})}})))),D.on("error",(e=>{(0,d.t)({internalEventHub:D,iframe:b}),f.emit("detection_failed",{message:`Error from ${u}: ${e.message}`,payload:e.payload}),f.emit("loading",!1,{message:`Vendor '${u}' detection has failed`})})),D.on("loaded",(()=>{f.emit("ready",{domElement:b}),f.emit("loading",!1,{message:`Vendor '${u}' screen has loaded`})})),w.on("results",(0,s.n)(Object.assign(Object.assign({},e),{mountElement:h,attachForm:E}))),w.on(["input_required","processing","error"],(()=>f.emit("loading",!1,{message:"Completed process unsuccessfully"}))),w.map(["input_required","processing","error","warning"],f),h.appendChild(b)}))))}},9221:(e,t,n)=>{n.d(t,{N:()=>a});var i=n(9188),o=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(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(r,s)}c((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.Ns(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}}))}}}]);
2
- //# sourceMappingURL=idv-mastercard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"idv-mastercard.js","mappings":"8IAGO,MAAMA,GAAa,E,QAAA,GAAuB,CAC/CC,OAAQ,aACRC,aAAc,CACZC,MAAO,8BA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endors/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 position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\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 = {\n vendorParameters: { tokenURL: string };\n dummyModeOptions: DummyHTMLOptions;\n iframeMessagingOptions: IframeMessagingOptions;\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 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 { feat } from '@feature-flags';\nimport { OneSDKError } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport { mkEventHub } from '@module/common/modules/eventHub';\nimport {\n useFormToReviewResults,\n} from '@module/common/vendors/form/useForm';\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/**\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 = feat(`modules.idv.containsReviewScreen`)[vendor];\n\n return defineWrapper<IDVModule>(vendor, async (\n sharedDependencies,\n options,\n ) => {\n // load mastercard token/iframe url from IDVClient\n const { localEventHub, recipe } = sharedDependencies;\n const { mountElement } = options;\n localEventHub.emit('loading', true, { message: `Loading IDV vendor '${vendor}'` });\n // For Form component to be included after the \"results\" event, the recipe\n // 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 // Form is not displayed for vendors which already have a review screen\n const recipeProvideReviewScreen = recipe.idv.provideReviewScreen ?? feat('recipeDefaults.idv.provideReviewScreen');\n const attachForm = !containsReviewScreen && recipeProvideReviewScreen;\n\n const privateEventHub = mkEventHub<Events>();\n\n /*-------- 0) FETCH SESSION DATA */\n type VendorParameters = { tokenURL: string };\n const {\n vendorParameters,\n idvClient,\n entityId,\n } = 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 // \"detection_complete\" is only emitted when vendors already have a review screen\n // this event is only emitted after the review screen. When includeForm is true\n // it only happens after the \"results\" event and the following Form review\n if (!attachForm) 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 form.`,\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 cleanup({ internalEventHub: iframeListener, iframe });\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 includeForm is true, instead of emitting 'results' event with the idv results\n // first mount the Form to the same mountElement and only when Form emits a 'results' event\n // then emit 'results' too\n privateEventHub.on(\n 'results',\n useFormToReviewResults({\n ...sharedDependencies,\n mountElement,\n attachForm: attachForm,\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([\n 'input_required',\n 'processing',\n 'error',\n 'warning',\n ], 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","position","top","left","right","bottom","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","sharedDependencies","localEventHub","recipe","mountElement","recipeProvideReviewScreen","idv","provideReviewScreen","attachForm","privateEventHub","idvClient","on","initProcess","isSynchronous","e","error","domElement","map","appendChild","initialiseIDVSession","frankieClient","getToken","relayState","session"],"sourceRoot":""}
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[205],{6269:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>y});var i=n(5473),o=n(1114);class r extends o.V{retrieveAndDelete(e){return t=this,n=void 0,o=function*(){const t=`/data/v1/key-value/${e}`;return this.frankie.get(t,{params:{delete:!0}}).then((e=>e.data))},new((i=void 0)||(i=Promise))((function(e,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(a,s)}c((o=o.apply(t,n||[])).next())}));var t,n,i,o}}var a=n(9188),s=n(1144),c=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 l(e){return`sessionId:${e}:idv_action_details`}var d=n(5635),u=n(9221),f=n(7117),m=n(5353),v=n(4334);function h(...e){return t=this,n=void 0,o=function*(){const[t]=e,{mode:n,session:i,localEventHub:o}=t,r=t.recipe.idv.provider,a=null==r?void 0:r.redirect_uri;try{const{vendorParameters:o}=yield(0,u.N)({frankieClient:t.frankieClient,localEventHub:t.localEventHub,relayState:JSON.stringify({redirect_uri:null!=a?a:window.location.href,sessionId:i.sessionId})});n.is(d.O_.DUMMY)?function(...e){const[t,n]=e,{mountElement:i}=n,{session:o,localEventHub:r}=t,{iframe:a,iframeListener:s}=(0,m.h)(t,{dummyModeOptions:{title:"OCRLabs",errorPayload:{type:"error"},successPayload:{type:"success"},loadedPayload:{type:"loaded"}},iframeMessagingOptions:{emitOnLoad:!1,mapMessageToEvent:({message:e,targetEventHub:t})=>{const{data:n}=e,{type:i}=n;t.emit(i)}},vendorParameters:{tokenURL:"https://not-used.com"}}),c=new f.D,d=l(o.sessionId),u=t.recipe.idv.provider,v=null==u?void 0:u.redirect_uri,h=()=>{v?location.href=v:location.reload()};s.on("success",(()=>{c.store(d,{workflow:"IDV_SUCCESS"}),(0,m.t)({iframe:a,internalEventHub:s}),h()})),s.on("error",(()=>{c.store(d,{workflow:"IDV_ERROR"}),(0,m.t)({iframe:a,internalEventHub:s}),h()})),s.on("loaded",(()=>{r.emit("ready",{domElement:a})})),i.appendChild(a)}(...e):t.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{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(a,s)}c((o=o.apply(t,n||[])).next())}));var t,n,i,o}var p=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 y=(0,i.f)("ocrlabs",((e,t)=>p(void 0,void 0,void 0,(function*(){const n=yield function(e){return p(this,void 0,void 0,(function*(){var t;const{frankieClient:n,session:i}=e,o=new r(n),a=l(i.sessionId);try{const e=yield o.retrieveAndDelete(a),n=null===(t=null==e?void 0:e.value)||void 0===t?void 0:t.workflow;if("IDV_ERROR"===n)return"fail";if("IDV_SUCCESS"===n)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"===n?yield function(e){return c(this,void 0,void 0,(function*(){const{localEventHub:t,frankieClient:n}=e;t.emit("detection_complete");const i=new a.Ns(n),o=yield i.initProcess({isSynchronous:!0});try{const t=e.oneSdkInstance.individual();yield t.search()}catch(e){const n="Error updating data for the individual. Check error events from module 'individual' for more details.This isn't related to IDV capture.";t.emit("warning",{message:n,payload:e})}const r=n.entityId;(0,s.N)({eventHub:t,results:o,entityId:r})}))}(e):"fail"===n?yield function(e){return c(this,void 0,void 0,(function*(){const{localEventHub:t}=e;t.emit("detection_failed",{message:"User flow was unsuccessful"})}))}(e):yield h(e,t)}))))},1144:(e,t,n)=>{n.d(t,{N:()=>r});var i=n(4334),o=n(9188);function r(e){const{eventHub:t,results:n,entityId:r}=e;switch(n.checkStatus){case o.Yt.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:r});break;case o.Yt.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:r});break;case o.Yt.INTERRUPTED:case o.Yt.INCOMPLETE:case o.Yt.DOCUMENTS_INVALID:case o.Yt.WAITING_DOC_UPLOAD:case o.Yt.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:r},n.checkStatus);break;case o.Yt.PROVIDER_OFFLINE:case o.Yt.AWAITING_CONSENT:{const e=n.checkStatus===o.Yt.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.Yt.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.Yt.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})}}}},5353:(e,t,n)=>{n.d(t,{t:()=>a,h:()=>r});var i=n(1031),o=n(4334);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,{position:"absolute",top:0,left:0,right:0,bottom:0,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.t.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()}},9221:(e,t,n)=>{n.d(t,{N:()=>r});var i=n(9188),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.Ns(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
- //# sourceMappingURL=idv-ocrlabs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"idv-ocrlabs.js","mappings":"wJAOO,MAAMA,UAAsBC,EAAA,EAC3B,iBAAAC,CAAwBC,G,qCAC5B,MAAMC,EAA0B,sBAAsBD,IACtD,OAAOE,KAAKC,QACTC,IAAqBH,EAAyB,CAC7CI,OAAQ,CACNC,QAAQ,KAGXC,MAAMC,GAAMA,EAAEC,MACnB,E,8lBCfK,SAASC,EAAiBC,GAC/B,MAAO,aAAaA,sBACtB,C,sDCGO,SAAeC,KAAgBC,G,qCACpC,MAAOC,GAAeD,GAChB,KAAEE,EAAI,QAAEC,EAAO,cAAEC,GAAkBH,EAGnCI,EAA4CJ,EAAYK,OAAOC,IAAIC,SACnEC,EAAeJ,aAAc,EAAdA,EAAgBI,aACrC,IACE,MAAM,iBAAEC,SAA2B,OAAuC,CACxEC,cAAeV,EAAYU,cAC3BP,cAAeH,EAAYG,cAC3BQ,WAAYC,KAAKC,UAAU,CACzBL,aAAcA,QAAAA,EAAgBM,OAAOC,SAASC,KAC9CnB,UAAWK,EAAQL,cAInBI,EAAKgB,GAAG,KAAQC,OChBjB,YAA2BnB,GAChC,MAAOC,EAAamB,GAAWpB,GACzB,aAAEqB,GAAiBD,GACnB,QAAEjB,EAAO,cAAEC,GAAkBH,GAE7B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KAAM,EACNC,MAAO,EACPC,OAAQ,EACRC,OAAQ,EACRC,OAAQ,EACRC,QAAS,EACTC,MAAO,OACPC,OAAQ,OACRC,SAAU,OACVC,KAAM,UACNC,cAAe,aAEjB5F,EAAO6F,MAAQ,iFACClH,EAAYC,KAAKgB,GAAG,IAASC,OAG3CG,EAAO8F,OEvDJ,SAAyB3F,GAC9B,MAAM4F,EAAuB,CAACnF,EAAmB,CAAC,IAAM,6BAA6BrB,KAAKC,UAAUoB,WAM9FoF,EAAiB7F,EAAiBK,cACpC,oBAAoBuF,EAAqB5F,EAAiBK,oCAC1D,GACEyF,EAAoBF,EAAqB5F,EAAiBI,gBAGhE,MAAO,oGAGDyF,iDALgBD,EAAqB5F,EAAiBE,wEAUpD4F,wCAGA9F,EAAiBC,mpCAsC3B,CFPoB8F,CAAgBpG,EAAQK,kBAExCH,EAAOmG,IAAMrG,EAAQV,iBAAiB2B,SAGjC,CAAEf,SAAQC,iBACnB,CAWO,SAASmG,EAAQC,GAItBA,EAAarG,OAAO8F,OAAS,GAC7BO,EAAa9E,iBAAiB+E,MAC9BD,EAAarG,OAAOuG,QACtB,C,sVGtEO,SAAeC,EACpB1G,G,yCAEA,MAAQhB,cAAeoE,EAAQ,cAAE7D,GAAkBS,EACnD,IACE,MAAMwC,EAAY,IAAI,KAAUjD,IAG1B,iBAAED,EAAgB,SAAE4D,SAAmBV,EAAUmE,SAA2B,CAChFnH,WAAYQ,EAAQR,aAMtB,OAFA4D,EAASpC,KAAK,yBAA0B,CAAEjC,QAAS,OAAF,wBAAOO,GAAgB,CAAE4D,eAEnE,CAAE5D,mBAAkBkD,YAAWU,WACxC,CAAE,MAAOpB,GAEP,MADAsB,EAASpC,KAAK,+BACRc,CACR,CACF,G","sources":["webpack://OneSdk/./modules/frankie-client/clients/StorageClient.ts","webpack://OneSdk/./modules/idv/vendors/OcrLabs/shared.ts","webpack://OneSdk/./modules/idv/vendors/OcrLabs/startFlow.ts","webpack://OneSdk/./modules/idv/vendors/OcrLabs/startDummyFlow.ts","webpack://OneSdk/./modules/idv/vendors/OcrLabs/index.ts","webpack://OneSdk/./modules/idv/vendors/OcrLabs/endFlow.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/initialiseSession.ts"],"sourcesContent":["/**\n * May be used to abstract quick storage. May be implemented as a wrapper for LocalStorage\n * OR as a wrapper for a backend API which stores temporary data in redis\n */\n\nimport { BaseClient } from \"./BaseClient\";\n\nexport class StorageClient extends BaseClient {\n async retrieveAndDelete<Type>(key: string): Promise<{ value: Type }> {\n const keyPairRetrieveEndpoint = `/data/v1/key-value/${key}`;\n return this.frankie\n .get<{ value: Type }>(keyPairRetrieveEndpoint, {\n params: {\n delete: true,\n },\n })\n .then((d) => d.data);\n }\n}\n","// LOGIC SHARED WITH BFF. Changes here have to also be made there\n// File src/controllers/flows/actions/idv.ts\nexport function createStorageKey(sessionId: string) {\n return `sessionId:${sessionId}:idv_action_details`;\n}\nexport type RelayState = {\n redirect_uri: string;\n sessionId: string;\n};\nexport type StoredActionDetails = {\n workflow: \"IDV_SUCCESS\" | \"IDV_ERROR\";\n action: \"IDKIT_SUCCESS\" | \"IDKIT_ERROR\";\n entityId: string;\n relayState: RelayState;\n};","import { WrapperParameters } from '@module/common/modules/defineModule';\nimport { IDVModule } from '@module/idv/definition.types';\nimport { SdkMode } from '@module/index';\nimport { initialiseIDVSession } from '../common/initialiseSession';\nimport { startDummyFlow } from './startDummyFlow';\nimport { OneSDKError } from '@module/common';\n\nexport async function startNewFlow(...args: WrapperParameters<IDVModule>) {\n const [globalState] = args;\n const { mode, session, localEventHub } = globalState;\n type VendorParameters = { tokenURL: string };\n // Default redirect_uri to window.location.href, so the user is redirected back to the same page by default\n const providerRecipe = <{ redirect_uri?: string }>globalState.recipe.idv.provider;\n const redirect_uri = providerRecipe?.redirect_uri;\n try {\n const { vendorParameters } = await initialiseIDVSession<VendorParameters>({\n frankieClient: globalState.frankieClient,\n localEventHub: globalState.localEventHub,\n relayState: JSON.stringify({\n redirect_uri: redirect_uri ?? window.location.href,\n sessionId: session.sessionId,\n }),\n });\n\n if (mode.is(SdkMode.DUMMY)) {\n // In dummy mode, simply display the iframe implementation\n startDummyFlow(...args);\n } else {\n // Otherwise, redirect to OCRLabs` URL\n globalState.frankieClient.redirect(new URL(vendorParameters.tokenURL));\n }\n } catch (e) {\n localEventHub.emit('error', new OneSDKError('Failed initialising a new idv flow', e));\n }\n}\n","import type { WrapperParameters } from '@module/common/modules/defineModule';\nimport { LocalStorage } from '@module/common/modules/LocalStorage';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport { cleanup, createIframe } from '../common/iframeUtils/createIframe';\n\nimport { createStorageKey } from './shared';\n\nexport function startDummyFlow(...args: WrapperParameters<IDVModule>) {\n const [globalState, options] = args;\n const { mountElement } = options;\n const { session, localEventHub } = globalState;\n\n const { iframe, iframeListener } = createIframe(globalState, {\n dummyModeOptions: {\n title: 'OCRLabs',\n errorPayload: {\n type: 'error',\n },\n successPayload: {\n type: 'success',\n },\n loadedPayload: {\n type: 'loaded',\n },\n },\n iframeMessagingOptions: {\n emitOnLoad: false,\n mapMessageToEvent: ({ message, targetEventHub }) => {\n const { data } = message;\n const { type } = data as { type: 'error' | 'success' | 'loaded' };\n targetEventHub.emit(type);\n },\n },\n vendorParameters: {\n tokenURL: 'https://not-used.com',\n },\n });\n\n // To pretend the result was stored in BFF cache, we store it in localStorage\n // The dummy implementation of StorageClient will read it from localStorage, instead of sending a request to BFF\n const storage = new LocalStorage();\n const key = createStorageKey(session.sessionId);\n\n // Redirect to url provided via recipe\n const providerRecipe = globalState.recipe.idv.provider as { redirect_uri?: string };\n const redirect_uri = providerRecipe?.redirect_uri;\n const redirect = () => {\n if (redirect_uri) location.href = redirect_uri;\n else location.reload();\n };\n\n iframeListener.on('success', () => {\n storage.store(key, { workflow: 'IDV_SUCCESS' });\n cleanup({ iframe, internalEventHub: iframeListener });\n redirect();\n });\n iframeListener.on('error', () => {\n storage.store(key, { workflow: 'IDV_ERROR' });\n cleanup({ iframe, internalEventHub: iframeListener });\n redirect();\n });\n iframeListener.on('loaded', () => {\n localEventHub.emit('ready', { domElement: iframe });\n });\n\n mountElement.appendChild(iframe);\n}\n","import { defineWrapper } from '@module/common/modules/defineModule';\nimport type { FrankieApiClient } from '@module/frankie-client';\nimport { StorageClient } from '@module/frankie-client/clients/StorageClient';\nimport type { IDVModule } from '@module/idv/definition.types';\nimport type { SessionContext } from '@module/session/SessionContext';\n\nimport { onError, onSuccess } from './endFlow';\nimport { createStorageKey } from './shared';\nimport { startNewFlow } from './startFlow';\n\nimport type { StoredActionDetails } from './shared';\n\ntype Step = 'new' | 'fail' | 'success';\n\nexport const initialise = defineWrapper<IDVModule>('ocrlabs', async (globalState, options) => {\n const stepOfTheFlow: Step = await getNextStep(globalState);\n\n const { localEventHub, session } = globalState;\n\n // TODO: determine which cases to unpersist the session. Are these correct?\n localEventHub.on('results', () => session.unpersist());\n localEventHub.on('processing', () => session.unpersist());\n localEventHub.on('error', () => session.unpersist());\n\n if (stepOfTheFlow === 'success') await onSuccess(globalState);\n else if (stepOfTheFlow === 'fail') await onError(globalState);\n else await startNewFlow(globalState, options);\n});\n\nasync function getNextStep(globalState: { frankieClient: FrankieApiClient; session: SessionContext }): Promise<Step> {\n const { frankieClient, session } = globalState;\n const storageClient = new StorageClient(frankieClient);\n const sessionId = session.sessionId;\n // This key needs to be in sync with what BFF's /v1/actions/:workflow stores\n const key = createStorageKey(sessionId);\n try {\n const stepData = await storageClient.retrieveAndDelete<StoredActionDetails>(key);\n\n const workflow = stepData?.value?.workflow;\n if (workflow === 'IDV_ERROR') return 'fail';\n else if (workflow === 'IDV_SUCCESS') return 'success';\n else throw new Error('Invalid action');\n } catch (e) {\n // If 404 or action is not recognized, start new flow\n return 'new';\n }\n}\n","import type { OneSdkContext } from '@frankieone/one-sdk';\nimport type { EventHub } from '@module/common';\nimport type { FrankieApiClient } from '@module/frankie-client';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { IDVModule } from '@module/idv/definition.types';\n\nimport { checkStatusEventMapping } from '../common/checkStatusEventMapping';\n\nexport async function onError(globalState: {\n localEventHub: EventHub<IDVModule['moduleEvents']>;\n frankieClient: FrankieApiClient;\n}) {\n const { localEventHub } = globalState;\n\n localEventHub.emit('detection_failed', {\n message: `User flow was unsuccessful`,\n });\n}\nexport async function onSuccess(globalState: {\n localEventHub: EventHub<IDVModule['moduleEvents']>;\n frankieClient: FrankieApiClient;\n oneSdkInstance: OneSdkContext;\n}) {\n const { localEventHub, frankieClient } = globalState;\n\n localEventHub.emit('detection_complete');\n const idvClient = new IDVClient(frankieClient);\n\n const results = await idvClient.initProcess({\n isSynchronous: true,\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 const errorMessage =\n '' +\n 'Error updating data for the individual. ' +\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\n const entityId = frankieClient.entityId;\n checkStatusEventMapping({\n eventHub: localEventHub,\n results,\n entityId,\n });\n}\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 position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\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 = {\n vendorParameters: { tokenURL: string };\n dummyModeOptions: DummyHTMLOptions;\n iframeMessagingOptions: IframeMessagingOptions;\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 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 { 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":["StorageClient","BaseClient","retrieveAndDelete","key","keyPairRetrieveEndpoint","this","frankie","get","params","delete","then","d","data","createStorageKey","sessionId","startNewFlow","args","globalState","mode","session","localEventHub","providerRecipe","recipe","idv","provider","redirect_uri","vendorParameters","frankieClient","relayState","JSON","stringify","window","location","href","is","DUMMY","options","mountElement","iframe","iframeListener","createIframe","dummyModeOptions","title","errorPayload","type","successPayload","loadedPayload","iframeMessagingOptions","emitOnLoad","mapMessageToEvent","message","targetEventHub","emit","tokenURL","storage","LocalStorage","redirect","reload","on","store","workflow","internalEventHub","domElement","appendChild","startDummyFlow","URL","e","OneSDKError","initialise","stepOfTheFlow","storageClient","stepData","value","Error","getNextStep","unpersist","idvClient","IDVClient","results","initProcess","isSynchronous","individual","oneSdkInstance","search","errorMessage","payload","entityId","checkStatusEventMapping","eventHub","onSuccess","onError","checkStatus","COMPLETE","document","ocrDocument","FAILED","INTERRUPTED","INCOMPLETE","DOCUMENTS_INVALID","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","PROVIDER_OFFLINE","AWAITING_CONSENT","errorStatus","CHECK_PROCESSING","createElement","iframeEventListener","mkEventHub","onload","addEventListener","source","contentWindow","iframeElement","mkEventListener","createIframeEventListener","Object","assign","style","position","top","left","right","bottom","border","margin","padding","width","height","fontSize","font","verticalAlign","allow","srcdoc","stringifyPostMessage","onLoadedAction","onCompletedAction","createDummyHTML","src","cleanup","dependencies","off","remove","initialiseIDVSession","getToken"],"sourceRoot":""}
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[336],{9832:(e,n,o)=>{o.r(n),o.d(n,{initialise:()=>i});var t=o(5473);const i=(0,t.f)("onfido",((e,n)=>{return o=void 0,t=void 0,d=function*(){var o;const{oneSdkInstance:t,recipe:{idv:{provider:i,documents:d}}}=e,{mountElement:c,eventHub:m}=n,a=t.component("ocr",{instanceName:"idv-ocr-onfido",documents:d,maxDocumentCount:null!==(o="onfido"===i.name&&(null==i?void 0:i.maxDocumentCount))&&void 0!==o?o:-1}),r=t.component("biometrics",{instanceName:"idv-biometrics-onfido",provider:{name:"onfido",fallback:"onfido"===i.name&&(null==i?void 0:i.fallback)||void 0}});a.on("ready",(({domElement:e})=>m.emit("ready",{domElement:e}))),r.on("ready",(({domElement:e})=>m.emit("ready",{domElement:e}))),a.on("error",(e=>m.emit("error",e))),r.on("error",(e=>m.emit("error",e))),a.on("detection_failed",(({message:e})=>m.emit("detection_failed",{message:e}))),r.on("detection_failed",(({message:e})=>m.emit("detection_failed",{message:e}))),a.on("detection_complete",(()=>m.emit("detection_complete"))),r.on("detection_complete",(()=>m.emit("detection_complete"))),a.on("results",(()=>{r.mount(c)})),r.on("results",(({checkStatus:e,document:n,entityId:o})=>{m.emit("results",{checkStatus:e,document:n,entityId:o})})),a.on("loading",((e,n)=>m.emit("loading",e,n))),r.on("loading",((e,n)=>m.emit("loading",e,n))),a.mount(c)},new((i=void 0)||(i=Promise))((function(e,n){function c(e){try{a(d.next(e))}catch(e){n(e)}}function m(e){try{a(d.throw(e))}catch(e){n(e)}}function a(n){var o;n.done?e(n.value):(o=n.value,o instanceof i?o:new i((function(e){e(o)}))).then(c,m)}a((d=d.apply(o,t||[])).next())}));var o,t,i,d}))}}]);
2
- //# sourceMappingURL=idv-onfido.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"idv-onfido.js","mappings":"8IAIO,MAAMA,GAAa,OACxB,UACA,CAAOC,EAAuBC,KAAyC,O,OAAD,E,OAAA,E,EAAA,Y,MAEpE,MAAM,eACJC,EACAC,QACEC,KAAK,SAAEC,EAAQ,UAAEC,KAEjBN,GACE,aAAEO,EAAY,SAAEC,GAAaP,EAG7BQ,EAAMP,EAAeQ,UAAU,MAAO,CAC1CC,aAAc,iBACdL,YACAM,iBAC4D,QAAzD,EAAkB,WAAlBP,EAASQ,OAAqBR,aAAQ,EAARA,EAAUO,yBAAiB,SAAK,IAE7DE,EAAaZ,EAAeQ,UAAU,aAAc,CACxDC,aAAc,wBACdN,SAAU,CACRQ,KAAM,SACNE,SACqB,WAAlBV,EAASQ,OAAqBR,aAAQ,EAARA,EAAUU,gBAAaC,KAK5DP,EAAIQ,GAAG,SAAS,EAAGC,gBAAiBV,EAASW,KAAK,QAAS,CAAED,iBAC7DJ,EAAWG,GAAG,SAAS,EAAGC,gBACxBV,EAASW,KAAK,QAAS,CAAED,iBAI3BT,EAAIQ,GAAG,SAAUG,GAAUZ,EAASW,KAAK,QAASC,KAClDN,EAAWG,GAAG,SAAUG,GAAUZ,EAASW,KAAK,QAASC,KAGzDX,EAAIQ,GAAG,oBAAoB,EAAGI,aAC5Bb,EAASW,KAAK,mBAAoB,CAAEE,cAEtCP,EAAWG,GAAG,oBAAoB,EAAGI,aACnCb,EAASW,KAAK,mBAAoB,CAAEE,cAItCZ,EAAIQ,GAAG,sBAAsB,IAAMT,EAASW,KAAK,wBACjDL,EAAWG,GAAG,sBAAsB,IAClCT,EAASW,KAAK,wBAIhBV,EAAIQ,GAAG,WAAW,KAChBH,EAAWQ,MAAMf,EAAa,IAIhCO,EAAWG,GAAG,WAAW,EAAGM,cAAaC,WAAUC,eACjDjB,EAASW,KAAK,UAAW,CAAEI,cAAaC,WAAUC,YAAW,IAI/DhB,EAAIQ,GAAG,WAAW,CAACS,EAAOL,IACxBb,EAASW,KAAK,UAAWO,EAAOL,KAElCP,EAAWG,GAAG,WAAW,CAACS,EAAOL,IAC/Bb,EAASW,KAAK,UAAWO,EAAOL,KAIlCZ,EAAIa,MAAMf,EACZ,E,YAtEsE,K,6QAsErE,G","sources":["webpack://OneSdk/./modules/idv/vendors/Onfido/index.ts"],"sourcesContent":["import { defineWrapper } from '@module/common/modules/defineModule';\nimport type { InjectedState } from '@module/common/types';\nimport type { IDVModule } from '@module/idv';\n\nexport const initialise = defineWrapper<IDVModule>(\n 'onfido',\n async (shared: InjectedState, options: IDVModule['wrapperOptions']) => {\n // Destructure properties from the shared and options objects\n const {\n oneSdkInstance,\n recipe: {\n idv: { provider, documents },\n },\n } = shared;\n const { mountElement, eventHub } = options;\n\n // Create OCR and biometrics components\n const ocr = oneSdkInstance.component('ocr', {\n instanceName: 'idv-ocr-onfido',\n documents,\n maxDocumentCount:\n (provider.name === 'onfido' && provider?.maxDocumentCount) ?? -1,\n });\n const biometrics = oneSdkInstance.component('biometrics', {\n instanceName: 'idv-biometrics-onfido',\n provider: {\n name: 'onfido',\n fallback:\n (provider.name === 'onfido' && provider?.fallback) || undefined,\n },\n });\n\n // Handle ready from OCR and biometrics components\n ocr.on('ready', ({ domElement }) => eventHub.emit('ready', { domElement }));\n biometrics.on('ready', ({ domElement }) =>\n eventHub.emit('ready', { domElement }),\n );\n\n // Handle errors from OCR and biometrics components\n ocr.on('error', (error) => eventHub.emit('error', error));\n biometrics.on('error', (error) => eventHub.emit('error', error));\n\n // Handle detection failures from OCR and biometrics components\n ocr.on('detection_failed', ({ message }) =>\n eventHub.emit('detection_failed', { message }),\n );\n biometrics.on('detection_failed', ({ message }) =>\n eventHub.emit('detection_failed', { message }),\n );\n\n // Handle detection completion events from OCR and biometrics components\n ocr.on('detection_complete', () => eventHub.emit('detection_complete'));\n biometrics.on('detection_complete', () =>\n eventHub.emit('detection_complete'),\n );\n\n // Trigger biometrics mount when OCR results are received\n ocr.on('results', () => {\n biometrics.mount(mountElement);\n });\n\n // Emit results when results are received from a biometrics component\n biometrics.on('results', ({ checkStatus, document, entityId }) => {\n eventHub.emit('results', { checkStatus, document, entityId });\n });\n\n // Emit loading state when loading events are received\n ocr.on('loading', (state, message) =>\n eventHub.emit('loading', state, message),\n );\n biometrics.on('loading', (state, message) =>\n eventHub.emit('loading', state, message),\n );\n\n // Mount OCR component to the specified element\n ocr.mount(mountElement);\n },\n);\n"],"names":["initialise","shared","options","oneSdkInstance","recipe","idv","provider","documents","mountElement","eventHub","ocr","component","instanceName","maxDocumentCount","name","biometrics","fallback","undefined","on","domElement","emit","error","message","mount","checkStatus","document","entityId","state"],"sourceRoot":""}
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[834],{4090:(e,t,n)=>{n.d(t,{a:()=>i,g:()=>r});var o=n(4334);const i=e=>{return t=void 0,n=[e],r=function*({sdkVersion:e="12"}){yield(0,o.loadAsyncAsset)(`https://sdk.onfido.com/v${e}`),Number(e)<14&&(yield(0,o.loadAsyncAsset)(`https://sdk.onfido.com/v${e}/style.css`,"style"))},new((i=void 0)||(i=Promise))((function(e,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function d(e){try{c(r.throw(e))}catch(e){o(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(s,d)}c((r=r.apply(t,n||[])).next())}));var t,n,i,r},r=(e,t)=>{const n=document.querySelector("body");new MutationObserver(((n,o)=>{var i;for(const r of n){const n=null===(i=r.addedNodes)||void 0===i?void 0:i[0];(null==n?void 0:n.classList.contains(e))&&(t.emit("ready",{domElement:n}),o.disconnect())}})).observe(n,{childList:!0,subtree:!0})}},9255:(e,t,n)=>{n.d(t,{p:()=>r});var o=n(5635),i=n(4334);const r={[o.By.COMPLETE]:({ocrDocument:e,ocrClient:t,eventHub:n})=>n.emit("results",{document:e,entityId:t.entityId}),[o.By.WAITING_OCR_RUN]:({eventHub:e})=>{e.emit("error",new i.OneSDKError(`Two attempts to get OCR results failed with an unresolved "${o.By.WAITING_OCR_RUN}". This is a system failure.`,{payload:null}))},[o.By.PROVIDER_OFFLINE]:({eventHub:e})=>e.emit("error",new i.OneSDKError(`Provider is offline. Either switch providers and restart or skip OCR temporarily. Status ${o.By.PROVIDER_OFFLINE}`,{payload:null})),default:({documentStatus:e,eventHub:t})=>t.emit("input_required",{documentType:null,side:"front"},e,(()=>({})))}},9687:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>u});var o=n(4334),i=n(5473),r=n(4090),s=n(9188),d=n(325),c=n(9255),a=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function d(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,d)}c((o=o.apply(e,t||[])).next())}))};const u=(0,i.f)("dummy-ocr",((e,t)=>a(void 0,void 0,void 0,(function*(){const{frankieClient:n}=e,{mountElement:o,eventHub:i}=t,c=new s.Ns(n),u=new d.UZ(n);try{const{entityId:t,token:n,vendorParameters:s}=yield c.getToken();i.emit("session_data_generated",{session:{entityId:t,token:n,vendorParameters:s}}),(0,r.g)("dummy-ocr-modal",i);const y=document.createElement("div");Object.assign(y.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",justifyContent:"center",alignItems:"center"}),y.className="dummy-ocr-modal",o.appendChild(y);const v=document.createElement("div");v.style.backgroundColor="#fff",v.style.padding="200px",v.style.borderRadius="5px",y.appendChild(v);const f=document.createElement("button");f.id="run-ocr-button",f.textContent="Run OCR",f.addEventListener("click",(()=>a(void 0,void 0,void 0,(function*(){const{oneSdkInstance:t}=e;yield l(u,i,t),m(y,i)})))),v.appendChild(f);const p=document.createElement("button");p.id="close-button",p.textContent="Close",p.addEventListener("click",(()=>{i.emit("input_required",{documentType:null,side:"front"},d.By.INTERRUPTED,(()=>({}))),m(y,i)})),v.appendChild(p)}catch(e){const{code:t=null,message:n=""}=e;i.emit("session_data_failed_loading",{code:t,message:n})}return{}})))),l=(e,t,n)=>a(void 0,void 0,void 0,(function*(){var i;try{let o=yield e.attachNewOCRDocument();o.documentStatus===d.By.WAITING_OCR_RUN&&(o=yield e.rerun(o.ocrDocument.documentId));const{ocrDocument:r,documentStatus:s}=o;(null!==(i=c.p[s])&&void 0!==i?i:c.p.default)({ocrDocument:r,documentStatus:s,ocrClient:e,eventHub:t}),yield n.individual().search()}catch(e){const{message:n=""}=e;t.emit("error",new o.OneSDKError("Error from OCR documents submission",{message:n}))}})),m=(e,t)=>{try{e.remove(),t.emit("session_closed")}catch(e){const{type:n=null,message:i=""}=e;t.emit("error",new o.OneSDKError("Error from vendor SDK 'Onfido'",{type:n,message:i}))}}}}]);
2
- //# sourceMappingURL=ocr-dummy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ocr-dummy.js","mappings":"sIAIO,MAAMA,EAAU,IAAgD,O,OAAD,E,EAAA,I,EAAA,WAAxC,WAAEC,EAAa,aAErC,IAAAC,gBAAe,2BAA2BD,KAE5CE,OAAOF,GAAc,WACjB,IAA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AAmB4C,GACe,QAAhC,MAAiB5C,UAAe,QAAI,IAAiBD,SAC5D,CACdP,cACAQ,iBACAP,YACArB,mBAIIgE,EAAeY,aAAaC,QACpC,CAAE,MAAOR,GACP,MAAM,QAAEE,EAAU,IAAOF,EACzBrE,EAASY,KAAK,QAAS,IAAI,EAAAY,YAAY,sCAAuC,CAAE+C,YAClF,CACF,IAGML,EAAgB,CACpBY,EACA9E,KAEA,IACE8E,EAAQC,SACR/E,EAASY,KAAK,iBAChB,CAAE,MAAOyD,GACP,MAAM,KAAEW,EAAO,KAAI,QAAET,EAAU,IAAOF,EACtCrE,EAASY,KAAK,QAAS,IAAI,EAAAY,YAAY,iCAAkC,CACvEwD,OACAT,YAEJ,E","sources":["webpack://OneSdk/./modules/common/vendors/onfido/index.ts","webpack://OneSdk/./modules/ocr/vendors/common/statusEvaluators.ts","webpack://OneSdk/./modules/ocr/vendors/dummy-ocr/index.ts"],"sourcesContent":["import type { Events as BiometricsEvents } from '@module/biometrics';\nimport { type EventHub, loadAsyncAsset } from '@module/common';\nimport type { Events as OcrEvents } from '@module/ocr';\n\nexport const install = async ({ sdkVersion = '12' }): Promise<void> => {\n // install Onfido script from CDN\n await loadAsyncAsset(`https://sdk.onfido.com/v${sdkVersion}`);\n // note that from version 14 onwards, a separate stylesheet is no longer required as it will be included with the default library.\n if (Number(sdkVersion) < 14 && process.env.NODE_ENV !== 'test') {\n await loadAsyncAsset(`https://sdk.onfido.com/v${sdkVersion}/style.css`, 'style');\n }\n};\n\nexport const observeReady = (\n mutationClass: string,\n eventHub: EventHub<BiometricsEvents | OcrEvents>,\n): 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(mutationClass)) {\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","import { OCRStatus } from '@frankieone/one-sdk';\nimport type { EventHub} from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport type { Document } from '@module/common/shared/models/Document';\nimport type { OCRClient } from '@module/frankie-client/clients/OCRClient';\nimport type { Events } from '@module/ocr';\n\nexport interface StatusEvaluators {\n ocrDocument?: Document;\n documentStatus?: OCRStatus;\n ocrClient?: OCRClient;\n eventHub: EventHub<Events>;\n}\n\nexport const statusEvaluators = {\n [OCRStatus.COMPLETE]: ({ ocrDocument, ocrClient, eventHub }: StatusEvaluators) =>\n eventHub.emit('results', { document: ocrDocument, entityId: ocrClient.entityId }),\n [OCRStatus.WAITING_OCR_RUN]: ({ eventHub }: StatusEvaluators) => {\n eventHub.emit(\n 'error',\n new OneSDKError(\n `Two attempts to get OCR results failed with an unresolved \"${OCRStatus.WAITING_OCR_RUN}\". This is a system failure.`,\n { payload: null },\n ),\n );\n },\n [OCRStatus.PROVIDER_OFFLINE]: ({ eventHub }: StatusEvaluators) =>\n eventHub.emit(\n 'error',\n new OneSDKError(\n `Provider is offline. Either switch providers and restart or skip OCR temporarily. Status ${OCRStatus.PROVIDER_OFFLINE}`,\n { payload: null },\n ),\n ),\n default: ({ documentStatus, eventHub }: StatusEvaluators) =>\n eventHub.emit('input_required', { documentType: null, side: 'front' }, documentStatus, () => ({})),\n} as const;\n","import type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport { observeReady } from '@module/common/vendors/onfido';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type {\n OCRResults,\n} from '@module/frankie-client/clients/OCRClient';\nimport {\n OCRClient,\n OCRStatus,\n} from '@module/frankie-client/clients/OCRClient';\nimport type { Events, OCRModule } from '@module/ocr';\nimport type {\n StatusEvaluators,\n} from '@module/ocr/vendors/common/statusEvaluators';\nimport {\n statusEvaluators,\n} from '@module/ocr/vendors/common/statusEvaluators';\nimport type { OneSdkContext } from '@module/sdk/types';\n\nexport const initialise = defineWrapper<OCRModule>('dummy-ocr', async (\n shared,\n options,\n) => {\n const { frankieClient } = shared;\n const { mountElement, eventHub } = options;\n const idvClient = new IDVClient(frankieClient);\n const ocrClient = new OCRClient(frankieClient);\n try {\n // generate onfido sdk token from backend\n const { entityId, token, vendorParameters } = await idvClient.getToken();\n eventHub.emit('session_data_generated', {\n session: { entityId, token, vendorParameters },\n });\n observeReady('dummy-ocr-modal', eventHub);\n\n // Create a modal container\n const modalContainer = document.createElement('div');\n Object.assign(modalContainer.style, {\n position: 'fixed',\n top: '0',\n left: '0',\n width: '100%',\n height: '100%',\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n });\n modalContainer.className = 'dummy-ocr-modal';\n mountElement.appendChild(modalContainer);\n\n // Create modal content\n const modalContent = document.createElement('div');\n modalContent.style.backgroundColor = '#fff';\n modalContent.style.padding = '200px';\n modalContent.style.borderRadius = '5px';\n modalContainer.appendChild(modalContent);\n\n // Create Run OCR button\n const runOcrButton = document.createElement('button');\n runOcrButton.id = 'run-ocr-button';\n runOcrButton.textContent = 'Run OCR';\n runOcrButton.addEventListener('click', async () => {\n const { oneSdkInstance } = shared;\n await handleComplete(ocrClient, eventHub, oneSdkInstance);\n removeElement(modalContainer, eventHub);\n });\n modalContent.appendChild(runOcrButton);\n\n // Create close button\n const closeButton = document.createElement('button');\n closeButton.id = 'close-button';\n closeButton.textContent = 'Close';\n closeButton.addEventListener('click', () => {\n eventHub.emit('input_required', {\n documentType: null,\n side: 'front',\n }, OCRStatus.INTERRUPTED, () => ({}));\n removeElement(modalContainer, eventHub);\n });\n modalContent.appendChild(closeButton);\n } catch (error) {\n const { code = null, message = '' } = error;\n eventHub.emit('session_data_failed_loading', { code, message });\n }\n return {};\n});\n\nconst handleComplete = async (\n ocrClient: OCRClient,\n eventHub: EventHub<Events>,\n oneSdkInstance: OneSdkContext,\n): Promise<void> => {\n try {\n let response: OCRResults = await ocrClient.attachNewOCRDocument();\n // If waiting_ocr_run is returned, try to rerun\n if (response.documentStatus === OCRStatus.WAITING_OCR_RUN) {\n response = await ocrClient.rerun(response.ocrDocument.documentId);\n }\n const { ocrDocument, documentStatus } = response;\n const evaluateStatus = statusEvaluators[documentStatus] ?? statusEvaluators.default;\n evaluateStatus(({\n ocrDocument,\n documentStatus,\n ocrClient,\n eventHub,\n } as StatusEvaluators));\n\n // Update global state with the latest ocr check outcome\n await oneSdkInstance.individual().search();\n } catch (error) {\n const { message = '' } = error;\n eventHub.emit('error', new OneSDKError('Error from OCR documents submission', { message }));\n }\n};\n\n// remove modal element\nconst removeElement = (\n element: HTMLElement,\n eventHub: EventHub<Events>,\n): void => {\n try {\n element.remove();\n eventHub.emit('session_closed');\n } catch (error) {\n const { type = null, message = '' } = error;\n eventHub.emit('error', new OneSDKError(`Error from vendor SDK 'Onfido'`, {\n type,\n message,\n }));\n }\n};\n"],"names":["install","sdkVersion","loadAsyncAsset","Number","observeReady","mutationClass","eventHub","targetNode","document","querySelector","MutationObserver","mutations","observer","mutation","mutationElement","addedNodes","classList","contains","emit","domElement","disconnect","observe","childList","subtree","statusEvaluators","COMPLETE","ocrDocument","ocrClient","entityId","WAITING_OCR_RUN","OneSDKError","payload","PROVIDER_OFFLINE","default","documentStatus","documentType","side","initialise","shared","options","frankieClient","mountElement","idvClient","token","vendorParameters","getToken","session","modalContainer","createElement","Object","assign","style","position","top","left","width","height","backgroundColor","display","justifyContent","alignItems","className","appendChild","modalContent","padding","borderRadius","runOcrButton","id","textContent","addEventListener","oneSdkInstance","handleComplete","removeElement","closeButton","INTERRUPTED","error","code","message","response","attachNewOCRDocument","rerun","documentId","individual","search","element","remove","type"],"sourceRoot":""}
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[192],{1272:(e,n,t)=>{t.d(n,{g6:()=>c,ai:()=>l,Yv:()=>d});var o=t(4334),r=t(5635),i=t(4527);const c=(e,{eventHub:n,entityId:t})=>{let c=!1;const s=["InternalServerError","skip","OSVersionNotSupported","browserNotSupported"];return{biometrics:{onLog:({type:e})=>{"noAttemps"===e&&(c=!0)},onError:({type:e,payload:i})=>{c?n.emit("detection_failed",{message:null==i?void 0:i.message}):"permissionDenied"===e?n.emit("input_required",{entityId:t},r.Yt.INTERRUPTED):s.includes(e)&&n.emit("error",new o.OneSDKError("Error from vendor SDK 'Incode'",{type:e,payload:i}))}},ocr:{onLog:({type:e,payload:t})=>{["IDNotDetected","nothingHappened","manualCaptureOn","successCapture","attemptFailed","success"].includes(e)?n.emit("info",{message:null==t?void 0:t.message,payload:{type:e}}):"noAttemps"===e&&(c=!0)},onError:({type:e,payload:t})=>{c?n.emit("detection_failed",{message:null==t?void 0:t.message}):"permissionDenied"===e?n.emit("input_required",{documentType:null,side:"front"},i.By.INTERRUPTED,(()=>({}))):s.includes(e)&&n.emit("error",new o.OneSDKError("Error from vendor SDK 'Incode'",{type:e,payload:t}))}}}[e]};var s=function(e,n,t,o){return new(t||(t=Promise))((function(r,i){function c(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o.throw(e))}catch(e){i(e)}}function d(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,s)}d((o=o.apply(e,n||[])).next())}))};const d=(e,n)=>s(void 0,void 0,void 0,(function*(){if("ocr"===e)return yield a("front",Object.assign(Object.assign({},n),{onSuccess:e=>s(void 0,[e],void 0,(function*({skipBackIdCapture:e,typeOfId:t,countryCode:o}){var r,i;(null===(r=null==n?void 0:n.validate)||void 0===r?void 0:r.call(n,{typeOfId:t,countryCode:o}))&&(e?null===(i=null==n?void 0:n.onSuccess)||void 0===i||i.call(n,{}):yield a("back",n))}))}));if("biometrics"===e)return yield a("selfie",n);throw new o.OneSDKError("Unknown purpose",{purpose:e})})),a=(e,n)=>s(void 0,void 0,void 0,(function*(){const{incode:t,token:r,eventHub:i,mountElement:c,onSuccess:d=(()=>({})),onError:a,onLog:u}=n;return new Promise(((n,l)=>{try{t.renderCamera(e,c,{onSuccess:e=>s(void 0,void 0,void 0,(function*(){return d(e),n({})})),onError:e=>(a(e),l(e)),onLog:e=>{u(e)},token:r,numberOfTries:3})}catch(e){const{message:n=""}=e;return i.emit("error",new o.OneSDKError("Error from vendor SDK 'Incode'",{message:n})),l(e)}}))}));var u=function(e,n,t,o){return new(t||(t=Promise))((function(r,i){function c(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o.throw(e))}catch(e){i(e)}}function d(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,s)}d((o=o.apply(e,n||[])).next())}))};const l=e=>u(void 0,[e],void 0,(function*({apiURL:e,sdkVersion:n="1.69.1"}){return yield(0,o.loadAsyncAsset)(`https://sdk.incode.com/sdk/onBoarding-${n}.js`),{incode:yield v({apiURL:`${e}/0/`})}})),v=e=>u(void 0,[e],void 0,(function*({apiURL:e}){const n=window.OnBoarding.create({apiURL:e});return yield n.warmup(),n}))},6164:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>l});var o=t(591),r=t(5635),i=t(4334),c=t(5473),s=t(1272),d=t(9188),a=t(6151),u=t(4576);const l=(0,c.f)("incode",((e,n)=>{return t=void 0,c=void 0,m=function*(){const{frankieClient:t,recipe:{ocr:{documents:c,provider:l}},localEventHub:m}=e,{mountElement:p,eventHub:y}=n,f=new d.Ns(t),g=yield(0,a.j)(f,y);if(!g)return void m.emit("loading",!1,{message:"Failed while loading session for vendor 'Incode'"});const{vendorParameters:w}=g;try{const{apiURL:t,token:i,interviewId:d}=w,{incode:a}=yield(0,s.ai)({apiURL:t,sdkVersion:"incode"===l.name&&l.sdkVersion}),{onLog:m,onError:f}=(0,s.g6)("ocr",{eventHub:y}),g={incode:a,token:{token:i,interviewId:d},eventHub:y,mountElement:p,onError:f,onLog:m},E=(0,s.Yv)("ocr",Object.assign(Object.assign({},g),{validate:({typeOfId:e,countryCode:n})=>{var t;y.emit("info",{message:"onSuccess",payload:{typeOfId:e,countryCode:n}});const o=e=>{y.emit("input_required",{documentType:e,side:"front"},r.By.DOCUMENTS_INVALID,(()=>({})))};if(!c)return!0;const i=c.find((({type:n})=>n===(v[e]||e)));return i?!(null==i?void 0:i.countries)||!!(null===(t=null==i?void 0:i.countries)||void 0===t?void 0:t.includes(n))||(o(i.type),!1):(o(c[0].type),!1)},onSuccess:()=>{y.emit("session_closed"),(0,u.K)(e,Object.assign(Object.assign({},n),{attachReviewScreen:!(0,o.T)("modules.ocr.containsReviewScreen.incode")}))}}));y.emit("ready",{domElement:p}),y.emit("loading",!1,{message:"Vendor 'Incode' screen has loaded"}),yield E}catch(e){const{type:n=null,message:t=""}=e;y.emit("error",new i.OneSDKError("Error from vendor SDK 'Incode'",{type:n,message:t})),y.emit("loading",!1,{message:"Failed while executing vendor 'Incode'"})}return{}},new((l=void 0)||(l=Promise))((function(e,n){function o(e){try{i(m.next(e))}catch(e){n(e)}}function r(e){try{i(m.throw(e))}catch(e){n(e)}}function i(n){var t;n.done?e(n.value):(t=n.value,t instanceof l?t:new l((function(e){e(t)}))).then(o,r)}i((m=m.apply(t,c||[])).next())}));var t,c,l,m})),v={Passport:"PASSPORT",DriversLicense:"DRIVERS_LICENCE",MedicalCard:"NATIONAL_HEALTH_ID"}},6151:(e,n,t)=>{t.d(n,{j:()=>o});const o=(e,n)=>{return t=void 0,o=void 0,i=function*(){try{const{entityId:t,token:o,vendorParameters:r}=yield e.getToken();return n.emit("session_data_generated",{session:{entityId:t,token:o,vendorParameters:r}}),{entityId:t,token:o,vendorParameters:r}}catch(e){const{code:t=null,message:o=""}=e;return n.emit("session_data_failed_loading",{code:t,message:o}),null}},new((r=void 0)||(r=Promise))((function(e,n){function c(e){try{d(i.next(e))}catch(e){n(e)}}function s(e){try{d(i.throw(e))}catch(e){n(e)}}function d(n){var t;n.done?e(n.value):(t=n.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,s)}d((i=i.apply(t,o||[])).next())}));var t,o,r,i}},4576:(e,n,t)=>{t.d(n,{K:()=>a});var o=t(591),r=t(4334),i=t(846),c=t(325),s=t(9255),d=t(4527);const a=(e,n)=>{return t=void 0,a=void 0,l=function*(){var t,a;const{frankieClient:u,oneSdkInstance:l,localEventHub:v}=e;try{const m=new c.UZ(u);v.emit("loading",!0,{message:"Retrieving IDV results"});let p=yield m.attachNewOCRDocument();p.documentStatus===d.By.WAITING_OCR_RUN&&(p=yield m.rerun(p.ocrDocument.documentId)),yield l.individual().search();const{ocrDocument:y,documentStatus:f}=p,g=null!==(t=s.p[f])&&void 0!==t?t:s.p.default,w=(0,r.mkEventHub)(),E=n.mountElement,I=null!==(a=e.recipe.ocr.provideReviewScreen)&&void 0!==a?a:(0,o.T)("recipeDefaults.ocr.provideReviewScreen");w.on("results",(0,i.n)({localEventHub:v,mountElement:E,oneSdkInstance:l,attachForm:I&&n.attachReviewScreen})),w.map(["input_required","error"],v),g({ocrDocument:y,documentStatus:f,ocrClient:m,eventHub:w})}catch(e){v.emit("error",new r.OneSDKError("Failed submitting and retrieving OCR results",e)),v.emit("loading",!1,{message:"Failed retrieving OCR results"})}},new((u=void 0)||(u=Promise))((function(e,n){function o(e){try{i(l.next(e))}catch(e){n(e)}}function r(e){try{i(l.throw(e))}catch(e){n(e)}}function i(n){var t;n.done?e(n.value):(t=n.value,t instanceof u?t:new u((function(e){e(t)}))).then(o,r)}i((l=l.apply(t,a||[])).next())}));var t,a,u,l}},9255:(e,n,t)=>{t.d(n,{p:()=>i});var o=t(5635),r=t(4334);const i={[o.By.COMPLETE]:({ocrDocument:e,ocrClient:n,eventHub:t})=>t.emit("results",{document:e,entityId:n.entityId}),[o.By.WAITING_OCR_RUN]:({eventHub:e})=>{e.emit("error",new r.OneSDKError(`Two attempts to get OCR results failed with an unresolved "${o.By.WAITING_OCR_RUN}". This is a system failure.`,{payload:null}))},[o.By.PROVIDER_OFFLINE]:({eventHub:e})=>e.emit("error",new r.OneSDKError(`Provider is offline. Either switch providers and restart or skip OCR temporarily. Status ${o.By.PROVIDER_OFFLINE}`,{payload:null})),default:({documentStatus:e,eventHub:n})=>n.emit("input_required",{documentType:null,side:"front"},e,(()=>({})))}}}]);
2
- //# sourceMappingURL=ocr-incode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ocr-incode.js","mappings":"qKAmBO,MAAMA,EAAsB,CACjCC,GACEC,WACAC,eAQF,IAAIC,GAAiB,EAGrB,MAAMC,EAAgB,CACpB,sBACA,OACA,wBACA,uBA2GF,MAAO,CAAEC,WAnGU,CAMjBC,MAAO,EACHC,WAEW,cAATA,IAGFJ,GAAiB,EACnB,EAOFK,QAAS,EACLD,OAAME,cAGJN,EACFF,EAASS,KAAK,mBAAoB,CAChCC,QAASF,aAAO,EAAPA,EAASE,UAEF,qBAATJ,EACTN,EAASS,KAAK,iBAAkB,CAAER,YAAY,KAAUU,aAC/CR,EAAcS,SAASN,IAChCN,EAASS,KAAK,QAAS,IAAI,EAAAI,YAAY,iCAAkC,CACvEP,OACAE,YAEJ,GAgEiBM,IAvDT,CAMVT,MAAO,EACHC,OAAME,cAEJ,CACF,gBACA,kBACA,kBACA,iBACA,gBACA,WACAI,SAASN,GACTN,EAASS,KAAK,OAAQ,CACpBC,QAASF,aAAO,EAAPA,EAASE,QAClBF,QAAS,CAAEF,UAEK,cAATA,IAGTJ,GAAiB,EACnB,EAOFK,QAAS,EACLD,OAAME,cAGJN,EACFF,EAASS,KAAK,mBAAoB,CAChCC,QAASF,aAAO,EAAPA,EAASE,UAEF,qBAATJ,EACTN,EAASS,KAAK,iBACZ,CACEM,aAAc,KACdC,KAAM,SACL,KAAUL,aAAa,KAAM,CAAG,KAC5BR,EAAcS,SAASN,IAChCN,EAASS,KAAK,QAAS,IAAI,EAAAI,YAAY,iCAAkC,CACvEP,OACAE,YAEJ,IAIuBT,EAAO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C,EAAUI,MAAMhD,EAASiD,YAAYC,mBAGlDP,EAAeQ,aAAaC,SAClC,MAAM,YAAEH,EAAW,eAAEH,GAAmB9C,EAClCqD,EAAiD,QAAhC,MAAiBP,UAAe,QAAI,IAAiBQ,QAGtEC,GAAkB,IAAAC,cAClB5D,EAAemB,EAAQnB,aACvB6D,EACiC,QAArC,EAAA3C,EAAOG,OAAOnC,IAAI4E,2BAAmB,SAAI,OAAK,0CAEhDH,EAAgBI,GACd,WACA,OAAuB,CACrBvC,gBACAxB,eACA+C,iBAGAiB,WAAYH,GAA6B1C,EAAQkB,sBAGrDsB,EAAgBM,IAAI,CAAC,iBAAkB,SAAUzC,GAEjDiC,EAAe,CACbJ,cACAH,iBACAF,YACA5E,SAAUuF,GAEd,CAAE,MAAOO,GACP1C,EAAc3C,KAAK,QAAS,IAAI,EAAAI,YAAY,+CAAgDiF,IAC5F1C,EAAc3C,KAAK,WAAW,EAAO,CAAEC,QAAS,iCAClD,CACF,E,YA7CmB,K,6QA6ClB,C,0DCpEM,MAAMqF,EAAmB,CAC9B,CAAC,KAAUC,UAAW,EAAGf,cAAaL,YAAW5E,cAC/CA,EAASS,KAAK,UAAW,CAAEwF,SAAUhB,EAAahF,SAAU2E,EAAU3E,WACxE,CAAC,KAAU8E,iBAAkB,EAAG/E,eAC9BA,EAASS,KACP,QACA,IAAI,EAAAI,YACF,8DAA8D,KAAUkE,8CACxE,CAAEvE,QAAS,OAEd,EAEH,CAAC,KAAU0F,kBAAmB,EAAGlG,cAC/BA,EAASS,KACP,QACA,IAAI,EAAAI,YACF,4FAA4F,KAAUqF,mBACtG,CAAE1F,QAAS,QAGjB8E,QAAS,EAAGR,iBAAgB9E,cAC1BA,EAASS,KAAK,iBAAkB,CAAEM,aAAc,KAAMC,KAAM,SAAW8D,GAAgB,KAAM,CAAG,K","sources":["webpack://OneSdk/./modules/common/vendors/incode/createEventHandlers.ts","webpack://OneSdk/./modules/common/vendors/incode/startCamera.ts","webpack://OneSdk/./modules/common/vendors/incode/index.ts","webpack://OneSdk/./modules/ocr/vendors/Incode/index.ts","webpack://OneSdk/./modules/ocr/vendors/common/createSession.ts","webpack://OneSdk/./modules/ocr/vendors/common/initProcess.ts","webpack://OneSdk/./modules/ocr/vendors/common/statusEvaluators.ts"],"sourcesContent":["import { IDVStatus } from '@frankieone/one-sdk';\nimport type { Events as BiometricsEvents } from '@module/biometrics';\nimport type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport type {\n IncodeResponse,\n} from '@module/common/vendors/incode/onBoarding.types';\nimport type { Events as OcrEvents } from '@module/ocr';\nimport { OCRStatus } from '@module/types';\n\n/**\n * Creates event handlers for a given EventHub.\n *\n * @param {'ocr' | 'biometrics'} module - The module type for which to create event handlers.\n * @param {object} options - The options for creating event handlers.\n * @param {EventHub<OcrEvents | BiometricsEvents>} options.eventHub - The EventHub for handling events.\n * @param {string} [options.entityId] - An optional entityId parameter.\n * @returns {object} - The event handlers for the specified module ('biometrics' or 'ocr').\n **/\nexport const createEventHandlers = (\n module: 'ocr' | 'biometrics', {\n eventHub,\n entityId,\n }: {\n eventHub: EventHub<OcrEvents | BiometricsEvents>;\n entityId?: string;\n },\n) => {\n\n // A flag indicating whether the event handler should emit error event\n let noAttemptsFlag = false;\n\n // user or environment issues that are not related to a specific workflow\n const genericErrors = [\n 'InternalServerError',\n 'skip',\n 'OSVersionNotSupported',\n 'browserNotSupported',\n ];\n\n /**\n * Event handlers for biometrics-related events.\n *\n * @namespace biometrics\n */\n const biometrics = {\n /**\n * Handles log events for biometrics.\n *\n * @param {IncodeResponse} response - The response object from Incode.\n */\n onLog: (\n { type }: IncodeResponse,\n ): void => {\n if (type === 'noAttemps') { // not a typo, 'noAttemps' comes from Incode SDK\n // we would like to emit this scenario along with an Incode error event\n // update the error state so that a corresponding error can be emitted\n noAttemptsFlag = true;\n }\n },\n /**\n * Handles error events for biometrics.\n *\n * @param {IncodeResponse} response - The response object from Incode.\n */\n onError: (\n { type, payload }: IncodeResponse,\n ): void => {\n // check if error state is being flagged in the log already\n if (noAttemptsFlag) {\n eventHub.emit('detection_failed', {\n message: payload?.message,\n });\n } else if (type === 'permissionDenied') {\n eventHub.emit('input_required', { entityId }, IDVStatus.INTERRUPTED);\n } else if (genericErrors.includes(type)) {\n eventHub.emit('error', new OneSDKError(`Error from vendor SDK 'Incode'`, {\n type,\n payload,\n }));\n }\n },\n };\n\n /**\n * Event handlers for OCR-related events.\n *\n * @namespace ocr\n */\n const ocr = {\n /**\n * Handles log events for OCR.\n *\n * @param {IncodeResponse} response - The response object from Incode.\n */\n onLog: (\n { type, payload }: IncodeResponse,\n ): void => {\n if ([\n 'IDNotDetected',\n 'nothingHappened',\n 'manualCaptureOn',\n 'successCapture',\n 'attemptFailed',\n 'success',\n ].includes(type)) {\n eventHub.emit('info', {\n message: payload?.message,\n payload: { type },\n });\n } else if (type === 'noAttemps') { // not a typo, 'noAttemps' comes from Incode SDK\n // we would like to emit this scenario along with an Incode error event\n // update the error state so that a corresponding error can be emitted\n noAttemptsFlag = true;\n }\n },\n /**\n * Handles error events for OCR.\n *\n * @param {IncodeResponse} response - The response object from Incode.\n */\n onError: (\n { type, payload }: IncodeResponse,\n ): void => {\n // check if error state is being flagged in the log already\n if (noAttemptsFlag) {\n eventHub.emit('detection_failed', {\n message: payload?.message,\n });\n } else if (type === 'permissionDenied') {\n eventHub.emit('input_required',\n {\n documentType: null,\n side: 'front',\n }, OCRStatus.INTERRUPTED, () => ({}));\n } else if (genericErrors.includes(type)) {\n eventHub.emit('error', new OneSDKError(`Error from vendor SDK 'Incode'`, {\n type,\n payload,\n }));\n }\n },\n };\n\n return { biometrics, ocr }[module];\n};\n","import type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport type {\n IncodeInstance,\n IncodeResponse,\n IncodeSuccessResponse,\n} from '@module/common/vendors/incode/onBoarding.types';\nimport type { Events } from '@module/ocr';\n\ntype CameraProps = {\n incode: IncodeInstance;\n token: { token: string; interviewId: string };\n eventHub: EventHub<Events>;\n mountElement: HTMLElement;\n onSuccess?: (response: Partial<IncodeSuccessResponse>) => void;\n onError: (response: unknown, payload?: unknown) => void;\n onLog: (response: unknown) => void;\n validate?: ({\n typeOfId,\n countryCode,\n }: Partial<IncodeSuccessResponse>) => boolean;\n};\n\nexport const startCamera = async (\n purpose: 'biometrics' | 'ocr',\n cameraProps: CameraProps,\n) => {\n if (purpose === 'ocr') {\n return await renderCamera('front', {\n ...cameraProps,\n onSuccess: async ({\n skipBackIdCapture,\n typeOfId,\n countryCode,\n }: IncodeSuccessResponse,\n ): Promise<void> => {\n if (!cameraProps?.validate?.({ typeOfId, countryCode })) return;\n // when Incode determines it needs to capture the back of document\n if (!skipBackIdCapture) {\n await renderCamera('back', cameraProps);\n } else {\n cameraProps?.onSuccess?.({});\n }\n },\n });\n } else if (purpose === 'biometrics') {\n return await renderCamera('selfie', cameraProps);\n }\n throw new OneSDKError('Unknown purpose', { purpose });\n};\n\nconst renderCamera = async (\n type: 'front' | 'back' | 'selfie',\n cameraProps: CameraProps,\n) => {\n const {\n incode,\n token,\n eventHub,\n mountElement,\n onSuccess = () => ({}),\n onError,\n onLog,\n } = cameraProps;\n return new Promise((resolve, reject): void => {\n try {\n incode.renderCamera(type, mountElement, {\n onSuccess: async (response: IncodeSuccessResponse): Promise<void> => {\n onSuccess(response);\n return resolve({});\n },\n onError: (error: IncodeResponse) => {\n onError(error);\n return reject(error);\n },\n onLog: (log: IncodeResponse) => {\n onLog(log);\n },\n token,\n numberOfTries: 3,\n });\n } catch (error) {\n const { message = '' } = error;\n eventHub.emit('error', new OneSDKError(`Error from vendor SDK 'Incode'`, { message }));\n return reject(error);\n }\n });\n};\n","import { loadAsyncAsset } from '@module/common';\nimport type {\n IncodeConfig,\n IncodeInstance,\n} from '@module/common/vendors/incode/onBoarding.types';\n\nexport { createEventHandlers } from './createEventHandlers';\nexport { startCamera } from './startCamera';\nexport * from './onBoarding.types';\n\nexport const install = async ({\n apiURL,\n sdkVersion = '1.69.1',\n}: IncodeConfig & { sdkVersion?: string }): Promise<{\n incode: IncodeInstance;\n}> => {\n // install Incode script from CDN\n await loadAsyncAsset(`https://sdk.incode.com/sdk/onBoarding-${sdkVersion}.js`);\n // instructed by vendor to add `/0/` to the end of the apiURL\n const incode = await createInstance({ apiURL: `${apiURL}/0/` });\n return { incode };\n};\n\nconst createInstance = async ({\n apiURL,\n}: IncodeConfig): Promise<IncodeInstance> => {\n const incode = window.OnBoarding.create({ apiURL });\n await incode.warmup();\n return incode;\n};\n","import { feat } from '@feature-flags';\nimport { OCRStatus } from '@frankieone/one-sdk';\nimport { OneSDKError } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport type { DocumentType } from '@module/common/shared/models/SupportingDocument';\nimport type { IncodeSession } from '@module/common/vendors/incode';\nimport {\n createEventHandlers,\n install,\n startCamera,\n} from '@module/common/vendors/incode';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { OCRModule } from '@module/ocr';\nimport { createSession } from '@module/ocr/vendors/common/createSession';\nimport { initProcessAndEvaluateResults } from '@module/ocr/vendors/common/initProcess';\n\nexport const initialise = defineWrapper<OCRModule>(\n 'incode',\n async (shared, options) => {\n const {\n frankieClient,\n recipe: {\n ocr: { documents, provider },\n },\n localEventHub,\n } = shared;\n const { mountElement, eventHub } = options;\n const idvClient = new IDVClient(frankieClient);\n\n // generate session token from backend\n const idvSession = await createSession<IncodeSession>(idvClient, eventHub);\n // terminate initialising if session failed\n if (!idvSession) {\n localEventHub.emit('loading', false, {\n message: `Failed while loading session for vendor 'Incode'`,\n });\n return;\n }\n\n const { vendorParameters } = idvSession;\n\n try {\n // initialise Incode with credentials\n const { apiURL, token, interviewId } = vendorParameters;\n const { incode } = await install({\n apiURL,\n sdkVersion: provider.name === 'incode' && provider.sdkVersion,\n });\n\n const { onLog, onError } = createEventHandlers('ocr', { eventHub });\n const cameraProps = {\n incode,\n token: { token, interviewId },\n eventHub,\n mountElement,\n onError,\n onLog,\n };\n // turn on camera to capture the front of document\n const startCameraPromise = startCamera('ocr', {\n ...cameraProps,\n validate: ({ typeOfId, countryCode }): boolean => {\n eventHub.emit('info', {\n message: 'onSuccess',\n payload: { typeOfId, countryCode },\n });\n const emitInputRequired = (documentType: DocumentType): void => {\n eventHub.emit(\n 'input_required',\n {\n documentType,\n side: 'front',\n },\n OCRStatus.DOCUMENTS_INVALID,\n () => ({}),\n );\n };\n\n // Check if documents config is given,\n if (!documents) {\n return true; // No documents, validation passes\n }\n\n // Find the accepted document type\n const acceptedDocType = documents.find(\n ({ type }) => type === (incodeDocumentsDict[typeOfId] || typeOfId),\n );\n\n // If no accepted document is matched, validation fails\n if (!acceptedDocType) {\n emitInputRequired(documents[0].type);\n return false;\n }\n\n // If the accepted document does not specify countries, validation passes\n if (!acceptedDocType?.countries) {\n return true;\n }\n\n // If the accepted document specifies countries\n // and the country code is matched, validation passes\n if (acceptedDocType?.countries?.includes(countryCode)) {\n return true;\n }\n\n // validation fails in other cases\n emitInputRequired(acceptedDocType.type);\n return false;\n },\n onSuccess: () => {\n eventHub.emit('session_closed');\n\n initProcessAndEvaluateResults(shared, {\n ...options,\n attachReviewScreen: !feat(\n 'modules.ocr.containsReviewScreen.incode',\n ),\n });\n },\n });\n eventHub.emit('ready', { domElement: mountElement });\n eventHub.emit('loading', false, {\n message: `Vendor 'Incode' screen has loaded`,\n });\n await startCameraPromise;\n } catch (error) {\n const { type = null, message = '' } = error;\n eventHub.emit(\n 'error',\n new OneSDKError(`Error from vendor SDK 'Incode'`, {\n type,\n message,\n }),\n );\n eventHub.emit('loading', false, {\n message: `Failed while executing vendor 'Incode'`,\n });\n }\n\n return {};\n },\n);\n\nconst incodeDocumentsDict = {\n Passport: 'PASSPORT',\n DriversLicense: 'DRIVERS_LICENCE',\n MedicalCard: 'NATIONAL_HEALTH_ID',\n};\n","import type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { Events } from '@module/ocr/events';\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 { feat } from '@feature-flags';\nimport { OneSDKError, mkEventHub } from '@module/common';\nimport type { WrapperParameters } from '@module/common/modules/defineModule';\nimport {\n useFormToReviewResults,\n} from '@module/common/vendors/form/useForm';\nimport type { OCRResults } from '@module/frankie-client/clients/OCRClient';\nimport { OCRClient } from '@module/frankie-client/clients/OCRClient';\nimport type { Events, OCRModule } from '@module/ocr';\nimport type {\n StatusEvaluators,\n} from '@module/ocr/vendors/common/statusEvaluators';\nimport { statusEvaluators } from '@module/ocr/vendors/common/statusEvaluators';\nimport { OCRStatus } from '@module/types';\n\ntype Shared = WrapperParameters<OCRModule>[0];\ntype Options = WrapperParameters<OCRModule>[1] & {\n /** Each vendor wrapper needs to flag if their underlying vendor UI already contains a review screen.\n * If it doesn't provide one, we ALWAYS flag that in 'attachReviewScreen' as true.\n * This value can be manually overriden by recipe configuration (ocr.provideReviewScreen) */\n attachReviewScreen: boolean;\n};\n/**\n * This function will\n * 1) Trigger the OCR processing\n * 2) Fetch the updated individual details\n * 3) Evaluate the OCR status to trigger the appropriate event\n * 4) Initialise the Form for manual review, if required\n *\n * It will also emit loading events at the start and end of the process, as well as between long lasting steps\n * @throws This function doesn't throw exceptions, only error events\n * @param shared\n * @param options\n */\nexport const initProcessAndEvaluateResults = async (\n shared: Shared,\n options: Options,\n): Promise<void> => {\n const { frankieClient, oneSdkInstance, localEventHub } = shared;\n try {\n const ocrClient = new OCRClient(frankieClient);\n\n localEventHub.emit('loading', true, { message: 'Retrieving IDV results' });\n let response: OCRResults = await ocrClient.attachNewOCRDocument();\n // If waiting_ocr_run is returned, try to rerun\n if (response.documentStatus === OCRStatus.WAITING_OCR_RUN) {\n response = await ocrClient.rerun(response.ocrDocument.documentId);\n }\n // Update global state with the latest ocr check outcome\n await oneSdkInstance.individual().search();\n const { ocrDocument, documentStatus } = response;\n const evaluateStatus = statusEvaluators[documentStatus] ?? statusEvaluators.default;\n\n // When receiving results event, initialise Form for user manual review\n const privateEventHub = mkEventHub<Events>();\n const mountElement = options.mountElement;\n const recipeProvideReviewScreen =\n shared.recipe.ocr.provideReviewScreen ?? feat('recipeDefaults.ocr.provideReviewScreen');\n\n privateEventHub.on(\n 'results',\n useFormToReviewResults({\n localEventHub,\n mountElement,\n oneSdkInstance,\n // Based on recipe configuration and if the vendor options determine\n // if Form should be attached\n attachForm: recipeProvideReviewScreen && options.attachReviewScreen,\n }),\n );\n privateEventHub.map(['input_required', 'error'], localEventHub);\n\n evaluateStatus({\n ocrDocument,\n documentStatus,\n ocrClient,\n eventHub: privateEventHub,\n } as StatusEvaluators);\n } catch (e) {\n localEventHub.emit('error', new OneSDKError('Failed submitting and retrieving OCR results', e));\n localEventHub.emit('loading', false, { message: 'Failed retrieving OCR results' });\n }\n};\n","import { OCRStatus } from '@frankieone/one-sdk';\nimport type { EventHub} from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport type { Document } from '@module/common/shared/models/Document';\nimport type { OCRClient } from '@module/frankie-client/clients/OCRClient';\nimport type { Events } from '@module/ocr';\n\nexport interface StatusEvaluators {\n ocrDocument?: Document;\n documentStatus?: OCRStatus;\n ocrClient?: OCRClient;\n eventHub: EventHub<Events>;\n}\n\nexport const statusEvaluators = {\n [OCRStatus.COMPLETE]: ({ ocrDocument, ocrClient, eventHub }: StatusEvaluators) =>\n eventHub.emit('results', { document: ocrDocument, entityId: ocrClient.entityId }),\n [OCRStatus.WAITING_OCR_RUN]: ({ eventHub }: StatusEvaluators) => {\n eventHub.emit(\n 'error',\n new OneSDKError(\n `Two attempts to get OCR results failed with an unresolved \"${OCRStatus.WAITING_OCR_RUN}\". This is a system failure.`,\n { payload: null },\n ),\n );\n },\n [OCRStatus.PROVIDER_OFFLINE]: ({ eventHub }: StatusEvaluators) =>\n eventHub.emit(\n 'error',\n new OneSDKError(\n `Provider is offline. Either switch providers and restart or skip OCR temporarily. Status ${OCRStatus.PROVIDER_OFFLINE}`,\n { payload: null },\n ),\n ),\n default: ({ documentStatus, eventHub }: StatusEvaluators) =>\n eventHub.emit('input_required', { documentType: null, side: 'front' }, documentStatus, () => ({})),\n} as const;\n"],"names":["createEventHandlers","module","eventHub","entityId","noAttemptsFlag","genericErrors","biometrics","onLog","type","onError","payload","emit","message","INTERRUPTED","includes","OneSDKError","ocr","documentType","side","startCamera","purpose","cameraProps","renderCamera","onSuccess","skipBackIdCapture","typeOfId","countryCode","validate","incode","token","mountElement","Promise","resolve","reject","response","error","log","numberOfTries","install","apiURL","sdkVersion","loadAsyncAsset","createInstance","window","OnBoarding","create","warmup","initialise","shared","options","frankieClient","recipe","documents","provider","localEventHub","idvClient","idvSession","vendorParameters","interviewId","name","startCameraPromise","emitInputRequired","DOCUMENTS_INVALID","acceptedDocType","find","incodeDocumentsDict","countries","attachReviewScreen","domElement","Passport","DriversLicense","MedicalCard","createSession","getToken","session","code","initProcessAndEvaluateResults","oneSdkInstance","ocrClient","attachNewOCRDocument","documentStatus","WAITING_OCR_RUN","rerun","ocrDocument","documentId","individual","search","evaluateStatus","default","privateEventHub","mkEventHub","recipeProvideReviewScreen","provideReviewScreen","on","attachForm","map","e","statusEvaluators","COMPLETE","document","PROVIDER_OFFLINE"],"sourceRoot":""}
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[849],{4090:(e,n,t)=>{t.d(n,{a:()=>i,g:()=>r});var o=t(4334);const i=e=>{return n=void 0,t=[e],r=function*({sdkVersion:e="12"}){yield(0,o.loadAsyncAsset)(`https://sdk.onfido.com/v${e}`),Number(e)<14&&(yield(0,o.loadAsyncAsset)(`https://sdk.onfido.com/v${e}/style.css`,"style"))},new((i=void 0)||(i=Promise))((function(e,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function d(e){try{c(r.throw(e))}catch(e){o(e)}}function c(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,d)}c((r=r.apply(n,t||[])).next())}));var n,t,i,r},r=(e,n)=>{const t=document.querySelector("body");new MutationObserver(((t,o)=>{var i;for(const r of t){const t=null===(i=r.addedNodes)||void 0===i?void 0:i[0];(null==t?void 0:t.classList.contains(e))&&(n.emit("ready",{domElement:t}),o.disconnect())}})).observe(t,{childList:!0,subtree:!0})}},87:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>p});var o=t(591),i=t(4334),r=t(5473),s=t(1057),d=t(4090),c=t(9188),a=t(325),u=t(6151),l=t(4576),v=function(e,n,t,o){return new(t||(t=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function d(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(s,d)}c((o=o.apply(e,n||[])).next())}))};const m="passport",f="driving_licence",y="national_identity_card",p=(0,r.f)("onfido",((e,n)=>v(void 0,void 0,void 0,(function*(){const{frankieClient:t,recipe:r}=e,{ocr:{provider:p,documents:g}}=r,{mountElement:E,eventHub:w}=n,O=new c.Ns(t),I=yield(0,u.j)(O,w);if(!I)return void w.emit("loading",!1,{message:"Failed while loading session for vendor 'Onfido'"});(0,d.g)("onfido-sdk-ui-Theme-portal",w),w.on("ready",(()=>w.emit("loading",!1,{message:"Vendor 'Onfido' screen has loaded"}))),yield(0,d.a)({sdkVersion:"onfido"===p.name&&p.sdkVersion});const R=function(e){const n={type:"document",options:{documentTypes:{}}};return e?(e.forEach((({type:e,countries:t})=>{e!==s.KG.NATIONAL_HEALTH_ID&&e!==s.KG.NATIONAL_ID||(n.options.documentTypes[y]="ALL"===t[0]||{country:t[0]}),e===s.KG.PASSPORT&&(n.options.documentTypes[m]="ALL"===t[0]||{country:t[0]}),e===s.KG.DRIVERS_LICENCE&&(n.options.documentTypes[f]="ALL"===t[0]||{country:t[0]})})),n):(n.options.documentTypes={[m]:!0,[y]:!0,[f]:!0},n)}(g),{token:b}=I,T=window.Onfido.init(Object.assign(Object.assign({steps:[R]},((e,n)=>({token:e,containerEl:n,useModal:!0,isModalOpen:!0,disableAnalytics:!0,disableAnalyticsCookies:!0}))(b,E)),{customUI:"onfido"===p.name&&p.customUI,onComplete:()=>v(void 0,void 0,void 0,(function*(){yield h(T,{eventHub:w}),(0,l.K)(e,Object.assign(Object.assign({},n),{attachReviewScreen:!(0,o.T)("modules.ocr.containsReviewScreen.onfido")}))})),onError:e=>((e,n)=>v(void 0,void 0,void 0,(function*(){const{type:t=null,message:o=""}=n;w.emit("error",new i.OneSDKError("Error from vendor SDK 'Onfido'",{type:t,message:o})),yield h(e,{eventHub:w,loadingEvent:"Failed while executing vendor 'Onfido'"})})))(T,e),onUserExit:()=>v(void 0,void 0,void 0,(function*(){return(e=>v(void 0,void 0,void 0,(function*(){w.emit("input_required",{documentType:null,side:"front"},a.By.INTERRUPTED,(()=>({}))),yield h(e,{eventHub:w,loadingEvent:"User exited"})})))(T)})),onModalRequestClose:()=>v(void 0,void 0,void 0,(function*(){return(e=>v(void 0,void 0,void 0,(function*(){w.emit("input_required",{documentType:null,side:"front"},a.By.INTERRUPTED,(()=>({}))),yield h(e,{eventHub:w,loadingEvent:"User exited"})})))(T)}))}));return{}})))),h=(e,n)=>v(void 0,void 0,void 0,(function*(){const{eventHub:t,loadingEvent:o}=n;try{yield e.safeTearDown(),t.emit("session_closed")}catch(e){const{type:n=null,message:o=""}=e;t.emit("error",new i.OneSDKError("Error from vendor SDK 'Onfido'",{type:n,message:o}))}finally{o&&t.emit("loading",!1,{message:o})}}))},6151:(e,n,t)=>{t.d(n,{j:()=>o});const o=(e,n)=>{return t=void 0,o=void 0,r=function*(){try{const{entityId:t,token:o,vendorParameters:i}=yield e.getToken();return n.emit("session_data_generated",{session:{entityId:t,token:o,vendorParameters:i}}),{entityId:t,token:o,vendorParameters:i}}catch(e){const{code:t=null,message:o=""}=e;return n.emit("session_data_failed_loading",{code:t,message:o}),null}},new((i=void 0)||(i=Promise))((function(e,n){function s(e){try{c(r.next(e))}catch(e){n(e)}}function d(e){try{c(r.throw(e))}catch(e){n(e)}}function c(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,d)}c((r=r.apply(t,o||[])).next())}));var t,o,i,r}},4576:(e,n,t)=>{t.d(n,{K:()=>a});var o=t(591),i=t(4334),r=t(846),s=t(325),d=t(9255),c=t(4527);const a=(e,n)=>{return t=void 0,a=void 0,l=function*(){var t,a;const{frankieClient:u,oneSdkInstance:l,localEventHub:v}=e;try{const m=new s.UZ(u);v.emit("loading",!0,{message:"Retrieving IDV results"});let f=yield m.attachNewOCRDocument();f.documentStatus===c.By.WAITING_OCR_RUN&&(f=yield m.rerun(f.ocrDocument.documentId)),yield l.individual().search();const{ocrDocument:y,documentStatus:p}=f,h=null!==(t=d.p[p])&&void 0!==t?t:d.p.default,g=(0,i.mkEventHub)(),E=n.mountElement,w=null!==(a=e.recipe.ocr.provideReviewScreen)&&void 0!==a?a:(0,o.T)("recipeDefaults.ocr.provideReviewScreen");g.on("results",(0,r.n)({localEventHub:v,mountElement:E,oneSdkInstance:l,attachForm:w&&n.attachReviewScreen})),g.map(["input_required","error"],v),h({ocrDocument:y,documentStatus:p,ocrClient:m,eventHub:g})}catch(e){v.emit("error",new i.OneSDKError("Failed submitting and retrieving OCR results",e)),v.emit("loading",!1,{message:"Failed retrieving OCR results"})}},new((u=void 0)||(u=Promise))((function(e,n){function o(e){try{r(l.next(e))}catch(e){n(e)}}function i(e){try{r(l.throw(e))}catch(e){n(e)}}function r(n){var t;n.done?e(n.value):(t=n.value,t instanceof u?t:new u((function(e){e(t)}))).then(o,i)}r((l=l.apply(t,a||[])).next())}));var t,a,u,l}},9255:(e,n,t)=>{t.d(n,{p:()=>r});var o=t(5635),i=t(4334);const r={[o.By.COMPLETE]:({ocrDocument:e,ocrClient:n,eventHub:t})=>t.emit("results",{document:e,entityId:n.entityId}),[o.By.WAITING_OCR_RUN]:({eventHub:e})=>{e.emit("error",new i.OneSDKError(`Two attempts to get OCR results failed with an unresolved "${o.By.WAITING_OCR_RUN}". This is a system failure.`,{payload:null}))},[o.By.PROVIDER_OFFLINE]:({eventHub:e})=>e.emit("error",new i.OneSDKError(`Provider is offline. Either switch providers and restart or skip OCR temporarily. Status ${o.By.PROVIDER_OFFLINE}`,{payload:null})),default:({documentStatus:e,eventHub:n})=>n.emit("input_required",{documentType:null,side:"front"},e,(()=>({})))}}}]);
2
- //# sourceMappingURL=ocr-onfido.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ocr-onfido.js","mappings":"sIAIO,MAAMA,EAAU,IAAgD,O,OAAD,E,EAAA,I,EAAA,WAAxC,WAAEC,EAAa,aAErC,IAAAC,gBAAe,2BAA2BD,KAE5CE,OAAOF,GAAc,WACjB,IAAAC,gBAAe,2BAA2BD,cAAwB,SAE5E,E,YAPsE,K,6QAOrE,EAEYG,EAAe,CAC1BC,EACAC,KAGA,MAAMC,EAAaC,SAASC,cAAc,QAEzB,IAAIC,kBAAiB,CACpCC,EACAC,K,MAEA,IAAK,MAAMC,KAAYF,EAAW,CAChC,MAAMG,EAAqC,QAAnB,EAAAD,EAASE,kBAAU,eAAG,IAC1CD,aA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AAIsE,2BAAmB,SAAI,OAAK,0CAEhDH,EAAgB5D,GACd,WACA,OAAuB,CACrB+C,gBACAnD,eACAkD,iBAGAkB,WAAYF,GAA6BxE,EAAQqC,sBAGrDiC,EAAgBK,IAAI,CAAC,iBAAkB,SAAUlB,GAEjDW,EAAe,CACbJ,cACAH,iBACAH,YACA/E,SAAU2F,GAEd,CAAE,MAAOM,GACPnB,EAAclE,KAAK,QAAS,IAAI,EAAAiD,YAAY,+CAAgDoC,IAC5FnB,EAAclE,KAAK,WAAW,EAAO,CAAEkB,QAAS,iCAClD,CACF,E,YA7CmB,K,6QA6ClB,C,0DCpEM,MAAMoE,EAAmB,CAC9B,CAAC,KAAUC,UAAW,EAAGd,cAAaN,YAAW/E,cAC/CA,EAASY,KAAK,UAAW,CAAEV,SAAUmF,EAAad,SAAUQ,EAAUR,WACxE,CAAC,KAAUY,iBAAkB,EAAGnF,eAC9BA,EAASY,KACP,QACA,IAAI,EAAAiD,YACF,8DAA8D,KAAUsB,8CACxE,CAAEiB,QAAS,OAEd,EAEH,CAAC,KAAUC,kBAAmB,EAAGrG,cAC/BA,EAASY,KACP,QACA,IAAI,EAAAiD,YACF,4FAA4F,KAAUwC,mBACtG,CAAED,QAAS,QAGjBV,QAAS,EAAGR,iBAAgBlF,cAC1BA,EAASY,KAAK,iBAAkB,CAAEoD,aAAc,KAAMC,KAAM,SAAWiB,GAAgB,KAAM,CAAG,K","sources":["webpack://OneSdk/./modules/common/vendors/onfido/index.ts","webpack://OneSdk/./modules/ocr/vendors/Onfido/index.ts","webpack://OneSdk/./modules/ocr/vendors/common/createSession.ts","webpack://OneSdk/./modules/ocr/vendors/common/initProcess.ts","webpack://OneSdk/./modules/ocr/vendors/common/statusEvaluators.ts"],"sourcesContent":["import type { Events as BiometricsEvents } from '@module/biometrics';\nimport { type EventHub, loadAsyncAsset } from '@module/common';\nimport type { Events as OcrEvents } from '@module/ocr';\n\nexport const install = async ({ sdkVersion = '12' }): Promise<void> => {\n // install Onfido script from CDN\n await loadAsyncAsset(`https://sdk.onfido.com/v${sdkVersion}`);\n // note that from version 14 onwards, a separate stylesheet is no longer required as it will be included with the default library.\n if (Number(sdkVersion) < 14 && process.env.NODE_ENV !== 'test') {\n await loadAsyncAsset(`https://sdk.onfido.com/v${sdkVersion}/style.css`, 'style');\n }\n};\n\nexport const observeReady = (\n mutationClass: string,\n eventHub: EventHub<BiometricsEvents | OcrEvents>,\n): 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(mutationClass)) {\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","import { feat } from '@feature-flags';\nimport type { EventHub } from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport { DocumentType } from '@module/common/shared/models/SupportingDocument';\nimport { install, observeReady } from '@module/common/vendors/onfido';\nimport type {\n SdkError,\n SdkHandle,\n SdkOptions,\n StepDefinition,\n} from '@module/common/vendors/onfido/onfido.types';\nimport { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport { OCRStatus } from '@module/frankie-client/clients/OCRClient';\nimport type { Events, OCRModule, OCRRecipeOptions } from '@module/ocr';\nimport { createSession } from '@module/ocr/vendors/common/createSession';\nimport { initProcessAndEvaluateResults } from '@module/ocr/vendors/common/initProcess';\n\nconst ONFIDO_ACCEPTABLE_DOCUMENTS = {\n Passport: 'passport',\n DriversLicense: 'driving_licence',\n Medicare: 'national_identity_card',\n};\n\nexport const initialise = defineWrapper<OCRModule>(\n 'onfido',\n async (shared, options) => {\n const { frankieClient, recipe } = shared;\n const {\n ocr: { provider, documents },\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 initialise if session failed\n if (!idvSession) {\n eventHub.emit('loading', false, {\n message: `Failed while loading session for vendor 'Onfido'`,\n });\n return;\n }\n\n observeReady('onfido-sdk-ui-Theme-portal', eventHub);\n eventHub.on('ready', () =>\n eventHub.emit('loading', false, {\n message: `Vendor 'Onfido' screen has loaded`,\n }),\n );\n await install({\n sdkVersion: provider.name === 'onfido' && provider.sdkVersion,\n });\n\n const steps: StepDefinition = declaringSteps(documents);\n\n // initialise onfido instance\n const { token } = idvSession;\n const Onfido = window.Onfido;\n\n const ONFIDO_OPTIONS_PROPS = (\n token: string,\n mountElement: HTMLElement,\n ): Partial<SdkOptions> => {\n return {\n token,\n containerEl: mountElement,\n useModal: true,\n isModalOpen: true,\n disableAnalytics: true,\n disableAnalyticsCookies: true,\n };\n };\n\n const onError = async (instance: SdkHandle, error: SdkError) => {\n const { type = null, message = '' } = error;\n eventHub.emit(\n 'error',\n new OneSDKError(`Error from vendor SDK 'Onfido'`, {\n type,\n message,\n }),\n );\n await removeVendorSdk(instance, {\n eventHub,\n loadingEvent: `Failed while executing vendor 'Onfido'`,\n });\n };\n\n const onUserExit = async (instance: SdkHandle) => {\n // When user has not completed the process and exited it, we emit input_required event\n // This will trigger Onfido init modal again (see event listener for input_required at mount method)\n eventHub.emit(\n 'input_required',\n {\n documentType: null,\n side: 'front',\n },\n OCRStatus.INTERRUPTED,\n () => ({}),\n );\n await removeVendorSdk(instance, {\n eventHub,\n loadingEvent: 'User exited',\n });\n };\n\n const onModalRequestClose = async (instance: SdkHandle) => {\n // When user has not completed the process and exited it, we emit input_required event\n // This will trigger Onfido init modal again (see event listener for input_required at mount method)\n eventHub.emit(\n 'input_required',\n {\n documentType: null,\n side: 'front',\n },\n OCRStatus.INTERRUPTED,\n () => ({}),\n );\n await removeVendorSdk(instance, {\n eventHub,\n loadingEvent: 'User exited',\n });\n };\n\n const instance: SdkHandle = Onfido.init({\n steps: [steps],\n ...ONFIDO_OPTIONS_PROPS(token, mountElement),\n customUI: provider.name === 'onfido' && provider.customUI,\n onComplete: async (): Promise<void> => {\n await removeVendorSdk(instance, { eventHub });\n\n initProcessAndEvaluateResults(shared, {\n ...options,\n attachReviewScreen: !feat('modules.ocr.containsReviewScreen.onfido'),\n });\n },\n onError: (error: SdkError) => onError(instance, error),\n onUserExit: async (): Promise<void> => onUserExit(instance),\n onModalRequestClose: async (): Promise<void> =>\n onModalRequestClose(instance),\n });\n\n return {};\n },\n);\n\n// destroy onfido instance\nconst removeVendorSdk = async (\n instance: SdkHandle,\n opts: { eventHub: EventHub<Events>; loadingEvent?: string },\n): Promise<void> => {\n const { eventHub, loadingEvent } = opts;\n try {\n await instance.safeTearDown();\n eventHub.emit('session_closed');\n } catch (error) {\n const { type = null, message = '' } = error;\n eventHub.emit(\n 'error',\n new OneSDKError(`Error from vendor SDK 'Onfido'`, {\n type,\n message,\n }),\n );\n } finally {\n if (loadingEvent)\n eventHub.emit('loading', false, { message: loadingEvent });\n }\n};\n\nfunction declaringSteps(\n documents: OCRRecipeOptions['documents'],\n): StepDefinition {\n const steps: StepDefinition = {\n type: 'document',\n options: {\n documentTypes: {},\n },\n };\n\n if (!documents) {\n steps.options.documentTypes = {\n [ONFIDO_ACCEPTABLE_DOCUMENTS.Passport]: true,\n [ONFIDO_ACCEPTABLE_DOCUMENTS.Medicare]: true,\n [ONFIDO_ACCEPTABLE_DOCUMENTS.DriversLicense]: true,\n };\n return steps;\n }\n\n documents.forEach(({ type, countries }) => {\n if (\n type === DocumentType.NATIONAL_HEALTH_ID ||\n type === DocumentType.NATIONAL_ID\n ) {\n steps.options.documentTypes[ONFIDO_ACCEPTABLE_DOCUMENTS.Medicare] =\n countries[0] === 'ALL'\n ? true\n : {\n country: countries[0],\n };\n }\n if (type === DocumentType.PASSPORT) {\n steps.options.documentTypes[ONFIDO_ACCEPTABLE_DOCUMENTS.Passport] =\n countries[0] === 'ALL'\n ? true\n : {\n country: countries[0],\n };\n }\n if (type === DocumentType.DRIVERS_LICENCE) {\n steps.options.documentTypes[ONFIDO_ACCEPTABLE_DOCUMENTS.DriversLicense] =\n countries[0] === 'ALL'\n ? true\n : {\n country: countries[0],\n };\n }\n });\n\n return steps;\n}\n","import type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { Events } from '@module/ocr/events';\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 { feat } from '@feature-flags';\nimport { OneSDKError, mkEventHub } from '@module/common';\nimport type { WrapperParameters } from '@module/common/modules/defineModule';\nimport {\n useFormToReviewResults,\n} from '@module/common/vendors/form/useForm';\nimport type { OCRResults } from '@module/frankie-client/clients/OCRClient';\nimport { OCRClient } from '@module/frankie-client/clients/OCRClient';\nimport type { Events, OCRModule } from '@module/ocr';\nimport type {\n StatusEvaluators,\n} from '@module/ocr/vendors/common/statusEvaluators';\nimport { statusEvaluators } from '@module/ocr/vendors/common/statusEvaluators';\nimport { OCRStatus } from '@module/types';\n\ntype Shared = WrapperParameters<OCRModule>[0];\ntype Options = WrapperParameters<OCRModule>[1] & {\n /** Each vendor wrapper needs to flag if their underlying vendor UI already contains a review screen.\n * If it doesn't provide one, we ALWAYS flag that in 'attachReviewScreen' as true.\n * This value can be manually overriden by recipe configuration (ocr.provideReviewScreen) */\n attachReviewScreen: boolean;\n};\n/**\n * This function will\n * 1) Trigger the OCR processing\n * 2) Fetch the updated individual details\n * 3) Evaluate the OCR status to trigger the appropriate event\n * 4) Initialise the Form for manual review, if required\n *\n * It will also emit loading events at the start and end of the process, as well as between long lasting steps\n * @throws This function doesn't throw exceptions, only error events\n * @param shared\n * @param options\n */\nexport const initProcessAndEvaluateResults = async (\n shared: Shared,\n options: Options,\n): Promise<void> => {\n const { frankieClient, oneSdkInstance, localEventHub } = shared;\n try {\n const ocrClient = new OCRClient(frankieClient);\n\n localEventHub.emit('loading', true, { message: 'Retrieving IDV results' });\n let response: OCRResults = await ocrClient.attachNewOCRDocument();\n // If waiting_ocr_run is returned, try to rerun\n if (response.documentStatus === OCRStatus.WAITING_OCR_RUN) {\n response = await ocrClient.rerun(response.ocrDocument.documentId);\n }\n // Update global state with the latest ocr check outcome\n await oneSdkInstance.individual().search();\n const { ocrDocument, documentStatus } = response;\n const evaluateStatus = statusEvaluators[documentStatus] ?? statusEvaluators.default;\n\n // When receiving results event, initialise Form for user manual review\n const privateEventHub = mkEventHub<Events>();\n const mountElement = options.mountElement;\n const recipeProvideReviewScreen =\n shared.recipe.ocr.provideReviewScreen ?? feat('recipeDefaults.ocr.provideReviewScreen');\n\n privateEventHub.on(\n 'results',\n useFormToReviewResults({\n localEventHub,\n mountElement,\n oneSdkInstance,\n // Based on recipe configuration and if the vendor options determine\n // if Form should be attached\n attachForm: recipeProvideReviewScreen && options.attachReviewScreen,\n }),\n );\n privateEventHub.map(['input_required', 'error'], localEventHub);\n\n evaluateStatus({\n ocrDocument,\n documentStatus,\n ocrClient,\n eventHub: privateEventHub,\n } as StatusEvaluators);\n } catch (e) {\n localEventHub.emit('error', new OneSDKError('Failed submitting and retrieving OCR results', e));\n localEventHub.emit('loading', false, { message: 'Failed retrieving OCR results' });\n }\n};\n","import { OCRStatus } from '@frankieone/one-sdk';\nimport type { EventHub} from '@module/common';\nimport { OneSDKError } from '@module/common';\nimport type { Document } from '@module/common/shared/models/Document';\nimport type { OCRClient } from '@module/frankie-client/clients/OCRClient';\nimport type { Events } from '@module/ocr';\n\nexport interface StatusEvaluators {\n ocrDocument?: Document;\n documentStatus?: OCRStatus;\n ocrClient?: OCRClient;\n eventHub: EventHub<Events>;\n}\n\nexport const statusEvaluators = {\n [OCRStatus.COMPLETE]: ({ ocrDocument, ocrClient, eventHub }: StatusEvaluators) =>\n eventHub.emit('results', { document: ocrDocument, entityId: ocrClient.entityId }),\n [OCRStatus.WAITING_OCR_RUN]: ({ eventHub }: StatusEvaluators) => {\n eventHub.emit(\n 'error',\n new OneSDKError(\n `Two attempts to get OCR results failed with an unresolved \"${OCRStatus.WAITING_OCR_RUN}\". This is a system failure.`,\n { payload: null },\n ),\n );\n },\n [OCRStatus.PROVIDER_OFFLINE]: ({ eventHub }: StatusEvaluators) =>\n eventHub.emit(\n 'error',\n new OneSDKError(\n `Provider is offline. Either switch providers and restart or skip OCR temporarily. Status ${OCRStatus.PROVIDER_OFFLINE}`,\n { payload: null },\n ),\n ),\n default: ({ documentStatus, eventHub }: StatusEvaluators) =>\n eventHub.emit('input_required', { documentType: null, side: 'front' }, documentStatus, () => ({})),\n} as const;\n"],"names":["install","sdkVersion","loadAsyncAsset","Number","observeReady","mutationClass","eventHub","targetNode","document","querySelector","MutationObserver","mutations","observer","mutation","mutationElement","addedNodes","classList","contains","emit","domElement","disconnect","observe","childList","subtree","ONFIDO_ACCEPTABLE_DOCUMENTS","initialise","shared","options","frankieClient","recipe","ocr","provider","documents","mountElement","idvClient","idvSession","message","on","name","steps","type","documentTypes","forEach","countries","NATIONAL_HEALTH_ID","NATIONAL_ID","country","PASSPORT","DRIVERS_LICENCE","declaringSteps","token","instance","window","Onfido","init","containerEl","useModal","isModalOpen","disableAnalytics","disableAnalyticsCookies","ONFIDO_OPTIONS_PROPS","customUI","onComplete","removeVendorSdk","attachReviewScreen","onError","error","OneSDKError","loadingEvent","onUserExit","documentType","side","INTERRUPTED","onModalRequestClose","opts","safeTearDown","createSession","entityId","vendorParameters","getToken","session","code","initProcessAndEvaluateResults","oneSdkInstance","localEventHub","ocrClient","response","attachNewOCRDocument","documentStatus","WAITING_OCR_RUN","rerun","ocrDocument","documentId","individual","search","evaluateStatus","default","privateEventHub","mkEventHub","recipeProvideReviewScreen","provideReviewScreen","attachForm","map","e","statusEvaluators","COMPLETE","payload","PROVIDER_OFFLINE"],"sourceRoot":""}