add devices:list, devices:remove, and tunnel.token

This commit is contained in:
AJ ONeal 2017-03-15 23:48:39 -06:00
parent d64699977e
commit 64393a540d
2 changed files with 51 additions and 0 deletions

View File

@ -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));

23
oauth3.tunnel.js Normal file
View File

@ -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));