@velion-la/onboarding-sdk-web 1.1.0-beta.2 → 1.1.0-beta.3

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.
@@ -1,2 +1,2 @@
1
- var e=Object.defineProperty,t=(t,r,n)=>((t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n)(t,"symbol"!=typeof r?r+"":r,n),r=/* @__PURE__ */(e=>(e.PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.DEVICE_NOT_FOUND="CAMERA_DEVICE_NOT_FOUND",e.DEVICE_NOT_READABLE="CAMERA_DEVICE_NOT_READABLE",e.INSECURE_CONTEXT="CAMERA_INSECURE_CONTEXT",e.POLICY_BLOCKED="CAMERA_POLICY_BLOCKED",e.NOT_SUPPORTED="CAMERA_NOT_SUPPORTED",e.WEBVIEW_BLOCKED="CAMERA_WEBVIEW_BLOCKED",e.CONSTRAINT_ERROR="CAMERA_CONSTRAINT_ERROR",e.UNKNOWN="CAMERA_UNKNOWN_ERROR",e))(r||{}),n=/* @__PURE__ */(e=>(e.SESSION_INVALID="SESSION_INVALID",e.SESSION_EXPIRED="SESSION_EXPIRED",e.SESSION_FETCH_FAILED="SESSION_FETCH_FAILED",e.SESSION_DECLINED="SESSION_DECLINED",e.ROUTING_TIMEOUT="ROUTING_TIMEOUT",e.FINGERPRINT_FAILED="FINGERPRINT_FAILED",e.DOCUMENT_UPLOAD_FAILED="DOCUMENT_UPLOAD_FAILED",e.LIVENESS_FAILED="LIVENESS_FAILED",e.LIVENESS_INIT_FAILED="LIVENESS_INIT_FAILED",e.LIVENESS_VIDEO_UPLOAD_FAILED="LIVENESS_VIDEO_UPLOAD_FAILED",e.CAMERA_ERROR="CAMERA_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.ALREADY_STARTED="ALREADY_STARTED",e.INSTANCE_DESTROYED="INSTANCE_DESTROYED",e.INSECURE_EMBED="INSECURE_EMBED",e.INTEGRITY_FAILED="INTEGRITY_FAILED",e.UNSUPPORTED_BROWSER="UNSUPPORTED_BROWSER",e.RUNTIME_LOAD_FAILED="RUNTIME_LOAD_FAILED",e.UNKNOWN="UNKNOWN",e))(n||{});const i="VELION_INIT",s="VELION_READY",o="VELION_SUCCESS",a="VELION_ERROR",c="VELION_STEP_CHANGE",l="VELION_STEP_COMPLETE",f="VELION_TOKEN_EXPIRED",d="VELION_EXIT",h="VELION_LIVENESS_VIDEO_UPLOADED",E="VELION_TOKEN",u=Object.freeze,g=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,m=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,y=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,R=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,I=0x6666666666666666666666666666666666666666666666666666666666666658n,N=g-1n,p=u({p:g,n:m,h:8n,a:N,d:y,Gx:R,Gy:I}),O=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&1===e.BYTES_PER_ELEMENT,T=(e,t,r="")=>{if(O(e)&&(void 0===t||e.length===t))return e;const n=O(e),i=(r?`"${r}" `:"")+"expected Uint8Array"+(void 0!==t?` of length ${t}`:"")+", got "+(n?`length=${e.length}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)},w=(e,t)=>e.toString(16).padStart(t,"0"),_=e=>{let t="";for(const r of T(e))t+=w(r,2);return t},A=e=>{const t="hex invalid";if("string"!=typeof e)throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);const r=new Uint8Array(e.length/2);for(let n=0,i=0;n<r.length;n++,i+=2){const t=e.charCodeAt(i),s=e.charCodeAt(i+1);r[n]=16*((15&t)+9*(t>>6))+(15&s)+9*(s>>6)}return r},b=(...e)=>{let t=0;for(const i of e)t+=T(i).length;const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r},S=(e,t,r,n="bad number: out of range")=>{if("bigint"!=typeof e)throw new TypeError(n);if(t<=e&&e<r)return e;throw new RangeError(n)},D=(e,t=g)=>(e%=t)>=0n?e:t+e,v=(1n<<255n)-1n,L=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=19n*(e>>255n)+(e&v);return t=19n*(t>>255n)+(t&v),t%g},U=async(e,...t)=>T(await(e=>{const t=X[e];if("function"!=typeof t)throw new Error("hashes."+e+" not set");return t})(e)(b(...t)),64,"digest"),C=e=>{if(e instanceof P)return e;throw new TypeError("Point expected")},x=2n**256n,k=class e{constructor(e,r,n,i){t(this,"X"),t(this,"Y"),t(this,"Z"),t(this,"T");const s=x;this.X=S(e,0n,s),this.Y=S(r,0n,s),this.Z=S(n,1n,s),this.T=S(i,0n,s),u(this)}static CURVE(){return p}static fromAffine(t){return new e(t.x,t.y,1n,L(t.x*t.y))}static fromBytes(t,r=!1){const n=((e,t="",r)=>Uint8Array.from(T(e,r,t)))(t,"point",32),i=n[31];n[31]=-129&i;const s=B(n);r||S(s,0n,g);const o=L(s*s),a=D(o-1n),c=L(y*o+1n);let{isValid:l,value:f}=Y(a,c);if(!l)throw new Error("bad point: y not sqrt");const d=!!(128&i);if(!r&&0n===f&&d)throw new Error("bad point: x==0, isLastByteOdd");return d!==!!(1n&f)&&(f=D(-f)),new e(f,s,1n,L(f*s))}static fromHex(t,r){return e.fromBytes(A(t),r)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=N,t=y;if(this.is0())throw new Error("bad point: ZERO");const{X:r,Y:n,Z:i,T:s}=this,o=L(r*r),a=L(n*n),c=L(i*i),l=L(c*c),f=L(o*e);if(L(c*(f+a))!==D(l+L(t*L(o*a))))throw new Error("bad point: equation left != right (1)");if(L(r*n)!==L(i*s))throw new Error("bad point: equation left != right (2)");return this}equals(e){const{X:t,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=C(e);return L(t*o)===L(i*n)&&L(r*o)===L(s*n)}is0(){return this.equals(M)}negate(){return new e(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:r,Z:n}=this,i=N,s=L(t*t),o=L(r*r),a=L(2n*n*n),c=L(i*s),l=D(t+r),f=D(L(l*l)-s-o),d=D(c+o),h=D(d-a),E=D(c-o),u=L(f*h),g=L(d*E),m=L(f*E),y=L(h*d);return new e(u,g,y,m)}add(t){const{X:r,Y:n,Z:i,T:s}=this,{X:o,Y:a,Z:c,T:l}=C(t),f=N,d=y,h=L(r*o),E=L(n*a),u=L(L(s*d)*l),g=L(i*c),m=D(L(D(r+n)*D(o+a))-h-E),R=D(g-u),I=D(g+u),p=D(E-L(f*h)),O=L(m*R),T=L(I*p),w=L(m*p),_=L(R*I);return new e(O,T,_,w)}subtract(e){return this.add(C(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return M;if(S(e,1n,m),!t&&this.is0())return M;if(1n===e)return this;if(this.equals(F))return q(e).p;let r=M,n=F,i=this;for(let s=0;t?s<256:e>0n;s++)1n&e?r=r.add(i):t&&(n=n.add(i)),i=i.double(),e>>=1n;return r}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:r}=this;if(this.equals(M))return{x:0n,y:1n};const n=((e,t)=>{if(0n===e)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let r=D(e,t),n=t,i=0n,s=1n;for(;0n!==r;){const e=n/r,t=n-r*e,o=i-s*e;n=r,r=t,i=s,s=o}if(1n!==n)throw new Error("invert: does not exist");return D(i,t)})(r,g);if(1n!==L(r*n))throw new Error("invalid inverse");return{x:L(e*n),y:L(t*n)}}toBytes(){const{x:e,y:t}=this.toAffine(),r=V(t);return r[31]|=1n&e?128:0,r}toHex(){return _(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(m/2n,!1).double().add(this).is0()}};t(k,"BASE"),t(k,"ZERO");let P=k;const F=new P(R,I,1n,D(R*I)),M=new P(0n,1n,1n,0n);P.BASE=F,P.ZERO=M;const V=e=>A(w(S(e,0n,x),64)).reverse(),B=e=>BigInt("0x"+_(Uint8Array.from(T(e)).reverse())),H=(e,t)=>{let r=e;for(;t-- >0;)r=L(r*r);return r},W=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Y=(e,t)=>{const r=L(t*L(t*t)),n=L(L(r*r)*t),i=(e=>{const t=L(e*e),r=L(t*e),n=L(H(r,2)*r),i=L(H(n,1)*e),s=L(H(i,5)*i),o=L(H(s,10)*s),a=L(H(o,20)*o),c=L(H(a,40)*a),l=L(H(c,80)*c),f=L(H(l,80)*c),d=L(H(f,10)*s);return L(H(d,2)*e)})(L(e*n));let s=L(e*L(r*i));const o=L(t*L(s*s)),a=s,c=L(s*W),l=o===e,f=o===D(-e),d=o===D(-e*W);return l&&(s=a),(f||d)&&(s=c),1n==(1n&D(s))&&(s=D(-s)),{isValid:l||f,value:s}},$=e=>{return t=B(e),D(t,m);var t},z=(e,t,r,n)=>{e=T(e,64,"signature"),t=T(t,void 0,"message"),r=T(r,32,"publicKey");const i=(e=>{if(null===e||"object"!=typeof e)throw new TypeError("expected valid options object");return e.zip215??!0})(n),s=e.subarray(0,32),o=B(e.subarray(32,64));let a,c,l,f=Uint8Array.of(),d=!1;try{a=P.fromBytes(r,i),c=P.fromBytes(s,i),l=F.multiply(o,!1),f=b(s,r,t),d=!0}catch(h){}return[f,e=>{if(!d)return!1;if(!i&&a.isSmallOrder())return!1;const t=$(e);return c.add(a.multiply(t,!1)).subtract(l).clearCofactor().is0()}]},K=async(e,t,r,n={})=>(async e=>e[1](await U("sha512Async",e[0])))(z(e,t,r,n)),X={sha512Async:async e=>{const t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",b(e)))},sha512:void 0};let G;const Z=(e,t)=>{const r=t.negate();return e?r:t},q=e=>{const t=G||(G=(()=>{const e=[];let t,r=F;for(let n=0;n<33;n++){t=r,e.push(t);for(let n=1;n<128;n++)t=t.add(r),e.push(t);r=t.double()}return e})());let r=M,n=F;for(let i=0;i<33;i++){let s=Number(255n&e);e>>=8n,s>128&&(s-=256,e+=1n);const o=128*i,a=o+Math.abs(s)-1,c=i%2!=0,l=s<0;0===s?n=n.add(Z(c,t[o])):r=r.add(Z(l,t[a]))}if(0n!==e)throw new Error("invalid wnaf");return{p:r,f:n}},j="lpqLG4Ta0YyBn/+lQh95tFl4CuTIHWapeeq7+xnPH+U=";function J(e){const t=atob(e),r=new ArrayBuffer(t.length),n=new Uint8Array(r);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return r}function Q(e){if(e instanceof Error&&"NotSupportedError"===e.name)return!0;const t=e instanceof Error?e.message:String(e);return/unrecognized|not supported|unsupported/i.test(t)}async function ee(e,t,r){if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unsupported_browser",detail:"crypto.subtle is unavailable (insecure context or very old browser); the manifest signature cannot be verified."};const n=J(e),i=await async function(e,t,r){let n;try{n=await crypto.subtle.importKey("raw",e,{name:"Ed25519"},!1,["verify"])}catch(i){return Q(i)?{kind:"unsupported"}:{kind:"error",detail:`pubkey import failed: ${i.message}`}}try{return{kind:"verdict",valid:await crypto.subtle.verify({name:"Ed25519"},n,t,r)}}catch(i){return Q(i)?{kind:"unsupported"}:{kind:"error",detail:i.message}}}(n,t,r);if("error"===i.kind)return{ok:!1,reason:"invalid_signature",detail:i.detail};let s;if("verdict"===i.kind)s=i.valid;else try{s=await async function(e,t,r){return K(new Uint8Array(t),new Uint8Array(r),new Uint8Array(e),{zip215:!1})}(n,t,r)}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return s?null:{ok:!1,reason:"invalid_signature"}}const te="https://static.velion.la/sdk/onboarding/v1";function re(e){try{const r=new URL(e);return"https:"===r.protocol||"http:"===r.protocol&&("localhost"===(t=r.hostname)||"127.0.0.1"===t||"::1"===t||t.endsWith(".local"))}catch{return!1}var t}const ne=["containerId","sessionId","sessionToken","apiUrl","expiresAt","theme","colorMode","locale","allowEmbedded","livenessShowIntro","livenessShowBackButton","fingerprintEndpoint","debug","googleMapsApiKey","showFinalResultScreen","showProgressBar","finalResultScreenTexts","routingTimeoutMs"];class ie{constructor(e){this.status="IDLE",this.iframe=null,this.container=null,this.messageHandler=null,this.containerResizeObserver=null,this.iframeHeightWindowResizeHandler=null,this.cdnOrigin="",this.readyTimer=null,this.config=Object.freeze({...e})}clearReadyTimer(){null!==this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null)}armReadyTimer(e){this.clearReadyTimer();const t=this.config.runtimeReadyTimeoutMs??3e4;t>0&&(this.readyTimer=setTimeout(()=>{this.readyTimer=null,"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:`The onboarding runtime at ${e} did not become ready within ${t} ms. Check that the CDN serves the assets referenced by its index.html and that the host page's Content-Security-Policy allows the runtime scripts.`}))},t))}async start(){if("DESTROYED"===this.status)return void this.config.onError?.({code:n.INSTANCE_DESTROYED,message:"This VelionOnboarding instance has been destroyed. Create a new instance to retry."});if("IDLE"!==this.status)return void this.config.onError?.({code:n.ALREADY_STARTED,message:"start() was called on an already-running SDK instance. Call destroy() before re-starting."});const e=document.getElementById(this.config.containerId);if(!e)return void this.config.onError?.({code:n.CONTAINER_NOT_FOUND,message:`No DOM element found with id="${this.config.containerId}". Ensure the element exists before calling start().`});const t=(this.config.cdnUrl??te).replace(/\/$/,"");if(!re(t))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure cdnUrl: "${t}". Must be https:// (http:// is allowed only for localhost).`});if(this.config.apiUrl&&!re(this.config.apiUrl))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure apiUrl: "${this.config.apiUrl}". Must be https:// (http:// is allowed only for localhost).`});if(this.cdnOrigin=function(e){try{return new URL(e).origin}catch{return""}}(t),!this.cdnOrigin)return void this.config.onError?.({code:n.UNKNOWN,message:`Invalid cdnUrl: ${t}. Must be a valid absolute URL.`});this.container=e,this.status="INITIALIZING";const r=document.createElement("iframe");r.setAttribute("title","Velion Onboarding"),r.setAttribute("allow","camera"),r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-modals"),r.setAttribute("referrerpolicy","no-referrer"),r.style.width="100%",r.style.border="none",r.style.display="block";const u=e=>{if(e.origin!==this.cdnOrigin)return;if(e.source!==this.iframe?.contentWindow)return;const t=e.data;if(t&&"string"==typeof t.type)switch(this.clearReadyTimer(),t.type){case s:this.status="RUNNING";break;case o:this.status="COMPLETED",this.config.onSuccess?.(t.payload);break;case a:this.status="ERROR",this.config.onError?.(t.payload);break;case c:{const e=t.payload;this.config.onStepChange?.(e.step,e.stepIndex);break}case l:{const e=t.payload;this.config.onStepComplete?.(e.step);break}case d:this.status="EXITED",this.config.onExit?.(t.payload);break;case h:this.config.onLivenessVideoUploaded?.(t.payload);break;case f:{const e=this.config.onTokenExpired;e?e().then(e=>this.sendToIframe({type:E,payload:e}),()=>{this.config.onError?.({code:n.SESSION_EXPIRED,message:"Token refresh failed."})}):this.config.onError?.({code:n.SESSION_EXPIRED,message:"Session token expired. Provide onTokenExpired in config to refresh."});break}}};window.addEventListener("message",u),this.messageHandler=u,this.iframe=r,e.replaceChildren(r),this.attachIframeHeightSync(e,r);const g=await this.resolveManifest(t);if(!g)return;const m=g.entry.startsWith("/")?g.entry:`/${g.entry}`;return new Promise(e=>{r.onload=()=>{if(!this.iframe?.contentWindow)return this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:"Iframe failed to load."}),void e();const r=function(e){const t={containerId:"velion-sdk-root",allowEmbedded:!0};for(const r of ne){if("containerId"===r||"allowEmbedded"===r)continue;const n=e[r];void 0!==n&&"function"!=typeof n&&(t[r]=n)}return t}(this.config);let s;try{s=JSON.parse(JSON.stringify(r))}catch{s=r}this.sendToIframe({type:i,payload:s}),this.status="RUNNING",this.armReadyTimer(t),e()},r.onerror=()=>{this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:`Failed to load onboarding app from ${t}. Check cdnUrl and network.`}),e()},r.src=`${t}${m}`})}async resolveManifest(e){let t;try{t=await async function(e,t=j){let r,n,i,s;try{const t=await fetch(`${e}/manifest.json`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(404===t.status)return{ok:!1,reason:"unavailable"};if(!t.ok)return{ok:!1,reason:"unavailable",detail:`HTTP ${t.status}`};r=await t.arrayBuffer(),n=(new TextDecoder).decode(r)}catch(o){return{ok:!1,reason:"unavailable",detail:o.message}}try{if(i=JSON.parse(n),"string"!=typeof i.version||"string"!=typeof i.entry||"string"!=typeof i.buildTime)return{ok:!1,reason:"malformed"}}catch(o){return{ok:!1,reason:"malformed",detail:o.message}}if(!t)return{ok:!0,manifest:i,signed:!1};try{const t=await fetch(`${e}/manifest.sig`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(!t.ok)return{ok:!1,reason:"invalid_signature",detail:`sig HTTP ${t.status}`};s=J((await t.text()).trim())}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return await ee(t,s,r)||{ok:!0,manifest:i,signed:!0}}(e)}catch(r){return this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`Manifest verification crashed unexpectedly: ${r.message}`}),null}if(t.ok)return!t.signed&&j?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:"Internal: manifest reported as unsigned despite pubkey being set."}),null):t.manifest;if("unavailable"===t.reason){return!0!==this.config.allowUnverifiedCdn?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN at "${e}" did not expose /manifest.json. The loader is configured to require a signed manifest. If the CDN is migrating, set \`allowUnverifiedCdn: true\` on the loader config — but only as a temporary measure.`}),null):{version:"legacy",buildTime:/* @__PURE__ */(new Date).toISOString(),entry:"/index.html"}}return"unsupported_browser"===t.reason?(this.status="ERROR",this.config.onError?.({code:n.UNSUPPORTED_BROWSER,message:"This browser cannot verify the signature of the Velion CDN manifest, so the onboarding cannot start. It needs a secure context (https) and WebCrypto (Chrome/Edge 67+, Firefox 68+, Safari 14+). "+(t.detail?`Detail: ${t.detail}`:"")}),null):(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" failed integrity check (${t.reason}). Refusing to load the iframe to protect the user. `+("detail"in t&&t.detail?`Detail: ${t.detail}`:"")}),null)}attachIframeHeightSync(e,t){const r=()=>{if(this.iframe!==t||this.container!==e)return;const r=e.clientHeight;r>0?(t.style.height=`${r}px`,t.style.minHeight=""):(t.style.height="min(85vh, 880px)",t.style.minHeight="")};r(),requestAnimationFrame(r),requestAnimationFrame(()=>{requestAnimationFrame(r)}),"undefined"!=typeof ResizeObserver?(this.containerResizeObserver=new ResizeObserver(r),this.containerResizeObserver.observe(e)):(this.iframeHeightWindowResizeHandler=r,window.addEventListener("resize",r))}detachIframeHeightSync(){this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),this.iframeHeightWindowResizeHandler&&(window.removeEventListener("resize",this.iframeHeightWindowResizeHandler),this.iframeHeightWindowResizeHandler=null)}sendToIframe(e){this.iframe?.contentWindow&&this.iframe.contentWindow.postMessage(e,this.cdnOrigin)}getStatus(){return this.status}static getVersion(){return"1.1.0-beta.2"}destroy(){"DESTROYED"!==this.status&&(this.clearReadyTimer(),this.detachIframeHeightSync(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.container&&(this.iframe.remove(),this.container.replaceChildren()),this.iframe=null,this.container=null,this.status="DESTROYED")}}function se(e){}export{r as CameraErrorCode,te as DEFAULT_CDN_URL,n as SdkErrorCode,a as VELION_MSG_ERROR,d as VELION_MSG_EXIT,i as VELION_MSG_INIT,h as VELION_MSG_LIVENESS_VIDEO_UPLOADED,s as VELION_MSG_READY,c as VELION_MSG_STEP_CHANGE,l as VELION_MSG_STEP_COMPLETE,o as VELION_MSG_SUCCESS,E as VELION_MSG_TOKEN,f as VELION_MSG_TOKEN_EXPIRED,ie as VelionOnboarding,se as setOpenCVBaseUrl};
1
+ var e=Object.defineProperty,t=(t,r,n)=>((t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n)(t,"symbol"!=typeof r?r+"":r,n),r=/* @__PURE__ */(e=>(e.PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.DEVICE_NOT_FOUND="CAMERA_DEVICE_NOT_FOUND",e.DEVICE_NOT_READABLE="CAMERA_DEVICE_NOT_READABLE",e.INSECURE_CONTEXT="CAMERA_INSECURE_CONTEXT",e.POLICY_BLOCKED="CAMERA_POLICY_BLOCKED",e.NOT_SUPPORTED="CAMERA_NOT_SUPPORTED",e.WEBVIEW_BLOCKED="CAMERA_WEBVIEW_BLOCKED",e.CONSTRAINT_ERROR="CAMERA_CONSTRAINT_ERROR",e.UNKNOWN="CAMERA_UNKNOWN_ERROR",e))(r||{}),n=/* @__PURE__ */(e=>(e.SESSION_INVALID="SESSION_INVALID",e.SESSION_EXPIRED="SESSION_EXPIRED",e.SESSION_FETCH_FAILED="SESSION_FETCH_FAILED",e.SESSION_DECLINED="SESSION_DECLINED",e.ROUTING_TIMEOUT="ROUTING_TIMEOUT",e.FINGERPRINT_FAILED="FINGERPRINT_FAILED",e.DOCUMENT_UPLOAD_FAILED="DOCUMENT_UPLOAD_FAILED",e.LIVENESS_FAILED="LIVENESS_FAILED",e.LIVENESS_INIT_FAILED="LIVENESS_INIT_FAILED",e.LIVENESS_VIDEO_UPLOAD_FAILED="LIVENESS_VIDEO_UPLOAD_FAILED",e.CAMERA_ERROR="CAMERA_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.ALREADY_STARTED="ALREADY_STARTED",e.INSTANCE_DESTROYED="INSTANCE_DESTROYED",e.INSECURE_EMBED="INSECURE_EMBED",e.INTEGRITY_FAILED="INTEGRITY_FAILED",e.UNSUPPORTED_BROWSER="UNSUPPORTED_BROWSER",e.RUNTIME_LOAD_FAILED="RUNTIME_LOAD_FAILED",e.UNKNOWN="UNKNOWN",e))(n||{});const i="VELION_INIT",s="VELION_READY",o="VELION_SUCCESS",a="VELION_ERROR",c="VELION_STEP_CHANGE",l="VELION_STEP_COMPLETE",f="VELION_TOKEN_EXPIRED",d="VELION_EXIT",h="VELION_LIVENESS_VIDEO_UPLOADED",E="VELION_TOKEN",u=Object.freeze,g=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,m=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,y=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,R=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,I=0x6666666666666666666666666666666666666666666666666666666666666658n,N=g-1n,p=u({p:g,n:m,h:8n,a:N,d:y,Gx:R,Gy:I}),O=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&1===e.BYTES_PER_ELEMENT,T=(e,t,r="")=>{if(O(e)&&(void 0===t||e.length===t))return e;const n=O(e),i=(r?`"${r}" `:"")+"expected Uint8Array"+(void 0!==t?` of length ${t}`:"")+", got "+(n?`length=${e.length}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)},w=(e,t)=>e.toString(16).padStart(t,"0"),_=e=>{let t="";for(const r of T(e))t+=w(r,2);return t},A=e=>{const t="hex invalid";if("string"!=typeof e)throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);const r=new Uint8Array(e.length/2);for(let n=0,i=0;n<r.length;n++,i+=2){const t=e.charCodeAt(i),s=e.charCodeAt(i+1);r[n]=16*((15&t)+9*(t>>6))+(15&s)+9*(s>>6)}return r},b=(...e)=>{let t=0;for(const i of e)t+=T(i).length;const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r},S=(e,t,r,n="bad number: out of range")=>{if("bigint"!=typeof e)throw new TypeError(n);if(t<=e&&e<r)return e;throw new RangeError(n)},D=(e,t=g)=>(e%=t)>=0n?e:t+e,v=(1n<<255n)-1n,L=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=19n*(e>>255n)+(e&v);return t=19n*(t>>255n)+(t&v),t%g},U=async(e,...t)=>T(await(e=>{const t=X[e];if("function"!=typeof t)throw new Error("hashes."+e+" not set");return t})(e)(b(...t)),64,"digest"),C=e=>{if(e instanceof P)return e;throw new TypeError("Point expected")},x=2n**256n,k=class e{constructor(e,r,n,i){t(this,"X"),t(this,"Y"),t(this,"Z"),t(this,"T");const s=x;this.X=S(e,0n,s),this.Y=S(r,0n,s),this.Z=S(n,1n,s),this.T=S(i,0n,s),u(this)}static CURVE(){return p}static fromAffine(t){return new e(t.x,t.y,1n,L(t.x*t.y))}static fromBytes(t,r=!1){const n=((e,t="",r)=>Uint8Array.from(T(e,r,t)))(t,"point",32),i=n[31];n[31]=-129&i;const s=B(n);r||S(s,0n,g);const o=L(s*s),a=D(o-1n),c=L(y*o+1n);let{isValid:l,value:f}=Y(a,c);if(!l)throw new Error("bad point: y not sqrt");const d=!!(128&i);if(!r&&0n===f&&d)throw new Error("bad point: x==0, isLastByteOdd");return d!==!!(1n&f)&&(f=D(-f)),new e(f,s,1n,L(f*s))}static fromHex(t,r){return e.fromBytes(A(t),r)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=N,t=y;if(this.is0())throw new Error("bad point: ZERO");const{X:r,Y:n,Z:i,T:s}=this,o=L(r*r),a=L(n*n),c=L(i*i),l=L(c*c),f=L(o*e);if(L(c*(f+a))!==D(l+L(t*L(o*a))))throw new Error("bad point: equation left != right (1)");if(L(r*n)!==L(i*s))throw new Error("bad point: equation left != right (2)");return this}equals(e){const{X:t,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=C(e);return L(t*o)===L(i*n)&&L(r*o)===L(s*n)}is0(){return this.equals(M)}negate(){return new e(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:r,Z:n}=this,i=N,s=L(t*t),o=L(r*r),a=L(2n*n*n),c=L(i*s),l=D(t+r),f=D(L(l*l)-s-o),d=D(c+o),h=D(d-a),E=D(c-o),u=L(f*h),g=L(d*E),m=L(f*E),y=L(h*d);return new e(u,g,y,m)}add(t){const{X:r,Y:n,Z:i,T:s}=this,{X:o,Y:a,Z:c,T:l}=C(t),f=N,d=y,h=L(r*o),E=L(n*a),u=L(L(s*d)*l),g=L(i*c),m=D(L(D(r+n)*D(o+a))-h-E),R=D(g-u),I=D(g+u),p=D(E-L(f*h)),O=L(m*R),T=L(I*p),w=L(m*p),_=L(R*I);return new e(O,T,_,w)}subtract(e){return this.add(C(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return M;if(S(e,1n,m),!t&&this.is0())return M;if(1n===e)return this;if(this.equals(F))return q(e).p;let r=M,n=F,i=this;for(let s=0;t?s<256:e>0n;s++)1n&e?r=r.add(i):t&&(n=n.add(i)),i=i.double(),e>>=1n;return r}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:r}=this;if(this.equals(M))return{x:0n,y:1n};const n=((e,t)=>{if(0n===e)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let r=D(e,t),n=t,i=0n,s=1n;for(;0n!==r;){const e=n/r,t=n-r*e,o=i-s*e;n=r,r=t,i=s,s=o}if(1n!==n)throw new Error("invert: does not exist");return D(i,t)})(r,g);if(1n!==L(r*n))throw new Error("invalid inverse");return{x:L(e*n),y:L(t*n)}}toBytes(){const{x:e,y:t}=this.toAffine(),r=V(t);return r[31]|=1n&e?128:0,r}toHex(){return _(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(m/2n,!1).double().add(this).is0()}};t(k,"BASE"),t(k,"ZERO");let P=k;const F=new P(R,I,1n,D(R*I)),M=new P(0n,1n,1n,0n);P.BASE=F,P.ZERO=M;const V=e=>A(w(S(e,0n,x),64)).reverse(),B=e=>BigInt("0x"+_(Uint8Array.from(T(e)).reverse())),H=(e,t)=>{let r=e;for(;t-- >0;)r=L(r*r);return r},W=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Y=(e,t)=>{const r=L(t*L(t*t)),n=L(L(r*r)*t),i=(e=>{const t=L(e*e),r=L(t*e),n=L(H(r,2)*r),i=L(H(n,1)*e),s=L(H(i,5)*i),o=L(H(s,10)*s),a=L(H(o,20)*o),c=L(H(a,40)*a),l=L(H(c,80)*c),f=L(H(l,80)*c),d=L(H(f,10)*s);return L(H(d,2)*e)})(L(e*n));let s=L(e*L(r*i));const o=L(t*L(s*s)),a=s,c=L(s*W),l=o===e,f=o===D(-e),d=o===D(-e*W);return l&&(s=a),(f||d)&&(s=c),1n==(1n&D(s))&&(s=D(-s)),{isValid:l||f,value:s}},$=e=>{return t=B(e),D(t,m);var t},z=(e,t,r,n)=>{e=T(e,64,"signature"),t=T(t,void 0,"message"),r=T(r,32,"publicKey");const i=(e=>{if(null===e||"object"!=typeof e)throw new TypeError("expected valid options object");return e.zip215??!0})(n),s=e.subarray(0,32),o=B(e.subarray(32,64));let a,c,l,f=Uint8Array.of(),d=!1;try{a=P.fromBytes(r,i),c=P.fromBytes(s,i),l=F.multiply(o,!1),f=b(s,r,t),d=!0}catch(h){}return[f,e=>{if(!d)return!1;if(!i&&a.isSmallOrder())return!1;const t=$(e);return c.add(a.multiply(t,!1)).subtract(l).clearCofactor().is0()}]},K=async(e,t,r,n={})=>(async e=>e[1](await U("sha512Async",e[0])))(z(e,t,r,n)),X={sha512Async:async e=>{const t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",b(e)))},sha512:void 0};let G;const Z=(e,t)=>{const r=t.negate();return e?r:t},q=e=>{const t=G||(G=(()=>{const e=[];let t,r=F;for(let n=0;n<33;n++){t=r,e.push(t);for(let n=1;n<128;n++)t=t.add(r),e.push(t);r=t.double()}return e})());let r=M,n=F;for(let i=0;i<33;i++){let s=Number(255n&e);e>>=8n,s>128&&(s-=256,e+=1n);const o=128*i,a=o+Math.abs(s)-1,c=i%2!=0,l=s<0;0===s?n=n.add(Z(c,t[o])):r=r.add(Z(l,t[a]))}if(0n!==e)throw new Error("invalid wnaf");return{p:r,f:n}},j="lpqLG4Ta0YyBn/+lQh95tFl4CuTIHWapeeq7+xnPH+U=";function J(e){const t=atob(e),r=new ArrayBuffer(t.length),n=new Uint8Array(r);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return r}function Q(e){if(e instanceof Error&&"NotSupportedError"===e.name)return!0;const t=e instanceof Error?e.message:String(e);return/unrecognized|not supported|unsupported/i.test(t)}async function ee(e,t,r){if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unsupported_browser",detail:"crypto.subtle is unavailable (insecure context or very old browser); the manifest signature cannot be verified."};const n=J(e),i=await async function(e,t,r){let n;try{n=await crypto.subtle.importKey("raw",e,{name:"Ed25519"},!1,["verify"])}catch(i){return Q(i)?{kind:"unsupported"}:{kind:"error",detail:`pubkey import failed: ${i.message}`}}try{return{kind:"verdict",valid:await crypto.subtle.verify({name:"Ed25519"},n,t,r)}}catch(i){return Q(i)?{kind:"unsupported"}:{kind:"error",detail:i.message}}}(n,t,r);if("error"===i.kind)return{ok:!1,reason:"invalid_signature",detail:i.detail};let s;if("verdict"===i.kind)s=i.valid;else try{s=await async function(e,t,r){return K(new Uint8Array(t),new Uint8Array(r),new Uint8Array(e),{zip215:!1})}(n,t,r)}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return s?null:{ok:!1,reason:"invalid_signature"}}const te="https://static.velion.la/sdk/onboarding/v1";function re(e){try{const r=new URL(e);return"https:"===r.protocol||"http:"===r.protocol&&("localhost"===(t=r.hostname)||"127.0.0.1"===t||"::1"===t||t.endsWith(".local"))}catch{return!1}var t}const ne=["containerId","sessionId","sessionToken","apiUrl","expiresAt","theme","colorMode","locale","allowEmbedded","livenessShowIntro","livenessShowBackButton","fingerprintEndpoint","debug","googleMapsApiKey","showFinalResultScreen","showProgressBar","finalResultScreenTexts","routingTimeoutMs"];class ie{constructor(e){this.status="IDLE",this.iframe=null,this.container=null,this.messageHandler=null,this.containerResizeObserver=null,this.iframeHeightWindowResizeHandler=null,this.cdnOrigin="",this.readyTimer=null,this.config=Object.freeze({...e})}clearReadyTimer(){null!==this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null)}armReadyTimer(e){this.clearReadyTimer();const t=this.config.runtimeReadyTimeoutMs??3e4;t>0&&(this.readyTimer=setTimeout(()=>{this.readyTimer=null,"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:`The onboarding runtime at ${e} did not become ready within ${t} ms. Check that the CDN serves the assets referenced by its index.html and that the host page's Content-Security-Policy allows the runtime scripts.`}))},t))}async start(){if("DESTROYED"===this.status)return void this.config.onError?.({code:n.INSTANCE_DESTROYED,message:"This VelionOnboarding instance has been destroyed. Create a new instance to retry."});if("IDLE"!==this.status)return void this.config.onError?.({code:n.ALREADY_STARTED,message:"start() was called on an already-running SDK instance. Call destroy() before re-starting."});const e=document.getElementById(this.config.containerId);if(!e)return void this.config.onError?.({code:n.CONTAINER_NOT_FOUND,message:`No DOM element found with id="${this.config.containerId}". Ensure the element exists before calling start().`});const t=(this.config.cdnUrl??te).replace(/\/$/,"");if(!re(t))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure cdnUrl: "${t}". Must be https:// (http:// is allowed only for localhost).`});if(this.config.apiUrl&&!re(this.config.apiUrl))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure apiUrl: "${this.config.apiUrl}". Must be https:// (http:// is allowed only for localhost).`});if(this.cdnOrigin=function(e){try{return new URL(e).origin}catch{return""}}(t),!this.cdnOrigin)return void this.config.onError?.({code:n.UNKNOWN,message:`Invalid cdnUrl: ${t}. Must be a valid absolute URL.`});this.container=e,this.status="INITIALIZING";const r=document.createElement("iframe");r.setAttribute("title","Velion Onboarding"),r.setAttribute("allow","camera"),r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-modals"),r.setAttribute("referrerpolicy","no-referrer"),r.style.width="100%",r.style.border="none",r.style.display="block";const u=e=>{if(e.origin!==this.cdnOrigin)return;if(e.source!==this.iframe?.contentWindow)return;const t=e.data;if(t&&"string"==typeof t.type)switch(this.clearReadyTimer(),t.type){case s:this.status="RUNNING";break;case o:this.status="COMPLETED",this.config.onSuccess?.(t.payload);break;case a:this.status="ERROR",this.config.onError?.(t.payload);break;case c:{const e=t.payload;this.config.onStepChange?.(e.step,e.stepIndex);break}case l:{const e=t.payload;this.config.onStepComplete?.(e.step);break}case d:this.status="EXITED",this.config.onExit?.(t.payload);break;case h:this.config.onLivenessVideoUploaded?.(t.payload);break;case f:{const e=this.config.onTokenExpired;e?e().then(e=>this.sendToIframe({type:E,payload:e}),()=>{this.config.onError?.({code:n.SESSION_EXPIRED,message:"Token refresh failed."})}):this.config.onError?.({code:n.SESSION_EXPIRED,message:"Session token expired. Provide onTokenExpired in config to refresh."});break}}};window.addEventListener("message",u),this.messageHandler=u,this.iframe=r,e.replaceChildren(r),this.attachIframeHeightSync(e,r);const g=await this.resolveManifest(t);if(!g)return;const m=g.entry.startsWith("/")?g.entry:`/${g.entry}`;return new Promise(e=>{r.onload=()=>{if(!this.iframe?.contentWindow)return this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:"Iframe failed to load."}),void e();const r=function(e){const t={containerId:"velion-sdk-root",allowEmbedded:!0};for(const r of ne){if("containerId"===r||"allowEmbedded"===r)continue;const n=e[r];void 0!==n&&"function"!=typeof n&&(t[r]=n)}return t}(this.config);let s;try{s=JSON.parse(JSON.stringify(r))}catch{s=r}this.sendToIframe({type:i,payload:s}),this.status="RUNNING",this.armReadyTimer(t),e()},r.onerror=()=>{this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:`Failed to load onboarding app from ${t}. Check cdnUrl and network.`}),e()},r.src=`${t}${m}`})}async resolveManifest(e){let t;try{t=await async function(e,t=j){let r,n,i,s;try{const t=await fetch(`${e}/manifest.json`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(404===t.status)return{ok:!1,reason:"unavailable"};if(!t.ok)return{ok:!1,reason:"unavailable",detail:`HTTP ${t.status}`};r=await t.arrayBuffer(),n=(new TextDecoder).decode(r)}catch(o){return{ok:!1,reason:"unavailable",detail:o.message}}try{if(i=JSON.parse(n),"string"!=typeof i.version||"string"!=typeof i.entry||"string"!=typeof i.buildTime)return{ok:!1,reason:"malformed"}}catch(o){return{ok:!1,reason:"malformed",detail:o.message}}if(!t)return{ok:!0,manifest:i,signed:!1};try{const t=await fetch(`${e}/manifest.sig`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(!t.ok)return{ok:!1,reason:"invalid_signature",detail:`sig HTTP ${t.status}`};s=J((await t.text()).trim())}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return await ee(t,s,r)||{ok:!0,manifest:i,signed:!0}}(e)}catch(r){return this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`Manifest verification crashed unexpectedly: ${r.message}`}),null}if(t.ok)return!t.signed&&j?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:"Internal: manifest reported as unsigned despite pubkey being set."}),null):t.manifest;if("unavailable"===t.reason){return!0!==this.config.allowUnverifiedCdn?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN at "${e}" did not expose /manifest.json. The loader is configured to require a signed manifest. If the CDN is migrating, set \`allowUnverifiedCdn: true\` on the loader config — but only as a temporary measure.`}),null):{version:"legacy",buildTime:/* @__PURE__ */(new Date).toISOString(),entry:"/index.html"}}return"unsupported_browser"===t.reason?(this.status="ERROR",this.config.onError?.({code:n.UNSUPPORTED_BROWSER,message:"This browser cannot verify the signature of the Velion CDN manifest, so the onboarding cannot start. It needs a secure context (https) and WebCrypto (Chrome/Edge 67+, Firefox 68+, Safari 14+). "+(t.detail?`Detail: ${t.detail}`:"")}),null):(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" failed integrity check (${t.reason}). Refusing to load the iframe to protect the user. `+("detail"in t&&t.detail?`Detail: ${t.detail}`:"")}),null)}attachIframeHeightSync(e,t){const r=()=>{if(this.iframe!==t||this.container!==e)return;const r=e.clientHeight;r>0?(t.style.height=`${r}px`,t.style.minHeight=""):(t.style.height="min(85vh, 880px)",t.style.minHeight="")};r(),requestAnimationFrame(r),requestAnimationFrame(()=>{requestAnimationFrame(r)}),"undefined"!=typeof ResizeObserver?(this.containerResizeObserver=new ResizeObserver(r),this.containerResizeObserver.observe(e)):(this.iframeHeightWindowResizeHandler=r,window.addEventListener("resize",r))}detachIframeHeightSync(){this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),this.iframeHeightWindowResizeHandler&&(window.removeEventListener("resize",this.iframeHeightWindowResizeHandler),this.iframeHeightWindowResizeHandler=null)}sendToIframe(e){this.iframe?.contentWindow&&this.iframe.contentWindow.postMessage(e,this.cdnOrigin)}getStatus(){return this.status}static getVersion(){return"1.1.0-beta.3"}destroy(){"DESTROYED"!==this.status&&(this.clearReadyTimer(),this.detachIframeHeightSync(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.container&&(this.iframe.remove(),this.container.replaceChildren()),this.iframe=null,this.container=null,this.status="DESTROYED")}}function se(e){}export{r as CameraErrorCode,te as DEFAULT_CDN_URL,n as SdkErrorCode,a as VELION_MSG_ERROR,d as VELION_MSG_EXIT,i as VELION_MSG_INIT,h as VELION_MSG_LIVENESS_VIDEO_UPLOADED,s as VELION_MSG_READY,c as VELION_MSG_STEP_CHANGE,l as VELION_MSG_STEP_COMPLETE,o as VELION_MSG_SUCCESS,E as VELION_MSG_TOKEN,f as VELION_MSG_TOKEN_EXPIRED,ie as VelionOnboarding,se as setOpenCVBaseUrl};
2
2
  //# sourceMappingURL=velion-sdk.es.js.map
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VelionSDK={})}(this,function(e){"use strict";var t=Object.defineProperty,r=(e,r,n)=>((e,r,n)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n)(e,"symbol"!=typeof r?r+"":r,n),n=(e=>(e.PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.DEVICE_NOT_FOUND="CAMERA_DEVICE_NOT_FOUND",e.DEVICE_NOT_READABLE="CAMERA_DEVICE_NOT_READABLE",e.INSECURE_CONTEXT="CAMERA_INSECURE_CONTEXT",e.POLICY_BLOCKED="CAMERA_POLICY_BLOCKED",e.NOT_SUPPORTED="CAMERA_NOT_SUPPORTED",e.WEBVIEW_BLOCKED="CAMERA_WEBVIEW_BLOCKED",e.CONSTRAINT_ERROR="CAMERA_CONSTRAINT_ERROR",e.UNKNOWN="CAMERA_UNKNOWN_ERROR",e))(n||{}),i=(e=>(e.SESSION_INVALID="SESSION_INVALID",e.SESSION_EXPIRED="SESSION_EXPIRED",e.SESSION_FETCH_FAILED="SESSION_FETCH_FAILED",e.SESSION_DECLINED="SESSION_DECLINED",e.ROUTING_TIMEOUT="ROUTING_TIMEOUT",e.FINGERPRINT_FAILED="FINGERPRINT_FAILED",e.DOCUMENT_UPLOAD_FAILED="DOCUMENT_UPLOAD_FAILED",e.LIVENESS_FAILED="LIVENESS_FAILED",e.LIVENESS_INIT_FAILED="LIVENESS_INIT_FAILED",e.LIVENESS_VIDEO_UPLOAD_FAILED="LIVENESS_VIDEO_UPLOAD_FAILED",e.CAMERA_ERROR="CAMERA_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.ALREADY_STARTED="ALREADY_STARTED",e.INSTANCE_DESTROYED="INSTANCE_DESTROYED",e.INSECURE_EMBED="INSECURE_EMBED",e.INTEGRITY_FAILED="INTEGRITY_FAILED",e.UNSUPPORTED_BROWSER="UNSUPPORTED_BROWSER",e.RUNTIME_LOAD_FAILED="RUNTIME_LOAD_FAILED",e.UNKNOWN="UNKNOWN",e))(i||{});const s="VELION_INIT",o="VELION_READY",a="VELION_SUCCESS",c="VELION_ERROR",l="VELION_STEP_CHANGE",d="VELION_STEP_COMPLETE",f="VELION_TOKEN_EXPIRED",E="VELION_EXIT",h="VELION_LIVENESS_VIDEO_UPLOADED",u="VELION_TOKEN",g=Object.freeze,I=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,m=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,y=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,R=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,N=0x6666666666666666666666666666666666666666666666666666666666666658n,O=I-1n,p=g({p:I,n:m,h:8n,a:O,d:y,Gx:R,Gy:N}),_=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&1===e.BYTES_PER_ELEMENT,T=(e,t,r="")=>{if(_(e)&&(void 0===t||e.length===t))return e;const n=_(e),i=(r?`"${r}" `:"")+"expected Uint8Array"+(void 0!==t?` of length ${t}`:"")+", got "+(n?`length=${e.length}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)},S=(e,t)=>e.toString(16).padStart(t,"0"),w=e=>{let t="";for(const r of T(e))t+=S(r,2);return t},A=e=>{const t="hex invalid";if("string"!=typeof e)throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);const r=new Uint8Array(e.length/2);for(let n=0,i=0;n<r.length;n++,i+=2){const t=e.charCodeAt(i),s=e.charCodeAt(i+1);r[n]=16*((15&t)+9*(t>>6))+(15&s)+9*(s>>6)}return r},b=(...e)=>{let t=0;for(const i of e)t+=T(i).length;const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r},D=(e,t,r,n="bad number: out of range")=>{if("bigint"!=typeof e)throw new TypeError(n);if(t<=e&&e<r)return e;throw new RangeError(n)},L=(e,t=I)=>(e%=t)>=0n?e:t+e,v=(1n<<255n)-1n,C=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=19n*(e>>255n)+(e&v);return t=19n*(t>>255n)+(t&v),t%I},U=async(e,...t)=>T(await(e=>{const t=X[e];if("function"!=typeof t)throw new Error("hashes."+e+" not set");return t})(e)(b(...t)),64,"digest"),V=e=>{if(e instanceof P)return e;throw new TypeError("Point expected")},M=2n**256n,x=class e{constructor(e,t,n,i){r(this,"X"),r(this,"Y"),r(this,"Z"),r(this,"T");const s=M;this.X=D(e,0n,s),this.Y=D(t,0n,s),this.Z=D(n,1n,s),this.T=D(i,0n,s),g(this)}static CURVE(){return p}static fromAffine(t){return new e(t.x,t.y,1n,C(t.x*t.y))}static fromBytes(t,r=!1){const n=((e,t="",r)=>Uint8Array.from(T(e,r,t)))(t,"point",32),i=n[31];n[31]=-129&i;const s=H(n);r||D(s,0n,I);const o=C(s*s),a=L(o-1n),c=C(y*o+1n);let{isValid:l,value:d}=G(a,c);if(!l)throw new Error("bad point: y not sqrt");const f=!!(128&i);if(!r&&0n===d&&f)throw new Error("bad point: x==0, isLastByteOdd");return f!==!!(1n&d)&&(d=L(-d)),new e(d,s,1n,C(d*s))}static fromHex(t,r){return e.fromBytes(A(t),r)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=O,t=y;if(this.is0())throw new Error("bad point: ZERO");const{X:r,Y:n,Z:i,T:s}=this,o=C(r*r),a=C(n*n),c=C(i*i),l=C(c*c),d=C(o*e);if(C(c*(d+a))!==L(l+C(t*C(o*a))))throw new Error("bad point: equation left != right (1)");if(C(r*n)!==C(i*s))throw new Error("bad point: equation left != right (2)");return this}equals(e){const{X:t,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=V(e);return C(t*o)===C(i*n)&&C(r*o)===C(s*n)}is0(){return this.equals(F)}negate(){return new e(L(-this.X),this.Y,this.Z,L(-this.T))}double(){const{X:t,Y:r,Z:n}=this,i=O,s=C(t*t),o=C(r*r),a=C(2n*n*n),c=C(i*s),l=L(t+r),d=L(C(l*l)-s-o),f=L(c+o),E=L(f-a),h=L(c-o),u=C(d*E),g=C(f*h),I=C(d*h),m=C(E*f);return new e(u,g,m,I)}add(t){const{X:r,Y:n,Z:i,T:s}=this,{X:o,Y:a,Z:c,T:l}=V(t),d=O,f=y,E=C(r*o),h=C(n*a),u=C(C(s*f)*l),g=C(i*c),I=L(C(L(r+n)*L(o+a))-E-h),m=L(g-u),R=L(g+u),N=L(h-C(d*E)),p=C(I*m),_=C(R*N),T=C(I*N),S=C(m*R);return new e(p,_,S,T)}subtract(e){return this.add(V(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return F;if(D(e,1n,m),!t&&this.is0())return F;if(1n===e)return this;if(this.equals(k))return j(e).p;let r=F,n=k,i=this;for(let s=0;t?s<256:e>0n;s++)1n&e?r=r.add(i):t&&(n=n.add(i)),i=i.double(),e>>=1n;return r}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:r}=this;if(this.equals(F))return{x:0n,y:1n};const n=((e,t)=>{if(0n===e)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let r=L(e,t),n=t,i=0n,s=1n;for(;0n!==r;){const e=n/r,t=n-r*e,o=i-s*e;n=r,r=t,i=s,s=o}if(1n!==n)throw new Error("invert: does not exist");return L(i,t)})(r,I);if(1n!==C(r*n))throw new Error("invalid inverse");return{x:C(e*n),y:C(t*n)}}toBytes(){const{x:e,y:t}=this.toAffine(),r=B(t);return r[31]|=1n&e?128:0,r}toHex(){return w(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(m/2n,!1).double().add(this).is0()}};r(x,"BASE"),r(x,"ZERO");let P=x;const k=new P(R,N,1n,L(R*N)),F=new P(0n,1n,1n,0n);P.BASE=k,P.ZERO=F;const B=e=>A(S(D(e,0n,M),64)).reverse(),H=e=>BigInt("0x"+w(Uint8Array.from(T(e)).reverse())),W=(e,t)=>{let r=e;for(;t-- >0;)r=C(r*r);return r},Y=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,G=(e,t)=>{const r=C(t*C(t*t)),n=C(C(r*r)*t),i=(e=>{const t=C(e*e),r=C(t*e),n=C(W(r,2)*r),i=C(W(n,1)*e),s=C(W(i,5)*i),o=C(W(s,10)*s),a=C(W(o,20)*o),c=C(W(a,40)*a),l=C(W(c,80)*c),d=C(W(l,80)*c),f=C(W(d,10)*s);return C(W(f,2)*e)})(C(e*n));let s=C(e*C(r*i));const o=C(t*C(s*s)),a=s,c=C(s*Y),l=o===e,d=o===L(-e),f=o===L(-e*Y);return l&&(s=a),(d||f)&&(s=c),1n==(1n&L(s))&&(s=L(-s)),{isValid:l||d,value:s}},$=e=>{return t=H(e),L(t,m);var t},K=(e,t,r,n)=>{e=T(e,64,"signature"),t=T(t,void 0,"message"),r=T(r,32,"publicKey");const i=(e=>{if(null===e||"object"!=typeof e)throw new TypeError("expected valid options object");return e.zip215??!0})(n),s=e.subarray(0,32),o=H(e.subarray(32,64));let a,c,l,d=Uint8Array.of(),f=!1;try{a=P.fromBytes(r,i),c=P.fromBytes(s,i),l=k.multiply(o,!1),d=b(s,r,t),f=!0}catch(E){}return[d,e=>{if(!f)return!1;if(!i&&a.isSmallOrder())return!1;const t=$(e);return c.add(a.multiply(t,!1)).subtract(l).clearCofactor().is0()}]},z=async(e,t,r,n={})=>(async e=>e[1](await U("sha512Async",e[0])))(K(e,t,r,n)),X={sha512Async:async e=>{const t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",b(e)))},sha512:void 0};let Z;const q=(e,t)=>{const r=t.negate();return e?r:t},j=e=>{const t=Z||(Z=(()=>{const e=[];let t,r=k;for(let n=0;n<33;n++){t=r,e.push(t);for(let n=1;n<128;n++)t=t.add(r),e.push(t);r=t.double()}return e})());let r=F,n=k;for(let i=0;i<33;i++){let s=Number(255n&e);e>>=8n,s>128&&(s-=256,e+=1n);const o=128*i,a=o+Math.abs(s)-1,c=i%2!=0,l=s<0;0===s?n=n.add(q(c,t[o])):r=r.add(q(l,t[a]))}if(0n!==e)throw new Error("invalid wnaf");return{p:r,f:n}},J="lpqLG4Ta0YyBn/+lQh95tFl4CuTIHWapeeq7+xnPH+U=";function Q(e){const t=atob(e),r=new ArrayBuffer(t.length),n=new Uint8Array(r);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return r}function ee(e){if(e instanceof Error&&"NotSupportedError"===e.name)return!0;const t=e instanceof Error?e.message:String(e);return/unrecognized|not supported|unsupported/i.test(t)}async function te(e,t,r){if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unsupported_browser",detail:"crypto.subtle is unavailable (insecure context or very old browser); the manifest signature cannot be verified."};const n=Q(e),i=await async function(e,t,r){let n;try{n=await crypto.subtle.importKey("raw",e,{name:"Ed25519"},!1,["verify"])}catch(i){return ee(i)?{kind:"unsupported"}:{kind:"error",detail:`pubkey import failed: ${i.message}`}}try{return{kind:"verdict",valid:await crypto.subtle.verify({name:"Ed25519"},n,t,r)}}catch(i){return ee(i)?{kind:"unsupported"}:{kind:"error",detail:i.message}}}(n,t,r);if("error"===i.kind)return{ok:!1,reason:"invalid_signature",detail:i.detail};let s;if("verdict"===i.kind)s=i.valid;else try{s=await async function(e,t,r){return z(new Uint8Array(t),new Uint8Array(r),new Uint8Array(e),{zip215:!1})}(n,t,r)}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return s?null:{ok:!1,reason:"invalid_signature"}}const re="https://static.velion.la/sdk/onboarding/v1";function ne(e){try{const r=new URL(e);return"https:"===r.protocol||"http:"===r.protocol&&("localhost"===(t=r.hostname)||"127.0.0.1"===t||"::1"===t||t.endsWith(".local"))}catch{return!1}var t}const ie=["containerId","sessionId","sessionToken","apiUrl","expiresAt","theme","colorMode","locale","allowEmbedded","livenessShowIntro","livenessShowBackButton","fingerprintEndpoint","debug","googleMapsApiKey","showFinalResultScreen","showProgressBar","finalResultScreenTexts","routingTimeoutMs"];e.CameraErrorCode=n,e.DEFAULT_CDN_URL=re,e.SdkErrorCode=i,e.VELION_MSG_ERROR=c,e.VELION_MSG_EXIT=E,e.VELION_MSG_INIT=s,e.VELION_MSG_LIVENESS_VIDEO_UPLOADED=h,e.VELION_MSG_READY=o,e.VELION_MSG_STEP_CHANGE=l,e.VELION_MSG_STEP_COMPLETE=d,e.VELION_MSG_SUCCESS=a,e.VELION_MSG_TOKEN=u,e.VELION_MSG_TOKEN_EXPIRED=f,e.VelionOnboarding=class{constructor(e){this.status="IDLE",this.iframe=null,this.container=null,this.messageHandler=null,this.containerResizeObserver=null,this.iframeHeightWindowResizeHandler=null,this.cdnOrigin="",this.readyTimer=null,this.config=Object.freeze({...e})}clearReadyTimer(){null!==this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null)}armReadyTimer(e){this.clearReadyTimer();const t=this.config.runtimeReadyTimeoutMs??3e4;t>0&&(this.readyTimer=setTimeout(()=>{this.readyTimer=null,"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:i.RUNTIME_LOAD_FAILED,message:`The onboarding runtime at ${e} did not become ready within ${t} ms. Check that the CDN serves the assets referenced by its index.html and that the host page's Content-Security-Policy allows the runtime scripts.`}))},t))}async start(){if("DESTROYED"===this.status)return void this.config.onError?.({code:i.INSTANCE_DESTROYED,message:"This VelionOnboarding instance has been destroyed. Create a new instance to retry."});if("IDLE"!==this.status)return void this.config.onError?.({code:i.ALREADY_STARTED,message:"start() was called on an already-running SDK instance. Call destroy() before re-starting."});const e=document.getElementById(this.config.containerId);if(!e)return void this.config.onError?.({code:i.CONTAINER_NOT_FOUND,message:`No DOM element found with id="${this.config.containerId}". Ensure the element exists before calling start().`});const t=(this.config.cdnUrl??re).replace(/\/$/,"");if(!ne(t))return void this.config.onError?.({code:i.UNKNOWN,message:`Insecure cdnUrl: "${t}". Must be https:// (http:// is allowed only for localhost).`});if(this.config.apiUrl&&!ne(this.config.apiUrl))return void this.config.onError?.({code:i.UNKNOWN,message:`Insecure apiUrl: "${this.config.apiUrl}". Must be https:// (http:// is allowed only for localhost).`});if(this.cdnOrigin=function(e){try{return new URL(e).origin}catch{return""}}(t),!this.cdnOrigin)return void this.config.onError?.({code:i.UNKNOWN,message:`Invalid cdnUrl: ${t}. Must be a valid absolute URL.`});this.container=e,this.status="INITIALIZING";const r=document.createElement("iframe");r.setAttribute("title","Velion Onboarding"),r.setAttribute("allow","camera"),r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-modals"),r.setAttribute("referrerpolicy","no-referrer"),r.style.width="100%",r.style.border="none",r.style.display="block";const n=e=>{if(e.origin!==this.cdnOrigin)return;if(e.source!==this.iframe?.contentWindow)return;const t=e.data;if(t&&"string"==typeof t.type)switch(this.clearReadyTimer(),t.type){case o:this.status="RUNNING";break;case a:this.status="COMPLETED",this.config.onSuccess?.(t.payload);break;case c:this.status="ERROR",this.config.onError?.(t.payload);break;case l:{const e=t.payload;this.config.onStepChange?.(e.step,e.stepIndex);break}case d:{const e=t.payload;this.config.onStepComplete?.(e.step);break}case E:this.status="EXITED",this.config.onExit?.(t.payload);break;case h:this.config.onLivenessVideoUploaded?.(t.payload);break;case f:{const e=this.config.onTokenExpired;e?e().then(e=>this.sendToIframe({type:u,payload:e}),()=>{this.config.onError?.({code:i.SESSION_EXPIRED,message:"Token refresh failed."})}):this.config.onError?.({code:i.SESSION_EXPIRED,message:"Session token expired. Provide onTokenExpired in config to refresh."});break}}};window.addEventListener("message",n),this.messageHandler=n,this.iframe=r,e.replaceChildren(r),this.attachIframeHeightSync(e,r);const g=await this.resolveManifest(t);if(!g)return;const I=g.entry.startsWith("/")?g.entry:`/${g.entry}`;return new Promise(e=>{r.onload=()=>{if(!this.iframe?.contentWindow)return this.status="ERROR",this.config.onError?.({code:i.UNKNOWN,message:"Iframe failed to load."}),void e();const r=function(e){const t={containerId:"velion-sdk-root",allowEmbedded:!0};for(const r of ie){if("containerId"===r||"allowEmbedded"===r)continue;const n=e[r];void 0!==n&&"function"!=typeof n&&(t[r]=n)}return t}(this.config);let n;try{n=JSON.parse(JSON.stringify(r))}catch{n=r}this.sendToIframe({type:s,payload:n}),this.status="RUNNING",this.armReadyTimer(t),e()},r.onerror=()=>{this.status="ERROR",this.config.onError?.({code:i.UNKNOWN,message:`Failed to load onboarding app from ${t}. Check cdnUrl and network.`}),e()},r.src=`${t}${I}`})}async resolveManifest(e){let t;try{t=await async function(e,t=J){let r,n,i,s;try{const t=await fetch(`${e}/manifest.json`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(404===t.status)return{ok:!1,reason:"unavailable"};if(!t.ok)return{ok:!1,reason:"unavailable",detail:`HTTP ${t.status}`};r=await t.arrayBuffer(),n=(new TextDecoder).decode(r)}catch(o){return{ok:!1,reason:"unavailable",detail:o.message}}try{if(i=JSON.parse(n),"string"!=typeof i.version||"string"!=typeof i.entry||"string"!=typeof i.buildTime)return{ok:!1,reason:"malformed"}}catch(o){return{ok:!1,reason:"malformed",detail:o.message}}if(!t)return{ok:!0,manifest:i,signed:!1};try{const t=await fetch(`${e}/manifest.sig`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(!t.ok)return{ok:!1,reason:"invalid_signature",detail:`sig HTTP ${t.status}`};s=Q((await t.text()).trim())}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return await te(t,s,r)||{ok:!0,manifest:i,signed:!0}}(e)}catch(r){return this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:`Manifest verification crashed unexpectedly: ${r.message}`}),null}if(t.ok)return!t.signed&&J?(this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:"Internal: manifest reported as unsigned despite pubkey being set."}),null):t.manifest;if("unavailable"===t.reason){return!0!==this.config.allowUnverifiedCdn?(this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:`CDN at "${e}" did not expose /manifest.json. The loader is configured to require a signed manifest. If the CDN is migrating, set \`allowUnverifiedCdn: true\` on the loader config — but only as a temporary measure.`}),null):{version:"legacy",buildTime:(new Date).toISOString(),entry:"/index.html"}}return"unsupported_browser"===t.reason?(this.status="ERROR",this.config.onError?.({code:i.UNSUPPORTED_BROWSER,message:"This browser cannot verify the signature of the Velion CDN manifest, so the onboarding cannot start. It needs a secure context (https) and WebCrypto (Chrome/Edge 67+, Firefox 68+, Safari 14+). "+(t.detail?`Detail: ${t.detail}`:"")}),null):(this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" failed integrity check (${t.reason}). Refusing to load the iframe to protect the user. `+("detail"in t&&t.detail?`Detail: ${t.detail}`:"")}),null)}attachIframeHeightSync(e,t){const r=()=>{if(this.iframe!==t||this.container!==e)return;const r=e.clientHeight;r>0?(t.style.height=`${r}px`,t.style.minHeight=""):(t.style.height="min(85vh, 880px)",t.style.minHeight="")};r(),requestAnimationFrame(r),requestAnimationFrame(()=>{requestAnimationFrame(r)}),"undefined"!=typeof ResizeObserver?(this.containerResizeObserver=new ResizeObserver(r),this.containerResizeObserver.observe(e)):(this.iframeHeightWindowResizeHandler=r,window.addEventListener("resize",r))}detachIframeHeightSync(){this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),this.iframeHeightWindowResizeHandler&&(window.removeEventListener("resize",this.iframeHeightWindowResizeHandler),this.iframeHeightWindowResizeHandler=null)}sendToIframe(e){this.iframe?.contentWindow&&this.iframe.contentWindow.postMessage(e,this.cdnOrigin)}getStatus(){return this.status}static getVersion(){return"1.1.0-beta.2"}destroy(){"DESTROYED"!==this.status&&(this.clearReadyTimer(),this.detachIframeHeightSync(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.container&&(this.iframe.remove(),this.container.replaceChildren()),this.iframe=null,this.container=null,this.status="DESTROYED")}},e.setOpenCVBaseUrl=function(e){},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VelionSDK={})}(this,function(e){"use strict";var t=Object.defineProperty,r=(e,r,n)=>((e,r,n)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n)(e,"symbol"!=typeof r?r+"":r,n),n=(e=>(e.PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.DEVICE_NOT_FOUND="CAMERA_DEVICE_NOT_FOUND",e.DEVICE_NOT_READABLE="CAMERA_DEVICE_NOT_READABLE",e.INSECURE_CONTEXT="CAMERA_INSECURE_CONTEXT",e.POLICY_BLOCKED="CAMERA_POLICY_BLOCKED",e.NOT_SUPPORTED="CAMERA_NOT_SUPPORTED",e.WEBVIEW_BLOCKED="CAMERA_WEBVIEW_BLOCKED",e.CONSTRAINT_ERROR="CAMERA_CONSTRAINT_ERROR",e.UNKNOWN="CAMERA_UNKNOWN_ERROR",e))(n||{}),i=(e=>(e.SESSION_INVALID="SESSION_INVALID",e.SESSION_EXPIRED="SESSION_EXPIRED",e.SESSION_FETCH_FAILED="SESSION_FETCH_FAILED",e.SESSION_DECLINED="SESSION_DECLINED",e.ROUTING_TIMEOUT="ROUTING_TIMEOUT",e.FINGERPRINT_FAILED="FINGERPRINT_FAILED",e.DOCUMENT_UPLOAD_FAILED="DOCUMENT_UPLOAD_FAILED",e.LIVENESS_FAILED="LIVENESS_FAILED",e.LIVENESS_INIT_FAILED="LIVENESS_INIT_FAILED",e.LIVENESS_VIDEO_UPLOAD_FAILED="LIVENESS_VIDEO_UPLOAD_FAILED",e.CAMERA_ERROR="CAMERA_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.ALREADY_STARTED="ALREADY_STARTED",e.INSTANCE_DESTROYED="INSTANCE_DESTROYED",e.INSECURE_EMBED="INSECURE_EMBED",e.INTEGRITY_FAILED="INTEGRITY_FAILED",e.UNSUPPORTED_BROWSER="UNSUPPORTED_BROWSER",e.RUNTIME_LOAD_FAILED="RUNTIME_LOAD_FAILED",e.UNKNOWN="UNKNOWN",e))(i||{});const s="VELION_INIT",o="VELION_READY",a="VELION_SUCCESS",c="VELION_ERROR",l="VELION_STEP_CHANGE",d="VELION_STEP_COMPLETE",f="VELION_TOKEN_EXPIRED",E="VELION_EXIT",h="VELION_LIVENESS_VIDEO_UPLOADED",u="VELION_TOKEN",g=Object.freeze,I=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,m=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,y=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,R=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,N=0x6666666666666666666666666666666666666666666666666666666666666658n,O=I-1n,p=g({p:I,n:m,h:8n,a:O,d:y,Gx:R,Gy:N}),_=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&1===e.BYTES_PER_ELEMENT,T=(e,t,r="")=>{if(_(e)&&(void 0===t||e.length===t))return e;const n=_(e),i=(r?`"${r}" `:"")+"expected Uint8Array"+(void 0!==t?` of length ${t}`:"")+", got "+(n?`length=${e.length}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)},S=(e,t)=>e.toString(16).padStart(t,"0"),w=e=>{let t="";for(const r of T(e))t+=S(r,2);return t},A=e=>{const t="hex invalid";if("string"!=typeof e)throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);const r=new Uint8Array(e.length/2);for(let n=0,i=0;n<r.length;n++,i+=2){const t=e.charCodeAt(i),s=e.charCodeAt(i+1);r[n]=16*((15&t)+9*(t>>6))+(15&s)+9*(s>>6)}return r},b=(...e)=>{let t=0;for(const i of e)t+=T(i).length;const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r},D=(e,t,r,n="bad number: out of range")=>{if("bigint"!=typeof e)throw new TypeError(n);if(t<=e&&e<r)return e;throw new RangeError(n)},L=(e,t=I)=>(e%=t)>=0n?e:t+e,v=(1n<<255n)-1n,C=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=19n*(e>>255n)+(e&v);return t=19n*(t>>255n)+(t&v),t%I},U=async(e,...t)=>T(await(e=>{const t=X[e];if("function"!=typeof t)throw new Error("hashes."+e+" not set");return t})(e)(b(...t)),64,"digest"),V=e=>{if(e instanceof P)return e;throw new TypeError("Point expected")},M=2n**256n,x=class e{constructor(e,t,n,i){r(this,"X"),r(this,"Y"),r(this,"Z"),r(this,"T");const s=M;this.X=D(e,0n,s),this.Y=D(t,0n,s),this.Z=D(n,1n,s),this.T=D(i,0n,s),g(this)}static CURVE(){return p}static fromAffine(t){return new e(t.x,t.y,1n,C(t.x*t.y))}static fromBytes(t,r=!1){const n=((e,t="",r)=>Uint8Array.from(T(e,r,t)))(t,"point",32),i=n[31];n[31]=-129&i;const s=H(n);r||D(s,0n,I);const o=C(s*s),a=L(o-1n),c=C(y*o+1n);let{isValid:l,value:d}=G(a,c);if(!l)throw new Error("bad point: y not sqrt");const f=!!(128&i);if(!r&&0n===d&&f)throw new Error("bad point: x==0, isLastByteOdd");return f!==!!(1n&d)&&(d=L(-d)),new e(d,s,1n,C(d*s))}static fromHex(t,r){return e.fromBytes(A(t),r)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=O,t=y;if(this.is0())throw new Error("bad point: ZERO");const{X:r,Y:n,Z:i,T:s}=this,o=C(r*r),a=C(n*n),c=C(i*i),l=C(c*c),d=C(o*e);if(C(c*(d+a))!==L(l+C(t*C(o*a))))throw new Error("bad point: equation left != right (1)");if(C(r*n)!==C(i*s))throw new Error("bad point: equation left != right (2)");return this}equals(e){const{X:t,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=V(e);return C(t*o)===C(i*n)&&C(r*o)===C(s*n)}is0(){return this.equals(F)}negate(){return new e(L(-this.X),this.Y,this.Z,L(-this.T))}double(){const{X:t,Y:r,Z:n}=this,i=O,s=C(t*t),o=C(r*r),a=C(2n*n*n),c=C(i*s),l=L(t+r),d=L(C(l*l)-s-o),f=L(c+o),E=L(f-a),h=L(c-o),u=C(d*E),g=C(f*h),I=C(d*h),m=C(E*f);return new e(u,g,m,I)}add(t){const{X:r,Y:n,Z:i,T:s}=this,{X:o,Y:a,Z:c,T:l}=V(t),d=O,f=y,E=C(r*o),h=C(n*a),u=C(C(s*f)*l),g=C(i*c),I=L(C(L(r+n)*L(o+a))-E-h),m=L(g-u),R=L(g+u),N=L(h-C(d*E)),p=C(I*m),_=C(R*N),T=C(I*N),S=C(m*R);return new e(p,_,S,T)}subtract(e){return this.add(V(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return F;if(D(e,1n,m),!t&&this.is0())return F;if(1n===e)return this;if(this.equals(k))return j(e).p;let r=F,n=k,i=this;for(let s=0;t?s<256:e>0n;s++)1n&e?r=r.add(i):t&&(n=n.add(i)),i=i.double(),e>>=1n;return r}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:r}=this;if(this.equals(F))return{x:0n,y:1n};const n=((e,t)=>{if(0n===e)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let r=L(e,t),n=t,i=0n,s=1n;for(;0n!==r;){const e=n/r,t=n-r*e,o=i-s*e;n=r,r=t,i=s,s=o}if(1n!==n)throw new Error("invert: does not exist");return L(i,t)})(r,I);if(1n!==C(r*n))throw new Error("invalid inverse");return{x:C(e*n),y:C(t*n)}}toBytes(){const{x:e,y:t}=this.toAffine(),r=B(t);return r[31]|=1n&e?128:0,r}toHex(){return w(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(m/2n,!1).double().add(this).is0()}};r(x,"BASE"),r(x,"ZERO");let P=x;const k=new P(R,N,1n,L(R*N)),F=new P(0n,1n,1n,0n);P.BASE=k,P.ZERO=F;const B=e=>A(S(D(e,0n,M),64)).reverse(),H=e=>BigInt("0x"+w(Uint8Array.from(T(e)).reverse())),W=(e,t)=>{let r=e;for(;t-- >0;)r=C(r*r);return r},Y=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,G=(e,t)=>{const r=C(t*C(t*t)),n=C(C(r*r)*t),i=(e=>{const t=C(e*e),r=C(t*e),n=C(W(r,2)*r),i=C(W(n,1)*e),s=C(W(i,5)*i),o=C(W(s,10)*s),a=C(W(o,20)*o),c=C(W(a,40)*a),l=C(W(c,80)*c),d=C(W(l,80)*c),f=C(W(d,10)*s);return C(W(f,2)*e)})(C(e*n));let s=C(e*C(r*i));const o=C(t*C(s*s)),a=s,c=C(s*Y),l=o===e,d=o===L(-e),f=o===L(-e*Y);return l&&(s=a),(d||f)&&(s=c),1n==(1n&L(s))&&(s=L(-s)),{isValid:l||d,value:s}},$=e=>{return t=H(e),L(t,m);var t},K=(e,t,r,n)=>{e=T(e,64,"signature"),t=T(t,void 0,"message"),r=T(r,32,"publicKey");const i=(e=>{if(null===e||"object"!=typeof e)throw new TypeError("expected valid options object");return e.zip215??!0})(n),s=e.subarray(0,32),o=H(e.subarray(32,64));let a,c,l,d=Uint8Array.of(),f=!1;try{a=P.fromBytes(r,i),c=P.fromBytes(s,i),l=k.multiply(o,!1),d=b(s,r,t),f=!0}catch(E){}return[d,e=>{if(!f)return!1;if(!i&&a.isSmallOrder())return!1;const t=$(e);return c.add(a.multiply(t,!1)).subtract(l).clearCofactor().is0()}]},z=async(e,t,r,n={})=>(async e=>e[1](await U("sha512Async",e[0])))(K(e,t,r,n)),X={sha512Async:async e=>{const t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",b(e)))},sha512:void 0};let Z;const q=(e,t)=>{const r=t.negate();return e?r:t},j=e=>{const t=Z||(Z=(()=>{const e=[];let t,r=k;for(let n=0;n<33;n++){t=r,e.push(t);for(let n=1;n<128;n++)t=t.add(r),e.push(t);r=t.double()}return e})());let r=F,n=k;for(let i=0;i<33;i++){let s=Number(255n&e);e>>=8n,s>128&&(s-=256,e+=1n);const o=128*i,a=o+Math.abs(s)-1,c=i%2!=0,l=s<0;0===s?n=n.add(q(c,t[o])):r=r.add(q(l,t[a]))}if(0n!==e)throw new Error("invalid wnaf");return{p:r,f:n}},J="lpqLG4Ta0YyBn/+lQh95tFl4CuTIHWapeeq7+xnPH+U=";function Q(e){const t=atob(e),r=new ArrayBuffer(t.length),n=new Uint8Array(r);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return r}function ee(e){if(e instanceof Error&&"NotSupportedError"===e.name)return!0;const t=e instanceof Error?e.message:String(e);return/unrecognized|not supported|unsupported/i.test(t)}async function te(e,t,r){if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unsupported_browser",detail:"crypto.subtle is unavailable (insecure context or very old browser); the manifest signature cannot be verified."};const n=Q(e),i=await async function(e,t,r){let n;try{n=await crypto.subtle.importKey("raw",e,{name:"Ed25519"},!1,["verify"])}catch(i){return ee(i)?{kind:"unsupported"}:{kind:"error",detail:`pubkey import failed: ${i.message}`}}try{return{kind:"verdict",valid:await crypto.subtle.verify({name:"Ed25519"},n,t,r)}}catch(i){return ee(i)?{kind:"unsupported"}:{kind:"error",detail:i.message}}}(n,t,r);if("error"===i.kind)return{ok:!1,reason:"invalid_signature",detail:i.detail};let s;if("verdict"===i.kind)s=i.valid;else try{s=await async function(e,t,r){return z(new Uint8Array(t),new Uint8Array(r),new Uint8Array(e),{zip215:!1})}(n,t,r)}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return s?null:{ok:!1,reason:"invalid_signature"}}const re="https://static.velion.la/sdk/onboarding/v1";function ne(e){try{const r=new URL(e);return"https:"===r.protocol||"http:"===r.protocol&&("localhost"===(t=r.hostname)||"127.0.0.1"===t||"::1"===t||t.endsWith(".local"))}catch{return!1}var t}const ie=["containerId","sessionId","sessionToken","apiUrl","expiresAt","theme","colorMode","locale","allowEmbedded","livenessShowIntro","livenessShowBackButton","fingerprintEndpoint","debug","googleMapsApiKey","showFinalResultScreen","showProgressBar","finalResultScreenTexts","routingTimeoutMs"];e.CameraErrorCode=n,e.DEFAULT_CDN_URL=re,e.SdkErrorCode=i,e.VELION_MSG_ERROR=c,e.VELION_MSG_EXIT=E,e.VELION_MSG_INIT=s,e.VELION_MSG_LIVENESS_VIDEO_UPLOADED=h,e.VELION_MSG_READY=o,e.VELION_MSG_STEP_CHANGE=l,e.VELION_MSG_STEP_COMPLETE=d,e.VELION_MSG_SUCCESS=a,e.VELION_MSG_TOKEN=u,e.VELION_MSG_TOKEN_EXPIRED=f,e.VelionOnboarding=class{constructor(e){this.status="IDLE",this.iframe=null,this.container=null,this.messageHandler=null,this.containerResizeObserver=null,this.iframeHeightWindowResizeHandler=null,this.cdnOrigin="",this.readyTimer=null,this.config=Object.freeze({...e})}clearReadyTimer(){null!==this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null)}armReadyTimer(e){this.clearReadyTimer();const t=this.config.runtimeReadyTimeoutMs??3e4;t>0&&(this.readyTimer=setTimeout(()=>{this.readyTimer=null,"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:i.RUNTIME_LOAD_FAILED,message:`The onboarding runtime at ${e} did not become ready within ${t} ms. Check that the CDN serves the assets referenced by its index.html and that the host page's Content-Security-Policy allows the runtime scripts.`}))},t))}async start(){if("DESTROYED"===this.status)return void this.config.onError?.({code:i.INSTANCE_DESTROYED,message:"This VelionOnboarding instance has been destroyed. Create a new instance to retry."});if("IDLE"!==this.status)return void this.config.onError?.({code:i.ALREADY_STARTED,message:"start() was called on an already-running SDK instance. Call destroy() before re-starting."});const e=document.getElementById(this.config.containerId);if(!e)return void this.config.onError?.({code:i.CONTAINER_NOT_FOUND,message:`No DOM element found with id="${this.config.containerId}". Ensure the element exists before calling start().`});const t=(this.config.cdnUrl??re).replace(/\/$/,"");if(!ne(t))return void this.config.onError?.({code:i.UNKNOWN,message:`Insecure cdnUrl: "${t}". Must be https:// (http:// is allowed only for localhost).`});if(this.config.apiUrl&&!ne(this.config.apiUrl))return void this.config.onError?.({code:i.UNKNOWN,message:`Insecure apiUrl: "${this.config.apiUrl}". Must be https:// (http:// is allowed only for localhost).`});if(this.cdnOrigin=function(e){try{return new URL(e).origin}catch{return""}}(t),!this.cdnOrigin)return void this.config.onError?.({code:i.UNKNOWN,message:`Invalid cdnUrl: ${t}. Must be a valid absolute URL.`});this.container=e,this.status="INITIALIZING";const r=document.createElement("iframe");r.setAttribute("title","Velion Onboarding"),r.setAttribute("allow","camera"),r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-modals"),r.setAttribute("referrerpolicy","no-referrer"),r.style.width="100%",r.style.border="none",r.style.display="block";const n=e=>{if(e.origin!==this.cdnOrigin)return;if(e.source!==this.iframe?.contentWindow)return;const t=e.data;if(t&&"string"==typeof t.type)switch(this.clearReadyTimer(),t.type){case o:this.status="RUNNING";break;case a:this.status="COMPLETED",this.config.onSuccess?.(t.payload);break;case c:this.status="ERROR",this.config.onError?.(t.payload);break;case l:{const e=t.payload;this.config.onStepChange?.(e.step,e.stepIndex);break}case d:{const e=t.payload;this.config.onStepComplete?.(e.step);break}case E:this.status="EXITED",this.config.onExit?.(t.payload);break;case h:this.config.onLivenessVideoUploaded?.(t.payload);break;case f:{const e=this.config.onTokenExpired;e?e().then(e=>this.sendToIframe({type:u,payload:e}),()=>{this.config.onError?.({code:i.SESSION_EXPIRED,message:"Token refresh failed."})}):this.config.onError?.({code:i.SESSION_EXPIRED,message:"Session token expired. Provide onTokenExpired in config to refresh."});break}}};window.addEventListener("message",n),this.messageHandler=n,this.iframe=r,e.replaceChildren(r),this.attachIframeHeightSync(e,r);const g=await this.resolveManifest(t);if(!g)return;const I=g.entry.startsWith("/")?g.entry:`/${g.entry}`;return new Promise(e=>{r.onload=()=>{if(!this.iframe?.contentWindow)return this.status="ERROR",this.config.onError?.({code:i.UNKNOWN,message:"Iframe failed to load."}),void e();const r=function(e){const t={containerId:"velion-sdk-root",allowEmbedded:!0};for(const r of ie){if("containerId"===r||"allowEmbedded"===r)continue;const n=e[r];void 0!==n&&"function"!=typeof n&&(t[r]=n)}return t}(this.config);let n;try{n=JSON.parse(JSON.stringify(r))}catch{n=r}this.sendToIframe({type:s,payload:n}),this.status="RUNNING",this.armReadyTimer(t),e()},r.onerror=()=>{this.status="ERROR",this.config.onError?.({code:i.UNKNOWN,message:`Failed to load onboarding app from ${t}. Check cdnUrl and network.`}),e()},r.src=`${t}${I}`})}async resolveManifest(e){let t;try{t=await async function(e,t=J){let r,n,i,s;try{const t=await fetch(`${e}/manifest.json`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(404===t.status)return{ok:!1,reason:"unavailable"};if(!t.ok)return{ok:!1,reason:"unavailable",detail:`HTTP ${t.status}`};r=await t.arrayBuffer(),n=(new TextDecoder).decode(r)}catch(o){return{ok:!1,reason:"unavailable",detail:o.message}}try{if(i=JSON.parse(n),"string"!=typeof i.version||"string"!=typeof i.entry||"string"!=typeof i.buildTime)return{ok:!1,reason:"malformed"}}catch(o){return{ok:!1,reason:"malformed",detail:o.message}}if(!t)return{ok:!0,manifest:i,signed:!1};try{const t=await fetch(`${e}/manifest.sig`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(!t.ok)return{ok:!1,reason:"invalid_signature",detail:`sig HTTP ${t.status}`};s=Q((await t.text()).trim())}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return await te(t,s,r)||{ok:!0,manifest:i,signed:!0}}(e)}catch(r){return this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:`Manifest verification crashed unexpectedly: ${r.message}`}),null}if(t.ok)return!t.signed&&J?(this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:"Internal: manifest reported as unsigned despite pubkey being set."}),null):t.manifest;if("unavailable"===t.reason){return!0!==this.config.allowUnverifiedCdn?(this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:`CDN at "${e}" did not expose /manifest.json. The loader is configured to require a signed manifest. If the CDN is migrating, set \`allowUnverifiedCdn: true\` on the loader config — but only as a temporary measure.`}),null):{version:"legacy",buildTime:(new Date).toISOString(),entry:"/index.html"}}return"unsupported_browser"===t.reason?(this.status="ERROR",this.config.onError?.({code:i.UNSUPPORTED_BROWSER,message:"This browser cannot verify the signature of the Velion CDN manifest, so the onboarding cannot start. It needs a secure context (https) and WebCrypto (Chrome/Edge 67+, Firefox 68+, Safari 14+). "+(t.detail?`Detail: ${t.detail}`:"")}),null):(this.status="ERROR",this.config.onError?.({code:i.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" failed integrity check (${t.reason}). Refusing to load the iframe to protect the user. `+("detail"in t&&t.detail?`Detail: ${t.detail}`:"")}),null)}attachIframeHeightSync(e,t){const r=()=>{if(this.iframe!==t||this.container!==e)return;const r=e.clientHeight;r>0?(t.style.height=`${r}px`,t.style.minHeight=""):(t.style.height="min(85vh, 880px)",t.style.minHeight="")};r(),requestAnimationFrame(r),requestAnimationFrame(()=>{requestAnimationFrame(r)}),"undefined"!=typeof ResizeObserver?(this.containerResizeObserver=new ResizeObserver(r),this.containerResizeObserver.observe(e)):(this.iframeHeightWindowResizeHandler=r,window.addEventListener("resize",r))}detachIframeHeightSync(){this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),this.iframeHeightWindowResizeHandler&&(window.removeEventListener("resize",this.iframeHeightWindowResizeHandler),this.iframeHeightWindowResizeHandler=null)}sendToIframe(e){this.iframe?.contentWindow&&this.iframe.contentWindow.postMessage(e,this.cdnOrigin)}getStatus(){return this.status}static getVersion(){return"1.1.0-beta.3"}destroy(){"DESTROYED"!==this.status&&(this.clearReadyTimer(),this.detachIframeHeightSync(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.container&&(this.iframe.remove(),this.container.replaceChildren()),this.iframe=null,this.container=null,this.status="DESTROYED")}},e.setOpenCVBaseUrl=function(e){},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=velion-sdk.umd.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velion-la/onboarding-sdk-web",
3
- "version": "1.1.0-beta.2",
3
+ "version": "1.1.0-beta.3",
4
4
  "description": "Web SDK for the Velion Onboarding (KYC) flow. Thin client that boots the full verification experience (ID document OCR, passive + active liveness, device fingerprint, OTP verification, address picker, and personal / legal information forms) inside an embedded iframe served from the Velion CDN.",
5
5
  "type": "module",
6
6
  "main": "./dist/velion-sdk.umd.js",