1"use strict";(self.webpackChunkhost=self.webpackChunkhost||[]).push([[77,2322,7285,5393,8865,1451,8990],{58990:(e,t,n)=>{n.r(t),n.d(t,{MultiFactorAuthenticationProvider:()=>_,useMultiFactorAuthentication:()=>T});var o=n(77285);const i={multiFactorAuthenticationAuthStatus:null,setMultiFactorAuthenticationAuthStatus:void 0,isCancelled:!1,setIsCancelled:void 0,authenticationExpiresAt:null,setAuthenicationExpiresAt:void 0},r=(0,o.createContext)(i);var s=n(11871),l=n(73659),a=n(52322);const u=e=>(0,a.jsx)(l.Text,Object.assign({textStyle:"body-02-regular",color:"$text01"},e)),c=({isOpen:e,onClose:t,headingText:n,IconComponent:o,iconColor:i,mainContent:r,primaryButtonText:u,onPrimaryButtonClick:c})=>(0,a.jsxs)(l.Modal,{isOpen:e,onClose:t,size:"5xl",isCentered:!0,children:[(0,a.jsx)(s.ModalOverlay,{}),(0,a.jsxs)(l.ModalContent,{children:[(0,a.jsx)(l.ModalHeader,{children:(0,a.jsx)(l.ModalCloseButton,{})}),(0,a.jsxs)(l.ModalBody,{children:[(0,a.jsx)(o,{color:i,w:"48px",h:"48px",mb:"16px"}),(0,a.jsx)(l.Heading,{size:"h1",as:"h2",color:"$fg.primary",mb:"24px",children:n}),r]}),(0,a.jsx)(l.ModalFooter,{children:(0,a.jsx)(s.Flex,{flexDir:"row",children:(0,a.jsx)(l.Button,{onClick:c,ml:"auto",children:u})})})]})]}),d=e=>(0,a.jsx)(l.Text,Object.assign({color:"$bg.button.primary.base",textStyle:"body-02-regular"},e)),p=({isOpen:e,onClose:t,onPrimaryButtonClick:n,duration:o})=>(0,a.jsx)(c,{isOpen:e,onClose:t,IconComponent:l.SecurityIcon,iconColor:"denim.500",headingText:"Two-factor authentication",primaryButtonText:"Cancel",onPrimaryButtonClick:n,mainContent:(0,a.jsxs)(s.Box,{children:[(0,a.jsx)(u,{mb:"16px",children:"Use the Allica mobile app to approve your request."}),(0,a.jsx)(u,{mb:"16px",children:"If you're using a new device, you'll need to install and register the Allica app to continue."}),o.length>0&&(0,a.jsxs)(d,{mb:"16px",children:[(0,a.jsx)(l.StopClockIcon,{"data-testid":"stop-clock-icon",color:"$bg.button.primary.base",w:"24px",h:"24px",mb:"3px",mr:"8px"}),o]})]})});let h=function(e){return e.AUTH_REQUESTED="AUTH_REQUESTED",e.NO_DEVICES_REGISTERED="NO_DEVICES_REGISTERED",e.AUTH_DENIED="AUTH_DENIED",e.AUTH_EXPIRED="AUTH_EXPIRED",e.USER_ID_UNKNOWN_TO_SCA_SERVER="USER_ID_UNKNOWN_TO_SCA_SERVER",e}({});const E=({isOpen:e,onClose:t,onPrimaryButtonClick:n})=>(0,a.jsx)(c,{isOpen:e,onClose:t,IconComponent:l.NoDeviceIcon,iconColor:"$fg.system.error_default",headingText:"No registered device found",primaryButtonText:"Ok",onPrimaryButtonClick:n,mainContent:(0,a.jsxs)(s.Box,{children:[(0,a.jsx)(u,{mb:"16px",children:"Before proceeding with this operation, you must download the Allica App and activate your account on your mobile device."}),(0,a.jsx)(u,{mb:"16px",children:"Find the app by searching for 'Allica Bank' on your device's App Store."})]})}),x=({isOpen:e,onClose:t,onPrimaryButtonClick:n})=>(0,a.jsx)(c,{isOpen:e,onClose:t,IconComponent:l.SecurityErrorIcon,iconColor:"$fg.system.error_default",headingText:"Authorisation declined",primaryButtonText:"Ok",onPrimaryButtonClick:n,mainContent:(0,a.jsxs)(s.Box,{children:[(0,a.jsx)(u,{mb:"16px",children:"Your request for authorisation has been declined."}),(0,a.jsx)(u,{mb:"16px",children:"If you wish to proceed, please start the authorisation process again. If this is an error try again or contact our support team for assistance."})]})}),m=({isOpen:e,onClose:t,onPrimaryButtonClick:n})=>(0,a.jsx)(c,{isOpen:e,onClose:t,IconComponent:l.TimeoutIcon,iconColor:"$fg.system.error_default",headingText:"Authorisation timeout",primaryButtonText:"Ok",onPrimaryButtonClick:n,mainContent:(0,a.jsxs)(s.Box,{children:[(0,a.jsx)(u,{mb:"16px",children:"Your Two-Factor Authentication session has timed out. For your security, authentication actions are time restricted."}),(0,a.jsx)(u,{mb:"16px",children:"Please try again. If you continue to experience issues, check your network connection or contact our support team."})]})});var C=n(65774);const _=({children:e})=>{const[t,n]=(0,o.useState)(null),[i,s]=(0,o.useState)(!1),[l,u]=(0,o.useState)(null),c=(0,o.useRef)(null),[d,_]=(0,o.useState)(null),A=(0,o.useRef)(null),y=()=>{c.current&&clearTimeout(c.current),A.current&&clearTimeout(A.current)};(0,o.useEffect)((()=>{t!==h.AUTH_REQUESTED&&(y(),u(null),_(null))}),[t,c.current,A.current]);const f=()=>{s(!0),_(null),y()},T=()=>{n(null),u(null),_(null),y()};(0,o.useEffect)((()=>
1{if(l&&!i){new Date(l)<new Date?(n(h.AUTH_EXPIRED),y()):(A.current=setTimeout((()=>{const e=(0,C.intervalToDuration)({start:new Date,end:l});0===e.minutes&&0===e.seconds&&n(h.AUTH_EXPIRED),_(e)}),1e3),0===(null==d?void 0:d.minutes)&&0===(null==d?void 0:d.seconds)&&clearTimeout(A.current))}}),[l,d,i]);return(0,a.jsxs)(r.Provider,{value:{multiFactorAuthenticationAuthStatus:t,setMultiFactorAuthenticationAuthStatus:n,handleMultiFactorAuthenticatedMutation:(e,t)=>{c.current=setTimeout((async()=>{e(t,{onSuccess:()=>{n(null)},onError:e=>{var t;401!==(null==e||null==(t=e.response)?void 0:t.status)&&n(null)}})}),1e3)},isCancelled:i,setIsCancelled:s,authenticationExpiresAt:l,setAuthenicationExpiresAt:u},children:[(0,a.jsx)(p,{isOpen:t===h.AUTH_REQUESTED&&!i,onClose:f,onPrimaryButtonClick:f,duration:(()=>{if(0===(null==d?void 0:d.minutes))return`${null==d?void 0:d.seconds} seconds left`;if(void 0!==(null==d?void 0:d.minutes)&&void 0!==(null==d?void 0:d.seconds)&&(null==d?void 0:d.minutes)>0){const e=(null==d?void 0:d.seconds)<10?`0${null==d?void 0:d.seconds}`:null==d?void 0:d.seconds;return`${d.minutes}:${e} mins left`}return""})()}),(0,a.jsx)(E,{isOpen:(t===h.NO_DEVICES_REGISTERED||t===h.USER_ID_UNKNOWN_TO_SCA_SERVER)&&!i,onClose:T,onPrimaryButtonClick:T}),(0,a.jsx)(x,{isOpen:t===h.AUTH_DENIED&&!i,onClose:T,onPrimaryButtonClick:T}),(0,a.jsx)(m,{isOpen:t===h.AUTH_EXPIRED&&!i,onClose:T,onPrimaryButtonClick:T}),e]})},A=(e,t)=>{if(e&&t){const n=Object.keys(e).find((e=>e.toLowerCase()===t.toLowerCase()));return n?e[n]:void 0}};var y=n(13849),f=n(76543);const T=e=>{const{error:t,mutate:n,variables:i,reset:s}=e,{isFeatureOn:l}=(0,y.useFeatureFlags)(),a=l(f.FeaturedFlags.olbv2_2FA_countdown),{multiFactorAuthenticationAuthStatus:u,setMultiFactorAuthenticationAuthStatus:c,handleMultiFactorAuthenticatedMutation:d,isCancelled:p,setIsCancelled:E,setAuthenicationExpiresAt:x,authenticationExpiresAt:m}=(()=>{const e=(0,o.useContext)(r);if(void 0===e)throw new Error("useMultiFactorAuthentication must be within MultiFactorAuthenticationContext Provider");return e})();(0,o.useEffect)((()=>{var e,o;if(t)if(p)s(),null==c||c(null),null==E||E(!1),null==x||x(null);else if(401===(null==(e=t.response)?void 0:e.status)&&null!=(o=t.response)&&o.data.code){const e=A(t.response.headers,"Authorization-Expires-At");var r,l;if(e&&!m&&a&&(null==x||x(new Date(e))),u!==h.AUTH_EXPIRED)if(null==c||c(t.response.data.code),(null==(r=t.response)?void 0:r.data.code)===h.AUTH_REQUESTED)null==d||d(n,{data:i.data,headers:{"Authorization-Id":A(null==(l=t.response)?void 0:l.headers,"Authorization-Id"),"Idempotency-Id":A(i.headers,"Idempotency-Id")}})}else null==c||c(null)}),[t,p]);const C=[h.AUTH_REQUESTED,h.AUTH_DENIED,h.NO_DEVICES_REGISTERED,h.AUTH_EXPIRED,h.USER_ID_UNKNOWN_TO_SCA_SERVER].includes(u);return Object.assign({},e,{isHandlingMultiFactorAuthentication:C})}},11837:(e,t,n)=>{var o=n(77285),i=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,n){var o,r={},u=null,c=null;for(o in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)s.call(t,o)&&!a.hasOwnProperty(o)&&(r[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===r[o]&&(r[o]=t[o]);return{$$typeof:i,type:e,key:u,ref:c,props:r,_owner:l.current}}t.Fragment=r,t.jsx=u,t.jsxs=u},52322:(e,t,n)=>{e.exports=n(11837)}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.