0.0.4
[henge/kiak.git] / old / bootstrap.js
1 /**
2 * @file Bootstrapping API
3 * @author Jordan Lavatai and Ken Grimes
4 * @version 0.0.1
5 * @license AGPL-3.0
6 * @copyright Strapp.io
7 */
8
9 import fs from "strappfileManager"
10
11 /** @func Returns public key for the user
12 * @desc Attempts to find a stored key. If unsucessful, ask user for key. If user
13 * doesn't have a key, generates a key
14 * @dependencies keyManager, fileSystem
15 * @options specif
16 * @return {Object} cryptoKey object
17 */
18 function resolveKey() {
19 return new Promise( (resolve, reject) => {
20 /* See if publicKey has been generated before */
21 const publicKey = fs.strappID
22 if (publicKey === '') {
23 resolve(generateKey())
24 }
25 else {
26 resolve(publicKey)
27 }
28 })
29 }
30
31 /* Init FileSystem */
32 fs.initFileSystem()
33
34 /* Find or generate key */
35 let key = resolveKey()
36
37 /* Auth */
38 /* Authorization-header: Strapp pubkey (no answer)*/
39 /* Determine answer, add answer to "." */
40
41
42 /* Setup hardcoded files e.g. "..", ".", "accounts", "ice", "sdp", "log", "run" */
43 /* Add the files to the filesystem only if they dont already exist /*
44
45 /* Connect to host */
46
47
48
49
50