local-id-scan-journey
Version:
A React component for GBG ID verification and document scanning with bundled SDK
3 lines (2 loc) • 7.63 kB
JavaScript
;var e=require("react/jsx-runtime"),r=require("react"),n=function(){return n=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},n.apply(this,arguments)};function o(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 t(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 c(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 a={},i=function(e){if(a[e])return a[e];try{var r="/".concat(e);return e.endsWith(".wasm"),a[e]=r,r}catch(r){throw console.error("Error creating URL for ".concat(e,":"),r),new Error("Could not import asset: ".concat(e))}},s=["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"],l=[],d=["idesmicro_asm.wasm","idesmicro_asm.js"];exports.LocalIdScanJourney=function(u){var f=u.backendUrl,b=u.token,p=u.journeyDefinitionId,h=u.defaultInputProvider,y=void 0===h?"SMART_CAPTURE":h,j=u.tripleScanAnalyzerGuidancePage,v=void 0===j||j,m=u.fileUploadOnCameraCaptureJourneys,g=void 0!==m&&m,w=u.previewPages,S=u.manualCapture,x=void 0!==S&&S,E=u.assetsDirectory,C=void 0===E?"assets":E,k=u.smartCapture,D=u.isVerboseLogEnabled,L=void 0!==D&&D,A=u.hideLogo,G=void 0!==A&&A,P=u.hideAutoCaptureHints,I=void 0!==P&&P,O=u.className,R=void 0===O?"":O,U=u.style,K=void 0===U?{}:U,M=r.useRef(null),W=r.useState(null),B=W[0],F=W[1],N=r.useState(!0),z=N[0],T=N[1];return r.useEffect((function(){var e=null;return o(void 0,void 0,void 0,(function(){var r,n,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),T(!0),F(null),console.log("Loading SDK scripts:",s),console.log("Loading SDK CSS:",l),r=s.map((function(e){return new Promise((function(r,n){try{var o=document.createElement("script"),t=i(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=l.map((function(e){return new Promise((function(r,n){try{var o=document.createElement("link"),t=i(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: "+d.join(", ")),[4,Promise.all(c(c([],r,!0),n,!0))];case 1:if(t.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: "+d.join(", "));return o={backendUrl:f,container:M.current,token:b,journeyDefinitionId:p,defaultInputProvider:y,tripleScanAnalyzerGuidancePage:v,fileUploadOnCameraCaptureJourneys:g,previewPages:w,manualCapture:x,assetsDirectory:C,smartCapture:k,isVerboseLogEnabled:L,hideLogo:G,hideAutoCaptureHints:I},e=new window.IDscan.Component(o),T(!1),[3,3];case 2:return a=t.sent(),console.error("Error initializing GBG SDK:",a),F(a instanceof Error?a.message:"Failed to initialize GBG SDK"),T(!1),[3,3];case 3:return[2]}}))})),function(){e&&"function"==typeof e.destroy&&e.destroy(),Object.values(a).forEach((function(e){if(e.startsWith("blob:"))try{URL.revokeObjectURL(e)}catch(r){console.error("Error revoking blob URL: ".concat(e),r)}})),Object.keys(a).forEach((function(e){return delete a[e]}))}}),[f,b,p,y,v,g,w,x,C,k,L,G,I]),e.jsxs("div",{ref:M,className:"gbg-id-scan-journey ".concat(R),style:n({minHeight:"500px",width:"100%"},K),children:[z&&e.jsx("div",{className:"loading",children:"Loading GBG ID Verification..."}),B&&e.jsxs("div",{className:"error",style:{color:"red",padding:"20px"},children:[e.jsx("h3",{children:"Error Loading GBG SDK"}),e.jsx("p",{children:B}),e.jsxs("div",{children:[e.jsx("h4",{children:"Troubleshooting Tips:"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Ensure WebAssembly files are available in your public directory"}),e.jsx("li",{children:"Check that your backend URL and token are correct"}),e.jsx("li",{children:"Verify that you have a stable internet connection"}),e.jsx("li",{children:"Check browser console for more detailed error messages"}),e.jsxs("li",{children:["Run:"," ",e.jsx("code",{children:"node node_modules/local-id-scan-journey/scripts/postinstall.js"})," ","to copy SDK files"]})]}),e.jsxs("p",{children:[e.jsx("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."]})]})]})]})};
//# sourceMappingURL=index.cjs.js.map