नाम सर्भर प्रोटोकल
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).
नाम ढाँचा गर्ने नियम
प्रयोगकर्ता नामहरू उनीहरूको ढाँचाको बारेमा केही नियमहरू सुनिश्चित गर्न एक रेजेक्स द्वारा जाँच गरिन्छः
लम्बाइ ३ देखि ३२ वर्णको बीचमा हुनुपर्छ
Those characters must be alphanumerical with dashes
-
being also accepted.
नाम सोध्नु
यो नाम सर्भर द्वारा प्रदान गरिएको मुख्य सेवा हो। यसले प्रयोगकर्ता नामसँग मेल खाने Jami ID प्राप्त गर्न सक्षम गर्दछ।
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 कागजात हो 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 कागजात हो जसको १ स्ट्रिंग विशेषता छः error
. यो विशेषता त्रुटि सन्देशले भरिएको छ जसले त्रुटिलाई व्याख्या गर्दछ (र भविष्यमा क्लाइन्टमा प्रदर्शन गर्न सकिन्छ) ।
सन्दर्भ कार्यान्वयनको बारेमा, फिर्ता गरिएको कागजातः
{
"error":"address not registred"
}
नाम दर्ता
प्रोटोकलको यो भाग नयाँ नाम/पता जोडी दर्ता गर्न प्रयोग गरिन्छ। यो मुख्य सार्वजनिक रेजिस्ट्रीमा प्रयोग गरिन्छ तर अनुकूलन कार्यान्वयनमा वैकल्पिक हुन सक्छ।
Request register
foobar
नाम दर्ता गर्न अनुरोध POST
अनुरोध हो र /name/
foobar
URI को रूपमा राखिएको छ। हेडर विशेषता Content-type
लाई application/json
मा सेट गर्नुपर्दछ।
अनुरोधको शरीर दुई स्ट्रिंग विशेषताहरूसँगको JSON कागजात होः addr
र owner
. addr
मा 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
.
शरीरमा १ बुलियन विशेषता success
सँग JSON कागजात छ 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 कागजात होः 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"
}
केही लिंकहरू
gitlab:jami-nameservice:
ns.jami.net
द्वारा प्रयोग गरिएको सन्दर्भ NodeJS कार्यान्वयन र Ethereum नोडको क्वेरी।