util

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKeyJwk       = "PublicKeyJwk"
	PublicKeyMultibase = "PublicKeyMultibase"
)

Variables

View Source
var (
	ErrFragmentAndQuery = errors.New("Unable to create new DID. Fragment and Query are mutually exclusive")
	ErrParseInvalid     = errors.New("Unable to parse string into DID, invalid format.")
)
View Source
var (
	ErrParentDirNotExists = errors.New("FileItem's Parent Directory does not exist")
	ErrEmptyData          = errors.New("Passed Buffer is Empty")
)
View Source
var DidForbiddenSymbolsRegexp, _ = regexp.Compile(`^[^&\\]+$`)
View Source
var ValidNetworkPrefixes = []string{
	"mainnet",
	"testnet",
	"devnet",
}
View Source
var VerificationMethodType = map[string]string{
	"JsonWebKey2020":             PublicKeyJwk,
	"Ed25519VerificationKey2020": PublicKeyMultibase,
}

Functions

func Complement

func Complement(vs []string, ts []string) []string

Complement returns a new slice containing all strings from the slice that do not satisfy the predicate

func Contains

func Contains(vs []string, t string) bool

Contains returns true if the string is in the slice

func DefaultUrlMIME

func DefaultUrlMIME() *types.MIME

** ─────────────────────────────────────────────────────── ** ─── MIME Management ─────────────────────────────────── ** ─────────────────────────────────────────────────────── DefaultUrlMIME is the standard MIME type for URLs

func Ext

func Ext(m *types.MIME) string

Ext Method adjusts extension for JPEG

func FileCount

func FileCount(p *types.Payload) int

FileCount returns the number of files in the Payload

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter returns a new slice containing all strings from the slice that satisfy the predicate

func GetNativeType

func GetNativeType(el *pb.ECGroupElement) *ec.GroupElement

func GetNativeTypeFromCredReq

func GetNativeTypeFromCredReq(r *pb.CLCredReq) (*cl.CredRequest, error)

func GetNativeTypeFromCredential

func GetNativeTypeFromCredential(c *pb.CLCredential) (*cl.Cred, *qr.RepresentationProof, error)

func GetNativeTypeFromPair

func GetNativeTypeFromPair(el *pb.Pair) *common.Pair

func GetNativeTypeFromProveCredential

func GetNativeTypeFromProveCredential(p *pb.ProveCLCredential) (*big.Int, *qr.RepresentationProof, []*big.Int,
	[]*big.Int, []int, []int, error)

func GetNativeTypeFromUpdateCredential

func GetNativeTypeFromUpdateCredential(u *pb.UpdateCLCredential) (*big.Int, *big.Int, []*big.Int)

func GetVerificationMethodType

func GetVerificationMethodType(vmType string) string

GetVerificationMethodType returns the verification method type

Header returns the header of the FileItem

func IndexOf

func IndexOf(vs []string, t string) int

IndexOf returns the index of the first instance of a value in a slice

func IsAudio

func IsAudio(m *types.MIME) bool

IsAudio Checks if Mime is Audio

func IsDidFragment

func IsDidFragment(prefix string, didUrl string) bool

IsDidFragment checks if a DID fragment is valid

func IsFile

func IsFile(m *types.MIME) bool

IsFile Checks if Path is a File

func IsFullDidFragment

func IsFullDidFragment(prefix string, didUrl string) bool

IsFullDidFragment checks if a DID fragment is for full string

func IsImage

func IsImage(m *types.MIME) bool

IsImage Checks if Mime is Image

func IsMedia

func IsMedia(m *types.MIME) bool

IsMedia Checks if Mime is any media

func IsMultiple

func IsMultiple(p *types.Payload) (bool, error)

IsMultiple returns true if the transfer is a multiple transfer. Error returned if No Items present in Payload

func IsNotValidDIDArray

func IsNotValidDIDArray(prefix string, array []string) (bool, int)

IsNotValidDIDArray checks if a DID array is invalid

func IsNotValidDIDArrayFragment

func IsNotValidDIDArrayFragment(prefix string, array []string) (bool, int)

IsNotValidDIDArrayFragment checks if a DID array is invalid

func IsPDF

func IsPDF(m *types.MIME) bool

IsPDF Checks if Mime is PDF

func IsSingle

func IsSingle(p *types.Payload) (bool, error)

IsSingle returns true if the transfer is a single transfer. Error returned if No Items present in Payload

func IsUrl

func IsUrl(m *types.MIME) bool

IsUrl Checks if Path is a URL

func IsValidDid

func IsValidDid(prefix string, did string) bool

IsValidDid checks if a DID is valid

func IsValidNetworkPrefix

func IsValidNetworkPrefix(prefix string) bool

func IsVideo

func IsVideo(m *types.MIME) bool

IsVideo Checks if Mime is Video

func Libp2pID

func Libp2pID(p *types.Peer) (peer.ID, error)

Libp2pID returns the PeerID based on PublicKey from Profile

func NewFileItem

func NewFileItem(path string, tbuf []byte) (*types.Payload_Item, error)

NewFileItem creates a new transfer file item

func NewMime

func NewMime(path string) (*types.MIME, error)

NewMime creates a new MIME type from Path

func NewThumbnail

func NewThumbnail(path string, tbuf []byte, mime *types.MIME, ch chan *types.Thumbnail)

NewThumbnail creates a new thumbnail for the given file

func OLC

func OLC(l *types.Location) string

OLC returns Open Location code

func OS

func OS(p *types.Peer) string

OS returns Peer Device GOOS

func PermitsThumbnail

func PermitsThumbnail(m *types.MIME) bool

PermitsThumbnail Checks if Mime Type Allows Thumbnail Generation. Image, Video, Audio, and PDF are allowed.

func PubKey

func PubKey(p *types.Peer) (crypto.PubKey, error)

PubKey returns the Public Key from the Peer

func SetPathFromFolder

func SetPathFromFolder(f *types.FileItem, folder config.Folder) (string, error)

SetPathFromFolder sets the path of the FileItem

func SplitDidUrlIntoDidAndFragment

func SplitDidUrlIntoDidAndFragment(didUrl string) (string, string)

SplitDidUrlIntoDidAndFragment splits a DID URL into DID and fragment

func ToPbCLCredential

func ToPbCLCredential(c *cl.Cred, AProof *qr.RepresentationProof) *pb.CLCredential

func ToPbCredRequest

func ToPbCredRequest(r *cl.CredRequest) *pb.CLCredReq

func ToPbECGroupElement

func ToPbECGroupElement(el *ec.GroupElement) *pb.ECGroupElement

func ToPbPair

func ToPbPair(el *common.Pair) *pb.Pair

func ToPbProveCLCredential

func ToPbProveCLCredential(A *big.Int, proof *qr.RepresentationProof,
	knownAttrs, commitmentsOfAttrs []*big.Int,
	revealedKnownAttrsIndices, revealedCommitmentsOfAttrsIndices []int) *pb.ProveCLCredential

func ToPbUpdateCLCredential

func ToPbUpdateCLCredential(nym, nonce *big.Int, newKnownAttrs []*big.Int) *pb.UpdateCLCredential

func ToTransferItem

func ToTransferItem(f *types.FileItem) *types.Payload_Item

ToTransferItem Returns Transfer for FileItem

func URLCount

func URLCount(p *types.Payload) int

URLCount returns the number of URLs in the Payload

Types

type ClientStream

type ClientStream interface {
	Send(*pb.ZkMessage) error
	Recv() (*pb.ZkMessage, error)
	grpc.ClientStream
}

ClientStream is an interface that fits all the auto-generated client stream interfaces declared within this package.

type GetProfileFunc

type GetProfileFunc func() (*types.Profile, error)

GetProfileFunc returns a function that returns the Profile and error

type PayloadItemFunc

type PayloadItemFunc func(item *types.Payload_Item, index int, total int) error

** ─────────────────────────────────────────────────────── ** ─── Payload Management ──────────────────────────────── ** ─────────────────────────────────────────────────────── PayloadItemFunc is the Map function for PayloadItem

type PbConvertibleType

type PbConvertibleType interface {
	GetNativeType() interface{}
}

type ServerStream

type ServerStream interface {
	Send(*pb.ZkMessage) error
	Recv() (*pb.ZkMessage, error)
	grpc.ServerStream
}

ServerStream is an interface that fits all the auto-generated server stream interfaces declared within this package.

Jump to

Keyboard shortcuts

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