diff --git a/Examples/Examples/HomeView.swift b/Examples/Examples/HomeView.swift index 0372f2c3..66e542a9 100644 --- a/Examples/Examples/HomeView.swift +++ b/Examples/Examples/HomeView.swift @@ -15,12 +15,18 @@ struct HomeView: View { var body: some View { TodoListView() .toolbar { - ToolbarItem(placement: .cancellationAction) { + ToolbarItemGroup(placement: .cancellationAction) { Button("Sign out") { Task { try! await supabase.auth.signOut() } } + + Button("Reauthenticate") { + Task { + try! await supabase.auth.reauthenticate() + } + } } } .task { diff --git a/Sources/Auth/AuthClient.swift b/Sources/Auth/AuthClient.swift index e885c7af..d39988ca 100644 --- a/Sources/Auth/AuthClient.swift +++ b/Sources/Auth/AuthClient.swift @@ -811,6 +811,13 @@ public actor AuthClient { .decoded(decoder: configuration.decoder) } + /// Sends a re-authentication OTP to the user's email or phone number. + public func reauthenticate() async throws { + try await api.authorizedExecute( + Request(path: "/reauthenticate", method: .get) + ) + } + /// Gets the current user details if there is an existing session. /// - Parameter jwt: Takes in an optional access token jwt. If no jwt is provided, user() will /// attempt to get the jwt from the current session. diff --git a/Tests/AuthTests/RequestsTests.swift b/Tests/AuthTests/RequestsTests.swift index 26058294..5263b621 100644 --- a/Tests/AuthTests/RequestsTests.swift +++ b/Tests/AuthTests/RequestsTests.swift @@ -344,6 +344,16 @@ final class RequestsTests: XCTestCase { } } + func testReauthenticate() async { + sessionManager.returnSession = .success(.validSession) + + let sut = makeSUT() + + await assert { + try await sut.reauthenticate() + } + } + private func assert(_ block: () async throws -> Void) async { do { try await block() diff --git a/Tests/AuthTests/__Snapshots__/RequestsTests/testReauthenticate.1.txt b/Tests/AuthTests/__Snapshots__/RequestsTests/testReauthenticate.1.txt new file mode 100644 index 00000000..6a2f6bd8 --- /dev/null +++ b/Tests/AuthTests/__Snapshots__/RequestsTests/testReauthenticate.1.txt @@ -0,0 +1,5 @@ +curl \ + --header "Apikey: dummy.api.key" \ + --header "Authorization: Bearer accesstoken" \ + --header "X-Client-Info: gotrue-swift/x.y.z" \ + "http://localhost:54321/auth/v1/reauthenticate" \ No newline at end of file diff --git a/Tests/RealtimeTests/_PushTests.swift b/Tests/RealtimeTests/_PushTests.swift index 6bb7b863..a78e4e9b 100644 --- a/Tests/RealtimeTests/_PushTests.swift +++ b/Tests/RealtimeTests/_PushTests.swift @@ -5,6 +5,7 @@ // Created by Guilherme Souza on 03/01/24. // +import ConcurrencyExtras @testable import Realtime import XCTest @@ -14,6 +15,12 @@ final class _PushTests: XCTestCase { apiKey: "apikey" )) + override func invokeTest() { + withMainSerialExecutor { + super.invokeTest() + } + } + func testPushWithoutAck() async { let channel = RealtimeChannelV2( topic: "realtime:users", @@ -64,7 +71,6 @@ final class _PushTests: XCTestCase { await push.send() } await Task.megaYield() - await push.didReceive(status: .ok) let status = await task.value diff --git a/supabase-swift.xcworkspace/xcshareddata/swiftpm/Package.resolved b/supabase-swift.xcworkspace/xcshareddata/swiftpm/Package.resolved index 77553e5d..965ec113 100644 --- a/supabase-swift.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/supabase-swift.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/openid/AppAuth-iOS.git", "state" : { - "revision" : "269c90515328c24f90b2ed17a67c8a796b485448", - "version" : "1.7.2" + "revision" : "7e2c09cbeb3bb799f26c268dbedb26325ea722a9", + "version" : "1.7.3" } }, { @@ -95,8 +95,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-custom-dump", "state" : { - "revision" : "3ce83179e5f0c83ad54c305779c6b438e82aaf1d", - "version" : "1.2.1" + "revision" : "f01efb26f3a192a0e88dcdb7c3c391ec2fc25d9c", + "version" : "1.3.0" } }, {