member

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Device = MemberType("Device")
	Person = MemberType("Person")
)

Variables

This section is empty.

Functions

func FromJSON

func FromJSON(str []byte) (*PrivateMember, *PublicMember, error)

func JsonPublicMemberValueBy

func JsonPublicMemberValueBy(p1, p2 *JsonPublicMember) bool

func MakePublicMemberJWT

func MakePublicMemberJWT(signer *key.PrivateKey, pm *PublicMember) (string, error)

func Matcher

func Matcher(args ...string) func(p *PrivateMember) bool

func ToPrivateKeys

func ToPrivateKeys(pkms []*PrivateMember) []*key.PrivateKey

func ToPublicKeys

func ToPublicKeys(pkms []*PublicMember) []*key.PublicKey

Types

type JsonPrivateMember

type JsonPrivateMember struct {
	Clazz string `json:"clazz"`
	Member
	PrivateKey string `json:"privatekey"`
}

func ToJsonPrivateMember

func ToJsonPrivateMember(pkms ...*PrivateMember) []*JsonPrivateMember

func (*JsonPrivateMember) AsPrivateMember

func (pm *JsonPrivateMember) AsPrivateMember() (*PrivateMember, error)

func (*JsonPrivateMember) String

func (pm *JsonPrivateMember) String() ([]byte, error)

type JsonPrivatePublicMember

type JsonPrivatePublicMember struct {
	Member
	PrivateKey *string
	PublicKey  *string
}

type JsonPublicMember

type JsonPublicMember struct {
	Clazz string `json:"clazz"`
	Member
	PublicKey string `json:"publicKey"`
}

func ToJsonPublicMember

func ToJsonPublicMember(pkms ...*PrivateMember) []*JsonPublicMember

func (*JsonPublicMember) String

func (pm *JsonPublicMember) String() ([]byte, error)

type JsonPublicMemberSorter

type JsonPublicMemberSorter struct {
	Values [](*JsonPublicMember)
	By     func(p1, p2 *JsonPublicMember) bool // Closure used in the Less method.
}

func (*JsonPublicMemberSorter) Len

func (s *JsonPublicMemberSorter) Len() int

Len is part of sort.Interface.

func (*JsonPublicMemberSorter) Less

func (s *JsonPublicMemberSorter) Less(i, j int) bool

Less is part of sort.Interface. It is implemented by calling the "by" closure in the sorter.

func (*JsonPublicMemberSorter) Swap

func (s *JsonPublicMemberSorter) Swap(i, j int)

Swap is part of sort.Interface.

type Member

type Member struct {
	MemberBase
	Id string `json:"id"`
}

func NewMember

func NewMember(m *MemberArg) (*Member, error)

type MemberArg

type MemberArg struct {
	Id         string
	Type       MemberType
	Name       string
	Device     string
	Email      string
	ValidUntil *time.Time
	Updated    *time.Time `json:"updated"`
	Created    *time.Time `json:"created"`
}

type MemberBase

type MemberBase struct {
	Type       MemberType `json:"type"`
	Name       string     `json:"name"`
	Email      string     `json:"email,omitempty"`
	Device     string     `json:"device,omitempty"`
	ValidUntil time.Time  `json:"validUntil"`
	Updated    time.Time  `json:"updated"`
	Created    time.Time  `json:"created"`
}

type MemberType

type MemberType string

type PrivateMember

type PrivateMember struct {
	Member
	PrivateKey key.PrivateKey
}

func Filter

func Filter(pkms []*PrivateMember, filters ...func(*PrivateMember) bool) []*PrivateMember

func FilterByType

func FilterByType(pkms []*PrivateMember, typs ...MemberType) []*PrivateMember

func JsToPrivateMember

func JsToPrivateMember(jspriv *JsonPrivateMember) (*PrivateMember, error)

func MakePrivateMember

func MakePrivateMember(pm *PrivateMemberArg) (*PrivateMember, error)

func (*PrivateMember) AsJSON

func (pm *PrivateMember) AsJSON() *JsonPrivateMember

func (*PrivateMember) Public

func (pm *PrivateMember) Public() *PublicMember

type PrivateMemberArg

type PrivateMemberArg struct {
	Member     MemberArg
	PrivateKey *key.PrivateKey
}

type PublicMember

type PublicMember struct {
	Member
	PublicKey key.PublicKey
}

func JsToPublicMember

func JsToPublicMember(jspub *JsonPublicMember) (*PublicMember, error)

func MakePublicMember

func MakePublicMember(pm *PublicMember) (*PublicMember, error)

func (*PublicMember) AsJSON

func (pm *PublicMember) AsJSON() *JsonPublicMember

type PublicMemberClaim

type PublicMemberClaim struct {
	JsonPublicMember
	jwt.StandardClaims
}

func VerifyJWT

func VerifyJWT(pk *key.PrivateKey, tknStr string) (*PublicMemberClaim, *jwt.Token, error)

Jump to

Keyboard shortcuts

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