Skip to content

Commit

Permalink
Merge branch 'nhost:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
totzk9 authored Dec 4, 2024
2 parents 292af4c + 5fa2f64 commit b91d35c
Show file tree
Hide file tree
Showing 23 changed files with 358 additions and 25 deletions.
110 changes: 110 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,116 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2024-11-28

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`nhost_auth_dart` - `v2.4.0`](#nhost_auth_dart---v240)
- [`nhost_sdk` - `v5.5.0`](#nhost_sdk---v550)
- [`nhost_dart` - `v2.0.7`](#nhost_dart---v207)
- [`nhost_flutter_auth` - `v4.0.7`](#nhost_flutter_auth---v407)
- [`nhost_flutter_graphql` - `v3.0.8`](#nhost_flutter_graphql---v308)
- [`nhost_graphql_adapter` - `v4.0.7`](#nhost_graphql_adapter---v407)
- [`nhost_storage_dart` - `v2.0.7`](#nhost_storage_dart---v207)
- [`nhost_functions_dart` - `v2.0.7`](#nhost_functions_dart---v207)
- [`nhost_gql_links` - `v4.0.8`](#nhost_gql_links---v408)

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.
- `nhost_dart` - `v2.0.7`
- `nhost_flutter_auth` - `v4.0.7`
- `nhost_flutter_graphql` - `v3.0.8`
- `nhost_graphql_adapter` - `v4.0.7`
- `nhost_storage_dart` - `v2.0.7`
- `nhost_functions_dart` - `v2.0.7`
- `nhost_gql_links` - `v4.0.8`

---

#### `nhost_auth_dart` - `v2.4.0`

- **FEAT**: add support for sign-in with id token (#149).

#### `nhost_sdk` - `v5.5.0`

- **FEAT**: add support for sign-in with id token (#149).


## 2024-11-26

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`nhost_auth_dart` - `v2.3.0`](#nhost_auth_dart---v230)
- [`nhost_dart` - `v2.0.6`](#nhost_dart---v206)
- [`nhost_flutter_auth` - `v4.0.6`](#nhost_flutter_auth---v406)
- [`nhost_flutter_graphql` - `v3.0.7`](#nhost_flutter_graphql---v307)
- [`nhost_functions_dart` - `v2.0.6`](#nhost_functions_dart---v206)
- [`nhost_graphql_adapter` - `v4.0.6`](#nhost_graphql_adapter---v406)
- [`nhost_sdk` - `v5.4.0`](#nhost_sdk---v540)
- [`nhost_storage_dart` - `v2.0.6`](#nhost_storage_dart---v206)
- [`nhost_gql_links` - `v4.0.7`](#nhost_gql_links---v407)

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.
- `nhost_gql_links` - `v4.0.7`

---

#### `nhost_auth_dart` - `v2.3.0`

- **REFACTOR**: remove unnecessary and unused files (#148).
- **FEAT**: add email OTP sign-in and verification methods (#150).

#### `nhost_dart` - `v2.0.6`

- **FIX**: test: add required parameter.

#### `nhost_flutter_auth` - `v4.0.6`

- **REFACTOR**: remove unnecessary and unused files (#148).

#### `nhost_flutter_graphql` - `v3.0.7`

- **REFACTOR**: remove unnecessary and unused files (#148).

#### `nhost_functions_dart` - `v2.0.6`

- **REFACTOR**: remove unnecessary and unused files (#148).

#### `nhost_graphql_adapter` - `v4.0.6`

- **REFACTOR**: remove unnecessary and unused files (#148).

#### `nhost_sdk` - `v5.4.0`

- **FIX**: handle null phoneNumber in User fromJson.
- **FEAT**: add email OTP sign-in and verification methods (#150).

#### `nhost_storage_dart` - `v2.0.6`

- **REFACTOR**: remove unnecessary and unused files (#148).


## 2024-07-19

### Changes
Expand Down
9 changes: 9 additions & 0 deletions packages/nhost_auth_dart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 2.4.0

- **FEAT**: add support for sign-in with id token (#149).

## 2.3.0

- **REFACTOR**: remove unnecessary and unused files (#148).
- **FEAT**: add email OTP sign-in and verification methods (#150).

## 2.2.1

- Update a dependency to the latest release.
Expand Down
130 changes: 130 additions & 0 deletions packages/nhost_auth_dart/lib/src/auth_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,83 @@ class NhostAuthClient implements HasuraAuthClient {
return res;
}

/// Authenticates a user using an ID token from a third-party provider.
///
/// This method allows users to sign in using an OpenID Connect [idToken] from a specified
/// [provider] (google, apple). An optional [nonce] parameter can be provided for additional security.
///
/// Throws an [NhostException] if sign in fails.
@override
Future<AuthResponse> signInIdToken({
required String provider,
required String idToken,
String? nonce,
String? locale,
String? defaultRole,
Map<String, Object?>? metadata,
List<String>? roles,
String? displayName,
String? redirectTo,
}) async {
log.finer('Attempting sign in (idToken)');
AuthResponse? res;

try {
res = await _apiClient.post(
'/signin/idtoken',
jsonBody: {
'provider': provider,
'idToken': idToken,
if (nonce != null) 'nonce': nonce,
if (locale != null) 'locale': locale,
if (defaultRole != null) 'defaultRole': defaultRole,
if (metadata != null) 'metadata': metadata,
if (roles != null) 'roles': roles,
if (displayName != null) 'displayName': displayName,
if (redirectTo != null) 'redirectTo': redirectTo,
},
responseDeserializer: AuthResponse.fromJson,
);
} catch (e, st) {
log.finer('Sign in failed', e, st);
await clearSession();
rethrow;
}

if (res != null) {
log.finer('Sign in successful');
await setSession(res.session!);
return res;
} else {
throw AuthServiceException(
'Sign in failed',
);
}
}

/// Links an existing user account to a third-party provider using an OpenID Connect [idToken].
///
/// This method enables linking a user account with an OpenID Connect [idToken] from a specified
/// [provider], such as "google" or "apple". You can optionally provide a [nonce] for enhanced security.
///
/// Throws an [NhostException] if the link attempt fails.
@override
Future<void> linkIdToken({
required String provider,
required String idToken,
String? nonce,
}) async {
await _apiClient.post<String>(
'/link/idtoken',
jsonBody: {
'provider': provider,
'idToken': idToken,
if (nonce != null) 'nonce': nonce,
},
headers: _session.authenticationHeaders,
);
}

/// Signs in a user with a magic link.
///
/// An email will be sent to the [email] with a link. When the user
Expand Down Expand Up @@ -379,6 +456,59 @@ class NhostAuthClient implements HasuraAuthClient {
return res;
}

/// Attempts to send an OTP to the specified [email] to begin the sign-in process
///
/// Throws an [NhostException] if the request fails
@override
Future<void> signInEmailOTP({
required String email,
String? locale,
String? defaultRole,
Map<String, Object?>? metadata,
List<String>? roles,
String? displayName,
String? redirectTo,
}) async {
log.finer('Attempting sign in (otp)');

final includeRoleOptions =
defaultRole != null || (roles != null && roles.isNotEmpty);
final options = {
if (metadata != null) 'metadata': metadata,
if (locale != null) 'locale': locale,
if (includeRoleOptions) 'defaultRole': defaultRole,
if (includeRoleOptions) 'allowedRoles': roles,
if (displayName != null) 'displayName': displayName,
if (redirectTo != null) 'redirectTo': redirectTo,
};
await _apiClient.post(
'/signin/otp/email',
jsonBody: {
'email': email,
if (options.isNotEmpty) 'options': options,
},
);
}

/// Attempts to verify the one-time password (OTP) and complete the sign-in process
///
/// Throws an [NhostException] if verification fails
@override
Future<AuthResponse> verifyEmailOTP({
required String email,
required String otp,
}) async {
final res = await _apiClient.post(
'/signin/otp/email/verify',
jsonBody: {'email': email, 'otp': otp},
responseDeserializer: AuthResponse.fromJson,
);

log.finer('Sign in successful');
await setSession(res.session!);
return res;
}

/// Attempts a sign in using the credentials stored in the [AuthStore]
/// provided during construction.
///
Expand Down
4 changes: 2 additions & 2 deletions packages/nhost_auth_dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nhost_auth_dart
description: Nhost Dart Auth Service SDK
version: 2.2.1
version: 2.4.0
homepage: https://nhost.io
repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_sdk
issue_tracker: https://github.com/nhost/nhost-dart/issues
Expand All @@ -14,7 +14,7 @@ dependencies:
logging: ^1.1.0
meta: ^1.7.0
#Nhost_sdk
nhost_sdk: ^5.3.1
nhost_sdk: ^5.5.0
dev_dependencies:
lints: ^2.0.0
test: ^1.16.0
8 changes: 8 additions & 0 deletions packages/nhost_dart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.0.7

- Update a dependency to the latest release.

## 2.0.6

- **FIX**: test: add required parameter.

## 2.0.5

- **FIX**: test: add required parameter.
Expand Down
14 changes: 7 additions & 7 deletions packages/nhost_dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nhost_dart
description: Nhost Dart SDK
version: 2.0.5
version: 2.0.7
homepage: https://nhost.io
repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_sdk
issue_tracker: https://github.com/nhost/nhost-dart/issues
Expand All @@ -16,11 +16,11 @@ dependencies:
path: ^1.8.0

#NHOST Package
nhost_sdk: ^5.3.1
nhost_storage_dart: ^2.0.5
nhost_auth_dart: ^2.2.1
nhost_functions_dart: ^2.0.5
nhost_graphql_adapter: ^4.0.5
nhost_sdk: ^5.5.0
nhost_storage_dart: ^2.0.7
nhost_auth_dart: ^2.4.0
nhost_functions_dart: ^2.0.7
nhost_graphql_adapter: ^4.0.7
dev_dependencies:
fake_async: ^1.3.1
graphql: ^5.2.0-beta.9
Expand All @@ -33,7 +33,7 @@ dev_dependencies:
test: ^1.22.0
gql: ^1.0.0
gql_exec: ^1.0.0
nhost_gql_links: ^4.0.6
nhost_gql_links: ^4.0.8
async: ^2.10.0
stream_channel: ^2.1.1
web_socket_channel: ^2.2.0
8 changes: 8 additions & 0 deletions packages/nhost_flutter_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 4.0.7

- Update a dependency to the latest release.

## 4.0.6

- **REFACTOR**: remove unnecessary and unused files (#148).

## 4.0.5

- Update a dependency to the latest release.
Expand Down
4 changes: 2 additions & 2 deletions packages/nhost_flutter_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: nhost_flutter_auth
description: >
Provides Nhost authentication state to your Flutter app, making it easy to set
up protected resources, and react to sign ins and sign outs.
version: 4.0.5
version: 4.0.7
homepage: https://nhost.io
repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_flutter_auth
issue_tracker: https://github.com/nhost/nhost-dart/issues
Expand All @@ -15,7 +15,7 @@ dependencies:
flutter:
sdk: flutter
#Nhost_dart
nhost_dart: ^2.0.5
nhost_dart: ^2.0.7
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
8 changes: 8 additions & 0 deletions packages/nhost_flutter_graphql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 3.0.8

- Update a dependency to the latest release.

## 3.0.7

- **REFACTOR**: remove unnecessary and unused files (#148).

## 3.0.6

- Update a dependency to the latest release.
Expand Down
4 changes: 2 additions & 2 deletions packages/nhost_flutter_graphql/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: nhost_flutter_graphql
description: >
Provides GraphQL clients to your Flutter application, automatically configured
to work with Nhost
version: 3.0.6
version: 3.0.8
homepage: https://nhost.io
repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_flutter_graphql
issue_tracker: https://github.com/nhost/nhost-dart/issues
Expand All @@ -18,7 +18,7 @@ dependencies:
logging: ^1.1.0

#Nhost_dart
nhost_flutter_auth: ^4.0.5
nhost_flutter_auth: ^4.0.7
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
Loading

0 comments on commit b91d35c

Please sign in to comment.