@asgardeo/react 0.16.1 → 0.17.0
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/cjs/index.js +29 -23
- package/dist/cjs/index.js.map +2 -2
- package/dist/index.js +45 -39
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
generateFlattenedUserProfile as generateFlattenedUserProfile2,
|
|
9
9
|
getBrandingPreference,
|
|
10
10
|
getActiveTheme,
|
|
11
|
-
Platform as
|
|
11
|
+
Platform as Platform4,
|
|
12
12
|
extractUserClaimsFromIdToken as extractUserClaimsFromIdToken2
|
|
13
13
|
} from "@asgardeo/browser";
|
|
14
14
|
import { useEffect as useEffect6, useMemo as useMemo7, useRef as useRef2, useState as useState8, useCallback as useCallback8 } from "react";
|
|
@@ -1106,7 +1106,7 @@ var FlowProvider = ({
|
|
|
1106
1106
|
var FlowProvider_default = FlowProvider;
|
|
1107
1107
|
|
|
1108
1108
|
// src/contexts/FlowMeta/FlowMetaProvider.tsx
|
|
1109
|
-
import { FlowMetaType, getFlowMetaV2 } from "@asgardeo/browser";
|
|
1109
|
+
import { FlowMetaType, getFlowMetaV2, Platform as Platform2 } from "@asgardeo/browser";
|
|
1110
1110
|
import { TranslationBundleConstants } from "@asgardeo/i18n";
|
|
1111
1111
|
import { useCallback as useCallback3, useEffect as useEffect2, useRef, useState as useState3 } from "react";
|
|
1112
1112
|
|
|
@@ -1165,7 +1165,7 @@ var FlowMetaProvider = ({
|
|
|
1165
1165
|
children,
|
|
1166
1166
|
enabled = true
|
|
1167
1167
|
}) => {
|
|
1168
|
-
const { baseUrl, applicationId } = useAsgardeo_default();
|
|
1168
|
+
const { baseUrl, applicationId, platform } = useAsgardeo_default();
|
|
1169
1169
|
const i18nContext = useI18n_default();
|
|
1170
1170
|
const [meta, setMeta] = useState3(null);
|
|
1171
1171
|
const [isLoading, setIsLoading] = useState3(false);
|
|
@@ -1173,7 +1173,7 @@ var FlowMetaProvider = ({
|
|
|
1173
1173
|
const [pendingLanguage, setPendingLanguage] = useState3(null);
|
|
1174
1174
|
const hasFetchedRef = useRef(false);
|
|
1175
1175
|
const fetchFlowMeta = useCallback3(async () => {
|
|
1176
|
-
if (!enabled) {
|
|
1176
|
+
if (!enabled || platform !== Platform2.AsgardeoV2) {
|
|
1177
1177
|
setMeta(null);
|
|
1178
1178
|
return;
|
|
1179
1179
|
}
|
|
@@ -1191,10 +1191,10 @@ var FlowMetaProvider = ({
|
|
|
1191
1191
|
} finally {
|
|
1192
1192
|
setIsLoading(false);
|
|
1193
1193
|
}
|
|
1194
|
-
}, [enabled, baseUrl, applicationId, i18nContext?.currentLanguage]);
|
|
1194
|
+
}, [enabled, platform, baseUrl, applicationId, i18nContext?.currentLanguage]);
|
|
1195
1195
|
const switchLanguage = useCallback3(
|
|
1196
1196
|
async (language) => {
|
|
1197
|
-
if (!enabled) return;
|
|
1197
|
+
if (!enabled || platform !== Platform2.AsgardeoV2) return;
|
|
1198
1198
|
setIsLoading(true);
|
|
1199
1199
|
setError(null);
|
|
1200
1200
|
try {
|
|
@@ -1221,7 +1221,7 @@ var FlowMetaProvider = ({
|
|
|
1221
1221
|
setIsLoading(false);
|
|
1222
1222
|
}
|
|
1223
1223
|
},
|
|
1224
|
-
[enabled, baseUrl, applicationId, i18nContext]
|
|
1224
|
+
[enabled, platform, baseUrl, applicationId, i18nContext]
|
|
1225
1225
|
);
|
|
1226
1226
|
useEffect2(() => {
|
|
1227
1227
|
if (pendingLanguage && i18nContext?.setLanguage) {
|
|
@@ -1593,7 +1593,7 @@ var OrganizationProvider_default = OrganizationProvider;
|
|
|
1593
1593
|
|
|
1594
1594
|
// src/contexts/Theme/ThemeProvider.tsx
|
|
1595
1595
|
import {
|
|
1596
|
-
Platform as
|
|
1596
|
+
Platform as Platform3
|
|
1597
1597
|
} from "@asgardeo/browser";
|
|
1598
1598
|
|
|
1599
1599
|
// src/contexts/Theme/v1/ThemeProvider.tsx
|
|
@@ -1939,7 +1939,7 @@ var ThemeProvider3 = ({
|
|
|
1939
1939
|
mode
|
|
1940
1940
|
}) => {
|
|
1941
1941
|
const { platform } = useAsgardeo_default();
|
|
1942
|
-
if (platform ===
|
|
1942
|
+
if (platform === Platform3.AsgardeoV2) {
|
|
1943
1943
|
const v2Props = { theme };
|
|
1944
1944
|
return /* @__PURE__ */ jsx8(ThemeProvider_default2, { ...v2Props, children });
|
|
1945
1945
|
}
|
|
@@ -2063,7 +2063,7 @@ var AsgardeoProvider = ({
|
|
|
2063
2063
|
resolvedBaseUrl = `${(await asgardeo.getConfiguration()).baseUrl}/o`;
|
|
2064
2064
|
setBaseUrl(resolvedBaseUrl);
|
|
2065
2065
|
}
|
|
2066
|
-
if (config.platform ===
|
|
2066
|
+
if (config.platform === Platform4.AsgardeoV2) {
|
|
2067
2067
|
const claims = extractUserClaimsFromIdToken2(decodedToken);
|
|
2068
2068
|
setUser(claims);
|
|
2069
2069
|
setUserProfile({
|
|
@@ -2072,25 +2072,31 @@ var AsgardeoProvider = ({
|
|
|
2072
2072
|
schemas: []
|
|
2073
2073
|
});
|
|
2074
2074
|
} else {
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
setCurrentOrganization(fetchedOrganization);
|
|
2088
|
-
} catch (error) {
|
|
2075
|
+
const shouldFetchUserProfile = preferences?.user?.fetchUserProfile !== false;
|
|
2076
|
+
if (shouldFetchUserProfile) {
|
|
2077
|
+
try {
|
|
2078
|
+
const fetchedUser = await asgardeo.getUser({ baseUrl: resolvedBaseUrl });
|
|
2079
|
+
setUser(fetchedUser);
|
|
2080
|
+
} catch (error) {
|
|
2081
|
+
}
|
|
2082
|
+
try {
|
|
2083
|
+
const fetchedUserProfile = await asgardeo.getUserProfile({ baseUrl: resolvedBaseUrl });
|
|
2084
|
+
setUserProfile(fetchedUserProfile);
|
|
2085
|
+
} catch (error) {
|
|
2086
|
+
}
|
|
2089
2087
|
}
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2088
|
+
const shouldFetchOrganizations = preferences?.user?.fetchOrganizations !== false;
|
|
2089
|
+
if (shouldFetchOrganizations) {
|
|
2090
|
+
try {
|
|
2091
|
+
const fetchedOrganization = await asgardeo.getCurrentOrganization();
|
|
2092
|
+
setCurrentOrganization(fetchedOrganization);
|
|
2093
|
+
} catch (error) {
|
|
2094
|
+
}
|
|
2095
|
+
try {
|
|
2096
|
+
const fetchedMyOrganizations = await asgardeo.getMyOrganizations();
|
|
2097
|
+
setMyOrganizations(fetchedMyOrganizations);
|
|
2098
|
+
} catch (error) {
|
|
2099
|
+
}
|
|
2094
2100
|
}
|
|
2095
2101
|
}
|
|
2096
2102
|
const currentSignInStatus = await asgardeo.isSignedIn();
|
|
@@ -2103,7 +2109,7 @@ var AsgardeoProvider = ({
|
|
|
2103
2109
|
}
|
|
2104
2110
|
async function signIn(...args) {
|
|
2105
2111
|
const arg1 = args[0];
|
|
2106
|
-
const isV2FlowRequest = config.platform ===
|
|
2112
|
+
const isV2FlowRequest = config.platform === Platform4.AsgardeoV2 && typeof arg1 === "object" && arg1 !== null && ("flowId" in arg1 || "applicationId" in arg1);
|
|
2107
2113
|
try {
|
|
2108
2114
|
if (!isV2FlowRequest) {
|
|
2109
2115
|
setIsUpdatingSession(true);
|
|
@@ -2144,7 +2150,7 @@ var AsgardeoProvider = ({
|
|
|
2144
2150
|
}
|
|
2145
2151
|
const currentUrl = new URL(window.location.href);
|
|
2146
2152
|
const hasAuthParamsResult = hasAuthParams(currentUrl, afterSignInUrl) && hasCalledForThisInstance(currentUrl, instanceId ?? 0);
|
|
2147
|
-
const isV2Platform = config.platform ===
|
|
2153
|
+
const isV2Platform = config.platform === Platform4.AsgardeoV2;
|
|
2148
2154
|
if (hasAuthParamsResult) {
|
|
2149
2155
|
try {
|
|
2150
2156
|
if (isV2Platform) {
|
|
@@ -2260,7 +2266,7 @@ var AsgardeoProvider = ({
|
|
|
2260
2266
|
await fetchBranding();
|
|
2261
2267
|
}, [fetchBranding]);
|
|
2262
2268
|
useEffect6(() => {
|
|
2263
|
-
if (config.platform ===
|
|
2269
|
+
if (config.platform === Platform4.AsgardeoV2) {
|
|
2264
2270
|
return;
|
|
2265
2271
|
}
|
|
2266
2272
|
const shouldFetchBranding = preferences?.theme?.inheritFromBranding !== false;
|
|
@@ -3667,7 +3673,7 @@ var OrganizationContext2 = ({
|
|
|
3667
3673
|
var OrganizationContext_default2 = OrganizationContext2;
|
|
3668
3674
|
|
|
3669
3675
|
// src/components/presentation/auth/SignIn/BaseSignIn.tsx
|
|
3670
|
-
import { Platform as
|
|
3676
|
+
import { Platform as Platform5 } from "@asgardeo/browser";
|
|
3671
3677
|
|
|
3672
3678
|
// src/components/presentation/auth/SignIn/v1/BaseSignIn.tsx
|
|
3673
3679
|
import {
|
|
@@ -8975,7 +8981,7 @@ var BaseSignIn_default2 = BaseSignIn2;
|
|
|
8975
8981
|
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
8976
8982
|
var BaseSignIn3 = (props) => {
|
|
8977
8983
|
const { platform } = useAsgardeo_default();
|
|
8978
|
-
if (platform ===
|
|
8984
|
+
if (platform === Platform5.AsgardeoV2) {
|
|
8979
8985
|
return /* @__PURE__ */ jsx69(BaseSignIn_default2, { ...props });
|
|
8980
8986
|
}
|
|
8981
8987
|
return /* @__PURE__ */ jsx69(BaseSignIn_default, { ...props });
|
|
@@ -8984,7 +8990,7 @@ var BaseSignIn_default3 = BaseSignIn3;
|
|
|
8984
8990
|
|
|
8985
8991
|
// src/components/presentation/auth/SignIn/SignIn.tsx
|
|
8986
8992
|
import {
|
|
8987
|
-
Platform as
|
|
8993
|
+
Platform as Platform6
|
|
8988
8994
|
} from "@asgardeo/browser";
|
|
8989
8995
|
|
|
8990
8996
|
// src/components/presentation/auth/SignIn/v2/SignIn.tsx
|
|
@@ -9733,7 +9739,7 @@ var SignIn2 = ({ className, size = "medium", children, preferences, ...rest }) =
|
|
|
9733
9739
|
window.location.href = url.toString();
|
|
9734
9740
|
}
|
|
9735
9741
|
};
|
|
9736
|
-
if (platform ===
|
|
9742
|
+
if (platform === Platform6.AsgardeoV2) {
|
|
9737
9743
|
return /* @__PURE__ */ jsx71(
|
|
9738
9744
|
SignIn_default,
|
|
9739
9745
|
{
|
|
@@ -9768,7 +9774,7 @@ var SignIn2 = ({ className, size = "medium", children, preferences, ...rest }) =
|
|
|
9768
9774
|
var SignIn_default2 = SignIn2;
|
|
9769
9775
|
|
|
9770
9776
|
// src/components/presentation/auth/SignUp/BaseSignUp.tsx
|
|
9771
|
-
import { Platform as
|
|
9777
|
+
import { Platform as Platform7 } from "@asgardeo/browser";
|
|
9772
9778
|
|
|
9773
9779
|
// src/components/presentation/auth/SignUp/v1/BaseSignUp.tsx
|
|
9774
9780
|
import {
|
|
@@ -11507,7 +11513,7 @@ var BaseSignUp_default2 = BaseSignUp2;
|
|
|
11507
11513
|
import { jsx as jsx80 } from "react/jsx-runtime";
|
|
11508
11514
|
var BaseSignUp3 = (props) => {
|
|
11509
11515
|
const { platform } = useAsgardeo_default();
|
|
11510
|
-
if (platform ===
|
|
11516
|
+
if (platform === Platform7.AsgardeoV2) {
|
|
11511
11517
|
return /* @__PURE__ */ jsx80(BaseSignUp_default2, { ...props });
|
|
11512
11518
|
}
|
|
11513
11519
|
return /* @__PURE__ */ jsx80(BaseSignUp_default, { ...props });
|
|
@@ -11515,7 +11521,7 @@ var BaseSignUp3 = (props) => {
|
|
|
11515
11521
|
var BaseSignUp_default3 = BaseSignUp3;
|
|
11516
11522
|
|
|
11517
11523
|
// src/components/presentation/auth/SignUp/SignUp.tsx
|
|
11518
|
-
import { Platform as
|
|
11524
|
+
import { Platform as Platform8 } from "@asgardeo/browser";
|
|
11519
11525
|
|
|
11520
11526
|
// src/components/presentation/auth/SignUp/v1/SignUp.tsx
|
|
11521
11527
|
import {
|
|
@@ -11639,7 +11645,7 @@ var SignUp_default2 = SignUp2;
|
|
|
11639
11645
|
import { jsx as jsx83 } from "react/jsx-runtime";
|
|
11640
11646
|
var SignUp3 = (props) => {
|
|
11641
11647
|
const { platform } = useAsgardeo_default();
|
|
11642
|
-
if (platform ===
|
|
11648
|
+
if (platform === Platform8.AsgardeoV2) {
|
|
11643
11649
|
return /* @__PURE__ */ jsx83(SignUp_default2, { ...props });
|
|
11644
11650
|
}
|
|
11645
11651
|
return /* @__PURE__ */ jsx83(SignUp_default, { ...props });
|