|
5 | 5 | import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart';
|
6 | 6 | import 'package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart';
|
7 | 7 | import 'package:firebase_auth_platform_interface/src/method_channel/method_channel_user_credential.dart';
|
| 8 | +import 'package:firebase_auth_platform_interface/src/method_channel/utils/exception.dart'; |
8 | 9 | import 'package:firebase_auth_platform_interface/src/method_channel/utils/pigeon_helper.dart';
|
9 | 10 | import 'package:firebase_auth_platform_interface/src/pigeon/messages.pigeon.dart';
|
10 | 11 |
|
@@ -16,8 +17,12 @@ class MethodChannelMultiFactor extends MultiFactorPlatform {
|
16 | 17 |
|
17 | 18 | @override
|
18 | 19 | Future<MultiFactorSession> getSession() async {
|
19 |
| -final pigeonObject = await _api.getSession(auth.app.name); |
20 |
| -return MultiFactorSession(pigeonObject.id); |
| 20 | +try { |
| 21 | +final pigeonObject = await _api.getSession(auth.app.name); |
| 22 | +return MultiFactorSession(pigeonObject.id); |
| 23 | +} catch (e, stack) { |
| 24 | +convertPlatformException(e, stack, fromPigeon: true); |
| 25 | +} |
21 | 26 | }
|
22 | 27 |
|
23 | 28 | @override
|
@@ -39,14 +44,18 @@ class MethodChannelMultiFactor extends MultiFactorPlatform {
|
39 | 44 | throw ArgumentError('verificationId must not be null');
|
40 | 45 | }
|
41 | 46 |
|
42 |
| -await _api.enrollPhone( |
43 |
| -auth.app.name, |
44 |
| -PigeonPhoneMultiFactorAssertion( |
45 |
| -verificationId: verificationId, |
46 |
| -verificationCode: verificationCode, |
47 |
| -), |
48 |
| -displayName, |
49 |
| -); |
| 47 | +try { |
| 48 | +await _api.enrollPhone( |
| 49 | +auth.app.name, |
| 50 | +PigeonPhoneMultiFactorAssertion( |
| 51 | +verificationId: verificationId, |
| 52 | +verificationCode: verificationCode, |
| 53 | +), |
| 54 | +displayName, |
| 55 | +); |
| 56 | +} catch (e, stack) { |
| 57 | +convertPlatformException(e, stack, fromPigeon: true); |
| 58 | +} |
50 | 59 | } else {
|
51 | 60 | throw UnimplementedError(
|
52 | 61 | 'Credential type ${_assertion.credential} is not supported yet',
|
@@ -66,16 +75,24 @@ class MethodChannelMultiFactor extends MultiFactorPlatform {
|
66 | 75 | );
|
67 | 76 | }
|
68 | 77 |
|
69 |
| -return _api.unenroll( |
70 |
| -auth.app.name, |
71 |
| -uidToUnenroll, |
72 |
| -); |
| 78 | +try { |
| 79 | +return _api.unenroll( |
| 80 | +auth.app.name, |
| 81 | +uidToUnenroll, |
| 82 | +); |
| 83 | +} catch (e, stack) { |
| 84 | +convertPlatformException(e, stack, fromPigeon: true); |
| 85 | +} |
73 | 86 | }
|
74 | 87 |
|
75 | 88 | @override
|
76 | 89 | Future<List<MultiFactorInfo>> getEnrolledFactors() async {
|
77 |
| -final data = await _api.getEnrolledFactors(auth.app.name); |
78 |
| -return multiFactorInfoPigeonToObject(data); |
| 90 | +try { |
| 91 | +final data = await _api.getEnrolledFactors(auth.app.name); |
| 92 | +return multiFactorInfoPigeonToObject(data); |
| 93 | +} catch (e, stack) { |
| 94 | +convertPlatformException(e, stack, fromPigeon: true); |
| 95 | +} |
79 | 96 | }
|
80 | 97 | }
|
81 | 98 |
|
@@ -112,18 +129,22 @@ class MethodChannelMultiFactorResolver extends MultiFactorResolverPlatform {
|
112 | 129 | throw ArgumentError('verificationId must not be null');
|
113 | 130 | }
|
114 | 131 |
|
115 |
| -final data = await _api.resolveSignIn( |
116 |
| -_resolverId, |
117 |
| -PigeonPhoneMultiFactorAssertion( |
118 |
| -verificationId: verificationId, |
119 |
| -verificationCode: verificationCode, |
120 |
| -), |
121 |
| -); |
122 |
| - |
123 |
| -MethodChannelUserCredential userCredential = |
124 |
| -MethodChannelUserCredential(_auth, data.cast<String, dynamic>()); |
125 |
| - |
126 |
| -return userCredential; |
| 132 | +try { |
| 133 | +final data = await _api.resolveSignIn( |
| 134 | +_resolverId, |
| 135 | +PigeonPhoneMultiFactorAssertion( |
| 136 | +verificationId: verificationId, |
| 137 | +verificationCode: verificationCode, |
| 138 | +), |
| 139 | +); |
| 140 | + |
| 141 | +MethodChannelUserCredential userCredential = |
| 142 | +MethodChannelUserCredential(_auth, data.cast<String, dynamic>()); |
| 143 | + |
| 144 | +return userCredential; |
| 145 | +} catch (e, stack) { |
| 146 | +convertPlatformException(e, stack, fromPigeon: true); |
| 147 | +} |
127 | 148 | } else {
|
128 | 149 | throw UnimplementedError(
|
129 | 150 | 'Credential type ${_assertion.credential} is not supported yet',
|
|
0 commit comments