As the blockchain and also distributed storage systems are immutable they seem in many cases not the best way for point2point message transfers. Even though messages should be always encrypted they will remain in the chain.
For that reason we introduced a Realtime Session2Session protocol bases on our Websocket Interface and JSON Messages. This protocol never stores any payload in the blockchain or distributed storages!
To start such a communication you need to create first a JSON WT compliant Token and submit that via the websocket.
Kindly note that we created three testuser: 0x9166b9fEC04DB238C6f11752a3cC2DA7348305C6, 0x26b945e3F2aAd85C26356AF8F4779018da98f7fF and 0x6feeca565f0de5db2dd393cf16278f4c34739098 with password aloaha123 for you.
To create your own user kindly use: https://coin.codeb.io/identity.asmx?op=CreateKeyOnServer from the Identity Namespace
First you need to authenticate to the node with an authentication message.
You can create that manually or with your own software. To make things easier for you you can use our Web Service API EncryptedPasswordJSONToken on https://coin.codeb.io/json.asmx?op=EncryptedPasswordJSONToken.
It will return the authentication message in the form of:
{ “@type”: “specs/jwt”, “@id”: “bb6474b4-5017-4d64-a21d-714b31c6c7ae”, “ktype”: “1”, “exp”: 1598308962, “authentication”: { “type”: “passwordauth”, “encrypted”: “eyJhbGciOiJFQ0RILUVTIiwiZW5jIjoiQTI1NkdDTSIsImVjY3B1YiI6IlJVTkxNU0FBQUFDV0g1dGJfQ0Q4RTJnNDRqaU5SVDZMNG9Zd2tNeVlNM0loNE1HYW9Hb0dNRHZVYW1RbWRnSVl2dEtVSWJ5WXN0ZWlwRWlnbUpkZFJDU1VQN2kwZjlZNCIsImVwayI6eyJrdHkiOiJFQyIsIngiOiIxcTE3MWsxdlhicjVKdExMaThONzY3SFRHRG5fRVFOMlRVUGxMXzdkektRIiwieSI6IkktVUlhWXU0anpyWl82dG96YXJyYTJXMTVDaVVzXzZ0TXBNYlRfMlNnb3MiLCJjcnYiOiJQLTI1NiJ9fQ..zK8dMUgqKf13yF3e.oYns4QXjudpkvcPgnkNjcYZUPHGijwmqPt8IR4LndY1N5hbBjz8RY7d5Isy9l5atkvML7dOpXysbjZaAxEaSmBRBPf99QrxjoJ4KU5-jhNs.Uej84k0_kGSu2-PjDersjw” } }
Note: The above token will contain your username/password encrypted with the nodes cryptographic keys.
Now you need to send the above authentication message via our Web Socket to the server. (Take note of the sessionid as you need that later)
You will receive a JSON WT in the form as:
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImFkZHJlc3MiOiIweGE1QUZFNUMxQ0JkYzgzODIwQzRDZDRBOEI4RDhBMzRGMWEwOGQzYmIiLCJlY2NwdWIiOiJSVU5MTVNBQUFBQ1dINXRiX0NEOEUyZzQ0amlOUlQ2TDRvWXdrTXlZTTNJaDRNR2FvR29HTUR2VWFtUW1kZ0lZdnRLVUlieVlzdGVpcEVpZ21KZGRSQ1NVUDdpMGY5WTQifQ.eyJsb2dnZWRJbkFzIjoiMHg5MTY2YjlmRUMwNERCMjM4QzZmMTE3NTJhM2NDMkRBNzM0ODMwNUM2IiwiaWF0IjoiMTU5ODU0MTA2NCIsImV4cCI6IjE1OTgzMDg5NjIiLCJ-dGhyZWFkIjp7InRoaWQiOiJiYjY0NzRiNC01MDE3LTRkNjQtYTIxZC03MTRiMzFjNmM3YWUifSwiQGlkIjoiYzk0MjZjYTAtZGFkZC00YTljLTliNWYtZGY2NDZkNzU3ZjI1Iiwic2Vzc2lvbmlkIjoiM2M2MTE5YTctNWFjYy00ZmU2LThkMGEtNzc0YWI2YzJmYzQ0In0.J_x4ThXDZUOkKBnj9OGVkd3YkrNWGOBE7u3M61JZ9_Tq1nvBKf-b6QctjMDLEBbSHPmF9Cw6lAfoneCiQKYjow
Note: In case you are interested to decode the above and have a look inside just send it back to the WebSocket with: “decode: eyJhbGciO…….w6lAfoneCiQKYjow”
The result will be similar to the below:
{“alg”:”ES256″,”typ”:”JWT”,”address”:”0xa5AFE5C1CBdc83820C4Cd4A8B8D8A34F1a08d3bb”,”eccpub”:”RUNLMSAAAACWH5tb_CD8E2g44jiNRT6L4oYwkMyYM3Ih4MGaoGoGMDvUamQmdgIYvtKUIbyYsteipEigmJddRCSUP7i0f9Y4″} {“loggedInAs”:”0x9166b9fEC04DB238C6f11752a3cC2DA7348305C6″,”iat”:”1598541064″,”exp”:”1598308962″,”~thread”:{“thid”:”bb6474b4-5017-4d64-a21d-714b31c6c7ae”},”@id”:”c9426ca0-dadd-4a9c-9b5f-df646d757f25″,”sessionid”:”3c6119a7-5acc-4fe6-8d0a-774ab6c2fc44″} {“signature”:”J_x4ThXDZUOkKBnj9OGVkd3YkrNWGOBE7u3M61JZ9_Tq1nvBKf-b6QctjMDLEBbSHPmF9Cw6lAfoneCiQKYjow”}
Now it is time to open a second websocket. For example via: http://coin.codeb.io/websocket.aspx
Note: Again take note of the sessionid please!
Now you can create the JSON needed to send a message from the first websockets session to the second session. You can use our helper API CreateRemoteSendJSON on: https://coin.codeb.io/json.asmx?op=CreateRemoteSendJSON
Fill in the LocalSessionID (SessionID of your first session), the RemoteSessionID (our second test session), the authtoken (the base64 JSON-WT token created above) and obviously the message. Kindly note here that for your own security the message should be signed and must be encrypted! The evaluation of the message is done by the recipient.
A token would look like:
{“@type”:”specs/message”,”localsessionid”:”3c6119a7-5acc-4fe6-8d0a-774ab6c2fc44″,”remotesessionid”:”38cfdf91-2d50-4cff-a4ae-a4632c8ddef0″,”authtoken”:”eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImFkZHJlc3MiOiIweGE1QUZFNUMxQ0JkYzgzODIwQzRDZDRBOEI4RDhBMzRGMWEwOGQzYmIiLCJlY2NwdWIiOiJSVU5MTVNBQUFBQ1dINXRiX0NEOEUyZzQ0amlOUlQ2TDRvWXdrTXlZTTNJaDRNR2FvR29HTUR2VWFtUW1kZ0lZdnRLVUlieVlzdGVpcEVpZ21KZGRSQ1NVUDdpMGY5WTQifQ.eyJsb2dnZWRJbkFzIjoiMHg5MTY2YjlmRUMwNERCMjM4QzZmMTE3NTJhM2NDMkRBNzM0ODMwNUM2IiwiaWF0IjoiMTU5ODU0MTA2NCIsImV4cCI6IjE1OTgzMDg5NjIiLCJ-dGhyZWFkIjp7InRoaWQiOiJiYjY0NzRiNC01MDE3LTRkNjQtYTIxZC03MTRiMzFjNmM3YWUifSwiQGlkIjoiYzk0MjZjYTAtZGFkZC00YTljLTliNWYtZGY2NDZkNzU3ZjI1Iiwic2Vzc2lvbmlkIjoiM2M2MTE5YTctNWFjYy00ZmU2LThkMGEtNzc0YWI2YzJmYzQ0In0.J_x4ThXDZUOkKBnj9OGVkd3YkrNWGOBE7u3M61JZ9_Tq1nvBKf-b6QctjMDLEBbSHPmF9Cw6lAfoneCiQKYjow”,”message”:”test”,”thid”:”40443ae1-645a-4b0e-8cc0-58e0e2a6c933″}
Now paste and send this token from within your first web sockets session.
If the remotesession can be reached you receive a: {“result”:”Message sent OK”}
The remote session receives a token like:
{“remotemessage”:”test”,”originatingsesssion”:”3c6119a7-5acc-4fe6-8d0a-774ab6c2fc44″,”thid”:”40443ae1-645a-4b0e-8cc0-58e0e2a6c933″,”senderauth”:”eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImFkZHJlc3MiOiIweGE1QUZFNUMxQ0JkYzgzODIwQzRDZDRBOEI4RDhBMzRGMWEwOGQzYmIiLCJlY2NwdWIiOiJSVU5MTVNBQUFBQ1dINXRiX0NEOEUyZzQ0amlOUlQ2TDRvWXdrTXlZTTNJaDRNR2FvR29HTUR2VWFtUW1kZ0lZdnRLVUlieVlzdGVpcEVpZ21KZGRSQ1NVUDdpMGY5WTQifQ.eyJsb2dnZWRJbkFzIjoiMHg5MTY2YjlmRUMwNERCMjM4QzZmMTE3NTJhM2NDMkRBNzM0ODMwNUM2IiwiaWF0IjoiMTU5ODU0MTA2NCIsImV4cCI6IjE1OTgzMDg5NjIiLCJ-dGhyZWFkIjp7InRoaWQiOiJiYjY0NzRiNC01MDE3LTRkNjQtYTIxZC03MTRiMzFjNmM3YWUifSwiQGlkIjoiYzk0MjZjYTAtZGFkZC00YTljLTliNWYtZGY2NDZkNzU3ZjI1Iiwic2Vzc2lvbmlkIjoiM2M2MTE5YTctNWFjYy00ZmU2LThkMGEtNzc0YWI2YzJmYzQ0In0.J_x4ThXDZUOkKBnj9OGVkd3YkrNWGOBE7u3M61JZ9_Tq1nvBKf-b6QctjMDLEBbSHPmF9Cw6lAfoneCiQKYjow”}