Documentation
¶
Overview ¶
Package weshnet contains code for integrating the Berty protocol in your project.
See https://berty.tech/protocol for more information.
Index ¶
- Constants
- Variables
- func ConnectAll(t testing.TB, m mocknet.Mocknet)
- func ConnectInLine(t testing.TB, m mocknet.Mocknet)
- func CreateMultiMemberGroupInstance(ctx context.Context, t *testing.T, tps ...*TestingProtocol) *protocoltypes.Group
- func CreatePeersWithGroupTest(ctx context.Context, t testing.TB, pathBase string, memberCount int, ...) ([]*mockedPeer, crypto.PrivKey, func())
- func DefaultOrbitDBOptions(g *protocoltypes.Group, options *orbitdb.CreateDBOptions, ...) (*orbitdb.CreateDBOptions, error)
- func FilterGroupForReplication(m *protocoltypes.Group) (*protocoltypes.Group, error)
- func GetRootDatastoreForPath(dir string, key []byte, salt []byte, logger *zap.Logger) (datastore.Batching, error)
- func MetadataStoreAddDeviceToGroup(ctx context.Context, m *MetadataStore, g *protocoltypes.Group, ...) (operation.Operation, error)
- func MetadataStoreSendSecret(ctx context.Context, m *MetadataStore, g *protocoltypes.Group, ...) (operation.Operation, error)
- func NewGroupMultiMember() (*protocoltypes.Group, crypto.PrivKey, error)
- func NewOrbitDatastoreCache(ds datastore.Batching) cache.Interface
- func NewSimpleAccessController(_ context.Context, _ iface.BaseOrbitDB, params accesscontroller.ManifestParams, ...) (accesscontroller.Interface, error)
- func RestoreAccountExport(ctx context.Context, reader io.Reader, coreAPI coreiface.CoreAPI, ...) error
- type AccountContact
- type AccountKeys
- type BertySignedKeyStore
- func (s *BertySignedKeyStore) CreateKey(ctx context.Context, id string) (crypto.PrivKey, error)
- func (s *BertySignedKeyStore) GetKey(_ context.Context, id string) (crypto.PrivKey, error)
- func (s *BertySignedKeyStore) HasKey(_ context.Context, id string) (bool, error)
- func (s *BertySignedKeyStore) SetKey(pk crypto.PrivKey) error
- func (s *BertySignedKeyStore) Sign(privKey crypto.PrivKey, bytes []byte) ([]byte, error)
- func (s *BertySignedKeyStore) Verify(signature []byte, publicKey crypto.PubKey, data []byte) error
- type ConnectTestingProtocolFunc
- type ConnectednessManager
- type ConnectednessType
- type ConnectednessUpdate
- type EventMetadataReceived
- type FallBackOption
- type GroupContext
- func (gc *GroupContext) ActivateGroupContext(contactPK crypto.PubKey) (err error)
- func (gc *GroupContext) Close() error
- func (gc *GroupContext) DevicePubKey() crypto.PubKey
- func (gc *GroupContext) Group() *protocoltypes.Group
- func (gc *GroupContext) IsClosed() bool
- func (gc *GroupContext) MemberPubKey() crypto.PubKey
- func (gc *GroupContext) MessageStore() *MessageStore
- func (gc *GroupContext) MetadataStore() *MetadataStore
- func (gc *GroupContext) SecretStore() secretstore.SecretStore
- func (gc *GroupContext) TagGroupContextPeers(ipfsCoreAPI ipfsutil.ExtendedCoreAPI, weight int)
- func (gc *GroupContext) WaitForDeviceAdded(ctx context.Context, devicePK crypto.PubKey) (found chan struct{})
- type GroupContextMap
- type GroupMap
- type GroupOpenMode
- type GroupStatus
- type GroupsSigPubKeyMap
- type MessageStore
- func (m *MessageStore) AddMessage(ctx context.Context, payload []byte) (operation.Operation, error)
- func (m *MessageStore) CacheSizeForDevicePK(devicePK []byte) (size int, ok bool)
- func (m *MessageStore) Close() error
- func (m *MessageStore) GetMessageByCID(c cid.Cid) (operation.Operation, error)
- func (m *MessageStore) GetOutOfStoreMessageEnvelope(_ context.Context, c cid.Cid) (*protocoltypes.OutOfStoreMessageEnvelope, error)
- func (m *MessageStore) ListEvents(ctx context.Context, since, until []byte, reverse bool) (<-chan *protocoltypes.GroupMessageEvent, error)
- func (m *MessageStore) ProcessMessageQueueForDevicePK(ctx context.Context, devicePK []byte)
- type MetadataStore
- func (m *MetadataStore) AddDeviceToGroup(ctx context.Context) (operation.Operation, error)
- func (m *MetadataStore) ClaimGroupOwnership(ctx context.Context, groupSK crypto.PrivKey) (operation.Operation, error)
- func (m *MetadataStore) Close() error
- func (m *MetadataStore) ContactBlock(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestDisable(ctx context.Context) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestEnable(ctx context.Context) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestIncomingAccept(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestIncomingDiscard(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestIncomingReceived(ctx context.Context, contact *protocoltypes.ShareableContact) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestOutgoingEnqueue(ctx context.Context, contact *protocoltypes.ShareableContact, ...) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestOutgoingSent(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
- func (m *MetadataStore) ContactRequestReferenceReset(ctx context.Context) (operation.Operation, error)
- func (m *MetadataStore) ContactSendAliasKey(ctx context.Context) (operation.Operation, error)
- func (m *MetadataStore) ContactUnblock(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
- func (m *MetadataStore) GetContactFromGroupPK(groupPK []byte) *protocoltypes.ShareableContact
- func (m *MetadataStore) GetDevicesForMember(pk crypto.PubKey) ([]crypto.PubKey, error)
- func (m *MetadataStore) GetIncomingContactRequestsStatus() (bool, *protocoltypes.ShareableContact)
- func (m *MetadataStore) GetMemberByDevice(pk crypto.PubKey) (crypto.PubKey, error)
- func (m *MetadataStore) GetRequestOwnMetadataForContact(pk []byte) ([]byte, error)
- func (m *MetadataStore) GroupJoin(ctx context.Context, g *protocoltypes.Group) (operation.Operation, error)
- func (m *MetadataStore) GroupLeave(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
- func (m *MetadataStore) ListAdmins() []crypto.PubKey
- func (m *MetadataStore) ListContacts() map[string]*AccountContact
- func (m *MetadataStore) ListContactsByStatus(states ...protocoltypes.ContactState) []*protocoltypes.ShareableContact
- func (m *MetadataStore) ListDevices() []crypto.PubKey
- func (m *MetadataStore) ListEvents(_ context.Context, since, until []byte, reverse bool) (<-chan *protocoltypes.GroupMetadataEvent, error)
- func (m *MetadataStore) ListMembers() []crypto.PubKey
- func (m *MetadataStore) ListMultiMemberGroups() []*protocoltypes.Group
- func (m *MetadataStore) ListOtherMembersDevices() []crypto.PubKey
- func (m *MetadataStore) ListVerifiedCredentials() []*protocoltypes.AccountVerifiedCredentialRegistered
- func (m *MetadataStore) SendAccountVerifiedCredentialAdded(ctx context.Context, token *protocoltypes.AccountVerifiedCredentialRegistered) (operation.Operation, error)
- func (m *MetadataStore) SendAliasProof(ctx context.Context) (operation.Operation, error)
- func (m *MetadataStore) SendAppMetadata(ctx context.Context, message []byte) (operation.Operation, error)
- func (m *MetadataStore) SendGroupReplicating(ctx context.Context, authenticationURL, replicationServer string) (operation.Operation, error)
- func (m *MetadataStore) SendSecret(ctx context.Context, memberPK crypto.PubKey) (operation.Operation, error)
- type NewOrbitDBOptions
- type OOSMOption
- type OOSMService
- type OOSMServiceClient
- type Opts
- type OrbitDBMessageMarshaler
- func (m *OrbitDBMessageMarshaler) GetDevicePKForPeerID(id peer.ID) (pdg *PeerDeviceGroup, ok bool)
- func (m *OrbitDBMessageMarshaler) Marshal(msg *iface.MessageExchangeHeads) ([]byte, error)
- func (m *OrbitDBMessageMarshaler) RegisterGroup(sid string, group *protocoltypes.Group)
- func (m *OrbitDBMessageMarshaler) RegisterSharedKeyForTopic(topic string, sk enc.SharedKey)
- func (m *OrbitDBMessageMarshaler) Unmarshal(payload []byte, msg *iface.MessageExchangeHeads) error
- type PeerDeviceGroup
- type PeerStatus
- type PeersConnectedness
- type RestoreAccountHandler
- type Service
- type ServiceClient
- func NewClientFromService(ctx context.Context, s *grpc.Server, svc Service, opts ...grpc.DialOption) (ServiceClient, error)
- func NewInMemoryServiceClient() (ServiceClient, error)
- func NewPersistentServiceClient(path string) (ServiceClient, error)
- func NewServiceClient(opts Opts) (ServiceClient, error)
- func TestingClient(ctx context.Context, t testing.TB, svc Service, clientOpts []grpc.DialOption, ...) (client ServiceClient, cleanup func())
- func TestingClientFromServer(ctx context.Context, t testing.TB, s *grpc.Server, svc Service, ...) (client ServiceClient, cleanup func())
- type ServiceMethods
- type Status
- type Swiper
- type TestingOpts
- type TestingProtocol
- type WeshOrbitDB
- func (s *WeshOrbitDB) GetDevicePKForPeerID(id peer.ID) (pdg *PeerDeviceGroup, ok bool)
- func (s *WeshOrbitDB) IsGroupLoaded(groupID string) bool
- func (s *WeshOrbitDB) OpenGroup(ctx context.Context, g *protocoltypes.Group, options *orbitdb.CreateDBOptions) (*GroupContext, error)
- func (s *WeshOrbitDB) OpenGroupReplication(ctx context.Context, g *protocoltypes.Group, options *orbitdb.CreateDBOptions) (iface.Store, iface.Store, error)
- func (s *WeshOrbitDB) SetGroupSigPubKey(groupID string, pubKey crypto.PubKey) error
Examples ¶
Constants ¶
const ( NamespaceOrbitDBDatastore = "orbitdb_datastore" NamespaceOrbitDBDirectory = "orbitdb" NamespaceIPFSDatastore = "ipfs_datastore" )
const ( TyberEventTinderPeerFound = "Tinder peer found" TyberEventTinderPeerJoined = "Tinder peer joined" TyberEventTinderPeerLeft = "Tinder peer left" )
const ClientBufferSize = 4 * 1024 * 1024
const CurrentGroupVersion = 1
const InMemoryDir = ":memory:"
Variables ¶
var InMemoryDirectory = cacheleveldown.InMemoryDirectory
var WithLogger = func(l *zap.Logger) OOSMOption { return func(s *oosmService) error { s.logger = l return nil } }
WithLogger set the given logger.
var WithRootDatastore = func(ds ds.Datastore) OOSMOption { return func(s *oosmService) error { s.rootDatastore = ds return nil } }
WithRootDatastore set the root datastore.
var WithSecretStore = func(ss secretstore.SecretStore) OOSMOption { return func(s *oosmService) error { s.secretStore = ss return nil } }
WithSecretStore set the secret store.
Functions ¶
func ConnectAll ¶
ConnectAll peers between themselves
func CreateMultiMemberGroupInstance ¶
func CreateMultiMemberGroupInstance(ctx context.Context, t *testing.T, tps ...*TestingProtocol) *protocoltypes.Group
func DefaultOrbitDBOptions ¶
func DefaultOrbitDBOptions(g *protocoltypes.Group, options *orbitdb.CreateDBOptions, keystore *BertySignedKeyStore, storeType string, groupOpenMode GroupOpenMode) (*orbitdb.CreateDBOptions, error)
func FilterGroupForReplication ¶
func FilterGroupForReplication(m *protocoltypes.Group) (*protocoltypes.Group, error)
func GetRootDatastoreForPath ¶
func MetadataStoreAddDeviceToGroup ¶
func MetadataStoreAddDeviceToGroup(ctx context.Context, m *MetadataStore, g *protocoltypes.Group, md secretstore.OwnMemberDevice) (operation.Operation, error)
func MetadataStoreSendSecret ¶
func MetadataStoreSendSecret(ctx context.Context, m *MetadataStore, g *protocoltypes.Group, md secretstore.OwnMemberDevice, memberPK crypto.PubKey, encryptedSecret []byte) (operation.Operation, error)
func NewGroupMultiMember ¶
func NewGroupMultiMember() (*protocoltypes.Group, crypto.PrivKey, error)
NewGroupMultiMember creates a new Group object and an invitation to be used by the first member of the group
func NewSimpleAccessController ¶
func NewSimpleAccessController(_ context.Context, _ iface.BaseOrbitDB, params accesscontroller.ManifestParams, options ...accesscontroller.Option) (accesscontroller.Interface, error)
NewSimpleAccessController Returns a non configurable access controller
func RestoreAccountExport ¶
Types ¶
type AccountContact ¶
type AccountContact struct {
// contains filtered or unexported fields
}
type AccountKeys ¶
type AccountKeys interface { AccountPrivKey() (crypto.PrivKey, error) AccountProofPrivKey() (crypto.PrivKey, error) DevicePrivKey() (crypto.PrivKey, error) ContactGroupPrivKey(pk crypto.PubKey) (crypto.PrivKey, error) MemberDeviceForGroup(g *protocoltypes.Group) (secretstore.OwnMemberDevice, error) }
type BertySignedKeyStore ¶
type ConnectTestingProtocolFunc ¶
Connect Peers Helper
type ConnectednessManager ¶
type ConnectednessManager struct {
// contains filtered or unexported fields
}
func NewConnectednessManager ¶
func NewConnectednessManager() *ConnectednessManager
func (*ConnectednessManager) AssociatePeer ¶
func (m *ConnectednessManager) AssociatePeer(group string, peer peer.ID)
AssociatePeer associate a peer to a group
func (*ConnectednessManager) UpdateState ¶
func (m *ConnectednessManager) UpdateState(peer peer.ID, update ConnectednessType)
UpdateState update peer current connectedness state
func (*ConnectednessManager) WaitForConnectednessChange ¶
func (m *ConnectednessManager) WaitForConnectednessChange(ctx context.Context, gkey string, current PeersConnectedness) ([]peer.ID, bool)
WaitForConnectednessChange wait until the given `current` peers status differ from `local` peers state
type ConnectednessType ¶
type ConnectednessType int
const ( ConnectednessTypeDisconnected ConnectednessType = iota ConnectednessTypeReconnecting ConnectednessTypeConnected )
type ConnectednessUpdate ¶
type ConnectednessUpdate struct { Peer peer.ID Status ConnectednessType }
type EventMetadataReceived ¶
type EventMetadataReceived struct { MetaEvent *protocoltypes.GroupMetadataEvent Event proto.Message }
type FallBackOption ¶
type FallBackOption struct {
// contains filtered or unexported fields
}
FallBackOption is a structure that permit to fallback to a default option if the option is not set.
type GroupContext ¶
type GroupContext struct {
// contains filtered or unexported fields
}
func NewContextGroup ¶
func NewContextGroup(group *protocoltypes.Group, metadataStore *MetadataStore, messageStore *MessageStore, secretStore secretstore.SecretStore, memberDevice secretstore.OwnMemberDevice, logger *zap.Logger) *GroupContext
func (*GroupContext) ActivateGroupContext ¶
func (gc *GroupContext) ActivateGroupContext(contactPK crypto.PubKey) (err error)
func (*GroupContext) Close ¶
func (gc *GroupContext) Close() error
func (*GroupContext) DevicePubKey ¶
func (gc *GroupContext) DevicePubKey() crypto.PubKey
func (*GroupContext) Group ¶
func (gc *GroupContext) Group() *protocoltypes.Group
func (*GroupContext) IsClosed ¶
func (gc *GroupContext) IsClosed() bool
func (*GroupContext) MemberPubKey ¶
func (gc *GroupContext) MemberPubKey() crypto.PubKey
func (*GroupContext) MessageStore ¶
func (gc *GroupContext) MessageStore() *MessageStore
func (*GroupContext) MetadataStore ¶
func (gc *GroupContext) MetadataStore() *MetadataStore
func (*GroupContext) SecretStore ¶
func (gc *GroupContext) SecretStore() secretstore.SecretStore
func (*GroupContext) TagGroupContextPeers ¶
func (gc *GroupContext) TagGroupContextPeers(ipfsCoreAPI ipfsutil.ExtendedCoreAPI, weight int)
func (*GroupContext) WaitForDeviceAdded ¶
func (gc *GroupContext) WaitForDeviceAdded(ctx context.Context, devicePK crypto.PubKey) (found chan struct{})
type GroupContextMap ¶
type GroupOpenMode ¶
type GroupOpenMode uint64
const ( GroupOpenModeUndefined GroupOpenMode = iota GroupOpenModeReplicate GroupOpenModeWrite )
type GroupStatus ¶
type GroupStatus struct {
// contains filtered or unexported fields
}
type GroupsSigPubKeyMap ¶
type MessageStore ¶
FIXME: replace cache by a circular buffer to avoid an attack by RAM saturation
func (*MessageStore) AddMessage ¶
func (*MessageStore) CacheSizeForDevicePK ¶
func (m *MessageStore) CacheSizeForDevicePK(devicePK []byte) (size int, ok bool)
func (*MessageStore) Close ¶
func (m *MessageStore) Close() error
func (*MessageStore) GetMessageByCID ¶
func (m *MessageStore) GetMessageByCID(c cid.Cid) (operation.Operation, error)
func (*MessageStore) GetOutOfStoreMessageEnvelope ¶
func (m *MessageStore) GetOutOfStoreMessageEnvelope(_ context.Context, c cid.Cid) (*protocoltypes.OutOfStoreMessageEnvelope, error)
func (*MessageStore) ListEvents ¶
func (m *MessageStore) ListEvents(ctx context.Context, since, until []byte, reverse bool) (<-chan *protocoltypes.GroupMessageEvent, error)
FIXME: use iterator instead to reduce resource usage (require go-ipfs-log improvements)
func (*MessageStore) ProcessMessageQueueForDevicePK ¶
func (m *MessageStore) ProcessMessageQueueForDevicePK(ctx context.Context, devicePK []byte)
type MetadataStore ¶
func (*MetadataStore) AddDeviceToGroup ¶
func (*MetadataStore) ClaimGroupOwnership ¶
func (*MetadataStore) Close ¶
func (m *MetadataStore) Close() error
func (*MetadataStore) ContactBlock ¶
func (m *MetadataStore) ContactBlock(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
ContactBlock indicates the payload includes that the deviceKeystore has blocked a contact
func (*MetadataStore) ContactRequestDisable ¶
ContactRequestDisable indicates the payload includes that the deviceKeystore has disabled incoming contact requests
func (*MetadataStore) ContactRequestEnable ¶
ContactRequestEnable indicates the payload includes that the deviceKeystore has enabled incoming contact requests
func (*MetadataStore) ContactRequestIncomingAccept ¶
func (m *MetadataStore) ContactRequestIncomingAccept(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
ContactRequestIncomingAccept indicates the payload includes that the deviceKeystore has accepted a contact request
func (*MetadataStore) ContactRequestIncomingDiscard ¶
func (m *MetadataStore) ContactRequestIncomingDiscard(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
ContactRequestIncomingDiscard indicates the payload includes that the deviceKeystore has ignored a contact request
func (*MetadataStore) ContactRequestIncomingReceived ¶
func (m *MetadataStore) ContactRequestIncomingReceived(ctx context.Context, contact *protocoltypes.ShareableContact) (operation.Operation, error)
ContactRequestIncomingReceived indicates the payload includes that the deviceKeystore has received a contact request
func (*MetadataStore) ContactRequestOutgoingEnqueue ¶
func (m *MetadataStore) ContactRequestOutgoingEnqueue(ctx context.Context, contact *protocoltypes.ShareableContact, ownMetadata []byte) (operation.Operation, error)
ContactRequestOutgoingEnqueue indicates the payload includes that the deviceKeystore will attempt to send a new contact request
func (*MetadataStore) ContactRequestOutgoingSent ¶
func (m *MetadataStore) ContactRequestOutgoingSent(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
ContactRequestOutgoingSent indicates the payload includes that the deviceKeystore has sent a contact request
func (*MetadataStore) ContactRequestReferenceReset ¶
func (m *MetadataStore) ContactRequestReferenceReset(ctx context.Context) (operation.Operation, error)
ContactRequestReferenceReset indicates the payload includes that the deviceKeystore has a new contact request reference
func (*MetadataStore) ContactSendAliasKey ¶
func (*MetadataStore) ContactUnblock ¶
func (m *MetadataStore) ContactUnblock(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
ContactUnblock indicates the payload includes that the deviceKeystore has unblocked a contact
func (*MetadataStore) GetContactFromGroupPK ¶
func (m *MetadataStore) GetContactFromGroupPK(groupPK []byte) *protocoltypes.ShareableContact
func (*MetadataStore) GetDevicesForMember ¶
func (*MetadataStore) GetIncomingContactRequestsStatus ¶
func (m *MetadataStore) GetIncomingContactRequestsStatus() (bool, *protocoltypes.ShareableContact)
func (*MetadataStore) GetMemberByDevice ¶
func (*MetadataStore) GetRequestOwnMetadataForContact ¶
func (m *MetadataStore) GetRequestOwnMetadataForContact(pk []byte) ([]byte, error)
func (*MetadataStore) GroupJoin ¶
func (m *MetadataStore) GroupJoin(ctx context.Context, g *protocoltypes.Group) (operation.Operation, error)
GroupJoin indicates the payload includes that the deviceKeystore has joined a group
func (*MetadataStore) GroupLeave ¶
func (m *MetadataStore) GroupLeave(ctx context.Context, pk crypto.PubKey) (operation.Operation, error)
GroupLeave indicates the payload includes that the deviceKeystore has left a group
func (*MetadataStore) ListAdmins ¶
func (m *MetadataStore) ListAdmins() []crypto.PubKey
func (*MetadataStore) ListContacts ¶
func (m *MetadataStore) ListContacts() map[string]*AccountContact
func (*MetadataStore) ListContactsByStatus ¶
func (m *MetadataStore) ListContactsByStatus(states ...protocoltypes.ContactState) []*protocoltypes.ShareableContact
func (*MetadataStore) ListDevices ¶
func (m *MetadataStore) ListDevices() []crypto.PubKey
func (*MetadataStore) ListEvents ¶
func (m *MetadataStore) ListEvents(_ context.Context, since, until []byte, reverse bool) (<-chan *protocoltypes.GroupMetadataEvent, error)
FIXME: use iterator instead to reduce resource usage (require go-ipfs-log improvements)
func (*MetadataStore) ListMembers ¶
func (m *MetadataStore) ListMembers() []crypto.PubKey
func (*MetadataStore) ListMultiMemberGroups ¶
func (m *MetadataStore) ListMultiMemberGroups() []*protocoltypes.Group
func (*MetadataStore) ListOtherMembersDevices ¶
func (m *MetadataStore) ListOtherMembersDevices() []crypto.PubKey
func (*MetadataStore) ListVerifiedCredentials ¶
func (m *MetadataStore) ListVerifiedCredentials() []*protocoltypes.AccountVerifiedCredentialRegistered
func (*MetadataStore) SendAccountVerifiedCredentialAdded ¶
func (m *MetadataStore) SendAccountVerifiedCredentialAdded(ctx context.Context, token *protocoltypes.AccountVerifiedCredentialRegistered) (operation.Operation, error)
func (*MetadataStore) SendAliasProof ¶
func (*MetadataStore) SendAppMetadata ¶
func (*MetadataStore) SendGroupReplicating ¶
func (*MetadataStore) SendSecret ¶
type NewOrbitDBOptions ¶
type NewOrbitDBOptions struct { baseorbitdb.NewOrbitDBOptions Datastore datastore.Batching SecretStore secretstore.SecretStore RotationInterval *rendezvous.RotationInterval PrometheusRegister prometheus.Registerer GroupMetadataStoreType string GroupMessageStoreType string ReplicationMode bool }
type OOSMOption ¶
type OOSMOption func(*oosmService) error
var WithDefaultLogger OOSMOption = func(s *oosmService) error { s.logger = zap.NewNop() return nil }
WithDefaultLogger init a noop logger.
var WithDefaultRootDatastore OOSMOption = func(s *oosmService) error { s.rootDatastore = ds_sync.MutexWrap(ds.NewMapDatastore()) return nil }
WithDefaultRootDatastore init a in-memory datastore.
var WithDefaultSecretStore OOSMOption = func(s *oosmService) error { if err := WithFallbackRootDatastore(s); err != nil { return err } if err := WithFallbackLogger(s); err != nil { return err } var err error s.secretStore, err = secretstore.NewSecretStore(s.rootDatastore, &secretstore.NewSecretStoreOptions{ Logger: s.logger, }) return err }
WithDefaultSecretStore init a new secret store. Call WithRootDatastore before this option if you want to use your datastore. Call WithLogger before this option if you want to use your logger.
var WithFallbackDefaults OOSMOption = func(s *oosmService) error { for _, def := range defaults { if !def.fallback(s) { continue } if err := def.opt(s); err != nil { return err } } return nil }
WithFallbackDefaults set the default options if no option is set.
var WithFallbackLogger OOSMOption = func(s *oosmService) error { if fallbackLogger.fallback(s) { return fallbackLogger.opt(s) } return nil }
WithFallbackLogger set the logger if no logger is set.
var WithFallbackRootDatastore OOSMOption = func(s *oosmService) error { if fallbackRootDatastore.fallback(s) { return fallbackRootDatastore.opt(s) } return nil }
WithFallbackRootDatastore set the root datastore if no root datastore is set.
var WithFallbackSecretStore OOSMOption = func(s *oosmService) error { if fallbackSecretStore.fallback(s) { return fallbackSecretStore.opt(s) } return nil }
WithFallbackSecretStore set the secret store if no secret store is set. Call WithRootDatastore before this option if you want to use your datastore if a new secret store is created. Call WithLogger before this option if you want to use your logger if a new secret store is created.
type OOSMService ¶
type OOSMService interface { outofstoremessagetypes.OutOfStoreMessageServiceServer }
func NewOutOfStoreMessageService ¶
func NewOutOfStoreMessageService(opts ...OOSMOption) (OOSMService, error)
type OOSMServiceClient ¶
type OOSMServiceClient interface { outofstoremessagetypes.OutOfStoreMessageServiceClient io.Closer }
func NewOutOfStoreMessageServiceClient ¶
func NewOutOfStoreMessageServiceClient(opts ...OOSMOption) (OOSMServiceClient, error)
NewOutOfStoreMessageServiceClient creates a new Wesh protocol service and returns a gRPC ServiceClient which uses a direct in-memory connection. When finished, you must call Close(). This opens or creates a Wesh account where the datastore location is specified by the path argument. The service will not start any network stuff, it will only use the filesystem to store or get data.
type Opts ¶
type Opts struct { Logger *zap.Logger IpfsCoreAPI ipfsutil.ExtendedCoreAPI DatastoreDir string RootDatastore ds.Batching OrbitDB *WeshOrbitDB TinderService *tinder.Service Host host.Host PubSub *pubsub.PubSub GRPCInsecureMode bool LocalOnly bool SecretStore secretstore.SecretStore PrometheusRegister prometheus.Registerer // These are used if OrbitDB is nil. GroupMetadataStoreType string GroupMessageStoreType string // contains filtered or unexported fields }
Opts contains optional configuration flags for building a new Client
type OrbitDBMessageMarshaler ¶
type OrbitDBMessageMarshaler struct {
// contains filtered or unexported fields
}
func NewOrbitDBMessageMarshaler ¶
func NewOrbitDBMessageMarshaler(selfid peer.ID, secretStore secretstore.SecretStore, rp *rendezvous.RotationInterval, useReplicationMode bool) *OrbitDBMessageMarshaler
func (*OrbitDBMessageMarshaler) GetDevicePKForPeerID ¶
func (m *OrbitDBMessageMarshaler) GetDevicePKForPeerID(id peer.ID) (pdg *PeerDeviceGroup, ok bool)
func (*OrbitDBMessageMarshaler) Marshal ¶
func (m *OrbitDBMessageMarshaler) Marshal(msg *iface.MessageExchangeHeads) ([]byte, error)
func (*OrbitDBMessageMarshaler) RegisterGroup ¶
func (m *OrbitDBMessageMarshaler) RegisterGroup(sid string, group *protocoltypes.Group)
func (*OrbitDBMessageMarshaler) RegisterSharedKeyForTopic ¶
func (m *OrbitDBMessageMarshaler) RegisterSharedKeyForTopic(topic string, sk enc.SharedKey)
func (*OrbitDBMessageMarshaler) Unmarshal ¶
func (m *OrbitDBMessageMarshaler) Unmarshal(payload []byte, msg *iface.MessageExchangeHeads) error
type PeerDeviceGroup ¶
type PeerDeviceGroup struct { Group *protocoltypes.Group DevicePK crypto.PubKey }
type PeerStatus ¶
type PeerStatus struct {
// contains filtered or unexported fields
}
type PeersConnectedness ¶
type PeersConnectedness map[peer.ID]ConnectednessType
type RestoreAccountHandler ¶
type Service ¶
type Service interface { protocoltypes.ProtocolServiceServer Close() error Status() Status IpfsCoreAPI() coreiface.CoreAPI }
Service is the main Berty Protocol interface
func NewService ¶
NewService initializes a new Service using the opts. If opts.RootDatastore is nil and opts.DatastoreDir is "" or InMemoryDirectory, then set opts.RootDatastore to an in-memory data store. Otherwise, if opts.RootDatastore is nil then set opts.RootDatastore to a persistent data store at opts.DatastoreDir .
Example (Basic) ¶
// disable ressources manager for test os.Setenv("LIBP2P_RCMGR", "false") ctx, cancel := context.WithCancel(context.Background()) defer cancel() client, err := weshnet.NewService(weshnet.Opts{}) if err != nil { panic(err) } defer client.Close() ret, err := client.ServiceGetConfiguration(ctx, &protocoltypes.ServiceGetConfiguration_Request{}) if err != nil { panic(err) } for _, listener := range ret.Listeners { if listener == "/p2p-circuit" { fmt.Println(listener) } }
Output: /p2p-circuit
type ServiceClient ¶
type ServiceClient interface { protocoltypes.ProtocolServiceClient io.Closer }
func NewClientFromService ¶
func NewClientFromService(ctx context.Context, s *grpc.Server, svc Service, opts ...grpc.DialOption) (ServiceClient, error)
func NewInMemoryServiceClient ¶
func NewInMemoryServiceClient() (ServiceClient, error)
NewInMemoryServiceClient creates a new in-memory Wesh protocol service and returns a gRPC ServiceClient which uses a direct in-memory connection. When finished, you must call Close(). This creates a new Wesh account where the key store is in memory. (If you don't export the data then it is lost when you call Close(). ) The IPFS node, cached data, and configuration are also in memory.
Example (Basic) ¶
// disable ressources manager for test os.Setenv("LIBP2P_RCMGR", "false") ctx, cancel := context.WithCancel(context.Background()) defer cancel() client, err := weshnet.NewInMemoryServiceClient() if err != nil { panic(err) } defer client.Close() ret, err := client.ServiceGetConfiguration(ctx, &protocoltypes.ServiceGetConfiguration_Request{}) if err != nil { panic(err) } for _, listener := range ret.Listeners { if listener == "/p2p-circuit" { fmt.Println(listener) } }
Output: /p2p-circuit
func NewPersistentServiceClient ¶
func NewPersistentServiceClient(path string) (ServiceClient, error)
NewPersistentServiceClient creates a Wesh protocol service using persistent storage files in the directory given by the directory path. If the directory doesn't exist, this creates it with files of a new Wesh account and peer identity. (If the directory doesn't exist, this will create it only if the parent directory exists. Otherwise you must first create the parent directories.) However, if the persistent storage files already exist, then this opens them to use the existing Wesh account and peer identity. This returns a gRPC ServiceClient which uses a direct in-memory connection. When finished, you must call Close().
Example (Basic) ¶
// disable ressources manager for test os.Setenv("LIBP2P_RCMGR", "false") ctx, cancel := context.WithCancel(context.Background()) defer cancel() // create a temporary path to host data of our persistent service path, err := os.MkdirTemp("", "weshnet-test-persistent") if err != nil { panic(err) } defer os.RemoveAll(path) var peerid string // open once { client, err := weshnet.NewPersistentServiceClient(path) if err != nil { panic(err) } ret, err := client.ServiceGetConfiguration(ctx, &protocoltypes.ServiceGetConfiguration_Request{}) if err != nil { panic(err) } peerid = ret.PeerId if err := client.Close(); err != nil { panic(err) } } // open twice { client, err := weshnet.NewPersistentServiceClient(path) if err != nil { panic(err) } defer client.Close() ret, err := client.ServiceGetConfiguration(ctx, &protocoltypes.ServiceGetConfiguration_Request{}) if err != nil { panic(err) } if peerid != ret.PeerId { panic("peerid should be identical") } }
Output:
func NewServiceClient ¶
func NewServiceClient(opts Opts) (ServiceClient, error)
NewServiceClient initializes a new ServiceClient using the opts. If opts.RootDatastore is nil and opts.DatastoreDir is "" or InMemoryDirectory, then set opts.RootDatastore to an in-memory data store. Otherwise, if opts.RootDatastore is nil then set opts.RootDatastore to a persistent data store at opts.DatastoreDir .
Example (Basic) ¶
// disable ressources manager for test os.Setenv("LIBP2P_RCMGR", "false") ctx, cancel := context.WithCancel(context.Background()) defer cancel() client, err := weshnet.NewServiceClient(weshnet.Opts{}) if err != nil { panic(err) } defer client.Close() ret, err := client.ServiceGetConfiguration(ctx, &protocoltypes.ServiceGetConfiguration_Request{}) if err != nil { panic(err) } for _, listener := range ret.Listeners { if listener == "/p2p-circuit" { fmt.Println(listener) } }
Output: /p2p-circuit
func TestingClient ¶
func TestingClient(ctx context.Context, t testing.TB, svc Service, clientOpts []grpc.DialOption, serverOpts []grpc.ServerOption) (client ServiceClient, cleanup func())
func TestingClientFromServer ¶
func TestingClientFromServer(ctx context.Context, t testing.TB, s *grpc.Server, svc Service, dialOpts ...grpc.DialOption) (client ServiceClient, cleanup func())
type ServiceMethods ¶
type ServiceMethods interface {
GetContextGroupForID(id []byte) (*GroupContext, error)
}
type Swiper ¶
type Swiper struct {
// contains filtered or unexported fields
}
func NewSwiper ¶
func NewSwiper(logger *zap.Logger, tinder *tinder.Service, rp *rendezvous.RotationInterval) *Swiper
func (*Swiper) RefreshContactRequest ¶
type TestingOpts ¶
type TestingOpts struct { Logger *zap.Logger Mocknet mocknet.Mocknet DiscoveryServer *tinder.MockDriverServer SecretStore secretstore.SecretStore CoreAPIMock ipfsutil.CoreAPIMock OrbitDB *WeshOrbitDB ConnectFunc ConnectTestingProtocolFunc }
type TestingProtocol ¶
type TestingProtocol struct { Opts *Opts Service Service Client ServiceClient RootDatastore datastore.Batching IpfsCoreAPI ipfsutil.ExtendedCoreAPI OrbitDB *WeshOrbitDB SecretStore secretstore.SecretStore }
func NewTestingProtocol ¶
func NewTestingProtocol(ctx context.Context, t testing.TB, opts *TestingOpts, ds datastore.Batching) (*TestingProtocol, func())
func NewTestingProtocolWithMockedPeers ¶
func NewTestingProtocolWithMockedPeers(ctx context.Context, t testing.TB, opts *TestingOpts, ds datastore.Batching, amount int) ([]*TestingProtocol, func())
type WeshOrbitDB ¶
type WeshOrbitDB struct { baseorbitdb.BaseOrbitDB // contains filtered or unexported fields }
func NewTestOrbitDB ¶
func NewWeshOrbitDB ¶
func NewWeshOrbitDB(ctx context.Context, ipfs coreiface.CoreAPI, options *NewOrbitDBOptions) (*WeshOrbitDB, error)
func (*WeshOrbitDB) GetDevicePKForPeerID ¶
func (s *WeshOrbitDB) GetDevicePKForPeerID(id peer.ID) (pdg *PeerDeviceGroup, ok bool)
func (*WeshOrbitDB) IsGroupLoaded ¶
func (s *WeshOrbitDB) IsGroupLoaded(groupID string) bool
func (*WeshOrbitDB) OpenGroup ¶
func (s *WeshOrbitDB) OpenGroup(ctx context.Context, g *protocoltypes.Group, options *orbitdb.CreateDBOptions) (*GroupContext, error)
func (*WeshOrbitDB) OpenGroupReplication ¶
func (s *WeshOrbitDB) OpenGroupReplication(ctx context.Context, g *protocoltypes.Group, options *orbitdb.CreateDBOptions) (iface.Store, iface.Store, error)
func (*WeshOrbitDB) SetGroupSigPubKey ¶
func (s *WeshOrbitDB) SetGroupSigPubKey(groupID string, pubKey crypto.PubKey) error
SetGroupSigPubKey registers a new group signature pubkey, mainly used to replicate a store data without needing to access to its content
Source Files
¶
- account_export.go
- api_app.go
- api_client.go
- api_contact.go
- api_contactrequest.go
- api_debug.go
- api_event.go
- api_group.go
- api_multimember.go
- api_replication.go
- api_verified_credentials.go
- connectedness_manager.go
- consts.go
- contact_request_manager.go
- doc.go
- events.go
- events_sig_checkers.go
- group.go
- group_context.go
- iface_account.go
- message_marshaler.go
- orbitdb.go
- orbitdb_datastore_cache.go
- orbitdb_signed_entry_accesscontroller.go
- orbitdb_signed_entry_identity_provider.go
- orbitdb_signed_entry_keystore.go
- service.go
- service_client.go
- service_group.go
- service_outofstoremessage.go
- store_message.go
- store_message_metrics.go
- store_message_queue.go
- store_metadata.go
- store_metadata_index.go
- store_options.go
- store_utils.go
- testing.go
- tinder_swiper.go
- tyber.go
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
handshake
Package handshake implements a capability-based handshake.
|
Package handshake implements a capability-based handshake. |
tools
Package tools ensures that `go mod` detect some required dependencies.
|
Package tools ensures that `go mod` detect some required dependencies. |
pkg
|
|
cryptoutil
Package cryptoutil contains generic & stateless crypto helpers.
|
Package cryptoutil contains generic & stateless crypto helpers. |
errcode
Package errcode contains the list of Berty error codes.
|
Package errcode contains the list of Berty error codes. |
grpcutil
Package grpcutil contains gRPC lazy codecs, messages and a buf-based listener.
|
Package grpcutil contains gRPC lazy codecs, messages and a buf-based listener. |
ipfsutil
Package ipfsutil contains helpers around IPFS (logging, datastore, networking, core API, ...).
|
Package ipfsutil contains helpers around IPFS (logging, datastore, networking, core API, ...). |
outofstoremessagetypes
Package outofstoremessagetypes is a reverse proxy.
|
Package outofstoremessagetypes is a reverse proxy. |
protocoltypes
This package is generated with Protobuf.
|
This package is generated with Protobuf. |
replicationtypes
Package replicationtypes is a reverse proxy.
|
Package replicationtypes is a reverse proxy. |
secretstore
Package secretstore contains function related to device, groups and messages keys.
|
Package secretstore contains function related to device, groups and messages keys. |
testutil
Package testutil contains testing helpers (logging, slow skipping).
|
Package testutil contains testing helpers (logging, slow skipping). |