@frankieone/one-sdk 0.7.3-rc → 0.8.0-alpha
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/idv/vendors/Mastercard/iframe.d.ts.map +1 -1
- package/dist/esm/modules/idv/vendors/Mastercard/iframe.js +11 -4
- package/dist/esm/modules/idv/vendors/Mastercard/iframe.js.map +1 -1
- package/dist/esm/modules/meta.json +1 -1
- package/dist/release.txt +2 -2
- package/dist/umd/929.js +1 -1
- package/dist/umd/929.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 +1 -1
package/dist/commit.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
4c6f1d90f8db299dd2887551dfbfde75803717e9
|
|
2
|
+
4c6f1d90f8db299dd2887551dfbfde75803717e9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../../../../../../modules/idv/vendors/Mastercard/iframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAA+B,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,EAAE,EAAE,CAAC;CACX,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../../../../../../modules/idv/vendors/Mastercard/iframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAA+B,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,EAAE,EAAE,CAAC;CACX,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CAwBlH;AACD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,CAAC,cAAc,CAAC,CAWlG"}
|
|
@@ -6,10 +6,17 @@ import { SdkModes } from "../../../sdk/types";
|
|
|
6
6
|
*/
|
|
7
7
|
export function createIframe(globalState, vendorParameters) {
|
|
8
8
|
const iframe = document.createElement("iframe");
|
|
9
|
-
|
|
10
|
-
iframe.style
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
// Styling reset based on https://www.easeout.co/blog/2020-06-16-css-resets-normalizing/
|
|
10
|
+
Object.assign(iframe.style, {
|
|
11
|
+
border: 0,
|
|
12
|
+
margin: 0,
|
|
13
|
+
padding: 0,
|
|
14
|
+
width: "100%",
|
|
15
|
+
height: "100%",
|
|
16
|
+
fontSize: "100%",
|
|
17
|
+
font: "inherit",
|
|
18
|
+
verticalAlign: "baseline",
|
|
19
|
+
});
|
|
13
20
|
iframe.allow = "camera;fullscreen;accelerometer;gyroscope;magnetometer";
|
|
14
21
|
const isDummy = globalState.mode.is(SdkModes.DUMMY);
|
|
15
22
|
if (isDummy) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.js","sourceRoot":"","sources":["../../../../../../modules/idv/vendors/Mastercard/iframe.ts"],"names":[],"mappings":"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
|
|
|
1
|
-
{ "version": "0.
|
|
1
|
+
{ "version": "0.8.0-alpha" }
|
package/dist/release.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
v0.
|
|
1
|
+
v0.8.0-alpha
|
|
2
|
+
v0.8.0-alpha
|
package/dist/umd/929.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[929],{3929:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>r});var
|
|
1
|
+
"use strict";(self.webpackChunkOneSdk=self.webpackChunkOneSdk||[]).push([[929],{3929:(e,t,n)=>{n.r(t),n.d(t,{initialise:()=>r});var c=n(9434),o=n(6932),i=n(7549),s=n(1306);var a=function(e,t,n,c){return new(n||(n=Promise))((function(o,i){function s(e){try{r(c.next(e))}catch(e){i(e)}}function a(e){try{r(c.throw(e))}catch(e){i(e)}}function r(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}r((c=c.apply(e,t||[])).next())}))};const r=(0,c.J)("mastercard",((e,t)=>a(void 0,void 0,void 0,(function*(){const{frankieClient:n,localEventHub:c}=e,r=new o.Bv(n),{vendorParameters:u,entityId:l}=yield r.getToken();c.emit("session_data_generated",{session:Object.assign(Object.assign({},u),{entityId:l})});const m=function(e,t){const n=document.createElement("iframe");return Object.assign(n.style,{border:0,margin:0,padding:0,width:"100%",height:"100%",fontSize:"100%",font:"inherit",verticalAlign:"baseline"}),n.allow="camera;fullscreen;accelerometer;gyroscope;magnetometer",e.mode.is(s.Z.DUMMY)?n.srcdoc='<body style="background-color: white">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n setTimeout(() => {\n window.parent.postMessage(JSON.stringify({ payload: { value: "loaded" } }), "*");\n }, DUMMY_LOAD_DELAY);\n function cancelClicked() {\n window.parent.postMessage(JSON.stringify({ payload: { value: "error" } }), "*");\n }\n function completeClicked() {\n window.parent.postMessage(JSON.stringify({ payload: { value: "success" }, workflowExecutionId: "random-execution-id" }), "*");\n }\n <\/script>\n <h1>Mastercard IDV iframe contents</h1>\n <button onclick="cancelClicked()">Cancel</button>\n <button onclick="completeClicked()">Complete</button>\n</body>':n.src=t.tokenURL,n}(e,u),k=function(e){const t=(0,i.mkEventHub)();return window.addEventListener("message",(n=>{n.source===e.contentWindow&&function(e,t){const n=JSON.parse(t.data),c=n.payload;e.emit("info",{message:`Received message ${c.value}`,payload:n}),"loaded"===c.value?e.emit("loaded"):"success"===c.value?e.emit("success",{workflowId:n.workflowExecutionId}):"error"===c.value?e.emit("error"):e.emit("warning",{message:`Unexpected message ${c.value}`,payload:n})}(t,n)}),!1),(0,i.mkEventListener)(t)}(m);k.on("success",(({workflowId:e})=>a(void 0,void 0,void 0,(function*(){d({internalEventHub:k,iframe:m}),c.emit("detection_complete");const t=yield r.initProcess({isSynchronous:!0,vendorParameters:{checkId:e}});!function(e){const{eventHub:t,results:n,entityId:c}=e;switch(n.checkStatus){case o.ck.COMPLETE:t.emit("results",{checkStatus:n.checkStatus,document:n.ocrDocument,entityId:c});break;case o.ck.FAILED:t.emit("results",{checkStatus:n.checkStatus,document:null,entityId:c});break;case o.ck.INCOMPLETE:t.emit("processing",{checkStatus:n.checkStatus,entityId:c});break;case o.ck.DOCUMENTS_INVALID:case o.ck.WAITING_DOC_UPLOAD:case o.ck.WAITING_SELFIE_UPLOAD:t.emit("input_required",{entityId:c},n.checkStatus);break;case o.ck.PROVIDER_OFFLINE:case o.ck.AWAITING_CONSENT:{const e=n.checkStatus===o.ck.PROVIDER_OFFLINE?`Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${o.ck.PROVIDER_OFFLINE}`:"Consent was not provided to the IDV Api. We can't continue.";t.emit("error",new i.OneSDKError(e,{errorStatus:n.checkStatus}))}}}({eventHub:c,results:t,entityId:l})})))),k.on("error",(()=>{d({internalEventHub:k,iframe:m}),c.emit("detection_failed",{message:"General error from the Mastercard component"})})),k.on("loaded",(()=>{c.emit("ready",{domElement:m})}));const{mountElement:f}=t;f.appendChild(m)}))));function d(e){e.iframe.srcdoc="",e.internalEventHub.off(),e.iframe.remove()}}}]);
|
|
2
2
|
//# sourceMappingURL=929.js.map
|
package/dist/umd/929.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"929.js","mappings":"sdAOO,MAAMA,GAAa,OAAyB,cAAc,CAAOC,EAAaC,IAAY,OAAD,6BAE9F,MAAM,cAAEC,EAAa,cAAEC,GAAkBH,EAKnCI,EAAY,IAAIC,EAAA,GAAUH,IAG1B,iBAAEI,EAAgB,SAAEC,SAAmBH,EAAUI,WAGvDL,EAAcM,KAAK,yBAA0B,CAAEC,QAAS,OAAF,wBAAOJ,GAAgB,CAAEC,eAI/E,MAAMI,ECVD,SAAsBX,EAA4BM,GACvD,MAAMK,EAASC,SAASC,cAAc,UAetC,OAdAF,EAAOG,MAAMC,MAAQ,OACrBJ,EAAOG,MAAME,OAAS,OACtBL,EAAOG,MAAMG,OAAS,OACtBN,EAAOG,MAAMI,SAAW,OACxBP,EAAOQ,MAAQ,yDAECnB,EAAYoB,KAAKC,GAAG,WAGlCV,EAAOW,OAqCQ,ksBAnCfX,EAAOY,IAAMjB,EAAiBkB,SAGzBb,CACT,CDPiBc,CAAazB,EAAaM,GAEnCoB,ECUD,SAAmCf,GACxC,MAAMgB,GAAsB,IAAAC,cAS5B,OAPAC,OAAOC,iBACL,WACCC,IACKA,EAAQC,SAAWrB,EAAOsB,eAMpC,SAA2BC,EAAoCC,GAE7D,MAAMC,EAA2BC,KAAKC,MAAMH,EAAMI,MAC5CC,EAAUJ,EAAYI,QAE5BN,EAASzB,KAAK,OAAQ,CAAEsB,QAAS,oBAAoBS,EAAQC,QAASD,QAASJ,IACzD,WAAlBI,EAAQC,MAAoBP,EAASzB,KAAK,UACnB,YAAlB+B,EAAQC,MAAqBP,EAASzB,KAAK,UAAW,CAAEiC,WAAYN,EAAYO,sBAC9D,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B,GAAG,UAAU,KAC1B5C,EAAcM,KAAK,QAAS,CAAEmD,WAAYjD,GAAS,IAMrD,MAAM,aAAEkD,GAAiB5D,EACzB4D,EAAaC,YAAYnD,EAC3B,MAKA,SAASqC,EAAQe,GACfA,EAAapD,OAAOW,OAAS,GAC7ByC,EAAad,iBAAiBe,MAC9BD,EAAapD,OAAOsD,QACtB,C","sources":["webpack://OneSdk/./modules/idv/vendors/Mastercard/index.ts","webpack://OneSdk/./modules/idv/vendors/Mastercard/iframe.ts","webpack://OneSdk/./modules/idv/vendors/Mastercard/statusMapping.ts"],"sourcesContent":["import { EventListener } from \"@module/common\";\nimport { defineWrapper } from \"@module/common/modules/defineModule\";\nimport { IDVClient } from \"@module/frankie-client/clients/IDVClient\";\nimport { IDVModule } from \"@module/idv/definition\";\nimport { createIframe, createIframeEventListener } from \"./iframe\";\nimport { onCheckResults } from \"./statusMapping\";\n\nexport const initialise = defineWrapper<IDVModule>(\"mastercard\", async (globalState, options) => {\n // load mastercard token/iframe url from IDVClient\n const { frankieClient, localEventHub } = globalState;\n /* */\n\n /********* 0) FETCH SESSION DATA */\n\n const idvClient = new IDVClient(frankieClient);\n // Mastercard generates a token an an url to be used in the iframe\n // During the same call, if the entity doesn't exist yet, Frankie cretes one and returns the new entity id\n const { vendorParameters, entityId } = await idvClient.getToken<{ tokenURL: string }>();\n // TODO: Add entity id to the individual module and trigger a reload of the enity data\n // Emit session_data_generated for information purposes only. This has no functionality\n localEventHub.emit(\"session_data_generated\", { session: { ...vendorParameters, entityId } });\n\n /********* 1) CREATE IFRAME */\n\n const iframe = createIframe(globalState, vendorParameters);\n // Abstract message listening for the iframe into a regular event listener\n const iframeListener = createIframeEventListener(iframe);\n\n /********* 2) MAP EVENTS */\n\n // iframe \"SUCCESS\" => emits \"detection_complete\", trigger checks and runs cleanup\n iframeListener.on(\"success\", async ({ workflowId }) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n\n localEventHub.emit(\"detection_complete\");\n\n const results = await idvClient.initProcess({\n isSynchronous: true,\n vendorParameters: {\n checkId: workflowId,\n },\n });\n\n onCheckResults({\n eventHub: localEventHub,\n results,\n entityId,\n });\n });\n // iframe \"ERROR\" => emits \"detection_failed\" and runs cleanup\n iframeListener.on(\"error\", () => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // TODO: better error message and reason\n localEventHub.emit(\"detection_failed\", { message: \"General error from the Mastercard component\" });\n });\n // iframe \"LOOADED\" => emits \"ready\"\n iframeListener.on(\"loaded\", () => {\n localEventHub.emit(\"ready\", { domElement: iframe });\n });\n\n /********* 3) MOUNT IFRAME */\n\n // Inject iframe in the provider DOM container\n const { mountElement } = options;\n mountElement.appendChild(iframe);\n});\n\n/**\n * Cleanup\n */\nfunction cleanup(dependencies: { internalEventHub: EventListener; iframe: HTMLIFrameElement }) {\n dependencies.iframe.srcdoc = \"\";\n dependencies.internalEventHub.off();\n dependencies.iframe.remove();\n}\n","import { EventHub, EventListener, mkEventHub, mkEventListener } from \"@module/common\";\nimport { InjectedState } from \"@module/common/types\";\nimport { SdkModes } from \"@module/sdk/types\";\n\ntype IFrameMessages = {\n loaded: [];\n success: [{ workflowId: string }];\n error: [];\n};\n\n/**\n * Create and return an iframe element configured according to globalState and vendorParameters returned from api\n * @returns The iframe element\n */\nexport function createIframe(globalState: InjectedState, vendorParameters: { tokenURL: string }): HTMLIFrameElement {\n const iframe = document.createElement(\"iframe\");\n iframe.style.width = \"100%\";\n iframe.style.height = \"100%\";\n iframe.style.resize = \"both\";\n iframe.style.overflow = \"auto\";\n iframe.allow = \"camera;fullscreen;accelerometer;gyroscope;magnetometer\";\n\n const isDummy = globalState.mode.is(SdkModes.DUMMY);\n\n if (isDummy) {\n iframe.srcdoc = DUMMY_HTML;\n } else {\n iframe.src = vendorParameters.tokenURL;\n }\n\n return iframe;\n}\n/**\n * Listening to messages from the iframe\n * @returns an event hub that will listen to messages from the iframe\n */\nexport function createIframeEventListener(iframe: HTMLIFrameElement): EventListener<IFrameMessages> {\n const iframeEventListener = mkEventHub<IFrameMessages>();\n // Listen to messages from the provided iframe only\n window.addEventListener(\n \"message\",\n (message) => {\n if (message.source === iframe.contentWindow) onMessageReceived(iframeEventListener, message);\n },\n false\n );\n return mkEventListener(iframeEventListener);\n}\nfunction onMessageReceived(eventHub: EventHub<IFrameMessages>, event: MessageEvent<string>) {\n type MessageData = { payload: { value: string }; workflowExecutionId: string };\n const messageData: MessageData = JSON.parse(event.data);\n const payload = messageData.payload;\n\n eventHub.emit(\"info\", { message: `Received message ${payload.value}`, payload: messageData });\n if (payload.value === \"loaded\") eventHub.emit(\"loaded\");\n else if (payload.value === \"success\") eventHub.emit(\"success\", { workflowId: messageData.workflowExecutionId });\n else if (payload.value === \"error\") eventHub.emit(\"error\");\n else eventHub.emit(\"warning\", { message: `Unexpected message ${payload.value}`, payload: messageData });\n}\n/**\n * DUMMY implementation of the iframe contents\n */\nconst DUMMY_HTML = `<body style=\"background-color: white\">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n setTimeout(() => {\n window.parent.postMessage(JSON.stringify({ payload: { value: \"loaded\" } }), \"*\");\n }, DUMMY_LOAD_DELAY);\n function cancelClicked() {\n window.parent.postMessage(JSON.stringify({ payload: { value: \"error\" } }), \"*\");\n }\n function completeClicked() {\n window.parent.postMessage(JSON.stringify({ payload: { value: \"success\" }, workflowExecutionId: \"random-execution-id\" }), \"*\");\n }\n </script>\n <h1>Mastercard IDV iframe contents</h1>\n <button onclick=\"cancelClicked()\">Cancel</button>\n <button onclick=\"completeClicked()\">Complete</button>\n</body>`;\n","import { EventHub, OneSDKError } from \"@module/common\";\nimport { IDVStatus } from \"@module/frankie-client/clients/IDVClient\";\nimport { IDVModule } from \"@module/idv/definition\";\nimport { Document } from \"../../../common/shared/models/Document\";\n\ntype IDVEventHub = EventHub<IDVModule[\"moduleEvents\"]>;\n\n/**\n * Interpret results from initProcess endpoint and emit appropriate events\n * @param results\n */\nexport function onCheckResults(options: {\n eventHub: IDVEventHub;\n results: { checkStatus: IDVStatus; ocrDocument?: Document };\n entityId: string;\n}) {\n const { eventHub, results, entityId } = options;\n switch (results.checkStatus) {\n case IDVStatus.COMPLETE:\n {\n eventHub.emit(\"results\", {\n checkStatus: results.checkStatus,\n document: results.ocrDocument,\n entityId,\n });\n }\n break;\n case IDVStatus.FAILED:\n {\n eventHub.emit(\"results\", {\n checkStatus: results.checkStatus,\n document: null,\n entityId,\n });\n }\n break;\n case IDVStatus.INCOMPLETE:\n {\n eventHub.emit(\"processing\", {\n checkStatus: results.checkStatus,\n entityId,\n });\n }\n break;\n case IDVStatus.DOCUMENTS_INVALID:\n case IDVStatus.WAITING_DOC_UPLOAD:\n case IDVStatus.WAITING_SELFIE_UPLOAD:\n {\n eventHub.emit(\"input_required\", { entityId }, results.checkStatus);\n }\n break;\n case IDVStatus.PROVIDER_OFFLINE:\n case IDVStatus.AWAITING_CONSENT:\n {\n const errorMessage =\n results.checkStatus === IDVStatus.PROVIDER_OFFLINE\n ? `Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${IDVStatus.PROVIDER_OFFLINE}`\n : \"Consent was not provided to the IDV Api. We can't continue.\";\n eventHub.emit(\n \"error\",\n new OneSDKError(errorMessage, {\n errorStatus: results.checkStatus,\n })\n );\n }\n break;\n }\n}\n"],"names":["initialise","globalState","options","frankieClient","localEventHub","idvClient","IDVClient","vendorParameters","entityId","getToken","emit","session","iframe","document","createElement","style","width","height","resize","overflow","allow","mode","is","srcdoc","src","tokenURL","createIframe","iframeListener","iframeEventListener","mkEventHub","window","addEventListener","message","source","contentWindow","eventHub","event","messageData","JSON","parse","data","payload","value","workflowId","workflowExecutionId","onMessageReceived","mkEventListener","createIframeEventListener","on","cleanup","internalEventHub","results","initProcess","isSynchronous","checkId","checkStatus","ocrDocument","errorMessage","OneSDKError","errorStatus","onCheckResults","domElement","mountElement","appendChild","dependencies","off","remove"],"sourceRoot":""}
|
|
1
|
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Qe,GACfA,EAAa1D,OAAOiB,OAAS,GAC7ByC,EAAad,iBAAiBe,MAC9BD,EAAa1D,OAAO4D,QACtB,C","sources":["webpack://OneSdk/./modules/idv/vendors/Mastercard/index.ts","webpack://OneSdk/./modules/idv/vendors/Mastercard/iframe.ts","webpack://OneSdk/./modules/idv/vendors/Mastercard/statusMapping.ts"],"sourcesContent":["import { EventListener } from \"@module/common\";\nimport { defineWrapper } from \"@module/common/modules/defineModule\";\nimport { IDVClient } from \"@module/frankie-client/clients/IDVClient\";\nimport { IDVModule } from \"@module/idv/definition\";\nimport { createIframe, createIframeEventListener } from \"./iframe\";\nimport { onCheckResults } from \"./statusMapping\";\n\nexport const initialise = defineWrapper<IDVModule>(\"mastercard\", async (globalState, options) => {\n // load mastercard token/iframe url from IDVClient\n const { frankieClient, localEventHub } = globalState;\n /* */\n\n /********* 0) FETCH SESSION DATA */\n\n const idvClient = new IDVClient(frankieClient);\n // Mastercard generates a token an an url to be used in the iframe\n // During the same call, if the entity doesn't exist yet, Frankie cretes one and returns the new entity id\n const { vendorParameters, entityId } = await idvClient.getToken<{ tokenURL: string }>();\n // TODO: Add entity id to the individual module and trigger a reload of the enity data\n // Emit session_data_generated for information purposes only. This has no functionality\n localEventHub.emit(\"session_data_generated\", { session: { ...vendorParameters, entityId } });\n\n /********* 1) CREATE IFRAME */\n\n const iframe = createIframe(globalState, vendorParameters);\n // Abstract message listening for the iframe into a regular event listener\n const iframeListener = createIframeEventListener(iframe);\n\n /********* 2) MAP EVENTS */\n\n // iframe \"SUCCESS\" => emits \"detection_complete\", trigger checks and runs cleanup\n iframeListener.on(\"success\", async ({ workflowId }) => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n\n localEventHub.emit(\"detection_complete\");\n\n const results = await idvClient.initProcess({\n isSynchronous: true,\n vendorParameters: {\n checkId: workflowId,\n },\n });\n\n onCheckResults({\n eventHub: localEventHub,\n results,\n entityId,\n });\n });\n // iframe \"ERROR\" => emits \"detection_failed\" and runs cleanup\n iframeListener.on(\"error\", () => {\n // cleanup immediately to prevent attempts to redirect internally\n cleanup({ internalEventHub: iframeListener, iframe });\n // TODO: better error message and reason\n localEventHub.emit(\"detection_failed\", { message: \"General error from the Mastercard component\" });\n });\n // iframe \"LOOADED\" => emits \"ready\"\n iframeListener.on(\"loaded\", () => {\n localEventHub.emit(\"ready\", { domElement: iframe });\n });\n\n /********* 3) MOUNT IFRAME */\n\n // Inject iframe in the provider DOM container\n const { mountElement } = options;\n mountElement.appendChild(iframe);\n});\n\n/**\n * Cleanup\n */\nfunction cleanup(dependencies: { internalEventHub: EventListener; iframe: HTMLIFrameElement }) {\n dependencies.iframe.srcdoc = \"\";\n dependencies.internalEventHub.off();\n dependencies.iframe.remove();\n}\n","import { EventHub, EventListener, mkEventHub, mkEventListener } from \"@module/common\";\nimport { InjectedState } from \"@module/common/types\";\nimport { SdkModes } from \"@module/sdk/types\";\n\ntype IFrameMessages = {\n loaded: [];\n success: [{ workflowId: string }];\n error: [];\n};\n\n/**\n * Create and return an iframe element configured according to globalState and vendorParameters returned from api\n * @returns The iframe element\n */\nexport function createIframe(globalState: InjectedState, vendorParameters: { tokenURL: string }): HTMLIFrameElement {\n const iframe = document.createElement(\"iframe\");\n // Styling reset based on https://www.easeout.co/blog/2020-06-16-css-resets-normalizing/\n Object.assign(iframe.style, {\n border: 0,\n margin: 0,\n padding: 0,\n width: \"100%\",\n height: \"100%\",\n fontSize: \"100%\",\n font: \"inherit\",\n verticalAlign: \"baseline\",\n });\n iframe.allow = \"camera;fullscreen;accelerometer;gyroscope;magnetometer\";\n\n const isDummy = globalState.mode.is(SdkModes.DUMMY);\n\n if (isDummy) {\n iframe.srcdoc = DUMMY_HTML;\n } else {\n iframe.src = vendorParameters.tokenURL;\n }\n\n return iframe;\n}\n/**\n * Listening to messages from the iframe\n * @returns an event hub that will listen to messages from the iframe\n */\nexport function createIframeEventListener(iframe: HTMLIFrameElement): EventListener<IFrameMessages> {\n const iframeEventListener = mkEventHub<IFrameMessages>();\n // Listen to messages from the provided iframe only\n window.addEventListener(\n \"message\",\n (message) => {\n if (message.source === iframe.contentWindow) onMessageReceived(iframeEventListener, message);\n },\n false\n );\n return mkEventListener(iframeEventListener);\n}\nfunction onMessageReceived(eventHub: EventHub<IFrameMessages>, event: MessageEvent<string>) {\n type MessageData = { payload: { value: string }; workflowExecutionId: string };\n const messageData: MessageData = JSON.parse(event.data);\n const payload = messageData.payload;\n\n eventHub.emit(\"info\", { message: `Received message ${payload.value}`, payload: messageData });\n if (payload.value === \"loaded\") eventHub.emit(\"loaded\");\n else if (payload.value === \"success\") eventHub.emit(\"success\", { workflowId: messageData.workflowExecutionId });\n else if (payload.value === \"error\") eventHub.emit(\"error\");\n else eventHub.emit(\"warning\", { message: `Unexpected message ${payload.value}`, payload: messageData });\n}\n/**\n * DUMMY implementation of the iframe contents\n */\nconst DUMMY_HTML = `<body style=\"background-color: white\">\n <script>\n const DUMMY_LOAD_DELAY = 500;\n setTimeout(() => {\n window.parent.postMessage(JSON.stringify({ payload: { value: \"loaded\" } }), \"*\");\n }, DUMMY_LOAD_DELAY);\n function cancelClicked() {\n window.parent.postMessage(JSON.stringify({ payload: { value: \"error\" } }), \"*\");\n }\n function completeClicked() {\n window.parent.postMessage(JSON.stringify({ payload: { value: \"success\" }, workflowExecutionId: \"random-execution-id\" }), \"*\");\n }\n </script>\n <h1>Mastercard IDV iframe contents</h1>\n <button onclick=\"cancelClicked()\">Cancel</button>\n <button onclick=\"completeClicked()\">Complete</button>\n</body>`;\n","import { EventHub, OneSDKError } from \"@module/common\";\nimport { IDVStatus } from \"@module/frankie-client/clients/IDVClient\";\nimport { IDVModule } from \"@module/idv/definition\";\nimport { Document } from \"../../../common/shared/models/Document\";\n\ntype IDVEventHub = EventHub<IDVModule[\"moduleEvents\"]>;\n\n/**\n * Interpret results from initProcess endpoint and emit appropriate events\n * @param results\n */\nexport function onCheckResults(options: {\n eventHub: IDVEventHub;\n results: { checkStatus: IDVStatus; ocrDocument?: Document };\n entityId: string;\n}) {\n const { eventHub, results, entityId } = options;\n switch (results.checkStatus) {\n case IDVStatus.COMPLETE:\n {\n eventHub.emit(\"results\", {\n checkStatus: results.checkStatus,\n document: results.ocrDocument,\n entityId,\n });\n }\n break;\n case IDVStatus.FAILED:\n {\n eventHub.emit(\"results\", {\n checkStatus: results.checkStatus,\n document: null,\n entityId,\n });\n }\n break;\n case IDVStatus.INCOMPLETE:\n {\n eventHub.emit(\"processing\", {\n checkStatus: results.checkStatus,\n entityId,\n });\n }\n break;\n case IDVStatus.DOCUMENTS_INVALID:\n case IDVStatus.WAITING_DOC_UPLOAD:\n case IDVStatus.WAITING_SELFIE_UPLOAD:\n {\n eventHub.emit(\"input_required\", { entityId }, results.checkStatus);\n }\n break;\n case IDVStatus.PROVIDER_OFFLINE:\n case IDVStatus.AWAITING_CONSENT:\n {\n const errorMessage =\n results.checkStatus === IDVStatus.PROVIDER_OFFLINE\n ? `Provider is offline. Either switch providers and restart or skip IDV temporarily. Status ${IDVStatus.PROVIDER_OFFLINE}`\n : \"Consent was not provided to the IDV Api. We can't continue.\";\n eventHub.emit(\n \"error\",\n new OneSDKError(errorMessage, {\n errorStatus: results.checkStatus,\n })\n );\n }\n break;\n }\n}\n"],"names":["initialise","globalState","options","frankieClient","localEventHub","idvClient","IDVClient","vendorParameters","entityId","getToken","emit","session","iframe","document","createElement","Object","assign","style","border","margin","padding","width","height","fontSize","font","verticalAlign","allow","mode","is","srcdoc","src","tokenURL","createIframe","iframeListener","iframeEventListener","mkEventHub","window","addEventListener","message","source","contentWindow","eventHub","event","messageData","JSON","parse","data","payload","value","workflowId","workflowExecutionId","onMessageReceived","mkEventListener","createIframeEventListener","on","cleanup","internalEventHub","results","initProcess","isSynchronous","checkId","checkStatus","ocrDocument","errorMessage","OneSDKError","errorStatus","onCheckResults","domElement","mountElement","appendChild","dependencies","off","remove"],"sourceRoot":""}
|