You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Tidy up, add deps and add a few more calls.
This commit is contained in:
@@ -38,10 +38,34 @@ var init = function(exports){
|
|||||||
return this.credentials.accessToken != undefined;
|
return this.credentials.accessToken != undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Room operations
|
||||||
|
// ===============
|
||||||
|
|
||||||
|
createRoom: function(options, callback) {
|
||||||
|
// valid options include: room_alias_name, visibility, invite
|
||||||
|
return this._doAuthedRequest(
|
||||||
|
callback, "POST", "/createRoom", undefined, options
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Public (non-authed) operations
|
||||||
|
// ==============================
|
||||||
|
|
||||||
publicRooms: function(callback) {
|
publicRooms: function(callback) {
|
||||||
return this._doRequest(callback, "GET", "/publicRooms");
|
return this._doRequest(callback, "GET", "/publicRooms");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
registerFlows: function(callback) {
|
||||||
|
return this._doRequest(callback, "GET", "/register");
|
||||||
|
},
|
||||||
|
|
||||||
|
loginFlows: function(callback) {
|
||||||
|
return this._doRequest(callback, "GET", "/login");
|
||||||
|
},
|
||||||
|
|
||||||
|
// Syncing operations
|
||||||
|
// ==================
|
||||||
|
|
||||||
initialSync: function(limit, callback) {
|
initialSync: function(limit, callback) {
|
||||||
var params = {
|
var params = {
|
||||||
limit: limit
|
limit: limit
|
||||||
@@ -51,6 +75,9 @@ var init = function(exports){
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Internals
|
||||||
|
// =========
|
||||||
|
|
||||||
_doAuthedRequest: function(callback, method, path, params, data) {
|
_doAuthedRequest: function(callback, method, path, params, data) {
|
||||||
if (!params) { params = {}; }
|
if (!params) { params = {}; }
|
||||||
params.access_token = this.credentials.accessToken;
|
params.access_token = this.credentials.accessToken;
|
||||||
@@ -61,7 +88,7 @@ var init = function(exports){
|
|||||||
var fullUri = this.credentials.baseUrl + PREFIX + path;
|
var fullUri = this.credentials.baseUrl + PREFIX + path;
|
||||||
if (!params) { params = {}; }
|
if (!params) { params = {}; }
|
||||||
|
|
||||||
request(
|
return request(
|
||||||
{
|
{
|
||||||
uri: fullUri,
|
uri: fullUri,
|
||||||
method: method,
|
method: method,
|
||||||
@@ -102,19 +129,6 @@ var init = function(exports){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.test = function(){
|
|
||||||
request({
|
|
||||||
uri: "http://localhost:8008/_matrix/client/api/v1/publicRooms",
|
|
||||||
method: "GET",
|
|
||||||
withCredentials: false,
|
|
||||||
},
|
|
||||||
function(err, response, body) {
|
|
||||||
console.log(body);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof exports === 'undefined') {
|
if (typeof exports === 'undefined') {
|
||||||
|
@@ -11,5 +11,9 @@
|
|||||||
],
|
],
|
||||||
"browserify": "browser/index.js",
|
"browserify": "browser/index.js",
|
||||||
"author": "matrix.org",
|
"author": "matrix.org",
|
||||||
"license": "Apache 2.0"
|
"license": "Apache 2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"browser-request": "^0.3.3",
|
||||||
|
"request": "^2.53.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user