diff --git a/packages/celest_auth/CHANGELOG.md b/packages/celest_auth/CHANGELOG.md index 82866d4c..eef20f21 100644 --- a/packages/celest_auth/CHANGELOG.md +++ b/packages/celest_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0-dev.2 + +- Clear browser cookies on `signOut` + ## 0.3.0-dev.1 - Initial version. diff --git a/packages/celest_auth/lib/src/auth.dart b/packages/celest_auth/lib/src/auth.dart index 98c0b7b2..c44127fe 100644 --- a/packages/celest_auth/lib/src/auth.dart +++ b/packages/celest_auth/lib/src/auth.dart @@ -20,5 +20,5 @@ abstract interface class Auth { Stream get authStateChanges; /// Signs out the current user, if any. - void signOut(); + Future signOut(); } diff --git a/packages/celest_auth/lib/src/auth_impl.dart b/packages/celest_auth/lib/src/auth_impl.dart index 6e6aa108..eb0cb8db 100644 --- a/packages/celest_auth/lib/src/auth_impl.dart +++ b/packages/celest_auth/lib/src/auth_impl.dart @@ -82,10 +82,14 @@ final class AuthImpl implements Auth { } @override - void signOut() { + Future signOut() async { localStorage.delete('userId'); secureStorage.delete('cork'); - _authStateController.add(const Unauthenticated()); + try { + await protocol.signOut(); + } finally { + _authStateController.add(const Unauthenticated()); + } } final CelestBase celest; diff --git a/packages/celest_auth/pubspec.yaml b/packages/celest_auth/pubspec.yaml index dbe7ea85..dbb2918f 100644 --- a/packages/celest_auth/pubspec.yaml +++ b/packages/celest_auth/pubspec.yaml @@ -1,6 +1,6 @@ name: celest_auth description: The Auth runtime and client library for Celest, the Flutter cloud platform. -version: 0.3.0-dev.1 +version: 0.3.0-dev.2 homepage: https://celest.dev repository: https://github.com/celest-dev/celest/tree/main/packages/celest_auth @@ -12,7 +12,7 @@ dependencies: built_collection: ^5.1.1 built_value: ^8.9.1 cedar: ^0.1.0 - celest_core: ^0.3.0-dev.1 + celest_core: ^0.3.0-dev.2 chunked_stream: ^1.4.2 corks_cedar: ^0.1.0 ffi: ^2.1.2 diff --git a/packages/celest_core/CHANGELOG.md b/packages/celest_core/CHANGELOG.md index e4d89a51..0dde39b5 100644 --- a/packages/celest_core/CHANGELOG.md +++ b/packages/celest_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0-dev.2 + +- Add `signOut` method to `AuthProtocol` for clearing browser cookies + ## 0.3.0-dev.1 - Adds `SecureStorage` interface for storage of sensitive data in the platform keychain diff --git a/packages/celest_core/lib/src/auth/auth_client.dart b/packages/celest_core/lib/src/auth/auth_client.dart index a18d9d3b..a6599d30 100644 --- a/packages/celest_core/lib/src/auth/auth_client.dart +++ b/packages/celest_core/lib/src/auth/auth_client.dart @@ -16,6 +16,11 @@ final class AuthClient with BaseProtocol implements AuthProtocol { return User.fromJson(response); } + @override + Future signOut() async { + await postJson('/_auth/sign-out', {}); + } + @override late final EmailClient email = EmailClient(celest); } diff --git a/packages/celest_core/lib/src/auth/auth_protocol.dart b/packages/celest_core/lib/src/auth/auth_protocol.dart index 3a7712c6..d5bbec0a 100644 --- a/packages/celest_core/lib/src/auth/auth_protocol.dart +++ b/packages/celest_core/lib/src/auth/auth_protocol.dart @@ -5,6 +5,7 @@ abstract interface class AuthProtocol { EmailProtocol get email; Future userInfo(); + Future signOut(); } abstract interface class EmailProtocol { diff --git a/packages/celest_core/pubspec.yaml b/packages/celest_core/pubspec.yaml index 88c0916f..b35d4c3c 100644 --- a/packages/celest_core/pubspec.yaml +++ b/packages/celest_core/pubspec.yaml @@ -1,6 +1,6 @@ name: celest_core description: Celest types and utilities shared between the client and the cloud. -version: 0.3.0-dev.1 +version: 0.3.0-dev.2 homepage: https://celest.dev repository: https://github.com/celest-dev/celest/tree/main/packages/celest_core