fact

package
v0.0.0-...-96bc9f9 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const FactAccountId = "account_id"
View Source
const FactAddress = "address"
View Source
const FactCountryOfIssuance = "country_of_issuance"
View Source
const FactDateOfBirth = "date_of_birth"
View Source
const FactDateOfExpiration = "date_of_expiration"
View Source
const FactDateOfIssuance = "date_of_issuance"
View Source
const FactDisplayName = "display_name"
View Source
const FactDocumentNumber = "document_number"
View Source
const FactEmailAddress = "email_address"
View Source
const FactGivenNames = "given_names"
View Source
const FactIssuingAuthority = "issuing_authority"
View Source
const FactLocation = "location"
View Source
const FactNationality = "nationality"
View Source
const FactNickname = "nickname"
View Source
const FactPhoto = "photo"
View Source
const FactPlaceOfBirth = "place_of_birth"
View Source
const FactSelfieVerification = "selfie_verification"
View Source
const FactSex = "sex"
View Source
const FactSurname = "surname"
View Source
const FactUnverifiedPhoneNumber = "unverified_phone_number"
View Source
const SourceDrivingLicense = "driving_license"
View Source
const SourceFacebook = "facebook"
View Source
const SourceIdentityCard = "identity_card"
View Source
const SourceLinkedin = "linkedin"
View Source
const SourceLive = "live"
View Source
const SourcePassport = "passport"
View Source
const SourceTwitter = "twitter"
View Source
const SourceUserSpecified = "user_specified"

Variables

View Source
var (
	OperatorEqual              = "=="
	OperatorDifferent          = "!="
	OperatorGreaterOrEqualThan = ">="
	OperatorLessOrEqualThan    = "<="
	OperatorGreaterThan        = ">"
	OperatorLessThan           = "<"

	RequestInformation  = "identities.facts.query.req"
	ResponseInformation = "identities.facts.query.resp"

	StatusAccepted     = "accepted"
	StatusRejected     = "rejected"
	StatusUnauthorized = "unauthorized"

	ErrFactEmptyName           = errors.New("provided fact does not specify a name")
	ErrFactBadSource           = errors.New("fact must specify one source")
	ErrFactInvalidSource       = errors.New("provided fact does not specify a valid source")
	ErrFactInvalidOperator     = errors.New("provided fact does not specify a valid operator")
	ErrFactInvalidFactToSource = errors.New("provided source does not support given fact")
	ErrInvalidSourceSpec       = errors.New("internal error : invalid source spec")
)
View Source
var (
	ErrBadJSONPayload               = errors.New("bad json payload")
	ErrResponseBadSignature         = errors.New("bad response signature")
	ErrRequestTimeout               = errors.New("request timeout")
	ErrMessageBadIssuer             = errors.New("bad response issuer")
	ErrMessageBadSubject            = errors.New("bad response subject")
	ErrMessageBadAudience           = errors.New("bad response audience")
	ErrMessageBadStatus             = errors.New("bad response status")
	ErrMessageExpired               = errors.New("response has expired")
	ErrMessageIssuedTooSoon         = errors.New("response was issued in the future")
	ErrStatusRejected               = errors.New("fact request was rejected")
	ErrStatusUnauthorized           = errors.New("you are not authorized to interact with this user")
	ErrFactRequestBadIdentity       = errors.New("fact request must specify a valid self id")
	ErrFactRequestBadFacts          = errors.New("fact request must specify one or more facts")
	ErrFactQRRequestBadConversation = errors.New("fact qr request must specify a valid conversation id")
	ErrFactQRRequestBadFacts        = errors.New("fact qr request must specify one or more facts")
	ErrFactResultMismatch           = errors.New("fact has differing attested values")
	ErrFactNotAttested              = errors.New("fact has attestations with empty or invalid values")
	ErrBadAttestationSubject        = errors.New("attestation is not related to the responder")
	ErrMissingConversationID        = errors.New("deep link request must specify a unique conversation id")
	ErrMissingCallback              = errors.New("deep link request must specify a callback url")
	ErrFactRequestCID               = errors.New("cid not provided")
	ErrSigningKeyInvalid            = errors.New("signing key was invalid at the time the attestation was issued")
	ErrNotConnected                 = errors.New("you're not permitting connections from the specifed recipient")
	ErrNotEnoughCredits             = errors.New("your credits have expired, please log in to the developer portal and top up your account")
	ErrEmptyFacts                   = errors.New("facts not provided")
	ErrEmptySource                  = errors.New("empty source provided")

	ServiceSelfIntermediary = "self_intermediary"
)

Functions

This section is empty.

Types

type Config

type Config struct {
	SelfID         string
	DeviceID       string
	KeyID          string
	Environment    string
	PrivateKey     ed25519.PrivateKey
	Rest           restTransport
	PKI            pkiClient
	Messaging      messagingClient
	FileInteractor *object.RemoteFileInteractor
}

Config stores all configuration needed by the fact service

type DeepLinkFactRequest

type DeepLinkFactRequest struct {
	ConversationID string
	Description    string
	Callback       string
	Facts          []Fact
	Expiry         time.Duration
	Auth           bool
}

DeepLinkFactRequest contains the details of the requested facts

type Delegation

type Delegation struct {
	Subjects    []string `json:"subjects"`
	Actions     []string `json:"actions"`
	Effect      string   `json:"effect"`
	Resources   []string `json:"resources"`
	Conditions  []string `json:"conditions"`
	Description string   `json:"description, omitempty"`
}

func ParseDelegationCertificate

func ParseDelegationCertificate(input string) (*Delegation, error)

func (*Delegation) Encode

func (d *Delegation) Encode() (string, error)

type Fact

type Fact struct {
	Fact          string            `json:"fact"`
	Sources       []string          `json:"sources,omitempty"`
	Origin        string            `json:"iss,omitempty"`
	Operator      string            `json:"operator,omitempty"`
	Attestations  []json.RawMessage `json:"attestations,omitempty"`
	Issuers       []string          `json:"issuers,omitempty"`
	ExpectedValue string            `json:"expected_value,omitempty"`
	AttestedValue string            `json:"-"`
	// contains filtered or unexported fields
}

Fact specific details about the fact

func (*Fact) AttestedValues

func (f *Fact) AttestedValues() []string

AttestedValues returns all attested values for an attestations

func (*Fact) Result

func (f *Fact) Result() bool

Result the result returned from an intermediary request This will return true if all of the expectations were met

type FactGroup

type FactGroup struct {
	Name string `json:"name"`
	Icon string `json:"icon"`
}

type FactRequest

type FactRequest struct {
	SelfID      string
	Description string
	Facts       []Fact
	Expiry      time.Duration
	AllowedFor  time.Duration
	Callback    json.RawMessage
	Auth        bool
}

FactRequest specifies the parameters of an information request

type FactRequestAsync

type FactRequestAsync struct {
	SelfID      string
	Description string
	Facts       []Fact
	Expiry      time.Duration
	AllowedFor  time.Duration
	CID         string
	Callback    json.RawMessage
	Auth        bool
}

FactRequestAsync specifies the parameters of an information requestAsync

type FactResponse

type FactResponse struct {
	Status string
	Facts  []Fact
}

FactResponse contains the details of the requested facts

type FactToIssue

type FactToIssue struct {
	Key        string         `json:"key"`
	Value      string         `json:"value"`
	Source     string         `json:"-"`
	Group      *FactGroup     `json:"group,omitempty"`
	Type       string         `json:"type,omitempty"`
	ExpTimeout *time.Duration `json:"-"`
}

type IntermediaryFactRequest

type IntermediaryFactRequest struct {
	SelfID       string
	Description  string
	Intermediary string
	Facts        []Fact
	Expiry       time.Duration
}

IntermediaryFactRequest specifies the paramters on an information request via an intermediary

type IntermediaryFactResponse

type IntermediaryFactResponse struct {
	Facts []Fact
}

IntermediaryFactResponse contains the details of the requested facts

type QRConfig

type QRConfig struct {
	Size            int
	ForegroundColor string
	BackgroundColor string
}

type QRFactRequest

type QRFactRequest struct {
	ConversationID string
	Description    string
	Facts          []Fact
	Options        map[string]string
	Expiry         time.Duration
	QRConfig       QRConfig
	Auth           bool
}

QRFactRequest contains the details of the requested facts

type QRFactResponse

type QRFactResponse struct {
	Responder      string
	Facts          []Fact
	Options        map[string]string
	Accepted       bool
	ConversationID string
	DeviceID       string
}

QRFactResponse contains the details of the requested facts

type Service

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

Service handles all fact operations

func NewService

func NewService(cfg Config) *Service

NewService creates a new client for interacting with facts

func (Service) Attest

func (s Service) Attest(selfID string, facts []Fact) ([]json.RawMessage, error)

Attest creates an attested fact about a self identity

func (*Service) FactResponse

func (s *Service) FactResponse(issuer, subject string, response []byte) ([]Fact, error)

FactResponse validate and process a fact response

func (s Service) GenerateDeepLink(req *DeepLinkFactRequest) (string, error)

GenerateDeepLink generates a qr code containing an fact request

func (Service) GenerateQRCode

func (s Service) GenerateQRCode(req *QRFactRequest) ([]byte, error)

GenerateQRCode generates a qr code containing an fact request

func (*Service) Issue

func (s *Service) Issue(selfID string, facts []FactToIssue, viewers []string) error

Issues a fact to a specific user.

func (Service) Request

func (s Service) Request(req *FactRequest) (*FactResponse, error)

Request requests a fact from a given identity

func (Service) RequestAsync

func (s Service) RequestAsync(req *FactRequestAsync) error

RequestAsync requests a fact from a given identity and does not wait for the response

func (Service) RequestViaIntermediary

func (s Service) RequestViaIntermediary(req *IntermediaryFactRequest) (*IntermediaryFactResponse, error)

RequestViaIntermediary requests a fact from a given identity via a trusted intermediary. The intermediary verifies that the identity has a given fact and that it meets the requested requirements.

func (Service) Subscribe

func (s Service) Subscribe(auth bool, sub func(sender string, res *StandardResponse))

Subscribe subscribes to fact request responses

func (Service) WaitForResponse

func (s Service) WaitForResponse(cid string, exp time.Duration) (*QRFactResponse, error)

WaitForResponse waits for completion of a fact request that was initiated by qr code

type StandardResponse

type StandardResponse struct {
	ID           string    `json:"jti"`
	Type         string    `json:"typ"`
	Conversation string    `json:"cid"`
	Issuer       string    `json:"iss"`
	Audience     string    `json:"aud"`
	Subject      string    `json:"sub"`
	IssuedAt     time.Time `json:"iat"`
	ExpiresAt    time.Time `json:"exp"`
	DeviceID     string    `json:"device_id"`
	Status       string    `json:"status"`
	Description  string    `json:"description"`
	Facts        []Fact    `json:"facts"`
	Auth         bool      `json:"auth"`
}

Jump to

Keyboard shortcuts

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