utils

package
v0.6.26-beta.10 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Minimum length of base colon separated DID
	MIN_BASE_PART_LENGTH = 3

	// Maximum length of base colon separated DID
	MAX_BASE_PART_LENGTH = 4

	// Minimum length of method specific ID
	ChallengeLength = 32
)

Variables

View Source
var (
	ErrBaseNotFound              = errors.New("Unable to determine base did of provided string.")
	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.")
	DidForbiddenSymbolsRegexp, _ = regexp.Compile(`^[^&\\]+$`)
)

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 ContainsFragment

func ContainsFragment(didUrl string) bool

ContainsFragment checks if a DID has a fragment in the full string

func ContainsModule

func ContainsModule(didUrl string) bool

ContainsModule checks if a core service module is present in the DID

func ContainsPath

func ContainsPath(didUrl string) bool

ContainsPath returns true if a DID has a path in the full string

func ContainsQuery

func ContainsQuery(didUrl string) bool

ContainsQuery checks if a DID has a query in the full string

func ContainsString

func ContainsString(s string, t string) bool

ContainsString returns true if this string contains target string

func ConvertAccAddressToDid

func ConvertAccAddressToDid(address interface{}) string

WARNING: This method is used only for module simulation tests. Do not implement this method across different types in the package. ConvertAccAddressToDid converts an AccAddress to a DID

func ConvertDidToAccAddress

func ConvertDidToAccAddress(did string) (sdk.AccAddress, error)

WARNING: This method is used only for module simulation tests. Do not implement this method across different types in the package. ConvertDidToAccAddress converts a DID to an AccAddress

func CreateChallenge

func CreateChallenge() (challenge protocol.URLEncodedBase64, err error)

CreateChallenge creates a new challenge that should be signed and returned by the authenticator. The spec recommends using at least 16 bytes with 100 bits of entropy. We use 32 bytes.

func ExtractBase

func ExtractBase(did string) (bool, string)

ExtractBase extracts the did base (did:snr:<network>:<address>) or (did:snr:address)

func ExtractFragment

func ExtractFragment(didUrl string) (bool, string)

ExtractFragment splits a DID URL and pulls the fragment

func ExtractIdentifier

func ExtractIdentifier(did string) (bool, string)

ExtractIdentifier extracts the identifier from a DID

func ExtractPath

func ExtractPath(didUrl string) (bool, string)

ExtractPath splits a DID URL and pulls the path

func ExtractQuery

func ExtractQuery(didUrl string) (bool, string)

ExtractQuery splits a DID URL and pulls the query

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 IndexOf

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

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

func IsFragment

func IsFragment(didUrl string) bool

IsFragment checks if a DID fragment is valid

func IsPath

func IsPath(didUrl string) bool

IsPath returns true if a DID has a path in the full string

func IsQuery

func IsQuery(didUrl string) bool

IsQuery checks if a DID query is valid

func IsValidDid

func IsValidDid(did string) bool

IsValidDid checks if a DID is valid

func MakeCredentialFromAssertionData

func MakeCredentialFromAssertionData(c *protocol.ParsedCredentialAssertionData) *types.WebauthnCredential

MakeCredentialFromAssertionData creates a new WebauthnCredential from a ParsedCredentialAssertionData and contains all needed information about a WebAuthn credential for storage. This is then used to create a VerificationMethod for the DID Document.

func MakeCredentialFromCreationData

func MakeCredentialFromCreationData(c *protocol.ParsedCredentialCreationData) *types.WebauthnCredential

MakeCredentialFromCreationData creates a new WebauthnCredential from a ParsedCredentialCreationData and contains all needed information about a WebAuthn credential for storage. This is then used to create a VerificationMethod for the DID Document.

func ToFragment

func ToFragment(str string) string

func ToIdentifier

func ToIdentifier(str string) string

func ToNetwork

func ToNetwork(str string) string

func ToQuery

func ToQuery(str string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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