नाम सर्वर प्रोटोकॉल

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

नाम स्वरूपण के नियम

उपयोगकर्ता नामों को उनके प्रारूप के बारे में कुछ नियम सुनिश्चित करने के लिए एक रेजेक्स द्वारा जांच किया जाता हैः

  • लंबाई 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 दस्तावेज़ है जिसमें 1 स्ट्रिंग विशेषता हैः 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 दस्तावेज़ है जिसमें 1 स्ट्रिंग विशेषता हैः 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 दस्तावेज़ है जिसमें 1 स्ट्रिंग विशेषता हैः error है। यह विशेषता एक त्रुटि संदेश के साथ भरी हुई है जो त्रुटि की व्याख्या करती है (और भविष्य में क्लाइंट में प्रदर्शित की जा सकती है) ।

संदर्भ कार्यान्वयन के संबंध में, लौटाया गया दस्तावेज हैः

{
    "error":"address not registred"
}

नाम का पंजीकरण

प्रोटोकॉल का यह हिस्सा एक नए नाम/पते जोड़े को पंजीकृत करने के लिए उपयोग किया जाता है। यह मुख्य सार्वजनिक रजिस्ट्री पर उपयोग किया जाता है लेकिन कस्टम कार्यान्वयन में वैकल्पिक हो सकता है।

Request register

foobar नाम को पंजीकृत करने के लिए एक POST अनुरोध है जिसमें /name/foobar URI के रूप में है। शीर्षक विशेषता Content-type को application/json पर सेट किया जाना चाहिए।

अनुरोध का शरीर 2 स्ट्रिंग गुणों के साथ एक JSON दस्तावेज़ हैः addr और owneraddr में Jami ID 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.

शरीर में 1 बुलियन विशेषता success के साथ एक JSON दस्तावेज़ होता है true पर सेट किया गया।

उदाहरण के लिएः

{
    "success":true
}

फिर नाम या पते के लिए पूछताछ के लिए आगे के प्रयास सफल होने चाहिए।

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.

शरीर 2 गुणों के साथ एक JSON दस्तावेज़ हैः 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.

शरीर 3 गुणों के साथ एक JSON दस्तावेज़ हैः success जो false, name और addr के लिए एक बुलियन सेट है जो मूल अनुरोध से दोहराए गए दोनों स्ट्रिंग हैं।

foobar को पंजीकृत करने से निम्नलिखित प्रतिक्रिया होगीः

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