mitra-interactions-sdk 1.0.60-beta.45 → 1.0.60-beta.47
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 +24 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -64,12 +64,32 @@ var POPUP_W = 480;
|
|
|
64
64
|
var POPUP_H = 600;
|
|
65
65
|
var POPUP_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
66
66
|
var SSO_AUTH_PAGE_URL = "https://beta.infusion.cloud/sdk-auth.html";
|
|
67
|
-
async function fetchSsoAuthPageUrl(
|
|
67
|
+
async function fetchSsoAuthPageUrl(baseURL, projectId) {
|
|
68
68
|
const config = isConfigured() ? getConfig() : null;
|
|
69
69
|
if (config == null ? void 0 : config.authPageUrl) return config.authPageUrl;
|
|
70
|
+
const discovered = await discoverSsoAuthPageUrl(baseURL, projectId);
|
|
71
|
+
if (discovered) return discovered;
|
|
72
|
+
const injected = readInjectedEnv().authPageUrl;
|
|
73
|
+
if (injected) return injected;
|
|
70
74
|
return SSO_AUTH_PAGE_URL;
|
|
71
75
|
}
|
|
72
|
-
|
|
76
|
+
async function discoverSsoAuthPageUrl(baseURL, projectId) {
|
|
77
|
+
if (!baseURL || !projectId) return null;
|
|
78
|
+
try {
|
|
79
|
+
const path = `/sso/config?projectId=${encodeURIComponent(projectId)}`;
|
|
80
|
+
const response = await getFetch()(buildBffAuthEndpoint(baseURL, path), {
|
|
81
|
+
method: "GET",
|
|
82
|
+
headers: { accept: "application/json" }
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) return null;
|
|
85
|
+
const data = await response.json().catch(() => null);
|
|
86
|
+
const url = data && typeof data.authPageUrl === "string" ? data.authPageUrl : "";
|
|
87
|
+
return url || null;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
var SSO_ENABLED_PROVIDERS = ["google", "microsoft"];
|
|
73
93
|
function providerLabel(provider) {
|
|
74
94
|
return provider === "microsoft" ? "Microsoft" : provider === "google" ? "Google" : provider;
|
|
75
95
|
}
|
|
@@ -224,7 +244,7 @@ async function loginWithProvider(provider, options) {
|
|
|
224
244
|
const { authUrl, projectId } = resolveLoginOptions(options);
|
|
225
245
|
const state = generateState();
|
|
226
246
|
const appId = String(projectId);
|
|
227
|
-
const authPageUrl = await fetchSsoAuthPageUrl(authUrl);
|
|
247
|
+
const authPageUrl = await fetchSsoAuthPageUrl(authUrl, appId);
|
|
228
248
|
const pageOrigin = getOriginFromUrl(authPageUrl);
|
|
229
249
|
const redirectUri = stripToOriginPath(authPageUrl);
|
|
230
250
|
const startUrl = buildStartUrl(authPageUrl, provider, state, appId, authUrl);
|
|
@@ -248,7 +268,7 @@ async function startSsoRedirect(provider, options) {
|
|
|
248
268
|
const { authUrl, projectId } = resolveLoginOptions(options);
|
|
249
269
|
const state = generateState();
|
|
250
270
|
const appId = String(projectId);
|
|
251
|
-
const authPageUrl = await fetchSsoAuthPageUrl();
|
|
271
|
+
const authPageUrl = await fetchSsoAuthPageUrl(authUrl, appId);
|
|
252
272
|
const redirectUri = stripToOriginPath(authPageUrl);
|
|
253
273
|
persistRedirectContext({
|
|
254
274
|
state,
|