Skip to content

Commit

Permalink
Merge pull request #466 from atsign-foundation/gkc/at_cli_commons/han…
Browse files Browse the repository at this point in the history
…dle-malformatted-atsigns

fix: at_cli_commons: handle malformed atsigns (no leading `@`) in CLIBase constructor
  • Loading branch information
gkc authored Dec 3, 2023
2 parents 364df5d + 746d5fb commit af5d9ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions packages/at_cli_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.4
- fix: handle malformed atsigns (no leading `@`) in CLIBase constructor
- build: updated dependencies
## 1.0.3
- Added `example/` package, moved code samples from `bin/` to `example/`
## 1.0.2
Expand Down
14 changes: 7 additions & 7 deletions packages/at_cli_commons/lib/src/cli_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:at_cli_commons/src/service_factories.dart';
import 'package:at_cli_commons/src/utils.dart';
import 'package:at_client/at_client.dart';
import 'package:at_onboarding_cli/at_onboarding_cli.dart';
import 'package:at_utils/at_logger.dart';
import 'package:at_utils/at_utils.dart';
import 'package:chalkdart/chalk.dart';
import 'package:logging/logging.dart';
import 'package:version/version.dart';
Expand Down Expand Up @@ -76,7 +76,7 @@ class CLIBase {
return cliBase;
}

final String atSign;
late final String atSign;
final String nameSpace;
final String rootDomain;
final String? homeDir;
Expand Down Expand Up @@ -112,7 +112,7 @@ class CLIBase {
/// ```
/// Throws an [IllegalArgumentException] if the parameters fail validation.
CLIBase(
{required this.atSign,
{required String atSign,
required this.nameSpace,
required this.rootDomain,
this.homeDir,
Expand All @@ -122,6 +122,7 @@ class CLIBase {
this.downloadDir,
this.cramSecret,
this.syncDisabled = false}) {
this.atSign = AtUtils.fixAtSign(atSign);
if (homeDir == null) {
if (atKeysFilePath == null) {
throw IllegalArgumentException(
Expand All @@ -138,10 +139,10 @@ class CLIBase {
}

atKeysFilePathToUse =
atKeysFilePath ?? '$homeDir/.atsign/keys/${atSign}_key.atKeys';
atKeysFilePath ?? '$homeDir/.atsign/keys/${this.atSign}_key.atKeys';
localStoragePathToUse =
storageDir ?? '$homeDir/.$nameSpace/$atSign/storage';
downloadPathToUse = downloadDir ?? '$homeDir/.$nameSpace/$atSign/files';
storageDir ?? '$homeDir/.$nameSpace/${this.atSign}/storage';
downloadPathToUse = downloadDir ?? '$homeDir/.$nameSpace/${this.atSign}/files';

AtSignLogger.defaultLoggingHandler = AtSignLogger.stdErrLoggingHandler;

Expand Down Expand Up @@ -173,7 +174,6 @@ class CLIBase {
..rootDomain = rootDomain
..fetchOfflineNotifications = true
..atKeysFilePath = atKeysFilePathToUse
..useAtChops = true
..cramSecret = cramSecret
..atProtocolEmitted = Version(2, 0, 0);

Expand Down
12 changes: 6 additions & 6 deletions packages/at_cli_commons/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_cli_commons
description: Library of useful stuff when building cli programs which use the AtClient SDK
version: 1.0.3
version: 1.0.4

repository: https://github.com/atsign-foundation/at_libraries/tree/trunk/packages/at_cli_commons
homepage: https://docs.atsign.com/
Expand All @@ -10,14 +10,14 @@ environment:

dependencies:
args: ^2.4.2
at_client: ^3.0.62
at_onboarding_cli: ^1.3.0
at_client: ^3.0.68
at_onboarding_cli: ^1.4.0
at_utils: ^3.0.15
chalkdart: ^2.0.9
version: ^3.0.2
logging: ^1.2.0
meta: ^1.9.1
meta: ^1.11.0

dev_dependencies:
lints: ^2.1.1
test: ^1.24.4
lints: ^3.0.0
test: ^1.24.9

0 comments on commit af5d9ad

Please sign in to comment.