Documentation ¶
Index ¶
- func BuildCanonicalPath(pathType PathType, paths ...string) string
- func BuildCanonicalPathForTlf(tlf tlf.ID, paths ...string) string
- func BuildCanonicalPathForTlfName(t tlf.Type, tlfName tlf.CanonicalName) string
- func BuildCanonicalPathForTlfType(t tlf.Type, paths ...string) string
- func BuildProtocolPathForTlfName(t tlf.Type, tlfName tlf.CanonicalName) keybase1.Path
- func CheckHandleOffline(ctx context.Context, name string, t tlf.Type) error
- func IdentifyHandle(ctx context.Context, nug idutil.NormalizedUsernameGetter, ...) error
- func IdentifySingleAssertion(ctx context.Context, assertion, reason string, identifier idutil.Identifier, ...) (name kbname.NormalizedUsername, err error)
- func IdentifyUserList(ctx context.Context, nug idutil.NormalizedUsernameGetter, ...) error
- func MakeExtendedIdentify(ctx context.Context, behavior keybase1.TLFIdentifyBehavior) (context.Context, error)
- func NewReadAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error
- func NewWriteAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error
- type ConstIDGetter
- type ExtendedIdentify
- func (ei *ExtendedIdentify) GetTlfBreakAndClose() keybase1.TLFBreak
- func (ei *ExtendedIdentify) OnError(ctx context.Context)
- func (ei *ExtendedIdentify) TeamBreak(ctx context.Context, teamID keybase1.TeamID, ...)
- func (ei *ExtendedIdentify) UserBreak(ctx context.Context, username kbname.NormalizedUsername, uid keybase1.UID, ...)
- type ExtendedIdentifyAlreadyExists
- type Handle
- func MakeHandle(ctx context.Context, bareHandle tlf.Handle, t tlf.Type, ...) (*Handle, error)
- func MakeHandleWithTlfID(ctx context.Context, bareHandle tlf.Handle, t tlf.Type, ...) (*Handle, error)
- func NewHandle(ty tlf.Type, ...) *Handle
- func ParseHandle(ctx context.Context, kbpki idutil.KBPKI, idGetter IDGetter, ...) (*Handle, error)
- func ParseHandlePreferred(ctx context.Context, kbpki idutil.KBPKI, idGetter IDGetter, ...) (*Handle, error)
- func ParseHandlePreferredQuick(ctx context.Context, kbpki idutil.KBPKI, osg idutil.OfflineStatusGetter, ...) (handle *Handle, err error)
- func (h *Handle) ClearResolvedReaders()
- func (h Handle) ConflictInfo() *tlf.HandleExtension
- func (h Handle) DeepCopy() *Handle
- func (h Handle) Equals(codec kbfscodec.Codec, other Handle) (bool, error)
- func (h Handle) EqualsIgnoreName(codec kbfscodec.Codec, other Handle) (bool, error)
- func (h Handle) Extensions() (extensions []tlf.HandleExtension)
- func (h *Handle) FavoriteData() favorites.Data
- func (h Handle) FinalizedInfo() *tlf.HandleExtension
- func (h Handle) FirstResolvedWriter() keybase1.UserOrTeamID
- func (h *Handle) GetCanonicalName() tlf.CanonicalName
- func (h *Handle) GetCanonicalPath() string
- func (h Handle) GetPreferredFormat(username kbname.NormalizedUsername) tlf.PreferredName
- func (h *Handle) GetProtocolPath() keybase1.Path
- func (h Handle) IsBackedByTeam() bool
- func (h Handle) IsConflict() bool
- func (h Handle) IsFinal() bool
- func (h Handle) IsLocalConflict() bool
- func (h Handle) IsReader(user keybase1.UID) bool
- func (h Handle) IsWriter(user keybase1.UID) bool
- func (h Handle) MutuallyResolvesTo(ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, ...) error
- func (h *Handle) ResolveAgain(ctx context.Context, resolver idutil.Resolver, idGetter IDGetter, ...) (*Handle, error)
- func (h *Handle) ResolveAgainForUser(ctx context.Context, resolver idutil.Resolver, idGetter IDGetter, ...) (*Handle, error)
- func (h Handle) ResolvedReaders() []keybase1.UserOrTeamID
- func (h Handle) ResolvedUsersMap() map[keybase1.UserOrTeamID]kbname.NormalizedUsername
- func (h Handle) ResolvedWriters() []keybase1.UserOrTeamID
- func (h Handle) ResolvesTo(ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, ...) (resolvesTo bool, partialResolvedH *Handle, err error)
- func (h *Handle) SetFinalizedInfo(info *tlf.HandleExtension)
- func (h *Handle) SetName(name tlf.CanonicalName)
- func (h *Handle) SetResolvedWriter(id keybase1.UserOrTeamID, name kbname.NormalizedUsername)
- func (h *Handle) SetTlfID(id tlf.ID)
- func (h Handle) TlfID() tlf.ID
- func (h Handle) ToBareHandle() (tlf.Handle, error)
- func (h Handle) ToBareHandleOrBust() tlf.Handle
- func (h *Handle) ToFavToAdd(created bool) favorites.ToAdd
- func (h *Handle) ToFavorite() favorites.Folder
- func (h Handle) Type() tlf.Type
- func (h Handle) TypeForKeying() tlf.KeyingType
- func (h Handle) UnresolvedReaders() []keybase1.SocialAssertion
- func (h Handle) UnresolvedWriters() []keybase1.SocialAssertion
- func (h Handle) WithUpdatedConflictInfo(codec kbfscodec.Codec, info *tlf.HandleExtension) (*Handle, error)
- type HandleFinalizedError
- type HandleMismatchError
- type IDGetter
- type NoSuchNameError
- type PathType
- type ReadAccessError
- type WriteAccessError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCanonicalPath ¶
BuildCanonicalPath returns a canonical path for a path components. This a canonical path and may need to be converted to a platform specific path, for example, on Windows, this might correspond to k:\private\username. Note that "canonical" here indicates it's in the form of /keybase/<tlfType>/blah... . It does not try to canonicalize TLF names.
func BuildCanonicalPathForTlf ¶
BuildCanonicalPathForTlf returns a canonical path for a tlf. Although tlf identifies a TLF, paths should still include the TLF name. This function does not try to canonicalize TLF names.
func BuildCanonicalPathForTlfName ¶
func BuildCanonicalPathForTlfName(t tlf.Type, tlfName tlf.CanonicalName) string
BuildCanonicalPathForTlfName returns a canonical path for a tlf.
func BuildCanonicalPathForTlfType ¶
BuildCanonicalPathForTlfType is like BuildCanonicalPath, but accepts a tlf.Type instead of PathType.
func BuildProtocolPathForTlfName ¶
BuildProtocolPathForTlfName builds a `keybase1.Path` for the given TLF type and name.
func CheckHandleOffline ¶
CheckHandleOffline does light checks whether a TLF handle looks ok, it avoids all network calls.
func IdentifyHandle ¶
func IdentifyHandle( ctx context.Context, nug idutil.NormalizedUsernameGetter, identifier idutil.Identifier, osg idutil.OfflineStatusGetter, h *Handle) error
IdentifyHandle identifies the canonical names in the given handle.
func IdentifySingleAssertion ¶
func IdentifySingleAssertion( ctx context.Context, assertion, reason string, identifier idutil.Identifier, offline keybase1.OfflineAvailability) ( name kbname.NormalizedUsername, err error)
IdentifySingleAssertion identifies a single assertion, and takes care of any necessary extended identify behaviors. It does not relay any broken identify warnings back to the caller, however.
func IdentifyUserList ¶
func IdentifyUserList(ctx context.Context, nug idutil.NormalizedUsernameGetter, identifier idutil.Identifier, ids []keybase1.UserOrTeamID, t tlf.Type, offline keybase1.OfflineAvailability) error
IdentifyUserList identifies the users in the given list. Only use this when the usernames are not known - like when rekeying.
func MakeExtendedIdentify ¶
func MakeExtendedIdentify(ctx context.Context, behavior keybase1.TLFIdentifyBehavior) (context.Context, error)
MakeExtendedIdentify populates a context with an ExtendedIdentify directive.
func NewReadAccessError ¶
func NewReadAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error
NewReadAccessError constructs a ReadAccessError for the given directory and user.
func NewWriteAccessError ¶
func NewWriteAccessError(h *Handle, username kbname.NormalizedUsername, filename string) error
NewWriteAccessError is an access error trying to write a file
Types ¶
type ConstIDGetter ¶
ConstIDGetter is an IDGetter that always returns the same TLF ID.
func (ConstIDGetter) GetIDForHandle ¶
GetIDForHandle implements the IDGetter interface for ConstIDGetter.
func (ConstIDGetter) ValidateLatestHandleNotFinal ¶
ValidateLatestHandleNotFinal implements the IDGetter interface for ConstIDGetter.
type ExtendedIdentify ¶
type ExtendedIdentify struct { Behavior keybase1.TLFIdentifyBehavior // contains filtered or unexported fields }
ExtendedIdentify is a struct to track the behavior and results of an identify.
func GetExtendedIdentify ¶
func GetExtendedIdentify(ctx context.Context) (ei *ExtendedIdentify)
GetExtendedIdentify returns the extended identify info associated with the given context.
func (*ExtendedIdentify) GetTlfBreakAndClose ¶
func (ei *ExtendedIdentify) GetTlfBreakAndClose() keybase1.TLFBreak
GetTlfBreakAndClose returns a keybase1.TLFBreak. This should only be called for behavior.WarningInsteadOfErrorOnBrokenTracks() == true, and after makeTlfBreaksIfNeeded is called, to make sure user proof breaks get populated in GUI mode.
If called otherwise, we don't panic here anymore, since we can't panic on nil ei.tlfBreaks. The reason is if a previous successful identify has already happened recently, it could cause this identify to be skipped, which means ei.tlfBreaks is never populated. In this case, it's safe to return an empty keybase1.TLFBreak.
func (*ExtendedIdentify) OnError ¶
func (ei *ExtendedIdentify) OnError(ctx context.Context)
OnError is called when the identify process has encountered a hard error.
func (*ExtendedIdentify) TeamBreak ¶
func (ei *ExtendedIdentify) TeamBreak( ctx context.Context, teamID keybase1.TeamID, breaks *keybase1.IdentifyTrackBreaks)
TeamBreak should be called when an identify call for a team has completed, and may (or may not) contain breaks.
func (*ExtendedIdentify) UserBreak ¶
func (ei *ExtendedIdentify) UserBreak( ctx context.Context, username kbname.NormalizedUsername, uid keybase1.UID, breaks *keybase1.IdentifyTrackBreaks)
UserBreak should be called when an identify call for a user has completed, and may (or may not) contain breaks.
type ExtendedIdentifyAlreadyExists ¶
type ExtendedIdentifyAlreadyExists struct{}
ExtendedIdentifyAlreadyExists is returned when MakeExtendedIdentify is called on a context already with ExtendedIdentify.
func (ExtendedIdentifyAlreadyExists) Error ¶
func (e ExtendedIdentifyAlreadyExists) Error() string
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle contains all the info in a tlf.Handle as well as additional info. This doesn't embed tlf.Handle to avoid having to keep track of data in multiple places.
func MakeHandle ¶
func MakeHandle( ctx context.Context, bareHandle tlf.Handle, t tlf.Type, resolver idutil.Resolver, nug idutil.NormalizedUsernameGetter, idGetter IDGetter, offline keybase1.OfflineAvailability) ( *Handle, error)
MakeHandle creates a Handle from the given tlf.Handle and the given NormalizedUsernameGetter (which is usually a KBPKI). `t` is the `tlf.Type` of the new handle. (Note this could be different from `bareHandle.Type()`, if this is an implicit team TLF.)
func MakeHandleWithTlfID ¶
func MakeHandleWithTlfID( ctx context.Context, bareHandle tlf.Handle, t tlf.Type, resolver idutil.Resolver, nug idutil.NormalizedUsernameGetter, tlfID tlf.ID, offline keybase1.OfflineAvailability) ( *Handle, error)
MakeHandleWithTlfID is like `MakeHandle`, but it ensures the handle's TLF ID is always set to `tlfID`, even if it corresponds to an implicit team for which the iteam settings don't yet contain a TLF ID (due to a cross-device race or certain testing scenarios).
func NewHandle ¶
func NewHandle( ty tlf.Type, resolvedWriters map[keybase1.UserOrTeamID]kbname.NormalizedUsername, unresolvedWriters, unresolvedReaders []keybase1.SocialAssertion, name tlf.CanonicalName, tlfID tlf.ID) *Handle
NewHandle returns a simple new Handle based on the given fields. This is probably most useful for testing.
func ParseHandle ¶
func ParseHandle( ctx context.Context, kbpki idutil.KBPKI, idGetter IDGetter, osg idutil.OfflineStatusGetter, name string, t tlf.Type) ( *Handle, error)
ParseHandle parses a Handle from an encoded string. See Handle.GetCanonicalName() for the opposite direction.
Some errors that may be returned and can be specially handled:
idutil.TlfNameNotCanonical: Returned when the given name is not canonical -- another name to try (which itself may not be canonical) is in the error. Usually, you want to treat this as a symlink to the name to try.
idutil.NoSuchNameError: Returned when public is set and the given folder has no public folder.
TODO In future perhaps all code should switch over to preferred handles, and rename TlfNameNotCanonical to TlfNameNotPreferred.
func ParseHandlePreferred ¶
func ParseHandlePreferred( ctx context.Context, kbpki idutil.KBPKI, idGetter IDGetter, osg idutil.OfflineStatusGetter, name string, t tlf.Type) ( *Handle, error)
ParseHandlePreferred returns idutil.TlfNameNotCanonical if not in the preferred format. Preferred format means that the users own username (from kbpki) as a writer is put before other usernames in the tlf name. i.e. Canon Preferred myname,other myname,other another,myname myname,another This function also can return idutil.NoSuchNameError or idutil.TlfNameNotCanonical. idutil.TlfNameNotCanonical is returned from this function when the name is not the *preferred* name.
func ParseHandlePreferredQuick ¶
func ParseHandlePreferredQuick( ctx context.Context, kbpki idutil.KBPKI, osg idutil.OfflineStatusGetter, name string, ty tlf.Type) (handle *Handle, err error)
ParseHandlePreferredQuick parses a handle from a name, without doing this time consuming checks needed for implicit-team checking or TLF-ID-fetching.
func (*Handle) ClearResolvedReaders ¶
func (h *Handle) ClearResolvedReaders()
ClearResolvedReaders forgets all the resolved reader. Useful for testing.
func (Handle) ConflictInfo ¶
func (h Handle) ConflictInfo() *tlf.HandleExtension
ConflictInfo returns the handle's conflict info, if any.
func (Handle) EqualsIgnoreName ¶
EqualsIgnoreName returns whether h and other contain the same info ignoring the name.
func (Handle) Extensions ¶
func (h Handle) Extensions() (extensions []tlf.HandleExtension)
Extensions returns a list of extensions for the given handle.
func (*Handle) FavoriteData ¶
FavoriteData converts a TlfHandle into FavoriteData, suitable for Favorites calls.
func (Handle) FinalizedInfo ¶
func (h Handle) FinalizedInfo() *tlf.HandleExtension
FinalizedInfo returns the handle's finalized info, if any.
func (Handle) FirstResolvedWriter ¶
func (h Handle) FirstResolvedWriter() keybase1.UserOrTeamID
FirstResolvedWriter returns the handle's first resolved writer ID (when sorted). For SingleTeam handles, this returns the team to which the TLF belongs.
func (*Handle) GetCanonicalName ¶
func (h *Handle) GetCanonicalName() tlf.CanonicalName
GetCanonicalName returns the canonical name of this TLF.
func (*Handle) GetCanonicalPath ¶
GetCanonicalPath returns the full canonical path of this TLF.
func (Handle) GetPreferredFormat ¶
func (h Handle) GetPreferredFormat( username kbname.NormalizedUsername) tlf.PreferredName
GetPreferredFormat returns a TLF name formatted with the username given as the parameter first. This calls tlf.CanonicalToPreferredName with the canonical tlf name which will be reordered into the preferred format. An empty username is allowed here and results in the canonical ordering.
func (*Handle) GetProtocolPath ¶
GetProtocolPath returns the `keybase1.Path` representing this handle.
func (Handle) IsBackedByTeam ¶
IsBackedByTeam returns true if h represents a TLF backed by a team. It could be either a SingleTeam TLF or a private/public TLF backed by an implicit team.
func (Handle) IsConflict ¶
IsConflict returns whether or not this TlfHandle represents a conflicted top-level folder.
func (Handle) IsFinal ¶
IsFinal returns whether or not this TlfHandle represents a finalized top-level folder.
func (Handle) IsLocalConflict ¶
IsLocalConflict returns whether or not this TlfHandle represents a locally conflict branch for a top-level folder.
func (Handle) IsReader ¶
IsReader returns whether or not the given user is a reader for the top-level folder represented by this TlfHandle.
func (Handle) IsWriter ¶
IsWriter returns whether or not the given user is a writer for the top-level folder represented by this TlfHandle.
func (Handle) MutuallyResolvesTo ¶
func (h Handle) MutuallyResolvesTo( ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter, other Handle, rev kbfsmd.Revision, tlfID tlf.ID, log logger.Logger) error
MutuallyResolvesTo checks that the target handle, and the provided `other` handle, resolve to each other.
func (*Handle) ResolveAgain ¶
func (h *Handle) ResolveAgain( ctx context.Context, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter) (*Handle, error)
ResolveAgain tries to resolve any unresolved assertions in the given handle and returns a new handle with the results. As an optimization, if h contains no unresolved assertions, it just returns itself.
func (*Handle) ResolveAgainForUser ¶
func (h *Handle) ResolveAgainForUser( ctx context.Context, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter, uid keybase1.UID) (*Handle, error)
ResolveAgainForUser tries to resolve any unresolved assertions in the given handle and returns a new handle with the results. As an optimization, if h contains no unresolved assertions, it just returns itself. If uid != keybase1.UID(""), it only allows assertions that resolve to uid.
func (Handle) ResolvedReaders ¶
func (h Handle) ResolvedReaders() []keybase1.UserOrTeamID
ResolvedReaders returns the handle's resolved reader IDs in sorted order. If the handle is public, nil will be returned.
func (Handle) ResolvedUsersMap ¶
func (h Handle) ResolvedUsersMap() map[keybase1.UserOrTeamID]kbname.NormalizedUsername
ResolvedUsersMap returns a map of resolved users from uid to usernames.
func (Handle) ResolvedWriters ¶
func (h Handle) ResolvedWriters() []keybase1.UserOrTeamID
ResolvedWriters returns the handle's resolved writer IDs in sorted order.
func (Handle) ResolvesTo ¶
func (h Handle) ResolvesTo( ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter, other Handle) ( resolvesTo bool, partialResolvedH *Handle, err error)
ResolvesTo returns whether this handle resolves to the given one. It also returns the partially-resolved version of h, i.e. h resolved except for unresolved assertions in other; this should equal other if and only if true is returned.
func (*Handle) SetFinalizedInfo ¶
func (h *Handle) SetFinalizedInfo(info *tlf.HandleExtension)
SetFinalizedInfo sets the handle's finalized info to the given one, which may be nil. TODO: remove this to make TlfHandle fully immutable
func (*Handle) SetName ¶
func (h *Handle) SetName(name tlf.CanonicalName)
SetName sets the TLF name associated with this Handle. Useful for testing.
func (*Handle) SetResolvedWriter ¶
func (h *Handle) SetResolvedWriter( id keybase1.UserOrTeamID, name kbname.NormalizedUsername)
SetResolvedWriter resolves the given `id` to the given `name`. Useful for testing.
func (Handle) TlfID ¶
TlfID returns the TLF ID corresponding to this handle, if it's known. If it's wasn't known at the time the handle was constructed, tlf.NullID is returned.
func (Handle) ToBareHandle ¶
ToBareHandle returns a tlf.Handle corresponding to this handle.
func (Handle) ToBareHandleOrBust ¶
ToBareHandleOrBust returns a tlf.Handle corresponding to this handle, and panics if there's an error. Used by tests.
func (*Handle) ToFavToAdd ¶
ToFavToAdd converts a TlfHandle into a Favorite to be added, and sets internal state about whether the corresponding folder was just created or not.
func (*Handle) ToFavorite ¶
ToFavorite converts a TlfHandle into a Favorite, suitable for Favorites calls.
func (Handle) TypeForKeying ¶
func (h Handle) TypeForKeying() tlf.KeyingType
TypeForKeying returns the keying type for the handle h.
func (Handle) UnresolvedReaders ¶
func (h Handle) UnresolvedReaders() []keybase1.SocialAssertion
UnresolvedReaders returns the handle's unresolved readers in sorted order. If the handle is public, nil will be returned.
func (Handle) UnresolvedWriters ¶
func (h Handle) UnresolvedWriters() []keybase1.SocialAssertion
UnresolvedWriters returns the handle's unresolved writers in sorted order.
func (Handle) WithUpdatedConflictInfo ¶
func (h Handle) WithUpdatedConflictInfo( codec kbfscodec.Codec, info *tlf.HandleExtension) (*Handle, error)
WithUpdatedConflictInfo returns a new handle with the conflict info set to the given one, if the existing one is nil. (In this case, the given one may also be nil.) Otherwise, the given conflict info must match the existing one.
type HandleFinalizedError ¶
type HandleFinalizedError struct { }
HandleFinalizedError is returned when something attempts to modify a finalized TLF handle.
func (HandleFinalizedError) Error ¶
func (e HandleFinalizedError) Error() string
Error implements the error interface for HandleFinalizedError.
type HandleMismatchError ¶
HandleMismatchError indicates an inconsistent or unverifiable MD object for the given top-level folder.
func (HandleMismatchError) Error ¶
func (e HandleMismatchError) Error() string
Error implements the error interface for HandleMismatchError
type IDGetter ¶
type IDGetter interface { // GetIDForHandle returns the tlf.ID associated with the given // handle, if the logged-in user has read permission on the // folder. It may or may not create the folder if it doesn't // exist yet, and it may return `tlf.NullID` with a `nil` error if // it doesn't create a missing folder. GetIDForHandle(ctx context.Context, handle *Handle) (tlf.ID, error) // ValidateLatestHandleForTLF returns true if the TLF ID contained // in `h` does not currently map to a finalized TLF. ValidateLatestHandleNotFinal(ctx context.Context, h *Handle) ( bool, error) }
IDGetter is an interface for resolving TLF handles to their TLF IDs.
type NoSuchNameError ¶
type NoSuchNameError struct {
Name string
}
NoSuchNameError indicates that the user tried to access a TLF that doesn't exist.
func (NoSuchNameError) Error ¶
func (e NoSuchNameError) Error() string
Error implements the error interface for NoSuchNameError
type PathType ¶
type PathType string
PathType describes the types for different paths
const ( // KeybasePathType is the keybase root (like /keybase) KeybasePathType PathType = "keybase" // PublicPathType is the keybase public folder list (like /keybase/public) PublicPathType PathType = "public" // PrivatePathType is the keybase private folder list (like // /keybase/private) PrivatePathType PathType = "private" // SingleTeamPathType is the keybase team folder list (like /keybase/teams) SingleTeamPathType PathType = "team" )
type ReadAccessError ¶
type ReadAccessError struct { User kbname.NormalizedUsername Filename string Tlf tlf.CanonicalName Type tlf.Type }
ReadAccessError indicates that the user tried to read from a top-level folder without read permission.
func (ReadAccessError) Error ¶
func (e ReadAccessError) Error() string
Error implements the error interface for ReadAccessError
type WriteAccessError ¶
type WriteAccessError struct { User kbname.NormalizedUsername Filename string Tlf tlf.CanonicalName Type tlf.Type }
WriteAccessError indicates an error when trying to write a file
func (WriteAccessError) Error ¶
func (e WriteAccessError) Error() string
Error implements the error interface for WriteAccessError