From a86e76991b4b20d8e50f90005a9a04f99878f2e3 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 15 Aug 2023 09:18:32 -0400 Subject: [PATCH 1/9] feat: add iframe message listener --- package.json | 2 +- src/components/blocks/MyAccount.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index cd1c8f19..5fa74f20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cadt-ui", - "version": "1.2.4", + "version": "1.2.5", "private": true, "author": "Chia Network Inc. ", "homepage": "./", diff --git a/src/components/blocks/MyAccount.js b/src/components/blocks/MyAccount.js index 9c7ea4fc..f6d5ed38 100644 --- a/src/components/blocks/MyAccount.js +++ b/src/components/blocks/MyAccount.js @@ -57,6 +57,34 @@ const MyAccount = ({ openModal = false, onClose, isHeader = true }) => { } }, []); + useEffect(() => { + // Sign in from iframe + window.addEventListener( + 'message', + event => { + if (event.origin !== window.location.origin) { + return; + } + console.log('Received message:', event.data); + if ( + event?.data?.serverAddress && + validateUrl(event?.data?.serverAddress) + ) { + dispatch( + signIn({ + apiKey: event?.data?.apiKey, + serverAddress: event?.data?.serverAddress, + }), + ); + setServerAddress(null); + setApiKey(null); + setIsLogInModalOpen(false); + } + }, + false, + ); + }, []); + return ( {isHeader && ( From 4b220a6983064583eedde1751db891857c724da5 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 15 Aug 2023 09:42:43 -0400 Subject: [PATCH 2/9] fix: clean up listener --- src/components/blocks/MyAccount.js | 55 ++++++++++++++++-------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/components/blocks/MyAccount.js b/src/components/blocks/MyAccount.js index f6d5ed38..3bc35a55 100644 --- a/src/components/blocks/MyAccount.js +++ b/src/components/blocks/MyAccount.js @@ -58,31 +58,36 @@ const MyAccount = ({ openModal = false, onClose, isHeader = true }) => { }, []); useEffect(() => { - // Sign in from iframe - window.addEventListener( - 'message', - event => { - if (event.origin !== window.location.origin) { - return; - } - console.log('Received message:', event.data); - if ( - event?.data?.serverAddress && - validateUrl(event?.data?.serverAddress) - ) { - dispatch( - signIn({ - apiKey: event?.data?.apiKey, - serverAddress: event?.data?.serverAddress, - }), - ); - setServerAddress(null); - setApiKey(null); - setIsLogInModalOpen(false); - } - }, - false, - ); + // Function to handle the message event + const handleMessage = event => { + if (event.origin !== window.location.origin) { + return; + } + console.log('Received message:', event.data); + if ( + event?.data?.serverAddress && + validateUrl(event?.data?.serverAddress) + ) { + dispatch( + signIn({ + apiKey: event?.data?.apiKey, + serverAddress: event?.data?.serverAddress, + }), + ); + setServerAddress(null); + setApiKey(null); + setIsLogInModalOpen(false); + } + }; + + // Add the event listener + window.addEventListener('message', handleMessage, false); + + // Return a function that will be called when the component unmounts + return () => { + // Remove the event listener + window.removeEventListener('message', handleMessage, false); + }; }, []); return ( From c729618b9ec2efc510a1d863d91be3fc81f7f20a Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 10:46:09 -0500 Subject: [PATCH 3/9] Update to digicert hsm signing --- .github/workflows/build-installers.yaml | 469 ++++++++++++------------ 1 file changed, 241 insertions(+), 228 deletions(-) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 1bd02058..ec88f6ea 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -1,228 +1,241 @@ -name: Build & Release - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }} - cancel-in-progress: true - -jobs: - build_mac: - name: Build Mac Installer - runs-on: macos-latest - steps: - - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: install dmg-license - run: npm i dmg-license - - - name: npm install - run: | - node --version - npm install - - - name: Import Apple installer signing certificate - uses: Apple-Actions/import-codesign-certs@v1 - with: - p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }} - p12-password: ${{ secrets.APPLE_DEV_ID_APP_PASS }} - - - name: Build electron app - env: - CSC_FOR_PULL_REQUEST: "true" - run: npm run electron:package:mac - - - name: Notarize - run: | - DMG_FILE=$(find ${{ github.workspace }}/dist/ -type f -name '*.dmg') - npm install -g notarize-cli - notarize-cli \ - --file="$DMG_FILE" \ - --bundle-id net.chia.cadt-ui \ - --username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \ - --password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}" - - - name: Upload Mac Installer - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-mac-installer - path: ${{ github.workspace }}/dist/*.dmg - - build_windows: - name: Build Windows Installer - runs-on: windows-2019 - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: Ignore Husky where not compatible - run: npm pkg delete scripts.prepare - - - name: npm install - run: | - node --version - npm install - - - name: Build electron app - env: - CSC_LINK: ${{ secrets.WIN_CODE_SIGN_CERT }} - CSC_KEY_PASSWORD: ${{ secrets.WIN_CODE_SIGN_PASSWORD }} - run: npm run electron:package:win - - - name: Upload Windows Installer - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-windows-installer - path: ${{ github.workspace }}/dist/*.exe - - build_linux: - name: Build Linux Installer - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: npm install - run: | - node --version - npm install - - - name: Build electron app - run: npm run electron:package:linux - - - name: Rename Linux installer to be standard format for apt - run: | - ORIGINAL=$(ls dist/*.deb) - MODIFIED=${ORIGINAL:0:-10}-1${ORIGINAL#${ORIGINAL:0:-10}} - mv $ORIGINAL $MODIFIED - - - name: Upload Linux Installer - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-linux-installer - path: ${{ github.workspace }}/dist/*.deb - - build_web: - name: Build CADT UI Web App - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: npm install and build - run: | - node --version - npm install - npm run build - - - name: Create .tar.gz of the web build - run: tar -cvzf cadt-ui-web-build.tar.gz build - - - name: Upload build artifact - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-web-build - path: cadt-ui-web-build.tar.gz - - release: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - needs: - - build_mac - - build_windows - - build_linux - - build_web - steps: - - name: Download Windows artifacts - uses: actions/download-artifact@v3 - with: - name: cadt-ui-windows-installer - path: cadt-ui-windows-installer - - - name: Download MacOS artifacts - uses: actions/download-artifact@v3 - with: - name: cadt-ui-mac-installer - path: cadt-ui-mac-installer - - - name: Download Linux artifacts - uses: actions/download-artifact@v3 - with: - name: cadt-ui-linux-installer - path: cadt-ui-linux-installer - - - name: Download Web artifact - uses: actions/download-artifact@v3 - with: - name: cadt-ui-web-build - path: cadt-ui-web-build - - - name: Get Filenames - run: | - DMG_FILE=$(find ${{ github.workspace }}/cadt-ui-mac-installer/ -type f -name '*.dmg') - DEB_FILE=$(find ${{ github.workspace }}/cadt-ui-linux-installer/ -type f -name '*.deb') - EXE_FILE=$(find ${{ github.workspace }}/cadt-ui-windows-installer/ -type f -name '*.exe') - WEB_FILE=$(find ${{ github.workspace }}/cadt-ui-web-build/ -type f -name '*.tar.gz') - - echo "DMG_FILE=$DMG_FILE" >>$GITHUB_ENV - echo "DEB_FILE=$DEB_FILE" >>$GITHUB_ENV - echo "EXE_FILE=$EXE_FILE" >>$GITHUB_ENV - echo "WEB_FILE=$WEB_FILE" >>$GITHUB_ENV - - - name: Release - uses: softprops/action-gh-release@v0.1.15 - with: - files: | - ${{ env.DMG_FILE }} - ${{ env.DEB_FILE }} - ${{ env.EXE_FILE }} - ${{ env.WEB_FILE }} - - - name: Trigger apt repo update - run: | - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy +name: Build & Release + +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' + +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }} + cancel-in-progress: true + +jobs: + build_mac: + name: Build Mac Installer + runs-on: macos-latest + steps: + - uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: install dmg-license + run: npm i dmg-license + + - name: npm install + run: | + node --version + npm install + + - name: Import Apple installer signing certificate + uses: Apple-Actions/import-codesign-certs@v1 + with: + p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }} + p12-password: ${{ secrets.APPLE_DEV_ID_APP_PASS }} + + - name: Build electron app + env: + CSC_FOR_PULL_REQUEST: "true" + run: npm run electron:package:mac + + - name: Notarize + run: | + DMG_FILE=$(find ${{ github.workspace }}/dist/ -type f -name '*.dmg') + npm install -g notarize-cli + notarize-cli \ + --file="$DMG_FILE" \ + --bundle-id net.chia.cadt-ui \ + --username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \ + --password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}" + + - name: Upload Mac Installer + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-mac-installer + path: ${{ github.workspace }}/dist/*.dmg + + build_windows: + name: Build Windows Installer + runs-on: windows-2019 + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: Ignore Husky where not compatible + run: npm pkg delete scripts.prepare + + - name: npm install + run: | + node --version + npm install + + - name: Build electron app + run: npm run electron:package:win + + # Windows Code Signing + - name: Get installer name for signing + run: | + FILE=$(find dist -type f -name '*.exe') + echo "Installer file is $FILE" + echo "INSTALLER_FILE=$FILE" >> "$GITHUB_ENV" + + - name: Sign windows artifacts + uses: chia-network/actions/digicert/windows-sign@main + with: + sm_api_key: ${{ secrets.SM_API_KEY }} + sm_client_cert_file_b64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }} + sm_client_cert_password: ${{ secrets.SM_CLIENT_CERT_PASSWORD }} + sm_code_signing_cert_sha1_hash: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} + file: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + + - name: Upload Windows Installer + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-windows-installer + path: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + + build_linux: + name: Build Linux Installer + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: npm install + run: | + node --version + npm install + + - name: Build electron app + run: npm run electron:package:linux + + - name: Rename Linux installer to be standard format for apt + run: | + ORIGINAL=$(ls dist/*.deb) + MODIFIED=${ORIGINAL:0:-10}-1${ORIGINAL#${ORIGINAL:0:-10}} + mv $ORIGINAL $MODIFIED + + - name: Upload Linux Installer + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-linux-installer + path: ${{ github.workspace }}/dist/*.deb + + build_web: + name: Build CADT UI Web App + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: npm install and build + run: | + node --version + npm install + npm run build + + - name: Create .tar.gz of the web build + run: tar -cvzf cadt-ui-web-build.tar.gz build + + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-web-build + path: cadt-ui-web-build.tar.gz + + release: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + needs: + - build_mac + - build_windows + - build_linux + - build_web + steps: + - name: Download Windows artifacts + uses: actions/download-artifact@v3 + with: + name: cadt-ui-windows-installer + path: cadt-ui-windows-installer + + - name: Download MacOS artifacts + uses: actions/download-artifact@v3 + with: + name: cadt-ui-mac-installer + path: cadt-ui-mac-installer + + - name: Download Linux artifacts + uses: actions/download-artifact@v3 + with: + name: cadt-ui-linux-installer + path: cadt-ui-linux-installer + + - name: Download Web artifact + uses: actions/download-artifact@v3 + with: + name: cadt-ui-web-build + path: cadt-ui-web-build + + - name: Get Filenames + run: | + DMG_FILE=$(find ${{ github.workspace }}/cadt-ui-mac-installer/ -type f -name '*.dmg') + DEB_FILE=$(find ${{ github.workspace }}/cadt-ui-linux-installer/ -type f -name '*.deb') + EXE_FILE=$(find ${{ github.workspace }}/cadt-ui-windows-installer/ -type f -name '*.exe') + WEB_FILE=$(find ${{ github.workspace }}/cadt-ui-web-build/ -type f -name '*.tar.gz') + + echo "DMG_FILE=$DMG_FILE" >>$GITHUB_ENV + echo "DEB_FILE=$DEB_FILE" >>$GITHUB_ENV + echo "EXE_FILE=$EXE_FILE" >>$GITHUB_ENV + echo "WEB_FILE=$WEB_FILE" >>$GITHUB_ENV + + - name: Release + uses: softprops/action-gh-release@v0.1.15 + with: + files: | + ${{ env.DMG_FILE }} + ${{ env.DEB_FILE }} + ${{ env.EXE_FILE }} + ${{ env.WEB_FILE }} + + - name: Trigger apt repo update + run: | + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy From 29e8aeda4a7b60b03499f56d04b11a91e54e51bc Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 10:48:20 -0500 Subject: [PATCH 4/9] Run the find in bash --- .github/workflows/build-installers.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index ec88f6ea..6cb85b11 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -96,6 +96,7 @@ jobs: # Windows Code Signing - name: Get installer name for signing + shell: bash run: | FILE=$(find dist -type f -name '*.exe') echo "Installer file is $FILE" From 0fb304afcc252cf97a0b145da11f479474ed0bfb Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 10:54:49 -0500 Subject: [PATCH 5/9] Fix find command to just find the installer, not the other exes in subdirs --- .github/workflows/build-installers.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 6cb85b11..4eb84d1b 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -98,7 +98,7 @@ jobs: - name: Get installer name for signing shell: bash run: | - FILE=$(find dist -type f -name '*.exe') + FILE=$(find dist -type f -maxdepth 1 -name '*.exe') echo "Installer file is $FILE" echo "INSTALLER_FILE=$FILE" >> "$GITHUB_ENV" From ab211dcb5fa8b80df2968f37a3e43f2ba3d28a03 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 11:06:43 -0500 Subject: [PATCH 6/9] Try quoting file for signing --- .github/workflows/build-installers.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 4eb84d1b..b3df4fc2 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -109,13 +109,13 @@ jobs: sm_client_cert_file_b64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }} sm_client_cert_password: ${{ secrets.SM_CLIENT_CERT_PASSWORD }} sm_code_signing_cert_sha1_hash: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} - file: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + file: "${{ github.workspace }}/${{ env.INSTALLER_FILE }}" - name: Upload Windows Installer uses: actions/upload-artifact@v3 with: name: cadt-ui-windows-installer - path: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + path: "${{ github.workspace }}/${{ env.INSTALLER_FILE }}" build_linux: name: Build Linux Installer From 1e80d442f074aa4041778f6bfe4de75cc88d4d38 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Wed, 16 Aug 2023 11:07:44 -0400 Subject: [PATCH 7/9] feat: hide connect --- src/components/layout/Header.js | 2 +- src/navigation/AppNavigator.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/layout/Header.js b/src/components/layout/Header.js index 48812a16..4d08bb16 100644 --- a/src/components/layout/Header.js +++ b/src/components/layout/Header.js @@ -57,7 +57,7 @@ const Header = () => { )} - + {window.self === window.top && } diff --git a/src/navigation/AppNavigator.js b/src/navigation/AppNavigator.js index 83842b8d..52207288 100644 --- a/src/navigation/AppNavigator.js +++ b/src/navigation/AppNavigator.js @@ -46,7 +46,7 @@ const AppNavigator = () => { return ( {showProgressOverlay && } - {!connectionCheck ? ( + {!connectionCheck && window.self === window.top ? ( dispatch(getOrganizationData())} From 0d890cddecb6d8758ca00633ae204896774871a7 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Wed, 16 Aug 2023 15:01:27 -0400 Subject: [PATCH 8/9] feat: hide header when in iframe --- src/components/layout/Dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/layout/Dashboard.js b/src/components/layout/Dashboard.js index 1f46ddf5..7f7a97c7 100644 --- a/src/components/layout/Dashboard.js +++ b/src/components/layout/Dashboard.js @@ -36,7 +36,7 @@ const InnerContainer = styled('div')` const Dashboard = withTheme(({ children }) => { return (
-
+ {window.self === window.top &&
} From 5c31d3c5a0f800ca9f6d73d1cc35cc649189812c Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 17 Aug 2023 11:35:49 -0400 Subject: [PATCH 9/9] feat: namespace localstorage keys --- package-lock.json | 4 ++-- src/store/actions/app.js | 12 ++++++------ src/store/actions/climateWarehouseActions.js | 2 +- src/utils/urlUtils.js | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1a5f33f..db6d5e4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cadt-ui", - "version": "1.2.4", + "version": "1.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cadt-ui", - "version": "1.2.4", + "version": "1.2.5", "hasInstallScript": true, "dependencies": { "@date-io/dayjs": "^2.16.0", diff --git a/src/store/actions/app.js b/src/store/actions/app.js index bc7c2ef3..7722c33f 100644 --- a/src/store/actions/app.js +++ b/src/store/actions/app.js @@ -129,11 +129,11 @@ export const setNotificationMessage = (type, id) => { export const signIn = ({ apiKey, serverAddress }) => { return async dispatch => { if (serverAddress) { - localStorage.setItem('serverAddress', serverAddress); + localStorage.setItem('cadtRemoteServerAddress', serverAddress); let payload = { serverAddress }; if (apiKey) { - localStorage.setItem('apiKey', apiKey); + localStorage.setItem('cadtRemoteServerApiKey', apiKey); payload = { ...payload, apiKey }; } @@ -149,8 +149,8 @@ export const signIn = ({ apiKey, serverAddress }) => { export const signOut = () => { return async dispatch => { - localStorage.removeItem('apiKey'); - localStorage.removeItem('serverAddress'); + localStorage.removeItem('cadtRemoteServerApiKey'); + localStorage.removeItem('cadtRemoteServerAddress'); dispatch({ type: actions.SIGN_USER_OUT, payload: { @@ -163,8 +163,8 @@ export const signOut = () => { export const signInFromLocalStorage = () => { return async dispatch => { - const apiKey = localStorage.getItem('apiKey'); - const serverAddress = localStorage.getItem('serverAddress'); + const apiKey = localStorage.getItem('cadtRemoteServerApiKey'); + const serverAddress = localStorage.getItem('cadtRemoteServerAddress'); if (serverAddress) { let payload = { serverAddress }; diff --git a/src/store/actions/climateWarehouseActions.js b/src/store/actions/climateWarehouseActions.js index c625a404..4dd0ca17 100644 --- a/src/store/actions/climateWarehouseActions.js +++ b/src/store/actions/climateWarehouseActions.js @@ -2539,7 +2539,7 @@ export const getVintages = options => { // TODO to replace with an extended wrapper that also adds try catch finally and also handles network connection and progress indicator dispatches const fetchWrapper = async (url, payload) => { - const apiKey = localStorage.getItem('apiKey'); + const apiKey = localStorage.getItem('cadtRemoteServerApiKey'); url = overrideURL(url); diff --git a/src/utils/urlUtils.js b/src/utils/urlUtils.js index aa8a5060..56f50d88 100644 --- a/src/utils/urlUtils.js +++ b/src/utils/urlUtils.js @@ -16,7 +16,7 @@ export const validateUrl = url => { }; export const overrideURL = originalUrl => { - const serverAddress = localStorage.getItem('serverAddress'); + const serverAddress = localStorage.getItem('cadtRemoteServerAddress'); // If serverAddress is valid, replace the domain of the original URL. if (serverAddress && typeof serverAddress === 'string') {