@@ -863,29 +863,41 @@ extension Auth: AuthInterop {
863
863
displayName: nil ,
864
864
idToken: nil ,
865
865
requestConfiguration: self . requestConfiguration)
866
-
867
866
#if os(iOS)
868
- self . wrapInjectRecaptcha ( request: request,
869
- action: AuthRecaptchaAction . signUpPassword) { response, error in
870
- if let error {
867
+ Task {
868
+ do {
869
+ let response = try await self . injectRecaptcha (
870
+ request: request,
871
+ action: AuthRecaptchaAction . signUpPassword
872
+ )
873
+ self . internalCreateUserWithEmail (
874
+ request: request,
875
+ inResponse: response,
876
+ decoratedCallback: decoratedCallback
877
+ )
878
+ } catch {
871
879
DispatchQueue . main. async {
872
880
decoratedCallback ( . failure( error) )
873
881
}
874
882
return
875
883
}
876
- self . internalCreateUserWithEmail ( request: request, inResponse: response,
877
- decoratedCallback: decoratedCallback)
878
884
}
879
885
#else
880
- self . internalCreateUserWithEmail ( request: request, decoratedCallback: decoratedCallback)
886
+ self . internalCreateUserWithEmail (
887
+ request: request,
888
+ decoratedCallback: decoratedCallback
889
+ )
881
890
#endif
882
891
}
883
892
}
884
893
885
- func internalCreateUserWithEmail( request: SignUpNewUserRequest ,
886
- inResponse: SignUpNewUserResponse ? = nil ,
887
- decoratedCallback: @escaping ( Result < AuthDataResult , Error > )
888
- -> Void ) {
894
+ private func internalCreateUserWithEmail( request: SignUpNewUserRequest ,
895
+ inResponse: SignUpNewUserResponse ? = nil ,
896
+ decoratedCallback: @escaping ( Result <
897
+ AuthDataResult ,
898
+ Error
899
+ > )
900
+ -> Void ) {
889
901
Task {
890
902
do {
891
903
var response : SignUpNewUserResponse
@@ -1161,12 +1173,15 @@ extension Auth: AuthInterop {
1161
1173
requestConfiguration: self . requestConfiguration
1162
1174
)
1163
1175
#if os(iOS)
1164
- self . wrapInjectRecaptcha ( request: request,
1165
- action: AuthRecaptchaAction . getOobCode) { result, error in
1166
- if let completion {
1167
- DispatchQueue . main. async {
1168
- completion ( error)
1169
- }
1176
+ Task {
1177
+ do {
1178
+ _ = try await self . injectRecaptcha (
1179
+ request: request,
1180
+ action: AuthRecaptchaAction . getOobCode
1181
+ )
1182
+ Auth . wrapMainAsync ( completion, nil )
1183
+ } catch {
1184
+ Auth . wrapMainAsync ( completion, error)
1170
1185
}
1171
1186
}
1172
1187
#else
@@ -1234,12 +1249,15 @@ extension Auth: AuthInterop {
1234
1249
requestConfiguration: self . requestConfiguration
1235
1250
)
1236
1251
#if os(iOS)
1237
- self . wrapInjectRecaptcha ( request: request,
1238
- action: AuthRecaptchaAction . getOobCode) { result, error in
1239
- if let completion {
1240
- DispatchQueue . main. async {
1241
- completion ( error)
1242
- }
1252
+ Task {
1253
+ do {
1254
+ _ = try await self . injectRecaptcha (
1255
+ request: request,
1256
+ action: AuthRecaptchaAction . getOobCode
1257
+ )
1258
+ Auth . wrapMainAsync ( completion, nil )
1259
+ } catch {
1260
+ Auth . wrapMainAsync ( completion, error)
1243
1261
}
1244
1262
}
1245
1263
#else
@@ -2289,21 +2307,6 @@ extension Auth: AuthInterop {
2289
2307
}
2290
2308
2291
2309
#if os(iOS)
2292
- private func wrapInjectRecaptcha< T: AuthRPCRequest > ( request: T ,
2293
- action: AuthRecaptchaAction ,
2294
- _ callback: @escaping (
2295
- ( T . Response ? , Error ? ) -> Void
2296
- ) ) {
2297
- Task {
2298
- do {
2299
- let response = try await injectRecaptcha ( request: request, action: action)
2300
- callback ( response, nil )
2301
- } catch {
2302
- callback ( nil , error)
2303
- }
2304
- }
2305
- }
2306
-
2307
2310
func injectRecaptcha< T: AuthRPCRequest > ( request: T ,
2308
2311
action: AuthRecaptchaAction ) async throws -> T
2309
2312
. Response {
0 commit comments