@onairosofficial/onairos-capacitor 0.1.2 → 0.1.3

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/onairos.d.ts CHANGED
@@ -402,38 +402,28 @@ declare module '@onairosofficial/onairos-capacitor' {
402
402
  // ===============================================
403
403
 
404
404
  /**
405
- * Configure Google OAuth client IDs for all platforms
406
- *
407
- * IMPORTANT FOR CAPACITOR APPS:
408
- * Capacitor apps MUST provide their own Google OAuth credentials because:
409
- * 1. Google does not allow `capacitor://` scheme in redirect URIs
410
- * 2. Google blocks OAuth in embedded WebViews (disallowed_useragent)
411
- * 3. Native apps require platform-specific client IDs (iOS bundle ID, Android package + SHA-1)
412
- *
413
- * To create your credentials:
414
- * 1. Go to Google Cloud Console (https://console.cloud.google.com)
415
- * 2. Create OAuth 2.0 credentials for each platform:
416
- * - Web application (for web browsers)
417
- * - iOS (with your bundle identifier)
418
- * - Android (with your package name and SHA-1 fingerprint)
419
- *
420
- * @param clientIds - Object containing platform-specific client IDs
421
- * @returns Updated client IDs object
422
- *
405
+ * Configure developer-owned native Google OAuth client IDs.
406
+ *
407
+ * A Capacitor build is a native app even before store publication. Create
408
+ * an iOS client for the exact bundle ID and/or an Android client for the
409
+ * exact package name and signing SHA-1.
410
+ *
411
+ * The SDK supplies the Onairos web/server OAuth client used as the ID-token
412
+ * audience. Do not pass an iOS or Android client ID as `webClientId` or
413
+ * `serverClientId`, or backend verification will fail with an audience
414
+ * mismatch. Those two fields remain optional for advanced deployments whose
415
+ * backend explicitly verifies a different web OAuth client.
416
+ *
423
417
  * @example
424
418
  * ```typescript
425
419
  * import { updateGoogleClientIds } from '@onairosofficial/onairos-capacitor';
426
- *
427
- * // For Capacitor apps - provide YOUR OWN client IDs
420
+ *
428
421
  * updateGoogleClientIds({
429
- * webClientId: 'your-web-client-id.apps.googleusercontent.com',
430
422
  * iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
431
- * androidClientId: 'your-android-client-id.apps.googleusercontent.com',
432
- * serverClientId: 'your-server-client-id.apps.googleusercontent.com' // For backend token verification
423
+ * androidClientId: 'your-android-client-id.apps.googleusercontent.com'
433
424
  * });
434
425
  * ```
435
- */
436
- export function updateGoogleClientIds(clientIds: {
426
+ */ export function updateGoogleClientIds(clientIds: {
437
427
  webClientId?: string;
438
428
  iosClientId?: string;
439
429
  androidClientId?: string;
@@ -470,7 +460,7 @@ declare module '@onairosofficial/onairos-capacitor' {
470
460
  *
471
461
  * REQUIREMENTS:
472
462
  * 1. Install @codetrix-studio/capacitor-google-auth: `npm install @codetrix-studio/capacitor-google-auth`
473
- * 2. Configure with YOUR OWN Google OAuth Client IDs
463
+ * 2. Configure with your own native iOS and/or Android OAuth client ID
474
464
  * 3. Set up native platform config (Info.plist for iOS, google-services.json for Android)
475
465
  *
476
466
  * @returns Promise with sign-in result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onairosofficial/onairos-capacitor",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "engines": {
5
5
  "node": ">=20 <26"
6
6
  },
@@ -1,13 +1,15 @@
1
+ import { DEFAULT_ONAIROS_GOOGLE_WEB_CLIENT_ID } from './utils/googleWebClientId.js';
2
+
1
3
  const pick = (value) => {
2
4
  const s = typeof value === 'string' ? value.trim() : '';
3
5
  return s && s !== 'undefined' && s !== 'null' ? s : null;
4
6
  };
5
7
 
6
8
  let googleClientIds = {
7
- webClientId: null,
9
+ webClientId: DEFAULT_ONAIROS_GOOGLE_WEB_CLIENT_ID,
8
10
  iosClientId: null,
9
11
  androidClientId: null,
10
- serverClientId: null,
12
+ serverClientId: DEFAULT_ONAIROS_GOOGLE_WEB_CLIENT_ID,
11
13
  };
12
14
 
13
15
  let youtubeClientId = null;
@@ -18,22 +20,31 @@ export const updateGoogleClientIds = (clientIds = {}) => {
18
20
  const androidClientId = pick(clientIds.androidClientId);
19
21
  const serverClientId = pick(clientIds.serverClientId);
20
22
 
23
+ // Google native clients identify the installed app, but Onairos verifies the
24
+ // ID token against the web OAuth client. Keep those concerns separate so the
25
+ // native client ID can never accidentally become the backend token audience.
26
+ const nextWebClientId =
27
+ webClientId || googleClientIds.webClientId || DEFAULT_ONAIROS_GOOGLE_WEB_CLIENT_ID;
28
+ const nextServerClientId =
29
+ serverClientId || webClientId || googleClientIds.serverClientId || nextWebClientId;
30
+
21
31
  googleClientIds = {
22
- ...googleClientIds,
23
- ...(webClientId ? { webClientId } : {}),
24
- ...(iosClientId ? { iosClientId } : {}),
25
- ...(androidClientId ? { androidClientId } : {}),
26
- ...(serverClientId ? { serverClientId } : {}),
32
+ webClientId: nextWebClientId,
33
+ iosClientId: iosClientId || googleClientIds.iosClientId,
34
+ androidClientId: androidClientId || googleClientIds.androidClientId,
35
+ serverClientId: nextServerClientId,
27
36
  };
28
37
 
29
38
  if (typeof window !== 'undefined') {
30
- if (webClientId) {
31
- window.onairosGoogleClientId = webClientId;
32
- window.onairosGoogleWebClientId = webClientId;
39
+ window.onairosGoogleClientId = googleClientIds.webClientId;
40
+ window.onairosGoogleWebClientId = googleClientIds.webClientId;
41
+ window.onairosGoogleServerClientId = googleClientIds.serverClientId;
42
+ if (googleClientIds.iosClientId) {
43
+ window.onairosGoogleIosClientId = googleClientIds.iosClientId;
44
+ }
45
+ if (googleClientIds.androidClientId) {
46
+ window.onairosGoogleAndroidClientId = googleClientIds.androidClientId;
33
47
  }
34
- if (iosClientId) window.onairosGoogleIosClientId = iosClientId;
35
- if (androidClientId) window.onairosGoogleAndroidClientId = androidClientId;
36
- if (serverClientId) window.onairosGoogleServerClientId = serverClientId;
37
48
  }
38
49
 
39
50
  return googleClientIds;
@@ -501,6 +501,8 @@ function EmailAuthComponent({ onSuccess, testMode = false, preVerifiedEmail = nu
501
501
  (typeof window !== 'undefined' && window.onairosGoogleClientId) || '';
502
502
  const iosClientId =
503
503
  (typeof window !== 'undefined' && window.onairosGoogleIosClientId) || '';
504
+ const serverClientId =
505
+ (typeof window !== 'undefined' && window.onairosGoogleServerClientId) || webClientId;
504
506
 
505
507
  if (!webClientId || !iosClientId) {
506
508
  setGoogleHint('To enable Google sign-in in this iOS app, set updateGoogleClientIds({ webClientId, iosClientId }) in the host app. Otherwise use email login.');
@@ -515,7 +517,7 @@ function EmailAuthComponent({ onSuccess, testMode = false, preVerifiedEmail = nu
515
517
  iOSClientId: iosClientId,
516
518
  // If your backend verifies tokens / you need server-side validation, set this to the web client id.
517
519
  // (Safe default here.)
518
- iOSServerClientId: webClientId,
520
+ iOSServerClientId: serverClientId,
519
521
  mode: 'online',
520
522
  },
521
523
  });
@@ -700,6 +700,8 @@ function EmailAuthComponent({
700
700
  (typeof window !== 'undefined' && window.onairosGoogleClientId) || '';
701
701
  const iosClientId =
702
702
  (typeof window !== 'undefined' && window.onairosGoogleIosClientId) || '';
703
+ const serverClientId =
704
+ (typeof window !== 'undefined' && window.onairosGoogleServerClientId) || webClientId;
703
705
 
704
706
  if (!webClientId || !iosClientId) {
705
707
  setGoogleHint('To enable Google sign-in in this iOS app, set updateGoogleClientIds({ webClientId, iosClientId }) in the host app. Otherwise use email login.');
@@ -714,7 +716,7 @@ function EmailAuthComponent({
714
716
  iOSClientId: iosClientId,
715
717
  // If your backend verifies tokens / you need server-side validation, set this to the web client id.
716
718
  // (Safe default here.)
717
- iOSServerClientId: webClientId,
719
+ iOSServerClientId: serverClientId,
718
720
  mode: 'online',
719
721
  },
720
722
  });