Documentation
¶
Index ¶
- Constants
- Variables
- func BlobPath(root, id string) (string, error)
- func DocumentKey(file string, revision, epoch int64) string
- func FileType(name string) string
- func IsAgentScope(scope string) bool
- func LinkID(token string) string
- func Mtime(s string) (string, error)
- func OpenBlob(path string, key []byte, sealed bool, size int64) (io.ReadSeekCloser, error)
- func OpenThumb(root string, key []byte, blob string) (io.ReadSeekCloser, error)
- func ParseDeviceKey(der []byte) (*ecdsa.PublicKey, error)
- func ParseDocumentKey(key string) (file string, revision, epoch int64, err error)
- func Rank(role string) int
- func ReadThumb(root string, key []byte, blob string) ([]byte, error)
- func RemoveBlobs(root string, ids []string) error
- func SealedSize(plain int64) int64
- func StoredSizeOK(sealed bool, plain, disk int64) bool
- func SyncDirectory(path string) error
- func Thumbnail(ctx context.Context, r io.ReadSeeker, size int64) ([]byte, error)
- func ValidName(name string) bool
- func ValidType(t string) bool
- func ViewKind(name string) (ext, kind string)
- func WithDevice(ctx context.Context) context.Context
- func WithLogin(ctx context.Context, l Login) context.Context
- func WithPeer(ctx context.Context, p Peer) context.Context
- func WithServiceAccess(ctx context.Context, a ServiceAccess) context.Context
- func WriteThumb(root string, key []byte, blob string, thumb []byte) error
- type AppPassword
- type Change
- type Colleague
- type ContentMatcher
- type DeletedWorkspace
- type Device
- type EditorSession
- type ErrDeviceRevoked
- type Event
- type File
- type Folder
- type Grant
- type GuestItem
- type GuestLink
- type GuestListing
- type Hit
- type Item
- type Leaver
- type Link
- type Location
- type Login
- type Peer
- type Person
- type ServiceAccess
- type Share
- type SharedFrom
- type SharedItem
- type Store
- func (s *Store) AddFolder(ctx context.Context, user, workspace, parent, name string) (Folder, error)
- func (s *Store) AgentTokenUser(ctx context.Context, token string, at time.Time) (string, AppPassword, error)
- func (s *Store) AppPasswordUser(ctx context.Context, username, secret string) (string, error)
- func (s *Store) AppPasswords(ctx context.Context, user string) ([]AppPassword, error)
- func (s *Store) AppendUpload(ctx context.Context, staging string, key []byte, user, id string, ...) (UploadSession, error)
- func (s *Store) ApplyRetention(ctx context.Context, at time.Time, trashDays int) ([]string, error)
- func (s *Store) ApproveLink(ctx context.Context, user, name, platform, challenge, redirect string) (string, error)
- func (s *Store) ApprovePhone(ctx context.Context, user string) (string, error)
- func (s *Store) Authorize(ctx context.Context, user, workspace string, need int) error
- func (s *Store) AuthorizeItem(ctx context.Context, user, workspace, folder, file string, need int) error
- func (s *Store) AuthorizeSharedManager(ctx context.Context, user, workspace string) error
- func (s *Store) CallbackActor(ctx context.Context, file string, revision, epoch int64) (string, error)
- func (s *Store) CancelUpload(ctx context.Context, staging, user, id string) error
- func (s *Store) Changes(ctx context.Context, user, workspace string, after int64, limit int) (cs []Change, next int64, more bool, err error)
- func (s *Store) Children(ctx context.Context, user, workspace, parent string) ([]Folder, []File, error)
- func (s *Store) CloseEditor(ctx context.Context, key string) error
- func (s *Store) CloseViewCopy(ctx context.Context, user, id string) (blob string, err error)
- func (s *Store) Colleagues(ctx context.Context, user string) ([]Colleague, error)
- func (s *Store) CompleteUpload(ctx context.Context, staging, blobs string, key []byte, user, id string) (File, error)
- func (s *Store) CopyFile(ctx context.Context, user, id string, to Location) (File, error)
- func (s *Store) CreateAgentToken(ctx context.Context, user, name, scope, workspace, folder string) (AppPassword, string, error)
- func (s *Store) CreateAppPassword(ctx context.Context, user, name string) (AppPassword, string, error)
- func (s *Store) CreateGuestLink(ctx context.Context, user, kind, id string, expires int64, secret string, ...) (GuestLink, string, error)
- func (s *Store) CreateLink(ctx context.Context, user, kind, id, role string, expires int64) (Link, string, error)
- func (s *Store) CreateServiceToken(ctx context.Context, user, workspace, name, role, token string) (string, error)
- func (s *Store) CreateWorkspace(ctx context.Context, user, name string, quota int64) (Workspace, error)
- func (s *Store) DeferRevocation(ctx context.Context, id string) error
- func (s *Store) DeleteWorkspace(ctx context.Context, user, workspace, confirm string) (recoverable bool, err error)
- func (s *Store) DeletedWorkspaces(ctx context.Context, user string) ([]DeletedWorkspace, error)
- func (s *Store) DeviceUser(ctx context.Context, token string, ...) (string, error)
- func (s *Store) Devices(ctx context.Context, user string) ([]Device, error)
- func (s *Store) EditorDownload(ctx context.Context, id string) (File, error)
- func (s *Store) EditorSession(ctx context.Context, user, id string) (EditorSession, error)
- func (s *Store) EnsurePersonalWorkspace(ctx context.Context, user string) (string, error)
- func (s *Store) Events(ctx context.Context, user string) ([]Event, error)
- func (s *Store) ExpireAgentTokens(ctx context.Context, at time.Time) (int, error)
- func (s *Store) ExpireTickets(ctx context.Context) error
- func (s *Store) ExpireUploads(ctx context.Context, staging string) (int, error)
- func (s *Store) ExpireViewCopies(ctx context.Context) ([]string, error)
- func (s *Store) File(ctx context.Context, user, id string, need int) (File, error)
- func (s *Store) Files(ctx context.Context, user, workspace string, trashed bool) ([]File, error)
- func (s *Store) FolderChildren(ctx context.Context, user, id string) (Folder, []Folder, []File, error)
- func (s *Store) FolderPath(ctx context.Context, user, workspace, id string) ([]string, error)
- func (s *Store) FolderTree(ctx context.Context, user, folder string) (string, []ZipEntry, error)
- func (s *Store) Folders(ctx context.Context, user, workspace string, trashed bool) ([]Folder, error)
- func (s *Store) Grant(ctx context.Context, user, workspace, group, role string) error
- func (s *Store) Grants(ctx context.Context, user, workspace string) ([]Grant, error)
- func (s *Store) GuestFile(ctx context.Context, token, secret, id string) (File, error)
- func (s *Store) GuestLinks(ctx context.Context, user, kind, id string) ([]GuestLink, error)
- func (s *Store) GuestUpload(ctx context.Context, token, secret, name string, v Version) (File, error)
- func (s *Store) GuestView(ctx context.Context, token, secret, folder string) (GuestListing, error)
- func (s *Store) Handover(ctx context.Context, user, source string, to Target) (string, error)
- func (s *Store) IndexChanges(ctx context.Context, after int64, limit int) ([]string, int64, error)
- func (s *Store) IndexFile(ctx context.Context, id string) (File, error)
- func (s *Store) IndexFiles(ctx context.Context, afterID string, limit int) ([]File, error)
- func (s *Store) IssueTicket(ctx context.Context, user, name string, size, maxSize int64) (string, Ticket, error)
- func (s *Store) IssueViewTicket(ctx context.Context, user, name string, size, maxSize int64) (string, ViewCopy, error)
- func (s *Store) Leavers(ctx context.Context, user string) ([]Leaver, error)
- func (s *Store) Links(ctx context.Context, user, kind, id string) ([]Link, error)
- func (s *Store) Lookup(ctx context.Context, user, workspace, parent, name string) (Item, error)
- func (s *Store) MarkDropped(ctx context.Context, id string) error
- func (s *Store) MarkViewDropped(ctx context.Context, id string, ok bool) error
- func (s *Store) MoveFile(ctx context.Context, user, id string, expected int64, to Location) (File, error)
- func (s *Store) MoveFolder(ctx context.Context, user, id, parent, name string) (Folder, error)
- func (s *Store) OpenLink(ctx context.Context, user, token string) (SharedItem, error)
- func (s *Store) OperatorHandover(ctx context.Context, source string, to Target) (string, error)
- func (s *Store) OperatorLeavers(ctx context.Context) ([]Leaver, error)
- func (s *Store) PeerFetch(ctx context.Context, user, id string) (File, error)
- func (s *Store) PeerFree(ctx context.Context, user string) (int64, error)
- func (s *Store) PeerGuestLink(ctx context.Context, user, id string, expires int64, maxLife time.Duration) (GuestLink, string, error)
- func (s *Store) PeerGuestSetting(ctx context.Context, user string) (bool, error)
- func (s *Store) PeerSetting(ctx context.Context, user string) (enabled, set bool, err error)
- func (s *Store) PendingRevocations(ctx context.Context) ([]EditorSession, error)
- func (s *Store) PendingViewDrops(ctx context.Context) ([]ViewCopy, error)
- func (s *Store) People(ctx context.Context, user, q string) ([]Person, error)
- func (s *Store) PruneChanges(ctx context.Context, before time.Time) error
- func (s *Store) PruneDevices(ctx context.Context, at time.Time) error
- func (s *Store) Publish(ctx context.Context, user string, f File, v Version, expected int64) (File, error)
- func (s *Store) PublishEditor(ctx context.Context, user string, f File, v Version, key string, final bool) (bool, error)
- func (s *Store) PurgeDeletedWorkspaces(ctx context.Context, at time.Time, days int) ([]string, error)
- func (s *Store) PurgeFile(ctx context.Context, user, id string) ([]string, error)
- func (s *Store) PurgeFolder(ctx context.Context, user, id string) ([]string, error)
- func (s *Store) PurgeVersion(ctx context.Context, user, id string, revision int64) ([]string, error)
- func (s *Store) Quota(ctx context.Context, user, workspace string, quota int64) error
- func (s *Store) ReconcileSuiteGroups(ctx context.Context, groups []suitedir.Group) (SuiteReport, error)
- func (s *Store) RecordPicks(ctx context.Context, user string, ids []string) error
- func (s *Store) RedeemLink(ctx context.Context, code, verifier string, key []byte) (token, user string, err error)
- func (s *Store) RedeemPhone(ctx context.Context, code, name, platform string, key []byte) (token, user string, err error)
- func (s *Store) RenameWorkspace(ctx context.Context, user, workspace, name string) error
- func (s *Store) RestoreVersion(ctx context.Context, user, id string, revision, expected int64) (File, error)
- func (s *Store) RestoreWorkspace(ctx context.Context, user, workspace string) error
- func (s *Store) RevocationStatus(ctx context.Context) (map[string]int, error)
- func (s *Store) RevokeAppPassword(ctx context.Context, user, id string) error
- func (s *Store) RevokeDevice(ctx context.Context, user, id string, wipe bool) error
- func (s *Store) RevokeLink(ctx context.Context, user, id string) error
- func (s *Store) RevokeSSOEditors(ctx context.Context, tx *sql.Tx, sid string) error
- func (s *Store) RevokeServiceToken(ctx context.Context, user, id string) error
- func (s *Store) RevokeUserCredentials(ctx context.Context, tx *sql.Tx, user string) error
- func (s *Store) RevokeUserEditors(ctx context.Context, tx *sql.Tx, user string) error
- func (s *Store) RevokeUserEditorsBefore(ctx context.Context, tx *sql.Tx, user string, cutoff time.Time) error
- func (s *Store) SealLegacyBlobs(ctx context.Context, root string, key []byte) (int, error)
- func (s *Store) Search(ctx context.Context, user, q string, limit int) ([]Hit, bool, error)
- func (s *Store) SearchContent(ctx context.Context, user, q, typ string, limit int, m ContentMatcher, ...) ([]Hit, bool, error)
- func (s *Store) SearchFolder(ctx context.Context, user, workspace, folder, q string, limit int) ([]Hit, bool, error)
- func (s *Store) SearchFolderContent(ctx context.Context, user, workspace, folder, q, typ string, limit int, ...) ([]Hit, bool, error)
- func (s *Store) ServiceToken(ctx context.Context, token string) (string, ServiceAccess, error)
- func (s *Store) SetAgentScope(ctx context.Context, user, id, scope string) error
- func (s *Store) SetEditorsShare(ctx context.Context, user, workspace string, on bool) error
- func (s *Store) SetFolderTrash(ctx context.Context, user, id string, trash bool) error
- func (s *Store) SetFolderTrashSince(ctx context.Context, user, id string, trash bool, head int64) error
- func (s *Store) SetPeerGuestSetting(ctx context.Context, user string, enabled bool) error
- func (s *Store) SetPeerSetting(ctx context.Context, user string, enabled bool) error
- func (s *Store) SetRetention(ctx context.Context, user, workspace string, trashDays, keepVersions int) error
- func (s *Store) SetTrash(ctx context.Context, user, id string, expected int64, trash bool) error
- func (s *Store) Share(ctx context.Context, user, kind, id, principalKind, principalID, role string) (Share, error)
- func (s *Store) SharedWithMe(ctx context.Context, user string) ([]SharedItem, error)
- func (s *Store) Shares(ctx context.Context, user, kind, id string) ([]Share, error)
- func (s *Store) Snapshot(ctx context.Context, user, workspace, afterID string, limit int) (folders []Folder, files []File, head int64, nextID string, err error)
- func (s *Store) StartUpload(ctx context.Context, user string, u UploadSession, max int64) (UploadSession, error)
- func (s *Store) StoreViewCopy(ctx context.Context, root string, key []byte, c ViewCopy, token string, ...) error
- func (s *Store) SweepOrphans(ctx context.Context, root string, grace time.Duration) (int, error)
- func (s *Store) Ticket(ctx context.Context, token string) (Ticket, error)
- func (s *Store) TicketUpload(ctx context.Context, staging, blobs string, key []byte, t Ticket, ...) (received int64, f *File, err error)
- func (s *Store) UnlinkDevice(ctx context.Context, user, token string) error
- func (s *Store) Unshare(ctx context.Context, user, id string) error
- func (s *Store) UpgradeBlobs(ctx context.Context, root string, key []byte, rate int64) (int, error)
- func (s *Store) Upload(ctx context.Context, user, id string) (UploadSession, error)
- func (s *Store) Versions(ctx context.Context, user, id string) ([]Version, error)
- func (s *Store) ViewClosed(ctx context.Context, id string) (string, error)
- func (s *Store) ViewCopy(ctx context.Context, user, id string) (ViewCopy, error)
- func (s *Store) ViewDownload(ctx context.Context, id string) (ViewCopy, error)
- func (s *Store) ViewTicket(ctx context.Context, token string) (ViewCopy, error)
- func (s *Store) Workspaces(ctx context.Context, user string, administration bool) ([]Workspace, error)
- type SuiteReport
- type Target
- type Ticket
- type UploadSession
- type Version
- type ViewCopy
- type Workspace
- type ZipEntry
Constants ¶
const ( // AgentIdleLimit is how long an agent token may go unused before it is revoked. AgentIdleLimit = 90 * 24 * time.Hour // AgentTokenPrefix marks an agent token; device tokens are DevicePrefix. AgentTokenPrefix = "kya_" )
App passwords let a user's own WebDAV client sign in with HTTP Basic. Each is 160 random bits shown once, stored as SHA-256 (no slow hash: the secret is not guessable), and valid only while its account is active. AI agent tokens share the table with an MCP scope: Bearer credentials for /mcp only, never WebDAV, revoked after AgentIdleLimit unused.
const ( ScopeDAV = "dav" ScopeMCPRead = "mcp:read" ScopeMCPWrite = "mcp:write" )
Scopes: a WebDAV password, or an agent token that reads, or reads and writes.
const ( TicketLife = 15 * time.Minute // PeerFolderName is the folder KyPost's files go into, made on first use at the root of My files. PeerFolderName = "Mail attachments" )
KyPost saves files into a user's My files through upload tickets (docs/KYPOST.md). What a peer context may do is access.go's; this file holds the switch, the folder and the tickets.
const ( ThumbnailSize = 256 ThumbnailMaxFile = 64 << 20 )
Thumbnails are PNGs of raster images inside ThumbnailSize square. A decompression bomb is refused from its header: the decoder's memory is bounded before any pixel buffer exists, and one image decodes at a time.
const ( ViewLife = 24 * time.Hour // ViewMaxBytes is the save-attachment limit: KyPost's 25 MiB inbound cap. ViewMaxBytes = int64(25 << 20) // ViewKeyPrefix names a viewing copy's Euro-Office document key; ParseDocumentKey refuses it. ViewKeyPrefix = "view-" )
Viewing copies (docs/KYPOST.md "Viewing copies"): one mail attachment KyPost sends for one person to read in Euro-Office's view mode. A copy is not a file: no folder, share, link, search, change row, WebDAV, MCP or sync ever sees it. It counts against My files' quota from the moment its ticket is issued, and it is gone at ViewLife.
const (
DevicePrefix = "kyd_"
)
Device credentials are a client's own bearer tokens. A computer links through the browser: it receives a one-time code on its loopback listener and redeems it with its PKCE verifier. A phone scans a one-time code the signed-in user shows as a QR code. Codes and tokens are 256 random bits, stored as SHA-256 only. A device may enrol a P-256 signing key when it links, and only then: DeviceUser hands it to the caller to check the request's signature.
const OperatorActor = "system:operator-cli"
OperatorActor records handovers run from the server CLI.
const PickLife = 24 * time.Hour
PickLife is how long KyPost may fetch a file the user chose in the picker's copy mode.
Variables ¶
var ( // ErrPeerOff is a peer write refused because the user's KyPost switch is off. ErrPeerOff = errors.New("kypost switch off") // ErrPeerGone is a peer write refused because the pairing it came under has ended. ErrPeerGone = errors.New("kypost no longer paired") )
var ( ErrDenied = errors.New("drive access denied") ErrConflict = errors.New("revision conflict") ErrQuota = errors.New("workspace quota exceeded") ErrInvalid = errors.New("invalid drive input") // ErrTooLarge is a body over the upload limit; it is also ErrQuota. ErrTooLarge = fmt.Errorf("%w: upload limit", ErrQuota) )
var ErrGone = errors.New("change cursor expired")
ErrGone is a change cursor below rows that were pruned; the client must re-enumerate.
var ErrNoThumbnail = errors.New("no thumbnail for this file")
var ErrNotFound = errors.New("drive item not found")
ErrNotFound means no live item has that name; distinct from ErrDenied, which hides existence.
var ErrPassword = errors.New("link password required or wrong")
A guest link lets someone without an account view and download one file or folder, or, in upload-only mode, drop files into one folder without seeing it. It always expires. It works only while its creator could still create it, so a link dies with its creator's access. Every unusable link answers ErrNotFound; a missing or wrong password is ErrPassword.
var ErrPeerGuestOff = errors.New("kypost guest links off")
ErrPeerGuestOff is a KyPost guest link refused because the user's guest switch is off.
var ErrTicketLimit = errors.New("too many live upload tickets")
ErrTicketLimit is a user already holding ticketsPerUser live tickets.
var ErrUnsupported = errors.New("content does not match its type")
ErrUnsupported is content that is not what its name says.
var ErrWrongKey = errors.New("drive: deployment key does not match this database")
ErrWrongKey means the deployment key differs from the one this drive was first opened with.
Functions ¶
func DocumentKey ¶
DocumentKey names one editor document. Epoch 0 keeps the original "<file>-<revision>" form; a cross-workspace move starts a new epoch so sessions after it never share a key with older ones.
func FileType ¶ added in v0.6.1
FileType is the search type of a file named name, by its last extension ignoring case, or "".
func IsAgentScope ¶ added in v0.4.3
func Mtime ¶ added in v0.4.3
Mtime normalizes an RFC 3339 client mtime to UTC. "" stays "" (absent). Times before 1970 or more than a day ahead are ErrInvalid.
func OpenBlob ¶
OpenBlob opens a stored blob of size plaintext bytes for reading. A sealed blob must have exactly the size its format gives; its last chunk is authenticated before OpenBlob returns and every other chunk before any of its bytes are read. A KYB2 blob opens only under the file name (blob ID) it was written for.
func OpenThumb ¶ added in v0.4.3
OpenThumb streams a cache entry (thumbnail or document text), authenticating each chunk as it is read; a missing one is fs.ErrNotExist.
func ParseDeviceKey ¶ added in v0.6.1
ParseDeviceKey accepts a P-256 public key as SPKI DER, the only signing key a device enrols.
func ParseDocumentKey ¶
func RemoveBlobs ¶
RemoveBlobs deletes blobs whose last reference was purged. A missing file is already gone.
func SealedSize ¶
SealedSize is the on-disk size of a KYB2 blob holding plain bytes.
func StoredSizeOK ¶ added in v0.5.0
StoredSizeOK reports whether disk bytes can hold plain bytes stored as sealed says.
func SyncDirectory ¶
func Thumbnail ¶
Thumbnail returns a PNG thumbnail of the raster image in r, which holds size bytes.
func ValidType ¶ added in v0.6.1
ValidType reports whether t is a search type filter ("" is no filter).
func ViewKind ¶ added in v0.6.1
ViewKind is name's lowercase extension and Euro-Office document type, or "" for a type a viewing copy may not have.
func WithDevice ¶ added in v0.4.3
WithDevice marks ctx as acting through a device token, which syncs files and nothing more: every method that creates or changes access, or mints a session or credential, refuses it (admin() included), so revoking a device leaves nothing of it behind. devices_access_test.go classifies every exported Store method.
func WithLogin ¶ added in v0.5.0
WithLogin binds the editor sessions opened through ctx to l, so a back-channel logout of that sign-in revokes them even after its browser session expired and was removed.
func WithPeer ¶ added in v0.6.1
WithPeer marks ctx as KyPost acting, under p, for the user it names in each call.
func WithServiceAccess ¶
func WithServiceAccess(ctx context.Context, a ServiceAccess) context.Context
Types ¶
type AppPassword ¶
type AppPassword struct {
ID string `json:"id"`
Name string `json:"name"`
Created string `json:"created"`
LastUsed int64 `json:"last_used"`
Scope string `json:"scope"`
// Workspace limits an agent token to Folder in it ("" = the workspace root); empty means
// everything its user can reach.
Workspace string `json:"workspace,omitempty"`
Folder string `json:"folder,omitempty"`
// RevokeAfter is when an unused agent token is revoked, Unix seconds; 0 for WebDAV.
RevokeAfter int64 `json:"revoke_after,omitempty"`
}
type Change ¶ added in v0.4.3
type Change struct {
Kind string `json:"kind"`
ID string `json:"id"`
Removed bool `json:"removed"`
File *File `json:"file,omitempty"`
Folder *Folder `json:"folder,omitempty"`
}
Change is an item's current state: live with File or Folder set, or Removed (trashed, purged or now in another workspace).
type ContentMatcher ¶ added in v0.4.3
type ContentMatcher interface {
Match(ctx context.Context, q string, files []File) (map[string]float64, error)
}
ContentMatcher scores the files among files whose content matches q, keyed by file ID. files are exactly the live files the user can read in the searched scope; the matcher must not look beyond them.
type DeletedWorkspace ¶ added in v0.6.1
type DeletedWorkspace struct {
ID string `json:"id"`
Name string `json:"name"`
DeletedAt string `json:"deleted_at"`
DeletedBy string `json:"deleted_by"`
Used int64 `json:"used"`
Items int64 `json:"items"`
}
DeletedWorkspace is a shared workspace in its recovery period, for administrators: its size and item count, never file names.
type EditorSession ¶
type ErrDeviceRevoked ¶ added in v0.4.3
type ErrDeviceRevoked struct{ Wipe bool }
ErrDeviceRevoked answers a revoked token for 30 days, telling the device whether to wipe.
func (ErrDeviceRevoked) Error ¶ added in v0.4.3
func (ErrDeviceRevoked) Error() string
func (ErrDeviceRevoked) Is ¶ added in v0.4.3
func (ErrDeviceRevoked) Is(target error) bool
Is lets a revoked token count as denied wherever its wipe flag is not needed.
type File ¶
type File struct {
ID string `json:"id"`
Workspace string `json:"workspace"`
Parent string `json:"parent"`
Name string `json:"name"`
Revision int64 `json:"revision"`
Trashed bool `json:"trashed"`
Size int64 `json:"size"`
Digest string `json:"digest"`
Blob string `json:"-"`
Sealed bool `json:"-"`
Modified string `json:"modified"` // when the current version was created
Mtime string `json:"mtime"` // the client's modification time, else Modified
}
type GuestItem ¶
type GuestItem struct {
Kind string `json:"kind"`
ID string `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
}
GuestItem is a file or folder as a guest sees it: never its workspace or anything above the link.
type GuestListing ¶
type Hit ¶
type Hit struct {
Kind string `json:"kind"`
ID string `json:"id"`
Workspace string `json:"workspace"`
Parent string `json:"parent"`
Name string `json:"name"`
Path string `json:"path"`
Match []string `json:"match"`
// shared item, never above it.
Shared *SharedFrom `json:"shared,omitempty"`
// contains filtered or unexported fields
}
Hit is a live file or folder whose name or content matched. Path joins its ancestor folder names with "/". Match lists "name" and/or "content".
type Leaver ¶
type Leaver struct {
Workspace string `json:"workspace"`
Name string `json:"name"`
Status string `json:"status"`
Size int64 `json:"size"`
Items int `json:"items"`
}
Leaver is a personal workspace whose owner can no longer use it. It carries counts, never names.
type Login ¶ added in v0.5.0
Login is the browser sign-in a request acts through: its session token hash, the identity provider's sid ("" for a local sign-in) and when its credentials were verified.
type Peer ¶ added in v0.6.1
Peer is the pairing a peer context acts under. SwitchDefault is the user's switch when they never chose (on for a KyIdentity pairing, off for an environment one); Live reports whether that pairing still stands. peerSwitch checks both in the transaction of the write it allows, so an unpair or a switch turned off while bytes stream publishes nothing. Pairing fingerprints the pairing (never its secret); a ticket keeps the one it was issued under and works only while it is current.
type Person ¶
type Person struct {
ID string `json:"id"`
Name string `json:"name"`
Username string `json:"username"`
}
Person is an active account a user can share with.
type ServiceAccess ¶
type SharedFrom ¶ added in v0.6.1
type SharedFrom struct {
}
SharedFrom names where a shared hit comes from, as Shared with me shows it: the workspace's name, or a personal workspace owner's display name, and the user's highest role there.
type SharedItem ¶
type SharedItem struct {
}
SharedItem is a folder or file someone shared with the user beyond their own workspace access.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func New ¶
New opens the drive store. key is the deployment key; names are sealed under keys derived from it.
func (*Store) AgentTokenUser ¶ added in v0.4.3
func (s *Store) AgentTokenUser(ctx context.Context, token string, at time.Time) (string, AppPassword, error)
AgentTokenUser returns the user and record of an active user's agent token. WebDAV passwords never match. A token unused for AgentIdleLimit before at is deleted and refused like a wrong one, whether or not the sweep has run.
func (*Store) AppPasswordUser ¶
AppPasswordUser returns the ID of the active user named username (any case) that owns secret. Agent tokens never match.
func (*Store) AppPasswords ¶
func (*Store) AppendUpload ¶
func (s *Store) AppendUpload(ctx context.Context, staging string, key []byte, user, id string, start, length int64, r io.Reader) (UploadSession, error)
AppendUpload seals exactly length bytes of r as the segment starting at start, which must be the session's received count. Concurrent appends at one offset: one wins, the rest ErrConflict.
func (*Store) ApplyRetention ¶
ApplyRetention purges what workspace policies have expired as of at. trashDays (0 = off) empties the trash of every workspace, personal ones included, whose own trash_days is 0. Each item commits on its own and is re-checked against the policy in force inside that transaction, so one document still open in an editor does not hold back the rest. Selection pages by cursor, so permanently skipped items cannot starve later ones.
func (*Store) ApproveLink ¶ added in v0.4.3
func (s *Store) ApproveLink(ctx context.Context, user, name, platform, challenge, redirect string) (string, error)
ApproveLink records the signed-in user's approval and returns the one-time code for the client's loopback redirect.
func (*Store) ApprovePhone ¶ added in v0.6.1
ApprovePhone returns a one-time code, valid 120 seconds, that the signed-in user shows as a QR code for a phone to scan. A phone code carries no challenge: whoever holds it first links.
func (*Store) AuthorizeItem ¶
func (s *Store) AuthorizeItem(ctx context.Context, user, workspace, folder, file string, need int) error
AuthorizeItem is authorizeItem for callers outside the package.
func (*Store) AuthorizeSharedManager ¶
func (*Store) CallbackActor ¶
func (s *Store) CallbackActor(ctx context.Context, file string, revision, epoch int64) (string, error)
CallbackActor chooses an authorized participant; ownership does not follow the first opener. Age alone does not refuse a save: the sweep revokes expired sessions once their document closes.
func (*Store) CancelUpload ¶
CancelUpload discards the caller's session and its staged bytes.
func (*Store) Changes ¶ added in v0.4.3
func (s *Store) Changes(ctx context.Context, user, workspace string, after int64, limit int) (cs []Change, next int64, more bool, err error)
Changes reads up to limit rows after the cursor and returns each item they name once, in order of first appearance, as it is now. next is the cursor for the following call; more reports rows beyond it.
func (*Store) Children ¶
func (s *Store) Children(ctx context.Context, user, workspace, parent string) ([]Folder, []File, error)
Children lists the live folders and files directly under parent, sorted by name.
func (*Store) CloseEditor ¶
CloseEditor records that Euro-Office closed key without changes.
func (*Store) CloseViewCopy ¶ added in v0.6.1
CloseViewCopy ends user's own copy id and returns its blob for removal ("" when none). An opened copy may still be showing in another tab, so its row stays, revoked, until its Euro-Office drop is delivered (PendingViewDrops); one never opened is deleted.
func (*Store) Colleagues ¶
Colleagues lists active accounts that can receive a handover into their My files.
func (*Store) CompleteUpload ¶
func (s *Store) CompleteUpload(ctx context.Context, staging, blobs string, key []byte, user, id string) (File, error)
CompleteUpload publishes a fully received session as a file version and removes it. It ignores cancellation: a proxy that times out on a long re-seal drops the connection, and stopping then would only make every Retry re-seal the whole file again. The size cap bounds the work.
func (*Store) CopyFile ¶
CopyFile publishes the source's current bytes as revision 1 of a new file. The source is read inside the same transaction, so a concurrent purge cannot remove the shared blob.
func (*Store) CreateAgentToken ¶ added in v0.4.3
func (s *Store) CreateAgentToken(ctx context.Context, user, name, scope, workspace, folder string) (AppPassword, string, error)
CreateAgentToken returns a new agent token of scope and its secret, which is not stored. With workspace set the token reaches only folder ("" = the workspace root), which must be live and readable by user now; the store still authorizes every later operation as user.
func (*Store) CreateAppPassword ¶
func (s *Store) CreateAppPassword(ctx context.Context, user, name string) (AppPassword, string, error)
CreateAppPassword returns the new password's record and its secret, which is not stored.
func (*Store) CreateGuestLink ¶
func (s *Store) CreateGuestLink(ctx context.Context, user, kind, id string, expires int64, secret string, uploadOnly bool, maxLife time.Duration) (GuestLink, string, error)
CreateGuestLink returns a guest link and its token, which is not stored. maxLife is the administrator's limit; the expiry is mandatory.
func (*Store) CreateLink ¶
func (s *Store) CreateLink(ctx context.Context, user, kind, id, role string, expires int64) (Link, string, error)
CreateLink returns the new link and its token, which is not stored.
func (*Store) CreateServiceToken ¶
func (*Store) CreateWorkspace ¶
func (*Store) DeferRevocation ¶
DeferRevocation backs a failed drop off exponentially, 2s doubling up to an hour, so drops that keep failing queue behind newer ones.
func (*Store) DeleteWorkspace ¶ added in v0.5.0
func (s *Store) DeleteWorkspace(ctx context.Context, user, workspace, confirm string) (recoverable bool, err error)
DeleteWorkspace deletes a shared workspace. Admin only; My files is ErrDenied. An unknown or already deleted workspace is nil with no event. recoverable reports which kind ran:
- Empty (no live or trashed file or folder): it is removed at once with every access to it. An upload in progress refuses it (ErrConflict).
- Holding items: confirm must be its exact name, else ErrConflict. It is deleted recoverably: every grant and share lapses (they come back on restore), and its links, service tokens, AI agent tokens limited to it and editor sessions are revoked for good. Its files stay until RestoreWorkspace or PurgeDeletedWorkspaces.
func (*Store) DeletedWorkspaces ¶ added in v0.6.1
DeletedWorkspaces lists deleted shared workspaces, newest first. Admin only.
func (*Store) DeviceUser ¶ added in v0.4.3
func (s *Store) DeviceUser(ctx context.Context, token string, verify func(id string, key *ecdsa.PublicKey) error) (string, error)
DeviceUser returns the active user a live device token belongs to. verify gets the device's ID and enrolled key (nil for an unsigned device) and runs before anything else is revealed or written, so a token without its key learns nothing and keeps nothing alive; its error is returned as is. A token revoked in the last 30 days is ErrDeviceRevoked; anything else unusable is ErrDenied.
func (*Store) EditorDownload ¶
EditorDownload serves a live session's document at its newest saved revision. The caller has verified that Euro-Office signed the request.
func (*Store) EditorSession ¶
EditorSession opens the file for user. A document a force-save left open at the current revision and epoch is joined, so co-editors always share one key.
func (*Store) EnsurePersonalWorkspace ¶
EnsurePersonalWorkspace creates one private workspace per immutable account ID. Ownership is retained when the directory account is removed; another account cannot inherit it.
func (*Store) ExpireAgentTokens ¶ added in v0.4.3
ExpireAgentTokens revokes every agent token unused for AgentIdleLimit before at and returns how many. AgentTokenUser refuses an idle token on its own; this removes the ones nobody presents.
func (*Store) ExpireTickets ¶ added in v0.6.1
ExpireTickets deletes expired tickets and picks. Their sessions expire with them (ExpireUploads).
func (*Store) ExpireUploads ¶
ExpireUploads removes expired sessions, then staging directories with no session that are an hour old (crash residue; the hour keeps a session that is starting up safe). Staging is not user data.
func (*Store) ExpireViewCopies ¶ added in v0.6.1
ExpireViewCopies ends copies past ViewLife and returns the blobs to remove. An opened copy Euro-Office may still be showing is revoked, not deleted, so PendingViewDrops still drops it; its row goes once the drop is delivered, or editorGrace after expiry if it never is. Unopened copies, unused tickets and delivered drops are deleted.
func (*Store) FolderChildren ¶
func (s *Store) FolderChildren(ctx context.Context, user, id string) (Folder, []Folder, []File, error)
FolderChildren lists a folder the user can read, whatever gives them access to it.
func (*Store) FolderPath ¶ added in v0.4.3
FolderPath returns the names from the workspace root down to folder id ("" = the root, no names), which user must be able to read. ErrNotFound when the folder or an ancestor is trashed, gone or in another workspace.
func (*Store) FolderTree ¶
FolderTree lists a live folder and everything live beneath it, read in one transaction, with paths built only from validated names and rooted at the folder's own name. Access is the workspace's read grant; per-item grants (M3) must recheck each member here.
func (*Store) GuestFile ¶
GuestFile returns a file a guest link can download, and audits the download.
func (*Store) GuestLinks ¶
GuestLinks lists an item's live guest links for those who may share it.
func (*Store) GuestUpload ¶
func (s *Store) GuestUpload(ctx context.Context, token, secret, name string, v Version) (File, error)
GuestUpload publishes a blob into an upload-only link's folder on its creator's authority. A taken name is numbered rather than refused, so a guest cannot learn what the folder holds.
func (*Store) GuestView ¶
GuestView lists what a guest link shows: the file, or a folder at or below the link's folder.
func (*Store) Handover ¶
Handover moves a leaver's whole personal tree, trash and versions included, into a new folder at the target root and returns that folder. The admin gains no read access.
func (*Store) IndexChanges ¶ added in v0.4.3
IndexChanges returns the files named by up to limit change rows after seq after, each once, and the last seq read (after itself when there are none).
func (*Store) IndexFile ¶ added in v0.4.3
IndexFile returns file id at its current version, trashed or not; ErrNotFound when it is gone.
func (*Store) IndexFiles ¶ added in v0.4.3
IndexFiles pages every file at its current version, trashed or not, by ID after afterID.
func (*Store) IssueTicket ¶ added in v0.6.1
func (s *Store) IssueTicket(ctx context.Context, user, name string, size, maxSize int64) (string, Ticket, error)
IssueTicket gives KyPost (a peer context) a ticket for one file of exactly size bytes named name, bound to user. The token is 256 random bits, returned once; only its hash is stored.
func (*Store) IssueViewTicket ¶ added in v0.6.1
func (s *Store) IssueViewTicket(ctx context.Context, user, name string, size, maxSize int64) (string, ViewCopy, error)
IssueViewTicket (a peer context) reserves a viewing copy of exactly size bytes named name for user and returns its single-use upload ticket, of which only the hash is stored.
func (*Store) Leavers ¶
Leavers lists non-empty personal workspaces whose owner is missing or not active.
func (*Store) Links ¶
Links lists an item's live organisation links for those who may share it; never their tokens.
func (*Store) Lookup ¶
Lookup finds the live folder or file named name under parent by name_hmac, so it never decrypts siblings. A folder wins when both exist.
func (*Store) MarkViewDropped ¶ added in v0.6.1
MarkViewDropped records a drop, or with ok false backs the next attempt off a minute. ponytail: a flat one-minute retry, not editor sessions' doubling backoff; copies die at ViewLife anyway.
func (*Store) MoveFile ¶
func (s *Store) MoveFile(ctx context.Context, user, id string, expected int64, to Location) (File, error)
MoveFile renames or relocates a file without creating a version. Moving to another workspace needs manager rights on the source, since the file leaves it, plus editor rights and room for every retained version on the target. It revokes every open editor session on the file, since each was authorized for the source workspace.
func (*Store) MoveFolder ¶
MoveFolder renames or re-parents a live folder within its workspace.
func (*Store) OpenLink ¶
OpenLink gives the user the link's access and returns its item. Every way a link can be unusable (unknown, revoked, expired, trashed item, lapsed owner) is ErrNotFound alike.
func (*Store) OperatorHandover ¶
OperatorHandover is Handover for the server CLI, whose operator already holds the database. It also writes an audit record.
func (*Store) OperatorLeavers ¶
OperatorLeavers is Leavers for the server CLI.
func (*Store) PeerFetch ¶ added in v0.6.1
PeerFetch (a peer context) is a file KyPost may read for user: picked, live and still readable.
func (*Store) PeerFree ¶ added in v0.6.1
PeerFree is the free quota of the user's My files, or a new one's quota when there is none.
func (*Store) PeerGuestLink ¶ added in v0.6.1
func (s *Store) PeerGuestLink(ctx context.Context, user, id string, expires int64, maxLife time.Duration) (GuestLink, string, error)
PeerGuestLink (a peer context) is KyPost's guest link: view and download, no password, on a file peerLink admits, while the user's guest switch is on (else ErrPeerGuestOff).
func (*Store) PeerGuestSetting ¶ added in v0.6.1
PeerGuestSetting is "Let KyPost create guest links for people outside the organisation": off unless the user turned it on.
func (*Store) PeerSetting ¶ added in v0.6.1
PeerSetting is the user's stored choice for "Let KyPost save and share my files"; set is false when they never chose (the caller applies the pairing's default).
func (*Store) PendingRevocations ¶
func (s *Store) PendingRevocations(ctx context.Context) ([]EditorSession, error)
func (*Store) PendingViewDrops ¶ added in v0.6.1
PendingViewDrops are revoked copies Euro-Office may still be showing; the API drops each from Euro-Office and marks it with MarkViewDropped.
func (*Store) People ¶
People finds active accounts by name or username for an active signed-in user to share with: 2–100 characters, at most 20 results, never the caller, never an email address.
func (*Store) PruneChanges ¶ added in v0.4.3
PruneChanges deletes rows created before before, except each workspace's newest, so an idle workspace's cursor stays valid. It raises each workspace's floor to the highest seq it deleted there.
func (*Store) PruneDevices ¶ added in v0.4.3
PruneDevices deletes devices revoked 30 days before at or idle for 90, and expired codes.
func (*Store) Publish ¶
func (s *Store) Publish(ctx context.Context, user string, f File, v Version, expected int64) (File, error)
Publish makes a durably stored immutable blob visible. Caller owns that blob until success.
func (*Store) PublishEditor ¶
func (s *Store) PublishEditor(ctx context.Context, user string, f File, v Version, key string, final bool) (bool, error)
PublishEditor serializes a document's saves with other uploads and acknowledges exact retries. The digest of the document's newest save is successful without publishing another blob.
func (*Store) PurgeDeletedWorkspaces ¶ added in v0.6.1
func (s *Store) PurgeDeletedWorkspaces(ctx context.Context, at time.Time, days int) ([]string, error)
PurgeDeletedWorkspaces permanently removes workspaces deleted more than days ago (0 = never), as actor system, one transaction each, and returns the blobs left unreferenced for the caller to remove after commit (the orphan sweep catches any it misses). A workspace with a file still open in an editor (an undelivered drop) is skipped until a later run.
func (*Store) PurgeFolder ¶
func (*Store) PurgeVersion ¶
func (*Store) ReconcileSuiteGroups ¶ added in v0.6.1
func (s *Store) ReconcileSuiteGroups(ctx context.Context, groups []suitedir.Group) (SuiteReport, error)
ReconcileSuiteGroups moves each suite group's workspace towards the state KyIdentity lists (KyIdentity docs/SUITE-DIRECTORY.md), keyed on the group ID only, as actor system, one transaction per group, so a crash halfway repeats safely and one failing group does not stop the rest. A group absent from groups is left alone. Nothing it made is ever deleted.
func (*Store) RecordPicks ¶ added in v0.6.1
RecordPicks lets KyPost fetch files for PickLife: the user chose them in the picker's copy mode, in their own session. Each must be a live file the user may share.
func (*Store) RedeemLink ¶ added in v0.4.3
func (s *Store) RedeemLink(ctx context.Context, code, verifier string, key []byte) (token, user string, err error)
RedeemLink spends a computer's code once, checks the verifier against its S256 challenge and returns a new device token and its user. Any failure is ErrDenied and burns the code.
func (*Store) RedeemPhone ¶ added in v0.6.1
func (s *Store) RedeemPhone(ctx context.Context, code, name, platform string, key []byte) (token, user string, err error)
RedeemPhone spends a phone code from ApprovePhone once and links the named phone. Any failure is ErrDenied and burns the code.
func (*Store) RenameWorkspace ¶ added in v0.5.0
RenameWorkspace renames a shared workspace. Admin only; My files cannot be renamed.
func (*Store) RestoreVersion ¶
func (*Store) RestoreWorkspace ¶ added in v0.6.1
RestoreWorkspace brings back a deleted shared workspace with its grants and shares. Admin only; a live, personal or unknown workspace is ErrNotFound. Revoked links and tokens stay revoked. Its name was kept reserved (nameFree), so it cannot collide.
func (*Store) RevocationStatus ¶
func (*Store) RevokeAppPassword ¶
func (*Store) RevokeDevice ¶ added in v0.4.3
RevokeDevice stops one of the user's devices at once; the token keeps answering with wipe for 30 days.
func (*Store) RevokeLink ¶
RevokeLink ends an organisation or guest link and every access that came through it.
func (*Store) RevokeSSOEditors ¶ added in v0.5.0
RevokeSSOEditors revokes, like RevokeUserEditors, the editor sessions opened through the SSO login sid, whether or not its browser session still exists.
func (*Store) RevokeServiceToken ¶
func (*Store) RevokeUserCredentials ¶ added in v0.6.1
RevokeUserCredentials ends, in the caller's transaction, the credentials user issued that outlive a password: WebDAV passwords, agent tokens and pending computer links are deleted, linked computers revoked (no wipe), and service tokens and guest links revoked; revoking a service token also ends the editors opened through it. Organisation links stay: they need a signed-in opener. Nil (no drive store) is a no-op.
func (*Store) RevokeUserEditors ¶
RevokeUserEditors revokes user's editor sessions in the caller's transaction and starts a new key epoch on their files, so a saved editor configuration cannot rejoin the old document. Nil (no drive store) is a no-op.
func (*Store) RevokeUserEditorsBefore ¶ added in v0.5.0
func (s *Store) RevokeUserEditorsBefore(ctx context.Context, tx *sql.Tx, user string, cutoff time.Time) error
RevokeUserEditorsBefore revokes, like RevokeUserEditors, user's editor sessions opened through a sign-in verified before cutoff. Sessions from before login binding count as 0.
func (*Store) SealLegacyBlobs ¶
SealLegacyBlobs replaces every plaintext blob with a sealed copy under a new ID. Each swap moves all version rows naming the old blob in one transaction and records the old ID in drive_blob_retire; the file is removed after commit. Pending retirements from an interrupted run are finished first, so a rerun is always safe.
func (*Store) Search ¶
Search matches q case-insensitively against every live name in the workspaces user can read. Names are sealed, so they are decrypted and matched here; SQL never sees them. It returns at most limit hits and whether more matched.
func (*Store) SearchContent ¶ added in v0.4.3
func (s *Store) SearchContent(ctx context.Context, user, q, typ string, limit int, m ContentMatcher, shared bool) ([]Hit, bool, error)
SearchContent is Search that also asks m (nil: names only) which readable files' contents match. Name matches come first in Search's order, then content-only matches by score. A type (ValidType) keeps only hits of that type and allows an empty q, which matches every name. shared also searches the items in the user's Shared with me list outside those workspaces (searchShared); every such hit returned is re-checked for read access first.
func (*Store) SearchFolder ¶ added in v0.4.3
func (s *Store) SearchFolder(ctx context.Context, user, workspace, folder, q string, limit int) ([]Hit, bool, error)
SearchFolder is Search within the live subtree of folder in workspace ("" = the whole workspace), the folder itself excluded; each Path is relative to folder.
func (*Store) SearchFolderContent ¶ added in v0.4.3
func (s *Store) SearchFolderContent(ctx context.Context, user, workspace, folder, q, typ string, limit int, m ContentMatcher) ([]Hit, bool, error)
SearchFolderContent is SearchFolder that also asks m (nil: names only) which files in the subtree match by content, as SearchContent does.
func (*Store) ServiceToken ¶
func (*Store) SetAgentScope ¶ added in v0.4.3
SetAgentScope moves the user's own agent token between read and write. A WebDAV password never becomes an agent token, nor the reverse (ErrInvalid).
func (*Store) SetEditorsShare ¶
SetEditorsShare lets a shared workspace's managers allow its editors to share, up to their role.
func (*Store) SetFolderTrash ¶
SetFolderTrash trashes a folder and everything live beneath it as one batch, or restores exactly that batch. Items trashed earlier stay in the trash. A folder whose parent is still trashed comes back at the workspace root.
func (*Store) SetFolderTrashSince ¶ added in v0.6.1
func (s *Store) SetFolderTrashSince(ctx context.Context, user, id string, trash bool, head int64) error
SetFolderTrashSince is SetFolderTrash on the condition that nothing in the folder's live subtree changed after head, the workspace change-log position the caller last saw (a desktop client's cursor). A change row after head naming the folder or a live folder or file beneath it, or a head below the pruned floor, is ErrConflict and changes nothing.
func (*Store) SetPeerGuestSetting ¶ added in v0.6.1
SetPeerGuestSetting stores the user's own choice. Only the user's sign-in reaches it.
func (*Store) SetPeerSetting ¶ added in v0.6.1
SetPeerSetting stores the user's own choice. Only the user's sign-in reaches it.
func (*Store) SetRetention ¶
func (s *Store) SetRetention(ctx context.Context, user, workspace string, trashDays, keepVersions int) error
SetRetention configures automatic purging for one workspace; 0 turns a rule off.
func (*Store) Share ¶
func (s *Store) Share(ctx context.Context, user, kind, id, principalKind, principalID, role string) (Share, error)
Share grants role on a live folder or file to a person or a group, replacing any role that principal already had there.
func (*Store) SharedWithMe ¶
SharedWithMe lists live items shared with the user or their groups at a higher role than the user's own access to the workspace (none, for most), folders first, then by name: a workspace reader with an editor share edits from there. Each item appears once, at its highest shared role.
func (*Store) Shares ¶
Shares lists the people and groups an item is shared with, for those who may share it.
func (*Store) Snapshot ¶ added in v0.4.3
func (s *Store) Snapshot(ctx context.Context, user, workspace, afterID string, limit int) (folders []Folder, files []File, head int64, nextID string, err error)
Snapshot pages a workspace's live folders and files by ID after afterID. head is the workspace's change cursor in the same transaction: a client that follows Changes from the first page's head misses nothing written while it paged. nextID is "" on the last page.
func (*Store) StartUpload ¶
func (s *Store) StartUpload(ctx context.Context, user string, u UploadSession, max int64) (UploadSession, error)
StartUpload opens a session for a new file (File empty, Expected 0) or a new version of File at revision Expected. Size must fit max and the workspace's free quota now; Publish checks quota again at completion.
func (*Store) StoreViewCopy ¶ added in v0.6.1
func (s *Store) StoreViewCopy(ctx context.Context, root string, key []byte, c ViewCopy, token string, r io.Reader) error
StoreViewCopy (a peer context, under the pairing that issued the ticket) seals exactly c.Size bytes of r into root and spends the ticket. Bytes that do not look like the name's type are ErrUnsupported; a wrong length is ErrInvalid.
func (*Store) SweepOrphans ¶
SweepOrphans removes staging files left by a crash and blobs no version names. Only files older than grace are touched, so an upload between its rename and its commit is safe; only names WriteBlob creates are considered.
func (*Store) Ticket ¶ added in v0.6.1
Ticket finds a live ticket by its token's hash; anything else is ErrNotFound.
func (*Store) TicketUpload ¶ added in v0.6.1
func (s *Store) TicketUpload(ctx context.Context, staging, blobs string, key []byte, t Ticket, start, length int64, r io.Reader) (received int64, f *File, err error)
TicketUpload (a peer context) stores length bytes of r at start of t's file through the ordinary upload session path, as t's owner in a peer context. The first bytes open the session in the owner's peer folder (made or remade here), under the first free numbered name; the session expires with the ticket. The last bytes publish the file and spend the ticket. f is nil until then.
func (*Store) UnlinkDevice ¶ added in v0.4.3
UnlinkDevice revokes the device that token belongs to, without wipe: the user unlinked it from the computer itself, which keeps its files.
func (*Store) UpgradeBlobs ¶ added in v0.5.0
UpgradeBlobs rewrites every KYB1 blob listed in drive_blob_kyb1 as KYB2 under the same ID, at most rate bytes per second. Each rewrite is staged, synced and decrypted against the version digest before it atomically replaces the blob and drops the queue row, so a run that dies anywhere leaves a readable blob and a rerun is safe. Failed blobs stay queued.
func (*Store) Upload ¶
Upload returns the caller's own unexpired session, rechecking edit access to its workspace.
func (*Store) ViewClosed ¶ added in v0.6.1
ViewClosed deletes copy id when Euro-Office reports its document closed: nobody is left to drop.
func (*Store) ViewCopy ¶ added in v0.6.1
ViewCopy opens user's own stored, unexpired copy id through the sign-in on ctx (WithLogin), binding the copy to it as EditorSession does (only the first sign-in may open it): whatever revokes that sign-in's editors (revokeEditors) revokes the copy too. Anything else is ErrNotFound.
func (*Store) ViewDownload ¶ added in v0.6.1
ViewDownload is copy id for Euro-Office, whose signature the caller verified: only a copy opened through a sign-in that has not been revoked.
func (*Store) ViewTicket ¶ added in v0.6.1
ViewTicket finds the copy an unspent, unexpired upload ticket names; anything else is ErrNotFound.
type SuiteReport ¶ added in v0.6.1
type SuiteReport struct {
Created, Renamed, Restored, Archived, MembersChanged int
}
SuiteReport counts what one ReconcileSuiteGroups pass changed.
type Target ¶
type Target struct{ Workspace, User string }
Target is a handover destination: a shared workspace or a colleague's My files.
type Ticket ¶ added in v0.6.1
type Ticket struct {
Pairing string
ID string
Owner string
Name string
Size int64
Expires int64
Session string
}
Ticket is a live upload ticket. Session is the upload session its first byte opened.
type UploadSession ¶
type UploadSession struct {
ID string `json:"id"`
Workspace string `json:"workspace"`
Parent string `json:"parent"`
Name string `json:"name"`
File string `json:"file"`
Expected int64 `json:"revision"`
Size int64 `json:"size"`
Received int64 `json:"received"`
Expires int64 `json:"expires"`
Mtime string `json:"mtime"` // applied to the published version
}
type Version ¶
type Workspace ¶
type Workspace struct {
Kind string `json:"kind"`
ID string `json:"id"`
Name string `json:"name"`
Quota int64 `json:"quota"`
Used int64 `json:"used"`
Role string `json:"role"`
TrashDays int `json:"trash_days"`
KeepVersions int `json:"keep_versions"`
Items int64 `json:"items"` // files and folders, trashed ones included; 0 deletes at once
Head int64 `json:"head"` // newest change seq; unchanged means nothing to fetch
}
Source Files
¶
- access.go
- apppasswords.go
- blobs.go
- changes.go
- devices.go
- guest.go
- handover.go
- index.go
- links.go
- lookup.go
- move.go
- names.go
- peer.go
- purge.go
- retention.go
- schema.go
- seal_legacy.go
- sealed.go
- search.go
- service.go
- sessions.go
- shares.go
- store.go
- suitegroups.go
- thumbs.go
- trash.go
- types.go
- upgrade.go
- uploads.go
- viewcopies.go
- workspaces.go
- zip.go