codeforlife 2.7.1 → 2.7.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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/hooks/auth.tsx +15 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.7.2](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v2.7.1...v2.7.2) (2025-08-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* comment ([1364251](https://github.com/ocadotechnology/codeforlife-package-javascript/commit/13642516aea7a89d7c3e24e7813391686587447f))
|
|
7
|
+
|
|
1
8
|
## [2.7.1](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v2.7.0...v2.7.1) (2025-08-15)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/hooks/auth.tsx
CHANGED
|
@@ -31,14 +31,25 @@ export interface SessionMetadata {
|
|
|
31
31
|
otp_bypass_token_exists: boolean
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function useSessionMetadata
|
|
34
|
+
export function useSessionMetadata<T = SessionMetadata>(
|
|
35
|
+
cookieName = SESSION_METADATA_COOKIE_NAME,
|
|
36
|
+
): T | undefined {
|
|
35
37
|
return useSelector(selectIsLoggedIn)
|
|
36
|
-
? (JSON.parse(
|
|
37
|
-
Cookies.get(SESSION_METADATA_COOKIE_NAME)!,
|
|
38
|
-
) as SessionMetadata)
|
|
38
|
+
? (JSON.parse(Cookies.get(cookieName)!) as T)
|
|
39
39
|
: undefined
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* A utility function to predefine a useSessionMetadata hook.
|
|
44
|
+
* @param cookieName The name of the session metadata cookie.
|
|
45
|
+
* @returns An object containing the session metadata.
|
|
46
|
+
*/
|
|
47
|
+
useSessionMetadata.predefine = <SessionMetadata,>(
|
|
48
|
+
cookieName = SESSION_METADATA_COOKIE_NAME,
|
|
49
|
+
) => {
|
|
50
|
+
return () => useSessionMetadata<SessionMetadata>(cookieName)
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
export type UseSessionChildrenFunction<Required extends boolean> = (
|
|
43
54
|
metadata: Required extends true
|
|
44
55
|
? SessionMetadata
|