Skip to content
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

fix: Uptake public key hash changes #2160

Merged
merged 20 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fbb6244
fix: Uptake public key hash changes
sitaram-kalluri Nov 15, 2024
db95194
fix: Add dependency_overrides in the pubspec.yaml
sitaram-kalluri Nov 26, 2024
8182577
fix: Add functional test to verify publicKeyHash is set in metadata b…
sitaram-kalluri Nov 27, 2024
65940f5
fix: Add E2E test to verify publicKeyHash
sitaram-kalluri Nov 27, 2024
dc70d7b
Merge remote-tracking branch 'origin/trunk' into 2121-uptake-pubkeyha…
sitaram-kalluri Nov 27, 2024
2d4223c
fix: Remove hard coded atSign from E2E test to verify publicKeyHash
sitaram-kalluri Nov 27, 2024
25b567f
fix: Add version check for second atSign
sitaram-kalluri Nov 27, 2024
a8656d9
fix: Skip publicKeyHash E2E test
sitaram-kalluri Nov 27, 2024
0eb9ca3
fix: Add randomId to have unique keys on each run
sitaram-kalluri Nov 27, 2024
24194dc
fix: Remove the skip tag
sitaram-kalluri Nov 27, 2024
c0924fa
Merge branch 'trunk' into 2121-uptake-pubkeyhash-changes
sitaram-kalluri Dec 5, 2024
4fb2928
fix: Update the server version to fix th E2E test
sitaram-kalluri Dec 5, 2024
04517b2
Merge branch 'trunk' into 2121-uptake-pubkeyhash-changes
sitaram-kalluri Dec 9, 2024
79d45da
fix: Update the server version in the E2E test log.
sitaram-kalluri Dec 9, 2024
cb2efb8
Merge remote-tracking branch 'origin/2121-uptake-pubkeyhash-changes' …
sitaram-kalluri Dec 9, 2024
594d592
Merge remote-tracking branch 'origin/trunk' into 2121-uptake-pubkeyha…
sitaram-kalluri Dec 9, 2024
c3c2321
fix: Update the version to 3.1.1
sitaram-kalluri Dec 9, 2024
7ce9aea
fix: Replace not null check with isNotNullOrEmpty
sitaram-kalluri Dec 10, 2024
85db4dc
Merge branch 'trunk' into 2121-uptake-pubkeyhash-changes
sitaram-kalluri Dec 10, 2024
075b674
Merge branch 'trunk' into 2121-uptake-pubkeyhash-changes
gkc Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ class ResourceManager {
commandBody =
'${AtConstants.encryptingKeyName}:${atNotification.atMetadata!.encKeyName}:$commandBody';
}
if (atNotification.atMetadata!.pubKeyHash != null) {
commandBody =
'${AtConstants.sharedWithPublicKeyHash}:${atNotification.atMetadata!.pubKeyHash?.hash}:${AtConstants.sharedWithPublicKeyHashingAlgo}:${atNotification.atMetadata!.pubKeyHash?.hashingAlgo}:$commandBody';
}
if (atNotification.atMetadata!.pubKeyCS != null) {
commandBody =
'${AtConstants.sharedWithPublicKeyCheckSum}:${atNotification.atMetadata!.pubKeyCS}:$commandBody';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ abstract class AbstractUpdateVerbHandler extends ChangeVerbHandler {
verbParams[AtConstants.sharedKeyEncryptedEncryptingKeyName];
metadata.skeEncAlgo =
verbParams[AtConstants.sharedKeyEncryptedEncryptingAlgo];
if (verbParams[AtConstants.sharedWithPublicKeyHash] != null &&
verbParams[AtConstants.sharedWithPublicKeyHashingAlgo] != null) {
sitaram-kalluri marked this conversation as resolved.
Show resolved Hide resolved
metadata.pubKeyHash = PublicKeyHash(
verbParams[AtConstants.sharedWithPublicKeyHash]!,
verbParams[AtConstants.sharedWithPublicKeyHashingAlgo]!);
}

updateParams.metadata = metadata;
return updateParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class MonitorVerbHandler extends AbstractVerbHandler {
"skeEncKeyName": atNotification.atMetadata?.skeEncKeyName,
"skeEncAlgo": atNotification.atMetadata?.skeEncAlgo,
"sharedKeyEnc": atNotification.atMetadata?.sharedKeyEnc,
"pubKeyHash":
jsonEncode(atNotification.atMetadata?.pubKeyHash?.toJson())
};

await _checkAndSend(notification);
Expand Down Expand Up @@ -222,7 +224,8 @@ class Notification {
"availableAt": atNotification.atMetadata?.availableAt.toString(),
"expiresAt":
(atNotification.atMetadata?.expiresAt ?? atNotification.expiresAt)
.toString()
.toString(),
'pubKeyHash': jsonEncode(atNotification.atMetadata?.pubKeyHash?.toJson())
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ class NotifyVerbHandler extends AbstractVerbHandler {
if (verbParams[AtConstants.sharedWithPublicKeyCheckSum] != null) {
atMetadata.pubKeyCS = verbParams[AtConstants.sharedWithPublicKeyCheckSum];
}
if (verbParams[AtConstants.sharedWithPublicKeyHash].isNotNullOrEmpty &&
verbParams[AtConstants.sharedWithPublicKeyHashingAlgo]
.isNotNullOrEmpty) {
atMetadata.pubKeyHash = PublicKeyHash(
verbParams[AtConstants.sharedWithPublicKeyHash]!,
verbParams[AtConstants.sharedWithPublicKeyHashingAlgo]!);
}
if (verbParams[AtConstants.encryptingKeyName] != null) {
atMetadata.encKeyName = verbParams[AtConstants.encryptingKeyName];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,24 @@ class SyncProgressiveVerbHandler extends AbstractVerbHandler {
if (metaData == null) {
return metaDataMap;
}
metaData.toJson().forEach((key, value) {
if (value != null) {
metaDataMap[key] = value.toString();
Iterator itr = metaData.toJson().entries.iterator;
while (itr.moveNext()) {
// The value of [AtConstants.sharedWithPublicKeyHash] stores a Map containing
// the hash value and the hashing algorithm used for hashing the data.
// For example, {"hash":"dummy_value", "hashingAlgo":"sha512"}.
// Using toString() will not allow convert this into a Map, which is necessary
// for constructing the PublicKeyHash type on the client side.
// Therefore, a JSON-encoded string is used here, and on the client side,
// "jsonDecode" will be used to retrieve the Map and build the PublicKeyHash instance.
if (itr.current.key == AtConstants.sharedWithPublicKeyHash &&
itr.current.value != null) {
metaDataMap[itr.current.key] = jsonEncode(itr.current.value);
continue;
}
if (itr.current.value != null) {
metaDataMap[itr.current.key] = itr.current.value.toString();
}
});
}
return metaDataMap;
}

Expand Down
17 changes: 12 additions & 5 deletions packages/at_secondary_server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
sdk: '>=3.0.0 <4.0.0'

dependencies:
args: 2.5.0
args: 2.6.0
uuid: 3.0.7
convert: 3.1.1
cron: 0.5.1
Expand All @@ -19,24 +19,31 @@ dependencies:
basic_utils: 5.7.0
ecdsa: 0.1.0
encrypt: 5.0.3
at_commons: 5.0.1
at_commons: 5.0.2
at_utils: 3.0.19
at_chops: 2.0.1
at_chops: 2.2.0
at_lookup: 3.0.49
at_server_spec: 5.0.2
at_persistence_spec: 2.0.14
at_persistence_secondary_server: 3.0.65
intl: ^0.19.0
json_annotation: ^4.8.0
version: 3.0.2
meta: 1.15.0
meta: 1.16.0
mutex: 3.1.0
yaml: 3.1.2
logging: 1.2.0

dependency_overrides:
at_persistence_secondary_server:
git:
url: https://github.com/atsign-foundation/at_server.git
path: packages/at_persistence_secondary_server
ref: 2121-uptake-public-key-hash-at-persistence_secondary-server

dev_dependencies:
build_runner: ^2.3.3
test: ^1.24.4
test: ^1.25.8
coverage: ^1.6.1
lints: ^5.0.0
mocktail: ^1.0.3
11 changes: 9 additions & 2 deletions packages/at_secondary_server/test/sync_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:collection';
import 'dart:convert';
import 'dart:io';

import 'package:at_chops/at_chops.dart';
import 'package:at_commons/at_commons.dart';
import 'package:at_persistence_secondary_server/at_persistence_secondary_server.dart';
import 'package:at_secondary/src/connection/inbound/inbound_connection_impl.dart';
Expand All @@ -10,8 +11,8 @@ import 'package:at_secondary/src/utils/handler_util.dart';
import 'package:at_secondary/src/utils/secondary_util.dart';
import 'package:at_secondary/src/verb/handler/sync_progressive_verb_handler.dart';
import 'package:at_server_spec/at_verb_spec.dart';
import 'package:test/test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:test/test.dart';

import 'test_utils.dart';

Expand Down Expand Up @@ -115,7 +116,10 @@ void main() {
..ttb = 1000
..ttr = 100
..isBinary = false
..encoding = 'base64'));
..encoding = 'base64'
..pubKeyHash =
PublicKeyHash('dummy_hash', HashingAlgoType.sha512.name)
..pubKeyCS = 'dummy_pub_key_cs'));

verbHandler = SyncProgressiveVerbHandler(keyStoreManager.getKeyStore());
var response = Response();
Expand All @@ -136,6 +140,9 @@ void main() {
expect(syncResponseMap['metadata']['ttr'], '100');
expect(syncResponseMap['metadata']['isBinary'], 'false');
expect(syncResponseMap['metadata']['encoding'], 'base64');
expect(syncResponseMap['metadata']['pubKeyCS'], 'dummy_pub_key_cs');
expect(syncResponseMap['metadata']['pubKeyHash'],
'{"hash":"dummy_hash","hashingAlgo":"sha512"}');
});

when(() => mockKeyStore.isKeyExists(any())).thenReturn(true);
Expand Down
8 changes: 8 additions & 0 deletions tests/at_end2end_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ dependencies:
at_demo_data: ^1.0.3
at_lookup: ^3.0.48


dependency_overrides:
at_persistence_secondary_server:
git:
url: https://github.com/atsign-foundation/at_server.git
path: packages/at_persistence_secondary_server
ref: 2121-uptake-public-key-hash-at-persistence_secondary-server

dev_dependencies:
lints: ^1.0.1
test: ^1.14.4
Expand Down
11 changes: 9 additions & 2 deletions tests/at_functional_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ environment:
dependencies:
hex: ^0.2.0
at_demo_data: ^1.1.0
at_chops: ^2.0.0
at_chops: ^2.2.0
at_lookup: ^3.0.48
at_commons: ^4.1.2
at_commons: ^5.0.2
uuid: ^3.0.7
elliptic: ^0.3.8

dependency_overrides:
at_persistence_secondary_server:
git:
url: https://github.com/atsign-foundation/at_server.git
path: packages/at_persistence_secondary_server
ref: 2121-uptake-public-key-hash-at-persistence_secondary-server

dev_dependencies:
lints: ^4.0.0
test: ^1.25.8
Expand Down