From 84726c33dd6dd0e6336ade6cba5d7b201dd6d0a0 Mon Sep 17 00:00:00 2001 From: KONIJETI YASWANTHA NAGARJUNA <50859121+YaswanthNagarjuna@users.noreply.github.com> Date: Mon, 7 Aug 2023 16:04:18 +0530 Subject: [PATCH] Added configuration for the number of qrCode auto refresh before showing retry option --- .../resources/application-local.properties | 2 +- oidc-ui/.env | 2 +- oidc-ui/src/common/ErrorIndicator.js | 6 +++--- oidc-ui/src/components/LoginQRCode.js | 18 +++--------------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/esignet-service/src/main/resources/application-local.properties b/esignet-service/src/main/resources/application-local.properties index 515e88db5..7fa06c381 100644 --- a/esignet-service/src/main/resources/application-local.properties +++ b/esignet-service/src/main/resources/application-local.properties @@ -237,4 +237,4 @@ mosip.esignet.ui.config.key-values={'sbi.env': 'Developer', 'sbi.timeout.DISC': 'linked-transaction-expire-in-secs': 120, 'wallet.qr-code-buffer-in-secs': 10, \ 'mosip.esignet.qr-code.deep-link-uri': 'inji://landing-page-name?linkCode=LINK_CODE&linkExpireDateTime=LINK_EXPIRE_DT', \ 'mosip.esignet.qr-code.download-uri': '#', 'mosip.esignet.qr-code.enable': 'true', 'auth.txnid.length': 10, \ - 'otp.length': 6, 'password.regex': ''} \ No newline at end of file + 'otp.length': 6, 'password.regex': '', 'wallet.qr-code.auto-refresh-limit': 3} \ No newline at end of file diff --git a/oidc-ui/.env b/oidc-ui/.env index 6298dd1bb..f15f00f71 100644 --- a/oidc-ui/.env +++ b/oidc-ui/.env @@ -45,4 +45,4 @@ REACT_APP_WALLET_LOGO_URL="" REACT_APP_CONSENT_SCREEN_TIME_OUT_BUFFER_IN_SEC=5 -REACT_WALLET_QR_CODE_AUTO_REFRESH_LIMIT=10 \ No newline at end of file +REACT_WALLET_QR_CODE_AUTO_REFRESH_LIMIT=3 \ No newline at end of file diff --git a/oidc-ui/src/common/ErrorIndicator.js b/oidc-ui/src/common/ErrorIndicator.js index 57fe8481e..bff1140f9 100644 --- a/oidc-ui/src/common/ErrorIndicator.js +++ b/oidc-ui/src/common/ErrorIndicator.js @@ -24,7 +24,7 @@ const ErrorIndicator = ({ const { t } = useTranslation("translation", { keyPrefix: i18nKeyPrefix }); //Redirecting if transaction invalid - if (errorCode === "invalid_transaction") { + if (errorCode === "invalid_transaction" || errorCode === "link_code_limit_reached") { let response = location.hash; if (!response) { @@ -48,12 +48,12 @@ const ErrorIndicator = ({ if (nonce) { params = params + "nonce=" + nonce + "&"; } - params = params + "error_description=" + t(errorCode, defaultMsg) + "&"; + params = params + "error_description=" + t("invalid_transaction", defaultMsg) + "&"; //REQUIRED params = params + "state=" + state + "&"; //REQUIRED - params = params + "error=" + errorCode; + params = params + "error=" + "invalid_transaction"; window.location.replace(redirect_uri + params); return; diff --git a/oidc-ui/src/components/LoginQRCode.js b/oidc-ui/src/components/LoginQRCode.js index 77bf427bf..18e0b1d36 100644 --- a/oidc-ui/src/components/LoginQRCode.js +++ b/oidc-ui/src/components/LoginQRCode.js @@ -53,8 +53,6 @@ export default function LoginQRCode({ configurationKeys.walletQrCodeAutoRefreshLimit ) ?? process.env.REACT_WALLET_QR_CODE_AUTO_REFRESH_LIMIT; - const maxUiRefreshes = 3; - const GenerateQRCode = (response, logoUrl) => { let text = openIDConnectService.getEsignetConfiguration( @@ -129,23 +127,14 @@ export default function LoginQRCode({ }; }, []); - let fetchQrCodeCounter = 0; let qrCodeRefreshCount = 0; const fetchQRCode = async () => { + // If successfulFetchQrCount is 3, stop QR code generation and show QR code expired with a refresh button. if (qrCodeRefreshCount >= walletQrCodeAutoRefreshLimit) { - // If fetchQRCode is triggered 10 times, show invalid transaction and redirect back to relying party UI. - setError({ - errorCode: "invalid_transaction", - defaultMsg: "Invalid Transaction", - }); - return; - } - if (fetchQrCodeCounter >= maxUiRefreshes) { - // If successfulFetchQrCount is 3, stop QR code generation and show QR code expired with a refresh button. setError({ errorCode: "qr_code_expired", - defaultMsg: "QR code expired", + defaultMsg: "QR Code Expired", }); return; } @@ -202,7 +191,7 @@ export default function LoginQRCode({ fetchQRCode(); }, timeLeftWithBuffer * 1000); setQrCodeTimeout(_timer); - fetchQrCodeCounter++; + qrCodeRefreshCount++; } } catch (error) { setError({ @@ -211,7 +200,6 @@ export default function LoginQRCode({ defaultMsg: error.message, }); } - qrCodeRefreshCount++; }; const triggerLinkStatus = async (