model

package
v0.0.0-...-4ff583b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DATA_FORMAT_JSON   = "application/json"
	DATA_FORMAT_VC_JWT = "application/vc+jwt"
	DATA_FORMAT_VC_LDP = "application/vc+ldp"
)
View Source
const (
	INTERFACE_RECORDS     = "Records"
	METHOD_RECORDS_QUERY  = "Query"
	METHOD_RECORDS_WRITE  = "Write"
	METHOD_RECORDS_COMMIT = "Commit"
	METHOD_RECORDS_DELETE = "Delete"

	INTERFACE_HOOKS     = "Hooks"
	METHOD_HOOKS_WRITE  = "Write"
	METHOD_HOOKS_QUERY  = "Query"
	METHOD_HOOKS_DELETE = "Delete"
)

Variables

View Source
var DescriptorSchemaType schema.Type

Functions

func CreateCIDFromNode

func CreateCIDFromNode(node datamodel.Node) cid.Cid

func CreateDataCID

func CreateDataCID(data string) string

func CreateDescriptorCID

func CreateDescriptorCID(descriptor Descriptor) string

See:

func CreateProcessingCID

func CreateProcessingCID(mp MessageProcessing) string

func CreateRecordCID

func CreateRecordCID(descriptorCID string, processingCID string) string

func ResolveDID

func ResolveDID(didToResolve string) (*didsdk.Document, error)

func VerifyAttestation

func VerifyAttestation(message *Message) bool

func VerifyAuthorization

func VerifyAuthorization(message *Message) bool

Types

type DWNJWS

type DWNJWS struct {
	Payload    string      `json:"payload" bson:"payload"`
	Signatures []DWNJWSSig `json:"signatures" bson:"signatures"`
}

func CreateAttestation

func CreateAttestation(message *Message, authKeyUri string, publicKey crypto.PublicKey, privateKey crypto.PrivateKey) DWNJWS

func CreateAuthorization

func CreateAuthorization(message *Message, authKeyUri string, publicKey crypto.PublicKey, privateKey crypto.PrivateKey) DWNJWS

type DWNJWSSig

type DWNJWSSig struct {
	Protected string `json:"protected" bson:"protected"`
	Signature string `json:"signature" bson:"signature"`
}

type Descriptor

type Descriptor struct {

	// Base Required Fields per https://identity.foundation/decentralized-web-node/spec/#messages
	Interface  string `json:"interface" bson:"interface"`
	Method     string `json:"method" bson:"method"`
	DataCID    string `json:"dataCid,omitempty" bson:"dataCID"`
	DataFormat string `json:"dataFormat,omitempty" bson:"dataFormat"`

	// CollectionsQuery, HooksWrite per https://identity.foundation/decentralized-web-node/spec/#collectionsquery, https://identity.foundation/decentralized-web-node/spec/#hooks
	Filter DescriptorFilter `json:"filter,omitempty"`

	// CollectionsWrite, Delete, Commit per https://identity.foundation/decentralized-web-node/spec/#collectionswrite
	ParentID        string  `json:"parentId,omitempty" bson:"parent_id"`
	Protocol        string  `json:"protocol,omitempty" bson:"protocol"`
	ProtocolVersion string  `json:"protocolVersion,omitempty" bson:"protocol_version"`
	Schema          string  `json:"schema,omitempty" bson:"schema"`
	CommitStrategy  string  `json:"commitStrategy,omitempty" bson:"commit_strategy"`
	Published       bool    `json:"published,omitempty" bson:"published"`
	DateCreated     string  `json:"dateCreated,omitempty" bson:"date_created"`
	DatePublished   *string `json:"datePublished,omitempty" bson:"date_published"`

	// HooksWrite per https://identity.foundation/decentralized-web-node/spec/#hooks
	URI string `json:"uri,omitempty" bson:"uri"`
}

type DescriptorFilter

type DescriptorFilter struct {
	Schema          string `json:"schema,omitempty"`
	RecordID        string `json:"recordId,omitempty"`
	ContextID       string `json:"contextId,omitempty"`
	Protocol        string `json:"protocol,omitempty"`
	ProtocolVersion string `json:"protocolVersion,omitempty"`
	DataFormat      string `json:"dataFormat,omitempty"`
	DateSort        string `json:"dateSort,omitempty"`
}

type FeatureDetection

type FeatureDetection struct {
	Type       string           `json:"type"`
	Interfaces FeatureInterface `json:"interfaces"`
}
var CurrentFeatureDetection FeatureDetection = FeatureDetection{
	Type: "FeatureDetection",
	Interfaces: FeatureInterface{
		Records: RecordsFeatures{
			RecordsQuery:  true,
			RecordsWrite:  true,
			RecordsCommit: true,
			RecordsDelete: true,
		},
		Hooks: HooksFeatures{
			HooksQuery:  true,
			HooksWrite:  true,
			HooksDelete: true,
		},
		Permissions: PermissionsFeatures{
			PermissionsRequest: true,
			PermissionsGrant:   true,
			PermissionsRevoke:  true,
		},
		Messaging: MessagingFeatures{
			Batching: true,
		},
		Protocols: ProtocolsFeatures{
			ProtocolsQuery:     true,
			ProtocolsConfigure: true,
		},
	},
}

type FeatureInterface

type FeatureInterface struct {
	Records     RecordsFeatures     `json:"records,omitempty"`
	Hooks       HooksFeatures       `json:"hooks,omitempty"`
	Permissions PermissionsFeatures `json:"permissions,omitempty"`
	Messaging   MessagingFeatures   `json:"messaging,omitempty"`
	Protocols   ProtocolsFeatures   `json:"protocols,omitempty"`
}

type HooksFeatures

type HooksFeatures struct {
	HooksQuery  bool `json:"HooksQuery"`
	HooksWrite  bool `json:"HooksWrite"`
	HooksDelete bool `json:"HooksDelete"`
}

type Message

type Message struct {
	RecordID      string            `json:"recordId,omitempty" bson:"record_id"`
	ContextID     string            `json:"contextId,omitempty" bson:"context_id"`
	Data          string            `json:"data,omitempty" bson:"data"`
	Processing    MessageProcessing `json:"processing" bson:"processing"`
	Descriptor    Descriptor        `json:"descriptor" bson:"descriptor"`
	Attestation   DWNJWS            `json:"attestation,omitempty" bson:"attestation"`
	Authorization DWNJWS            `json:"authorization,omitempty" bson:"authorization"`
}

func CreateInitialRecordsWriteMessage

func CreateInitialRecordsWriteMessage(authorDID string, recipientDID string, protocolDef *ProtocolDefinition, schema string, dataFormat string, data []byte) *Message

func CreateMessage

func CreateMessage(authorDID string, recipientDID string, dataFormat string, data []byte, interfaceName string, methodName string, recordId string, schema string) *Message

func CreateQueryRecordsMessage

func CreateQueryRecordsMessage(schemaUri string, recordId string, protocolDef *ProtocolDefinition, requestorDID string) *Message

func CreateRecordsCommitMessage

func CreateRecordsCommitMessage(logicalRecordId string, schemaUrl string, committerDID string) *Message

func CreateUpdateRecordsWriteMessage

func CreateUpdateRecordsWriteMessage(authorDID string, recipientDID string, logicalRecordId string, protocolDef *ProtocolDefinition, schemaUri string, dataFormat string, data []byte) *Message

type MessageProcessing

type MessageProcessing struct {
	Nonce        string `json:"nonce" bson:"nonce"`
	AuthorDID    string `json:"author" bson:"author_did"`
	RecipientDID string `json:"recipient" bson:"recipient_did"`
}

type MessageResultEntry

type MessageResultEntry struct {
	Result []byte `json:"result"`
}

type MessageResultObject

type MessageResultObject struct {
	Status  ResponseStatus       `json:"status"`
	Entries []MessageResultEntry `json:"entries"`
}

type MessagingFeatures

type MessagingFeatures struct {
	Batching bool `json:"batching"`
}

type PermissionsFeatures

type PermissionsFeatures struct {
	PermissionsRequest bool `json:"PermissionsRequest"`
	PermissionsGrant   bool `json:"PermissionsGrant"`
	PermissionsRevoke  bool `json:"PermissionsRevoke"`
}

type ProtocolDefinition

type ProtocolDefinition struct {
	ContextID       string
	Protocol        string
	ProtocolVersion string
}

type ProtocolsFeatures

type ProtocolsFeatures struct {
	ProtocolsQuery     bool `json:"ProtocolsQuery"`
	ProtocolsConfigure bool `json:"ProtocolsConfigure"`
}

type RecordsFeatures

type RecordsFeatures struct {
	RecordsQuery  bool `json:"RecordsQuery"`
	RecordsWrite  bool `json:"RecordsWrite"`
	RecordsCommit bool `json:"RecordsCommit"`
	RecordsDelete bool `json:"RecordsDelete"`
}

type RequestObject

type RequestObject struct {
	Messages []Message `json:"messages"`
}

type ResponseObject

type ResponseObject struct {
	Status  ResponseStatus        `json:"status"`
	Replies []MessageResultObject `json:"replies"`
}

type ResponseStatus

type ResponseStatus struct {
	Code   int    `json:"code"`
	Detail string `json:"detail"`
}

Jump to

Keyboard shortcuts

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