capacitor-auth-manager 2.4.3 → 3.0.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/AI-INTEGRATION-GUIDE.md +174 -0
- package/CHANGELOG.md +127 -0
- package/CapacitorAuthManager.podspec +3 -3
- package/README.md +91 -73
- package/android/build.gradle +17 -25
- package/android/consumer-rules.pro +2 -0
- package/android/proguard-rules.pro +5 -30
- package/android/src/main/AndroidManifest.xml +4 -9
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthErrorCodes.java +32 -0
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthException.java +34 -0
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthStorage.java +46 -25
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManager.java +54 -38
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManagerPlugin.java +77 -54
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/GoogleAuthProvider.java +171 -41
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/ProviderFactory.java +5 -0
- package/dist/angular.cjs.js +421 -3376
- package/dist/core.cjs.js +589 -149
- package/dist/esm/angular/auth.guard.d.ts +1 -1
- package/dist/esm/angular/auth.module.d.ts +1 -1
- package/dist/esm/angular/auth.module.js +1 -1
- package/dist/esm/angular/auth.service.d.ts +2 -2
- package/dist/esm/angular/auth.service.js +1 -1
- package/dist/esm/angular/index.d.ts +4 -4
- package/dist/esm/angular/index.js +4 -4
- package/dist/esm/capacitor-plugin.d.ts +2 -3
- package/dist/esm/capacitor-plugin.js +14 -4
- package/dist/esm/core/auth-manager.d.ts +20 -2
- package/dist/esm/core/auth-manager.js +68 -12
- package/dist/esm/core/index.d.ts +5 -4
- package/dist/esm/core/index.js +5 -4
- package/dist/esm/core/provider-manifests.d.ts +1 -1
- package/dist/esm/core/provider-manifests.js +12 -13
- package/dist/esm/core/provider-registry.d.ts +8 -5
- package/dist/esm/core/provider-registry.js +41 -10
- package/dist/esm/core/types.d.ts +2 -2
- package/dist/esm/definitions.d.ts +26 -0
- package/dist/esm/index.d.ts +12 -12
- package/dist/esm/index.js +7 -7
- package/dist/esm/package.json +1 -0
- package/dist/esm/providers/base-provider.d.ts +7 -8
- package/dist/esm/providers/base-provider.js +7 -8
- package/dist/esm/providers/native/google-native-provider.d.ts +13 -2
- package/dist/esm/providers/native/google-native-provider.js +50 -6
- package/dist/esm/providers/oauth-provider.d.ts +2 -2
- package/dist/esm/providers/oauth-provider.js +3 -3
- package/dist/esm/providers/provider-factory.d.ts +5 -5
- package/dist/esm/providers/provider-factory.js +2 -2
- package/dist/esm/providers/web/google-provider.d.ts +74 -18
- package/dist/esm/providers/web/google-provider.js +391 -117
- package/dist/esm/providers/web/index.d.ts +1 -1
- package/dist/esm/providers/web/index.js +1 -1
- package/dist/esm/react/hooks.d.ts +2 -2
- package/dist/esm/react/hooks.js +2 -2
- package/dist/esm/react/index.d.ts +3 -3
- package/dist/esm/react/index.js +3 -3
- package/dist/esm/react/types.d.ts +1 -1
- package/dist/esm/utils/auth-error.d.ts +1 -1
- package/dist/esm/utils/auth-error.js +1 -1
- package/dist/esm/utils/event-emitter.d.ts +1 -1
- package/dist/esm/utils/event-emitter.js +1 -1
- package/dist/esm/utils/pending-verification-store.js +1 -1
- package/dist/esm/utils/storage.d.ts +2 -2
- package/dist/esm/utils/storage.js +31 -7
- package/dist/esm/vue/composables.d.ts +2 -2
- package/dist/esm/vue/composables.js +1 -1
- package/dist/esm/vue/index.d.ts +2 -2
- package/dist/esm/vue/index.js +2 -2
- package/dist/esm/web.d.ts +1 -1
- package/dist/esm/web.js +6 -6
- package/dist/plugin.cjs.js +291 -2771
- package/dist/plugin.js +585 -147
- package/dist/providers-web.cjs.js +1317 -0
- package/dist/react.cjs.js +310 -3265
- package/dist/vue.cjs.js +266 -3221
- package/ios/Plugin/AuthStorage.swift +3 -1
- package/ios/Plugin/GoogleAuthProvider.swift +7 -4
- package/ios/Plugin/Models.swift +28 -0
- package/ios/Plugin/Plugin.swift +64 -40
- package/package.json +55 -33
- package/scripts/configure.js +71 -325
|
@@ -2,23 +2,24 @@ package com.aoneahsan.capacitor_auth_manager;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.content.SharedPreferences;
|
|
5
|
-
import androidx.security.crypto.EncryptedSharedPreferences;
|
|
6
|
-
import androidx.security.crypto.MasterKey;
|
|
7
5
|
|
|
8
6
|
import com.getcapacitor.JSObject;
|
|
9
7
|
|
|
10
8
|
import org.json.JSONException;
|
|
11
9
|
import org.json.JSONObject;
|
|
12
10
|
|
|
13
|
-
import java.
|
|
14
|
-
import java.
|
|
11
|
+
import java.util.HashMap;
|
|
12
|
+
import java.util.Map;
|
|
15
13
|
|
|
16
14
|
public class AuthStorage {
|
|
17
15
|
private static final String PREFS_NAME = "cap_auth_prefs";
|
|
18
16
|
private static final String KEY_PREFIX = "cap_auth_";
|
|
19
17
|
|
|
20
18
|
private final Context context;
|
|
19
|
+
|
|
20
|
+
// Disk storage holds profile metadata only. Credentials stay in process memory.
|
|
21
21
|
private SharedPreferences sharedPreferences;
|
|
22
|
+
private final Map<String, String> memoryStore = new HashMap<>();
|
|
22
23
|
private String persistence = "local";
|
|
23
24
|
|
|
24
25
|
public enum Persistence {
|
|
@@ -43,33 +44,27 @@ public class AuthStorage {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
private void initializeStorage() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
50
|
-
.build();
|
|
51
|
-
|
|
52
|
-
sharedPreferences = EncryptedSharedPreferences.create(
|
|
53
|
-
context,
|
|
54
|
-
PREFS_NAME,
|
|
55
|
-
masterKey,
|
|
56
|
-
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
|
57
|
-
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
|
58
|
-
);
|
|
59
|
-
} catch (GeneralSecurityException | IOException e) {
|
|
60
|
-
// Fallback to regular shared preferences
|
|
61
|
-
sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
|
62
|
-
}
|
|
47
|
+
// Remove the old encrypted credential store when upgrading to the metadata-only layout.
|
|
48
|
+
context.deleteSharedPreferences(PREFS_NAME);
|
|
49
|
+
sharedPreferences = context.getSharedPreferences("cap_auth_metadata", Context.MODE_PRIVATE);
|
|
63
50
|
}
|
|
64
|
-
|
|
51
|
+
|
|
65
52
|
public void setPersistence(String persistence) {
|
|
66
53
|
this.persistence = persistence;
|
|
67
54
|
}
|
|
68
55
|
|
|
56
|
+
/** Metadata storage is not encrypted; bearer credentials are never written here. */
|
|
57
|
+
public boolean isEncrypted() {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
69
61
|
public String get(String key) {
|
|
70
62
|
if (persistence.equals(Persistence.NONE.getValue())) {
|
|
71
63
|
return null;
|
|
72
64
|
}
|
|
65
|
+
if (sharedPreferences == null || persistence.equals(Persistence.SESSION.getValue())) {
|
|
66
|
+
return memoryStore.get(KEY_PREFIX + key);
|
|
67
|
+
}
|
|
73
68
|
return sharedPreferences.getString(KEY_PREFIX + key, null);
|
|
74
69
|
}
|
|
75
70
|
|
|
@@ -77,14 +72,26 @@ public class AuthStorage {
|
|
|
77
72
|
if (persistence.equals(Persistence.NONE.getValue())) {
|
|
78
73
|
return;
|
|
79
74
|
}
|
|
75
|
+
if (sharedPreferences == null || persistence.equals(Persistence.SESSION.getValue())) {
|
|
76
|
+
memoryStore.put(KEY_PREFIX + key, value);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
80
79
|
sharedPreferences.edit().putString(KEY_PREFIX + key, value).apply();
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
public void remove(String key) {
|
|
83
|
+
if (sharedPreferences == null || persistence.equals(Persistence.SESSION.getValue())) {
|
|
84
|
+
memoryStore.remove(KEY_PREFIX + key);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
84
87
|
sharedPreferences.edit().remove(KEY_PREFIX + key).apply();
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
public void clear() {
|
|
91
|
+
memoryStore.clear();
|
|
92
|
+
if (sharedPreferences == null || persistence.equals(Persistence.SESSION.getValue())) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
88
95
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
|
89
96
|
for (String key : sharedPreferences.getAll().keySet()) {
|
|
90
97
|
if (key.startsWith(KEY_PREFIX)) {
|
|
@@ -122,16 +129,29 @@ public class AuthStorage {
|
|
|
122
129
|
return null;
|
|
123
130
|
}
|
|
124
131
|
|
|
132
|
+
// Profile metadata respects the configured persistence; credentials remain in memory.
|
|
133
|
+
public void saveUser(String provider, JSObject user) {
|
|
134
|
+
if (user != null) set("user_" + provider, user.toString());
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public JSObject getUser(String provider) {
|
|
138
|
+
String json = get("user_" + provider);
|
|
139
|
+
try { return json == null ? null : JSObject.fromJSONObject(new JSONObject(json)); }
|
|
140
|
+
catch (JSONException invalidProfile) { return null; }
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public void deleteUser(String provider) { remove("user_" + provider); }
|
|
144
|
+
|
|
125
145
|
// Credential storage methods
|
|
126
146
|
|
|
127
147
|
public void saveCredential(String provider, JSObject credential) {
|
|
128
148
|
if (credential != null) {
|
|
129
|
-
|
|
149
|
+
memoryStore.put("credential_" + provider, credential.toString());
|
|
130
150
|
}
|
|
131
151
|
}
|
|
132
152
|
|
|
133
153
|
public JSObject getCredential(String provider) {
|
|
134
|
-
String jsonString = get("credential_" + provider);
|
|
154
|
+
String jsonString = memoryStore.get("credential_" + provider);
|
|
135
155
|
if (jsonString != null) {
|
|
136
156
|
try {
|
|
137
157
|
return JSObject.fromJSONObject(new JSONObject(jsonString));
|
|
@@ -143,7 +163,8 @@ public class AuthStorage {
|
|
|
143
163
|
}
|
|
144
164
|
|
|
145
165
|
public void deleteCredential(String provider) {
|
|
146
|
-
remove("credential_" + provider);
|
|
166
|
+
memoryStore.remove("credential_" + provider);
|
|
167
|
+
sharedPreferences.edit().remove(KEY_PREFIX + "credential_" + provider).apply();
|
|
147
168
|
}
|
|
148
169
|
|
|
149
170
|
public boolean hasCredential(String provider) {
|
package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManager.java
CHANGED
|
@@ -138,13 +138,13 @@ public class CapacitorAuthManager {
|
|
|
138
138
|
|
|
139
139
|
public void signIn(String provider, JSObject credentials, JSObject options, AuthCallback<JSObject> callback) {
|
|
140
140
|
if (!isInitialized) {
|
|
141
|
-
callback.onResult(AuthResult.error(new
|
|
141
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
BaseAuthProvider authProvider = providers.get(provider);
|
|
146
146
|
if (authProvider == null) {
|
|
147
|
-
callback.onResult(AuthResult.error(new
|
|
147
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_ENABLED, "Provider " + provider + " not configured")));
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -160,7 +160,7 @@ public class CapacitorAuthManager {
|
|
|
160
160
|
|
|
161
161
|
public void signOut(JSObject options, AuthCallback<Void> callback) {
|
|
162
162
|
if (!isInitialized) {
|
|
163
|
-
callback.onResult(AuthResult.error(new
|
|
163
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -180,7 +180,7 @@ public class CapacitorAuthManager {
|
|
|
180
180
|
callback.onResult(result);
|
|
181
181
|
});
|
|
182
182
|
} else {
|
|
183
|
-
callback.onResult(AuthResult.error(new
|
|
183
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_ENABLED, "Provider " + provider + " not found")));
|
|
184
184
|
}
|
|
185
185
|
} else {
|
|
186
186
|
// Sign out from all providers
|
|
@@ -196,7 +196,7 @@ public class CapacitorAuthManager {
|
|
|
196
196
|
|
|
197
197
|
public void getCurrentUser(AuthCallback<JSObject> callback) {
|
|
198
198
|
if (!isInitialized) {
|
|
199
|
-
callback.onResult(AuthResult.error(new
|
|
199
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -208,35 +208,51 @@ public class CapacitorAuthManager {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
}
|
|
211
|
+
// No active provider: ask each configured provider in turn and answer exactly ONCE. The
|
|
212
|
+
// previous loop fired every provider's async callback AND an unconditional success(null),
|
|
213
|
+
// which resolved the same PluginCall twice.
|
|
214
|
+
java.util.List<java.util.Map.Entry<String, BaseAuthProvider>> candidates =
|
|
215
|
+
new java.util.ArrayList<>(providers.entrySet());
|
|
216
|
+
findCurrentUserFrom(candidates, 0, callback);
|
|
217
|
+
}
|
|
220
218
|
|
|
221
|
-
|
|
219
|
+
private void findCurrentUserFrom(
|
|
220
|
+
java.util.List<java.util.Map.Entry<String, BaseAuthProvider>> candidates,
|
|
221
|
+
int index,
|
|
222
|
+
AuthCallback<JSObject> callback
|
|
223
|
+
) {
|
|
224
|
+
if (index >= candidates.size()) {
|
|
225
|
+
callback.onResult(AuthResult.success(null));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
java.util.Map.Entry<String, BaseAuthProvider> entry = candidates.get(index);
|
|
229
|
+
entry.getValue().getCurrentUser(result -> {
|
|
230
|
+
if (result.isSuccess() && result.getData() != null && result.getData().has("uid")) {
|
|
231
|
+
// Remember which provider owns the restored session for subsequent calls.
|
|
232
|
+
currentProvider = entry.getKey();
|
|
233
|
+
callback.onResult(result);
|
|
234
|
+
} else {
|
|
235
|
+
findCurrentUserFrom(candidates, index + 1, callback);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
222
238
|
}
|
|
223
239
|
|
|
224
240
|
public void refreshToken(JSObject options, AuthCallback<JSObject> callback) {
|
|
225
241
|
if (!isInitialized) {
|
|
226
|
-
callback.onResult(AuthResult.error(new
|
|
242
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
227
243
|
return;
|
|
228
244
|
}
|
|
229
245
|
|
|
230
246
|
String provider = options != null && options.has("provider") ? options.getString("provider") : currentProvider;
|
|
231
247
|
|
|
232
248
|
if (provider == null) {
|
|
233
|
-
callback.onResult(AuthResult.error(new
|
|
249
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.MISSING_CONFIGURATION, "No provider specified")));
|
|
234
250
|
return;
|
|
235
251
|
}
|
|
236
252
|
|
|
237
253
|
BaseAuthProvider authProvider = providers.get(provider);
|
|
238
254
|
if (authProvider == null) {
|
|
239
|
-
callback.onResult(AuthResult.error(new
|
|
255
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_ENABLED, "Provider " + provider + " not configured")));
|
|
240
256
|
return;
|
|
241
257
|
}
|
|
242
258
|
|
|
@@ -285,7 +301,7 @@ public class CapacitorAuthManager {
|
|
|
285
301
|
|
|
286
302
|
public void configure(String provider, JSObject options, AuthCallback<Void> callback) {
|
|
287
303
|
if (!isInitialized) {
|
|
288
|
-
callback.onResult(AuthResult.error(new
|
|
304
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
289
305
|
return;
|
|
290
306
|
}
|
|
291
307
|
|
|
@@ -304,7 +320,7 @@ public class CapacitorAuthManager {
|
|
|
304
320
|
}
|
|
305
321
|
});
|
|
306
322
|
} else {
|
|
307
|
-
callback.onResult(AuthResult.error(new
|
|
323
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.UNSUPPORTED_PROVIDER, "Unknown provider: " + provider)));
|
|
308
324
|
}
|
|
309
325
|
} catch (Exception e) {
|
|
310
326
|
logger.error("Failed to configure provider: " + provider, e);
|
|
@@ -314,13 +330,13 @@ public class CapacitorAuthManager {
|
|
|
314
330
|
|
|
315
331
|
public void linkAccount(String provider, JSObject credentials, JSObject options, AuthCallback<JSObject> callback) {
|
|
316
332
|
if (!isInitialized) {
|
|
317
|
-
callback.onResult(AuthResult.error(new
|
|
333
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
318
334
|
return;
|
|
319
335
|
}
|
|
320
336
|
|
|
321
337
|
BaseAuthProvider authProvider = providers.get(provider);
|
|
322
338
|
if (authProvider == null) {
|
|
323
|
-
callback.onResult(AuthResult.error(new
|
|
339
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_ENABLED, "Provider " + provider + " not configured")));
|
|
324
340
|
return;
|
|
325
341
|
}
|
|
326
342
|
|
|
@@ -329,13 +345,13 @@ public class CapacitorAuthManager {
|
|
|
329
345
|
|
|
330
346
|
public void unlinkAccount(String provider, AuthCallback<Void> callback) {
|
|
331
347
|
if (!isInitialized) {
|
|
332
|
-
callback.onResult(AuthResult.error(new
|
|
348
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
333
349
|
return;
|
|
334
350
|
}
|
|
335
351
|
|
|
336
352
|
BaseAuthProvider authProvider = providers.get(provider);
|
|
337
353
|
if (authProvider == null) {
|
|
338
|
-
callback.onResult(AuthResult.error(new
|
|
354
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_ENABLED, "Provider " + provider + " not configured")));
|
|
339
355
|
return;
|
|
340
356
|
}
|
|
341
357
|
|
|
@@ -345,7 +361,7 @@ public class CapacitorAuthManager {
|
|
|
345
361
|
public void sendPasswordResetEmail(String email, JSObject actionCodeSettings, AuthCallback<Void> callback) {
|
|
346
362
|
// Password reset is not supported on Android native - requires web-based email/password provider
|
|
347
363
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
348
|
-
callback.onResult(AuthResult.error(new
|
|
364
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
349
365
|
"sendPasswordResetEmail is not supported on Android. This method requires web-based providers. " +
|
|
350
366
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
351
367
|
}
|
|
@@ -353,7 +369,7 @@ public class CapacitorAuthManager {
|
|
|
353
369
|
public void sendEmailVerification(JSObject options, AuthCallback<Void> callback) {
|
|
354
370
|
// Email verification is not supported on Android native - requires web-based email/password provider
|
|
355
371
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
356
|
-
callback.onResult(AuthResult.error(new
|
|
372
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
357
373
|
"sendEmailVerification is not supported on Android. This method requires web-based providers. " +
|
|
358
374
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
359
375
|
}
|
|
@@ -361,7 +377,7 @@ public class CapacitorAuthManager {
|
|
|
361
377
|
public void sendSmsCode(String phoneNumber, String recaptchaToken, String testCode, AuthCallback<Void> callback) {
|
|
362
378
|
// SMS code is not supported on Android native - requires web-based SMS provider
|
|
363
379
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
364
|
-
callback.onResult(AuthResult.error(new
|
|
380
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
365
381
|
"sendSmsCode is not supported on Android. This method requires web-based providers. " +
|
|
366
382
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
367
383
|
}
|
|
@@ -369,7 +385,7 @@ public class CapacitorAuthManager {
|
|
|
369
385
|
public void verifySmsCode(String phoneNumber, String code, String verificationId, AuthCallback<JSObject> callback) {
|
|
370
386
|
// SMS verification is not supported on Android native - requires web-based SMS provider
|
|
371
387
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
372
|
-
callback.onResult(AuthResult.error(new
|
|
388
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
373
389
|
"verifySmsCode is not supported on Android. This method requires web-based providers. " +
|
|
374
390
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
375
391
|
}
|
|
@@ -377,7 +393,7 @@ public class CapacitorAuthManager {
|
|
|
377
393
|
public void sendEmailCode(String email, String recaptchaToken, String testCode, AuthCallback<Void> callback) {
|
|
378
394
|
// Email code is not supported on Android native - requires web-based email-code provider
|
|
379
395
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
380
|
-
callback.onResult(AuthResult.error(new
|
|
396
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
381
397
|
"sendEmailCode is not supported on Android. This method requires web-based providers. " +
|
|
382
398
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
383
399
|
}
|
|
@@ -385,7 +401,7 @@ public class CapacitorAuthManager {
|
|
|
385
401
|
public void verifyEmailCode(String email, String code, String verificationId, AuthCallback<JSObject> callback) {
|
|
386
402
|
// Email code verification is not supported on Android native - requires web-based email-code provider
|
|
387
403
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
388
|
-
callback.onResult(AuthResult.error(new
|
|
404
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
389
405
|
"verifyEmailCode is not supported on Android. This method requires web-based providers. " +
|
|
390
406
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
391
407
|
}
|
|
@@ -393,7 +409,7 @@ public class CapacitorAuthManager {
|
|
|
393
409
|
public void updateProfile(JSObject options, AuthCallback<JSObject> callback) {
|
|
394
410
|
// Profile updates are not supported on Android native - OAuth providers manage profiles externally
|
|
395
411
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
396
|
-
callback.onResult(AuthResult.error(new
|
|
412
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
397
413
|
"updateProfile is not supported on Android. OAuth providers manage profiles externally. " +
|
|
398
414
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
399
415
|
}
|
|
@@ -401,27 +417,27 @@ public class CapacitorAuthManager {
|
|
|
401
417
|
public void deleteAccount(JSObject options, AuthCallback<Void> callback) {
|
|
402
418
|
// Account deletion is not supported on Android native - OAuth providers manage accounts externally
|
|
403
419
|
// See docs/api-reference/CAPABILITY_MATRIX.md for platform support details
|
|
404
|
-
callback.onResult(AuthResult.error(new
|
|
420
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.OPERATION_NOT_ALLOWED,
|
|
405
421
|
"deleteAccount is not supported on Android. OAuth providers manage accounts externally. " +
|
|
406
422
|
"See docs/api-reference/CAPABILITY_MATRIX.md for platform support details.")));
|
|
407
423
|
}
|
|
408
424
|
|
|
409
425
|
public void getIdToken(JSObject options, AuthCallback<JSObject> callback) {
|
|
410
426
|
if (!isInitialized) {
|
|
411
|
-
callback.onResult(AuthResult.error(new
|
|
427
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
412
428
|
return;
|
|
413
429
|
}
|
|
414
430
|
|
|
415
431
|
String provider = options != null && options.has("provider") ? options.getString("provider") : currentProvider;
|
|
416
432
|
|
|
417
433
|
if (provider == null) {
|
|
418
|
-
callback.onResult(AuthResult.error(new
|
|
434
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.MISSING_CONFIGURATION, "No provider specified")));
|
|
419
435
|
return;
|
|
420
436
|
}
|
|
421
437
|
|
|
422
438
|
BaseAuthProvider authProvider = providers.get(provider);
|
|
423
439
|
if (authProvider == null) {
|
|
424
|
-
callback.onResult(AuthResult.error(new
|
|
440
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_ENABLED, "Provider " + provider + " not configured")));
|
|
425
441
|
return;
|
|
426
442
|
}
|
|
427
443
|
|
|
@@ -436,20 +452,20 @@ public class CapacitorAuthManager {
|
|
|
436
452
|
|
|
437
453
|
public void revokeAccess(JSObject options, AuthCallback<Void> callback) {
|
|
438
454
|
if (!isInitialized) {
|
|
439
|
-
callback.onResult(AuthResult.error(new
|
|
455
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_INITIALIZED, "Auth manager not initialized")));
|
|
440
456
|
return;
|
|
441
457
|
}
|
|
442
458
|
|
|
443
459
|
String provider = options != null && options.has("provider") ? options.getString("provider") : currentProvider;
|
|
444
460
|
|
|
445
461
|
if (provider == null) {
|
|
446
|
-
callback.onResult(AuthResult.error(new
|
|
462
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.MISSING_CONFIGURATION, "No provider specified")));
|
|
447
463
|
return;
|
|
448
464
|
}
|
|
449
465
|
|
|
450
466
|
BaseAuthProvider authProvider = providers.get(provider);
|
|
451
467
|
if (authProvider == null) {
|
|
452
|
-
callback.onResult(AuthResult.error(new
|
|
468
|
+
callback.onResult(AuthResult.error(new AuthException(AuthErrorCodes.PROVIDER_NOT_ENABLED, "Provider " + provider + " not configured")));
|
|
453
469
|
return;
|
|
454
470
|
}
|
|
455
471
|
|