pyios-firebase 0.2.0__py3-none-any.whl

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.
Files changed (65) hide show
  1. pyios_firebase/__init__.py +26 -0
  2. pyios_firebase/analytics/__init__.py +434 -0
  3. pyios_firebase/analytics/names.py +251 -0
  4. pyios_firebase/app_check/__init__.py +483 -0
  5. pyios_firebase/auth/__init__.py +131 -0
  6. pyios_firebase/auth/_apple_name_cache.py +97 -0
  7. pyios_firebase/auth/_common.py +121 -0
  8. pyios_firebase/auth/_ui.py +21 -0
  9. pyios_firebase/auth/apple.py +326 -0
  10. pyios_firebase/auth/auth.py +592 -0
  11. pyios_firebase/auth/credentials.py +551 -0
  12. pyios_firebase/auth/errors.py +321 -0
  13. pyios_firebase/auth/facebook.py +240 -0
  14. pyios_firebase/auth/google.py +167 -0
  15. pyios_firebase/auth/multi_factor.py +394 -0
  16. pyios_firebase/auth/results.py +361 -0
  17. pyios_firebase/auth/user.py +457 -0
  18. pyios_firebase/core/__init__.py +32 -0
  19. pyios_firebase/crashlytics/__init__.py +463 -0
  20. pyios_firebase/database/__init__.py +62 -0
  21. pyios_firebase/database/database.py +144 -0
  22. pyios_firebase/database/errors.py +80 -0
  23. pyios_firebase/database/query.py +569 -0
  24. pyios_firebase/database/reference.py +428 -0
  25. pyios_firebase/database/snapshot.py +218 -0
  26. pyios_firebase/database/values.py +271 -0
  27. pyios_firebase/firestore/__init__.py +59 -0
  28. pyios_firebase/firestore/_limits.py +48 -0
  29. pyios_firebase/firestore/_query_state.py +228 -0
  30. pyios_firebase/firestore/_write.py +18 -0
  31. pyios_firebase/firestore/aggregate.py +137 -0
  32. pyios_firebase/firestore/collection_reference.py +100 -0
  33. pyios_firebase/firestore/document_change.py +63 -0
  34. pyios_firebase/firestore/document_reference.py +229 -0
  35. pyios_firebase/firestore/document_snapshot.py +102 -0
  36. pyios_firebase/firestore/enums.py +66 -0
  37. pyios_firebase/firestore/field_value.py +94 -0
  38. pyios_firebase/firestore/filter.py +319 -0
  39. pyios_firebase/firestore/firestore.py +184 -0
  40. pyios_firebase/firestore/listener_registration.py +55 -0
  41. pyios_firebase/firestore/query.py +679 -0
  42. pyios_firebase/firestore/query_snapshot.py +103 -0
  43. pyios_firebase/firestore/snapshot_metadata.py +36 -0
  44. pyios_firebase/firestore/transaction.py +130 -0
  45. pyios_firebase/firestore/write_batch.py +125 -0
  46. pyios_firebase/functions/__init__.py +329 -0
  47. pyios_firebase/messaging/__init__.py +37 -0
  48. pyios_firebase/messaging/messaging.py +435 -0
  49. pyios_firebase/messaging/notifications.py +292 -0
  50. pyios_firebase/performance/__init__.py +486 -0
  51. pyios_firebase/py.typed +0 -0
  52. pyios_firebase/remote_config/__init__.py +660 -0
  53. pyios_firebase/storage/__init__.py +41 -0
  54. pyios_firebase/storage/errors.py +103 -0
  55. pyios_firebase/storage/metadata.py +202 -0
  56. pyios_firebase/storage/reference.py +402 -0
  57. pyios_firebase/storage/storage.py +120 -0
  58. pyios_firebase/storage/task.py +198 -0
  59. pyios_firebase/types.py +93 -0
  60. pyios_firebase/util.py +413 -0
  61. pyios_firebase-0.2.0.dist-info/METADATA +1969 -0
  62. pyios_firebase-0.2.0.dist-info/RECORD +65 -0
  63. pyios_firebase-0.2.0.dist-info/WHEEL +5 -0
  64. pyios_firebase-0.2.0.dist-info/licenses/LICENSE +21 -0
  65. pyios_firebase-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,167 @@
1
+ """Google Sign-In, then Firebase Auth.
2
+
3
+ from pyios_firebase.auth.google import start_google_sign_in
4
+
5
+ def on_signed_in(result, error):
6
+ if error is not None:
7
+ if not error.cancelled: # cancelled: the user closed the sheet
8
+ print("Sign-in failed:", error.description)
9
+ return
10
+ print("Signed in:", result.user.uid)
11
+
12
+ start_google_sign_in(on_signed_in)
13
+
14
+ Needs the ``GoogleSignIn`` framework, and the reversed client ID URL scheme
15
+ (``com.googleusercontent.apps.YOUR-CLIENT-ID``) in ``CFBundleURLTypes``.
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ __all__ = (
21
+ "GOOGLE_SIGN_IN_CANCELED",
22
+ "GOOGLE_SIGN_IN_DOMAIN",
23
+ "get_google_credential",
24
+ "on_gid_signin_handle_url",
25
+ "on_gid_signin_handle_url_kivy",
26
+ "sign_out_of_google",
27
+ "start_google_sign_in",
28
+ )
29
+
30
+ from collections.abc import Callable
31
+ from typing import Any, Final
32
+
33
+ from rubicon.objc import objc_id
34
+
35
+ from ..util import objc_class, objc_instance, one_shot_block
36
+ from ._ui import root_view_controller
37
+ from .auth import Auth
38
+ from .credentials import AuthCredential, GoogleAuthProvider
39
+ from .errors import AuthError, auth_error_from_nserror, simple_auth_error
40
+ from .results import AuthDataResult
41
+
42
+ GOOGLE_SIGN_IN_CANCELED: Final = -5
43
+ """``GIDSignInErrorCode.canceled``: the user closed the Google sheet."""
44
+ GOOGLE_SIGN_IN_DOMAIN: Final = "com.google.GIDSignIn"
45
+ """The error domain of Google Sign-In errors."""
46
+
47
+ CredentialCallback = Callable[[AuthCredential | None, AuthError | None], None]
48
+ DataResultCallback = Callable[[AuthDataResult | None, AuthError | None], None]
49
+
50
+
51
+ def _google_error(error: Any) -> AuthError:
52
+ result = auth_error_from_nserror(error)
53
+ if (
54
+ result.domain == GOOGLE_SIGN_IN_DOMAIN
55
+ and result.code == GOOGLE_SIGN_IN_CANCELED
56
+ ):
57
+ result.cancelled = True
58
+ return result
59
+
60
+
61
+ def get_google_credential(callback: CredentialCallback) -> None:
62
+ """Show the Google sign-in sheet and give back a Firebase credential,
63
+ without signing in to Firebase (for example to link Google to the
64
+ current user, or to re-authenticate).
65
+
66
+ Args:
67
+ callback: gets ``(credential, None)``, or ``(None, error)``.
68
+ ``error.cancelled`` is True when the user closed the sheet.
69
+ """
70
+
71
+ def done(result_ptr: Any, error_ptr: Any) -> None:
72
+ if error_ptr:
73
+ callback(None, _google_error(objc_instance(error_ptr)))
74
+ return
75
+ try:
76
+ google_user = objc_instance(result_ptr).user
77
+ credential = GoogleAuthProvider.credential(
78
+ str(google_user.idToken.tokenString),
79
+ str(google_user.accessToken.tokenString),
80
+ )
81
+ except Exception as e: # noqa: BLE001 - must always answer the caller
82
+ callback(
83
+ None, simple_auth_error(f"Google sign-in gave no usable tokens: {e}")
84
+ )
85
+ return
86
+ callback(credential, None)
87
+
88
+ try:
89
+ client_id = objc_class("FIRApp").defaultApp().options.clientID
90
+ if client_id is None:
91
+ raise ValueError(
92
+ "GoogleService-Info.plist has no CLIENT_ID (enable Google sign-in first)"
93
+ )
94
+ sign_in = objc_class("GIDSignIn").sharedInstance
95
+ sign_in.configuration = (
96
+ objc_class("GIDConfiguration").alloc().initWithClientID_(client_id)
97
+ )
98
+ presenter = root_view_controller()
99
+ except Exception as e: # noqa: BLE001
100
+ callback(None, simple_auth_error(str(e)))
101
+ return
102
+ sign_in.signInWithPresentingViewController_completion_(
103
+ presenter, one_shot_block(done, objc_id, objc_id)
104
+ )
105
+
106
+
107
+ def start_google_sign_in(
108
+ callback: DataResultCallback, auth: Auth | None = None
109
+ ) -> None:
110
+ """Show the Google sign-in sheet, then sign in to Firebase.
111
+
112
+ Args:
113
+ callback: gets ``(AuthDataResult, None)``, or ``(None, error)``.
114
+ ``error.cancelled`` is True when the user closed the sheet: not a
115
+ failure to report.
116
+ auth: the ``Auth`` to sign in to (default: ``Auth.auth()``).
117
+ """
118
+
119
+ def got_credential(
120
+ credential: AuthCredential | None, error: AuthError | None
121
+ ) -> None:
122
+ if credential is None:
123
+ callback(None, error)
124
+ return
125
+ (auth or Auth.auth()).sign_in_with_credential(credential, callback)
126
+
127
+ get_google_credential(got_credential)
128
+
129
+
130
+ def sign_out_of_google() -> None:
131
+ """Sign out of Google Sign-In, so the next sign-in shows the account picker.
132
+
133
+ Call it with ``Auth.sign_out()``, which signs out of Firebase only.
134
+ """
135
+ objc_class("GIDSignIn").sharedInstance.signOut()
136
+
137
+
138
+ def on_gid_signin_handle_url(url_string: str) -> bool:
139
+ """Give a URL the app was opened with to Google Sign-In.
140
+
141
+ Call it from your app's "open URL" handler. Newer Google Sign-In versions
142
+ finish without it, so it is a safe backup.
143
+
144
+ Args:
145
+ url_string: the URL.
146
+
147
+ Returns:
148
+ True if Google Sign-In handled the URL; False if it is not a sign-in URL.
149
+ """
150
+ url = objc_class("NSURL").URLWithString_(url_string)
151
+ return bool(objc_class("GIDSignIn").sharedInstance.handleURL_(url))
152
+
153
+
154
+ def on_gid_signin_handle_url_kivy(
155
+ _window: Any, filename: str | bytes, *_args: Any
156
+ ) -> None:
157
+ """Kivy handler: ``Window.bind(on_drop_file=on_gid_signin_handle_url_kivy)``.
158
+
159
+ Kivy (SDL) passes URLs the app was opened with as "dropped files"; this
160
+ forwards them to ``on_gid_signin_handle_url``.
161
+
162
+ Args:
163
+ filename: the URL, as Kivy passes it (``bytes`` or ``str``). The
164
+ other arguments Kivy passes (the window, the position) are ignored.
165
+ """
166
+ url_string = filename.decode("utf-8") if isinstance(filename, bytes) else filename
167
+ on_gid_signin_handle_url(url_string)
@@ -0,0 +1,394 @@
1
+ """Multi-factor authentication: SMS and TOTP (authenticator app) second factors.
2
+
3
+ Enroll a second factor for the signed-in user::
4
+
5
+ mfa = auth.current_user.multi_factor
6
+ mfa.get_session(on_session) # 1. a session
7
+ PhoneAuthProvider().verify_phone_number( # 2. SMS for enrollment
8
+ "+15555550100", on_code_sent, multi_factor_session=session)
9
+ assertion = PhoneMultiFactorGenerator.assertion(phone.credential(verification_id, code))
10
+ mfa.enroll(assertion, "My phone", on_enrolled) # 3. enroll
11
+
12
+ Sign in when a second factor is required::
13
+
14
+ def on_signed_in(result, error):
15
+ if error is not None and error.code == AuthErrorCode.SECOND_FACTOR_REQUIRED:
16
+ resolver = error.resolver # hints: the user's factors
17
+ ... # verify one, then:
18
+ resolver.resolve_sign_in(assertion, on_signed_in)
19
+
20
+ Multi-factor needs Identity Platform (Firebase Authentication with Identity
21
+ Platform) and the factor enabled in the console. Enrolling needs a verified
22
+ email address.
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ __all__ = (
28
+ "PHONE_FACTOR_ID",
29
+ "TOTP_FACTOR_ID",
30
+ "MultiFactor",
31
+ "MultiFactorAssertion",
32
+ "MultiFactorInfo",
33
+ "MultiFactorResolver",
34
+ "MultiFactorSession",
35
+ "PhoneMultiFactorGenerator",
36
+ "PhoneMultiFactorInfo",
37
+ "TOTPMultiFactorGenerator",
38
+ "TOTPSecret",
39
+ )
40
+
41
+ from collections.abc import Callable
42
+ from datetime import datetime
43
+ from typing import TYPE_CHECKING, Final
44
+
45
+ from ..types import ObjCObject
46
+ from ..util import nsdate_to_datetime, objc_class
47
+ from ._common import error_block, result_block, text
48
+ from .errors import AuthError
49
+
50
+ if TYPE_CHECKING:
51
+ from .credentials import AuthCredential
52
+ from .results import AuthDataResult
53
+
54
+ PHONE_FACTOR_ID: Final = "phone"
55
+ """The ``factor_id`` of SMS second factors."""
56
+ TOTP_FACTOR_ID: Final = "totp"
57
+ """The ``factor_id`` of TOTP (authenticator app) second factors."""
58
+
59
+ ErrorCallback = Callable[[AuthError | None], None]
60
+
61
+
62
+ class MultiFactorSession:
63
+ """Proves the first factor was just completed (or that the user is signed
64
+ in, for enrollment). Pass it to SMS verification or ``generate_secret``.
65
+
66
+ Args:
67
+ native: the native ``FIRMultiFactorSession``.
68
+ """
69
+
70
+ def __init__(self, native: ObjCObject) -> None:
71
+ self._native = native
72
+
73
+ @property
74
+ def native(self) -> ObjCObject:
75
+ """The ``FIRMultiFactorSession``."""
76
+ return self._native
77
+
78
+
79
+ class MultiFactorInfo:
80
+ """One enrolled second factor.
81
+
82
+ Args:
83
+ native: the native ``FIRMultiFactorInfo``.
84
+ """
85
+
86
+ def __init__(self, native: ObjCObject) -> None:
87
+ self._native = native
88
+
89
+ @property
90
+ def native(self) -> ObjCObject:
91
+ """The ``FIRMultiFactorInfo``."""
92
+ return self._native
93
+
94
+ @property
95
+ def uid(self) -> str:
96
+ """The factor's ID (its enrollment ID for TOTP sign-in)."""
97
+ return str(self._native.UID)
98
+
99
+ @property
100
+ def factor_id(self) -> str:
101
+ """``PHONE_FACTOR_ID`` or ``TOTP_FACTOR_ID``."""
102
+ return str(self._native.factorID)
103
+
104
+ @property
105
+ def display_name(self) -> str | None:
106
+ """The name given at enrollment, or ``None``."""
107
+ return text(self._native.displayName)
108
+
109
+ @property
110
+ def enrollment_date(self) -> datetime | None:
111
+ """When the factor was enrolled (UTC)."""
112
+ return nsdate_to_datetime(self._native.enrollmentDate)
113
+
114
+ def __repr__(self) -> str:
115
+ return f"{type(self).__name__}(factor_id={self.factor_id!r}, uid={self.uid!r})"
116
+
117
+
118
+ class PhoneMultiFactorInfo(MultiFactorInfo):
119
+ """An enrolled SMS second factor.
120
+
121
+ Args:
122
+ native: the native ``FIRPhoneMultiFactorInfo``.
123
+ """
124
+
125
+ @property
126
+ def phone_number(self) -> str:
127
+ """The phone number, usually masked in sign-in hints (``+*******0100``)."""
128
+ return str(self._native.phoneNumber)
129
+
130
+
131
+ def _wrap_info(native: ObjCObject) -> MultiFactorInfo:
132
+ if str(native.factorID) == PHONE_FACTOR_ID:
133
+ return PhoneMultiFactorInfo(native)
134
+ return MultiFactorInfo(native)
135
+
136
+
137
+ class MultiFactorAssertion:
138
+ """Proof of a second factor, for ``MultiFactor.enroll`` or
139
+ ``MultiFactorResolver.resolve_sign_in``. Make it with
140
+ ``PhoneMultiFactorGenerator`` or ``TOTPMultiFactorGenerator``.
141
+
142
+ Args:
143
+ native: the native ``FIRMultiFactorAssertion``.
144
+ """
145
+
146
+ def __init__(self, native: ObjCObject) -> None:
147
+ self._native = native
148
+
149
+ @property
150
+ def native(self) -> ObjCObject:
151
+ """The ``FIRMultiFactorAssertion``."""
152
+ return self._native
153
+
154
+ @property
155
+ def factor_id(self) -> str:
156
+ """``PHONE_FACTOR_ID`` or ``TOTP_FACTOR_ID``."""
157
+ return str(self._native.factorID)
158
+
159
+
160
+ class PhoneMultiFactorGenerator:
161
+ """Make SMS second-factor assertions."""
162
+
163
+ @staticmethod
164
+ def assertion(credential: AuthCredential) -> MultiFactorAssertion:
165
+ """An assertion from a phone credential.
166
+
167
+ Args:
168
+ credential: from ``PhoneAuthProvider.credential`` after
169
+ ``verify_phone_number`` (enrollment) or
170
+ ``verify_phone_number_for_sign_in`` (sign-in).
171
+
172
+ Returns:
173
+ A ``MultiFactorAssertion`` with ``factor_id`` ``"phone"``.
174
+ """
175
+ return MultiFactorAssertion(
176
+ objc_class("FIRPhoneMultiFactorGenerator").assertionWithCredential_(
177
+ credential.native
178
+ )
179
+ )
180
+
181
+
182
+ class TOTPSecret:
183
+ """A new TOTP secret, to show to the user while they set up their
184
+ authenticator app.
185
+
186
+ Args:
187
+ native: the native ``FIRTOTPSecret``.
188
+ """
189
+
190
+ def __init__(self, native: ObjCObject) -> None:
191
+ self._native = native
192
+
193
+ @property
194
+ def native(self) -> ObjCObject:
195
+ """The ``FIRTOTPSecret``."""
196
+ return self._native
197
+
198
+ def shared_secret_key(self) -> str:
199
+ """The secret, to type into an authenticator app by hand."""
200
+ return str(self._native.sharedSecretKey())
201
+
202
+ def generate_qr_code_url(self, account_name: str, issuer: str) -> str:
203
+ """An ``otpauth://`` URL, to show as a QR code for an authenticator app.
204
+
205
+ Args:
206
+ account_name: shown in the authenticator app, usually the email.
207
+ issuer: your app's name, shown in the authenticator app.
208
+
209
+ Returns:
210
+ The URL.
211
+ """
212
+ return str(
213
+ self._native.generateQRCodeURLWithAccountName_issuer_(account_name, issuer)
214
+ )
215
+
216
+ def open_in_otp_app(self, qr_code_url: str) -> None:
217
+ """Open the URL in an installed authenticator app (if there is one).
218
+
219
+ Args:
220
+ qr_code_url: from ``generate_qr_code_url``.
221
+ """
222
+ self._native.openInOTPAppWithQRCodeURL_(qr_code_url)
223
+
224
+
225
+ class TOTPMultiFactorGenerator:
226
+ """Make TOTP (authenticator app) secrets and assertions."""
227
+
228
+ @staticmethod
229
+ def generate_secret(
230
+ session: MultiFactorSession,
231
+ callback: Callable[[TOTPSecret | None, AuthError | None], None],
232
+ ) -> None:
233
+ """Make a new TOTP secret for enrollment.
234
+
235
+ Args:
236
+ session: from ``MultiFactor.get_session``.
237
+ callback: gets ``(TOTPSecret, None)``, or ``(None, error)``.
238
+ """
239
+ objc_class(
240
+ "FIRTOTPMultiFactorGenerator"
241
+ ).generateSecretWithMultiFactorSession_completion_(
242
+ session.native, result_block(callback, TOTPSecret)
243
+ )
244
+
245
+ @staticmethod
246
+ def assertion_for_enrollment(
247
+ secret: TOTPSecret, one_time_password: str
248
+ ) -> MultiFactorAssertion:
249
+ """An assertion to enroll the authenticator app.
250
+
251
+ Args:
252
+ secret: from ``generate_secret``.
253
+ one_time_password: the 6-digit code the app shows now.
254
+
255
+ Returns:
256
+ A ``MultiFactorAssertion`` with ``factor_id`` ``"totp"``.
257
+ """
258
+ return MultiFactorAssertion(
259
+ objc_class(
260
+ "FIRTOTPMultiFactorGenerator"
261
+ ).assertionForEnrollmentWithSecret_oneTimePassword_(
262
+ secret.native, one_time_password
263
+ )
264
+ )
265
+
266
+ @staticmethod
267
+ def assertion_for_sign_in(
268
+ enrollment_id: str, one_time_password: str
269
+ ) -> MultiFactorAssertion:
270
+ """An assertion to finish a sign-in with the authenticator app.
271
+
272
+ Args:
273
+ enrollment_id: the ``uid`` of the TOTP hint in ``MultiFactorResolver.hints``.
274
+ one_time_password: the 6-digit code the app shows now.
275
+
276
+ Returns:
277
+ A ``MultiFactorAssertion`` with ``factor_id`` ``"totp"``.
278
+ """
279
+ return MultiFactorAssertion(
280
+ objc_class(
281
+ "FIRTOTPMultiFactorGenerator"
282
+ ).assertionForSignInWithEnrollmentID_oneTimePassword_(
283
+ enrollment_id, one_time_password
284
+ )
285
+ )
286
+
287
+
288
+ class MultiFactor:
289
+ """A user's second factors. Get it with ``User.multi_factor``.
290
+
291
+ Args:
292
+ native: the native ``FIRMultiFactor``.
293
+ """
294
+
295
+ def __init__(self, native: ObjCObject) -> None:
296
+ self._native = native
297
+
298
+ @property
299
+ def enrolled_factors(self) -> list[MultiFactorInfo]:
300
+ """The enrolled second factors (``PhoneMultiFactorInfo`` for SMS)."""
301
+ return [_wrap_info(info) for info in self._native.enrolledFactors]
302
+
303
+ def get_session(
304
+ self, callback: Callable[[MultiFactorSession | None, AuthError | None], None]
305
+ ) -> None:
306
+ """Start an enrollment: get a session for SMS verification or a TOTP secret.
307
+
308
+ Args:
309
+ callback: gets ``(MultiFactorSession, None)``, or ``(None, error)``
310
+ (``REQUIRES_RECENT_LOGIN`` if the sign-in is old).
311
+ """
312
+ self._native.getSessionWithCompletion_(
313
+ result_block(callback, MultiFactorSession)
314
+ )
315
+
316
+ def enroll(
317
+ self,
318
+ assertion: MultiFactorAssertion,
319
+ display_name: str | None = None,
320
+ callback: ErrorCallback | None = None,
321
+ ) -> None:
322
+ """Enroll a second factor.
323
+
324
+ Args:
325
+ assertion: from ``PhoneMultiFactorGenerator`` or
326
+ ``TOTPMultiFactorGenerator.assertion_for_enrollment``.
327
+ display_name: a name to show in sign-in hints, for example "Work phone".
328
+ callback: gets ``None`` or the error (``UNVERIFIED_EMAIL`` if the
329
+ email address is not verified yet).
330
+ """
331
+ self._native.enrollWithAssertion_displayName_completion_(
332
+ assertion.native, display_name, error_block(callback)
333
+ )
334
+
335
+ def unenroll(
336
+ self, factor: MultiFactorInfo | str, callback: ErrorCallback | None = None
337
+ ) -> None:
338
+ """Remove a second factor.
339
+
340
+ Args:
341
+ factor: the factor, or its ``uid``.
342
+ callback: gets ``None`` or the error. Removing the factor used to
343
+ sign in signs the user out.
344
+ """
345
+ if isinstance(factor, MultiFactorInfo):
346
+ self._native.unenrollWithInfo_completion_(
347
+ factor.native, error_block(callback)
348
+ )
349
+ else:
350
+ self._native.unenrollWithFactorUID_completion_(
351
+ factor, error_block(callback)
352
+ )
353
+
354
+
355
+ class MultiFactorResolver:
356
+ """Finishes a sign-in that needs a second factor. Get it from
357
+ ``AuthError.resolver`` when ``error.code == AuthErrorCode.SECOND_FACTOR_REQUIRED``.
358
+
359
+ Args:
360
+ native: the native ``FIRMultiFactorResolver``.
361
+ """
362
+
363
+ def __init__(self, native: ObjCObject) -> None:
364
+ self._native = native
365
+
366
+ @property
367
+ def hints(self) -> list[MultiFactorInfo]:
368
+ """The user's enrolled factors: let them choose one."""
369
+ return [_wrap_info(info) for info in self._native.hints]
370
+
371
+ @property
372
+ def session(self) -> MultiFactorSession:
373
+ """The session proving the first factor: pass it to SMS verification."""
374
+ return MultiFactorSession(self._native.session)
375
+
376
+ def resolve_sign_in(
377
+ self,
378
+ assertion: MultiFactorAssertion,
379
+ callback: Callable[[AuthDataResult | None, AuthError | None], None]
380
+ | None = None,
381
+ ) -> None:
382
+ """Finish the sign-in with a second factor.
383
+
384
+ Args:
385
+ assertion: from ``PhoneMultiFactorGenerator.assertion`` or
386
+ ``TOTPMultiFactorGenerator.assertion_for_sign_in``.
387
+ callback: gets ``(AuthDataResult, None)``, or ``(None, error)``
388
+ (``INVALID_VERIFICATION_CODE`` for a wrong code).
389
+ """
390
+ from .results import AuthDataResult
391
+
392
+ self._native.resolveSignInWithAssertion_completion_(
393
+ assertion.native, result_block(callback, AuthDataResult)
394
+ )