diff --git a/.gitignore b/.gitignore index 18bd7c47..c356c480 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,67 @@ .DS_Store .atom/ .idea/ +.vscode/ .packages .pub/ .dart_tool/ pubspec.lock +pubspec_overrides.local.yaml flutter_export_environment.sh coverage +coverage/ *.iml +*.ipr +*.iws .flutter-plugins .flutter-plugins-dependencies +devtools_options.yaml .project .classpath .settings .last_build_id +.metadata + +# Local planning notes +backlog.md +task-list.md +todo.md +todos.md + +# Dart / Flutter generated docs and build output +doc/api/ +build/ +.dart_tool/ + +# Flutter example generated platform files +packages/**/example/.metadata +packages/**/example/.flutter-plugins +packages/**/example/.flutter-plugins-dependencies +packages/**/example/devtools_options.yaml +packages/**/example/build/ +packages/**/example/ios/Flutter/.last_build_id +packages/**/example/ios/Flutter/Generated.xcconfig +packages/**/example/ios/Flutter/flutter_export_environment.sh +packages/**/example/ios/Flutter/ephemeral/ +packages/**/example/ios/Flutter/Flutter.framework +packages/**/example/ios/Flutter/Flutter.podspec +packages/**/example/ios/Flutter/App.framework +packages/**/example/ios/Flutter/flutter_assets/ +packages/**/example/ios/Pods/ +packages/**/example/ios/.symlinks/ +packages/**/example/ios/Runner/GeneratedPluginRegistrant.* +packages/**/example/ios/Podfile.lock +packages/**/example/android/.gradle/ +packages/**/example/android/local.properties +packages/**/example/android/app/debug/ +packages/**/example/android/app/profile/ +packages/**/example/android/app/release/ +packages/**/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +packages/**/example/android/app/src/main/kotlin/io/flutter/plugins/GeneratedPluginRegistrant.kt # Misc .env.local diff --git a/packages/nhost_auth_dart/README.md b/packages/nhost_auth_dart/README.md index 8e1441aa..91618dbe 100644 --- a/packages/nhost_auth_dart/README.md +++ b/packages/nhost_auth_dart/README.md @@ -44,5 +44,5 @@ void main() async { ```yaml dependencies: - nhost_auth_dart: ^2.0.0 + nhost_auth_dart: ^2.6.1 ``` diff --git a/packages/nhost_auth_dart/lib/src/auth_client.dart b/packages/nhost_auth_dart/lib/src/auth_client.dart index 4f80b9bd..392c494e 100644 --- a/packages/nhost_auth_dart/lib/src/auth_client.dart +++ b/packages/nhost_auth_dart/lib/src/auth_client.dart @@ -963,8 +963,9 @@ class NhostAuthClient implements HasuraAuthClient { @override String toString() { return { - 'accessToken': accessToken, - 'refreshToken': _session.session?.refreshToken, + 'accessToken': accessToken == null ? null : '', + 'refreshToken': + _session.session?.refreshToken == null ? null : '', 'accessTokenExpiresIn': _session.session?.accessTokenExpiresIn, 'userEmail': _session.session?.user?.email, }.toString(); diff --git a/packages/nhost_auth_dart/pubspec.yaml b/packages/nhost_auth_dart/pubspec.yaml index 19badb3d..53982d2f 100644 --- a/packages/nhost_auth_dart/pubspec.yaml +++ b/packages/nhost_auth_dart/pubspec.yaml @@ -1,8 +1,8 @@ name: nhost_auth_dart -description: Nhost Dart Auth Service SDK +description: Dart client for Nhost Auth with email/password, passwordless, MFA, anonymous sign-in, and session management. version: 2.6.1 homepage: https://nhost.io -repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_sdk +repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_auth_dart issue_tracker: https://github.com/nhost/nhost-dart/issues environment: diff --git a/packages/nhost_auth_dart/test/auth_client_test.dart b/packages/nhost_auth_dart/test/auth_client_test.dart new file mode 100644 index 00000000..dd4e6756 --- /dev/null +++ b/packages/nhost_auth_dart/test/auth_client_test.dart @@ -0,0 +1,46 @@ +import 'package:nhost_auth_dart/nhost_auth_dart.dart'; +import 'package:nhost_sdk/nhost_sdk.dart'; +import 'package:test/test.dart'; + +const _accessToken = 'eyJhbGciOiJIUzI1NiJ9.' + 'eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWFsbG93ZWQtcm9sZXMiOlsidXNlciIsIm1lIl0sIngtaGFzdXJhLWRlZmF1bHQtcm9sZSI6InVzZXIiLCJ4LWhhc3VyYS11c2VyLWlkIjoiNzEwYTgyNjMtNTgyNi00NTYzLWE4YTUtNGUyNzJkNDQxYWVkIiwieC1oYXN1cmEtdXNlci1pc0Fub255bW91cyI6ImZhbHNlIn0sInN1YiI6IjcxMGE4MjYzLTU4MjYtNDU2My1hOGE1LTRlMjcyZDQ0MWFlZCIsImlzcyI6Imhhc3VyYS1hdXRoIiwiaWF0IjoxNjQzMzQ3NzgwLCJleHAiOjE2NDMzNDg2ODB9.' + 'xzsBH0p34ynPwaHnNs97gVL5tdrccFOrxosuqBra1iw'; +const _refreshToken = 'refresh-token-should-not-be-logged'; + +void main() { + group('NhostAuthClient', () { + test('does not expose session tokens in string output', () async { + final auth = NhostAuthClient(url: 'http://localhost'); + addTearDown(auth.close); + + await auth.setSession( + Session( + accessToken: _accessToken, + accessTokenExpiresIn: Duration(seconds: 900), + refreshToken: _refreshToken, + user: User( + id: '710a8263-5826-4563-a8a5-4e272d441aed', + displayName: 'Test User', + locale: 'en', + createdAt: DateTime.utc(2024), + isAnonymous: false, + defaultRole: 'user', + roles: const ['user'], + emailVerified: true, + phoneNumber: '', + phoneNumberVerified: false, + email: 'test@example.com', + ), + ), + ); + + final output = auth.toString(); + + expect(output, isNot(contains(_accessToken))); + expect(output, isNot(contains(_refreshToken))); + expect(output, contains('accessToken: ')); + expect(output, contains('refreshToken: ')); + expect(output, contains('test@example.com')); + }); + }); +} diff --git a/packages/nhost_dart/README.md b/packages/nhost_dart/README.md index ce620383..2a4fe8d0 100644 --- a/packages/nhost_dart/README.md +++ b/packages/nhost_dart/README.md @@ -23,37 +23,42 @@ import 'package:nhost_dart/nhost_dart.dart'; void main() async { final nhost = NhostClient( subdomain: Subdomain( - region: 'eu-central-1', - subdomain: 'backend-5e69d1d7', - ), - ); - - - // for self host or local host you may use ServiceUrls - /* - final nhost = NhostClient( - serviceUrls: ServiceUrls( - authUrl: '', - storageUrl: '', - functionsUrl: '', - graphqlUrl: '', - ), - ); - */ + region: 'eu-central-1', + subdomain: 'backend-5e69d1d7', + ), + ); + + // For self-hosted or local projects, use ServiceUrls instead. + /* + final nhost = NhostClient( + serviceUrls: ServiceUrls( + authUrl: 'http://localhost:1337/v1/auth', + storageUrl: 'http://localhost:1337/v1/storage', + functionsUrl: 'http://localhost:1337/v1/functions', + graphqlUrl: 'http://localhost:1337/v1/graphql', + ), + ); + */ // User registration - await nhost.auth.register(email: 'new-user@gmail.com', password: 'xxxxx'); + final authResponse = await nhost.auth.signUp( + email: 'new-user@gmail.com', + password: 'password-1', + ); // Upload a file - final currentUser = nhost.auth.currentUser; + final currentUser = authResponse.user ?? nhost.auth.currentUser; await nhost.storage.uploadBytes( - filePath: '/users/${currentUser.id}/image.jpg', - bytes: [/* ... */], - contentType: 'image/jpeg', - ), + fileName: '/users/${currentUser!.id}/image.jpg', + fileContents: [/* ... */], + mimeType: 'image/jpeg', + ); // Log out - await nhost.auth.logout(); + await nhost.auth.signOut(); + + // Release resources + nhost.close(); } ``` @@ -63,7 +68,7 @@ void main() async { ```yaml dependencies: - nhost_dart: ^1.0.1 + nhost_dart: ^2.2.0 ``` ## 🔥 More Dart & Flutter packages from Nhost diff --git a/packages/nhost_dart/pubspec.yaml b/packages/nhost_dart/pubspec.yaml index 388f66c0..eb062fb6 100644 --- a/packages/nhost_dart/pubspec.yaml +++ b/packages/nhost_dart/pubspec.yaml @@ -1,8 +1,8 @@ name: nhost_dart -description: Nhost Dart SDK +description: Dart client for Nhost Auth, Storage, Functions, and GraphQL helpers for apps using Nhost. version: 2.2.0 homepage: https://nhost.io -repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_sdk +repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_dart issue_tracker: https://github.com/nhost/nhost-dart/issues environment: diff --git a/packages/nhost_flutter_auth/.metadata b/packages/nhost_flutter_auth/.metadata deleted file mode 100644 index 933d7a89..00000000 --- a/packages/nhost_flutter_auth/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: b7d4806243a4e906bf061f79a0e314ba28111aa6 - channel: dev - -project_type: package diff --git a/packages/nhost_flutter_auth/README.md b/packages/nhost_flutter_auth/README.md index 956603ba..65a7299f 100644 --- a/packages/nhost_flutter_auth/README.md +++ b/packages/nhost_flutter_auth/README.md @@ -13,7 +13,7 @@ outs. ```yaml dependencies: - nhost_flutter_auth: ^3.0.0 + nhost_flutter_auth: ^4.2.1 ``` ## 🔥 More Dart & Flutter packages from Nhost diff --git a/packages/nhost_flutter_auth/example/.metadata b/packages/nhost_flutter_auth/example/.metadata deleted file mode 100644 index 3fdf5328..00000000 --- a/packages/nhost_flutter_auth/example/.metadata +++ /dev/null @@ -1,45 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled. - -version: - revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - channel: stable - -project_type: app - -# Tracks metadata for the flutter migrate command -migration: - platforms: - - platform: root - create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - - platform: android - create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - - platform: ios - create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - - platform: linux - create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - - platform: macos - create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - - platform: web - create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - - platform: windows - create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 - - # User provided section - - # List of Local paths (relative to this file) that should be - # ignored by the migrate tool. - # - # Files that are not part of the templates will be ignored by default. - unmanaged_files: - - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/packages/nhost_flutter_auth/pubspec.yaml b/packages/nhost_flutter_auth/pubspec.yaml index 0dc3d282..42924402 100644 --- a/packages/nhost_flutter_auth/pubspec.yaml +++ b/packages/nhost_flutter_auth/pubspec.yaml @@ -1,7 +1,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. + Flutter widgets and listenables for exposing Nhost authentication state in + your app. version: 4.2.1 homepage: https://nhost.io repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_flutter_auth diff --git a/packages/nhost_flutter_graphql/.metadata b/packages/nhost_flutter_graphql/.metadata deleted file mode 100644 index 933d7a89..00000000 --- a/packages/nhost_flutter_graphql/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: b7d4806243a4e906bf061f79a0e314ba28111aa6 - channel: dev - -project_type: package diff --git a/packages/nhost_flutter_graphql/README.md b/packages/nhost_flutter_graphql/README.md index 7dd52dc6..573acdf8 100644 --- a/packages/nhost_flutter_graphql/README.md +++ b/packages/nhost_flutter_graphql/README.md @@ -12,7 +12,7 @@ to work with [Nhost](https://nhost.io). ```yaml dependencies: - nhost_flutter_graphql: ^3.0.0 + nhost_flutter_graphql: ^3.1.2 ``` ## 🔥 More Dart & Flutter packages from Nhost diff --git a/packages/nhost_flutter_graphql/example/.metadata b/packages/nhost_flutter_graphql/example/.metadata deleted file mode 100644 index 9e70ade3..00000000 --- a/packages/nhost_flutter_graphql/example/.metadata +++ /dev/null @@ -1,45 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled. - -version: - revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - channel: stable - -project_type: app - -# Tracks metadata for the flutter migrate command -migration: - platforms: - - platform: root - create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - - platform: android - create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - - platform: ios - create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - - platform: linux - create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - - platform: macos - create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - - platform: web - create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - - platform: windows - create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 - - # User provided section - - # List of Local paths (relative to this file) that should be - # ignored by the migrate tool. - # - # Files that are not part of the templates will be ignored by default. - unmanaged_files: - - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/packages/nhost_flutter_graphql/pubspec.yaml b/packages/nhost_flutter_graphql/pubspec.yaml index 419c1c8d..a8a2f96d 100644 --- a/packages/nhost_flutter_graphql/pubspec.yaml +++ b/packages/nhost_flutter_graphql/pubspec.yaml @@ -1,7 +1,7 @@ name: nhost_flutter_graphql description: > - Provides GraphQL clients to your Flutter application, automatically configured - to work with Nhost + Flutter GraphQL provider for authenticated Nhost queries and subscriptions + with graphql_flutter. version: 3.1.2 homepage: https://nhost.io repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_flutter_graphql diff --git a/packages/nhost_functions_dart/README.md b/packages/nhost_functions_dart/README.md index 0def7731..67342264 100644 --- a/packages/nhost_functions_dart/README.md +++ b/packages/nhost_functions_dart/README.md @@ -29,5 +29,5 @@ void main() async { ```yaml dependencies: - nhost_functions_dart: ^1.0.0 + nhost_functions_dart: ^2.0.10 ``` diff --git a/packages/nhost_functions_dart/pubspec.yaml b/packages/nhost_functions_dart/pubspec.yaml index fb85b2f9..176c62c5 100644 --- a/packages/nhost_functions_dart/pubspec.yaml +++ b/packages/nhost_functions_dart/pubspec.yaml @@ -1,8 +1,8 @@ name: nhost_functions_dart -description: Nhost Dart Functions Service SDK +description: Dart client for calling Nhost serverless functions with authenticated HTTP requests. version: 2.0.10 homepage: https://nhost.io -repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_sdk +repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_functions_dart issue_tracker: https://github.com/nhost/nhost-dart/issues environment: diff --git a/packages/nhost_gql_links/README.md b/packages/nhost_gql_links/README.md index ea7af443..04b3630b 100644 --- a/packages/nhost_gql_links/README.md +++ b/packages/nhost_gql_links/README.md @@ -14,7 +14,7 @@ and generally isn't meant for use directly. ```yaml dependencies: - nhost_gql_links: ^3.0.0 + nhost_gql_links: ^4.0.11 ``` ## 🔥 More Dart & Flutter packages from Nhost diff --git a/packages/nhost_gql_links/pubspec.yaml b/packages/nhost_gql_links/pubspec.yaml index cae3a500..e1333fc0 100644 --- a/packages/nhost_gql_links/pubspec.yaml +++ b/packages/nhost_gql_links/pubspec.yaml @@ -1,6 +1,6 @@ name: nhost_gql_links version: 4.0.11 -description: Constructs GraphQL links for use with graphql and ferry packages +description: Low-level GraphQL links for Nhost authentication over HTTP and WebSocket transports. homepage: https://nhost.io repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_gql_links issue_tracker: https://github.com/nhost/nhost-dart/issues diff --git a/packages/nhost_graphql_adapter/README.md b/packages/nhost_graphql_adapter/README.md index 01c579e1..a96a6c60 100644 --- a/packages/nhost_graphql_adapter/README.md +++ b/packages/nhost_graphql_adapter/README.md @@ -17,7 +17,7 @@ for widgets that work great with ```yaml dependencies: - nhost_graphql_adapter: ^3.0.0 + nhost_graphql_adapter: ^4.0.10 ``` ## 🔥 More Dart & Flutter packages from Nhost diff --git a/packages/nhost_graphql_adapter/pubspec.yaml b/packages/nhost_graphql_adapter/pubspec.yaml index 0146295f..dd7ed062 100644 --- a/packages/nhost_graphql_adapter/pubspec.yaml +++ b/packages/nhost_graphql_adapter/pubspec.yaml @@ -1,6 +1,6 @@ name: nhost_graphql_adapter version: 4.0.10 -description: Easily connect to your Nhost.io GraphQL backend using the graphql package. +description: GraphQL client helpers for connecting package:graphql clients to an authenticated Nhost backend. homepage: https://nhost.io repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_graphql_adapter issue_tracker: https://github.com/nhost/nhost-dart/issues diff --git a/packages/nhost_sdk/pubspec.yaml b/packages/nhost_sdk/pubspec.yaml index 3e2665bf..6c2898fe 100644 --- a/packages/nhost_sdk/pubspec.yaml +++ b/packages/nhost_sdk/pubspec.yaml @@ -1,5 +1,5 @@ name: nhost_sdk -description: Nhost authentication and file storage/retrieval APIs for the Dart language. +description: Shared core types and low-level HTTP APIs used by the Nhost Dart and Flutter packages. version: 5.8.0 homepage: https://nhost.io repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_sdk diff --git a/packages/nhost_storage_dart/README.md b/packages/nhost_storage_dart/README.md index edf889f8..05321cae 100644 --- a/packages/nhost_storage_dart/README.md +++ b/packages/nhost_storage_dart/README.md @@ -58,6 +58,6 @@ void main() async { ```yaml dependencies: - nhost_auth_dart: ^2.0.0 - nhost_storage_dart: ^2.0.0 + nhost_auth_dart: ^2.6.1 + nhost_storage_dart: ^2.2.0 ``` diff --git a/packages/nhost_storage_dart/pubspec.yaml b/packages/nhost_storage_dart/pubspec.yaml index b757f26b..a51610e8 100644 --- a/packages/nhost_storage_dart/pubspec.yaml +++ b/packages/nhost_storage_dart/pubspec.yaml @@ -1,8 +1,8 @@ name: nhost_storage_dart -description: Nhost Dart Storage Service SDK +description: Dart client for Nhost Storage with file upload, download, deletion, presigned URLs, and image transforms. version: 2.2.0 homepage: https://nhost.io -repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_sdk +repository: https://github.com/nhost/nhost-dart/tree/main/packages/nhost_storage_dart issue_tracker: https://github.com/nhost/nhost-dart/issues environment: