bw

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	ErrObjectNotFound     = errObjectNotFound()
	ErrAttachmentNotFound = errAttachmentNotFound()
)

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(itemId, filePath string) (*Object, error)
	CreateObject(Object) (*Object, error)
	EditObject(Object) (*Object, error)
	GetAttachment(itemId, attachmentId string) ([]byte, error)
	GetObject(objType, itemId string) (*Object, error)
	HasSessionKey() bool
	LoginWithAPIKey(password, clientId, clientSecret string) error
	LoginWithPassword(username, password string) error
	Logout() error
	DeleteAttachment(itemId, attachmentId string) error
	DeleteObject(objType, itemId string) error
	SetServer(string) error
	SetSessionKey(string)
	Status() (*Status, error)
	Sync() error
	Unlock(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,omitempty"`
}

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 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"`
	ID             string       `json:"id,omitempty"`
	ExternalID     string       `json:"externalId,omitempty"`
	FolderID       string       `json:"folderId,omitempty"`
	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"`
}

type ObjectType

type ObjectType string
const (
	ObjectTypeItem       ObjectType = "item"
	ObjectTypeAttachment ObjectType = "attachment"
	ObjectTypeFolder     ObjectType = "folder"
)

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

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