Commit Graph

225 Commits

Author SHA1 Message Date
Evgeny Poberezkin
a2016241df support Home, End and Del keys (#87)
* add Home and End keys

* support Delete key

* simplify updateTermState
2021-04-10 12:53:22 +01:00
Evgeny Poberezkin
5c44ad0a62 Windows support in editor mode (#85)
* use System.Terminal for "editor" mode (WIP, does not work in POSIX)

* fix getKey - only return one event on control keys

* fix printing with System.Terminal

* different markdown escape for color, added black color

* fix color escapes

* make black invisible

* markdown fixes

* remove Key type, fix editor bug, refactor

* refactor: use getKey in getTermLine

* default mode is "editor", remove windows warning

* markdown: code snippet

* use ! for color markdown

* edit previous input

* clean up

* use getWindowSize from System.Terminal
2021-04-10 11:57:28 +01:00
Efim Poberezkin
d0b047d197 automate changelogs (#84) v0.2.0 2021-04-09 18:20:09 +04:00
Evgeny Poberezkin
b8241af7e9 refactor chat terminal (#83) 2021-04-08 20:20:06 +01:00
Evgeny Poberezkin
44c5a3142e Markdown (#81)
* Markdown type

* Markdown parser (WIP)

* fix markdown parser

* style markdown in messages

* one-letter color abbreviations in markdown
2021-04-08 19:32:38 +01:00
Evgeny Poberezkin
59ef46314d Support windows terminal in basic mode (#80)
* add terminal package

* basic terminal mode with utf8 support in windows

* fix terminal input in basic mode on mac

* test code

* send StyledString to ChatTerminal

* clean up

* support StyledString with System.Terminal

* minor style change

* clean up

* minor style change
2021-04-07 20:20:32 +01:00
Evgeny Poberezkin
d8965d4a23 remove terminal mode "simple" (#78) 2021-04-03 21:53:16 +01:00
Evgeny Poberezkin
4353dcb3a7 enforce windows terminal mode to basic, warning message (#77) 2021-04-03 20:39:37 +01:00
Efim Poberezkin
16eb560dbc automate releases (#76) 2021-04-03 23:17:51 +04:00
Efim Poberezkin
bd753dbe47 agent sqlite: enable FKs in *all* db connections (#75) 2021-03-29 19:27:05 +04:00
Efim Poberezkin
08171e987d agent sqlite: initialize database in home directory by default (#74) 2021-03-29 19:18:54 +04:00
Evgeny Poberezkin
da72efc20a readme: note on docker (#73) 2021-03-09 07:17:11 +00:00
Evgeny Poberezkin
7cad237092 simplify installation instruction (#72) 2021-03-09 07:08:36 +00:00
Evgeny Poberezkin
9b0ed1d62d Windows terminal editing (#71)
* windows-compatible getChar without buffering, option to use terminal without editing

* option to choose terminal mode, conditional compilation for Windows

* conditional extension

* add basic terminal mode (no contact insertion)

* option help
2021-03-09 07:05:08 +00:00
Efim Poberezkin
b9943c359d chat: subscribe to all connections on startup (#70) 2021-03-06 15:39:00 +04:00
Efim Poberezkin
11c8bee836 agent store: make newtypes for msg internal Ids (#68) 2021-03-04 23:19:12 +04:00
Efim Poberezkin
93e782b874 agent store: organize sender and broker fields into tuples (#67) 2021-03-04 23:00:00 +04:00
Efim Poberezkin
cc9a67f38a agent store: explain use for various message Ids (#66) 2021-03-04 22:30:15 +04:00
Efim Poberezkin
660e35d1d1 check that sqlite library is compiled with threadsafe code (#63) 2021-03-02 22:30:59 +04:00
Evgeny Poberezkin
a3990ea170 Types.hs -> Protocol.hs (#62) 2021-02-28 17:00:14 +00:00
Evgeny Poberezkin
d96aeb727f improve rsa encryption (#61)
* clrify encryption schemes

* increase SMP ping delay

* include authTag and msg size in encrypted message header, pad messages to fixed size

* use newtype for Key and IV bytestrings

* rename CryptoError constructors

* refactor Word to Int conversion

* refactor padding, replace padding character

* rfc corrections, comment

* rename aesTagSize -> authTagSize

* failing test
2021-02-28 16:17:28 +00:00
Evgeny Poberezkin
927ff230da Separate db connection for each TCP client connection (#60)
* use separate db connections for each TCP client connection

* refactor atomically, increast delay in tests

* increase test delay for SMP server to start

* increase SMP ping frequency

* remove comment

* separate SQLite connection per thread, to support multi-threaded mode

* remove redundant import
2021-02-28 14:59:29 +00:00
Evgeny Poberezkin
7570ef9e22 SMP heartbeat to maintain the connection (#59)
* SMP heartbeat to maintain the connection

* separate SMP commands into sections

* update SMP command sections

* update SMP commands comment

Co-authored-by: Efim Poberezkin <efim.poberezkin@gmail.com>
2021-02-27 15:24:05 +00:00
Efim Poberezkin
3af34dea8b agent store: accept internal ts and return internal id (#58) 2021-02-27 15:06:51 +04:00
Efim Poberezkin
135aac77ab add chat history instructions to README (#56) 2021-02-26 18:53:50 +04:00
Efim Poberezkin
8134bb0eb9 agent store: settle naming of Rcv and Snd entities (#55) 2021-02-26 18:17:56 +04:00
Efim Poberezkin
a0c52033f7 add *.session.sql to .gitignore - for saving db queries (#52) 2021-02-26 18:17:56 +04:00
Efim Poberezkin
dac35d8ea8 agent sqlite: merge SQLite and SQLite.Util (#54) 2021-02-26 18:17:56 +04:00
Efim Poberezkin
b4ebe85ce3 agent sqlite: move sql queries closer to parameters (#53) 2021-02-26 18:17:56 +04:00
Efim Poberezkin
0f60c53a66 agent: save messages (#45) 2021-02-25 19:02:27 +04:00
Efim Poberezkin
dca1bee926 chat: fix welcome line (#51) 2021-02-26 18:17:29 +04:00
Evgeny Poberezkin
1f38beb23d add mutex to prevent ansi codes appearing in the output (#50) 2021-02-26 18:17:29 +04:00
Evgeny Poberezkin
51aab978bd remove GADT syntax from existential wrappers (#49) 2021-02-26 18:17:29 +04:00
Efim Poberezkin
3a161e93ca add Dockerfile for building chat executable and instructions on running it (#48)
* [WIP] add instructions how to build project inside docker container

* docker run -> docker create

* add Dockerfile for building chat executable and instructions
2021-02-26 18:17:29 +04:00
Evgeny Poberezkin
1251caa4e8 terminal UI (#44)
* separate terminal IO to separate thread via queues

* terminal input arithmetics (WIP)

* editable multiline terminal input

* print messages above input area

* support Up/Down arrows

* terminal chat: move by word, move to the beginning/end of input

* insert active contact when typing starts

* refactor inserting active contact

* highlight "to contact"

* add username to prompt

* change beginning/end of line keys to shoft-arrow

* remove unused code

* add ctrl arrow key bindings

* add comment for debugging keys in terminal

Co-authored-by: Efim Poberezkin <efim.poberezkin@gmail.com>
2021-02-26 18:17:29 +04:00
Efim Poberezkin
033af51d6d add instructions on how to run chat client to README (#43)
* add instructions on how to run chat client to README

* wording

* wording

* corrections to the manual

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-02-26 18:17:29 +04:00
Efim Poberezkin
f3840928e0 dog-food: distinguish self from contacts (#42)
* dog-food: distinguish self from contacts

* add missing space

* rename tty functions

* return indents

* remove indentation in sent messages

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-02-26 18:17:29 +04:00
Efim Poberezkin
8d05ace601 crypto rfc: clean up e2e (#41) 2021-02-15 20:39:21 +04:00
Efim Poberezkin
1cf1c6a4b1 crypto (#33)
* add crypto rfc

* crypto rfc: fix handshake logic

* transport encryption

* e2e encryption and command verification

* crypto rfc: clarify secrecy of public keys

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-02-15 20:22:40 +04:00
Efim Poberezkin
c25a6d6896 crypto: clean up magic numbers (#40) 2021-02-15 19:51:02 +04:00
Evgeny Poberezkin
435ab21e71 E2E message encryption (#38)
* RSA OAEP functions

* encrypt/decrypt using AES AEAD GSM

* fix JOIN syntax test

* encrypt/decrypt functions working

* e2e encryption!

* refactor monadic transitions

* rename liftError' to liftEitherError

* combine CryproFailable functions
2021-02-26 18:14:22 +04:00
Efim Poberezkin
469f84bb74 use cryptographic key pairs for encryption keys (#39)
* use cryptographic key pairs for encryption keys

* use speaking key types

* fix key types

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-02-26 18:14:22 +04:00
Evgeny Poberezkin
0fe41dbf16 Sign / verify SMP commands (#37)
* generate key pair

* crypto: sign/verify functions

* remove extension

* parse/serialize keys

* use RSA recipient/sender keys (TODO sign/verify)

* make PublicKey newtype, assign 0s to private_p & private_q

* replace SMP command parsing with Attoparsec

* rename types: Signed->Transmission, Transmission->SignedTransmission

* sign and verify commands (server tests skipped, agent tests pass)

* SMP client: avoid seralizing transmission twice when sending commands

* update SMP server tests to use command signatures

* remove support for "SEND :msg" syntax from SMP server protocol

* rename RSA module name to R to avoid confusion with C used for S.M.Crypto

* update key sizes to use bits `div` 8

* tidy up
2021-02-26 18:14:22 +04:00
Efim Poberezkin
ce362da311 fix ghc version in build (#36) 2021-02-26 18:14:22 +04:00
Efim Poberezkin
7e9cfcce8c agent sqlite: rework schema, make methods transactional, enable foreign keys (#34)
* agent sqlite: rework schema

* agent sqlite: explicitly mark primary keys as NOT NULL

* agent sqlite: adjust connections and queues fkeys

* agent sqlite: remove ack_mode from queues tables

* [WIP] agent sqlite: refactor methods

* agent sqlite: implement transactional createRcvConn

* add comment

* agent sqlite: remove ConnAlias from createRcvConn signature

* agent sqlite: implement transactional createSndConn

* agent sqlite: remove monadic stack from store util methods

* agent sqlite: refactor getConn

* agent sqlite: rename conn -> dbConn

* agent sqlite: move transactional logic to utils

* agent sqlite: remove addServer from store interface

* fix comment

* agent sqlite: refactor getRcvQueue

* agent sqlite: refactor deleteConn

* agent sqlite: remove old deleteConn

* agent sqlite: enable FKs

* agent sqlite: refactor methods upgrading connection to duplex

* agent sqlite: uncomment not implemented methods

* agent sqlite: rename methods upgrading connection to duplex

* use liftEither

* agent sqlite: refactor update queue status methods

* agent sqlite: refactor createMsg

* clean up

* fix compilation errors in src

* fix existing tests

* clean up tests

* agent sqlite: test that foreign keys are enabled

* change private members naming

* tests: expect specific error code

* clean up

* agent sqlite: consistently separate lifts from logic to their own lines
2021-02-04 19:23:43 +04:00
Evgeny Poberezkin
1f61267308 chat prototype (#35)
* chat prototype

* chat prototype now compiles

* chat prototype works

* agent: respond SENT mId to SEND (instead of OK), ne repsonse to chat message in terminal

* chat prototype help, update commands

* chat CLI options

* add active contact to ChatClient (not used yet)

* refactor agentTransmission

* InviteContact -> AddContact

* automatically insert active contact

* highlight contact in chat

* name for invitations

* do not ask name on start

* change default server to smp.simplex.im
2021-02-26 18:13:04 +04:00
Evgeny Poberezkin
3192092349 message management (#32)
* message management rfc

* update message management rfc

* message management ideas (WIP)

* message management updated

* messages RFC

* update agent MSG constructor to include recipient/broker/sender message IDs and timestamps

* remove agent command ACK - agent automatically acknowledges server messages

* correct messages doc
2021-02-26 18:13:04 +04:00
Evgeny Poberezkin
4b5349fb94 Refactor END notifications (#31)
* kill TCP server client threads when the main server thread is killed; test END notification when server connection dies

* revert to using forkIO in the tests

* make subscriptions state change atomic

* remove commented out code

* Revert "revert to using forkIO in the tests"

This reverts commit c0bacd92e4.
2021-02-26 18:13:04 +04:00
Evgeny Poberezkin
17b429afe7 handle TCP disconnections (WIP) (#29)
* handle TCP disconnections (WIP)

* agent: handle SMP server disconnections

* agent: notify client about lost subscriptions when SMP server disconnects

* comments for testing functions

* remove test apps

* chore: reorder functions in Transport

* add comment

Co-authored-by: Efim Poberezkin <efim.poberezkin@gmail.com>
2021-02-26 18:13:04 +04:00
Efim Poberezkin
e09d3bae99 agent store: move SQLite Types -> Util (#30) 2021-01-25 20:14:33 +04:00