gopass/docs/jsonapi.md
Jean Jordaan 393dd0391d Editing while reading (#890)
* Editing while reading

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Hyphenate sub-store

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Markup literals

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* "it's" is "it is", "its" is possessive.

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Make clear that it's the .config in $HOME

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Use commas for phrasing

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Hyphenate sub-command

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Mark bash blocks as bash

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Add some semantic linebreaks; fix code block quoting

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Improve phrasing

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Markup, commas ..

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* gopass is consistently lowercase

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>

* Add some linebreaks, improve phrasing

Signed-off-by: Jean Jordaan <jean.jordaan@gmail.com>
2018-08-11 07:17:35 +02:00

1.9 KiB

JSON API

Overview

The API follows the specification for native messaging from Mozilla and Chrome. Each JSON-UTF8 encoded message is prefixed with a 32-bit integer specifying the length of the message. Communication is performed via stdin/stdout.

WARNING: This API MUST NOT be exposed over the network to remote hosts. No authentication is performed and the only safe way is to communicate via stdin/stdout as you do in your terminal.

The implementation is located in utils/jsonapi.

Request Types

query

Query:

{
  "type": "query",
  "query": "secret"
}

Response:

[
    "somewhere/mysecret/loginname",
    "somewhere/else/secretsauce"
]

queryHost

Similar to query but cuts hostnames and subdomains from the left side until the response to the query is non-empty. Stops if only the public suffix is remaining.

Query:

{
  "type": "queryHost",
  "host": "some.domain.example.com"
}

Response:

[
    "somewhere/domain.example.com/loginname",
    "somewhere/other.domain.example.com"
]

getLogin

Query:

{
   "type": "getLogin",
   "entry": "somewhere/else/secretsauce"
}

Response:

{
   "username": "hugo",
   "password": "thepassword"
}

create

Query:

{
   "type": "create",
   "login": "myusername",
   "password": "",
   "length": 12,
   "generate": true,
   "use_symbols": true
}

Response:

{
   "username": "myusername",
   "password": "5^dX9j1\"b5^q"
}

Error Response

If an uncaught error occurs, the stringified error message is send back as the response:

{
  "error": "Some error occurred with fancy message"
}