next-auth-heksso 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.
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ export interface KeycloakSession {
|
|
|
5
5
|
getAccessToken: () => Promise<string>;
|
|
6
6
|
}
|
|
7
7
|
export declare const KeycloakSessionContext: React.Context<KeycloakSession>;
|
|
8
|
+
export declare function useKeycloakSession(): KeycloakSession;
|
|
8
9
|
export declare function KeycloakSessionProvider(props: {
|
|
9
10
|
children: ReactNode | ReactNode[];
|
|
10
11
|
signInPage?: string;
|
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.KeycloakSessionProvider = exports.KeycloakSessionContext = void 0;
|
|
35
|
+
exports.KeycloakSessionProvider = exports.useKeycloakSession = exports.KeycloakSessionContext = void 0;
|
|
36
36
|
const react_1 = require("next-auth/react");
|
|
37
37
|
const router_1 = require("next/router");
|
|
38
38
|
const react_2 = __importStar(require("react"));
|
|
@@ -43,6 +43,10 @@ exports.KeycloakSessionContext = (0, react_2.createContext)({
|
|
|
43
43
|
return "";
|
|
44
44
|
})
|
|
45
45
|
});
|
|
46
|
+
function useKeycloakSession() {
|
|
47
|
+
return (0, react_2.useContext)(exports.KeycloakSessionContext);
|
|
48
|
+
}
|
|
49
|
+
exports.useKeycloakSession = useKeycloakSession;
|
|
46
50
|
function refreshAccessToken() {
|
|
47
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
52
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { signOut, useSession } from "next-auth/react"
|
|
2
2
|
import { useRouter } from "next/router"
|
|
3
|
-
import React, { createContext, ReactNode, useCallback, useEffect, useMemo, useState } from "react"
|
|
3
|
+
import React, { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useState } from "react"
|
|
4
4
|
|
|
5
5
|
export interface KeycloakSession {
|
|
6
6
|
isAuthenticated: boolean
|
|
@@ -16,6 +16,10 @@ export const KeycloakSessionContext = createContext<KeycloakSession>({
|
|
|
16
16
|
}
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
+
export function useKeycloakSession() {
|
|
20
|
+
return useContext(KeycloakSessionContext)
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
async function refreshAccessToken() {
|
|
20
24
|
try {
|
|
21
25
|
const response = await fetch("/api/auth/session", {
|