Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/core/v1/referrer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ const (

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

// OwnershipClaimReferrerType is the type for ownership claim referrers.
// An ownership claim asserts that the authenticated caller is the operational
// owner of the record. The caller's identity must match the owner_id in the
// claim payload — the server enforces this at push time.
OwnershipClaimReferrerType = "agntcy.dir.ownership.v1.Claim"
)
54 changes: 28 additions & 26 deletions api/core/v1/rules.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions api/ownership/v1/claim.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0

package v1

import (
"errors"
"fmt"

corev1 "github.com/agntcy/dir/api/core/v1"
"github.com/agntcy/oasf-sdk/pkg/decoder"
)

// ReferrerType returns the referrer type for OwnershipClaim.
func (c *OwnershipClaim) ReferrerType() string {
return corev1.OwnershipClaimReferrerType
}

// MarshalReferrer exports the OwnershipClaim into a RecordReferrer.
func (c *OwnershipClaim) MarshalReferrer() (*corev1.RecordReferrer, error) {
if c == nil {
return nil, errors.New("ownership claim is nil")
}

data, err := decoder.StructToProto(c)
if err != nil {
return nil, fmt.Errorf("failed to convert ownership claim to struct: %w", err)
}

return &corev1.RecordReferrer{
Type: c.ReferrerType(),
Data: data,
}, nil
}

// UnmarshalReferrer loads the OwnershipClaim from a RecordReferrer.
func (c *OwnershipClaim) UnmarshalReferrer(ref *corev1.RecordReferrer) error {
if ref == nil || ref.GetData() == nil {
return errors.New("referrer or data is nil")
}

decoded, err := decoder.ProtoToStruct[OwnershipClaim](ref.GetData())
if err != nil {
return fmt.Errorf("failed to decode ownership claim from referrer: %w", err)
}

c.OwnerId = decoded.GetOwnerId()
c.ClaimedAt = decoded.GetClaimedAt()

return nil
}
164 changes: 164 additions & 0 deletions api/ownership/v1/claim.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/search/v1/record_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func init() {
13: "verified",
14: "trusted",
15: "annotation",
16: "manager",
}
RecordQueryType_value = map[string]int32{
"": 0,
Expand All @@ -44,6 +45,7 @@ func init() {
"verified": 13,
"trusted": 14,
"annotation": 15,
"manager": 16,
}

ValidQueryTypes = []string{
Expand All @@ -62,5 +64,6 @@ func init() {
"verified",
"trusted",
"annotation",
"manager",
}
}
Loading
Loading