Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: publish v1.0.0-dev.1 #159

Merged
merged 7 commits into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
flutter-version: ['2.5.0', '2.10.5', '3.x']
flutter-version: ['3.x']

runs-on: ${{ matrix.os }}

Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,47 @@
## [1.0.0-dev.1]
- feat: add Mac OS and Windows support for deeplinks
- BREAKING: Remove SupabaseAuthRequiredState as well as overriding methods in SupabaseAuthState
dshukertjr marked this conversation as resolved.
Show resolved Hide resolved
```dart
// Before

await Supabase.initialize(
url: 'SUPABASE_URL',
anonKey: 'SUPABASE_ANON_KEY',
);
...

// Class extending `SupabaseAuthState` or `AuthRequiredState` was necessary
// to persist auth state
class AuthState<T extends StatefulWidget> extends SupabaseAuthState<T> {
...
}

// After

// Initializing Supabase is all you need to do to persist auth state
// Deeplinks will also be automatically handled when you initialize Supabase.
await Supabase.initialize(
url: 'SUPABASE_URL',
anonKey: 'SUPABASE_ANON_KEY',
);

...

// You can get the initial session of the user with `SupabaseAuth.instance.initialSession`
try {
final initialSession = await SupabaseAuth.instance.initialSession;
} catch(error) {
// Handle errors in session initial recovery here
}

// You should now use `onAuthStateChanged` as the
Supabase.instance.client.auth.onAuthStateChange((event, session) {
// handle sinin/ signups here
});
```
- fix: OAuth should open in an external browser
- BREAKING: update supabase package [v1.0.0-dev.1](https://github.com/supabase-community/supabase-dart/blob/main/CHANGELOG.md#100-dev1)
bdlukaa marked this conversation as resolved.
Show resolved Hide resolved

## [0.3.3]
- feat: update supabase package [v0.3.6](https://github.com/supabase-community/supabase-dart/blob/main/CHANGELOG.md#036)

Expand Down
40 changes: 23 additions & 17 deletions lib/src/supabase_auth.dart
Expand Up @@ -102,18 +102,22 @@ class SupabaseAuth with WidgetsBindingObserver {
if (hasPersistedSession) {
final persistedSession = await _instance._localStorage.accessToken();
if (persistedSession != null) {
final response = await Supabase.instance.client.auth
.recoverSession(persistedSession);
final error = response.error;

if (error != null) {
Supabase.instance.log(response.error!.message);
try {
final response = await Supabase.instance.client.auth
.recoverSession(persistedSession);
if (!_instance._initialSessionCompleter.isCompleted) {
_instance._initialSessionCompleter.complete(response.data);
}
} on GotrueError catch (error) {
Supabase.instance.log(error.message);
if (!_instance._initialSessionCompleter.isCompleted) {
_instance._initialSessionCompleter.completeError(error);
}
} catch (error) {
Supabase.instance.log(error.toString());
if (!_instance._initialSessionCompleter.isCompleted) {
_instance._initialSessionCompleter.completeError(error);
}
}
if (!_instance._initialSessionCompleter.isCompleted) {
_instance._initialSessionCompleter.complete(response.data);
}
}
}
Expand Down Expand Up @@ -171,13 +175,12 @@ class SupabaseAuth with WidgetsBindingObserver {
return false;
}

final response =
await Supabase.instance.client.auth.recoverSession(jsonStr);
if (response.error != null) {
try {
await Supabase.instance.client.auth.recoverSession(jsonStr);
return true;
} catch (error) {
SupabaseAuth.instance.localStorage.removePersistedSession();
return false;
} else {
return true;
}
}

Expand Down Expand Up @@ -274,9 +277,12 @@ class SupabaseAuth with WidgetsBindingObserver {

Future<void> _recoverSessionFromUrl(Uri uri) async {
// recover session from deeplink
final response = await Supabase.instance.client.auth.getSessionFromUrl(uri);
if (response.error != null) {
Supabase.instance.log(response.error!.message);
try {
await Supabase.instance.client.auth.getSessionFromUrl(uri);
} on GotrueError catch (error) {
Supabase.instance.log(error.message);
} catch (error) {
Supabase.instance.log(error.toString());
}
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
@@ -1,6 +1,6 @@
name: supabase_flutter
description: Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
version: 0.3.3
version: 1.0.0-dev.1
homepage: 'https://supabase.io'
repository: 'https://github.com/supabase/supabase-flutter'

Expand All @@ -14,7 +14,7 @@ dependencies:
sdk: flutter
hive: ^2.2.1
hive_flutter: ^1.1.0
supabase: ^0.3.6
supabase: ^1.0.0-dev.1
url_launcher: ^6.1.2

dev_dependencies:
Expand Down
17 changes: 11 additions & 6 deletions test/widget_test_stubs.dart
Expand Up @@ -17,8 +17,10 @@ class _MockWidgetState extends State<MockWidget> {
Widget build(BuildContext context) {
return isSignedIn
? TextButton(
onPressed: () {
Supabase.instance.client.auth.signOut();
onPressed: () async {
try {
await Supabase.instance.client.auth.signOut();
} catch (_) {}
},
child: const Text('Sign out'),
)
Expand All @@ -45,7 +47,7 @@ class MockLocalStorage extends LocalStorage {

/// Session expires at is at its maximum value for unix timestamp
accessToken: () async =>
'{"currentSession":{"access_token":"","expires_in":3600,"refresh_token":"","user":{"id":"","aud":"","created_at":"","role":"authenticated","updated_at":""}},"expiresAt":2147483647}',
'{"currentSession":{"token_type": "","access_token":"","expires_in":3600,"refresh_token":"","user":{"app_metadata": {},"id":"","aud":"","created_at":"","role":"authenticated","updated_at":""}},"expiresAt":2147483647}',
persistSession: (_) async {},
removePersistedSession: () async {},
hasAccessToken: () async => true,
Expand All @@ -55,10 +57,13 @@ class MockLocalStorage extends LocalStorage {
// Register the mock handler for uni_links
void mockAppLink() {
const channel = MethodChannel('com.llfbandit.app_links/messages');
const anotherChannel = MethodChannel('com.llfbandit.app_links/events');

TestWidgetsFlutterBinding.ensureInitialized();

TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (call) {
return null;
});
.setMockMethodCallHandler(channel, (call) => null);

TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger
.setMockMethodCallHandler(anotherChannel, (message) => null);
}