0.0.4
[henge/kiak.git] / old / bootstrap.js
diff --git a/old/bootstrap.js b/old/bootstrap.js
new file mode 100644 (file)
index 0000000..0757908
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * @file      Bootstrapping API 
+ * @author    Jordan Lavatai and Ken Grimes
+ * @version   0.0.1
+ * @license   AGPL-3.0
+ * @copyright Strapp.io
+ */
+
+import fs from "strappfileManager"
+
+/** @func Returns public key for the user
+ *  @desc Attempts to find a stored key. If unsucessful, ask user for key. If user
+ *        doesn't have a key, generates a key
+ *  @dependencies keyManager, fileSystem
+ *  @options specif
+ *  @return {Object} cryptoKey object
+ */
+function resolveKey() {
+  return new Promise( (resolve, reject) => {
+    /* See if publicKey has been generated before */
+    const publicKey = fs.strappID
+    if (publicKey === '') {
+      resolve(generateKey())
+    }    
+    else {
+      resolve(publicKey)
+    }
+  })
+}
+
+/* Init FileSystem */
+fs.initFileSystem()
+
+/* Find or generate key */
+let key = resolveKey()
+
+/* Auth */
+/* Authorization-header: Strapp pubkey (no answer)*/
+/* Determine answer, add answer to "." */
+
+
+/* Setup hardcoded files e.g. "..", ".", "accounts", "ice", "sdp", "log", "run" */
+/* Add the files to the filesystem only if they dont already exist /*
+
+/* Connect to host */
+
+  
+
+
+