Documentation
¶
Overview ¶
file: bwcli/client.go
file: bwcli/runner.go
file: bwcli/types.go
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) ConfigureAgentTempDir(serverURL, userID string) error
- func (c *Client) CreateItem(ctx context.Context, session string, item *Item) (Item, error)
- func (c *Client) EditItem(ctx context.Context, session, itemID string, item *Item) (Item, error)
- func (c *Client) EnsureServer(ctx context.Context, serverURL string, env map[string]string) error
- func (c *Client) GetItem(ctx context.Context, session, itemID string) (Item, error)
- func (c *Client) ListCollections(ctx context.Context, session, organizationID string) ([]Collection, error)
- func (c *Client) ListItems(ctx context.Context, session string) ([]Item, error)
- func (c *Client) ListOrganizations(ctx context.Context, session string) ([]Organization, error)
- func (c *Client) LoginAPIKey(ctx context.Context, serverURL, clientID, clientSecret string) error
- func (c *Client) LogoutWithEnv(ctx context.Context, env map[string]string) error
- func (c *Client) Status(ctx context.Context) (Status, error)
- func (c *Client) Sync(ctx context.Context, session string) error
- func (c *Client) Unlock(ctx context.Context, masterPassword string) (string, error)
- func (c *Client) UpsertItemByName(ctx context.Context, session string, item *Item) (Item, bool, error)
- func (c *Client) UpsertSecureNote(ctx context.Context, session string, name string, notes string, orgID string, ...) (Item, bool, error)
- type Collection
- type Config
- type ExecRunner
- type Field
- type FieldType
- type Item
- type ItemType
- type Organization
- type RunResult
- type Runner
- type SecureNote
- type SecureNoteType
- type Status
Constants ¶
const ( ArbitraryErrorMaxLength = 200 DefaultBwBinary = "bw" )
Variables ¶
var ( ErrLocked = errors.New("bwcli: vault locked") ErrNotFound = errors.New("bwcli: not found") ErrCLI = errors.New("bwcli: generic error") ErrDecode = errors.New("bwcli: decode error") ErrTimeout = errors.New("bwcli: timeout") ErrServerVersionMismatch = errors.New( "bwcli: server does not support this CLI version " + "(userDecryptionOptions missing); upgrade the server or downgrade the bw CLI") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ConfigureAgentTempDir ¶
func (*Client) CreateItem ¶
func (*Client) EnsureServer ¶
EnsureServer ensures bw is configured to use serverURL. If the current server differs, it logs out (required by bw) and updates it.
func (*Client) ListCollections ¶
func (*Client) ListOrganizations ¶
func (*Client) LoginAPIKey ¶
LoginAPIKey logs in using Bitwarden API key values. This method does NOT store session; it just performs login.
func (*Client) LogoutWithEnv ¶
func (*Client) Unlock ¶
Unlock unlocks the vault and returns the session token (bw unlock --raw). The session MUST be passed per command via BW_SESSION env by the caller.
type Collection ¶
type Collection struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
OrganizationID string `json:"organizationId,omitempty"`
Raw json.RawMessage `json:"-"`
}
type ExecRunner ¶
ExecRunner is the production runner using os/exec.
type Item ¶
type Item struct {
SecureNote *SecureNote `json:"secureNote,omitempty"`
Notes string `json:"notes,omitempty"`
FolderID string `json:"folderId,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
OrganizationID string `json:"organizationId,omitempty"`
CollectionIDs []string `json:"collectionIds,omitempty"`
Identity json.RawMessage `json:"identity,omitempty"`
Raw json.RawMessage `json:"-"`
PasswordHistory json.RawMessage `json:"passwordHistory,omitempty"`
Fields []Field `json:"fields,omitempty"`
Login json.RawMessage `json:"login,omitempty"`
Card json.RawMessage `json:"card,omitempty"`
Type ItemType `json:"type,omitempty"`
Reprompt int `json:"reprompt,omitempty"`
Favorite bool `json:"favorite,omitempty"`
}
Item is a minimal representation of Bitwarden items. Many fields are optional and vary by "type". Keep unknown parts in Raw.
type Organization ¶
type Organization struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Raw json.RawMessage `json:"-"`
}
Organization / Collection kept minimal for backup grouping later.
type Runner ¶
type Runner interface {
Run(ctx context.Context, cmd string, args []string, env map[string]string, stdin []byte) RunResult
}
Runner abstracts execution so unit tests can inject a fake.
type SecureNote ¶
type SecureNote struct {
Type SecureNoteType `json:"type"`
}
type Status ¶
type Status struct {
ServerURL string `json:"serverUrl,omitempty"`
LastSync string `json:"lastSync,omitempty"`
UserEmail string `json:"userEmail,omitempty"`
UserID string `json:"userId,omitempty"`
Status string `json:"status,omitempty"` // "unauthenticated", "locked", "unlocked"
Raw json.RawMessage `json:"-"`
}
Status mirrors the important parts of `bw status` output. Keep it resilient to schema changes.