| Copyright | (c) simplex.chat |
|---|---|
| License | AGPL-3 |
| Maintainer | chat@simplex.chat |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Simplex.Messaging.Protocol
Description
Types, parsers, serializers and functions to send and receive SMP protocol commands and responses.
See https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md
Synopsis
- supportedSMPClientVRange :: VersionRangeSMPC
- maxMessageLength :: VersionSMP -> Int
- paddedProxiedTLength :: Int
- e2eEncConfirmationLength :: Int
- e2eEncMessageLength :: Int
- data SMPClientVersion
- type VersionSMPC = Version SMPClientVersion
- type VersionRangeSMPC = VersionRange SMPClientVersion
- pattern VersionSMPC :: Word16 -> VersionSMPC
- class ProtocolMsgTag (Tag msg) => ProtocolEncoding v err msg | msg -> err, msg -> v where
- type Tag msg
- encodeProtocol :: Version v -> msg -> ByteString
- protocolP :: Version v -> Tag msg -> Parser msg
- fromProtocolError :: ProtocolErrorType -> err
- checkCredentials :: Maybe TAuthorizations -> EntityId -> msg -> Either err msg
- data Command (p :: Party) where
- NEW :: NewQueueReq -> Command Creator
- SUB :: Command Recipient
- SUBS :: Command RecipientService
- KEY :: SndPublicAuthKey -> Command Recipient
- RKEY :: NonEmpty RcvPublicAuthKey -> Command Recipient
- LSET :: LinkId -> QueueLinkData -> Command Recipient
- LDEL :: Command Recipient
- NKEY :: NtfPublicAuthKey -> RcvNtfPublicDhKey -> Command Recipient
- NDEL :: Command Recipient
- GET :: Command Recipient
- ACK :: MsgId -> Command Recipient
- OFF :: Command Recipient
- DEL :: Command Recipient
- QUE :: Command Recipient
- SKEY :: SndPublicAuthKey -> Command Sender
- SEND :: MsgFlags -> MsgBody -> Command Sender
- PING :: Command IdleClient
- LKEY :: SndPublicAuthKey -> Command LinkClient
- LGET :: Command LinkClient
- NSUB :: Command Notifier
- NSUBS :: Command NotifierService
- PRXY :: SMPServer -> Maybe BasicAuth -> Command ProxiedClient
- PFWD :: VersionSMP -> PublicKeyX25519 -> EncTransmission -> Command ProxiedClient
- RFWD :: EncFwdTransmission -> Command ProxyService
- data SubscriptionMode
- data NewQueueReq = NewQueueReq {
- rcvAuthKey :: RcvPublicAuthKey
- rcvDhKey :: RcvPublicDhKey
- auth_ :: Maybe BasicAuth
- subMode :: SubscriptionMode
- queueReqData :: Maybe QueueReqData
- ntfCreds :: Maybe NewNtfCreds
- data QueueReqData
- = QRMessaging (Maybe (SenderId, QueueLinkData))
- | QRContact (Maybe (LinkId, (SenderId, QueueLinkData)))
- data QueueMode
- type QueueLinkData = (EncFixedDataBytes, EncUserDataBytes)
- type EncFixedDataBytes = EncDataBytes
- type EncUserDataBytes = EncDataBytes
- newtype EncDataBytes = EncDataBytes ByteString
- data NewNtfCreds = NewNtfCreds NtfPublicAuthKey RcvNtfPublicDhKey
- data ServerNtfCreds = ServerNtfCreds NotifierId RcvNtfPublicDhKey
- data Party
- data Cmd = forall p.PartyI p => Cmd (SParty p) (Command p)
- type family QueueParty (p :: Party) :: Constraint where ...
- type family BatchParty (p :: Party) :: Constraint where ...
- type family ServiceParty (p :: Party) :: Constraint where ...
- data ASubscriberParty = forall p.(PartyI p, ServiceParty p) => ASP (SParty p)
- data BrokerMsg where
- IDS :: QueueIdsKeys -> BrokerMsg
- LNK :: SenderId -> QueueLinkData -> BrokerMsg
- SOK :: Maybe ServiceId -> BrokerMsg
- SOKS :: Int64 -> BrokerMsg
- MSG :: RcvMessage -> BrokerMsg
- NID :: NotifierId -> RcvNtfPublicDhKey -> BrokerMsg
- NMSG :: CbNonce -> EncNMsgMeta -> BrokerMsg
- PKEY :: SessionId -> VersionRangeSMP -> CertChainPubKey -> BrokerMsg
- RRES :: EncFwdResponse -> BrokerMsg
- PRES :: EncResponse -> BrokerMsg
- END :: BrokerMsg
- ENDS :: Int64 -> BrokerMsg
- DELD :: BrokerMsg
- INFO :: QueueInfo -> BrokerMsg
- OK :: BrokerMsg
- ERR :: ErrorType -> BrokerMsg
- PONG :: BrokerMsg
- data SParty :: Party -> Type where
- SCreator :: SParty Creator
- SRecipient :: SParty Recipient
- SRecipientService :: SParty RecipientService
- SSender :: SParty Sender
- SIdleClient :: SParty IdleClient
- SNotifier :: SParty Notifier
- SNotifierService :: SParty NotifierService
- SSenderLink :: SParty LinkClient
- SProxiedClient :: SParty ProxiedClient
- SProxyService :: SParty ProxyService
- class PartyI (p :: Party) where
- data QueueIdsKeys = QIK {
- rcvId :: RecipientId
- sndId :: SenderId
- rcvPublicDhKey :: RcvPublicDhKey
- queueMode :: Maybe QueueMode
- linkId :: Maybe LinkId
- serviceId :: Maybe ServiceId
- serverNtfCreds :: Maybe ServerNtfCreds
- data ProtocolErrorType
- data ErrorType
- data CommandError
- data ProxyError
- = PROTOCOL { }
- | BROKER { }
- | BASIC_AUTH
- | NO_SESSION
- data BrokerErrorType
- = RESPONSE {
- respErr :: String
- | UNEXPECTED {
- respErr :: String
- | NETWORK { }
- | HOST
- | NO_SERVICE
- | TRANSPORT { }
- | TIMEOUT
- = RESPONSE {
- data NetworkError
- = NEConnectError {
- connectError :: String
- | NETLSError {
- tlsError :: String
- | NEUnknownCAError
- | NEFailedError
- | NETimeoutError
- | NESubscribeError {
- subscribeError :: String
- = NEConnectError {
- data BlockingInfo = BlockingInfo {
- reason :: BlockingReason
- notice :: Maybe ClientNotice
- data BlockingReason
- data RawTransmission
- type Transmission c = (CorrId, EntityId, c)
- type TAuthorizations = (TransmissionAuth, Maybe (Signature 'Ed25519))
- data TransmissionAuth
- type SignedTransmission c = (Maybe TAuthorizations, Signed, Transmission c)
- type SignedTransmissionOrError e c = Either (Transmission e) (SignedTransmission c)
- type SentRawTransmission = (Maybe TAuthorizations, ByteString)
- data ClientMsgEnvelope = ClientMsgEnvelope {}
- data PubHeader = PubHeader {
- phVersion :: VersionSMPC
- phE2ePubDhKey :: Maybe PublicKeyX25519
- data ClientMessage = ClientMessage PrivHeader ByteString
- data PrivHeader
- class (ProtocolTypeI (ProtoType msg), ProtocolEncoding v err msg, ProtocolEncoding v err (ProtoCommand msg), Show err, Show msg) => Protocol v err msg | msg -> v, msg -> err where
- type ProtoCommand msg = cmd | cmd -> msg
- type ProtoType msg = (sch :: ProtocolType) | sch -> msg
- protocolClientHandshake :: Transport c => c 'TClient -> Maybe KeyPairX25519 -> KeyHash -> VersionRange v -> Bool -> Maybe (ServiceCredentials, KeyPairEd25519) -> ExceptT TransportError IO (THandle v c 'TClient)
- useServiceAuth :: ProtoCommand msg -> Bool
- protocolPing :: ProtoCommand msg
- protocolError :: msg -> Maybe err
- data ProtocolType
- data SProtocolType (p :: ProtocolType) where
- SPSMP :: SProtocolType 'PSMP
- SPNTF :: SProtocolType 'PNTF
- SPXFTP :: SProtocolType 'PXFTP
- data AProtocolType = forall p.ProtocolTypeI p => AProtocolType (SProtocolType p)
- class ProtocolTypeI (p :: ProtocolType) where
- type family UserProtocol (p :: ProtocolType) :: Constraint where ...
- data ProtocolServer p = ProtocolServer {
- scheme :: SProtocolType p
- host :: NonEmpty TransportHost
- port :: ServiceName
- keyHash :: KeyHash
- type ProtoServer msg = ProtocolServer (ProtoType msg)
- type SMPServer = ProtocolServer 'PSMP
- pattern SMPServer :: NonEmpty TransportHost -> ServiceName -> KeyHash -> ProtocolServer 'PSMP
- type SMPServerWithAuth = ProtoServerWithAuth 'PSMP
- type NtfServer = ProtocolServer 'PNTF
- pattern NtfServer :: NonEmpty TransportHost -> ServiceName -> KeyHash -> ProtocolServer 'PNTF
- type NtfServerWithAuth = ProtoServerWithAuth 'PNTF
- type XFTPServer = ProtocolServer 'PXFTP
- pattern XFTPServer :: NonEmpty TransportHost -> ServiceName -> KeyHash -> ProtocolServer 'PXFTP
- type XFTPServerWithAuth = ProtoServerWithAuth 'PXFTP
- data ProtoServerWithAuth p = ProtoServerWithAuth {
- protoServer :: ProtocolServer p
- serverBasicAuth :: Maybe BasicAuth
- data AProtoServerWithAuth = forall p.ProtocolTypeI p => AProtoServerWithAuth (SProtocolType p) (ProtoServerWithAuth p)
- newtype BasicAuth = BasicAuth {
- unBasicAuth :: ByteString
- data SrvLoc = SrvLoc HostName ServiceName
- newtype CorrId = CorrId {
- bs :: ByteString
- pattern NoCorrId :: CorrId
- newtype EntityId = EntityId {
- unEntityId :: ByteString
- pattern NoEntity :: EntityId
- type QueueId = EntityId
- type RecipientId = QueueId
- type SenderId = QueueId
- type LinkId = QueueId
- type NotifierId = QueueId
- type ServiceId = EntityId
- type RcvPrivateAuthKey = APrivateAuthKey
- type RcvPublicAuthKey = APublicAuthKey
- type RcvPublicDhKey = PublicKeyX25519
- type RcvDhSecret = DhSecretX25519
- type SndPrivateAuthKey = APrivateAuthKey
- type SndPublicAuthKey = APublicAuthKey
- type NtfPrivateAuthKey = APrivateAuthKey
- type NtfPublicAuthKey = APublicAuthKey
- type RcvNtfPublicDhKey = PublicKeyX25519
- type RcvNtfDhSecret = DhSecretX25519
- data Message
- data RcvMessage = RcvMessage {
- msgId :: MsgId
- msgBody :: EncRcvMsgBody
- type MsgId = ByteString
- type MsgBody = ByteString
- type MaxMessageLen = 16088
- type MaxRcvMessageLen = MaxMessageLen + 16
- newtype EncRcvMsgBody = EncRcvMsgBody ByteString
- data RcvMsgBody
- = RcvMsgBody { }
- | RcvMsgQuota {
- msgTs :: SystemTime
- data ClientRcvMsgBody
- = ClientRcvMsgBody { }
- | ClientRcvMsgQuota {
- msgTs :: SystemTime
- type EncNMsgMeta = ByteString
- data SMPMsgMeta = SMPMsgMeta {}
- data NMsgMeta = NMsgMeta {}
- newtype EncFwdResponse = EncFwdResponse ByteString
- newtype EncFwdTransmission = EncFwdTransmission ByteString
- newtype EncResponse = EncResponse ByteString
- newtype EncTransmission = EncTransmission ByteString
- data FwdResponse = FwdResponse {}
- data FwdTransmission = FwdTransmission {}
- data MsgFlags = MsgFlags {
- notification :: Bool
- initialSMPClientVersion :: VersionSMPC
- currentSMPClientVersion :: VersionSMPC
- senderCanSecure :: Maybe QueueMode -> Bool
- queueReqMode :: QueueReqData -> QueueMode
- queueParty :: SParty p -> Maybe (Dict (PartyI p, QueueParty p))
- batchParty :: SParty p -> Maybe (Dict (PartyI p, BatchParty p))
- serviceParty :: SParty p -> Maybe (Dict (PartyI p, ServiceParty p))
- partyClientRole :: SParty p -> Maybe SMPServiceRole
- partyServiceRole :: ServiceParty p => SParty p -> SMPServiceRole
- userProtocol :: SProtocolType p -> Maybe (Dict (UserProtocol p))
- rcvMessageMeta :: MsgId -> ClientRcvMsgBody -> SMPMsgMeta
- noMsgFlags :: MsgFlags
- messageId :: Message -> MsgId
- messageTs :: Message -> SystemTime
- toNetworkError :: SomeException -> NetworkError
- class ProtocolMsgTag t where
- decodeTag :: ByteString -> Maybe t
- messageTagP :: ProtocolMsgTag t => Parser t
- data TransmissionForAuth = TransmissionForAuth {}
- encodeTransmissionForAuth :: ProtocolEncoding v e c => THandleParams v p -> Transmission c -> TransmissionForAuth
- encodeTransmission :: ProtocolEncoding v e c => THandleParams v p -> Transmission c -> ByteString
- transmissionP :: THandleParams v p -> Parser RawTransmission
- _smpP :: Encoding a => Parser a
- encodeRcvMsgBody :: RcvMsgBody -> MaxLenBS MaxRcvMessageLen
- clientRcvMsgBodyP :: Parser ClientRcvMsgBody
- legacyEncodeServer :: ProtocolServer p -> ByteString
- legacyServerP :: forall p. ProtocolTypeI p => Parser (ProtocolServer p)
- legacyStrEncodeServer :: ProtocolTypeI p => ProtocolServer p -> ByteString
- srvHostnamesSMPClientVersion :: VersionSMPC
- sndAuthKeySMPClientVersion :: VersionSMPC
- shortLinksSMPClientVersion :: VersionSMPC
- sameSrvAddr :: ProtocolServer p -> ProtocolServer p -> Bool
- sameSrvAddr' :: ProtoServerWithAuth p -> ProtoServerWithAuth p -> Bool
- noAuthSrv :: ProtocolServer p -> ProtoServerWithAuth p
- toMsgInfo :: Message -> MsgInfo
- data TransportBatch r
- = TBTransmissions ByteString Int [r]
- | TBTransmission ByteString r
- | TBError TransportError r
- tPut :: Transport c => THandle v c p -> NonEmpty (Either TransportError SentRawTransmission) -> IO [Either TransportError ()]
- tPutLog :: Transport c => THandle v c p -> ByteString -> IO (Either TransportError ())
- tGetServer :: (ProtocolEncoding v err cmd, Transport c) => THandle v c 'TServer -> IO (NonEmpty (SignedTransmissionOrError err cmd))
- tGetClient :: (ProtocolEncoding v err cmd, Transport c) => THandle v c 'TClient -> IO (NonEmpty (Transmission (Either err cmd)))
- tParse :: THandleParams v p -> ByteString -> NonEmpty (Either TransportError RawTransmission)
- tDecodeServer :: forall v err cmd. ProtocolEncoding v err cmd => THandleParams v 'TServer -> Either TransportError RawTransmission -> SignedTransmissionOrError err cmd
- tDecodeClient :: forall v err cmd. ProtocolEncoding v err cmd => THandleParams v 'TClient -> Either TransportError RawTransmission -> Transmission (Either err cmd)
- tEncode :: Bool -> SentRawTransmission -> ByteString
- tEncodeBatch1 :: Bool -> SentRawTransmission -> ByteString
- batchTransmissions :: THandleParams v p -> NonEmpty (Either TransportError SentRawTransmission) -> [TransportBatch ()]
- batchTransmissions' :: forall v p r. THandleParams v p -> NonEmpty (Either TransportError SentRawTransmission, r) -> [TransportBatch r]
- batchTransmissions_ :: Int -> NonEmpty (Either TransportError ByteString, r) -> [TransportBatch r]
- data CommandTag (p :: Party) where
- NEW_ :: CommandTag Creator
- SUB_ :: CommandTag Recipient
- SUBS_ :: CommandTag RecipientService
- KEY_ :: CommandTag Recipient
- RKEY_ :: CommandTag Recipient
- LSET_ :: CommandTag Recipient
- LDEL_ :: CommandTag Recipient
- NKEY_ :: CommandTag Recipient
- NDEL_ :: CommandTag Recipient
- GET_ :: CommandTag Recipient
- ACK_ :: CommandTag Recipient
- OFF_ :: CommandTag Recipient
- DEL_ :: CommandTag Recipient
- QUE_ :: CommandTag Recipient
- SKEY_ :: CommandTag Sender
- SEND_ :: CommandTag Sender
- PING_ :: CommandTag IdleClient
- LKEY_ :: CommandTag LinkClient
- LGET_ :: CommandTag LinkClient
- PRXY_ :: CommandTag ProxiedClient
- PFWD_ :: CommandTag ProxiedClient
- RFWD_ :: CommandTag ProxyService
- NSUB_ :: CommandTag Notifier
- NSUBS_ :: CommandTag NotifierService
- data BrokerMsgTag
- checkParty :: forall t p p'. (PartyI p, PartyI p') => t p' -> Either String (t p)
SMP protocol parameters
maxMessageLength :: VersionSMP -> Int Source #
paddedProxiedTLength :: Int Source #
e2eEncConfirmationLength :: Int Source #
e2eEncMessageLength :: Int Source #
SMP protocol types
data SMPClientVersion Source #
Instances
| VersionScope SMPClientVersion Source # | |
Defined in Simplex.Messaging.Protocol | |
| VersionI SMPClientVersion SMPQueueInfo Source # | |
Defined in Simplex.Messaging.Agent.Protocol Associated Types | |
| VersionRangeI SMPClientVersion SMPQueueUri Source # | |
Defined in Simplex.Messaging.Agent.Protocol Associated Types | |
| type VersionRangeT SMPClientVersion SMPQueueInfo Source # | |
Defined in Simplex.Messaging.Agent.Protocol | |
| type VersionT SMPClientVersion SMPQueueUri Source # | |
Defined in Simplex.Messaging.Agent.Protocol | |
type VersionSMPC = Version SMPClientVersion Source #
pattern VersionSMPC :: Word16 -> VersionSMPC Source #
class ProtocolMsgTag (Tag msg) => ProtocolEncoding v err msg | msg -> err, msg -> v where Source #
Methods
encodeProtocol :: Version v -> msg -> ByteString Source #
protocolP :: Version v -> Tag msg -> Parser msg Source #
fromProtocolError :: ProtocolErrorType -> err Source #
checkCredentials :: Maybe TAuthorizations -> EntityId -> msg -> Either err msg Source #
Instances
data Command (p :: Party) where Source #
Parameterized type for SMP protocol commands from all clients.
Constructors
Instances
| PartyI p => ProtocolEncoding SMPVersion ErrorType (Command p) Source # | |
Defined in Simplex.Messaging.Protocol Methods encodeProtocol :: Version SMPVersion -> Command p -> ByteString Source # protocolP :: Version SMPVersion -> Tag (Command p) -> Parser (Command p) Source # fromProtocolError :: ProtocolErrorType -> ErrorType Source # checkCredentials :: Maybe TAuthorizations -> EntityId -> Command p -> Either ErrorType (Command p) Source # | |
| Show (Command p) Source # | |
| type Tag (Command p) Source # | |
Defined in Simplex.Messaging.Protocol | |
data SubscriptionMode Source #
Constructors
| SMSubscribe | |
| SMOnlyCreate |
Instances
| Show SubscriptionMode Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> SubscriptionMode -> ShowS show :: SubscriptionMode -> String showList :: [SubscriptionMode] -> ShowS | |
| Eq SubscriptionMode Source # | |
Defined in Simplex.Messaging.Protocol Methods (==) :: SubscriptionMode -> SubscriptionMode -> Bool (/=) :: SubscriptionMode -> SubscriptionMode -> Bool | |
| Encoding SubscriptionMode Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: SubscriptionMode -> ByteString Source # smpDecode :: ByteString -> Either String SubscriptionMode Source # smpP :: Parser SubscriptionMode Source # | |
| StrEncoding SubscriptionMode Source # | |
Defined in Simplex.Messaging.Protocol Methods strEncode :: SubscriptionMode -> ByteString Source # strDecode :: ByteString -> Either String SubscriptionMode Source # strP :: Parser SubscriptionMode Source # | |
data NewQueueReq Source #
Constructors
| NewQueueReq | |
Fields
| |
Instances
| Show NewQueueReq Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> NewQueueReq -> ShowS show :: NewQueueReq -> String showList :: [NewQueueReq] -> ShowS | |
data QueueReqData Source #
Constructors
| QRMessaging (Maybe (SenderId, QueueLinkData)) | |
| QRContact (Maybe (LinkId, (SenderId, QueueLinkData))) |
Instances
| Show QueueReqData Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> QueueReqData -> ShowS show :: QueueReqData -> String showList :: [QueueReqData] -> ShowS | |
| Encoding QueueReqData Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: QueueReqData -> ByteString Source # smpDecode :: ByteString -> Either String QueueReqData Source # smpP :: Parser QueueReqData Source # | |
Constructors
| QMMessaging | |
| QMContact |
type QueueLinkData = (EncFixedDataBytes, EncUserDataBytes) Source #
type EncFixedDataBytes = EncDataBytes Source #
type EncUserDataBytes = EncDataBytes Source #
newtype EncDataBytes Source #
Constructors
| EncDataBytes ByteString |
Instances
| Show EncDataBytes Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> EncDataBytes -> ShowS show :: EncDataBytes -> String showList :: [EncDataBytes] -> ShowS | |
| Eq EncDataBytes Source # | |
Defined in Simplex.Messaging.Protocol | |
| Encoding EncDataBytes Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: EncDataBytes -> ByteString Source # smpDecode :: ByteString -> Either String EncDataBytes Source # smpP :: Parser EncDataBytes Source # | |
| StrEncoding EncDataBytes Source # | |
Defined in Simplex.Messaging.Protocol Methods strEncode :: EncDataBytes -> ByteString Source # strDecode :: ByteString -> Either String EncDataBytes Source # strP :: Parser EncDataBytes Source # | |
| FromField EncDataBytes Source # | |
Defined in Simplex.Messaging.Protocol Methods fromField :: FieldParser EncDataBytes # | |
| ToField EncDataBytes Source # | |
Defined in Simplex.Messaging.Protocol Methods toField :: EncDataBytes -> SQLData # | |
data NewNtfCreds Source #
Constructors
| NewNtfCreds NtfPublicAuthKey RcvNtfPublicDhKey |
Instances
| Show NewNtfCreds Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> NewNtfCreds -> ShowS show :: NewNtfCreds -> String showList :: [NewNtfCreds] -> ShowS | |
| Encoding NewNtfCreds Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: NewNtfCreds -> ByteString Source # smpDecode :: ByteString -> Either String NewNtfCreds Source # smpP :: Parser NewNtfCreds Source # | |
data ServerNtfCreds Source #
Constructors
| ServerNtfCreds NotifierId RcvNtfPublicDhKey |
Instances
| Show ServerNtfCreds Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> ServerNtfCreds -> ShowS show :: ServerNtfCreds -> String showList :: [ServerNtfCreds] -> ShowS | |
| Eq ServerNtfCreds Source # | |
Defined in Simplex.Messaging.Protocol Methods (==) :: ServerNtfCreds -> ServerNtfCreds -> Bool (/=) :: ServerNtfCreds -> ServerNtfCreds -> Bool | |
| Encoding ServerNtfCreds Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: ServerNtfCreds -> ByteString Source # smpDecode :: ByteString -> Either String ServerNtfCreds Source # smpP :: Parser ServerNtfCreds Source # | |
SMP protocol clients
Constructors
| Creator | |
| Recipient | |
| RecipientService | |
| Sender | |
| IdleClient | |
| Notifier | |
| NotifierService | |
| LinkClient | |
| ProxiedClient | |
| ProxyService |
Instances
| Show Party Source # | |
| TestEquality SParty Source # | |
Defined in Simplex.Messaging.Protocol Methods testEquality :: forall (a :: k) (b :: k). SParty a -> SParty b -> Maybe (a :~: b) | |
Type for client command of any participant.
Instances
| Show Cmd Source # | |
| ProtocolEncoding SMPVersion ErrorType Cmd Source # | |
Defined in Simplex.Messaging.Protocol Methods encodeProtocol :: Version SMPVersion -> Cmd -> ByteString Source # protocolP :: Version SMPVersion -> Tag Cmd -> Parser Cmd Source # fromProtocolError :: ProtocolErrorType -> ErrorType Source # checkCredentials :: Maybe TAuthorizations -> EntityId -> Cmd -> Either ErrorType Cmd Source # | |
| type Tag Cmd Source # | |
Defined in Simplex.Messaging.Protocol | |
type family QueueParty (p :: Party) :: Constraint where ... Source #
Equations
| QueueParty Recipient = () | |
| QueueParty Sender = () | |
| QueueParty Notifier = () | |
| QueueParty LinkClient = () | |
| QueueParty p = (Int ~ Bool, TypeError ((Text "Party " :<>: ShowType p) :<>: Text " is not QueueParty")) |
type family BatchParty (p :: Party) :: Constraint where ... Source #
Equations
| BatchParty Recipient = () | |
| BatchParty Notifier = () | |
| BatchParty p = (Int ~ Bool, TypeError ((Text "Party " :<>: ShowType p) :<>: Text " is not BatchParty")) |
type family ServiceParty (p :: Party) :: Constraint where ... Source #
Equations
| ServiceParty RecipientService = () | |
| ServiceParty NotifierService = () | |
| ServiceParty p = (Int ~ Bool, TypeError ((Text "Party " :<>: ShowType p) :<>: Text " is not ServiceParty")) |
data ASubscriberParty Source #
Constructors
| forall p.(PartyI p, ServiceParty p) => ASP (SParty p) |
Instances
| Show ASubscriberParty Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> ASubscriberParty -> ShowS show :: ASubscriberParty -> String showList :: [ASubscriberParty] -> ShowS | |
| Eq ASubscriberParty Source # | |
Defined in Simplex.Messaging.Protocol Methods (==) :: ASubscriberParty -> ASubscriberParty -> Bool (/=) :: ASubscriberParty -> ASubscriberParty -> Bool | |
| Encoding ASubscriberParty Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: ASubscriberParty -> ByteString Source # smpDecode :: ByteString -> Either String ASubscriberParty Source # smpP :: Parser ASubscriberParty Source # | |
| StrEncoding ASubscriberParty Source # | |
Defined in Simplex.Messaging.Protocol Methods strEncode :: ASubscriberParty -> ByteString Source # strDecode :: ByteString -> Either String ASubscriberParty Source # strP :: Parser ASubscriberParty Source # | |
Constructors
| IDS :: QueueIdsKeys -> BrokerMsg | |
| LNK :: SenderId -> QueueLinkData -> BrokerMsg | |
| SOK :: Maybe ServiceId -> BrokerMsg | Service subscription success - confirms when queue was associated with the service |
| SOKS :: Int64 -> BrokerMsg | The number of queues subscribed with SUBS command |
| MSG :: RcvMessage -> BrokerMsg | |
| NID :: NotifierId -> RcvNtfPublicDhKey -> BrokerMsg | |
| NMSG :: CbNonce -> EncNMsgMeta -> BrokerMsg | |
| PKEY :: SessionId -> VersionRangeSMP -> CertChainPubKey -> BrokerMsg | |
| RRES :: EncFwdResponse -> BrokerMsg | |
| PRES :: EncResponse -> BrokerMsg | |
| END :: BrokerMsg | |
| ENDS :: Int64 -> BrokerMsg | |
| DELD :: BrokerMsg | |
| INFO :: QueueInfo -> BrokerMsg | |
| OK :: BrokerMsg | |
| ERR :: ErrorType -> BrokerMsg | |
| PONG :: BrokerMsg |
Instances
data SParty :: Party -> Type where Source #
Singleton types for SMP protocol clients
Constructors
Instances
| TestEquality SParty Source # | |
Defined in Simplex.Messaging.Protocol Methods testEquality :: forall (a :: k) (b :: k). SParty a -> SParty b -> Maybe (a :~: b) | |
| Show (SParty p) Source # | |
class PartyI (p :: Party) where Source #
Instances
| PartyI 'Creator Source # | |
| PartyI 'IdleClient Source # | |
Defined in Simplex.Messaging.Protocol Methods sParty :: SParty 'IdleClient Source # | |
| PartyI 'LinkClient Source # | |
Defined in Simplex.Messaging.Protocol Methods sParty :: SParty 'LinkClient Source # | |
| PartyI 'Notifier Source # | |
| PartyI 'NotifierService Source # | |
Defined in Simplex.Messaging.Protocol Methods | |
| PartyI 'ProxiedClient Source # | |
Defined in Simplex.Messaging.Protocol Methods sParty :: SParty 'ProxiedClient Source # | |
| PartyI 'ProxyService Source # | |
Defined in Simplex.Messaging.Protocol Methods sParty :: SParty 'ProxyService Source # | |
| PartyI 'Recipient Source # | |
| PartyI 'RecipientService Source # | |
Defined in Simplex.Messaging.Protocol Methods | |
| PartyI 'Sender Source # | |
data QueueIdsKeys Source #
Queue IDs and keys
Constructors
| QIK | |
Fields
| |
Instances
| Show QueueIdsKeys Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> QueueIdsKeys -> ShowS show :: QueueIdsKeys -> String showList :: [QueueIdsKeys] -> ShowS | |
| Eq QueueIdsKeys Source # | |
Defined in Simplex.Messaging.Protocol | |
data ProtocolErrorType Source #
Constructors
| PECmdSyntax | |
| PECmdUnknown | |
| PESession | |
| PEBlock |
Type for protocol errors.
Constructors
| BLOCK | incorrect block format, encoding or signature size |
| SESSION | incorrect SMP session ID (TLS Finished message / tls-unique binding RFC5929) |
| CMD | SMP command is unknown or has invalid syntax |
Fields | |
| PROXY | error from proxied relay |
Fields | |
| AUTH | command authorization error - bad signature or non-existing SMP queue |
| BLOCKED | command with the entity that was blocked |
Fields | |
| SERVICE | service signature is not allowed for command or session; service command is sent not in service session |
| CRYPTO | encryption/decryption error in proxy protocol |
| QUOTA | SMP queue capacity is exceeded on the server |
| STORE | SMP server storage error |
Fields
| |
| NO_MSG | ACK command is sent without message to be acknowledged |
| LARGE_MSG | sent message is too large (> maxMessageLength = 16088 bytes) |
| EXPIRED | relay public key is expired |
| INTERNAL | internal server error |
| DUPLICATE_ | used internally, never returned by the server (to be removed) |
Instances
data CommandError Source #
SMP command error type.
Constructors
| UNKNOWN | unknown command |
| SYNTAX | error parsing command |
| PROHIBITED | command is not allowed (bad service role, or SUB/GET used with the same queue in the same TCP session) |
| NO_AUTH | transmission has no required credentials (signature or queue ID) |
| HAS_AUTH | transmission has credentials that are not allowed for this command |
| NO_ENTITY | transmission has no required entity ID (e.g. SMP queue) |
Instances
data ProxyError Source #
Constructors
| PROTOCOL | Correctly parsed SMP server ERR response. This error is forwarded to the agent client as AgentErrorType `ERR PROXY PROTOCOL err`. |
Fields | |
| BROKER | destination server error |
Fields | |
| BASIC_AUTH | basic auth provided to proxy is invalid |
| NO_SESSION | |
Instances
data BrokerErrorType Source #
SMP server errors.
Constructors
| RESPONSE | invalid server response (failed to parse) |
Fields
| |
| UNEXPECTED | unexpected response |
Fields
| |
| NETWORK | network error |
Fields | |
| HOST | no compatible server host (e.g. onion when public is required, or vice versa) |
| NO_SERVICE | service unavailable client-side - used in agent errors |
| TRANSPORT | handshake or other transport error |
Fields | |
| TIMEOUT | command response timeout |
Instances
data NetworkError Source #
Constructors
| NEConnectError | |
Fields
| |
| NETLSError | |
Fields
| |
| NEUnknownCAError | |
| NEFailedError | |
| NETimeoutError | |
| NESubscribeError | |
Fields
| |
Instances
data BlockingInfo Source #
Constructors
| BlockingInfo | |
Fields
| |
Instances
data BlockingReason Source #
Instances
data RawTransmission Source #
unparsed SMP transmission with signature.
Instances
| Show RawTransmission Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> RawTransmission -> ShowS show :: RawTransmission -> String showList :: [RawTransmission] -> ShowS | |
type Transmission c = (CorrId, EntityId, c) Source #
Parsed SMP transmission without signature, size and session ID.
type TAuthorizations = (TransmissionAuth, Maybe (Signature 'Ed25519)) Source #
data TransmissionAuth Source #
Constructors
| TASignature ASignature | |
| TAAuthenticator CbAuthenticator |
Instances
| Show TransmissionAuth Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> TransmissionAuth -> ShowS show :: TransmissionAuth -> String showList :: [TransmissionAuth] -> ShowS | |
type SignedTransmission c = (Maybe TAuthorizations, Signed, Transmission c) Source #
signed parsed transmission, with original raw bytes and parsing error.
type SignedTransmissionOrError e c = Either (Transmission e) (SignedTransmission c) Source #
type SentRawTransmission = (Maybe TAuthorizations, ByteString) Source #
unparsed sent SMP transmission with signature.
data ClientMsgEnvelope Source #
SMP message body format
Constructors
| ClientMsgEnvelope | |
Instances
| Show ClientMsgEnvelope Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> ClientMsgEnvelope -> ShowS show :: ClientMsgEnvelope -> String showList :: [ClientMsgEnvelope] -> ShowS | |
| Encoding ClientMsgEnvelope Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: ClientMsgEnvelope -> ByteString Source # smpDecode :: ByteString -> Either String ClientMsgEnvelope Source # smpP :: Parser ClientMsgEnvelope Source # | |
Constructors
| PubHeader | |
Fields
| |
data ClientMessage Source #
Constructors
| ClientMessage PrivHeader ByteString |
Instances
| Encoding ClientMessage Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: ClientMessage -> ByteString Source # smpDecode :: ByteString -> Either String ClientMessage Source # smpP :: Parser ClientMessage Source # | |
data PrivHeader Source #
Constructors
| PHConfirmation APublicAuthKey | |
| PHEmpty |
Instances
| Show PrivHeader Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> PrivHeader -> ShowS show :: PrivHeader -> String showList :: [PrivHeader] -> ShowS | |
| Encoding PrivHeader Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: PrivHeader -> ByteString Source # smpDecode :: ByteString -> Either String PrivHeader Source # smpP :: Parser PrivHeader Source # | |
class (ProtocolTypeI (ProtoType msg), ProtocolEncoding v err msg, ProtocolEncoding v err (ProtoCommand msg), Show err, Show msg) => Protocol v err msg | msg -> v, msg -> err where Source #
Associated Types
type ProtoCommand msg = cmd | cmd -> msg Source #
type ProtoType msg = (sch :: ProtocolType) | sch -> msg Source #
Methods
protocolClientHandshake :: Transport c => c 'TClient -> Maybe KeyPairX25519 -> KeyHash -> VersionRange v -> Bool -> Maybe (ServiceCredentials, KeyPairEd25519) -> ExceptT TransportError IO (THandle v c 'TClient) Source #
useServiceAuth :: ProtoCommand msg -> Bool Source #
protocolPing :: ProtoCommand msg Source #
protocolError :: msg -> Maybe err Source #
Instances
data ProtocolType Source #
Instances
data SProtocolType (p :: ProtocolType) where Source #
Constructors
| SPSMP :: SProtocolType 'PSMP | |
| SPNTF :: SProtocolType 'PNTF | |
| SPXFTP :: SProtocolType 'PXFTP |
Instances
data AProtocolType Source #
Constructors
| forall p.ProtocolTypeI p => AProtocolType (SProtocolType p) |
Instances
| FromJSON AProtocolType Source # | |
Defined in Simplex.Messaging.Protocol Methods parseJSON :: Value -> Parser AProtocolType parseJSONList :: Value -> Parser [AProtocolType] omittedField :: Maybe AProtocolType | |
| ToJSON AProtocolType Source # | |
Defined in Simplex.Messaging.Protocol Methods toJSON :: AProtocolType -> Value toEncoding :: AProtocolType -> Encoding toJSONList :: [AProtocolType] -> Value toEncodingList :: [AProtocolType] -> Encoding omitField :: AProtocolType -> Bool | |
| Show AProtocolType Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> AProtocolType -> ShowS show :: AProtocolType -> String showList :: [AProtocolType] -> ShowS | |
| Eq AProtocolType Source # | |
Defined in Simplex.Messaging.Protocol | |
| StrEncoding AProtocolType Source # | |
Defined in Simplex.Messaging.Protocol Methods strEncode :: AProtocolType -> ByteString Source # strDecode :: ByteString -> Either String AProtocolType Source # strP :: Parser AProtocolType Source # | |
class ProtocolTypeI (p :: ProtocolType) where Source #
Methods
Instances
| ProtocolTypeI 'PNTF Source # | |
Defined in Simplex.Messaging.Protocol Methods | |
| ProtocolTypeI 'PSMP Source # | |
Defined in Simplex.Messaging.Protocol Methods | |
| ProtocolTypeI 'PXFTP Source # | |
Defined in Simplex.Messaging.Protocol Methods | |
type family UserProtocol (p :: ProtocolType) :: Constraint where ... Source #
Equations
| UserProtocol PSMP = () | |
| UserProtocol PXFTP = () | |
| UserProtocol a = (Int ~ Bool, TypeError ((Text "Servers for protocol " :<>: ShowType a) :<>: Text " cannot be configured by the users")) |
data ProtocolServer p Source #
server location and transport key digest (hash).
Constructors
| ProtocolServer | |
Fields
| |
Instances
type ProtoServer msg = ProtocolServer (ProtoType msg) Source #
type SMPServer = ProtocolServer 'PSMP Source #
pattern SMPServer :: NonEmpty TransportHost -> ServiceName -> KeyHash -> ProtocolServer 'PSMP Source #
type SMPServerWithAuth = ProtoServerWithAuth 'PSMP Source #
type NtfServer = ProtocolServer 'PNTF Source #
pattern NtfServer :: NonEmpty TransportHost -> ServiceName -> KeyHash -> ProtocolServer 'PNTF Source #
type NtfServerWithAuth = ProtoServerWithAuth 'PNTF Source #
type XFTPServer = ProtocolServer 'PXFTP Source #
pattern XFTPServer :: NonEmpty TransportHost -> ServiceName -> KeyHash -> ProtocolServer 'PXFTP Source #
data ProtoServerWithAuth p Source #
Constructors
| ProtoServerWithAuth | |
Fields
| |
Instances
data AProtoServerWithAuth Source #
Constructors
| forall p.ProtocolTypeI p => AProtoServerWithAuth (SProtocolType p) (ProtoServerWithAuth p) |
Instances
Constructors
| BasicAuth | |
Fields
| |
Constructors
| SrvLoc HostName ServiceName |
Transmission correlation ID.
Instances
| FromJSON CorrId Source # | |
Defined in Simplex.Messaging.Protocol Methods parseJSON :: Value -> Parser CorrId parseJSONList :: Value -> Parser [CorrId] omittedField :: Maybe CorrId | |
| ToJSON CorrId Source # | |
Defined in Simplex.Messaging.Protocol Methods toEncoding :: CorrId -> Encoding toJSONList :: [CorrId] -> Value toEncodingList :: [CorrId] -> Encoding | |
| IsString CorrId Source # | |
Defined in Simplex.Messaging.Protocol Methods fromString :: String -> CorrId | |
| Show CorrId Source # | |
| Eq CorrId Source # | |
| Ord CorrId Source # | |
| Encoding CorrId Source # | |
| StrEncoding CorrId Source # | |
Constructors
| EntityId | |
Fields
| |
Instances
| Show EntityId Source # | |
| Eq EntityId Source # | |
| Ord EntityId Source # | |
Defined in Simplex.Messaging.Transport | |
| Encoding EntityId Source # | |
| StrEncoding EntityId Source # | |
| FromField EntityId Source # | |
Defined in Simplex.Messaging.Agent.Store.AgentStore | |
| ToField EntityId Source # | |
Defined in Simplex.Messaging.Agent.Store.AgentStore | |
type RecipientId = QueueId Source #
SMP queue ID for the recipient.
type NotifierId = QueueId Source #
SMP queue ID for notifications.
type RcvPrivateAuthKey = APrivateAuthKey Source #
Recipient's private key used by the recipient to authorize (v6: sign, v7: encrypt hash) SMP commands.
Only used by SMP agent, kept here so its definition is close to respective public key.
type RcvPublicAuthKey = APublicAuthKey Source #
Recipient's public key used by SMP server to verify authorization of SMP commands.
type RcvPublicDhKey = PublicKeyX25519 Source #
Public key used for DH exchange to encrypt message bodies from server to recipient
type RcvDhSecret = DhSecretX25519 Source #
DH Secret used to encrypt message bodies from server to recipient
type SndPrivateAuthKey = APrivateAuthKey Source #
Sender's private key used by the recipient to authorize (v6: sign, v7: encrypt hash) SMP commands.
Only used by SMP agent, kept here so its definition is close to respective public key.
type SndPublicAuthKey = APublicAuthKey Source #
Sender's public key used by SMP server to verify authorization of SMP commands.
type NtfPrivateAuthKey = APrivateAuthKey Source #
Private key used by push notifications server to authorize (sign or encrypt hash) NSUB command.
type NtfPublicAuthKey = APublicAuthKey Source #
Public key used by SMP server to verify authorization of NSUB command sent by push notifications server.
type RcvNtfPublicDhKey = PublicKeyX25519 Source #
Public key used for DH exchange to encrypt notification metadata from server to recipient
type RcvNtfDhSecret = DhSecretX25519 Source #
DH Secret used to encrypt notification metadata from server to recipient
received message without server/recipient encryption
Constructors
| Message | |
| MessageQuota | |
data RcvMessage Source #
Constructors
| RcvMessage | |
Fields
| |
Instances
| Show RcvMessage Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> RcvMessage -> ShowS show :: RcvMessage -> String showList :: [RcvMessage] -> ShowS | |
| Eq RcvMessage Source # | |
Defined in Simplex.Messaging.Protocol | |
type MaxMessageLen = 16088 Source #
type MaxRcvMessageLen = MaxMessageLen + 16 Source #
newtype EncRcvMsgBody Source #
Constructors
| EncRcvMsgBody ByteString |
Instances
| Show EncRcvMsgBody Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> EncRcvMsgBody -> ShowS show :: EncRcvMsgBody -> String showList :: [EncRcvMsgBody] -> ShowS | |
| Eq EncRcvMsgBody Source # | |
Defined in Simplex.Messaging.Protocol | |
data RcvMsgBody Source #
Constructors
| RcvMsgBody | |
| RcvMsgQuota | |
Fields
| |
data ClientRcvMsgBody Source #
Constructors
| ClientRcvMsgBody | |
| ClientRcvMsgQuota | |
Fields
| |
type EncNMsgMeta = ByteString Source #
data SMPMsgMeta Source #
Instances
| Show SMPMsgMeta Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> SMPMsgMeta -> ShowS show :: SMPMsgMeta -> String showList :: [SMPMsgMeta] -> ShowS | |
| Eq SMPMsgMeta Source # | |
Defined in Simplex.Messaging.Protocol | |
| StrEncoding SMPMsgMeta Source # | |
Defined in Simplex.Messaging.Protocol Methods strEncode :: SMPMsgMeta -> ByteString Source # strDecode :: ByteString -> Either String SMPMsgMeta Source # strP :: Parser SMPMsgMeta Source # | |
newtype EncFwdResponse Source #
Constructors
| EncFwdResponse ByteString |
Instances
| Show EncFwdResponse Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> EncFwdResponse -> ShowS show :: EncFwdResponse -> String showList :: [EncFwdResponse] -> ShowS | |
| Eq EncFwdResponse Source # | |
Defined in Simplex.Messaging.Protocol Methods (==) :: EncFwdResponse -> EncFwdResponse -> Bool (/=) :: EncFwdResponse -> EncFwdResponse -> Bool | |
newtype EncFwdTransmission Source #
Constructors
| EncFwdTransmission ByteString |
Instances
| Show EncFwdTransmission Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> EncFwdTransmission -> ShowS show :: EncFwdTransmission -> String showList :: [EncFwdTransmission] -> ShowS | |
newtype EncResponse Source #
Constructors
| EncResponse ByteString |
Instances
| Show EncResponse Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> EncResponse -> ShowS show :: EncResponse -> String showList :: [EncResponse] -> ShowS | |
| Eq EncResponse Source # | |
Defined in Simplex.Messaging.Protocol | |
newtype EncTransmission Source #
Constructors
| EncTransmission ByteString |
Instances
| Show EncTransmission Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> EncTransmission -> ShowS show :: EncTransmission -> String showList :: [EncTransmission] -> ShowS | |
data FwdResponse Source #
Constructors
| FwdResponse | |
Fields | |
Instances
| Encoding FwdResponse Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: FwdResponse -> ByteString Source # smpDecode :: ByteString -> Either String FwdResponse Source # smpP :: Parser FwdResponse Source # | |
data FwdTransmission Source #
Constructors
| FwdTransmission | |
Fields | |
Instances
| Encoding FwdTransmission Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: FwdTransmission -> ByteString Source # smpDecode :: ByteString -> Either String FwdTransmission Source # smpP :: Parser FwdTransmission Source # | |
Constructors
| MsgFlags | |
Fields
| |
Instances
| FromJSON MsgFlags Source # | |
Defined in Simplex.Messaging.Protocol Methods parseJSON :: Value -> Parser MsgFlags parseJSONList :: Value -> Parser [MsgFlags] omittedField :: Maybe MsgFlags | |
| ToJSON MsgFlags Source # | |
Defined in Simplex.Messaging.Protocol Methods toEncoding :: MsgFlags -> Encoding toJSONList :: [MsgFlags] -> Value toEncodingList :: [MsgFlags] -> Encoding | |
| Show MsgFlags Source # | |
| Eq MsgFlags Source # | |
| Encoding MsgFlags Source # | |
| StrEncoding MsgFlags Source # | |
| FromField MsgFlags Source # | |
Defined in Simplex.Messaging.Agent.Store.AgentStore | |
| ToField MsgFlags Source # | |
Defined in Simplex.Messaging.Agent.Store.AgentStore | |
senderCanSecure :: Maybe QueueMode -> Bool Source #
queueReqMode :: QueueReqData -> QueueMode Source #
queueParty :: SParty p -> Maybe (Dict (PartyI p, QueueParty p)) Source #
batchParty :: SParty p -> Maybe (Dict (PartyI p, BatchParty p)) Source #
serviceParty :: SParty p -> Maybe (Dict (PartyI p, ServiceParty p)) Source #
partyClientRole :: SParty p -> Maybe SMPServiceRole Source #
partyServiceRole :: ServiceParty p => SParty p -> SMPServiceRole Source #
userProtocol :: SProtocolType p -> Maybe (Dict (UserProtocol p)) Source #
rcvMessageMeta :: MsgId -> ClientRcvMsgBody -> SMPMsgMeta Source #
toNetworkError :: SomeException -> NetworkError Source #
Parse and serialize
class ProtocolMsgTag t where Source #
Instances
| ProtocolMsgTag NtfCmdTag Source # | |
Defined in Simplex.Messaging.Notifications.Protocol | |
| ProtocolMsgTag NtfResponseTag Source # | |
Defined in Simplex.Messaging.Notifications.Protocol Methods decodeTag :: ByteString -> Maybe NtfResponseTag Source # | |
| ProtocolMsgTag BrokerMsgTag Source # | |
Defined in Simplex.Messaging.Protocol Methods decodeTag :: ByteString -> Maybe BrokerMsgTag Source # | |
| NtfEntityI e => ProtocolMsgTag (NtfCommandTag e) Source # | |
Defined in Simplex.Messaging.Notifications.Protocol Methods decodeTag :: ByteString -> Maybe (NtfCommandTag e) Source # | |
| PartyI p => ProtocolMsgTag (CommandTag p) Source # | |
Defined in Simplex.Messaging.Protocol Methods decodeTag :: ByteString -> Maybe (CommandTag p) Source # | |
messageTagP :: ProtocolMsgTag t => Parser t Source #
data TransmissionForAuth Source #
Constructors
| TransmissionForAuth | |
encodeTransmissionForAuth :: ProtocolEncoding v e c => THandleParams v p -> Transmission c -> TransmissionForAuth Source #
encodeTransmission :: ProtocolEncoding v e c => THandleParams v p -> Transmission c -> ByteString Source #
transmissionP :: THandleParams v p -> Parser RawTransmission Source #
SMP transmission parser.
clientRcvMsgBodyP :: Parser ClientRcvMsgBody Source #
legacyEncodeServer :: ProtocolServer p -> ByteString Source #
legacyServerP :: forall p. ProtocolTypeI p => Parser (ProtocolServer p) Source #
legacyStrEncodeServer :: ProtocolTypeI p => ProtocolServer p -> ByteString Source #
sameSrvAddr :: ProtocolServer p -> ProtocolServer p -> Bool Source #
sameSrvAddr' :: ProtoServerWithAuth p -> ProtoServerWithAuth p -> Bool Source #
noAuthSrv :: ProtocolServer p -> ProtoServerWithAuth p Source #
TCP transport functions
data TransportBatch r Source #
Constructors
| TBTransmissions ByteString Int [r] | |
| TBTransmission ByteString r | |
| TBError TransportError r |
tPut :: Transport c => THandle v c p -> NonEmpty (Either TransportError SentRawTransmission) -> IO [Either TransportError ()] Source #
Send signed SMP transmission to TCP transport.
tGetServer :: (ProtocolEncoding v err cmd, Transport c) => THandle v c 'TServer -> IO (NonEmpty (SignedTransmissionOrError err cmd)) Source #
Receive server transmissions
tGetClient :: (ProtocolEncoding v err cmd, Transport c) => THandle v c 'TClient -> IO (NonEmpty (Transmission (Either err cmd))) Source #
Receive client transmissions
tParse :: THandleParams v p -> ByteString -> NonEmpty (Either TransportError RawTransmission) Source #
tDecodeServer :: forall v err cmd. ProtocolEncoding v err cmd => THandleParams v 'TServer -> Either TransportError RawTransmission -> SignedTransmissionOrError err cmd Source #
tDecodeClient :: forall v err cmd. ProtocolEncoding v err cmd => THandleParams v 'TClient -> Either TransportError RawTransmission -> Transmission (Either err cmd) Source #
tEncode :: Bool -> SentRawTransmission -> ByteString Source #
tEncodeBatch1 :: Bool -> SentRawTransmission -> ByteString Source #
batchTransmissions :: THandleParams v p -> NonEmpty (Either TransportError SentRawTransmission) -> [TransportBatch ()] Source #
batchTransmissions' :: forall v p r. THandleParams v p -> NonEmpty (Either TransportError SentRawTransmission, r) -> [TransportBatch r] Source #
encodes and batches transmissions into blocks
batchTransmissions_ :: Int -> NonEmpty (Either TransportError ByteString, r) -> [TransportBatch r] Source #
Pack encoded transmissions into batches
exports for tests
data CommandTag (p :: Party) where Source #
Constructors
Instances
| Show (CommandTag p) Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> CommandTag p -> ShowS show :: CommandTag p -> String showList :: [CommandTag p] -> ShowS | |
| PartyI p => Encoding (CommandTag p) Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: CommandTag p -> ByteString Source # smpDecode :: ByteString -> Either String (CommandTag p) Source # smpP :: Parser (CommandTag p) Source # | |
| PartyI p => ProtocolMsgTag (CommandTag p) Source # | |
Defined in Simplex.Messaging.Protocol Methods decodeTag :: ByteString -> Maybe (CommandTag p) Source # | |
data BrokerMsgTag Source #
Constructors
| IDS_ | |
| LNK_ | |
| SOK_ | |
| SOKS_ | |
| MSG_ | |
| NID_ | |
| NMSG_ | |
| PKEY_ | |
| RRES_ | |
| PRES_ | |
| END_ | |
| ENDS_ | |
| DELD_ | |
| INFO_ | |
| OK_ | |
| ERR_ | |
| PONG_ |
Instances
| Show BrokerMsgTag Source # | |
Defined in Simplex.Messaging.Protocol Methods showsPrec :: Int -> BrokerMsgTag -> ShowS show :: BrokerMsgTag -> String showList :: [BrokerMsgTag] -> ShowS | |
| Encoding BrokerMsgTag Source # | |
Defined in Simplex.Messaging.Protocol Methods smpEncode :: BrokerMsgTag -> ByteString Source # smpDecode :: ByteString -> Either String BrokerMsgTag Source # smpP :: Parser BrokerMsgTag Source # | |
| ProtocolMsgTag BrokerMsgTag Source # | |
Defined in Simplex.Messaging.Protocol Methods decodeTag :: ByteString -> Maybe BrokerMsgTag Source # | |
checkParty :: forall t p p'. (PartyI p, PartyI p') => t p' -> Either String (t p) Source #