diff --git a/lib/client.js b/lib/client.js index afbb1b0c8..834f740c0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2788,7 +2788,7 @@ MatrixClient.prototype.register = function(username, password, /** * Requests an email verification token for the purposes of registration. * This API proxies the Identity Server /validate/email/requestToken API, - * adding registration-specific behaviour. Specifically, an account with + * adding registration-specific behaviour. Specifically, if an account with * the given email address already exists, it will either send an email * to the address informing them of this or return M_THREEPID_IN_USE * (which one is up to the Home Server). @@ -2796,17 +2796,14 @@ MatrixClient.prototype.register = function(username, password, * requestEmailToken calls the equivalent API directly on the ID server, * therefore bypassing the registration-specific logic. * - * @param {string} email - * @param {string} clientSecret - * @param {string} sendAttempt - * @param {string} nextLink Optional - * @param {module:client.callback} callback Optional. - * @return {module:client.Promise} Resolves: TODO - * @return {module:http-api.MatrixError} Rejects: with an error response. + * Parameters and return value are as for requestEmailToken */ MatrixClient.prototype.requestRegisterEmailToken = function(email, clientSecret, sendAttempt, nextLink, callback) { var id_server_url = url.parse(this.idBaseUrl); + if (id_server_url.host == null) { + throw new Error("Invalid ID server URL: " + this.idBaseUrl); + } var params = { client_secret: clientSecret, @@ -3707,13 +3704,19 @@ MatrixClient.prototype.getEventMapper = function() { * Note that the Home Server offers APIs to proxy this API for specific * situations, allowing for better feedback to the user. * - * @param {string} email - * @param {string} clientSecret - * @param {string} sendAttempt - * @param {string} nextLink Optional + * @param {string} email The email address to request a token for + * @param {string} clientSecret A secret binary string generated by the client. + * It is recommended this be around 16 ASCII characters. + * @param {number} sendAttempt If an identity server sees a duplicate request + * with the same sendAttempt, it will not send another email. + * To request another email to be sent, use a larger value for + * the sendAttempt param as was used in the previous request. + * @param {string} nextLink Optional If specified, the client will be redirected + * to this link after validation. * @param {module:client.callback} callback Optional. * @return {module:client.Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. + * @throws Error if No ID server is set */ MatrixClient.prototype.requestEmailToken = function(email, clientSecret, sendAttempt, nextLink, callback) {