diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml index ad421fd04..cc98c4355 100644 --- a/app/android/app/src/main/AndroidManifest.xml +++ b/app/android/app/src/main/AndroidManifest.xml @@ -1,35 +1,38 @@ - - - - - - - - - - - + + + + + + + - + + + + - + + + diff --git a/app/android/app/src/main/java/bc/gov/invasivesbc/AuthBridge.java b/app/android/app/src/main/java/bc/gov/invasivesbc/AuthBridge.java index 94d33f2c6..0c4a8a9f0 100644 --- a/app/android/app/src/main/java/bc/gov/invasivesbc/AuthBridge.java +++ b/app/android/app/src/main/java/bc/gov/invasivesbc/AuthBridge.java @@ -3,6 +3,7 @@ import android.content.Intent; import android.net.Uri; +import android.util.Log; import androidx.activity.result.ActivityResult; import androidx.activity.result.ActivityResultLauncher; @@ -39,10 +40,17 @@ private void initAuthService() { @ActivityCallback() public void authCompleteCallback(PluginCall call, ActivityResult result) { + Log.d("auth", "authcomplete callback"); AuthorizationResponse authorizationResponse = AuthorizationResponse.fromIntent(result.getData()); AuthorizationException authorizationException = AuthorizationException.fromIntent(result.getData()); authState.update(authorizationResponse, authorizationException); + + if (authorizationException != null) { + Log.e("auth", authorizationException.toJsonString()); + } + + if (authorizationResponse == null) { JSObject r = new JSObject(); r.put("authorized", false); @@ -79,6 +87,7 @@ public void token(PluginCall call) { JSObject ret = new JSObject(); ret.put("error", "no authstate"); call.resolve(ret); + Log.e("auth", "no authstate"); return; } this.authState.performActionWithFreshTokens(authService, new AuthState.AuthStateAction() { @@ -87,6 +96,7 @@ public void execute(@Nullable String accessToken, @Nullable String idToken, @Nul if (ex != null) { JSObject ret = new JSObject(); ret.put("error", "error obtaining tokens"); + Log.e("auth", "error obtaining tokens"); call.resolve(ret); return; } @@ -101,6 +111,7 @@ public void execute(@Nullable String accessToken, @Nullable String idToken, @Nul @PluginMethod() public void authStart(PluginCall call) { + if (this.authService == null) { initAuthService(); } @@ -116,7 +127,8 @@ public void authStart(PluginCall call) { "invasives-bc-4565", ResponseTypeValues.CODE, Uri.parse("invasivesbc://callback") - ).build(); + ).setScopes("openid") + .build(); Intent authIntent = authService.getAuthorizationRequestIntent(req); @@ -126,15 +138,22 @@ public void authStart(PluginCall call) { @PluginMethod() public void authStatus(PluginCall call) { + if (this.authState == null) { + Log.e("auth", "no authstate"); + JSObject ret = new JSObject(); ret.put("error", "no authstate"); call.resolve(ret); + return; } JSObject ret = new JSObject(); ret.put("authorized", this.authState.isAuthorized()); + + Log.d("auth", "authstate: " + this.authState.isAuthorized()); + call.resolve(ret); } diff --git a/app/package-lock.json b/app/package-lock.json index 6f966871e..d3782dfd0 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -18,7 +18,6 @@ "@capacitor/core": "^6.1.2", "@capacitor/geolocation": "^6.0.1", "@capacitor/ios": "^6.1.2", - "@ionic/pwa-elements": "^3.3.0", "@mapbox/mapbox-gl-draw": "^1.5.0", "@mui/icons-material": "^5.16.7", "@mui/material": "^5.16.7", @@ -83,10 +82,7 @@ "typescript": "5.5.4", "urlencode": "^2.0.0", "uuid": "^9.0.1", - "wkt": "^0.1.1", - "workbox-precaching": "^7.1.0", - "workbox-strategies": "^7.1.0", - "workbox-window": "^7.1.0" + "wkt": "^0.1.1" }, "devDependencies": { "@capacitor/assets": "^3.0.5", @@ -3252,16 +3248,6 @@ "node": ">=16.0.0" } }, - "node_modules/@ionic/pwa-elements": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@ionic/pwa-elements/-/pwa-elements-3.3.0.tgz", - "integrity": "sha512-vbykpxd2nGRlA67AnqDwsiVf8PUmInLyi6lQdnPDjeiML1WZa0CPe6r632nGDV9PTi+sWNde9Xexg9SD6Pwyqw==", - "license": "MIT", - "engines": { - "node": ">=16.0.0", - "npm": ">=8.0.0" - } - }, "node_modules/@ionic/utils-array": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/@ionic/utils-array/-/utils-array-2.1.6.tgz", @@ -8131,6 +8117,7 @@ "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "dev": true, "license": "MIT" }, "node_modules/@types/use-sync-external-store": { @@ -25808,6 +25795,7 @@ "version": "7.3.0", "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-7.3.0.tgz", "integrity": "sha512-Z+mYrErfh4t3zi7NVTvOuACB0A/jA3bgxUN3PwtAVHvfEsZxV9Iju580VEETug3zYJRc0Dmii/aixI/Uxj8fmw==", + "dev": true, "license": "MIT" }, "node_modules/workbox-expiration": { @@ -25848,6 +25836,7 @@ "version": "7.3.0", "resolved": "https://registry.npmjs.org/workbox-precaching/-/workbox-precaching-7.3.0.tgz", "integrity": "sha512-ckp/3t0msgXclVAYaNndAGeAoWQUv7Rwc4fdhWL69CCAb2UHo3Cef0KIUctqfQj1p8h6aGyz3w8Cy3Ihq9OmIw==", + "dev": true, "license": "MIT", "dependencies": { "workbox-core": "7.3.0", @@ -25884,6 +25873,7 @@ "version": "7.3.0", "resolved": "https://registry.npmjs.org/workbox-routing/-/workbox-routing-7.3.0.tgz", "integrity": "sha512-ZUlysUVn5ZUzMOmQN3bqu+gK98vNfgX/gSTZ127izJg/pMMy4LryAthnYtjuqcjkN4HEAx1mdgxNiKJMZQM76A==", + "dev": true, "license": "MIT", "dependencies": { "workbox-core": "7.3.0" @@ -25893,6 +25883,7 @@ "version": "7.3.0", "resolved": "https://registry.npmjs.org/workbox-strategies/-/workbox-strategies-7.3.0.tgz", "integrity": "sha512-tmZydug+qzDFATwX7QiEL5Hdf7FrkhjaF9db1CbB39sDmEZJg3l9ayDvPxy8Y18C3Y66Nrr9kkN1f/RlkDgllg==", + "dev": true, "license": "MIT", "dependencies": { "workbox-core": "7.3.0" @@ -25920,6 +25911,7 @@ "version": "7.3.0", "resolved": "https://registry.npmjs.org/workbox-window/-/workbox-window-7.3.0.tgz", "integrity": "sha512-qW8PDy16OV1UBaUNGlTVcepzrlzyzNW/ZJvFQQs2j2TzGsg6IKjcpZC1RSquqQnTOafl5pCj5bGfAHlCjOOjdA==", + "dev": true, "license": "MIT", "dependencies": { "@types/trusted-types": "^2.0.2", diff --git a/app/package.json b/app/package.json index e22213a24..19b7b140a 100644 --- a/app/package.json +++ b/app/package.json @@ -22,7 +22,6 @@ "@capacitor/core": "^6.1.2", "@capacitor/geolocation": "^6.0.1", "@capacitor/ios": "^6.1.2", - "@ionic/pwa-elements": "^3.3.0", "@mapbox/mapbox-gl-draw": "^1.5.0", "@mui/icons-material": "^5.16.7", "@mui/material": "^5.16.7", @@ -87,10 +86,7 @@ "typescript": "5.5.4", "urlencode": "^2.0.0", "uuid": "^9.0.1", - "wkt": "^0.1.1", - "workbox-precaching": "^7.1.0", - "workbox-strategies": "^7.1.0", - "workbox-window": "^7.1.0" + "wkt": "^0.1.1" }, "devDependencies": { "@capacitor/assets": "^3.0.5", diff --git a/app/src/main.tsx b/app/src/main.tsx index 4e51e5180..03f78510b 100644 --- a/app/src/main.tsx +++ b/app/src/main.tsx @@ -4,7 +4,6 @@ import { Router } from 'react-router-dom'; import setupStore, { historySingleton } from 'state/store'; import { PersistGate } from 'redux-persist/integration/react'; import App from './UI/App'; -import { defineCustomElements as pwaLoader } from '@ionic/pwa-elements/loader'; import { PersistorContext } from 'utils/PersistorContext'; import { TileCacheService } from 'utils/tile-cache'; import { Context, TileCacheServiceFactory } from 'utils/tile-cache/context'; @@ -12,12 +11,6 @@ import { MOBILE } from 'state/build-time-config'; import TileCache from 'state/actions/cache/TileCache'; import { RecordCacheServiceFactory } from 'utils/record-cache/context'; -if ('serviceWorker' in navigator) { - navigator.serviceWorker.register(import.meta.env.MODE === 'production' ? '/worker.js' : '/dev-sw.js?dev-sw', { - type: import.meta.env.MODE === 'production' ? 'classic' : 'module' - }); -} - async function mountApp(CONFIG) { const { store, persistor } = setupStore(CONFIG); @@ -50,8 +43,6 @@ async function mountApp(CONFIG) { ); } - - pwaLoader(window); } } diff --git a/app/src/worker.ts b/app/src/worker.ts deleted file mode 100644 index 8ef95ec32..000000000 --- a/app/src/worker.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching'; -import { registerRoute, Route } from 'workbox-routing'; -import { NetworkFirst } from 'workbox-strategies'; -import { ExpirationPlugin } from 'workbox-expiration'; -import { CacheableResponsePlugin } from 'workbox-cacheable-response'; - -self.__WB_DISABLE_DEV_LOGS = true; - -cleanupOutdatedCaches(); - -// this value is injected by vite -precacheAndRoute(self.__WB_MANIFEST); - -const apiDocs = new Route( - ({ request, sameOrigin }) => { - return request.url.includes(`/api/api-docs`); - }, - new NetworkFirst({ - cacheName: 'api-docs', - networkTimeoutSeconds: 10, - matchOptions: { - ignoreSearch: false, - ignoreVary: false - }, - plugins: [ - new ExpirationPlugin({ - maxAgeSeconds: 3600 * 24 * 3 // 3 days - }), - new CacheableResponsePlugin({ - statuses: [200] - }) - ] - }) -); - -// Register the new route -registerRoute(apiDocs); diff --git a/app/vite.config.ts b/app/vite.config.ts index 8b7780320..985787ff9 100644 --- a/app/vite.config.ts +++ b/app/vite.config.ts @@ -5,7 +5,6 @@ import tsconfigPaths from 'vite-tsconfig-paths'; import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'; import rollupNodePolyFill from 'rollup-plugin-node-polyfills'; import { visualizer } from 'rollup-plugin-visualizer'; -import { VitePWA } from 'vite-plugin-pwa'; // sets up constants in the code, based on build environment function buildSpecificDefines() { @@ -117,21 +116,6 @@ export default defineConfig({ // Use React plugin in all *.jsx and *.tsx files include: '**/*.{jsx,tsx}', ...reactDevOptions() - }), - VitePWA({ - srcDir: '.', - filename: 'worker.ts', - strategies: 'injectManifest', - injectRegister: false, - //manifest: true, - injectManifest: { - maximumFileSizeToCacheInBytes: 20 * 1024 * 1024, - globPatterns: ['**/*.{js,css,svg,gif,png,jpg}'] - }, - devOptions: { - enabled: true, - type: 'module' - } }) ], optimizeDeps: {