keeper

package
v0.0.0-...-05cdca5 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeeper

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

APIKeeper - keeper server api wrapper

func NewAPIKeeper

func NewAPIKeeper(
	crypto contract.ISecretCrypto,
	l contract.IApplicationLogger,
) *APIKeeper

NewAPIKeeper - constructor. Creates new keeper server api instance

func (*APIKeeper) Delete

func (a *APIKeeper) Delete(
	ctx context.Context,
	userID contract.UserID,
	id contract.SecretID,
) error

Delete - delete user secret

func (*APIKeeper) GetAllSecrets

func (a *APIKeeper) GetAllSecrets(
	ctx context.Context,
	userID contract.UserID,
) ([]contract.IUserSecretItem, error)

GetAllSecrets - get all user secrets

func (*APIKeeper) SaveSecret

func (a *APIKeeper) SaveSecret(
	ctx context.Context,
	userID contract.UserID,
	secret contract.IUserSecretItem,
) (contract.IUserSecretItem, error)

SaveSecret - save or update user secret

type ClientKeeper

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

ClientKeeper - client keeper

func NewClientKeeper

NewClientKeeper - constructor. Creates new client keeper

func (*ClientKeeper) Delete

func (c *ClientKeeper) Delete(
	ctx context.Context,
	userID contract.UserID,
	id contract.SecretID,
) error

Delete - delete secret for user

func (*ClientKeeper) GetAllSecrets

func (c *ClientKeeper) GetAllSecrets(
	ctx context.Context,
	userID contract.UserID,
) ([]contract.IUserSecretItem, error)

GetAllSecrets - get all secrets for user

func (*ClientKeeper) SaveSecret

SaveSecret - save secret for the user

type GetPrivateKeyFunc

type GetPrivateKeyFunc func() ([]byte, error)

GetPrivateKeyFunc - get private key function

Example

GetPrivateKeyFunc - example of GetPrivateKeyFunc

package main

import (
	"crypto/sha256"
	"fmt"
	"github.com/itksb/go-secret-keeper/internal/client/keeper"
)

func main() {
	key := []byte("1234567890") // source from config or env

	f := keeper.GetPrivateKeyFunc(func() ([]byte, error) {
		sum := sha256.Sum256(key)
		return sum[:], nil
	})

	result, _ := f()
	fmt.Println(result)
}
Output:

type IClientKeeper

type IClientKeeper interface {
	contract.IKeeper
}

IClientKeeper - client keeper interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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