Documentation ¶
Overview ¶
Package gophkeeper contains core Gophkeeper types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBadCredential indecates that the credential provided are bad. ErrBadCredential = errors.New("bad credential") // ErrInvalidToken indecates that the token provided is invalid. ErrInvalidToken = errors.New("invalid token") // ErrIdentityDuplicate indecates that there is already such an identity. ErrIdentityDuplicate = errors.New("identity already exists") )
View Source
var ErrResourceNotFound = errors.New("resource not found")
ErrResourceNotFound is returned when there is no resource with the ResourceID (or it's owned by another identity).
Functions ¶
This section is empty.
Types ¶
type Blob ¶
type Blob struct { Content io.ReadCloser // Content of the blob. Meta string // Meta info of the blob. }
Blob is an encrypted blob.
type Credential ¶
Credential is a user authentication credential.
type Gophkeeper ¶
type Gophkeeper interface { // Register registers a new identity into gophkeeper. Register(context.Context, Credential) error // Authenticate authenticates an identity and returns an access token. Authenticate(context.Context, Credential) (Token, error) // Identity returns the identity associated with the token. Identity(context.Context, Token) (Identity, error) }
Gophkeeper is gophkeeper.
type Identity ¶
type Identity interface { // StorePiece stores a piece and returns its ResourceID. StorePiece(ctx context.Context, piece Piece, password string) (ResourceID, error) // RestorePiece restores a piece by ResourceID. RestorePiece(ctx context.Context, rid ResourceID, password string) (Piece, error) // StoreBlob stores a blob and returns its ResourceID. StoreBlob(ctx context.Context, blob Blob, password string) (ResourceID, error) // RestoreBlob restores a blob by ResourceID. RestoreBlob(ctx context.Context, rid ResourceID, password string) (Blob, error) // Delete deletes the resource by ResourceID. Delete(context.Context, ResourceID) error // List returns list of all stored resources. List(context.Context) ([]Resource, error) }
Identity is a gophkeeper's identity.
type Piece ¶
type Piece struct { Content []byte // Content of the piece. Meta string // Meta info of the piece. }
Piece is a piece of encrypted information.
type Resource ¶
type Resource struct { ID ResourceID Type ResourceType Meta string }
Resource is a resource information.
type ResourceType ¶
type ResourceType int
ResourceType is type of resource stored.
const ( // ResourceTypePiece is a resource type // indicating a resource of type Piece. ResourceTypePiece ResourceType = iota + 1 // ResourceTypeBlob is a reource type // indicating a resource of type Blob. ResourceTypeBlob )
func (ResourceType) String ¶
func (t ResourceType) String() string
String returns string representation of ResourceType.
Click to show internal directories.
Click to hide internal directories.