@trainon-inc/capacitor-clerk-native 1.21.0 → 1.23.0

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/README.md CHANGED
@@ -49,7 +49,7 @@ Alternatively, install from GitHub Packages:
49
49
  1. Create a `.npmrc` file in your project root:
50
50
  ```
51
51
  @trainon-inc:registry=https://npm.pkg.github.com
52
- //npm.pkg.github.com/:_authToken= YOUR_GITHUB_TOKEN
52
+ //npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
53
53
  ```
54
54
 
55
55
  2. Install the package:
@@ -339,19 +339,21 @@ function Profile() {
339
339
  └─────────────────────────────────────────────────┘
340
340
  ```
341
341
 
342
- ### Android Architecture
342
+ ### Android Architecture (Web Provider)
343
343
 
344
344
  ```
345
345
  ┌─────────────────────────────────────────────────┐
346
346
  │ JavaScript/React (Capacitor WebView) │
347
- │ - Uses capacitor-clerk-native hooks
348
- └─────────────────┬───────────────────────────────┘
349
- │ Capacitor Bridge
350
- ┌─────────────────▼───────────────────────────────┐
351
- │ ClerkNativePlugin (Gradle Module) │
352
- │ - Android library module │
353
- - Receives calls from JavaScript
354
- │ - Can integrate with Clerk Android SDK
347
+ │ - Uses @clerk/clerk-react (web provider)
348
+ │ - Full Clerk functionality via web SDK │
349
+ └─────────────────────────────────────────────────┘
350
+ (No native plugin needed for auth)
351
+
352
+ ┌─────────────────────────────────────────────────┐
353
+ ClerkNativePlugin (Gradle Module) - Stub
354
+ │ - Exists for Capacitor plugin registration
355
+ │ - Returns "use web provider" for all methods │
356
+ │ - No native Clerk SDK dependency │
355
357
  └─────────────────────────────────────────────────┘
356
358
  ```
357
359
 
@@ -414,59 +416,53 @@ function Profile() {
414
416
 
415
417
  ## Android Setup
416
418
 
417
- Android is supported using the same bridge pattern as iOS. The plugin provides a stub implementation that you can extend with the Clerk Android SDK.
419
+ **Important**: On Android, this plugin provides a stub implementation. Android WebViews work well with web-based authentication (unlike iOS which has cookie issues), so **Android should use the web Clerk provider (`@clerk/clerk-react`)** instead of the native plugin.
418
420
 
419
- ### Prerequisites
420
-
421
- - ✅ A [Clerk account](https://dashboard.clerk.com/sign-up)
422
- - ✅ A Clerk application set up in the dashboard
423
- - ✅ Android Studio with Gradle 8.7+ and AGP 8.5+
421
+ ### Why Web Provider for Android?
424
422
 
425
- ### 1. Sync Capacitor
426
-
427
- After installing the plugin, sync your Android project:
428
-
429
- ```bash
430
- npx cap sync android
431
- ```
423
+ - Android WebViews handle cookies correctly - no authentication issues
424
+ - ✅ The Clerk Android SDK is still in early stages (v0.1.x) with evolving APIs
425
+ - Using `@clerk/clerk-react` provides a stable, well-tested experience
426
+ - ✅ Simpler setup - no native configuration required
432
427
 
433
- This will:
434
- - Add the plugin to `capacitor.settings.gradle`
435
- - Add the plugin dependency to `capacitor.build.gradle`
428
+ ### Recommended App Setup
436
429
 
437
- ### 2. Plugin Structure
430
+ Configure your app to use the native plugin only on iOS:
438
431
 
439
- The plugin includes:
432
+ ```typescript
433
+ import { Capacitor } from "@capacitor/core";
434
+ import { ClerkProvider as WebClerkProvider } from "@clerk/clerk-react";
435
+ import { ClerkProvider as NativeClerkProvider } from "@trainon-inc/capacitor-clerk-native";
436
+
437
+ // Use native Clerk only on iOS (due to WebView cookie issues)
438
+ // Android WebViews work fine with web Clerk
439
+ const isIOS = Capacitor.getPlatform() === "ios";
440
+ const ClerkProvider = isIOS ? NativeClerkProvider : WebClerkProvider;
441
+
442
+ export function App() {
443
+ const clerkProps = isIOS
444
+ ? { publishableKey: "pk_test_..." }
445
+ : {
446
+ publishableKey: "pk_test_...",
447
+ signInFallbackRedirectUrl: "/home",
448
+ signUpFallbackRedirectUrl: "/home",
449
+ };
440
450
 
451
+ return (
452
+ <ClerkProvider {...clerkProps}>
453
+ <YourApp />
454
+ </ClerkProvider>
455
+ );
456
+ }
441
457
  ```
442
- android/
443
- ├── build.gradle # Gradle build configuration
444
- └── src/
445
- └── main/
446
- ├── AndroidManifest.xml # Android manifest
447
- └── java/
448
- └── com/trainon/capacitor/clerk/
449
- └── ClerkNativePlugin.java
450
- ```
451
-
452
- ### 3. Gradle Configuration
453
-
454
- The plugin uses these default configurations (which can be overridden by your app's `variables.gradle`):
455
-
456
- | Property | Default | Description |
457
- |----------|---------|-------------|
458
- | `compileSdkVersion` | 35 | Android compile SDK |
459
- | `minSdkVersion` | 23 | Minimum Android version |
460
- | `targetSdkVersion` | 35 | Target Android version |
461
- | `junitVersion` | 4.13.2 | JUnit test version |
462
458
 
463
- ### 4. Build Requirements
459
+ ### Build Requirements
464
460
 
465
461
  - **Gradle**: 8.11.1+
466
- - **Android Gradle Plugin**: 8.7.2+
467
- - **Java**: 21
468
-
469
- These are configured in the plugin's `build.gradle` and are compatible with Capacitor 7.
462
+ - **Android Gradle Plugin**: 8.5.0+
463
+ - **Java**: 17+
464
+ - **Min SDK**: 23 (Android 6.0)
465
+ - **Target SDK**: 35 (Android 15)
470
466
 
471
467
  ### Troubleshooting Android
472
468
 
@@ -476,20 +472,21 @@ Could not resolve project :trainon-inc-capacitor-clerk-native
476
472
  No matching variant of project was found. No variants exist.
477
473
  ```
478
474
 
479
- **Solution**: Ensure you have the latest version of the plugin (1.16.0+) which includes the required `build.gradle` and `AndroidManifest.xml` files. Run:
475
+ **Solution**: Update to the latest plugin version:
480
476
  ```bash
481
477
  npm update @trainon-inc/capacitor-clerk-native
482
478
  npx cap sync android
483
479
  ```
484
480
 
481
+ #### "invalid source release: 21" error
482
+ The plugin uses Java 17. Ensure your Android Studio uses JDK 17+:
483
+ - **File → Project Structure → SDK Location → Gradle JDK** → Select JDK 17+
484
+
485
485
  #### Gradle sync fails
486
486
  - Clean the project: **Build → Clean Project**
487
487
  - Invalidate caches: **File → Invalidate Caches / Restart**
488
488
  - Delete `.gradle` folder and re-sync
489
489
 
490
- #### AGP version mismatch
491
- If you see AGP version conflicts, ensure your app's `build.gradle` uses AGP 8.5.0 or higher, matching the plugin's requirements.
492
-
493
490
  ## Contributing
494
491
 
495
492
  Contributions are welcome! This plugin was created to solve a real problem we encountered, and we'd love to make it better.
@@ -37,8 +37,8 @@ android {
37
37
  abortOnError false
38
38
  }
39
39
  compileOptions {
40
- sourceCompatibility JavaVersion.VERSION_21
41
- targetCompatibility JavaVersion.VERSION_21
40
+ sourceCompatibility JavaVersion.VERSION_17
41
+ targetCompatibility JavaVersion.VERSION_17
42
42
  }
43
43
  }
44
44
 
@@ -1,2 +1,3 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.INTERNET" />
2
3
  </manifest>
@@ -5,77 +5,88 @@ import com.getcapacitor.PluginCall;
5
5
  import com.getcapacitor.PluginMethod;
6
6
  import com.getcapacitor.annotation.CapacitorPlugin;
7
7
 
8
+ /**
9
+ * Android stub for Clerk Native plugin.
10
+ *
11
+ * On Android, authentication is handled by the web Clerk provider (@clerk/clerk-react)
12
+ * because Android WebViews work well with web-based auth (unlike iOS which has cookie issues).
13
+ *
14
+ * This plugin exists to satisfy Capacitor's plugin registration but all methods
15
+ * will return errors indicating to use the web provider instead.
16
+ */
8
17
  @CapacitorPlugin(name = "ClerkNative")
9
18
  public class ClerkNativePlugin extends Plugin {
10
19
 
20
+ private static final String USE_WEB_MESSAGE = "Android uses web Clerk provider. Configure your app to use @clerk/clerk-react on Android.";
21
+
11
22
  @PluginMethod
12
23
  public void configure(PluginCall call) {
13
- call.reject("Android not yet implemented");
24
+ // Allow configure to succeed silently - the web provider will handle auth
25
+ call.resolve();
14
26
  }
15
27
 
16
28
  @PluginMethod
17
29
  public void load(PluginCall call) {
18
- call.reject("Android not yet implemented");
30
+ call.reject(USE_WEB_MESSAGE);
19
31
  }
20
32
 
21
33
  @PluginMethod
22
34
  public void signInWithEmail(PluginCall call) {
23
- call.reject("Android not yet implemented");
35
+ call.reject(USE_WEB_MESSAGE);
24
36
  }
25
37
 
26
38
  @PluginMethod
27
39
  public void verifyEmailCode(PluginCall call) {
28
- call.reject("Android not yet implemented");
40
+ call.reject(USE_WEB_MESSAGE);
29
41
  }
30
42
 
31
43
  @PluginMethod
32
44
  public void signInWithPassword(PluginCall call) {
33
- call.reject("Android not yet implemented");
45
+ call.reject(USE_WEB_MESSAGE);
34
46
  }
35
47
 
36
48
  @PluginMethod
37
49
  public void signUp(PluginCall call) {
38
- call.reject("Android not yet implemented");
50
+ call.reject(USE_WEB_MESSAGE);
39
51
  }
40
52
 
41
53
  @PluginMethod
42
54
  public void verifySignUpEmail(PluginCall call) {
43
- call.reject("Android not yet implemented");
55
+ call.reject(USE_WEB_MESSAGE);
44
56
  }
45
57
 
46
58
  @PluginMethod
47
59
  public void getUser(PluginCall call) {
48
- call.reject("Android not yet implemented");
60
+ call.reject(USE_WEB_MESSAGE);
49
61
  }
50
62
 
51
63
  @PluginMethod
52
64
  public void getToken(PluginCall call) {
53
- call.reject("Android not yet implemented");
65
+ call.reject(USE_WEB_MESSAGE);
54
66
  }
55
67
 
56
68
  @PluginMethod
57
69
  public void signOut(PluginCall call) {
58
- call.reject("Android not yet implemented");
70
+ call.reject(USE_WEB_MESSAGE);
59
71
  }
60
72
 
61
73
  @PluginMethod
62
74
  public void updateUser(PluginCall call) {
63
- call.reject("Android not yet implemented");
75
+ call.reject(USE_WEB_MESSAGE);
64
76
  }
65
77
 
66
78
  @PluginMethod
67
79
  public void requestPasswordReset(PluginCall call) {
68
- call.reject("Android not yet implemented");
80
+ call.reject(USE_WEB_MESSAGE);
69
81
  }
70
82
 
71
83
  @PluginMethod
72
84
  public void resetPassword(PluginCall call) {
73
- call.reject("Android not yet implemented");
85
+ call.reject(USE_WEB_MESSAGE);
74
86
  }
75
87
 
76
88
  @PluginMethod
77
89
  public void refreshSession(PluginCall call) {
78
- call.reject("Android not yet implemented");
90
+ call.reject(USE_WEB_MESSAGE);
79
91
  }
80
92
  }
81
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainon-inc/capacitor-clerk-native",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "Capacitor plugin for Clerk native authentication using bridge pattern to integrate Clerk iOS/Android SDKs with CocoaPods/Gradle",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",