message

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MessageRPCEndpoint = "/im/rpc"
	MessageWSEndpoint  = "/im/ws"
)
View Source
const OriginProofScheme = "anp-rfc9421-origin-proof-v1"

Variables

View Source
var (
	ErrTargetRequired         = errors.New("direct message target is required")
	ErrGroupRequired          = errors.New("group target is required")
	ErrMemberRequired         = errors.New("group member target is required")
	ErrGroupOwnerCannotLeave  = errors.New("group owner cannot leave the group")
	ErrTextRequired           = errors.New("message text is required")
	ErrFilePathRequired       = errors.New("attachment file path is required")
	ErrMimeTypeWithoutFile    = errors.New("mime_type requires an attachment file")
	ErrMessageIDRequired      = errors.New("attachment message id is required")
	ErrOutputPathRequired     = errors.New("attachment output path is required")
	ErrDownloadTargetNeeded   = errors.New("attachment download requires either --with or --group")
	ErrDownloadTargetConflict = errors.New(
		"attachment download accepts either --with or --group, but not both",
	)
	ErrAttachmentNotFound       = errors.New("attachment not found in message content")
	ErrAttachmentIDRequired     = errors.New("attachment_id is required for messages with multiple attachments")
	ErrAttachmentMessageInvalid = errors.New("message is not an attachment manifest")
	ErrAttachmentSenderRequired = errors.New("attachment message sender_did is required")
	ErrTransportUnavailable     = errors.New("message transport is unavailable")
	ErrSecureNotSupported       = errors.New("secure messaging is not supported for this command yet")
	ErrMessageNotFound          = errors.New("message not found")
)

Functions

func BuildAttachmentCommitObjectRPCParams

func BuildAttachmentCommitObjectRPCParams(
	record *identity.StoredIdentity,
	manager *identity.Manager,
	serviceDID string,
	prepared *preparedAttachment,
	slot *attachmentCreateSlotResult,
) (map[string]any, error)

func BuildAttachmentCreateSlotRPCParams

func BuildAttachmentCreateSlotRPCParams(
	record *identity.StoredIdentity,
	manager *identity.Manager,
	serviceDID string,
	targetKind string,
	targetDID string,
	prepared *preparedAttachment,
) (map[string]any, error)

func BuildAttachmentDownloadTicketRPCParams

func BuildAttachmentDownloadTicketRPCParams(
	record *identity.StoredIdentity,
	manager *identity.Manager,
	serviceDID string,
	senderDID string,
	messageID string,
	groupDID string,
	selection *attachmentSelection,
) (map[string]any, error)

func BuildDirectAttachmentSendRPCParams

func BuildDirectAttachmentSendRPCParams(
	record *identity.StoredIdentity,
	manager *identity.Manager,
	targetDID string,
	manifest map[string]any,
) (map[string]any, error)

func BuildDirectSendRPCParams

func BuildDirectSendRPCParams(record *identity.StoredIdentity, manager *identity.Manager, targetDID string, text string, messageType string) (map[string]any, error)

func BuildGroupAddRPCParams

func BuildGroupAddRPCParams(record *identity.StoredIdentity, manager *identity.Manager, request GroupMemberRequest) (map[string]any, error)

func BuildGroupAttachmentSendRPCParams

func BuildGroupAttachmentSendRPCParams(
	record *identity.StoredIdentity,
	manager *identity.Manager,
	groupDID string,
	manifest map[string]any,
) (map[string]any, error)

func BuildGroupCreateRPCParams

func BuildGroupCreateRPCParams(record *identity.StoredIdentity, manager *identity.Manager, serviceDID string, request GroupCreateRequest) (map[string]any, error)

func BuildGroupGetInfoRPCParams

func BuildGroupGetInfoRPCParams(record *identity.StoredIdentity, request GroupInfoRequest) (map[string]any, error)

func BuildGroupGetRPCParams

func BuildGroupGetRPCParams(record *identity.StoredIdentity, request GroupGetRequest) (map[string]any, error)

func BuildGroupJoinRPCParams

func BuildGroupJoinRPCParams(record *identity.StoredIdentity, manager *identity.Manager, request GroupJoinRequest) (map[string]any, error)

func BuildGroupLeaveRPCParams

func BuildGroupLeaveRPCParams(record *identity.StoredIdentity, manager *identity.Manager, request GroupLeaveRequest) (map[string]any, error)

func BuildGroupListRPCParams added in v1.0.13

func BuildGroupListRPCParams(record *identity.StoredIdentity, request GroupListRequest) (map[string]any, error)

func BuildGroupMembersRPCParams

func BuildGroupMembersRPCParams(record *identity.StoredIdentity, request GroupMembersRequest) (map[string]any, error)

func BuildGroupMessagesRPCParams

func BuildGroupMessagesRPCParams(record *identity.StoredIdentity, request GroupMessagesRequest) (map[string]any, error)

func BuildGroupRemoveRPCParams

func BuildGroupRemoveRPCParams(record *identity.StoredIdentity, manager *identity.Manager, request GroupMemberRequest) (map[string]any, error)

func BuildGroupSendRPCParams

func BuildGroupSendRPCParams(record *identity.StoredIdentity, manager *identity.Manager, groupDID string, text string, messageType string) (map[string]any, error)

func BuildGroupUpdatePolicyRPCParams

func BuildGroupUpdatePolicyRPCParams(record *identity.StoredIdentity, manager *identity.Manager, groupDID string, patch map[string]any) (map[string]any, error)

func BuildGroupUpdateProfileRPCParams

func BuildGroupUpdateProfileRPCParams(record *identity.StoredIdentity, manager *identity.Manager, groupDID string, patch map[string]any) (map[string]any, error)

func BuildHistoryRPCParams

func BuildHistoryRPCParams(record *identity.StoredIdentity, request HistoryRequest) (map[string]any, error)

func BuildInboxRPCParams

func BuildInboxRPCParams(record *identity.StoredIdentity, request InboxRequest) map[string]any

func BuildMarkReadRPCParams

func BuildMarkReadRPCParams(record *identity.StoredIdentity, request MarkReadRequest) (map[string]any, error)

func BuildSecureAckPayload added in v1.0.16

func BuildSecureAckPayload(sessionID string, ackedMessageID string) map[string]any

func BuildSecureInitPayload added in v1.0.16

func BuildSecureInitPayload() map[string]any

func CompleteBareHandle

func CompleteBareHandle(target string, didDomain string) string

CompleteBareHandle expands a bare handle like "alice" to "alice.<didDomain>". Explicit DIDs and full handles pass through unchanged.

func FlushQueuedSecureOutbox added in v1.0.16

func FlushQueuedSecureOutbox(ctx context.Context, resolved *appconfig.Resolved, manager *identity.Manager, record *identity.StoredIdentity, peerDID string, rpc func(string, map[string]any) (map[string]any, error)) []string

func IsSecureAckPlaintext added in v1.0.16

func IsSecureAckPlaintext(plaintext map[string]any) bool

func IsSecureInitPlaintext added in v1.0.16

func IsSecureInitPlaintext(plaintext map[string]any) bool

func NewSecureE2EEClientForRecord added in v1.0.16

func NewSecureE2EEClientForRecord(ctx context.Context, manager *identity.Manager, record *identity.StoredIdentity, rpc func(string, map[string]any) (map[string]any, error)) (*anpsdk.MessageServiceE2EEClient, error)

NewSecureE2EEClientForRecord creates one direct-e2ee client for the given identity.

func PublishSecurePrekeys added in v1.0.16

func PublishSecurePrekeys(ctx context.Context, resolved *appconfig.Resolved, manager *identity.Manager, record *identity.StoredIdentity) []string

PublishSecurePrekeys ensures one identity has a published secure prekey bundle.

Types

type AttachmentDownloadRequest

type AttachmentDownloadRequest struct {
	IdentityName string
	With         string
	Group        string
	MessageID    string
	AttachmentID string
	OutputPath   string
}

type CommandResult

type CommandResult struct {
	Data     map[string]any
	Summary  string
	Warnings []string
}

type GroupCreateRequest

type GroupCreateRequest struct {
	IdentityName        string
	Name                string
	Description         string
	Discoverability     string
	AdmissionMode       string
	Slug                string
	Goal                string
	Rules               string
	MessagePrompt       string
	DocURL              string
	AttachmentsAllowed  *bool
	MaxMembers          string
	MemberMaxMessages   *int64
	MemberMaxTotalChars *int64
}

type GroupGetRequest

type GroupGetRequest struct {
	IdentityName string
	Group        string
}

type GroupInfoRequest

type GroupInfoRequest struct {
	IdentityName      string
	Group             string
	IncludePolicy     bool
	IncludeMemberList bool
}

type GroupJoinRequest

type GroupJoinRequest struct {
	IdentityName string
	Group        string
	ReasonText   string
}

type GroupLeaveRequest

type GroupLeaveRequest struct {
	IdentityName string
	Group        string
}

type GroupListRequest added in v1.0.13

type GroupListRequest struct {
	IdentityName string
	Limit        int
}

type GroupMemberRequest

type GroupMemberRequest struct {
	IdentityName string
	Group        string
	Member       string
	Role         string
	ReasonText   string
}

type GroupMembersRequest

type GroupMembersRequest struct {
	IdentityName string
	Group        string
	Limit        int
}

type GroupMessagesRequest

type GroupMessagesRequest struct {
	IdentityName string
	Group        string
	Limit        int
	Cursor       string
	Skip         int
}

type GroupUpdateRequest

type GroupUpdateRequest struct {
	IdentityName        string
	Group               string
	Name                string
	Description         string
	Discoverability     string
	AdmissionMode       string
	Slug                string
	Goal                string
	Rules               string
	MessagePrompt       string
	DocURL              string
	AttachmentsAllowed  *bool
	MaxMembers          string
	MemberMaxMessages   *int64
	MemberMaxTotalChars *int64
}

type HTTPTransport

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

func NewHTTPTransport

func NewHTTPTransport(resolved *appconfig.Resolved, auth *authContext, httpClient *http.Client) *HTTPTransport

func NewHTTPTransportForRPCEndpoint

func NewHTTPTransportForRPCEndpoint(
	resolved *appconfig.Resolved,
	auth *authContext,
	httpClient *http.Client,
	rpcEndpointURL string,
) *HTTPTransport

func (*HTTPTransport) AddGroupMember

func (t *HTTPTransport) AddGroupMember(ctx context.Context, request GroupMemberRequest) (map[string]any, error)

func (*HTTPTransport) CommitAttachmentObject

func (t *HTTPTransport) CommitAttachmentObject(
	ctx context.Context,
	serviceDID string,
	prepared *preparedAttachment,
	slot *attachmentCreateSlotResult,
) (*attachmentCommitObjectResult, error)

func (*HTTPTransport) CreateAttachmentSlot

func (t *HTTPTransport) CreateAttachmentSlot(
	ctx context.Context,
	targetKind string,
	targetDID string,
	prepared *preparedAttachment,
) (*attachmentCreateSlotResult, error)

func (*HTTPTransport) CreateGroup

func (t *HTTPTransport) CreateGroup(ctx context.Context, request GroupCreateRequest) (map[string]any, error)

func (*HTTPTransport) DownloadAttachmentObject

func (t *HTTPTransport) DownloadAttachmentObject(
	ctx context.Context,
	objectURI string,
	downloadTicket string,
) ([]byte, http.Header, error)

func (*HTTPTransport) GetAttachmentDownloadTicket

func (t *HTTPTransport) GetAttachmentDownloadTicket(
	ctx context.Context,
	params map[string]any,
) (*attachmentDownloadTicketResult, error)

func (*HTTPTransport) GetGroup

func (t *HTTPTransport) GetGroup(ctx context.Context, request GroupGetRequest) (map[string]any, error)

func (*HTTPTransport) GetGroupInfo

func (t *HTTPTransport) GetGroupInfo(ctx context.Context, request GroupInfoRequest) (map[string]any, error)

func (*HTTPTransport) GetHistory

func (t *HTTPTransport) GetHistory(ctx context.Context, request HistoryRequest) (map[string]any, error)

func (*HTTPTransport) GetInbox

func (t *HTTPTransport) GetInbox(ctx context.Context, request InboxRequest) (map[string]any, error)

func (*HTTPTransport) GetMessageServiceDID

func (t *HTTPTransport) GetMessageServiceDID(ctx context.Context) (string, error)

func (*HTTPTransport) JoinGroup

func (t *HTTPTransport) JoinGroup(ctx context.Context, request GroupJoinRequest) (map[string]any, error)

func (*HTTPTransport) LeaveGroup

func (t *HTTPTransport) LeaveGroup(ctx context.Context, request GroupLeaveRequest) (map[string]any, error)

func (*HTTPTransport) ListGroupMembers

func (t *HTTPTransport) ListGroupMembers(ctx context.Context, request GroupMembersRequest) (map[string]any, error)

func (*HTTPTransport) ListGroupMessages

func (t *HTTPTransport) ListGroupMessages(ctx context.Context, request GroupMessagesRequest) (map[string]any, error)

func (*HTTPTransport) ListGroups added in v1.0.13

func (t *HTTPTransport) ListGroups(ctx context.Context, request GroupListRequest) (map[string]any, error)

func (*HTTPTransport) MarkRead

func (t *HTTPTransport) MarkRead(ctx context.Context, request MarkReadRequest) (map[string]any, error)

func (*HTTPTransport) RemoveGroupMember

func (t *HTTPTransport) RemoveGroupMember(ctx context.Context, request GroupMemberRequest) (map[string]any, error)

func (*HTTPTransport) SendDirect

func (t *HTTPTransport) SendDirect(ctx context.Context, request SendRequest) (*directSendResult, error)

func (*HTTPTransport) SendDirectAttachment

func (t *HTTPTransport) SendDirectAttachment(
	ctx context.Context,
	targetDID string,
	manifest map[string]any,
) (*directSendResult, error)

func (*HTTPTransport) SendGroup

func (t *HTTPTransport) SendGroup(ctx context.Context, request SendRequest) (*groupSendResult, error)

func (*HTTPTransport) SendGroupAttachment

func (t *HTTPTransport) SendGroupAttachment(
	ctx context.Context,
	groupDID string,
	manifest map[string]any,
) (*groupSendResult, error)

func (*HTTPTransport) UpdateGroupPolicy

func (t *HTTPTransport) UpdateGroupPolicy(ctx context.Context, request GroupGetRequest, patch map[string]any) (map[string]any, error)

func (*HTTPTransport) UpdateGroupProfile

func (t *HTTPTransport) UpdateGroupProfile(ctx context.Context, request GroupGetRequest, patch map[string]any) (map[string]any, error)

func (*HTTPTransport) UploadAttachmentObject

func (t *HTTPTransport) UploadAttachmentObject(
	ctx context.Context,
	uploadURI string,
	headers map[string]string,
	payload []byte,
) error

func (*HTTPTransport) WithRPCEndpoint

func (t *HTTPTransport) WithRPCEndpoint(rpcEndpointURL string) *HTTPTransport

type HistoryRequest

type HistoryRequest struct {
	IdentityName string
	With         string
	Limit        int
	Cursor       string
	Skip         int
}

type InboxRequest

type InboxRequest struct {
	IdentityName string
	Scope        string
	With         string
	Group        string
	Limit        int
	UnreadOnly   bool
	MarkRead     bool
}

type MarkReadRequest

type MarkReadRequest struct {
	IdentityName string
	MessageIDs   []string
}

type SecureOutboxActionRequest added in v1.0.16

type SecureOutboxActionRequest struct {
	IdentityName string
	OutboxID     string
}

type SecurePeerRequest added in v1.0.16

type SecurePeerRequest struct {
	IdentityName string
	With         string
}

type SecureStatusRequest added in v1.0.16

type SecureStatusRequest struct {
	IdentityName string
	With         string
}

type SendRequest

type SendRequest struct {
	IdentityName string
	Target       string
	Group        string
	Text         string
	MessageType  string
	SecureMode   string
	FilePath     string
	MIMEType     string
}

func (SendRequest) HasAttachment

func (r SendRequest) HasAttachment() bool

type Service

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

func NewService

func NewService(resolved *appconfig.Resolved) (*Service, error)

func (*Service) AddGroupMember

func (s *Service) AddGroupMember(ctx context.Context, request GroupMemberRequest) (*CommandResult, error)

func (*Service) Config

func (s *Service) Config() *appconfig.Resolved

func (*Service) CreateGroup

func (s *Service) CreateGroup(ctx context.Context, request GroupCreateRequest) (*CommandResult, error)

func (*Service) DownloadAttachment

func (s *Service) DownloadAttachment(ctx context.Context, request AttachmentDownloadRequest) (*CommandResult, error)

func (*Service) GetGroup

func (s *Service) GetGroup(ctx context.Context, request GroupGetRequest) (*CommandResult, error)

func (*Service) GroupMembers

func (s *Service) GroupMembers(ctx context.Context, request GroupMembersRequest) (*CommandResult, error)

func (*Service) GroupMessages

func (s *Service) GroupMessages(ctx context.Context, request GroupMessagesRequest) (*CommandResult, error)

func (*Service) History

func (s *Service) History(ctx context.Context, request HistoryRequest) (*CommandResult, error)

func (*Service) Inbox

func (s *Service) Inbox(ctx context.Context, request InboxRequest) (*CommandResult, error)

func (*Service) JoinGroup

func (s *Service) JoinGroup(ctx context.Context, request GroupJoinRequest) (*CommandResult, error)

func (*Service) LeaveGroup

func (s *Service) LeaveGroup(ctx context.Context, request GroupLeaveRequest) (*CommandResult, error)

func (*Service) ListGroups added in v1.0.13

func (s *Service) ListGroups(ctx context.Context, request GroupListRequest) (*CommandResult, error)

func (*Service) MarkRead

func (s *Service) MarkRead(ctx context.Context, request MarkReadRequest) (*CommandResult, error)

func (*Service) RemoveGroupMember

func (s *Service) RemoveGroupMember(ctx context.Context, request GroupMemberRequest) (*CommandResult, error)

func (*Service) SecureDrop added in v1.0.16

func (s *Service) SecureDrop(ctx context.Context, request SecureOutboxActionRequest) (*CommandResult, error)

func (*Service) SecureFailed added in v1.0.16

func (s *Service) SecureFailed(ctx context.Context, request SecureStatusRequest) (*CommandResult, error)

func (*Service) SecureInit added in v1.0.16

func (s *Service) SecureInit(ctx context.Context, request SecurePeerRequest) (*CommandResult, error)

func (*Service) SecureRepair added in v1.0.16

func (s *Service) SecureRepair(ctx context.Context, request SecurePeerRequest) (*CommandResult, error)

func (*Service) SecureRetry added in v1.0.16

func (s *Service) SecureRetry(ctx context.Context, request SecureOutboxActionRequest) (*CommandResult, error)

func (*Service) SecureStatus added in v1.0.16

func (s *Service) SecureStatus(ctx context.Context, request SecureStatusRequest) (*CommandResult, error)

func (*Service) Send

func (s *Service) Send(ctx context.Context, request SendRequest) (*CommandResult, error)

func (*Service) UpdateGroup

func (s *Service) UpdateGroup(ctx context.Context, request GroupUpdateRequest) (*CommandResult, error)

type ServiceError

type ServiceError struct {
	StatusCode int
	RPCCode    int
	Message    string
	Data       any
}

func (*ServiceError) Error

func (e *ServiceError) Error() string

type Transport

type Transport interface {
	SendDirect(context.Context, SendRequest) (*directSendResult, error)
	SendGroup(context.Context, SendRequest) (*groupSendResult, error)
	GetInbox(context.Context, InboxRequest) (map[string]any, error)
	GetHistory(context.Context, HistoryRequest) (map[string]any, error)
	MarkRead(context.Context, MarkReadRequest) (map[string]any, error)
	CreateGroup(context.Context, GroupCreateRequest) (map[string]any, error)
	GetGroupInfo(context.Context, GroupInfoRequest) (map[string]any, error)
	JoinGroup(context.Context, GroupJoinRequest) (map[string]any, error)
	AddGroupMember(context.Context, GroupMemberRequest) (map[string]any, error)
	RemoveGroupMember(context.Context, GroupMemberRequest) (map[string]any, error)
	LeaveGroup(context.Context, GroupLeaveRequest) (map[string]any, error)
	GetGroup(context.Context, GroupGetRequest) (map[string]any, error)
	ListGroups(context.Context, GroupListRequest) (map[string]any, error)
	ListGroupMembers(context.Context, GroupMembersRequest) (map[string]any, error)
	ListGroupMessages(context.Context, GroupMessagesRequest) (map[string]any, error)
	UpdateGroupProfile(context.Context, GroupGetRequest, map[string]any) (map[string]any, error)
	UpdateGroupPolicy(context.Context, GroupGetRequest, map[string]any) (map[string]any, error)
}

type WSProxyTransport

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

func NewWSProxyTransport

func NewWSProxyTransport(resolved *appconfig.Resolved, identityName string) *WSProxyTransport

func (*WSProxyTransport) AddGroupMember

func (t *WSProxyTransport) AddGroupMember(ctx context.Context, request GroupMemberRequest) (map[string]any, error)

func (*WSProxyTransport) CreateGroup

func (t *WSProxyTransport) CreateGroup(ctx context.Context, request GroupCreateRequest) (map[string]any, error)

func (*WSProxyTransport) GetGroup

func (t *WSProxyTransport) GetGroup(ctx context.Context, request GroupGetRequest) (map[string]any, error)

func (*WSProxyTransport) GetGroupInfo

func (t *WSProxyTransport) GetGroupInfo(ctx context.Context, request GroupInfoRequest) (map[string]any, error)

func (*WSProxyTransport) GetHistory

func (t *WSProxyTransport) GetHistory(ctx context.Context, request HistoryRequest) (map[string]any, error)

func (*WSProxyTransport) GetInbox

func (t *WSProxyTransport) GetInbox(ctx context.Context, request InboxRequest) (map[string]any, error)

func (*WSProxyTransport) JoinGroup

func (t *WSProxyTransport) JoinGroup(ctx context.Context, request GroupJoinRequest) (map[string]any, error)

func (*WSProxyTransport) LeaveGroup

func (t *WSProxyTransport) LeaveGroup(ctx context.Context, request GroupLeaveRequest) (map[string]any, error)

func (*WSProxyTransport) ListGroupMembers

func (t *WSProxyTransport) ListGroupMembers(ctx context.Context, request GroupMembersRequest) (map[string]any, error)

func (*WSProxyTransport) ListGroupMessages

func (t *WSProxyTransport) ListGroupMessages(ctx context.Context, request GroupMessagesRequest) (map[string]any, error)

func (*WSProxyTransport) ListGroups added in v1.0.13

func (t *WSProxyTransport) ListGroups(ctx context.Context, request GroupListRequest) (map[string]any, error)

func (*WSProxyTransport) MarkRead

func (t *WSProxyTransport) MarkRead(ctx context.Context, request MarkReadRequest) (map[string]any, error)

func (*WSProxyTransport) RemoveGroupMember

func (t *WSProxyTransport) RemoveGroupMember(ctx context.Context, request GroupMemberRequest) (map[string]any, error)

func (*WSProxyTransport) SendDirect

func (t *WSProxyTransport) SendDirect(ctx context.Context, request SendRequest) (*directSendResult, error)

func (*WSProxyTransport) SendGroup

func (t *WSProxyTransport) SendGroup(ctx context.Context, request SendRequest) (*groupSendResult, error)

func (*WSProxyTransport) UpdateGroupPolicy

func (t *WSProxyTransport) UpdateGroupPolicy(ctx context.Context, request GroupGetRequest, patch map[string]any) (map[string]any, error)

func (*WSProxyTransport) UpdateGroupProfile

func (t *WSProxyTransport) UpdateGroupProfile(ctx context.Context, request GroupGetRequest, patch map[string]any) (map[string]any, error)

Jump to

Keyboard shortcuts

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