@trainon-inc/capacitor-clerk-native 1.13.0 → 1.15.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.
|
@@ -4,6 +4,8 @@ import Capacitor
|
|
|
4
4
|
// Protocol for Clerk bridge - the App target will implement this
|
|
5
5
|
@objc public protocol ClerkBridge: AnyObject {
|
|
6
6
|
func signIn(withEmail email: String, password: String, completion: @escaping (String?, Error?) -> Void)
|
|
7
|
+
func signInWithEmailCode(email: String, completion: @escaping (Error?) -> Void)
|
|
8
|
+
func verifyEmailCode(code: String, completion: @escaping (Error?) -> Void)
|
|
7
9
|
func signUp(withEmail email: String, password: String, completion: @escaping (String?, Error?) -> Void)
|
|
8
10
|
func signOut(completion: @escaping (Error?) -> Void)
|
|
9
11
|
func getToken(completion: @escaping (String?, Error?) -> Void)
|
|
@@ -149,14 +151,50 @@ public class ClerkNativePlugin: CAPPlugin {
|
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
@objc func signInWithEmail(_ call: CAPPluginCall) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
guard let bridge = clerkBridge else {
|
|
155
|
+
call.reject("Clerk bridge not configured")
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
guard let email = call.getString("email") else {
|
|
160
|
+
call.reject("Must provide email")
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
bridge.signInWithEmailCode(email: email) { error in
|
|
165
|
+
if let error = error {
|
|
166
|
+
call.reject("Sign in with email failed: \(error.localizedDescription)")
|
|
167
|
+
} else {
|
|
168
|
+
call.resolve(["requiresCode": true])
|
|
169
|
+
}
|
|
170
|
+
}
|
|
155
171
|
}
|
|
156
172
|
|
|
157
173
|
@objc func verifyEmailCode(_ call: CAPPluginCall) {
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
guard let bridge = clerkBridge else {
|
|
175
|
+
call.reject("Clerk bridge not configured")
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
guard let code = call.getString("code") else {
|
|
180
|
+
call.reject("Must provide code")
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
bridge.verifyEmailCode(code: code) { error in
|
|
185
|
+
if let error = error {
|
|
186
|
+
call.reject("Email code verification failed: \(error.localizedDescription)")
|
|
187
|
+
} else {
|
|
188
|
+
// Get the full user after verification
|
|
189
|
+
bridge.getUser { user, getUserError in
|
|
190
|
+
if let getUserError = getUserError {
|
|
191
|
+
call.reject("Verification succeeded but failed to get user: \(getUserError.localizedDescription)")
|
|
192
|
+
} else {
|
|
193
|
+
call.resolve(["user": user ?? NSNull()])
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
160
198
|
}
|
|
161
199
|
|
|
162
200
|
@objc func verifySignUpEmail(_ call: CAPPluginCall) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainon-inc/capacitor-clerk-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.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",
|