Nombre Protocolo del servidor
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).
Reglas sobre el formato de los nombres
Los nombres de usuario son verificados por un regex para asegurar algunas reglas sobre su formato:
La longitud debe ser de entre 3 y 32 caracteres
Estos caracteres deben ser alfanuméricos y también debe aceptarse el guión
-
.
Buscando un nombre
Este es el servicio principal proporcionado por un servidor de nombres.
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
.
En nuestro ejemplo, la respuesta JSON sería:
{
"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
.
El cuerpo es un documento JSON con un atributo de cadena: error
. Este atributo está lleno de un mensaje de error que explica el error (y podría mostrarse en el cliente en el futuro).
En relación con la ejecución de referencia, el documento devuelto será:
{
"error":"name not registred"
}
Buscando una dirección
Este servicio es una búsqueda inversa. Usted consulta una dirección y un nombre de usuario se devuelve si uno está registrado en el servidor de nombres.
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
.
El cuerpo es un documento JSON con un atributo de cadena: name
. El valor de este campo es el nombre registrado en esta dirección
En nuestro ejemplo, la respuesta JSON sería:
{
"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
.
El cuerpo es un documento JSON con un atributo de cadena: error
. Este atributo está lleno de un mensaje de error que explica el error (y podría mostrarse en el cliente en el futuro).
En relación con la ejecución de referencia, el documento devuelto será:
{
"error":"address not registred"
}
Registro de un nombre
Esta parte del protocolo se utiliza para registrar un nuevo par de nombres/direcciones.
Request register
Una solicitud de registro del nombre foobar
es una solicitud POST
con /name/
foobar
como URI. El atributo de encabezado Content-type
debe fijarse en application/json
.
El cuerpo de la solicitud es un documento JSON con 2 atributos de cadena: addr
y owner
. addr
contiene el ID Jami prefijado con 0x
y owner
es el nombre que debe registrarse.
Un ejemplo de foobar
podría ser:
{
"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
.
El cuerpo contiene un documento JSON con 1 atributo booleano success
fijado en true
.
Como ejemplo:
{
"success":true
}
Los intentos adicionales de consultar el nombre o la dirección deberían entonces tener éxito.
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
.
El cuerpo es un documento JSON con 2 atributos: success
que es un boolean y error
que es una cadena. success
se establece en false
y error
se llena de un mensaje de error que explica el error (y podría mostrarse en el cliente en el futuro).
Para un formato inválido del nombre de usuario, el cuerpo podría ser:
{
"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
.
El cuerpo es un documento JSON con 3 atributos: success
que es un conjunto booleano de false
, name
y addr
que son ambas cadenas replicadas de la solicitud original.
El registro de foobar
, ya que ya está registrado, daría lugar a la siguiente respuesta:
{
"success": false,
"name":"foobar",
"addr":"0x29347542eb07159fdeadbeefae16243d152f6b7b"
}
Algunos enlaces
: implementación de referencia de NodeJS utilizada por
ns.jami.net
y haciendo consultas a un nodo de Ethereum.