core

package module
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 45 Imported by: 7

README

Secrets Management Go SDK

Go

View docs

This library provides interface to Keeper® Secrets Manager and can be used to access your Keeper vault, read and update existing records, rotate passwords and more. Keeper Secrets Manager is an open source project with contributions from Keeper's engineering team and partners.

Features:

Obtain a One-Time Access Token

Keeper Secrets Manager authenticates your API requests using advanced encryption that uses locally stored private key, device id and client id. To register your device and generate private key you will need to generate a One-Time Access Token via Web Vault or Keeper Commander CLI.

Via Web Vault

Secrets Manager > Applications > Create Application - will let you chose application name, shared folder(s) and permissions and generate One-Time Access Token. Note: Keeper does not store One-Time Access Tokens - save or copy the token offline for later use.

One-Time Access Tokens can be generated as needed: Secrets Manager > Applications > Application Name > Devices Tab > Edit > Add Device button - will let you create new Device and generate its One-Time Access Token.

What is an application?

Via Keeper Commander CLI

Login to Keeper with Commander CLI and perform following:

  1. Create Application

    $ sm app create [NAME]
    
  2. Share Secrets to the Application

    $ sm share add --app [NAME] --secret [UID] --editable
    
    • --app - Name of the Application.
    • --secret - Record UID or Shared Folder UID
    • --editable - if omitted defaults to false
  3. Create client

    $ sm client add --app [NAME] --unlock-ip --count 1
    
Install
go get github.com/keeper-security/secrets-manager-go/core
Quick Start
package main

// Import Secrets Manager
import ksm "github.com/keeper-security/secrets-manager-go/core"

func main() {
	// Establish connection
	// One time secrets generated via Web Vault or Commander CLI
	clientOptions := &ksm.ClientOptions{
		Token:  "US:ONE_TIME_TOKEN_BASE64",
		Config: ksm.NewFileKeyValueStorage("ksm-config.json")}
	sm := ksm.NewSecretsManager(clientOptions)
	// One time tokens can be used only once - afterwards use the generated config file
	// sm := ksm.NewSecretsManager(&ksm.ClientOptions{Config: ksm.NewFileKeyValueStorage("ksm-config.json")})

	// Retrieve all records
	allRecords, _ := sm.GetSecrets([]string{})

	// Get password from first record:
	password := allRecords[0].Password()

	// WARNING: Avoid logging sensitive data
	print("My password from Keeper: ", password)
}

Samples

File Download
sm := ksm.NewSecretsManager(&ksm.ClientOptions{Config: ksm.NewFileKeyValueStorage("ksm-config.json")})

if records, err := sm.GetSecrets([]string{}); err == nil {
	for _, r := range records {
		fmt.Println("\tTitle: " + r.Title())
		for i, f := range r.Files {
			fmt.Printf("\t\tfile #%d -> name: %s", i, f.Name)
			f.SaveFile("/tmp/"+f.Name, true)
		}
	}
}
Update record
sm := ksm.NewSecretsManager(&ksm.ClientOptions{Config: ksm.NewFileKeyValueStorage("ksm-config.json")})

if records, err := sm.GetSecrets([]string{}); err == nil && len(records) > 0 {
	record := records[0]
	newPassword := fmt.Sprintf("Test Password - " + time.Now().Format(time.RFC850))
	record.SetPassword(newPassword)

	if err := sm.Save(record); err != nil {
		fmt.Println("Error saving record: " + err.Error())
	}
}

Configuration

Types

Listed in priority order

  1. Environment variable
  2. Configuration store
  3. Code
Available configurations:
  • clientKey - One Time Access Token used during initialization
  • hostname - Keeper Backend host. Available values:
    • keepersecurity.com
    • keepersecurity.eu
    • keepersecurity.com.au
    • govcloud.keepersecurity.us

Adding more records or shared folders to the Application

Via Web Vault

Drag&Drop records into the shared folder or select from the record menu any of the options to CreateDuplicate/Move or create new records straight into the shared folder. As an alternative use: Secrets Manager > Application > Application Name > Folders & Records > Edit and use search field to add any folders or records then click Save.

Via Commander CLI
sm share add --app [NAME] --secret [UID2]
sm share add --app [NAME] --secret [UID3] --editable
Retrieve secret(s)
sm := ksm.NewSecretsManager(&ksm.ClientOptions{Config: ksm.NewFileKeyValueStorage("ksm-config.json")})
allSecrets, _ := sm.GetSecrets([]string{})
Update secret
secretToUpdate = allSecrets[0]
secretToUpdate.SetPassword("NewPassword123$")
secretsManager.Save(secretToUpdate)

Change Log

1.6.2

  • KSM-467 - Fixed ExpiresOn conversion from UnixTimeMilliseconds.

1.6.1

  • KSM-450 - Added folderUid and innerFolderUid to Record
  • KSM-451 - Fix subFolderUid crash on empty string value

1.6.0

  • KSM-414 - Added support for Folders
  • KSM-435 - Improved Passkey field type support

1.5.2

  • KSM-409 New field type: Passkey
  • KSM-404 New filed type: script and modification to some record types
  • KSM-384 Support for record Transactions

1.5.0

  • KSM-317 - Notation improvements
  • KSM-356 - Create custom fields
  • KSM-365 - Fixed KEY_CLINET_KEY is missing error
  • KSM-366 - Avoid exceptions/panics and return errors instead
  • KSM-367 - Fixed license not shown on pkg.go.dev

1.4.0

  • KSM-288 - Record removal
  • KSM-306 - Added support for Japan and Canada data centers
  • KSM-312 - Improve password generation entropy

For additional information please check our detailed Go SDK docs for Keeper Secrets Manager.

Documentation

Secrets Manager Guide

Enterprise Admin Guide

Keeper Commander Guide

Keeper Security Website

Documentation

Index

Constants

View Source
const (
	Aes256KeySize    = 32
	AesGcmNonceSize  = 12
	AesCbcNonceSize  = 16
	DefaultBlockSize = 16
)
View Source
const AsciiDigits string = "0123456789"
View Source
const AsciiLowercase string = "abcdefghijklmnopqrstuvwxyz"
View Source
const AsciiSpecialCharacters string = "\"!@#$%()+;<>=?[]{}^.,"
View Source
const AsciiUppercase string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
View Source
const (
	DEFAULT_CONFIG_PATH string = "client-config.json"
)
View Source
const DefaultPasswordLength int = 32

Generate password

View Source
const EscapeChar = '\\'

New notation parser/extractor allows to search by title/label and to escape special chars

View Source
const EscapeChars = "/[]\\" // /[]\ -> \/ ,\[, \], \\

Variables

View Source
var ErrKeyExchange = errors.New("key exchange failed")

ErrKeyExchange is returned if the key exchange fails.

Functions

func Base64HmacFromString

func Base64HmacFromString(key []byte, message string) string

Base64HmacFromString generates base64 encoded HMAC of the message string with the given key

func Base64ToBytes

func Base64ToBytes(text string) []byte

func Base64ToString

func Base64ToString(base64Text string) string

func Base64ToStringSafe

func Base64ToStringSafe(base64Text string) string

func ByteToInt

func ByteToInt(b []byte) string

func BytesToBase64

func BytesToBase64(data []byte) string

func BytesToString

func BytesToString(b []byte) string

func BytesToUrlSafeStr

func BytesToUrlSafeStr(data []byte) string

func ClearBytes

func ClearBytes(bytes []byte)

func CloneByteSlice

func CloneByteSlice(src []byte) []byte

func Decrypt

func Decrypt(data, key []byte) ([]byte, error)

Decrypt AES-GCM encrypted message

func DecryptAesCbc added in v1.6.0

func DecryptAesCbc(data, key []byte) ([]byte, error)

Decrypt AES-CBC encrypted message

func DecryptRecord

func DecryptRecord(data, secretKey []byte) (string, error)

func DictToJson

func DictToJson(dict map[string]interface{}) string

func DictToJsonWithDefultIndent

func DictToJsonWithDefultIndent(dict map[string]interface{}) string

func DictToJsonWithIndent

func DictToJsonWithIndent(dict map[string]interface{}, indent string) string

func ECDH

func ECDH(priv PrivateKey, pub PublicKey) ([]byte, error)

ECDH computes a shared key from a private key and a peer's public key.

func ECDH_Ecdsa

func ECDH_Ecdsa(priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey) ([]byte, error)

ECDH computes a shared key from a private key and a peer's public key.

func EcPublicKeyFromEncodedPoint

func EcPublicKeyFromEncodedPoint(publicKey []byte) (crypto.PublicKey, error)

func EcPublicKeyToEncodedPoint

func EcPublicKeyToEncodedPoint(pub *ecdsa.PublicKey) ([]byte, error)

func EncryptAesCbc added in v1.6.0

func EncryptAesCbc(data []byte, key []byte) ([]byte, error)

Encrypt a message using AES-CBC.

func EncryptAesCbcFull added in v1.6.0

func EncryptAesCbcFull(data, key, nonce []byte) ([]byte, error)

Encrypt a message using AES-CBC with custom nonce.

func EncryptAesGcm

func EncryptAesGcm(data []byte, key []byte) ([]byte, error)

Encrypt a message using AES-GCM.

func EncryptAesGcmFull

func EncryptAesGcmFull(data, key, nonce []byte) ([]byte, error)

Encrypt a message using AES-GCM with custom nonce.

func GeneratePassword

func GeneratePassword(minLength int, lowercase, uppercase, digits, specialCharacters, specialCharacterSet string) (string, error)

GeneratePassword returns a new password of specified minimum length using provided number of uppercase, lowercase, digits and special characters.

Empty strings or strings with invalid int values are treated as nil and used only if sum of the non nil values don't reach minLength

Note: If all character groups are unspecified or all have exact zero length then password characters are chosen from all groups uniformly at random.

Note: If all charset lengths are negative or 0 but can't reach min_length then all exact/negative charset lengths will be treated as minimum number of characters instead.

minLength is the minimum password length - default: 32 lowercase is the minimum number of lowercase characters if positive, exact if 0 or negative uppercase is the minimum number of uppercase characters if positive, exact if 0 or negative digits is the minimum number of digits if positive, exact if 0 or negative specialCharacters is the minimum number of special characters if positive, exact if 0 or negative specialCharacterSet is a string containing custom set of special characters to pick from

func GeneratePasswordWithOptions

func GeneratePasswordWithOptions(options *PasswordOptions) (string, error)

GeneratePasswordWithOptions generates new password using provided options If options is nil the new password will be generated using defaults All lengths are optional and substituted with reasonable defaults when missing To exclude a charset - set corresponding option to 0 To use default length value - set its option to empty string "" Note: Any strings containing non integer values will be treated as empty string

func GeneratePrivateKeyDer

func GeneratePrivateKeyDer() ([]byte, error)

func GenerateRandomBytes

func GenerateRandomBytes(size int) ([]byte, error)

func GenerateUid

func GenerateUid() string

func GenerateUidWithLength

func GenerateUidWithLength(bitLength int) string

func GetClientVersion

func GetClientVersion(hardcode bool) string

getClientVersion returns the version of the client

func GetDefaultOwnerPublicKey

func GetDefaultOwnerPublicKey() string

func GetOS

func GetOS() string

func GetRandomBytes

func GetRandomBytes(size int) ([]byte, error)

func GetServerHostname

func GetServerHostname(hostname string, configStore IKeyValueStorage) string

func GetSharedFolderKey added in v1.6.0

func GetSharedFolderKey(folders []*KeeperFolder, responseFolders []interface{}, parent string) []byte

func HmacDigest

func HmacDigest(key []byte, message []byte) []byte

func IsFieldClass

func IsFieldClass(field interface{}) bool

func IsJson

func IsJson(jsonStr string) bool

func JsonToDict

func JsonToDict(content string) map[string]interface{}

func NewFileCache

func NewFileCache(filePath string) *fileCache

func NewFileKeyValueStorage

func NewFileKeyValueStorage(filePath ...interface{}) *fileKeyValueStorage

func NewMemoryCache

func NewMemoryCache() *memoryCache

func NewMemoryKeyValueStorage

func NewMemoryKeyValueStorage(config ...interface{}) *memoryKeyValueStorage

func NowMilliseconds

func NowMilliseconds() int64

func ObjToDict

func ObjToDict(obj interface{}) map[string]interface{}

func PadBinary

func PadBinary(s []byte) []byte

func PathExists

func PathExists(path string) (bool, error)

PathExists returns whether the given file or directory exists

func PublicEncrypt

func PublicEncrypt(data []byte, serverPublicRawKeyBytes []byte, idz []byte) (encrypted []byte, err error)

func Sign

func Sign(data []byte, privateKey *PrivateKey) ([]byte, error)

func StrToBool

func StrToBool(val string) (bool, error)

StrToBool convert a string representation of truth to a boolean true or false.

func StringToBytes

func StringToBytes(s string) []byte

func UnpadBinary

func UnpadBinary(s []byte) []byte

func UrlSafeSha256FromString

func UrlSafeSha256FromString(text string) string

UrlSafeSha256FromString generates URL safe encoded SHA256 sum of data in URL safe base64 encoded string

func UrlSafeStrToBytes

func UrlSafeStrToBytes(text string) []byte

func UrlSafeStrToBytesSafe

func UrlSafeStrToBytesSafe(text string) []byte

UrlSafeStrToBytesSafe decodes base64 text to bytes, returns empty byte slice on error

func Verify

func Verify(data []byte, signature []byte, publicKey *PublicKey) error

Verify validates decrypted message against the given public key. On success, returns nil, on failure returns a relevant error.

Types

type AccountNumber

type AccountNumber struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewAccountNumber

func NewAccountNumber(value string) *AccountNumber

AccountNumber field constructor with the single value to eliminate the complexity of the passing List as a value

type AddFileResponse

type AddFileResponse struct {
	Url               string `json:"url"`
	Parameters        string `json:"parameters"`
	SuccessStatusCode int    `json:"successStatusCode"`
}

func AddFileResponseFromJson

func AddFileResponseFromJson(jsonData string) (*AddFileResponse, error)

type Address

type Address struct {
	Street1 string `json:"street1,omitempty"`
	Street2 string `json:"street2,omitempty"`
	City    string `json:"city,omitempty"`
	State   string `json:"state,omitempty"`
	Country string `json:"country,omitempty"`
	Zip     string `json:"zip,omitempty"`
}

type AddressRef

type AddressRef struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewAddressRef

func NewAddressRef(value string) *AddressRef

AddressRef field constructor with the single value to eliminate the complexity of the passing List as a value

type Addresses

type Addresses struct {
	KeeperRecordField
	Required      bool      `json:"required,omitempty"`
	PrivacyScreen bool      `json:"privacyScreen,omitempty"`
	Value         []Address `json:"value,omitempty"`
}

func NewAddresses

func NewAddresses(value Address) *Addresses

Addresses field constructor with the single value to eliminate the complexity of the passing List as a value

type AppData

type AppData struct {
	Title   string `json:"title,omitempty"`
	AppType string `json:"type,omitempty"`
}

Application info

func NewAppData

func NewAppData(title, appType string) *AppData

type BankAccount

type BankAccount struct {
	AccountType   string `json:"accountType,omitempty"`
	RoutingNumber string `json:"routingNumber,omitempty"`
	AccountNumber string `json:"accountNumber,omitempty"`
	OtherType     string `json:"otherType,omitempty"`
}

type BankAccounts

type BankAccounts struct {
	KeeperRecordField
	Required      bool          `json:"required,omitempty"`
	PrivacyScreen bool          `json:"privacyScreen,omitempty"`
	Value         []BankAccount `json:"value,omitempty"`
}

func NewBankAccounts

func NewBankAccounts(value BankAccount) *BankAccounts

BankAccounts field constructor with the single value to eliminate the complexity of the passing List as a value

type BirthDate

type BirthDate struct {
	KeeperRecordField
	Required      bool    `json:"required,omitempty"`
	PrivacyScreen bool    `json:"privacyScreen,omitempty"`
	Value         []int64 `json:"value,omitempty"`
}

func NewBirthDate

func NewBirthDate(value int64) *BirthDate

BirthDate field constructor with the single value to eliminate the complexity of the passing List as a value

type CardRef

type CardRef struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewCardRef

func NewCardRef(value string) *CardRef

CardRef field constructor with the single value to eliminate the complexity of the passing List as a value

type Checkbox added in v1.5.2

type Checkbox struct {
	KeeperRecordField
	Required bool   `json:"required,omitempty"`
	Value    []bool `json:"value,omitempty"`
}

func NewCheckbox added in v1.5.2

func NewCheckbox(value bool) *Checkbox

Checkbox field constructor with the single value to eliminate the complexity of the passing List as a value

type ClientOptions

type ClientOptions struct {
	// Token specifies a One-Time Access Token used
	// to generate the configuration to use with core.SecretsManager client
	Token string

	// InsecureSkipVerify controls whether the client verifies
	// server's certificate chain and host name
	InsecureSkipVerify bool

	// Config specifies either one of the built-in IKeyValueStorage interfaces or a custom one
	Config IKeyValueStorage

	// LogLevel overrides the default log level for the logger
	LogLevel klog.LogLevel

	// Deprecated: Use Token instead. If both are set, hostname from the token takes priority.
	Hostname string
}

type CompleteTransactionPayload added in v1.5.2

type CompleteTransactionPayload struct {
	ClientVersion string `json:"clientVersion"`
	ClientId      string `json:"clientId"`
	RecordUid     string `json:"recordUid"`
}

func (*CompleteTransactionPayload) CompleteTransactionPayloadFromJson added in v1.5.2

func (p *CompleteTransactionPayload) CompleteTransactionPayloadFromJson(jsonData string)

func (*CompleteTransactionPayload) CompleteTransactionPayloadToJson added in v1.5.2

func (p *CompleteTransactionPayload) CompleteTransactionPayloadToJson() (string, error)

type ConfigKey

type ConfigKey string
const (
	KEY_URL                  ConfigKey = "url" // base URL for the Secrets Manager service
	KEY_SERVER_PUBLIC_KEY_ID ConfigKey = "serverPublicKeyId"
	KEY_CLIENT_ID            ConfigKey = "clientId"
	KEY_CLIENT_KEY           ConfigKey = "clientKey"         // The key that is used to identify the client before public key
	KEY_APP_KEY              ConfigKey = "appKey"            // The application key with which all secrets are encrypted
	KEY_OWNER_PUBLIC_KEY     ConfigKey = "appOwnerPublicKey" // The application owner public key, to create records
	KEY_PRIVATE_KEY          ConfigKey = "privateKey"        // The client's private key
	KEY_PUBLIC_KEY           ConfigKey = "publicKey"         // The client's public key
	KEY_HOSTNAME             ConfigKey = "hostname"          // base hostname for the Secrets Manager service

)

func GetConfigKey

func GetConfigKey(value string) ConfigKey

func GetConfigKeys

func GetConfigKeys() []ConfigKey

type Context

type Context struct {
	TransmissionKey TransmissionKey
	ClientId        []byte
	ClientKey       []byte
}

func NewContext

func NewContext(transmissionKey TransmissionKey, clientId []byte, clientKey []byte) *Context

type CopyableMap

type CopyableMap map[string]interface{}

func (CopyableMap) DeepCopy

func (m CopyableMap) DeepCopy() map[string]interface{}

DeepCopy will create a deep copy of this map. The depth of this copy is all inclusive. Both maps and slices will be considered when making the copy.

type CopyableSlice

type CopyableSlice []interface{}

func (CopyableSlice) DeepCopy

func (s CopyableSlice) DeepCopy() []interface{}

DeepCopy will create a deep copy of this slice. The depth of this copy is all inclusive. Both maps and slices will be considered when making the copy.

type CreateFolderPayload added in v1.6.0

type CreateFolderPayload struct {
	ClientVersion   string `json:"clientVersion"`
	ClientId        string `json:"clientId"`
	FolderUid       string `json:"folderUid"`
	SharedFolderUid string `json:"sharedFolderUid"`
	SharedFolderKey string `json:"sharedFolderKey"`
	Data            string `json:"data"`
	ParentUid       string `json:"parentUid"`
}

func (*CreateFolderPayload) CreateFolderPayloadFromJson added in v1.6.0

func (p *CreateFolderPayload) CreateFolderPayloadFromJson(jsonData string)

func (*CreateFolderPayload) CreateFolderPayloadToJson added in v1.6.0

func (p *CreateFolderPayload) CreateFolderPayloadToJson() (string, error)

type CreateOptions added in v1.6.0

type CreateOptions struct {
	FolderUid    string
	SubFolderUid string
}

type CreatePayload

type CreatePayload struct {
	ClientVersion string `json:"clientVersion"`
	ClientId      string `json:"clientId"`
	RecordUid     string `json:"recordUid"`
	RecordKey     string `json:"recordKey"`
	FolderUid     string `json:"folderUid"`
	FolderKey     string `json:"folderKey"`
	Data          string `json:"data"`
	SubFolderUid  string `json:"subFolderUid,omitempty"`
}

func (*CreatePayload) CreatePayloadFromJson

func (p *CreatePayload) CreatePayloadFromJson(jsonData string)

func (*CreatePayload) CreatePayloadToJson

func (p *CreatePayload) CreatePayloadToJson() (string, error)

type DatabaseType added in v1.5.2

type DatabaseType struct {
	KeeperRecordField
	Required bool     `json:"required,omitempty"`
	Value    []string `json:"value,omitempty"`
}

func NewDatabaseType added in v1.5.2

func NewDatabaseType(value string) *DatabaseType

DatabaseType field constructor with the single value to eliminate the complexity of the passing List as a value

type Date

type Date struct {
	KeeperRecordField
	Required      bool    `json:"required,omitempty"`
	PrivacyScreen bool    `json:"privacyScreen,omitempty"`
	Value         []int64 `json:"value,omitempty"`
}

func NewDate

func NewDate(value int64) *Date

Date field constructor with the single value to eliminate the complexity of the passing List as a value

type DeleteFolderPayload added in v1.6.0

type DeleteFolderPayload struct {
	ClientVersion string   `json:"clientVersion"`
	ClientId      string   `json:"clientId"`
	FolderUids    []string `json:"folderUids"`
	ForceDeletion bool     `json:"forceDeletion"`
}

func (*DeleteFolderPayload) DeleteFolderPayloadFromJson added in v1.6.0

func (p *DeleteFolderPayload) DeleteFolderPayloadFromJson(jsonData string)

func (*DeleteFolderPayload) DeleteFolderPayloadToJson added in v1.6.0

func (p *DeleteFolderPayload) DeleteFolderPayloadToJson() (string, error)

type DeleteFolderResponse added in v1.6.0

type DeleteFolderResponse struct {
	FolderUid    string `json:"folderUid"`
	ResponseCode string `json:"responseCode"`
	ErrorMessage string `json:"errorMessage"`
}

type DeleteFoldersResponse added in v1.6.0

type DeleteFoldersResponse struct {
	Folders []DeleteFolderResponse `json:"folders"`
}

func DeleteFoldersResponseFromJson added in v1.6.0

func DeleteFoldersResponseFromJson(jsonData string) (*DeleteFoldersResponse, error)

type DeletePayload

type DeletePayload struct {
	ClientVersion string   `json:"clientVersion"`
	ClientId      string   `json:"clientId"`
	RecordUids    []string `json:"recordUids"`
}

func (*DeletePayload) DeletePayloadFromJson

func (p *DeletePayload) DeletePayloadFromJson(jsonData string)

func (*DeletePayload) DeletePayloadToJson

func (p *DeletePayload) DeletePayloadToJson() (string, error)

type DeleteSecretResponse

type DeleteSecretResponse struct {
	RecordUid    string `json:"recordUid"`
	ResponseCode string `json:"responseCode"`
	ErrorMessage string `json:"errorMessage"`
}

type DeleteSecretsResponse

type DeleteSecretsResponse struct {
	Records []DeleteSecretResponse `json:"records"`
}

func DeleteSecretsResponseFromJson

func DeleteSecretsResponseFromJson(jsonData string) (*DeleteSecretsResponse, error)

type DirectoryType added in v1.5.2

type DirectoryType struct {
	KeeperRecordField
	Required bool     `json:"required,omitempty"`
	Value    []string `json:"value,omitempty"`
}

func NewDirectoryType added in v1.5.2

func NewDirectoryType(value string) *DirectoryType

DirectoryType field constructor with the single value to eliminate the complexity of the passing List as a value

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

ECDSASignature needed for compatibility with openssl (python > hazmat > openssl > ec > _ecdsa_sig_sign) which uses ASN.1/DER SEQUENCE format NB! MaxLen for ASN.1, depends on the encoding. P1363 only needs 64 bytes. And an OpePGP encoding only needs 66 bytes. ECDSASignature using ASN.1/DER needs up to 72 bytes. DER requires a minimum number of bytes. If ASN.1/BER is used, then the signature can be hundreds of bytes.

type Email

type Email struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewEmail

func NewEmail(value string) *Email

Email field constructor with the single value to eliminate the complexity of the passing List as a value

type EncryptedPayload

type EncryptedPayload struct {
	EncryptedPayload []byte
	Signature        []byte
}

func NewEncryptedPayload

func NewEncryptedPayload(encryptedPayload []byte, signature []byte) *EncryptedPayload

type ExpirationDate

type ExpirationDate struct {
	KeeperRecordField
	Required      bool    `json:"required,omitempty"`
	PrivacyScreen bool    `json:"privacyScreen,omitempty"`
	Value         []int64 `json:"value,omitempty"`
}

func NewExpirationDate

func NewExpirationDate(value int64) *ExpirationDate

ExpirationDate field constructor with the single value to eliminate the complexity of the passing List as a value

type FieldSectionFlag

type FieldSectionFlag byte
const (
	FieldSectionFields FieldSectionFlag = 1 << iota
	FieldSectionCustom
	FieldSectionBoth = FieldSectionFields | FieldSectionCustom
)

type FieldTokenFlag

type FieldTokenFlag byte
const (
	FieldTokenType FieldTokenFlag = 1 << iota
	FieldTokenLabel
	FieldTokenBoth = FieldTokenType | FieldTokenLabel
)

type FileRef

type FileRef struct {
	KeeperRecordField
	Required bool     `json:"required,omitempty"`
	Value    []string `json:"value,omitempty"`
}

func NewFileRef

func NewFileRef(value string) *FileRef

FileRef field constructor with the single value to eliminate the complexity of the passing List as a value

type FileUploadPayload

type FileUploadPayload struct {
	ClientVersion   string `json:"clientVersion"`
	ClientId        string `json:"clientId"`
	FileRecordUid   string `json:"fileRecordUid"`
	FileRecordKey   string `json:"fileRecordKey"`
	FileRecordData  string `json:"fileRecordData"`
	OwnerRecordUid  string `json:"ownerRecordUid"`
	OwnerRecordData string `json:"ownerRecordData"`
	LinkKey         string `json:"linkKey"`
	FileSize        int    `json:"fileSize"`
}

func FileUploadPayloadFromJson

func FileUploadPayloadFromJson(jsonData string) *FileUploadPayload

func (*FileUploadPayload) FileUploadPayloadToJson

func (p *FileUploadPayload) FileUploadPayloadToJson() (string, error)

type Folder

type Folder struct {
	ParentUid string
	Name      string
	// contains filtered or unexported fields
}

func GetFolderByKey

func GetFolderByKey(folderUid string, folders []*Folder) *Folder

func NewFolderFromJson

func NewFolderFromJson(folderDict map[string]interface{}, secretKey []byte) *Folder

func (*Folder) Records

func (f *Folder) Records() []*Record

type GetPayload

type GetPayload struct {
	ClientVersion    string   `json:"clientVersion"`
	ClientId         string   `json:"clientId"`
	PublicKey        string   `json:"publicKey,omitempty"`
	RequestedRecords []string `json:"requestedRecords"`
	RequestedFolders []string `json:"requestedFolders"`
}

func (*GetPayload) GetPayloadFromJson

func (p *GetPayload) GetPayloadFromJson(jsonData string)

func (*GetPayload) GetPayloadToJson

func (p *GetPayload) GetPayloadToJson() (string, error)

type HOTP

type HOTP struct {
	Secret  string // Secret key (required)
	Digits  int    // OTP digit count (default: 6)
	Counter int64  // Counter value (default: 0)
}

HOTP represents HMAC-Based OTP - https://datatracker.ietf.org/doc/html/rfc4226

func (*HOTP) Generate

func (hotp *HOTP) Generate() (string, error)

Generates HOTP code and returns OTP as string and any error encountered.

type Host

type Host struct {
	Hostname string `json:"hostName,omitempty"`
	Port     string `json:"port,omitempty"`
}

type Hosts

type Hosts struct {
	KeeperRecordField
	Required      bool   `json:"required,omitempty"`
	PrivacyScreen bool   `json:"privacyScreen,omitempty"`
	Value         []Host `json:"value,omitempty"`
}

func NewHosts

func NewHosts(value Host) *Hosts

Hosts field constructor with the single value to eliminate the complexity of the passing List as a value

type ICache

type ICache interface {
	SaveCachedValue(data []byte) error
	GetCachedValue() ([]byte, error)
	Purge() error
}

type IKeyValueStorage

type IKeyValueStorage interface {
	ReadStorage() map[string]interface{}
	SaveStorage(updatedConfig map[string]interface{})
	Get(key ConfigKey) string
	Set(key ConfigKey, value interface{}) map[string]interface{}
	Delete(key ConfigKey) map[string]interface{}
	DeleteAll() map[string]interface{}
	Contains(key ConfigKey) bool
	IsEmpty() bool
}

type KeeperFile

type KeeperFile struct {
	FileKey string

	FileData []byte

	Uid          string
	Type         string
	Title        string
	Name         string
	LastModified int
	Size         int

	F              map[string]interface{}
	RecordKeyBytes []byte
	// contains filtered or unexported fields
}

func NewKeeperFileFromJson

func NewKeeperFileFromJson(fileDict map[string]interface{}, recordKeyBytes []byte) *KeeperFile

func (*KeeperFile) DecryptFileKey

func (f *KeeperFile) DecryptFileKey() []byte

func (*KeeperFile) DeepCopy

func (f *KeeperFile) DeepCopy() *KeeperFile

func (*KeeperFile) GetFileData

func (f *KeeperFile) GetFileData() []byte

func (*KeeperFile) GetMeta

func (f *KeeperFile) GetMeta() map[string]interface{}

func (*KeeperFile) GetUrl

func (f *KeeperFile) GetUrl() string

func (*KeeperFile) SaveFile

func (f *KeeperFile) SaveFile(path string, createFolders bool) bool

func (*KeeperFile) ToString

func (f *KeeperFile) ToString() string

type KeeperFileData

type KeeperFileData struct {
	Title        string `json:"title,omitempty"`
	Name         string `json:"name,omitempty"`
	Type         string `json:"type,omitempty"`
	Size         int64  `json:"size,omitempty"`
	LastModified int64  `json:"lastModified,omitempty"`
}

type KeeperFileUpload

type KeeperFileUpload struct {
	Name  string
	Title string
	Type  string
	Data  []byte
}

func GetFileForUpload

func GetFileForUpload(filePath, fileName, fileTitle, mimeType string) (*KeeperFileUpload, error)

type KeeperFolder added in v1.6.0

type KeeperFolder struct {
	FolderKey []byte
	FolderUid string
	ParentUid string
	Name      string
}

func NewKeeperFolder added in v1.6.0

func NewKeeperFolder(folderMap map[string]interface{}, folderKey []byte) *KeeperFolder

type KeeperRecordData

type KeeperRecordData struct {
	Type   string              `json:"type,omitempty"`
	Title  string              `json:"title,omitempty"`
	Notes  string              `json:"notes,omitempty"`
	Fields []KeeperRecordField `json:"fields,omitempty"`
	Custom []KeeperRecordField `json:"custom,omitempty"`
}

type KeeperRecordField

type KeeperRecordField struct {
	Type  string `json:"type"`
	Label string `json:"label,omitempty"`
}

type KeyPair

type KeyPair struct {
	PublicKey  string `json:"publicKey,omitempty"`
	PrivateKey string `json:"privateKey,omitempty"`
}

type KeyPairs

type KeyPairs struct {
	KeeperRecordField
	Required      bool      `json:"required,omitempty"`
	PrivacyScreen bool      `json:"privacyScreen,omitempty"`
	Value         []KeyPair `json:"value,omitempty"`
}

func NewKeyPairs

func NewKeyPairs(value KeyPair) *KeyPairs

KeyPairs field constructor with the single value to eliminate the complexity of the passing List as a value

type KsmHttpResponse

type KsmHttpResponse struct {
	StatusCode   int
	Data         []byte
	HttpResponse *http.Response
}

func NewKsmHttpResponse

func NewKsmHttpResponse(statusCode int, data []byte, httpResponse *http.Response) *KsmHttpResponse

type LicenseNumber

type LicenseNumber struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewLicenseNumber

func NewLicenseNumber(value string) *LicenseNumber

LicenseNumber field constructor with the single value to eliminate the complexity of the passing List as a value

type Login

type Login struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewLogin

func NewLogin(value string) *Login

Login field constructor with the single value to eliminate the complexity of the passing List as a value

type Multiline

type Multiline struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewMultiline

func NewMultiline(value string) *Multiline

Multiline field constructor with the single value to eliminate the complexity of the passing List as a value

type Name

type Name struct {
	First  string `json:"first,omitempty"`
	Middle string `json:"middle,omitempty"`
	Last   string `json:"last,omitempty"`
}

type Names

type Names struct {
	KeeperRecordField
	Required      bool   `json:"required,omitempty"`
	PrivacyScreen bool   `json:"privacyScreen,omitempty"`
	Value         []Name `json:"value,omitempty"`
}

func NewNames

func NewNames(value Name) *Names

Names field constructor with the single value to eliminate the complexity of the passing List as a value

type NotationSection

type NotationSection struct {
	Section   string       // section name - ex. prefix
	IsPresent bool         // presence flag
	StartPos  int          // section start position in URI
	EndPos    int          // section end position in URI
	Text      *ParserTuple // <unescaped, raw> text
	Parameter *ParserTuple // <field type>|<field label>|<file name>
	Index1    *ParserTuple // numeric index [N] or []
	Index2    *ParserTuple // property index - ex. field/name[0][middle]
}

func NewNotationSection

func NewNotationSection(section string) *NotationSection

func ParseNotation

func ParseNotation(notation string) ([]*NotationSection, error)

func ParseNotationInLegacyMode

func ParseNotationInLegacyMode(notation string) ([]*NotationSection, error)

func ParseSection

func ParseSection(notation string, section string, pos int) (*NotationSection, error)

type OneTimeCode

type OneTimeCode struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewOneTimeCode

func NewOneTimeCode(value string) *OneTimeCode

OneTimeCode field constructor with the single value to eliminate the complexity of the passing List as a value

type PamHostname added in v1.5.2

type PamHostname struct {
	KeeperRecordField
	Required      bool   `json:"required,omitempty"`
	PrivacyScreen bool   `json:"privacyScreen,omitempty"`
	Value         []Host `json:"value,omitempty"`
}

func NewPamHostname added in v1.5.2

func NewPamHostname(value Host) *PamHostname

PamHostname field constructor with the single value to eliminate the complexity of the passing List as a value

type PamResource added in v1.5.2

type PamResource struct {
	ControllerUid string   `json:"controllerUid,omitempty"`
	FolderUid     string   `json:"folderUid,omitempty"`
	ResourceRef   []string `json:"resourceRef,omitempty"`
}

type PamResources added in v1.5.2

type PamResources struct {
	KeeperRecordField
	Required bool          `json:"required,omitempty"`
	Value    []PamResource `json:"value,omitempty"`
}

func NewPamResources added in v1.5.2

func NewPamResources(value PamResource) *PamResources

PamResources field constructor with the single value to eliminate the complexity of the passing List as a value

type ParserTuple

type ParserTuple struct {
	Text    string // unescaped text
	RawText string // raw text incl. delimiter(s), escape characters etc.
}

func ParseSubsection

func ParseSubsection(text string, pos int, delimiters string, escaped bool) (*ParserTuple, error)

type Passkey added in v1.5.2

type Passkey struct {
	PrivateKey   PasskeyPrivateKey `json:"privateKey,omitempty"`
	CredentialId string            `json:"credentialId,omitempty"`
	SignCount    int64             `json:"signCount,omitempty"`
	UserId       string            `json:"userId,omitempty"`
	RelyingParty string            `json:"relyingParty,omitempty"`
	Username     string            `json:"username,omitempty"`
	CreatedDate  int64             `json:"createdDate,omitempty"`
}

type PasskeyPrivateKey added in v1.6.0

type PasskeyPrivateKey struct {
	Crv    string   `json:"crv,omitempty"`
	D      string   `json:"d,omitempty"`
	Ext    bool     `json:"ext,omitempty"`
	KeyOps []string `json:"key_ops,omitempty"`
	Kty    string   `json:"kty,omitempty"`
	X      string   `json:"x,omitempty"`
	Y      int64    `json:"y,omitempty"`
}

type Passkeys added in v1.5.2

type Passkeys struct {
	KeeperRecordField
	Required bool      `json:"required,omitempty"`
	Value    []Passkey `json:"value,omitempty"`
}

func NewPasskeys added in v1.5.2

func NewPasskeys(value Passkey) *Passkeys

Passkeys field constructor with the single value to eliminate the complexity of the passing List as a value

type Password

type Password struct {
	KeeperRecordField
	Required          bool                `json:"required,omitempty"`
	PrivacyScreen     bool                `json:"privacyScreen,omitempty"`
	EnforceGeneration bool                `json:"enforceGeneration,omitempty"`
	Complexity        *PasswordComplexity `json:"complexity,omitempty"`
	Value             []string            `json:"value,omitempty"`
}

func NewPassword

func NewPassword(value string) *Password

Password field constructor with the single value to eliminate the complexity of the passing List as a value

type PasswordComplexity

type PasswordComplexity struct {
	Length    int `json:"length,omitempty"`
	Caps      int `json:"caps,omitempty"`
	Lowercase int `json:"lowercase,omitempty"`
	Digits    int `json:"digits,omitempty"`
	Special   int `json:"special,omitempty"`
}

type PasswordOptions

type PasswordOptions struct {
	MinLength               string
	UppercaseLength         string
	LowercaseLength         string
	DigitsLength            string
	SpecialCharactersLength string
	SpecialCharacterSet     string
}

PasswordOptions provides complexity settings for GeneratePasswordWithOptions Positive values specify minimum length, zero or negative - exact length Generated password must have at least MinLength characters - exact values may be converted to min values Empty strings or missing values will be substituted with a reasonable defaults ex. passing nil will generate password with length = DefaultPasswordLength using all charsets

type PaymentCard

type PaymentCard struct {
	CardNumber         string `json:"cardNumber,omitempty"`
	CardExpirationDate string `json:"cardExpirationDate,omitempty"`
	CardSecurityCode   string `json:"cardSecurityCode,omitempty"`
}

type PaymentCards

type PaymentCards struct {
	KeeperRecordField
	Required      bool          `json:"required,omitempty"`
	PrivacyScreen bool          `json:"privacyScreen,omitempty"`
	Value         []PaymentCard `json:"value,omitempty"`
}

func NewPaymentCards

func NewPaymentCards(value PaymentCard) *PaymentCards

PaymentCards field constructor with the single value to eliminate the complexity of the passing List as a value

type Phone

type Phone struct {
	Region string `json:"region,omitempty"` // Region code. Ex. US
	Number string `json:"number,omitempty"` // Phone number. Ex. 510-222-5555
	Ext    string `json:"ext,omitempty"`    // Extension number. Ex. 9987
	Type   string `json:"type,omitempty"`   // Phone number type. Ex. Mobile
}

type Phones

type Phones struct {
	KeeperRecordField
	Required      bool    `json:"required,omitempty"`
	PrivacyScreen bool    `json:"privacyScreen,omitempty"`
	Value         []Phone `json:"value,omitempty"`
}

func NewPhones

func NewPhones(value Phone) *Phones

Phones field constructor with the single value to eliminate the complexity of the passing List as a value

type PinCode

type PinCode struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewPinCode

func NewPinCode(value string) *PinCode

PinCode field constructor with the single value to eliminate the complexity of the passing List as a value

type PrivateKey

type PrivateKey ecdsa.PrivateKey

func DerBase64PrivateKeyToPrivateKey

func DerBase64PrivateKeyToPrivateKey(privateKeyDerBase64 string) (*PrivateKey, error)

func GenerateKeys

func GenerateKeys(curve elliptic.Curve) (PrivateKey, error)

func GenerateNewEccKey

func GenerateNewEccKey() (PrivateKey, error)

func GenerateP256Keys

func GenerateP256Keys() (PrivateKey, error)

func GeneratePrivateKeyEcc

func GeneratePrivateKeyEcc() (PrivateKey, error)

func LoadDerPrivateKeyDer

func LoadDerPrivateKeyDer(data []byte) (*PrivateKey, error)

func (*PrivateKey) Bytes

func (priv *PrivateKey) Bytes() []byte

Bytes returns private key D value

func (*PrivateKey) Equals

func (priv *PrivateKey) Equals(k *PrivateKey) bool

Equals compares two private keys with constant time (to resist timing attacks)

func (*PrivateKey) GetPublicKey

func (priv *PrivateKey) GetPublicKey() *PublicKey

GetPublicKey returns the associated PublicKey for this privatekey, If the key is missing then one is generated.

func (*PrivateKey) Hex

func (priv *PrivateKey) Hex() string

Hex returns private key bytes as a hex string

func (*PrivateKey) SetBytes

func (priv *PrivateKey) SetBytes(d []byte) *PrivateKey

SetBytes reconstructs the private key from D bytes

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

Sign signs digest with priv, reading randomness from rand.

The opts argument is not currently used but, in keeping with the crypto.Signer interface,
should be the hash function used to digest the message.

type PublicKey

type PublicKey ecdsa.PublicKey

func (*PublicKey) Bytes

func (pub *PublicKey) Bytes() (buf []byte)

Bytes concatenates public key x and y values

func (*PublicKey) Check

func (pub *PublicKey) Check(curve elliptic.Curve) bool

Check if public key is valid for the curve

func (*PublicKey) SetBytes

func (pub *PublicKey) SetBytes(buf []byte) *PublicKey

SetBytes decodes buf and stores the values in pub X and Y

type QueryOptions added in v1.6.0

type QueryOptions struct {
	RecordsFilter []string
	FoldersFilter []string
}

type Record

type Record struct {
	RecordKeyBytes []byte
	Uid            string

	Files      []*KeeperFile
	Revision   int64
	IsEditable bool

	RawJson    string
	RecordDict map[string]interface{}
	// contains filtered or unexported fields
}

func FindSecretByTitle

func FindSecretByTitle(recordTitle string, records []*Record) *Record

func FindSecretsByTitle

func FindSecretsByTitle(recordTitle string, records []*Record) []*Record

func NewRecord

func NewRecord(templateRecordUid string, records []*Record, newRecordUid string) (*Record, error)

NewRecord returns a new empty record of the same type as template object but with new UID and RecordKeyBytes generates and uses new random UID if newRecordUid is empty returns error if template record is not found

func NewRecordClone

func NewRecordClone(templateRecordUid string, records []*Record, newRecordUid string) (*Record, error)

NewRecordClone returns a deep copy of the template object with new UID and RecordKeyBytes generates and uses new random UID if newRecordUid is empty returns error if template record is not found

func NewRecordFromJson

func NewRecordFromJson(recordDict map[string]interface{}, secretKey []byte, folderUid string) *Record

func NewRecordFromRecordData

func NewRecordFromRecordData(recordData *RecordCreate, folder *Folder) *Record

func NewRecordFromRecordDataWithUid

func NewRecordFromRecordDataWithUid(recordUid string, recordData *RecordCreate, folder *Folder) *Record

func (*Record) AddCustomField

func (r *Record) AddCustomField(field interface{}) error

AddCustomField adds new custom field to the record The new field must satisfy the IsFieldClass function

func (*Record) CanClone

func (r *Record) CanClone() bool

func (*Record) DownloadFile

func (r *Record) DownloadFile(fileUid string, path string) bool

func (*Record) DownloadFileByTitle

func (r *Record) DownloadFileByTitle(title string, path string) bool

func (*Record) FieldExists

func (r *Record) FieldExists(section, name string) bool

func (*Record) FindFile

func (r *Record) FindFile(name string) *KeeperFile

FindFile finds the first file with matching file UID, name or title

func (*Record) FindFileByFilename

func (r *Record) FindFileByFilename(filename string) *KeeperFile

FindFileByName finds the first file with matching filename

func (*Record) FindFileByTitle

func (r *Record) FindFileByTitle(title string) *KeeperFile

FindFileByTitle finds the first file with matching title

func (*Record) FindFiles

func (r *Record) FindFiles(name string) []*KeeperFile

FindFiles finds all files with matching file UID, name or title

func (*Record) FolderUid

func (r *Record) FolderUid() string

func (*Record) GetCustomFieldValue

func (r *Record) GetCustomFieldValue(fieldType string, single bool) ([]interface{}, error)

func (*Record) GetCustomFieldValueByLabel

func (r *Record) GetCustomFieldValueByLabel(fieldLabel string) string

GetCustomFieldValueByLabel returns string value of the *first* field from custom[] that matches fieldLabel

func (*Record) GetCustomFieldValueByType

func (r *Record) GetCustomFieldValueByType(fieldType string) string

GetCustomFieldValueByType returns string value of the *first* field from custom[] that matches fieldType

func (*Record) GetCustomFieldValues

func (r *Record) GetCustomFieldValues(label string, fieldType string) []string

func (*Record) GetCustomFieldsByLabel

func (r *Record) GetCustomFieldsByLabel(fieldLabel string) []map[string]interface{}

func (*Record) GetCustomFieldsByType

func (r *Record) GetCustomFieldsByType(fieldType string) []map[string]interface{}

func (*Record) GetFieldValueByLabel

func (r *Record) GetFieldValueByLabel(fieldLabel string) string

GetFieldValueByLabel returns string value of the *first* field from fields[] that matches fieldLabel

func (*Record) GetFieldValueByType

func (r *Record) GetFieldValueByType(fieldType string) string

GetFieldValueByType returns string value of the *first* field from fields[] that matches fieldType

func (*Record) GetFieldValuesByType

func (r *Record) GetFieldValuesByType(fieldType string) []string

func (*Record) GetFieldsByLabel

func (r *Record) GetFieldsByLabel(fieldLabel string) []map[string]interface{}

func (*Record) GetFieldsByMask

func (r *Record) GetFieldsByMask(fieldToken string, fieldTokenFlag FieldTokenFlag, fieldType FieldSectionFlag) []map[string]interface{}

GetFieldsByMask returns all fields from the corresponding field section (fields, custom or both) where fieldToken matches the FieldTokenFlag (type, label or both)

func (*Record) GetFieldsBySection

func (r *Record) GetFieldsBySection(fieldSectionType FieldSectionFlag) []interface{}

func (*Record) GetFieldsByType

func (r *Record) GetFieldsByType(fieldType string) []map[string]interface{}

func (*Record) GetStandardFieldValue

func (r *Record) GetStandardFieldValue(fieldType string, single bool) ([]interface{}, error)

func (*Record) InnerFolderUid added in v1.6.1

func (r *Record) InnerFolderUid() string

func (*Record) InsertField

func (r *Record) InsertField(section string, field interface{}) error

func (*Record) Notes

func (r *Record) Notes() string

func (*Record) Password

func (r *Record) Password() string

func (*Record) Print

func (r *Record) Print()

func (*Record) RemoveField

func (r *Record) RemoveField(section, name string, removeAll bool) int

func (*Record) SetCustomFieldValue

func (r *Record) SetCustomFieldValue(fieldType string, value interface{}) error

func (*Record) SetCustomFieldValueSingle

func (r *Record) SetCustomFieldValueSingle(fieldLabel, value string)

func (*Record) SetFieldValueSingle

func (r *Record) SetFieldValueSingle(fieldType, value string)

func (*Record) SetNotes

func (r *Record) SetNotes(notes string)

func (*Record) SetPassword

func (r *Record) SetPassword(password string)

func (*Record) SetStandardFieldValue

func (r *Record) SetStandardFieldValue(fieldType string, value interface{}) error

func (*Record) SetTitle

func (r *Record) SetTitle(title string)

func (*Record) SetType

func (r *Record) SetType(newType string)

func (*Record) Title

func (r *Record) Title() string

func (*Record) ToString

func (r *Record) ToString() string

func (*Record) Type

func (r *Record) Type() string

func (*Record) UpdateField

func (r *Record) UpdateField(section string, field interface{}) error

type RecordCreate

type RecordCreate struct {
	RecordType string        `json:"type,omitempty"`
	Title      string        `json:"title,omitempty"`
	Notes      string        `json:"notes,omitempty"`
	Fields     []interface{} `json:"fields,omitempty"`
	Custom     []interface{} `json:"custom,omitempty"`
}

func NewRecordCreate

func NewRecordCreate(recordType, title string) *RecordCreate

func NewRecordCreateFromJson

func NewRecordCreateFromJson(recordJson string) *RecordCreate

func NewRecordCreateFromJsonDecoder

func NewRecordCreateFromJsonDecoder(recordJson string, disallowUnknownFields bool) (*RecordCreate, error)

func (RecordCreate) GetFieldByType

func (r RecordCreate) GetFieldByType(field interface{}) interface{}

GetFieldByType returns first found field of the same type as field param The search goes first through fields[] then custom[] Note: Method returns a pointer so any value modifications are reflected directly in the record

func (RecordCreate) GetFieldsByType

func (r RecordCreate) GetFieldsByType(field interface{}) []interface{}

GetFieldsByType returns all fields of the same type as field param The search goes first through fields[] then custom[] Note: Method returns pointers so any value modifications are reflected directly in the record

func (RecordCreate) ToDict

func (r RecordCreate) ToDict() map[string]interface{}

func (RecordCreate) ToJson

func (r RecordCreate) ToJson() string

type RecordField

type RecordField struct {
	Type     string
	Label    string
	Value    []interface{}
	Required bool
}

func NewRecordField

func NewRecordField(fieldType, label string, required bool, value interface{}) *RecordField

type RecordRef added in v1.5.2

type RecordRef struct {
	KeeperRecordField
	Required bool     `json:"required,omitempty"`
	Value    []string `json:"value,omitempty"`
}

func NewRecordRef added in v1.5.2

func NewRecordRef(value string) *RecordRef

RecordRef field constructor with the single value to eliminate the complexity of the passing List as a value

type Schedule added in v1.5.2

type Schedule struct {
	Type          string `json:"type,omitempty"`
	UtcTime       string `json:"utcTime,omitempty"`
	Weekday       string `json:"weekday,omitempty"`
	IntervalCount int    `json:"intervalCount,omitempty"`
}

type Schedules added in v1.5.2

type Schedules struct {
	KeeperRecordField
	Required bool       `json:"required,omitempty"`
	Value    []Schedule `json:"value,omitempty"`
}

func NewSchedules added in v1.5.2

func NewSchedules(value Schedule) *Schedules

Schedules field constructor with the single value to eliminate the complexity of the passing List as a value

type Script added in v1.5.2

type Script struct {
	FileRef   string   `json:"fileRef,omitempty"`
	Command   string   `json:"command,omitempty"`
	RecordRef []string `json:"recordRef,omitempty"`
}

type Scripts added in v1.5.2

type Scripts struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []Script `json:"value,omitempty"`
}

func NewScripts added in v1.5.2

func NewScripts(value Script) *Scripts

Scripts field constructor with the single value to eliminate the complexity of the passing List as a value

type Secret

type Secret struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewSecret

func NewSecret(value string) *Secret

Secret field constructor with the single value to eliminate the complexity of the passing List as a value

type SecretsManager

type SecretsManager struct {
	Token          string
	Hostname       string
	VerifySslCerts bool
	Config         IKeyValueStorage
	// contains filtered or unexported fields
}

func NewSecretsManager

func NewSecretsManager(options *ClientOptions, arg ...interface{}) *SecretsManager

NewSecretsManager returns new *SecretsManager initialized with the options provided. If the configuration file cannot be initialized or parsed returns nil

func (*SecretsManager) CompleteTransaction added in v1.5.2

func (c *SecretsManager) CompleteTransaction(recordUid string, rollback bool) (err error)

func (*SecretsManager) CreateFolder added in v1.6.0

func (c *SecretsManager) CreateFolder(createOptions CreateOptions, folderName string, folders []*KeeperFolder) (folderUid string, err error)

CreateFolder creates new folder using the provided options.

folders == nil will force downloading all folders metadata with every request. Folders metadata could be retrieved from GetFolders() and cached and reused as long as it is not modified externally or internally

createOptions.FolderUid is required and must be a parent shared folder

createOptions.SubFolderUid could be many levels deep under its parent. If SubFolderUid is empty - new folder is created under parent FolderUid

func (*SecretsManager) CreateSecret

func (c *SecretsManager) CreateSecret(record *Record) (recordUid string, err error)

CreateSecret creates new record from a cloned record found by NewRecord and the new record will be placed into the same shared folder as the original

func (*SecretsManager) CreateSecretWithRecordData

func (c *SecretsManager) CreateSecretWithRecordData(recUid, folderUid string, recordData *RecordCreate) (recordUid string, err error)

CreateSecretWithRecordData creates new record using recordUID, folderUID and record data provided Note: if param recUid is empty - new auto generated record UID will be used

func (*SecretsManager) CreateSecretWithRecordDataAndOptions added in v1.6.0

func (c *SecretsManager) CreateSecretWithRecordDataAndOptions(createOptions CreateOptions, recordData *RecordCreate, folders []*KeeperFolder) (recordUid string, err error)

CreateSecretWithRecordDataAndOptions creates new record using CreateOptions and record data provided

func (*SecretsManager) DefaultKeeperServerPublicKeyId

func (c *SecretsManager) DefaultKeeperServerPublicKeyId() string

func (*SecretsManager) DeleteFolder added in v1.6.0

func (c *SecretsManager) DeleteFolder(folderUids []string, forceDeletion bool) (statuses map[string]string, err error)

DeleteFolder removes the selected folders. Use forceDeletion flag to remove non-empty folders Note! When using forceDeletion avoid sending parent with its children folder UIDs. Depending on the delete order you may get an error ex. if parent force-deleted child first. There's no guarantee that list will always be processed in FIFO order. Note! Any folders UIDs missing from the vault or not shared to the KSM Application will not result in error.

func (*SecretsManager) DeleteSecrets

func (c *SecretsManager) DeleteSecrets(recordUids []string) (statuses map[string]string, err error)

func (*SecretsManager) FindNotation

func (c *SecretsManager) FindNotation(records []*Record, notation string) (fieldValue []interface{}, err error)

func (*SecretsManager) GenerateTransmissionKey

func (c *SecretsManager) GenerateTransmissionKey(keyId string) *TransmissionKey

func (*SecretsManager) GetFolders added in v1.6.0

func (c *SecretsManager) GetFolders() ([]*KeeperFolder, error)

func (*SecretsManager) GetNotation

func (c *SecretsManager) GetNotation(notation string) (fieldValue []interface{}, err error)

func (*SecretsManager) GetNotationResults

func (c *SecretsManager) GetNotationResults(notation string) ([]string, error)

GetNotationResults returns a string list with all values specified by the notation or throws an error. Use TryGetNotationResults to just log errors and continue returning an empty string list on error.

func (*SecretsManager) GetSecretByTitle

func (c *SecretsManager) GetSecretByTitle(recordTitle string) (record *Record, err error)

func (*SecretsManager) GetSecrets

func (c *SecretsManager) GetSecrets(uids []string) (records []*Record, err error)

GetSecrets retrieves all records associated with the given application optionally filtered by uids

func (*SecretsManager) GetSecretsByTitle

func (c *SecretsManager) GetSecretsByTitle(recordTitle string) (records []*Record, err error)

func (*SecretsManager) GetSecretsFullResponse

func (c *SecretsManager) GetSecretsFullResponse(uids []string) (response *SecretsManagerResponse, err error)

func (*SecretsManager) GetSecretsFullResponseWithOptions added in v1.6.0

func (c *SecretsManager) GetSecretsFullResponseWithOptions(queryOptions QueryOptions) (response *SecretsManagerResponse, err error)

func (*SecretsManager) GetSecretsWithOptions added in v1.6.0

func (c *SecretsManager) GetSecretsWithOptions(queryOptions QueryOptions) (records []*Record, err error)

GetSecretsWithOptions retrieves all records associated with the given application optionally filtered by query options

func (*SecretsManager) HandleHttpError

func (c *SecretsManager) HandleHttpError(rs *http.Response, body []byte, httpError error) (retry bool, err error)

func (*SecretsManager) LoadSecretKey

func (c *SecretsManager) LoadSecretKey() string

Returns client_id from the environment variable, config file, or in the code

func (*SecretsManager) NotationPrefix

func (c *SecretsManager) NotationPrefix() string

func (*SecretsManager) PostFunction

func (c *SecretsManager) PostFunction(
	url string,
	transmissionKey *TransmissionKey,
	encryptedPayloadAndSignature *EncryptedPayload,
	verifySslCerts bool) (*KsmHttpResponse, error)

func (*SecretsManager) PostQuery

func (c *SecretsManager) PostQuery(path string, payload interface{}) (body []byte, err error)

func (*SecretsManager) PrepareContext

func (c *SecretsManager) PrepareContext() *Context

func (*SecretsManager) Save

func (c *SecretsManager) Save(record *Record) (err error)

func (*SecretsManager) SaveBeginTransaction added in v1.5.2

func (c *SecretsManager) SaveBeginTransaction(record *Record, transactionType UpdateTransactionType) (err error)

SaveBeginTransaction requires corresponding call to CompleteTransaction to either commit or rollback

func (*SecretsManager) SetCache

func (c *SecretsManager) SetCache(cache ICache)

func (*SecretsManager) TryGetNotationResults

func (c *SecretsManager) TryGetNotationResults(notation string) []string

TryGetNotationResults returns a string list with all values specified by the notation or empty list on error. It simply logs any errors and continue returning an empty string list on error.

func (*SecretsManager) UpdateFolder added in v1.6.0

func (c *SecretsManager) UpdateFolder(folderUid, folderName string, folders []*KeeperFolder) (err error)

UpdateFolder changes the folder metadata - currently folder name only folders == nil will force downloading all folders metadata with every request

func (*SecretsManager) UploadFile

func (c *SecretsManager) UploadFile(record *Record, file *KeeperFileUpload) (uid string, err error)

func (*SecretsManager) UploadFilePath

func (c *SecretsManager) UploadFilePath(record *Record, filePath string) (uid string, err error)

type SecretsManagerResponse

type SecretsManagerResponse struct {
	AppData   AppData
	Folders   []*Folder
	Records   []*Record
	ExpiresOn int64
	Warnings  string
	JustBound bool
}

Server response contained details about the application and the records that were requested to be returned

func (SecretsManagerResponse) ExpiresOnStr

func (r SecretsManagerResponse) ExpiresOnStr(dateFormat string) string

ExpiresOnStr retrieves string formatted expiration date if dateFormat is empty default format is used: "%Y-%m-%d %H:%M:%S"

type SecureNote

type SecureNote struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewSecureNote

func NewSecureNote(value string) *SecureNote

SecureNote field constructor with the single value to eliminate the complexity of the passing List as a value

type SecurityQuestion

type SecurityQuestion struct {
	Question string `json:"question,omitempty"`
	Answer   string `json:"answer,omitempty"`
}

type SecurityQuestions

type SecurityQuestions struct {
	KeeperRecordField
	Required      bool               `json:"required,omitempty"`
	PrivacyScreen bool               `json:"privacyScreen,omitempty"`
	Value         []SecurityQuestion `json:"value,omitempty"`
}

func NewSecurityQuestions

func NewSecurityQuestions(value SecurityQuestion) *SecurityQuestions

SecurityQuestions field constructor with the single value to eliminate the complexity of the passing List as a value

type TOTP

type TOTP struct {
	Secret    string // Secret key (required)
	Digits    int    // OTP digit count (default: 6)
	Algorithm string // OTP Algorithm ("SHA1" or "SHA256" or "SHA512") (default: SHA1)
	Period    int64  // Period for which OTP is valid (seconds) (default: 30) == X in RFC6238
	UnixTime  int64  // (Optional) Unix Timestamp (default: Current unix timestamp)
}

TOTP represents Time-based OTP - https://datatracker.ietf.org/doc/html/rfc6238

func (*TOTP) Generate

func (totp *TOTP) Generate() (code string, seconds int, err error)

Generates TOTP code and returns OTP as string, seconds remaining and any error encountered.

type Text

type Text struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewText

func NewText(value string) *Text

Text field constructor with the single value to eliminate the complexity of the passing List as a value

type TotpCode

type TotpCode struct {
	Code     string // TOTP Code
	TimeLeft int    // Time left in seconds (time before expiration)
	Period   int    // Period in seconds
}

TotpCode provides detailed info about the generated TOTP code

func GetTotpCode

func GetTotpCode(totpUrl string) (*TotpCode, error)

Generates TOTP code from the URL and returns OTP as string, seconds remaining and any error encountered.

type TransmissionKey

type TransmissionKey struct {
	PublicKeyId  string
	Key          []byte
	EncryptedKey []byte
}

func NewTransmissionKey

func NewTransmissionKey(publicKeyId string, key []byte, encryptedKey []byte) *TransmissionKey

type UpdateFolderPayload added in v1.6.0

type UpdateFolderPayload struct {
	ClientVersion string `json:"clientVersion"`
	ClientId      string `json:"clientId"`
	FolderUid     string `json:"folderUid"`
	Data          string `json:"data"`
}

func (*UpdateFolderPayload) UpdateFolderPayloadFromJson added in v1.6.0

func (p *UpdateFolderPayload) UpdateFolderPayloadFromJson(jsonData string)

func (*UpdateFolderPayload) UpdateFolderPayloadToJson added in v1.6.0

func (p *UpdateFolderPayload) UpdateFolderPayloadToJson() (string, error)

type UpdatePayload

type UpdatePayload struct {
	ClientVersion   string                `json:"clientVersion"`
	ClientId        string                `json:"clientId"`
	RecordUid       string                `json:"recordUid"`
	Revision        int64                 `json:"revision"`
	Data            string                `json:"data"`
	TransactionType UpdateTransactionType `json:"transactionType,omitempty"`
}

func (*UpdatePayload) UpdatePayloadFromJson

func (p *UpdatePayload) UpdatePayloadFromJson(jsonData string)

func (*UpdatePayload) UpdatePayloadToJson

func (p *UpdatePayload) UpdatePayloadToJson() (string, error)

type UpdateTransactionType added in v1.5.2

type UpdateTransactionType string
const (
	TransactionTypeNone     UpdateTransactionType = ""
	TransactionTypeGeneral  UpdateTransactionType = "general"
	TransactionTypeRotation UpdateTransactionType = "rotation"
)

type Url

type Url struct {
	KeeperRecordField
	Required      bool     `json:"required,omitempty"`
	PrivacyScreen bool     `json:"privacyScreen,omitempty"`
	Value         []string `json:"value,omitempty"`
}

func NewUrl

func NewUrl(value string) *Url

Url field constructor with the single value to eliminate the complexity of the passing List as a value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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