Име Протокол сервера

The protocol used by Jami to query and register a name is based on an HTTP REST API answering requests with JSON documents and regular HTTP status codes.

The public name server is hosted at ns.jami.net. Another implementation could use any other database or directory service making the name server protocol reusable.

If you run your own name server, looking up a username in the form of username@example.com will look up the name username with the name server at example.com (there is no need to add @ns.jami.net to use the default name server).

Правила о форматисању имена

Имена корисника проверља регекс како би се осигурало неке правила о њиховом форматисању:

  • Дужина мора бити између 3 и 32 знака

  • Those characters must be alphanumerical with dashes - being also accepted.

Питање имена

Ово је главни сервис који пружа сервер имена. То омогућава добијање ИД Џами одговарајућег корисничком имену.

Request name

A request for the name foobar is a GET request with /name/foobar* as the URI.

Response name (Success)

If the name is found, a response with status code 200 OK must be sent to the client with a Content-type field set as application/json.

The body is a JSON documents with 2 string attributes : name and addr. name is equal to the one requested and addr is a hexadecimal representation of the Jami ID prefixed with 0x.

У нашем примери, одговор JSON би био:

{
    "name":"foobar",
    "addr":"0x29347542eb07159f316577e1ae16243d152f6b7b"
}

Response name (Not found)

If the name is not found, a response with status code 404 Not Found must be sent to the client with a Content-type field set as application/json.

Тело је JSON документ са 1 струна атрибута: error. Овај атрибут је испуњен грешком која објашњава грешку (и може се приказивати у клијенту у будућности).

У вези са референтном спроводом, враћен документ је:

{
    "error":"name not registred"
}

Поиштање адресе

Ова услуга је обратна трага. Попитате адресу и корисничко име се враћа ако је регистровано на серверу имена.

Request address

A request for the ID jami:29347542eb07159f316577e1ae16243d152f6b7b is a GET request with /addr/29347542eb07159f316577e1ae16243d152f6b7b as the URI.

Response address (Success)

If the address corresponds to a username, a response with status code 200 OK must be sent to the client with a Content-type field set as application/json.

Тело је JSON документ са 1 струна атрибута: name. Значење овог поља је име регистровано на ову адресу

У нашем примери, одговор JSON би био:

{
    "name":"foobar"
}

Response address (Not found)

If the address is not found, a response with status code 404 Not Found must be sent to the client with a Content-type field set as application/json.

Тело је JSON документ са 1 струна атрибута: error. Овај атрибут је испуњен грешком која објашњава грешку (и може се приказивати у клијенту у будућности).

У вези са референтном спроводом, враћен документ је:

{
    "error":"address not registred"
}

Регистрација имена

Овај део протокола се користи за регистрацију новог пар имена/адреса.

Request register

Задатак за регистрацију имена foobar је POST захтев са /name/foobar као УРИ.

Тело захтева је JSON документ са 2 атрибуте струје: addr и owner. addr садржи ИД Џами префиксиран са 0x и owner је име које се региструје.

Пример за foobar може бити:

{
    "addr":"0x29347542eb07159f316577e1ae16243d152f6b7b",
    "owner":"foobar"
}

Response register (Success)

If the name/address pair is successfully registered, a response with status code 200 OK must be sent to the client with a Content-type field set as application/json.

Тело садржи JSON документ са 1 булеански атрибут success постављен на true.

На пример:

{
    "success":true
}

У овом случају, уколико се настави да се тражи име или адреса, биће успешни.

Response register (Bad request)

If the registration cannot be achieved because of an error in the request (formatting, missing attribute, etc.), a response with status code 400 Bad Request must be sent to the client with a Content-type field set as application/json.

Тело је JSON документ са 2 атрибута: success који је булеански и error који је рад. success је постављен на false и error је испуњен грешком која објашњава грешку (и може се приказивати у клијенту у будућности).

За неважни форматирање корисничког имена, тело би могло бити:

{
    "success": false,
    "error": "invalid name"
}

Response register (Forbidden)

If the registration cannot be achieved because the name is already taken, a response with status code 403 Forbidden must be sent to the client with a Content-type field set as application/json.

Тело је JSON документ са 3 атрибута: success који је булеански скуп на false, name и addr који су оба струна репликација из оригиналне траге.

Регистрација foobar, пошто је већ регистрована, довела би до следећег одговора:

{
    "success": false,
    "name":"foobar",
    "addr":"0x29347542eb07159fdeadbeefae16243d152f6b7b"
}