Skip to content

Commit 70071b3

Browse files
authored
chore: update readme and changelog (#79)
1 parent 41dfe52 commit 70071b3

File tree

2 files changed

+173
-10
lines changed

2 files changed

+173
-10
lines changed

CHANGELOG.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,89 @@
1+
## 3.0.0
2+
3+
### Dependencies update
4+
5+
1. Switch to flutter_web_auth_2 package
6+
Replace the legacy [flutter_web_auth](https://pub.dev/packages/flutter_web_auth) package with the new [flutter_web_auth_2](https://pub.dev/packages/flutter_web_auth_2). Since the `flutter_web_auth` package is no longer maintained, we have to switch to the new package to support the latest Flutter versions.
7+
8+
**flutter_web_auth_2** setup guide:
9+
10+
- iOS: No additional setup required
11+
- Android: In order to capture the callback URL. You wil need to add the following activity to your AndroidManifest.xml file. Replace `YOUR_CALLBACK_URL_SCHEME_HERE` with your actual callback URL scheme (io.logto etc.).
12+
13+
```xml
14+
<manifest>
15+
<application>
16+
17+
<activity
18+
android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
19+
android:exported="true">
20+
<intent-filter android:label="flutter_web_auth_2">
21+
<action android:name="android.intent.action.VIEW" />
22+
<category android:name="android.intent.category.DEFAULT" />
23+
<category android:name="android.intent.category.BROWSABLE" />
24+
<data android:scheme="YOUR_CALLBACK_URL_SCHEME_HERE" />
25+
</intent-filter>
26+
</activity>
27+
28+
</application>
29+
</manifest>
30+
```
31+
32+
Remove any `android:taskAffinity` entries and add set `android:launchMode="singleTop"` to the main activity in the AndroidManifest.xml file.
33+
34+
- Web: Create a new endpoint to capture the callback URL and sent it back to the application using `postMessage` API. The endpoint should be the same as the `redirectUri` parameter in the `signIn` method.
35+
36+
```html
37+
<!DOCTYPE html>
38+
<title>Authentication complete</title>
39+
<p>
40+
Authentication is complete. If this does not happen automatically, please
41+
close the window.
42+
</p>
43+
<script>
44+
function postAuthenticationMessage() {
45+
const message = {
46+
"flutter-web-auth-2": window.location.href,
47+
};
48+
49+
if (window.opener) {
50+
window.opener.postMessage(message, window.location.origin);
51+
window.close();
52+
} else if (window.parent && window.parent !== window) {
53+
window.parent.postMessage(message, window.location.origin);
54+
} else {
55+
localStorage.setItem("flutter-web-auth-2", window.location.href);
56+
window.close();
57+
}
58+
}
59+
60+
postAuthenticationMessage();
61+
</script>
62+
```
63+
64+
Please check the setup guide in the [flutter_web_auth_2](https://pub.dev/packages/flutter_web_auth_2#setup) package for more details.
65+
66+
2. Other patches
67+
- bump crypto package
68+
- bump jose package
69+
- bump json_annotation package
70+
71+
### New features
72+
73+
1. With the latest `flutter_web_auth_2` package, this SDK now supports the Web platform. You can use Logto dart SDK in your Flutter web projects as well. Officially supported platforms are iOS, Android, and Web.
74+
75+
### Bug fixes
76+
77+
1. Fix the namespace missing issue when building with the latest Gradle version on Android. ([#75](https://github.com/logto-io/dart/issues/75))
78+
2. Fix the issue that the webview is not closing after the user completes the OAuth2 authorization flow on Android. ([60](https://github.com/logto-io/dart/issues/60))
79+
3. Fix the issue on Android that the sign-in session is not cleared after the user signs out.
80+
81+
### Breaking changes
82+
83+
`logtoClient.signOut` method now requires a `redirectUri` parameter. For iOS platform, this parameter is useless, but for Android and Web platforms which require an additional `end_session` request to clean up the sign-in session, this parameter will be used as the `post_logout_redirect_uri` parameter in the `end_session` request.
84+
85+
User experience on iOS will not be affected by this change, but for Android and Web platforms, when users click the sign-out button, an `end_session` request will be triggered by opening a webview with the `post_logout_redirect_uri` parameter set to the `redirectUri` value. This will clear the sign-in session and redirect the user back to the `redirectUri` page.
86+
187
## 2.1.0
288

389
### New features

README.md

Lines changed: 87 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,100 @@
66
<span><i><a href="https://logto.io" target="_blank">Logto</a> helps you quickly focus on everything after signing in.</i></span>
77
</p>
88

9-
# Logto Flutter SDKs
9+
# Logto Flutter SDK
1010

1111
[![Build Status](https://github.com/logto-io/kotlin/actions/workflows/main.yml/badge.svg)](https://github.com/logto-io/dart/actions/workflows/main.yml)
1212

13-
Logto's flutter SDK for native apps.
13+
This project is the official Flutter SDK for [Logto](https://logto.io). It provides a simple way to integrate Logto into your Flutter project.
1414

15-
[pub.dev](https://pub.dev/packages/logto_dart_sdk)
15+
In the background, this SDK uses the [flutter_web_auth_2](https://pub.dev/packages/flutter_web_auth_2) package to handle the OAuth2 flow.
1616

17-
## Packages
17+
## Installation
1818

19-
- logto_core: Core SDK is used for generation dart project with basic API and util method provided.
20-
- logto_client: Client SDK for flutter native apps. Built based on logto_core with user sign-in interaction flow integrated
19+
Add the following dependencies to your `pubspec.yaml` file:
2120

22-
## Platforms
21+
```yaml
22+
dependencies:
23+
logto_dart_sdk: ^3.0.0
24+
```
2325
24-
iOS, Android
26+
Then run `flutter pub get` to install the package.
2527

26-
## Integration Guide
28+
Or directly install the package by running:
2729

28-
[Flutter SDK tutorial](https://docs.logto.io/sdk/flutter/)
30+
```bash
31+
flutter pub add logto_dart_sdk
32+
```
33+
34+
Check out the package on [pub.dev](https://pub.dev/packages/logto_dart_sdk).
35+
36+
## Setup
37+
38+
- iOS: No additional setup required.
39+
- [Android](https://github.com/ThexXTURBOXx/flutter_web_auth_2?tab=readme-ov-file#android).
40+
- [Web](https://github.com/ThexXTURBOXx/flutter_web_auth_2?tab=readme-ov-file#web)
41+
42+
Learn more about the [flutter_web_auth_2 setup](https://github.com/ThexXTURBOXx/flutter_web_auth_2?tab=readme-ov-file#setup).
43+
44+
## Usages
45+
46+
### Init Logto SDK
47+
48+
```dart
49+
final logtoConfig = const LogtoConfig(
50+
endpoint: "<your-logto-endpoint>",
51+
appId: "<your-app-id>"
52+
);
53+
54+
void _init() {
55+
logtoClient = LogtoClient(
56+
config: logtoConfig,
57+
httpClient: http.Client(), // Optional http client
58+
);
59+
render();
60+
}
61+
```
62+
63+
### Sign in and sign out
64+
65+
```dart
66+
// Sign in
67+
await logtoClient.signIn(redirectUri);
68+
69+
// Sign out
70+
await logtoClient.signOut(redirectUri);
71+
```
72+
73+
### Full SDK documentation
74+
75+
Check [Flutter SDK guide](https://docs.logto.io/quick-starts/flutter) for more details.
76+
77+
## Supported platforms
78+
79+
iOS, Android, Web
80+
81+
## Migration guide
82+
83+
:::note
84+
For SDK version before 3.0.0, this SDK uses the [flutter_web_auth](https://pub.dev/packages/flutter_web_auth) package.
85+
:::
86+
87+
1. Upgrade to the latest version
88+
89+
```yaml
90+
dependencies:
91+
logto_dart_sdk: ^3.0.0
92+
```
93+
94+
2. Update the manifest files (Android platform only)
95+
96+
Replace the flutter_web_auth callback activity with the new `flutter_web_auth_2` in the AndroidManifest.xml file.
97+
98+
- FlutterWebAuth -> FlutterWebAuth2
99+
- flutter_web_auth -> flutter_web_auth_2
100+
101+
3. `redirectUri` parameter is now required for the `signOut` method.
102+
103+
```dart
104+
await logtoClient.signOut(redirectUri);
105+
```

0 commit comments

Comments
 (0)