@enterprisestandard/react 0.0.3-beta.1 → 0.0.3-beta.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/index.js +22 -8
- package/dist/ui/sign-in-loading.d.ts +1 -1
- package/dist/ui/signed-in.d.ts +1 -1
- package/dist/ui/signed-out.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -232,8 +232,9 @@ function sso(config) {
|
|
|
232
232
|
}
|
|
233
233
|
async function fetchJwks() {
|
|
234
234
|
const url = configWithDefaults.jwks_uri || `${configWithDefaults.authority}/protocol/openid-connect/certs`;
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
const cached = jwksCache.get(url);
|
|
236
|
+
if (cached)
|
|
237
|
+
return cached;
|
|
237
238
|
return retryWithBackoff(async () => {
|
|
238
239
|
if (!configWithDefaults)
|
|
239
240
|
throw new Error("SSO Manager not initialized");
|
|
@@ -616,7 +617,7 @@ function SignInLoading({ complete = false, children }) {
|
|
|
616
617
|
return /* @__PURE__ */ jsxDEV(Fragment, {
|
|
617
618
|
children
|
|
618
619
|
}, undefined, false, undefined, this);
|
|
619
|
-
return
|
|
620
|
+
return null;
|
|
620
621
|
}
|
|
621
622
|
// src/ui/signed-in.tsx
|
|
622
623
|
import { jsxDEV as jsxDEV2, Fragment as Fragment2 } from "react/jsx-dev-runtime";
|
|
@@ -626,14 +627,14 @@ function SignedIn({ children }) {
|
|
|
626
627
|
return /* @__PURE__ */ jsxDEV2(Fragment2, {
|
|
627
628
|
children
|
|
628
629
|
}, undefined, false, undefined, this);
|
|
629
|
-
return
|
|
630
|
+
return null;
|
|
630
631
|
}
|
|
631
632
|
// src/ui/signed-out.tsx
|
|
632
633
|
import { jsxDEV as jsxDEV3, Fragment as Fragment3 } from "react/jsx-dev-runtime";
|
|
633
634
|
function SignedOut({ children }) {
|
|
634
635
|
const { user } = useUser();
|
|
635
636
|
if (user)
|
|
636
|
-
return
|
|
637
|
+
return null;
|
|
637
638
|
return /* @__PURE__ */ jsxDEV3(Fragment3, {
|
|
638
639
|
children
|
|
639
640
|
}, undefined, false, undefined, this);
|
|
@@ -707,6 +708,12 @@ function SSOProvider({
|
|
|
707
708
|
setIsLoading(true);
|
|
708
709
|
try {
|
|
709
710
|
const response = await fetch(userUrl);
|
|
711
|
+
if (response.status === 401) {
|
|
712
|
+
setUserState(null);
|
|
713
|
+
saveUserToStorage(null);
|
|
714
|
+
setIsLoading(false);
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
710
717
|
if (!response.ok) {
|
|
711
718
|
throw new Error(`Failed to fetch user: ${response.status} ${response.statusText}`);
|
|
712
719
|
}
|
|
@@ -728,8 +735,8 @@ function SSOProvider({
|
|
|
728
735
|
const storedUser = loadUserFromStorage();
|
|
729
736
|
if (storedUser) {
|
|
730
737
|
setUserState(storedUser);
|
|
731
|
-
|
|
732
|
-
|
|
738
|
+
}
|
|
739
|
+
if (userUrl) {
|
|
733
740
|
fetchUserFromUrl();
|
|
734
741
|
} else {
|
|
735
742
|
setIsLoading(false);
|
|
@@ -799,6 +806,13 @@ function useToken() {
|
|
|
799
806
|
setError(null);
|
|
800
807
|
try {
|
|
801
808
|
const response = await fetch(url);
|
|
809
|
+
if (response.status === 401) {
|
|
810
|
+
context.setUser(null);
|
|
811
|
+
setToken(null);
|
|
812
|
+
setExpires(null);
|
|
813
|
+
setIsLoading(false);
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
802
816
|
if (!response.ok) {
|
|
803
817
|
throw new Error(`Failed to fetch JWT: ${response.status} ${response.statusText}`);
|
|
804
818
|
}
|
|
@@ -814,7 +828,7 @@ function useToken() {
|
|
|
814
828
|
} finally {
|
|
815
829
|
setIsLoading(false);
|
|
816
830
|
}
|
|
817
|
-
}, []);
|
|
831
|
+
}, [context]);
|
|
818
832
|
const refresh = useCallback(async () => {
|
|
819
833
|
const url = refreshUrl || tokenUrl;
|
|
820
834
|
if (!url) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
2
|
export declare function SignInLoading({ complete, children }: {
|
|
3
3
|
complete?: boolean;
|
|
4
|
-
} & PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
} & PropsWithChildren): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/ui/signed-in.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
export declare function SignedIn({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function SignedIn({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/ui/signed-out.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
export declare function SignedOut({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function SignedOut({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element | null;
|