31 lines
597 B
JavaScript
31 lines
597 B
JavaScript
|
"use strict";
|
||
|
|
||
|
import os from 'os';
|
||
|
|
||
|
import make_cert from 'make-cert';
|
||
|
import systeminfo from 'systeminformation';
|
||
|
|
||
|
import hash from '../crypto/hash.mjs';
|
||
|
|
||
|
class Agent {
|
||
|
constructor() {
|
||
|
|
||
|
}
|
||
|
|
||
|
async init(secret_join) {
|
||
|
this.secret_join = secret_join;
|
||
|
|
||
|
/** Our peer id - calculated automatically from the system's uuid */
|
||
|
this.peer_id = hash("sha256", "base64", await systeminfo.system().serial)
|
||
|
.replace(/[+/=]/g, "");
|
||
|
this.peer_name = os.hostname();
|
||
|
|
||
|
|
||
|
|
||
|
// Properties: key, cert
|
||
|
this.cert = make_cert(`${our_id}.systemquery-peer.localhost`);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default Agent;
|