UNPKG

98.2 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/base-apis.js"],"names":["httpApi","require","utils","MatrixBaseApis","opts","checkObjectHasKeys","baseUrl","idBaseUrl","httpOpts","accessToken","request","prefix","PREFIX_R0","onlyData","extraParams","queryParams","localTimeoutMs","useAuthorizationHeader","_http","MatrixHttpApi","_txnCtr","prototype","getHomeserverUrl","getIdentityServerUrl","stripProto","startsWith","split","getAccessToken","isLoggedIn","undefined","makeTxnId","Date","getTime","isUsernameAvailable","username","authedRequest","then","response","available","register","password","sessionId","auth","bindThreepids","guestAccessToken","callback","email","session","params","bind_email","msisdn","bind_msisdn","guest_access_token","x_show_msisdn","registerRequest","registerGuest","body","data","kind","loginFlows","login","loginType","login_data","type","extend","error","access_token","user_id","credentials","userId","loginWithPassword","user","loginWithSAML2","relayState","relay_state","getCasLoginUrl","redirectUrl","getSsoLoginUrl","getUrl","loginWithToken","token","logout","deactivateAccount","erase","Error","authedRequestWithPrefix","getFallbackAuthUrl","authSessionId","path","encodeUri","$loginType","createRoom","options","roomState","roomId","$roomId","fetchRoomEvent","eventId","$eventId","members","includeMembership","excludeMembership","atEventId","membership","not_membership","at","queryString","encodeParams","upgradeRoom","newVersion","new_version","getGroupSummary","groupId","$groupId","getGroupProfile","setGroupProfile","profile","setGroupJoinPolicy","policy","getGroupUsers","getGroupInvitedUsers","getGroupRooms","inviteUserToGroup","$userId","removeUserFromGroup","addUserToGroupSummary","roleId","$roleId","removeUserFromGroupSummary","addRoomToGroupSummary","categoryId","$categoryId","removeRoomFromGroupSummary","addRoomToGroup","isPublic","updateGroupRoomVisibility","removeRoomFromGroup","acceptGroupInvite","joinGroup","leaveGroup","getJoinedGroups","createGroup","content","getPublicisedGroups","userIds","user_ids","setGroupPublicity","publicise","getStateEvent","eventType","stateKey","pathParams","$eventType","$stateKey","sendStateEvent","redactEvent","roomInitialSync","limit","isFunction","setRoomReadMarkersHttpRequest","rmEventId","rrEventId","getJoinedRooms","getJoinedRoomMembers","publicRooms","query_params","server","length","createAlias","alias","$alias","room_id","deleteAlias","getRoomIdForAlias","resolveRoomAlias","roomAlias","getRoomDirectoryVisibility","setRoomDirectoryVisibility","visibility","setRoomDirectoryVisibilityAppService","networkId","$networkId","searchUserDirectory","search_term","term","uploadContent","file","cancelUpload","promise","getCurrentUploads","getProfileInfo","info","$info","getThreePids","addThreePid","creds","bind","deleteThreePid","medium","address","PREFIX_UNSTABLE","setPassword","authDict","newPassword","getDevices","setDeviceDetails","device_id","$device_id","deleteDevice","deleteMultipleDevices","devices","getPushers","setPusher","pusher","getPushRules","addPushRule","scope","ruleId","$kind","$ruleId","deletePushRule","setPushRuleEnabled","enabled","setPushRuleActions","actions","search","queryparams","next_batch","uploadKeysRequest","deviceId","$deviceId","downloadKeysForUsers","device_keys","forEach","u","claimOneTimeKeys","key_algorithm","queries","i","query","one_time_keys","getKeyChanges","oldToken","newToken","qps","from","to","requestEmailToken","clientSecret","sendAttempt","nextLink","client_secret","send_attempt","next_link","idServerRequest","PREFIX_IDENTITY_V1","submitMsisdnToken","sid","lookupThreePid","sendToDevice","contentMap","txnId","$txnId","messages","getThirdpartyProtocols","getThirdpartyLocation","protocol","$protocol","module","exports"],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBA;;AAEA;;;;;;;;;;;;;;;;;AAOA,IAAMA,UAAUC,QAAQ,YAAR,CAAhB;AACA,IAAMC,QAAQD,QAAQ,SAAR,CAAd;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAASE,cAAT,CAAwBC,IAAxB,EAA8B;AAC1BF,UAAMG,kBAAN,CAAyBD,IAAzB,EAA+B,CAAC,SAAD,EAAY,SAAZ,CAA/B;;AAEA,SAAKE,OAAL,GAAeF,KAAKE,OAApB;AACA,SAAKC,SAAL,GAAiBH,KAAKG,SAAtB;;AAEA,QAAMC,WAAW;AACbF,iBAASF,KAAKE,OADD;AAEbC,mBAAWH,KAAKG,SAFH;AAGbE,qBAAaL,KAAKK,WAH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W;AACzD,WAAO,KAAKtP,KAAL,CAAWmE,uBAAX,CACHxD,SADG,EACQ,KADR,EACe,uBADf,EACwCA,SADxC,EACmDA,SADnD,EAEH7B,QAAQwM,eAFL,EAGLpK,IAHK,CAGA,UAACC,QAAD,EAAc;AACjB;AACA,YAAI,CAACA,QAAD,IAAa,QAAOA,QAAP,uDAAOA,QAAP,OAAqB,QAAtC,EAAgD;AAC5C,kBAAM,IAAI+C,KAAJ,sDACiD/C,QADjD,CAAN;AAGH;AACD,eAAOA,QAAP;AACH,KAXM,CAAP;AAYH,CAbD;;AAeA;;;;;;;;AAQAlC,eAAekB,SAAf,CAAyBoP,qBAAzB,GAAiD,UAASC,QAAT,EAAmB1N,MAAnB,EAA2B;AACxE,QAAMwC,OAAOtF,MAAMuF,SAAN,CAAgB,gCAAhB,EAAkD;AAC3DkL,mBAAWD;AADgD,KAAlD,CAAb;;AAIA,WAAO,KAAKxP,KAAL,CAAWmE,uBAAX,CACHxD,SADG,EACQ,KADR,EACe2D,IADf,EACqBxC,MADrB,EAC6BnB,SAD7B,EAEH7B,QAAQwM,eAFL,CAAP;AAIH,CATD;;AAWA;;;AAGAoE,OAAOC,OAAP,GAAiB1Q,cAAjB","file":"base-apis.js","sourcesContent":["/*\nCopyright 2015, 2016 OpenMarket Ltd\nCopyright 2017 Vector Creations Ltd\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\"use strict\";\n\n/**\n * This is an internal module. MatrixBaseApis is currently only meant to be used\n * by {@link client~MatrixClient}.\n *\n * @module base-apis\n */\n\nconst httpApi = require(\"./http-api\");\nconst utils = require(\"./utils\");\n\n/**\n * Low-level wrappers for the Matrix APIs\n *\n * @constructor\n *\n * @param {Object} opts Configuration options\n *\n * @param {string} opts.baseUrl Required. The base URL to the client-server\n * HTTP API.\n *\n * @param {string} opts.idBaseUrl Optional. The base identity server URL for\n * identity server requests.\n *\n * @param {Function} opts.request Required. The function to invoke for HTTP\n * requests. The value of this property is typically <code>require(\"request\")\n * </code> as it returns a function which meets the required interface. See\n * {@link requestFunction} for more information.\n *\n * @param {string} opts.accessToken The access_token for this user.\n *\n * @param {Number=} opts.localTimeoutMs Optional. The default maximum amount of\n * time to wait before timing out HTTP requests. If not specified, there is no\n * timeout.\n *\n * @param {Object} opts.queryParams Optional. Extra query parameters to append\n * to all requests with this client. Useful for application services which require\n * <code>?user_id=</code>.\n *\n * @param {boolean} [opts.useAuthorizationHeader = false] Set to true to use\n * Authorization header instead of query param to send the access token to the server.\n */\nfunction MatrixBaseApis(opts) {\n utils.checkObjectHasKeys(opts, [\"baseUrl\", \"request\"]);\n\n this.baseUrl = opts.baseUrl;\n this.idBaseUrl = opts.idBaseUrl;\n\n const httpOpts = {\n baseUrl: opts.baseUrl,\n idBaseUrl: opts.idBaseUrl,\n accessToken: opts.accessToken,\n request: opts.request,\n prefix: httpApi.PREFIX_R0,\n onlyData: true,\n extraParams: opts.queryParams,\n localTimeoutMs: opts.localTimeoutMs,\n useAuthorizationHeader: opts.useAuthorizationHeader,\n };\n this._http = new httpApi.MatrixHttpApi(this, httpOpts);\n\n this._txnCtr = 0;\n}\n\n/**\n * Get the Homeserver URL of this client\n * @return {string} Homeserver URL of this client\n */\nMatrixBaseApis.prototype.getHomeserverUrl = function() {\n return this.baseUrl;\n};\n\n/**\n * Get the Identity Server URL of this client\n * @param {boolean} stripProto whether or not to strip the protocol from the URL\n * @return {string} Identity Server URL of this client\n */\nMatrixBaseApis.prototype.getIdentityServerUrl = function(stripProto=false) {\n if (stripProto && (this.idBaseUrl.startsWith(\"http://\") ||\n this.idBaseUrl.startsWith(\"https://\"))) {\n return this.idBaseUrl.split(\"://\")[1];\n }\n return this.idBaseUrl;\n};\n\n/**\n * Get the access token associated with this account.\n * @return {?String} The access_token or null\n */\nMatrixBaseApis.prototype.getAccessToken = function() {\n return this._http.opts.accessToken || null;\n};\n\n/**\n * @return {boolean} true if there is a valid access_token for this client.\n */\nMatrixBaseApis.prototype.isLoggedIn = function() {\n return this._http.opts.accessToken !== undefined;\n};\n\n/**\n * Make up a new transaction id\n *\n * @return {string} a new, unique, transaction id\n */\nMatrixBaseApis.prototype.makeTxnId = function() {\n return \"m\" + new Date().getTime() + \".\" + (this._txnCtr++);\n};\n\n\n// Registration/Login operations\n// =============================\n\n/**\n * Check whether a username is available prior to registration. An error response\n * indicates an invalid/unavailable username.\n * @param {string} username The username to check the availability of.\n * @return {module:client.Promise} Resolves: to `true`.\n */\nMatrixBaseApis.prototype.isUsernameAvailable = function(username) {\n return this._http.authedRequest(\n undefined, \"GET\", '/register/available', { username: username },\n ).then((response) => {\n return response.available;\n });\n};\n\n/**\n * @param {string} username\n * @param {string} password\n * @param {string} sessionId\n * @param {Object} auth\n * @param {Object} bindThreepids Set key 'email' to true to bind any email\n * threepid uses during registration in the ID server. Set 'msisdn' to\n * true to bind msisdn.\n * @param {string} guestAccessToken\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.register = function(\n username, password,\n sessionId, auth, bindThreepids, guestAccessToken,\n callback,\n) {\n // backwards compat\n if (bindThreepids === true) {\n bindThreepids = {email: true};\n } else if (bindThreepids === null || bindThreepids === undefined) {\n bindThreepids = {};\n }\n\n if (auth === undefined || auth === null) {\n auth = {};\n }\n if (sessionId) {\n auth.session = sessionId;\n }\n\n const params = {\n auth: auth,\n };\n if (username !== undefined && username !== null) {\n params.username = username;\n }\n if (password !== undefined && password !== null) {\n params.password = password;\n }\n if (bindThreepids.email) {\n params.bind_email = true;\n }\n if (bindThreepids.msisdn) {\n params.bind_msisdn = true;\n }\n if (guestAccessToken !== undefined && guestAccessToken !== null) {\n params.guest_access_token = guestAccessToken;\n }\n // Temporary parameter added to make the register endpoint advertise\n // msisdn flows. This exists because there are clients that break\n // when given stages they don't recognise. This parameter will cease\n // to be necessary once these old clients are gone.\n // Only send it if we send any params at all (the password param is\n // mandatory, so if we send any params, we'll send the password param)\n if (password !== undefined && password !== null) {\n params.x_show_msisdn = true;\n }\n\n return this.registerRequest(params, undefined, callback);\n};\n\n/**\n * Register a guest account.\n * @param {Object=} opts Registration options\n * @param {Object} opts.body JSON HTTP body to provide.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.registerGuest = function(opts, callback) {\n opts = opts || {};\n opts.body = opts.body || {};\n return this.registerRequest(opts.body, \"guest\", callback);\n};\n\n/**\n * @param {Object} data parameters for registration request\n * @param {string=} kind type of user to register. may be \"guest\"\n * @param {module:client.callback=} callback\n * @return {module:client.Promise} Resolves: to the /register response\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.registerRequest = function(data, kind, callback) {\n const params = {};\n if (kind) {\n params.kind = kind;\n }\n\n return this._http.request(\n callback, \"POST\", \"/register\", params, data,\n );\n};\n\n/**\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.loginFlows = function(callback) {\n return this._http.request(callback, \"GET\", \"/login\");\n};\n\n/**\n * @param {string} loginType\n * @param {Object} data\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.login = function(loginType, data, callback) {\n const login_data = {\n type: loginType,\n };\n\n // merge data into login_data\n utils.extend(login_data, data);\n\n return this._http.authedRequest(\n (error, response) => {\n if (loginType === \"m.login.password\" && response &&\n response.access_token && response.user_id) {\n this._http.opts.accessToken = response.access_token;\n this.credentials = {\n userId: response.user_id,\n };\n }\n\n if (callback) {\n callback(error, response);\n }\n }, \"POST\", \"/login\", undefined, login_data,\n );\n};\n\n/**\n * @param {string} user\n * @param {string} password\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.loginWithPassword = function(user, password, callback) {\n return this.login(\"m.login.password\", {\n user: user,\n password: password,\n }, callback);\n};\n\n/**\n * @param {string} relayState URL Callback after SAML2 Authentication\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.loginWithSAML2 = function(relayState, callback) {\n return this.login(\"m.login.saml2\", {\n relay_state: relayState,\n }, callback);\n};\n\n/**\n * @param {string} redirectUrl The URL to redirect to after the HS\n * authenticates with CAS.\n * @return {string} The HS URL to hit to begin the CAS login process.\n */\nMatrixBaseApis.prototype.getCasLoginUrl = function(redirectUrl) {\n return this.getSsoLoginUrl(redirectUrl, \"cas\");\n};\n\n/**\n * @param {string} redirectUrl The URL to redirect to after the HS\n * authenticates with the SSO.\n * @param {string} loginType The type of SSO login we are doing (sso or cas).\n * Defaults to 'sso'.\n * @return {string} The HS URL to hit to begin the SSO login process.\n */\nMatrixBaseApis.prototype.getSsoLoginUrl = function(redirectUrl, loginType) {\n if (loginType === undefined) {\n loginType = \"sso\";\n }\n return this._http.getUrl(\"/login/\"+loginType+\"/redirect\", {\n \"redirectUrl\": redirectUrl,\n }, httpApi.PREFIX_R0);\n};\n\n/**\n * @param {string} token Login token previously received from homeserver\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.loginWithToken = function(token, callback) {\n return this.login(\"m.login.token\", {\n token: token,\n }, callback);\n};\n\n\n/**\n * Logs out the current session.\n * Obviously, further calls that require authorisation should fail after this\n * method is called. The state of the MatrixClient object is not affected:\n * it is up to the caller to either reset or destroy the MatrixClient after\n * this method succeeds.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: On success, the empty object\n */\nMatrixBaseApis.prototype.logout = function(callback) {\n return this._http.authedRequest(\n callback, \"POST\", '/logout',\n );\n};\n\n/**\n * Deactivates the logged-in account.\n * Obviously, further calls that require authorisation should fail after this\n * method is called. The state of the MatrixClient object is not affected:\n * it is up to the caller to either reset or destroy the MatrixClient after\n * this method succeeds.\n * @param {object} auth Optional. Auth data to supply for User-Interactive auth.\n * @param {boolean} erase Optional. If set, send as `erase` attribute in the\n * JSON request body, indicating whether the account should be erased. Defaults\n * to false.\n * @return {module:client.Promise} Resolves: On success, the empty object\n */\nMatrixBaseApis.prototype.deactivateAccount = function(auth, erase) {\n if (typeof(erase) === 'function') {\n throw new Error(\n 'deactivateAccount no longer accepts a callback parameter',\n );\n }\n\n const body = {};\n if (auth) {\n body.auth = auth;\n }\n if (erase !== undefined) {\n body.erase = erase;\n }\n\n return this._http.authedRequestWithPrefix(\n undefined, \"POST\", '/account/deactivate', undefined, body,\n httpApi.PREFIX_R0,\n );\n};\n\n/**\n * Get the fallback URL to use for unknown interactive-auth stages.\n *\n * @param {string} loginType the type of stage being attempted\n * @param {string} authSessionId the auth session ID provided by the homeserver\n *\n * @return {string} HS URL to hit to for the fallback interface\n */\nMatrixBaseApis.prototype.getFallbackAuthUrl = function(loginType, authSessionId) {\n const path = utils.encodeUri(\"/auth/$loginType/fallback/web\", {\n $loginType: loginType,\n });\n\n return this._http.getUrl(path, {\n session: authSessionId,\n }, httpApi.PREFIX_R0);\n};\n\n// Room operations\n// ===============\n\n/**\n * Create a new room.\n * @param {Object} options a list of options to pass to the /createRoom API.\n * @param {string} options.room_alias_name The alias localpart to assign to\n * this room.\n * @param {string} options.visibility Either 'public' or 'private'.\n * @param {string[]} options.invite A list of user IDs to invite to this room.\n * @param {string} options.name The name to give this room.\n * @param {string} options.topic The topic to give this room.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: <code>{room_id: {string},\n * room_alias: {string(opt)}}</code>\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.createRoom = function(options, callback) {\n // valid options include: room_alias_name, visibility, invite\n return this._http.authedRequest(\n callback, \"POST\", \"/createRoom\", undefined, options,\n );\n};\n\n/**\n * @param {string} roomId\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.roomState = function(roomId, callback) {\n const path = utils.encodeUri(\"/rooms/$roomId/state\", {$roomId: roomId});\n return this._http.authedRequest(callback, \"GET\", path);\n};\n\n/**\n * Get an event in a room by its event id.\n * @param {string} roomId\n * @param {string} eventId\n * @param {module:client.callback} callback Optional.\n *\n * @return {Promise} Resolves to an object containing the event.\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.fetchRoomEvent = function(roomId, eventId, callback) {\n const path = utils.encodeUri(\n \"/rooms/$roomId/event/$eventId\", {\n $roomId: roomId,\n $eventId: eventId,\n },\n );\n return this._http.authedRequest(callback, \"GET\", path);\n};\n\n/**\n * @param {string} roomId\n * @param {string} includeMembership the membership type to include in the response\n * @param {string} excludeMembership the membership type to exclude from the response\n * @param {string} atEventId the id of the event for which moment in the timeline the members should be returned for\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: dictionary of userid to profile information\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.members =\nfunction(roomId, includeMembership, excludeMembership, atEventId, callback) {\n const queryParams = {};\n if (includeMembership) {\n queryParams.membership = includeMembership;\n }\n if (excludeMembership) {\n queryParams.not_membership = excludeMembership;\n }\n if (atEventId) {\n queryParams.at = atEventId;\n }\n\n const queryString = utils.encodeParams(queryParams);\n\n const path = utils.encodeUri(\"/rooms/$roomId/members?\" + queryString,\n {$roomId: roomId});\n return this._http.authedRequest(callback, \"GET\", path);\n};\n\n/**\n * Upgrades a room to a new protocol version\n * @param {string} roomId\n * @param {string} newVersion The target version to upgrade to\n * @return {module:client.Promise} Resolves: Object with key 'replacement_room'\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.upgradeRoom = function(roomId, newVersion) {\n const path = utils.encodeUri(\"/rooms/$roomId/upgrade\", {$roomId: roomId});\n return this._http.authedRequest(\n undefined, \"POST\", path, undefined, {new_version: newVersion},\n );\n};\n\n\n/**\n * @param {string} groupId\n * @return {module:client.Promise} Resolves: Group summary object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getGroupSummary = function(groupId) {\n const path = utils.encodeUri(\"/groups/$groupId/summary\", {$groupId: groupId});\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n/**\n * @param {string} groupId\n * @return {module:client.Promise} Resolves: Group profile object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getGroupProfile = function(groupId) {\n const path = utils.encodeUri(\"/groups/$groupId/profile\", {$groupId: groupId});\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n/**\n * @param {string} groupId\n * @param {Object} profile The group profile object\n * @param {string=} profile.name Name of the group\n * @param {string=} profile.avatar_url MXC avatar URL\n * @param {string=} profile.short_description A short description of the room\n * @param {string=} profile.long_description A longer HTML description of the room\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setGroupProfile = function(groupId, profile) {\n const path = utils.encodeUri(\"/groups/$groupId/profile\", {$groupId: groupId});\n return this._http.authedRequest(\n undefined, \"POST\", path, undefined, profile,\n );\n};\n\n/**\n * @param {string} groupId\n * @param {object} policy The join policy for the group. Must include at\n * least a 'type' field which is 'open' if anyone can join the group\n * the group without prior approval, or 'invite' if an invite is\n * required to join.\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setGroupJoinPolicy = function(groupId, policy) {\n const path = utils.encodeUri(\n \"/groups/$groupId/settings/m.join_policy\",\n {$groupId: groupId},\n );\n return this._http.authedRequest(\n undefined, \"PUT\", path, undefined, {\n 'm.join_policy': policy,\n },\n );\n};\n\n/**\n * @param {string} groupId\n * @return {module:client.Promise} Resolves: Group users list object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getGroupUsers = function(groupId) {\n const path = utils.encodeUri(\"/groups/$groupId/users\", {$groupId: groupId});\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n/**\n * @param {string} groupId\n * @return {module:client.Promise} Resolves: Group users list object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getGroupInvitedUsers = function(groupId) {\n const path = utils.encodeUri(\"/groups/$groupId/invited_users\", {$groupId: groupId});\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n/**\n * @param {string} groupId\n * @return {module:client.Promise} Resolves: Group rooms list object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getGroupRooms = function(groupId) {\n const path = utils.encodeUri(\"/groups/$groupId/rooms\", {$groupId: groupId});\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n/**\n * @param {string} groupId\n * @param {string} userId\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.inviteUserToGroup = function(groupId, userId) {\n const path = utils.encodeUri(\n \"/groups/$groupId/admin/users/invite/$userId\",\n {$groupId: groupId, $userId: userId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @param {string} userId\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.removeUserFromGroup = function(groupId, userId) {\n const path = utils.encodeUri(\n \"/groups/$groupId/admin/users/remove/$userId\",\n {$groupId: groupId, $userId: userId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @param {string} userId\n * @param {string} roleId Optional.\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.addUserToGroupSummary = function(groupId, userId, roleId) {\n const path = utils.encodeUri(\n roleId ?\n \"/groups/$groupId/summary/$roleId/users/$userId\" :\n \"/groups/$groupId/summary/users/$userId\",\n {$groupId: groupId, $roleId: roleId, $userId: userId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @param {string} userId\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.removeUserFromGroupSummary = function(groupId, userId) {\n const path = utils.encodeUri(\n \"/groups/$groupId/summary/users/$userId\",\n {$groupId: groupId, $userId: userId},\n );\n return this._http.authedRequest(undefined, \"DELETE\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @param {string} roomId\n * @param {string} categoryId Optional.\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.addRoomToGroupSummary = function(groupId, roomId, categoryId) {\n const path = utils.encodeUri(\n categoryId ?\n \"/groups/$groupId/summary/$categoryId/rooms/$roomId\" :\n \"/groups/$groupId/summary/rooms/$roomId\",\n {$groupId: groupId, $categoryId: categoryId, $roomId: roomId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @param {string} roomId\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.removeRoomFromGroupSummary = function(groupId, roomId) {\n const path = utils.encodeUri(\n \"/groups/$groupId/summary/rooms/$roomId\",\n {$groupId: groupId, $roomId: roomId},\n );\n return this._http.authedRequest(undefined, \"DELETE\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @param {string} roomId\n * @param {bool} isPublic Whether the room-group association is visible to non-members\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.addRoomToGroup = function(groupId, roomId, isPublic) {\n if (isPublic === undefined) {\n isPublic = true;\n }\n const path = utils.encodeUri(\n \"/groups/$groupId/admin/rooms/$roomId\",\n {$groupId: groupId, $roomId: roomId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined,\n { \"m.visibility\": { type: isPublic ? \"public\" : \"private\" } },\n );\n};\n\n/**\n * Configure the visibility of a room-group association.\n * @param {string} groupId\n * @param {string} roomId\n * @param {bool} isPublic Whether the room-group association is visible to non-members\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.updateGroupRoomVisibility = function(groupId, roomId, isPublic) {\n // NB: The /config API is generic but there's not much point in exposing this yet as synapse\n // is the only server to implement this. In future we should consider an API that allows\n // arbitrary configuration, i.e. \"config/$configKey\".\n\n const path = utils.encodeUri(\n \"/groups/$groupId/admin/rooms/$roomId/config/m.visibility\",\n {$groupId: groupId, $roomId: roomId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined,\n { type: isPublic ? \"public\" : \"private\" },\n );\n};\n\n/**\n * @param {string} groupId\n * @param {string} roomId\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.removeRoomFromGroup = function(groupId, roomId) {\n const path = utils.encodeUri(\n \"/groups/$groupId/admin/rooms/$roomId\",\n {$groupId: groupId, $roomId: roomId},\n );\n return this._http.authedRequest(undefined, \"DELETE\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @param {Object} opts Additional options to send alongside the acceptance.\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.acceptGroupInvite = function(groupId, opts = null) {\n const path = utils.encodeUri(\n \"/groups/$groupId/self/accept_invite\",\n {$groupId: groupId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, opts || {});\n};\n\n/**\n * @param {string} groupId\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.joinGroup = function(groupId) {\n const path = utils.encodeUri(\n \"/groups/$groupId/self/join\",\n {$groupId: groupId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, {});\n};\n\n/**\n * @param {string} groupId\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.leaveGroup = function(groupId) {\n const path = utils.encodeUri(\n \"/groups/$groupId/self/leave\",\n {$groupId: groupId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, {});\n};\n\n/**\n * @return {module:client.Promise} Resolves: The groups to which the user is joined\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getJoinedGroups = function() {\n const path = utils.encodeUri(\"/joined_groups\");\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n/**\n * @param {Object} content Request content\n * @param {string} content.localpart The local part of the desired group ID\n * @param {Object} content.profile Group profile object\n * @return {module:client.Promise} Resolves: Object with key group_id: id of the created group\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.createGroup = function(content) {\n const path = utils.encodeUri(\"/create_group\");\n return this._http.authedRequest(\n undefined, \"POST\", path, undefined, content,\n );\n};\n\n/**\n * @param {string[]} userIds List of user IDs\n * @return {module:client.Promise} Resolves: Object as exmaple below\n *\n * {\n * \"users\": {\n * \"@bob:example.com\": {\n * \"+example:example.com\"\n * }\n * }\n * }\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getPublicisedGroups = function(userIds) {\n const path = utils.encodeUri(\"/publicised_groups\");\n return this._http.authedRequest(\n undefined, \"POST\", path, undefined, { user_ids: userIds },\n );\n};\n\n/**\n * @param {string} groupId\n * @param {bool} isPublic Whether the user's membership of this group is made public\n * @return {module:client.Promise} Resolves: Empty object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setGroupPublicity = function(groupId, isPublic) {\n const path = utils.encodeUri(\n \"/groups/$groupId/self/update_publicity\",\n {$groupId: groupId},\n );\n return this._http.authedRequest(undefined, \"PUT\", path, undefined, {\n publicise: isPublic,\n });\n};\n\n/**\n * Retrieve a state event.\n * @param {string} roomId\n * @param {string} eventType\n * @param {string} stateKey\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getStateEvent = function(roomId, eventType, stateKey, callback) {\n const pathParams = {\n $roomId: roomId,\n $eventType: eventType,\n $stateKey: stateKey,\n };\n let path = utils.encodeUri(\"/rooms/$roomId/state/$eventType\", pathParams);\n if (stateKey !== undefined) {\n path = utils.encodeUri(path + \"/$stateKey\", pathParams);\n }\n return this._http.authedRequest(\n callback, \"GET\", path,\n );\n};\n\n/**\n * @param {string} roomId\n * @param {string} eventType\n * @param {Object} content\n * @param {string} stateKey\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.sendStateEvent = function(roomId, eventType, content, stateKey,\n callback) {\n const pathParams = {\n $roomId: roomId,\n $eventType: eventType,\n $stateKey: stateKey,\n };\n let path = utils.encodeUri(\"/rooms/$roomId/state/$eventType\", pathParams);\n if (stateKey !== undefined) {\n path = utils.encodeUri(path + \"/$stateKey\", pathParams);\n }\n return this._http.authedRequest(\n callback, \"PUT\", path, undefined, content,\n );\n};\n\n/**\n * @param {string} roomId\n * @param {string} eventId\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.redactEvent = function(roomId, eventId, callback) {\n const path = utils.encodeUri(\"/rooms/$roomId/redact/$eventId\", {\n $roomId: roomId,\n $eventId: eventId,\n });\n return this._http.authedRequest(callback, \"POST\", path, undefined, {});\n};\n\n/**\n * @param {string} roomId\n * @param {Number} limit\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) {\n if (utils.isFunction(limit)) {\n callback = limit; limit = undefined;\n }\n const path = utils.encodeUri(\"/rooms/$roomId/initialSync\",\n {$roomId: roomId},\n );\n if (!limit) {\n limit = 30;\n }\n return this._http.authedRequest(\n callback, \"GET\", path, { limit: limit },\n );\n};\n\n/**\n * Set a marker to indicate the point in a room before which the user has read every\n * event. This can be retrieved from room account data (the event type is `m.fully_read`)\n * and displayed as a horizontal line in the timeline that is visually distinct to the\n * position of the user's own read receipt.\n * @param {string} roomId ID of the room that has been read\n * @param {string} rmEventId ID of the event that has been read\n * @param {string} rrEventId ID of the event tracked by the read receipt. This is here\n * for convenience because the RR and the RM are commonly updated at the same time as\n * each other. Optional.\n * @return {module:client.Promise} Resolves: the empty object, {}.\n */\nMatrixBaseApis.prototype.setRoomReadMarkersHttpRequest =\n function(roomId, rmEventId, rrEventId) {\n const path = utils.encodeUri(\"/rooms/$roomId/read_markers\", {\n $roomId: roomId,\n });\n\n const content = {\n \"m.fully_read\": rmEventId,\n \"m.read\": rrEventId,\n };\n\n return this._http.authedRequest(\n undefined, \"POST\", path, undefined, content,\n );\n};\n\n/**\n * @return {module:client.Promise} Resolves: A list of the user's current rooms\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getJoinedRooms = function() {\n const path = utils.encodeUri(\"/joined_rooms\");\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n/**\n * Retrieve membership info. for a room.\n * @param {string} roomId ID of the room to get membership for\n * @return {module:client.Promise} Resolves: A list of currently joined users\n * and their profile data.\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getJoinedRoomMembers = function(roomId) {\n const path = utils.encodeUri(\"/rooms/$roomId/joined_members\", {\n $roomId: roomId,\n });\n return this._http.authedRequest(undefined, \"GET\", path);\n};\n\n// Room Directory operations\n// =========================\n\n/**\n * @param {Object} options Options for this request\n * @param {string} options.server The remote server to query for the room list.\n * Optional. If unspecified, get the local home\n * server's public room list.\n * @param {number} options.limit Maximum number of entries to return\n * @param {string} options.since Token to paginate from\n * @param {object} options.filter Filter parameters\n * @param {string} options.filter.generic_search_term String to search for\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.publicRooms = function(options, callback) {\n if (typeof(options) == 'function') {\n callback = options;\n options = {};\n }\n if (options === undefined) {\n options = {};\n }\n\n const query_params = {};\n if (options.server) {\n query_params.server = options.server;\n delete options.server;\n }\n\n if (Object.keys(options).length === 0 && Object.keys(query_params).length === 0) {\n return this._http.authedRequest(callback, \"GET\", \"/publicRooms\");\n } else {\n return this._http.authedRequest(\n callback, \"POST\", \"/publicRooms\", query_params, options,\n );\n }\n};\n\n/**\n * Create an alias to room ID mapping.\n * @param {string} alias The room alias to create.\n * @param {string} roomId The room ID to link the alias to.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO.\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.createAlias = function(alias, roomId, callback) {\n const path = utils.encodeUri(\"/directory/room/$alias\", {\n $alias: alias,\n });\n const data = {\n room_id: roomId,\n };\n return this._http.authedRequest(\n callback, \"PUT\", path, undefined, data,\n );\n};\n\n/**\n * Delete an alias to room ID mapping. This alias must be on your local server\n * and you must have sufficient access to do this operation.\n * @param {string} alias The room alias to delete.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO.\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.deleteAlias = function(alias, callback) {\n const path = utils.encodeUri(\"/directory/room/$alias\", {\n $alias: alias,\n });\n return this._http.authedRequest(\n callback, \"DELETE\", path, undefined, undefined,\n );\n};\n\n/**\n * Get room info for the given alias.\n * @param {string} alias The room alias to resolve.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: Object with room_id and servers.\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getRoomIdForAlias = function(alias, callback) {\n // TODO: deprecate this or resolveRoomAlias\n const path = utils.encodeUri(\"/directory/room/$alias\", {\n $alias: alias,\n });\n return this._http.authedRequest(\n callback, \"GET\", path,\n );\n};\n\n/**\n * @param {string} roomAlias\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.resolveRoomAlias = function(roomAlias, callback) {\n // TODO: deprecate this or getRoomIdForAlias\n const path = utils.encodeUri(\"/directory/room/$alias\", {$alias: roomAlias});\n return this._http.request(callback, \"GET\", path);\n};\n\n/**\n * Get the visibility of a room in the current HS's room directory\n * @param {string} roomId\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getRoomDirectoryVisibility =\n function(roomId, callback) {\n const path = utils.encodeUri(\"/directory/list/room/$roomId\", {\n $roomId: roomId,\n });\n return this._http.authedRequest(callback, \"GET\", path);\n};\n\n/**\n * Set the visbility of a room in the current HS's room directory\n * @param {string} roomId\n * @param {string} visibility \"public\" to make the room visible\n * in the public directory, or \"private\" to make\n * it invisible.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setRoomDirectoryVisibility =\n function(roomId, visibility, callback) {\n const path = utils.encodeUri(\"/directory/list/room/$roomId\", {\n $roomId: roomId,\n });\n return this._http.authedRequest(\n callback, \"PUT\", path, undefined, { \"visibility\": visibility },\n );\n};\n\n/**\n * Set the visbility of a room bridged to a 3rd party network in\n * the current HS's room directory.\n * @param {string} networkId the network ID of the 3rd party\n * instance under which this room is published under.\n * @param {string} roomId\n * @param {string} visibility \"public\" to make the room visible\n * in the public directory, or \"private\" to make\n * it invisible.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setRoomDirectoryVisibilityAppService =\n function(networkId, roomId, visibility, callback) {\n const path = utils.encodeUri(\"/directory/list/appservice/$networkId/$roomId\", {\n $networkId: networkId,\n $roomId: roomId,\n });\n return this._http.authedRequest(\n callback, \"PUT\", path, undefined, { \"visibility\": visibility },\n );\n};\n\n// User Directory Operations\n// =========================\n\n/**\n * Query the user directory with a term matching user IDs, display names and domains.\n * @param {object} opts options\n * @param {string} opts.term the term with which to search.\n * @param {number} opts.limit the maximum number of results to return. The server will\n * apply a limit if unspecified.\n * @return {module:client.Promise} Resolves: an array of results.\n */\nMatrixBaseApis.prototype.searchUserDirectory = function(opts) {\n const body = {\n search_term: opts.term,\n };\n\n if (opts.limit !== undefined) {\n body.limit = opts.limit;\n }\n\n return this._http.authedRequest(\n undefined, \"POST\", \"/user_directory/search\", undefined, body,\n );\n};\n\n\n// Media operations\n// ================\n\n/**\n * Upload a file to the media repository on the home server.\n *\n * @param {object} file The object to upload. On a browser, something that\n * can be sent to XMLHttpRequest.send (typically a File). Under node.js,\n * a a Buffer, String or ReadStream.\n *\n * @param {object} opts options object\n *\n * @param {string=} opts.name Name to give the file on the server. Defaults\n * to <tt>file.name</tt>.\n *\n * @param {boolean=} opts.includeFilename if false will not send the filename,\n * e.g for encrypted file uploads where filename leaks are undesirable.\n * Defaults to true.\n *\n * @param {string=} opts.type Content-type for the upload. Defaults to\n * <tt>file.type</tt>, or <tt>applicaton/octet-stream</tt>.\n *\n * @param {boolean=} opts.rawResponse Return the raw body, rather than\n * parsing the JSON. Defaults to false (except on node.js, where it\n * defaults to true for backwards compatibility).\n *\n * @param {boolean=} opts.onlyContentUri Just return the content URI,\n * rather than the whole body. Defaults to false (except on browsers,\n * where it defaults to true for backwards compatibility). Ignored if\n * opts.rawResponse is true.\n *\n * @param {Function=} opts.callback Deprecated. Optional. The callback to\n * invoke on success/failure. See the promise return values for more\n * information.\n *\n * @param {Function=} opts.progressHandler Optional. Called when a chunk of\n * data has been uploaded, with an object containing the fields `loaded`\n * (number of bytes transferred) and `total` (total size, if known).\n *\n * @return {module:client.Promise} Resolves to response object, as\n * determined by this.opts.onlyData, opts.rawResponse, and\n * opts.onlyContentUri. Rejects with an error (usually a MatrixError).\n */\nMatrixBaseApis.prototype.uploadContent = function(file, opts) {\n return this._http.uploadContent(file, opts);\n};\n\n/**\n * Cancel a file upload in progress\n * @param {module:client.Promise} promise The promise returned from uploadContent\n * @return {boolean} true if canceled, otherwise false\n */\nMatrixBaseApis.prototype.cancelUpload = function(promise) {\n return this._http.cancelUpload(promise);\n};\n\n/**\n * Get a list of all file uploads in progress\n * @return {array} Array of objects representing current uploads.\n * Currently in progress is element 0. Keys:\n * - promise: The promise associated with the upload\n * - loaded: Number of bytes uploaded\n * - total: Total number of bytes to upload\n */\nMatrixBaseApis.prototype.getCurrentUploads = function() {\n return this._http.getCurrentUploads();\n};\n\n\n// Profile operations\n// ==================\n\n/**\n * @param {string} userId\n * @param {string} info The kind of info to retrieve (e.g. 'displayname',\n * 'avatar_url').\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getProfileInfo = function(userId, info, callback) {\n if (utils.isFunction(info)) {\n callback = info; info = undefined;\n }\n\n const path = info ?\n utils.encodeUri(\"/profile/$userId/$info\",\n { $userId: userId, $info: info }) :\n utils.encodeUri(\"/profile/$userId\",\n { $userId: userId });\n return this._http.authedRequest(callback, \"GET\", path);\n};\n\n\n// Account operations\n// ==================\n\n/**\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getThreePids = function(callback) {\n const path = \"/account/3pid\";\n return this._http.authedRequest(\n callback, \"GET\", path, undefined, undefined,\n );\n};\n\n/**\n * @param {Object} creds\n * @param {boolean} bind\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.addThreePid = function(creds, bind, callback) {\n const path = \"/account/3pid\";\n const data = {\n 'threePidCreds': creds,\n 'bind': bind,\n };\n return this._http.authedRequest(\n callback, \"POST\", path, null, data,\n );\n};\n\n/**\n * @param {string} medium The threepid medium (eg. 'email')\n * @param {string} address The threepid address (eg. 'bob@example.com')\n * this must be as returned by getThreePids.\n * @return {module:client.Promise} Resolves: The server response on success\n * (generally the empty JSON object)\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.deleteThreePid = function(medium, address) {\n const path = \"/account/3pid/delete\";\n const data = {\n 'medium': medium,\n 'address': address,\n };\n return this._http.authedRequestWithPrefix(\n undefined, \"POST\", path, null, data, httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * Make a request to change your password.\n * @param {Object} authDict\n * @param {string} newPassword The new desired password.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setPassword = function(authDict, newPassword, callback) {\n const path = \"/account/password\";\n const data = {\n 'auth': authDict,\n 'new_password': newPassword,\n };\n\n return this._http.authedRequest(\n callback, \"POST\", path, null, data,\n );\n};\n\n\n// Device operations\n// =================\n\n/**\n * Gets all devices recorded for the logged-in user\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getDevices = function() {\n const path = \"/devices\";\n return this._http.authedRequestWithPrefix(\n undefined, \"GET\", path, undefined, undefined,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * Update the given device\n *\n * @param {string} device_id device to update\n * @param {Object} body body of request\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setDeviceDetails = function(device_id, body) {\n const path = utils.encodeUri(\"/devices/$device_id\", {\n $device_id: device_id,\n });\n\n\n return this._http.authedRequestWithPrefix(\n undefined, \"PUT\", path, undefined, body,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * Delete the given device\n *\n * @param {string} device_id device to delete\n * @param {object} auth Optional. Auth data to supply for User-Interactive auth.\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.deleteDevice = function(device_id, auth) {\n const path = utils.encodeUri(\"/devices/$device_id\", {\n $device_id: device_id,\n });\n\n const body = {};\n\n if (auth) {\n body.auth = auth;\n }\n\n return this._http.authedRequestWithPrefix(\n undefined, \"DELETE\", path, undefined, body,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * Delete multiple device\n *\n * @param {string[]} devices IDs of the devices to delete\n * @param {object} auth Optional. Auth data to supply for User-Interactive auth.\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.deleteMultipleDevices = function(devices, auth) {\n const body = {devices};\n\n if (auth) {\n body.auth = auth;\n }\n\n return this._http.authedRequestWithPrefix(\n undefined, \"POST\", \"/delete_devices\", undefined, body,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n\n// Push operations\n// ===============\n\n/**\n * Gets all pushers registered for the logged-in user\n *\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: Array of objects representing pushers\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getPushers = function(callback) {\n const path = \"/pushers\";\n return this._http.authedRequest(\n callback, \"GET\", path, undefined, undefined,\n );\n};\n\n/**\n * Adds a new pusher or updates an existing pusher\n *\n * @param {Object} pusher Object representing a pusher\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: Empty json object on success\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setPusher = function(pusher, callback) {\n const path = \"/pushers/set\";\n return this._http.authedRequest(\n callback, \"POST\", path, null, pusher,\n );\n};\n\n/**\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.getPushRules = function(callback) {\n return this._http.authedRequest(callback, \"GET\", \"/pushrules/\");\n};\n\n/**\n * @param {string} scope\n * @param {string} kind\n * @param {string} ruleId\n * @param {Object} body\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.addPushRule = function(scope, kind, ruleId, body, callback) {\n // NB. Scope not uri encoded because devices need the '/'\n const path = utils.encodeUri(\"/pushrules/\" + scope + \"/$kind/$ruleId\", {\n $kind: kind,\n $ruleId: ruleId,\n });\n return this._http.authedRequest(\n callback, \"PUT\", path, undefined, body,\n );\n};\n\n/**\n * @param {string} scope\n * @param {string} kind\n * @param {string} ruleId\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.deletePushRule = function(scope, kind, ruleId, callback) {\n // NB. Scope not uri encoded because devices need the '/'\n const path = utils.encodeUri(\"/pushrules/\" + scope + \"/$kind/$ruleId\", {\n $kind: kind,\n $ruleId: ruleId,\n });\n return this._http.authedRequest(callback, \"DELETE\", path);\n};\n\n/**\n * Enable or disable a push notification rule.\n * @param {string} scope\n * @param {string} kind\n * @param {string} ruleId\n * @param {boolean} enabled\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setPushRuleEnabled = function(scope, kind,\n ruleId, enabled, callback) {\n const path = utils.encodeUri(\"/pushrules/\" + scope + \"/$kind/$ruleId/enabled\", {\n $kind: kind,\n $ruleId: ruleId,\n });\n return this._http.authedRequest(\n callback, \"PUT\", path, undefined, {\"enabled\": enabled},\n );\n};\n\n/**\n * Set the actions for a push notification rule.\n * @param {string} scope\n * @param {string} kind\n * @param {string} ruleId\n * @param {array} actions\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: result object\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.setPushRuleActions = function(scope, kind,\n ruleId, actions, callback) {\n const path = utils.encodeUri(\"/pushrules/\" + scope + \"/$kind/$ruleId/actions\", {\n $kind: kind,\n $ruleId: ruleId,\n });\n return this._http.authedRequest(\n callback, \"PUT\", path, undefined, {\"actions\": actions},\n );\n};\n\n\n// Search\n// ======\n\n/**\n * Perform a server-side search.\n * @param {Object} opts\n * @param {string} opts.next_batch the batch token to pass in the query string\n * @param {Object} opts.body the JSON object to pass to the request body.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.search = function(opts, callback) {\n const queryparams = {};\n if (opts.next_batch) {\n queryparams.next_batch = opts.next_batch;\n }\n return this._http.authedRequest(\n callback, \"POST\", \"/search\", queryparams, opts.body,\n );\n};\n\n// Crypto\n// ======\n\n/**\n * Upload keys\n *\n * @param {Object} content body of upload request\n *\n * @param {Object=} opts\n *\n * @param {string=} opts.device_id explicit device_id to use for upload\n * (default is to use the same as that used during auth).\n *\n * @param {module:client.callback=} callback\n *\n * @return {module:client.Promise} Resolves: result object. Rejects: with\n * an error response ({@link module:http-api.MatrixError}).\n */\nMatrixBaseApis.prototype.uploadKeysRequest = function(content, opts, callback) {\n opts = opts || {};\n const deviceId = opts.device_id;\n let path;\n if (deviceId) {\n path = utils.encodeUri(\"/keys/upload/$deviceId\", {\n $deviceId: deviceId,\n });\n } else {\n path = \"/keys/upload\";\n }\n return this._http.authedRequestWithPrefix(\n callback, \"POST\", path, undefined, content, httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * Download device keys\n *\n * @param {string[]} userIds list of users to get keys for\n *\n * @param {Object=} opts\n *\n * @param {string=} opts.token sync token to pass in the query request, to help\n * the HS give the most recent results\n *\n * @return {module:client.Promise} Resolves: result object. Rejects: with\n * an error response ({@link module:http-api.MatrixError}).\n */\nMatrixBaseApis.prototype.downloadKeysForUsers = function(userIds, opts) {\n if (utils.isFunction(opts)) {\n // opts used to be 'callback'.\n throw new Error(\n 'downloadKeysForUsers no longer accepts a callback parameter',\n );\n }\n opts = opts || {};\n\n const content = {\n device_keys: {},\n };\n if ('token' in opts) {\n content.token = opts.token;\n }\n userIds.forEach((u) => {\n content.device_keys[u] = {};\n });\n\n return this._http.authedRequestWithPrefix(\n undefined, \"POST\", \"/keys/query\", undefined, content,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * Claim one-time keys\n *\n * @param {string[]} devices a list of [userId, deviceId] pairs\n *\n * @param {string} [key_algorithm = signed_curve25519] desired key type\n *\n * @return {module:client.Promise} Resolves: result object. Rejects: with\n * an error response ({@link module:http-api.MatrixError}).\n */\nMatrixBaseApis.prototype.claimOneTimeKeys = function(devices, key_algorithm) {\n const queries = {};\n\n if (key_algorithm === undefined) {\n key_algorithm = \"signed_curve25519\";\n }\n\n for (let i = 0; i < devices.length; ++i) {\n const userId = devices[i][0];\n const deviceId = devices[i][1];\n const query = queries[userId] || {};\n queries[userId] = query;\n query[deviceId] = key_algorithm;\n }\n const content = {one_time_keys: queries};\n return this._http.authedRequestWithPrefix(\n undefined, \"POST\", \"/keys/claim\", undefined, content,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * Ask the server for a list of users who have changed their device lists\n * between a pair of sync tokens\n *\n * @param {string} oldToken\n * @param {string} newToken\n *\n * @return {module:client.Promise} Resolves: result object. Rejects: with\n * an error response ({@link module:http-api.MatrixError}).\n */\nMatrixBaseApis.prototype.getKeyChanges = function(oldToken, newToken) {\n const qps = {\n from: oldToken,\n to: newToken,\n };\n\n return this._http.authedRequestWithPrefix(\n undefined, \"GET\", \"/keys/changes\", qps, undefined,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n\n// Identity Server Operations\n// ==========================\n\n/**\n * Requests an email verification token directly from an Identity Server.\n *\n * Note that the Home Server offers APIs to proxy this API for specific\n * situations, allowing for better feedback to the user.\n *\n * @param {string} email The email address to request a token for\n * @param {string} clientSecret A secret binary string generated by the client.\n * It is recommended this be around 16 ASCII characters.\n * @param {number} sendAttempt If an identity server sees a duplicate request\n * with the same sendAttempt, it will not send another email.\n * To request another email to be sent, use a larger value for\n * the sendAttempt param as was used in the previous request.\n * @param {string} nextLink Optional If specified, the client will be redirected\n * to this link after validation.\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: TODO\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n * @throws Error if No ID server is set\n */\nMatrixBaseApis.prototype.requestEmailToken = function(email, clientSecret,\n sendAttempt, nextLink, callback) {\n const params = {\n client_secret: clientSecret,\n email: email,\n send_attempt: sendAttempt,\n next_link: nextLink,\n };\n return this._http.idServerRequest(\n callback, \"POST\", \"/validate/email/requestToken\",\n params, httpApi.PREFIX_IDENTITY_V1,\n );\n};\n\n/**\n * Submits an MSISDN token to the identity server\n *\n * This is used when submitting the code sent by SMS to a phone number.\n * The ID server has an equivalent API for email but the js-sdk does\n * not expose this, since email is normally validated by the user clicking\n * a link rather than entering a code.\n *\n * @param {string} sid The sid given in the response to requestToken\n * @param {string} clientSecret A secret binary string generated by the client.\n * This must be the same value submitted in the requestToken call.\n * @param {string} token The token, as enetered by the user.\n *\n * @return {module:client.Promise} Resolves: Object, currently with no parameters.\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n * @throws Error if No ID server is set\n */\nMatrixBaseApis.prototype.submitMsisdnToken = function(sid, clientSecret, token) {\n const params = {\n sid: sid,\n client_secret: clientSecret,\n token: token,\n };\n return this._http.idServerRequest(\n undefined, \"POST\", \"/validate/msisdn/submitToken\",\n params, httpApi.PREFIX_IDENTITY_V1,\n );\n};\n\n/**\n * Looks up the public Matrix ID mapping for a given 3rd party\n * identifier from the Identity Server\n * @param {string} medium The medium of the threepid, eg. 'email'\n * @param {string} address The textual address of the threepid\n * @param {module:client.callback} callback Optional.\n * @return {module:client.Promise} Resolves: A threepid mapping\n * object or the empty object if no mapping\n * exists\n * @return {module:http-api.MatrixError} Rejects: with an error response.\n */\nMatrixBaseApis.prototype.lookupThreePid = function(medium, address, callback) {\n const params = {\n medium: medium,\n address: address,\n };\n return this._http.idServerRequest(\n callback, \"GET\", \"/lookup\",\n params, httpApi.PREFIX_IDENTITY_V1,\n );\n};\n\n\n// Direct-to-device messaging\n// ==========================\n\n/**\n * Send an event to a specific list of devices\n *\n * @param {string} eventType type of event to send\n * @param {Object.<string, Object<string, Object>>} contentMap\n * content to send. Map from user_id to device_id to content object.\n * @param {string=} txnId transaction id. One will be made up if not\n * supplied.\n * @return {module:client.Promise} Resolves to the result object\n */\nMatrixBaseApis.prototype.sendToDevice = function(\n eventType, contentMap, txnId,\n) {\n const path = utils.encodeUri(\"/sendToDevice/$eventType/$txnId\", {\n $eventType: eventType,\n $txnId: txnId ? txnId : this.makeTxnId(),\n });\n\n const body = {\n messages: contentMap,\n };\n\n return this._http.authedRequestWithPrefix(\n undefined, \"PUT\", path, undefined, body,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n// Third party Lookup API\n// ======================\n\n/**\n * Get the third party protocols that can be reached using\n * this HS\n * @return {module:client.Promise} Resolves to the result object\n */\nMatrixBaseApis.prototype.getThirdpartyProtocols = function() {\n return this._http.authedRequestWithPrefix(\n undefined, \"GET\", \"/thirdparty/protocols\", undefined, undefined,\n httpApi.PREFIX_UNSTABLE,\n ).then((response) => {\n // sanity check\n if (!response || typeof(response) !== 'object') {\n throw new Error(\n `/thirdparty/protocols did not return an object: ${response}`,\n );\n }\n return response;\n });\n};\n\n/**\n * Get information on how a specific place on a third party protocol\n * may be reached.\n * @param {string} protocol The protocol given in getThirdpartyProtocols()\n * @param {object} params Protocol-specific parameters, as given in th\n * response to getThirdpartyProtocols()\n * @return {module:client.Promise} Resolves to the result object\n */\nMatrixBaseApis.prototype.getThirdpartyLocation = function(protocol, params) {\n const path = utils.encodeUri(\"/thirdparty/location/$protocol\", {\n $protocol: protocol,\n });\n\n return this._http.authedRequestWithPrefix(\n undefined, \"GET\", path, params, undefined,\n httpApi.PREFIX_UNSTABLE,\n );\n};\n\n/**\n * MatrixBaseApis object\n */\nmodule.exports = MatrixBaseApis;\n"]}
\No newline at end of file