walnut_launchpad.html/js/www@daplie.com.js

228 lines
7.0 KiB
JavaScript
Raw Permalink Normal View History

2017-08-14 19:45:19 +00:00
;(function (exports) {
'use strict';
var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.core.js').OAUTH3;
OAUTH3._pkgs['www@daplie.com'] = {
add: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
2017-08-14 19:45:19 +00:00
return OAUTH3.request({
method: 'POST'
, url: OAUTH3.url.normalize(providerUri)
2017-08-24 17:26:29 +00:00
+ '/api/www@daplie.com/acl/sites/' + opts.hostname
2017-10-02 19:09:06 +00:00
+ '?' + OAUTH3.utils.query.stringify({
2017-11-07 21:45:11 +00:00
tld: opts.tld, sld: opts.sld, sub: opts.sub, unzip: opts.unzip
2017-10-02 19:09:06 +00:00
, strip: opts.strip, path: opts.path
})
2017-08-14 19:45:19 +00:00
, session: session
, multipart: opts.multipart // special property to be figured out by browser request code
2017-08-25 23:48:14 +00:00
, progress: opts.progress
2017-08-22 18:37:57 +00:00
}).then(function (result) {
return result;
});
}
2017-08-31 07:42:59 +00:00
, archiveUrl: function (opts) {
var providerUri = opts.audience;
return OAUTH3.url.normalize(providerUri.replace(/api\./, 'assets.'))
+ '/assets/www@daplie.com/acl/archives/' + opts.hostname
2017-11-07 21:45:11 +00:00
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, strip: opts.strip, path: opts.path })
2017-08-31 07:42:59 +00:00
;
}
2017-09-06 00:25:00 +00:00
, listShares: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
// TODO needs a way to have api and assets for audience
return OAUTH3.request({
method: 'GET'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname)
2017-11-07 21:45:11 +00:00
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path })
2017-09-06 00:25:00 +00:00
, session: session
}).then(function (result) {
return result;
});
}
2017-09-06 20:12:37 +00:00
, removeShare: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
// TODO needs a way to have api and assets for audience
return OAUTH3.request({
method: 'DELETE'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname) + '/' + (opts.challenge || opts.token)
2017-11-07 21:45:11 +00:00
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path })
2017-09-06 20:12:37 +00:00
, session: session
}).then(function (result) {
return result;
});
}
2017-09-01 20:50:33 +00:00
, invite: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
// TODO needs a way to have api and assets for audience
return OAUTH3.request({
method: 'POST'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname)
2017-09-06 00:25:00 +00:00
+ '?' + OAUTH3.utils.query.stringify({
tld: opts.tld
, sld: opts.sld
/*, sub: opts.sub*/
, mode: opts.mode
, path: opts.path
, email: opts.email
, comment: opts.comment
})
2017-09-01 20:50:33 +00:00
, session: session
}).then(function (result) {
return result;
});
}
, acceptInvite: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
// TODO needs a way to have api and assets for audience
return OAUTH3.request({
method: 'POST'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/accept/' + opts.token
2017-11-07 21:45:11 +00:00
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub })
2017-09-01 20:50:33 +00:00
, session: session
}).then(function (result) {
return result;
});
}
2017-08-31 07:42:59 +00:00
, download: function (opts) {
var session = opts.session;
var me = this;
// TODO needs a way to have api and assets for audience
return OAUTH3.request({
method: 'GET'
, url: me.archiveUrl
, session: session
}).then(function (result) {
return result;
});
}
2017-08-24 17:26:29 +00:00
, archive: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
return OAUTH3.request({
method: 'POST'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/archives/' + opts.hostname
2017-11-03 19:14:06 +00:00
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, strip: opts.strip, path: opts.path })
2017-08-24 17:26:29 +00:00
, session: session
2017-08-31 07:42:59 +00:00
}).then(function (result) {
return result;
});
}
, contents: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
return OAUTH3.request({
method: 'GET'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/fs/' + opts.hostname
2017-11-07 21:45:11 +00:00
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path })
2017-08-31 07:42:59 +00:00
, session: session
2017-08-24 17:26:29 +00:00
}).then(function (result) {
return result;
2017-11-02 22:56:53 +00:00
});
}
, contentRange: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
return OAUTH3.request({
method: 'GET'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/fs/' + opts.hostname
2017-11-07 21:45:11 +00:00
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path
2017-11-02 22:56:53 +00:00
, offset: opts.offset, length: opts.length, json: true })
, session: session
}).then(function (result) {
return result;
2017-08-24 17:26:29 +00:00
});
}
, remove: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
return OAUTH3.request({
method: 'DELETE'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/sites/' + opts.hostname
2017-10-02 19:09:06 +00:00
+ '?' + OAUTH3.utils.query.stringify({
2017-11-07 21:45:11 +00:00
tld: opts.tld, sld: opts.sld, sub: opts.sub
2017-10-02 19:09:06 +00:00
, path: opts.path, confirm: opts.confirm
})
2017-08-24 17:26:29 +00:00
, session: session
, multipart: opts.multipart // special property to be figured out by browser request code
}).then(function (result) {
return result;
});
}
2017-08-22 18:37:57 +00:00
, list: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
return OAUTH3.request({
method: 'GET'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/list/'
, session: session
}).then(function (result) {
result.data = result.data && result.data.sites || result.data;
return result;
});
}
, request: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
return OAUTH3.request({
method: 'POST'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/request/:tld/:sld/:sub'
.replace(/(:tld)/, opts.tld)
.replace(/(:sld)/, opts.sld)
.replace(/(:sub)/, opts.sub || '')
, session: session
}).then(function (result) {
// result.data
return result;
});
}
, claim: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
return OAUTH3.request({
method: 'POST'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/claim/:tld/:sld/:sub'
.replace(/(:tld)/, opts.tld)
.replace(/(:sld)/, opts.sld)
.replace(/(:sub)/, opts.sub || '')
, session: session
}).then(function (result) {
// result.data
2017-08-22 18:37:57 +00:00
return result;
2017-08-14 19:45:19 +00:00
});
}
};
}('undefined' !== typeof exports ? exports : window));