bw

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateLayout = "2006-01-02T15:04:05.000Z"
)
View Source
const (
	DefaultBitwardenServerURL = "https://vault.bitwarden.com"
)

Variables

View Source
var (
	ErrObjectNotFound     = errors.New("object not found")
	ErrAttachmentNotFound = errors.New("attachment not found")
)

Functions

This section is empty.

Types

type Attachment added in v0.5.0

type Attachment struct {
	ID       string `json:"id,omitempty"`
	FileName string `json:"fileName,omitempty"`
	Size     string `json:"size,omitempty"`
	SizeName string `json:"sizeName,omitempty"`
	Url      string `json:"url,omitempty"`
}

type Client

type Client interface {
	CreateAttachment(ctx context.Context, itemId, filePath string) (*Object, error)
	CreateObject(context.Context, Object) (*Object, error)
	EditObject(context.Context, Object) (*Object, error)
	GetAttachment(ctx context.Context, itemId, attachmentId string) ([]byte, error)
	GetObject(context.Context, Object) (*Object, error)
	GetSessionKey() string
	HasSessionKey() bool
	ListObjects(ctx context.Context, objType string, options ...ListObjectsOption) ([]Object, error)
	LoginWithAPIKey(ctx context.Context, password, clientId, clientSecret string) error
	LoginWithPassword(ctx context.Context, username, password string) error
	Logout(context.Context) error
	DeleteAttachment(ctx context.Context, itemId, attachmentId string) error
	DeleteObject(context.Context, Object) error
	SetServer(context.Context, string) error
	SetSessionKey(string)
	Status(context.Context) (*Status, error)
	Sync(context.Context) error
	Unlock(ctx context.Context, password string) error
}

func NewClient

func NewClient(execPath string, opts ...Options) Client

type Field

type Field struct {
	Name     string    `json:"name,omitempty"`
	Value    string    `json:"value,omitempty"`
	Type     FieldType `json:"type"`
	LinkedId *int      `json:"linkedId"`
}

type FieldType

type FieldType int
const (
	FieldTypeText    FieldType = 0
	FieldTypeHidden  FieldType = 1
	FieldTypeBoolean FieldType = 2
	FieldTypeLinked  FieldType = 3
)

type ItemType

type ItemType int
const (
	ItemTypeLogin      ItemType = 1
	ItemTypeSecureNote ItemType = 2
)

type ListObjectsOption added in v0.8.0

type ListObjectsOption func(args *[]string)

func WithCollectionID added in v0.8.0

func WithCollectionID(id string) ListObjectsOption

func WithFolderID added in v0.8.0

func WithFolderID(id string) ListObjectsOption

func WithOrganizationID added in v0.8.0

func WithOrganizationID(id string) ListObjectsOption

func WithSearch added in v0.8.0

func WithSearch(search string) ListObjectsOption

func WithUrl added in v0.8.0

func WithUrl(url string) ListObjectsOption

type ListObjectsOptionGenerator added in v0.8.0

type ListObjectsOptionGenerator func(id string) ListObjectsOption

type Login

type Login struct {
	Username string     `json:"username,omitempty"`
	Password string     `json:"password,omitempty"`
	Totp     string     `json:"totp,omitempty"`
	URIs     []LoginURI `json:"uris,omitempty"`
}

type LoginURI added in v0.4.0

type LoginURI struct {
	Match *URIMatch `json:"match,omitempty"`
	URI   string    `json:"uri,omitempty"`
}

type Object

type Object struct {
	CollectionIds  []string      `json:"collectionIds,omitempty"`
	CreationDate   *time.Time    `json:"creationDate,omitempty"`
	DeletedDate    *time.Time    `json:"deletedDate,omitempty"`
	ID             string        `json:"id,omitempty"`
	ExternalID     string        `json:"externalId,omitempty"`
	FolderID       string        `json:"folderId,omitempty"`
	Groups         []interface{} `json:"groups"` // Not implemented yet
	Login          Login         `json:"login,omitempty"`
	Name           string        `json:"name,omitempty"`
	Notes          string        `json:"notes,omitempty"`
	Object         ObjectType    `json:"object,omitempty"`
	OrganizationID string        `json:"organizationId,omitempty"`
	SecureNote     SecureNote    `json:"secureNote,omitempty"`
	Type           ItemType      `json:"type,omitempty"`
	Fields         []Field       `json:"fields,omitempty"`
	Reprompt       int           `json:"reprompt,omitempty"`
	Favorite       bool          `json:"favorite,omitempty"`
	RevisionDate   *time.Time    `json:"revisionDate,omitempty"`
	Attachments    []Attachment  `json:"attachments,omitempty"`
}

func FilterObjectsByType added in v0.8.0

func FilterObjectsByType(objs []Object, itemType ItemType) []Object

type ObjectType

type ObjectType string
const (
	ObjectTypeItem          ObjectType = "item"
	ObjectTypeAttachment    ObjectType = "attachment"
	ObjectTypeFolder        ObjectType = "folder"
	ObjectTypeOrgCollection ObjectType = "org-collection"
	ObjectTypeOrganization  ObjectType = "organization"
)

type Options

type Options func(c Client)

func DisableRetryBackoff added in v0.6.0

func DisableRetryBackoff() Options

func DisableSync

func DisableSync() Options

func WithAppDataDir

func WithAppDataDir(appDataDir string) Options

func WithExtraCACertsPath added in v0.7.0

func WithExtraCACertsPath(extraCACertsPath string) Options

type SecureNote

type SecureNote struct {
	Type int `json:"type,omitempty"`
}

type Status

type Status struct {
	ServerURL string      `json:"serverURL,omitempty"`
	LastSync  time.Time   `json:"lastSync,omitempty"`
	UserEmail string      `json:"userEmail,omitempty"`
	UserID    string      `json:"userID,omitempty"`
	Status    VaultStatus `json:"status,omitempty"`
}

func (*Status) VaultFromServer added in v0.3.2

func (s *Status) VaultFromServer(serverUrl string) bool

func (*Status) VaultOfUser added in v0.3.2

func (s *Status) VaultOfUser(email string) bool

type URIMatch added in v0.4.0

type URIMatch int
const (
	URIMatchBaseDomain URIMatch = 0
	URIMatchHost       URIMatch = 1
	URIMatchStartWith  URIMatch = 2
	URIMatchExact      URIMatch = 3
	URIMatchRegExp     URIMatch = 4
	URIMatchNever      URIMatch = 5
)

type VaultStatus

type VaultStatus string
const (
	StatusLocked          VaultStatus = "locked"
	StatusUnauthenticated VaultStatus = "unauthenticated"
	StatusUnlocked        VaultStatus = "unlocked"
)

Jump to

Keyboard shortcuts

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