-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Secure atKeys with pass-phrase #703
Changes from 10 commits
0ee953a
2fb5481
de9bfee
d3b8dbe
6877c41
6f3f785
2aeb924
055dd66
514f53f
a00fea5
5be8bf9
0bdb5e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:at_client/at_client.dart'; | ||
import 'package:path/path.dart' as path; | ||
|
||
class HomeDirectoryUtil { | ||
static const String defaultPathUniqueID = 'singleton'; | ||
|
||
static final homeDir = getHomeDirectory(); | ||
|
||
static String? getHomeDirectory() { | ||
|
@@ -50,4 +53,62 @@ class HomeDirectoryUtil { | |
enrollmentId: enrollmentId), | ||
'hive'); | ||
} | ||
|
||
/// Generate a path like this: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really don't like that we are duplicating this code, again. I think instead we should move these functions to at_utils from at_cli_commons. Rather than delay this PR further, please create another ticket to take care of this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created the following ticket: #720 |
||
/// $baseDir/.atsign/storage/$atSign/$progName/$uniqueID | ||
/// (normalized to use platform-specific path separator) | ||
static String standardAtClientStoragePath({ | ||
required String baseDir, | ||
required String atSign, | ||
required String progName, // e.g. npt, sshnp, sshnpd, srvd etc | ||
String uniqueID = defaultPathUniqueID, | ||
}) { | ||
return path.normalize('$baseDir' | ||
'/.atsign' | ||
'/storage' | ||
'/$atSign' | ||
'/$progName' | ||
'/$uniqueID' | ||
.replaceAll('/', Platform.pathSeparator)); | ||
} | ||
|
||
Directory standardWindowsAtClientStorageDir({ | ||
required String atSign, | ||
required String progName, // e.g. npt, sshnp, sshnpd, srvd etc | ||
required String uniqueID, | ||
}) { | ||
return Directory(standardAtClientStoragePath( | ||
baseDir: Platform.environment['TEMP']!, | ||
atSign: atSign, | ||
progName: progName, | ||
uniqueID: uniqueID, | ||
)); | ||
} | ||
|
||
/// Generate a path like this: | ||
/// $baseDir/.atsign/storage/$atSign/$progName/$uniqueID | ||
/// (normalized to use platform-specific path separator) | ||
/// where baseDir is either | ||
/// - for Windows: `Platform.environment['TEMP']` | ||
/// - for others: [getHomeDirectory] | ||
static Directory standardAtClientStorageDir({ | ||
required String atSign, | ||
required String progName, // e.g. npt, sshnp, sshnpd, srvd etc | ||
required String uniqueID, | ||
}) { | ||
if (Platform.isWindows) { | ||
return standardAtClientStorageDir( | ||
atSign: atSign, | ||
progName: progName, | ||
uniqueID: uniqueID, | ||
); | ||
} else { | ||
return Directory(standardAtClientStoragePath( | ||
baseDir: getHomeDirectory()!, | ||
atSign: atSign, | ||
progName: progName, | ||
uniqueID: uniqueID, | ||
)); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extract the code below into its own file as a function which will return an AtClient given some args (similar to what we have in the noports repo here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change in implemented in 5be8bf9