store

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSStore

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

FSStore is a simple file-system-backed store for sealed objects and user containers. Structure:

{base}/o/{cid}              -> original JSON-LD bytes
{base}/o/canonical/{cid}.nq -> canonical n-quads text
{base}/u/{login}/g/{slug}/latest -> text file containing CID
{base}/u/{login}/g/{slug}/_history -> JSON array of history entries

func NewFSStore

func NewFSStore(base string) *FSStore

func (*FSStore) AppendHistory

func (s *FSStore) AppendHistory(user, slug, cidStr string) error

AppendHistory appends a history entry (CID + timestamp) to _history (JSON array).

func (*FSStore) DeleteObject

func (s *FSStore) DeleteObject(cid string) error

DeleteObject removes an object and its associated files

func (*FSStore) EnsureUserContainer

func (s *FSStore) EnsureUserContainer(user string) error

Utility: Create container for user (e.g., when user logs in)

func (*FSStore) GetObjectAuthor

func (s *FSStore) GetObjectAuthor(cid string) (githubUser, githubID string, err error)

GetObjectAuthor retrieves the author information from a stored object

func (*FSStore) ObjectPath

func (s *FSStore) ObjectPath(cid string) string

ObjectPath returns the path where the original JSON-LD for a CID is stored.

func (*FSStore) ReadCanonical

func (s *FSStore) ReadCanonical(cid string) ([]byte, error)

Utility: Read canonical n-quads for a cid

func (*FSStore) ReadHistory

func (s *FSStore) ReadHistory(user, slug string) ([]HistoryEntry, error)

ReadHistory reads and returns the history entries for a gist.

func (*FSStore) ReadLatest

func (s *FSStore) ReadLatest(user, slug string) (string, error)

ReadLatest returns the CID stored in latest (or empty string if not present).

func (*FSStore) ReadMarkdownContent

func (s *FSStore) ReadMarkdownContent(cid string) ([]byte, error)

ReadMarkdownContent reads the markdown content for a CID if it exists

func (*FSStore) ReadObject

func (s *FSStore) ReadObject(cid string) ([]byte, error)

Utility: Read object raw JSON-LD

func (*FSStore) ReadSignature

func (s *FSStore) ReadSignature(cid string) (*SignatureMetadata, error)

ReadSignature reads signature metadata for a CID.

func (*FSStore) SaveIdentity

func (s *FSStore) SaveIdentity(githubID string, doc []byte) error

Utility: Save identity doc at /id/github:{id}

func (*FSStore) SaveObject

func (s *FSStore) SaveObject(cid string, raw []byte, canonical []byte) error

SaveObject writes the raw JSON-LD and canonical bytes to disk. It injects the computed CID as the @id field into the stored JSON-LD.

func (*FSStore) SaveObjectWithAuthor

func (s *FSStore) SaveObjectWithAuthor(cid string, raw []byte, canonical []byte, githubUser, githubID string, markdownContent ...string) error

SaveObjectWithAuthor writes the raw JSON-LD and canonical bytes to disk. It injects the computed CID as the @id field and author information into the stored JSON-LD. If markdownContent is provided, it is also saved alongside the JSON-LD.

func (*FSStore) SaveSignature

func (s *FSStore) SaveSignature(cid, signature, signerAddr string, usePersonalSign bool) error

SaveSignature writes signature metadata to disk.

func (*FSStore) SignaturePath

func (s *FSStore) SignaturePath(cid string) string

SignaturePath returns the path where the signature metadata for a CID is stored.

func (*FSStore) UpdateLatest

func (s *FSStore) UpdateLatest(user, slug, cid string) error

UpdateLatest writes the pointer file /u/{login}/g/{slug}/latest containing the CID.

type HistoryEntry

type HistoryEntry struct {
	CID       string    `json:"cid"`
	CreatedAt time.Time `json:"createdAt"`
}

type SignatureMetadata

type SignatureMetadata struct {
	Signature       string `json:"signature"`
	SignerAddress   string `json:"signerAddress"`
	UsePersonalSign bool   `json:"usePersonalSign"`
}

SignatureMetadata holds information about a signature.

Jump to

Keyboard shortcuts

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