feat(useragent): callouts feature for approving new things
This commit is contained in:
@@ -66,7 +66,7 @@ Future<Connection> connectAndAuthorize(
|
||||
KeyAlgorithm.ed25519 => KeyType.KEY_TYPE_ED25519,
|
||||
},
|
||||
);
|
||||
final response = await connection.request(
|
||||
final response = await connection.ask(
|
||||
UserAgentRequest(authChallengeRequest: req),
|
||||
);
|
||||
talker.info(
|
||||
@@ -94,7 +94,7 @@ Future<Connection> connectAndAuthorize(
|
||||
);
|
||||
|
||||
final signature = await key.sign(challenge);
|
||||
final solutionResponse = await connection.request(
|
||||
final solutionResponse = await connection.ask(
|
||||
UserAgentRequest(authChallengeSolution: AuthChallengeSolution(signature: signature)),
|
||||
);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class Connection {
|
||||
|
||||
Stream<UserAgentResponse> get outOfBandMessages => _outOfBandMessages.stream;
|
||||
|
||||
Future<UserAgentResponse> request(UserAgentRequest message) async {
|
||||
Future<UserAgentResponse> ask(UserAgentRequest message) async {
|
||||
_ensureOpen();
|
||||
|
||||
final requestId = _nextRequestId++;
|
||||
@@ -49,7 +49,23 @@ class Connection {
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future<void> tell(UserAgentRequest message) async {
|
||||
_ensureOpen();
|
||||
|
||||
final requestId = _nextRequestId++;
|
||||
message.id = requestId;
|
||||
|
||||
talker.debug('Sending message: ${message.toDebugString()}');
|
||||
|
||||
try {
|
||||
_tx.add(message);
|
||||
} catch (error, stackTrace) {
|
||||
talker.error('Failed to send message: $error', error, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> close() async {
|
||||
talker.debug('Closing connection...');
|
||||
final rxSubscription = _rxSubscription;
|
||||
if (rxSubscription == null) {
|
||||
return;
|
||||
@@ -86,6 +102,7 @@ class Connection {
|
||||
}
|
||||
|
||||
void _handleDone() {
|
||||
talker.debug('Connection closed by server.');
|
||||
if (_rxSubscription == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:arbiter/proto/user_agent.pb.dart';
|
||||
import 'package:protobuf/well_known_types/google/protobuf/empty.pb.dart';
|
||||
|
||||
Future<List<WalletEntry>> listEvmWallets(Connection connection) async {
|
||||
final response = await connection.request(
|
||||
final response = await connection.ask(
|
||||
UserAgentRequest(evmWalletList: Empty()),
|
||||
);
|
||||
if (!response.hasEvmWalletList()) {
|
||||
@@ -25,7 +25,7 @@ Future<List<WalletEntry>> listEvmWallets(Connection connection) async {
|
||||
}
|
||||
|
||||
Future<void> createEvmWallet(Connection connection) async {
|
||||
final response = await connection.request(
|
||||
final response = await connection.ask(
|
||||
UserAgentRequest(evmWalletCreate: Empty()),
|
||||
);
|
||||
if (!response.hasEvmWalletCreate()) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:protobuf/well_known_types/google/protobuf/timestamp.pb.dart';
|
||||
Future<List<GrantEntry>> listEvmGrants(Connection connection) async {
|
||||
final request = EvmGrantListRequest();
|
||||
|
||||
final response = await connection.request(
|
||||
final response = await connection.ask(
|
||||
UserAgentRequest(evmGrantList: request),
|
||||
);
|
||||
if (!response.hasEvmGrantList()) {
|
||||
@@ -43,7 +43,7 @@ Future<int> createEvmGrant(
|
||||
}
|
||||
|
||||
Future<void> deleteEvmGrant(Connection connection, int grantId) async {
|
||||
final response = await connection.request(
|
||||
final response = await connection.ask(
|
||||
UserAgentRequest(evmGrantDelete: EvmGrantDeleteRequest(grantId: grantId)),
|
||||
);
|
||||
if (!response.hasEvmGrantDelete()) {
|
||||
|
||||
@@ -10,7 +10,7 @@ Future<BootstrapResult> bootstrapVault(
|
||||
) async {
|
||||
final encryptedKey = await _encryptVaultKeyMaterial(connection, password);
|
||||
|
||||
final response = await connection.request(
|
||||
final response = await connection.ask(
|
||||
UserAgentRequest(
|
||||
bootstrapEncryptedKey: BootstrapEncryptedKey(
|
||||
nonce: encryptedKey.nonce,
|
||||
@@ -31,7 +31,7 @@ Future<BootstrapResult> bootstrapVault(
|
||||
Future<UnsealResult> unsealVault(Connection connection, String password) async {
|
||||
final encryptedKey = await _encryptVaultKeyMaterial(connection, password);
|
||||
|
||||
final response = await connection.request(
|
||||
final response = await connection.ask(
|
||||
UserAgentRequest(
|
||||
unsealEncryptedKey: UnsealEncryptedKey(
|
||||
nonce: encryptedKey.nonce,
|
||||
@@ -56,7 +56,7 @@ Future<_EncryptedVaultKey> _encryptVaultKeyMaterial(
|
||||
final clientKeyPair = await keyExchange.newKeyPair();
|
||||
final clientPublicKey = await clientKeyPair.extractPublicKey();
|
||||
|
||||
final handshakeResponse = await connection.request(
|
||||
final handshakeResponse = await connection.ask(
|
||||
UserAgentRequest(unsealStart: UnsealStart(clientPubkey: clientPublicKey.bytes)),
|
||||
);
|
||||
if (!handshakeResponse.hasUnsealStartResponse()) {
|
||||
|
||||
Reference in New Issue
Block a user