respondToChallenge method
- @protected
Helper function to respond to a challenge request. This will create and
send the appropriate ChallengeResponseCommand
to the socket
.
Implementation
@protected
void respondToChallenge({
required String commandId,
required String salt,
required String secret,
required WebSocket socket,
required DateTime timestamp,
}) {
if ((DateTime.now().millisecondsSinceEpoch -
timestamp.millisecondsSinceEpoch)
.abs() >=
300000) {
throw Exception('[EXPIRED]: received expired challenge');
}
socket.add(
ChallengeResponseCommand(
commandId: commandId,
signature: DriverSignatureHelper().createSignature(
secret,
[
salt,
timestamp.millisecondsSinceEpoch.toString(),
],
),
).toString(),
);
}