You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Add API calls for other requestToken endpoints
This commit is contained in:
@@ -2807,6 +2807,61 @@ MatrixClient.prototype.register = function(username, password,
|
||||
*/
|
||||
MatrixClient.prototype.requestRegisterEmailToken = function(email, clientSecret,
|
||||
sendAttempt, nextLink, callback) {
|
||||
return this._requestTokenFromEndpoint(
|
||||
"/register/email/requestToken", email, clientSecret, sendAttempt, nextLink, callback
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Requests an email verification token for the purposes of adding a
|
||||
* third party identifier to an account.
|
||||
* This API proxies the Identity Server /validate/email/requestToken API,
|
||||
* adding specific behaviour for the addition of email addresses to an
|
||||
* account. 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).
|
||||
*
|
||||
* requestEmailToken calls the equivalent API directly on the ID server,
|
||||
* therefore bypassing the email addition specific logic.
|
||||
*
|
||||
* Parameters and return value are as for requestEmailToken
|
||||
*/
|
||||
MatrixClient.prototype.request3pidAddEmailToken = function(email, clientSecret,
|
||||
sendAttempt, nextLink, callback) {
|
||||
return this._requestTokenFromEndpoint(
|
||||
"/account/3pid/email/requestToken", email, clientSecret, sendAttempt, nextLink, callback
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Requests an email verification token for the purposes of resetting
|
||||
* the password on an account.
|
||||
* This API proxies the Identity Server /validate/email/requestToken API,
|
||||
* adding specific behaviour for the password resetting. Specifically,
|
||||
* if no account with the given email address exists, it may either
|
||||
* return M_THREEPID_NOT_FOUND or send an email
|
||||
* to the address informing them of this (which one is up to the Home Server).
|
||||
*
|
||||
* requestEmailToken calls the equivalent API directly on the ID server,
|
||||
* therefore bypassing the password reset specific logic.
|
||||
*
|
||||
* Parameters and return value are as for requestEmailToken
|
||||
*/
|
||||
MatrixClient.prototype.requestPasswordEmailToken = function(email, clientSecret,
|
||||
sendAttempt, nextLink, callback) {
|
||||
return this._requestTokenFromEndpoint(
|
||||
"/account/password/email/requestToken", email, clientSecret, sendAttempt, nextLink, callback
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal utility function for requesting validation tokens from usage-specific
|
||||
* requestToken endpoints.
|
||||
*/
|
||||
MatrixClient.prototype._requestTokenFromEndpoint = function(endpoint,
|
||||
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);
|
||||
@@ -2820,7 +2875,7 @@ MatrixClient.prototype.requestRegisterEmailToken = function(email, clientSecret,
|
||||
id_server: id_server_url.host,
|
||||
};
|
||||
return this._http.request(
|
||||
callback, "POST", "/register/email/requestToken", undefined,
|
||||
callback, "POST", endpoint, undefined,
|
||||
params
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user