项目作者: AraBlocks

项目描述 :
A http server to create Ara Identities
高级语言: JavaScript
项目地址: git://github.com/AraBlocks/ara-identity-server.git
创建时间: 2018-07-10T19:10:12Z
项目社区:https://github.com/AraBlocks/ara-identity-server

开源协议:GNU Lesser General Public License v3.0

下载


ara-identity-server" class="reference-link"> ara-identity-server

Important: mount.sh must be removed from git history before making this repo public.

Build Status

A cryptographic key management system which exposes a http api to create Ara identities.

Status

Stable

Dependencies

Installation

  1. $ npm install ara-network ara-network-node-identity-manager

Important: Ensure ara-network is linked:

  1. $ cd ~/ara-network-node-identity-manager && npm link
  2. $ cd ~/ara-network && npm link ara-network-node-identity-manager

or run all commands in ~/ara-network-node-identity-manager directory.

Usage

Use ann to spin up an express server with the following options:

  1. usage: ann -t ara-network-node-identity-manager [options]
  2. Options:
  3. --debug, -D Enable debug output [boolean]
  4. --conf, -C Path to configuration file [string]
  5. --help, -h Show help [boolean]
  6. --identity, -i Ara Identity for the network node [string] [required]
  7. --secret, -s Shared secret key [string]
  8. --name, -n Human readable network keys name. [string] [required]
  9. --keyring, -k Path to ARA network keys [string] [required]
  10. --port, -p Port for network node to listen on. [number]
  11. --sslKey, -K Path to ssl key file for the server [string]
  12. --sslCert, -C Path to ssl certificate file for the server [string]

Create an http server:

  1. $ ann -t . -i DID -k ~/.ara/keyring -n name

Create an https server:

  1. $ ann -t . -i DID -k ~/.ara/keyring -n name -C example-cert.pem -K example-key.pem

Specify port and shared secret key:

  1. $ ann -t . -i DID -k ~/.ara/keyring -n name -s sharedsecret -p 1337

Example

  1. $ DEBUG=express* ann -t . -i did:ara:3dcd040d936f78a35d5ae905001282444a32511718a87c70069624f70d87d994 -k ~/.ara/keyring -n resolver -p 8877
  2. ara: info: Configuring network node '.'.
  3. ara: info: Starting network node '.'
  4. ? Please enter the passphrase associated with the node identity.
  5. Passphrase: [hidden]
  6. ara: info: ara-network-node-identity-manager: discovery key: 66d83aa5f9ec2eb722bd7eb41c609deea92040324f9643b5a2b9936a026e441e
  7. express:application set "x-powered-by" to true +0ms
  8. express:application set "etag" to 'weak' +2ms
  9. express:application set "etag fn" to [Function: generateETag] +0ms
  10. express:application set "env" to 'development' +0ms
  11. express:application set "query parser" to 'extended' +0ms
  12. express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
  13. express:application set "subdomain offset" to 2 +1ms
  14. express:application set "trust proxy" to false +0ms
  15. express:application set "trust proxy fn" to [Function: trustNone] +0ms
  16. express:application booting in development mode +0ms
  17. express:application set "view" to [Function: View] +0ms
  18. express:application set "views" to '/Users/vipyne/Documents/littlstar/ara/ara-network-node-identity-manager/views' +0ms
  19. express:application set "jsonp callback name" to 'callback' +0ms
  20. express:router use '/' query +1ms
  21. express:router:layer new '/' +0ms
  22. express:router use '/' expressInit +0ms
  23. express:router:layer new '/' +0ms
  24. express:router:route new '/api/v1/create' +1ms
  25. express:router:layer new '/api/v1/create' +0ms
  26. express:router:route post '/api/v1/create' +0ms
  27. express:router:layer new '/' +0ms
  28. express:router:route new '/api/v1/resolve' +0ms
  29. express:router:layer new '/api/v1/resolve' +0ms
  30. express:router:route get '/api/v1/resolve' +0ms
  31. express:router:layer new '/' +0ms
  32. ara: info: identity-manager: Server listening on port 8877
  33. ara: info: identity-manager: Announcing 66d83aa5f9ec2eb722bd7eb41c609deea92040324f9643b5a2b9936a026e441e on port 8877

Authentication

  • For now, the server uses an authenticationKey retrieved from the keyring file to validate incoming create & resolve requests
  • It should be set in the request header as authentication
  • The authenticationKey value can be retrieved using getClientAuthKey() method in util.js
  • Please refer to ara-network to learn more about keyrings

API

" class="reference-link">create ? passphrase

Accepts a passphrase then creates and returns a DID.

  • passphrase: A new passphrase

Returns an object:

  • did: ‘did:ara:abc123…’
  • mnemonic: ‘word some thing else …’
  • ddo : ‘{“@context”: “”,….}’
  • walletAddress : ‘0x30ff0edf64a015e8d412ec9427415f2d23117078’

Important: Store the mnemonic in a safe, analog place; it is the only recovery mechanism for an Ara ID.

  1. $ curl -H 'authentication: <authenticationKey>' \
  2. -H 'Content-Type: application/x-www-form-urlencoded' \
  3. -i -X POST -d "passphrase=asdf" "http://localhost:8877/1.0/identifiers"
  4. HTTP/1.1 200 OK
  5. X-Powered-By: Express
  6. Content-Type: application/json
  7. Date: Thu, 23 Aug 2018 19:53:38 GMT
  8. Connection: keep-alive
  9. Content-Length: 177
  10. {
  11. "mnemonic" : "pupil quit wisdom lyrics local expire genius analyst ridge flight famous convince",
  12. "did" : "did:ara:f68227cd68522794942a78635362223f274433402caf67e6476bec6609060265",
  13. "ddo" :
  14. {
  15. "authentication" : [],
  16. "proof" : {
  17. "signatureValue" : "d4c66e5c098e69abe8eee6d978ddd0c09837afa0471dc95da13a551415ea2c064464263061339422ac3e94ba132a55a35941d1be8ee8c6157283434e192ac80e",
  18. "created" : "2018-08-23T19:57:12.076Z",
  19. "type" : "Ed25519VerificationKey2018",
  20. "domain" : "ara",
  21. "creator" : "did:ara:f68227cd68522794942a78635362223f274433402caf67e6476bec6609060265#owner",
  22. "nonce" : "c56aaa700a99a9c5f7f830407c8de0228563323b773114070c2953f28bc36090"
  23. },
  24. "created" : "2018-08-23T19:57:12.073Z",
  25. "@context" : "https://w3id.org/did/v1",
  26. "service" : [],
  27. "id" : "did:ara:f68227cd68522794942a78635362223f274433402caf67e6476bec6609060265",
  28. "updated" : "2018-08-23T19:57:12.073Z",
  29. "publicKey" : [
  30. {
  31. "publicKeyBase64" : "PaCJ81oUieUlCp4Y1NiIj8nRDNALK9n5kdr7GYJBgJl",
  32. "owner" : "did:ara:f68227cd68522794942a78635362223f274433402caf67e6476bec6609060265",
  33. "type" : "Ed25519VerificationKey2018",
  34. "id" : "did:ara:f68227cd68522794942a78635362223f274433402caf67e6476bec6609060265#owner",
  35. "publicKeyBase58" : "HbGQRRvepSHVGG1CKJwAoZUdHUa1wJdEMS1k9Cp2Q6kk",
  36. "publicKeyHex" : "f68227cd68522794942a78635362223f274433402caf67e6476bec6609060265"
  37. }
  38. ]
  39. },
  40. "walletAddress" : "0x30ff0edf64a015e8d412ec9427415f2d23117078"
  41. }

" class="reference-link">resolve ? did

Accepts a DID and returns the associated DDO.

  • did: A did to resolve

Returns a DDO.

The response format might be changed in the future to match the did-resolution spec

  1. $ curl -H "authentication: <authenticationKey>" \
  2. -i -X GET \
  3. "http://localhost:8877/1.0/identifiers/did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f"
  4. HTTP/1.1 200 OK
  5. X-Powered-By: Express
  6. Content-Type: application/json
  7. Date: Thu, 23 Aug 2018 20:26:00 GMT
  8. Connection: keep-alive
  9. Content-Length: 1069
  10. {
  11. "didDocument": {
  12. "@context": "https://w3id.org/did/v1",
  13. "id": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f",
  14. "publicKey": [
  15. {
  16. "id": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f#owner",
  17. "type": "Ed25519VerificationKey2018",
  18. "owner": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f",
  19. "publicKeyHex": "ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f",
  20. "publicKeyBase58": "GvLUCv4cuLLZK9bBdrgDx5MsSv1AnYXho9W3mppFxbmx",
  21. "publicKeyBase64": "OyJGbsgm4HO+1qusTB1QRrfRoycUyNUdiypziaboA6P"
  22. },
  23. {
  24. "id": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f#eth",
  25. "type": "Secp256k1VerificationKey2018",
  26. "owner": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f",
  27. "publicKeyHex": "3a1e2cd7aea7d27c0b5971d840276328b4be8e2e7ded9ef00630d7b4ea897d165e099e4062d8b391edda2f02b203511e490729e3e411ab2f90f424d7cd725fd2",
  28. "publicKeyBase58": "2APqouovufGPLL7bPyZZPGqth2CxpG3zufz5uEGk1uLLNyyubGc57rR7Lnuxigxb7KAHSkAB1YN7dFrye3rwe2q7",
  29. "publicKeyBase64": "6HizXrqfSfAtZcdhAJ2MotL6OLn3tnvAGMNe06ol9Fl4JnkBi2LOR7dovArIDUR5JBynj5BGrL5D0JNfNcl/S"
  30. }
  31. ],
  32. "authentication": [
  33. {
  34. "publicKey": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f#owner",
  35. "type": "Ed25519SignatureAuthentication2018"
  36. },
  37. {
  38. "publicKey": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f#eth",
  39. "type": "Secp256k1SignatureAuthentication2018"
  40. }
  41. ],
  42. "service": [],
  43. "created": "2018-09-10T21:20:42.864Z",
  44. "updated": "2018-09-10T21:20:42.864Z",
  45. "proof": {
  46. "type": "Ed25519VerificationKey2018",
  47. "nonce": "5a6a1a3a5ed250ba31adbde5909f6c0b8d04a5572b4801c6edc635cfc839f9f8",
  48. "domain": "ara",
  49. "created": "2018-09-10T21:20:42.867Z",
  50. "creator": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f#owner",
  51. "signatureValue": "da0b371e3e0e1612132992f99e6025e0daa5b2a5425cdf66c7353b126076ef895ab80679b7d423b9a7c80e4c124bb74c8dda6fcca9011f78feec7b73ce355e04"
  52. }
  53. },
  54. "didReference": {
  55. "reference": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f",
  56. "did": "did:ara:ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f",
  57. "method": "ara",
  58. "identifier": "ec8919bb209b81cefb5aaeb13075411adf468c9c532354762ca9ce269ba00e8f",
  59. "path": "",
  60. "fragment": "",
  61. "query": ""
  62. },
  63. "methodMetadata": {},
  64. "resolverMetadata": {
  65. "retrieved": "2018-09-12T21:36:56.768Z",
  66. "duration": 0,
  67. "driverId": "did:ara",
  68. "driver": "HttpDriver"
  69. }
  70. }

" class="reference-link">status

Emits back a message if the server is reachable and running

  1. $ curl -i -X GET "http://localhost:8877/1.0/identifiers/status"
  2. HTTP/1.1 200 OK
  3. X-Powered-By: Express
  4. Content-Type: text/html; charset=utf-8
  5. Content-Length: 39
  6. ETag: W/"27-Lt/602+OsqNBpoQXD3gIgR3WfhI"
  7. Date: Tue, 11 Sep 2018 16:05:01 GMT
  8. Connection: keep-alive
  9. Ara Identity Manager up and running.

" class="reference-link">transfer

Transfers ARA tokens to the mentioned DID. Accepts DID and optional token paramenter. Default Tokens : 100

  • did: User DID to which tokens need to be transferred
  • tokens : No of Tokens that needs to be transferred (Optional) (Default Value : 100)
  1. $ curl -H 'authentication: 4f2b0b9de037d2ed2e761637dc479414850fc693dc527f59a48dcb3c5ac84469f0dc53b0ad9ee8636d9c58fdf8daa97fab22286317ec95b7573cdd84597f952f' /
  2. -H 'Content-Type: application/x-www-form-urlencoded' /
  3. -i -X POST -d "tokens=<no_of_tokens>" "http://localhost:8600/1.0/identifiers/did:ara:785b9662245f689ec13cd3bf6ab7e8e2f32a7166e2b8485c29e12109b200229f/transfer"
  4. HTTP/1.1 200 OK
  5. X-Powered-By: Express
  6. Access-Control-Allow-Origin: http://mrmanager.ara.one
  7. Access-Control-Allow-Headers: Authentication, Content-Type
  8. Content-Type: application/json
  9. Date: Tue, 24 Sep 2019 17:49:07 GMT
  10. Connection: keep-alive
  11. Content-Length: 147
  12. {"created_at":"2019-09-24T17:49:07.618Z","did":"did:ara:785b9662245f689ec13cd3bf6ab7e8e2f32a7166e2b8485c29e12109b200229f","tokens_requested":"<no_of_tokens>"}%

" class="reference-link">balance

Get the ARA Balance of a user wallet. Accepts DID

  • did: DID of the Littlstar User
  1. $ curl -H 'authentication: 4f2b0b9de037d2ed2e761637dc479414850fc693dc527f59a48dcb3c5ac84469f0dc53b0ad9ee8636d9c58fdf8daa97fab22286317ec95b7573cdd84597f952f' /
  2. -i -X GET "http://localhost:8600/1.0/identifiers/did:ara:785b9662245f689ec13cd3bf6ab7e8e2f32a7166e2b8485c29e12109b200229f/balance"
  3. HTTP/1.1 200 OK
  4. X-Powered-By: Express
  5. Access-Control-Allow-Origin: http://mrmanager.ara.one
  6. Access-Control-Allow-Headers: Authentication, Content-Type
  7. Content-Type: application/json
  8. Date: Tue, 24 Sep 2019 17:49:07 GMT
  9. Connection: keep-alive
  10. Content-Length: 147
  11. {"balance":"201"}

Contributing

Releases follow Semantic Versioning

See Also

License

LGPL-3.0