@coreiam/auth 1.0.7 → 1.0.8

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.
@@ -16,9 +16,9 @@ const AuthContext = (0, react_1.createContext)({
16
16
  register: async () => ({ error: 'CoreIAMProvider is not mounted' }),
17
17
  refetchIdentity: async () => { },
18
18
  });
19
- function CoreIAMProvider({ children, initialIdentity = null, redirects = {}, }) {
20
- const [identity, setIdentity] = (0, react_1.useState)(initialIdentity);
21
- const [isLoading, setIsLoading] = (0, react_1.useState)(initialIdentity === null);
19
+ function CoreIAMProvider({ children, initialIdentity, redirects = {}, }) {
20
+ const [identity, setIdentity] = (0, react_1.useState)(initialIdentity ?? null);
21
+ const [isLoading, setIsLoading] = (0, react_1.useState)(initialIdentity === undefined);
22
22
  const router = (0, navigation_1.useRouter)();
23
23
  const refetchIdentity = async () => {
24
24
  try {
@@ -33,7 +33,16 @@ function CoreIAMProvider({ children, initialIdentity = null, redirects = {}, })
33
33
  }
34
34
  };
35
35
  (0, react_1.useEffect)(() => {
36
- if (initialIdentity === null) {
36
+ // FIX: was `initialIdentity === null`, which can't tell "SSR ran and
37
+ // confirmed you're logged out" (a correct, final null) apart from "no
38
+ // SSR value was ever provided" (a real undefined). Since layout.tsx
39
+ // always calls getSession() and passes its result — even when that
40
+ // result legitimately is null — every logged-out page view was
41
+ // treated as "no SSR value, fetch again," firing a second, wholly
42
+ // redundant /auth/profile call for something SSR had already
43
+ // determined. undefined (the prop genuinely omitted) is the only case
44
+ // that should trigger this fallback fetch.
45
+ if (initialIdentity === undefined) {
37
46
  refetchIdentity();
38
47
  }
39
48
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreiam/auth",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "main": "./dist/core/index.js",
5
5
  "types": "./dist/core/index.d.ts",
6
6
  "exports": {