Skip to content

Commit

Permalink
fix: Update the code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sitaram-kalluri committed Jan 16, 2024
1 parent 077cbb5 commit 910a6a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
5 changes: 2 additions & 3 deletions packages/at_secondary_server/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ enrollment:
# The duration of the time window in hours.
timeFrameInHours: 1
# The threshold value for the delay interval in seconds.
# If the time elapsed between the reception of the last invalid OTP and the
# current date and time surpasses the delayIntervalThreshold, initiate a reset
# to the default value.
# If the duration between the last received invalid OTP and the current date-time
# exceeds the delayIntervalThreshold, trigger a reset to the default value.
delayIntervalThreshold: 55
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ import 'package:at_persistence_secondary_server/at_persistence_secondary_server.
class EnrollVerbHandler extends AbstractVerbHandler {
static Enroll enrollVerb = Enroll();

/// Defaulting the initial delay to 1000 in milliseconds (1 second).
/// Defaulting the initial delay to 1000 milliseconds (1 second).
@visibleForTesting
static int initialDelayInMilliseconds = 1000;

/// A list storing a series of delay intervals for handling invalid OTP series.
/// The series is initially set to [0, 1000] and is updated using the Fibonacci sequence.
/// where 1000 represents the 1 second in milli-seconds.
/// The series is initially set to [0, [initialDelayInMilliseconds]] and is updated using the Fibonacci sequence.
@visibleForTesting
List<int> delayForInvalidOTPSeries = <int>[0, initialDelayInMilliseconds];

/// The threshold value for the delay interval in seconds.
/// The threshold value for the delay interval in milliseconds.
/// When the last delay in '_delayForInvalidOTPSeries' surpasses this threshold,
/// the series is reset to [0, 1] to prevent excessively long delay intervals.
/// the series is reset to [0, initialDelayInMilliseconds] to prevent excessively long delay intervals.
@visibleForTesting
int enrollmentResponseDelayIntervalInMillis = Duration(
seconds: AtSecondaryConfig.enrollmentResponseDelayIntervalInSeconds)
Expand Down Expand Up @@ -435,17 +434,16 @@ class EnrollVerbHandler extends AbstractVerbHandler {
///
/// This method updates a series of delays stored in the '_delayForInvalidOTPSeries'
/// list.
/// The delays are calculated based on the Fibonacci sequence with the
/// initial values [0, 1000].
/// If the last delay in the series surpasses a predefined threshold,
/// the series is reset to [0, 1000].
/// The delays are calculated based on the Fibonacci sequence. If the last delay in the
/// series surpasses a predefined threshold, the series is reset to default value.
///
/// Returns the calculated delay interval in milliseconds.
@visibleForTesting
int getDelayIntervalInMilliseconds() {
// If the last digit in "delayForInvalidOTPSeries" list reaches the threshold (enrollmentResponseDelayIntervalInMillis)
// then return the same without further incrementing the delay.
// If the last digit in "delayForInvalidOTPSeries" list reaches the threshold
// (enrollmentResponseDelayIntervalInMillis) then return the same without
// further incrementing the delay.
if (delayForInvalidOTPSeries.last >=
enrollmentResponseDelayIntervalInMillis) {
return delayForInvalidOTPSeries.last;
Expand Down
2 changes: 0 additions & 2 deletions packages/at_secondary_server/test/enroll_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,6 @@ void main() {
inboundConnection.getMetaData().isAuthenticated = true;
await otpVerbHandler.processVerb(
response, getVerbParam(VerbSyntax.otp, 'otp:get'), inboundConnection);
print('OTP: ${response.data}');

inboundConnection.getMetaData().isAuthenticated = false;
enrollmentRequest =
Expand All @@ -846,7 +845,6 @@ void main() {
inboundConnection.getMetaData().isAuthenticated = true;
await otpVerbHandler.processVerb(
response, getVerbParam(VerbSyntax.otp, 'otp:get'), inboundConnection);
print('OTP: ${response.data}');
inboundConnection.getMetaData().isAuthenticated = false;
enrollmentRequest =
'enroll:request:{"appName":"wavi","deviceName":"mydevice","namespaces":{"wavi":"r"},"otp":"${response.data}","apkamPublicKey":"dummy_apkam_public_key"}';
Expand Down

0 comments on commit 910a6a9

Please sign in to comment.