This package contains code for an example Web application for a class at BayHac2014. The application allows to create encrypted emails from within a browser.
This is not production level code.
The purpose of this package to demonstrate techniques for development of portable Haskell libraries that can be used with native compilations as well as cross-compilations to client-side javascript via the Haste compiler.
http://alephcloud.github.io/bayhac2014/slides/index.html
The package includes a library component that can be compiled with native GHC as well as with the Haste compiler. The library exposes two interfaces:
- a Haskell API for encryption and decryption with a password and
- a JSON service API that wraps the Haskell API in JSON data types.
The package further contains an application that serves the JSON API over HTTP using scotty.
The package also contains an application that exports the JSON API as client side javascript module.
Finally, there is a cabal test suite for unit testing the library with a native compilation.
The following instructions installs the haste-compiler in a cabal sandbox. Note, however, that the resulting haste-compiler itself is not using a sandbox for compilations.
Build Haste:
cabal sandbox init
echo 'constraints: scientific<0.3' >> cabal.config
cabal install haste-compiler -j
export PATH=./.cabal-sandbox/bin:$PATH
Setup Haste:
echo 'solver: topdown' >> ~/.cabal/config
haste-boot
sed -i '/solver: topdown/d' ~/.cabal/config
If haste-boot
failes with an error message that inlcude the text only already installed instances can be used
you may try to temporarily add the
following to your ~/.cabal/config
while running haste-boot
.
The native version of the library and the server application can be installed via
cabal install
The test suite can be run via
cabal configure --enable-tests
cabal build
cabal test
The javascript module is build via
mv cabal.sandbox.config cabal.sandbox.config.disabled
haste-inst install -fhaste
haste-inst configure -fhaste
haste-inst build
The resulting javascript code is in the file src/Client.js
. It can be tested
by opening the file Main.html
in a browser from the root directory of the
package.
This package includes a copy of a version of SJCL
in the file ./lib/sjcl.js
. SJCL is hosted at https://github.com/bitwiseshiftleft/sjcl and
distributed under a BSD license as described at http://bitwiseshiftleft.github.io/sjcl.
The file ./src/BayHac2014/Cryptmail/Json.hs
and the files in the directory
./src/BayHac2014/Cryptmail/Json
of this package in part contain code that was
copied, derived, or inspired by the Aeson
package. The Aeson package is
distributed under a BSD3 License and copyright of (c) 2011-2014 Bryan
O'Sullivan (c) 2011 MailRank, Inc.. A copy of the LICENSE of the Aeson package
can be found
here.