ariadne_identity_go

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 11 Imported by: 0

README

ariadneIdentityGo

Ariadne Signature Profile match and verify library written in go.

This is Ariadne Signature Profile match and verify library by go which implements Ariadne Signature Profile v0

Implementation for each service provider refer toAvailable claims/proofs

!!! Most service providers are not implemented now !!!

!!!This library is not stabilize now !!!

Example

if you just need simple match and verify, you can use this library like this.

Claims:=[]spec.Claim{
    spec.NewClaim("claim1"),
    spec.NewClaim("claim2"),
    ...
}
fingerPrint:="aspe:..."
Cmrs:=ariadne_identity_go.MakeClaimsMatcher()(Claims)
Crs:=ariadne_identity_go.MakeClaimVerifier(spec.Proxys{
    ...//proxys,see documentation.
})(Cmrs,fingerPrint)
//Crs is []spec.ClaimResult

if you use "github.com/samber/mo","github.com/samber/lo",you can use this library like this, so that you can solve match and verify error by yourself.

Claims := []spec.Claim{
	spec.NewClaim("https://..."),
	spec.NewClaim("https://..."),
    ...
}
fingerPrint := "aspe:..."
CmrR := ariadne_identity_go.MakeClaimsMatcherR()(Claims)
Cmrs := lo.Map(lo.Filter(CmrR, func(cmrR mo.Result[spec.ClaimMatchResult], _ int) bool {
	if cmrR.IsError() {
		fmt.Printf("Error: %v\n", cmrR.Error())
	}
	return cmrR.IsOk() 
}), func(cmrr mo.Result[spec.ClaimMatchResult], _ int) spec.ClaimMatchResult {
	return cmrr.MustGet()
})
CrR := ariadne_identity_go.MakeClaimVerifierR(spec.Proxys{
    ...//proxys,see documentation.
})(Cmrs, fingerPrint)
Crs := lo.Map(lo.Filter(CrR, func(crR mo.Result[spec.ClaimResult], _ int) bool {
	if crR.IsError() {
		fmt.Printf("Error: %v\n", crR.Error())
	}
	return crR.IsOk() 
}), func(crr mo.Result[spec.ClaimResult], _ int) spec.ClaimResult {
	return crr.MustGet()
})
for _, cr := range Crs {
	j, _ := json.Marshal(cr)
	fmt.Println(string(j))
}
//Crs is []spec.ClaimResult

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServiceProviders = map[string]Spec.ServiceProvider{
	"github":  serviceproviders.Github,
	"forgejo": serviceproviders.Forgejo,
	"misskey": serviceproviders.Misskey,
	"dns":     serviceproviders.Dns,
}

ServiceProviders is a list of usable service providers, see the documentation for details.

Functions

func MakeClaimVerifier

func MakeClaimVerifier(P Spec.Proxys) func(C []Spec.ClaimMatchResult, uf string) []Spec.ClaimResult

MakeClaimVerifier returns a function that takes a list of claim match results and a user id and returns a list of claim results as []spec.ClaimResult,you can't get the verify error.

func MakeClaimVerifierR

func MakeClaimVerifierR(P Spec.Proxys) func(C []Spec.ClaimMatchResult, uf string) []mo.Result[Spec.ClaimResult]

MakeClaimVerifierR returns a function that takes a list of claim match results and a user id and returns a list of claim results as []mo.Result[Spec.ClaimResult].

func MakeClaimsMatcher

func MakeClaimsMatcher() func(C []Spec.Claim) []Spec.ClaimMatchResult

MakeClaimsMatcher returns a function that takes a list of claims and returns a list of claim match results as []spec.ClaimMatchResult,you can't get the match error.

func MakeClaimsMatcherR

func MakeClaimsMatcherR() func(C []Spec.Claim) []mo.Result[Spec.ClaimMatchResult]

MakeClaimsMatcherR returns a function that takes a list of claims and returns a list of claim match results as []mo.Result[Spec.ClaimMatchResult].

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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