bitwarden

package
v0.0.0-...-96202ad Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2017 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AesCbc256_B64                     = iota
	AesCbc128_HmacSha256_B64          = iota
	AesCbc256_HmacSha256_B64          = iota
	Rsa2048_OaepSha256_B64            = iota
	Rsa2048_OaepSha1_B64              = iota
	Rsa2048_OaepSha256_HmacSha256_B64 = iota
	Rsa2048_OaepSha1_HmacSha256_B64   = iota
)
View Source
const (
	CipherType_Folder     = iota
	CipherType_Login      = iota
	CipherType_SecureNote = iota
	CipherType_Card       = iota
	CipherType_Identity   = iota
)
View Source
const (
	FieldType_Text    = iota
	FieldType_Hidden  = iota
	FieldType_Boolean = iota
)
View Source
const (
	PATH_FOLDERS = "folders"
)
View Source
const (
	PATH_SYNC = "sync"
)
View Source
const (
	SecureNoteType_Generic = iota
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(resp *http.Response) error

func DecryptString

func DecryptString(s string, mk CryptoKey) (string, error)

func DecryptValue

func DecryptValue(s string, mk CryptoKey) ([]byte, error)

func EncryptString

func EncryptString(s string, mk CryptoKey) (string, error)

func EncryptValue

func EncryptValue(v []byte, mk CryptoKey) (string, error)

func HashPassword

func HashPassword(password string, key CryptoKey) string

Types

type Account

type Account struct {
	Id                 string  `json:"id"`
	Name               string  `json:"name"`
	Email              string  `json:"email"`
	MasterPasswordHash string  `json:"masterPasswordHash"`
	MasterPasswordHint *string `json:"masterPasswordHint,omitempty"`
	Key                string  `json:"key"`
	Keys               Keys    `json:"keys"`
	RefreshToken       string  `json:"-"`
}

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

func (*AccountService) GetProfile

func (c *AccountService) GetProfile() (Account, error)

type CardData

type CardData struct {
	CipherData
	CardholderName *string
	Brand          *string
	Number         *string
	ExpMonth       *string
	ExpYear        *string
	Code           *string
}

type Cipher

type Cipher struct {
	Type                int
	FolderId            *string // Must be pointer to output null in json. Android app will crash if not null
	OrganizationId      *string
	Favorite            bool
	Edit                bool
	Id                  string          `json:"Id,omitempty"`
	Login               *LoginData      `json:"Login,omitempty"`
	Card                *CardData       `json:"Card,omitempty"`
	SecureNote          *SecureNoteData `json:"SecureNote,omitempty"`
	Identity            *IdentityData   `json:"Identity,omitempty"`
	Attachments         []string
	OrganizationUseTotp bool
	RevisionDate        *Time `json:"RevisionDate,omitempty"`
}

The data we store

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(mk CryptoKey) error

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(mk CryptoKey) error

func (*Cipher) MarshalData

func (c *Cipher) MarshalData() ([]byte, error)

func (*Cipher) UnMarshalData

func (c *Cipher) UnMarshalData(v []byte) error

type CipherData

type CipherData struct {
	Name   *string      `json:"Name,omitempty"`
	Notes  *string      `json:"Notes,omitempty"`
	Fields *[]FieldData `json:"Fields,omitempty"`
}

type CipherDetailsResponse

type CipherDetailsResponse struct {
	CipherResponse
	CollectionIds []string
}

func NewCipherDetailsResponse

func NewCipherDetailsResponse(cipher Cipher) CipherDetailsResponse

func (*CipherDetailsResponse) ToCipher

func (cdr *CipherDetailsResponse) ToCipher() Cipher

type CipherMiniDetailsResponse

type CipherMiniDetailsResponse struct {
	CipherMiniResponse
	CollectionIds []string
}

func NewCipherMiniDetailsResponse

func NewCipherMiniDetailsResponse(cipher Cipher) CipherMiniDetailsResponse

func (*CipherMiniDetailsResponse) ToCipher

func (cmdr *CipherMiniDetailsResponse) ToCipher() Cipher

type CipherMiniResponse

type CipherMiniResponse struct {
	Response

	Id             string
	OrganizationId *string
	Type           int
	Data           interface{}
	Attachments    []string
	RevisionDate   *Time
}

func NewCipherMiniResponse

func NewCipherMiniResponse(cipher Cipher) CipherMiniResponse

func (*CipherMiniResponse) ToCipher

func (cmr *CipherMiniResponse) ToCipher() Cipher

type CipherRequest

type CipherRequest struct {
	Type           int
	OrganizationId *string
	FolderId       *string
	Favorite       bool
	Name           *string
	Notes          *string
	Fields         *[]FieldData
	Attachments    *[]string

	Login      *LoginData      `json:"Login,omitempty"`
	Card       *CardData       `json:"Card,omitempty"`
	SecureNote *SecureNoteData `json:"SecureNote,omitempty"`
	Identity   *IdentityData   `json:"Identity,omitempty"`

	RevisionDate *Time
}

Experimental Request objects

func (*CipherRequest) FromCipher

func (cr *CipherRequest) FromCipher(c Cipher) error

func (*CipherRequest) ToCipher

func (cr *CipherRequest) ToCipher() (Cipher, error)

type CipherResponse

type CipherResponse struct {
	CipherMiniResponse

	FolderId            *string // Must be pointer to output null in json. Android app will crash if not null
	Favorite            bool
	Edit                bool
	OrganizationUseTotp bool
}

func NewCipherResponse

func NewCipherResponse(cipher Cipher) CipherResponse

func (*CipherResponse) ToCipher

func (cmr *CipherResponse) ToCipher() Cipher

type CipherService

type CipherService struct {
	// contains filtered or unexported fields
}

func (*CipherService) AddCipher

func (c *CipherService) AddCipher(cipher *Cipher) (*Cipher, error)

func (*CipherService) DeleteCipher

func (c *CipherService) DeleteCipher(cipher *Cipher) (*Cipher, error)

func (*CipherService) ListCiphers

func (c *CipherService) ListCiphers() ([]Cipher, error)

func (*CipherService) UpdateCipher

func (c *CipherService) UpdateCipher(cipher *Cipher) (*Cipher, error)

type CipherString

type CipherString struct {
	// contains filtered or unexported fields
}

func Encrypt

func Encrypt(pt []byte, key CryptoKey) (*CipherString, error)

func MakeEncKey

func MakeEncKey(key []byte) (*CipherString, error)

func NewCipherString

func NewCipherString(encryptedString string) (*CipherString, error)

func NewCipherStringRaw

func NewCipherStringRaw(encryptionType int, ct string, iv string, mac string) (*CipherString, error)

func (*CipherString) Decrypt

func (cs *CipherString) Decrypt(key CryptoKey) ([]byte, error)

func (*CipherString) DecryptKey

func (cs *CipherString) DecryptKey(key CryptoKey, encryptionType int) (CryptoKey, error)

func (*CipherString) ToString

func (cs *CipherString) ToString() string

type Client

type Client struct {
	// BaseURL for API requests.
	APIBaseURL      *url.URL
	IdentityBaseURL *url.URL
	WebVaultBaseURL *url.URL
	IconsBaseURL    *url.URL

	// UserAgent used when communicating with the Bitwarden API.
	UserAgent string

	// Services
	Cipher  *CipherService
	Folder  *FolderService
	Account *AccountService
	Sync    *SyncService

	// Set to true to output debugging logs during API calls
	Debug bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

func NewUserPasswordAuthClient

func NewUserPasswordAuthClient(username string, password string) (*Client, error)

type CryptoKey

type CryptoKey struct {
	EncKey         []byte
	MacKey         []byte
	EncryptionType int
}

func MakeKey

func MakeKey(password string, salt string) CryptoKey

func NewCryptoKey

func NewCryptoKey(key []byte, encryptionType int) (CryptoKey, error)

type Decryptable

type Decryptable interface {
	Decrypt(mk CryptoKey) error
}

type Domains

type Domains struct {
	EquivalentDomains       []string
	GlobalEquivalentDomains []GlobalEquivalentDomains
	Object                  string
}

type ErrorResponse

type ErrorResponse struct {
	Response

	ExceptionMessage    string
	ExceptionStackTrace string
	Message             string
	ValidationErrors    map[string][2]string
}

type FieldData

type FieldData struct {
	Type  int
	Name  string
	Value string
}

type Folder

type Folder struct {
	Id           string
	Name         string
	Object       string
	RevisionDate *Time
}

func (*Folder) Decrypt

func (f *Folder) Decrypt(mk CryptoKey) error

func (*Folder) Encrypt

func (f *Folder) Encrypt(mk CryptoKey) error

type FolderService

type FolderService struct {
	// contains filtered or unexported fields
}

func (*FolderService) AddFolder

func (c *FolderService) AddFolder(folder *Folder) (*Folder, error)

func (*FolderService) DeleteFolder

func (c *FolderService) DeleteFolder(folder *Folder) (*Folder, error)

func (*FolderService) ListFolders

func (c *FolderService) ListFolders() ([]Folder, error)

func (*FolderService) UpdateFolder

func (c *FolderService) UpdateFolder(folder *Folder) (*Folder, error)

type GlobalEquivalentDomains

type GlobalEquivalentDomains struct {
	Type     int
	Domains  []string
	Excluded bool
}

type HttpErrorResponse

type HttpErrorResponse struct {
	HttpResponse *http.Response
	ErrorResponse
}

func (*HttpErrorResponse) Error

func (r *HttpErrorResponse) Error() string

Error implements the error interface.

type IdentityData

type IdentityData struct {
	CipherData
	Title          *string
	FirstName      *string
	MiddleName     *string
	LastName       *string
	Address1       *string
	Address2       *string
	Address3       *string
	City           *string
	State          *string
	PostalCode     *string
	Country        *string
	Company        *string
	Email          *string
	Phone          *string
	SSN            *string
	Username       *string
	PassportNumber *string
	LicenseNumber  *string
}

type Keys

type Keys struct {
	EncryptedPrivateKey string `json:"encryptedPrivateKey"`
	PublicKey           string `json:"publicKey"`
}

type List

type List struct {
	Object string
	Data   interface{}
}

func (List) Decrypt

func (l List) Decrypt(mk CryptoKey) error

type LoginData

type LoginData struct {
	CipherData
	URI      *string `json:"Uri"`
	Username *string `json:"Username"`
	Password *string `json:"Password"`
	ToTp     *string `json:"Totp"`
}

type Profile

type Profile struct {
	Id                 string
	Name               string
	Email              string
	EmailVerified      bool
	Premium            bool
	MasterPasswordHint string
	Culture            string
	TwoFactorEnabled   bool
	Key                string
	PrivateKey         string
	SecurityStamp      string
	Organizations      []string
	Object             string
}

type ProfileOrganizationResponse

type ProfileOrganizationResponse struct {
}

type ProfileResponse

type ProfileResponse struct {
	Response
	Id                 string
	Name               string
	Email              string
	EmailVerified      bool
	Premium            bool
	MasterPasswordHint *string
	Culture            string
	TwoFactorEnabled   bool
	Key                string
	PrivateKey         string
	SecurityStamp      *string

	Organizations *[]ProfileOrganizationResponse
}

func NewProfileResponse

func NewProfileResponse(user Account) ProfileResponse

type Response

type Response struct {
	// TODO
	Object string
}

Response objects

type SecureNoteData

type SecureNoteData struct {
	CipherData
	Type *string // is int, but sent as string from web
}

type SyncData

type SyncData struct {
	Profile Profile
	Folders []Folder
	Ciphers []CipherDetailsResponse `json:"Ciphers,omitempty"`
	Domains Domains
	Object  string
}

type SyncService

type SyncService struct {
	// contains filtered or unexported fields
}

func (*SyncService) GetSync

func (c *SyncService) GetSync() (SyncData, error)

type Time

type Time struct {
	time.Time
}

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type User

type User struct {
	Id                              string
	Name                            string
	Email                           string
	EmailVerified                   bool
	MasterPassword                  string
	MasterPasswordHint              string
	Culture                         string
	SecurityStamp                   string
	TwoFactorProviders              string
	TwoFactorRecoveryCode           string
	EquivalentDomains               string
	ExcludedGlobalEquivalentDomains string
	AccountRevisionDate             Time
	Key                             string
	PublicKey                       string
	PrivateKey                      string
	//Premium                       bool
	//PremiumExpirationDate         Time
	//Storage                       int
	MaxStorageGb int
	//Gateway                       int
	//GatewayCustomerId             string
	//GatewaySubscriptionId         string
	CreationDate Time
	RevisionDate Time
}

Jump to

Keyboard shortcuts

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