Skip to content

Commit

Permalink
fix idtoken issue, add largeHeap=true, delete serviceworker
Browse files Browse the repository at this point in the history
  • Loading branch information
plasticviking committed Feb 4, 2025
1 parent 4ce8ec8 commit 79c7ea3
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 112 deletions.
61 changes: 32 additions & 29 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:exported="true"
android:label="@string/title_activity_main"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBarLaunch">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- Permissions -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>

<uses-permission android:name="android.permission.INTERNET" />
<!-- Permissions -->

<uses-permission android:name="android.permission.INTERNET" />
</manifest>
21 changes: 20 additions & 1 deletion app/android/app/src/main/java/bc/gov/invasivesbc/AuthBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -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;
}
Expand All @@ -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();
}
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
22 changes: 7 additions & 15 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 0 additions & 9 deletions app/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ 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';
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);

Expand Down Expand Up @@ -50,8 +43,6 @@ async function mountApp(CONFIG) {
</PersistGate>
);
}

pwaLoader(window);
}
}

Expand Down
37 changes: 0 additions & 37 deletions app/src/worker.ts

This file was deleted.

16 changes: 0 additions & 16 deletions app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 79c7ea3

Please sign in to comment.