Help us shape the future of Go! Take the 2026 Go Developer Survey

sobject_invite

package
v0.57.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ControllerID = "alpha/so-invite/server"

ControllerID is the ID of the controller.

View Source
const ProtocolID = protocol.ID("alpha/so-invite")

ProtocolID is the bifrost protocol ID for the SO invite handshake.

View Source
const SRPCSOInviteServiceServiceID = "sobject.invite.SOInviteService"

Variables

View Source
var Version = controller.MustParseVersion("0.0.1")

Version is the version of the controller implementation.

Functions

func BuildJoinResponse

func BuildJoinResponse(inviteID string, privKey crypto.PrivKey) (*sobject.SOJoinResponse, error)

BuildJoinResponse constructs and signs a SOJoinResponse for an invite. The invitee calls this with their private key and the invite details.

func DeserializeInviteLink(encoded string) (*sobject.SOInviteMessage, error)

DeserializeInviteLink deserializes a base58-encoded SOInviteMessage from a URL path or query parameter.

func HashInviteToken

func HashInviteToken(token []byte) []byte

HashInviteToken computes the SHA256 hash of a raw invite token. Used by clients that need to compare raw invite tokens with SOInvite.token_hash.

func LeaveSharedObject

func LeaveSharedObject(ctx context.Context, childBus bus.Bus, localPeerID, ownerPeerID peer.ID, request *sobject.SOLeaveRequest) (*sobject.SOLeaveResponse, error)

LeaveSharedObject sends signed departure consent to the authenticated native owner. The caller verifies the returned configuration proof before retiring its local access.

func NewSRPCSOInviteServiceHandler

func NewSRPCSOInviteServiceHandler(impl SRPCSOInviteServiceServer, serviceID string) srpc.Handler

NewSRPCSOInviteServiceHandler constructs a new RPC handler. serviceID: if empty, uses default: sobject.invite.SOInviteService

func SRPCRegisterSOInviteService

func SRPCRegisterSOInviteService(mux srpc.Mux, impl SRPCSOInviteServiceServer) error

SRPCRegisterSOInviteService registers the implementation with the mux. Uses the default serviceID: sobject.invite.SOInviteService

func SerializeInviteLink(msg *sobject.SOInviteMessage) (string, error)

SerializeInviteLink serializes an SOInviteMessage as a base58 string suitable for embedding in a URL path or query parameter.

func ValidateJoinResponse

func ValidateJoinResponse(
	joinResp *sobject.SOJoinResponse,
) (peer.ID, crypto.PubKey, error)

ValidateJoinResponse validates a signed join response and returns the responder identity.

Types

type AcceptInviteRequest

type AcceptInviteRequest struct {

	// JoinResponse is the signed join response from the invitee.
	JoinResponse *sobject.SOJoinResponse `protobuf:"bytes,1,opt,name=join_response,json=joinResponse,proto3" json:"joinResponse,omitempty"`
	// Token is the raw invite token.
	// The owner SHA256 hashes it to verify against the on-chain token_hash.
	// Only the owner sees the raw token on the authenticated stream.
	// The cloud beacon/mailbox layer gates on token_hash (never sees raw token).
	Token []byte `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
	// StorageJoinResponse proves the persistent local storage identity that will
	// read and write the joined copy.
	StorageJoinResponse *sobject.SOJoinResponse `protobuf:"bytes,3,opt,name=storage_join_response,json=storageJoinResponse,proto3" json:"storageJoinResponse,omitempty"`
	// contains filtered or unexported fields
}

AcceptInviteRequest is sent by the invitee to the owner.

func (*AcceptInviteRequest) CloneMessageVT

func (*AcceptInviteRequest) CloneVT

func (*AcceptInviteRequest) EqualMessageVT

func (this *AcceptInviteRequest) EqualMessageVT(thatMsg any) bool

func (*AcceptInviteRequest) EqualVT

func (this *AcceptInviteRequest) EqualVT(that *AcceptInviteRequest) bool

func (*AcceptInviteRequest) GetJoinResponse

func (x *AcceptInviteRequest) GetJoinResponse() *sobject.SOJoinResponse

func (*AcceptInviteRequest) GetStorageJoinResponse added in v0.57.2

func (x *AcceptInviteRequest) GetStorageJoinResponse() *sobject.SOJoinResponse

func (*AcceptInviteRequest) GetToken

func (x *AcceptInviteRequest) GetToken() []byte

func (*AcceptInviteRequest) MarshalJSON

func (x *AcceptInviteRequest) MarshalJSON() ([]byte, error)

MarshalJSON marshals the AcceptInviteRequest to JSON.

func (*AcceptInviteRequest) MarshalProtoJSON

func (x *AcceptInviteRequest) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the AcceptInviteRequest message to JSON.

func (*AcceptInviteRequest) MarshalProtoText

func (x *AcceptInviteRequest) MarshalProtoText() string

func (*AcceptInviteRequest) MarshalToSizedBufferVT

func (m *AcceptInviteRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*AcceptInviteRequest) MarshalToVT

func (m *AcceptInviteRequest) MarshalToVT(dAtA []byte) (int, error)

func (*AcceptInviteRequest) MarshalVT

func (m *AcceptInviteRequest) MarshalVT() (dAtA []byte, err error)

func (*AcceptInviteRequest) ProtoMessage

func (*AcceptInviteRequest) ProtoMessage()

func (*AcceptInviteRequest) Reset

func (x *AcceptInviteRequest) Reset()

func (*AcceptInviteRequest) SizeVT

func (m *AcceptInviteRequest) SizeVT() (n int)

func (*AcceptInviteRequest) String

func (x *AcceptInviteRequest) String() string

func (*AcceptInviteRequest) UnmarshalJSON

func (x *AcceptInviteRequest) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the AcceptInviteRequest from JSON.

func (*AcceptInviteRequest) UnmarshalProtoJSON

func (x *AcceptInviteRequest) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the AcceptInviteRequest message from JSON.

func (*AcceptInviteRequest) UnmarshalVT

func (m *AcceptInviteRequest) UnmarshalVT(dAtA []byte) error

type AcceptInviteResponse

type AcceptInviteResponse struct {

	// Grant is the encrypted SOGrant for the invitee.
	Grant *sobject.SOGrant `protobuf:"bytes,1,opt,name=grant,proto3" json:"grant,omitempty"`
	// SharedObjectId is the ID of the shared object the invitee was enrolled in.
	SharedObjectId string `protobuf:"bytes,2,opt,name=shared_object_id,json=sharedObjectId,proto3" json:"sharedObjectId,omitempty"`
	// OwnerGrant is the owner's existing root grant. The invitee preserves it so
	// the owner can read later state written by the joined copy.
	OwnerGrant *sobject.SOGrant `protobuf:"bytes,3,opt,name=owner_grant,json=ownerGrant,proto3" json:"ownerGrant,omitempty"`
	// SharedObjectState is the owner's authorized state after enrollment. The
	// invitee installs this state so both copies use the same root transform.
	SharedObjectState *sobject.SOState `protobuf:"bytes,4,opt,name=shared_object_state,json=sharedObjectState,proto3" json:"sharedObjectState,omitempty"`
	// contains filtered or unexported fields
}

AcceptInviteResponse is returned by the owner after enrollment.

func (*AcceptInviteResponse) CloneMessageVT

func (*AcceptInviteResponse) CloneVT

func (*AcceptInviteResponse) EqualMessageVT

func (this *AcceptInviteResponse) EqualMessageVT(thatMsg any) bool

func (*AcceptInviteResponse) EqualVT

func (this *AcceptInviteResponse) EqualVT(that *AcceptInviteResponse) bool

func (*AcceptInviteResponse) GetGrant

func (x *AcceptInviteResponse) GetGrant() *sobject.SOGrant

func (*AcceptInviteResponse) GetOwnerGrant added in v0.57.2

func (x *AcceptInviteResponse) GetOwnerGrant() *sobject.SOGrant

func (*AcceptInviteResponse) GetSharedObjectId

func (x *AcceptInviteResponse) GetSharedObjectId() string

func (*AcceptInviteResponse) GetSharedObjectState added in v0.57.2

func (x *AcceptInviteResponse) GetSharedObjectState() *sobject.SOState

func (*AcceptInviteResponse) MarshalJSON

func (x *AcceptInviteResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshals the AcceptInviteResponse to JSON.

func (*AcceptInviteResponse) MarshalProtoJSON

func (x *AcceptInviteResponse) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the AcceptInviteResponse message to JSON.

func (*AcceptInviteResponse) MarshalProtoText

func (x *AcceptInviteResponse) MarshalProtoText() string

func (*AcceptInviteResponse) MarshalToSizedBufferVT

func (m *AcceptInviteResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*AcceptInviteResponse) MarshalToVT

func (m *AcceptInviteResponse) MarshalToVT(dAtA []byte) (int, error)

func (*AcceptInviteResponse) MarshalVT

func (m *AcceptInviteResponse) MarshalVT() (dAtA []byte, err error)

func (*AcceptInviteResponse) ProtoMessage

func (*AcceptInviteResponse) ProtoMessage()

func (*AcceptInviteResponse) Reset

func (x *AcceptInviteResponse) Reset()

func (*AcceptInviteResponse) SizeVT

func (m *AcceptInviteResponse) SizeVT() (n int)

func (*AcceptInviteResponse) String

func (x *AcceptInviteResponse) String() string

func (*AcceptInviteResponse) UnmarshalJSON

func (x *AcceptInviteResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the AcceptInviteResponse from JSON.

func (*AcceptInviteResponse) UnmarshalProtoJSON

func (x *AcceptInviteResponse) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the AcceptInviteResponse message from JSON.

func (*AcceptInviteResponse) UnmarshalVT

func (m *AcceptInviteResponse) UnmarshalVT(dAtA []byte) error

type EnrollFn

type EnrollFn func(ctx context.Context, result *InviteLookupResult, inviteePeerID peer.ID, inviteePubKey crypto.PubKey) (*sobject.SOGrant, error)

EnrollFn enrolls a participant after invite verification. Called with the resolved invite context and the invitee's identity. Returns the SOGrant for the invitee.

type InviteController

type InviteController struct {
	// Server owns the invitation stream service and its controller lifetime.
	*stream_srpc_server.Server
}

InviteController wraps the SRPC server with the bifrost stream handler.

func NewInviteController

func NewInviteController(
	le *logrus.Entry,
	b bus.Bus,
	lookupFn InviteLookupFn,
	enrollFn EnrollFn,
	leaveFn LeaveFn,
	peerIDs []string,
) (*InviteController, error)

NewInviteController constructs an SO invite controller.

type InviteLookupFn

type InviteLookupFn func(ctx context.Context, tokenHash []byte) (*InviteLookupResult, error)

InviteLookupFn resolves an invite by token hash. Returns nil result if no matching invite is found.

type InviteLookupResult

type InviteLookupResult struct {
	// Host is the SOHost managing the shared object.
	Host *sobject.SOHost
	// InviteMutator applies invite state mutations for this shared object.
	InviteMutator sobject.InviteMutator
	// Invite is the matching SOInvite.
	Invite *sobject.SOInvite
	// SharedObjectID is the ID of the shared object.
	SharedObjectID string
	// OwnerPrivKey is the owner's private key for signing config changes.
	OwnerPrivKey crypto.PrivKey
}

InviteLookupResult contains the resolved invite and its context.

type JoinResult

type JoinResult struct {
	// Grant is the encrypted SOGrant for the invitee.
	Grant *sobject.SOGrant
	// SharedObjectID is the ID of the shared object.
	SharedObjectID string
	// OwnerGrant keeps the originating owner's root access on the joined copy.
	OwnerGrant *sobject.SOGrant
	// SharedObjectState is the owner's authorized state after enrollment.
	SharedObjectState *sobject.SOState
}

JoinResult contains the result of a successful invite join.

func JoinViaInvite

func JoinViaInvite(
	ctx context.Context,
	childBus bus.Bus,
	localPeerID peer.ID,
	inviteePrivKey crypto.PrivKey,
	storagePrivKey crypto.PrivKey,
	inviteMsg *sobject.SOInviteMessage,
) (*JoinResult, error)

JoinViaInvite executes the invitee side of the invite handshake.

The invitee must already have a session transport running with a child bus that can reach the owner's peer (via signaling/WebRTC). This function: 1. Builds and signs a SOJoinResponse 2. Opens an SRPC stream to the owner on protocol alpha/so-invite 3. Sends AcceptInviteRequest with the raw token 4. Returns the SOGrant from the owner

type LeaveFn

LeaveFn commits voluntary departure while retaining the selected native host through acknowledgment.

type SRPCSOInviteServiceClient

type SRPCSOInviteServiceClient interface {
	// SRPCClient returns the underlying SRPC client.
	SRPCClient() srpc.Client

	// AcceptInvite verifies admission proofs and issues native participant grants.
	AcceptInvite(ctx context.Context, in *AcceptInviteRequest) (*AcceptInviteResponse, error)
	// Leave verifies signed consent and returns the owner's committed removal proof.
	Leave(ctx context.Context, in *sobject.SOLeaveRequest) (*sobject.SOLeaveResponse, error)
}

func NewSRPCSOInviteServiceClient

func NewSRPCSOInviteServiceClient(cc srpc.Client) SRPCSOInviteServiceClient

func NewSRPCSOInviteServiceClientWithServiceID

func NewSRPCSOInviteServiceClientWithServiceID(cc srpc.Client, serviceID string) SRPCSOInviteServiceClient

type SRPCSOInviteServiceHandler

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

func (SRPCSOInviteServiceHandler) GetMethodIDs

func (SRPCSOInviteServiceHandler) GetMethodIDs() []string

func (*SRPCSOInviteServiceHandler) GetServiceID

func (d *SRPCSOInviteServiceHandler) GetServiceID() string

func (*SRPCSOInviteServiceHandler) InvokeMethod

func (d *SRPCSOInviteServiceHandler) InvokeMethod(
	serviceID, methodID string,
	strm srpc.Stream,
) (bool, error)

func (SRPCSOInviteServiceHandler) InvokeMethod_AcceptInvite

func (SRPCSOInviteServiceHandler) InvokeMethod_AcceptInvite(impl SRPCSOInviteServiceServer, strm srpc.Stream) error

func (SRPCSOInviteServiceHandler) InvokeMethod_Leave

func (SRPCSOInviteServiceHandler) InvokeMethod_Leave(impl SRPCSOInviteServiceServer, strm srpc.Stream) error

type SRPCSOInviteServiceServer

type SRPCSOInviteServiceServer interface {
	// AcceptInvite verifies admission proofs and issues native participant grants.
	AcceptInvite(context.Context, *AcceptInviteRequest) (*AcceptInviteResponse, error)
	// Leave verifies signed consent and returns the owner's committed removal proof.
	Leave(context.Context, *sobject.SOLeaveRequest) (*sobject.SOLeaveResponse, error)
}

type SRPCSOInviteService_AcceptInviteStream

type SRPCSOInviteService_AcceptInviteStream interface {
	srpc.Stream
}

type SRPCSOInviteService_LeaveStream

type SRPCSOInviteService_LeaveStream interface {
	srpc.Stream
}

type Server

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

Server implements the SOInviteService SRPC server.

func NewServer

func NewServer(le *logrus.Entry, lookupFn InviteLookupFn, enrollFn EnrollFn, leaveFn LeaveFn) *Server

NewServer constructs a new SO invite server.

func (*Server) AcceptInvite

func (s *Server) AcceptInvite(ctx context.Context, req *AcceptInviteRequest) (*AcceptInviteResponse, error)

AcceptInvite processes a join request from an invitee.

func (*Server) Leave

Leave binds the transport to a departing identity before invoking the native owner.

Jump to

Keyboard shortcuts

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