@@ -1407,15 +1407,16 @@ instance ConnectionModeI m => FromJSON (ConnectionLink m) where
14071407
14081408instance ConnectionModeI m => StrEncoding (ConnShortLink m ) where
14091409 strEncode = \ case
1410- CSLInvitation srv (SMP. EntityId lnkId) (LinkKey k) -> encLink srv ( lnkId <> k) ' i'
1411- CSLContact ct srv (LinkKey k) -> encLink srv k $ toLower $ ctTypeChar ct
1410+ CSLInvitation srv (SMP. EntityId lnkId) (LinkKey k) -> encLink srv lnkId k ' i'
1411+ CSLContact ct srv (LinkKey k) -> encLink srv " " k $ toLower $ ctTypeChar ct
14121412 where
1413- encLink (SMPServer (h :| hs) port (C. KeyHash kh)) linkUri linkType =
1414- B. concat [" https://" , strEncode h, port', " /" , B. singleton linkType, " #" , khStr, hosts, B64. encodeUnpadded linkUri ]
1413+ encLink (SMPServer (h :| hs) port (C. KeyHash kh)) lnkId k linkType =
1414+ B. concat [" https://" , strEncode h, port', " /" , B. singleton linkType, " #" , khStr, hosts, lnkIdStr, B64. encodeUnpadded k ]
14151415 where
14161416 port' = if null port then " " else B. pack (' :' : port)
1417+ khStr = if B. null kh then " " else B64. encodeUnpadded kh <> " &"
14171418 hosts = if null hs then " " else strEncode (TransportHosts_ hs) <> " /"
1418- khStr = if B. null kh then " " else B64. encodeUnpadded kh <> " @ "
1419+ lnkIdStr = if B. null lnkId then " " else B64. encodeUnpadded lnkId <> " . "
14191420 strP = (\ (ACSL _ l) -> checkConnMode l) <$?> strP
14201421 {-# INLINE strP #-}
14211422
@@ -1426,19 +1427,17 @@ instance StrEncoding AConnShortLink where
14261427 h <- " https://" *> strP
14271428 port <- A. char ' :' *> (B. unpack <$> A. takeWhile1 isDigit) <|> pure " "
14281429 contactType <- A. char ' /' *> contactTypeP
1429- keyHash <- optional (A. char ' /' ) *> A. char ' #' *> (strP <* A. char ' @ ' <|> pure (C. KeyHash " " ))
1430+ keyHash <- optional (A. char ' /' ) *> A. char ' #' *> (strP <* A. char ' & ' <|> pure (C. KeyHash " " ))
14301431 TransportHosts_ hs <- strP <* " /" <|> pure (TransportHosts_ [] )
1431- linkUri <- strP
14321432 let srv = SMPServer (h :| hs) port keyHash
14331433 case contactType of
1434- Nothing
1435- | B. length linkUri == 56 ->
1436- let (lnkId, k) = B. splitAt 24 linkUri
1437- in pure $ ACSL SCMInvitation $ CSLInvitation srv (SMP. EntityId lnkId) (LinkKey k)
1438- | otherwise -> fail " bad ConnShortLink: incorrect linkID and key length"
1439- Just ct
1440- | B. length linkUri == 32 -> pure $ ACSL SCMContact $ CSLContact ct srv (LinkKey linkUri)
1441- | otherwise -> fail " bad ConnShortLink: incorrect key length"
1434+ Nothing -> do
1435+ lnkId <- strP <* A. char ' .'
1436+ k <- strP
1437+ pure $ ACSL SCMInvitation $ CSLInvitation srv (SMP. EntityId lnkId) (LinkKey k)
1438+ Just ct -> do
1439+ k <- strP
1440+ pure $ ACSL SCMContact $ CSLContact ct srv (LinkKey k)
14421441 where
14431442 contactTypeP = do
14441443 Just <$> (A. anyChar >>= ctTypeP . toUpper)
0 commit comments