diff --git a/packages/at_commons/CHANGELOG.md b/packages/at_commons/CHANGELOG.md index 16629dd1..20b42069 100644 --- a/packages/at_commons/CHANGELOG.md +++ b/packages/at_commons/CHANGELOG.md @@ -1,3 +1,5 @@ +## 4.1.2 +- feat: Add "expiry" enroll params to support apkam keys to auto expiry after specified time duration ## 4.1.1 - feat: Add "delete" operation to the enroll verb to allow deletion of denied enrollments ## 4.1.0 diff --git a/packages/at_commons/lib/src/verb/enroll_params.dart b/packages/at_commons/lib/src/verb/enroll_params.dart index 2d6f0ceb..425f4e12 100644 --- a/packages/at_commons/lib/src/verb/enroll_params.dart +++ b/packages/at_commons/lib/src/verb/enroll_params.dart @@ -1,6 +1,6 @@ +import 'package:at_commons/at_commons.dart'; import 'package:json_annotation/json_annotation.dart'; -import 'package:at_commons/at_commons.dart'; part 'enroll_params.g.dart'; @JsonSerializable() @@ -15,7 +15,10 @@ class EnrollParams { String? encryptedAPKAMSymmetricKey; String? apkamPublicKey; List? enrollmentStatusFilter; + Duration? apkamKeysExpiryDuration; + EnrollParams(); + factory EnrollParams.fromJson(Map json) => _$EnrollParamsFromJson(json); diff --git a/packages/at_commons/lib/src/verb/enroll_params.g.dart b/packages/at_commons/lib/src/verb/enroll_params.g.dart index cc1c788d..a126cf80 100644 --- a/packages/at_commons/lib/src/verb/enroll_params.g.dart +++ b/packages/at_commons/lib/src/verb/enroll_params.g.dart @@ -1,5 +1,4 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// dart run build_runner build to generate this file part of 'enroll_params.dart'; @@ -23,7 +22,10 @@ EnrollParams _$EnrollParamsFromJson(Map json) => EnrollParams() ..apkamPublicKey = json['apkamPublicKey'] as String? ..enrollmentStatusFilter = (json['enrollmentStatusFilter'] as List?) ?.map((e) => $enumDecode(_$EnrollmentStatusEnumMap, e)) - .toList(); + .toList() + ..apkamKeysExpiryDuration = json['apkamKeysExpiryInMillis'] == null + ? null + : Duration(milliseconds: json['apkamKeysExpiryInMillis']); Map _$EnrollParamsToJson(EnrollParams instance) => { @@ -41,6 +43,8 @@ Map _$EnrollParamsToJson(EnrollParams instance) => 'enrollmentStatusFilter': instance.enrollmentStatusFilter ?.map((e) => _$EnrollmentStatusEnumMap[e]!) .toList(), + 'apkamKeysExpiryInMillis': + instance.apkamKeysExpiryDuration?.inMilliseconds, }; const _$EnrollmentStatusEnumMap = { diff --git a/packages/at_commons/lib/src/verb/enroll_verb_builder.dart b/packages/at_commons/lib/src/verb/enroll_verb_builder.dart index e9895a1b..79555e10 100644 --- a/packages/at_commons/lib/src/verb/enroll_verb_builder.dart +++ b/packages/at_commons/lib/src/verb/enroll_verb_builder.dart @@ -44,6 +44,8 @@ class EnrollVerbBuilder extends AbstractVerbBuilder { /// Accepts a list of enrollment statuses. Defaults to all EnrollmentStatuses List? enrollmentStatusFilter; + Duration? apkamKeysExpiryDuration; + @override String buildCommand() { var sb = StringBuffer(); @@ -64,7 +66,8 @@ class EnrollVerbBuilder extends AbstractVerbBuilder { encryptedDefaultEncryptionPrivateKey ..encryptedDefaultSelfEncryptionKey = encryptedDefaultSelfEncryptionKey ..encryptedAPKAMSymmetricKey = encryptedAPKAMSymmetricKey - ..enrollmentStatusFilter = enrollmentStatusFilter; + ..enrollmentStatusFilter = enrollmentStatusFilter + ..apkamKeysExpiryDuration = apkamKeysExpiryDuration; Map enrollParamsJson = enrollParams.toJson(); enrollParamsJson.removeWhere(_removeElements); diff --git a/packages/at_commons/lib/src/verb/notify_verb_builder.dart b/packages/at_commons/lib/src/verb/notify_verb_builder.dart index bf0cb9a0..f02f766e 100644 --- a/packages/at_commons/lib/src/verb/notify_verb_builder.dart +++ b/packages/at_commons/lib/src/verb/notify_verb_builder.dart @@ -1,10 +1,9 @@ import 'package:at_commons/src/keystore/at_key.dart'; -import 'package:at_commons/src/verb/abstract_verb_builder.dart'; import 'package:at_commons/src/utils/string_utils.dart'; +import 'package:at_commons/src/verb/abstract_verb_builder.dart'; import 'package:uuid/uuid.dart'; import '../at_constants.dart'; - import 'operation_enum.dart'; import 'verb_util.dart'; diff --git a/packages/at_commons/pubspec.yaml b/packages/at_commons/pubspec.yaml index e84b265b..37ebb016 100644 --- a/packages/at_commons/pubspec.yaml +++ b/packages/at_commons/pubspec.yaml @@ -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: 4.1.1 +version: 4.1.2 repository: https://github.com/atsign-foundation/at_libraries homepage: https://atsign.dev diff --git a/packages/at_commons/test/enroll_verb_builder_test.dart b/packages/at_commons/test/enroll_verb_builder_test.dart index 51a9a216..746d1c10 100644 --- a/packages/at_commons/test/enroll_verb_builder_test.dart +++ b/packages/at_commons/test/enroll_verb_builder_test.dart @@ -15,10 +15,11 @@ void main() { ..enrollmentId = '1234' ..encryptedAPKAMSymmetricKey = 'dummy_pkam_sym_key' ..encryptedDefaultEncryptionPrivateKey = 'dummy_encrypted_private_key' - ..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key'; + ..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key' + ..apkamKeysExpiryDuration = Duration(minutes: 1); var command = enrollVerbBuilder.buildCommand(); expect(command, - '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'); + '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","apkamKeysExpiryInMillis":60000}\n'); }); test('A test to verify enroll approve operation', () {