* @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)
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(''))
}
}
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 }