Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/nhost_auth_dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ void main() async {

```yaml
dependencies:
nhost_auth_dart: ^2.0.0
nhost_auth_dart: ^2.6.1
```
5 changes: 3 additions & 2 deletions packages/nhost_auth_dart/lib/src/auth_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -963,8 +963,9 @@ class NhostAuthClient implements HasuraAuthClient {
@override
String toString() {
return {
'accessToken': accessToken,
'refreshToken': _session.session?.refreshToken,
'accessToken': accessToken == null ? null : '<redacted>',
'refreshToken':
_session.session?.refreshToken == null ? null : '<redacted>',
'accessTokenExpiresIn': _session.session?.accessTokenExpiresIn,
'userEmail': _session.session?.user?.email,
}.toString();
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,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:
Expand Down
46 changes: 46 additions & 0 deletions packages/nhost_auth_dart/test/auth_client_test.dart
Original file line number Diff line number Diff line change
@@ -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: <redacted>'));
expect(output, contains('refreshToken: <redacted>'));
expect(output, contains('test@example.com'));
});
});
}
55 changes: 30 additions & 25 deletions packages/nhost_dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
```

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/nhost_dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 0 additions & 10 deletions packages/nhost_flutter_auth/.metadata

This file was deleted.

2 changes: 1 addition & 1 deletion packages/nhost_flutter_auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 0 additions & 45 deletions packages/nhost_flutter_auth/example/.metadata

This file was deleted.

4 changes: 2 additions & 2 deletions packages/nhost_flutter_auth/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 0 additions & 10 deletions packages/nhost_flutter_graphql/.metadata

This file was deleted.

2 changes: 1 addition & 1 deletion packages/nhost_flutter_graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 0 additions & 45 deletions packages/nhost_flutter_graphql/example/.metadata

This file was deleted.

4 changes: 2 additions & 2 deletions packages/nhost_flutter_graphql/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/nhost_functions_dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ void main() async {

```yaml
dependencies:
nhost_functions_dart: ^1.0.0
nhost_functions_dart: ^2.0.10
```
Loading