You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Remove v1 identity server fallbacks
Fixes https://github.com/vector-im/riot-web/issues/10443 **Review with https://github.com/matrix-org/matrix-react-sdk/pull/4191**
This commit is contained in:
100
src/base-apis.js
100
src/base-apis.js
@@ -28,13 +28,7 @@ import {SERVICE_TYPES} from './service-types';
|
|||||||
import {logger} from './logger';
|
import {logger} from './logger';
|
||||||
import {PushProcessor} from "./pushprocessor";
|
import {PushProcessor} from "./pushprocessor";
|
||||||
import * as utils from "./utils";
|
import * as utils from "./utils";
|
||||||
import {
|
import {MatrixHttpApi, PREFIX_IDENTITY_V2, PREFIX_R0, PREFIX_UNSTABLE,} from "./http-api";
|
||||||
MatrixHttpApi,
|
|
||||||
PREFIX_IDENTITY_V1,
|
|
||||||
PREFIX_IDENTITY_V2,
|
|
||||||
PREFIX_R0,
|
|
||||||
PREFIX_UNSTABLE,
|
|
||||||
} from "./http-api";
|
|
||||||
|
|
||||||
function termsUrlForService(serviceType, baseUrl) {
|
function termsUrlForService(serviceType, baseUrl) {
|
||||||
switch (serviceType) {
|
switch (serviceType) {
|
||||||
@@ -1895,28 +1889,10 @@ MatrixBaseApis.prototype.requestEmailToken = async function(
|
|||||||
next_link: nextLink,
|
next_link: nextLink,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await this._http.idServerRequest(
|
|
||||||
undefined, "POST", "/validate/email/requestToken",
|
|
||||||
params, PREFIX_IDENTITY_V2, identityAccessToken,
|
|
||||||
);
|
|
||||||
// TODO: Fold callback into above call once v1 path below is removed
|
|
||||||
if (callback) callback(null, response);
|
|
||||||
return response;
|
|
||||||
} catch (err) {
|
|
||||||
if (err.cors === "rejected" || err.httpStatus === 404) {
|
|
||||||
// Fall back to deprecated v1 API for now
|
|
||||||
// TODO: Remove this path once v2 is only supported version
|
|
||||||
// See https://github.com/vector-im/riot-web/issues/10443
|
|
||||||
logger.warn("IS doesn't support v2, falling back to deprecated v1");
|
|
||||||
return await this._http.idServerRequest(
|
return await this._http.idServerRequest(
|
||||||
callback, "POST", "/validate/email/requestToken",
|
callback, "POST", "/validate/email/requestToken",
|
||||||
params, PREFIX_IDENTITY_V1,
|
params, PREFIX_IDENTITY_V2, identityAccessToken,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
if (callback) callback(err);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1963,28 +1939,10 @@ MatrixBaseApis.prototype.requestMsisdnToken = async function(
|
|||||||
next_link: nextLink,
|
next_link: nextLink,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await this._http.idServerRequest(
|
|
||||||
undefined, "POST", "/validate/msisdn/requestToken",
|
|
||||||
params, PREFIX_IDENTITY_V2, identityAccessToken,
|
|
||||||
);
|
|
||||||
// TODO: Fold callback into above call once v1 path below is removed
|
|
||||||
if (callback) callback(null, response);
|
|
||||||
return response;
|
|
||||||
} catch (err) {
|
|
||||||
if (err.cors === "rejected" || err.httpStatus === 404) {
|
|
||||||
// Fall back to deprecated v1 API for now
|
|
||||||
// TODO: Remove this path once v2 is only supported version
|
|
||||||
// See https://github.com/vector-im/riot-web/issues/10443
|
|
||||||
logger.warn("IS doesn't support v2, falling back to deprecated v1");
|
|
||||||
return await this._http.idServerRequest(
|
return await this._http.idServerRequest(
|
||||||
callback, "POST", "/validate/msisdn/requestToken",
|
callback, "POST", "/validate/msisdn/requestToken",
|
||||||
params, PREFIX_IDENTITY_V1,
|
params, PREFIX_IDENTITY_V2, identityAccessToken,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
if (callback) callback(err);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2018,24 +1976,10 @@ MatrixBaseApis.prototype.submitMsisdnToken = async function(
|
|||||||
token: msisdnToken,
|
token: msisdnToken,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
|
||||||
return await this._http.idServerRequest(
|
return await this._http.idServerRequest(
|
||||||
undefined, "POST", "/validate/msisdn/submitToken",
|
undefined, "POST", "/validate/msisdn/submitToken",
|
||||||
params, PREFIX_IDENTITY_V2, identityAccessToken,
|
params, PREFIX_IDENTITY_V2, identityAccessToken,
|
||||||
);
|
);
|
||||||
} catch (err) {
|
|
||||||
if (err.cors === "rejected" || err.httpStatus === 404) {
|
|
||||||
// Fall back to deprecated v1 API for now
|
|
||||||
// TODO: Remove this path once v2 is only supported version
|
|
||||||
// See https://github.com/vector-im/riot-web/issues/10443
|
|
||||||
logger.warn("IS doesn't support v2, falling back to deprecated v1");
|
|
||||||
return await this._http.idServerRequest(
|
|
||||||
undefined, "POST", "/validate/msisdn/submitToken",
|
|
||||||
params, PREFIX_IDENTITY_V1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2190,7 +2134,6 @@ MatrixBaseApis.prototype.lookupThreePid = async function(
|
|||||||
callback,
|
callback,
|
||||||
identityAccessToken,
|
identityAccessToken,
|
||||||
) {
|
) {
|
||||||
try {
|
|
||||||
// Note: we're using the V2 API by calling this function, but our
|
// Note: we're using the V2 API by calling this function, but our
|
||||||
// function contract requires a V1 response. We therefore have to
|
// function contract requires a V1 response. We therefore have to
|
||||||
// convert it manually.
|
// convert it manually.
|
||||||
@@ -2199,7 +2142,6 @@ MatrixBaseApis.prototype.lookupThreePid = async function(
|
|||||||
);
|
);
|
||||||
const result = response.find(p => p.address === address);
|
const result = response.find(p => p.address === address);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
// TODO: Fold callback into above call once v1 path below is removed
|
|
||||||
if (callback) callback(null, {});
|
if (callback) callback(null, {});
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -2216,27 +2158,8 @@ MatrixBaseApis.prototype.lookupThreePid = async function(
|
|||||||
// signatures
|
// signatures
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Fold callback into above call once v1 path below is removed
|
|
||||||
if (callback) callback(null, mapping);
|
if (callback) callback(null, mapping);
|
||||||
return mapping;
|
return mapping;
|
||||||
} catch (err) {
|
|
||||||
if (err.cors === "rejected" || err.httpStatus === 404) {
|
|
||||||
// Fall back to deprecated v1 API for now
|
|
||||||
// TODO: Remove this path once v2 is only supported version
|
|
||||||
// See https://github.com/vector-im/riot-web/issues/10443
|
|
||||||
const params = {
|
|
||||||
medium: medium,
|
|
||||||
address: address,
|
|
||||||
};
|
|
||||||
logger.warn("IS doesn't support v2, falling back to deprecated v1");
|
|
||||||
return await this._http.idServerRequest(
|
|
||||||
callback, "GET", "/lookup",
|
|
||||||
params, PREFIX_IDENTITY_V1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (callback) callback(err, undefined);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2254,7 +2177,6 @@ MatrixBaseApis.prototype.bulkLookupThreePids = async function(
|
|||||||
query,
|
query,
|
||||||
identityAccessToken,
|
identityAccessToken,
|
||||||
) {
|
) {
|
||||||
try {
|
|
||||||
// Note: we're using the V2 API by calling this function, but our
|
// Note: we're using the V2 API by calling this function, but our
|
||||||
// function contract requires a V1 response. We therefore have to
|
// function contract requires a V1 response. We therefore have to
|
||||||
// convert it manually.
|
// convert it manually.
|
||||||
@@ -2278,22 +2200,6 @@ MatrixBaseApis.prototype.bulkLookupThreePids = async function(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {threepids: v1results};
|
return {threepids: v1results};
|
||||||
} catch (err) {
|
|
||||||
if (err.cors === "rejected" || err.httpStatus === 404) {
|
|
||||||
// Fall back to deprecated v1 API for now
|
|
||||||
// TODO: Remove this path once v2 is only supported version
|
|
||||||
// See https://github.com/vector-im/riot-web/issues/10443
|
|
||||||
const params = {
|
|
||||||
threepids: query,
|
|
||||||
};
|
|
||||||
logger.warn("IS doesn't support v2, falling back to deprecated v1");
|
|
||||||
return await this._http.idServerRequest(
|
|
||||||
undefined, "POST", "/bulk_lookup", params,
|
|
||||||
PREFIX_IDENTITY_V1, identityAccessToken,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export const PREFIX_UNSTABLE = "/_matrix/client/unstable";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* URI path for v1 of the the identity API
|
* URI path for v1 of the the identity API
|
||||||
|
* @deprecated Use v2.
|
||||||
*/
|
*/
|
||||||
export const PREFIX_IDENTITY_V1 = "/_matrix/identity/api/v1";
|
export const PREFIX_IDENTITY_V1 = "/_matrix/identity/api/v1";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user