module App.URLDecoder where
import Data.Base64.Types (extractBase64)
import Data.Text.Encoding.Base64.URL qualified as Base64URL
import Fitch.Proof (Proof)
import Parser.IncompleteProof (parseIncompleteProof, safeParsePrint)
encodeForUrl :: Proof -> Text
encodeForUrl :: Proof -> Text
encodeForUrl = Base64 'UrlPadded Text -> Text
forall (k :: Alphabet) a. Base64 k a -> a
extractBase64 (Base64 'UrlPadded Text -> Text)
-> (Proof -> Base64 'UrlPadded Text) -> Proof -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Base64 'UrlPadded Text
Base64URL.encodeBase64 (Text -> Base64 'UrlPadded Text)
-> (Proof -> Text) -> Proof -> Base64 'UrlPadded Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proof -> Text
safeParsePrint
decodeFromUrl :: Text -> Maybe Proof
decodeFromUrl :: Text -> Maybe Proof
decodeFromUrl = Text -> Maybe Proof
parseIncompleteProof (Text -> Maybe Proof) -> (Text -> Text) -> Text -> Maybe Proof
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
Base64URL.decodeBase64Lenient