schema

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDeviceIdentifier

func MakeDeviceIdentifier() string

MakeDeviceIdentifier creates a randomly-assigned device identifier

Types

type Cipher

type Cipher struct {
	Id             string       `json:"id"`
	Name           string       `json:"name"`
	Type           CipherType   `json:"type"`
	FolderId       string       `json:"folderId,omitempty"`
	OrganizationId string       `json:"organizationId,omitempty"`
	Favorite       bool         `json:"favorite,omitempty"`
	Edit           bool         `json:"edit"`
	RevisionDate   time.Time    `json:"revisionDate"`
	CollectionIds  []string     `json:"collectionIds,omitempty"`
	ViewPassword   bool         `json:"viewPassword"`
	Login          *CipherLogin `json:"Login,omitempty"`
	//	Card           *CardData       `json:"Card,omitempty"`
	//	SecureNote     *SecureNoteData `json:"SecureNote,omitempty"`
	//	Identity       *IdentityData   `json:"Identity,omitempty"`
	Attachments []string `json:"Attachments,omitempty"`
	Object      string   `json:"object"`
}

func (Cipher) Decrypt

func (c Cipher) Decrypt(s *Session) (Crypter, error)

Decrypt a cipher

func (Cipher) String

func (c Cipher) String() string

type CipherLogin

type CipherLogin struct {
	Username string `json:"Username,omitempty"` // crypt
	Password string `json:"Password,omitempty"` // crypt
	URI      string `json:"URI,omitempty"`      // crypt
}

type CipherType

type CipherType uint
const (
	CipherTypeLogin CipherType
	CipherTypeNote
	CipherTypeCard
	CipherTypeIdentity
)

func (CipherType) Marshal

func (t CipherType) Marshal() ([]byte, error)

func (CipherType) String

func (t CipherType) String() string

type Ciphers

type Ciphers []*Cipher

func (*Ciphers) Read

func (c *Ciphers) Read(r io.Reader) error

func (*Ciphers) Write

func (c *Ciphers) Write(w io.Writer) error

type Crypter

type Crypter interface {
	// Decrypt the object and return a new object
	Decrypt(*Session) (Crypter, error)
}

type Device

type Device struct {
	Name       string     `json:"deviceName"`
	Identifier string     `json:"deviceIdentifier,omitempty"`
	Type       DeviceType `json:"deviceType,omitempty"`
	PushToken  string     `json:"devicePushToken,omitempty"`
}

Device represents a device

func NewDevice

func NewDevice(name string) *Device

Return a new device with a random identifier

func NewDeviceEx

func NewDeviceEx(deviceType DeviceType, deviceIdentifier, name, pushToken string) *Device

Return a new device with a known identifier and type

func (Device) String

func (d Device) String() string

type DeviceType

type DeviceType uint
const (
	Android DeviceType = iota

	ChromeExtension
	FirefoxExtension
	OperaExtension
	EdgeExtension
	WindowsDesktop
	MacOsDesktop
	LinuxDesktop
	ChromeBrowser
	FirefoxBrowser
	OperaBrowser
	EdgeBrowser
	IEBrowser
	UnknownBrowser
	AndroidAmazon
	UWP
	SafariBrowser
	VivaldiBrowser
	VivaldiExtension
	SafariExtension
)

func MakeDeviceType

func MakeDeviceType() DeviceType

MakeDeviceType returns the device type for the current runtime

type Domains

type Domains struct {
	Object string `json:"object"`
}

func (*Domains) Read

func (d *Domains) Read(r io.Reader) error

func (Domains) String

func (d Domains) String() string

func (*Domains) Write

func (d *Domains) Write(w io.Writer) error

type Folder

type Folder struct {
	Id           string    `json:"id"`
	Name         string    `json:"name"` // Encrypted
	RevisionDate time.Time `json:"revisionDate"`
	Object       string    `json:"object"`
}

func (Folder) Decrypt

func (f Folder) Decrypt(s *Session) (Crypter, error)

Decrypt a folder

func (Folder) String

func (f Folder) String() string

type Folders

type Folders []*Folder

func (*Folders) Read

func (f *Folders) Read(r io.Reader) error

Read a list of folders

func (*Folders) Write

func (f *Folders) Write(w io.Writer) error

Write a list of folders

type Kdf

type Kdf struct {
	Type       int `json:"kdf"`
	Iterations int `json:"KdfIterations"`
}

type Organization

type Organization struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	Status     uint   `json:"status"`
	Type       uint   `json:"type"`
	Enabled    bool   `json:"enabled"`
	Identifier string `json:"identifier"`
	UserId     string `json:"userId"`
	Object     string `json:"object"`
}

func (Organization) String

func (o Organization) String() string

type Profile

type Profile struct {
	Id                      string          `json:"id"`
	Name                    string          `json:"name"`
	Email                   string          `json:"email"`
	EmailVerified           bool            `json:"emailVerified"`
	Key                     string          `json:"key"`
	Premium                 bool            `json:"premium"`
	PremiumFromOrganization bool            `json:"premiumFromOrganization"`
	MasterPasswordHash      string          `json:"masterPasswordHash"`
	MasterPasswordHint      *string         `json:"masterPasswordHint,omitempty"`
	Culture                 string          `json:"culture"`
	TwoFactorEnabled        bool            `json:"twoFactorEnabled"`
	SecurityStamp           *string         `json:"securityStamp,omitempty"`
	ForcePasswordReset      bool            `json:"forcePasswordReset"`
	UsesKeyConnector        bool            `json:"usesKeyConnector"`
	Organizations           []*Organization `json:"organizations,omitempty"`
	Object                  string          `json:"object"`
}

func NewProfile

func NewProfile() *Profile

func (*Profile) Read

func (p *Profile) Read(r io.Reader) error

func (Profile) String

func (p Profile) String() string

func (*Profile) Write

func (p *Profile) Write(w io.Writer) error

type ReaderWriter

type ReaderWriter interface {
	// Write the object to the writer
	Write(io.Writer) error

	// Read the object from the reader
	Read(io.Reader) error
}

type Session

type Session struct {
	// Device identifier
	Device *Device `json:"device,omitempty"`

	// Login Token
	Token *Token `json:"token,omitempty"`

	// Encryption parameters
	Kdf
	// contains filtered or unexported fields
}

Session represents a long-running session with the Bitwarden server

func NewSession

func NewSession() *Session

Create a new empty session

func (*Session) CacheKey

func (s *Session) CacheKey(key, email, password string) error

Create the encryption key from an email and password and cache it. Returns ErrNotAuthorized error if the key, email or password credentials are invalid

func (*Session) DecryptStr

func (s *Session) DecryptStr(value string) (string, error)

Decrypt a cipher string, requires a cached key first

func (*Session) IsValid

func (s *Session) IsValid() bool

Return true if the session has a token and the token is not expired

func (*Session) MakeDecryptKey

func (s *Session) MakeDecryptKey(salt, password string, cipher *crypto.Encrypted) *crypto.CryptoKey

Make a decryption key from a session

func (*Session) MakeInternalKey

func (s *Session) MakeInternalKey(salt, password string) []byte

Make a master key from a session

func (*Session) Read

func (s *Session) Read(r io.Reader) error

Session Reader

func (Session) String

func (s Session) String() string

func (*Session) Write

func (s *Session) Write(w io.Writer) error

Session Writer

type Token

type Token struct {
	TokenType   string    `json:"token_type"`
	AccessToken string    `json:"access_token"`
	ExpiresIn   int       `json:"expires_in"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
}

func (Token) IsValid

func (t Token) IsValid() bool

Jump to

Keyboard shortcuts

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