X-Git-Url: https://git.kengrimes.com/?p=henge%2Fkiak.git;a=blobdiff_plain;f=src%2Fstrapp.js;h=aefbc1b9f9a5429b47c9d51a8c2b02a5cf7b56b6;hp=9ec9d096c9c03d6daff3866c120c922650fd9548;hb=b98d95ba22c7a5b1bcf89fb8ac0a8b159f8c8184;hpb=552b28b4fc1ed42e3362c1826acf94c349425b1c diff --git a/src/strapp.js b/src/strapp.js index 9ec9d09..aefbc1b 100644 --- a/src/strapp.js +++ b/src/strapp.js @@ -6,8 +6,17 @@ * @copyright August 2017 - Ken Grimes, Jordan Lavatai * @summmary Bootstrapper for the strapp.io mechanism */ +import LocalForage from "localforage" const StrappFile = (() => { + const localforage = LocalForage.createInstance({ + driver: [LocalForage.LOCALSTORAGE, + LocalForage.INDEXEDDB, + LocalForage.WEBSQL], + name: 'strapp', + version: 0.1, + storeName: 'strapp' + }) const authorize = (pubKey, mode, stat) => { let allowed if (pubKey === stat.owner) @@ -50,6 +59,15 @@ const StrappFile = (() => { static PermissionDenied() { return new Promise((resolve, reject) => reject('Permission denied')) } + static get(path) { + return localforage.getItem(path) + } + static set(path, data) { + return localforage.setItem(path, data) + } + static delete(path) { + return localforage.removeItem(path) + } HEAD(opt) { if (authorize(opt.pubKey, 'r', this.stat)) return new Promise((resolve, reject) => resolve('')) @@ -86,13 +104,46 @@ const StrappFile = (() => { } } StrappFile.defaults = { - type: 'mime/type', - perm: 0, - owner: 'thisOwnerPubKey', - group: 'groupname', - changed: 'time', - created: 'time', - accessed: 'time - not saved' + stat: { + type: 'mime/type', + perm: 0, + owner: 'thisOwnerPubKey', + group: 'groupname', + changed: 'time', + created: 'time', + accessed: 'time - not saved' + } } return StrappFile })() + +const StrappPeerConnection = (() => { + class StrappPeerConnection extends StrappFile { + GET(opts) { + //get metadata (held in filesystem), with owner, usage info, etc + //if unauthed, send message down socket + } + PUT(opts) { + //create w/ sdp, register callback (or pipe), set owner + } + POST(opts) { + //send msg + } + CONNECT(opts) { + //send routing message down socket + //POST(opts.routemessage) + } + } + return StrappPeerConnection +})() + +const StrappDirectory = (() => { + class StrappDirectory extends StrappFile { + } + return StrappDirectory +})() + + + +export default StrappFile +export { StrappPeerConnection, StrappDirectory }