applyHandshake method
Called by SankofaModuleRegistry.routeHandshake when the server
returns a non-empty modules.deploy payload AND that payload's
enabled field is true. The registry skips this entirely when
the server says enabled: false — there's no kill-switch path
here because there's no opt-out: the server simply refuses to
issue patches for disabled customers.
The current implementation no-ops; the platform plugin's own fetch is the authoritative path for the install. A future optimization can use the unified handshake's pre-fetched payload (download_url + sha256 + label) to skip the second round-trip.
Implementation
@override
Future<void> applyHandshake(Map<String, dynamic> config) async {
// v2.2 — always read signing_keys, even when the module is disabled
// for THIS device's current request (e.g. has_update=false). The
// pubkeys are project-scoped, not request-scoped, and a future
// apply call in this session needs them ready.
final rawKeys = config['signing_keys'];
if (rawKeys is List) {
final out = <String>[];
for (final entry in rawKeys) {
if (entry is Map) {
final pk = entry['pubkey_b64'];
if (pk is String && pk.isNotEmpty) {
out.add(pk);
}
}
}
_serverSigningKeysB64 = List.unmodifiable(out);
if (kDebugMode && out.isNotEmpty) {
debugPrint('[Sankofa.deploy] handshake cached ${out.length} server signing key(s)');
}
}
if (config['enabled'] == false) return;
// Future: if config['has_update'] == true, feed the
// download_url + sha256 + label + size into the platform plugin
// so the Rust updater can install without an extra fetch.
// For now we let the platform plugin's checkForUpdate() handle it.
if (kDebugMode) {
final hasUpdate = config['has_update'] == true;
final label = config['label'] as String?;
if (hasUpdate) {
debugPrint('[Sankofa.deploy] handshake reports pending update: $label');
}
}
}