@bobfrankston/mailx 1.0.187 → 1.0.188

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.187",
3
+ "version": "1.0.188",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -24,7 +24,7 @@
24
24
  "@bobfrankston/iflow-node": "^0.1.2",
25
25
  "@bobfrankston/miscinfo": "^1.0.8",
26
26
  "@bobfrankston/oauthsupport": "^1.0.21",
27
- "@bobfrankston/msger": "^0.1.237",
27
+ "@bobfrankston/msger": "^0.1.238",
28
28
  "@capacitor/android": "^8.3.0",
29
29
  "@capacitor/cli": "^8.3.0",
30
30
  "@capacitor/core": "^8.3.0",
@@ -243,7 +243,8 @@ const OAUTH_CLIENT = {
243
243
  clientSecret: "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",
244
244
  authUri: "https://accounts.google.com/o/oauth2/auth",
245
245
  tokenUri: "https://oauth2.googleapis.com/token",
246
- redirectUri: "http://localhost",
246
+ // Reverse client ID scheme — auto-allowed for Google "installed" apps
247
+ redirectUri: "com.googleusercontent.apps.1067464114116-ndd19nqat8lucb0mbb0mvl7i3tbhnc43:/oauth2callback",
247
248
  };
248
249
  const OAUTH_SCOPES = "https://mail.google.com/ https://www.googleapis.com/auth/contacts.readonly https://www.googleapis.com/auth/drive.file";
249
250
  // ── Token cache (IndexedDB) ──
@@ -362,8 +363,29 @@ function createNativeTokenProvider(email) {
362
363
  };
363
364
  }
364
365
  // ── Initialization ──
366
+ async function waitForNativeBridge(timeoutMs = 5000) {
367
+ if (window._nativeBridge)
368
+ return;
369
+ return new Promise((resolve) => {
370
+ const start = Date.now();
371
+ const check = () => {
372
+ if (window._nativeBridge || Date.now() - start > timeoutMs) {
373
+ resolve();
374
+ }
375
+ else {
376
+ setTimeout(check, 50);
377
+ }
378
+ };
379
+ // Also listen for the event C# dispatches after bridge injection
380
+ window.addEventListener("nativebridgeready", () => resolve(), { once: true });
381
+ check();
382
+ });
383
+ }
365
384
  export async function initAndroid() {
366
385
  console.log("[android] Initializing mailx...");
386
+ // Wait for C# to inject the native bridge (TCP/FS/HTTP + OAuth)
387
+ await waitForNativeBridge();
388
+ console.log(`[android] Native bridge: ${window._nativeBridge ? "ready" : "timeout"}`);
367
389
  db = new WebMailxDB("mailx");
368
390
  await db.waitReady();
369
391
  bodyStore = new WebMessageStore();