mitra-interactions-sdk 1.0.60-beta.2 → 1.0.60-beta.3
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 +8 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -347,7 +347,7 @@ async function fetchSsoAuthPageUrl(_baseURL) {
|
|
|
347
347
|
}
|
|
348
348
|
function buildStartUrl(authPageUrl, provider, state, appId, apiUrl) {
|
|
349
349
|
const sep = authPageUrl.includes("?") ? "&" : "?";
|
|
350
|
-
return authPageUrl + sep + new URLSearchParams({ provider, state, appId, apiUrl }).toString();
|
|
350
|
+
return authPageUrl + sep + new URLSearchParams({ provider, state, appId, apiUrl, origin: window.location.origin }).toString();
|
|
351
351
|
}
|
|
352
352
|
function getOriginFromUrl2(url) {
|
|
353
353
|
try {
|
|
@@ -370,6 +370,7 @@ function openOAuthPopup(providerUrl, expectedOrigin, expectedState) {
|
|
|
370
370
|
const outerH = window.outerHeight || screen.height;
|
|
371
371
|
const left = Math.max(0, (window.screenX || 0) + (outerW - POPUP_W) / 2);
|
|
372
372
|
const top = Math.max(0, (window.screenY || 0) + (outerH - POPUP_H) / 2);
|
|
373
|
+
console.log("[mitra-sso] window.open ->", providerUrl);
|
|
373
374
|
const popup = window.open(
|
|
374
375
|
providerUrl,
|
|
375
376
|
"mitra-oauth",
|
|
@@ -404,11 +405,11 @@ function openOAuthPopup(providerUrl, expectedOrigin, expectedState) {
|
|
|
404
405
|
reject(new Error(data.error || "Erro na autentica\xE7\xE3o OAuth."));
|
|
405
406
|
return;
|
|
406
407
|
}
|
|
407
|
-
if (!data.
|
|
408
|
-
reject(new Error("Resposta OAuth sem
|
|
408
|
+
if (!data.token) {
|
|
409
|
+
reject(new Error("Resposta OAuth sem token."));
|
|
409
410
|
return;
|
|
410
411
|
}
|
|
411
|
-
resolve({
|
|
412
|
+
resolve({ token: data.token });
|
|
412
413
|
}
|
|
413
414
|
function cleanup() {
|
|
414
415
|
clearTimeout(timer);
|
|
@@ -437,13 +438,9 @@ async function loginWithProvider(provider, options) {
|
|
|
437
438
|
const pageOrigin = getOriginFromUrl2(authPageUrl);
|
|
438
439
|
const redirectUri = authPageUrl;
|
|
439
440
|
const startUrl = buildStartUrl(authPageUrl, provider, state, appId, authUrl);
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
redirectUri,
|
|
444
|
-
appId
|
|
445
|
-
});
|
|
446
|
-
const response = normalizeResponse(tokens, authUrl);
|
|
441
|
+
console.log("[mitra-sso] authPageUrl:", authPageUrl, "| startUrl:", startUrl, "| redirectUri:", redirectUri);
|
|
442
|
+
const { token } = await openOAuthPopup(startUrl, pageOrigin, state);
|
|
443
|
+
const response = normalizeResponse(token, authUrl);
|
|
447
444
|
autoConfigureFromLogin2(response, authUrl, projectId);
|
|
448
445
|
return response;
|
|
449
446
|
} finally {
|