Skip to content

Commit

Permalink
Merge branch 'main' into fix-android-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
sharjeelyunus authored Jan 20, 2025
2 parents 567a8cb + e43805e commit ba8bc56
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 28 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,53 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2025-01-16

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`ensemble` - `v1.1.15`](#ensemble---v1115)
- [`ensemble_chat` - `v0.0.1+1`](#ensemble_chat---v0011)
- [`ensemble_auth` - `v1.0.1`](#ensemble_auth---v101)
- [`ensemble_camera` - `v0.0.1+1`](#ensemble_camera---v0011)
- [`ensemble_location` - `v0.0.1+1`](#ensemble_location---v0011)
- [`ensemble_contacts` - `v0.0.1+1`](#ensemble_contacts---v0011)
- [`ensemble_file_manager` - `v0.0.1+1`](#ensemble_file_manager---v0011)
- [`ensemble_bluetooth` - `v0.0.1+1`](#ensemble_bluetooth---v0011)
- [`ensemble_connect` - `v0.0.1+1`](#ensemble_connect---v0011)
- [`ensemble_deeplink` - `v0.0.1+1`](#ensemble_deeplink---v0011)
- [`ensemble_network_info` - `v0.0.1+1`](#ensemble_network_info---v0011)

Packages with dependency updates only:

> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `ensemble_chat` - `v0.0.1+1`
- `ensemble_auth` - `v1.0.1`
- `ensemble_camera` - `v0.0.1+1`
- `ensemble_location` - `v0.0.1+1`
- `ensemble_contacts` - `v0.0.1+1`
- `ensemble_file_manager` - `v0.0.1+1`
- `ensemble_bluetooth` - `v0.0.1+1`
- `ensemble_connect` - `v0.0.1+1`
- `ensemble_deeplink` - `v0.0.1+1`
- `ensemble_network_info` - `v0.0.1+1`

---

#### `ensemble` - `v1.1.15`

- **FIX**: type comma. ([f0749e36](https://github.com/ensembleUI/ensemble/commit/f0749e36da3e1f3e39866039b1062bd8f81319ee))
- **FIX**: typo missing semi-colon. ([76d0d99a](https://github.com/ensembleUI/ensemble/commit/76d0d99a8a7f0a2b0f583cb7888c649cfd0b3282))


## 2025-01-07

### Changes
Expand Down
30 changes: 24 additions & 6 deletions modules/auth/lib/signin/auth_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,26 @@ class AuthManager with UserAuthentication {
Future<String?> signInWithSocialCredential(BuildContext context,
{required AuthenticatedUser user,
required String idToken,
AuthToken? token}) async {
AuthToken? token,
/// Optional string but required to complete Firebase Auth Sign-In with Apple flow.
///
/// This is the authorization code returned by Apple Sign In and will be used to authenticate with Firebase as the accessToken.
///
/// Can be `null` since it only applies to Apple Sign In
/// See [Firebase docs](https://firebase.google.com/docs/auth/ios/apple#sign_in_with_apple_and_authenticate_with_firebase) for more information.
/// Inspriration from [Mediuam](https://medium.com/@muhammad.fathy/resolving-the-firebase-auth-invalid-credential-invalid-oauth-response-from-apple-com-6bca6b6a8575)
String? authCode,
/// Optional string which, if set, will be be embedded in the resulting `identityToken` for Firebase Auth Sign-In with Apple flow.
///
/// This can be used to mitigate replay attacks by using a unique argument per sign-in attempt.
///
/// Can be `null`, in which case no nonce will be passed to the request.
/// See [Firebase docs](https://firebase.google.com/docs/auth/ios/apple#sign_in_with_apple_and_authenticate_with_firebase) for more information.
String? rawNonce}) async {
if (user.provider == null || user.provider == SignInProvider.local) {
return _signInLocally(context, user: user);
} else if (user.provider == SignInProvider.firebase) {
return _signInWithFirebase(context, user: user, idToken: idToken);
return _signInWithFirebase(context, user: user, idToken: idToken, authCode: authCode, rawNonce: rawNonce);
}
// else if (user.provider == SignInProvider.auth0) {
// return _updateCurrentUser(context, user);
Expand Down Expand Up @@ -133,12 +148,14 @@ class AuthManager with UserAuthentication {
Future<String?> _signInWithFirebase(BuildContext context,
{required AuthenticatedUser user,
required String idToken,
AuthToken? token}) async {
AuthToken? token,
String? authCode,
String? rawNonce}) async {
// initialize Firebase once
customFirebaseApp ??= await _initializeFirebaseSignIn();

final credential = _formatCredential(
client: user.client, idToken: idToken, accessToken: token?.token);
client: user.client, idToken: idToken, accessToken: token?.token, authCode: authCode, rawNonce: rawNonce);
final UserCredential authResult =
await FirebaseAuth.instanceFor(app: customFirebaseApp!)
.signInWithCredential(credential);
Expand All @@ -153,12 +170,13 @@ class AuthManager with UserAuthentication {
}

OAuthCredential _formatCredential(
{SignInClient? client, required String idToken, String? accessToken}) {
{SignInClient? client, required String idToken, String? accessToken, String? authCode, String? rawNonce}) {
if (client == SignInClient.google) {
return GoogleAuthProvider.credential(
idToken: idToken, accessToken: accessToken);
} else if (client == SignInClient.apple) {
return OAuthProvider('apple.com').credential(idToken: idToken);
/// Supply rawNonce and authCode as the accessToken to complete the Apple Sign In Flow
return OAuthProvider('apple.com').credential(idToken: idToken, rawNonce: rawNonce, accessToken: authCode);
}
throw RuntimeError("Invalid Sign In Client");
}
Expand Down
16 changes: 11 additions & 5 deletions modules/auth/lib/signin/widget/sign_in_with_apple.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:developer';
import 'dart:convert';
import 'dart:io';

import 'package:crypto/crypto.dart';
import 'package:ensemble/framework/action.dart';
import 'package:ensemble/framework/error_handling.dart';
import 'package:ensemble/framework/event.dart';
Expand Down Expand Up @@ -79,12 +80,17 @@ class SignInWithAppleState extends EWidgetState<SignInWithAppleImpl> {
buttonController: widget._controller,
onTap: () async {
try {
/// Generate a cryptographically secure nonce for Apple Sign In
final rawNonce = generateNonce();
/// Hash the nonce for later use within the Apple Sign In request for secure verification.
/// This is the nonce that will be used to verify the identity token after the user signs in with Apple.
final nonce = sha256.convert(utf8.encode(rawNonce)).toString();
final credential =
await SignInWithApple.getAppleIDCredential(scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
]);
_onAuthenticated(credential);
], nonce: nonce);
_onAuthenticated(credential, rawNonce);
} catch (e) {
log(e.toString());
if (widget._controller.onError != null) {
Expand All @@ -105,7 +111,7 @@ class SignInWithAppleState extends EWidgetState<SignInWithAppleImpl> {
return button;
}

void _onAuthenticated(AuthorizationCredentialAppleID credential) async {
void _onAuthenticated(AuthorizationCredentialAppleID credential, String rawNonce) async {
if (credential.identityToken == null) {
throw RuntimeError('Invalid token.');
}
Expand All @@ -121,7 +127,7 @@ class SignInWithAppleState extends EWidgetState<SignInWithAppleImpl> {
if (widget._controller.provider != SignInProvider.server) {
// Apple don't have any access token related.
await AuthManager().signInWithSocialCredential(context,
user: user, idToken: credential.identityToken!);
user: user, idToken: credential.identityToken!, authCode: credential.authorizationCode, rawNonce: rawNonce);

// trigger onSignIn callback
if (widget._controller.onSignedIn != null) {
Expand Down Expand Up @@ -192,4 +198,4 @@ class SignInWithAppleState extends EWidgetState<SignInWithAppleImpl> {
}
return null;
}
}
}
2 changes: 1 addition & 1 deletion modules/auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

ensemble_ts_interpreter:
Expand Down
2 changes: 1 addition & 1 deletion modules/bracket/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion modules/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble
ensemble_ts_interpreter:
git:
Expand Down
2 changes: 1 addition & 1 deletion modules/chat/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

ensemble_ts_interpreter:
Expand Down
2 changes: 1 addition & 1 deletion modules/connect/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

plaid_flutter: ^3.1.2
Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

flutter_contacts: ^1.1.7+1
Expand Down
2 changes: 1 addition & 1 deletion modules/deeplink/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

flutter_branch_sdk: ^7.0.1
Expand Down
5 changes: 5 additions & 0 deletions modules/ensemble/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.15

- **FIX**: type comma. ([f0749e36](https://github.com/ensembleUI/ensemble/commit/f0749e36da3e1f3e39866039b1062bd8f81319ee))
- **FIX**: typo missing semi-colon. ([76d0d99a](https://github.com/ensembleUI/ensemble/commit/76d0d99a8a7f0a2b0f583cb7888c649cfd0b3282))

## 1.1.14

## 1.1.13
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble/lib/action/action_invokable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class ActionInvokable with Invokable {
ActionType.dismissDialog,
ActionType.closeAllDialogs,
ActionType.executeActionGroup,
ActionType.takeScreenshot
ActionType.takeScreenshot,
ActionType.saveFile,
ActionType.controlDeviceBackNavigation,
ActionType.closeApp,
Expand Down
3 changes: 3 additions & 0 deletions modules/ensemble/lib/ensemble_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const String backgroundBluetoothSubscribeTask = 'backgroundBluetoothSubscribeTas

const String ensembleMethodChannelName = 'com.ensembleui.host.platform';
GlobalKey<NavigatorState>? externalAppNavigateKey;
ScrollController? externalScrollController;

@pragma('vm:entry-point')
void callbackDispatcher() {
Expand Down Expand Up @@ -104,8 +105,10 @@ class EnsembleApp extends StatefulWidget {
this.onAppLoad,
this.forcedLocale,
GlobalKey<NavigatorState>? navigatorKey,
ScrollController? screenScroller,
}) {
externalAppNavigateKey = navigatorKey;
externalScrollController = screenScroller;
}

final ScreenPayload? screenPayload;
Expand Down
6 changes: 5 additions & 1 deletion modules/ensemble/lib/framework/view/page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:developer';

import 'package:ensemble/ensemble.dart';
import 'package:ensemble/ensemble_app.dart';
import 'package:ensemble/framework/data_context.dart';
import 'package:ensemble/framework/devmode.dart';
import 'package:ensemble/framework/event.dart';
Expand Down Expand Up @@ -583,7 +584,10 @@ class PageState extends State<Page>
child: getBody(appBar != null),
));

return CustomScrollView(slivers: slivers);
return CustomScrollView(
controller: externalScrollController,
slivers: slivers,
);
}

Widget getBody(bool hasAppBar) {
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description: Ensemble Runtime
# This version is used _only_ for the Runner app, which is used if you just do
# a `flutter run` or a `flutter make-host-app-editable`. It has no impact
# on any other native host app that you embed your Flutter project into.
version: 1.1.14
version: 1.1.15

environment:
sdk: ">=3.5.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble_bluetooth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble
ensemble_ts_interpreter:
git:
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble_network_info/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

network_info_plus: ^5.0.3
Expand Down
2 changes: 1 addition & 1 deletion modules/file_manager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble
ensemble_ts_interpreter:
git:
Expand Down
2 changes: 1 addition & 1 deletion modules/firebase_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion modules/location/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

ensemble_ts_interpreter:
Expand Down
2 changes: 1 addition & 1 deletion modules/moengage/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble

moengage_flutter: ^8.0.0
Expand Down
2 changes: 1 addition & 1 deletion starter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.14
ref: ensemble-v1.1.15
path: modules/ensemble


Expand Down

0 comments on commit ba8bc56

Please sign in to comment.