currentKeyId static method
Credentials.keyId when present; falls back to matching the stored
raw key's 16-char prefix for a file written by an older CLI or a
pasted login --key, which never records a keyId.
Implementation
static String? currentKeyId(
Credentials creds,
List<Map<String, dynamic>> keys,
) {
if (creds.keyId != null) return creds.keyId;
final prefix = creds.apiKey.length >= 16
? creds.apiKey.substring(0, 16)
: creds.apiKey;
for (final key in keys) {
if (key['prefix'] == prefix) return key['id'] as String;
}
return null;
}