@asgardeo/react 0.16.0 → 0.16.2
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/AsgardeoReactClient.d.ts +1 -0
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/index.js +25 -21
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
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";
|
|
@@ -575,6 +575,7 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
575
575
|
__publicField(this, "asgardeo");
|
|
576
576
|
__publicField(this, "loadingState", false);
|
|
577
577
|
__publicField(this, "clientInstanceId");
|
|
578
|
+
__publicField(this, "initializeConfig");
|
|
578
579
|
this.clientInstanceId = instanceId;
|
|
579
580
|
this.asgardeo = new api_default(void 0, instanceId);
|
|
580
581
|
}
|
|
@@ -796,6 +797,9 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
796
797
|
const arg1 = args[0];
|
|
797
798
|
const arg2 = args[1];
|
|
798
799
|
const config = await this.asgardeo.getConfigData();
|
|
800
|
+
if (!config || Object.keys(config).length === 0) {
|
|
801
|
+
await this.initialize(this.initializeConfig);
|
|
802
|
+
}
|
|
799
803
|
const isV2Platform = config && config.platform === Platform.AsgardeoV2;
|
|
800
804
|
if (isV2Platform && typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) {
|
|
801
805
|
return void 0;
|
|
@@ -1102,7 +1106,7 @@ var FlowProvider = ({
|
|
|
1102
1106
|
var FlowProvider_default = FlowProvider;
|
|
1103
1107
|
|
|
1104
1108
|
// src/contexts/FlowMeta/FlowMetaProvider.tsx
|
|
1105
|
-
import { FlowMetaType, getFlowMetaV2 } from "@asgardeo/browser";
|
|
1109
|
+
import { FlowMetaType, getFlowMetaV2, Platform as Platform2 } from "@asgardeo/browser";
|
|
1106
1110
|
import { TranslationBundleConstants } from "@asgardeo/i18n";
|
|
1107
1111
|
import { useCallback as useCallback3, useEffect as useEffect2, useRef, useState as useState3 } from "react";
|
|
1108
1112
|
|
|
@@ -1161,7 +1165,7 @@ var FlowMetaProvider = ({
|
|
|
1161
1165
|
children,
|
|
1162
1166
|
enabled = true
|
|
1163
1167
|
}) => {
|
|
1164
|
-
const { baseUrl, applicationId } = useAsgardeo_default();
|
|
1168
|
+
const { baseUrl, applicationId, platform } = useAsgardeo_default();
|
|
1165
1169
|
const i18nContext = useI18n_default();
|
|
1166
1170
|
const [meta, setMeta] = useState3(null);
|
|
1167
1171
|
const [isLoading, setIsLoading] = useState3(false);
|
|
@@ -1169,7 +1173,7 @@ var FlowMetaProvider = ({
|
|
|
1169
1173
|
const [pendingLanguage, setPendingLanguage] = useState3(null);
|
|
1170
1174
|
const hasFetchedRef = useRef(false);
|
|
1171
1175
|
const fetchFlowMeta = useCallback3(async () => {
|
|
1172
|
-
if (!enabled) {
|
|
1176
|
+
if (!enabled || platform !== Platform2.AsgardeoV2) {
|
|
1173
1177
|
setMeta(null);
|
|
1174
1178
|
return;
|
|
1175
1179
|
}
|
|
@@ -1187,10 +1191,10 @@ var FlowMetaProvider = ({
|
|
|
1187
1191
|
} finally {
|
|
1188
1192
|
setIsLoading(false);
|
|
1189
1193
|
}
|
|
1190
|
-
}, [enabled, baseUrl, applicationId, i18nContext?.currentLanguage]);
|
|
1194
|
+
}, [enabled, platform, baseUrl, applicationId, i18nContext?.currentLanguage]);
|
|
1191
1195
|
const switchLanguage = useCallback3(
|
|
1192
1196
|
async (language) => {
|
|
1193
|
-
if (!enabled) return;
|
|
1197
|
+
if (!enabled || platform !== Platform2.AsgardeoV2) return;
|
|
1194
1198
|
setIsLoading(true);
|
|
1195
1199
|
setError(null);
|
|
1196
1200
|
try {
|
|
@@ -1217,7 +1221,7 @@ var FlowMetaProvider = ({
|
|
|
1217
1221
|
setIsLoading(false);
|
|
1218
1222
|
}
|
|
1219
1223
|
},
|
|
1220
|
-
[enabled, baseUrl, applicationId, i18nContext]
|
|
1224
|
+
[enabled, platform, baseUrl, applicationId, i18nContext]
|
|
1221
1225
|
);
|
|
1222
1226
|
useEffect2(() => {
|
|
1223
1227
|
if (pendingLanguage && i18nContext?.setLanguage) {
|
|
@@ -1589,7 +1593,7 @@ var OrganizationProvider_default = OrganizationProvider;
|
|
|
1589
1593
|
|
|
1590
1594
|
// src/contexts/Theme/ThemeProvider.tsx
|
|
1591
1595
|
import {
|
|
1592
|
-
Platform as
|
|
1596
|
+
Platform as Platform3
|
|
1593
1597
|
} from "@asgardeo/browser";
|
|
1594
1598
|
|
|
1595
1599
|
// src/contexts/Theme/v1/ThemeProvider.tsx
|
|
@@ -1935,7 +1939,7 @@ var ThemeProvider3 = ({
|
|
|
1935
1939
|
mode
|
|
1936
1940
|
}) => {
|
|
1937
1941
|
const { platform } = useAsgardeo_default();
|
|
1938
|
-
if (platform ===
|
|
1942
|
+
if (platform === Platform3.AsgardeoV2) {
|
|
1939
1943
|
const v2Props = { theme };
|
|
1940
1944
|
return /* @__PURE__ */ jsx8(ThemeProvider_default2, { ...v2Props, children });
|
|
1941
1945
|
}
|
|
@@ -2059,7 +2063,7 @@ var AsgardeoProvider = ({
|
|
|
2059
2063
|
resolvedBaseUrl = `${(await asgardeo.getConfiguration()).baseUrl}/o`;
|
|
2060
2064
|
setBaseUrl(resolvedBaseUrl);
|
|
2061
2065
|
}
|
|
2062
|
-
if (config.platform ===
|
|
2066
|
+
if (config.platform === Platform4.AsgardeoV2) {
|
|
2063
2067
|
const claims = extractUserClaimsFromIdToken2(decodedToken);
|
|
2064
2068
|
setUser(claims);
|
|
2065
2069
|
setUserProfile({
|
|
@@ -2099,7 +2103,7 @@ var AsgardeoProvider = ({
|
|
|
2099
2103
|
}
|
|
2100
2104
|
async function signIn(...args) {
|
|
2101
2105
|
const arg1 = args[0];
|
|
2102
|
-
const isV2FlowRequest = config.platform ===
|
|
2106
|
+
const isV2FlowRequest = config.platform === Platform4.AsgardeoV2 && typeof arg1 === "object" && arg1 !== null && ("flowId" in arg1 || "applicationId" in arg1);
|
|
2103
2107
|
try {
|
|
2104
2108
|
if (!isV2FlowRequest) {
|
|
2105
2109
|
setIsUpdatingSession(true);
|
|
@@ -2140,7 +2144,7 @@ var AsgardeoProvider = ({
|
|
|
2140
2144
|
}
|
|
2141
2145
|
const currentUrl = new URL(window.location.href);
|
|
2142
2146
|
const hasAuthParamsResult = hasAuthParams(currentUrl, afterSignInUrl) && hasCalledForThisInstance(currentUrl, instanceId ?? 0);
|
|
2143
|
-
const isV2Platform = config.platform ===
|
|
2147
|
+
const isV2Platform = config.platform === Platform4.AsgardeoV2;
|
|
2144
2148
|
if (hasAuthParamsResult) {
|
|
2145
2149
|
try {
|
|
2146
2150
|
if (isV2Platform) {
|
|
@@ -2256,7 +2260,7 @@ var AsgardeoProvider = ({
|
|
|
2256
2260
|
await fetchBranding();
|
|
2257
2261
|
}, [fetchBranding]);
|
|
2258
2262
|
useEffect6(() => {
|
|
2259
|
-
if (config.platform ===
|
|
2263
|
+
if (config.platform === Platform4.AsgardeoV2) {
|
|
2260
2264
|
return;
|
|
2261
2265
|
}
|
|
2262
2266
|
const shouldFetchBranding = preferences?.theme?.inheritFromBranding !== false;
|
|
@@ -3663,7 +3667,7 @@ var OrganizationContext2 = ({
|
|
|
3663
3667
|
var OrganizationContext_default2 = OrganizationContext2;
|
|
3664
3668
|
|
|
3665
3669
|
// src/components/presentation/auth/SignIn/BaseSignIn.tsx
|
|
3666
|
-
import { Platform as
|
|
3670
|
+
import { Platform as Platform5 } from "@asgardeo/browser";
|
|
3667
3671
|
|
|
3668
3672
|
// src/components/presentation/auth/SignIn/v1/BaseSignIn.tsx
|
|
3669
3673
|
import {
|
|
@@ -8971,7 +8975,7 @@ var BaseSignIn_default2 = BaseSignIn2;
|
|
|
8971
8975
|
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
8972
8976
|
var BaseSignIn3 = (props) => {
|
|
8973
8977
|
const { platform } = useAsgardeo_default();
|
|
8974
|
-
if (platform ===
|
|
8978
|
+
if (platform === Platform5.AsgardeoV2) {
|
|
8975
8979
|
return /* @__PURE__ */ jsx69(BaseSignIn_default2, { ...props });
|
|
8976
8980
|
}
|
|
8977
8981
|
return /* @__PURE__ */ jsx69(BaseSignIn_default, { ...props });
|
|
@@ -8980,7 +8984,7 @@ var BaseSignIn_default3 = BaseSignIn3;
|
|
|
8980
8984
|
|
|
8981
8985
|
// src/components/presentation/auth/SignIn/SignIn.tsx
|
|
8982
8986
|
import {
|
|
8983
|
-
Platform as
|
|
8987
|
+
Platform as Platform6
|
|
8984
8988
|
} from "@asgardeo/browser";
|
|
8985
8989
|
|
|
8986
8990
|
// src/components/presentation/auth/SignIn/v2/SignIn.tsx
|
|
@@ -9729,7 +9733,7 @@ var SignIn2 = ({ className, size = "medium", children, preferences, ...rest }) =
|
|
|
9729
9733
|
window.location.href = url.toString();
|
|
9730
9734
|
}
|
|
9731
9735
|
};
|
|
9732
|
-
if (platform ===
|
|
9736
|
+
if (platform === Platform6.AsgardeoV2) {
|
|
9733
9737
|
return /* @__PURE__ */ jsx71(
|
|
9734
9738
|
SignIn_default,
|
|
9735
9739
|
{
|
|
@@ -9764,7 +9768,7 @@ var SignIn2 = ({ className, size = "medium", children, preferences, ...rest }) =
|
|
|
9764
9768
|
var SignIn_default2 = SignIn2;
|
|
9765
9769
|
|
|
9766
9770
|
// src/components/presentation/auth/SignUp/BaseSignUp.tsx
|
|
9767
|
-
import { Platform as
|
|
9771
|
+
import { Platform as Platform7 } from "@asgardeo/browser";
|
|
9768
9772
|
|
|
9769
9773
|
// src/components/presentation/auth/SignUp/v1/BaseSignUp.tsx
|
|
9770
9774
|
import {
|
|
@@ -11503,7 +11507,7 @@ var BaseSignUp_default2 = BaseSignUp2;
|
|
|
11503
11507
|
import { jsx as jsx80 } from "react/jsx-runtime";
|
|
11504
11508
|
var BaseSignUp3 = (props) => {
|
|
11505
11509
|
const { platform } = useAsgardeo_default();
|
|
11506
|
-
if (platform ===
|
|
11510
|
+
if (platform === Platform7.AsgardeoV2) {
|
|
11507
11511
|
return /* @__PURE__ */ jsx80(BaseSignUp_default2, { ...props });
|
|
11508
11512
|
}
|
|
11509
11513
|
return /* @__PURE__ */ jsx80(BaseSignUp_default, { ...props });
|
|
@@ -11511,7 +11515,7 @@ var BaseSignUp3 = (props) => {
|
|
|
11511
11515
|
var BaseSignUp_default3 = BaseSignUp3;
|
|
11512
11516
|
|
|
11513
11517
|
// src/components/presentation/auth/SignUp/SignUp.tsx
|
|
11514
|
-
import { Platform as
|
|
11518
|
+
import { Platform as Platform8 } from "@asgardeo/browser";
|
|
11515
11519
|
|
|
11516
11520
|
// src/components/presentation/auth/SignUp/v1/SignUp.tsx
|
|
11517
11521
|
import {
|
|
@@ -11635,7 +11639,7 @@ var SignUp_default2 = SignUp2;
|
|
|
11635
11639
|
import { jsx as jsx83 } from "react/jsx-runtime";
|
|
11636
11640
|
var SignUp3 = (props) => {
|
|
11637
11641
|
const { platform } = useAsgardeo_default();
|
|
11638
|
-
if (platform ===
|
|
11642
|
+
if (platform === Platform8.AsgardeoV2) {
|
|
11639
11643
|
return /* @__PURE__ */ jsx83(SignUp_default2, { ...props });
|
|
11640
11644
|
}
|
|
11641
11645
|
return /* @__PURE__ */ jsx83(SignUp_default, { ...props });
|