X-Git-Url: https://git.kengrimes.com/?p=henge%2Fkiak.git;a=blobdiff_plain;f=bootstrap.js;h=ba48382ef2ba0156f6b1df59dba72dc15eb6c018;hp=a90539ee0703f6380d3896924d83802d9de0fff5;hb=44e0b2d571c71ebd410b78366c8bc9dc463a96c4;hpb=d17ac76d8256b00eb253138a554c7d3d51139b9e diff --git a/bootstrap.js b/bootstrap.js index a90539e..ba48382 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -1,68 +1,12 @@ /** - * @file Shared API + * @file Bootstrapping API * @author Jordan Lavatai and Ken Grimes * @version 0.0.1 - * @license APGL-3.0 + * @license AGPL-3.0 * @copyright Strapp.io */ -const dlog = (msg) => console.log(msg) - -/***********************/ -/** Helper functions **/ -/***********************/ - -/* SDP Interop helper functions to be used by beginRTCOffer and beginRTCAnswer */ - -/** @func Determines the multimedia signaling protocol for the given session description - * @desc Does some basic duck typing to determine the type of Session Description - * @arg {Object} Session Description Object - * @return {String} Returns 'planB' if Session Description is planB, 'Unified' if - * Session Description is Unified - */ -function determineSessionDescription(sessionDescription) { -} - -/** @func Converts a planB session description to Unified session description - * @arg {Object} Session Description Object - * @return {Object} PlanB Session Description - */ -function toUnified(sessionDescription) { -} - -/** @func Converts a Unified session description to planB session description - * @arg {Object} Session Description Object - * @return {Object} PlanB Session Description - */ -function toPlanB(sessionDescription) { -} - -/* WebSocket wielder helper functions */ - -/* Function for setting up webSocket wielders message handler */ -/* TBD */ -/* TBD */ - -/* SDP Negotiation helper functions */ - -/* addRemoteIceCandidate() */ -/* addIceCandidateCreationHandler(callback for sending?) */ -/* handleIceRequest() - WebSpocketless entity specific */ - - -/***********************/ -/** Exposed functions **/ -/***********************/ - -/** @func Attempts to create a websocket - * @desc If user agent supports web sockets, attempt to create a websocket - * with given domain - * @arg {String} domain - ip address or domain name of other end of websocket - * @return {Boolean} returns true if successful, false if unsucessful - */ -export function createWebSocket(domain) { - -} +import fs from "fileManager" /** @func Returns public key for the user * @desc Attempts to find a stored key. If unsucessful, ask user for key. If user @@ -71,37 +15,36 @@ export function createWebSocket(domain) { * @options specif * @return {Object} cryptoKey object */ -export function resolveKey() { - +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) + } + }) } -/** @func Begins the SDP handshake process as the offerer - * @desc - * - * - */ -export function beginRTCOffer() { -} +/* Init FileSystem */ +fs.initFileSystem() -/** @func Begins the SDP handshake process as the answerer - * @desc - * - * - */ -export function beginRTCAnswer() { -} +/* 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 */ + + -/** @func Generic way to message host from client - * @desc tbd - * @arg {Object} data object to be sent - */ -export function sendHostData(data) { -} -/** @func Generic way to message client from host - * @desc tbd - * @arg {Object} data object to be sent - */ -export function sendClientData(data){ -}