resources

package
v0.0.1-rc9 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorize

type Authorize struct {
	Key
	Attributes AuthorizeAttributes `json:"attributes"`
}

type AuthorizeAttributes

type AuthorizeAttributes struct {
	Proof *Proof `json:"proof,omitempty"`
}

type AuthorizeListRequest

type AuthorizeListRequest struct {
	Data     []Authorize `json:"data"`
	Included Included    `json:"included"`
	Links    *Links      `json:"links"`
}

type AuthorizeRequest

type AuthorizeRequest struct {
	Data     Authorize `json:"data"`
	Included Included  `json:"included"`
}

type Claim

type Claim struct {
	// User group id authorized with
	Group *uuid.UUID `json:"group,omitempty"`
	// Organization DID authorized with
	Org string `json:"org"`
	// User role id authorized with
	Role uint32 `json:"role"`
	// User DID authorized with
	User string `json:"user"`
}

Authorized user personal data

type Details

type Details json.RawMessage

func (Details) MarshalJSON

func (d Details) MarshalJSON() ([]byte, error)

MarshalJSON - casts Details to []byte

func (*Details) Scan

func (r *Details) Scan(src interface{}) error

Scan - implements db driver method for auto unmarshal

func (Details) String

func (d Details) String() string

func (*Details) UnmarshalJSON

func (d *Details) UnmarshalJSON(data []byte) error

UnmarshalJSON - casts data to Details

func (Details) Value

func (r Details) Value() (driver.Value, error)

Value - implements db driver method for auto marshal

type Flag

type Flag struct {
	Name  string `json:"name"`
	Value int32  `json:"value"`
}

type Flagger

type Flagger interface {
	IsFlag() bool
}

type Flags

type Flags struct {
	Mask   int32  `json:"mask"`
	Values []Flag `json:"flags"`
}

func FlagsFromMask

func FlagsFromMask(mask int32, allFlags map[int32]string) Flags

type Included

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

Included - an array of Resource objects that are related to the primary data and/or each other (“included resources”).

func (*Included) Add

func (c *Included) Add(includes ...Resource)

Add - adds new include into collection. If one already present - skips it

func (Included) MarshalJSON

func (c Included) MarshalJSON() ([]byte, error)

MarshalJSON - marshals include collection as array of json objects

func (*Included) MustAuthorize

func (c *Included) MustAuthorize(key Key) *Authorize

MustAuthorize - returns Authorize from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustToken

func (c *Included) MustToken(key Key) *Token

MustToken - returns Token from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustValidationResult

func (c *Included) MustValidationResult(key Key) *ValidationResult

MustValidationResult - returns ValidationResult from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) UnmarshalJSON

func (c *Included) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshal array of json objects into include collection

type Jwt

type Jwt struct {
	// Base64 encoded JWT
	Token     string `json:"token"`
	TokenType string `json:"tokenType"`
}

JWT token

type Key

type Key struct {
	ID   string       `json:"id"`
	Type ResourceType `json:"type"`
}

func NewKeyInt64

func NewKeyInt64(id int64, resourceType ResourceType) Key

func (Key) AsRelation

func (r Key) AsRelation() *Relation

func (*Key) GetKey

func (r *Key) GetKey() Key

func (Key) GetKeyP

func (r Key) GetKeyP() *Key
type Links struct {
	First string `json:"first,omitempty"`
	Last  string `json:"last,omitempty"`
	Next  string `json:"next,omitempty"`
	Prev  string `json:"prev,omitempty"`
	Self  string `json:"self,omitempty"`
}

type Proof

type Proof struct {
	// Group identifier stored in credential
	Group *uuid.UUID `json:"group,omitempty"`
	// Issuer DID (organization DID)
	Issuer string `json:"issuer"`
	// JSON encoded ZK proof (MTPV2OffChain) the user own a credential with Hash(role, groups). If group is not provided then Hash(role).
	Proof json.RawMessage `json:"proof"`
	// User role stored in credential
	Role uint32 `json:"role"`
}

Auth proof

type Relation

type Relation struct {
	Data  *Key   `json:"data,omitempty"`
	Links *Links `json:"links,omitempty"`
}

type RelationCollection

type RelationCollection struct {
	Data  []Key  `json:"data"`
	Links *Links `json:"links,omitempty"`
}

func (RelationCollection) MarshalJSON

func (r RelationCollection) MarshalJSON() ([]byte, error)

type Resource

type Resource interface {
	//GetKey - returns key of the Resource
	GetKey() Key
}

type ResourceType

type ResourceType string
const (
	AUTHORIZE         ResourceType = "authorize"
	TOKEN             ResourceType = "token"
	VALIDATION_RESULT ResourceType = "validation-result"
)

List of ResourceType

type Token

type Token struct {
	Key
	Attributes TokenAttributes `json:"attributes"`
}

type TokenAttributes

type TokenAttributes struct {
	AccessToken  Jwt `json:"accessToken"`
	RefreshToken Jwt `json:"refreshToken"`
}

type TokenListResponse

type TokenListResponse struct {
	Data     []Token  `json:"data"`
	Included Included `json:"included"`
	Links    *Links   `json:"links"`
}

type TokenResponse

type TokenResponse struct {
	Data     Token    `json:"data"`
	Included Included `json:"included"`
}

type ValidationResult

type ValidationResult struct {
	Key
	Attributes ValidationResultAttributes `json:"attributes"`
}

type ValidationResultAttributes

type ValidationResultAttributes struct {
	Claims []Claim `json:"claims"`
}

type ValidationResultListResponse

type ValidationResultListResponse struct {
	Data     []ValidationResult `json:"data"`
	Included Included           `json:"included"`
	Links    *Links             `json:"links"`
}

type ValidationResultResponse

type ValidationResultResponse struct {
	Data     ValidationResult `json:"data"`
	Included Included         `json:"included"`
}

Jump to

Keyboard shortcuts

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