From cda9a8d231ae3bd83081dfe629d4ddaa2a28b8ff Mon Sep 17 00:00:00 2001 From: murali-shris Date: Thu, 12 Oct 2023 17:43:32 +0530 Subject: [PATCH] fix: dart analyzer issues --- .../example/apkam_authenticate.dart | 2 -- .../onboard/at_onboarding_service_impl.dart | 29 ++++++++----------- .../test/at_onboarding_cli_test.dart | 1 - .../pubspec.yaml | 14 ++++++++- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/packages/at_onboarding_cli/example/apkam_authenticate.dart b/packages/at_onboarding_cli/example/apkam_authenticate.dart index 445ea65e..2e2f1cf9 100644 --- a/packages/at_onboarding_cli/example/apkam_authenticate.dart +++ b/packages/at_onboarding_cli/example/apkam_authenticate.dart @@ -1,5 +1,3 @@ -import 'package:at_client/at_client.dart'; -import 'package:at_lookup/at_lookup.dart'; import 'package:at_onboarding_cli/at_onboarding_cli.dart'; import 'package:at_utils/at_logger.dart'; diff --git a/packages/at_onboarding_cli/lib/src/onboard/at_onboarding_service_impl.dart b/packages/at_onboarding_cli/lib/src/onboard/at_onboarding_service_impl.dart index 63ae2044..ba458469 100644 --- a/packages/at_onboarding_cli/lib/src/onboard/at_onboarding_service_impl.dart +++ b/packages/at_onboarding_cli/lib/src/onboard/at_onboarding_service_impl.dart @@ -29,7 +29,6 @@ class AtOnboardingServiceImpl implements AtOnboardingService { bool _isAtsignOnboarded = false; AtSignLogger logger = AtSignLogger('OnboardingCli'); AtOnboardingPreference atOnboardingPreference; - AtClient? _atClient; AtLookUp? _atLookUp; final StreamController _pkamSuccessController = @@ -72,13 +71,14 @@ class AtOnboardingServiceImpl implements AtOnboardingService { _atLookUp?.enrollmentId = enrollmentId; _atLookUp?.signingAlgoType = atOnboardingPreference.signingAlgoType; _atLookUp?.hashingAlgoType = atOnboardingPreference.hashingAlgoType; - _atClient ??= atClientManager.atClient; + atClient ??= atClientManager.atClient; + _atLookUp!.atChops = atChops; } @override @Deprecated('Use getter') Future getAtClient() async { - return _atClient; + return atClient; } @override @@ -131,6 +131,7 @@ class AtOnboardingServiceImpl implements AtOnboardingService { await _generateAtKeysFile( atOnboardingResponse.enrollmentId, atOnboardingResponse.atAuthKeys!); } + _isAtsignOnboarded = atOnboardingResponse.isSuccessful; return _isAtsignOnboarded; } @@ -397,29 +398,29 @@ class AtOnboardingServiceImpl implements AtOnboardingService { AtAuthKeys atAuthKeys = _decryptAtKeysFile( (await _readAtKeysFile(atOnboardingPreference.atKeysFilePath))); //backup keys into local secondary - bool? response = await _atClient + bool? response = await atClient ?.getLocalSecondary() ?.putValue(AtConstants.atPkamPublicKey, atAuthKeys.apkamPublicKey!); logger.finer('PkamPublicKey persist to localSecondary: status $response'); // save pkam private key only when auth mode is keyFile. if auth mode is sim/any other secure element private key cannot be read and hence will not be part of keys file if (atOnboardingPreference.authMode == PkamAuthMode.keysFile) { - response = await _atClient + response = await atClient ?.getLocalSecondary() ?.putValue(AtConstants.atPkamPrivateKey, atAuthKeys.apkamPrivateKey!); logger .finer('PkamPrivateKey persist to localSecondary: status $response'); } - response = await _atClient?.getLocalSecondary()?.putValue( + response = await atClient?.getLocalSecondary()?.putValue( '${AtConstants.atEncryptionPublicKey}$_atSign', atAuthKeys.defaultEncryptionPublicKey!); logger.finer( 'EncryptionPublicKey persist to localSecondary: status $response'); - response = await _atClient?.getLocalSecondary()?.putValue( + response = await atClient?.getLocalSecondary()?.putValue( AtConstants.atEncryptionPrivateKey, atAuthKeys.defaultEncryptionPrivateKey!); logger.finer( 'EncryptionPrivateKey persist to localSecondary: status $response'); - response = await _atClient?.getLocalSecondary()?.putValue( + response = await atClient?.getLocalSecondary()?.putValue( AtConstants.atEncryptionSelfKey, atAuthKeys.defaultSelfEncryptionKey!); } @@ -433,8 +434,7 @@ class AtOnboardingServiceImpl implements AtOnboardingService { ..authMode = atOnboardingPreference.authMode; var atAuthResponse = await atAuth!.authenticate(atAuthRequest); logger.finer('Auth response: $atAuthResponse'); - if (!_isAtsignOnboarded && - atAuthResponse.isSuccessful && + if (atAuthResponse.isSuccessful && atOnboardingPreference.atKeysFilePath != null) { logger.finer('Calling persist keys to local secondary'); await _initAtClient(atAuth!.atChops!, @@ -617,7 +617,7 @@ class AtOnboardingServiceImpl implements AtOnboardingService { await (_atLookUp as AtLookupImpl).close(); } _atLookUp = null; - _atClient = null; + atClient = null; logger.info( 'Closing current instance of at_onboarding_cli (exit code: $exitCode)'); } @@ -629,18 +629,13 @@ class AtOnboardingServiceImpl implements AtOnboardingService { } @override - set atClient(AtClient? atClient) { - _atClient = atClient; - } + AtClient? atClient; @override set atLookUp(AtLookUp? atLookUp) { _atLookUp = atLookUp; } - @override - AtClient? get atClient => _atClient; - @override AtLookUp? get atLookUp => _atLookUp; diff --git a/packages/at_onboarding_cli/test/at_onboarding_cli_test.dart b/packages/at_onboarding_cli/test/at_onboarding_cli_test.dart index b06c7b00..40b4f6e5 100644 --- a/packages/at_onboarding_cli/test/at_onboarding_cli_test.dart +++ b/packages/at_onboarding_cli/test/at_onboarding_cli_test.dart @@ -9,7 +9,6 @@ import 'package:at_client/at_client.dart'; import 'package:at_auth/at_auth.dart'; import 'package:test/expect.dart'; import 'package:test/scaffolding.dart'; -import 'package:at_demo_data/at_demo_data.dart' as at_demo; class MockAtLookupImpl extends Mock implements AtLookupImpl {} diff --git a/tests/at_onboarding_cli_functional_tests/pubspec.yaml b/tests/at_onboarding_cli_functional_tests/pubspec.yaml index e7f0d13a..6db2eb4f 100644 --- a/tests/at_onboarding_cli_functional_tests/pubspec.yaml +++ b/tests/at_onboarding_cli_functional_tests/pubspec.yaml @@ -9,11 +9,23 @@ environment: dependencies: at_onboarding_cli: path: ../../packages/at_onboarding_cli - at_commons: ^3.0.55 + at_commons: ^3.0.56 at_utils: ^3.0.15 at_lookup: ^3.0.40 at_client: ^3.0.65 +dependency_overrides: + at_auth: + git: + url: https://github.com/atsign-foundation/at_libraries + path: packages/at_auth + ref: at_auth_new_package + at_chops: + git: + url: https://github.com/atsign-foundation/at_libraries + path: packages/at_chops + ref: at_auth_new_package + dev_dependencies: lints: ^1.0.0 test: ^1.17.2