@multiplatform.one/keycloak 0.7.16 → 0.7.17
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/@types/expoKeycloakAuth.d.d.mts +25 -0
- package/lib/@types/expoKeycloakAuth.d.d.ts +25 -0
- package/lib/@types/expoKeycloakAuth.d.js +1 -0
- package/lib/@types/expoKeycloakAuth.d.mjs +0 -0
- package/lib/Authenticated.d.mts +33 -0
- package/lib/Authenticated.d.ts +33 -0
- package/lib/Authenticated.js +20 -0
- package/lib/Authenticated.mjs +20 -0
- package/lib/authConfig.d.mts +12 -0
- package/lib/authConfig.d.ts +12 -0
- package/lib/authConfig.js +9 -0
- package/lib/authConfig.mjs +9 -0
- package/lib/chunk-2BKS6UM5.js +51 -0
- package/lib/chunk-2BSUCVXL.js +50 -0
- package/lib/chunk-2L5TXBDK.mjs +7 -0
- package/lib/chunk-2VDDEPLF.js +27 -0
- package/lib/chunk-32AVT4GA.js +9 -0
- package/lib/chunk-3ZTSLDX7.js +13 -0
- package/lib/chunk-6F4PWJZI.js +1 -0
- package/lib/chunk-6FRYV4MK.mjs +27 -0
- package/lib/chunk-A2V2S4HP.js +22 -0
- package/lib/chunk-BUZONXAW.js +1 -0
- package/lib/chunk-CGLMLNUS.mjs +245 -0
- package/lib/chunk-FU4CT24B.mjs +32 -0
- package/lib/chunk-HH32BME2.mjs +0 -0
- package/lib/chunk-HTWZLBA4.mjs +13 -0
- package/lib/chunk-I5FNGKQ6.js +16 -0
- package/lib/chunk-JAFUI2JQ.mjs +9 -0
- package/lib/chunk-JPQI72HR.mjs +0 -0
- package/lib/chunk-L3HTVJ4B.mjs +13 -0
- package/lib/chunk-MDAAMGTE.js +1 -0
- package/lib/chunk-NH335CDK.js +32 -0
- package/lib/chunk-OA5TSQWZ.mjs +50 -0
- package/lib/chunk-OAUYHIWG.mjs +0 -0
- package/lib/chunk-OBB23GPX.mjs +0 -0
- package/lib/chunk-OZLV3US5.js +245 -0
- package/lib/chunk-P57PW2II.js +11 -0
- package/lib/chunk-TUJRPTZE.js +13 -0
- package/lib/chunk-UESWAK47.mjs +0 -0
- package/lib/chunk-UH4K7HGE.mjs +163 -0
- package/lib/chunk-UKSHA3X3.mjs +16 -0
- package/lib/chunk-VS4M7GMO.js +1 -0
- package/lib/chunk-WBQAMGXK.mjs +0 -0
- package/lib/chunk-WMH347OL.mjs +22 -0
- package/lib/chunk-WS4IMGVL.js +1 -0
- package/lib/chunk-X53FOCXA.js +28 -0
- package/lib/chunk-Y23BWOII.mjs +51 -0
- package/lib/chunk-Y5MS3XVZ.mjs +28 -0
- package/lib/chunk-YACGLW5Q.js +7 -0
- package/lib/chunk-ZCBD6HWK.js +1 -0
- package/lib/chunk-ZFXKCRJC.mjs +11 -0
- package/lib/chunk-ZW4GP2I5.js +163 -0
- package/lib/hooks/index.d.mts +5 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.js +19 -0
- package/lib/hooks/index.mjs +19 -0
- package/lib/hooks/useAuthConfig.d.mts +6 -0
- package/lib/hooks/useAuthConfig.d.ts +6 -0
- package/lib/hooks/useAuthConfig.js +8 -0
- package/lib/hooks/useAuthConfig.mjs +8 -0
- package/lib/hooks/useTokensFromQuery/index.d.mts +3 -0
- package/lib/hooks/useTokensFromQuery/index.d.ts +3 -0
- package/lib/hooks/useTokensFromQuery/index.js +7 -0
- package/lib/hooks/useTokensFromQuery/index.mjs +7 -0
- package/lib/hooks/useTokensFromQuery/index.native.d.mts +3 -0
- package/lib/hooks/useTokensFromQuery/index.native.d.ts +3 -0
- package/lib/hooks/useTokensFromQuery/index.native.js +7 -0
- package/lib/hooks/useTokensFromQuery/index.native.mjs +7 -0
- package/lib/hooks/useTokensFromState.d.mts +3 -0
- package/lib/hooks/useTokensFromState.d.ts +3 -0
- package/lib/hooks/useTokensFromState.js +9 -0
- package/lib/hooks/useTokensFromState.mjs +9 -0
- package/lib/index.d.mts +16 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +62 -0
- package/lib/index.mjs +62 -0
- package/lib/keycloak/context.d.mts +12 -0
- package/lib/keycloak/context.d.ts +12 -0
- package/lib/keycloak/context.js +7 -0
- package/lib/keycloak/context.mjs +7 -0
- package/lib/keycloak/index.d.mts +7 -0
- package/lib/keycloak/index.d.ts +7 -0
- package/lib/keycloak/index.js +14 -0
- package/lib/keycloak/index.mjs +14 -0
- package/lib/keycloak/keycloak.d.mts +37 -0
- package/lib/keycloak/keycloak.d.ts +37 -0
- package/lib/keycloak/keycloak.js +13 -0
- package/lib/keycloak/keycloak.mjs +13 -0
- package/lib/keycloak/keycloak.native.d.mts +33 -0
- package/lib/keycloak/keycloak.native.d.ts +33 -0
- package/lib/keycloak/keycloak.native.js +134 -0
- package/lib/keycloak/keycloak.native.mjs +134 -0
- package/lib/provider/AfterAuth.d.mts +28 -0
- package/lib/provider/AfterAuth.d.ts +28 -0
- package/lib/provider/AfterAuth.js +18 -0
- package/lib/provider/AfterAuth.mjs +18 -0
- package/lib/provider/AuthProvider/AuthProvider.d.mts +37 -0
- package/lib/provider/AuthProvider/AuthProvider.d.ts +37 -0
- package/lib/provider/AuthProvider/AuthProvider.js +19 -0
- package/lib/provider/AuthProvider/AuthProvider.mjs +19 -0
- package/lib/provider/AuthProvider/AuthProvider.native.d.mts +29 -0
- package/lib/provider/AuthProvider/AuthProvider.native.d.ts +29 -0
- package/lib/provider/AuthProvider/AuthProvider.native.js +25 -0
- package/lib/provider/AuthProvider/AuthProvider.native.mjs +25 -0
- package/lib/provider/AuthProvider/index.d.mts +4 -0
- package/lib/provider/AuthProvider/index.d.ts +4 -0
- package/lib/provider/AuthProvider/index.js +20 -0
- package/lib/provider/AuthProvider/index.mjs +20 -0
- package/lib/provider/KeycloakProvider.d.mts +34 -0
- package/lib/provider/KeycloakProvider.d.ts +34 -0
- package/lib/provider/KeycloakProvider.js +21 -0
- package/lib/provider/KeycloakProvider.mjs +21 -0
- package/lib/provider/index.d.mts +8 -0
- package/lib/provider/index.d.ts +8 -0
- package/lib/provider/index.js +28 -0
- package/lib/provider/index.mjs +28 -0
- package/lib/routes.d.mts +28 -0
- package/lib/routes.d.ts +28 -0
- package/lib/routes.js +127 -0
- package/lib/routes.mjs +127 -0
- package/lib/session/index.d.mts +3 -0
- package/lib/session/index.d.ts +3 -0
- package/lib/session/index.js +10 -0
- package/lib/session/index.mjs +10 -0
- package/lib/session/session.d.mts +18 -0
- package/lib/session/session.d.ts +18 -0
- package/lib/session/session.js +9 -0
- package/lib/session/session.mjs +9 -0
- package/lib/session/session.native.d.mts +8 -0
- package/lib/session/session.native.d.ts +8 -0
- package/lib/session/session.native.js +13 -0
- package/lib/session/session.native.mjs +13 -0
- package/lib/state.d.mts +12 -0
- package/lib/state.d.ts +12 -0
- package/lib/state.js +9 -0
- package/lib/state.mjs +9 -0
- package/lib/token.d.mts +17 -0
- package/lib/token.d.ts +17 -0
- package/lib/token.js +9 -0
- package/lib/token.mjs +9 -0
- package/lib/types.d.mts +20 -0
- package/lib/types.d.ts +20 -0
- package/lib/types.js +1 -0
- package/lib/types.mjs +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* File: /src/@types/expoKeycloakAuth.d.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 22-06-2023 10:07:56
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2023
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare module 'expo-keycloak-auth' {
|
|
23
|
+
export function useKeycloak(): any;
|
|
24
|
+
export const KeycloakProvider: any;
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* File: /src/@types/expoKeycloakAuth.d.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 22-06-2023 10:07:56
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2023
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare module 'expo-keycloak-auth' {
|
|
23
|
+
export function useKeycloak(): any;
|
|
24
|
+
export const KeycloakProvider: any;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React__default, { ReactNode, ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* File: /src/Authenticated.tsx
|
|
5
|
+
* Project: @multiplatform.one/keycloak
|
|
6
|
+
* File Created: 22-06-2023 10:07:56
|
|
7
|
+
* Author: Clay Risser
|
|
8
|
+
* -----
|
|
9
|
+
* BitSpur (c) Copyright 2021 - 2023
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface AuthenticatedProps {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
loadingComponent?: ComponentType;
|
|
28
|
+
loggedOutComponent?: ComponentType;
|
|
29
|
+
}
|
|
30
|
+
declare function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }: AuthenticatedProps): React__default.JSX.Element;
|
|
31
|
+
declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
|
|
32
|
+
|
|
33
|
+
export { Authenticated, type AuthenticatedProps, withAuthenticated };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React__default, { ReactNode, ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* File: /src/Authenticated.tsx
|
|
5
|
+
* Project: @multiplatform.one/keycloak
|
|
6
|
+
* File Created: 22-06-2023 10:07:56
|
|
7
|
+
* Author: Clay Risser
|
|
8
|
+
* -----
|
|
9
|
+
* BitSpur (c) Copyright 2021 - 2023
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface AuthenticatedProps {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
loadingComponent?: ComponentType;
|
|
28
|
+
loggedOutComponent?: ComponentType;
|
|
29
|
+
}
|
|
30
|
+
declare function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }: AuthenticatedProps): React__default.JSX.Element;
|
|
31
|
+
declare function withAuthenticated<P extends object>(Component: ComponentType<P>): (props: P) => React__default.JSX.Element;
|
|
32
|
+
|
|
33
|
+
export { Authenticated, type AuthenticatedProps, withAuthenticated };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunk2BSUCVXLjs = require('./chunk-2BSUCVXL.js');
|
|
5
|
+
require('./chunk-ZCBD6HWK.js');
|
|
6
|
+
require('./chunk-TUJRPTZE.js');
|
|
7
|
+
require('./chunk-3ZTSLDX7.js');
|
|
8
|
+
require('./chunk-I5FNGKQ6.js');
|
|
9
|
+
require('./chunk-VS4M7GMO.js');
|
|
10
|
+
require('./chunk-ZW4GP2I5.js');
|
|
11
|
+
require('./chunk-YACGLW5Q.js');
|
|
12
|
+
require('./chunk-NH335CDK.js');
|
|
13
|
+
require('./chunk-32AVT4GA.js');
|
|
14
|
+
require('./chunk-A2V2S4HP.js');
|
|
15
|
+
require('./chunk-2VDDEPLF.js');
|
|
16
|
+
require('./chunk-P57PW2II.js');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.Authenticated = _chunk2BSUCVXLjs.Authenticated; exports.withAuthenticated = _chunk2BSUCVXLjs.withAuthenticated;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Authenticated,
|
|
3
|
+
withAuthenticated
|
|
4
|
+
} from "./chunk-OA5TSQWZ.mjs";
|
|
5
|
+
import "./chunk-HH32BME2.mjs";
|
|
6
|
+
import "./chunk-L3HTVJ4B.mjs";
|
|
7
|
+
import "./chunk-HTWZLBA4.mjs";
|
|
8
|
+
import "./chunk-UKSHA3X3.mjs";
|
|
9
|
+
import "./chunk-OBB23GPX.mjs";
|
|
10
|
+
import "./chunk-UH4K7HGE.mjs";
|
|
11
|
+
import "./chunk-2L5TXBDK.mjs";
|
|
12
|
+
import "./chunk-FU4CT24B.mjs";
|
|
13
|
+
import "./chunk-JAFUI2JQ.mjs";
|
|
14
|
+
import "./chunk-WMH347OL.mjs";
|
|
15
|
+
import "./chunk-6FRYV4MK.mjs";
|
|
16
|
+
import "./chunk-ZFXKCRJC.mjs";
|
|
17
|
+
export {
|
|
18
|
+
Authenticated,
|
|
19
|
+
withAuthenticated
|
|
20
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare const defaultAuthConfig: AuthConfig;
|
|
4
|
+
declare const AuthConfigContext: React.Context<AuthConfig>;
|
|
5
|
+
interface AuthConfig {
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
loginRedirectUri?: string;
|
|
9
|
+
messageHandlerKeys?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { type AuthConfig, AuthConfigContext, defaultAuthConfig };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare const defaultAuthConfig: AuthConfig;
|
|
4
|
+
declare const AuthConfigContext: React.Context<AuthConfig>;
|
|
5
|
+
interface AuthConfig {
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
loginRedirectUri?: string;
|
|
9
|
+
messageHandlerKeys?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { type AuthConfig, AuthConfigContext, defaultAuthConfig };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunk32AVT4GAjs = require('./chunk-32AVT4GA.js');
|
|
5
|
+
require('./chunk-P57PW2II.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.AuthConfigContext = _chunk32AVT4GAjs.AuthConfigContext; exports.defaultAuthConfig = _chunk32AVT4GAjs.defaultAuthConfig;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
|
|
3
|
+
var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkZW4GP2I5js = require('./chunk-ZW4GP2I5.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkA2V2S4HPjs = require('./chunk-A2V2S4HP.js');
|
|
11
|
+
|
|
12
|
+
// src/provider/AfterAuth.tsx
|
|
13
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
14
|
+
var logger = console;
|
|
15
|
+
function AfterAuth({ children }) {
|
|
16
|
+
const authConfig = _chunk3ZTSLDX7js.useAuthConfig.call(void 0, );
|
|
17
|
+
const authState = _chunkA2V2S4HPjs.useAuthState.call(void 0, );
|
|
18
|
+
const keycloak = _chunkZW4GP2I5js.useKeycloak.call(void 0, );
|
|
19
|
+
_react.useEffect.call(void 0, () => {
|
|
20
|
+
if (!_chunkA2V2S4HPjs.persist || !_optionalChain([keycloak, 'optionalAccess', _ => _.authenticated]))
|
|
21
|
+
return;
|
|
22
|
+
if (keycloak.token) {
|
|
23
|
+
authState.setToken(keycloak.token);
|
|
24
|
+
if (keycloak.idToken)
|
|
25
|
+
authState.setIdToken(keycloak.idToken);
|
|
26
|
+
if (keycloak.refreshToken)
|
|
27
|
+
authState.setRefreshToken(keycloak.refreshToken);
|
|
28
|
+
}
|
|
29
|
+
}, [_optionalChain([keycloak, 'optionalAccess', _2 => _2.authenticated]), _optionalChain([keycloak, 'optionalAccess', _3 => _3.token]), _optionalChain([keycloak, 'optionalAccess', _4 => _4.idToken]), _optionalChain([keycloak, 'optionalAccess', _5 => _5.refreshToken])]);
|
|
30
|
+
_react.useEffect.call(void 0, () => {
|
|
31
|
+
if (authConfig.debug && _optionalChain([keycloak, 'optionalAccess', _6 => _6.token]))
|
|
32
|
+
logger.debug("token", keycloak.token);
|
|
33
|
+
}, [_optionalChain([keycloak, 'optionalAccess', _7 => _7.token])]);
|
|
34
|
+
_react.useEffect.call(void 0, () => {
|
|
35
|
+
if (authConfig.debug && _optionalChain([keycloak, 'optionalAccess', _8 => _8.idToken]))
|
|
36
|
+
logger.debug("idToken", keycloak.idToken);
|
|
37
|
+
}, [_optionalChain([keycloak, 'optionalAccess', _9 => _9.idToken])]);
|
|
38
|
+
_react.useEffect.call(void 0, () => {
|
|
39
|
+
if (authConfig.debug && _optionalChain([keycloak, 'optionalAccess', _10 => _10.refreshToken]))
|
|
40
|
+
logger.debug("refreshToken", keycloak.refreshToken);
|
|
41
|
+
}, [_optionalChain([keycloak, 'optionalAccess', _11 => _11.refreshToken])]);
|
|
42
|
+
_react.useEffect.call(void 0, () => {
|
|
43
|
+
if (_optionalChain([keycloak, 'optionalAccess', _12 => _12.authenticated]))
|
|
44
|
+
logger.debug("authenticated", keycloak.authenticated);
|
|
45
|
+
}, [_optionalChain([keycloak, 'optionalAccess', _13 => _13.authenticated])]);
|
|
46
|
+
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
exports.AfterAuth = AfterAuth;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkTUJRPTZEjs = require('./chunk-TUJRPTZE.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk3ZTSLDX7js = require('./chunk-3ZTSLDX7.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkI5FNGKQ6js = require('./chunk-I5FNGKQ6.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkZW4GP2I5js = require('./chunk-ZW4GP2I5.js');
|
|
13
|
+
|
|
14
|
+
// src/Authenticated.tsx
|
|
15
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
16
|
+
var _multiplatformone = require('multiplatform.one');
|
|
17
|
+
function Authenticated({ children, disabled, loggedOutComponent, loadingComponent }) {
|
|
18
|
+
const authConfig = _chunk3ZTSLDX7js.useAuthConfig.call(void 0, );
|
|
19
|
+
const keycloak = _chunkZW4GP2I5js.useKeycloak.call(void 0, );
|
|
20
|
+
const tokensFromQuery = _chunkTUJRPTZEjs.useTokensFromQuery.call(void 0, );
|
|
21
|
+
const tokensFromState = _chunkI5FNGKQ6js.useTokensFromState.call(void 0, );
|
|
22
|
+
_react.useEffect.call(void 0, () => {
|
|
23
|
+
if (!keycloak || _multiplatformone.MultiPlatform.isIframe || _multiplatformone.MultiPlatform.isServer || keycloak.authenticated || tokensFromQuery || tokensFromState) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
keycloak.login({
|
|
27
|
+
redirectUri: authConfig.loginRedirectUri
|
|
28
|
+
});
|
|
29
|
+
}, [keycloak]);
|
|
30
|
+
if (typeof disabled === "undefined")
|
|
31
|
+
disabled = authConfig.disabled;
|
|
32
|
+
if (disabled)
|
|
33
|
+
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
|
|
34
|
+
if (typeof keycloak === "undefined") {
|
|
35
|
+
const LoadingComponent = loadingComponent;
|
|
36
|
+
return LoadingComponent ? /* @__PURE__ */ _react2.default.createElement(LoadingComponent, null) : /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, authConfig.debug ? "loading" : null);
|
|
37
|
+
}
|
|
38
|
+
if (keycloak.authenticated)
|
|
39
|
+
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, children);
|
|
40
|
+
const LoggedOutComponent = loggedOutComponent;
|
|
41
|
+
return LoggedOutComponent ? /* @__PURE__ */ _react2.default.createElement(LoggedOutComponent, null) : /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, authConfig.debug ? "not authenticated" : null);
|
|
42
|
+
}
|
|
43
|
+
function withAuthenticated(Component) {
|
|
44
|
+
return (props) => /* @__PURE__ */ _react2.default.createElement(Authenticated, null, /* @__PURE__ */ _react2.default.createElement(Component, { ...props }));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.Authenticated = Authenticated; exports.withAuthenticated = withAuthenticated;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/token.ts
|
|
2
|
+
var _jwtdecode = require('jwt-decode');
|
|
3
|
+
function validToken(token, refreshToken) {
|
|
4
|
+
if (typeof token === "undefined")
|
|
5
|
+
return;
|
|
6
|
+
if (!token)
|
|
7
|
+
return false;
|
|
8
|
+
if (typeof token !== "string")
|
|
9
|
+
return token;
|
|
10
|
+
if (refreshToken) {
|
|
11
|
+
if (refreshToken === true || isTokenValid(refreshToken))
|
|
12
|
+
return token;
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return isTokenValid(token) ? token : false;
|
|
16
|
+
}
|
|
17
|
+
function isTokenValid(token) {
|
|
18
|
+
const { exp } = _jwtdecode.jwtDecode.call(void 0, token);
|
|
19
|
+
if (!exp)
|
|
20
|
+
return false;
|
|
21
|
+
return Math.floor(Date.now() / 1e3) <= exp;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
exports.validToken = validToken; exports.isTokenValid = isTokenValid;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/authConfig.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
var defaultAuthConfig = {};
|
|
4
|
+
var AuthConfigContext = _react.createContext.call(void 0, defaultAuthConfig);
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.defaultAuthConfig = defaultAuthConfig; exports.AuthConfigContext = AuthConfigContext;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk32AVT4GAjs = require('./chunk-32AVT4GA.js');
|
|
4
|
+
|
|
5
|
+
// src/hooks/useAuthConfig.ts
|
|
6
|
+
var _react = require('react');
|
|
7
|
+
function useAuthConfig() {
|
|
8
|
+
return _react.useContext.call(void 0, _chunk32AVT4GAjs.AuthConfigContext);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.useAuthConfig = useAuthConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/token.ts
|
|
2
|
+
import { jwtDecode } from "jwt-decode";
|
|
3
|
+
function validToken(token, refreshToken) {
|
|
4
|
+
if (typeof token === "undefined")
|
|
5
|
+
return;
|
|
6
|
+
if (!token)
|
|
7
|
+
return false;
|
|
8
|
+
if (typeof token !== "string")
|
|
9
|
+
return token;
|
|
10
|
+
if (refreshToken) {
|
|
11
|
+
if (refreshToken === true || isTokenValid(refreshToken))
|
|
12
|
+
return token;
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return isTokenValid(token) ? token : false;
|
|
16
|
+
}
|
|
17
|
+
function isTokenValid(token) {
|
|
18
|
+
const { exp } = jwtDecode(token);
|
|
19
|
+
if (!exp)
|
|
20
|
+
return false;
|
|
21
|
+
return Math.floor(Date.now() / 1e3) <= exp;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
validToken,
|
|
26
|
+
isTokenValid
|
|
27
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/state.ts
|
|
2
|
+
var _zustand = require('multiplatform.one/zustand');
|
|
3
|
+
var _multiplatformone = require('multiplatform.one');
|
|
4
|
+
var persist = _multiplatformone.MultiPlatform.isIframe || !_multiplatformone.MultiPlatform.isNext && !_multiplatformone.MultiPlatform.isServer;
|
|
5
|
+
var { useStore } = _zustand.createStateStore.call(void 0,
|
|
6
|
+
"auth",
|
|
7
|
+
{
|
|
8
|
+
idToken: "",
|
|
9
|
+
refreshToken: "",
|
|
10
|
+
token: ""
|
|
11
|
+
},
|
|
12
|
+
void 0,
|
|
13
|
+
{ persist }
|
|
14
|
+
);
|
|
15
|
+
function useAuthState() {
|
|
16
|
+
return useStore();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.persist = persist; exports.useAuthState = useAuthState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|