hwormhole-0.2.0.1: magic-wormhole client

Safe HaskellNone
LanguageHaskell2010

Transit

Description

Magic Wormhole is a technology for getting things from one computer to another, safely.

In order to use the library in an application, you need to create an "application ID" which is a unique application specific ascii string, a random 5-byte bytestring called "side" and a few application configuration options defined in Options type in the Conf module which sets up the transit server url, relay server url and the mode (send or receive).

Once the environment and the configurations are set, the app can be run via runApp.

Synopsis

Documentation

data Env Source #

Magic Wormhole transit app environment

Constructors

Env 

Fields

  • appID :: AppID

    Application specific ID

  • side :: Side

    random 5-byte bytestring

  • config :: Options

    configuration like relay and transit url

Instances
MonadReader Env App Source # 
Instance details

Defined in Transit.Internal.App

Methods

ask :: App Env

local :: (Env -> Env) -> App a -> App a

reader :: (Env -> a) -> App a

prepareAppEnv :: Text -> Options -> IO Env Source #

Create an Env, given the AppID and Options

app :: App () Source #

A file transfer application that takes an Env and depending on the config options, either sends or receives a file, directory or a text message from the peer.

runApp :: App a -> Env -> IO (Either Error a) Source #

run the App Monad Transformer

send :: Session -> Text -> MessageType -> App () Source #

Given the magic-wormhole session, appid, pass code, a function to print a helpful message on the command the receiver needs to type (simplest would be just a putStrLn) and the path on the disk of the sender of the file that needs to be sent, sendFile sends it via the wormhole securely. The receiver, on successfully receiving the file, would compute a sha256 sum of the encrypted file and sends it across to the sender, along with an acknowledgement, which the sender can verify.

receive :: Session -> Text -> App () Source #

receive a text message or file from the wormhole peer.

data Options Source #

Application Configuration options

Constructors

Options 

Fields

Instances
Eq Options Source # 
Instance details

Defined in Transit.Internal.Conf

Methods

(==) :: Options -> Options -> Bool

(/=) :: Options -> Options -> Bool

Show Options Source # 
Instance details

Defined in Transit.Internal.Conf

Methods

showsPrec :: Int -> Options -> ShowS

show :: Options -> String

showList :: [Options] -> ShowS

data Command Source #

Commands

Constructors

Send MessageType

Send a file, directory or a text message

Receive (Maybe Text)

Receive a file, directory or a text message

Instances
Eq Command Source # 
Instance details

Defined in Transit.Internal.Conf

Methods

(==) :: Command -> Command -> Bool

(/=) :: Command -> Command -> Bool

Show Command Source # 
Instance details

Defined in Transit.Internal.Conf

Methods

showsPrec :: Int -> Command -> ShowS

show :: Command -> String

showList :: [Command] -> ShowS

data Error Source #

An Error type for the Magic Wormhole Transit Module

Instances
Show Error Source # 
Instance details

Defined in Transit.Internal.Errors

Methods

showsPrec :: Int -> Error -> ShowS

show :: Error -> String

showList :: [Error] -> ShowS

Exception Error Source # 
Instance details

Defined in Transit.Internal.Errors

Methods

toException :: Error -> SomeException

fromException :: SomeException -> Maybe Error

displayException :: Error -> String

MonadError Error App 
Instance details

Defined in Transit.Internal.App

Methods

throwError :: Error -> App a

catchError :: App a -> (Error -> App a) -> App a

data MessageType Source #

Transfer type

Constructors

TMsg Text

Text message transfer

TFile FilePath

File or Directory transfer

Instances
Eq MessageType Source # 
Instance details

Defined in Transit.Internal.FileTransfer

Methods

(==) :: MessageType -> MessageType -> Bool

(/=) :: MessageType -> MessageType -> Bool

Show MessageType Source # 
Instance details

Defined in Transit.Internal.FileTransfer

Methods

showsPrec :: Int -> MessageType -> ShowS

show :: MessageType -> String

showList :: [MessageType] -> ShowS

parseWebSocketEndpoint :: String -> Maybe WebSocketEndpoint #

parseTransitRelayUri :: String -> Maybe RelayEndpoint Source #

Parse transit url of the form tcp:hostname:port