@veriff/incontext-sdk
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -10,12 +10,18 @@ 'use strict'; | ||
var MESSAGES = { | ||
var IFRAME_MESSAGES = { | ||
VERIFF_HANDSHAKE: 'VERIFF_HANDSHAKE', | ||
VERIFF_RENDER: 'VERIFF_RENDER', | ||
VERIFF_CLOSE: 'VERIFF_CLOSE' | ||
VERIFF_FINISHED: 'VERIFF_FINISHED', | ||
VERIFF_CANCELED: 'VERIFF_CANCELED' | ||
}; | ||
var CLIENT_MESSAGES = { | ||
FINISHED: 'FINISHED', | ||
CANCELED: 'CANCELED' | ||
}; | ||
var IFRAME_ID = 'veriffFrame'; | ||
var wrapperStyles = "\n position: fixed !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n z-index: 9999999;\n display: block !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n background: rgba(0, 0, 0, 0.6);\n"; | ||
var iframeStyles = "\n position: absolute !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n background: none;\n border: none\n"; | ||
var IFRAME_ID = 'veriffFrame'; | ||
function createIframe(url) { | ||
@@ -36,39 +42,53 @@ var frame = document.createElement('iframe'); | ||
function closeIframe(frame) { | ||
if (frame && frame.parentNode) { | ||
focusLock.off(frame); | ||
bodyScrollLock.enableBodyScroll(frame); | ||
var wrapper = frame.parentNode.parentNode; | ||
wrapper.removeChild(frame.parentNode); | ||
} else { | ||
bodyScrollLock.clearAllBodyScrollLocks(); | ||
function createVeriffFrame() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
url = _ref.url, | ||
_ref$onEvent = _ref.onEvent, | ||
onEvent = _ref$onEvent === void 0 ? function () {} : _ref$onEvent; | ||
if (!url) { | ||
throw new Error('URL is not provided. Please provide a valid Veriff session url.'); | ||
} | ||
} | ||
function handleMessage(event) { | ||
var frame = document.getElementById(IFRAME_ID); | ||
function closeIframe() { | ||
var frame = document.getElementById(IFRAME_ID); | ||
if (event.data === MESSAGES.VERIFF_HANDSHAKE) { | ||
frame.contentWindow.postMessage(MESSAGES.VERIFF_RENDER, '*'); | ||
} | ||
if (frame && frame.parentNode) { | ||
focusLock.off(frame); | ||
bodyScrollLock.enableBodyScroll(frame); | ||
var wrapper = frame.parentNode.parentNode; | ||
wrapper.removeChild(frame.parentNode); | ||
} else { | ||
bodyScrollLock.clearAllBodyScrollLocks(); | ||
} // eslint-disable-next-line no-use-before-define | ||
if (event.data === MESSAGES.VERIFF_CLOSE) { | ||
closeIframe(frame); | ||
window.removeEventListener('message', handleMessage); | ||
} | ||
} | ||
function init() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
url = _ref.url; | ||
function handleMessage(event) { | ||
var frame = document.getElementById(IFRAME_ID); | ||
if (!url) { | ||
throw new Error('URL is not provided. Please provide a valid Veriff session url.'); | ||
if (event.data === IFRAME_MESSAGES.VERIFF_HANDSHAKE) { | ||
frame.contentWindow.postMessage(IFRAME_MESSAGES.VERIFF_RENDER, '*'); | ||
} | ||
if (event.data === IFRAME_MESSAGES.VERIFF_CANCELED) { | ||
closeIframe(); | ||
onEvent(CLIENT_MESSAGES.CANCELED); | ||
} | ||
if (event.data === IFRAME_MESSAGES.VERIFF_FINISHED) { | ||
closeIframe(); | ||
onEvent(CLIENT_MESSAGES.FINISHED); | ||
} | ||
} | ||
createIframe(url); | ||
window.removeEventListener('message', handleMessage); | ||
window.addEventListener('message', handleMessage); | ||
return { | ||
close: closeIframe | ||
}; | ||
} | ||
exports.closeVeriffFrame = closeIframe; | ||
exports.createVeriffFrame = init; | ||
exports.createVeriffFrame = createVeriffFrame; |
@@ -1,14 +0,20 @@ | ||
import { enableBodyScroll, clearAllBodyScrollLocks, disableBodyScroll } from 'body-scroll-lock'; | ||
import { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'; | ||
import focusLock from 'dom-focus-lock'; | ||
var MESSAGES = { | ||
var IFRAME_MESSAGES = { | ||
VERIFF_HANDSHAKE: 'VERIFF_HANDSHAKE', | ||
VERIFF_RENDER: 'VERIFF_RENDER', | ||
VERIFF_CLOSE: 'VERIFF_CLOSE' | ||
VERIFF_FINISHED: 'VERIFF_FINISHED', | ||
VERIFF_CANCELED: 'VERIFF_CANCELED' | ||
}; | ||
var CLIENT_MESSAGES = { | ||
FINISHED: 'FINISHED', | ||
CANCELED: 'CANCELED' | ||
}; | ||
var IFRAME_ID = 'veriffFrame'; | ||
var wrapperStyles = "\n position: fixed !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n z-index: 9999999;\n display: block !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n background: rgba(0, 0, 0, 0.6);\n"; | ||
var iframeStyles = "\n position: absolute !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n background: none;\n border: none\n"; | ||
var IFRAME_ID = 'veriffFrame'; | ||
function createIframe(url) { | ||
@@ -29,38 +35,53 @@ var frame = document.createElement('iframe'); | ||
function closeIframe(frame) { | ||
if (frame && frame.parentNode) { | ||
focusLock.off(frame); | ||
enableBodyScroll(frame); | ||
var wrapper = frame.parentNode.parentNode; | ||
wrapper.removeChild(frame.parentNode); | ||
} else { | ||
clearAllBodyScrollLocks(); | ||
function createVeriffFrame() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
url = _ref.url, | ||
_ref$onEvent = _ref.onEvent, | ||
onEvent = _ref$onEvent === void 0 ? function () {} : _ref$onEvent; | ||
if (!url) { | ||
throw new Error('URL is not provided. Please provide a valid Veriff session url.'); | ||
} | ||
} | ||
function handleMessage(event) { | ||
var frame = document.getElementById(IFRAME_ID); | ||
function closeIframe() { | ||
var frame = document.getElementById(IFRAME_ID); | ||
if (event.data === MESSAGES.VERIFF_HANDSHAKE) { | ||
frame.contentWindow.postMessage(MESSAGES.VERIFF_RENDER, '*'); | ||
} | ||
if (frame && frame.parentNode) { | ||
focusLock.off(frame); | ||
enableBodyScroll(frame); | ||
var wrapper = frame.parentNode.parentNode; | ||
wrapper.removeChild(frame.parentNode); | ||
} else { | ||
clearAllBodyScrollLocks(); | ||
} // eslint-disable-next-line no-use-before-define | ||
if (event.data === MESSAGES.VERIFF_CLOSE) { | ||
closeIframe(frame); | ||
window.removeEventListener('message', handleMessage); | ||
} | ||
} | ||
function init() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
url = _ref.url; | ||
function handleMessage(event) { | ||
var frame = document.getElementById(IFRAME_ID); | ||
if (!url) { | ||
throw new Error('URL is not provided. Please provide a valid Veriff session url.'); | ||
if (event.data === IFRAME_MESSAGES.VERIFF_HANDSHAKE) { | ||
frame.contentWindow.postMessage(IFRAME_MESSAGES.VERIFF_RENDER, '*'); | ||
} | ||
if (event.data === IFRAME_MESSAGES.VERIFF_CANCELED) { | ||
closeIframe(); | ||
onEvent(CLIENT_MESSAGES.CANCELED); | ||
} | ||
if (event.data === IFRAME_MESSAGES.VERIFF_FINISHED) { | ||
closeIframe(); | ||
onEvent(CLIENT_MESSAGES.FINISHED); | ||
} | ||
} | ||
createIframe(url); | ||
window.removeEventListener('message', handleMessage); | ||
window.addEventListener('message', handleMessage); | ||
return { | ||
close: closeIframe | ||
}; | ||
} | ||
export { closeIframe as closeVeriffFrame, init as createVeriffFrame }; | ||
export { createVeriffFrame }; |
{ | ||
"name": "@veriff/incontext-sdk", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "In-Context Veriff browser integration", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -16,9 +16,26 @@ ## Installation | ||
// CommonJS | ||
var { createVeriffFrame } = require('@veriff/incontext-sdk'); | ||
const { createVeriffFrame } = require('@veriff/incontext-sdk'); | ||
createVeriffFrame({ url: VERIFF_SESSION_URL }) | ||
const veriffFrame = createVeriffFrame({ url: VERIFF_SESSION_URL }) | ||
``` | ||
This will render a popup with adapted Veriff application in iframe. | ||
This will render a modal with adapted Veriff application in iframe. | ||
### Listening for events | ||
Pass `onEvent` callback function when initializing SDK | ||
```javascript | ||
createVeriffFrame({ | ||
url, | ||
onEvent: function(event) { | ||
// | ||
} | ||
}) | ||
``` | ||
- `event`: | ||
- `CANCELED` - user closed the modal. | ||
- `FINISHED` - user finished verification flow. | ||
## Using with inline script | ||
@@ -39,10 +56,12 @@ | ||
### createVeriffFrame([options]) | ||
Create popup with Veriff application. | ||
Create modal with Veriff application. | ||
- `[options]` - Configuration object. | ||
- `url`: Veriff session URL | ||
- `url` - Veriff session URL | ||
- `onEvent` - Event callback function | ||
### closeVeriffFrame() | ||
Close Veriff popup. Normally popup will be closed due to user input, but if you want to control it(e.g. timeout), please use this function. | ||
Returns an object that controls the modal. | ||
### .close() | ||
Close Veriff modal. Normally modal will be closed due to user input, but if you want to control it(e.g. timeout), please use this function. | ||
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).veriffSDK={})}(this,function(e){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var n,t,o=(function(e,n){!function(e){function r(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}Object.defineProperty(e,"__esModule",{value:!0});var u=!1;if("undefined"!=typeof window){var n={get passive(){u=!0}};window.addEventListener("testPassive",null,n),window.removeEventListener("testPassive",null,n)}var a="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&/iP(ad|hone|od)/.test(window.navigator.platform),c=[],d=!1,l=-1,f=void 0,s=void 0,m=function(n){return c.some(function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(n))})},v=function(e){var n=e||window.event;return!!m(n.target)||(1<n.touches.length||(n.preventDefault&&n.preventDefault(),!1))},t=function(){setTimeout(function(){void 0!==s&&(document.body.style.paddingRight=s,s=void 0),void 0!==f&&(document.body.style.overflow=f,f=void 0)})};e.disableBodyScroll=function(i,e){if(a){if(!i)return void console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");if(i&&!c.some(function(e){return e.targetElement===i})){var n={targetElement:i,options:e||{}};c=[].concat(r(c),[n]),i.ontouchstart=function(e){1===e.targetTouches.length&&(l=e.targetTouches[0].clientY)},i.ontouchmove=function(e){var n,t,o,r;1===e.targetTouches.length&&(t=i,r=(n=e).targetTouches[0].clientY-l,!m(n.target)&&(t&&0===t.scrollTop&&0<r?v(n):(o=t)&&o.scrollHeight-o.scrollTop<=o.clientHeight&&r<0?v(n):n.stopPropagation()))},d||(document.addEventListener("touchmove",v,u?{passive:!1}:void 0),d=!0)}}else{o=e,setTimeout(function(){if(void 0===s){var e=!!o&&!0===o.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;e&&0<n&&(s=document.body.style.paddingRight,document.body.style.paddingRight=n+"px")}void 0===f&&(f=document.body.style.overflow,document.body.style.overflow="hidden")});var t={targetElement:i,options:e||{}};c=[].concat(r(c),[t])}var o},e.clearAllBodyScrollLocks=function(){a?(c.forEach(function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null}),d&&(document.removeEventListener("touchmove",v,u?{passive:!1}:void 0),d=!1),c=[],l=-1):(t(),c=[])},e.enableBodyScroll=function(n){if(a){if(!n)return void console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");n.ontouchstart=null,n.ontouchmove=null,c=c.filter(function(e){return e.targetElement!==n}),d&&0===c.length&&(document.removeEventListener("touchmove",v,u?{passive:!1}:void 0),d=!1)}else(c=c.filter(function(e){return e.targetElement!==n})).length||t()}}(n)}(n={exports:{}},n.exports),n.exports);(t=o)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")&&t.default;function r(e){for(var n=Array(e.length),t=0;t<e.length;++t)n[t]=e[t];return n}function l(e){return Array.isArray(e)?e:[e]}function i(e,n){var t=e.tabIndex-n.tabIndex,o=e.index-n.index;if(t){if(!e.tabIndex)return 1;if(!n.tabIndex)return-1}return t||o}function f(e,n,t){return r(e).map(function(e,n){return{node:e,index:n,tabIndex:t&&-1===e.tabIndex?(e.dataset||{}).focusGuard?0:-1:e.tabIndex}}).filter(function(e){return!n||0<=e.tabIndex}).sort(i)}function s(e,t){return e.reduce(function(e,n){return e.concat(r(n.querySelectorAll(t?B:R)),n.parentNode?r(n.parentNode.querySelectorAll(I.join(","))).filter(function(e){return e===n}):[])},[])}function u(e,n){var t=1<arguments.length&&void 0!==n?n:[];return t.push(e),e.parentNode&&u(e.parentNode,t),t}function m(e,n){for(var t=u(e),o=u(n),r=0;r<t.length;r+=1){var i=t[r];if(0<=o.indexOf(i))return i}return!1}function v(e){return r(e).filter(function(e){return function e(n){return!n||n===document||n.nodeType===Node.DOCUMENT_NODE||!function(e){return!(!e||!e.getPropertyValue)&&("none"===e.getPropertyValue("display")||"hidden"===e.getPropertyValue("visibility"))}(window.getComputedStyle(n,null))&&e(n.parentNode)}(e)}).filter(function(e){return function(e){return!(("INPUT"===e.tagName||"BUTTON"===e.tagName)&&("hidden"===e.type||e.disabled))}(e)})}function p(e,n){return f(v(s(e,n)),!0,n)}function g(e){return v(function(e){var n=e.querySelectorAll("[data-autofocus-inside]");return r(n).map(function(e){return s([e])}).reduce(function(e,n){return e.concat(n)},[])}(e))}function a(e){return"INPUT"===e.tagName&&"radio"===e.type}function h(e){return e[0]&&1<e.length&&a(e[0])&&e[0].name?function(n,e){return e.filter(a).filter(function(e){return e.name===n.name}).filter(function(e){return e.checked})[0]||n}(e[0],e):e[0]}function y(e){return l(e).filter(Boolean).reduce(function(e,n){var t=n.getAttribute(T);return e.push.apply(e,t?function e(t){for(var n=t.length,o=0;o<n;o+=1)for(var r=function(n){if(o!==n&&t[o].contains(t[n]))return{v:e(t.filter(function(e){return e!==t[n]}))}},i=0;i<n;i+=1){var u=r(i);if("object"===(void 0===u?"undefined":L(u)))return u.v}return t}(r(function e(n){return n.parentNode?e(n.parentNode):n}(n).querySelectorAll("["+T+'="'+t+'"]:not([data-focus-lock-disabled="disabled"])'))):[n]),e},[])}function b(e){return e.dataset&&e.dataset.focusGuard}function E(e){return!b(e)}function c(e,n){var t=document&&document.activeElement,o=y(e).filter(E),r=function(e,n,t){var o=l(e),r=l(n),i=o[0],u=null;return r.filter(Boolean).forEach(function(e){u=m(u||e,e)||u,t.filter(Boolean).forEach(function(e){var n=m(i,e);n&&(u=!u||n.contains(u)?n:m(n,u))})}),u}(t||e,e,o),i=p(o).filter(function(e){var n=e.node;return E(n)});if(i[0]||(i=function(e){return f(v(s(e)),!1)}(o).filter(function(e){var n=e.node;return E(n)}))[0]){var u=p([r]).map(function(e){return e.node}),a=function(e,n){var t=new Map;return n.forEach(function(e){return t.set(e.node,e)}),e.map(function(e){return t.get(e)}).filter(Boolean)}(u,i),c=a.map(function(e){return e.node}),d=function(e,n,t,o,r){var i=e.length,u=e[0],a=e[i-1];if(!(0<=e.indexOf(t))){var c=n.indexOf(t),d=n.indexOf(o||c),l=e.indexOf(o),f=c-d,s=n.indexOf(u),m=n.indexOf(a);return-1===c||-1===l?e.indexOf(r.length?h(r):h(e)):!f&&0<=l?l:c<=s&&b(t)&&1<Math.abs(f)?0:f&&1<Math.abs(f)?l:c<=s?i-1:m<c?0:f?1<Math.abs(f)?l:(i+l+f)%i:void 0}}(c,u,t,n,c.filter(function(n){return function(e){return!!e.autofocus||e.dataset&&!!e.dataset.autofocus||0<=n.indexOf(e)}}(function(e){return e.reduce(function(e,n){return e.concat(g(n))},[])}(o))));return void 0===d?d:a[d]}}function d(e){return e===document.activeElement}function w(e){var t=document&&document.activeElement;return!(!t||t.dataset&&t.dataset.focusGuard)&&y(e).reduce(function(e,n){return e||n.contains(t)||function(e){return!!function(e,n){return e.filter(function(e){return e===n})[0]}(r(e.querySelectorAll("iframe")),d)}(n)},!1)}function x(){return document&&document.activeElement===document.body||document&&r(document.querySelectorAll("[data-no-focus-lock]")).some(function(e){return e.contains(document.activeElement)})}function S(){var e=!1;if(P){var n=P;x()||(n&&!w(n)&&(e=function(e,n){var t=c(e,n);if(!V&&t){if(2<_)return console.error("FocusLock: focus-fighting detected. Only one focus management system could be active. See https://github.com/theKashey/focus-lock/#focus-fighting"),V=!0,void setTimeout(function(){V=!1},1);_++,function(e){e.focus(),e.contentWindow&&e.contentWindow.focus()}(t.node),_--}}(n,k)),k=document.activeElement)}return e}function N(e){return!!function(e){(P=e)&&S()}(function(e){return e.filter(function(e){return e}).slice(-1)[0]}(D))&&(e&&e.preventDefault(),!0)}var O=o.disableBodyScroll,A=o.enableBodyScroll,F=o.clearAllBodyScrollLocks,I=["button:enabled:not([readonly])","select:enabled:not([readonly])","textarea:enabled:not([readonly])","input:enabled:not([readonly])","a[href]","area[href]","iframe","object","embed","[tabindex]","[contenteditable]","[autofocus]"],T="data-focus-lock",R=I.join(","),B=R+", [data-focus-guard]",L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_=0,V=!1,P=0,k=null,D=[],M={on:function(e){0===D.length&&document.addEventListener("focusin",N),D.indexOf(e)<0&&(D.push(e),N())},off:function(n){D=D.filter(function(e){return e!==n}),N(),0===D.length&&document.removeEventListener("focusin",N)}},j={VERIFF_HANDSHAKE:"VERIFF_HANDSHAKE",VERIFF_RENDER:"VERIFF_RENDER",VERIFF_CLOSE:"VERIFF_CLOSE"},C="veriffFrame",H="\n position: fixed !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n z-index: 9999999;\n display: block !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n background: rgba(0, 0, 0, 0.6);\n",q="\n position: absolute !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n background: none;\n border: none\n";function K(e){e&&e.parentNode?(M.off(e),A(e),e.parentNode.parentNode.removeChild(e.parentNode)):F()}function U(e){var n=document.getElementById(C);e.data===j.VERIFF_HANDSHAKE&&n.contentWindow.postMessage(j.VERIFF_RENDER,"*"),e.data===j.VERIFF_CLOSE&&K(n)}e.closeVeriffFrame=K,e.createVeriffFrame=function(){var e=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}).url;if(!e)throw new Error("URL is not provided. Please provide a valid Veriff session url.");!function(e){var n=document.createElement("iframe");n.src=e,n.allow="camera; microphone",n.id=C,n.style.cssText=q;var t=document.createElement("div");t.style.cssText=H,t.appendChild(n),document.body.appendChild(t),M.on(n),O(n)}(e),window.removeEventListener("message",U),window.addEventListener("message",U)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).veriffSDK={})}(this,function(e){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var n,t,o=(function(e,n){!function(e){function r(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}Object.defineProperty(e,"__esModule",{value:!0});var u=!1;if("undefined"!=typeof window){var n={get passive(){u=!0}};window.addEventListener("testPassive",null,n),window.removeEventListener("testPassive",null,n)}var a="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&/iP(ad|hone|od)/.test(window.navigator.platform),c=[],d=!1,l=-1,f=void 0,s=void 0,m=function(n){return c.some(function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(n))})},v=function(e){var n=e||window.event;return!!m(n.target)||(1<n.touches.length||(n.preventDefault&&n.preventDefault(),!1))},t=function(){setTimeout(function(){void 0!==s&&(document.body.style.paddingRight=s,s=void 0),void 0!==f&&(document.body.style.overflow=f,f=void 0)})};e.disableBodyScroll=function(i,e){if(a){if(!i)return void console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");if(i&&!c.some(function(e){return e.targetElement===i})){var n={targetElement:i,options:e||{}};c=[].concat(r(c),[n]),i.ontouchstart=function(e){1===e.targetTouches.length&&(l=e.targetTouches[0].clientY)},i.ontouchmove=function(e){var n,t,o,r;1===e.targetTouches.length&&(t=i,r=(n=e).targetTouches[0].clientY-l,!m(n.target)&&(t&&0===t.scrollTop&&0<r?v(n):(o=t)&&o.scrollHeight-o.scrollTop<=o.clientHeight&&r<0?v(n):n.stopPropagation()))},d||(document.addEventListener("touchmove",v,u?{passive:!1}:void 0),d=!0)}}else{o=e,setTimeout(function(){if(void 0===s){var e=!!o&&!0===o.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;e&&0<n&&(s=document.body.style.paddingRight,document.body.style.paddingRight=n+"px")}void 0===f&&(f=document.body.style.overflow,document.body.style.overflow="hidden")});var t={targetElement:i,options:e||{}};c=[].concat(r(c),[t])}var o},e.clearAllBodyScrollLocks=function(){a?(c.forEach(function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null}),d&&(document.removeEventListener("touchmove",v,u?{passive:!1}:void 0),d=!1),c=[],l=-1):(t(),c=[])},e.enableBodyScroll=function(n){if(a){if(!n)return void console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");n.ontouchstart=null,n.ontouchmove=null,c=c.filter(function(e){return e.targetElement!==n}),d&&0===c.length&&(document.removeEventListener("touchmove",v,u?{passive:!1}:void 0),d=!1)}else(c=c.filter(function(e){return e.targetElement!==n})).length||t()}}(n)}(n={exports:{}},n.exports),n.exports);(t=o)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")&&t.default;function r(e){for(var n=Array(e.length),t=0;t<e.length;++t)n[t]=e[t];return n}function l(e){return Array.isArray(e)?e:[e]}function i(e,n){var t=e.tabIndex-n.tabIndex,o=e.index-n.index;if(t){if(!e.tabIndex)return 1;if(!n.tabIndex)return-1}return t||o}function f(e,n,t){return r(e).map(function(e,n){return{node:e,index:n,tabIndex:t&&-1===e.tabIndex?(e.dataset||{}).focusGuard?0:-1:e.tabIndex}}).filter(function(e){return!n||0<=e.tabIndex}).sort(i)}function s(e,t){return e.reduce(function(e,n){return e.concat(r(n.querySelectorAll(t?F:L)),n.parentNode?r(n.parentNode.querySelectorAll(O.join(","))).filter(function(e){return e===n}):[])},[])}function u(e,n){var t=1<arguments.length&&void 0!==n?n:[];return t.push(e),e.parentNode&&u(e.parentNode,t),t}function m(e,n){for(var t=u(e),o=u(n),r=0;r<t.length;r+=1){var i=t[r];if(0<=o.indexOf(i))return i}return!1}function v(e){return r(e).filter(function(e){return function e(n){return!n||n===document||n.nodeType===Node.DOCUMENT_NODE||!function(e){return!(!e||!e.getPropertyValue)&&("none"===e.getPropertyValue("display")||"hidden"===e.getPropertyValue("visibility"))}(window.getComputedStyle(n,null))&&e(n.parentNode)}(e)}).filter(function(e){return function(e){return!(("INPUT"===e.tagName||"BUTTON"===e.tagName)&&("hidden"===e.type||e.disabled))}(e)})}function p(e,n){return f(v(s(e,n)),!0,n)}function g(e){return v(function(e){var n=e.querySelectorAll("[data-autofocus-inside]");return r(n).map(function(e){return s([e])}).reduce(function(e,n){return e.concat(n)},[])}(e))}function a(e){return"INPUT"===e.tagName&&"radio"===e.type}function y(e){return e[0]&&1<e.length&&a(e[0])&&e[0].name?function(n,e){return e.filter(a).filter(function(e){return e.name===n.name}).filter(function(e){return e.checked})[0]||n}(e[0],e):e[0]}function h(e){return l(e).filter(Boolean).reduce(function(e,n){var t=n.getAttribute(B);return e.push.apply(e,t?function e(t){for(var n=t.length,o=0;o<n;o+=1)for(var r=function(n){if(o!==n&&t[o].contains(t[n]))return{v:e(t.filter(function(e){return e!==t[n]}))}},i=0;i<n;i+=1){var u=r(i);if("object"===(void 0===u?"undefined":P(u)))return u.v}return t}(r(function e(n){return n.parentNode?e(n.parentNode):n}(n).querySelectorAll("["+B+'="'+t+'"]:not([data-focus-lock-disabled="disabled"])'))):[n]),e},[])}function b(e){return e.dataset&&e.dataset.focusGuard}function w(e){return!b(e)}function c(e,n){var t=document&&document.activeElement,o=h(e).filter(w),r=function(e,n,t){var o=l(e),r=l(n),i=o[0],u=null;return r.filter(Boolean).forEach(function(e){u=m(u||e,e)||u,t.filter(Boolean).forEach(function(e){var n=m(i,e);n&&(u=!u||n.contains(u)?n:m(n,u))})}),u}(t||e,e,o),i=p(o).filter(function(e){var n=e.node;return w(n)});if(i[0]||(i=function(e){return f(v(s(e)),!1)}(o).filter(function(e){var n=e.node;return w(n)}))[0]){var u=p([r]).map(function(e){return e.node}),a=function(e,n){var t=new Map;return n.forEach(function(e){return t.set(e.node,e)}),e.map(function(e){return t.get(e)}).filter(Boolean)}(u,i),c=a.map(function(e){return e.node}),d=function(e,n,t,o,r){var i=e.length,u=e[0],a=e[i-1];if(!(0<=e.indexOf(t))){var c=n.indexOf(t),d=n.indexOf(o||c),l=e.indexOf(o),f=c-d,s=n.indexOf(u),m=n.indexOf(a);return-1===c||-1===l?e.indexOf(r.length?y(r):y(e)):!f&&0<=l?l:c<=s&&b(t)&&1<Math.abs(f)?0:f&&1<Math.abs(f)?l:c<=s?i-1:m<c?0:f?1<Math.abs(f)?l:(i+l+f)%i:void 0}}(c,u,t,n,c.filter(function(n){return function(e){return!!e.autofocus||e.dataset&&!!e.dataset.autofocus||0<=n.indexOf(e)}}(function(e){return e.reduce(function(e,n){return e.concat(g(n))},[])}(o))));return void 0===d?d:a[d]}}function d(e){return e===document.activeElement}function E(e){var t=document&&document.activeElement;return!(!t||t.dataset&&t.dataset.focusGuard)&&h(e).reduce(function(e,n){return e||n.contains(t)||function(e){return!!function(e,n){return e.filter(function(e){return e===n})[0]}(r(e.querySelectorAll("iframe")),d)}(n)},!1)}function x(){return document&&document.activeElement===document.body||document&&r(document.querySelectorAll("[data-no-focus-lock]")).some(function(e){return e.contains(document.activeElement)})}function S(){var e=!1;if(M){var n=M;x()||(n&&!E(n)&&(e=function(e,n){var t=c(e,n);if(!D&&t){if(2<k)return console.error("FocusLock: focus-fighting detected. Only one focus management system could be active. See https://github.com/theKashey/focus-lock/#focus-fighting"),D=!0,void setTimeout(function(){D=!1},1);k++,function(e){e.focus(),e.contentWindow&&e.contentWindow.focus()}(t.node),k--}}(n,_)),_=document.activeElement)}return e}function N(e){return!!function(e){(M=e)&&S()}(function(e){return e.filter(function(e){return e}).slice(-1)[0]}(R))&&(e&&e.preventDefault(),!0)}var I=o.disableBodyScroll,T=o.enableBodyScroll,A=o.clearAllBodyScrollLocks,O=["button:enabled:not([readonly])","select:enabled:not([readonly])","textarea:enabled:not([readonly])","input:enabled:not([readonly])","a[href]","area[href]","iframe","object","embed","[tabindex]","[contenteditable]","[autofocus]"],B="data-focus-lock",L=O.join(","),F=L+", [data-focus-guard]",P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k=0,D=!1,M=0,_=null,R=[],C={on:function(e){0===R.length&&document.addEventListener("focusin",N),R.indexOf(e)<0&&(R.push(e),N())},off:function(n){R=R.filter(function(e){return e!==n}),N(),0===R.length&&document.removeEventListener("focusin",N)}},V="VERIFF_HANDSHAKE",j="VERIFF_RENDER",q="VERIFF_FINISHED",H="VERIFF_CANCELED",U="FINISHED",W="CANCELED",G="\n position: fixed !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n z-index: 9999999;\n display: block !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n background: rgba(0, 0, 0, 0.6);\n",K="\n position: absolute !important;\n top: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n left: 0 !important;\n width: 100vw;\n height: 100%;\n margin: 0 !important;\n padding: 0 !important;\n background: none;\n border: none\n",Y="veriffFrame";e.createVeriffFrame=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=e.url,t=e.onEvent,o=void 0===t?function(){}:t;if(!n)throw new Error("URL is not provided. Please provide a valid Veriff session url.");function r(){var e=document.getElementById(Y);e&&e.parentNode?(C.off(e),T(e),e.parentNode.parentNode.removeChild(e.parentNode)):A();window.removeEventListener("message",i)}function i(e){var n=document.getElementById(Y);e.data===V&&n.contentWindow.postMessage(j,"*"),e.data===H&&(r(),o(W)),e.data===q&&(r(),o(U))}return function(e){var n=document.createElement("iframe");n.src=e,n.allow="camera; microphone",n.id=Y,n.style.cssText=K;var t=document.createElement("div");t.style.cssText=G,t.appendChild(n),document.body.appendChild(t),C.on(n),I(n)}(n),window.addEventListener("message",i),{close:r}},Object.defineProperty(e,"__esModule",{value:!0})}); |
18740
184
66