שם פרוטוקול השרת
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).
חוקים לגבי תיאור השם
שם משתמש בודק על ידי regex כדי להבטיח כמה חוקים לגבי צורתם:
אורך חייב להיות בין 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 עם תכונה של זרימה אחת: 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 עם תכונה של זרימה אחת: 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 עם תכונה של זרימה אחת: error
. התכונה הזו מלאה במסר שגיאה שמסביר את הטעות (ולאפשר להציג בה לקלינט בעתיד).
על ביצוע ההסתמך, המסמך המשיב הוא:
{
"error":"address not registred"
}
רישום שם
חלק זה של הפרוטוקול משמש לרשום זוג שם/כתובת חדש. הוא משמש ברישום הציבורי הראשי אך עשוי להיות אופציונלי בהיישום מותאם.
Request register
בקשה לרשום את השם foobar
היא בקשה POST
עם /name/
foobar
כ-URI.
גוף הבקשה הוא מסמך JSON עם 2 תכונות של קווים: addr
ו owner
. addr
מכיל את ID Jami המוקדמת עם 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 is unable to 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 אטributs: 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"
}
כמה קישורים
gitlab:jami-nameservice: יישום NodeJS של דף שימש על ידי
ns.jami.net
ושאילת קשר Ethereum.