add devices:list, devices:remove, and tunnel.token
This commit is contained in:
parent
d64699977e
commit
64393a540d
|
@ -16,4 +16,32 @@ OAUTH3.api['dns.list'] = function (providerUri, opts) {
|
|||
});
|
||||
};
|
||||
|
||||
OAUTH3.api['devices.list'] = function (providerUri, opts) {
|
||||
var session = opts.session;
|
||||
|
||||
return OAUTH3.request({
|
||||
url: OAUTH3.url.normalize(providerUri)
|
||||
+ '/api/com.daplie.domains/accounts/' + session.token.sub + '/devices'
|
||||
, method: 'GET'
|
||||
, session: session
|
||||
}, {}).then(function (res) {
|
||||
return res.data.devices || res.data;
|
||||
});
|
||||
};
|
||||
|
||||
OAUTH3.api['devices.detach'] = function (providerUri, opts) {
|
||||
var session = opts.session;
|
||||
|
||||
return OAUTH3.request({
|
||||
url: OAUTH3.url.normalize(providerUri)
|
||||
+ '/api/com.daplie.domains/accounts/' + session.token.sub
|
||||
+ '/devices/' + opts.data.device
|
||||
+ '/' + opts.data.tld + '/' + opts.data.sld + '/' + (opts.data.sub || '')
|
||||
, method: 'DELETE'
|
||||
, session: session
|
||||
}, {}).then(function (res) {
|
||||
return res.data.device || res.data;
|
||||
});
|
||||
};
|
||||
|
||||
}('undefined' !== typeof exports ? exports : window));
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
;(function (exports) {
|
||||
'use strict';
|
||||
|
||||
var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.core.js').OAUTH3;
|
||||
|
||||
OAUTH3.api['tunnel.token'] = function (providerUri, opts) {
|
||||
var session = opts.session;
|
||||
|
||||
return OAUTH3.request({
|
||||
method: 'POST'
|
||||
, url: OAUTH3.url.normalize(providerUri)
|
||||
+ '/api/org.oauth3.tunnel/accounts/' + session.token.sub + '/token'
|
||||
, session: session
|
||||
, data: {
|
||||
domains: opts.data.domains
|
||||
, device: opts.data.device
|
||||
}
|
||||
}).then(function (res) {
|
||||
return res.data.records || res.data;
|
||||
});
|
||||
};
|
||||
|
||||
}('undefined' !== typeof exports ? exports : window));
|
Loading…
Reference in New Issue