UNPKG

local-id-scan-journey

Version:

A React component for GBG ID verification and document scanning with bundled SDK

3 lines (2 loc) 7.58 kB
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useRef as n,useState as o,useEffect as t}from"react";var c=function(){return c=Object.assign||function(e){for(var r,n=1,o=arguments.length;n<o;n++)for(var t in r=arguments[n])Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e},c.apply(this,arguments)};function a(e,r,n,o){return new(n||(n=Promise))((function(t,c){function a(e){try{s(o.next(e))}catch(e){c(e)}}function i(e){try{s(o.throw(e))}catch(e){c(e)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,i)}s((o=o.apply(e,r||[])).next())}))}function i(e,r){var n,o,t,c={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=i(0),a.throw=i(1),a.return=i(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(c=0)),c;)try{if(n=1,o&&(t=2&i[0]?o.return:i[0]?o.throw||((t=o.return)&&t.call(o),0):o.next)&&!(t=t.call(o,i[1])).done)return t;switch(o=0,t&&(i=[2&i[0],t.value]),i[0]){case 0:case 1:t=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(t=c.trys,(t=t.length>0&&t[t.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!t||i[1]>t[0]&&i[1]<t[3])){c.label=i[1];break}if(6===i[0]&&c.label<t[1]){c.label=t[1],t=i;break}if(t&&c.label<t[2]){c.label=t[2],c.ops.push(i);break}t[2]&&c.ops.pop(),c.trys.pop();continue}i=r.call(e,c)}catch(e){i=[6,e],o=0}finally{n=t=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function s(e,r,n){if(n||2===arguments.length)for(var o,t=0,c=r.length;t<c;t++)!o&&t in r||(o||(o=Array.prototype.slice.call(r,0,t)),o[t]=r[t]);return e.concat(o||Array.prototype.slice.call(r))}"function"==typeof SuppressedError&&SuppressedError;var l={},d=function(e){if(l[e])return l[e];try{var r="/".concat(e);return e.endsWith(".wasm"),l[e]=r,r}catch(r){throw console.error("Error creating URL for ".concat(e,":"),r),new Error("Could not import asset: ".concat(e))}},u=["vendor.axios.cee2297d8064255b0106.js","vendor.asn1.js.3483cc7f63182a3f0b82.js","vendor.bn.js.8949dfa435f84f8e13a5.js","vendor.browserify-aes.bc1671aedb76de95cac6.js","vendor.browserify-sign.262d500dac7fbd793b85.js","vendor.buffer.f36bb1254e482f86b62a.js","vendor.create-ecdh.69ce73dde28c4e953a9b.js","vendor.diffie-hellman.96fa799e490efa568667.js","vendor.elliptic.8350666830498dccd184.js","vendor.hash.js.9a08305c13c240a0f2eb.js","vendor.lottie-web.c63ca72f96d1c4837c16.js","vendor.miller-rabin.dd407c301bc8de89c1bd.js","vendor.mobile-device-detect.8de5473c1f1106923305.js","vendor.mustache.0f5d8a4748abe782331b.js","vendor.public-encrypt.deb04f7e80668dc1211e.js","vendor.signalr-no-jquery.6ee4fa921ba8dc0eba79.js","vendor.sjcl.f4547262815d41f5fc42.js","vendor.stream-browserify.7ad9b49390911acdde5b.js","ides-micro.c7f56e19625c4d2863a9.js","idscan-jcs-10de8631.f74a686e9a7f6e42670c.js","idscan-jcs-1ab2fc53.d7c35cd3b5fff8a83ca1.js","idscan-jcs-3bb2ab8b.05fb7793762bf9f39d33.js","idscan-jcs-43dd7041.2b3ac18c07ac038ba585.js","idscan-jcs-6b882012.93839b50b8a7df33fef9.js","idscan-jcs-76945664.16afcfbbc3f1014ec443.js","idscan-jcs-77455583.178cfd426c47545c4f6f.js","idscan-jcs-89419957.ffffb2cf10c5a8b1202d.js","idscan-jcs-d91a9049.194314e02268c234efac.js"],f=[],b=["idesmicro_asm.wasm","idesmicro_asm.js"],p=function(p){var h=p.backendUrl,y=p.token,v=p.journeyDefinitionId,j=p.defaultInputProvider,m=void 0===j?"SMART_CAPTURE":j,g=p.tripleScanAnalyzerGuidancePage,w=void 0===g||g,S=p.fileUploadOnCameraCaptureJourneys,E=void 0!==S&&S,C=p.previewPages,k=p.manualCapture,D=void 0!==k&&k,A=p.assetsDirectory,G=void 0===A?"assets":A,L=p.smartCapture,x=p.isVerboseLogEnabled,P=void 0!==x&&x,I=p.hideLogo,O=void 0!==I&&I,U=p.hideAutoCaptureHints,K=void 0!==U&&U,R=p.className,M=void 0===R?"":R,W=p.style,B=void 0===W?{}:W,F=n(null),N=o(null),z=N[0],T=N[1],V=o(!0),_=V[0],H=V[1];return t((function(){var e=null;return a(void 0,void 0,void 0,(function(){var r,n,o,t;return i(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),H(!0),T(null),console.log("Loading SDK scripts:",u),console.log("Loading SDK CSS:",f),r=u.map((function(e){return new Promise((function(r,n){try{var o=document.createElement("script"),t=d(e);o.src=t,o.async=!0,o.onload=function(){console.log("✓ Loaded script: ".concat(e)),r()},o.onerror=function(r){console.error("✗ Failed to load script: ".concat(e),r),n(new Error("Failed to load script: ".concat(e,". Make sure the GBG SDK files are available in your public directory.")))},document.head.appendChild(o)}catch(e){n(e)}}))})),n=f.map((function(e){return new Promise((function(r,n){try{var o=document.createElement("link"),t=d(e);o.rel="stylesheet",o.href=t,o.onload=function(){console.log("✓ Loaded CSS: ".concat(e)),r()},o.onerror=function(r){console.error("✗ Failed to load CSS: ".concat(e),r),n(new Error("Failed to load CSS: ".concat(e)))},document.head.appendChild(o)}catch(e){n(e)}}))})),console.info("Important: WebAssembly files must be available in the public directory of your application. For WASM files to load correctly, ensure that the following files exist in your public directory: "+b.join(", ")),[4,Promise.all(s(s([],r,!0),n,!0))];case 1:if(c.sent(),console.log("All SDK files loaded successfully!"),!window.IDscan)throw new Error("GBG SDK failed to initialize. Make sure WebAssembly files are available in your public directory: "+b.join(", "));return o={backendUrl:h,container:F.current,token:y,journeyDefinitionId:v,defaultInputProvider:m,tripleScanAnalyzerGuidancePage:w,fileUploadOnCameraCaptureJourneys:E,previewPages:C,manualCapture:D,assetsDirectory:G,smartCapture:L,isVerboseLogEnabled:P,hideLogo:O,hideAutoCaptureHints:K},e=new window.IDscan.Component(o),H(!1),[3,3];case 2:return t=c.sent(),console.error("Error initializing GBG SDK:",t),T(t instanceof Error?t.message:"Failed to initialize GBG SDK"),H(!1),[3,3];case 3:return[2]}}))})),function(){e&&"function"==typeof e.destroy&&e.destroy(),Object.values(l).forEach((function(e){if(e.startsWith("blob:"))try{URL.revokeObjectURL(e)}catch(r){console.error("Error revoking blob URL: ".concat(e),r)}})),Object.keys(l).forEach((function(e){return delete l[e]}))}}),[h,y,v,m,w,E,C,D,G,L,P,O,K]),e("div",{ref:F,className:"gbg-id-scan-journey ".concat(M),style:c({minHeight:"500px",width:"100%"},B),children:[_&&r("div",{className:"loading",children:"Loading GBG ID Verification..."}),z&&e("div",{className:"error",style:{color:"red",padding:"20px"},children:[r("h3",{children:"Error Loading GBG SDK"}),r("p",{children:z}),e("div",{children:[r("h4",{children:"Troubleshooting Tips:"}),e("ul",{children:[r("li",{children:"Ensure WebAssembly files are available in your public directory"}),r("li",{children:"Check that your backend URL and token are correct"}),r("li",{children:"Verify that you have a stable internet connection"}),r("li",{children:"Check browser console for more detailed error messages"}),e("li",{children:["Run:"," ",r("code",{children:"node node_modules/local-id-scan-journey/scripts/postinstall.js"})," ","to copy SDK files"]})]}),e("p",{children:[r("strong",{children:"Note for Next.js users:"})," Make sure you've copied the WASM files to your public directory. See the README for installation instructions."]})]})]})]})};export{p as LocalIdScanJourney}; //# sourceMappingURL=index.esm.js.map