mitra-interactions-sdk 1.0.60-beta.4 → 1.0.60-beta.5
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 +6 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -255,10 +255,6 @@ function getFetch() {
|
|
|
255
255
|
if (typeof globalThis.fetch === "function") return globalThis.fetch;
|
|
256
256
|
throw new Error("fetch n\xE3o dispon\xEDvel. Use Node.js 18+ ou instale node-fetch.");
|
|
257
257
|
}
|
|
258
|
-
function buildEndpoint(authUrl, path) {
|
|
259
|
-
const base = authUrl.replace(/\/+$/, "");
|
|
260
|
-
return `${base}/iam/api/v1/auth${path}`;
|
|
261
|
-
}
|
|
262
258
|
function buildBffAuthEndpoint(gateway, path) {
|
|
263
259
|
const base = gateway.replace(/\/+$/, "");
|
|
264
260
|
return `${base}/auth${path}`;
|
|
@@ -287,25 +283,6 @@ function autoConfigureFromLogin2(response, authUrl, projectId) {
|
|
|
287
283
|
...response.integrationURL ? { integrationURL: response.integrationURL } : {}
|
|
288
284
|
});
|
|
289
285
|
}
|
|
290
|
-
async function postNewAuth(url, body) {
|
|
291
|
-
const fetchFn = getFetch();
|
|
292
|
-
const response = await fetchFn(url, {
|
|
293
|
-
method: "POST",
|
|
294
|
-
headers: { "Content-Type": "application/json" },
|
|
295
|
-
body: JSON.stringify(body)
|
|
296
|
-
});
|
|
297
|
-
if (!response.ok) {
|
|
298
|
-
const text = await response.text().catch(() => "");
|
|
299
|
-
let parsed = null;
|
|
300
|
-
try {
|
|
301
|
-
parsed = text ? JSON.parse(text) : null;
|
|
302
|
-
} catch (e) {
|
|
303
|
-
}
|
|
304
|
-
const msg = (parsed == null ? void 0 : parsed.message) || (parsed == null ? void 0 : parsed.error) || `HTTP ${response.status}`;
|
|
305
|
-
throw { message: msg, status: response.status, details: parsed };
|
|
306
|
-
}
|
|
307
|
-
return response.json();
|
|
308
|
-
}
|
|
309
286
|
async function postBffAuth(url, body) {
|
|
310
287
|
const fetchFn = getFetch();
|
|
311
288
|
const response = await fetchFn(url, {
|
|
@@ -498,13 +475,12 @@ async function refreshTokenSilently2(authUrl, _projectId) {
|
|
|
498
475
|
if (_refreshPromise2) return _refreshPromise2;
|
|
499
476
|
_refreshPromise2 = (async () => {
|
|
500
477
|
try {
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
return normalizeResponse(tokens, authUrl);
|
|
478
|
+
const data = await postBffAuth(buildBffAuthEndpoint(authUrl, "/refresh-token"), {});
|
|
479
|
+
return {
|
|
480
|
+
token: data.token,
|
|
481
|
+
baseURL: data.baseURL || authUrl,
|
|
482
|
+
...data.integrationURL ? { integrationURL: data.integrationURL } : {}
|
|
483
|
+
};
|
|
508
484
|
} finally {
|
|
509
485
|
_refreshPromise2 = null;
|
|
510
486
|
}
|