From c6a00c07dabe504c8be0ae496e95a549e621689d Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 21 Feb 2024 13:12:37 +0100 Subject: [PATCH 1/8] Add basic .editorconfig and GitHub Actions workflow to check it --- .editorconfig | 4 ++++ .github/workflows/code-formatting.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/workflows/code-formatting.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..55b8678fb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +# EditorConfig: https://EditorConfig.org + +[*] +charset = utf-8 diff --git a/.github/workflows/code-formatting.yml b/.github/workflows/code-formatting.yml new file mode 100644 index 000000000..d7142ab16 --- /dev/null +++ b/.github/workflows/code-formatting.yml @@ -0,0 +1,26 @@ +# This name is shown in status badges +name: code-formatting + +on: + push: + branches-ignore: + - 'tmp**' + pull_request: + branches-ignore: + - 'tmp**' + +jobs: + editorconfig: + name: Check EditorConfig compliance + + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Set up editorconfig-checker + uses: editorconfig-checker/action-editorconfig-checker@v2 + + - name: Check code formatting + run: editorconfig-checker From 4d10c119e6c82f0d60a925e2bc3ba0037fb91f8c Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 21 Feb 2024 13:19:52 +0100 Subject: [PATCH 2/8] Set editorconfig insert_final_newline = true This is effectively the current convention: - Files with final newline: 52 - Files without final newline: 22 --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index 55b8678fb..ec859ff66 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,3 +2,4 @@ [*] charset = utf-8 +insert_final_newline = true # Type of newline is managed by git in .gitattributes From 2b6b2604426de6a51ebbdc26ee1786d78d52e9eb Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 21 Feb 2024 13:41:53 +0100 Subject: [PATCH 3/8] Fix insert_final_newline violations --- .buildignore | 2 +- .env.template | 2 +- .gitignore | 2 +- .htaccess | 2 +- .vscode/settings.json | 2 +- Dockerfile | 2 +- nginx/nginx.conf | 2 +- postcss.config.js | 2 +- src/ConsoleBehavior.js | 2 +- src/components/Credentials/CredentialJson.js | 2 +- src/components/HandlerNotification.js | 2 +- src/components/Popups/DeletePopup.js | 2 +- src/components/PrivateRoute.js | 2 +- src/components/QRCodeScanner/CornerBox.js | 2 +- src/components/Spinner.js | 2 +- src/firebase.js | 2 +- src/functions/ParseJwt.js | 2 +- src/index.css | 2 +- src/locales/en.json | 2 +- src/pages/AddCredentials/AddCredentials.js | 2 +- src/pages/Home/CredentialDetail.js | 2 +- src/services/SigningRequestHandlers.ts | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.buildignore b/.buildignore index 51289604a..1824a52a0 100644 --- a/.buildignore +++ b/.buildignore @@ -3,4 +3,4 @@ tsconfig.json yarn.lock README.md .gitignore -*.tar.gz \ No newline at end of file +*.tar.gz diff --git a/.env.template b/.env.template index 34cce26b0..08993bd34 100644 --- a/.env.template +++ b/.env.template @@ -13,4 +13,4 @@ REACT_APP_FIREBASE_APP_ID= REACT_APP_FIREBASE_MEASUREMENT_ID= REACT_APP_DID_KEY_VERSION=jwk_jcs-pub REACT_APP_VERSION=$npm_package_version -REACT_APP_CONSOLE_TYPES=info,warn,error \ No newline at end of file +REACT_APP_CONSOLE_TYPES=info,warn,error diff --git a/.gitignore b/.gitignore index 5157b62be..56d4b421c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,4 @@ src/config/config.dev.ts src/config/config.prod.js ssl_keys/* *.tar.gz -.npmrc \ No newline at end of file +.npmrc diff --git a/.htaccess b/.htaccess index 152dce1fe..62d0312c1 100644 --- a/.htaccess +++ b/.htaccess @@ -1,4 +1,4 @@ Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^ index.html [QSA,L] \ No newline at end of file +RewriteRule ^ index.html [QSA,L] diff --git a/.vscode/settings.json b/.vscode/settings.json index 4a664bbc1..e70c03c9d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,4 +2,4 @@ "editor.tabSize": 2, "editor.detectIndentation": false, "editor.insertSpaces": false -} \ No newline at end of file +} diff --git a/Dockerfile b/Dockerfile index cdc2ec3a6..5797bfe31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,4 +17,4 @@ COPY --from=builder /home/node/app/build/ . EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 38a61e01f..f03614a8d 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -8,4 +8,4 @@ server { } # Add any additional Nginx configuration here as needed -} \ No newline at end of file +} diff --git a/postcss.config.js b/postcss.config.js index 9a5389100..5c1449894 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -3,4 +3,4 @@ module.exports = { require('tailwindcss'), require('autoprefixer'), ], -}; \ No newline at end of file +}; diff --git a/src/ConsoleBehavior.js b/src/ConsoleBehavior.js index f95c0fefe..922be9af5 100644 --- a/src/ConsoleBehavior.js +++ b/src/ConsoleBehavior.js @@ -39,4 +39,4 @@ function ConsoleBehavior() { }); } -export default ConsoleBehavior; \ No newline at end of file +export default ConsoleBehavior; diff --git a/src/components/Credentials/CredentialJson.js b/src/components/Credentials/CredentialJson.js index e91e2fc8a..ed28f26c5 100644 --- a/src/components/Credentials/CredentialJson.js +++ b/src/components/Credentials/CredentialJson.js @@ -41,4 +41,4 @@ const CredentialJson = ({ credential }) => { ); }; -export default CredentialJson; \ No newline at end of file +export default CredentialJson; diff --git a/src/components/HandlerNotification.js b/src/components/HandlerNotification.js index 2f5d3f87d..8bd5c4637 100644 --- a/src/components/HandlerNotification.js +++ b/src/components/HandlerNotification.js @@ -90,4 +90,4 @@ const HandlerNotification = ({ children }) => { }; -export default HandlerNotification; \ No newline at end of file +export default HandlerNotification; diff --git a/src/components/Popups/DeletePopup.js b/src/components/Popups/DeletePopup.js index 92e07a38c..775c7b601 100644 --- a/src/components/Popups/DeletePopup.js +++ b/src/components/Popups/DeletePopup.js @@ -44,4 +44,4 @@ const DeletePopup = ({ isOpen, onConfirm, onCancel, message, loading }) => { ); }; -export default DeletePopup; \ No newline at end of file +export default DeletePopup; diff --git a/src/components/PrivateRoute.js b/src/components/PrivateRoute.js index d62ee7831..4ef2bace0 100644 --- a/src/components/PrivateRoute.js +++ b/src/components/PrivateRoute.js @@ -99,4 +99,4 @@ const PrivateRoute = ({ children }) => { }; -export default PrivateRoute; \ No newline at end of file +export default PrivateRoute; diff --git a/src/components/QRCodeScanner/CornerBox.js b/src/components/QRCodeScanner/CornerBox.js index eaa4dccca..fba38c88d 100644 --- a/src/components/QRCodeScanner/CornerBox.js +++ b/src/components/QRCodeScanner/CornerBox.js @@ -23,4 +23,4 @@ const CornerBox = ({ qrDetected, side, position, boxSize }) => { return
; }; -export default CornerBox; \ No newline at end of file +export default CornerBox; diff --git a/src/components/Spinner.js b/src/components/Spinner.js index 748ca953d..4a6311b6e 100644 --- a/src/components/Spinner.js +++ b/src/components/Spinner.js @@ -14,4 +14,4 @@ function Spinner() { ); } -export default Spinner; \ No newline at end of file +export default Spinner; diff --git a/src/firebase.js b/src/firebase.js index 613668bdb..69eb8f2c8 100644 --- a/src/firebase.js +++ b/src/firebase.js @@ -148,4 +148,4 @@ const initializeFirebaseAndMessaging = async () => { } }; -initializeFirebaseAndMessaging(); \ No newline at end of file +initializeFirebaseAndMessaging(); diff --git a/src/functions/ParseJwt.js b/src/functions/ParseJwt.js index 9e4e3e05a..4ff818c52 100644 --- a/src/functions/ParseJwt.js +++ b/src/functions/ParseJwt.js @@ -15,4 +15,4 @@ function parseJwt(token) { return JSON.parse(jsonPayload); } -export default parseJwt; \ No newline at end of file +export default parseJwt; diff --git a/src/index.css b/src/index.css index cce158cfb..66a60ebd9 100644 --- a/src/index.css +++ b/src/index.css @@ -76,4 +76,4 @@ overflow: hidden; white-space: nowrap; text-overflow: ellipsis; -} \ No newline at end of file +} diff --git a/src/locales/en.json b/src/locales/en.json index a6f924b2d..4b3509c0d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -186,4 +186,4 @@ "navItemLogout": "Logout", "poweredBy": "Powered by wwWallet" } -} \ No newline at end of file +} diff --git a/src/pages/AddCredentials/AddCredentials.js b/src/pages/AddCredentials/AddCredentials.js index de6773db8..fe1e2e1eb 100644 --- a/src/pages/AddCredentials/AddCredentials.js +++ b/src/pages/AddCredentials/AddCredentials.js @@ -196,4 +196,4 @@ const Issuers = () => { ); }; -export default Issuers; \ No newline at end of file +export default Issuers; diff --git a/src/pages/Home/CredentialDetail.js b/src/pages/Home/CredentialDetail.js index 1daa95e8f..ec85cdabc 100644 --- a/src/pages/Home/CredentialDetail.js +++ b/src/pages/Home/CredentialDetail.js @@ -121,4 +121,4 @@ const CredentialDetail = () => { ); }; -export default CredentialDetail; \ No newline at end of file +export default CredentialDetail; diff --git a/src/services/SigningRequestHandlers.ts b/src/services/SigningRequestHandlers.ts index 629caa6d5..e163a37da 100644 --- a/src/services/SigningRequestHandlers.ts +++ b/src/services/SigningRequestHandlers.ts @@ -50,4 +50,4 @@ export function SigningRequestHandlerService(): SigningRequestHandlers { socket.send(JSON.stringify(outgoingMessage)); }, } -} \ No newline at end of file +} From bcbe6bff7ce13ce80ecf5a21010cb8c77506c41f Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 21 Feb 2024 13:22:43 +0100 Subject: [PATCH 4/8] Set editorconfig trim_trailing_whitespace = true --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index ec859ff66..adf766e9a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,3 +3,4 @@ [*] charset = utf-8 insert_final_newline = true # Type of newline is managed by git in .gitattributes +trim_trailing_whitespace = true From 51eada63756ee998bf6b950618046a19dde49306 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 21 Feb 2024 13:42:18 +0100 Subject: [PATCH 5/8] Fix trim_trailing_whitespace violations --- README.md | 18 +++++++-------- .../ChistmasAnimation/Snowfalling.js | 4 ++-- src/components/Credentials/CredentialJson.js | 2 +- src/components/HandlerNotification.js | 2 +- src/components/Popups/PinInput.js | 2 +- src/components/Popups/SelectCredentials.js | 2 +- src/components/PrivateRoute.js | 8 +++---- src/components/Sidebar.js | 4 ++-- src/components/useCheckURL.ts | 4 ++-- src/firebase.js | 6 ++--- src/functions/DateFormat.js | 2 -- src/i18n.js | 2 +- src/index.css | 2 +- src/index.js | 1 - src/pages/AddCredentials/AddCredentials.js | 18 +++++++-------- src/pages/History/History.js | 8 +++---- src/pages/Home/CredentialDetail.js | 8 +++---- src/pages/Home/Home.js | 22 +++++++++---------- src/pages/Login/Login.js | 2 +- src/pages/SendCredentials/SendCredentials.js | 8 +++---- src/pages/Settings/Settings.tsx | 2 +- src/services/LocalStorageKeystore.ts | 6 ++--- 22 files changed, 65 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index a8b361aba..f4657d093 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Our Web Wallet provides a range of features tailored to enhance the credential m ```bash git clone https://github.com/your-username/wallet-frontend.git ``` - + - **Option 2: Using SSH** ```bash git clone git@github.com:your-username/wallet-frontend.git @@ -63,12 +63,12 @@ The project uses environment variables to manage different configurations. A `.e - REACT_APP_WS_URL: The URL of the websocket service. - REACT_APP_WALLET_BACKEND_URL: The URL of your backend service. - REACT_APP_LOGIN_WITH_PASSWORD: A Boolean value which show/hide the classic login/signup. - - REACT_APP_FIREBASE_API_KEY: Your API key for Firebase. + - REACT_APP_FIREBASE_API_KEY: Your API key for Firebase. - REACT_APP_FIREBASE_AUTH_DOMAIN: Your Firebase authentication domain. - REACT_APP_FIREBASE_PROJECT_ID: Your Firebase project ID. - REACT_APP_FIREBASE_STORAGE_BUCKET: Your Firebase storage bucket. - REACT_APP_FIREBASE_MESSAGING_SENDER_ID: Your Firebase Messaging Sender ID. - - REACT_APP_FIREBASE_APP_ID: Your Firebase App ID. + - REACT_APP_FIREBASE_APP_ID: Your Firebase App ID. - REACT_APP_FIREBASE_MEASUREMENT_ID: Your Firebase Measurement ID. - REACT_APP_CONSOLE_TYPES: Enable console logs (info, warn, error) separated by commas or leave empty for none. @@ -101,7 +101,7 @@ The PRF (Pseudo Random Function) extension in WebAuthn enables the evaluation of | Windows | ✔ | ✔ | ❌ | ✔ | | ✔ | | MacOS | ✔ | ✔ | ❌ | ✔ | ❌ | ✔ | | Android | ✔ | ✔ | ❌ | ✔ | | ✔ | -| iOS | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| iOS | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ### PRF Compatibility Scenarios @@ -123,7 +123,7 @@ The PRF (Pseudo Random Function) extension in WebAuthn enables the evaluation of | iOS | FIDO Security Key | NFC | ❌ | -***Note:** In this table, we use the term "FIDO Security Key" to refer to compatible security keys. It's important to understand that any security key should work with the hmac-secret extension, provided it supports this feature. +***Note:** In this table, we use the term "FIDO Security Key" to refer to compatible security keys. It's important to understand that any security key should work with the hmac-secret extension, provided it supports this feature. For a detailed list of security key models that support hmac-secret, you can refer to the [FIDO MDS Explorer](https://opotonniee.github.io/fido-mds-explorer/), where hmac-secret support is listed under metadataStatement > authenticatorGetInfo > extensions.* The wwWallet is committed to delivering a secure and adaptable authentication experience with an emphasis on PRF extension compatibility. @@ -162,7 +162,7 @@ We welcome contributions from the community to help improve the wwWallet Fronten 1. **Create a New Branch:** Create a new branch for your feature or bug fix - ```bash + ```bash git checkout -b my-feature ``` Replace my-feature with a descriptive name. @@ -172,14 +172,14 @@ We welcome contributions from the community to help improve the wwWallet Fronten 3. **Commit Changes:** Commit your changes with a descriptive commit message: - ```bash + ```bash git commit -m "Add new feature" ``` 4. **Push Changes:** Push your changes to your new branrch: - ```bash + ```bash git push --set-upstream origin my-feature - ``` + ``` 5. **Create a Pull Request:** Open a pull request on the original repository. Provide a detailed description of your changes and their purpose. diff --git a/src/components/ChistmasAnimation/Snowfalling.js b/src/components/ChistmasAnimation/Snowfalling.js index a83c8df40..b8a5b7ee2 100644 --- a/src/components/ChistmasAnimation/Snowfalling.js +++ b/src/components/ChistmasAnimation/Snowfalling.js @@ -8,10 +8,10 @@ const Snowfalling = () => { const checkSeason = () => { const today = new Date(); const currentYear = today.getFullYear(); - + const start = new Date(currentYear, 11, 20); const end = new Date(currentYear + 1, 0, 6); - + return today >= start && today <= end; }; diff --git a/src/components/Credentials/CredentialJson.js b/src/components/Credentials/CredentialJson.js index ed28f26c5..ddd7ae9c8 100644 --- a/src/components/Credentials/CredentialJson.js +++ b/src/components/Credentials/CredentialJson.js @@ -23,7 +23,7 @@ const CredentialJson = ({ credential }) => {
-
+
{showJsonCredentials && credential ? (
diff --git a/src/components/HandlerNotification.js b/src/components/HandlerNotification.js index 8bd5c4637..5ee31cbaa 100644 --- a/src/components/HandlerNotification.js +++ b/src/components/HandlerNotification.js @@ -61,7 +61,7 @@ const HandlerNotification = ({ children }) => { console.log('Failed to receive message:', err); setMessageReceived(false); // Set isMessageReceived to false if there's an error }); - + return () => { if (!messageReceived) { diff --git a/src/components/Popups/PinInput.js b/src/components/Popups/PinInput.js index fc2c8e692..4cae24ea5 100644 --- a/src/components/Popups/PinInput.js +++ b/src/components/Popups/PinInput.js @@ -47,7 +47,7 @@ function PinInput({ showPopup, setShowPopup }) { inputRefs[index - 1].current.focus(); newPin[index - 1] = ''; } else if (value !== '' && index < 3) { - // Move focus to the next input and clean it + // Move focus to the next input and clean it const nextInput = inputRefs[index + 1].current; newPin[index + 1] = ''; setPin(newPin); diff --git a/src/components/Popups/SelectCredentials.js b/src/components/Popups/SelectCredentials.js index 70f3375e6..964980376 100644 --- a/src/components/Popups/SelectCredentials.js +++ b/src/components/Popups/SelectCredentials.js @@ -69,7 +69,7 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman

- + {t('selectCredentialPopup.title')}


diff --git a/src/components/PrivateRoute.js b/src/components/PrivateRoute.js index 4ef2bace0..09f89e728 100644 --- a/src/components/PrivateRoute.js +++ b/src/components/PrivateRoute.js @@ -13,7 +13,7 @@ const PrivateRoute = ({ children }) => { const [loading, setLoading] = useState(false); const keystore = useLocalStorageKeystore(); const isLoggedIn = api.isLoggedIn() && keystore.isOpen(); - + const location = useLocation(); const navigate = useNavigate(); @@ -59,8 +59,8 @@ const PrivateRoute = ({ children }) => { await api.post('/user/session/fcm_token/add', { fcm_token: fcmToken }); // Set a flag in sessionStorage to indicate that the token has been sent sessionStorage.setItem('tokenSentInSession', 'true'); - console.log('send FCM Token:', fcmToken); - + console.log('send FCM Token:', fcmToken); + console.log('FCM Token:', fcmToken); } catch (error) { console.error('Error sending FCM token to the backend:', error); @@ -70,7 +70,7 @@ const PrivateRoute = ({ children }) => { } } } - + sendFcmTokenToBackend(); }, [isPermissionGranted]); diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index d64e2f2bc..a62f66859 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -104,9 +104,9 @@ const Sidebar = ({ isOpen, toggle }) => {
    - {displayName || username} diff --git a/src/components/useCheckURL.ts b/src/components/useCheckURL.ts index 8907378eb..1850fb958 100644 --- a/src/components/useCheckURL.ts +++ b/src/components/useCheckURL.ts @@ -27,7 +27,7 @@ function useCheckURL(urlToCheck: string): { const res = await api.post('/communication/handle', { url, camera_was_used: (wwwallet_camera_was_used != null && wwwallet_camera_was_used === 'true') }); const { redirect_to, conformantCredentialsMap, verifierDomainName, preauth, ask_for_pin } = res.data; - + if (preauth && preauth == true) { if (ask_for_pin) { setShowPinInputPopup(true); @@ -64,7 +64,7 @@ function useCheckURL(urlToCheck: string): { await communicationHandler(urlToCheck); })(); } - + }, [api, keystore, urlToCheck, isLoggedIn]); useEffect(() => { diff --git a/src/firebase.js b/src/firebase.js index 69eb8f2c8..09f79c099 100644 --- a/src/firebase.js +++ b/src/firebase.js @@ -44,10 +44,10 @@ const requestForToken = async () => { console.log('ERROR:',err.message,err.code); if (err.code === 'messaging/permission-blocked') { console.error('Notification permission was blocked or click close.'); - return null; + return null; }else if (err.message === "Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker") { console.error('Failed beacuse there is no token created yet, so we are going to re-register'); - + } else { console.error('An error occurred while retrieving token:',err); return null; @@ -103,7 +103,7 @@ export const fetchToken = async () => { } } else { console.log('Messaging is not initialized.'); - + } return null; // Return null in case of failure }; diff --git a/src/functions/DateFormat.js b/src/functions/DateFormat.js index d49e25dab..502cf16aa 100644 --- a/src/functions/DateFormat.js +++ b/src/functions/DateFormat.js @@ -9,5 +9,3 @@ export function formatDate(dateString) { }; return new Date(dateString).toLocaleString(undefined, options); }; - - diff --git a/src/i18n.js b/src/i18n.js index eb27dd7f8..8102f07ff 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -10,7 +10,7 @@ i18n resources: { en: { translation: enTranslation }, }, - lng: 'en', + lng: 'en', interpolation: { escapeValue: false, }, diff --git a/src/index.css b/src/index.css index 66a60ebd9..b18c2f74c 100644 --- a/src/index.css +++ b/src/index.css @@ -20,7 +20,7 @@ .custom-scrollbar { scrollbar-width: thin; scrollbar-color: #ccc #f0f0f0; - padding-right: 5px; + padding-right: 5px; } .custom-scrollbar::-webkit-scrollbar { diff --git a/src/index.js b/src/index.js index 3ce4401cf..66f0b1819 100644 --- a/src/index.js +++ b/src/index.js @@ -8,4 +8,3 @@ ConsoleBehavior(); const root = createRoot(document.getElementById('root')); root.render(); - diff --git a/src/pages/AddCredentials/AddCredentials.js b/src/pages/AddCredentials/AddCredentials.js index fe1e2e1eb..0b8c506c8 100644 --- a/src/pages/AddCredentials/AddCredentials.js +++ b/src/pages/AddCredentials/AddCredentials.js @@ -86,19 +86,19 @@ const Issuers = () => { const handleContinue = () => { setLoading(true); - + console.log('Continue with:', selectedIssuer); - + if (selectedIssuer && selectedIssuer.did) { const payload = { legal_person_did: selectedIssuer.did, }; - + api.post('/communication/handle', payload) .then((response) => { const { redirect_to } = response.data; console.log(redirect_to); - + // Redirect to the URL received from the backend window.location.href = redirect_to; }) @@ -107,7 +107,7 @@ const Issuers = () => { console.error('Error sending request to backend:', error); }); } - + setLoading(false); setShowRedirectPopup(false); }; @@ -138,7 +138,7 @@ const Issuers = () => {
    )} - +

{t('pageAddCredentials.description')}

@@ -182,12 +182,12 @@ const Issuers = () => { popupMessage={`${t('pageAddCredentials.popup.messagePart1')} ${selectedIssuer?.friendlyName}${t('pageAddCredentials.popup.messagePart2')}`} /> )} - + {/* QR Code Scanner Modal */} {isQRScannerOpen && (
-
)} diff --git a/src/pages/History/History.js b/src/pages/History/History.js index 13fd9ee61..38a792fbc 100644 --- a/src/pages/History/History.js +++ b/src/pages/History/History.js @@ -3,7 +3,7 @@ import { BiLeftArrow, BiRightArrow } from 'react-icons/bi'; import { useTranslation } from 'react-i18next'; import Slider from 'react-slick'; -import "slick-carousel/slick/slick.css"; +import "slick-carousel/slick/slick.css"; import "slick-carousel/slick/slick-theme.css"; import { useApi } from '../../api'; @@ -106,9 +106,9 @@ const History = () => { {isImageModalOpen && (
-
setImageModalOpen(false)}>
+
setImageModalOpen(false)}>
- + {/* Popup content */}

@@ -147,7 +147,7 @@ const History = () => {

-
+
)} ); diff --git a/src/pages/Home/CredentialDetail.js b/src/pages/Home/CredentialDetail.js index ec85cdabc..9018fa51f 100644 --- a/src/pages/Home/CredentialDetail.js +++ b/src/pages/Home/CredentialDetail.js @@ -52,8 +52,8 @@ const CredentialDetail = () => {
-

{t('common.navItemCredentials')}

- +

{t('common.navItemCredentials')}

+
{credential && ( @@ -85,7 +85,7 @@ const CredentialDetail = () => {
- +
@@ -111,7 +111,7 @@ const CredentialDetail = () => { message={ {t('pageCredentials.deletePopup.messagePart1')}{' '} {credential.type.replace(/([A-Z])/g, ' $1')} {t('pageCredentials.deletePopup.messagePart2')} -
{t('pageCredentials.deletePopup.messagePart3')}{' '} {t('pageCredentials.deletePopup.messagePart4')} +
{t('pageCredentials.deletePopup.messagePart3')}{' '} {t('pageCredentials.deletePopup.messagePart4')}
} loading={loading} diff --git a/src/pages/Home/Home.js b/src/pages/Home/Home.js index 8b9c3630c..74fb948a1 100644 --- a/src/pages/Home/Home.js +++ b/src/pages/Home/Home.js @@ -7,7 +7,7 @@ import { BiLeftArrow, BiRightArrow } from 'react-icons/bi'; import {BsQrCodeScan} from 'react-icons/bs' import Slider from 'react-slick'; -import "slick-carousel/slick/slick.css"; +import "slick-carousel/slick/slick.css"; import "slick-carousel/slick/slick-theme.css"; import addImage from '../../assets/images/cred.png'; @@ -47,7 +47,7 @@ const Home = () => { centerPadding: '10px', // Set the padding between adjacent images to 2 pixels style: { margin: '0 10px' }, }; - + useEffect(() => { const handleResize = () => { setIsSmallScreen(window.innerWidth < 768); @@ -128,13 +128,13 @@ const Home = () => { - +

{t('pageCredentials.description')}

{isSmallScreen ? ( - <> + <> {credentials.length === 0 ? (
{
- { setShowDeletePopup(true); setSelectedCredential(credential); }} /> + { setShowDeletePopup(true); setSelectedCredential(credential); }} /> @@ -177,8 +177,8 @@ const Home = () => { )} - - ) : ( + + ) : (
{credentials.map((credential) => (
{
- )} + )} {/* Modal for Fullscreen credential */} @@ -221,8 +221,8 @@ const Home = () => { {/* QR Code Scanner Modal */} {isQRScannerOpen && (
-
)} @@ -236,7 +236,7 @@ const Home = () => { message={ {t('pageCredentials.deletePopup.messagePart1')}{' '} {selectedCredential.type.replace(/([A-Z])/g, ' $1')} {t('pageCredentials.deletePopup.messagePart2')} -
{t('pageCredentials.deletePopup.messagePart3')}{' '} {t('pageCredentials.deletePopup.messagePart4')} +
{t('pageCredentials.deletePopup.messagePart3')}{' '} {t('pageCredentials.deletePopup.messagePart4')}
} loading={loading} diff --git a/src/pages/Login/Login.js b/src/pages/Login/Login.js index 753dd5712..a0554b256 100644 --- a/src/pages/Login/Login.js +++ b/src/pages/Login/Login.js @@ -427,7 +427,7 @@ const WebauthnSignupLogin = ({ {isLogin && cachedUsers?.length > 0 && } )} - +

{t('pageSendCredentials.description')}

diff --git a/src/pages/Settings/Settings.tsx b/src/pages/Settings/Settings.tsx index 0cd8a75ef..b08d9afb0 100644 --- a/src/pages/Settings/Settings.tsx +++ b/src/pages/Settings/Settings.tsx @@ -738,7 +738,7 @@ const Settings = () => { onCancel={closeDeleteConfirmation} message={ - {t('pageSettings.deleteAccount.messageDeleteAccount1')} {t('pageSettings.deleteAccount.messageDeleteAccount2')} ? + {t('pageSettings.deleteAccount.messageDeleteAccount1')} {t('pageSettings.deleteAccount.messageDeleteAccount2')} ? } loading={loading} diff --git a/src/services/LocalStorageKeystore.ts b/src/services/LocalStorageKeystore.ts index bac631185..fb39c166c 100644 --- a/src/services/LocalStorageKeystore.ts +++ b/src/services/LocalStorageKeystore.ts @@ -579,12 +579,12 @@ export function useLocalStorageKeystore(): LocalStorageKeystore { const multicodecPublicKey = new Uint8Array(2 + compressedPublicKeyBytes.length); console.log("Compresses pub key length = ", compressedPublicKeyBytes.length) varint.encodeTo(0x1200, multicodecPublicKey, 0); - + multicodecPublicKey.set(compressedPublicKeyBytes, 2); - + // Base58-btc encode the multicodec public key const base58EncodedPublicKey = base58btc.encode(multicodecPublicKey); - + // Construct the did:key string const didKeyString = `did:key:${base58EncodedPublicKey}`; From e610889eb396a496e8c89b1e45a4c9f1e0beb84b Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 21 Feb 2024 13:40:38 +0100 Subject: [PATCH 6/8] Set editorconfig indent_style = tab --- .editorconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.editorconfig b/.editorconfig index adf766e9a..f0de91639 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,3 +4,10 @@ charset = utf-8 insert_final_newline = true # Type of newline is managed by git in .gitattributes trim_trailing_whitespace = true + +[{*.{Dockerfile,css,js,jsx,ts,tsx},Dockerfile}] +indent_style = tab + +[*.{yml,yaml}] # YAML does not allow tab indentation +indent_style = space +indent_size = 2 From 253ba8993de280c29047b8837a9eabecb24f77e3 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 21 Feb 2024 13:42:30 +0100 Subject: [PATCH 7/8] Fix indent_style violations --- Dockerfile | 2 +- development.Dockerfile | 2 +- src/ConsoleBehavior.js | 48 ++--- .../ChistmasAnimation/Snowfalling.js | 32 +-- .../Credentials/ApiFetchCredential.ts | 68 +++--- .../Credentials/CredentialDeleteButton.js | 10 +- src/components/Credentials/CredentialInfo.js | 100 ++++----- src/components/Credentials/CredentialJson.js | 24 +-- src/components/HandlerNotification.js | 110 +++++----- src/components/PrivateRoute.js | 110 +++++----- src/components/Sidebar.js | 56 +++-- src/firebase.js | 194 ++++++++--------- src/functions/DateFormat.js | 18 +- src/functions/ParseJwt.js | 22 +- src/i18n.js | 20 +- src/index.css | 58 +++--- src/pages/AddCredentials/AddCredentials.js | 52 ++--- src/pages/History/History.js | 170 +++++++-------- src/pages/Home/CredentialDetail.js | 12 +- src/pages/Home/Home.js | 166 +++++++-------- src/pages/Login/Login.js | 48 ++--- src/pages/NotFound/NotFound.js | 10 +- src/pages/SendCredentials/SendCredentials.js | 196 +++++++++--------- .../VerificationResult/VerificationResult.js | 20 +- src/util.ts | 4 +- 25 files changed, 774 insertions(+), 778 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5797bfe31..c3dcb8950 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /home/node/app COPY . . RUN --mount=type=secret,id=npmrc,required=true,target=./.npmrc,uid=1000 \ - yarn cache clean -f && yarn install && yarn build + yarn cache clean -f && yarn install && yarn build FROM nginx:alpine as deploy diff --git a/development.Dockerfile b/development.Dockerfile index 2e7b892cd..4e7008f8a 100644 --- a/development.Dockerfile +++ b/development.Dockerfile @@ -5,7 +5,7 @@ WORKDIR /dependencies # Install dependencies first so rebuild of these layers is only needed when dependencies change COPY package.json yarn.lock . RUN --mount=type=secret,id=npmrc,required=true,target=./.npmrc,uid=1000 \ - yarn install && yarn cache clean -f + yarn install && yarn cache clean -f FROM node:16-bullseye-slim as development diff --git a/src/ConsoleBehavior.js b/src/ConsoleBehavior.js index 922be9af5..e183285a3 100644 --- a/src/ConsoleBehavior.js +++ b/src/ConsoleBehavior.js @@ -13,30 +13,30 @@ function isMethodAllowed(method) { } function ConsoleBehavior() { - const originalConsole = { ...console }; - - const originalPrepareStackTrace = Error.prepareStackTrace; - - Object.keys(console).forEach(method => { - if (typeof console[method] === 'function') { - console[method] = (...args) => { - if (isMethodAllowed(method)) { - Error.prepareStackTrace = (_, stack) => stack; - const stack = new Error().stack; - Error.prepareStackTrace = originalPrepareStackTrace; - - const callSite = stack[1]; - if (callSite) { - const fileName = callSite.getFileName(); - const lineNumber = callSite.getLineNumber(); - args.push(`(at ${fileName}:${lineNumber})`); - } - - originalConsole[method].apply(console, args); - } - }; - } - }); + const originalConsole = { ...console }; + + const originalPrepareStackTrace = Error.prepareStackTrace; + + Object.keys(console).forEach(method => { + if (typeof console[method] === 'function') { + console[method] = (...args) => { + if (isMethodAllowed(method)) { + Error.prepareStackTrace = (_, stack) => stack; + const stack = new Error().stack; + Error.prepareStackTrace = originalPrepareStackTrace; + + const callSite = stack[1]; + if (callSite) { + const fileName = callSite.getFileName(); + const lineNumber = callSite.getLineNumber(); + args.push(`(at ${fileName}:${lineNumber})`); + } + + originalConsole[method].apply(console, args); + } + }; + } + }); } export default ConsoleBehavior; diff --git a/src/components/ChistmasAnimation/Snowfalling.js b/src/components/ChistmasAnimation/Snowfalling.js index b8a5b7ee2..0c8ec8691 100644 --- a/src/components/ChistmasAnimation/Snowfalling.js +++ b/src/components/ChistmasAnimation/Snowfalling.js @@ -2,27 +2,27 @@ import React, { useEffect, useState } from 'react'; import Snowfall from 'react-snowfall'; const Snowfalling = () => { - const [isChristmasSeason, setIsChristmasSeason] = useState(false); + const [isChristmasSeason, setIsChristmasSeason] = useState(false); - useEffect(() => { - const checkSeason = () => { - const today = new Date(); - const currentYear = today.getFullYear(); + useEffect(() => { + const checkSeason = () => { + const today = new Date(); + const currentYear = today.getFullYear(); - const start = new Date(currentYear, 11, 20); - const end = new Date(currentYear + 1, 0, 6); + const start = new Date(currentYear, 11, 20); + const end = new Date(currentYear + 1, 0, 6); - return today >= start && today <= end; - }; + return today >= start && today <= end; + }; - setIsChristmasSeason(checkSeason()); - }, []); + setIsChristmasSeason(checkSeason()); + }, []); - return ( - <> - {isChristmasSeason && } - - ); + return ( + <> + {isChristmasSeason && } + + ); } export default Snowfalling; diff --git a/src/components/Credentials/ApiFetchCredential.ts b/src/components/Credentials/ApiFetchCredential.ts index 272ba1400..b1aa94512 100644 --- a/src/components/Credentials/ApiFetchCredential.ts +++ b/src/components/Credentials/ApiFetchCredential.ts @@ -4,42 +4,42 @@ import { BackendApi } from '../../api'; import parseJwt from '../../functions/ParseJwt'; export async function fetchCredentialData(api: BackendApi, id = null) { - try { - const response = await api.get('/storage/vc'); + try { + const response = await api.get('/storage/vc'); - if (id) { - const targetImage = response.data.vc_list.find((img) => img.id.toString() === id); - const newImages = targetImage - ? [targetImage].map((item) => ({ - id: item.id, - credentialIdentifier:item.credentialIdentifier, - src: item.logoURL, - alt: item.issuerFriendlyName, - data: parseJwt(item.credential)["vc"]['credentialSubject'], - type: parseJwt(item.credential)['vc']["type"]["2"], - expdate: parseJwt(item.credential)['vc']["expirationDate"], - json:JSON.stringify(parseJwt(item.credential)["vc"], null, 2) + if (id) { + const targetImage = response.data.vc_list.find((img) => img.id.toString() === id); + const newImages = targetImage + ? [targetImage].map((item) => ({ + id: item.id, + credentialIdentifier: item.credentialIdentifier, + src: item.logoURL, + alt: item.issuerFriendlyName, + data: parseJwt(item.credential)["vc"]['credentialSubject'], + type: parseJwt(item.credential)['vc']["type"]["2"], + expdate: parseJwt(item.credential)['vc']["expirationDate"], + json: JSON.stringify(parseJwt(item.credential)["vc"], null, 2) - })) - : []; + })) + : []; - return newImages[0]; - } else { - const newImages = response.data.vc_list.map((item) => ({ - id: item.id, - credentialIdentifier:item.credentialIdentifier, - src: item.logoURL, - alt: item.issuerFriendlyName, - data: parseJwt(item.credential)["vc"]['credentialSubject'], - type: parseJwt(item.credential)['vc']["type"]["2"], - expdate: parseJwt(item.credential)['vc']["expirationDate"], - json:JSON.stringify(parseJwt(item.credential)["vc"], null, 2) - })); + return newImages[0]; + } else { + const newImages = response.data.vc_list.map((item) => ({ + id: item.id, + credentialIdentifier: item.credentialIdentifier, + src: item.logoURL, + alt: item.issuerFriendlyName, + data: parseJwt(item.credential)["vc"]['credentialSubject'], + type: parseJwt(item.credential)['vc']["type"]["2"], + expdate: parseJwt(item.credential)['vc']["expirationDate"], + json: JSON.stringify(parseJwt(item.credential)["vc"], null, 2) + })); - return newImages; - } - } catch (error) { - console.error('Failed to fetch data', error); - return null; - } + return newImages; + } + } catch (error) { + console.error('Failed to fetch data', error); + return null; + } } diff --git a/src/components/Credentials/CredentialDeleteButton.js b/src/components/Credentials/CredentialDeleteButton.js index a02931543..ae1525c7c 100644 --- a/src/components/Credentials/CredentialDeleteButton.js +++ b/src/components/Credentials/CredentialDeleteButton.js @@ -5,11 +5,11 @@ import { useTranslation } from 'react-i18next'; const CredentialDeleteButton = ({ onDelete }) => { const { t } = useTranslation(); - const handleClick = () => { - onDelete(); - }; + const handleClick = () => { + onDelete(); + }; - return ( + return (
- ); + ); }; export default CredentialDeleteButton; diff --git a/src/components/Credentials/CredentialInfo.js b/src/components/Credentials/CredentialInfo.js index 25b8ba3be..cc146c392 100644 --- a/src/components/Credentials/CredentialInfo.js +++ b/src/components/Credentials/CredentialInfo.js @@ -7,62 +7,62 @@ import { GiLevelEndFlag } from 'react-icons/gi'; import { formatDate } from '../../functions/DateFormat'; const getFieldIcon = (fieldName) => { - switch (fieldName) { - case 'type': - return ; - case 'expdate': - return ; - case 'dateOfBirth': - return ; - case 'familyName': - case 'firstName': - return ; - case 'diplomaTitle': - return ; - case 'eqfLevel': - return ; - case 'grade': - return ; - default: - return null; - } + switch (fieldName) { + case 'type': + return ; + case 'expdate': + return ; + case 'dateOfBirth': + return ; + case 'familyName': + case 'firstName': + return ; + case 'diplomaTitle': + return ; + case 'eqfLevel': + return ; + case 'grade': + return ; + default: + return null; + } }; const renderRow = (fieldName, fieldValue) => { - if (fieldValue) { - return ( - - - {getFieldIcon(fieldName)} - - {fieldValue} - - ); - } - return null; + if (fieldValue) { + return ( + + + {getFieldIcon(fieldName)} + + {fieldValue} + + ); + } + return null; }; const CredentialInfo = ({ credential }) => { - return ( -
- - - {credential && ( - <> - {renderRow('type', credential.type)} - {renderRow('expdate', formatDate(credential.expdate))} - {renderRow('familyName', credential.data.familyName)} - {renderRow('firstName', credential.data.firstName)} - {renderRow('dateOfBirth', credential.data.dateOfBirth)} - {renderRow('diplomaTitle', credential.data.diplomaTitle)} - {renderRow('eqfLevel', credential.data.eqfLevel)} - {renderRow('grade', credential.data.grade)} - - )} - -
-
- ); + return ( +
+ + + {credential && ( + <> + {renderRow('type', credential.type)} + {renderRow('expdate', formatDate(credential.expdate))} + {renderRow('familyName', credential.data.familyName)} + {renderRow('firstName', credential.data.firstName)} + {renderRow('dateOfBirth', credential.data.dateOfBirth)} + {renderRow('diplomaTitle', credential.data.diplomaTitle)} + {renderRow('eqfLevel', credential.data.eqfLevel)} + {renderRow('grade', credential.data.grade)} + + )} + +
+
+ ); }; export default CredentialInfo; diff --git a/src/components/Credentials/CredentialJson.js b/src/components/Credentials/CredentialJson.js index ddd7ae9c8..c021395fc 100644 --- a/src/components/Credentials/CredentialJson.js +++ b/src/components/Credentials/CredentialJson.js @@ -7,20 +7,20 @@ import { AiOutlineDown, AiOutlineUp } from 'react-icons/ai'; const CredentialJson = ({ credential }) => { const [showJsonCredentials, setShowJsonCredentials] = useState(false); - return ( + return (
- +

diff --git a/src/components/HandlerNotification.js b/src/components/HandlerNotification.js index 5ee31cbaa..62ec5596b 100644 --- a/src/components/HandlerNotification.js +++ b/src/components/HandlerNotification.js @@ -5,72 +5,72 @@ import { AiOutlineClose } from 'react-icons/ai'; import logo from '../assets/images/logo.png'; const ToastDisplay = ({ id, notification }) => { - return ( -
window.location.href = '/'} - > -
- Logo -
-
-

{notification?.title}

-

{notification?.body}

-
- -
- ); + return ( +
window.location.href = '/'} + > +
+ Logo +
+
+

{notification?.title}

+

{notification?.body}

+
+ +
+ ); }; const HandlerNotification = ({ children }) => { - const [notification, setNotification] = useState({ title: '', body: '' }); - const [isMessageReceived, setMessageReceived] = useState(null); + const [notification, setNotification] = useState({ title: '', body: '' }); + const [isMessageReceived, setMessageReceived] = useState(null); - const showToast = () => - toast((t) => , { - onClick: () => { - window.location.href = '/'; - }, - }); + const showToast = () => + toast((t) => , { + onClick: () => { + window.location.href = '/'; + }, + }); - useEffect(() => { - if (notification?.title) { - showToast(); - } - }, [notification]); + useEffect(() => { + if (notification?.title) { + showToast(); + } + }, [notification]); - useEffect(() => { - let messageReceived = false; + useEffect(() => { + let messageReceived = false; const unregisterMessageListener = onMessageListener() - .then((payload) => { - // Process the received message - setNotification({ - title: payload?.notification?.title, - body: payload?.notification?.body, + .then((payload) => { + // Process the received message + setNotification({ + title: payload?.notification?.title, + body: payload?.notification?.body, + }); + setMessageReceived(true); // Message has been received + }) + .catch((err) => { + console.log('Failed to receive message:', err); + setMessageReceived(false); // Set isMessageReceived to false if there's an error }); - setMessageReceived(true); // Message has been received - }) - .catch((err) => { - console.log('Failed to receive message:', err); - setMessageReceived(false); // Set isMessageReceived to false if there's an error - }); - return () => { - if (!messageReceived) { - setMessageReceived(false); // Set isMessageReceived to false if no message was received before unmount - } - }; - }, []); + return () => { + if (!messageReceived) { + setMessageReceived(false); // Set isMessageReceived to false if no message was received before unmount + } + }; + }, []); - // Render just children when waiting for message reception + // Render just children when waiting for message reception if (isMessageReceived === null || isMessageReceived === false) { // Render children when waiting for a message return ( diff --git a/src/components/PrivateRoute.js b/src/components/PrivateRoute.js index 09f89e728..fce26b410 100644 --- a/src/components/PrivateRoute.js +++ b/src/components/PrivateRoute.js @@ -7,59 +7,59 @@ import Layout from './Layout'; import Spinner from './Spinner'; // Import your spinner component const PrivateRoute = ({ children }) => { - const api = useApi(); - const [isPermissionGranted, setIsPermissionGranted] = useState(false); + const api = useApi(); + const [isPermissionGranted, setIsPermissionGranted] = useState(false); const [isPermissionValue, setispermissionValue] = useState(''); - const [loading, setLoading] = useState(false); - const keystore = useLocalStorageKeystore(); - const isLoggedIn = api.isLoggedIn() && keystore.isOpen(); - - const location = useLocation(); - const navigate = useNavigate(); - - useEffect(() => { - const requestNotificationPermission = async () => { - console.log(Notification.permission); - try { - if (Notification.permission !== 'granted') { + const [loading, setLoading] = useState(false); + const keystore = useLocalStorageKeystore(); + const isLoggedIn = api.isLoggedIn() && keystore.isOpen(); + + const location = useLocation(); + const navigate = useNavigate(); + + useEffect(() => { + const requestNotificationPermission = async () => { + console.log(Notification.permission); + try { + if (Notification.permission !== 'granted') { sessionStorage.setItem('tokenSentInSession', 'false'); - const permissionResult = await Notification.requestPermission(); - if (permissionResult === 'granted') { - setIsPermissionGranted(true); - } + const permissionResult = await Notification.requestPermission(); + if (permissionResult === 'granted') { + setIsPermissionGranted(true); + } setispermissionValue(permissionResult); - } else { - setIsPermissionGranted(true); - } - } catch (error) { - console.error('Error requesting notification permission:', error); - } - }; - - if (isLoggedIn) { - requestNotificationPermission(); - } - }, [isLoggedIn,location]); + } else { + setIsPermissionGranted(true); + } + } catch (error) { + console.error('Error requesting notification permission:', error); + } + }; + + if (isLoggedIn) { + requestNotificationPermission(); + } + }, [isLoggedIn, location]); useEffect(() => { const sendFcmTokenToBackend = async () => { - console.log('isPermissionGranted:',isPermissionGranted); + console.log('isPermissionGranted:', isPermissionGranted); if (isPermissionGranted) { // Check if the token has already been sent in the current session const tokenSentInSession = sessionStorage.getItem('tokenSentInSession'); - console.log('tokenSentInSession:',tokenSentInSession); + console.log('tokenSentInSession:', tokenSentInSession); - if (tokenSentInSession==='false') { + if (tokenSentInSession === 'false') { setLoading(true); try { const fcmToken = await fetchToken(); - await api.post('/user/session/fcm_token/add', { fcm_token: fcmToken }); - // Set a flag in sessionStorage to indicate that the token has been sent - sessionStorage.setItem('tokenSentInSession', 'true'); - console.log('send FCM Token:', fcmToken); + await api.post('/user/session/fcm_token/add', { fcm_token: fcmToken }); + // Set a flag in sessionStorage to indicate that the token has been sent + sessionStorage.setItem('tokenSentInSession', 'true'); + console.log('send FCM Token:', fcmToken); console.log('FCM Token:', fcmToken); } catch (error) { @@ -74,28 +74,28 @@ const PrivateRoute = ({ children }) => { sendFcmTokenToBackend(); }, [isPermissionGranted]); - useEffect(() => { - if (!isLoggedIn) { - const destination = location.pathname + location.search; - navigate('/login', { state: { from: destination } }); - } - }, [isLoggedIn, location, navigate]); + useEffect(() => { + if (!isLoggedIn) { + const destination = location.pathname + location.search; + navigate('/login', { state: { from: destination } }); + } + }, [isLoggedIn, location, navigate]); - if (!isLoggedIn) { - return ; - } + if (!isLoggedIn) { + return ; + } return ( - <> - {loading && } - {!loading && ( - - {children} - - )} - - ); + <> + {loading && } + {!loading && ( + + {children} + + )} + + ); }; diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index a62f66859..d15add45b 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -11,21 +11,19 @@ import { Trans, useTranslation } from 'react-i18next'; const NavItem = ({ - children, - handleNavigate, - location, - path, + children, + handleNavigate, + location, + path, }) => { - return ( -
  • handleNavigate(path)} - className={`cursor-pointer flex items-center space-x-2 mb-4 p-2 rounded-r-xl ${ - location.pathname === path ? 'bg-white text-custom-blue' : 'nav-item-animate-hover' - }`} - > - {children} -
  • - ); + return ( +
  • handleNavigate(path)} + className={`cursor-pointer flex items-center space-x-2 mb-4 p-2 rounded-r-xl ${location.pathname === path ? 'bg-white text-custom-blue' : 'nav-item-animate-hover'}`} + > + {children} +
  • + ); }; @@ -33,9 +31,9 @@ const NavItem = ({ const Sidebar = ({ isOpen, toggle }) => { - const api = useApi(); + const api = useApi(); const { username, displayName } = api.getSession(); - const location=useLocation(); + const location = useLocation(); const navigate = useNavigate(); const keystore = useLocalStorageKeystore(); const { t } = useTranslation(); @@ -50,19 +48,19 @@ const Sidebar = ({ isOpen, toggle }) => { if (location.pathname === path) { window.location.reload(); } else { - navigate(path); - if (window.innerWidth <= 639) { - toggle(); - } } + navigate(path); + if (window.innerWidth <= 639) { + toggle(); + } + } }; return ( - { setShowDeletePopup(true); }} /> + { setShowDeletePopup(true); }} />
    @@ -116,7 +116,7 @@ const CredentialDetail = () => { } loading={loading} /> - )} + )} ); }; diff --git a/src/pages/Home/Home.js b/src/pages/Home/Home.js index 74fb948a1..f39070637 100644 --- a/src/pages/Home/Home.js +++ b/src/pages/Home/Home.js @@ -22,17 +22,17 @@ import FullscreenPopup from '../../components/Popups/FullscreenImg'; import DeletePopup from '../../components/Popups/DeletePopup'; const Home = () => { - const api = useApi(); - const [credentials, setCredentials] = useState([]); - const [isSmallScreen, setIsSmallScreen] = useState(window.innerWidth < 768); - const [currentSlide, setCurrentSlide] = useState(1); + const api = useApi(); + const [credentials, setCredentials] = useState([]); + const [isSmallScreen, setIsSmallScreen] = useState(window.innerWidth < 768); + const [currentSlide, setCurrentSlide] = useState(1); const [showFullscreenImgPopup, setShowFullscreenImgPopup] = useState(false); const [selectedCredential, setSelectedCredential] = useState(null); - const [showDeletePopup, setShowDeletePopup] = useState(false); - const [loading, setLoading] = useState(false); + const [showDeletePopup, setShowDeletePopup] = useState(false); + const [loading, setLoading] = useState(false); - const navigate = useNavigate(); - const sliderRef = useRef(); + const navigate = useNavigate(); + const sliderRef = useRef(); const { t } = useTranslation(); const settings = { @@ -48,17 +48,17 @@ const Home = () => { style: { margin: '0 10px' }, }; - useEffect(() => { - const handleResize = () => { - setIsSmallScreen(window.innerWidth < 768); - }; + useEffect(() => { + const handleResize = () => { + setIsSmallScreen(window.innerWidth < 768); + }; - window.addEventListener('resize', handleResize); + window.addEventListener('resize', handleResize); - return () => { - window.removeEventListener('resize', handleResize); - }; - }, []); + return () => { + window.removeEventListener('resize', handleResize); + }; + }, []); useEffect(() => { const getData = async () => { @@ -69,13 +69,13 @@ const Home = () => { getData(); }, [api]); - const handleAddCredential = () => { - navigate('/add'); - }; + const handleAddCredential = () => { + navigate('/add'); + }; - const handleImageClick = (credential) => { - navigate(`/credential/${credential.id}`); - }; + const handleImageClick = (credential) => { + navigate(`/credential/${credential.id}`); + }; // QR Code part const [isQRScannerOpen, setQRScannerOpen] = useState(false); @@ -100,41 +100,41 @@ const Home = () => { window.location.href = '/'; }; - return ( - <> -
    -
    -

    {t('common.navItemCredentials')}

    + return ( + <> +
    +
    +

    {t('common.navItemCredentials')}

    - { isSmallScreen && ( + {isSmallScreen && ( + + )} - )} - + className="px-2 py-2 mb-2 text-white bg-custom-blue hover:bg-custom-blue-hover focus:ring-4 focus:outline-none focus:ring-custom-blue font-medium rounded-lg text-sm px-4 py-2 text-center dark:bg-custom-blue-hover dark:hover:bg-custom-blue-hover dark:focus:ring-custom-blue-hover" + onClick={handleAddCredential} + > +
    + +   {t('common.navItemCredentials')} +
    +
    -
    -
    -

    {t('pageCredentials.description')}

    -
    - {isSmallScreen ? ( - <> +
    +
    +

    {t('pageCredentials.description')}

    +
    + {isSmallScreen ? ( + <> {credentials.length === 0 ? (
    { {credentials.map((credential) => ( <> -
    {setShowFullscreenImgPopup(true);setSelectedCredential(credential);}}> +
    {setShowFullscreenImgPopup(true);setSelectedCredential(credential);}}> {credential.alt}
    @@ -169,7 +169,7 @@ const Home = () => {
    - { setShowDeletePopup(true); setSelectedCredential(credential); }} /> + { setShowDeletePopup(true); setSelectedCredential(credential); }} /> @@ -178,35 +178,35 @@ const Home = () => { )} - ) : ( -
    - {credentials.map((credential) => ( -
    handleImageClick(credential)} - > - {credential.alt} -
    - ))} + ) : ( +
    + {credentials.map((credential) => (
    handleImageClick(credential)} > - add new credential -
    - - {t('pageCredentials.addCardTitle')} -
    + {credential.alt} +
    + ))} +
    + add new credential +
    + + {t('pageCredentials.addCardTitle')}
    - )} -
    -
    +
    + )} +
    +
    {/* Modal for Fullscreen credential */} {showFullscreenImgPopup && ( { {/* QR Code Scanner Modal */} {isQRScannerOpen && (
    -
    )} @@ -241,9 +241,9 @@ const Home = () => { } loading={loading} /> - )} - - ); + )} + + ); }; export default Home; diff --git a/src/pages/Login/Login.js b/src/pages/Login/Login.js index a0554b256..71ecfb2c4 100644 --- a/src/pages/Login/Login.js +++ b/src/pages/Login/Login.js @@ -88,10 +88,10 @@ const PasswordStrength = ({ label, value }) => (
    = 50 && value < 100 - ? 'bg-yellow-500' - : 'bg-green-500' + ? 'bg-red-500' + : value >= 50 && value < 100 + ? 'bg-yellow-500' + : 'bg-green-500' }`} style={{ width: `${value}%` }} >
    @@ -207,7 +207,7 @@ const WebauthnSignupLogin = ({ case 'passkeySignupPrfNotSupported': setError( resolvePrfRetryPrompt(false)} > Cancel @@ -376,7 +376,7 @@ const WebauthnSignupLogin = ({ value={name} required /> -
    +
    )} - {isLogin && cachedUsers?.length > 0 && } + {isLogin && cachedUsers?.length > 0 && } + className="px-2 py-2 mb-2 text-white bg-custom-blue hover:bg-custom-blue-hover focus:ring-4 focus:outline-none focus:ring-custom-blue font-medium rounded-lg text-sm px-4 py-2 text-center dark:bg-custom-blue-hover dark:hover:bg-custom-blue-hover dark:focus:ring-custom-blue-hover" + onClick={openQRScanner} // Open the QR code scanner modal + > +
    + +
    + )} -
    -
    -

    {t('pageSendCredentials.description')}

    - -
    - -
    - - {filteredVerifiers.length === 0 ? ( -

    {t('pageSendCredentials.noFound')}

    - ) : ( -
      - {filteredVerifiers.map((verifier) => ( -
    • handleVerifierClick(verifier.did)} - > -
      -
    • - ))} -
    - )} -
    +
    +
    +

    {t('pageSendCredentials.description')}

    + +
    + +
    + + {filteredVerifiers.length === 0 ? ( +

    {t('pageSendCredentials.noFound')}

    + ) : ( +
      + {filteredVerifiers.map((verifier) => ( +
    • handleVerifierClick(verifier.did)} + > +
      +
    • + ))} +
    + )} +
    {showRedirectPopup && ( { onClose={closeQRScanner} />
    - )} - - ); + )} + + ); }; export default Verifiers; diff --git a/src/pages/VerificationResult/VerificationResult.js b/src/pages/VerificationResult/VerificationResult.js index f0f7ff8ca..d3a774116 100644 --- a/src/pages/VerificationResult/VerificationResult.js +++ b/src/pages/VerificationResult/VerificationResult.js @@ -2,16 +2,16 @@ import React from 'react'; import { FaCheckCircle } from 'react-icons/fa'; const VerificationResult = () => { - return ( - <> -
    - -

    - Verification Successful! -

    -
    - - ); + return ( + <> +
    + +

    + Verification Successful! +

    +
    + + ); }; export default VerificationResult; diff --git a/src/util.ts b/src/util.ts index deadcacaa..6a417d799 100644 --- a/src/util.ts +++ b/src/util.ts @@ -44,7 +44,7 @@ function replacerUint8ArrayToTaggedBase64Url(key: string, value: any): any { } export function jsonStringifyTaggedBinary(value: any): string { - return JSON.stringify(value, replacerUint8ArrayToTaggedBase64Url); + return JSON.stringify(value, replacerUint8ArrayToTaggedBase64Url); } function reviverTaggedBinaryToUint8Array(key: string, value: any): any { @@ -56,7 +56,7 @@ function reviverTaggedBinaryToUint8Array(key: string, value: any): any { } export function jsonParseTaggedBinary(json: string): any { - return JSON.parse(json, reviverTaggedBinaryToUint8Array); + return JSON.parse(json, reviverTaggedBinaryToUint8Array); } export function compareBy(f: (v: T) => U): (a: T, b: T) => number { From 3b7b0f6d8ae71f1ef835b102139eebafd215937c Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Wed, 6 Mar 2024 16:26:18 +0100 Subject: [PATCH 8/8] Fix indentation --- src/pages/Home/CredentialDetail.js | 28 ++++++++-------- src/pages/Home/Home.js | 2 +- src/pages/NotFound/NotFound.js | 54 +++++++++++++++--------------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/pages/Home/CredentialDetail.js b/src/pages/Home/CredentialDetail.js index a80dc6ebd..295087e50 100644 --- a/src/pages/Home/CredentialDetail.js +++ b/src/pages/Home/CredentialDetail.js @@ -67,9 +67,9 @@ const CredentialDetail = () => { {/* Block 1: credential */}
    {credential && credential.src ? ( - // Open the modal when the credential is clicked -
    setShowFullscreenImgPopup(true)}> - {credential.alt} + // Open the modal when the credential is clicked +
    setShowFullscreenImgPopup(true)}> + {credential.alt}
    ) : ( @@ -105,17 +105,17 @@ const CredentialDetail = () => { {showDeletePopup && credential && ( setShowDeletePopup(false)} - message={ - - {t('pageCredentials.deletePopup.messagePart1')}{' '} {credential.type.replace(/([A-Z])/g, ' $1')} {t('pageCredentials.deletePopup.messagePart2')} -
    {t('pageCredentials.deletePopup.messagePart3')}{' '} {t('pageCredentials.deletePopup.messagePart4')} -
    - } - loading={loading} - /> + isOpen={showDeletePopup} + onConfirm={handleSureDelete} + onCancel={() => setShowDeletePopup(false)} + message={ + + {t('pageCredentials.deletePopup.messagePart1')}{' '} {credential.type.replace(/([A-Z])/g, ' $1')} {t('pageCredentials.deletePopup.messagePart2')} +
    {t('pageCredentials.deletePopup.messagePart3')}{' '} {t('pageCredentials.deletePopup.messagePart4')} +
    + } + loading={loading} + /> )} ); diff --git a/src/pages/Home/Home.js b/src/pages/Home/Home.js index f39070637..024479c76 100644 --- a/src/pages/Home/Home.js +++ b/src/pages/Home/Home.js @@ -237,7 +237,7 @@ const Home = () => { {t('pageCredentials.deletePopup.messagePart1')}{' '} {selectedCredential.type.replace(/([A-Z])/g, ' $1')} {t('pageCredentials.deletePopup.messagePart2')}
    {t('pageCredentials.deletePopup.messagePart3')}{' '} {t('pageCredentials.deletePopup.messagePart4')} -
    + } loading={loading} /> diff --git a/src/pages/NotFound/NotFound.js b/src/pages/NotFound/NotFound.js index ea7003967..253e6e5bf 100644 --- a/src/pages/NotFound/NotFound.js +++ b/src/pages/NotFound/NotFound.js @@ -20,36 +20,36 @@ const NotFound = () => { }, 0); }, []); - return( -
    - -
    - - logo - -

    - {t('common.walletName')} -

    -
    -
    -

    - {t('notFound.title')} -

    + return ( +
    + +
    + + logo + +

    + {t('common.walletName')} +

    +
    +
    +

    + {t('notFound.title')} +

    -

    - {t('notFound.message')} -

    - +

    + {t('notFound.message')} +

    + +
    -
    - -
    + + ); };