keeper

package
v2.2.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 9 Imported by: 0

README

goutils/v2/keeper

The keeper package is a collection of utility functions designed to simplify common keeper tasks.


Table of contents


Functions

Keeper.AddRecord(map[string]string)
AddRecord(map[string]string) error

AddRecord adds a new record to the Keeper vault.

Parameters:

fields: A map containing the record fields.

fields.title: The title of the record. fields.login: The username or login of the record. fields.password: The password of the record. fields.notes: Additional notes related to the record.

Returns:

error: An error if the record cannot be added.


Keeper.CommanderInstalled()
CommanderInstalled() bool

CommanderInstalled checks if the Keeper Commander tool is installed on the current system.

Returns:

bool: True if the Keeper Commander tool is installed, false otherwise.


Keeper.LoggedIn()
LoggedIn() bool

LoggedIn checks if the user is logged into their Keeper vault.

Returns:

bool: True if the user is logged into their Keeper vault, false otherwise.


Keeper.RetrieveRecord(string)
RetrieveRecord(string) string, error

RetrieveRecord retrieves a user's Keeper record using the provided unique identifier (uid) and returns it as a JSON string.

Parameters:

uid: A string representing the unique identifier of the Keeper record to retrieve.

Returns:

string: The JSON string representation of the retrieved Keeper record. The JSON string contains the following attributes:

  • UID: The unique identifier of the record.
  • Title: The title of the record.
  • Username: The username associated with the record.
  • Password: The password of the record.
  • URL: The URL associated with the record.
  • TOTP: The one-time password (if any) associated with the record.
  • Note: Any additional notes associated with the record.

error: An error if the Keeper record cannot be retrieved or if there is an issue converting the record to a JSON string.


Keeper.SearchRecords(string)
SearchRecords(string) string, error

SearchRecords searches the user's Keeper records for records that match the provided search term.

Parameters:

searchTerm: A string representing the term to search for in the Keeper records.

Returns:

string: The unique identifier (UID) of the first Keeper record that matches the search term. If multiple records match the search term, only the UID of the first record is returned.

error: An error if the Keeper records cannot be searched or if the search term does not match any records.


Installation

To use the goutils/v2/keeper package, you first need to install it. Follow the steps below to install via go get.

go get github.com/l50/goutils/v2/keeper

Usage

After installation, you can import the package in your Go project using the following import statement:

import "github.com/l50/goutils/v2/keeper"

Tests

To ensure the package is working correctly, run the following command to execute the tests for goutils/v2/keeper:

go test -v

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keeper

type Keeper struct{}

Keeper represents a connection with the Keeper password manager.

func (Keeper) AddRecord

func (k Keeper) AddRecord(fields map[string]string) error

AddRecord adds a new record to the Keeper vault.

**Parameters:**

fields: A map containing the record fields.

fields.title: The title of the record. fields.login: The username or login of the record. fields.password: The password of the record. fields.notes: Additional notes related to the record.

**Returns:**

error: An error if the record cannot be added.

func (Keeper) CommanderInstalled

func (k Keeper) CommanderInstalled() bool

CommanderInstalled checks if the Keeper Commander tool is installed on the current system.

**Returns:**

bool: True if the Keeper Commander tool is installed, false otherwise.

Example
package main

import (
	"log"

	"github.com/l50/goutils/v2/pwmgr/keeper"
)

func main() {
	k := keeper.Keeper{}
	if !k.CommanderInstalled() {
		log.Fatal("keeper commander is not installed.")
	}
}
Output:

func (Keeper) LoggedIn

func (k Keeper) LoggedIn() bool

LoggedIn checks if the user is logged into their Keeper vault.

**Returns:**

bool: True if the user is logged into their Keeper vault, false otherwise.

Example
package main

import (
	"log"

	"github.com/l50/goutils/v2/pwmgr/keeper"
)

func main() {
	k := keeper.Keeper{}
	if !k.LoggedIn() {
		log.Fatal("not logged into keeper vault.")
	}
}
Output:

func (Keeper) RetrieveRecord

func (k Keeper) RetrieveRecord(uid string) (string, error)

RetrieveRecord retrieves a user's Keeper record using the provided unique identifier (uid) and returns it as a JSON string.

**Parameters:**

uid: A string representing the unique identifier of the Keeper record to retrieve.

**Returns:**

string: The JSON string representation of the retrieved Keeper record. The JSON string contains the following attributes:

- UID: The unique identifier of the record. - Title: The title of the record. - Username: The username associated with the record. - Password: The password of the record. - URL: The URL associated with the record. - TOTP: The one-time password (if any) associated with the record. - Note: Any additional notes associated with the record.

error: An error if the Keeper record cannot be retrieved or if there is an issue converting the record to a JSON string.

Example
package main

import (
	"log"

	"github.com/l50/goutils/v2/pwmgr/keeper"
)

func main() {
	k := keeper.Keeper{}
	record, err := k.RetrieveRecord("1234abcd")
	if err != nil {
		log.Fatalf("failed to retrieve record: %v", err)
	}
	log.Printf("retrieved record: %+v\n", record)
}
Output:

func (Keeper) SearchRecords

func (k Keeper) SearchRecords(searchTerm string) (string, error)

SearchRecords searches the user's Keeper records for records that match the provided search term.

**Parameters:**

searchTerm: A string representing the term to search for in the Keeper records.

**Returns:**

string: The unique identifier (UID) of the first Keeper record that matches the search term. If multiple records match the search term, only the UID of the first record is returned.

error: An error if the Keeper records cannot be searched or if the search term does not match any records.

Example
package main

import (
	"log"

	"github.com/l50/goutils/v2/pwmgr/keeper"
)

func main() {
	k := keeper.Keeper{}
	uid, err := k.SearchRecords("search term")
	if err != nil {
		log.Fatalf("failed to search records: %v", err)
	}
	log.Printf("found matching record with UID: %s\n", uid)
}
Output:

Jump to

Keyboard shortcuts

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