aboutsummaryrefslogtreecommitdiff
path: root/src/Ssb/Feed.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ssb/Feed.hs')
-rw-r--r--src/Ssb/Feed.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Ssb/Feed.hs b/src/Ssb/Feed.hs
index f4e96c2..ebdd2f4 100644
--- a/src/Ssb/Feed.hs
+++ b/src/Ssb/Feed.hs
@@ -72,7 +72,7 @@ extractMessageID (MessageID buf) = buf
-- Format of '%[base64 messageId].sha256', the '.sha256' is appended for
-- forward compatibility, and is currently assumed.
formatMessageID :: MessageID -> Text
-formatMessageID (MessageID buf) = "%" <> toS (Base64.encode buf) <> ".sha256"
+formatMessageID (MessageID buf) = "%" <> decodeUtf8 (Base64.encode buf) <> ".sha256"
-- | TODO: make safe
parseMessageID :: Text -> Either Text MessageID
@@ -80,7 +80,7 @@ parseMessageID arg = decode $ T.dropEnd constLen $ T.drop 1 arg
where
constLen = T.length ".sha256"
decode :: Text -> Either Text MessageID
- decode = mapRight MessageID . mapLeft toS . Base64.decode . toS
+ decode = mapRight MessageID . mapLeft toS . Base64.decode . encodeUtf8
instance FromJSON MessageID where
parseJSON = Aeson.withText "MessageID" $ \v -> case parseMessageID v of
@@ -115,14 +115,14 @@ extractSignature :: Signature -> ByteString
extractSignature (Signature buf) = buf
formatSignature :: Signature -> Text
-formatSignature (Signature buf) = toS (Base64.encode buf) <> ".sig.ed25519"
+formatSignature (Signature buf) = decodeUtf8 (Base64.encode buf) <> ".sig.ed25519"
parseSignature :: Text -> Either Text Signature
parseSignature txt = decode $ T.dropEnd constLen txt
where
constLen = T.length ".sig.ed25519"
decode :: Text -> Either Text Signature
- decode = mapRight Signature . mapLeft toS . Base64.decode . toS
+ decode = mapRight Signature . mapLeft toS . Base64.decode . encodeUtf8
instance FromJSON Signature where
parseJSON = Aeson.withText "Signature" $ \v -> case parseSignature v of
@@ -206,7 +206,7 @@ withSignature signature buf = (dropEnd (BS.length endTxt) buf) <> sigTxt
sigTxt =
",\n \"signature\": "
<> "\""
- <> toS (formatSignature signature)
+ <> encodeUtf8 (formatSignature signature)
<> "\""
<> endTxt
endTxt = "\n}"
@@ -332,9 +332,9 @@ encodeForSigning contentOrder arg = do
then
return (error "external V8 byte string encoder not initialized")
else do
- atomically $ putTMVar v8Input (cmd <> toS arg)
+ atomically $ putTMVar v8Input (cmd <> arg)
ret <- atomically $ takeTMVar v8Output
- let ret' = Base64.decode (toS ret)
+ let ret' = Base64.decode ret
return $ mapLeft toS ret'
where
cmd = if contentOrder