Skip to content

Commit

Permalink
addressed more review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
purnimavenkatasubbu committed Dec 4, 2024
2 parents 5dc5a47 + fb56a92 commit 3e05187
Show file tree
Hide file tree
Showing 38 changed files with 566 additions and 248 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/at_libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 # v1.6.5
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # v1.7.0
with:
sdk: stable

Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 # v1.6.5
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # v1.7.0
with:
sdk: stable

Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 # v1.6.5
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # v1.7.0
with:
sdk: stable

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/melos_bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2.16.0
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # v2.18.0
with:
channel: "stable"
- name: flutter pub get
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
sarif_file: results.sarif
2 changes: 2 additions & 0 deletions packages/at_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 2.0.9
- fix:Enable caching of encryption public key
## 2.0.8
- feat: Add "passPhrase" in "AtAuthRequest" to support password protected atKeys file
- build[deps]: Upgraded the following packages:
Expand Down
4 changes: 3 additions & 1 deletion packages/at_auth/lib/src/at_auth_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class AtAuthImpl implements AtAuth {
..atKey = (AtKey()
..key = 'publickey'
..sharedBy = atOnboardingRequest.atSign
..metadata = (Metadata()..isPublic = true))
..metadata = (Metadata()
..isPublic = true
..ttr = -1))
..value = encryptionPublicKey;
String? encryptKeyUpdateResult = await atLookUp!.executeVerb(updateBuilder);
_logger.info('Encryption public key update result $encryptKeyUpdateResult');
Expand Down
2 changes: 1 addition & 1 deletion packages/at_auth/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_auth
description: Package that implements common logic for onboarding/authenticating an atsign to a secondary server
version: 2.0.8
version: 2.0.9
homepage: https://atsign.com/
repository: https://github.com/atsign-foundation/at_libraries

Expand Down
8 changes: 8 additions & 0 deletions packages/at_cli_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.3.0
- feat: Add passPhrase as optional argument to "CLIBase" to support password protected atKeys file.
- build: Upgraded the following dependencies
- args to v2.6.0
- at_client to v3.3.0
- at_onboarding_cli to v1.8.0
- test to v1.25.9

## 1.2.1
- fix: fix impl of `standardAtClientStoragePath`

Expand Down
59 changes: 33 additions & 26 deletions packages/at_cli_commons/lib/src/cli_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ class CLIBase {
..addOption('max-connect-attempts',
help: 'Number of times to attempt to initially connect to atServer.'
' Note: there is a 3-second delay between connection attempts.',
defaultsTo: defaultMaxConnectAttempts.toString());
defaultsTo: defaultMaxConnectAttempts.toString())
..addOption('passPhrase',
abbr: 'P',
help:
'Pass Phrase to encrypt/decrypt the password protected atKeys file',
mandatory: false);

/// Constructs a CLIBase from a list of command-line arguments
/// and calls [init] on it.
Expand All @@ -67,17 +72,17 @@ class CLIBase {
}

CLIBase cliBase = CLIBase(
atSign: parsedArgs['atsign'],
atKeysFilePath: parsedArgs['key-file'],
nameSpace: parsedArgs['namespace'],
rootDomain: parsedArgs['root-domain'],
homeDir: getHomeDirectory(),
storageDir: parsedArgs['storage-dir'],
verbose: parsedArgs['verbose'],
cramSecret: parsedArgs['cram-secret'],
syncDisabled: parsedArgs['never-sync'],
maxConnectAttempts: int.parse(parsedArgs['max-connect-attempts']),
);
atSign: parsedArgs['atsign'],
atKeysFilePath: parsedArgs['key-file'],
nameSpace: parsedArgs['namespace'],
rootDomain: parsedArgs['root-domain'],
homeDir: getHomeDirectory(),
storageDir: parsedArgs['storage-dir'],
verbose: parsedArgs['verbose'],
cramSecret: parsedArgs['cram-secret'],
syncDisabled: parsedArgs['never-sync'],
maxConnectAttempts: int.parse(parsedArgs['max-connect-attempts']),
passPhrase: parsedArgs['passPhrase']);

await cliBase.init();

Expand All @@ -92,6 +97,7 @@ class CLIBase {
final String? storageDir;
final String? downloadDir;
final String? cramSecret;
final String? passPhrase;
final bool syncDisabled;
final int maxConnectAttempts;

Expand Down Expand Up @@ -120,19 +126,19 @@ class CLIBase {
/// cliBase.logger.logger.level = Level.FINEST;
/// ```
/// Throws an [IllegalArgumentException] if the parameters fail validation.
CLIBase({
required String atSign,
required this.nameSpace,
required this.rootDomain,
this.homeDir,
this.verbose = false,
this.atKeysFilePath,
this.storageDir,
this.downloadDir,
this.cramSecret,
this.syncDisabled = false,
this.maxConnectAttempts = defaultMaxConnectAttempts,
}) {
CLIBase(
{required String atSign,
required this.nameSpace,
required this.rootDomain,
this.homeDir,
this.verbose = false,
this.atKeysFilePath,
this.storageDir,
this.downloadDir,
this.cramSecret,
this.syncDisabled = false,
this.maxConnectAttempts = defaultMaxConnectAttempts,
this.passPhrase}) {
this.atSign = AtUtils.fixAtSign(atSign);
if (homeDir == null) {
if (atKeysFilePath == null) {
Expand Down Expand Up @@ -196,7 +202,8 @@ class CLIBase {
..fetchOfflineNotifications = true
..atKeysFilePath = atKeysFilePathToUse
..cramSecret = cramSecret
..atProtocolEmitted = Version(2, 0, 0);
..atProtocolEmitted = Version(2, 0, 0)
..passPhrase = passPhrase;

AtOnboardingService onboardingService = AtOnboardingServiceImpl(
atSign, atOnboardingConfig,
Expand Down
14 changes: 7 additions & 7 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.2.1
version: 1.3.0

repository: https://github.com/atsign-foundation/at_libraries/tree/trunk/packages/at_cli_commons
homepage: https://docs.atsign.com/
Expand All @@ -9,16 +9,16 @@ environment:
sdk: '>=2.15.0 <4.0.0'

dependencies:
args: ^2.4.2
at_client: ^3.0.68
at_onboarding_cli: ^1.4.0
at_utils: ^3.0.15
args: ^2.6.0
at_client: ^3.3.0
at_onboarding_cli: ^1.8.0
at_utils: ^3.0.19
chalkdart: ^2.0.9
version: ^3.0.2
logging: ^1.2.0
meta: ^1.11.0
path: ^1.9.0

dev_dependencies:
lints: ^3.0.0
test: ^1.24.9
lints: ^5.0.0
test: ^1.25.9
2 changes: 2 additions & 0 deletions packages/at_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 5.1.0
- feat: Introduce skipDeletesUntil for sync:from verb
## 5.0.2
- fix: Add "publicKeyHash" and "hashingAlgo" type to metadata.
- build[deps]: Upgraded the following package:
Expand Down
12 changes: 12 additions & 0 deletions packages/at_commons/lib/src/verb/sync_verb_builder.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import 'package:at_commons/at_builders.dart';

class SyncVerbBuilder implements VerbBuilder {
/// commitId from which entries will be synced from server to client
late int commitId;

/// if regex is set, then only keys matching the regex will be synced from server to client
String? regex;

@Deprecated(
'This field is not used anymore even though it is set in client. Remove this in next major release')
int limit = 10;

@Deprecated(
'This field is not used anymore even though it is set in client. Remove this in next major release')
bool isPaginated = false;

/// if skipDeletesUntil is set, then delete commit entries whose commitId is <= skipDeletesUntil will not be synced from server to client
int? skipDeletesUntil;

@override
String buildCommand() {
StringBuffer serverCommandBuffer = StringBuffer('sync:');
Expand All @@ -19,6 +28,9 @@ class SyncVerbBuilder implements VerbBuilder {
if (isPaginated) {
serverCommandBuffer.write(':limit:$limit');
}
if (skipDeletesUntil != null) {
serverCommandBuffer.write(':skipDeletesUntil:$skipDeletesUntil');
}
if (regex != null && regex!.isNotEmpty) {
serverCommandBuffer.write(':$regex');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/at_commons/lib/src/verb/syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class VerbSyntax {
r'^stats(?<statId>:((?!0)\d+)?(,(\d+))*)?(:(?<regex>(?<=:3:|:15:).+))?$';
static const sync = r'^sync:(?<from_commit_seq>[0-9]+|-1)(:(?<regex>.+))?$';
static const syncFrom =
r'^sync:from:(?<from_commit_seq>[0-9]+|-1)(:limit:(?<limit>\d+))(:(?<regex>.+))?$';
r'^sync:from:(?<from_commit_seq>[0-9]+|-1)(:limit:(?<limit>\d+))?(:skipDeletesUntil:(?<skipDeletesUntil>\d+))?(:(?<regex>.+))?$';

@visibleForTesting
static const metadataFragment = r'(:ttl:(?<ttl>(-?)\d+))?'
Expand Down
2 changes: 1 addition & 1 deletion packages/at_commons/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_commons
description: A library of Dart and Flutter utility classes that are used across other components of the atPlatform.
version: 5.0.2
version: 5.1.0
repository: https://github.com/atsign-foundation/at_libraries
homepage: https://atsign.dev

Expand Down
13 changes: 13 additions & 0 deletions packages/at_commons/test/sync_verb_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,17 @@ void main() {
command = command.replaceAll('\n', '');
assert(regex.hasMatch(command));
});

test('build sync stream verb command with skipDeletes', () {
var syncVerbBuilder = SyncVerbBuilder()
..commitId = -1
..isPaginated = true
..limit = 5
..skipDeletesUntil = 20;
var command = syncVerbBuilder.buildCommand();
expect(command, 'sync:from:-1:limit:5:skipDeletesUntil:20\n');
var regex = RegExp(VerbSyntax.syncFrom);
command = command.replaceAll('\n', '');
assert(regex.hasMatch(command));
});
}
17 changes: 4 additions & 13 deletions packages/at_lookup/lib/src/at_lookup_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ class AtLookupImpl implements AtLookUp {

AtConnection? get connection => _connection;

/// Setters or methods to initialize the connection
void setSocketConnection(OutboundConnection socketConnection) {
_connection = socketConnection;
}

void setWebSocketConnection(OutboundWebSocketConnection webSocketConnection) {
_connection = webSocketConnection;
}

late AtLookupOutboundConnectionFactory atOutboundConnectionFactory;

@override
Expand Down Expand Up @@ -651,9 +642,9 @@ class AtLookupImpl implements AtLookUp {

// Create the outbound connection and listener using the factory's methods
final outboundConnection =
atOutboundConnectionFactory.outBoundConnectionFactory(underlying);
messageListener = atOutboundConnectionFactory
.atLookupSocketListenerFactory(outboundConnection);
atOutboundConnectionFactory.createConnection(underlying);
messageListener =
atOutboundConnectionFactory.createListener(outboundConnection);

_connection = outboundConnection;

Expand Down Expand Up @@ -684,7 +675,7 @@ class AtLookupImpl implements AtLookUp {
Future<void> _sendCommand(String command) async {
await createConnection();
logger.finer('SENDING: $command');
_connection!.write(command);
await _connection!.write(command);
}

@override
Expand Down
4 changes: 3 additions & 1 deletion packages/at_lookup/lib/src/connection/at_connection.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'dart:async';

abstract class AtConnection<T> {
/// The underlying connection
T get underlying;

/// Write a data to the underlying socket of the connection
/// @param - data - Data to write to the socket
/// @throws [AtIOException] for any exception during the operation
void write(String data);
FutureOr<void> write(String data);

/// closes the underlying connection
Future<void> close();
Expand Down
Loading

0 comments on commit 3e05187

Please sign in to comment.