Ime Protokol servira

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).

Pravilniki o formiranju imena

Korisničke imena provjerava regex kako bi se osigurali neki pravila o njihovom formatu:

  • Dužina mora biti između 3 i 32 znakova

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

Tražim ime

Ovo je glavna usluga koju pruža server imena.

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.

U našem primjeru, odgovor na JSON bi bio:

{
    "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.

To je JSON dokument s 1 znakom: error. Ovaj znak je ispunjen greškom koja objašnjava pogrešku (i može se prikazati u klijentu u budućnosti).

U pogledu referentne provedbe, vraćeni dokument je:

{
    "error":"name not registred"
}

Upitavanje adrese

Ova usluga je obrnuto traženje. tražite adresu i korisničko ime se vraća ako je registriran na serveru imena.

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.

U ovom polju je vrijednost imena registriranog na ovu adresu

U našem primjeru, odgovor na JSON bi bio:

{
    "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.

To je JSON dokument s 1 znakom: error. Ovaj znak je ispunjen greškom koja objašnjava pogrešku (i može se prikazati u klijentu u budućnosti).

U pogledu referentne provedbe, vraćeni dokument je:

{
    "error":"address not registred"
}

Uvod u ime

Ovaj dio protokola koristi se za registraciju novog imena/adresa par.

Request register

Zahtjev za registraciju imena foobar je zahtjev POST s /name/foobar kao URI.

U tijelu zahtjeva je JSON dokument s 2 znakova: addr i owner. addr sadrži Jami ID prefiksiran s 0x i owner je ime koje se treba registrirati.

Primjer za foobar može biti:

{
    "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.

U tijelu je dokument JSON s 1 boolean atributom success postavljen na true.

Kao primjer:

{
    "success":true
}

Nadaljnji pokušaji ispitivanja imena ili adrese trebali bi biti uspješni.

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.

Tjel je JSON dokument s 2 atributa: success koji je boolean i error koji je niz. success je postavljen na false i error ispunjen je greškom koja objašnjava pogrešku (i može se prikazati u klijentu u budućnosti).

Za nevaljan oblikovanje korisničkog imena, tijelo može biti:

{
    "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.

Tjel je JSON dokument s 3 atributa: success koji je booleanski skup na false, name i addr koji su oba nizovi replicirani iz originalnog zahtjeva.

U slučaju registracije foobar, s obzirom na to da je već registrirana, rezultirat će sljedeći odgovor:

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