This commit is contained in:
ntr 2018-09-13 17:19:51 +10:00
parent 7db60975fa
commit e1a2675097
24 changed files with 45 additions and 0 deletions

4
client/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
package-lock.json
node_modules/
dist/
.cache/

5
client/index.html Executable file
View File

@ -0,0 +1,5 @@
<html>
<body>
<script src="./index.js"></script>
</body>
</html>

19
client/index.js Executable file
View File

@ -0,0 +1,19 @@
const cbor = require('borc');
const assert = require('assert');
// Create WebSocket connection.
const ws = new WebSocket('ws://localhost:40000');
ws.binaryType = 'arraybuffer';
// Connection opened
ws.addEventListener('open', function (event) {
ws.send(cbor.encode({ method: 'cryp_generate', params: { level: 64 }}));
ws.send(cbor.encode({ method: 'account_create', params: { name: 'ntr' }}));
});
// Listen for messages
ws.addEventListener('message', function (event) {
console.log('Message from server ', event.data);
const blob = new Uint8Array(event.data);
const decoded = cbor.decodeAll(blob);
console.log(decoded[0]);
});

17
client/package.json Executable file
View File

@ -0,0 +1,17 @@
{
"name": "cryps-client",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "parcel index.html",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "UNLICENSED",
"dependencies": {
"borc": "^2.0.3",
"cbor": "^4.1.1",
"parcel": "^1.9.7"
}
}

View File

View File