@@ -97,7 +97,7 @@ public final class GoTrueClient {
9797 email: email,
9898 password: password,
9999 data: data,
100- gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( hcaptchaToken : ) )
100+ gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( captchaToken : ) )
101101 )
102102 )
103103 )
@@ -121,7 +121,7 @@ public final class GoTrueClient {
121121 password: password,
122122 phone: phone,
123123 data: data,
124- gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( hcaptchaToken : ) )
124+ gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( captchaToken : ) )
125125 )
126126 )
127127 )
@@ -161,6 +161,18 @@ public final class GoTrueClient {
161161 )
162162 }
163163
164+ /// Allows signing in with an ID token issued by certain supported providers.
165+ /// The ID token is verified for validity and a new session is established.
166+ @discardableResult
167+ public func signInWithIdToken( credentials: OpenIDConnectCredentials ) async throws -> Session {
168+ try await _signIn (
169+ request: Paths . token. post (
170+ grantType: . idToken,
171+ . openIDConnectCredentials( credentials)
172+ )
173+ )
174+ }
175+
164176 private func _signIn( request: Request < Session > ) async throws -> Session {
165177 await Env . sessionManager. remove ( )
166178
@@ -200,7 +212,7 @@ public final class GoTrueClient {
200212 email: email,
201213 createUser: shouldCreateUser,
202214 data: data,
203- gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( hcaptchaToken : ) )
215+ gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( captchaToken : ) )
204216 )
205217 )
206218 )
@@ -226,7 +238,7 @@ public final class GoTrueClient {
226238 phone: phone,
227239 createUser: shouldCreateUser,
228240 data: data,
229- gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( hcaptchaToken : ) )
241+ gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( captchaToken : ) )
230242 )
231243 )
232244 )
@@ -251,11 +263,11 @@ public final class GoTrueClient {
251263 URLQueryItem ( name: " provider " , value: provider. rawValue) ,
252264 ]
253265
254- if let scopes = scopes {
266+ if let scopes {
255267 queryItems. append ( URLQueryItem ( name: " scopes " , value: scopes) )
256268 }
257269
258- if let redirectTo = redirectTo {
270+ if let redirectTo {
259271 queryItems. append ( URLQueryItem ( name: " redirect_to " , value: redirectTo. absoluteString) )
260272 }
261273
@@ -383,7 +395,7 @@ public final class GoTrueClient {
383395 )
384396 }
385397
386- guard let session = session else {
398+ guard let session else {
387399 throw GoTrueError . sessionNotFound
388400 }
389401
@@ -399,7 +411,7 @@ public final class GoTrueClient {
399411 let session = try ? await Env . sessionManager. session ( )
400412 await Env . sessionManager. remove ( )
401413
402- if let session = session {
414+ if let session {
403415 try await Env . client. send ( Paths . logout. post. withAuthorization ( session. accessToken) ) . value
404416 }
405417 }
@@ -420,7 +432,7 @@ public final class GoTrueClient {
420432 email: email,
421433 token: token,
422434 type: type,
423- gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( hcaptchaToken : ) )
435+ gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( captchaToken : ) )
424436 )
425437 )
426438 )
@@ -440,7 +452,7 @@ public final class GoTrueClient {
440452 phone: phone,
441453 token: token,
442454 type: type,
443- gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( hcaptchaToken : ) )
455+ gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( captchaToken : ) )
444456 )
445457 )
446458 )
@@ -483,7 +495,7 @@ public final class GoTrueClient {
483495 redirectTo: redirectTo,
484496 RecoverParams (
485497 email: email,
486- gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( hcaptchaToken : ) )
498+ gotrueMetaSecurity: captchaToken. map ( GoTrueMetaSecurity . init ( captchaToken : ) )
487499 )
488500 )
489501 ) . value
0 commit comments