briar issueshttps://code.briarproject.org/briar/briar/-/issues2020-10-31T12:52:40Zhttps://code.briarproject.org/briar/briar/-/issues/1577Some questions about Headless API2020-10-31T12:52:40ZNicoSome questions about Headless API@grote asked me to read carefully over the [Briar Headless API documentation](https://code.briarproject.org/briar/briar/blob/release-1.1.7/briar-headless/README.md) in order to find things that needs more explanation. And I do have some ...@grote asked me to read carefully over the [Briar Headless API documentation](https://code.briarproject.org/briar/briar/blob/release-1.1.7/briar-headless/README.md) in order to find things that needs more explanation. And I do have some questions that I'll copy-paste from our chat into separate discussion boxes below. With these questions, I hope to make clear in how far the documentation needs to be improved in order to make it easier for third-party developers to implement the API.Headless MVPNicoNicohttps://code.briarproject.org/briar/briar/-/issues/1512Can't pipe into headless prompt2020-10-31T12:52:40ZNicoCan't pipe into headless promptWhenever I try to pipe into Briar's registration prompt, I get this output:
```
No account found. Let's create one!
Nickname: Password: Exception in thread "main" java.lang.RuntimeException: EOF
at com.github.ajalt.clikt.output.NonInt...Whenever I try to pipe into Briar's registration prompt, I get this output:
```
No account found. Let's create one!
Nickname: Password: Exception in thread "main" java.lang.RuntimeException: EOF
at com.github.ajalt.clikt.output.NonInteractiveCliktConsole.promptForLine(CliktConsole.kt:63)
at com.github.ajalt.clikt.output.TermUi.prompt(TermUi.kt:94)
at com.github.ajalt.clikt.output.TermUi.prompt$default(TermUi.kt:86)
at org.briarproject.briar.headless.BriarServiceImpl.createAccount(BriarService.kt:60)
at org.briarproject.briar.headless.BriarServiceImpl.start(BriarService.kt:33)
at org.briarproject.briar.headless.Router.start$briar_headless(Router.kt:45)
at org.briarproject.briar.headless.Main.run(Main.kt:78)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:112)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:19)
at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:166)
at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:164)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:181)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:200)
at org.briarproject.briar.headless.MainKt.main(Main.kt:115)
```
This is how I tried it:
_Python_
```python
p = Popen(['java', '-jar', self.headless_jar, '-v'],
stdin=PIPE, universal_newlines=True)
p.communicate(credentials[0] + '\n' + credentials[1] +
'\n' + credentials[1] + '\n')
```
_Bash_
```bash
echo "nico
password
password
" | java -jar briar-headless.jar
```
Upstream had an issue called [NonInteractiveCliktConsole only reads in the first line from an input file](https://github.com/ajalt/clikt/issues/32) which sounds like the origin of this problem. It was fixed in newer versions (1.6.0). Before that version, it failed like this:
```bash
INFO: No database key in backup file
No account found. Let's create one!
Nickname: Password: Usage: briar-headless [OPTIONS]
Error: Could not get account information. Is STDIN connected?
```
In the meantime, [version 1.7.0](https://github.com/ajalt/clikt/releases/tag/1.7.0) was released but it doesn't change anything regarding this problem. I have [built a version of briar-headless with 1.7.0](https://media.dorfbrunnen.eu/briar/patched/briar-headless.jar) and tested it both in bash and python and get the same exception like with 1.6.0.
We should investigate why we get this exception when upstream claims to now support multi-line pipes.
On IRC we discussed to allow environment variables as an alternative for "scripted use" of the api.
Related:
* [Lines of code](https://github.com/ajalt/clikt/blob/master/clikt/src/main/kotlin/com/github/ajalt/clikt/output/CliktConsole.kt#L61) producing exception in _clikt_
* Fixed issue called [Make possible to use arbitrary input/output stream](https://github.com/ajalt/clikt/issues/57)
* [Lines of code](https://code.briarproject.org/NicoAlt/briar-gtk/blob/39986ba6b4cec35806efecaf59da7dcdc2214b3c/src/briar/api/api.py#L30) in briar-gtk's current code
* [Lines of code](https://code.briarproject.org/briar/briar/blob/4d26628f2a08169d4cbeebd1a9a4eafbca581504/briar-headless/src/main/java/org/briarproject/briar/headless/BriarService.kt#L31) of prompt in _briar-headless_
* Commit [Update clikt to 1.7.0 ](https://code.briarproject.org/NicoAlt/briar/commit/a53458be423f86ae01b28a035766391615fa80cc)Headless MVPTorsten GroteTorsten Grotehttps://code.briarproject.org/briar/briar/-/issues/1254Headless server/desktop app2019-06-18T11:50:21ZakwizgranHeadless server/desktop appUmbrella ticket for sponsor 1, objective 5.
Outstanding Tasks:
* [x] add command line options for things like controlling log verbosity, port to bind to, etc.
* [x] research better input validation options
* [x] unit tests for all con...Umbrella ticket for sponsor 1, objective 5.
Outstanding Tasks:
* [x] add command line options for things like controlling log verbosity, port to bind to, etc.
* [x] research better input validation options
* [x] unit tests for all controllers
* [x] REST API authentication with bearer token (maybe optional, or only when not bound to localhost?)
* [x] Websocket API authentication (problematic since JavaScript can't control headers in request)
* [x] simple API documentation in README.md
* [x] add support for adding contacts (blocked by missing support in core)Headless MVPTorsten GroteTorsten Grotehttps://code.briarproject.org/briar/briar/-/issues/1256REST endpoint for adding and removing contacts2019-05-16T14:06:09ZakwizgranREST endpoint for adding and removing contacts* [x] adding contacts
* [x] removing contacts
Subtask of #1254.* [x] adding contacts
* [x] removing contacts
Subtask of #1254.Headless MVPTorsten GroteTorsten Grotehttps://code.briarproject.org/briar/briar/-/issues/1452Websocket Authentication2018-11-27T10:00:33ZTorsten GroteWebsocket AuthenticationDespite many (older) claims in the internet that you can establish websocket connections with basic auth, this doesn't seem to be true for javascript libraries running in a recent browser. I managed to do it in Python and assumed it will...Despite many (older) claims in the internet that you can establish websocket connections with basic auth, this doesn't seem to be true for javascript libraries running in a recent browser. I managed to do it in Python and assumed it will just work on browsers as well, but it seems that isn't the case. At least I haven't been able to make this work. The only thing we can send in the upgrade request from a browser is a list of protocols. In absence of a standardized authentication mechanism, there's people using this already to pass auth tokens. I confirmed that we can access this header on the server side and check if there's an auth token in it.
If we don't want that hacky (but easy) solution, I am afraid we need to get into the business of tracking each session's authentication state and require them to send a first message with the token before we start sending stuff to it. Maybe even terminate sessions that haven't authenticated after a timeout.Headless MVPTorsten GroteTorsten Grotehttps://code.briarproject.org/briar/briar/-/issues/1257REST endpoint for sending private messages2018-10-19T13:24:26ZakwizgranREST endpoint for sending private messagesSubtask of #1254.Subtask of #1254.Headless MVPTorsten GroteTorsten Grotehttps://code.briarproject.org/briar/briar/-/issues/1258REST endpoint for publishing blog posts2018-10-19T13:24:04ZakwizgranREST endpoint for publishing blog postsSubtask of #1254.Subtask of #1254.Headless MVPTorsten GroteTorsten Grotehttps://code.briarproject.org/briar/briar/-/issues/1255Implement background service for headless desktop/server app2018-10-16T16:05:38ZakwizgranImplement background service for headless desktop/server appThis service will manage the app's lifecycle, similar to BriarService on Android.
Subtask of #1254.This service will manage the app's lifecycle, similar to BriarService on Android.
Subtask of #1254.Headless MVPTorsten GroteTorsten Grote