checking in some work- adding custom errors and low-level compat with SecretService, but it may not be needed.

This commit is contained in:
2021-11-28 21:43:30 -05:00
parent cf24035c85
commit 3cab98e584
8 changed files with 416 additions and 92 deletions

106
consts.go
View File

@@ -18,16 +18,16 @@ const (
// Methods
// DbusServiceChangeLock is [FUNCTION UNKNOWN; TODO.]
DbusServiceChangeLock string = DbusInterfaceService + ".ChangeLock"
/*
DbusServiceChangeLock has some references in the SecretService Dbus API but
it seems to be obsolete - undocumented, at the least.
*/
// DbusServiceChangeLock string = DbusInterfaceService + ".ChangeLock"
// DbusServiceCreateCollection is used to create a new Collection if it doesn't exist in Dbus.
// DbusServiceCreateCollection is used to create a new Collection via Service.CreateCollection.
DbusServiceCreateCollection string = DbusInterfaceService + ".CreateCollection"
/*
DbusServiceGetSecrets is used to fetch all Secret / Item items in a given Collection
(via Service.GetSecrets).
*/
// DbusServiceGetSecrets is used to fetch all Secret / Item items in a given Collection (via Service.GetSecrets).
DbusServiceGetSecrets string = DbusInterfaceService + ".GetSecrets"
// DbusServiceLock is used by Service.Lock.
@@ -63,7 +63,7 @@ const (
DbusInterfaceSession is the Dbus interface for working with a Session.
Found at /org/freedesktop/secrets/session/<session ID>/(DbusInterfaceSession)
*/
DbusInterfaceSession = DbusServiceBase + ".Session"
DbusInterfaceSession = DbusServiceBase + ".Session"
// Methods
@@ -128,6 +128,26 @@ const (
// DbusItemSetSecret is used by Item.SetSecret.
DbusItemSetSecret string = DbusInterfaceItem + ".SetSecret"
// Properties
// DbusItemLocked is a Dbus boolean for Item.Locked.
DbusItemLocked string = DbusInterfaceItem + ".Locked"
// DbusItemAttributes contains attributes (metadata, schema, etc.) for Item.Attributes.
DbusItemAttributes string = DbusInterfaceItem + ".Attributes"
// DbusItemLabel is the name (label) for Item.Label.
DbusItemLabel string = DbusInterfaceItem + ".Label"
// DbusItemType is the type of an Item (Item.Type).
DbusItemType string = DbusInterfaceItem + ".Type"
// DbusItemCreated is the time an Item was created (in a UNIX Epoch uint64) for Item.Created.
DbusItemCreated string = DbusInterfaceItem + ".Created"
// DbusItemModified is the time an Item was last modified (in a UNIX Epoch uint64) for Item.Modified.
DbusItemModified string = DbusInterfaceItem + ".Modified"
)
// Dbus paths.
@@ -137,3 +157,73 @@ const (
// DbusPromptPrefix is the path used for prompts comparison.
DbusPromptPrefix string = DbusPath + "/prompt/"
)
// FLAGS
// These are not currently used, but may be in the future.
// SERVICE
// ServiceInitFlag is a flag for Service.Open.
type ServiceInitFlag int
const (
FlagServiceNone ServiceInitFlag = iota
FlagServiceOpenSession
FlagServiceLoadCollections
)
// ServiceSearchFlag is a flag for Service.SearchItems.
type ServiceSearchFlag int
const (
FlagServiceSearchNone ServiceSearchFlag = iota
FlagServiceSearchAll
FlagServiceSearchUnlock
FlagServiceSearchLoadSecrets
)
// COLLECTION
// CollectionInitFlag is a flag for Collection.SearchItems and Collection.Items.
type CollectionInitFlag int
const (
FlagCollectionNone CollectionInitFlag = iota
FlagCollectionLoadItems
)
// ITEM
// ItemInitFlag are flags for Collection.SearchItems and Collection.Items.
type ItemInitFlag int
const (
FlagItemNone ItemInitFlag = iota
FlagItemLoadSecret
)
// ItemSearchFlag are flags for Collection.CreateItem.
type ItemSearchFlag int
const (
FlagItemCreateNone ItemSearchFlag = iota
FlatItemCreateReplace
)
// ERRORS
/*
SecretServiceErrEnum are just constants for the enum'd errors;
see SecretServiceError type and ErrSecretService* vars for what
actually gets returned.
They're used for finding the appropriate matching error.
*/
type SecretServiceErrEnum int
const (
EnumErrProtocol SecretServiceErrEnum = iota
EnumErrIsLocked
EnumErrNoSuchObject
EnumErrAlreadyExists
EnumErrInvalidFileFormat
)