diff --git a/CHANGELOG.md b/CHANGELOG.md index 459bb6cf..b25979cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/nhost_auth_dart/CHANGELOG.md b/packages/nhost_auth_dart/CHANGELOG.md index abc74238..fa44af0b 100644 --- a/packages/nhost_auth_dart/CHANGELOG.md +++ b/packages/nhost_auth_dart/CHANGELOG.md @@ -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. diff --git a/packages/nhost_auth_dart/lib/src/auth_client.dart b/packages/nhost_auth_dart/lib/src/auth_client.dart index 4fd6bd0f..a621324e 100644 --- a/packages/nhost_auth_dart/lib/src/auth_client.dart +++ b/packages/nhost_auth_dart/lib/src/auth_client.dart @@ -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 signInIdToken({ + required String provider, + required String idToken, + String? nonce, + String? locale, + String? defaultRole, + Map? metadata, + List? 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 linkIdToken({ + required String provider, + required String idToken, + String? nonce, + }) async { + await _apiClient.post( + '/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 @@ -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 signInEmailOTP({ + required String email, + String? locale, + String? defaultRole, + Map? metadata, + List? 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 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. /// diff --git a/packages/nhost_auth_dart/pubspec.yaml b/packages/nhost_auth_dart/pubspec.yaml index 10729211..aa3b1d47 100644 --- a/packages/nhost_auth_dart/pubspec.yaml +++ b/packages/nhost_auth_dart/pubspec.yaml @@ -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 @@ -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 diff --git a/packages/nhost_dart/CHANGELOG.md b/packages/nhost_dart/CHANGELOG.md index 69b0cecc..65140826 100644 --- a/packages/nhost_dart/CHANGELOG.md +++ b/packages/nhost_dart/CHANGELOG.md @@ -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. diff --git a/packages/nhost_dart/pubspec.yaml b/packages/nhost_dart/pubspec.yaml index 4ba80989..05562218 100644 --- a/packages/nhost_dart/pubspec.yaml +++ b/packages/nhost_dart/pubspec.yaml @@ -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 @@ -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 @@ -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 diff --git a/packages/nhost_flutter_auth/CHANGELOG.md b/packages/nhost_flutter_auth/CHANGELOG.md index b811026e..82085b00 100644 --- a/packages/nhost_flutter_auth/CHANGELOG.md +++ b/packages/nhost_flutter_auth/CHANGELOG.md @@ -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. diff --git a/packages/nhost_flutter_auth/pubspec.yaml b/packages/nhost_flutter_auth/pubspec.yaml index 840a4b9d..b35c7fa8 100644 --- a/packages/nhost_flutter_auth/pubspec.yaml +++ b/packages/nhost_flutter_auth/pubspec.yaml @@ -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 @@ -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 diff --git a/packages/nhost_flutter_graphql/CHANGELOG.md b/packages/nhost_flutter_graphql/CHANGELOG.md index d48bdcf8..0baf71f3 100644 --- a/packages/nhost_flutter_graphql/CHANGELOG.md +++ b/packages/nhost_flutter_graphql/CHANGELOG.md @@ -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. diff --git a/packages/nhost_flutter_graphql/pubspec.yaml b/packages/nhost_flutter_graphql/pubspec.yaml index 99926f79..7f591d62 100644 --- a/packages/nhost_flutter_graphql/pubspec.yaml +++ b/packages/nhost_flutter_graphql/pubspec.yaml @@ -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 @@ -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 diff --git a/packages/nhost_functions_dart/CHANGELOG.md b/packages/nhost_functions_dart/CHANGELOG.md index b2c4e666..b5e63a72 100644 --- a/packages/nhost_functions_dart/CHANGELOG.md +++ b/packages/nhost_functions_dart/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.7 + + - Update a dependency to the latest release. + +## 2.0.6 + + - **REFACTOR**: remove unnecessary and unused files (#148). + ## 2.0.5 - Update a dependency to the latest release. diff --git a/packages/nhost_functions_dart/pubspec.yaml b/packages/nhost_functions_dart/pubspec.yaml index 6ecc1b3f..b2e11ace 100644 --- a/packages/nhost_functions_dart/pubspec.yaml +++ b/packages/nhost_functions_dart/pubspec.yaml @@ -1,6 +1,6 @@ name: nhost_functions_dart description: Nhost Dart Functions Service 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 @@ -13,7 +13,7 @@ dependencies: http: ^1.1.0 logging: ^1.1.0 #Nhost_sdk - nhost_sdk: ^5.3.1 + nhost_sdk: ^5.5.0 dev_dependencies: lints: ^2.0.0 test: ^1.16.0 diff --git a/packages/nhost_gql_links/CHANGELOG.md b/packages/nhost_gql_links/CHANGELOG.md index c14a3f50..07161cce 100644 --- a/packages/nhost_gql_links/CHANGELOG.md +++ b/packages/nhost_gql_links/CHANGELOG.md @@ -1,3 +1,11 @@ +## 4.0.8 + + - Update a dependency to the latest release. + +## 4.0.7 + + - Update a dependency to the latest release. + ## 4.0.6 - Update a dependency to the latest release. diff --git a/packages/nhost_gql_links/pubspec.yaml b/packages/nhost_gql_links/pubspec.yaml index c9bb6cf8..38b6064d 100644 --- a/packages/nhost_gql_links/pubspec.yaml +++ b/packages/nhost_gql_links/pubspec.yaml @@ -1,5 +1,5 @@ name: nhost_gql_links -version: 4.0.6 +version: 4.0.8 description: Constructs GraphQL links for use with graphql and ferry packages homepage: https://nhost.io repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_gql_links @@ -20,7 +20,7 @@ dependencies: web_socket_channel: ^2.2.0 #Nhost_dart - nhost_sdk: ^5.3.1 + nhost_sdk: ^5.5.0 dev_dependencies: async: ^2.10.0 fake_async: ^1.3.1 diff --git a/packages/nhost_graphql_adapter/CHANGELOG.md b/packages/nhost_graphql_adapter/CHANGELOG.md index 98cfe888..fe91ceaf 100644 --- a/packages/nhost_graphql_adapter/CHANGELOG.md +++ b/packages/nhost_graphql_adapter/CHANGELOG.md @@ -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. diff --git a/packages/nhost_graphql_adapter/example/pubspec.yaml b/packages/nhost_graphql_adapter/example/pubspec.yaml index e39a4f89..fbf0a448 100644 --- a/packages/nhost_graphql_adapter/example/pubspec.yaml +++ b/packages/nhost_graphql_adapter/example/pubspec.yaml @@ -10,6 +10,6 @@ dependencies: graphql: ^5.2.0-beta.9 # Nhost packages - nhost_dart: ^2.0.5 + nhost_dart: ^2.0.7 dev_dependencies: lints: any diff --git a/packages/nhost_graphql_adapter/pubspec.yaml b/packages/nhost_graphql_adapter/pubspec.yaml index 1c5435b2..556ecf94 100644 --- a/packages/nhost_graphql_adapter/pubspec.yaml +++ b/packages/nhost_graphql_adapter/pubspec.yaml @@ -1,5 +1,5 @@ name: nhost_graphql_adapter -version: 4.0.5 +version: 4.0.7 description: Easily connect to your Nhost.io GraphQL backend using the graphql package. homepage: https://nhost.io repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_graphql_adapter @@ -14,8 +14,8 @@ dependencies: meta: ^1.7.0 #Nhost_dart - nhost_gql_links: ^4.0.6 - nhost_sdk: ^5.3.1 + nhost_gql_links: ^4.0.8 + nhost_sdk: ^5.5.0 dev_dependencies: async: ^2.10.0 lints: any diff --git a/packages/nhost_sdk/CHANGELOG.md b/packages/nhost_sdk/CHANGELOG.md index 641e9907..00293071 100644 --- a/packages/nhost_sdk/CHANGELOG.md +++ b/packages/nhost_sdk/CHANGELOG.md @@ -1,3 +1,12 @@ +## 5.5.0 + + - **FEAT**: add support for sign-in with id token (#149). + +## 5.4.0 + + - **FIX**: handle null phoneNumber in User fromJson. + - **FEAT**: add email OTP sign-in and verification methods (#150). + ## 5.3.1 - **FIX**: handle null phoneNumber in User fromJson. diff --git a/packages/nhost_sdk/lib/src/base/hasura_auth_client.dart b/packages/nhost_sdk/lib/src/base/hasura_auth_client.dart index 08737f75..3e54b0db 100644 --- a/packages/nhost_sdk/lib/src/base/hasura_auth_client.dart +++ b/packages/nhost_sdk/lib/src/base/hasura_auth_client.dart @@ -38,6 +38,12 @@ abstract class HasuraAuthClient { required String password, }); + Future signInIdToken( + {required String provider, required String idToken, String? nonce}); + + Future linkIdToken( + {required String provider, required String idToken, String? nonce}); + Future signInWithEmailPasswordless( String email, { String? redirectTo, @@ -63,6 +69,19 @@ abstract class HasuraAuthClient { String otp, ); + Future signInEmailOTP({ + required String email, + String? locale, + String? defaultRole, + Map? metadata, + List? roles, + String? displayName, + String? redirectTo, + }); + + Future verifyEmailOTP( + {required String email, required String otp}); + Future signInWithStoredCredentials(); Future signInWithRefreshToken(String refreshToken); diff --git a/packages/nhost_sdk/pubspec.yaml b/packages/nhost_sdk/pubspec.yaml index 5933bfa3..b4901902 100644 --- a/packages/nhost_sdk/pubspec.yaml +++ b/packages/nhost_sdk/pubspec.yaml @@ -1,6 +1,6 @@ name: nhost_sdk description: Nhost authentication and file storage/retrieval APIs for the Dart language. -version: 5.3.1 +version: 5.5.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 diff --git a/packages/nhost_storage_dart/CHANGELOG.md b/packages/nhost_storage_dart/CHANGELOG.md index 470e4f09..5c140aab 100644 --- a/packages/nhost_storage_dart/CHANGELOG.md +++ b/packages/nhost_storage_dart/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.7 + + - Update a dependency to the latest release. + +## 2.0.6 + + - **REFACTOR**: remove unnecessary and unused files (#148). + ## 2.0.5 - Update a dependency to the latest release. diff --git a/packages/nhost_storage_dart/example/pubspec.yaml b/packages/nhost_storage_dart/example/pubspec.yaml index 74261dfc..fcff53b3 100644 --- a/packages/nhost_storage_dart/example/pubspec.yaml +++ b/packages/nhost_storage_dart/example/pubspec.yaml @@ -11,4 +11,4 @@ dependencies: # Nhost packages nhost_storage_dart: path: ../ - nhost_auth_dart: ^2.2.1 \ No newline at end of file + nhost_auth_dart: ^2.4.0 \ No newline at end of file diff --git a/packages/nhost_storage_dart/pubspec.yaml b/packages/nhost_storage_dart/pubspec.yaml index 7c86a7a1..305b764e 100644 --- a/packages/nhost_storage_dart/pubspec.yaml +++ b/packages/nhost_storage_dart/pubspec.yaml @@ -1,6 +1,6 @@ name: nhost_storage_dart description: Nhost Dart Storage Service 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 @@ -13,7 +13,7 @@ dependencies: http: ^1.1.0 #Nhost_sdk - nhost_sdk: ^5.3.1 + nhost_sdk: ^5.5.0 dev_dependencies: lints: ^2.0.0 test: ^1.16.0