mitra-interactions-sdk 1.0.60-beta.3 → 1.0.60-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -724,7 +724,7 @@ function buildUrl(endpoint, params) {
724
724
  async function tryRefreshToken() {
725
725
  var _a, _b;
726
726
  const config = getConfig();
727
- if (!config.token || config.projectId == null) return false;
727
+ if (!config.token || config.projectId == null || !config.baseURL) return false;
728
728
  try {
729
729
  const baseURL = config.baseURL.replace(/\/+$/, "");
730
730
  const resp = await getFetch3()(`${baseURL}/mitraspace/project/refreshedToken/${config.projectId}`, {
@@ -774,7 +774,8 @@ async function handleResponse(response) {
774
774
  async function fetchWithRefresh(url, init) {
775
775
  const fetchFn = getFetch3();
776
776
  const response = await fetchFn(url, init);
777
- if (response.status === 403) {
777
+ const expiredStatus = isNewWorld() ? 401 : 403;
778
+ if (response.status === expiredStatus) {
778
779
  const refreshed = await tryRefreshToken();
779
780
  if (refreshed) {
780
781
  const newHeaders = { ...buildHeaders() };