Skip to content

Commit ba7ada1

Browse files
committed
agent: getConnLinkPrivKey
1 parent f8f172f commit ba7ada1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Simplex/Messaging/Agent.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module Simplex.Messaging.Agent
6464
setConnShortLink,
6565
deleteConnShortLink,
6666
getConnShortLink,
67+
getConnLinkPrivKey,
6768
deleteLocalInvShortLink,
6869
changeConnectionUser,
6970
prepareConnectionToJoin,
@@ -428,6 +429,10 @@ getConnShortLink :: AgentClient -> NetworkRequestMode -> UserId -> ConnShortLink
428429
getConnShortLink c = withAgentEnv c .:. getConnShortLink' c
429430
{-# INLINE getConnShortLink #-}
430431

432+
getConnLinkPrivKey :: AgentClient -> ConnId -> AE (Maybe C.PrivateKeyEd25519)
433+
getConnLinkPrivKey c = withAgentEnv c . getConnLinkPrivKey' c
434+
{-# INLINE getConnLinkPrivKey #-}
435+
431436
-- | This irreversibly deletes short link data, and it won't be retrievable again
432437
deleteLocalInvShortLink :: AgentClient -> ConnShortLink 'CMInvitation -> AE ()
433438
deleteLocalInvShortLink c = withAgentEnv c . deleteLocalInvShortLink' c
@@ -1087,6 +1092,14 @@ deleteConnShortLink' c nm connId cMode =
10871092
(RcvConnection _ rq, SCMInvitation) -> deleteQueueLink c nm rq
10881093
_ -> throwE $ CMD PROHIBITED "deleteConnShortLink: not contact address"
10891094

1095+
getConnLinkPrivKey' :: AgentClient -> ConnId -> AM (Maybe C.PrivateKeyEd25519)
1096+
getConnLinkPrivKey' c connId = do
1097+
SomeConn _ conn <- withStore c (`getConn` connId)
1098+
pure $ case conn of
1099+
ContactConnection _ rq -> linkPrivSigKey <$> shortLink rq
1100+
RcvConnection _ rq -> linkPrivSigKey <$> shortLink rq
1101+
_ -> Nothing
1102+
10901103
-- TODO [short links] remove 1-time invitation data and link ID from the server after the message is sent.
10911104
getConnShortLink' :: forall c. AgentClient -> NetworkRequestMode -> UserId -> ConnShortLink c -> AM (FixedLinkData c, ConnLinkData c)
10921105
getConnShortLink' c nm userId = \case

0 commit comments

Comments
 (0)