v1

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 23 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// PublicKeyReferrerType is the type for PublicKey referrers.
	PublicKeyReferrerType = "agntcy.dir.sign.v1.PublicKey"

	// SignatureReferrerType is the type for Signature referrers.
	SignatureReferrerType = "agntcy.dir.sign.v1.Signature"
)

Referrer type constants for the high-level Dir Store API.

View Source
const (

	// DefaultValidationTimeout is the default timeout for API-based validation HTTP calls.
	// This ensures validation doesn't block indefinitely if the OASF server is slow or unreachable.
	DefaultValidationTimeout = 30 * time.Second
)

Variables

View Source
var File_agntcy_dir_core_v1_record_proto protoreflect.FileDescriptor

Functions

func CalculateDigest

func CalculateDigest(data []byte) (ocidigest.Digest, error)

CalculateDigest calculates a SHA2-256 digest from raw bytes. This is used as a fallback when oras.PushBytes is not available.

func ConvertCIDToDigest

func ConvertCIDToDigest(cidString string) (ocidigest.Digest, error)

ConvertCIDToDigest converts a CID string to an OCI digest. This is the reverse of ConvertDigestToCID.

func ConvertDigestToCID

func ConvertDigestToCID(digest ocidigest.Digest) (string, error)

ConvertDigestToCID converts an OCI digest to a CID string. Uses the same CID parameters as the original Record.GetCid(): CIDv1, codec 1, SHA2-256.

func InitializeValidator added in v1.0.0

func InitializeValidator(schemaURL string) error

InitializeValidator initializes the OASF validator with the given schema URL.

func IsValidCID

func IsValidCID(cidString string) bool

IsValidCID validates a CID string.

Types

type DecodedRecord

type DecodedRecord interface {
	// GetRecord returns the underlying record data, which can be of supported type.
	GetRecord() any

	// HasV1Alpha1 checks if the record is of type V1Alpha1.
	HasV1Alpha1() bool
	GetV1Alpha1() *typesv1alpha1.Record

	// HasV1Alpha2 checks if the record is of type V1Alpha2.
	HasV1Alpha2() bool
	GetV1Alpha2() *typesv1alpha2.Record

	// HasV1 checks if the record is of type V1 (OASF 1.0.0).
	HasV1() bool
	GetV1() *typesv1.Record
}

DecodedRecord is an interface representing a decoded OASF record. It provides methods to access the underlying record data.

type NamedRecordRef added in v1.0.0

type NamedRecordRef struct {

	// The name of the record.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The version of the record.
	Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	// The CID of the record.
	Cid string `protobuf:"bytes,3,opt,name=cid,proto3" json:"cid,omitempty"`
	// contains filtered or unexported fields
}

Represents a named reference to a Record with version information.

func (*NamedRecordRef) Descriptor deprecated added in v1.0.0

func (*NamedRecordRef) Descriptor() ([]byte, []int)

Deprecated: Use NamedRecordRef.ProtoReflect.Descriptor instead.

func (*NamedRecordRef) GetCid added in v1.0.0

func (x *NamedRecordRef) GetCid() string

func (*NamedRecordRef) GetName added in v1.0.0

func (x *NamedRecordRef) GetName() string

func (*NamedRecordRef) GetVersion added in v1.0.0

func (x *NamedRecordRef) GetVersion() string

func (*NamedRecordRef) ProtoMessage added in v1.0.0

func (*NamedRecordRef) ProtoMessage()

func (*NamedRecordRef) ProtoReflect added in v1.0.0

func (x *NamedRecordRef) ProtoReflect() protoreflect.Message

func (*NamedRecordRef) Reset added in v1.0.0

func (x *NamedRecordRef) Reset()

func (*NamedRecordRef) String added in v1.0.0

func (x *NamedRecordRef) String() string

type Record

type Record struct {
	Data *structpb.Struct `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

Record is a generic object that encapsulates data of different Record types.

Supported schemas:

v0.7.0: https://schema.oasf.outshift.com/0.7.0/objects/record v0.8.0: https://schema.oasf.outshift.com/0.8.0/objects/record v1.0.0: https://schema.oasf.outshift.com/1.0.0/objects/record

func New

New creates a Record for a supported OASF typed record.

func UnmarshalRecord

func UnmarshalRecord(data []byte) (*Record, error)

UnmarshalRecord unmarshals canonical Record JSON bytes to a Record.

func (*Record) Decode

func (r *Record) Decode() (DecodedRecord, error)

Decode decodes the Record's data into a concrete type using the OASF SDK.

func (*Record) Descriptor deprecated

func (*Record) Descriptor() ([]byte, []int)

Deprecated: Use Record.ProtoReflect.Descriptor instead.

func (*Record) GetCid

func (r *Record) GetCid() string

GetCid calculates and returns the CID for this record. The CID is calculated from the record's content using CIDv1, codec 1, SHA2-256. Uses canonical JSON marshaling to ensure consistent, cross-language compatible results. Returns empty string if calculation fails.

func (*Record) GetData

func (x *Record) GetData() *structpb.Struct

func (*Record) GetSchemaVersion

func (r *Record) GetSchemaVersion() string

func (*Record) Marshal

func (r *Record) Marshal() ([]byte, error)

Marshal marshals the Record using canonical JSON serialization. This ensures deterministic, cross-language compatible byte representation. The output represents the pure Record data and is used for both CID calculation and storage.

func (*Record) ProtoMessage

func (*Record) ProtoMessage()

func (*Record) ProtoReflect

func (x *Record) ProtoReflect() protoreflect.Message

func (*Record) Reset

func (x *Record) Reset()

func (*Record) String

func (x *Record) String() string

func (*Record) Validate

func (r *Record) Validate(ctx context.Context) (bool, []string, error)

Validate validates the Record's data using the OASF SDK. The validator must be initialized with InitializeValidator before calling this method.

type RecordMeta

type RecordMeta struct {

	// CID of the record.
	Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"`
	// Annotations attached to the record.
	Annotations map[string]string `` /* 149-byte string literal not displayed */
	// Schema version of the record.
	SchemaVersion string `protobuf:"bytes,3,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"`
	// Creation timestamp of the record in the RFC3339 format.
	// Specs: https://www.rfc-editor.org/rfc/rfc3339.html
	CreatedAt string `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// contains filtered or unexported fields
}

Defines metadata about a record.

func (*RecordMeta) Descriptor deprecated

func (*RecordMeta) Descriptor() ([]byte, []int)

Deprecated: Use RecordMeta.ProtoReflect.Descriptor instead.

func (*RecordMeta) GetAnnotations

func (x *RecordMeta) GetAnnotations() map[string]string

func (*RecordMeta) GetCid

func (x *RecordMeta) GetCid() string

func (*RecordMeta) GetCreatedAt

func (x *RecordMeta) GetCreatedAt() string

func (*RecordMeta) GetSchemaVersion

func (x *RecordMeta) GetSchemaVersion() string

func (*RecordMeta) ProtoMessage

func (*RecordMeta) ProtoMessage()

func (*RecordMeta) ProtoReflect

func (x *RecordMeta) ProtoReflect() protoreflect.Message

func (*RecordMeta) Reset

func (x *RecordMeta) Reset()

func (*RecordMeta) String

func (x *RecordMeta) String() string

type RecordRef

type RecordRef struct {

	// Globally-unique content identifier (CID) of the record.
	// Specs: https://github.com/multiformats/cid
	Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"`
	// contains filtered or unexported fields
}

Defines a reference or a globally unique content identifier of a record.

func (*RecordRef) Descriptor deprecated

func (*RecordRef) Descriptor() ([]byte, []int)

Deprecated: Use RecordRef.ProtoReflect.Descriptor instead.

func (*RecordRef) GetCid

func (x *RecordRef) GetCid() string

func (*RecordRef) ProtoMessage

func (*RecordRef) ProtoMessage()

func (*RecordRef) ProtoReflect

func (x *RecordRef) ProtoReflect() protoreflect.Message

func (*RecordRef) Reset

func (x *RecordRef) Reset()

func (*RecordRef) String

func (x *RecordRef) String() string

type RecordReferrer

type RecordReferrer struct {

	// The type of the referrer.
	// For example, "agntcy.dir.sign.v1.Signature" for signatures.
	Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	// Record reference to which this referrer is associated.
	RecordRef *RecordRef `protobuf:"bytes,2,opt,name=record_ref,json=recordRef,proto3" json:"record_ref,omitempty"`
	// Annotations attached to the referrer object.
	Annotations map[string]string `` /* 149-byte string literal not displayed */
	// Creation timestamp of the record in the RFC3339 format.
	// Specs: https://www.rfc-editor.org/rfc/rfc3339.html
	CreatedAt string `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// The actual data of the referrer.
	Data *structpb.Struct `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

RecordReferrer represents a referrer object or an association to a record. The actual structure of the referrer object can vary depending on the type of referrer (e.g., signature, public key, etc.).

RecordReferrer types in the `agntcy.dir.` namespace are reserved for Directory-specific schemas and will be validated across Dir services.

func (*RecordReferrer) Descriptor deprecated

func (*RecordReferrer) Descriptor() ([]byte, []int)

Deprecated: Use RecordReferrer.ProtoReflect.Descriptor instead.

func (*RecordReferrer) GetAnnotations

func (x *RecordReferrer) GetAnnotations() map[string]string

func (*RecordReferrer) GetCreatedAt

func (x *RecordReferrer) GetCreatedAt() string

func (*RecordReferrer) GetData

func (x *RecordReferrer) GetData() *structpb.Struct

func (*RecordReferrer) GetRecordRef

func (x *RecordReferrer) GetRecordRef() *RecordRef

func (*RecordReferrer) GetType

func (x *RecordReferrer) GetType() string

func (*RecordReferrer) ProtoMessage

func (*RecordReferrer) ProtoMessage()

func (*RecordReferrer) ProtoReflect

func (x *RecordReferrer) ProtoReflect() protoreflect.Message

func (*RecordReferrer) Reset

func (x *RecordReferrer) Reset()

func (*RecordReferrer) String

func (x *RecordReferrer) String() string

type ReferrerObject

type ReferrerObject interface {
	// UnmarshalReferrer loads the object from a RecordReferrer.
	UnmarshalReferrer(*RecordReferrer) error

	// MarshalReferrer exports the object into a RecordReferrer.
	MarshalReferrer() (*RecordReferrer, error)

	// ReferrerType returns the type of the referrer.
	// Examples:
	//   - Signature: "agntcy.dir.sign.v1.Signature"
	//   - PublicKey: "agntcy.dir.sign.v1.PublicKey"
	ReferrerType() string
}

ReferrerObject defines an interface for referrer objects that can be marshaled and unmarshaled to/from RecordReferrer format.

Jump to

Keyboard shortcuts

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