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
package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManagerPlugin.java
CHANGED
|
@@ -11,6 +11,24 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
11
11
|
|
|
12
12
|
private CapacitorAuthManager implementation;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Reject a call with the {@link AuthErrorCodes} value the failure carries, so JS receives a real
|
|
16
|
+
* {@code AuthError.code} instead of one guessed from the message text. A plain exception (nothing
|
|
17
|
+
* below it set a code) falls back to {@code fallbackCode}.
|
|
18
|
+
*/
|
|
19
|
+
private static void rejectWith(PluginCall call, Exception error, String fallbackCode) {
|
|
20
|
+
if (error == null) {
|
|
21
|
+
call.reject("Unknown error", AuthErrorCodes.INTERNAL_ERROR);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
String message = error.getMessage() != null ? error.getMessage() : error.toString();
|
|
25
|
+
call.reject(message, AuthException.codeOf(error, fallbackCode));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private static void rejectWith(PluginCall call, Exception error) {
|
|
29
|
+
rejectWith(call, error, AuthErrorCodes.INTERNAL_ERROR);
|
|
30
|
+
}
|
|
31
|
+
|
|
14
32
|
@Override
|
|
15
33
|
public void load() {
|
|
16
34
|
implementation = new CapacitorAuthManager(getContext(), getActivity());
|
|
@@ -27,7 +45,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
27
45
|
options = call.getData();
|
|
28
46
|
}
|
|
29
47
|
if (options == null) {
|
|
30
|
-
call.reject("Options are required");
|
|
48
|
+
call.reject("Options are required", AuthErrorCodes.MISSING_CONFIGURATION);
|
|
31
49
|
return;
|
|
32
50
|
}
|
|
33
51
|
|
|
@@ -35,11 +53,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
35
53
|
if (result.isSuccess()) {
|
|
36
54
|
call.resolve();
|
|
37
55
|
} else {
|
|
38
|
-
call
|
|
56
|
+
rejectWith(call, result.getError());
|
|
39
57
|
}
|
|
40
58
|
});
|
|
41
59
|
} catch (Exception e) {
|
|
42
|
-
call.reject("Failed to initialize: " + e.getMessage());
|
|
60
|
+
call.reject("Failed to initialize: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.PROVIDER_INIT_FAILED));
|
|
43
61
|
}
|
|
44
62
|
}
|
|
45
63
|
|
|
@@ -51,7 +69,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
51
69
|
JSObject options = call.getObject("options");
|
|
52
70
|
|
|
53
71
|
if (provider == null) {
|
|
54
|
-
call.reject("Provider is required");
|
|
72
|
+
call.reject("Provider is required", AuthErrorCodes.MISSING_CONFIGURATION);
|
|
55
73
|
return;
|
|
56
74
|
}
|
|
57
75
|
|
|
@@ -59,11 +77,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
59
77
|
if (result.isSuccess()) {
|
|
60
78
|
call.resolve(result.getData());
|
|
61
79
|
} else {
|
|
62
|
-
call
|
|
80
|
+
rejectWith(call, result.getError());
|
|
63
81
|
}
|
|
64
82
|
});
|
|
65
83
|
} catch (Exception e) {
|
|
66
|
-
call.reject("Sign in failed: " + e.getMessage());
|
|
84
|
+
call.reject("Sign in failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.SIGN_IN_FAILED));
|
|
67
85
|
}
|
|
68
86
|
}
|
|
69
87
|
|
|
@@ -81,11 +99,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
81
99
|
if (result.isSuccess()) {
|
|
82
100
|
call.resolve();
|
|
83
101
|
} else {
|
|
84
|
-
call
|
|
102
|
+
rejectWith(call, result.getError());
|
|
85
103
|
}
|
|
86
104
|
});
|
|
87
105
|
} catch (Exception e) {
|
|
88
|
-
call.reject("Sign out failed: " + e.getMessage());
|
|
106
|
+
call.reject("Sign out failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.SIGN_OUT_FAILED));
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
|
|
@@ -101,11 +119,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
101
119
|
call.resolve(new JSObject());
|
|
102
120
|
}
|
|
103
121
|
} else {
|
|
104
|
-
call
|
|
122
|
+
rejectWith(call, result.getError());
|
|
105
123
|
}
|
|
106
124
|
});
|
|
107
125
|
} catch (Exception e) {
|
|
108
|
-
call.reject("Failed to get current user: " + e.getMessage());
|
|
126
|
+
call.reject("Failed to get current user: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.INTERNAL_ERROR));
|
|
109
127
|
}
|
|
110
128
|
}
|
|
111
129
|
|
|
@@ -123,11 +141,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
123
141
|
if (result.isSuccess()) {
|
|
124
142
|
call.resolve(result.getData());
|
|
125
143
|
} else {
|
|
126
|
-
call
|
|
144
|
+
rejectWith(call, result.getError());
|
|
127
145
|
}
|
|
128
146
|
});
|
|
129
147
|
} catch (Exception e) {
|
|
130
|
-
call.reject("Token refresh failed: " + e.getMessage());
|
|
148
|
+
call.reject("Token refresh failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.TOKEN_REFRESH_FAILED));
|
|
131
149
|
}
|
|
132
150
|
}
|
|
133
151
|
|
|
@@ -148,7 +166,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
148
166
|
ret.put("callbackId", callbackId);
|
|
149
167
|
call.resolve(ret);
|
|
150
168
|
} catch (Exception e) {
|
|
151
|
-
call.reject("Failed to add listener: " + e.getMessage());
|
|
169
|
+
call.reject("Failed to add listener: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.INTERNAL_ERROR));
|
|
152
170
|
}
|
|
153
171
|
}
|
|
154
172
|
|
|
@@ -158,7 +176,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
158
176
|
implementation.removeAllListeners();
|
|
159
177
|
call.resolve();
|
|
160
178
|
} catch (Exception e) {
|
|
161
|
-
call.reject("Failed to remove listeners: " + e.getMessage());
|
|
179
|
+
call.reject("Failed to remove listeners: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.INTERNAL_ERROR));
|
|
162
180
|
}
|
|
163
181
|
}
|
|
164
182
|
|
|
@@ -167,7 +185,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
167
185
|
try {
|
|
168
186
|
String provider = call.getString("provider");
|
|
169
187
|
if (provider == null) {
|
|
170
|
-
call.reject("Provider is required");
|
|
188
|
+
call.reject("Provider is required", AuthErrorCodes.MISSING_CONFIGURATION);
|
|
171
189
|
return;
|
|
172
190
|
}
|
|
173
191
|
|
|
@@ -175,11 +193,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
175
193
|
if (result.isSuccess()) {
|
|
176
194
|
call.resolve(result.getData());
|
|
177
195
|
} else {
|
|
178
|
-
call
|
|
196
|
+
rejectWith(call, result.getError());
|
|
179
197
|
}
|
|
180
198
|
});
|
|
181
199
|
} catch (Exception e) {
|
|
182
|
-
call.reject("Failed to check support: " + e.getMessage());
|
|
200
|
+
call.reject("Failed to check support: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.INTERNAL_ERROR));
|
|
183
201
|
}
|
|
184
202
|
}
|
|
185
203
|
|
|
@@ -190,7 +208,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
190
208
|
JSObject options = call.getObject("options");
|
|
191
209
|
|
|
192
210
|
if (provider == null || options == null) {
|
|
193
|
-
call.reject("Provider and options are required");
|
|
211
|
+
call.reject("Provider and options are required", AuthErrorCodes.MISSING_CONFIGURATION);
|
|
194
212
|
return;
|
|
195
213
|
}
|
|
196
214
|
|
|
@@ -198,11 +216,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
198
216
|
if (result.isSuccess()) {
|
|
199
217
|
call.resolve();
|
|
200
218
|
} else {
|
|
201
|
-
call
|
|
219
|
+
rejectWith(call, result.getError());
|
|
202
220
|
}
|
|
203
221
|
});
|
|
204
222
|
} catch (Exception e) {
|
|
205
|
-
call.reject("Configuration failed: " + e.getMessage());
|
|
223
|
+
call.reject("Configuration failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.MISSING_CONFIGURATION));
|
|
206
224
|
}
|
|
207
225
|
}
|
|
208
226
|
|
|
@@ -214,7 +232,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
214
232
|
JSObject options = call.getObject("options");
|
|
215
233
|
|
|
216
234
|
if (provider == null) {
|
|
217
|
-
call.reject("Provider is required");
|
|
235
|
+
call.reject("Provider is required", AuthErrorCodes.MISSING_CONFIGURATION);
|
|
218
236
|
return;
|
|
219
237
|
}
|
|
220
238
|
|
|
@@ -222,11 +240,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
222
240
|
if (result.isSuccess()) {
|
|
223
241
|
call.resolve(result.getData());
|
|
224
242
|
} else {
|
|
225
|
-
call
|
|
243
|
+
rejectWith(call, result.getError());
|
|
226
244
|
}
|
|
227
245
|
});
|
|
228
246
|
} catch (Exception e) {
|
|
229
|
-
call.reject("Account linking failed: " + e.getMessage());
|
|
247
|
+
call.reject("Account linking failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
230
248
|
}
|
|
231
249
|
}
|
|
232
250
|
|
|
@@ -235,7 +253,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
235
253
|
try {
|
|
236
254
|
String provider = call.getString("provider");
|
|
237
255
|
if (provider == null) {
|
|
238
|
-
call.reject("Provider is required");
|
|
256
|
+
call.reject("Provider is required", AuthErrorCodes.MISSING_CONFIGURATION);
|
|
239
257
|
return;
|
|
240
258
|
}
|
|
241
259
|
|
|
@@ -243,11 +261,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
243
261
|
if (result.isSuccess()) {
|
|
244
262
|
call.resolve();
|
|
245
263
|
} else {
|
|
246
|
-
call
|
|
264
|
+
rejectWith(call, result.getError());
|
|
247
265
|
}
|
|
248
266
|
});
|
|
249
267
|
} catch (Exception e) {
|
|
250
|
-
call.reject("Account unlinking failed: " + e.getMessage());
|
|
268
|
+
call.reject("Account unlinking failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
251
269
|
}
|
|
252
270
|
}
|
|
253
271
|
|
|
@@ -258,7 +276,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
258
276
|
JSObject actionCodeSettings = call.getObject("actionCodeSettings");
|
|
259
277
|
|
|
260
278
|
if (email == null) {
|
|
261
|
-
call.reject("Email is required");
|
|
279
|
+
call.reject("Email is required", AuthErrorCodes.EMAIL_REQUIRED);
|
|
262
280
|
return;
|
|
263
281
|
}
|
|
264
282
|
|
|
@@ -266,11 +284,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
266
284
|
if (result.isSuccess()) {
|
|
267
285
|
call.resolve();
|
|
268
286
|
} else {
|
|
269
|
-
call
|
|
287
|
+
rejectWith(call, result.getError());
|
|
270
288
|
}
|
|
271
289
|
});
|
|
272
290
|
} catch (Exception e) {
|
|
273
|
-
call.reject("Failed to send password reset email: " + e.getMessage());
|
|
291
|
+
call.reject("Failed to send password reset email: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
274
292
|
}
|
|
275
293
|
}
|
|
276
294
|
|
|
@@ -283,11 +301,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
283
301
|
if (result.isSuccess()) {
|
|
284
302
|
call.resolve();
|
|
285
303
|
} else {
|
|
286
|
-
call
|
|
304
|
+
rejectWith(call, result.getError());
|
|
287
305
|
}
|
|
288
306
|
});
|
|
289
307
|
} catch (Exception e) {
|
|
290
|
-
call.reject("Failed to send email verification: " + e.getMessage());
|
|
308
|
+
call.reject("Failed to send email verification: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
291
309
|
}
|
|
292
310
|
}
|
|
293
311
|
|
|
@@ -299,7 +317,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
299
317
|
String testCode = call.getString("testCode");
|
|
300
318
|
|
|
301
319
|
if (phoneNumber == null) {
|
|
302
|
-
call.reject("Phone number is required");
|
|
320
|
+
call.reject("Phone number is required", AuthErrorCodes.PHONE_REQUIRED);
|
|
303
321
|
return;
|
|
304
322
|
}
|
|
305
323
|
|
|
@@ -307,11 +325,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
307
325
|
if (result.isSuccess()) {
|
|
308
326
|
call.resolve();
|
|
309
327
|
} else {
|
|
310
|
-
call
|
|
328
|
+
rejectWith(call, result.getError());
|
|
311
329
|
}
|
|
312
330
|
});
|
|
313
331
|
} catch (Exception e) {
|
|
314
|
-
call.reject("Failed to send SMS code: " + e.getMessage());
|
|
332
|
+
call.reject("Failed to send SMS code: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
315
333
|
}
|
|
316
334
|
}
|
|
317
335
|
|
|
@@ -323,7 +341,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
323
341
|
String verificationId = call.getString("verificationId");
|
|
324
342
|
|
|
325
343
|
if (phoneNumber == null || code == null) {
|
|
326
|
-
call.reject("Phone number and code are required");
|
|
344
|
+
call.reject("Phone number and code are required", AuthErrorCodes.CREDENTIALS_REQUIRED);
|
|
327
345
|
return;
|
|
328
346
|
}
|
|
329
347
|
|
|
@@ -331,11 +349,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
331
349
|
if (result.isSuccess()) {
|
|
332
350
|
call.resolve(result.getData());
|
|
333
351
|
} else {
|
|
334
|
-
call
|
|
352
|
+
rejectWith(call, result.getError());
|
|
335
353
|
}
|
|
336
354
|
});
|
|
337
355
|
} catch (Exception e) {
|
|
338
|
-
call.reject("SMS verification failed: " + e.getMessage());
|
|
356
|
+
call.reject("SMS verification failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
339
357
|
}
|
|
340
358
|
}
|
|
341
359
|
|
|
@@ -347,7 +365,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
347
365
|
String testCode = call.getString("testCode");
|
|
348
366
|
|
|
349
367
|
if (email == null) {
|
|
350
|
-
call.reject("Email is required");
|
|
368
|
+
call.reject("Email is required", AuthErrorCodes.EMAIL_REQUIRED);
|
|
351
369
|
return;
|
|
352
370
|
}
|
|
353
371
|
|
|
@@ -355,11 +373,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
355
373
|
if (result.isSuccess()) {
|
|
356
374
|
call.resolve();
|
|
357
375
|
} else {
|
|
358
|
-
call
|
|
376
|
+
rejectWith(call, result.getError());
|
|
359
377
|
}
|
|
360
378
|
});
|
|
361
379
|
} catch (Exception e) {
|
|
362
|
-
call.reject("Failed to send email code: " + e.getMessage());
|
|
380
|
+
call.reject("Failed to send email code: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
363
381
|
}
|
|
364
382
|
}
|
|
365
383
|
|
|
@@ -371,7 +389,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
371
389
|
String verificationId = call.getString("verificationId");
|
|
372
390
|
|
|
373
391
|
if (email == null || code == null) {
|
|
374
|
-
call.reject("Email and code are required");
|
|
392
|
+
call.reject("Email and code are required", AuthErrorCodes.CREDENTIALS_REQUIRED);
|
|
375
393
|
return;
|
|
376
394
|
}
|
|
377
395
|
|
|
@@ -379,11 +397,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
379
397
|
if (result.isSuccess()) {
|
|
380
398
|
call.resolve(result.getData());
|
|
381
399
|
} else {
|
|
382
|
-
call
|
|
400
|
+
rejectWith(call, result.getError());
|
|
383
401
|
}
|
|
384
402
|
});
|
|
385
403
|
} catch (Exception e) {
|
|
386
|
-
call.reject("Email verification failed: " + e.getMessage());
|
|
404
|
+
call.reject("Email verification failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
387
405
|
}
|
|
388
406
|
}
|
|
389
407
|
|
|
@@ -399,11 +417,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
399
417
|
if (result.isSuccess()) {
|
|
400
418
|
call.resolve(result.getData());
|
|
401
419
|
} else {
|
|
402
|
-
call
|
|
420
|
+
rejectWith(call, result.getError());
|
|
403
421
|
}
|
|
404
422
|
});
|
|
405
423
|
} catch (Exception e) {
|
|
406
|
-
call.reject("Profile update failed: " + e.getMessage());
|
|
424
|
+
call.reject("Profile update failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
407
425
|
}
|
|
408
426
|
}
|
|
409
427
|
|
|
@@ -416,18 +434,23 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
416
434
|
if (result.isSuccess()) {
|
|
417
435
|
call.resolve();
|
|
418
436
|
} else {
|
|
419
|
-
call
|
|
437
|
+
rejectWith(call, result.getError());
|
|
420
438
|
}
|
|
421
439
|
});
|
|
422
440
|
} catch (Exception e) {
|
|
423
|
-
call.reject("Account deletion failed: " + e.getMessage());
|
|
441
|
+
call.reject("Account deletion failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
424
442
|
}
|
|
425
443
|
}
|
|
426
444
|
|
|
427
445
|
@PluginMethod
|
|
428
446
|
public void getIdToken(PluginCall call) {
|
|
429
447
|
try {
|
|
448
|
+
// JS passes { provider, forceRefresh } at the top level; fall back to the call data so
|
|
449
|
+
// both reach the orchestrator (it reads options.provider / options.forceRefresh).
|
|
430
450
|
JSObject options = call.getObject("options");
|
|
451
|
+
if (options == null) {
|
|
452
|
+
options = call.getData();
|
|
453
|
+
}
|
|
431
454
|
|
|
432
455
|
implementation.getIdToken(options, result -> {
|
|
433
456
|
if (result.isSuccess()) {
|
|
@@ -435,11 +458,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
435
458
|
ret.put("token", result.getData().getString("token"));
|
|
436
459
|
call.resolve(ret);
|
|
437
460
|
} else {
|
|
438
|
-
call
|
|
461
|
+
rejectWith(call, result.getError());
|
|
439
462
|
}
|
|
440
463
|
});
|
|
441
464
|
} catch (Exception e) {
|
|
442
|
-
call.reject("Failed to get ID token: " + e.getMessage());
|
|
465
|
+
call.reject("Failed to get ID token: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.INTERNAL_ERROR));
|
|
443
466
|
}
|
|
444
467
|
}
|
|
445
468
|
|
|
@@ -450,7 +473,7 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
450
473
|
JSObject parameters = call.getObject("parameters");
|
|
451
474
|
|
|
452
475
|
if (provider == null || parameters == null) {
|
|
453
|
-
call.reject("Provider and parameters are required");
|
|
476
|
+
call.reject("Provider and parameters are required", AuthErrorCodes.MISSING_CONFIGURATION);
|
|
454
477
|
return;
|
|
455
478
|
}
|
|
456
479
|
|
|
@@ -458,11 +481,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
458
481
|
if (result.isSuccess()) {
|
|
459
482
|
call.resolve();
|
|
460
483
|
} else {
|
|
461
|
-
call
|
|
484
|
+
rejectWith(call, result.getError());
|
|
462
485
|
}
|
|
463
486
|
});
|
|
464
487
|
} catch (Exception e) {
|
|
465
|
-
call.reject("Failed to set custom parameters: " + e.getMessage());
|
|
488
|
+
call.reject("Failed to set custom parameters: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.INTERNAL_ERROR));
|
|
466
489
|
}
|
|
467
490
|
}
|
|
468
491
|
|
|
@@ -480,11 +503,11 @@ public class CapacitorAuthManagerPlugin extends Plugin {
|
|
|
480
503
|
if (result.isSuccess()) {
|
|
481
504
|
call.resolve();
|
|
482
505
|
} else {
|
|
483
|
-
call
|
|
506
|
+
rejectWith(call, result.getError());
|
|
484
507
|
}
|
|
485
508
|
});
|
|
486
509
|
} catch (Exception e) {
|
|
487
|
-
call.reject("Access revocation failed: " + e.getMessage());
|
|
510
|
+
call.reject("Access revocation failed: " + e.getMessage(), AuthException.codeOf(e, AuthErrorCodes.OPERATION_NOT_ALLOWED));
|
|
488
511
|
}
|
|
489
512
|
}
|
|
490
513
|
}
|