Nimi Server protokoll
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).
Nimi vormingu eeskirjad
Kasutajainimed kontrollitakse regex’i poolt, et tagada nende formaadi kohta mõned reeglid:
Pikkus peab olema 3 kuni 32 karakteri vahel
Those characters must be alphanumerical with dashes
-
being also accepted.
Küsimus nime kohta
See on nimi server pakutav peamine teenus, mis võimaldab saada Jami ID, mis vastab kasutajanimele.
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
.
Meie näites oleks JSON vastus:
{
"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-dokumendid on JSON-dokumendid, millel on 1 järjekordne attribüüt: error
. See attribüüt on täidetud vigamise sõnumiga, mis selgitab viga (ja seda võib tulevikus kliendil näidata).
Referentsite rakendamise kohta tagastatakse dokumend:
{
"error":"name not registred"
}
Adressi küsimine
See teenus on pöördvaataht. Te küsite aadressi ja kasutajanimi saadakse tagasi, kui üks on registreeritud nime serveris.
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-dokumendid, millel on 1 järjekordne tunnus: name
. Selle välja väärtus on selles aadressi registreeritud nimi
Meie näites oleks JSON vastus:
{
"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-dokumendid on JSON-dokumendid, millel on 1 järjekordne attribüüt: error
. See attribüüt on täidetud vigamise sõnumiga, mis selgitab viga (ja seda võib tulevikus kliendil näidata).
Referentsite rakendamise kohta tagastatakse dokumend:
{
"error":"address not registred"
}
Nimi registreerimine
Seda protokolli osa kasutatakse uue nime/aadressi paari registreerimiseks.
Request register
Nimi registreerimise taotlus foobar
on POST
taotlus, mille URI on /name/
foobar
.Üleheegistus Content-type
peab olema seadistatud application/json
.
Taotluse keha on JSON-dokumend, millel on 2 järjekorda: addr
ja owner
. addr
sisaldab Jami ID, mille eesnäiteks on 0x
ja owner
on registreeritava nimi.
foobar
võib olla näiteks:
{
"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
.
Korpus sisaldab JSON-dokumendi, millel on 1 boolean-attribuut success
, mis on määratud true
.
Näiteks:
{
"success":true
}
Järgmised üritused nime või aadressi küsida peaks olema edukad.
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-dokumendid on 2 tunnusega: success
, mis on booliane ja error
, mis on string. success
on seadistatud false
ja error
on täis vigu sõnumit, mis selgitab vigu (ja seda võib tulevikus kliendil näidata).
Kasutaja nime kehtetuks vorminguks võib keha olla:
{
"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-dokumendid on 3 tunnusega: success
, mis on boolean set false
, name
ja addr
, mis on mõlemad reedid, mis on replitseeritud algsest taotlusest.
Registreerimine foobar
, kui see on juba registreeritud, toob kaasa järgmise vastuse:
{
"success": false,
"name":"foobar",
"addr":"0x29347542eb07159fdeadbeefae16243d152f6b7b"
}
Mõned sidemed
: eteroomite node’i rakendamine, mida kasutatakse
ns.jami.net
ja eteroomide noduse päring.