store

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package store contains a minimal, read-only SQLite reader, used to read credentials out of a kiro-cli database without taking on a dependency.

It implements only what that job needs: the file header, table B-tree pages, record decoding and overflow chains. There is no query planner, no index support and no write path. Nothing here ever modifies the file.

Index

Constants

View Source
const ProfileStateKey = "api.codewhisperer.profile"

ProfileStateKey is the state row holding the selected CodeWhisperer profile.

Variables

View Source
var ErrNotFound = errors.New("key not found")

ErrNotFound reports that a key is absent.

View Source
var ErrWALPresent = errors.New("the database is in WAL mode, so the main file may be stale")

ErrWALPresent reports that the database has an active write-ahead log.

The reader deliberately refuses these: the committed pages in the main file can be older than the contents of the WAL, so reading it would hand back a stale token that has already been replaced.

View Source
var RegistrationKeys = []string{
	"kirocli:odic:device-registration",
	"codewhisperer:odic:device-registration",
}

RegistrationKeys are the auth_kv keys that may hold a device registration.

View Source
var TokenKeys = []string{
	"kirocli:social:token",
	"kirocli:odic:token",
	"codewhisperer:odic:token",
}

TokenKeys are the auth_kv keys that may hold a token, in priority order.

The "odic" spelling is a typo in kiro-cli itself. It is reproduced exactly, because that is the key the data is actually stored under.

Functions

func ParseTimestamp

func ParseTimestamp(s string) (time.Time, error)

ParseTimestamp parses an RFC3339 timestamp from a kiro-cli record.

kiro-cli writes nanosecond precision, and some builds write more digits than Go's parser accepts, so the fraction is truncated to nine digits first.

Types

type Credentials

type Credentials struct {
	AccessToken  string
	RefreshToken string
	ProfileARN   string
	Region       string
	ExpiresAt    time.Time
	ClientID     string
	ClientSecret string
	// SourceKey records which auth_kv key the token came from, for logging.
	SourceKey string
}

Credentials is what a kiro-cli database yields.

It mirrors the fields the auth layer needs, without importing it, so the two packages stay independent.

func LoadCredentials

func LoadCredentials(path string) (*Credentials, error)

LoadCredentials reads credentials from a kiro-cli database.

It never writes: token rotation stays kiro-cli's responsibility, so kirogo keeps a refreshed token in memory only.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is an open, read-only SQLite database held in memory.

kiro-cli databases are small, so the whole file is read at once. That avoids any chance of observing a half-written page mid-read.

func Open

func Open(path string) (*DB, error)

Open reads and validates a SQLite database file.

func (*DB) Lookup

func (db *DB) Lookup(table, keyColumn, valueColumn, key string) (Value, error)

Lookup returns the value column of the row whose key column matches key.

It is the whole query surface this reader needs: kiro-cli stores credentials as key/value rows in small tables, so a scan is both simpler and fast enough. Column positions come from the table's CREATE statement rather than being assumed, so a schema change does not silently read the wrong column.

func (*DB) PageSize

func (db *DB) PageSize() int

PageSize returns the database page size.

func (*DB) Tables

func (db *DB) Tables() ([]string, error)

Tables lists the table names in the database, for diagnostics.

type Value

type Value struct {
	Type  ValueType
	Int   int64
	Float float64
	Bytes []byte
}

Value is one decoded column.

func (Value) IsNull

func (v Value) IsNull() bool

IsNull reports whether the column holds SQL NULL.

func (Value) Text

func (v Value) Text() string

Text returns the value as a string. A blob is interpreted as UTF-8, which is how kiro-cli stores its JSON payloads.

type ValueType

type ValueType int

ValueType is the storage class of a decoded column.

const (
	ValueNull ValueType = iota
	ValueInt
	ValueFloat
	ValueText
	ValueBlob
)

Storage classes.

Jump to

Keyboard shortcuts

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