local-id-scan-journey
Version:
A React component for GBG ID verification and document scanning with bundled SDK
3 lines • 35.2 kB
JavaScript
/*! For license information please see idscan-jcs-77455583.178cfd426c47545c4f6f.js.LICENSE.txt */
"use strict";(this.webpackChunkGBG_Idscan=this.webpackChunkGBG_Idscan||[]).push([[595],{1431:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JourneyManager=void 0;const i=n(5458),s=n(7993),a=n(2930),r=n(885),o=n(6297),h=n(577),d=n(7497),l=n(6178),u=n(5465),c=n(6202),E=n(1329),_=n(5005),p=n(6871),S=n(8142),m=n(7121);class f{constructor(){this._case=new i.CaseDictionaryService(l.dictionary),this._journeys=[],this.configure=e=>{this._config=e;const{auth:t,backendUrl:n,endpoints:i,mode:s,isVerboseLogEnabled:a,hideLogo:r}=this._config;return this._endpoints=i||u.constants.ENDPOINTS,this._authSettings=!0!==t?t:u.constants.AUTH_DEFAULTS,this._mode=s||m.Mode.WEB,this._isVerboseLoggingEnabled=a,h.default.configure(n+this._endpoints.socket).then((()=>this.assertBackendUrlExists(e))).then((()=>this))},this.initialize=({token:e})=>{performance.now();return a.default.configure({authSettings:this._authSettings,backendUrl:this._config.backendUrl,endpoints:this._endpoints,responseType:_.ResponseType.REFINED}).then((()=>a.default.initialize())).then((()=>{if(e)return this.assertAuthEnabled().then((()=>a.default.injectToken(e))).then((()=>this.setUserInfo()));performance.now();this._isVerboseLoggingEnabled})).then((()=>this))},this.caseDic=e=>this._case.convert(e,"beautify"),this.getVersion=()=>void 0!==this._version?Promise.resolve(this._version):a.default.get(this._endpoints.getVersion+"?channel="+this._mode,{},"version").then((({buildVersion:e,edition:t,CapturingMedia:n="FileUpload"})=>this._version={backend:e,backendEdition:t,capturingMedia:n,library:u.constants.VERSION})),this.injectToken=e=>this.assertAuthEnabled().then((()=>a.default.injectToken(e))),this.setUserInfo=()=>a.default.post(c.ENDPOINTS.postToken).then((e=>(E.STORAGE_KEYS.journeyId&&d.default.set(E.STORAGE_KEYS.journeyId,e.journeyId,24),E.STORAGE_KEYS.journeyDefinitionId&&d.default.set(E.STORAGE_KEYS.journeyDefinitionId,e.journeyDefinitionId,24),e))).catch((e=>{throw new s.ExceptionManager.AuthorizationException("error while getting userInfo")})),this.login=e=>(e.area=e.area?e.area:"scanning",this.assertUsernameExists(e).then((()=>this.assertPasswordExists(e))).then((()=>this.doLogin(e))).then((t=>{const n=o.ReductionService.reduce(t,{fullName:!1});return d.default.set(E.STORAGE_KEYS.userName,e.username,24),d.default.set(E.STORAGE_KEYS.userGroups,e.memberOf,24),d.default.set(E.STORAGE_KEYS.journeyId,e.journeyId,24),d.default.set(E.STORAGE_KEYS.journeyDefinitionId,e.journeyDefinitionId,24),{fullName:n.fullName,username:n["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"],role:n["http://schemas.microsoft.com/ws/2008/06/identity/claims/role"],token:n.access_token,memberOf:n.memberOf,journeyId:n.journeyId,journeyDefinitionId:n.journeyDefinitionId}}))),this.logout=()=>this.assertUserAuthenticated().then((()=>this.doLogout())),this.createJourney=(e,t=[])=>this.assertUserAuthenticated().then((()=>{performance.now();const n=new S.Journey(t,e);this._journeys.push(n);performance.now();return this._isVerboseLoggingEnabled,n})).then((e=>e.start())),this.toBase64=e=>r.ImageService.convert(e),this.getToken=()=>d.default.get(E.STORAGE_KEYS.defaultToken),this.getResults=e=>this.assertUserAuthenticated().then((()=>{performance.now();const t={journeyId:`${e}`};var n=a.default.get(`${this._endpoints.getJourney}`,{headers:t},"getJourney");performance.now();return this._isVerboseLoggingEnabled,n})).catch((e=>e.response&&401===e.response.status?s.ExceptionManager.process(new s.ExceptionManager.AuthorizationException(p.TranslationKey.EXCEPTION_AUTHORIZATION_ACCOUNT_NOT_AUTHORIZED,e.response)):s.ExceptionManager.process(new s.ExceptionManager.ServerException(p.TranslationKey.EXCEPTION,e.response)))),this.getJourneyDefinitions=()=>a.default.get(c.ENDPOINTS.journeyDefinitions+"?channelType="+this._mode).then((e=>Object.keys(e).map((t=>e[t])))),this.getCapturingMedia=e=>a.default.get(c.ENDPOINTS.getCapturingMedia+"?channelType="+this._mode+"&journeyDefinitionId="+e).then((e=>e)),this.doLogin=e=>a.default.post(this._endpoints.login,`userName=${encodeURIComponent(e.username)}&password=${encodeURIComponent(e.password)}&area=${encodeURIComponent(e.area)}&login-form-type=pwd&grant_type=password`,{headers:{"Content-Type":"application/x-www-form-urlencoded"}},"login").catch((e=>{if(void 0===e.response)throw s.ExceptionManager.process(new s.ExceptionManager.Exception(p.TranslationKey.EXCEPTION_SERVER_UNREACHABLE,e.response));const{response:{status:t}}=e||{response:{status:0}};switch(t){case 400:case 401:throw s.ExceptionManager.process(new s.ExceptionManager.AuthorizationException(p.TranslationKey.EXCEPTION_AUTHORIZATION_AUTH_DETAILS_INVALID,e.response));case 500:throw s.ExceptionManager.process(new s.ExceptionManager.ServerException(p.TranslationKey.EXCEPTION_SERVER,e.response));default:throw s.ExceptionManager.process(new s.ExceptionManager.Exception(p.TranslationKey.EXCEPTION,e.response))}})),this.doLogout=()=>a.default.post(this._endpoints.logout,void 0,void 0,"logout").catch((e=>{const{response:{status:t}}=e||{response:{status:0}};throw s.ExceptionManager.process(new s.ExceptionManager.Exception(p.TranslationKey.EXCEPTION,e.response))})),this.assertUserAuthenticated=()=>new Promise(((e,t)=>!0!==a.default.auth&&!1!==this._authSettings?t(s.ExceptionManager.process(new s.ExceptionManager.AuthorizationException(p.TranslationKey.EXCEPTION_AUTHORIZATION_PROCESS_NOT_AUTHORIZED))):e())),this.assertAuthEnabled=()=>new Promise(((e,t)=>!1===this._authSettings?t(s.ExceptionManager.process(new s.ExceptionManager.AuthorizationException(p.TranslationKey.EXCEPTION_AUTHORIZATION_AUTH_NOT_ENABLED))):e())),this.assertBackendUrlExists=({backendUrl:e})=>new Promise(((t,n)=>e?t():n(s.ExceptionManager.process(new s.ExceptionManager.MissingParameterException(p.TranslationKey.EXCEPTION_MISSING_PARAMETER_BACKEND_URL_MISSING))))),this.assertUsernameExists=e=>new Promise(((t,n)=>e.username?t():n(s.ExceptionManager.process(new s.ExceptionManager.MissingParameterException(p.TranslationKey.EXCEPTION_MISSING_PARAMETER_USERNAME_MISSING))))),this.assertPasswordExists=e=>new Promise(((t,n)=>e.password?t():n(s.ExceptionManager.process(new s.ExceptionManager.MissingParameterException(p.TranslationKey.EXCEPTION_MISSING_PARAMETER_PASSWORD_MISSING)))))}get journeys(){return this._journeys}get mode(){return this._mode}}t.JourneyManager=f,t.default=new f},2218:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JourneyFlow=void 0;const i=n(7993),s=n(7749),a=n(8273),r=n(6871);t.JourneyFlow=class{get state(){return this._state}get attempt(){return this._attempt}get history(){return this._history}constructor(e=s.FlowState.IDENTITY_FRONT,t=1){this._history=[],this.proceed=e=>{switch(e){case a.RequiredAction.FRONTSIDE_FIRST_SCAN:return this.setFlowVariables(s.FlowState.IDENTITY_FRONT,1);case a.RequiredAction.FRONTSIDE_SECOND_SCAN:return this.setFlowVariables(s.FlowState.IDENTITY_FRONT,2);case a.RequiredAction.FRONTSIDE_THIRD_SCAN:return this.setFlowVariables(s.FlowState.IDENTITY_FRONT,3);case a.RequiredAction.BACKSIDE_FIRST_SCAN:return this.setFlowVariables(s.FlowState.IDENTITY_BACK,1);case a.RequiredAction.BACKSIDE_SECOND_SCAN:return this.setFlowVariables(s.FlowState.IDENTITY_BACK,2);case a.RequiredAction.BACKSIDE_THIRD_SCAN:return this.setFlowVariables(s.FlowState.IDENTITY_BACK,3);case a.RequiredAction.ADDRESSDOCUMENT_FIRST_SCAN:return this.setFlowVariables(s.FlowState.ADDRESS,1);case a.RequiredAction.ADDRESSDOCUMENT_SECOND_SCAN:return this.setFlowVariables(s.FlowState.ADDRESS,2);case a.RequiredAction.ADDRESSDOCUMENT_THIRD_SCAN:return this.setFlowVariables(s.FlowState.ADDRESS,3);case a.RequiredAction.SELFIE_FIRST_SCAN:return this.setFlowVariables(s.FlowState.SELFIE,1);case a.RequiredAction.SELFIE_SECOND_SCAN:return this.setFlowVariables(s.FlowState.SELFIE,2);case a.RequiredAction.SELFIE_THIRD_SCAN:return this.setFlowVariables(s.FlowState.SELFIE,3);case a.RequiredAction.LIVENESS:return this.setFlowVariables(s.FlowState.LIVENESS,1);case a.RequiredAction.PASSIVE_LIVENESS:return this.setFlowVariables(s.FlowState.PASSIVE_LIVENESS,1);case a.RequiredAction.COVIDPASS_FIRST_SCAN:return this.setFlowVariables(s.FlowState.COVIDPASS,1);case a.RequiredAction.COVIDPASS_SECOND_SCAN:return this.setFlowVariables(s.FlowState.COVIDPASS,2);case a.RequiredAction.COVIDPASS_THIRD_SCAN:return this.setFlowVariables(s.FlowState.COVIDPASS,3);case a.RequiredAction.DATACHECKS:return this.setFlowVariables(s.FlowState.DATACHECKS,1);case a.RequiredAction.NONE:return this.setFlowVariables(s.FlowState.NONE,0);default:return Promise.reject(i.ExceptionManager.process(new i.ExceptionManager.FlowStateException(r.TranslationKey.EXCEPTION_FLOW_STATE_MISSING,e)))}},this.setFlowVariables=(e,t)=>(this._attempt=t,this._state=e,this.pushState()),this.pushState=()=>(this._history.push(this._state),Promise.resolve()),this._state=e,this._attempt=t,this.setFlowVariables(this._state,this._attempt)}}},4145:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DataService=t.DataStoreType=void 0;const i=n(4147),s=n(5880);var a;!function(e){e.ID_SCAN="ID_SCAN"}(a||(t.DataStoreType=a={}));class r{constructor(){this._dataStores={},this.getDataStore=e=>{if(this._dataStores[e]instanceof s.DataStore)return this._dataStores[e];if(e===a.ID_SCAN)return this._dataStores[e]=new s.DataStore(i.IdScanDataDefaults);throw new Error("Unsupported DataStore type")},this.deleteDataStore=e=>{this._dataStores[e]instanceof s.DataStore&&(this._dataStores[e].removeAllListeners(),delete this._dataStores[e])}}}t.DataService=r,t.default=new r},6339:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,s)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),n(8032),n(5455),n(6565),s(n(1216),t),s(n(8763),t),s(n(8515),t),s(n(7676),t),s(n(7461),t),s(n(8137),t),s(n(6680),t),s(n(8379),t),s(n(8856),t),s(n(5862),t),s(n(7749),t),s(n(1371),t),s(n(678),t),s(n(8829),t),s(n(8922),t),s(n(7621),t),s(n(642),t),s(n(7259),t),s(n(8273),t),s(n(4898),t),s(n(7918),t),s(n(4635),t),s(n(6871),t),s(n(7121),t),s(n(7289),t),s(n(7841),t),s(n(6227),t),s(n(1096),t),s(n(6287),t),s(n(6068),t),s(n(7645),t),s(n(4062),t),s(n(1644),t),s(n(5396),t),s(n(9342),t),s(n(2651),t),s(n(6920),t),s(n(357),t),s(n(2224),t),s(n(5363),t),s(n(6453),t),s(n(8538),t),s(n(3429),t),s(n(7480),t),s(n(6340),t),s(n(6370),t),s(n(4569),t),s(n(8304),t),s(n(936),t),s(n(135),t),s(n(2769),t),s(n(4378),t),s(n(487),t),s(n(1149),t),s(n(3169),t),s(n(6260),t),s(n(8321),t),s(n(8785),t),s(n(792),t),s(n(7303),t),s(n(1599),t),s(n(9386),t),s(n(8876),t),s(n(5141),t),s(n(4517),t),s(n(8163),t),s(n(2682),t)},8142:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Journey=void 0;const i=n(8414),s=n(2538),a=n(7993),r=n(5982),o=n(2930),h=n(7497),d=n(1329),l=n(6680),u=n(5862),c=n(7749),E=n(1371),_=n(642),p=n(7259),S=n(6871),m=n(2218),f=n(6489),I=n(114),g=n(1431),A=n(7121);class T{get endDate(){return this._endDate}get id(){return this._id}get glareCheck(){return this._glareCheck}get blurCheck(){return this._blurCheck}get lowResolutionCheck(){return this._lowResolutionCheck}get fullDocumentInViewCheck(){return this._fullDocumentInViewCheck}get information(){return this._information}get isCancelled(){return this._isCancelled}get isFinished(){return this._isFinished}get additionalData(){return this._additionalData}get startDate(){return this._startDate}get reference(){return this._reference}get result(){return this._result}get status(){return this._status}get totalRequests(){return this._totalRequests}get action(){return this._flow.state}get actionAttempt(){return this._flow.attempt}get tripleScanReason(){return this._tripleScanReason}get confidoInfo(){return this._confidoInfo}constructor(e,t=T.generateId()){this._inProgress=!1,this._isCancelled=!1,this._isFinished=!1,this._metaData=[],this._result=E.HighLevelResult.Undefined,this._totalRequests=0,this._flow=new m.JourneyFlow,this.headerToken=h.default.get(d.STORAGE_KEYS.journeyId),this.continue=(e,t)=>this.assertIsNotInProgress().then(this.assertUserAuthenticated).then(this.assertJourneyNotEnded).then((()=>e.imgId?this.assertImgIdExists(e.imgId).then((()=>this.assertCoordinatesExists(e.coordinates))).then((()=>this.sendWithCoordinates(e.imgId,e.coordinates,e.excludeOutputImages,e.journeyDefinitionId,t))):this.assertImgListExists(e.imgList).then((()=>this.send(e.imgList,e.coordinates,e.isDocumentExtracted,e.excludeOutputImages,e.journeyDefinitionId,t))))),this.continueCovid=(e,t)=>this.assertIsNotInProgress().then(this.assertUserAuthenticated).then(this.assertJourneyNotEnded).then((()=>this.sendCovid(e,t))),this.continueDataChecks=e=>this.assertIsNotInProgress().then(this.assertUserAuthenticated).then(this.assertJourneyNotEnded).then((()=>this.sendDataChecks(e))),this.cancel=(e=E.HighLevelResult.Aborted)=>this.assertUserAuthenticated().then((()=>{this._isCancelled=!0,this._status=p.JourneyState.ENDED,this._result=e,this._endDate=new Date})).then((()=>s.default.publish(_.JourneyEvent.JOURNEY_CANCEL,{id:this.id}))),this.crop=e=>o.default.post(o.default.endpoints.crop,e,void 0,"crop").catch((e=>{throw e.response&&401===e.response.status?a.ExceptionManager.process(new a.ExceptionManager.AuthorizationException(S.TranslationKey.EXCEPTION_AUTHORIZATION_ACCOUNT_NOT_AUTHORIZED,e.response)):e})),this.bindUpdate=e=>this.process(e),this.update=e=>this.process(e instanceof r.HttpResponse?e.data:e),this.getUsername=()=>h.default.get(d.STORAGE_KEYS.userName),this.getState=()=>({action:this.action,actionAttempt:this.actionAttempt}),this.start=()=>(this._startDate=new Date,this._status=p.JourneyState.STARTED,h.default.set(d.STORAGE_KEYS.journeyId,this.id,24),s.default.publish(_.JourneyEvent.JOURNEY_START,{id:this.id}).then((()=>this))),this.send=(e,t,n=void 0!==t,i=!0,a,r)=>(r=void 0===r?[]:r,this.setMetaData(r),s.default.publish(_.JourneyEvent.JOURNEY_PROGRESS,{id:this.id}).then((()=>{this._inProgress=!0})).then((()=>o.default.post(o.default.endpoints.upload,Object.assign(Object.assign({},this.id?{journeyId:this.id}:{}),{PersonEntryId:this.id,additionalData:[{name:"Platform",value:g.default.mode===A.Mode.WEB?"WJCS":A.Mode.CAPTURESTUDIO.toLowerCase()},{name:"UserName",value:this.getUsername()},...a?[{name:"JourneyDefinitionId",value:a}]:[],...this._additionalData],metadata:this.getMetaData(),coordinates:t,excludeOutputImagesFromResponse:void 0===i||i,inputImages:e,isDocumentExtracted:n,source:this.inferSource()}),{},"upload"))).then((e=>(this._inProgress=!1,this._metaData.splice(0,this._metaData.length),this.update(e)))).catch((e=>(this._inProgress=!1,Promise.reject(e))))),this.sendCovid=(e,t)=>s.default.publish(_.JourneyEvent.JOURNEY_PROGRESS,{id:this.id}).then((()=>{this._inProgress=!0})).then((()=>o.default.post(o.default.endpoints.covidpass,JSON.stringify({Base64Input:e,JourneyId:t}),void 0,"covid"))).then((e=>(this._inProgress=!1,this.update(e)))).catch((e=>(this._inProgress=!1,Promise.reject(e)))),this.sendDataChecks=e=>s.default.publish(_.JourneyEvent.JOURNEY_PROGRESS,{id:this.id}).then((()=>{this._inProgress=!0})).then((()=>o.default.post(o.default.endpoints.dataChecks,JSON.stringify({journeyId:e.journeyId,houseName:e.houseName,streetName:e.streetName,town:e.town,postCode:e.postCode}),void 0,"dataChecks"))).then((t=>(this._inProgress=!1,this._confidoInfo=e,this.update(t)))).catch((e=>(this._inProgress=!1,Promise.reject(e)))),this.sendWithCoordinates=(e,t,n,i,a)=>s.default.publish(_.JourneyEvent.JOURNEY_PROGRESS,{id:this.id}).then((()=>{this._inProgress=!0,a=void 0===a?[]:a,this.setMetaData(a)})).then((()=>o.default.post(o.default.endpoints.upload,Object.assign(Object.assign({},this.id?{journeyId:this.id}:{}),{additionalData:[{name:"Platform",value:g.default.mode===A.Mode.WEB?"WJCS":A.Mode.CAPTURESTUDIO.toLowerCase()},{name:"UserName",value:this.getUsername()},...i?[{name:"JourneyDefinitionId",value:i}]:[],...this._additionalData],metadata:this.getMetaData(),coordinates:t,excludeOutputImagesFromResponse:void 0===n||n,inputImageId:e,isDocumentExtracted:!0,source:this.inferSource()}),{},"send"))).then((e=>(this._inProgress=!1,this.update(e)))).catch((e=>{throw this._inProgress=!1,e})),this.checkInformation=e=>new Promise((t=>(this._information=this._information?this._information:{blurCheck:void 0,documents:[],glareCheck:void 0,holder:{address:{city:void 0,full:void 0,postCode:void 0},birthDate:void 0,birthPlace:void 0,firstName:void 0,fullName:void 0,gender:void 0,lastName:void 0,middleName:void 0},lowResolutionCheck:void 0,fullDocumentInViewCheck:void 0,scanReference:void 0,scannerIp:void 0,tripleScanReason:void 0},e.documents&&this._information.documents.push(...e.documents),e.holder&&(e.holder.address&&(this._information.holder.address.city=e.holder.address.city||this._information.holder.address.city,this._information.holder.address.full=e.holder.address.full||this._information.holder.address.full,this._information.holder.address.postCode=e.holder.address.postCode||this._information.holder.address.postCode),e.holder.birthDate&&(this._information.holder.birthDate=e.holder.birthDate||this._information.holder.birthDate),e.holder.birthPlace&&(this._information.holder.birthPlace=e.holder.birthPlace||this._information.holder.birthPlace),e.holder.firstName&&(this._information.holder.firstName=e.holder.firstName||this._information.holder.firstName),e.holder.fullName&&(this._information.holder.fullName=e.holder.fullName||this._information.holder.fullName),e.holder.gender&&(this._information.holder.gender=e.holder.gender||this._information.holder.gender),e.holder.lastName&&(this._information.holder.lastName=e.holder.lastName||this._information.holder.lastName),e.holder.middleName&&(this._information.holder.middleName=e.holder.middleName||this._information.holder.middleName)),e.scannerIp&&(this._information.scannerIp=e.scannerIp||this._information.scannerIp),e.glareCheck&&(this._information.glareCheck=e.glareCheck||this._information.glareCheck),e.blurCheck&&(this._information.blurCheck=e.blurCheck||this._information.blurCheck),e.lowResolutionCheck&&(this._information.lowResolutionCheck=e.lowResolutionCheck||this._information.lowResolutionCheck),e.fullDocumentInViewCheck&&(this._information.fullDocumentInViewCheck=e.fullDocumentInViewCheck||this._information.fullDocumentInViewCheck),e.scanReference&&(this._information.scanReference=e.scanReference||this._information.scanReference),e.tripleScanReason&&(this._information.tripleScanReason=e.tripleScanReason||this._information.tripleScanReason),t()))),this.process=e=>(this._totalRequests++,e?this.assertNoErrors(e.hasError).then((()=>this._flow.proceed(e.requiredAction))).then((()=>this.checkInformation(e.entryData))).then((()=>{const{entryData:{scanReference:t,glareCheck:n,blurCheck:i,lowResolutionCheck:a,fullDocumentInViewCheck:r,tripleScanReason:o}={}}=e;if(this._reference=t,this._glareCheck=n,this._blurCheck=i,this._lowResolutionCheck=a,this._fullDocumentInViewCheck=r,this._tripleScanReason=o,void 0===e.personEntryId||e.journeyId||(this._id=e.personEntryId),!0===e.isFinished)this._status=p.JourneyState.ENDED,this._isFinished=!0,this._endDate=new Date,this._result=this.parseResult(e),new Promise((()=>{setTimeout((()=>s.default.publish(_.JourneyEvent.JOURNEY_END,{id:this.id})),200)}));else if(this.totalRequests>0)return this._status=p.JourneyState.INPROGRESS,void s.default.publish(_.JourneyEvent.JOURNEY_PROGRESS,{id:this.id})})).then((()=>{void 0===e.personEntryId||e.journeyId||(this._id=e.personEntryId)})).then((()=>e)):Promise.resolve(e)),this.parseResult=({highLevelResult:e})=>{switch(e){case"Passed":return E.HighLevelResult.Passed;case"Refer":return E.HighLevelResult.Refer;case"Expired":return E.HighLevelResult.Expired;case"NotAccepted":return E.HighLevelResult.NotAccepted;case"Notsupported":return E.HighLevelResult.NotSupported;default:return E.HighLevelResult.Undefined}},this.inferSource=()=>this._flow.state===c.FlowState.ADDRESS?u.DocumentSource.ADDRESS:u.DocumentSource.IDENTITY,this.assertUserAuthenticated=()=>new Promise(((e,t)=>!0!==o.default.auth&&!1!==o.default.authSettings?t(a.ExceptionManager.process(new a.ExceptionManager.AuthorizationException(S.TranslationKey.EXCEPTION_AUTHORIZATION_PROCESS_NOT_AUTHORIZED))):e())),this.assertJourneyNotEnded=()=>new Promise(((e,t)=>this._status===p.JourneyState.ENDED?t(a.ExceptionManager.process(new a.ExceptionManager.FlowStateException(S.TranslationKey.EXCEPTION_FLOW_STATE_JOURNEY_ENDED))):e())),this.assertCoordinatesExists=e=>new Promise(((t,n)=>void 0===e?n(a.ExceptionManager.process(new a.ExceptionManager.MissingParameterException(S.TranslationKey.EXCEPTION_MISSING_PARAMETER_COORDINATES_MISSING))):t())),this.assertImgIdExists=e=>new Promise(((t,n)=>void 0===e||""===e?n(a.ExceptionManager.process(new a.ExceptionManager.MissingParameterException(S.TranslationKey.EXCEPTION_MISSING_PARAMETER_IMAGES_MISSING))):t())),this.assertImgListExists=(e=[])=>new Promise(((t,n)=>e.length?t():n(a.ExceptionManager.process(new a.ExceptionManager.MissingParameterException(S.TranslationKey.EXCEPTION_MISSING_PARAMETER_IMAGES_MISSING))))),this.assertNoErrors=e=>new Promise(((t,n)=>!0===e?n(a.ExceptionManager.process(new a.ExceptionManager.ServerException(S.TranslationKey.EXCEPTION_SERVER_DATA_NOT_PERSISTED))):t())),this.assertCurrentResult=(e=l.CurrentResult.Pass)=>new Promise(((t,n)=>e!==l.CurrentResult.Pass?n(a.ExceptionManager.process(new a.ExceptionManager.ServerException(S.TranslationKey.EXCEPTION_SERVER_RESULT_NOT_PASSING))):t())),this.assertIsNotInProgress=()=>new Promise(((e,t)=>this._inProgress?t(a.ExceptionManager.process(new a.ExceptionManager.BadRequestException(S.TranslationKey.EXCEPTION_BAD_REQUEST_WAITING_FOR_RESPONSE))):e())),this.headerToken?this._id=h.default.get(d.STORAGE_KEYS.journeyId):this._id=t,this._additionalData=e||[]}setMetaData(e){let t=this._flow.state;switch(t){case c.FlowState.IDENTITY_FRONT:t=I.JourneyStep.FRONTSIDE;break;case c.FlowState.IDENTITY_BACK:t=I.JourneyStep.BACKSIDE;break;case c.FlowState.ADDRESS:t=I.JourneyStep.ADDRESSDOCUMENT;break;case c.FlowState.COVIDPASS:t=I.JourneyStep.COVIDPASS;break;case c.FlowState.DATACHECKS:t=I.JourneyStep.DATACHECKS}e.forEach((e=>{""===e.step&&(e.step=t)})),this._metaData.push(...e)}getMetaData(){if(this._flow.state===c.FlowState.IDENTITY_FRONT){const e=[{name:"Channel",value:"Web",step:"GENERAL",type:"Simple"},{name:"Web Sdk Version",value:"21.0.0",step:"GENERAL",type:"Simple"},{name:"Platform",value:f.osName,step:"GENERAL",type:"Simple"},{name:"Platform Version",value:f.osVersion,step:"GENERAL",type:"Simple"},{name:"Browser",value:f.browserName,step:"GENERAL",type:"Simple"},{name:"Browser Version",value:f.fullBrowserVersion,step:"GENERAL",type:"Simple"}];this._metaData.push(...e)}if(g.default.mode===A.Mode.CAPTURESTUDIO){const e=this._metaData.filter((e=>"Capture Type"===e.name));this._metaData.splice(0,this._metaData.length),this._metaData.push(...e);const t=[{name:"Platform",value:f.osName,step:"GENERAL",type:"Simple"},{name:"Platform Version",value:f.osVersion,step:"GENERAL",type:"Simple"},{name:"Browser",value:f.browserName,step:"GENERAL",type:"Simple"},{name:"Browser Version",value:f.fullBrowserVersion,step:"GENERAL",type:"Simple"}];this._metaData.push(...t)}return this._metaData}}t.Journey=T,T.generateId=()=>i.v4()},8763:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JourneyContainer=void 0;const i=n(3123),s=n(2538),a=n(7993),r=n(2930),o=n(1216),h=n(7338),d=n(577),l=n(192),u=n(3272),c=n(2072),E=n(5828),_=n(6906),p=n(8137),S=n(7749),m=n(8829),f=n(7621),I=n(642),g=n(7259),A=n(4635),T=n(6871),N=n(7016),C=n(9609),R=n(5620),y=n(1192),w=n(2571),D=n(4145),v=n(1431),P=n(3181),O=n(7884),M=n(3012),b=n(2676),F=n(5827),x=n(7497),L=n(1329);t.JourneyContainer=class{constructor(e){this._container=document.createElement("div"),this._providers=[],this._ready=!1,this._dataStore=D.default.getDataStore(D.DataStoreType.ID_SCAN),this._isPredefinedJourney=!1,this._isTCCAccepted=!1,this._retry=!1,this.initialize=()=>{const{backendUrl:e,endpoints:t,container:n,token:i,mode:a,isVerboseLogEnabled:r,hideLogo:o}=this._config;return this.setContainer(n).then((e=>l.default.renderToContainer(e,A.Templates.Initializing))).then((()=>v.default.configure({auth:!0,backendUrl:e,endpoints:t,mode:a,isVerboseLogEnabled:r,hideLogo:o}))).then((()=>v.default.initialize({token:i}))).then((()=>Promise.all([s.default.subscribe(I.JourneyEvent.AUTH_CHANGE,this.onAuthStateChanged),...Object.keys(I.JourneyEvent).map((e=>s.default.subscribe(I.JourneyEvent[e],this.onJourneyEvent(e))))]))).then((()=>this._ready=!0)).then((()=>this.evaluate())).then((()=>this))},this.getJourneyDefinitions=()=>{const{backendUrl:e,endpoints:t,token:n,mode:i,isVerboseLogEnabled:s,hideLogo:a}=this._config;return v.default.configure({auth:!0,backendUrl:e,endpoints:t,mode:i,isVerboseLogEnabled:s,hideLogo:a}).then((()=>v.default.initialize({token:n}))).then((()=>v.default.getJourneyDefinitions()))},this.setJourneyDefinitonId=e=>new Promise((t=>{this._config.journeyDefinitionId=e,t()})),this.changeInputProvider=(e=m.InputProvider.NONE,t=m.ChangeMode.DEFAULT)=>new Promise(((n,i)=>{switch(t){case m.ChangeMode.DEFAULT:return this._providers.indexOf(e)>=0?n(this._inputProvider=e):i(a.ExceptionManager.process(new a.ExceptionManager.UnavailableInputProviderException(T.TranslationKey.EXCEPTION_UNAVAILABLE_INPUT_PROVIDER_NOT_AVAILABLE)));case m.ChangeMode.FALLBACK:return n(this._inputProvider=this._providers.indexOf(e)>=0?e:this._providers[0]);case m.ChangeMode.FORCE:return n(this._inputProvider=e);default:return i(a.ExceptionManager.process(new a.ExceptionManager.UnavailableInputProviderException(T.TranslationKey.EXCEPTION_UNAVAILABLE_INPUT_PROVIDER_NOT_AVAILABLE)))}})),this.terminate=()=>{s.default.terminate().then((()=>c.default.destroyWorker())).then((()=>this.terminateJourney()))},this.terminateJourney=()=>d.default.resetTerminal().catch((()=>{})).then((()=>i.default.stopStreaming())).catch((()=>{})).then((()=>this._journey&&this._journey.cancel())).then((()=>this.clearJourney())).then((()=>E.default.terminateService())),this.getJourneyState=()=>Object.assign({journey:this._dataStore.getState(),inputProvider:this._inputProvider?this._inputProvider:m.InputProvider.NONE,page:A.Templates.None},this._journey?this._journey.getState():{action:S.FlowState.NONE,actionAttempt:0}),this.requiresCamera=()=>[m.InputProvider.CAMERA,m.InputProvider.SMART_CAPTURE,m.InputProvider.LIVENESS].indexOf(this._inputProvider)>=0,this.getAvailableProviders=()=>[...this._providers],this.evaluate=(e=!1,t=!1,n=m.InputProvider.NONE)=>this.getJourney().then((e=>(this._isPredefinedJourney=t,e.status===g.JourneyState.ENDED||e.action===S.FlowState.LIVENESS||e.action===S.FlowState.PASSIVE_LIVENESS||e.action===S.FlowState.SELFIE||e.action===S.FlowState.ADDRESS||e.action===S.FlowState.COVIDPASS||e.action===S.FlowState.DATACHECKS?d.default.resetTerminal().catch((()=>{})).then((()=>e)):e))).then((i=>!0===this._ready?!1===r.default.auth?y.LoginStep.render.call(this):this._journeyDefinitionId&&(this._journeyDefinitionId||this._journeyDefinitionId)?this._isTCCAccepted||i.isCancelled?i.status===g.JourneyState.ENDED?w.ResultsStep.render.call(this):i.action===S.FlowState.LIVENESS?R.LivenessStep.render.call(this).then((()=>this.updateJourneyFields())).then((()=>this.hookGlobalButtons())):i.action===S.FlowState.PASSIVE_LIVENESS?P.PassiveLivenessStep.render.call(this).then((()=>this.updateJourneyFields())).then((()=>this.hookGlobalButtons())):i.action===S.FlowState.DATACHECKS?b.DataChecksStep.render.call(this).then((()=>this.updateJourneyFields())).then((()=>this.hookGlobalButtons())):N.GatewayStep.render.call(this,e,t,n).then((()=>this.updateJourneyFields())).then((()=>this.hookGlobalButtons())):F.TermsAndConditionsStep.render.call(this):C.JourneySelectStep.render.call(this):Promise.resolve())).catch((e=>{if(!1===r.default.auth)return y.LoginStep.render.call(this);throw e})),this.clearJourney=()=>(this._journey=void 0,this._cropResponse=void 0,x.default.remove(L.STORAGE_KEYS.journeyId),this._dataStore.reset(),s.default.publish(I.JourneyEvent.JOURNEY_CLEAR,{step:A.Templates.Result})),this.getJourney=()=>{if(this._journey)return Promise.resolve(this._journey);{const e=window&&window.jcs__id__box?window.jcs__id__box:void 0;return v.default.createJourney(e,this._config.additionalData).then((e=>this._journey=e))}},this.hookGlobalButtons=(e=!0)=>l.default.getElements(this._container,{cancel:'[data-jcs-element="cancel__journey"]'}).then((({cancel:t})=>{if(t instanceof HTMLElement&&(e||h.default.hideObject(t),t.addEventListener("click",(()=>d.default.resetTerminal().catch((()=>{})).then((()=>d.default.release())).then((()=>i.default.stopStreaming())).catch((()=>{})).then((()=>this._journey&&this._journey.cancel())).then((()=>E.default.terminateService())).then((()=>this.evaluate())))),d.default&&1===d.default.state))return O.ScannerProvider.startSocket.call(this)})),this.updateJourneyFields=()=>l.default.getElements(this._container,{action:'[data-jcs-element="info__journey__action"]',actionContainer:'[data-jcs-element="info__journey__action__container"]',attempt:'[data-jcs-element="info__journey__action__attempt"]',id:'[data-jcs-element="info__journey__id"]'}).then((({id:e,action:t,actionContainer:n,attempt:i})=>{this._journey&&(h.default.setText(e,this._journey.id.substr(0,8)),h.default.setText(i,String(this._journey.actionAttempt)),h.default.setText(t,o.default.getTranslation(`FLOW_STATE_${this._journey.action}`)))})),this.changeCameraStream=(e,t=p.ReticleType.NONE,n=!1,a=p.HintType.NONE,r=void 0,d)=>l.default.getElements(this._container,{cameraViewfinder:'[data-jcs-element="camera__viewfinder"]',status:'[data-jcs-element="view__status"]',statusMessage:'[data-jcs-element="view__status__message"]'}).then((({cameraViewfinder:l,status:u,statusMessage:c})=>(h.default.hideObject(u),l instanceof HTMLCanvasElement?i.default.stopStreaming().then((()=>i.default.clearCanvas(l))).then((()=>s.default.publish(I.JourneyEvent.CAMERA_CHANGE,{camera:e}))).then((()=>i.default.getStream(e,d))).then((e=>i.default.renderStreamToElement(e,l,{reticleType:t,hintType:a,watermark:n,mirror:r}))).catch((e=>{"EXCEPTION_PLATFORM_CAMERA_NOT_READABLE"==e.message&&(h.default.showObject(u),h.default.setText(c,o.default.getTranslation(T.TranslationKey.EXCEPTION_PLATFORM_CAMERA_NOT_READABLE)))})):Promise.resolve()))).then((()=>i.default.currentDeviceId)),this.freezeCameraStream=()=>l.default.getElements(this._container,{cameraViewfinder:'[data-jcs-element="camera__viewfinder"]'}).then((({cameraViewfinder:e})=>{if(e instanceof HTMLCanvasElement){const t=e.getContext("2d");return t&&i.default.getImageFromCurrentStream().then((e=>{const n=new Image;n.src=e,t.drawImage(n,0,0)})),i.default.stopStreaming()}return Promise.resolve()})),this.assertImageExists=e=>new Promise(((t,n)=>null==e||"string"!=typeof e?n(a.ExceptionManager.process(new a.ExceptionManager.BadRequestException(T.TranslationKey.EXCEPTION_BAD_REQUEST_INVALID_IMAGE))):t())),this.renderAvailableCameras=e=>i.default.getVideoCameras().then((e=>e.map((e=>({name:e.label,value:e.deviceId,selected:i.default.currentDeviceId===e.deviceId}))))).then((t=>{h.default.updateSelect(e,t),t&&t.length>1?h.default.showObject(e):h.default.hideObject(e)})),this.setProviders=(e,t=!1)=>new Promise(((n,s)=>{const r=this.parseProvidersFromCapturingMedia(e,t);return Promise.resolve().then((()=>{const{allowedInputProviders:e=Object.keys(m.InputProvider)}=this._config;return(0,u.allowItems)(r,e)})).then((()=>window.Worker?r:(0,u.removeItems)(r,[m.InputProvider.SMART_CAPTURE]))).then((()=>window.WebAssembly?r:(0,u.removeItems)(r,[m.InputProvider.SMART_CAPTURE]))).then((()=>(0,u.containsItems)(r,[m.InputProvider.CAMERA,m.InputProvider.SMART_CAPTURE,m.InputProvider.LIVENESS])?i.default.doDeviceProbe().then((()=>i.default.hasDeviceCapableOfResolution()?r:(0,u.removeItems)(r,[m.InputProvider.CAMERA,m.InputProvider.SMART_CAPTURE]))):Promise.resolve(r))).then((()=>r.length?n(this._providers=r):s(a.ExceptionManager.process(new a.ExceptionManager.UnavailableInputProviderException(T.TranslationKey.EXCEPTION_UNAVAILABLE_INPUT_PROVIDER_NONE_SPECIFIED))))).catch((()=>s(a.ExceptionManager.process(new a.ExceptionManager.UnavailableInputProviderException(T.TranslationKey.EXCEPTION_UNAVAILABLE_INPUT_PROVIDER_CANNOT_RETRIEVE)))))})),this.onJourneyEvent=e=>t=>{const{onJourneyEvent:n=()=>{}}=this._config;n(I.JourneyEvent[e],t,this.getJourneyState())},this.setContainer=e=>new Promise(((t,n)=>{if("string"==typeof e){const i=h.default.getElementBySelector(e);return i instanceof HTMLElement?(i.setAttribute("wsdk-container",""),t(this._container=i)):n(a.ExceptionManager.process(new a.ExceptionManager.TemplateException(T.TranslationKey.EXCEPTION_TEMPLATE_CONTAINER_MISSING)))}return e instanceof HTMLElement?(e.setAttribute("wsdk-container",""),t(this._container=e)):n(a.ExceptionManager.process(new a.ExceptionManager.InvalidParameterException(T.TranslationKey.EXCEPTION_INVALID_PARAMETER_SHOULD_BE_ELEMENT_OR_SELECTOR)))})),this.onAuthStateChanged=({authorized:e})=>this.evaluate().catch((()=>{})),this.parseProvidersFromCapturingMedia=(e,t=!1)=>{switch(e){case f.CapturingMedia.FileUpload:return[m.InputProvider.FILESYSTEM];case f.CapturingMedia.Camera:return[m.InputProvider.CAMERA,m.InputProvider.FILESYSTEM];case f.CapturingMedia.WebCamera:return t?[m.InputProvider.SMART_CAPTURE,m.InputProvider.CAMERA]:[m.InputProvider.SMART_CAPTURE,m.InputProvider.CAMERA,m.InputProvider.FILESYSTEM];case f.CapturingMedia.Scanner:return[m.InputProvider.SCANNER,m.InputProvider.FILESYSTEM,m.InputProvider.CAMERA];default:return[]}},this._config=e,this.assetsFolder=void 0===this._config.assetsDirectory?"assets":this._config.assetsDirectory,this._previewPages=M({documentStep:{smartCapture:!1,manualCapture:!1,fileUpload:!0},facematchStep:{manualCapture:!1,fileUpload:!0},poaStep:{manualCapture:!1,fileUpload:!0},passiveLivenessStep:{manualCapture:!1},covidStep:{manualCapture:!1,fileUpload:!0},dataChecksStep:{smartCapture:!1,manualCapture:!1,fileUpload:!1}},void 0!==this._config.previewPages?this._config.previewPages:{}),this._manualCapture=M({enabled:!1,timeout:15},void 0!==this._config.manualCapture?this._config.manualCapture:{});const{templates:t={},translator:n,dictionary:U,overlay:j,cameraOptions:V}=e;l.default.updateTemplates(Object.assign(Object.assign({},_.DefaultTemplates),t)),o.default.setTranslator(n),o.default.setDictionary(U),i.default.setConfiguration({overlay:j,cameraOptions:V})}getAllowedFileFormats(){var e=["image/bmp","image/jpg","image/jpeg","image/png","application/pdf"];this._journey.action==S.FlowState.SELFIE&&(e=["image/bmp","image/jpg","image/jpeg","image/png"]);const{allowedFileFormats:t=e}=this._config;return t}}}}]);
//# sourceMappingURL=idscan-jcs-77455583.178cfd426c47545c4f6f.js.map