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

feat: Modify the OTP syntax for client to set the expire duration #422

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@
## 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
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 @@ -129,7 +129,7 @@ class VerbSyntax {
static const enroll =
// The non-capturing group (?::)? matches ":" if the operation is request|approve|deny|revoke
r'^enroll:(?<operation>(?:list$|(request|approve|deny|revoke|update)))(?::)?(?<enrollParams>.+)?$';
static const otp = r'^otp:(?<operation>get|validate)(:(?<otp>\w+))?$';
static const otp = r'^otp:(?<operation>get)(:(?:ttl:(?<ttl>\d+)))?$';
static const keys = r'^keys:((?<operation>put|get|delete):?)'
r'(?:(?<visibility>public|private|self):?)?'
r'(?:namespace:(?<namespace>[a-zA-Z0-9_]+):?)?'
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.56
version: 3.0.57
repository: https://github.com/atsign-foundation/at_libraries
homepage: https://atsign.dev

Expand Down
24 changes: 24 additions & 0 deletions packages/at_commons/test/otp_verb_test.dart
Original file line number Diff line number Diff line change
@@ -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<dynamic, dynamic> 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<dynamic, dynamic> verbParams =
getVerbParams(VerbSyntax.otp, "otp:get:ttl:100");
expect(verbParams[AtConstants.operation], "get");
expect(verbParams['ttl'], '100');
expect(verbParams['otp'], null);
});
});
}
8 changes: 0 additions & 8 deletions packages/at_commons/test/syntax_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
}

Expand Down