Skip to content

Commit

Permalink
fix(core): Secure storage errors on Linux/Android
Browse files Browse the repository at this point in the history
Need to rework secure storage so that it can be used in an isolate
  • Loading branch information
dnys1 committed Mar 10, 2024
1 parent d003901 commit 2446a58
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
4 changes: 4 additions & 0 deletions packages/celest_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.1

- Fix secure storage issues on Android and Linux

## 0.3.0

- Adds `SecureStorage` interface for storage of sensitive data in the platform keychain
Expand Down
13 changes: 1 addition & 12 deletions packages/celest_core/lib/src/http/celest_http_client.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import 'dart:isolate';

import 'package:celest_core/src/http/http_client.vm.dart'
if (dart.library.js_interop) 'package:celest_core/src/http/http_client.web.dart';
import 'package:celest_core/src/storage/secure/secure_storage.dart';
import 'package:celest_core/src/storage/storage.dart';
import 'package:celest_core/src/util/globals.dart';
import 'package:http/http.dart' as http;

final class CelestHttpClient extends http.BaseClient {
Expand All @@ -21,7 +17,7 @@ final class CelestHttpClient extends http.BaseClient {

@override
Future<http.StreamedResponse> send(http.BaseRequest request) async {
final cork = await _readStorage(_secureStorage, 'cork');
final cork = _secureStorage.read('cork');
if (cork != null) {
request.headers['authorization'] = 'Bearer $cork';
}
Expand All @@ -35,10 +31,3 @@ final class CelestHttpClient extends http.BaseClient {
}
}
}

Future<String?> _readStorage(Storage storage, String key) async {
if (kIsWeb) {
return null;
}
return Isolate.run(() => storage.read(key));
}
2 changes: 1 addition & 1 deletion packages/celest_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: celest_core
description: Celest types and utilities shared between the client and the cloud.
version: 0.3.0
version: 0.3.1
homepage: https://celest.dev
repository: https://github.com/celest-dev/celest/tree/main/packages/celest_core

Expand Down

0 comments on commit 2446a58

Please sign in to comment.