@multiplatform.one/keycloak 0.7.17 → 1.0.1
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/lib/Authenticated.d.mts +2 -3
- package/lib/Authenticated.d.ts +2 -3
- package/lib/Authenticated.js +4 -4
- package/lib/Authenticated.mjs +3 -3
- package/lib/apollo.d.mts +7 -0
- package/lib/apollo.d.ts +7 -0
- package/lib/apollo.js +15 -0
- package/lib/apollo.mjs +15 -0
- package/lib/chunk-267L3NLO.mjs +53 -0
- package/lib/{chunk-NH335CDK.js → chunk-2VGMJ7WP.js} +7 -5
- package/lib/{chunk-Y23BWOII.mjs → chunk-3KAZ37SK.mjs} +2 -2
- package/lib/{chunk-Y5MS3XVZ.mjs → chunk-5CWGWY74.mjs} +1 -1
- package/lib/{chunk-OA5TSQWZ.mjs → chunk-6Q4DC5JX.mjs} +1 -1
- package/lib/{chunk-UH4K7HGE.mjs → chunk-7NZPJ2EN.mjs} +6 -8
- package/lib/{chunk-2BSUCVXL.js → chunk-K2FTCH55.js} +2 -2
- package/lib/{chunk-FU4CT24B.mjs → chunk-KWNIT4G4.mjs} +7 -5
- package/lib/{chunk-2BKS6UM5.js → chunk-NCIQ66UP.js} +3 -3
- package/lib/{chunk-ZW4GP2I5.js → chunk-NWZCPYQP.js} +5 -7
- package/lib/{chunk-X53FOCXA.js → chunk-S5HUGQLF.js} +2 -2
- package/lib/{chunk-OZLV3US5.js → chunk-VFQKAKK4.js} +7 -7
- package/lib/chunk-VPYXLUMD.js +53 -0
- package/lib/{chunk-CGLMLNUS.mjs → chunk-W4PGLIAZ.mjs} +2 -2
- package/lib/index.d.mts +3 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +18 -10
- package/lib/index.mjs +16 -8
- package/lib/keycloak/context.d.mts +2 -2
- package/lib/keycloak/context.d.ts +2 -2
- package/lib/keycloak/index.d.mts +2 -2
- package/lib/keycloak/index.d.ts +2 -2
- package/lib/keycloak/index.js +3 -3
- package/lib/keycloak/index.mjs +2 -2
- package/lib/keycloak/keycloak.d.mts +3 -3
- package/lib/keycloak/keycloak.d.ts +3 -3
- package/lib/keycloak/keycloak.js +3 -3
- package/lib/keycloak/keycloak.mjs +2 -2
- package/lib/keycloak/keycloak.native.js +2 -2
- package/lib/keycloak/keycloak.native.mjs +1 -1
- package/lib/provider/AfterAuth.js +4 -4
- package/lib/provider/AfterAuth.mjs +3 -3
- package/lib/provider/AuthProvider/AuthProvider.js +5 -5
- package/lib/provider/AuthProvider/AuthProvider.mjs +4 -4
- package/lib/provider/AuthProvider/AuthProvider.native.js +4 -4
- package/lib/provider/AuthProvider/AuthProvider.native.mjs +3 -3
- package/lib/provider/AuthProvider/index.js +5 -5
- package/lib/provider/AuthProvider/index.mjs +4 -4
- package/lib/provider/KeycloakProvider.js +6 -6
- package/lib/provider/KeycloakProvider.mjs +5 -5
- package/lib/provider/index.js +6 -6
- package/lib/provider/index.mjs +5 -5
- package/lib/routes.d.mts +6 -7
- package/lib/routes.d.ts +6 -7
- package/lib/routes.js +23 -23
- package/lib/routes.mjs +23 -23
- package/lib/session/index.js +2 -2
- package/lib/session/index.mjs +1 -1
- package/lib/session/session.d.mts +3 -3
- package/lib/session/session.d.ts +3 -3
- package/lib/session/session.js +2 -2
- package/lib/session/session.mjs +1 -1
- package/package.json +7 -6
- package/src/Authenticated.tsx +2 -4
- package/src/apollo.ts +95 -0
- package/src/index.ts +1 -0
- package/src/keycloak/keycloak.ts +4 -3
- package/src/provider/AfterAuth.tsx +1 -1
- package/src/routes.ts +40 -38
- package/src/session/session.ts +19 -9
package/lib/Authenticated.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, {
|
|
1
|
+
import React__default, { PropsWithChildren, ComponentType } from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* File: /src/Authenticated.tsx
|
|
@@ -21,8 +21,7 @@ import React__default, { ReactNode, ComponentType } from 'react';
|
|
|
21
21
|
* limitations under the License.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
interface AuthenticatedProps {
|
|
25
|
-
children: ReactNode;
|
|
24
|
+
interface AuthenticatedProps extends PropsWithChildren {
|
|
26
25
|
disabled?: boolean;
|
|
27
26
|
loadingComponent?: ComponentType;
|
|
28
27
|
loggedOutComponent?: ComponentType;
|
package/lib/Authenticated.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, {
|
|
1
|
+
import React__default, { PropsWithChildren, ComponentType } from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* File: /src/Authenticated.tsx
|
|
@@ -21,8 +21,7 @@ import React__default, { ReactNode, ComponentType } from 'react';
|
|
|
21
21
|
* limitations under the License.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
interface AuthenticatedProps {
|
|
25
|
-
children: ReactNode;
|
|
24
|
+
interface AuthenticatedProps extends PropsWithChildren {
|
|
26
25
|
disabled?: boolean;
|
|
27
26
|
loadingComponent?: ComponentType;
|
|
28
27
|
loggedOutComponent?: ComponentType;
|
package/lib/Authenticated.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkK2FTCH55js = require('./chunk-K2FTCH55.js');
|
|
5
5
|
require('./chunk-ZCBD6HWK.js');
|
|
6
6
|
require('./chunk-TUJRPTZE.js');
|
|
7
7
|
require('./chunk-3ZTSLDX7.js');
|
|
8
8
|
require('./chunk-I5FNGKQ6.js');
|
|
9
9
|
require('./chunk-VS4M7GMO.js');
|
|
10
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-NWZCPYQP.js');
|
|
11
|
+
require('./chunk-2VGMJ7WP.js');
|
|
11
12
|
require('./chunk-YACGLW5Q.js');
|
|
12
|
-
require('./chunk-NH335CDK.js');
|
|
13
13
|
require('./chunk-32AVT4GA.js');
|
|
14
14
|
require('./chunk-A2V2S4HP.js');
|
|
15
15
|
require('./chunk-2VDDEPLF.js');
|
|
@@ -17,4 +17,4 @@ require('./chunk-P57PW2II.js');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
exports.Authenticated =
|
|
20
|
+
exports.Authenticated = _chunkK2FTCH55js.Authenticated; exports.withAuthenticated = _chunkK2FTCH55js.withAuthenticated;
|
package/lib/Authenticated.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Authenticated,
|
|
3
3
|
withAuthenticated
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6Q4DC5JX.mjs";
|
|
5
5
|
import "./chunk-HH32BME2.mjs";
|
|
6
6
|
import "./chunk-L3HTVJ4B.mjs";
|
|
7
7
|
import "./chunk-HTWZLBA4.mjs";
|
|
8
8
|
import "./chunk-UKSHA3X3.mjs";
|
|
9
9
|
import "./chunk-OBB23GPX.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-7NZPJ2EN.mjs";
|
|
11
|
+
import "./chunk-KWNIT4G4.mjs";
|
|
11
12
|
import "./chunk-2L5TXBDK.mjs";
|
|
12
|
-
import "./chunk-FU4CT24B.mjs";
|
|
13
13
|
import "./chunk-JAFUI2JQ.mjs";
|
|
14
14
|
import "./chunk-WMH347OL.mjs";
|
|
15
15
|
import "./chunk-6FRYV4MK.mjs";
|
package/lib/apollo.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OperationVariables, DocumentNode, TypedDocumentNode, QueryHookOptions, NoInfer, QueryResult, DefaultContext, ApolloCache, MutationHookOptions, MutationTuple, SubscriptionHookOptions, SubscriptionResult } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
declare function useAuthQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): QueryResult<TData, TVariables>;
|
|
4
|
+
declare function useAuthMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<NoInfer<TData>, NoInfer<TVariables>, TContext, TCache>): MutationTuple<TData, TVariables, TContext, TCache>;
|
|
5
|
+
declare function useAuthSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(subscription: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SubscriptionHookOptions<NoInfer<TData>, NoInfer<TVariables>>): SubscriptionResult<TData, TVariables>;
|
|
6
|
+
|
|
7
|
+
export { useAuthMutation, useAuthQuery, useAuthSubscription };
|
package/lib/apollo.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OperationVariables, DocumentNode, TypedDocumentNode, QueryHookOptions, NoInfer, QueryResult, DefaultContext, ApolloCache, MutationHookOptions, MutationTuple, SubscriptionHookOptions, SubscriptionResult } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
declare function useAuthQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): QueryResult<TData, TVariables>;
|
|
4
|
+
declare function useAuthMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<NoInfer<TData>, NoInfer<TVariables>, TContext, TCache>): MutationTuple<TData, TVariables, TContext, TCache>;
|
|
5
|
+
declare function useAuthSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(subscription: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SubscriptionHookOptions<NoInfer<TData>, NoInfer<TVariables>>): SubscriptionResult<TData, TVariables>;
|
|
6
|
+
|
|
7
|
+
export { useAuthMutation, useAuthQuery, useAuthSubscription };
|
package/lib/apollo.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkVPYXLUMDjs = require('./chunk-VPYXLUMD.js');
|
|
6
|
+
require('./chunk-VS4M7GMO.js');
|
|
7
|
+
require('./chunk-NWZCPYQP.js');
|
|
8
|
+
require('./chunk-2VGMJ7WP.js');
|
|
9
|
+
require('./chunk-YACGLW5Q.js');
|
|
10
|
+
require('./chunk-P57PW2II.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.useAuthMutation = _chunkVPYXLUMDjs.useAuthMutation; exports.useAuthQuery = _chunkVPYXLUMDjs.useAuthQuery; exports.useAuthSubscription = _chunkVPYXLUMDjs.useAuthSubscription;
|
package/lib/apollo.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useAuthMutation,
|
|
3
|
+
useAuthQuery,
|
|
4
|
+
useAuthSubscription
|
|
5
|
+
} from "./chunk-267L3NLO.mjs";
|
|
6
|
+
import "./chunk-OBB23GPX.mjs";
|
|
7
|
+
import "./chunk-7NZPJ2EN.mjs";
|
|
8
|
+
import "./chunk-KWNIT4G4.mjs";
|
|
9
|
+
import "./chunk-2L5TXBDK.mjs";
|
|
10
|
+
import "./chunk-ZFXKCRJC.mjs";
|
|
11
|
+
export {
|
|
12
|
+
useAuthMutation,
|
|
13
|
+
useAuthQuery,
|
|
14
|
+
useAuthSubscription
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useKeycloak
|
|
3
|
+
} from "./chunk-7NZPJ2EN.mjs";
|
|
4
|
+
|
|
5
|
+
// src/apollo.ts
|
|
6
|
+
import { useQuery, useMutation, useSubscription } from "@apollo/client";
|
|
7
|
+
function useAuthQuery(query, options) {
|
|
8
|
+
const keycloak = useKeycloak();
|
|
9
|
+
return useQuery(query, {
|
|
10
|
+
...options,
|
|
11
|
+
skip: options?.skip || !keycloak?.authenticated || !keycloak.token,
|
|
12
|
+
context: {
|
|
13
|
+
...options?.context,
|
|
14
|
+
headers: {
|
|
15
|
+
...options?.context?.headers || {},
|
|
16
|
+
authorization: `Bearer ${keycloak?.token}`
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function useAuthMutation(mutation, options) {
|
|
22
|
+
const keycloak = useKeycloak();
|
|
23
|
+
return useMutation(mutation, {
|
|
24
|
+
...options,
|
|
25
|
+
context: {
|
|
26
|
+
...options?.context,
|
|
27
|
+
headers: {
|
|
28
|
+
...options?.context?.headers || {},
|
|
29
|
+
authorization: `Bearer ${keycloak?.token}`
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function useAuthSubscription(subscription, options) {
|
|
35
|
+
const keycloak = useKeycloak();
|
|
36
|
+
return useSubscription(subscription, {
|
|
37
|
+
...options,
|
|
38
|
+
skip: options?.skip || !keycloak?.authenticated || !keycloak.token,
|
|
39
|
+
context: {
|
|
40
|
+
...options?.context,
|
|
41
|
+
headers: {
|
|
42
|
+
...options?.context?.headers || {},
|
|
43
|
+
authorization: `Bearer ${keycloak?.token}`
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
useAuthQuery,
|
|
51
|
+
useAuthMutation,
|
|
52
|
+
useAuthSubscription
|
|
53
|
+
};
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
var _multiplatformone = require('multiplatform.one');
|
|
3
3
|
var _react = require('next-auth/react');
|
|
4
4
|
var _getServerSession;
|
|
5
|
-
async function getSession() {
|
|
5
|
+
async function getSession(options, req, res) {
|
|
6
6
|
if (_multiplatformone.MultiPlatform.isServer) {
|
|
7
7
|
if (typeof _getServerSession === "function")
|
|
8
|
-
return _getServerSession();
|
|
8
|
+
return _getServerSession(options, req, res);
|
|
9
9
|
const getSession2 = (await Promise.resolve().then(() => _interopRequireWildcard(require("next-auth")))).getServerSession;
|
|
10
|
-
_getServerSession = () =>
|
|
11
|
-
|
|
10
|
+
_getServerSession = (options2, req2, res2) => {
|
|
11
|
+
return req2 && res2 ? getSession2(req2, res2, options2) : getSession2(options2);
|
|
12
|
+
};
|
|
13
|
+
return _getServerSession(options, req, res);
|
|
12
14
|
}
|
|
13
|
-
return _react.getSession.call(void 0, );
|
|
15
|
+
return _react.getSession.call(void 0, options);
|
|
14
16
|
}
|
|
15
17
|
var useSession = (options) => {
|
|
16
18
|
return {};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-HTWZLBA4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useKeycloak
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7NZPJ2EN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
persist,
|
|
9
9
|
useAuthState
|
|
@@ -40,7 +40,7 @@ function AfterAuth({ children }) {
|
|
|
40
40
|
logger.debug("refreshToken", keycloak.refreshToken);
|
|
41
41
|
}, [keycloak?.refreshToken]);
|
|
42
42
|
useEffect(() => {
|
|
43
|
-
if (keycloak?.authenticated)
|
|
43
|
+
if (authConfig.debug && keycloak?.authenticated)
|
|
44
44
|
logger.debug("authenticated", keycloak.authenticated);
|
|
45
45
|
}, [keycloak?.authenticated]);
|
|
46
46
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
KeycloakContext
|
|
3
|
-
} from "./chunk-2L5TXBDK.mjs";
|
|
4
1
|
import {
|
|
5
2
|
getSession,
|
|
6
3
|
useSession
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KWNIT4G4.mjs";
|
|
5
|
+
import {
|
|
6
|
+
KeycloakContext
|
|
7
|
+
} from "./chunk-2L5TXBDK.mjs";
|
|
8
8
|
|
|
9
9
|
// src/keycloak/keycloak.ts
|
|
10
10
|
import { MultiPlatform } from "multiplatform.one";
|
|
@@ -136,8 +136,6 @@ function useKeycloak() {
|
|
|
136
136
|
if (keycloak)
|
|
137
137
|
return keycloak;
|
|
138
138
|
const { session, status } = useSession();
|
|
139
|
-
if (MultiPlatform.isServer)
|
|
140
|
-
return;
|
|
141
139
|
if (MultiPlatform.isStorybook) {
|
|
142
140
|
return new Keycloak({
|
|
143
141
|
email: "storybook@example.com",
|
|
@@ -149,8 +147,8 @@ function useKeycloak() {
|
|
|
149
147
|
return new Keycloak(session);
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
|
-
async function getKeycloak() {
|
|
153
|
-
const session = await getSession();
|
|
150
|
+
async function getKeycloak(options, req, res) {
|
|
151
|
+
const session = await getSession(options, req, res);
|
|
154
152
|
if (session?.accessToken)
|
|
155
153
|
return new Keycloak(session);
|
|
156
154
|
return new Keycloak();
|
|
@@ -9,14 +9,14 @@ var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
|
|
|
9
9
|
var _chunkI5FNGKQ6js = require('./chunk-I5FNGKQ6.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkNWZCPYQPjs = require('./chunk-NWZCPYQP.js');
|
|
13
13
|
|
|
14
14
|
// src/Authenticated.tsx
|
|
15
15
|
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
16
16
|
var _multiplatformone = require('multiplatform.one');
|
|
17
17
|
function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }) {
|
|
18
18
|
const authConfig = _chunk3ZTSLDX7js.useAuthConfig.call(void 0, );
|
|
19
|
-
const keycloak =
|
|
19
|
+
const keycloak = _chunkNWZCPYQPjs.useKeycloak.call(void 0, );
|
|
20
20
|
const tokensFromQuery = _chunkTUJRPTZEjs.useTokensFromQuery.call(void 0, );
|
|
21
21
|
const tokensFromState = _chunkI5FNGKQ6js.useTokensFromState.call(void 0, );
|
|
22
22
|
_react.useEffect.call(void 0, () => {
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
import { MultiPlatform } from "multiplatform.one";
|
|
3
3
|
import { useSession as useNextSession, getSession as getNextSession } from "next-auth/react";
|
|
4
4
|
var _getServerSession;
|
|
5
|
-
async function getSession() {
|
|
5
|
+
async function getSession(options, req, res) {
|
|
6
6
|
if (MultiPlatform.isServer) {
|
|
7
7
|
if (typeof _getServerSession === "function")
|
|
8
|
-
return _getServerSession();
|
|
8
|
+
return _getServerSession(options, req, res);
|
|
9
9
|
const getSession2 = (await import("next-auth")).getServerSession;
|
|
10
|
-
_getServerSession = () =>
|
|
11
|
-
|
|
10
|
+
_getServerSession = (options2, req2, res2) => {
|
|
11
|
+
return req2 && res2 ? getSession2(req2, res2, options2) : getSession2(options2);
|
|
12
|
+
};
|
|
13
|
+
return _getServerSession(options, req, res);
|
|
12
14
|
}
|
|
13
|
-
return getNextSession();
|
|
15
|
+
return getNextSession(options);
|
|
14
16
|
}
|
|
15
17
|
var useSession = (options) => {
|
|
16
18
|
return {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkNWZCPYQPjs = require('./chunk-NWZCPYQP.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ var logger = console;
|
|
|
15
15
|
function AfterAuth({ children }) {
|
|
16
16
|
const authConfig = _chunk3ZTSLDX7js.useAuthConfig.call(void 0, );
|
|
17
17
|
const authState = _chunkA2V2S4HPjs.useAuthState.call(void 0, );
|
|
18
|
-
const keycloak =
|
|
18
|
+
const keycloak = _chunkNWZCPYQPjs.useKeycloak.call(void 0, );
|
|
19
19
|
_react.useEffect.call(void 0, () => {
|
|
20
20
|
if (!_chunkA2V2S4HPjs.persist || !_optionalChain([keycloak, 'optionalAccess', _ => _.authenticated]))
|
|
21
21
|
return;
|
|
@@ -40,7 +40,7 @@ function AfterAuth({ children }) {
|
|
|
40
40
|
logger.debug("refreshToken", keycloak.refreshToken);
|
|
41
41
|
}, [_optionalChain([keycloak, 'optionalAccess', _11 => _11.refreshToken])]);
|
|
42
42
|
_react.useEffect.call(void 0, () => {
|
|
43
|
-
if (_optionalChain([keycloak, 'optionalAccess', _12 => _12.authenticated]))
|
|
43
|
+
if (authConfig.debug && _optionalChain([keycloak, 'optionalAccess', _12 => _12.authenticated]))
|
|
44
44
|
logger.debug("authenticated", keycloak.authenticated);
|
|
45
45
|
}, [_optionalChain([keycloak, 'optionalAccess', _13 => _13.authenticated])]);
|
|
46
46
|
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var _chunkYACGLW5Qjs = require('./chunk-YACGLW5Q.js');
|
|
4
3
|
|
|
4
|
+
var _chunk2VGMJ7WPjs = require('./chunk-2VGMJ7WP.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkYACGLW5Qjs = require('./chunk-YACGLW5Q.js');
|
|
8
8
|
|
|
9
9
|
// src/keycloak/keycloak.ts
|
|
10
10
|
var _multiplatformone = require('multiplatform.one');
|
|
@@ -135,9 +135,7 @@ function useKeycloak() {
|
|
|
135
135
|
const keycloak = _react3.useContext.call(void 0, _chunkYACGLW5Qjs.KeycloakContext);
|
|
136
136
|
if (keycloak)
|
|
137
137
|
return keycloak;
|
|
138
|
-
const { session, status } =
|
|
139
|
-
if (_multiplatformone.MultiPlatform.isServer)
|
|
140
|
-
return;
|
|
138
|
+
const { session, status } = _chunk2VGMJ7WPjs.useSession.call(void 0, );
|
|
141
139
|
if (_multiplatformone.MultiPlatform.isStorybook) {
|
|
142
140
|
return new Keycloak({
|
|
143
141
|
email: "storybook@example.com",
|
|
@@ -149,8 +147,8 @@ function useKeycloak() {
|
|
|
149
147
|
return new Keycloak(session);
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
|
-
async function getKeycloak() {
|
|
153
|
-
const session = await
|
|
150
|
+
async function getKeycloak(options, req, res) {
|
|
151
|
+
const session = await _chunk2VGMJ7WPjs.getSession.call(void 0, options, req, res);
|
|
154
152
|
if (_optionalChain([session, 'optionalAccess', _27 => _27.accessToken]))
|
|
155
153
|
return new Keycloak(session);
|
|
156
154
|
return new Keycloak();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkVFQKAKK4js = require('./chunk-VFQKAKK4.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunk32AVT4GAjs = require('./chunk-32AVT4GA.js');
|
|
@@ -10,7 +10,7 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
|
10
10
|
function KeycloakProvider({ children, debug, realm, clientId, baseUrl, session }) {
|
|
11
11
|
const authConfig = _react.useMemo.call(void 0, () => ({ debug }), [debug]);
|
|
12
12
|
return /* @__PURE__ */ _react2.default.createElement(_chunk32AVT4GAjs.AuthConfigContext.Provider, { value: authConfig }, /* @__PURE__ */ _react2.default.createElement(
|
|
13
|
-
|
|
13
|
+
_chunkVFQKAKK4js.AuthProvider,
|
|
14
14
|
{
|
|
15
15
|
sessionProvider: { session },
|
|
16
16
|
keycloakConfig: {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNCIQ66UPjs = require('./chunk-NCIQ66UP.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkNWZCPYQPjs = require('./chunk-NWZCPYQP.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkYACGLW5Qjs = require('./chunk-YACGLW5Q.js');
|
|
@@ -204,11 +204,11 @@ function AuthProvider({ children, sessionProvider, keycloakInitOptions, keycloak
|
|
|
204
204
|
_react.useEffect.call(void 0, () => {
|
|
205
205
|
function onError() {
|
|
206
206
|
if (keycloakClient && initOptions)
|
|
207
|
-
setKeycloak(new (0,
|
|
207
|
+
setKeycloak(new (0, _chunkNWZCPYQPjs.Keycloak)(keycloakClient));
|
|
208
208
|
}
|
|
209
209
|
function onUpdate() {
|
|
210
210
|
if (keycloakClient && initOptions)
|
|
211
|
-
setKeycloak(new (0,
|
|
211
|
+
setKeycloak(new (0, _chunkNWZCPYQPjs.Keycloak)(keycloakClient));
|
|
212
212
|
}
|
|
213
213
|
if (keycloakClient && initOptions) {
|
|
214
214
|
(async () => {
|
|
@@ -222,15 +222,15 @@ function AuthProvider({ children, sessionProvider, keycloakInitOptions, keycloak
|
|
|
222
222
|
try {
|
|
223
223
|
await keycloakClient.updateToken(5);
|
|
224
224
|
} catch (err) {
|
|
225
|
-
setKeycloak(new (0,
|
|
225
|
+
setKeycloak(new (0, _chunkNWZCPYQPjs.Keycloak)());
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
const authenticated = await keycloakClient.init(initOptions);
|
|
229
|
-
setKeycloak(new (0,
|
|
229
|
+
setKeycloak(new (0, _chunkNWZCPYQPjs.Keycloak)(authenticated ? keycloakClient : void 0));
|
|
230
230
|
})();
|
|
231
231
|
}
|
|
232
232
|
}, []);
|
|
233
|
-
return /* @__PURE__ */ _react2.default.createElement(_react3.SessionProvider, { ...sessionProvider }, /* @__PURE__ */ _react2.default.createElement(_chunkYACGLW5Qjs.KeycloakContext.Provider, { value: keycloak }, /* @__PURE__ */ _react2.default.createElement(
|
|
233
|
+
return /* @__PURE__ */ _react2.default.createElement(_react3.SessionProvider, { ...sessionProvider }, /* @__PURE__ */ _react2.default.createElement(_chunkYACGLW5Qjs.KeycloakContext.Provider, { value: keycloak }, /* @__PURE__ */ _react2.default.createElement(_chunkNCIQ66UPjs.AfterAuth, null, children)));
|
|
234
234
|
}
|
|
235
235
|
var defaultKeycloakInitOptions = {
|
|
236
236
|
checkLoginIframe: true,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkNWZCPYQPjs = require('./chunk-NWZCPYQP.js');
|
|
4
|
+
|
|
5
|
+
// src/apollo.ts
|
|
6
|
+
var _client = require('@apollo/client');
|
|
7
|
+
function useAuthQuery(query, options) {
|
|
8
|
+
const keycloak = _chunkNWZCPYQPjs.useKeycloak.call(void 0, );
|
|
9
|
+
return _client.useQuery.call(void 0, query, {
|
|
10
|
+
...options,
|
|
11
|
+
skip: _optionalChain([options, 'optionalAccess', _ => _.skip]) || !_optionalChain([keycloak, 'optionalAccess', _2 => _2.authenticated]) || !keycloak.token,
|
|
12
|
+
context: {
|
|
13
|
+
..._optionalChain([options, 'optionalAccess', _3 => _3.context]),
|
|
14
|
+
headers: {
|
|
15
|
+
..._optionalChain([options, 'optionalAccess', _4 => _4.context, 'optionalAccess', _5 => _5.headers]) || {},
|
|
16
|
+
authorization: `Bearer ${_optionalChain([keycloak, 'optionalAccess', _6 => _6.token])}`
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function useAuthMutation(mutation, options) {
|
|
22
|
+
const keycloak = _chunkNWZCPYQPjs.useKeycloak.call(void 0, );
|
|
23
|
+
return _client.useMutation.call(void 0, mutation, {
|
|
24
|
+
...options,
|
|
25
|
+
context: {
|
|
26
|
+
..._optionalChain([options, 'optionalAccess', _7 => _7.context]),
|
|
27
|
+
headers: {
|
|
28
|
+
..._optionalChain([options, 'optionalAccess', _8 => _8.context, 'optionalAccess', _9 => _9.headers]) || {},
|
|
29
|
+
authorization: `Bearer ${_optionalChain([keycloak, 'optionalAccess', _10 => _10.token])}`
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function useAuthSubscription(subscription, options) {
|
|
35
|
+
const keycloak = _chunkNWZCPYQPjs.useKeycloak.call(void 0, );
|
|
36
|
+
return _client.useSubscription.call(void 0, subscription, {
|
|
37
|
+
...options,
|
|
38
|
+
skip: _optionalChain([options, 'optionalAccess', _11 => _11.skip]) || !_optionalChain([keycloak, 'optionalAccess', _12 => _12.authenticated]) || !keycloak.token,
|
|
39
|
+
context: {
|
|
40
|
+
..._optionalChain([options, 'optionalAccess', _13 => _13.context]),
|
|
41
|
+
headers: {
|
|
42
|
+
..._optionalChain([options, 'optionalAccess', _14 => _14.context, 'optionalAccess', _15 => _15.headers]) || {},
|
|
43
|
+
authorization: `Bearer ${_optionalChain([keycloak, 'optionalAccess', _16 => _16.token])}`
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
exports.useAuthQuery = useAuthQuery; exports.useAuthMutation = useAuthMutation; exports.useAuthSubscription = useAuthSubscription;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AfterAuth
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3KAZ37SK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useAuthConfig
|
|
6
6
|
} from "./chunk-HTWZLBA4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
Keycloak
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7NZPJ2EN.mjs";
|
|
10
10
|
import {
|
|
11
11
|
KeycloakContext
|
|
12
12
|
} from "./chunk-2L5TXBDK.mjs";
|
package/lib/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Authenticated, AuthenticatedProps, withAuthenticated } from './Authenticated.mjs';
|
|
2
|
+
export { useAuthMutation, useAuthQuery, useAuthSubscription } from './apollo.mjs';
|
|
2
3
|
export { AuthConfig, AuthConfigContext, defaultAuthConfig } from './authConfig.mjs';
|
|
3
4
|
export { useAuthConfig } from './hooks/useAuthConfig.mjs';
|
|
4
5
|
export { useTokensFromQuery } from './hooks/useTokensFromQuery/index.mjs';
|
|
@@ -10,7 +11,8 @@ export { KeycloakProvider, KeycloakProviderProps } from './provider/KeycloakProv
|
|
|
10
11
|
export { Session, SessionContextValue, getSession, useSession } from './session/session.mjs';
|
|
11
12
|
export { KeycloakMock } from './types.mjs';
|
|
12
13
|
import 'react';
|
|
14
|
+
import '@apollo/client';
|
|
13
15
|
import 'keycloak-js';
|
|
14
16
|
import './token.mjs';
|
|
15
|
-
import 'next-auth/react';
|
|
16
17
|
import 'next-auth';
|
|
18
|
+
import 'next-auth/react';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Authenticated, AuthenticatedProps, withAuthenticated } from './Authenticated.js';
|
|
2
|
+
export { useAuthMutation, useAuthQuery, useAuthSubscription } from './apollo.js';
|
|
2
3
|
export { AuthConfig, AuthConfigContext, defaultAuthConfig } from './authConfig.js';
|
|
3
4
|
export { useAuthConfig } from './hooks/useAuthConfig.js';
|
|
4
5
|
export { useTokensFromQuery } from './hooks/useTokensFromQuery/index.js';
|
|
@@ -10,7 +11,8 @@ export { KeycloakProvider, KeycloakProviderProps } from './provider/KeycloakProv
|
|
|
10
11
|
export { Session, SessionContextValue, getSession, useSession } from './session/session.js';
|
|
11
12
|
export { KeycloakMock } from './types.js';
|
|
12
13
|
import 'react';
|
|
14
|
+
import '@apollo/client';
|
|
13
15
|
import 'keycloak-js';
|
|
14
16
|
import './token.js';
|
|
15
|
-
import 'next-auth/react';
|
|
16
17
|
import 'next-auth';
|
|
18
|
+
import 'next-auth/react';
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-WS4IMGVL.js');
|
|
2
|
+
require('./chunk-BUZONXAW.js');
|
|
2
3
|
|
|
3
4
|
|
|
4
|
-
var
|
|
5
|
-
require('./chunk-WS4IMGVL.js');
|
|
5
|
+
var _chunkS5HUGQLFjs = require('./chunk-S5HUGQLF.js');
|
|
6
6
|
require('./chunk-MDAAMGTE.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkVFQKAKK4js = require('./chunk-VFQKAKK4.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkNCIQ66UPjs = require('./chunk-NCIQ66UP.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkK2FTCH55js = require('./chunk-K2FTCH55.js');
|
|
17
17
|
require('./chunk-ZCBD6HWK.js');
|
|
18
18
|
|
|
19
19
|
|
|
@@ -24,17 +24,22 @@ var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkI5FNGKQ6js = require('./chunk-I5FNGKQ6.js');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var _chunkVPYXLUMDjs = require('./chunk-VPYXLUMD.js');
|
|
27
32
|
require('./chunk-VS4M7GMO.js');
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
|
|
31
36
|
|
|
32
|
-
var
|
|
33
|
-
require('./chunk-YACGLW5Q.js');
|
|
37
|
+
var _chunkNWZCPYQPjs = require('./chunk-NWZCPYQP.js');
|
|
34
38
|
|
|
35
39
|
|
|
36
40
|
|
|
37
|
-
var
|
|
41
|
+
var _chunk2VGMJ7WPjs = require('./chunk-2VGMJ7WP.js');
|
|
42
|
+
require('./chunk-YACGLW5Q.js');
|
|
38
43
|
|
|
39
44
|
|
|
40
45
|
|
|
@@ -59,4 +64,7 @@ require('./chunk-6F4PWJZI.js');
|
|
|
59
64
|
|
|
60
65
|
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
exports.AfterAuth = _chunkNCIQ66UPjs.AfterAuth; exports.AuthConfigContext = _chunk32AVT4GAjs.AuthConfigContext; exports.AuthProvider = _chunkVFQKAKK4js.AuthProvider; exports.Authenticated = _chunkK2FTCH55js.Authenticated; exports.Keycloak = _chunkNWZCPYQPjs.Keycloak; exports.KeycloakProvider = _chunkS5HUGQLFjs.KeycloakProvider; exports.defaultAuthConfig = _chunk32AVT4GAjs.defaultAuthConfig; exports.getKeycloak = _chunkNWZCPYQPjs.getKeycloak; exports.getSession = _chunk2VGMJ7WPjs.getSession; exports.useAuthConfig = _chunk3ZTSLDX7js.useAuthConfig; exports.useAuthMutation = _chunkVPYXLUMDjs.useAuthMutation; exports.useAuthQuery = _chunkVPYXLUMDjs.useAuthQuery; exports.useAuthSubscription = _chunkVPYXLUMDjs.useAuthSubscription; exports.useKeycloak = _chunkNWZCPYQPjs.useKeycloak; exports.useSession = _chunk2VGMJ7WPjs.useSession; exports.useTokensFromQuery = _chunkTUJRPTZEjs.useTokensFromQuery; exports.useTokensFromState = _chunkI5FNGKQ6js.useTokensFromState; exports.withAuthenticated = _chunkK2FTCH55js.withAuthenticated;
|