Add device agent library

Provide enrollment, elevated install, posture checks, keystore, and
system-tray helpers shared by the probo-agent binary.

Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
Ludovic Vielle
2026-07-14 20:40:05 +02:00
parent e767dd8377
commit b442e1ed76
44 changed files with 2814 additions and 88 deletions

View File

@@ -31,7 +31,8 @@ import (
// KeyFileName stores the device API key on disk.
const KeyFileName = "agent.key"
// ErrKeyNotFound is returned when no key file exists.
// ErrKeyNotFound is returned when no usable key is on disk (missing,
// empty, or whitespace-only file).
var ErrKeyNotFound = errors.New("agent key not found")
// KeyPath returns the absolute path of the device API key file.
@@ -72,7 +73,12 @@ func LoadAPIKey(dir string) (string, error) {
return "", fmt.Errorf("cannot read agent key: %w", err)
}
return strings.TrimSpace(string(data)), nil
key := strings.TrimSpace(string(data))
if key == "" {
return "", ErrKeyNotFound
}
return key, nil
}
// DeleteAPIKey removes the API key file.