Expand description
Credential storage — ~/.cinch/config.json (0600 permissions).
This module is the source of truth for the disk credential format used
by both CLI and desktop. The Go CLI’s
cinch/cmd/internal/credstore/store.go uses identical service/account
conventions; do not change SERVICE_NAME or the account key format
without coordinated updates on both sides.
Structs§
Enums§
Constants§
- DEVICE_
CODE_ MARKER_ END - DEVICE_
CODE_ MARKER_ START - stdout marker emitted by
cinch auth login --headlessso the orchestrating side (e.g.cinch pairrunning over SSH) can pick up the device-code URL without parsing free-form output. - LEGACY_
SERVICE_ NAME - Legacy Keychain service name used by builds prior to 2026-04-29. The credstore reads this as a fallback and migrates entries forward on first successful read.
- PAIRING_
COMPLETE_ MARKER_ END - PAIRING_
COMPLETE_ MARKER_ START - stdout marker emitted by the SSH pair script when the remote machine
has either reused an existing matching pairing or completed a fresh
device-code login. The orchestrating desktop uses this marker to
verify that the remote’s
user_idmatches the local active profile — without it, an exit-0 SSH session can falsely look successful when the remote was already signed in as a different user (orcinch auth loginshort-circuited before emitting any pairing evidence). - SERVICE_
NAME
Functions§
- add_
relay_ profile - Add a new RelayProfile to MultiConfig for a freshly-authenticated relay. Used by the deep-link callback when PendingRelayAdd is set. Returns relay_id.
- format_
device_ code_ marker - load_
config - load_
multi_ config - parse_
device_ code_ marker - parse_
pairing_ complete_ marker - poll_
key_ bundle - Poll
GET /auth/key-bundlefor up to 30s waiting for a key-bearer device to publish our encrypted user-key bundle. Returnstrueif a bundle arrived and the decrypted master key was persisted viacredstore::write_encryption_key; returnsfalseon timeout or any decode failure (with a single line printed to stderr per observed failure mode, mirroring the original CLI behavior). - read_
credentials - read_credentials returns the token for the currently-configured (user_id, device_id).
- read_
encryption_ key - Read the encryption key for a user from config.
- rotate_
credentials - rotate_credentials persists a new token after a WS
token_rotatedevent. - save_
config_ to_ disk - save_
multi_ config - wipe_
credentials - wipe_credentials clears all credential fields from config, bumps credential_version, and best-effort deletes any Keychain entries left over from pre-2026-05-08 CLI builds.
- wipe_
relay_ credentials - Remove credentials for a specific relay from MultiConfig.
- write_
credentials - write_credentials stores token in config.json (0600). Bumps credential_version and persists via save_config.
- write_
encryption_ key - Write the encryption key for a user to config.