@@ -10,7 +10,6 @@ import FirebaseCore
10
10
11
11
import CxxShim
12
12
13
- public typealias User = firebase . auth . User
14
13
public typealias AuthResult = firebase . auth . AuthResult
15
14
16
15
public protocol UserInfo {
@@ -23,13 +22,19 @@ public protocol UserInfo {
23
22
}
24
23
25
24
// TODO(WPP-1581): Improve the API to match the ObjC one better.
26
- extension User {
25
+ public final class User {
26
+ let impl : firebase . auth . User
27
+
28
+ init ( _ impl: firebase . auth . User ) {
29
+ self . impl = impl
30
+ }
31
+
27
32
public var isAnonymous : Bool {
28
- self . is_anonymous ( )
33
+ impl . is_anonymous ( )
29
34
}
30
35
31
36
public var isEmailVerified : Bool {
32
- self . is_email_verified ( )
37
+ impl . is_email_verified ( )
33
38
}
34
39
35
40
public var refreshToken : String ? {
@@ -68,7 +73,7 @@ extension User {
68
73
// fatalError("\(#function) not yet implemented")
69
74
// }
70
75
71
- public mutating func reload( completion: ( ( Error ? ) -> Void ) ? ) {
76
+ public func reload( completion: ( ( Error ? ) -> Void ) ? ) {
72
77
reloadImpl ( ) { error in
73
78
if let completion {
74
79
DispatchQueue . main. async {
@@ -78,7 +83,7 @@ extension User {
78
83
}
79
84
}
80
85
81
- public mutating func reload( ) async throws {
86
+ public func reload( ) async throws {
82
87
try await withCheckedThrowingContinuation { ( continuation: CheckedContinuation < Void , any Error > ) in
83
88
reloadImpl ( ) { error in
84
89
if let error {
@@ -90,15 +95,15 @@ extension User {
90
95
}
91
96
}
92
97
93
- private mutating func reloadImpl( completion: @escaping ( Error ? ) -> Void ) {
94
- let future = swift_firebase. swift_cxx_shims. firebase. auth. user_reload ( self )
98
+ private func reloadImpl( completion: @escaping ( Error ? ) -> Void ) {
99
+ let future = swift_firebase. swift_cxx_shims. firebase. auth. user_reload ( impl )
95
100
future. setCompletion ( {
96
101
let ( _, error) = future. resultAndError
97
102
completion ( error)
98
103
} )
99
104
}
100
105
101
- public mutating func reauthenticate( with credential: Credential , completion: ( ( AuthResult ? , Error ? ) -> Void ) ? ) {
106
+ public func reauthenticate( with credential: Credential , completion: ( ( AuthResult ? , Error ? ) -> Void ) ? ) {
102
107
reauthenticateImpl ( with: credential) { result, error in
103
108
if let completion {
104
109
DispatchQueue . main. async {
@@ -108,7 +113,7 @@ extension User {
108
113
}
109
114
}
110
115
111
- public mutating func reauthenticate( with credential: Credential ) async throws {
116
+ public func reauthenticate( with credential: Credential ) async throws {
112
117
try await withCheckedThrowingContinuation { ( continuation: CheckedContinuation < Void , any Error > ) in
113
118
reauthenticateImpl ( with: credential) { result, error in
114
119
if let error {
@@ -120,8 +125,8 @@ extension User {
120
125
}
121
126
}
122
127
123
- public mutating func reauthenticateImpl( with credential: Credential , completion: @escaping ( AuthResult ? , Error ? ) -> Void ) {
124
- let future = swift_firebase. swift_cxx_shims. firebase. auth. user_reauthenticate_and_retrieve_data ( self , credential)
128
+ public func reauthenticateImpl( with credential: Credential , completion: @escaping ( AuthResult ? , Error ? ) -> Void ) {
129
+ let future = swift_firebase. swift_cxx_shims. firebase. auth. user_reauthenticate_and_retrieve_data ( impl , credential)
125
130
future. setCompletion ( {
126
131
let ( result, error) = future. resultAndError
127
132
completion ( result, error)
@@ -130,20 +135,20 @@ extension User {
130
135
131
136
// -reauthenticateWithProvider:UIDelegate:completion:
132
137
133
- public mutating func getIDTokenResult( ) async throws -> AuthTokenResult {
138
+ public func getIDTokenResult( ) async throws -> AuthTokenResult {
134
139
return try await getIDTokenResult ( forcingRefresh: false )
135
140
}
136
141
137
- public mutating func getIDTokenResult( forcingRefresh forceRefresh: Bool ) async throws
142
+ public func getIDTokenResult( forcingRefresh forceRefresh: Bool ) async throws
138
143
-> AuthTokenResult {
139
144
return try await AuthTokenResult ( idTokenForcingRefresh ( forceRefresh) )
140
145
}
141
146
142
- public mutating func getIDToken( ) async throws -> String {
147
+ public func getIDToken( ) async throws -> String {
143
148
return try await idTokenForcingRefresh ( false )
144
149
}
145
150
146
- public mutating func idTokenForcingRefresh( _ forceRefresh: Bool , completion: ( ( String ? , Error ? ) -> Void ) ? ) {
151
+ public func idTokenForcingRefresh( _ forceRefresh: Bool , completion: ( ( String ? , Error ? ) -> Void ) ? ) {
147
152
idTokenForcingRefreshImpl ( forceRefresh) { result, error in
148
153
if let completion {
149
154
DispatchQueue . main. async {
@@ -153,7 +158,7 @@ extension User {
153
158
}
154
159
}
155
160
156
- public mutating func idTokenForcingRefresh( _ forceRefresh: Bool ) async throws
161
+ public func idTokenForcingRefresh( _ forceRefresh: Bool ) async throws
157
162
-> String {
158
163
try await withCheckedThrowingContinuation { ( continuation: CheckedContinuation < String , any Error > ) in
159
164
idTokenForcingRefreshImpl ( forceRefresh) { result, error in
@@ -166,8 +171,8 @@ extension User {
166
171
}
167
172
}
168
173
169
- private mutating func idTokenForcingRefreshImpl( _ forceRefresh: Bool , completion: @escaping ( String ? , Error ? ) -> Void ) {
170
- let future = swift_firebase. swift_cxx_shims. firebase. auth. user_get_token ( self , forceRefresh)
174
+ private func idTokenForcingRefreshImpl( _ forceRefresh: Bool , completion: @escaping ( String ? , Error ? ) -> Void ) {
175
+ let future = swift_firebase. swift_cxx_shims. firebase. auth. user_get_token ( impl , forceRefresh)
171
176
future. setCompletion ( {
172
177
let ( result, error) = future. resultAndError
173
178
let stringResult : String ?
@@ -191,7 +196,7 @@ extension User {
191
196
fatalError ( " \( #function) not yet implemented " )
192
197
}
193
198
194
- public mutating func sendEmailVerification( completion: ( ( Error ? ) -> Void ) ? ) {
199
+ public func sendEmailVerification( completion: ( ( Error ? ) -> Void ) ? ) {
195
200
sendEmailVerificationImpl ( ) { error in
196
201
if let completion {
197
202
DispatchQueue . main. async {
@@ -201,7 +206,7 @@ extension User {
201
206
}
202
207
}
203
208
204
- public mutating func sendEmailVerification( ) async throws {
209
+ public func sendEmailVerification( ) async throws {
205
210
try await withCheckedThrowingContinuation { ( continuation: CheckedContinuation < Void , any Error > ) in
206
211
sendEmailVerificationImpl ( ) { error in
207
212
if let error {
@@ -213,9 +218,8 @@ extension User {
213
218
}
214
219
}
215
220
216
- public mutating func sendEmailVerificationImpl( completion: @escaping ( Error ? ) -> Void ) {
217
- //let future = self.SendEmailVerification()
218
- let future = swift_firebase. swift_cxx_shims. firebase. auth. user_send_email_verification ( self )
221
+ public func sendEmailVerificationImpl( completion: @escaping ( Error ? ) -> Void ) {
222
+ let future = swift_firebase. swift_cxx_shims. firebase. auth. user_send_email_verification ( impl)
219
223
future. setCompletion ( {
220
224
let ( _, error) = future. resultAndError
221
225
completion ( error)
@@ -242,30 +246,30 @@ extension User {
242
246
243
247
extension User : UserInfo {
244
248
public var providerID : String {
245
- String ( swift_firebase. swift_cxx_shims. firebase. auth. user_provider_id ( self ) )
249
+ String ( swift_firebase. swift_cxx_shims. firebase. auth. user_provider_id ( impl ) )
246
250
}
247
251
248
252
public var uid : String {
249
- String ( swift_firebase. swift_cxx_shims. firebase. auth. user_uid ( self ) )
253
+ String ( swift_firebase. swift_cxx_shims. firebase. auth. user_uid ( impl ) )
250
254
}
251
255
252
256
public var displayName : String ? {
253
- let name = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_display_name ( self ) )
257
+ let name = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_display_name ( impl ) )
254
258
return name. isEmpty ? nil : name
255
259
}
256
260
257
261
public var photoURL : URL ? {
258
- let url = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_photo_url ( self ) )
262
+ let url = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_photo_url ( impl ) )
259
263
return url. isEmpty ? nil : URL ( string: url)
260
264
}
261
265
262
266
public var email : String ? {
263
- let email = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_email ( self ) )
267
+ let email = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_email ( impl ) )
264
268
return email. isEmpty ? nil : email
265
269
}
266
270
267
271
public var phoneNumber : String ? {
268
- let number = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_phone_number ( self ) )
272
+ let number = String ( swift_firebase. swift_cxx_shims. firebase. auth. user_phone_number ( impl ) )
269
273
return number. isEmpty ? nil : number
270
274
}
271
275
}
0 commit comments