mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-04-26 13:07:25 +00:00
* ntf: use separate key to encrypt NMsgMeta * key negotiation * save key on server, use for encryption * refactor? * store error * NtfQueueCreds * server - NtfCreds * comment, rename * fix type * ClientNtfCreds * encoding
44 lines
1.5 KiB
Haskell
44 lines
1.5 KiB
Haskell
{-# LANGUAGE DataKinds #-}
|
|
{-# LANGUAGE KindSignatures #-}
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
|
|
module Simplex.Messaging.Server.QueueStore where
|
|
|
|
import Simplex.Messaging.Encoding.String
|
|
import Simplex.Messaging.Protocol
|
|
|
|
data QueueRec = QueueRec
|
|
{ recipientId :: RecipientId,
|
|
recipientKey :: RcvPublicVerifyKey,
|
|
rcvDhSecret :: RcvDhSecret,
|
|
senderId :: SenderId,
|
|
senderKey :: Maybe SndPublicVerifyKey,
|
|
notifier :: Maybe NtfCreds,
|
|
status :: QueueStatus
|
|
}
|
|
deriving (Eq, Show)
|
|
|
|
data NtfCreds = NtfCreds
|
|
{ notifierId :: NotifierId,
|
|
notifierKey :: NtfPublicVerifyKey,
|
|
rcvNtfDhSecret :: RcvNtfDhSecret
|
|
}
|
|
deriving (Eq, Show)
|
|
|
|
instance StrEncoding NtfCreds where
|
|
strEncode NtfCreds {notifierId, notifierKey, rcvNtfDhSecret} = strEncode (notifierId, notifierKey, rcvNtfDhSecret)
|
|
strP = do
|
|
(notifierId, notifierKey, rcvNtfDhSecret) <- strP
|
|
pure NtfCreds {notifierId, notifierKey, rcvNtfDhSecret}
|
|
|
|
data QueueStatus = QueueActive | QueueOff deriving (Eq, Show)
|
|
|
|
class MonadQueueStore s m where
|
|
addQueue :: s -> QueueRec -> m (Either ErrorType ())
|
|
getQueue :: s -> SParty p -> QueueId -> m (Either ErrorType QueueRec)
|
|
secureQueue :: s -> RecipientId -> SndPublicVerifyKey -> m (Either ErrorType QueueRec)
|
|
addQueueNotifier :: s -> RecipientId -> NtfCreds -> m (Either ErrorType QueueRec)
|
|
suspendQueue :: s -> RecipientId -> m (Either ErrorType ())
|
|
deleteQueue :: s -> RecipientId -> m (Either ErrorType ())
|