Skip to content

Commit

Permalink
fix: deprecate/replace encryptedDefaultEncryptedPrivateKey
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-shris committed Nov 22, 2023
1 parent f9c1608 commit ea7d2d6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
3 changes: 3 additions & 0 deletions packages/at_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.58
- fix: Deprecate encryptedDefaultEncryptedPrivateKey in EnrollParams and introduce encryptedDefaultEncryptedPrivateKey for readability
- fix: Replace encryptedDefaultEncryptedPrivateKey with encryptedDefaultEncryptionPrivateKey in EnrollVerbBuilder
## 3.0.57
- feat: Introduced TTL(Time to Live) for OTP verb to configure OTP expiry
## 3.0.56
Expand Down
2 changes: 2 additions & 0 deletions packages/at_commons/lib/src/verb/enroll_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class EnrollParams {
String? deviceName;
Map<String, String>? namespaces;
String? otp;
@Deprecated('Use encryptedDefaultEncryptionPrivateKey')
String? encryptedDefaultEncryptedPrivateKey;
String? encryptedDefaultEncryptionPrivateKey;
String? encryptedDefaultSelfEncryptionKey;
String? encryptedAPKAMSymmetricKey;
String? apkamPublicKey;
Expand Down
5 changes: 4 additions & 1 deletion packages/at_commons/lib/src/verb/enroll_params.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/at_commons/lib/src/verb/enroll_verb_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {

Map<String, String>? namespaces;

String? encryptedDefaultEncryptedPrivateKey;
String? encryptedDefaultEncryptionPrivateKey;
String? encryptedDefaultSelfEncryptionKey;
String? encryptedAPKAMSymmetricKey;

Expand All @@ -45,8 +45,8 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
..apkamPublicKey = apkamPublicKey
..otp = otp
..namespaces = namespaces
..encryptedDefaultEncryptedPrivateKey =
encryptedDefaultEncryptedPrivateKey
..encryptedDefaultEncryptionPrivateKey =
encryptedDefaultEncryptionPrivateKey
..encryptedDefaultSelfEncryptionKey =
encryptedDefaultSelfEncryptionKey
..encryptedAPKAMSymmetricKey = encryptedAPKAMSymmetricKey)
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: 3.0.57
version: 3.0.58
repository: https://github.com/atsign-foundation/at_libraries
homepage: https://atsign.dev

Expand Down
16 changes: 8 additions & 8 deletions packages/at_commons/test/enroll_params_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ void main() {
group('A group of tests related to enroll verb', () {
test('A test to verify enroll request params', () {
String command =
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptedPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
command = command.replaceAll('enroll:request:', '');
var enrollParams = jsonDecode(command);
expect(enrollParams['enrollmentId'], '1234');
expect(enrollParams['appName'], 'wavi');
expect(enrollParams['deviceName'], 'pixel');
expect(enrollParams['namespaces']['wavi'], 'rw');
expect(enrollParams['namespaces']['__manage'], 'r');
expect(enrollParams['encryptedDefaultEncryptedPrivateKey'],
expect(enrollParams['encryptedDefaultEncryptionPrivateKey'],
'dummy_encrypted_private_key');
expect(enrollParams['encryptedDefaultSelfEncryptionKey'],
'dummy_self_encryption_key');
Expand All @@ -24,14 +24,14 @@ void main() {

test('A test to verify enroll approve params', () {
String command =
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptedPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}';
command = command.replaceAll('enroll:approve:', '');
var enrollParams = jsonDecode(command);
expect(enrollParams['enrollmentId'], '123');
expect(enrollParams['appName'], 'wavi');
expect(enrollParams['deviceName'], 'pixel');
expect(enrollParams['namespaces']['wavi'], 'rw');
expect(enrollParams['encryptedDefaultEncryptedPrivateKey'],
expect(enrollParams['encryptedDefaultEncryptionPrivateKey'],
'dummy_encrypted_private_key');
expect(enrollParams['encryptedDefaultSelfEncryptionKey'],
'dummy_self_encryption_key');
Expand Down Expand Up @@ -63,7 +63,7 @@ void main() {
..apkamPublicKey = 'abcd1234'
..enrollmentId = '1234'
..encryptedAPKAMSymmetricKey = 'dummy_pkam_sym_key'
..encryptedDefaultEncryptedPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultEncryptionPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key';

Map<String, dynamic> enrollParamsMap = enrollParams.toJson();
Expand All @@ -74,7 +74,7 @@ void main() {
expect(enrollParamsMap['enrollmentId'], '1234');
expect(
enrollParamsMap['encryptedAPKAMSymmetricKey'], 'dummy_pkam_sym_key');
expect(enrollParamsMap['encryptedDefaultEncryptedPrivateKey'],
expect(enrollParamsMap['encryptedDefaultEncryptionPrivateKey'],
'dummy_encrypted_private_key');
expect(enrollParamsMap['encryptedDefaultSelfEncryptionKey'],
'dummy_self_encryption_key');
Expand All @@ -88,7 +88,7 @@ void main() {
enrollParamsMap['apkamPublicKey'] = 'abcd1234';
enrollParamsMap['enrollmentId'] = '1234';
enrollParamsMap['encryptedAPKAMSymmetricKey'] = 'dummy_pkam_sym_key';
enrollParamsMap['encryptedDefaultEncryptedPrivateKey'] =
enrollParamsMap['encryptedDefaultEncryptionPrivateKey'] =
'dummy_encrypted_private_key';
enrollParamsMap['encryptedDefaultSelfEncryptionKey'] =
'dummy_self_encryption_key';
Expand All @@ -100,7 +100,7 @@ void main() {
expect(enrollParams.apkamPublicKey, 'abcd1234');
expect(enrollParams.enrollmentId, '1234');
expect(enrollParams.encryptedAPKAMSymmetricKey, 'dummy_pkam_sym_key');
expect(enrollParams.encryptedDefaultEncryptedPrivateKey,
expect(enrollParams.encryptedDefaultEncryptionPrivateKey,
'dummy_encrypted_private_key');
expect(enrollParams.encryptedDefaultSelfEncryptionKey,
'dummy_self_encryption_key');
Expand Down
8 changes: 4 additions & 4 deletions packages/at_commons/test/enroll_verb_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ void main() {
..apkamPublicKey = 'abcd1234'
..enrollmentId = '1234'
..encryptedAPKAMSymmetricKey = 'dummy_pkam_sym_key'
..encryptedDefaultEncryptedPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultEncryptionPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key';
var command = enrollVerbBuilder.buildCommand();
expect(command,
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptedPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}\n');
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}\n');
});

test('A test to verify enroll approve operation', () {
Expand All @@ -29,11 +29,11 @@ void main() {
..namespaces = {'wavi': 'rw'}
..apkamPublicKey = 'abcd1234'
..encryptedAPKAMSymmetricKey = 'dummy_pkam_sym_key'
..encryptedDefaultEncryptedPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultEncryptionPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key';
var command = enrollVerbBuilder.buildCommand();
expect(command,
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptedPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}\n');
'enroll:approve:{"enrollmentId":"123","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}\n');
});

test('A test to verify enroll deny operation', () {
Expand Down

0 comments on commit ea7d2d6

Please sign in to comment.