schema

package
v1.4.14 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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,width:36"`
	Name           string       `json:"name,width:30"`
	Type           CipherType   `json:"type,width:5"`
	FolderId       string       `json:"folderId,omitempty,width:36"`
	OrganizationId string       `json:"organizationId,omitempty,width:36"`
	Favorite       bool         `json:"favorite,omitempty,width:5"`
	Edit           bool         `json:"edit,width:5"`
	RevisionDate   time.Time    `json:"revisionDate,width:29"`
	CollectionIds  []string     `json:"collectionIds,omitempty"`
	ViewPassword   bool         `json:"viewPassword,width:5"`
	Login          *CipherLogin `json:"Login,omitempty,wrap"`
	//	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(k *crypto.CryptoKey) (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(*crypto.CryptoKey) (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,width:36"`
	Name         string    `json:"name"` // Encrypted
	RevisionDate time.Time `json:"revisionDate,width:29"`
	Object       string    `json:"object,width:6"`
}

func (Folder) Decrypt

func (f Folder) Decrypt(k *crypto.CryptoKey) (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 Iterable added in v1.0.2

type Iterable interface {
	Crypter
	*Folder | *Cipher
}

type Iterator added in v1.0.2

type Iterator[T Iterable] interface {
	// Return next value or nil if there are no more values
	Next() T

	// Compute and return the encryption/decryption key from the profile,
	// password and KDF parameters
	CryptKey(*Profile, string, Kdf) (*crypto.CryptoKey, error)

	// CanCrypt returns true if the iterator has a key
	// for encryption and decryption
	CanCrypt() bool

	// Decrypt the value and return a copy of it
	Decrypt(T) (T, error)
}

Iterate over values

func NewIterator added in v1.0.2

func NewIterator[T Iterable](values []T) Iterator[T]

NewIterator returns a new iterator which can be used to iterate over values

type Kdf

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

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" writer:",width:36"`
	Name                    string          `json:"name"`
	Email                   string          `json:"email"`
	EmailVerified           bool            `json:"emailVerified" writer:",width:5,right,omitempty"`
	Key                     string          `json:"key" writer:",wrap,omitempty"`
	Premium                 bool            `json:"premium" writer:",width:5,right,omitempty"`
	PremiumFromOrganization bool            `json:"premiumFromOrganization" writer:",width:5,right,omitempty"`
	Culture                 string          `json:"culture" writer:",width:5,right,omitempty"`
	TwoFactorEnabled        bool            `json:"twoFactorEnabled" writer:",width:5,right,omitempty"`
	SecurityStamp           *string         `json:"securityStamp" writer:",width:5,right,omitempty"`
	ForcePasswordReset      bool            `json:"forcePasswordReset" writer:",width:5,right,omitempty"`
	UsesKeyConnector        bool            `json:"usesKeyConnector" writer:",width:5,right,omitempty"`
	Organizations           []*Organization `json:"organizations,omitempty"`
	Object                  string          `json:"object" writer:"-"`
}

func NewProfile

func NewProfile() *Profile

func (*Profile) MakeKey added in v1.0.2

func (p *Profile) MakeKey(kdf Kdf, passwd string) (*crypto.CryptoKey, error)

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

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,wrap"`

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

	// Encryption parameters
	Kdf
}

Session represents a long-running session with the Bitwarden server

func NewSession

func NewSession() *Session

Create a new empty session

func (*Session) IsValid

func (s *Session) IsValid() bool

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

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