Ime Protokol strežnika

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

Pravila o oblikovanju imena

Uporabniška imena preverja regex, da zagotovijo nekatere pravila glede njihovega formata:

  • Dolžina mora biti med 3 in 32 znakoma

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

Vprašanje ime

To je glavna storitev, ki jo zagotavlja name server.

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.

V našem primeru bi bil odgovor na 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.

Telo je JSON dokument z 1 vrstico atributom: error. Ta atribut je napolnjen z sporočilom o napaki, ki pojasnjuje napako (in ga je mogoče prikazati v stranki v prihodnosti).

V zvezi z referenčno izvedbo je vrnjen dokument:

{
    "error":"name not registred"
}

Vprašanje za naslov

Ta storitev je obrnitev. Poizvedite naslov in uporabniško ime se vrne, če je registrirano na ime strežnika.

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.

Telo je JSON dokument z 1 znakom: name. Vrednost tega polja je ime, registrirano na ta naslov

V našem primeru bi bil odgovor na 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.

Telo je JSON dokument z 1 vrstico atributom: error. Ta atribut je napolnjen z sporočilom o napaki, ki pojasnjuje napako (in ga je mogoče prikazati v stranki v prihodnosti).

V zvezi z referenčno izvedbo je vrnjen dokument:

{
    "error":"address not registred"
}

Registriranje imena

Ta del protokola se uporablja za registracijo novega imena/naslova par.

Request register

Zahtevka za registracijo imena foobar je zahtevek POST z /name/foobar kot URI. Atribut glave Content-type je treba nastaviti na application/json.

V tem primeru se lahko vnesete v skupno stranko, ki je vnesena v skupno stranko.

Primer za foobar bi lahko bil:

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

V telesu je dokument JSON z 1 boolskim atributom success, ki je nastavljen na true.

Kot primer:

{
    "success":true
}

Nadaljnji poskusi za iskanje imena ali naslova bodo potem uspeš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.

Telo je JSON dokument z 2 atributoma: success, ki je booleanska in error, ki je niz. success je nastavljen na false in error je napolnjen z sporočilom o napaki, ki pojasnjuje napako (in ga je mogoče prikazati v stranki v prihodnosti).

Za nepravično oblikovanje uporabniškega imena bi lahko bil organ:

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

Telo je JSON dokument z 3 atributoma: success, ki je booleanska skupina na false, name in addr, ki sta obe verizi, ki so ponovljeni iz izvirne zahteve.

Če bi se registriranje foobar že registriralo, bi prišlo do naslednjega odgovora:

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