diff --git a/packages/at_commons/CHANGELOG.md b/packages/at_commons/CHANGELOG.md index c0fd26bf..a7de6a74 100644 --- a/packages/at_commons/CHANGELOG.md +++ b/packages/at_commons/CHANGELOG.md @@ -1,3 +1,5 @@ +## 3.0.57 +- feat: Introduced TTL(Time to Live) for OTP verb to configure OTP expiry ## 3.0.56 - feat: Introduce "AtInvalidEnrollmentException" which is thrown when an enrollment is expired or invalid - feat: Introduce error code 'AT0030' for Invalid Enrollment Status diff --git a/packages/at_commons/lib/src/verb/syntax.dart b/packages/at_commons/lib/src/verb/syntax.dart index 780816c8..050beb33 100644 --- a/packages/at_commons/lib/src/verb/syntax.dart +++ b/packages/at_commons/lib/src/verb/syntax.dart @@ -129,7 +129,7 @@ class VerbSyntax { static const enroll = // The non-capturing group (?::)? matches ":" if the operation is request|approve|deny|revoke r'^enroll:(?(?:list$|(request|approve|deny|revoke|update)))(?::)?(?.+)?$'; - static const otp = r'^otp:(?get|validate)(:(?\w+))?$'; + static const otp = r'^otp:(?get)(:(?:ttl:(?\d+)))?$'; static const keys = r'^keys:((?put|get|delete):?)' r'(?:(?public|private|self):?)?' r'(?:namespace:(?[a-zA-Z0-9_]+):?)?' diff --git a/packages/at_commons/pubspec.yaml b/packages/at_commons/pubspec.yaml index 8582feea..69055bba 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: 3.0.56 +version: 3.0.57 repository: https://github.com/atsign-foundation/at_libraries homepage: https://atsign.dev diff --git a/packages/at_commons/test/otp_verb_test.dart b/packages/at_commons/test/otp_verb_test.dart new file mode 100644 index 00000000..8510b0d3 --- /dev/null +++ b/packages/at_commons/test/otp_verb_test.dart @@ -0,0 +1,24 @@ +import 'package:at_commons/at_commons.dart'; +import 'package:test/test.dart'; + +import 'syntax_test.dart'; + +void main() { + group('A group of tests related to OTP verb syntax', () { + test('A test to verify otp:get regex', () { + Map verbParams = + getVerbParams(VerbSyntax.otp, "otp:get"); + expect(verbParams[AtConstants.operation], "get"); + expect(verbParams['ttl'], null); + expect(verbParams['otp'], null); + }); + + test('A test to verify otp:get regex with TTL', () { + Map verbParams = + getVerbParams(VerbSyntax.otp, "otp:get:ttl:100"); + expect(verbParams[AtConstants.operation], "get"); + expect(verbParams['ttl'], '100'); + expect(verbParams['otp'], null); + }); + }); +} diff --git a/packages/at_commons/test/syntax_test.dart b/packages/at_commons/test/syntax_test.dart index 679301fc..03484248 100644 --- a/packages/at_commons/test/syntax_test.dart +++ b/packages/at_commons/test/syntax_test.dart @@ -307,14 +307,6 @@ void main() { VerbUtil.getVerbParam(VerbSyntax.otp, command.trim())!; expect(enrollVerbParams['operation'], 'get'); }); - - test('A test to verify otp verb for validate operation', () { - String command = 'otp:validate:ABC123\n'; - var enrollVerbParams = - VerbUtil.getVerbParam(VerbSyntax.otp, command.trim()); - expect(enrollVerbParams!['operation'], 'validate'); - expect(enrollVerbParams['otp'], 'ABC123'); - }); }); }