keychain

package
v3.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package keychain reads and deletes the legacy items of mai in the system keychain: the macOS Keychain, the Windows Credential Manager, or the Linux Secret Service.

mai 3.0 and 3.1 kept the owner key and the agent keys in the keychain. The CLI now keeps them in its key file. This package is only for the move of the legacy items to the key file and for the removal of the legacy items. It never writes an item.

The service is "dev.mai". The accounts are "owner@<instance>" and "agent:<name>@<instance>".

Index

Constants

View Source
const Service = "dev.mai"

Service is the keychain service of each legacy item of mai.

Variables

View Source
var ErrNotFound = errors.New("keychain: item not found")

ErrNotFound means that the item does not exist.

View Source
var ErrUnavailable = errors.New("keychain: not available")

ErrUnavailable means that this system has no keychain that the CLI can use, for example a Linux host with no Secret Service. Such a keychain holds no item of mai.

Functions

This section is empty.

Types

type Memory

type Memory struct {
	Err error
	// contains filtered or unexported fields
}

Memory is a Store in memory, for tests. When Err is not nil, each call gives Err.

func NewMemory

func NewMemory() *Memory

NewMemory returns an empty Memory store.

func (*Memory) Accounts added in v3.2.0

func (m *Memory) Accounts() []string

Accounts gives the account of each item, sorted.

func (*Memory) Delete

func (m *Memory) Delete(account string) error

func (*Memory) Get

func (m *Memory) Get(account string) (string, error)

func (*Memory) Has added in v3.2.0

func (m *Memory) Has(account string) (bool, error)

func (*Memory) Put added in v3.2.0

func (m *Memory) Put(account, secret string)

Put adds or replaces the item of account. Only a test writes an item.

type Store

type Store interface {
	// Get reads the secret of the item of account.
	Get(account string) (string, error)
	// Has tells if the item of account exists. When it can, it reads no secret and shows no
	// prompt.
	Has(account string) (bool, error)
	// Delete removes the item of account. It gives ErrNotFound when the item does not exist.
	Delete(account string) error
}

Store gives access to the legacy items of Service. An implementation never prints or logs a secret.

func System

func System() Store

System returns the keychain of the OS, with the items of Service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL