@frankieone/one-sdk 1.4.0-rc → 1.4.2-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commit.txt +2 -2
- package/dist/esm/modules/biometrics/vendors/Incode/index.d.ts.map +1 -1
- package/dist/esm/modules/biometrics/vendors/Incode/index.js +3 -5
- package/dist/esm/modules/biometrics/vendors/Incode/index.js.map +1 -1
- package/dist/esm/modules/common/vendors/form/useForm.d.ts.map +1 -1
- package/dist/esm/modules/common/vendors/form/useForm.js +6 -0
- package/dist/esm/modules/common/vendors/form/useForm.js.map +1 -1
- package/dist/esm/modules/common/vendors/incode/index.d.ts +2 -4
- package/dist/esm/modules/common/vendors/incode/index.d.ts.map +1 -1
- package/dist/esm/modules/common/vendors/incode/index.js +6 -21
- package/dist/esm/modules/common/vendors/incode/index.js.map +1 -1
- package/dist/esm/modules/common/vendors/incode/onBoarding.types.d.ts +4 -1
- package/dist/esm/modules/common/vendors/incode/onBoarding.types.d.ts.map +1 -1
- package/dist/esm/modules/common/vendors/incode/startCamera.d.ts +5 -2
- package/dist/esm/modules/common/vendors/incode/startCamera.d.ts.map +1 -1
- package/dist/esm/modules/common/vendors/incode/startCamera.js +2 -7
- package/dist/esm/modules/common/vendors/incode/startCamera.js.map +1 -1
- package/dist/esm/modules/features.config.d.ts +3 -3
- package/dist/esm/modules/features.config.js +3 -3
- package/dist/esm/modules/features.config.js.map +1 -1
- package/dist/esm/modules/form/definition.d.ts +4 -2
- package/dist/esm/modules/form/definition.d.ts.map +1 -1
- package/dist/esm/modules/form/events.d.ts +32 -5
- package/dist/esm/modules/form/events.d.ts.map +1 -1
- package/dist/esm/modules/form/events.js +30 -1
- package/dist/esm/modules/form/events.js.map +1 -1
- package/dist/esm/modules/form/index.d.ts.map +1 -1
- package/dist/esm/modules/form/index.js +28 -5
- package/dist/esm/modules/form/index.js.map +1 -1
- package/dist/esm/modules/form/vendors/formio/index.d.ts +2 -18
- package/dist/esm/modules/form/vendors/formio/index.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/formio/index.js +9 -2
- package/dist/esm/modules/form/vendors/formio/index.js.map +1 -1
- package/dist/esm/modules/form/vendors/legacy/index.d.ts +4 -19
- package/dist/esm/modules/form/vendors/legacy/index.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/legacy/index.js +23 -27
- package/dist/esm/modules/form/vendors/legacy/index.js.map +1 -1
- package/dist/esm/modules/form/vendors/legacy/legacyUIEvents.types.d.ts +56 -11
- package/dist/esm/modules/form/vendors/legacy/legacyUIEvents.types.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/legacy/legacyUIEvents.types.js +54 -1
- package/dist/esm/modules/form/vendors/legacy/legacyUIEvents.types.js.map +1 -1
- package/dist/esm/modules/form/vendors/legacy/loadLegacyUI.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/legacy/loadLegacyUI.js +2 -8
- package/dist/esm/modules/form/vendors/legacy/loadLegacyUI.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/App.d.ts +0 -1
- package/dist/esm/modules/form/vendors/react/App.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/App.js +0 -1
- package/dist/esm/modules/form/vendors/react/App.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/{app.config.type.d.ts → appConfig.type.d.ts} +11 -6
- package/dist/esm/modules/form/vendors/react/appConfig.type.d.ts.map +1 -0
- package/dist/esm/modules/form/vendors/react/{app.config.type.js → appConfig.type.js} +2 -1
- package/dist/esm/modules/form/vendors/react/appConfig.type.js.map +1 -0
- package/dist/esm/modules/form/vendors/react/components/base/FrankieButton/BaseButton.js +1 -1
- package/dist/esm/modules/form/vendors/react/components/base/FrankieButton/BaseButton.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieCheckbox/FrankieCheckbox.d.ts +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieCheckbox/FrankieCheckbox.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieCheckbox/FrankieCheckbox.js +2 -2
- package/dist/esm/modules/form/vendors/react/components/view/FrankieCheckbox/FrankieCheckbox.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieDescription/FrankieDescription.d.ts +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieDescription/FrankieDescription.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieDescription/FrankieDescription.js +2 -2
- package/dist/esm/modules/form/vendors/react/components/view/FrankieDescription/FrankieDescription.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieHeading/Heading.d.ts +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieHeading/Heading.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieHeading/Heading.js +2 -2
- package/dist/esm/modules/form/vendors/react/components/view/FrankieHeading/Heading.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieInstructionList/FrankieInstructionList.d.ts +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieInstructionList/FrankieInstructionList.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/FrankieInstructionList/FrankieInstructionList.js +2 -2
- package/dist/esm/modules/form/vendors/react/components/view/FrankieInstructionList/FrankieInstructionList.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/Loader/Loader.js +6 -6
- package/dist/esm/modules/form/vendors/react/components/view/Loader/Loader.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/Wrapper/Wrapper.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/components/view/Wrapper/Wrapper.js +2 -2
- package/dist/esm/modules/form/vendors/react/components/view/Wrapper/Wrapper.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/constants/layout-mapper.const.d.ts +1 -0
- package/dist/esm/modules/form/vendors/react/constants/layout-mapper.const.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/features/Consent/Consent.js +1 -1
- package/dist/esm/modules/form/vendors/react/features/Consent/Consent.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/features/Consent/consent.config.js +1 -1
- package/dist/esm/modules/form/vendors/react/features/Consent/consent.config.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/features/Consent/consent.types.d.ts +1 -1
- package/dist/esm/modules/form/vendors/react/features/Consent/consent.types.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/features/Welcome/welcome.config.d.ts +1 -0
- package/dist/esm/modules/form/vendors/react/features/Welcome/welcome.config.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/features/Welcome/welcome.config.js +6 -5
- package/dist/esm/modules/form/vendors/react/features/Welcome/welcome.config.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/features/Welcome/welcome.type.d.ts +1 -1
- package/dist/esm/modules/form/vendors/react/features/Welcome/welcome.type.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/index.d.ts +4 -19
- package/dist/esm/modules/form/vendors/react/index.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/index.js +35 -19
- package/dist/esm/modules/form/vendors/react/index.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/layout/Main/MainLayout.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/layout/Main/MainLayout.js +2 -2
- package/dist/esm/modules/form/vendors/react/layout/Main/MainLayout.js.map +1 -1
- package/dist/esm/modules/form/vendors/react/pages/ScreenWrapper/ScreenWrapper.d.ts +1 -1
- package/dist/esm/modules/form/vendors/react/pages/ScreenWrapper/ScreenWrapper.d.ts.map +1 -1
- package/dist/esm/modules/form/vendors/react/pages/ScreenWrapper/ScreenWrapper.js +23 -3
- package/dist/esm/modules/form/vendors/react/pages/ScreenWrapper/ScreenWrapper.js.map +1 -1
- package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.d.ts.map +1 -1
- package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.js +5 -0
- package/dist/esm/modules/idv/vendors/common/iframeUtils/createIframe.js.map +1 -1
- package/dist/esm/modules/meta.json +1 -1
- package/dist/esm/modules/ocr/vendors/Incode/index.d.ts.map +1 -1
- package/dist/esm/modules/ocr/vendors/Incode/index.js +8 -9
- package/dist/esm/modules/ocr/vendors/Incode/index.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/componentLoader.d.ts.map +1 -1
- package/dist/esm/modules/sdk/initialisation/componentLoader.js +2 -1
- package/dist/esm/modules/sdk/initialisation/componentLoader.js.map +1 -1
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.js +29 -27
- package/dist/esm/modules/sdk/initialisation/sharedDependencies.js.map +1 -1
- package/dist/esm/styles/f1-style.css +1 -1
- package/dist/release.txt +1 -1
- package/dist/umd/094b58729ef1af71dc5b.woff +1 -0
- package/dist/umd/1c9c1ef03c6dd661b89b274e0eac38e0.woff +0 -0
- package/dist/umd/26a8e1ce5e55788744200ea5421806df.woff2 +0 -0
- package/dist/umd/369d1ed7fecb9baee970.woff2 +1 -0
- package/dist/umd/484bb29af46b36504acc.woff2 +1 -0
- package/dist/umd/4ef689ab7e6d52b7a907.woff2 +1 -0
- package/dist/umd/58b74e594849c43b2248b93a572bcb1f.woff2 +0 -0
- package/dist/umd/5c6cd9522ae574c0aaf0.woff +1 -0
- package/dist/umd/5ddf80d7ddb1d1c5a0bcfe99fac6ff26.woff +0 -0
- package/dist/umd/6c874e1a72a4fa9eeed83a59cf07bfae.woff2 +0 -0
- package/dist/umd/70e1b18ec7d6f3e4ea13.woff +1 -0
- package/dist/umd/781e1c7a245cdcdc4ca8.woff2 +1 -0
- package/dist/umd/7f6d57b96337c21c053dbcaf67e74b6d.woff +0 -0
- package/dist/umd/895.js +3 -0
- package/dist/umd/895.js.map +1 -0
- package/dist/umd/af823d3a76ce1e2e36afd5868421f454.woff +0 -0
- package/dist/umd/biometrics-incode.js +1 -1
- package/dist/umd/biometrics-incode.js.map +1 -1
- package/dist/umd/d0065c2d121111eb6143.woff +1 -0
- package/dist/umd/d216030199c873b0bf411ff675d9e59d.woff2 +0 -0
- package/dist/umd/form-formio.js +1 -1
- package/dist/umd/form-formio.js.map +1 -1
- package/dist/umd/form-legacy.js +1 -1
- package/dist/umd/form-legacy.js.map +1 -1
- package/dist/umd/form-react.js +1 -1
- package/dist/umd/form-react.js.map +1 -1
- package/dist/umd/idv-incode.js +1 -1
- package/dist/umd/idv-incode.js.map +1 -1
- package/dist/umd/idv-mastercard.js +1 -1
- package/dist/umd/idv-mastercard.js.map +1 -1
- package/dist/umd/idv-ocrlabs.js +1 -1
- package/dist/umd/idv-ocrlabs.js.map +1 -1
- package/dist/umd/ocr-dummy.js +1 -1
- package/dist/umd/ocr-dummy.js.map +1 -1
- package/dist/umd/ocr-incode.js +1 -1
- package/dist/umd/ocr-incode.js.map +1 -1
- package/dist/umd/ocr-onfido.js +1 -1
- package/dist/umd/ocr-onfido.js.map +1 -1
- package/dist/umd/oneSdk.umd.js +1 -1
- package/dist/umd/oneSdk.umd.js.map +1 -1
- package/dist/version.txt +2 -2
- package/package.json +50 -55
- package/dist/esm/modules/form/vendors/react/app.config.type.d.ts.map +0 -1
- package/dist/esm/modules/form/vendors/react/app.config.type.js.map +0 -1
- package/dist/umd/501.js +0 -3
- package/dist/umd/501.js.map +0 -1
- /package/dist/umd/{501.js.LICENSE.txt → 895.js.LICENSE.txt} +0 -0
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[153],{6715:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>u});var o=t(8016),i=t(2365),r=t(3655),c=t(5473),s=t(1272),
|
|
1
|
+
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[153],{6715:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>u});var o=t(8016),i=t(2365),r=t(3655),c=t(5473),s=t(1272),a=t(9188),d=function(e,n,t,o){return new(t||(t=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,s)}a((o=o.apply(e,n||[])).next())}))};const u=(0,c.f)("incode",((e,n)=>d(void 0,void 0,void 0,(function*(){const{frankieClient:t,recipe:c}=e,{biometrics:{provider:u}}=c,{mountElement:m,eventHub:l}=n,v=new a.Ns(t),p=yield(0,o.j)(v,l);if(!p)return;const{vendorParameters:f}=p;try{const{apiURL:e,token:n,interviewId:t}=f,{incode:o}=yield(0,s.ai)({apiURL:e,sdkVersion:"incode"===u.name&&u.sdkVersion}),i=document.createElement("style");i.innerHTML="\n .IncodeCaptureSelfieBordersContainer {\n display: flex;\n align-items: center;\n justify-content: center;\n }",document.head.appendChild(i);const{onLog:a,onError:p}=(0,s.g6)("biometrics",{eventHub:l,entityId:v.entityId}),y={incode:o,token:{token:n,interviewId:t},eventHub:l,mountElement:m,onError:p,onLog:a};(0,s.Yv)("biometrics",Object.assign(Object.assign({},y),{onSuccess:()=>d(void 0,void 0,void 0,(function*(){l.emit("detection_complete"),yield(0,r.W)({idvClient:v,recipe:c,eventHub:l}),l.emit("session_closed")}))})),l.emit("ready",{domElement:m})}catch(e){const n=(0,i.M)(c),{type:t=null,message:o=""}=e;l.emit("error",n("DEFAULT",{type:t,message:o}))}return{}}))))},8016:(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 c(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(n){var t;n.done?e(n.value):(t=n.value,t instanceof i?t:new i((function(e){e(t)}))).then(c,s)}a((r=r.apply(t,o||[])).next())}));var t,o,i,r}},2365:(e,n,t)=>{t.d(n,{M:()=>r});var o=t(4334),i=t(9188);const r=e=>{const{biometrics:{provider:{name:n}}}=e;return(e,...t)=>{return new o.OneSDKError((r=n,{DEFAULT:`Error from vendor SDK '${r}'`,INIT_PROCESS:"Error from biometrics submission",[i.Yt.PROVIDER_OFFLINE]:`Error initialising biometrics check with '${r}'. The service doesn't appear to be available.`,[i.Yt.WAITING_DOC_UPLOAD]:`Error initialising biometrics check with '${r}'. You might need to run the 'ocr' component before running 'biometrics'.`,[i.Yt.WAITING_SELFIE_UPLOAD]:`Error initialising biometrics check with '${r}'. You might need to capture selfie before running 'biometrics'.`})[e],t);var r}}},3655:(e,n,t)=>{t.d(n,{W:()=>r});var o=t(2365),i=t(9188);const r=e=>{return n=void 0,t=[e],c=function*({idvClient:e,recipe:n,eventHub:t}){const{biometrics:{is_synchronous:r}}=n,c=(0,o.M)(n),{checkStatus:s,ocrDocument:a}=yield e.initProcess({isSynchronous:!!r});(0,i.q8)(s)||(0,i.tX)(s)?t.emit("error",c(s)):t.emit(r?"results":"processing",{checkStatus:s,document:a,entityId:e.entityId})},new((r=void 0)||(r=Promise))((function(e,o){function i(e){try{a(c.next(e))}catch(e){o(e)}}function s(e){try{a(c.throw(e))}catch(e){o(e)}}function a(n){var t;n.done?e(n.value):(t=n.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}a((c=c.apply(n,t||[])).next())}));var n,t,r,c}},1272:(e,n,t)=>{t.d(n,{g6:()=>c,ai:()=>m,Yv:()=>a});var o=t(4334),i=t(6604),r=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:r})=>{c?n.emit("detection_failed",{message:null==r?void 0:r.message}):"permissionDenied"===e?n.emit("input_required",{entityId:t},i.Yt.INTERRUPTED):s.includes(e)&&n.emit("error",new o.OneSDKError("Error from vendor SDK 'Incode'",{type:e,payload:r}))}},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"},r.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(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,s)}a((o=o.apply(e,n||[])).next())}))};const a=(e,n)=>s(void 0,void 0,void 0,(function*(){if("ocr"===e)return yield d("front",Object.assign(Object.assign({},n),{onSuccess:e=>s(void 0,[e],void 0,(function*({skipBackIdCapture:e}){e?null==n||n.onSuccess({}):yield d("back",n)}))}));if("biometrics"===e)return yield d("selfie",n);throw new o.OneSDKError("Unknown purpose",{purpose:e})})),d=(e,n)=>s(void 0,void 0,void 0,(function*(){const{incode:t,token:i,eventHub:r,mountElement:c,onSuccess:a=(()=>({})),onError:d,onLog:u}=n;return new Promise(((n,m)=>{try{t.renderCamera(e,c,{onSuccess:e=>s(void 0,void 0,void 0,(function*(){return a(e),n({})})),onError:e=>(d(e),m(e)),onLog:e=>{u(e)},token:i,numberOfTries:3})}catch(e){const{message:n=""}=e;return r.emit("error",new o.OneSDKError("Error from vendor SDK 'Incode'",{message:n})),m(e)}}))}));var u=function(e,n,t,o){return new(t||(t=Promise))((function(i,r){function c(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,s)}a((o=o.apply(e,n||[])).next())}))};const m=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 l({apiURL:`${e}/0/`})}})),l=e=>u(void 0,[e],void 0,(function*({apiURL:e}){const n=window.OnBoarding.create({apiURL:e});return yield n.warmup(),n}))}}]);
|
|
2
2
|
//# sourceMappingURL=biometrics-incode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biometrics-incode.js","mappings":"seAaO,MAAMA,GAAa,OAAgC,UAAU,CAClEC,EACAC,IACG,OAAD,6BACF,MAAM,cAAEC,EAAa,OAAEC,GAAWH,GAC1BI,YAAY,SAAEC,IAAeF,GAC/B,aAAEG,EAAY,SAAEC,GAAaN,EAC7BO,EAAY,IAAI,KAAUN,GAG1BO,QAAmB,OAA6BD,EAAWD,GAEjE,IAAKE,EAAY,OACjB,MAAM,iBAAEC,GAAqBD,EAE7B,IAEE,MAAM,OAAEE,EAAM,SAAEC,EAAQ,MAAEC,GAAUH,GAC9B,OAAEI,EAAM,QAAEC,SAAkB,QAAQ,CACxCH,WACAD,SACAE,QACAG,WAA8B,WAAlBX,EAASY,MAAqBZ,EAASW,aAO/CE,EAAaC,SAASC,cAAc,SAC1CF,EAAWG,UAAY,kJAMvBF,SAASG,KAAKC,YAAYL,GAE1B,MAAM,MACJM,EAAK,QACLC,IACE,QAAoB,aAAc,CACpClB,WACAmB,SAAUlB,EAAUkB,WAEhBC,EAAc,CAClBb,SACAC,UACAR,WACAD,eACAmB,UACAD,UAKG,QAAY,aAAc,OAAF,wBACxBG,GAAW,CACdC,UAAW,IAA2B,OAAD,6BACnCrB,EAASsB,KAAK,4BACR,OAAY,CAAErB,YAAWL,SAAQI,aACvCA,EAASsB,KAAK,iBAChB,OAEFtB,EAASsB,KA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ACRgE,YAAa,GACbC,cAAe,GACfC,iBAAkB,EAClBC,qBAAsB,EACtBC,iBAAkB,EAClBC,qBAAsB,EACtBC,sBAAuB,EACvBrE,SAAU,GACVsE,IAAK,QACLC,iBAAiB,EACjBC,eAAgB,GAChBC,cAAe,IAInB,IAEMX,EAAiB,GAGsB,gCAHf,SAC5B9D,EAAQ,OACRD,IAEA,MAAMG,EAASwE,OAAOC,WAAWC,OAAO,CAAE5E,WAAUD,WAEpD,aADMG,EAAO2E,SACN3E,CACT,G","sources":["webpack://OneSdk/./modules/biometrics/vendors/Incode/index.ts","webpack://OneSdk/./modules/biometrics/vendors/common/createSession.ts","webpack://OneSdk/./modules/biometrics/vendors/common/errors.ts","webpack://OneSdk/./modules/biometrics/vendors/common/initProcess.ts","webpack://OneSdk/./modules/common/vendors/incode/createEventHandlers.ts","webpack://OneSdk/./modules/common/vendors/incode/startCamera.ts","webpack://OneSdk/./modules/common/vendors/incode/index.ts"],"sourcesContent":["import type { BiometricsModule } from '@module/biometrics';\nimport { createSession } from '@module/biometrics/vendors/common/createSession';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport { initProcess } from '@module/biometrics/vendors/common/initProcess';\nimport { defineWrapper } from '@module/common/modules/defineModule';\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';\n\nexport const initialise = defineWrapper<BiometricsModule>('incode', async (\n shared,\n options,\n) => {\n const { frankieClient, recipe } = shared;\n const { biometrics: { provider } } = recipe;\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) return;\n const { vendorParameters } = idvSession;\n\n try {\n // initialise Incode with credentials\n const { apiURL, clientId, token } = vendorParameters;\n const { incode, session } = await install({\n clientId,\n apiURL,\n token,\n sdkVersion: provider.name === 'incode' && provider.sdkVersion,\n });\n\n /**\n * There is CSS misalignment from Incode loading animation\n * Adding style override to enforce center alignment\n */\n const styleSheet = document.createElement('style');\n styleSheet.innerHTML = `\n .IncodeCaptureSelfieBordersContainer {\n display: flex;\n align-items: center;\n justify-content: center;\n }`;\n document.head.appendChild(styleSheet);\n\n const {\n onLog,\n onError,\n } = createEventHandlers('biometrics', {\n eventHub,\n entityId: idvClient.entityId,\n });\n const cameraProps = {\n incode,\n session,\n eventHub,\n mountElement,\n onError,\n onLog,\n };\n // turn on camera to capture selfie\n // \"void\" operator indicates the intention of non-blocking async process\n // it allows other events to emit while using camera to capture\n void startCamera('biometrics', {\n ...cameraProps,\n onSuccess: async (): Promise<void> => {\n eventHub.emit('detection_complete');\n await initProcess({ idvClient, recipe, eventHub });\n eventHub.emit('session_closed');\n },\n });\n eventHub.emit('ready', { domElement: mountElement });\n } catch (error) {\n const errorMessages = mkErrors(recipe);\n const { type = null, message = '' } = error;\n eventHub.emit('error', errorMessages('DEFAULT', { type, message }));\n }\n\n return {};\n});\n","import type { Events } from '@module/biometrics/events';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { _DictionaryWrite } from '@types';\n\n/**\n * Creates a session by obtaining an entity ID, token, and vendor parameters from an IDVClient.\n * It will also emit 'session_data_generated' event to the provided event hub.\n * This function won't throw errors. Instead, it will emit 'session_data_failed_loading' and return null.\n *\n * @param idvClient - The IDVClient instance used to obtain the session data.\n * @param eventHub - The EventHub instance for emitting session-related events.\n * @returns A Promise that resolves with an object containing entityId, token, and vendorParameters upon success, or null if a session couldn't be created\n */\nexport const createSession = async <T extends _DictionaryWrite<unknown>>(\n idvClient: IDVClient,\n eventHub: EventHub<Events>,\n): Promise<{ entityId: string; token: string; vendorParameters: T } | null> => {\n try {\n const { entityId, token, vendorParameters } = await idvClient.getToken<T>();\n eventHub.emit('session_data_generated', {\n session: { entityId, token, vendorParameters },\n });\n return { entityId, token, vendorParameters };\n } catch (error) {\n const { code = null, message = '' } = error;\n eventHub.emit('session_data_failed_loading', { code, message });\n return null;\n }\n};\n","import { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport type ErrorMessages = Record<\n 'DEFAULT' | 'INIT_PROCESS' | Extract<IDVStatus, 'PROVIDER_OFFLINE' | 'WAITING_DOC_UPLOAD' | 'WAITING_SELFIE_UPLOAD'>,\n string\n>;\n\nconst mkErrorMessages = (provider: string): ErrorMessages => ({\n DEFAULT: `Error from vendor SDK '${provider}'`,\n INIT_PROCESS: 'Error from biometrics submission',\n [IDVStatus.PROVIDER_OFFLINE]: `Error initialising biometrics check with '${provider}'. The service doesn't appear to be available.`,\n [IDVStatus.WAITING_DOC_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to run the 'ocr' component before running 'biometrics'.`,\n [IDVStatus.WAITING_SELFIE_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to capture selfie before running 'biometrics'.`,\n});\n\nexport const mkErrors = (recipe: RecipeParsed) => {\n const {\n biometrics: {\n provider: {\n name,\n },\n },\n } = recipe;\n\n return (type: keyof ErrorMessages, ...payload: unknown[]) => {\n return new OneSDKError(mkErrorMessages(name)[type], payload);\n };\n \n};\n","import type { Events } from '@module/biometrics/events';\nimport type { ErrorMessages } from '@module/biometrics/vendors/common/errors';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport {\n isErrorStatus,\n isInputRequiredStatus,\n} from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport const initProcess = async (\n { idvClient, recipe, eventHub }: {\n idvClient: IDVClient;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n },\n) => {\n const { biometrics: { is_synchronous: isSynchronous } } = recipe;\n const errorMessages = mkErrors(recipe);\n const {\n checkStatus,\n ocrDocument,\n } = await idvClient.initProcess({ isSynchronous: !!isSynchronous });\n if (isInputRequiredStatus(checkStatus) || isErrorStatus(checkStatus)) {\n eventHub.emit('error', errorMessages((checkStatus as keyof ErrorMessages)));\n } else {\n eventHub.emit(isSynchronous ? 'results' : 'processing', {\n checkStatus,\n document: ocrDocument,\n entityId: idvClient.entityId,\n });\n }\n};\n","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 { IncodeInstance, IncodeResponse, IncodeSession } from '@module/common/vendors/incode/onBoarding.types';\nimport type { Events } from '@module/ocr';\n\ntype CameraProps = {\n incode: IncodeInstance;\n session: IncodeSession;\n eventHub: EventHub<Events>;\n mountElement: HTMLElement;\n onSuccess?: (response: unknown) => void;\n onError: (response: unknown, payload?: unknown) => void;\n onLog: (response: unknown) => void;\n};\n\nexport const startCamera = async (purpose: 'biometrics' | 'ocr', cameraProps: CameraProps) => {\n if (purpose === 'ocr') {\n return await renderCamera('front', {\n ...cameraProps,\n onSuccess: async ({ skipBackIdCapture }: { skipBackIdCapture: boolean }): Promise<void> => {\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 (type: 'front' | 'back' | 'selfie', cameraProps: CameraProps) => {\n const { incode, session, eventHub, mountElement, onSuccess = () => ({}), onError, onLog } = cameraProps;\n return new Promise((resolve, reject): void => {\n if (mountElement.children.length > 0) {\n const error = new OneSDKError(`Incode requires mountElement to be an empty container.`, {});\n eventHub.emit('error', error);\n return reject(error);\n }\n try {\n incode.renderCamera(type, mountElement, {\n onSuccess: async (response): 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: session,\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 IncodeSession,\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 clientId,\n apiURL,\n token,\n sdkVersion = '1.66.0',\n}: IncodeConfig & { token: string; sdkVersion?: string }): Promise<{\n incode: IncodeInstance;\n session: IncodeSession;\n}> => {\n // install Incode script from CDN\n await loadAsyncAsset(`https://sdk.incode.com/sdk/onBoarding-${sdkVersion}.js`);\n\n const incode = await createInstance({ clientId, apiURL });\n\n const session : IncodeSession = {\n token: token,\n apiURL: '',\n interviewId: '',\n interviewCode: '',\n idCaptureTimeout: 0,\n selfieCaptureTimeout: 0,\n idCaptureRetries: 0,\n selfieCaptureRetries: 0,\n curpValidationRetries: 0,\n clientId: '',\n env: 'stage',\n existingSession: false,\n endScreenTitle: '',\n endScreenText: ''\n };\n \n return { incode, session };\n};\n\nconst createInstance = async ({\n clientId,\n apiURL,\n}: IncodeConfig): Promise<IncodeInstance> => {\n const incode = window.OnBoarding.create({ clientId, apiURL });\n await incode.warmup();\n return incode;\n};\n"],"names":["initialise","shared","options","frankieClient","recipe","biometrics","provider","mountElement","eventHub","idvClient","idvSession","vendorParameters","apiURL","clientId","token","incode","session","sdkVersion","name","styleSheet","document","createElement","innerHTML","head","appendChild","onLog","onError","entityId","cameraProps","onSuccess","emit","domElement","error","errorMessages","type","message","createSession","getToken","code","mkErrors","payload","OneSDKError","DEFAULT","INIT_PROCESS","PROVIDER_OFFLINE","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","initProcess","is_synchronous","isSynchronous","checkStatus","ocrDocument","createEventHandlers","module","noAttemptsFlag","genericErrors","INTERRUPTED","includes","ocr","documentType","side","startCamera","purpose","renderCamera","skipBackIdCapture","Promise","resolve","reject","children","length","response","log","numberOfTries","install","loadAsyncAsset","createInstance","interviewId","interviewCode","idCaptureTimeout","selfieCaptureTimeout","idCaptureRetries","selfieCaptureRetries","curpValidationRetries","env","existingSession","endScreenTitle","endScreenText","window","OnBoarding","create","warmup"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"biometrics-incode.js","mappings":"seAaO,MAAMA,GAAa,OAAgC,UAAU,CAClEC,EACAC,IACG,OAAD,6BACF,MAAM,cAAEC,EAAa,OAA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AA4B,OAAD,6BAE3C,OADAxC,EAAUwC,GACHF,EAAQ,CAAC,EAClB,IACAzC,QAAUM,IACRN,EAAQM,GACDoC,EAAOpC,IAEhBP,MAAQ6C,IACN7C,EAAM6C,EAAI,EAEZxD,QACAyD,cAAe,GAEnB,CAAE,MAAOvC,GACP,MAAM,QAAEG,EAAU,IAAOH,EAEzB,OADAvB,EAASqB,KAAK,QAAS,IAAI,EAAAY,YAAY,iCAAkC,CAAEP,aACpEiC,EAAOpC,EAChB,IAEJ,I,0SCpEO,MAAMwC,EAAU,GAKjB,gCALwB,OAC5B3D,EAAM,WACNI,EAAa,WAQb,aAHM,IAAAwD,gBAAe,yCAAyCxD,QAGvD,CAAED,aADY0D,EAAe,CAAE7D,OAAQ,GAAGA,SAEnD,IAEM6D,EAAiB,GAEsB,gCAFf,OAC5B7D,IAEA,MAAMG,EAAS2D,OAAOC,WAAWC,OAAO,CAAEhE,WAE1C,aADMG,EAAO8D,SACN9D,CACT,G","sources":["webpack://OneSdk/./modules/biometrics/vendors/Incode/index.ts","webpack://OneSdk/./modules/biometrics/vendors/common/createSession.ts","webpack://OneSdk/./modules/biometrics/vendors/common/errors.ts","webpack://OneSdk/./modules/biometrics/vendors/common/initProcess.ts","webpack://OneSdk/./modules/common/vendors/incode/createEventHandlers.ts","webpack://OneSdk/./modules/common/vendors/incode/startCamera.ts","webpack://OneSdk/./modules/common/vendors/incode/index.ts"],"sourcesContent":["import type { BiometricsModule } from '@module/biometrics';\nimport { createSession } from '@module/biometrics/vendors/common/createSession';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport { initProcess } from '@module/biometrics/vendors/common/initProcess';\nimport { defineWrapper } from '@module/common/modules/defineModule';\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';\n\nexport const initialise = defineWrapper<BiometricsModule>('incode', async (\n shared,\n options,\n) => {\n const { frankieClient, recipe } = shared;\n const { biometrics: { provider } } = recipe;\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) return;\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 /**\n * There is CSS misalignment from Incode loading animation\n * Adding style override to enforce center alignment\n */\n const styleSheet = document.createElement('style');\n styleSheet.innerHTML = `\n .IncodeCaptureSelfieBordersContainer {\n display: flex;\n align-items: center;\n justify-content: center;\n }`;\n document.head.appendChild(styleSheet);\n\n const {\n onLog,\n onError,\n } = createEventHandlers('biometrics', {\n eventHub,\n entityId: idvClient.entityId,\n });\n const cameraProps = {\n incode,\n token: { token, interviewId },\n eventHub,\n mountElement,\n onError,\n onLog,\n };\n // turn on camera to capture selfie\n // \"void\" operator indicates the intention of non-blocking async process\n // it allows other events to emit while using camera to capture\n void startCamera('biometrics', {\n ...cameraProps,\n onSuccess: async (): Promise<void> => {\n eventHub.emit('detection_complete');\n await initProcess({ idvClient, recipe, eventHub });\n eventHub.emit('session_closed');\n },\n });\n eventHub.emit('ready', { domElement: mountElement });\n } catch (error) {\n const errorMessages = mkErrors(recipe);\n const { type = null, message = '' } = error;\n eventHub.emit('error', errorMessages('DEFAULT', { type, message }));\n }\n\n return {};\n});\n","import type { Events } from '@module/biometrics/events';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport type { _DictionaryWrite } from '@types';\n\n/**\n * Creates a session by obtaining an entity ID, token, and vendor parameters from an IDVClient.\n * It will also emit 'session_data_generated' event to the provided event hub.\n * This function won't throw errors. Instead, it will emit 'session_data_failed_loading' and return null.\n *\n * @param idvClient - The IDVClient instance used to obtain the session data.\n * @param eventHub - The EventHub instance for emitting session-related events.\n * @returns A Promise that resolves with an object containing entityId, token, and vendorParameters upon success, or null if a session couldn't be created\n */\nexport const createSession = async <T extends _DictionaryWrite<unknown>>(\n idvClient: IDVClient,\n eventHub: EventHub<Events>,\n): Promise<{ entityId: string; token: string; vendorParameters: T } | null> => {\n try {\n const { entityId, token, vendorParameters } = await idvClient.getToken<T>();\n eventHub.emit('session_data_generated', {\n session: { entityId, token, vendorParameters },\n });\n return { entityId, token, vendorParameters };\n } catch (error) {\n const { code = null, message = '' } = error;\n eventHub.emit('session_data_failed_loading', { code, message });\n return null;\n }\n};\n","import { OneSDKError } from '@module/common';\nimport { IDVStatus } from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport type ErrorMessages = Record<\n 'DEFAULT' | 'INIT_PROCESS' | Extract<IDVStatus, 'PROVIDER_OFFLINE' | 'WAITING_DOC_UPLOAD' | 'WAITING_SELFIE_UPLOAD'>,\n string\n>;\n\nconst mkErrorMessages = (provider: string): ErrorMessages => ({\n DEFAULT: `Error from vendor SDK '${provider}'`,\n INIT_PROCESS: 'Error from biometrics submission',\n [IDVStatus.PROVIDER_OFFLINE]: `Error initialising biometrics check with '${provider}'. The service doesn't appear to be available.`,\n [IDVStatus.WAITING_DOC_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to run the 'ocr' component before running 'biometrics'.`,\n [IDVStatus.WAITING_SELFIE_UPLOAD]: `Error initialising biometrics check with '${provider}'. You might need to capture selfie before running 'biometrics'.`,\n});\n\nexport const mkErrors = (recipe: RecipeParsed) => {\n const {\n biometrics: {\n provider: {\n name,\n },\n },\n } = recipe;\n\n return (type: keyof ErrorMessages, ...payload: unknown[]) => {\n return new OneSDKError(mkErrorMessages(name)[type], payload);\n };\n \n};\n","import type { Events } from '@module/biometrics/events';\nimport type { ErrorMessages } from '@module/biometrics/vendors/common/errors';\nimport { mkErrors } from '@module/biometrics/vendors/common/errors';\nimport type { EventHub } from '@module/common';\nimport type { IDVClient } from '@module/frankie-client/clients/IDVClient';\nimport {\n isErrorStatus,\n isInputRequiredStatus,\n} from '@module/frankie-client/clients/IDVClient';\nimport type { RecipeParsed } from '@module/sdk/types';\n\nexport const initProcess = async (\n { idvClient, recipe, eventHub }: {\n idvClient: IDVClient;\n recipe: RecipeParsed;\n eventHub: EventHub<Events>;\n },\n) => {\n const { biometrics: { is_synchronous: isSynchronous } } = recipe;\n const errorMessages = mkErrors(recipe);\n const {\n checkStatus,\n ocrDocument,\n } = await idvClient.initProcess({ isSynchronous: !!isSynchronous });\n if (isInputRequiredStatus(checkStatus) || isErrorStatus(checkStatus)) {\n eventHub.emit('error', errorMessages((checkStatus as keyof ErrorMessages)));\n } else {\n eventHub.emit(isSynchronous ? 'results' : 'processing', {\n checkStatus,\n document: ocrDocument,\n entityId: idvClient.entityId,\n });\n }\n};\n","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} 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: unknown) => void;\n onError: (response: unknown, payload?: unknown) => void;\n onLog: (response: unknown) => void;\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 ({ skipBackIdCapture }: {\n skipBackIdCapture: boolean;\n }): Promise<void> => {\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): 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"],"names":["initialise","shared","options","frankieClient","recipe","biometrics","provider","mountElement","eventHub","idvClient","idvSession","vendorParameters","apiURL","token","interviewId","incode","sdkVersion","name","styleSheet","document","createElement","innerHTML","head","appendChild","onLog","onError","entityId","cameraProps","onSuccess","emit","domElement","error","errorMessages","type","message","createSession","getToken","session","code","mkErrors","payload","OneSDKError","DEFAULT","INIT_PROCESS","PROVIDER_OFFLINE","WAITING_DOC_UPLOAD","WAITING_SELFIE_UPLOAD","initProcess","is_synchronous","isSynchronous","checkStatus","ocrDocument","createEventHandlers","module","noAttemptsFlag","genericErrors","INTERRUPTED","includes","ocr","documentType","side","startCamera","purpose","renderCamera","skipBackIdCapture","Promise","resolve","reject","response","log","numberOfTries","install","loadAsyncAsset","createInstance","window","OnBoarding","create","warmup"],"sourceRoot":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default __webpack_public_path__ + "7f6d57b96337c21c053dbcaf67e74b6d.woff";
|
|
Binary file
|
package/dist/umd/form-formio.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[516],{2176:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>b});var o=t(591),d=t(4334),i=t(5473),r=t(5197),a=t(6104);var s=t(4124);function c(e){const n=s.Xr[e];return n?n.alpha2:null}function m(e){const n=s.Xr[e];return n?n.name:null}Object.keys(s.Xr).filter((e=>3===e.length)).map((e=>({value:e,label:m(e)})));const l=[function(e,n){const{basicPiiForm:{data:{firstName:t,middleName:o,lastName:d,dateOfBirth:i}}}=e;n.access("name").setValue({givenName:t,middleName:o,familyName:d,displayName:""});const r=new Date(i).toISOString().split("T")[0];n.access("dateOfBirth").setValue(r)},function(e,n){var t;const{addressComponentForm:{data:{residentialAddress:o}}}=e,d=n.access("addresses").getValue().find((e=>e.addressId===o.addressId)),i=d||(()=>{const e=new r.p;return e.addressType="RESIDENTIAL",e})();i.country=function(e){const n=s.Xr[e];return n?n.alpha3:null}((e=>{var n,t;return null!==(t=null===(n=e.find((e=>e.types.includes("country"))))||void 0===n?void 0:n.short_name)&&void 0!==t?t:null})(o.address_components)),i.longForm=o.formatted_address,i.addressId=null!==(t=o.addressId)&&void 0!==t?t:null,d?n.updateAddress(d.addressId,d):n.addAddress(i)},function(e,n){const{documents:t}=e;t.filter((e=>["PASSPORT","DRIVERS_LICENCE","NATIONAL_HEALTH_ID"].includes(e.genericDocument.data.idType))).map((e=>function(e,n){var t;const o=n.access("documents").getValue().find((n=>n.documentId===e.documentId))||new a.y;o.idType=e.idType,o.documentId=null!==(t=e.documentId)&&void 0!==t?t:null;const d=e.idType;if("PASSPORT"===d)o.idNumber=e.pass_idNumber,o.country=e.issuingCountry,o.idExpiry=e.pass_idExpiry;else if("DRIVERS_LICENCE"===d)o.country=e.issuingCountry,o.region=e.dl_region,o.idNumber=e.dl_idNumber,o.extraData.document_number=e.dl_cardNumber;else{if("NATIONAL_HEALTH_ID"!==d)throw new Error(`Unknown document type '${d}', can't map unknown data.`);o.country="AUS",o.idNumber=e.medi_idNumber,o.idExpiry=e.medi_idExpiry,o.extraData.reference=e.medi_cardPosition,o.idSubType=e.medi_cardColour}return o}(e.genericDocument.data,n))).forEach((e=>{e.documentId?n.updateDocument(e.documentId,e):n.addDocument(e)}))}];function u(e){const n=e.idType,t={documentId:e.documentId,idType:n,issuingCountry:e.country};if("PASSPORT"===n)Object.assign(t,{pass_idNumber:e.idNumber,pass_idExpiry:e.idExpiry});else if("DRIVERS_LICENCE"===n)Object.assign(t,{dl_idNumber:e.idNumber,dl_idExpiry:e.idExpiry,dl_cardNumber:e.extraData.document_number,dl_region:e.region});else{if("NATIONAL_HEALTH_ID"!==n)throw new Error(`Unknown document type '${n}', can't map to formio as this could have unexpected results`);Object.assign(t,{medi_idNumber:e.idNumber,medi_idExpiry:e.idExpiry,medi_cardPosition:e.extraData.reference,medi_cardColour:e.idSubType})}return t}var f=function(e,n,t,o){return new(t||(t=Promise))((function(d,i){function r(e){try{s(o.next(e))}catch(e){i(e)}}function a(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?d(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,a)}s((o=o.apply(e,n||[])).next())}))};const p=[["https://cdn.form.io/formiojs/formio.full.js","script"],["https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css","style"],[(0,o.T)("modules.form.font.cdnUrl"),"style"]],y=["https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css","https://cdn.form.io/formiojs/formio.full.min.css"],h=["form","formio"],b=(0,i.f)("formio",((e,n)=>f(void 0,void 0,void 0,(function*(){const{mountElement:t}=n;t.classList.add(...h);const i=(0,o.T)("modules.form.wrappingMode"),[r,a,s]=yield"shadow"===i?E(t):"iframe"===i?
|
|
1
|
+
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[516],{2176:(e,n,t)=>{t.r(n),t.d(n,{initialise:()=>b});var o=t(591),d=t(4334),i=t(5473),r=t(5197),a=t(6104);var s=t(4124);function c(e){const n=s.Xr[e];return n?n.alpha2:null}function m(e){const n=s.Xr[e];return n?n.name:null}Object.keys(s.Xr).filter((e=>3===e.length)).map((e=>({value:e,label:m(e)})));const l=[function(e,n){const{basicPiiForm:{data:{firstName:t,middleName:o,lastName:d,dateOfBirth:i}}}=e;n.access("name").setValue({givenName:t,middleName:o,familyName:d,displayName:""});const r=new Date(i).toISOString().split("T")[0];n.access("dateOfBirth").setValue(r)},function(e,n){var t;const{addressComponentForm:{data:{residentialAddress:o}}}=e,d=n.access("addresses").getValue().find((e=>e.addressId===o.addressId)),i=d||(()=>{const e=new r.p;return e.addressType="RESIDENTIAL",e})();i.country=function(e){const n=s.Xr[e];return n?n.alpha3:null}((e=>{var n,t;return null!==(t=null===(n=e.find((e=>e.types.includes("country"))))||void 0===n?void 0:n.short_name)&&void 0!==t?t:null})(o.address_components)),i.longForm=o.formatted_address,i.addressId=null!==(t=o.addressId)&&void 0!==t?t:null,d?n.updateAddress(d.addressId,d):n.addAddress(i)},function(e,n){const{documents:t}=e;t.filter((e=>["PASSPORT","DRIVERS_LICENCE","NATIONAL_HEALTH_ID"].includes(e.genericDocument.data.idType))).map((e=>function(e,n){var t;const o=n.access("documents").getValue().find((n=>n.documentId===e.documentId))||new a.y;o.idType=e.idType,o.documentId=null!==(t=e.documentId)&&void 0!==t?t:null;const d=e.idType;if("PASSPORT"===d)o.idNumber=e.pass_idNumber,o.country=e.issuingCountry,o.idExpiry=e.pass_idExpiry;else if("DRIVERS_LICENCE"===d)o.country=e.issuingCountry,o.region=e.dl_region,o.idNumber=e.dl_idNumber,o.extraData.document_number=e.dl_cardNumber;else{if("NATIONAL_HEALTH_ID"!==d)throw new Error(`Unknown document type '${d}', can't map unknown data.`);o.country="AUS",o.idNumber=e.medi_idNumber,o.idExpiry=e.medi_idExpiry,o.extraData.reference=e.medi_cardPosition,o.idSubType=e.medi_cardColour}return o}(e.genericDocument.data,n))).forEach((e=>{e.documentId?n.updateDocument(e.documentId,e):n.addDocument(e)}))}];function u(e){const n=e.idType,t={documentId:e.documentId,idType:n,issuingCountry:e.country};if("PASSPORT"===n)Object.assign(t,{pass_idNumber:e.idNumber,pass_idExpiry:e.idExpiry});else if("DRIVERS_LICENCE"===n)Object.assign(t,{dl_idNumber:e.idNumber,dl_idExpiry:e.idExpiry,dl_cardNumber:e.extraData.document_number,dl_region:e.region});else{if("NATIONAL_HEALTH_ID"!==n)throw new Error(`Unknown document type '${n}', can't map to formio as this could have unexpected results`);Object.assign(t,{medi_idNumber:e.idNumber,medi_idExpiry:e.idExpiry,medi_cardPosition:e.extraData.reference,medi_cardColour:e.idSubType})}return t}var f=function(e,n,t,o){return new(t||(t=Promise))((function(d,i){function r(e){try{s(o.next(e))}catch(e){i(e)}}function a(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?d(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,a)}s((o=o.apply(e,n||[])).next())}))};const p=[["https://cdn.form.io/formiojs/formio.full.js","script"],["https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css","style"],[(0,o.T)("modules.form.font.cdnUrl"),"style"]],y=["https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css","https://cdn.form.io/formiojs/formio.full.min.css"],h=["form","formio"],b=(0,i.f)("formio",((e,n)=>f(void 0,void 0,void 0,(function*(){const{mountElement:t}=n;t.classList.add(...h);const i=(0,o.T)("modules.form.wrappingMode"),[r,a,s]=yield"shadow"===i?E(t):"iframe"===i?g(t):_(t);return"iframe"===i||window.Formio?"iframe"===i&&(yield Promise.all(p.map((([e,n])=>(0,d.loadAsyncAsset)(e,{type:n,targetNode:s.document.body}))))):yield Promise.all(p.map((e=>(0,d.loadAsyncAsset)(...e)))),yield function(e,n){return f(this,void 0,void 0,(function*(){const{mountElement:t,windowWithFormio:o}=n,d=e.localEventHub,i=e.recipe.form.provider,r="formio"===i.name&&i.formUrl,a=e.oneSdkInstance.individual(),[s]=yield Promise.all([o.Formio.createForm(t,r),a.search()]);!function(e){var n,t,o,d;n=this,t=void 0,d=function*(){var n;const t=window.__ONE_SDK__DEVTOOLS.moduleInstances.components.form;(null==t?void 0:t.formioInstances)||null!==(n=t.formioInstances)&&void 0!==n||(t.formioInstances=[]),t.formioInstances.push(e)},new((o=void 0)||(o=Promise))((function(e,i){function r(e){try{s(d.next(e))}catch(e){i(e)}}function a(e){try{s(d.throw(e))}catch(e){i(e)}}function s(n){var t;n.done?e(n.value):(t=n.value,t instanceof o?t:new o((function(e){e(t)}))).then(r,a)}s((d=d.apply(n,t||[])).next())}))}(s),s.ready.then((()=>d.emit("ready",{domElement:t,config:i.config}))),s.on("submitPressed",(()=>f(this,void 0,void 0,(function*(){if(!s.checkValidity(null,!1,null,!0))return;var e,n;e=s.data,n=a,l.forEach((t=>t(e,n))),yield a.submit();const o=a.access("entityId").getValue(),i=a.access("__deprecated_applicant").getValue(),r=a.access("__deprecated_documents").getValue();d.emit("results",{applicant:i,documents:r,entityId:o}),t.innerHTML=""})))),function(e,n){var t;const{givenName:o,middleName:d,familyName:i}=e.access("name").getValue(),r=e.access("dateOfBirth").getValue(),a=e.access("documents").getValue(),s=e.access("addresses").getValue(),l=e.access("entityId").getValue(),{longForm:f,country:p,addressId:y}=null!==(t=s[0])&&void 0!==t?t:{};n.setSubmission({data:{basicPiiForm:{data:{entityId:l,firstName:o,middleName:d,lastName:i,dateOfBirth:r}},documents:a.filter((e=>["PASSPORT","DRIVERS_LICENCE","NATIONAL_HEALTH_ID"].includes(e.idType))).map((e=>({genericDocument:{data:u(e)}}))),addressComponentForm:{data:{useManualAddress:!1,residentialAddress:{addressId:y,formatted_address:null!=f?f:"",address_components:p?[{long_name:m(p),short_name:c(p),types:["country"]}]:[]}}}}})}(a,s),s.language="en"}))}(e,{mountElement:r,windowWithFormio:s}),e.localEventHub.emit("loaded",{domElement:a,provider:"formio"}),{cleanup:()=>{}}})))),v=e=>{const n=e.ownerDocument;y.forEach((t=>{const o=n.createElement("link");o.setAttribute("rel","stylesheet"),o.setAttribute("href",t),e.appendChild(o)}));const t=n.createElement("style"),d=(0,o.T)("modules.form.font.fontFamilyCSSRule"),i=e instanceof ShadowRoot?":host":".form.formio";t.innerHTML=`${i} { font-family: ${d} }`+function(e){return`${e} { ${["\n label {\n font-size: 0.8rem;\n }\n ","\n .card.card-body {\n padding: 0;\n background-color: initial !important;\n border: none !important;\n border-width: 0 !important;\n border-color: transparent !important;\n margin-bottom: 0 !important;\n }\n ",'\n .formio-component-datagrid table,\n .formio-component-datagrid table tbody,\n .formio-component-datagrid table tr,\n .formio-component-datagrid table td {\n border: none !important;\n border-width: 0 !important;\n border-color: transparent !important;\n }\n\n [ref^="datagrid-"] {\n padding: 0 !important;\n }\n [ref^="datagrid-"]:not(:first-of-type) {\n padding-top: 24px;\n }\n ',"\n .main-page-title {\n font-size: 1.2rem;\n font-weight: bold;\n }\n "].join("\n")} }`}(i),e.appendChild(t)},g=e=>f(void 0,void 0,void 0,(function*(){const n=document.createElement("iframe");return n.srcdoc='<html><body><div class="form formio"></div></body></html>',n.style.minHeight="600px",n.style.width="100%",n.style.height="100%",n.style.border="none",e.appendChild(n),yield new Promise(((e,t)=>{n.onload=e,n.onerror=t})),v(n.contentDocument.body),[n.contentDocument.querySelector(".form.formio"),n,n.contentWindow]})),_=e=>f(void 0,void 0,void 0,(function*(){v(e);const n=document.createElement("div");return e.appendChild(n),[n,e,window]})),E=e=>f(void 0,void 0,void 0,(function*(){const n=e.attachShadow({mode:"open"});v(n);const t=document.createElement("div");return n.appendChild(t),[t,n,window]}))}}]);
|
|
2
2
|
//# sourceMappingURL=form-formio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-formio.js","mappings":"mMAMO,SAASA,EAAeC,GAC7B,MAAMC,EAAU,KAAUD,GAC1B,OAAOC,EAAUA,EAAQC,OAAS,IACpC,CACO,SAASC,EAAaH,GAC3B,MAAMC,EAAU,KAAUD,GAC1B,OAAOC,EAAUA,EAAQG,KAAO,IAClC,CAE4B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,IAAI3D,SAAQ,CAACkE,EAASC,KAC1BR,EAAOS,OAASF,EAChBP,EAAOU,QAAUF,CAAM,IAEzBpB,EAAUY,EAAOW,gBAAgB/D,MAE1B,CADsBoD,EAAOW,gBAAgBC,cAA2B,gBACjDZ,EAAQA,EAAOa,cAC/C,IACM3E,EAAmBT,GAAoE,oCAC3F2D,EAAU3D,GAEV,MAAMqF,EAAuBnE,SAAS4C,cAAc,OAEpD,OADA9D,EAAagE,YAAYqB,GAClB,CAACA,EAAsBrF,EAAcU,OAC9C,IACMH,EAAsBP,GAAoE,oCAC9F,MAAMsF,EAAatF,EAAaO,aAAa,CAAEgF,KAAM,SACrD5B,EAAU2B,GACV,MAAMD,EAAuBnE,SAAS4C,cAAc,OAEpD,OADAwB,EAAWtB,YAAYqB,GAChB,CAACA,EAAsBC,EAAY5E,OAC5C,G","sources":["webpack://OneSdk/./modules/form/vendors/formio/transformers/countryData.ts","webpack://OneSdk/./modules/form/vendors/formio/transformers/assignFormioDataToIndividualModule.ts","webpack://OneSdk/./modules/form/vendors/formio/formioSdk.ts","webpack://OneSdk/./modules/form/vendors/formio/transformers/assignIndividualDataToFormioSdk.ts","webpack://OneSdk/./modules/form/vendors/formio/index.ts","webpack://OneSdk/./modules/form/vendors/formio/transformers/initialiseFormio.ts","webpack://OneSdk/./modules/form/vendors/formio/styleOverrides.ts"],"sourcesContent":["import { countries } from 'country-data';\n\nexport function alpha2ToAlpha3(alpha2: string): string | null {\n const country = countries[alpha2];\n return country ? country.alpha3 : null;\n}\nexport function alpha3ToAlpha2(alpha3: string): string | null {\n const country = countries[alpha3];\n return country ? country.alpha2 : null;\n}\nexport function alpha3ToName(alpha3: string): string | null {\n const country = countries[alpha3];\n return country ? country.name : null;\n}\n\nexport const allCountries = Object.keys(countries)\n .filter((code: string) => code.length === 3)\n .map((alpha3) => ({ value: alpha3, label: alpha3ToName(alpha3) }));\n","import { Address } from '@module/common/shared/models/Address';\nimport { Document } from '@module/common/shared/models/Document';\nimport type { IndividualModuleContext } from '@module/types';\n\nimport { findCountryAlpha2 } from '../formioSdk';\n\nimport { alpha2ToAlpha3 } from './countryData';\n\nimport type { FormIOOnboardingDataScheme } from '../formioSdk';\n\n// In order to increase cohesion, the transformation from formio data into the individual module is done by applying a series of transformations\n// To make sure the transformations aren't too convoluted, each transformation is done in a separate function, for different purposes (pipeline pattern):\n// - mapPIIData will inject name and date of birth into the individual module\n// - mapAddressObject will inject the residential address into the individual module\n// - mapDocumentObject will inject the document into the individual module.\n// !--> This is the place where the mapping for each document type is done <--!\n// All the \"transformer\" functions are defined below\nconst formioToIndividualModulePipeline = [mapPIIData, mapAddressObject, mapDocumentObjects];\nexport const assignFormioDataToIndividualModule = (\n formioData: FormIOOnboardingDataScheme,\n individualModule: IndividualModuleContext,\n) => formioToIndividualModulePipeline.forEach((transformer) => transformer(formioData, individualModule));\n\nfunction mapPIIData(formioData: FormIOOnboardingDataScheme, individualModule: IndividualModuleContext) {\n const {\n basicPiiForm: {\n data: { firstName, middleName, lastName, dateOfBirth },\n },\n } = formioData;\n\n /** NAME, DOB */\n individualModule.access('name').setValue({\n givenName: firstName,\n middleName: middleName,\n familyName: lastName,\n displayName: '',\n });\n const reformatted = new Date(dateOfBirth).toISOString().split('T')[0];\n individualModule.access('dateOfBirth').setValue(reformatted);\n}\nfunction mapAddressObject(formioData: FormIOOnboardingDataScheme, individualModule: IndividualModuleContext) {\n // If individual already has a residential address, simply update it with the new information\n // Otherwise, add new address object\n const {\n addressComponentForm: {\n data: { residentialAddress },\n },\n } = formioData;\n\n const addresses = individualModule.access('addresses');\n const findByAddressId = (address: Address) => address.addressId === residentialAddress.addressId;\n const createResidentialAddress = () => {\n const newAddress = new Address();\n newAddress.addressType = 'RESIDENTIAL';\n return newAddress;\n };\n const existingAddressObject = addresses.getValue().find(findByAddressId);\n\n const addressObject = existingAddressObject ? existingAddressObject : createResidentialAddress();\n addressObject.country = alpha2ToAlpha3(findCountryAlpha2(residentialAddress.address_components));\n // TODO: Does formio only support longForm address? When user manually inputs individual fields does this not return a broken down address?\n addressObject.longForm = residentialAddress.formatted_address;\n addressObject.addressId = residentialAddress.addressId ?? null;\n\n if (existingAddressObject) individualModule.updateAddress(existingAddressObject.addressId, existingAddressObject);\n else individualModule.addAddress(addressObject);\n}\nfunction mapDocumentObjects(formioData: FormIOOnboardingDataScheme, individualModule: IndividualModuleContext) {\n const { documents } = formioData;\n\n const documentObjects = documents\n .filter((doc) =>\n [\n // These are the document types we are including in the conversion\n // Whenever supporting new doc types add it here and add it to\n // the mapSingleDocumentObject function below\n // Also do the same in assignIndividualDataToFormioSdk.ts\n 'PASSPORT',\n 'DRIVERS_LICENCE',\n 'NATIONAL_HEALTH_ID',\n ].includes(doc.genericDocument.data.idType),\n )\n .map((documentData) => mapSingleDocumentObject(documentData.genericDocument.data, individualModule));\n\n documentObjects.forEach((documentObject) => {\n if (documentObject.documentId) individualModule.updateDocument(documentObject.documentId, documentObject);\n else individualModule.addDocument(documentObject);\n });\n}\nfunction mapSingleDocumentObject(\n documentData: FormIOOnboardingDataScheme['documents'][number]['genericDocument']['data'],\n individualModule: IndividualModuleContext,\n): Document {\n // If individual already has a document that matches the returned type from formio, simply update it with the new information\n // Otherwise, add new document object object\n\n // Determine the type of id coming from formio.\n const existingDocumentObject = individualModule\n .access('documents')\n .getValue()\n .find((doc) => doc.documentId === documentData.documentId);\n\n const documentObject: Document = existingDocumentObject ? existingDocumentObject : new Document();\n documentObject.idType = documentData.idType;\n documentObject.documentId = documentData.documentId ?? null;\n\n const idType = documentData.idType;\n\n // TODO: Convert this into a more generic mapping, instead of having a condition for each document type\n if (idType === 'PASSPORT') {\n documentObject.idNumber = documentData.pass_idNumber;\n documentObject.country = documentData.issuingCountry;\n documentObject.idExpiry = documentData.pass_idExpiry;\n } else if (idType === 'DRIVERS_LICENCE') {\n documentObject.country = documentData.issuingCountry;\n documentObject.region = documentData.dl_region;\n documentObject.idNumber = documentData.dl_idNumber;\n documentObject.extraData.document_number = documentData.dl_cardNumber;\n } else if (idType === 'NATIONAL_HEALTH_ID') {\n documentObject.country = 'AUS';\n documentObject.idNumber = documentData.medi_idNumber;\n documentObject.idExpiry = documentData.medi_idExpiry;\n documentObject.extraData.reference = documentData.medi_cardPosition;\n documentObject.idSubType = documentData.medi_cardColour;\n // TODO: map more medicare fields\n } else {\n throw new Error(`Unknown document type '${idType}', can't map unknown data.`);\n }\n\n return documentObject;\n}\n","import type { Document } from '@module/common/shared/models/Document';\n\nimport type { Paths } from 'type-fest';\n\ndeclare global {\n interface Window {\n Formio: {\n createForm: <Schema>(\n mountElement: Node,\n formUrl: string,\n options?: unknown\n ) => Promise<FormIOInstance<Schema>>;\n };\n }\n}\n\nexport type FormIOInstance<Schema> = {\n on: (evName: string, ...args: unknown[]) => void;\n ready: Promise<void>;\n language: string;\n data: Schema; // Check if this is correct\n setSubmission(submission: { data: Partial<Schema> });\n checkValidity: (data, dirty, row, client) => boolean;\n getComponent: <Component>(path: Paths<FormIOOnboardingDataScheme>) => Component;\n redraw: () => Promise<void>;\n};\n\n/** Component types */\nexport type SelectComponent = {\n data: {\n values: { label: string; value: string }[];\n };\n};\n\n/** Formio Onboarding data scheme (legacy form equivalent data) */\nexport type FormIOOnboardingDataScheme = {\n basicPiiForm: {\n data: {\n entityId: string;\n firstName: string;\n middleName: string;\n lastName: string;\n dateOfBirth: string;\n };\n };\n documents: {\n genericDocument: {\n data: {\n documentId: string;\n idType: Document['idType'];\n issuingCountry: string;\n\n dl_region: string;\n dl_idNumber: string;\n dl_cardNumber: string;\n\n pass_idNumber: string;\n pass_idExpiry: string;\n\n medi_idNumber: string;\n medi_cardPosition: string;\n medi_cardColour: string;\n medi_idExpiry: string;\n\n any_idNumber: string;\n };\n };\n }[];\n addressComponentForm: {\n data: {\n useManualAddress: boolean;\n residentialAddress: {\n addressId: string;\n formatted_address: string;\n address_components: {\n long_name: string;\n short_name: string;\n types: string[];\n }[];\n };\n };\n };\n};\n\ntype AddressData = FormIOOnboardingDataScheme['addressComponentForm']['data']['residentialAddress'];\nexport const findCountryAlpha2 = (comps: AddressData['address_components']) => {\n return comps.find((comp) => comp.types.includes('country'))?.short_name ?? null;\n};\n","import type { Document } from '@module/common/shared/models/Document';\nimport type { IndividualModuleContext } from '@module/individual';\n\nimport { alpha3ToAlpha2, alpha3ToName } from './countryData';\n\nimport type { FormIOInstance, FormIOOnboardingDataScheme } from '../formioSdk';\n\nexport function assignIndividualDataToFormioSdk(\n individual: IndividualModuleContext,\n formio: FormIOInstance<FormIOOnboardingDataScheme>,\n) {\n // Take pre existing data from the individual module and inject into the form\n const { givenName, middleName, familyName } = individual.access('name').getValue();\n const dateOfBirth = individual.access('dateOfBirth').getValue();\n const documents = individual.access('documents').getValue();\n const addresses = individual.access('addresses').getValue();\n const entityId = individual.access('entityId').getValue();\n\n const { longForm: addressLongForm, country: addressCountryAlpha3, addressId } = addresses[0] ?? {};\n\n // https://help.form.io/developers/form-development/form-renderer#submission-data\n formio.setSubmission({\n data: {\n basicPiiForm: {\n data: {\n entityId,\n firstName: givenName,\n middleName,\n lastName: familyName,\n dateOfBirth,\n },\n },\n documents: documents\n .filter((doc) =>\n [\n // These are the document types we are including in the conversion\n // Whenever supporting new doc types add it here and add it to\n // the documentObjectToGenericDocumentFields function below\n // Also do the same in assignFormioDataToIndividualModule.ts\n 'PASSPORT',\n 'DRIVERS_LICENCE',\n 'NATIONAL_HEALTH_ID',\n ].includes(doc.idType),\n )\n .map((doc) => ({\n genericDocument: {\n data: documentObjectToGenericDocumentFields(doc),\n },\n })),\n addressComponentForm: {\n data: {\n useManualAddress: false,\n residentialAddress: {\n addressId,\n formatted_address: addressLongForm ?? '',\n address_components: addressCountryAlpha3\n ? [\n {\n long_name: alpha3ToName(addressCountryAlpha3),\n short_name: alpha3ToAlpha2(addressCountryAlpha3),\n types: ['country'],\n },\n ]\n : [],\n },\n },\n },\n },\n });\n}\n\ntype GenericDocumentData = FormIOOnboardingDataScheme['documents'][number]['genericDocument']['data'];\nfunction documentObjectToGenericDocumentFields(documentObject: Document): GenericDocumentData {\n const idType = documentObject.idType;\n const genericDocumentFields = {\n documentId: documentObject.documentId,\n idType,\n issuingCountry: documentObject.country,\n } as GenericDocumentData;\n if (idType === 'PASSPORT') {\n Object.assign(genericDocumentFields, {\n pass_idNumber: documentObject.idNumber,\n pass_idExpiry: documentObject.idExpiry,\n });\n } else if (idType === 'DRIVERS_LICENCE') {\n Object.assign(genericDocumentFields, {\n dl_idNumber: documentObject.idNumber,\n dl_idExpiry: documentObject.idExpiry,\n dl_cardNumber: documentObject.extraData.document_number,\n dl_region: documentObject.region,\n });\n } else if (idType === 'NATIONAL_HEALTH_ID') {\n Object.assign(genericDocumentFields, {\n medi_idNumber: documentObject.idNumber,\n medi_idExpiry: documentObject.idExpiry,\n medi_cardPosition: documentObject.extraData.reference,\n medi_cardColour: documentObject.idSubType,\n // TODO: map more medicare fields\n });\n } else {\n throw new Error(`Unknown document type '${idType}', can't map to formio as this could have unexpected results`);\n }\n\n return genericDocumentFields;\n}\n","import { feat } from '@feature-flags';\nimport { loadAsyncAsset } from '@module/common';\nimport type { WrapperParameters } from '@module/common/modules/defineModule';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport type { FormModule } from '@module/form/definition';\n\nimport { generateScopeStyleOverrides } from './styleOverrides';\nimport {\n assignFormioDataToIndividualModule,\n} from './transformers/assignFormioDataToIndividualModule';\nimport {\n assignIndividualDataToFormioSdk,\n} from './transformers/assignIndividualDataToFormioSdk';\nimport { initialiseFormio } from './transformers/initialiseFormio';\n\nimport type { FormIOOnboardingDataScheme } from './formioSdk';\n\nconst GLOBAL_ASSETS: [string, 'script' | 'style'][] = [\n ['https://cdn.form.io/formiojs/formio.full.js', 'script'],\n // Since fonts won't work when loaded from inside the shadow dom, load FontAwesome icons here\n [\n 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css',\n 'style',\n ],\n // Also the general font chosen for the form in the feature flag\n [feat('modules.form.font.cdnUrl'), 'style'],\n];\nconst SCOPED_STYLES = [\n 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css',\n 'https://cdn.form.io/formiojs/formio.full.min.css',\n];\nconst CONTAINER_CLASSLIST = ['form', 'formio'];\nexport const initialise = defineWrapper<FormModule>('formio', async (\n shared,\n options,\n) => {\n const { mountElement } = options;\n\n mountElement.classList.add(...CONTAINER_CLASSLIST);\n const wrappingMode = feat('modules.form.wrappingMode');\n\n const [styledMountElement, wrapperElement, windowWithFormio] = await ((): Promise<[HTMLElement, Node, Window]> => {\n if (wrappingMode === 'shadow') return attachShadow(mountElement);\n if (wrappingMode === 'iframe') return attachIframe(mountElement);\n return attachDiv(mountElement);\n })();\n\n if (wrappingMode !== 'iframe' && !window.Formio) {\n await Promise.all(GLOBAL_ASSETS.map((asset) => loadAsyncAsset(...asset)));\n } else if (wrappingMode === 'iframe') {\n // Iframe will load the script inside the iframe, so we need to wait for it to load\n await Promise.all(\n GLOBAL_ASSETS.map(([url, type]) =>\n loadAsyncAsset(url, {\n type,\n targetNode: windowWithFormio.document.body,\n }),\n ),\n );\n }\n\n await loadFormio(shared, {\n mountElement: styledMountElement,\n windowWithFormio,\n });\n\n // DONE\n\n const localEventHub = shared.localEventHub;\n localEventHub.emit('loaded', {\n //TODO: make domElement take Node instead of HTMLElement\n domElement: wrapperElement as HTMLElement,\n provider: 'formio',\n });\n\n return {\n cleanup: () => {\n },\n };\n});\nconst addStyles = (mountElement: Node) => {\n const document = mountElement.ownerDocument;\n // Adding scoped styles\n SCOPED_STYLES.forEach((url) => {\n const link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', url);\n mountElement.appendChild(link);\n });\n // Assigning Font styles\n const customStyles = document.createElement('style');\n const fontFamilyName = feat('modules.form.font.fontFamilyCSSRule');\n\n const isShadowDom = mountElement instanceof ShadowRoot;\n const rootSelector = isShadowDom ? ':host' : '.form.formio';\n\n customStyles.innerHTML =\n `${rootSelector} { font-family: ${fontFamilyName} }` + generateScopeStyleOverrides(rootSelector);\n mountElement.appendChild(customStyles);\n};\nconst attachIframe = async (mountElement: HTMLElement): Promise<[HTMLElement, Node, Window]> => {\n const iframe = document.createElement('iframe');\n\n iframe.srcdoc = `<html><body><div class=\"form formio\"></div></body></html>`;\n iframe.style.minHeight = '600px';\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.border = 'none';\n\n mountElement.appendChild(iframe);\n // Wait till iframe parses the srcdoc\n await new Promise((resolve, reject) => {\n iframe.onload = resolve;\n iframe.onerror = reject;\n });\n addStyles(iframe.contentDocument.body);\n const internalMountElement = iframe.contentDocument.querySelector<HTMLElement>('.form.formio');\n return [internalMountElement, iframe, iframe.contentWindow];\n};\nconst attachDiv = async (mountElement: HTMLElement): Promise<[HTMLElement, Node, Window]> => {\n addStyles(mountElement);\n // Formio will remove all contents of the mount element, so we need to create a new internal mountElement\n const internalMountElement = document.createElement('div');\n mountElement.appendChild(internalMountElement);\n return [internalMountElement, mountElement, window];\n};\nconst attachShadow = async (mountElement: HTMLElement): Promise<[HTMLElement, Node, Window]> => {\n const shadowRoot = mountElement.attachShadow({ mode: 'open' });\n addStyles(shadowRoot);\n const internalMountElement = document.createElement('div');\n shadowRoot.appendChild(internalMountElement);\n return [internalMountElement, shadowRoot, window];\n};\n\n// FORM IO LIB\nasync function loadFormio(\n shared: WrapperParameters<FormModule>[0],\n options: { mountElement: HTMLElement; windowWithFormio: Window },\n) {\n const { mountElement, windowWithFormio } = options;\n\n const localEventHub = shared.localEventHub;\n const provider = shared.recipe.form.provider;\n const formUrl = provider.name === 'formio' && provider.formUrl;\n\n const individual = shared.oneSdkInstance.individual();\n\n const [formio] = await Promise.all([\n windowWithFormio.Formio.createForm<FormIOOnboardingDataScheme>(mountElement, formUrl),\n individual.search(),\n ]);\n initialiseFormio(formio);\n // 1) set all listeners first\n formio.ready.then(() => localEventHub.emit('ready', { domElement: mountElement as HTMLElement }));\n formio.on('submitPressed', async () => {\n if (!formio.checkValidity(null, false, null, true)) return;\n // When button is clicked, convert plain formio data to BFF data\n assignFormioDataToIndividualModule(formio.data, individual);\n // Submit data to BFF\n await individual.submit();\n\n const entityId = individual.access('entityId').getValue();\n const applicant = individual.access('__deprecated_applicant').getValue();\n const documents = individual.access('__deprecated_documents').getValue();\n // Emit \"results\" event, just like legacy ui also does.\n localEventHub.emit('results', { applicant, documents, entityId });\n mountElement.innerHTML = '';\n });\n\n assignIndividualDataToFormioSdk(individual, formio);\n\n // set additional configuration. This can be taken from the recipe\n formio.language = 'en';\n}\n","import {\n type FormIOInstance,\n type FormIOOnboardingDataScheme,\n} from '../formioSdk';\n\nexport async function initialiseFormio(formio: FormIOInstance<FormIOOnboardingDataScheme>) {\n // Adding formio instance to the devtools\n const formComponent = window.__ONE_SDK__DEVTOOLS.moduleInstances.components['form'] as {\n formioInstances: FormIOInstance<FormIOOnboardingDataScheme>[];\n };\n if (!formComponent?.formioInstances) formComponent.formioInstances ??= [];\n formComponent.formioInstances.push(formio);\n\n /**\n * Leaving this as an example of how OneSDK can programmatically change formio's components.\n * !Attention: UI Logic should not be done here, but in the formio platform directly.\n * !For example: The list of supported countries for each customer needs to be defined by techops using the drag and drop tool, not programmatically/through recipe.\n * !This will avoid the formio implementation from repeating the same problems of complex configuration we had with the legacy form implementation\n **/\n\n // const issuingCountrySelect = formio.getComponent<SelectComponent>('genericDocument.data.issuingCountry');\n // issuingCountrySelect.data.values = allCountries;\n // await formio.redraw();\n}\n","/**\n *\n * @param rootSelector The root selector to be used to scope the styles\n * @returns\n */\nexport function generateScopeStyleOverrides(rootSelector: string): string {\n const scopedStyleRules = [\n generalStyleOverrides(),\n overrideCardComponent(),\n overrideDataGridComponent(),\n genericClassnames(),\n ];\n // This line will join all the styles declared above and will scope them using the Sass library\n // When not using the shadow dom, this will prevent styles from leaking outside of the form elements\n // return compileString(`${rootSelector} { ${scopedStyleRules.join('\\n')} }`).css;\n\n // Temporarily removed the scoping of the styles, as it was causing issues\n // with the bundler and the way it was handling the styles\n return (`${rootSelector} { ${scopedStyleRules.join('\\n')} }`);\n}\n\n/**\n * Add all the different classnames we want to be available for use in the Formio builder\n * This is our preferred way of styling. Avoid making specific style changes to any HTML elements and simply provide a way for\n * our peers to customise reusable elements.\n * ie: Main titles, Section titles, Description text, Buttons, Section devider, Section Wrappers...\n **/\nfunction genericClassnames() {\n return `\n .main-page-title {\n font-size: 1.2rem;\n font-weight: bold;\n }\n `;\n}\n\n/** Generic styling that doesn't apply to any other category.\n * This might be unwanted and we might want to instead create a classname above such as:\n * .form-input label { ... }\n **/\nfunction generalStyleOverrides() {\n return `\n label {\n font-size: 0.8rem;\n }\n `;\n}\n\n// Below we add very specific styling overrides, which we want to avoid doing, unless absolutely necessary\n\n/**\n * Fix/Remove the appearence of the .card-body,\n * The card appearence is used when we bundle components in \"sections\" called \"Wells\"\n * We used them for example to group the PII, Address and Document fields together\n **/\nfunction overrideCardComponent() {\n return `\n .card.card-body {\n padding: 0;\n background-color: initial !important;\n border: none !important;\n border-width: 0 !important;\n border-color: transparent !important;\n margin-bottom: 0 !important;\n }\n `;\n}\n\n/**\n * Fix/Remove the appearence of the Datagrid component,\n * The datagrid is used is used when we want some form/resource to be rendered multiple times\n * ie: Array of Document objects\n * It looks terrible by default.\n **/\nfunction overrideDataGridComponent() {\n return `\n .formio-component-datagrid table,\n .formio-component-datagrid table tbody,\n .formio-component-datagrid table tr,\n .formio-component-datagrid table td {\n border: none !important;\n border-width: 0 !important;\n border-color: transparent !important;\n }\n\n [ref^=\"datagrid-\"] {\n padding: 0 !important;\n }\n [ref^=\"datagrid-\"]:not(:first-of-type) {\n padding-top: 24px;\n }\n `;\n}\n"],"names":["alpha3ToAlpha2","alpha3","country","alpha2","alpha3ToName","name","Object","keys","filter","code","length","map","value","label","formioToIndividualModulePipeline","formioData","individualModule","basicPiiForm","data","firstName","middleName","lastName","dateOfBirth","access","setValue","givenName","familyName","displayName","reformatted","Date","toISOString","split","addressComponentForm","residentialAddress","existingAddressObject","getValue","find","address","addressId","addressObject","newAddress","Address","addressType","createResidentialAddress","alpha2ToAlpha3","comps","comp","types","includes","short_name","findCountryAlpha2","address_components","longForm","formatted_address","updateAddress","addAddress","documents","doc","genericDocument","idType","documentData","documentObject","documentId","Document","idNumber","pass_idNumber","issuingCountry","idExpiry","pass_idExpiry","region","dl_region","dl_idNumber","extraData","document_number","dl_cardNumber","Error","medi_idNumber","medi_idExpiry","reference","medi_cardPosition","idSubType","medi_cardColour","mapSingleDocumentObject","forEach","updateDocument","addDocument","documentObjectToGenericDocumentFields","genericDocumentFields","assign","dl_idExpiry","GLOBAL_ASSETS","SCOPED_STYLES","CONTAINER_CLASSLIST","initialise","shared","options","mountElement","classList","add","wrappingMode","styledMountElement","wrapperElement","windowWithFormio","attachShadow","attachIframe","attachDiv","window","Formio","Promise","all","url","type","loadAsyncAsset","targetNode","document","body","asset","localEventHub","provider","recipe","form","formUrl","individual","oneSdkInstance","formio","createForm","search","formComponent","__ONE_SDK__DEVTOOLS","moduleInstances","components","formioInstances","push","initialiseFormio","ready","then","emit","domElement","on","checkValidity","transformer","submit","entityId","applicant","innerHTML","addresses","addressLongForm","addressCountryAlpha3","setSubmission","useManualAddress","long_name","assignIndividualDataToFormioSdk","language","loadFormio","cleanup","addStyles","ownerDocument","link","createElement","setAttribute","appendChild","customStyles","fontFamilyName","rootSelector","ShadowRoot","join","generateScopeStyleOverrides","iframe","srcdoc","style","minHeight","width","height","border","resolve","reject","onload","onerror","contentDocument","querySelector","contentWindow","internalMountElement","shadowRoot","mode"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"form-formio.js","mappings":"mMAMO,SAASA,EAAeC,GAC7B,MAAMC,EAAU,KAAUD,GAC1B,OAAOC,EAAUA,EAAQC,OAAS,IACpC,CACO,SAASC,EAAaH,GAC3B,MAAMC,EAAU,KAAUD,GAC1B,OAAOC,EAAUA,EAAQG,KAAO,IAClC,CAE4BC,OAAOC,KAAK,MACrCC,QAAQC,GAAiC,IAAhB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Q,CAACmE,EAASC,KAC1BR,EAAOS,OAASF,EAChBP,EAAOU,QAAUF,CAAM,IAEzBpB,EAAUY,EAAOW,gBAAgBhE,MAE1B,CADsBqD,EAAOW,gBAAgBC,cAA2B,gBACjDZ,EAAQA,EAAOa,cAC/C,IACM5E,EAAmBT,GAAoE,oCAC3F4D,EAAU5D,GAEV,MAAMsF,EAAuBpE,SAAS6C,cAAc,OAEpD,OADA/D,EAAaiE,YAAYqB,GAClB,CAACA,EAAsBtF,EAAcU,OAC9C,IACMH,EAAsBP,GAAoE,oCAC9F,MAAMuF,EAAavF,EAAaO,aAAa,CAAEiF,KAAM,SACrD5B,EAAU2B,GACV,MAAMD,EAAuBpE,SAAS6C,cAAc,OAEpD,OADAwB,EAAWtB,YAAYqB,GAChB,CAACA,EAAsBC,EAAY7E,OAC5C,G","sources":["webpack://OneSdk/./modules/form/vendors/formio/transformers/countryData.ts","webpack://OneSdk/./modules/form/vendors/formio/transformers/assignFormioDataToIndividualModule.ts","webpack://OneSdk/./modules/form/vendors/formio/formioSdk.ts","webpack://OneSdk/./modules/form/vendors/formio/transformers/assignIndividualDataToFormioSdk.ts","webpack://OneSdk/./modules/form/vendors/formio/index.ts","webpack://OneSdk/./modules/form/vendors/formio/transformers/initialiseFormio.ts","webpack://OneSdk/./modules/form/vendors/formio/styleOverrides.ts"],"sourcesContent":["import { countries } from 'country-data';\n\nexport function alpha2ToAlpha3(alpha2: string): string | null {\n const country = countries[alpha2];\n return country ? country.alpha3 : null;\n}\nexport function alpha3ToAlpha2(alpha3: string): string | null {\n const country = countries[alpha3];\n return country ? country.alpha2 : null;\n}\nexport function alpha3ToName(alpha3: string): string | null {\n const country = countries[alpha3];\n return country ? country.name : null;\n}\n\nexport const allCountries = Object.keys(countries)\n .filter((code: string) => code.length === 3)\n .map((alpha3) => ({ value: alpha3, label: alpha3ToName(alpha3) }));\n","import { Address } from '@module/common/shared/models/Address';\nimport { Document } from '@module/common/shared/models/Document';\nimport type { IndividualModuleContext } from '@module/types';\n\nimport { findCountryAlpha2 } from '../formioSdk';\n\nimport { alpha2ToAlpha3 } from './countryData';\n\nimport type { FormIOOnboardingDataScheme } from '../formioSdk';\n\n// In order to increase cohesion, the transformation from formio data into the individual module is done by applying a series of transformations\n// To make sure the transformations aren't too convoluted, each transformation is done in a separate function, for different purposes (pipeline pattern):\n// - mapPIIData will inject name and date of birth into the individual module\n// - mapAddressObject will inject the residential address into the individual module\n// - mapDocumentObject will inject the document into the individual module.\n// !--> This is the place where the mapping for each document type is done <--!\n// All the \"transformer\" functions are defined below\nconst formioToIndividualModulePipeline = [mapPIIData, mapAddressObject, mapDocumentObjects];\nexport const assignFormioDataToIndividualModule = (\n formioData: FormIOOnboardingDataScheme,\n individualModule: IndividualModuleContext,\n) => formioToIndividualModulePipeline.forEach((transformer) => transformer(formioData, individualModule));\n\nfunction mapPIIData(formioData: FormIOOnboardingDataScheme, individualModule: IndividualModuleContext) {\n const {\n basicPiiForm: {\n data: { firstName, middleName, lastName, dateOfBirth },\n },\n } = formioData;\n\n /** NAME, DOB */\n individualModule.access('name').setValue({\n givenName: firstName,\n middleName: middleName,\n familyName: lastName,\n displayName: '',\n });\n const reformatted = new Date(dateOfBirth).toISOString().split('T')[0];\n individualModule.access('dateOfBirth').setValue(reformatted);\n}\nfunction mapAddressObject(formioData: FormIOOnboardingDataScheme, individualModule: IndividualModuleContext) {\n // If individual already has a residential address, simply update it with the new information\n // Otherwise, add new address object\n const {\n addressComponentForm: {\n data: { residentialAddress },\n },\n } = formioData;\n\n const addresses = individualModule.access('addresses');\n const findByAddressId = (address: Address) => address.addressId === residentialAddress.addressId;\n const createResidentialAddress = () => {\n const newAddress = new Address();\n newAddress.addressType = 'RESIDENTIAL';\n return newAddress;\n };\n const existingAddressObject = addresses.getValue().find(findByAddressId);\n\n const addressObject = existingAddressObject ? existingAddressObject : createResidentialAddress();\n addressObject.country = alpha2ToAlpha3(findCountryAlpha2(residentialAddress.address_components));\n // TODO: Does formio only support longForm address? When user manually inputs individual fields does this not return a broken down address?\n addressObject.longForm = residentialAddress.formatted_address;\n addressObject.addressId = residentialAddress.addressId ?? null;\n\n if (existingAddressObject) individualModule.updateAddress(existingAddressObject.addressId, existingAddressObject);\n else individualModule.addAddress(addressObject);\n}\nfunction mapDocumentObjects(formioData: FormIOOnboardingDataScheme, individualModule: IndividualModuleContext) {\n const { documents } = formioData;\n\n const documentObjects = documents\n .filter((doc) =>\n [\n // These are the document types we are including in the conversion\n // Whenever supporting new doc types add it here and add it to\n // the mapSingleDocumentObject function below\n // Also do the same in assignIndividualDataToFormioSdk.ts\n 'PASSPORT',\n 'DRIVERS_LICENCE',\n 'NATIONAL_HEALTH_ID',\n ].includes(doc.genericDocument.data.idType),\n )\n .map((documentData) => mapSingleDocumentObject(documentData.genericDocument.data, individualModule));\n\n documentObjects.forEach((documentObject) => {\n if (documentObject.documentId) individualModule.updateDocument(documentObject.documentId, documentObject);\n else individualModule.addDocument(documentObject);\n });\n}\nfunction mapSingleDocumentObject(\n documentData: FormIOOnboardingDataScheme['documents'][number]['genericDocument']['data'],\n individualModule: IndividualModuleContext,\n): Document {\n // If individual already has a document that matches the returned type from formio, simply update it with the new information\n // Otherwise, add new document object object\n\n // Determine the type of id coming from formio.\n const existingDocumentObject = individualModule\n .access('documents')\n .getValue()\n .find((doc) => doc.documentId === documentData.documentId);\n\n const documentObject: Document = existingDocumentObject ? existingDocumentObject : new Document();\n documentObject.idType = documentData.idType;\n documentObject.documentId = documentData.documentId ?? null;\n\n const idType = documentData.idType;\n\n // TODO: Convert this into a more generic mapping, instead of having a condition for each document type\n if (idType === 'PASSPORT') {\n documentObject.idNumber = documentData.pass_idNumber;\n documentObject.country = documentData.issuingCountry;\n documentObject.idExpiry = documentData.pass_idExpiry;\n } else if (idType === 'DRIVERS_LICENCE') {\n documentObject.country = documentData.issuingCountry;\n documentObject.region = documentData.dl_region;\n documentObject.idNumber = documentData.dl_idNumber;\n documentObject.extraData.document_number = documentData.dl_cardNumber;\n } else if (idType === 'NATIONAL_HEALTH_ID') {\n documentObject.country = 'AUS';\n documentObject.idNumber = documentData.medi_idNumber;\n documentObject.idExpiry = documentData.medi_idExpiry;\n documentObject.extraData.reference = documentData.medi_cardPosition;\n documentObject.idSubType = documentData.medi_cardColour;\n // TODO: map more medicare fields\n } else {\n throw new Error(`Unknown document type '${idType}', can't map unknown data.`);\n }\n\n return documentObject;\n}\n","import type { Document } from '@module/common/shared/models/Document';\n\nimport type { Paths } from 'type-fest';\n\ndeclare global {\n interface Window {\n Formio: {\n createForm: <Schema>(\n mountElement: Node,\n formUrl: string,\n options?: unknown\n ) => Promise<FormIOInstance<Schema>>;\n };\n }\n}\n\nexport type FormIOInstance<Schema> = {\n on: (evName: string, ...args: unknown[]) => void;\n ready: Promise<void>;\n language: string;\n data: Schema; // Check if this is correct\n setSubmission(submission: { data: Partial<Schema> });\n checkValidity: (data, dirty, row, client) => boolean;\n getComponent: <Component>(path: Paths<FormIOOnboardingDataScheme>) => Component;\n redraw: () => Promise<void>;\n};\n\n/** Component types */\nexport type SelectComponent = {\n data: {\n values: { label: string; value: string }[];\n };\n};\n\n/** Formio Onboarding data scheme (legacy form equivalent data) */\nexport type FormIOOnboardingDataScheme = {\n basicPiiForm: {\n data: {\n entityId: string;\n firstName: string;\n middleName: string;\n lastName: string;\n dateOfBirth: string;\n };\n };\n documents: {\n genericDocument: {\n data: {\n documentId: string;\n idType: Document['idType'];\n issuingCountry: string;\n\n dl_region: string;\n dl_idNumber: string;\n dl_cardNumber: string;\n\n pass_idNumber: string;\n pass_idExpiry: string;\n\n medi_idNumber: string;\n medi_cardPosition: string;\n medi_cardColour: string;\n medi_idExpiry: string;\n\n any_idNumber: string;\n };\n };\n }[];\n addressComponentForm: {\n data: {\n useManualAddress: boolean;\n residentialAddress: {\n addressId: string;\n formatted_address: string;\n address_components: {\n long_name: string;\n short_name: string;\n types: string[];\n }[];\n };\n };\n };\n};\n\ntype AddressData = FormIOOnboardingDataScheme['addressComponentForm']['data']['residentialAddress'];\nexport const findCountryAlpha2 = (comps: AddressData['address_components']) => {\n return comps.find((comp) => comp.types.includes('country'))?.short_name ?? null;\n};\n","import type { Document } from '@module/common/shared/models/Document';\nimport type { IndividualModuleContext } from '@module/individual';\n\nimport { alpha3ToAlpha2, alpha3ToName } from './countryData';\n\nimport type { FormIOInstance, FormIOOnboardingDataScheme } from '../formioSdk';\n\nexport function assignIndividualDataToFormioSdk(\n individual: IndividualModuleContext,\n formio: FormIOInstance<FormIOOnboardingDataScheme>,\n) {\n // Take pre existing data from the individual module and inject into the form\n const { givenName, middleName, familyName } = individual.access('name').getValue();\n const dateOfBirth = individual.access('dateOfBirth').getValue();\n const documents = individual.access('documents').getValue();\n const addresses = individual.access('addresses').getValue();\n const entityId = individual.access('entityId').getValue();\n\n const { longForm: addressLongForm, country: addressCountryAlpha3, addressId } = addresses[0] ?? {};\n\n // https://help.form.io/developers/form-development/form-renderer#submission-data\n formio.setSubmission({\n data: {\n basicPiiForm: {\n data: {\n entityId,\n firstName: givenName,\n middleName,\n lastName: familyName,\n dateOfBirth,\n },\n },\n documents: documents\n .filter((doc) =>\n [\n // These are the document types we are including in the conversion\n // Whenever supporting new doc types add it here and add it to\n // the documentObjectToGenericDocumentFields function below\n // Also do the same in assignFormioDataToIndividualModule.ts\n 'PASSPORT',\n 'DRIVERS_LICENCE',\n 'NATIONAL_HEALTH_ID',\n ].includes(doc.idType),\n )\n .map((doc) => ({\n genericDocument: {\n data: documentObjectToGenericDocumentFields(doc),\n },\n })),\n addressComponentForm: {\n data: {\n useManualAddress: false,\n residentialAddress: {\n addressId,\n formatted_address: addressLongForm ?? '',\n address_components: addressCountryAlpha3\n ? [\n {\n long_name: alpha3ToName(addressCountryAlpha3),\n short_name: alpha3ToAlpha2(addressCountryAlpha3),\n types: ['country'],\n },\n ]\n : [],\n },\n },\n },\n },\n });\n}\n\ntype GenericDocumentData = FormIOOnboardingDataScheme['documents'][number]['genericDocument']['data'];\nfunction documentObjectToGenericDocumentFields(documentObject: Document): GenericDocumentData {\n const idType = documentObject.idType;\n const genericDocumentFields = {\n documentId: documentObject.documentId,\n idType,\n issuingCountry: documentObject.country,\n } as GenericDocumentData;\n if (idType === 'PASSPORT') {\n Object.assign(genericDocumentFields, {\n pass_idNumber: documentObject.idNumber,\n pass_idExpiry: documentObject.idExpiry,\n });\n } else if (idType === 'DRIVERS_LICENCE') {\n Object.assign(genericDocumentFields, {\n dl_idNumber: documentObject.idNumber,\n dl_idExpiry: documentObject.idExpiry,\n dl_cardNumber: documentObject.extraData.document_number,\n dl_region: documentObject.region,\n });\n } else if (idType === 'NATIONAL_HEALTH_ID') {\n Object.assign(genericDocumentFields, {\n medi_idNumber: documentObject.idNumber,\n medi_idExpiry: documentObject.idExpiry,\n medi_cardPosition: documentObject.extraData.reference,\n medi_cardColour: documentObject.idSubType,\n // TODO: map more medicare fields\n });\n } else {\n throw new Error(`Unknown document type '${idType}', can't map to formio as this could have unexpected results`);\n }\n\n return genericDocumentFields;\n}\n","import { feat } from '@feature-flags';\nimport { loadAsyncAsset } from '@module/common';\nimport type { WrapperParameters } from '@module/common/modules/defineModule';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport type { FormModule } from '@module/form/definition';\n\nimport { generateScopeStyleOverrides } from './styleOverrides';\nimport {\n assignFormioDataToIndividualModule,\n} from './transformers/assignFormioDataToIndividualModule';\nimport {\n assignIndividualDataToFormioSdk,\n} from './transformers/assignIndividualDataToFormioSdk';\nimport { initialiseFormio } from './transformers/initialiseFormio';\n\nimport type { FormIOOnboardingDataScheme } from './formioSdk';\n\nconst GLOBAL_ASSETS: [string, 'script' | 'style'][] = [\n ['https://cdn.form.io/formiojs/formio.full.js', 'script'],\n // Since fonts won't work when loaded from inside the shadow dom, load FontAwesome icons here\n [\n 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css',\n 'style',\n ],\n // Also the general font chosen for the form in the feature flag\n [feat('modules.form.font.cdnUrl'), 'style'],\n];\nconst SCOPED_STYLES = [\n 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css',\n 'https://cdn.form.io/formiojs/formio.full.min.css',\n];\nconst CONTAINER_CLASSLIST = ['form', 'formio'];\nexport const initialise = defineWrapper<FormModule>('formio', async (\n shared,\n options,\n) => {\n const { mountElement } = options;\n\n mountElement.classList.add(...CONTAINER_CLASSLIST);\n const wrappingMode = feat('modules.form.wrappingMode');\n\n const [styledMountElement, wrapperElement, windowWithFormio] = await ((): Promise<[HTMLElement, Node, Window]> => {\n if (wrappingMode === 'shadow') return attachShadow(mountElement);\n if (wrappingMode === 'iframe') return attachIframe(mountElement);\n return attachDiv(mountElement);\n })();\n\n if (wrappingMode !== 'iframe' && !window.Formio) {\n await Promise.all(GLOBAL_ASSETS.map((asset) => loadAsyncAsset(...asset)));\n } else if (wrappingMode === 'iframe') {\n // Iframe will load the script inside the iframe, so we need to wait for it to load\n await Promise.all(\n GLOBAL_ASSETS.map(([url, type]) =>\n loadAsyncAsset(url, {\n type,\n targetNode: windowWithFormio.document.body,\n }),\n ),\n );\n }\n\n await loadFormio(shared, {\n mountElement: styledMountElement,\n windowWithFormio,\n });\n\n // DONE\n\n const localEventHub = shared.localEventHub;\n localEventHub.emit('loaded', {\n //TODO: make domElement take Node instead of HTMLElement\n domElement: wrapperElement as HTMLElement,\n provider: 'formio',\n });\n\n return {\n cleanup: () => {\n },\n };\n});\nconst addStyles = (mountElement: Node) => {\n const document = mountElement.ownerDocument;\n // Adding scoped styles\n SCOPED_STYLES.forEach((url) => {\n const link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', url);\n mountElement.appendChild(link);\n });\n // Assigning Font styles\n const customStyles = document.createElement('style');\n const fontFamilyName = feat('modules.form.font.fontFamilyCSSRule');\n\n const isShadowDom = mountElement instanceof ShadowRoot;\n const rootSelector = isShadowDom ? ':host' : '.form.formio';\n\n customStyles.innerHTML =\n `${rootSelector} { font-family: ${fontFamilyName} }` + generateScopeStyleOverrides(rootSelector);\n mountElement.appendChild(customStyles);\n};\nconst attachIframe = async (mountElement: HTMLElement): Promise<[HTMLElement, Node, Window]> => {\n const iframe = document.createElement('iframe');\n\n iframe.srcdoc = `<html><body><div class=\"form formio\"></div></body></html>`;\n iframe.style.minHeight = '600px';\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.border = 'none';\n\n mountElement.appendChild(iframe);\n // Wait till iframe parses the srcdoc\n await new Promise((resolve, reject) => {\n iframe.onload = resolve;\n iframe.onerror = reject;\n });\n addStyles(iframe.contentDocument.body);\n const internalMountElement = iframe.contentDocument.querySelector<HTMLElement>('.form.formio');\n return [internalMountElement, iframe, iframe.contentWindow];\n};\nconst attachDiv = async (mountElement: HTMLElement): Promise<[HTMLElement, Node, Window]> => {\n addStyles(mountElement);\n // Formio will remove all contents of the mount element, so we need to create a new internal mountElement\n const internalMountElement = document.createElement('div');\n mountElement.appendChild(internalMountElement);\n return [internalMountElement, mountElement, window];\n};\nconst attachShadow = async (mountElement: HTMLElement): Promise<[HTMLElement, Node, Window]> => {\n const shadowRoot = mountElement.attachShadow({ mode: 'open' });\n addStyles(shadowRoot);\n const internalMountElement = document.createElement('div');\n shadowRoot.appendChild(internalMountElement);\n return [internalMountElement, shadowRoot, window];\n};\n\n// FORM IO LIB\nasync function loadFormio(\n shared: WrapperParameters<FormModule>[0],\n options: { mountElement: HTMLElement; windowWithFormio: Window },\n) {\n const { mountElement, windowWithFormio } = options;\n\n const localEventHub = shared.localEventHub;\n const provider = shared.recipe.form.provider;\n const formUrl = provider.name === 'formio' && provider.formUrl;\n\n const individual = shared.oneSdkInstance.individual();\n\n const [formio] = await Promise.all([\n windowWithFormio.Formio.createForm<FormIOOnboardingDataScheme>(mountElement, formUrl),\n individual.search(),\n ]);\n initialiseFormio(formio);\n // 1) set all listeners first\n formio.ready.then(() => localEventHub.emit('ready', {\n domElement: mountElement as HTMLElement,\n config: provider.config,\n }));\n formio.on('submitPressed', async () => {\n if (!formio.checkValidity(null, false, null, true)) return;\n // When button is clicked, convert plain formio data to BFF data\n assignFormioDataToIndividualModule(formio.data, individual);\n // Submit data to BFF\n await individual.submit();\n\n const entityId = individual.access('entityId').getValue();\n const applicant = individual.access('__deprecated_applicant').getValue();\n const documents = individual.access('__deprecated_documents').getValue();\n // Emit \"results\" event, just like legacy ui also does.\n localEventHub.emit('results', {\n applicant,\n documents,\n entityId,\n });\n mountElement.innerHTML = '';\n });\n\n assignIndividualDataToFormioSdk(individual, formio);\n\n // set additional configuration. This can be taken from the recipe\n formio.language = 'en';\n}\n","import {\n type FormIOInstance,\n type FormIOOnboardingDataScheme,\n} from '../formioSdk';\n\nexport async function initialiseFormio(formio: FormIOInstance<FormIOOnboardingDataScheme>) {\n // Adding formio instance to the devtools\n const formComponent = window.__ONE_SDK__DEVTOOLS.moduleInstances.components['form'] as {\n formioInstances: FormIOInstance<FormIOOnboardingDataScheme>[];\n };\n if (!formComponent?.formioInstances) formComponent.formioInstances ??= [];\n formComponent.formioInstances.push(formio);\n\n /**\n * Leaving this as an example of how OneSDK can programmatically change formio's components.\n * !Attention: UI Logic should not be done here, but in the formio platform directly.\n * !For example: The list of supported countries for each customer needs to be defined by techops using the drag and drop tool, not programmatically/through recipe.\n * !This will avoid the formio implementation from repeating the same problems of complex configuration we had with the legacy form implementation\n **/\n\n // const issuingCountrySelect = formio.getComponent<SelectComponent>('genericDocument.data.issuingCountry');\n // issuingCountrySelect.data.values = allCountries;\n // await formio.redraw();\n}\n","/**\n *\n * @param rootSelector The root selector to be used to scope the styles\n * @returns\n */\nexport function generateScopeStyleOverrides(rootSelector: string): string {\n const scopedStyleRules = [\n generalStyleOverrides(),\n overrideCardComponent(),\n overrideDataGridComponent(),\n genericClassnames(),\n ];\n // This line will join all the styles declared above and will scope them using the Sass library\n // When not using the shadow dom, this will prevent styles from leaking outside of the form elements\n // return compileString(`${rootSelector} { ${scopedStyleRules.join('\\n')} }`).css;\n\n // Temporarily removed the scoping of the styles, as it was causing issues\n // with the bundler and the way it was handling the styles\n return (`${rootSelector} { ${scopedStyleRules.join('\\n')} }`);\n}\n\n/**\n * Add all the different classnames we want to be available for use in the Formio builder\n * This is our preferred way of styling. Avoid making specific style changes to any HTML elements and simply provide a way for\n * our peers to customise reusable elements.\n * ie: Main titles, Section titles, Description text, Buttons, Section devider, Section Wrappers...\n **/\nfunction genericClassnames() {\n return `\n .main-page-title {\n font-size: 1.2rem;\n font-weight: bold;\n }\n `;\n}\n\n/** Generic styling that doesn't apply to any other category.\n * This might be unwanted and we might want to instead create a classname above such as:\n * .form-input label { ... }\n **/\nfunction generalStyleOverrides() {\n return `\n label {\n font-size: 0.8rem;\n }\n `;\n}\n\n// Below we add very specific styling overrides, which we want to avoid doing, unless absolutely necessary\n\n/**\n * Fix/Remove the appearence of the .card-body,\n * The card appearence is used when we bundle components in \"sections\" called \"Wells\"\n * We used them for example to group the PII, Address and Document fields together\n **/\nfunction overrideCardComponent() {\n return `\n .card.card-body {\n padding: 0;\n background-color: initial !important;\n border: none !important;\n border-width: 0 !important;\n border-color: transparent !important;\n margin-bottom: 0 !important;\n }\n `;\n}\n\n/**\n * Fix/Remove the appearence of the Datagrid component,\n * The datagrid is used is used when we want some form/resource to be rendered multiple times\n * ie: Array of Document objects\n * It looks terrible by default.\n **/\nfunction overrideDataGridComponent() {\n return `\n .formio-component-datagrid table,\n .formio-component-datagrid table tbody,\n .formio-component-datagrid table tr,\n .formio-component-datagrid table td {\n border: none !important;\n border-width: 0 !important;\n border-color: transparent !important;\n }\n\n [ref^=\"datagrid-\"] {\n padding: 0 !important;\n }\n [ref^=\"datagrid-\"]:not(:first-of-type) {\n padding-top: 24px;\n }\n `;\n}\n"],"names":["alpha3ToAlpha2","alpha3","country","alpha2","alpha3ToName","name","Object","keys","filter","code","length","map","value","label","formioToIndividualModulePipeline","formioData","individualModule","basicPiiForm","data","firstName","middleName","lastName","dateOfBirth","access","setValue","givenName","familyName","displayName","reformatted","Date","toISOString","split","addressComponentForm","residentialAddress","existingAddressObject","getValue","find","address","addressId","addressObject","newAddress","Address","addressType","createResidentialAddress","alpha2ToAlpha3","comps","comp","types","includes","short_name","findCountryAlpha2","address_components","longForm","formatted_address","updateAddress","addAddress","documents","doc","genericDocument","idType","documentData","documentObject","documentId","Document","idNumber","pass_idNumber","issuingCountry","idExpiry","pass_idExpiry","region","dl_region","dl_idNumber","extraData","document_number","dl_cardNumber","Error","medi_idNumber","medi_idExpiry","reference","medi_cardPosition","idSubType","medi_cardColour","mapSingleDocumentObject","forEach","updateDocument","addDocument","documentObjectToGenericDocumentFields","genericDocumentFields","assign","dl_idExpiry","GLOBAL_ASSETS","SCOPED_STYLES","CONTAINER_CLASSLIST","initialise","shared","options","mountElement","classList","add","wrappingMode","styledMountElement","wrapperElement","windowWithFormio","attachShadow","attachIframe","attachDiv","window","Formio","Promise","all","url","type","loadAsyncAsset","targetNode","document","body","asset","localEventHub","provider","recipe","form","formUrl","individual","oneSdkInstance","formio","createForm","search","formComponent","__ONE_SDK__DEVTOOLS","moduleInstances","components","formioInstances","push","initialiseFormio","ready","then","emit","domElement","config","on","checkValidity","transformer","submit","entityId","applicant","innerHTML","addresses","addressLongForm","addressCountryAlpha3","setSubmission","useManualAddress","long_name","assignIndividualDataToFormioSdk","language","loadFormio","cleanup","addStyles","ownerDocument","link","createElement","setAttribute","appendChild","customStyles","fontFamilyName","rootSelector","ShadowRoot","join","generateScopeStyleOverrides","iframe","srcdoc","style","minHeight","width","height","border","resolve","reject","onload","onerror","contentDocument","querySelector","contentWindow","internalMountElement","shadowRoot","mode"],"sourceRoot":""}
|
package/dist/umd/form-legacy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[823],{
|
|
1
|
+
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[823],{8665:(e,n,E)=>{E.r(n),E.d(n,{initialise:()=>S});var i=E(6604),t=E(4334),o=E(5473);const r=["INIT","FF_SAVE_RESULT","FF_CHECK_RESULT","FF_SAVE_ERROR","FF_CHECK_ERROR","FF_ONBOARDING_WIDGET_DESTROYED","DESTROY","SCREEN:WELCOME","SCREEN:DOCUMENT_TYPE_SELECT","SCREEN:DRIVERS_LICENCE_INPUT","SCREEN:NATIONAL_ID","SCREEN:MEDICARE_INPUT","SCREEN:PASSPORT_INPUT","SCREEN:NAME_INPUT","SCREEN:DOB_INPUT","SCREEN:ADDRESS_INPUT","SCREEN:DETAILS_SUMMARY","SCREEN:FAILURE","SCREEN:SUCCESS","SCREEN:NO_MATCH","SCREEN:PENDING_VERFICATION","SCREEN:ERROR","SCREEN:NAME_INPUT_CHECK","SCREEN:DOB_INPUT_CHECK","SCREEN:MANUAL_ADDRESS_INPUT","SCREEN:ADDITIONAL_ADDRESS_INPUT","SCREEN:ADDRESS_INPUT_CHECK"],a={"SCREEN:WELCOME":"form:welcome:ready","SCREEN:DOCUMENT_TYPE_SELECT":"form:document_type_select:ready","SCREEN:DRIVERS_LICENCE_INPUT":"form:drivers_license_input:ready","SCREEN:NATIONAL_ID":"form:national_id:ready","SCREEN:MEDICARE_INPUT":"form:medicare_input:ready","SCREEN:PASSPORT_INPUT":"form:passport_input:ready","SCREEN:NAME_INPUT":"form:name_input:ready","SCREEN:DOB_INPUT":"form:dob_input:ready","SCREEN:ADDRESS_INPUT":"form:address_input:ready","SCREEN:DETAILS_SUMMARY":"form:details_summary:ready","SCREEN:FAILURE":"form:failure:ready","SCREEN:SUCCESS":"form:success:ready","SCREEN:NO_MATCH":"form:no_match:ready","SCREEN:PENDING_VERFICATION":"form:pending_verification:ready","SCREEN:ERROR":"form:error:ready","SCREEN:NAME_INPUT_CHECK":"form:name_input_check:ready","SCREEN:DOB_INPUT_CHECK":"form:dob_input_check:ready","SCREEN:MANUAL_ADDRESS_INPUT":"form:manual_address_input:ready","SCREEN:ADDITIONAL_ADDRESS_INPUT":"form:additional_address_input:ready","SCREEN:ADDRESS_INPUT_CHECK":"form:address_input_check:ready"};var d=E(1668),c=E(486);const N=e=>e.emit.bind(e);var _=function(e,n,E,i){return new(E||(E=Promise))((function(t,o){function r(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof E?n:new E((function(e){e(n)}))).then(r,a)}d((i=i.apply(e,n||[])).next())}))};const R=["PASSPORT","DRIVERS_LICENCE","NATIONAL_ID","NATIONAL_HEALTH_ID"],S=(0,o.f)("legacy",((...e)=>_(void 0,void 0,void 0,(function*(){var n,E;const{eventListener:o,domElement:S,cleanup:s}=yield function(e){return n=this,E=arguments,o=function*([e,{mountElement:n}]){var E,i;const o=e.recipe.form.provider;if("legacy"!==o.name)throw new Error(`Attempt to initialise the wrong provider of the Legacy UI '${o.name}'`);if(!(null===(E=null===window||void 0===window?void 0:window.frankieFinancial)||void 0===E?void 0:E.initialiseOnboardingWidget)){const e=null!==(i=o.version)&&void 0!==i?i:"v4";yield(0,t.loadAsyncAsset)("https://assets.frankiefinancial.io/onboarding/:version:/ff-onboarding-widget.umd.js".replace(":version:",e))}const a=document.createElement("ff-onboarding-widget");n.appendChild(a);const{cleanup:_,eventListener:R}=function(e){const n={},E=(0,c.y)(),i=N(E);return e.forEach((e=>((e,E)=>{var i;null!==(i=n[e])&&void 0!==i||(n[e]=[]),n[e].push(E),window.addEventListener(e,E)})(e,(n=>{const E=n.detail,t=E instanceof Error?new d.p(E.message,E):E;i(e,t)})))),{cleanup(){Object.entries(n).forEach((([e,n])=>{n.forEach((n=>{window.removeEventListener(e,n)}))}))},eventListener:(0,c.n)(E)}}(r);return{eventListener:R,domElement:a,cleanup:()=>{_(),n.contains(a)&&n.removeChild(a)}}},new((i=void 0)||(i=Promise))((function(e,t){function r(e){try{d(o.next(e))}catch(e){t(e)}}function a(e){try{d(o.throw(e))}catch(e){t(e)}}function d(n){var E;n.done?e(n.value):(E=n.value,E instanceof i?E:new i((function(e){e(E)}))).then(r,a)}d((o=o.apply(n,E||[])).next())}));var n,E,i,o}(e),[C]=e,{localEventHub:l,oneSdkInstance:f,session:u,mode:m,recipe:{form:I}}=C,T=f.individual();l.emit("loaded",{domElement:S,provider:I.provider.name}),o.on("INIT",(({data:e})=>l.emit("ready",{domElement:S,config:e}))),Object.entries(a).forEach((([e,n])=>{o.on(e,(e=>l.emit(n,e)))})),o.on(["FF_CHECK_ERROR","FF_SAVE_ERROR"],(e=>l.emit("error",e))),o.on(["FF_SAVE_RESULT","FF_CHECK_RESULT"],(e=>_(void 0,void 0,void 0,(function*(){yield T.search(),l.emit("results",e)})))),o.on(["DESTROY","FF_ONBOARDING_WIDGET_DESTROYED"],(()=>l.emit("destroy")));const v=T.access("documents").getValue().map((e=>e.idType)).filter((e=>R.includes(e))),A=v.length>0?v:R,D=u.entityId?{entityId:u.entityId}:{applicantReference:u.reference},p=m.is(i.O_.DUMMY),O="legacy"===I.provider.name&&(null!==(E=null===(n=I.provider)||void 0===n?void 0:n.config)&&void 0!==E?E:{});return window.frankieFinancial.initialiseOnboardingWidget(Object.assign(Object.assign({},D),{ffToken:p?null:u.token,width:"100%",height:"100%",config:Object.assign(Object.assign({documentTypes:A},O),{mode:p?"demo":"production",frankieBackendUrl:p?(0,t.env2url)(t.ENVIRONMENTS.development):u.environment,idScanVerification:!1,enableDeviceCharacteristics:!1})})),{cleanup:s}}))))}}]);
|
|
2
2
|
//# sourceMappingURL=form-legacy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-legacy.js","mappings":"oLAwDA,MAAMA,EAA4BC,GAAiBA,EAAGC,KAAKC,KAAKF,G,0SC1ChE,MAAMG,EAAiD,CACrD,WACA,kBACA,cACA,sBAEWC,GAAa,OAA0B,UAAU,IAAUC,IAAS,oC,QAC/E,MACEC,cAAeC,EAAqB,WACpCC,EAAU,QACVC,SCbG,SAA4B,G,uCAACC,GAAa,aAAEC,K,QACjD,MAAMC,EAAWF,EAAYG,OAAOC,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Q4B,MACtCC,MAAO,OACPC,OAAQ,OACRzB,OAAQ,OAAF,sBACJa,iBACGQ,GAAqB,CACxBzB,KAAMsB,EAAc,OAAS,aAI7BQ,kBAAmBR,GAAc,IAAAS,SAAQ,EAAAC,aAAaC,aAAelC,EAAQmC,YAG7EC,oBAAoB,EACpBC,6BAA6B,OAI1B,CACL/E,UAEJ,K","sources":["webpack://OneSdk/./modules/common/modules/eventHub/windowEventHub.ts","webpack://OneSdk/./modules/form/vendors/legacy/index.ts","webpack://OneSdk/./modules/form/vendors/legacy/loadLegacyUI.ts"],"sourcesContent":["import { OneSDKError } from '@module/common/errors/OneSDKError.class';\nimport type { KeyOf } from '@types';\n\nimport { mkEventHub, mkEventListener } from '.';\n\nimport type { EventsDictionary, KeyOfExtendedEvents, EventHub } from './types';\n\n/**\n * This function is used to create an event hub that listens to events emitted by the window object.\n * This function will convert Error objects into OneSDKError objects.\n * @param autoEmitEventNames - The names of the events that should be listened to and reemitted automatically\n * @returns A cleanup method and an event listener\n */\nexport function mkWindowEventHub<Events extends EventsDictionary>(autoEmitEventNames: KeyOf<Events>[]) {\n type EventListenerCallback<T> = (event: CustomEvent<T>) => void;\n\n const listeners: {\n [key: string]: EventListenerCallback<unknown>[];\n } = {};\n\n const FormEventHub = mkEventHub<Events>();\n const emitToEventHub = extractGenericEmitMethod(FormEventHub);\n\n const addEventListener = (\n eventName: string,\n listener: EventListenerCallback<unknown>,\n ) => {\n listeners[eventName] ??= [];\n listeners[eventName].push(listener);\n\n window.addEventListener(eventName, listener);\n };\n autoEmitEventNames.forEach((eventName) =>\n addEventListener(eventName, (customEvent) => {\n const detail = customEvent.detail;\n const data = detail instanceof Error ? new OneSDKError(detail.message, detail) : detail;\n\n emitToEventHub(eventName as unknown as KeyOfExtendedEvents<Events>, data);\n }),\n );\n\n return {\n cleanup() {\n Object.entries(listeners).forEach(([eventName, listeners]) => {\n listeners.forEach((listener) => {\n window.removeEventListener(eventName, listener);\n });\n });\n },\n eventListener: mkEventListener(FormEventHub),\n };\n}\n\n/**\n * This function is simply used to simplify typescript's type inference\n */\nconst extractGenericEmitMethod = (eh: EventHub) => eh.emit.bind(eh) as (\n en: string,\n data: unknown\n) => void;\n","import { SdkMode } from '@frankieone/one-sdk';\nimport { ENVIRONMENTS, env2url } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport type { Document } from '@module/common/shared/models/Document';\nimport type { DeepPartial } from '@module/common/shared/models/general';\nimport type { FormModule } from '@module/form/definition';\n\nimport { loadLegacyUI } from './loadLegacyUI';\n\nimport type {\n LegacyUIConfiguration,\n SupportedDocumentType,\n} from './legacyUIOptions.types';\n\nconst SUPPORTED_DOCUMENT_TYPES: Document['idType'][] = [\n 'PASSPORT',\n 'DRIVERS_LICENCE',\n 'NATIONAL_ID',\n 'NATIONAL_HEALTH_ID',\n];\nexport const initialise = defineWrapper<FormModule>('legacy', async (...args) => {\n const {\n eventListener: legacyUIEventListener,\n domElement,\n cleanup,\n } = await loadLegacyUI(args);\n\n const [sharedState] = args;\n const {\n localEventHub,\n oneSdkInstance,\n session,\n mode,\n recipe: { form },\n } = sharedState;\n const individual = oneSdkInstance.individual();\n\n localEventHub.emit('loaded', { domElement, provider: 'legacy' });\n\n // setup events\n legacyUIEventListener.on('INIT', () => localEventHub.emit('ready', { domElement }));\n legacyUIEventListener.on('INIT', ({ data }) =>\n localEventHub.emit('info', {\n message: 'Legacy UI Initialised',\n payload: {\n config: data,\n },\n }),\n );\n legacyUIEventListener.on([\n 'FF_CHECK_ERROR',\n 'FF_SAVE_ERROR',\n ], (error) => localEventHub.emit('error', error));\n legacyUIEventListener.on('FF_SAVE_RESULT', async ({\n applicant,\n documents,\n }) => {\n cleanup();\n await individual.search();\n localEventHub.emit('results', {\n applicant,\n documents,\n entityId: applicant.entityId,\n });\n });\n legacyUIEventListener.on('FF_CHECK_RESULT', async ({\n applicant,\n documents,\n }) => {\n await individual.search();\n localEventHub.emit('results', {\n applicant,\n documents,\n entityId: applicant.entityId,\n });\n });\n legacyUIEventListener.on('FF_CHECK_RESULT', () =>\n localEventHub.emit('warning', {\n message: `Legacy UI emitted check results.`,\n }),\n );\n legacyUIEventListener.on('FF_ONBOARDING_WIDGET_DESTROYED', cleanup);\n\n // Initialise legacy ui\n const documents = individual.access('documents').getValue();\n // Select document types belonging to the entity\n const entityDocumentTypes = documents\n .map((document) => document.idType)\n .filter((idType): idType is SupportedDocumentType => SUPPORTED_DOCUMENT_TYPES.includes(idType));\n // prettier-ignore\n const documentTypes = entityDocumentTypes.length > 0\n ? entityDocumentTypes\n : SUPPORTED_DOCUMENT_TYPES as SupportedDocumentType[];\n\n const entityIdentifier = session.entityId\n ? { entityId: session.entityId }\n : { applicantReference: session.reference };\n const isDummyMode = mode.is(SdkMode.DUMMY);\n const legacyUIConfiguration = form.provider.name === 'legacy' && (form.provider?.config ?? {});\n\n window.frankieFinancial.initialiseOnboardingWidget({\n ...entityIdentifier,\n ffToken: isDummyMode ? null : session.token,\n width: '100%',\n height: '100%',\n config: {\n documentTypes,\n ...legacyUIConfiguration,\n mode: isDummyMode ? 'demo' : 'production',\n // Legacy ui requires a valid frankieone url to be provided,\n // and the session.environment in dummy mode won't be one for that\n // reason here in dummy mode we simply pass the development url\n frankieBackendUrl: isDummyMode ? env2url(ENVIRONMENTS.development) : session.environment,\n // Disabling the following features in Legacy UI that is already\n // powered by onesdk\n idScanVerification: false,\n enableDeviceCharacteristics: false,\n },\n });\n\n return {\n cleanup,\n };\n});\n\ndeclare global {\n type Options = {\n ffToken: string;\n width?: string;\n height?: string;\n config?: DeepPartial<LegacyUIConfiguration>;\n selector?: string;\n shadow?: boolean;\n entityId?: string;\n applicantReference?: string;\n };\n\n interface Window {\n frankieFinancial: {\n initialiseOnboardingWidget: (options: Options) => void;\n };\n }\n}\n","import { loadAsyncAsset } from '@module/common';\nimport type { WrapperParameters } from '@module/common/modules/defineModule';\nimport {\n mkWindowEventHub,\n} from '@module/common/modules/eventHub/windowEventHub';\nimport type { FormModule } from '@module/form/definition';\n\nimport type { LegacyUIEvents } from './legacyUIEvents.types';\n\nconst CDN_URL = 'https://assets.frankiefinancial.io/onboarding/:version:/ff-onboarding-widget.umd.js';\n\nexport async function loadLegacyUI([globalState, { mountElement }]: WrapperParameters<FormModule>) {\n const provider = globalState.recipe.form.provider;\n if (provider.name !== 'legacy')\n throw new Error(`Attempt to initialise the wrong provider of the Legacy UI '${provider.name}'`);\n\n // Don't load legacy ui twice\n if (!window?.frankieFinancial?.initialiseOnboardingWidget) {\n const version = provider.version ?? 'v4';\n await loadAsyncAsset(CDN_URL.replace(':version:', version));\n }\n\n const legacyUIElement = document.createElement('ff-onboarding-widget');\n mountElement.appendChild(legacyUIElement);\n\n const {\n cleanup: eventsCleanup,\n eventListener,\n } = mkWindowEventHub<LegacyUIEvents>([\n 'FF_CHECK_RESULT',\n 'FF_CHECK_ERROR',\n 'FF_SAVE_RESULT',\n 'FF_SAVE_ERROR',\n 'INIT',\n 'FF_ONBOARDING_WIDGET_DESTROYED',\n ]);\n\n const cleanup = () => {\n eventsCleanup();\n if (mountElement.contains(legacyUIElement)) mountElement.removeChild(legacyUIElement);\n };\n\n return { eventListener, domElement: legacyUIElement, cleanup };\n}\n"],"names":["extractGenericEmitMethod","eh","emit","bind","SUPPORTED_DOCUMENT_TYPES","initialise","args","eventListener","legacyUIEventListener","domElement","cleanup","globalState","mountElement","provider","recipe","form","name","Error","window","frankieFinancial","initialiseOnboardingWidget","version","loadAsyncAsset","replace","legacyUIElement","document","createElement","appendChild","eventsCleanup","autoEmitEventNames","listeners","FormEventHub","emitToEventHub","forEach","eventName","listener","push","addEventListener","customEvent","detail","data","message","Object","entries","removeEventListener","mkWindowEventHub","contains","removeChild","loadLegacyUI","sharedState","localEventHub","oneSdkInstance","session","mode","individual","on","payload","config","error","applicant","documents","search","entityId","entityDocumentTypes","access","getValue","map","idType","filter","includes","documentTypes","length","entityIdentifier","applicantReference","reference","isDummyMode","is","DUMMY","legacyUIConfiguration","ffToken","token","width","height","frankieBackendUrl","env2url","ENVIRONMENTS","development","environment","idScanVerification","enableDeviceCharacteristics"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"form-legacy.js","mappings":"kKAuEO,MAuBMA,EAA8C,CACzD,OACA,iBACA,kBACA,gBACA,iBACA,iCACA,UA7BA,iBACA,8BACA,+BACA,qBACA,wBACA,wBACA,oBACA,mBACA,uBACA,yBACA,iBACA,iBACA,kBACA,6BACA,eACA,0BACA,yBACA,8BACA,kCACA,8BAcWC,EAA0E,CACrF,iBAAkB,qBAClB,8BAA+B,kCAC/B,+BAAgC,mCAChC,qBAAsB,yBACtB,wBAAyB,4BACzB,wBAAyB,4BACzB,oBAAqB,wBACrB,mBAAoB,uBACpB,uBAAwB,2BACxB,yBAA0B,6BAC1B,iBAAkB,qBAClB,iBAAkB,qBAClB,kBAAmB,sBACnB,6BAA8B,kCAC9B,eAAgB,mBAChB,0BAA2B,8BAC3B,yBAA0B,6BAC1B,8BAA+B,kCAC/B,kCAAmC,sCACnC,6BAA8B,kC,uBCrEhC,MAAMC,EAA4BC,GAAiBA,EAAGC,KAAKC,KAAKF,G,0SCjChE,MAAMG,EAAiD,CACrD,WACA,kBACA,cACA,sBAEWC,GAAa,OAA0B,UAAU,IAAUC,IAAS,oC,QAC/E,MACEC,cAAeC,EAAqB,WACpCC,EAAU,QACVC,SCpBG,SAA4B,G,uCAACC,GAAa,aAAEC,K,QACjD,MAAMC,EAAWF,EAAYG,OAAOC,KAAKF,SACzC,GAAsB,WAAlBA,EAASG,KACX,MAAM,IAAIC,MAAM,8DAA8DJ,EAASG,SAGzF,KAA6B,QAAxB,EAAM,OAANE,aAAM,IAANA,YAAM,EAANA,OAAQC,wBAAgB,eAAEC,4BAA4B,CACzD,MAAMC,EAA0B,QAAhB,EAAAR,EAASQ,eAAO,QAAI,WAC9B,IAAAC,gBAVM,sFAUiBC,QAAQ,YAAaF,GACpD,CAEA,MAAMG,EAAkBC,SAASC,cAAc,wBAC/Cd,EAAae,YA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,QAAS0D,KAG1CpD,EAAsB+C,GAAG,CACvB,iBACA,oBACQI,GAAmC,0CACrCL,EAAWO,SACjBX,EAAchD,KAAK,UAAWyD,EAChC,MAGAnD,EAAsB+C,GAAG,CACvB,UACA,mCACC,IAAML,EAAchD,KAAK,aAG5B,MAEM4D,EAFYR,EAAWS,OAAO,aAAaC,WAG9CC,KAAKxC,GAAaA,EAASyC,SAC3BC,QAAQD,GAA4C9D,EAAyBgE,SAASF,KAEnFG,EAAgBP,EAAoBQ,OAAS,EAC/CR,EACA1D,EAEEmE,EAAmBnB,EAAQoB,SAC7B,CAAEA,SAAUpB,EAAQoB,UACpB,CAAEC,mBAAoBrB,EAAQsB,WAC5BC,EAActB,EAAKuB,GAAG,KAAQC,OAC9BC,EAA+C,WAAvB/D,EAAKF,SAASG,OAA2C,QAArB,EAAa,QAAb,EAAAD,EAAKF,gBAAQ,eAAE2C,cAAM,QAAI,CAAC,GAsB5F,OApBAtC,OAAOC,iBAAiBC,2BAA2B,OAAD,wBAC7CmD,GAAgB,CACnBQ,QAASJ,EAAc,KAAOvB,EAAQ4B,MACtCC,MAAO,OACPC,OAAQ,OACR1B,OAAQ,OAAF,sBACJa,iBACGS,GAAqB,CACxBzB,KAAMsB,EAAc,OAAS,aAI7BQ,kBAAmBR,GAAc,IAAAS,SAAQ,EAAAC,aAAaC,aAAelC,EAAQmC,YAG7EC,oBAAoB,EACpBC,6BAA6B,OAI1B,CACL/E,UAEJ,K","sources":["webpack://OneSdk/./modules/form/vendors/legacy/legacyUIEvents.types.ts","webpack://OneSdk/./modules/common/modules/eventHub/windowEventHub.ts","webpack://OneSdk/./modules/form/vendors/legacy/index.ts","webpack://OneSdk/./modules/form/vendors/legacy/loadLegacyUI.ts"],"sourcesContent":["import type { OneSDKError } from '@module/common';\nimport type { Applicant } from '@module/common/shared/models/Applicant';\nimport type { Document } from '@module/common/shared/models/Document';\nimport type { FormEvents } from '@module/form/events';\nimport type { CheckSummary } from '@module/types';\n\nimport type { LegacyUIConfiguration } from './legacyUIOptions.types';\n\n// use all events defined above to create a object type mapping event name to a tuple of [all data in the detail field]\nexport type LegacyUIScreenEvents = {\n 'SCREEN:WELCOME': [LegacyUIScreenPayload];\n 'SCREEN:DOCUMENT_TYPE_SELECT': [LegacyUIScreenPayload];\n 'SCREEN:DRIVERS_LICENCE_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:NATIONAL_ID': [LegacyUIScreenPayload];\n 'SCREEN:MEDICARE_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:PASSPORT_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:NAME_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:DOB_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:ADDRESS_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:DETAILS_SUMMARY': [LegacyUIScreenPayload];\n 'SCREEN:FAILURE': [LegacyUIScreenPayload];\n 'SCREEN:SUCCESS': [LegacyUIScreenPayload];\n 'SCREEN:NO_MATCH': [LegacyUIScreenPayload];\n 'SCREEN:PENDING_VERFICATION': [LegacyUIScreenPayload];\n 'SCREEN:ERROR': [LegacyUIScreenPayload];\n 'SCREEN:NAME_INPUT_CHECK': [LegacyUIScreenPayload];\n 'SCREEN:DOB_INPUT_CHECK': [LegacyUIScreenPayload];\n 'SCREEN:MANUAL_ADDRESS_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:ADDITIONAL_ADDRESS_INPUT': [LegacyUIScreenPayload];\n 'SCREEN:ADDRESS_INPUT_CHECK': [LegacyUIScreenPayload];\n}\n\nexport type LegacyUIEvents = {\n INIT: [{ data: LegacyUIConfiguration }];\n FF_SAVE_RESULT: [LegacyUIResultPayload];\n FF_CHECK_RESULT: [LegacyUIResultPayload];\n FF_SAVE_ERROR: [OneSDKError];\n FF_CHECK_ERROR: [OneSDKError];\n FF_ONBOARDING_WIDGET_DESTROYED: [];\n DESTROY: [];\n} & LegacyUIScreenEvents\n\n\nexport type LegacyUIScreenPayload = {\n readonly applicant?: Applicant;\n readonly documents?: Document[];\n readonly checkSummary?: CheckSummary;\n readonly name: string;\n readonly customerId: string;\n readonly sessionId: string;\n readonly timeStamp: string;\n readonly data: {\n [field: string]: string | boolean | number;\n };\n readonly channel: string | null;\n readonly version: string | null;\n readonly deviceType: string | null;\n readonly browser: string | null;\n}\n\nexport type LegacyUIResultPayload = {\n readonly applicant: Applicant;\n readonly documents: Document[];\n readonly attemptCount: number;\n readonly maxAttemptCount: number;\n readonly isCheckingAddress: boolean;\n readonly isCheckingIDs: boolean;\n readonly isSaveOnly: boolean;\n readonly checkSummary?: CheckSummary;\n readonly resultSlug?: 'success' | 'pending-success' | 'too-many-tries' | 'no-match' | 'partial-match';\n}\nexport const LegacyUIScreenEventKeys: (keyof LegacyUIScreenEvents)[] = [\n 'SCREEN:WELCOME',\n 'SCREEN:DOCUMENT_TYPE_SELECT',\n 'SCREEN:DRIVERS_LICENCE_INPUT',\n 'SCREEN:NATIONAL_ID',\n 'SCREEN:MEDICARE_INPUT',\n 'SCREEN:PASSPORT_INPUT',\n 'SCREEN:NAME_INPUT',\n 'SCREEN:DOB_INPUT',\n 'SCREEN:ADDRESS_INPUT',\n 'SCREEN:DETAILS_SUMMARY',\n 'SCREEN:FAILURE',\n 'SCREEN:SUCCESS',\n 'SCREEN:NO_MATCH',\n 'SCREEN:PENDING_VERFICATION',\n 'SCREEN:ERROR',\n 'SCREEN:NAME_INPUT_CHECK',\n 'SCREEN:DOB_INPUT_CHECK',\n 'SCREEN:MANUAL_ADDRESS_INPUT',\n 'SCREEN:ADDITIONAL_ADDRESS_INPUT',\n 'SCREEN:ADDRESS_INPUT_CHECK',\n];\n\nexport const LegacyUIEventKeys: (keyof LegacyUIEvents)[] = [\n 'INIT',\n 'FF_SAVE_RESULT',\n 'FF_CHECK_RESULT',\n 'FF_SAVE_ERROR',\n 'FF_CHECK_ERROR',\n 'FF_ONBOARDING_WIDGET_DESTROYED',\n 'DESTROY',\n ...LegacyUIScreenEventKeys,\n];\n\nexport const LegacyUIEventDict: Record<keyof LegacyUIScreenEvents, keyof FormEvents> = {\n 'SCREEN:WELCOME': 'form:welcome:ready',\n 'SCREEN:DOCUMENT_TYPE_SELECT': 'form:document_type_select:ready',\n 'SCREEN:DRIVERS_LICENCE_INPUT': 'form:drivers_license_input:ready',\n 'SCREEN:NATIONAL_ID': 'form:national_id:ready',\n 'SCREEN:MEDICARE_INPUT': 'form:medicare_input:ready',\n 'SCREEN:PASSPORT_INPUT': 'form:passport_input:ready',\n 'SCREEN:NAME_INPUT': 'form:name_input:ready',\n 'SCREEN:DOB_INPUT': 'form:dob_input:ready',\n 'SCREEN:ADDRESS_INPUT': 'form:address_input:ready',\n 'SCREEN:DETAILS_SUMMARY': 'form:details_summary:ready',\n 'SCREEN:FAILURE': 'form:failure:ready',\n 'SCREEN:SUCCESS': 'form:success:ready',\n 'SCREEN:NO_MATCH': 'form:no_match:ready',\n 'SCREEN:PENDING_VERFICATION': 'form:pending_verification:ready',\n 'SCREEN:ERROR': 'form:error:ready',\n 'SCREEN:NAME_INPUT_CHECK': 'form:name_input_check:ready',\n 'SCREEN:DOB_INPUT_CHECK': 'form:dob_input_check:ready',\n 'SCREEN:MANUAL_ADDRESS_INPUT': 'form:manual_address_input:ready',\n 'SCREEN:ADDITIONAL_ADDRESS_INPUT': 'form:additional_address_input:ready',\n 'SCREEN:ADDRESS_INPUT_CHECK': 'form:address_input_check:ready',\n};\n","import { OneSDKError } from '@module/common/errors/OneSDKError.class';\nimport type { KeyOf } from '@types';\n\nimport { mkEventHub, mkEventListener } from '.';\n\nimport type { EventsDictionary, KeyOfExtendedEvents, EventHub } from './types';\n\n/**\n * This function is used to create an event hub that listens to events emitted by the window object.\n * This function will convert Error objects into OneSDKError objects.\n * @param autoEmitEventNames - The names of the events that should be listened to and reemitted automatically\n * @returns A cleanup method and an event listener\n */\nexport function mkWindowEventHub<Events extends EventsDictionary>(autoEmitEventNames: KeyOf<Events>[]) {\n type EventListenerCallback<T> = (event: CustomEvent<T>) => void;\n\n const listeners: {\n [key: string]: EventListenerCallback<unknown>[];\n } = {};\n\n const FormEventHub = mkEventHub<Events>();\n const emitToEventHub = extractGenericEmitMethod(FormEventHub);\n\n const addEventListener = (\n eventName: string,\n listener: EventListenerCallback<unknown>,\n ) => {\n listeners[eventName] ??= [];\n listeners[eventName].push(listener);\n\n window.addEventListener(eventName, listener);\n };\n autoEmitEventNames.forEach((eventName) =>\n addEventListener(eventName, (customEvent) => {\n const detail = customEvent.detail;\n const data = detail instanceof Error ? new OneSDKError(detail.message, detail) : detail;\n\n emitToEventHub(eventName as unknown as KeyOfExtendedEvents<Events>, data);\n }),\n );\n\n return {\n cleanup() {\n Object.entries(listeners).forEach(([eventName, listeners]) => {\n listeners.forEach((listener) => {\n window.removeEventListener(eventName, listener);\n });\n });\n },\n eventListener: mkEventListener(FormEventHub),\n };\n}\n\n/**\n * This function is simply used to simplify typescript's type inference\n */\nconst extractGenericEmitMethod = (eh: EventHub) => eh.emit.bind(eh) as (\n en: string,\n data: unknown\n) => void;\n","import { SdkMode } from '@frankieone/one-sdk';\nimport { env2url, ENVIRONMENTS } from '@module/common';\nimport { defineWrapper } from '@module/common/modules/defineModule';\nimport type { Document } from '@module/common/shared/models/Document';\nimport type { DeepPartial } from '@module/common/shared/models/general';\nimport type { FormModule } from '@module/form/definition';\nimport type { FormEvents } from '@module/form/events';\nimport type {\n LegacyUIResultPayload,\n LegacyUIScreenEvents,\n LegacyUIScreenPayload,\n} from '@module/form/vendors/legacy/legacyUIEvents.types';\nimport {\n LegacyUIEventDict,\n} from '@module/form/vendors/legacy/legacyUIEvents.types';\n\nimport { loadLegacyUI } from './loadLegacyUI';\n\nimport type {\n LegacyUIConfiguration,\n SupportedDocumentType,\n} from './legacyUIOptions.types';\n\nconst SUPPORTED_DOCUMENT_TYPES: Document['idType'][] = [\n 'PASSPORT',\n 'DRIVERS_LICENCE',\n 'NATIONAL_ID',\n 'NATIONAL_HEALTH_ID',\n];\nexport const initialise = defineWrapper<FormModule>('legacy', async (...args) => {\n const {\n eventListener: legacyUIEventListener,\n domElement,\n cleanup,\n } = await loadLegacyUI(args);\n\n const [sharedState] = args;\n const {\n localEventHub,\n oneSdkInstance,\n session,\n mode,\n recipe: { form },\n } = sharedState;\n const individual = oneSdkInstance.individual();\n\n localEventHub.emit('loaded', { domElement, provider: form.provider.name });\n\n // setup events\n legacyUIEventListener.on('INIT', ({ data }) =>\n localEventHub.emit('ready', {\n domElement,\n config: data,\n }));\n\n // screen events\n Object.entries(LegacyUIEventDict)\n .forEach(([screenEvents, formEvents]: [keyof LegacyUIScreenEvents, keyof FormEvents]) => {\n legacyUIEventListener.on(screenEvents, (payload: LegacyUIScreenPayload) =>\n localEventHub.emit(formEvents, payload));\n });\n // error events\n legacyUIEventListener.on([\n 'FF_CHECK_ERROR',\n 'FF_SAVE_ERROR',\n ], (error) => localEventHub.emit('error', error));\n\n // check events\n legacyUIEventListener.on([\n 'FF_SAVE_RESULT',\n 'FF_CHECK_RESULT',\n ], async (payload: LegacyUIResultPayload) => {\n await individual.search();\n localEventHub.emit('results', payload);\n });\n\n // destroy events\n legacyUIEventListener.on([\n 'DESTROY',\n 'FF_ONBOARDING_WIDGET_DESTROYED',\n ], () => localEventHub.emit('destroy'));\n\n // Initialise legacy ui\n const documents = individual.access('documents').getValue();\n // Select document types belonging to the entity\n const entityDocumentTypes = documents\n .map((document) => document.idType)\n .filter((idType): idType is SupportedDocumentType => SUPPORTED_DOCUMENT_TYPES.includes(idType));\n // prettier-ignore\n const documentTypes = entityDocumentTypes.length > 0\n ? entityDocumentTypes\n : SUPPORTED_DOCUMENT_TYPES as SupportedDocumentType[];\n\n const entityIdentifier = session.entityId\n ? { entityId: session.entityId }\n : { applicantReference: session.reference };\n const isDummyMode = mode.is(SdkMode.DUMMY);\n const legacyUIConfiguration = form.provider.name === 'legacy' && (form.provider?.config ?? {});\n\n window.frankieFinancial.initialiseOnboardingWidget({\n ...entityIdentifier,\n ffToken: isDummyMode ? null : session.token,\n width: '100%',\n height: '100%',\n config: {\n documentTypes,\n ...legacyUIConfiguration,\n mode: isDummyMode ? 'demo' : 'production',\n // Legacy ui requires a valid frankieone url to be provided,\n // and the session.environment in dummy mode won't be one for that\n // reason here in dummy mode we simply pass the development url\n frankieBackendUrl: isDummyMode ? env2url(ENVIRONMENTS.development) : session.environment,\n // Disabling the following features in Legacy UI that is already\n // powered by onesdk\n idScanVerification: false,\n enableDeviceCharacteristics: false,\n },\n });\n\n return {\n cleanup,\n };\n});\n\ndeclare global {\n type Options = {\n ffToken: string;\n width?: string;\n height?: string;\n config?: DeepPartial<LegacyUIConfiguration>;\n selector?: string;\n shadow?: boolean;\n entityId?: string;\n applicantReference?: string;\n };\n\n interface Window {\n frankieFinancial: {\n initialiseOnboardingWidget: (options: Options) => void;\n };\n }\n}\n","import { loadAsyncAsset } from '@module/common';\nimport type { WrapperParameters } from '@module/common/modules/defineModule';\nimport {\n mkWindowEventHub,\n} from '@module/common/modules/eventHub/windowEventHub';\nimport type { FormModule } from '@module/form/definition';\n\nimport { LegacyUIEventKeys } from './legacyUIEvents.types';\n\nimport type { LegacyUIEvents } from './legacyUIEvents.types';\n\nconst CDN_URL = 'https://assets.frankiefinancial.io/onboarding/:version:/ff-onboarding-widget.umd.js';\n\nexport async function loadLegacyUI([globalState, { mountElement }]: WrapperParameters<FormModule>) {\n const provider = globalState.recipe.form.provider;\n if (provider.name !== 'legacy')\n throw new Error(`Attempt to initialise the wrong provider of the Legacy UI '${provider.name}'`);\n\n // Don't load legacy ui twice\n if (!window?.frankieFinancial?.initialiseOnboardingWidget) {\n const version = provider.version ?? 'v4';\n await loadAsyncAsset(CDN_URL.replace(':version:', version));\n }\n\n const legacyUIElement = document.createElement('ff-onboarding-widget');\n mountElement.appendChild(legacyUIElement);\n\n const {\n cleanup: eventsCleanup,\n eventListener,\n } = mkWindowEventHub<LegacyUIEvents>(LegacyUIEventKeys);\n\n const cleanup = () => {\n eventsCleanup();\n if (mountElement.contains(legacyUIElement)) mountElement.removeChild(legacyUIElement);\n };\n\n return { eventListener, domElement: legacyUIElement, cleanup };\n}\n"],"names":["LegacyUIEventKeys","LegacyUIEventDict","extractGenericEmitMethod","eh","emit","bind","SUPPORTED_DOCUMENT_TYPES","initialise","args","eventListener","legacyUIEventListener","domElement","cleanup","globalState","mountElement","provider","recipe","form","name","Error","window","frankieFinancial","initialiseOnboardingWidget","version","loadAsyncAsset","replace","legacyUIElement","document","createElement","appendChild","eventsCleanup","autoEmitEventNames","listeners","FormEventHub","emitToEventHub","forEach","eventName","listener","push","addEventListener","customEvent","detail","data","message","Object","entries","removeEventListener","mkWindowEventHub","contains","removeChild","loadLegacyUI","sharedState","localEventHub","oneSdkInstance","session","mode","individual","on","config","screenEvents","formEvents","payload","error","search","entityDocumentTypes","access","getValue","map","idType","filter","includes","documentTypes","length","entityIdentifier","entityId","applicantReference","reference","isDummyMode","is","DUMMY","legacyUIConfiguration","ffToken","token","width","height","frankieBackendUrl","env2url","ENVIRONMENTS","development","environment","idScanVerification","enableDeviceCharacteristics"],"sourceRoot":""}
|