@multiplatform.one/keycloak 0.7.15 → 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.js +1 -1
- package/lib/Authenticated.d.mts +2 -2
- package/lib/Authenticated.d.ts +2 -2
- package/lib/Authenticated.js +20 -19
- package/lib/Authenticated.mjs +13 -13
- package/lib/authConfig.d.mts +2 -4
- package/lib/authConfig.d.ts +2 -4
- package/lib/authConfig.js +9 -8
- package/lib/authConfig.mjs +2 -2
- 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-7MTPH6XK.mjs → chunk-6FRYV4MK.mjs} +10 -9
- package/lib/chunk-A2V2S4HP.js +22 -0
- package/lib/chunk-BUZONXAW.js +1 -0
- package/lib/{chunk-BVB33X7V.mjs → chunk-CGLMLNUS.mjs} +61 -81
- package/lib/chunk-FU4CT24B.mjs +32 -0
- package/lib/{chunk-Y4XMF3R6.mjs → chunk-HTWZLBA4.mjs} +1 -1
- package/lib/chunk-I5FNGKQ6.js +16 -0
- package/lib/{chunk-64PPU7Q3.mjs → chunk-JAFUI2JQ.mjs} +1 -5
- package/lib/{chunk-NXTVYIBR.mjs → chunk-L3HTVJ4B.mjs} +2 -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-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-UOKDJT5L.mjs → chunk-UKSHA3X3.mjs} +2 -2
- package/lib/chunk-VS4M7GMO.js +1 -0
- package/lib/chunk-WBQAMGXK.mjs +0 -0
- package/lib/{chunk-AD6VPMID.mjs → chunk-WMH347OL.mjs} +5 -3
- 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 +0 -4
- package/lib/hooks/index.d.ts +0 -4
- package/lib/hooks/index.js +19 -23
- package/lib/hooks/index.mjs +8 -23
- package/lib/hooks/useAuthConfig.js +8 -8
- package/lib/hooks/useAuthConfig.mjs +3 -3
- package/lib/hooks/useTokensFromQuery/index.js +7 -7
- package/lib/hooks/useTokensFromQuery/index.mjs +2 -2
- package/lib/hooks/useTokensFromQuery/index.native.js +5 -8
- package/lib/hooks/useTokensFromQuery/index.native.mjs +1 -1
- package/lib/hooks/useTokensFromState.js +9 -9
- package/lib/hooks/useTokensFromState.mjs +4 -4
- package/lib/index.d.mts +10 -7
- package/lib/index.d.ts +10 -7
- package/lib/index.js +62 -34
- package/lib/index.mjs +32 -26
- 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.ts → AfterAuth.d.mts} +6 -7
- package/lib/provider/{afterAuth.d.mts → AfterAuth.d.ts} +6 -7
- 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/{keycloakProvider.native.d.ts → AuthProvider/AuthProvider.native.d.mts} +9 -9
- package/lib/provider/{keycloakProvider.native.d.mts → AuthProvider/AuthProvider.native.d.ts} +9 -9
- 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 -39
- package/lib/provider/index.d.ts +8 -39
- package/lib/provider/index.js +28 -22
- package/lib/provider/index.mjs +22 -19
- 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/index.d.ts → state.d.mts} +2 -1
- package/lib/{state/index.d.mts → state.d.ts} +2 -1
- 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/{util.mjs → token.mjs} +2 -2
- package/lib/types.d.mts +5 -2
- package/lib/types.d.ts +5 -2
- package/lib/types.js +1 -8
- package/lib/types.mjs +1 -7
- package/package.json +28 -28
- package/routes/index.d.ts +22 -0
- package/routes/index.js +22 -0
- package/src/Authenticated.tsx +27 -17
- package/src/authConfig.ts +3 -9
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useTokensFromQuery/index.ts +1 -0
- package/src/hooks/useTokensFromState.ts +1 -1
- package/src/index.ts +3 -0
- package/src/{@types/coreJsPure.d.ts → keycloak/context.ts} +6 -11
- package/src/{hooks/useCurrentRouteName/index.native.ts → keycloak/index.ts} +4 -11
- package/src/keycloak/keycloak.native.ts +148 -0
- package/src/keycloak/keycloak.ts +175 -0
- package/src/provider/AfterAuth.tsx +63 -0
- package/src/provider/{keycloakProvider.native.tsx → AuthProvider/AuthProvider.native.tsx} +8 -16
- package/src/provider/{keycloakProvider.tsx → AuthProvider/AuthProvider.tsx} +81 -94
- package/src/provider/AuthProvider/index.ts +22 -0
- package/src/provider/KeycloakProvider.tsx +53 -0
- package/src/provider/index.ts +24 -0
- package/src/routes.ts +163 -0
- package/src/session/index.ts +22 -0
- package/src/{hooks/useCurrentRouteName/index.ts → session/session.native.ts} +11 -14
- package/src/session/session.ts +68 -0
- package/src/{state/index.ts → state.ts} +5 -4
- package/src/{util.ts → token.ts} +25 -11
- package/src/types.ts +4 -1
- package/lib/@types/coreJsPure.d.d.mts +0 -2
- package/lib/@types/coreJsPure.d.d.ts +0 -2
- package/lib/@types/coreJsPure.d.js +0 -1
- package/lib/chunk-3ZPHNEJL.js +0 -11
- package/lib/chunk-6NDWOV55.js +0 -1
- package/lib/chunk-A7UBOIAL.js +0 -13
- package/lib/chunk-AUUZ6BI7.js +0 -78
- package/lib/chunk-C2FNSVJO.js +0 -17
- package/lib/chunk-J4CCMILN.mjs +0 -41
- package/lib/chunk-K33RKJZX.js +0 -443
- package/lib/chunk-KLLABHIC.js +0 -13
- package/lib/chunk-L5HMOY4M.mjs +0 -18
- package/lib/chunk-MZ6E62HK.js +0 -33
- package/lib/chunk-NWRANDZ6.js +0 -98
- package/lib/chunk-OYWAYMFN.js +0 -17
- package/lib/chunk-RPUOO7AV.mjs +0 -10
- package/lib/chunk-RYM7KERK.mjs +0 -52
- package/lib/chunk-UBVYEZI3.js +0 -1
- package/lib/chunk-UHTKOFS6.mjs +0 -84
- package/lib/chunk-UL6L5ONI.js +0 -460
- package/lib/chunk-W5DJLFTQ.js +0 -56
- package/lib/chunk-WT5W6BSZ.js +0 -161
- package/lib/chunk-XEO3YXBM.js +0 -22
- package/lib/chunk-XO4W2SMN.mjs +0 -50
- package/lib/chunk-XVPWAAZ4.mjs +0 -76
- package/lib/chunk-YGNNHTFE.js +0 -12
- package/lib/hooks/useCurrentRouteName/index.d.mts +0 -3
- package/lib/hooks/useCurrentRouteName/index.d.ts +0 -3
- package/lib/hooks/useCurrentRouteName/index.js +0 -7
- package/lib/hooks/useCurrentRouteName/index.mjs +0 -7
- package/lib/hooks/useCurrentRouteName/index.native.d.mts +0 -3
- package/lib/hooks/useCurrentRouteName/index.native.d.ts +0 -3
- package/lib/hooks/useCurrentRouteName/index.native.js +0 -14
- package/lib/hooks/useCurrentRouteName/index.native.mjs +0 -14
- package/lib/hooks/useKeycloak/index.d.mts +0 -46
- package/lib/hooks/useKeycloak/index.d.ts +0 -46
- package/lib/hooks/useKeycloak/index.js +0 -11
- package/lib/hooks/useKeycloak/index.mjs +0 -12
- package/lib/hooks/useKeycloak/useKeycloak.d.mts +0 -2
- package/lib/hooks/useKeycloak/useKeycloak.d.ts +0 -2
- package/lib/hooks/useKeycloak/useKeycloak.js +0 -10
- package/lib/hooks/useKeycloak/useKeycloak.mjs +0 -11
- package/lib/hooks/useKeycloak/useKeycloak.native.d.mts +0 -20
- package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +0 -20
- package/lib/hooks/useKeycloak/useKeycloak.native.js +0 -80
- package/lib/hooks/useKeycloak/useKeycloak.native.mjs +0 -69
- package/lib/hooks/useLogin.d.mts +0 -3
- package/lib/hooks/useLogin.d.ts +0 -3
- package/lib/hooks/useLogin.js +0 -11
- package/lib/hooks/useLogin.mjs +0 -11
- package/lib/provider/afterAuth.js +0 -18
- package/lib/provider/afterAuth.mjs +0 -18
- package/lib/provider/keycloakProvider.d.mts +0 -42
- package/lib/provider/keycloakProvider.d.ts +0 -42
- package/lib/provider/keycloakProvider.js +0 -20
- package/lib/provider/keycloakProvider.mjs +0 -21
- package/lib/provider/keycloakProvider.native.js +0 -87
- package/lib/provider/keycloakProvider.native.mjs +0 -30
- package/lib/state/index.js +0 -7
- package/lib/state/index.mjs +0 -7
- package/lib/util.d.mts +0 -4
- package/lib/util.d.ts +0 -4
- package/lib/util.js +0 -8
- package/src/hooks/useKeycloak/index.ts +0 -47
- package/src/hooks/useKeycloak/useKeycloak.native.ts +0 -95
- package/src/hooks/useKeycloak/useKeycloak.ts +0 -106
- package/src/hooks/useLogin.ts +0 -47
- package/src/provider/afterAuth.tsx +0 -65
- package/src/provider/index.tsx +0 -117
- /package/lib/{@types/coreJsPure.d.mjs → chunk-HH32BME2.mjs} +0 -0
- /package/lib/{chunk-2GUOEPFY.mjs → chunk-JPQI72HR.mjs} +0 -0
- /package/lib/{chunk-AYKQVWMR.mjs → chunk-OAUYHIWG.mjs} +0 -0
package/lib/index.mjs
CHANGED
|
@@ -1,55 +1,61 @@
|
|
|
1
|
+
import "./chunk-UESWAK47.mjs";
|
|
2
|
+
import {
|
|
3
|
+
KeycloakProvider
|
|
4
|
+
} from "./chunk-Y5MS3XVZ.mjs";
|
|
5
|
+
import "./chunk-OAUYHIWG.mjs";
|
|
6
|
+
import "./chunk-JPQI72HR.mjs";
|
|
1
7
|
import {
|
|
2
8
|
AuthProvider
|
|
3
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CGLMLNUS.mjs";
|
|
4
10
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./chunk-BVB33X7V.mjs";
|
|
8
|
-
import "./chunk-XO4W2SMN.mjs";
|
|
11
|
+
AfterAuth
|
|
12
|
+
} from "./chunk-Y23BWOII.mjs";
|
|
9
13
|
import {
|
|
10
14
|
Authenticated,
|
|
11
15
|
withAuthenticated
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-2GUOEPFY.mjs";
|
|
16
|
+
} from "./chunk-OA5TSQWZ.mjs";
|
|
17
|
+
import "./chunk-HH32BME2.mjs";
|
|
15
18
|
import {
|
|
16
19
|
useTokensFromQuery
|
|
17
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-L3HTVJ4B.mjs";
|
|
18
21
|
import {
|
|
19
|
-
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
useAuthConfig
|
|
23
|
+
} from "./chunk-HTWZLBA4.mjs";
|
|
21
24
|
import {
|
|
22
|
-
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
useTokensFromState
|
|
26
|
+
} from "./chunk-UKSHA3X3.mjs";
|
|
27
|
+
import "./chunk-OBB23GPX.mjs";
|
|
24
28
|
import {
|
|
25
29
|
Keycloak,
|
|
30
|
+
getKeycloak,
|
|
26
31
|
useKeycloak
|
|
27
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-UH4K7HGE.mjs";
|
|
33
|
+
import "./chunk-2L5TXBDK.mjs";
|
|
28
34
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
useTokensFromState
|
|
33
|
-
} from "./chunk-UOKDJT5L.mjs";
|
|
34
|
-
import "./chunk-AD6VPMID.mjs";
|
|
35
|
+
getSession,
|
|
36
|
+
useSession
|
|
37
|
+
} from "./chunk-FU4CT24B.mjs";
|
|
35
38
|
import {
|
|
36
39
|
AuthConfigContext,
|
|
37
40
|
defaultAuthConfig
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import "./chunk-
|
|
40
|
-
import "./chunk-
|
|
41
|
+
} from "./chunk-JAFUI2JQ.mjs";
|
|
42
|
+
import "./chunk-WMH347OL.mjs";
|
|
43
|
+
import "./chunk-6FRYV4MK.mjs";
|
|
44
|
+
import "./chunk-ZFXKCRJC.mjs";
|
|
45
|
+
import "./chunk-WBQAMGXK.mjs";
|
|
41
46
|
export {
|
|
47
|
+
AfterAuth,
|
|
42
48
|
AuthConfigContext,
|
|
43
49
|
AuthProvider,
|
|
44
50
|
Authenticated,
|
|
45
51
|
Keycloak,
|
|
46
52
|
KeycloakProvider,
|
|
47
53
|
defaultAuthConfig,
|
|
48
|
-
|
|
54
|
+
getKeycloak,
|
|
55
|
+
getSession,
|
|
49
56
|
useAuthConfig,
|
|
50
|
-
useCurrentRouteName,
|
|
51
57
|
useKeycloak,
|
|
52
|
-
|
|
58
|
+
useSession,
|
|
53
59
|
useTokensFromQuery,
|
|
54
60
|
useTokensFromState,
|
|
55
61
|
withAuthenticated
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Keycloak } from './keycloak.mjs';
|
|
3
|
+
import 'keycloak-js';
|
|
4
|
+
import '../token.mjs';
|
|
5
|
+
import '../types.mjs';
|
|
6
|
+
import '../session/session.mjs';
|
|
7
|
+
import 'next-auth';
|
|
8
|
+
import 'next-auth/react';
|
|
9
|
+
|
|
10
|
+
declare const KeycloakContext: React.Context<Keycloak | undefined>;
|
|
11
|
+
|
|
12
|
+
export { KeycloakContext };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Keycloak } from './keycloak.js';
|
|
3
|
+
import 'keycloak-js';
|
|
4
|
+
import '../token.js';
|
|
5
|
+
import '../types.js';
|
|
6
|
+
import '../session/session.js';
|
|
7
|
+
import 'next-auth';
|
|
8
|
+
import 'next-auth/react';
|
|
9
|
+
|
|
10
|
+
declare const KeycloakContext: React.Context<Keycloak | undefined>;
|
|
11
|
+
|
|
12
|
+
export { KeycloakContext };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-VS4M7GMO.js');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkZW4GP2I5js = require('../chunk-ZW4GP2I5.js');
|
|
7
|
+
require('../chunk-YACGLW5Q.js');
|
|
8
|
+
require('../chunk-NH335CDK.js');
|
|
9
|
+
require('../chunk-P57PW2II.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.Keycloak = _chunkZW4GP2I5js.Keycloak; exports.getKeycloak = _chunkZW4GP2I5js.getKeycloak; exports.useKeycloak = _chunkZW4GP2I5js.useKeycloak;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "../chunk-OBB23GPX.mjs";
|
|
2
|
+
import {
|
|
3
|
+
Keycloak,
|
|
4
|
+
getKeycloak,
|
|
5
|
+
useKeycloak
|
|
6
|
+
} from "../chunk-UH4K7HGE.mjs";
|
|
7
|
+
import "../chunk-2L5TXBDK.mjs";
|
|
8
|
+
import "../chunk-FU4CT24B.mjs";
|
|
9
|
+
import "../chunk-ZFXKCRJC.mjs";
|
|
10
|
+
export {
|
|
11
|
+
Keycloak,
|
|
12
|
+
getKeycloak,
|
|
13
|
+
useKeycloak
|
|
14
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as keycloak_js from 'keycloak-js';
|
|
2
|
+
import keycloak_js__default, { KeycloakLoginOptions, KeycloakLogoutOptions } from 'keycloak-js';
|
|
3
|
+
import { AccessTokenParsed, TokenParsed } from '../token.mjs';
|
|
4
|
+
import { KeycloakMock } from '../types.mjs';
|
|
5
|
+
import { Session } from '../session/session.mjs';
|
|
6
|
+
import 'next-auth';
|
|
7
|
+
import 'next-auth/react';
|
|
8
|
+
|
|
9
|
+
declare class Keycloak {
|
|
10
|
+
token?: string;
|
|
11
|
+
idToken?: string;
|
|
12
|
+
refreshToken?: string;
|
|
13
|
+
private _idTokenParsed?;
|
|
14
|
+
private _refreshTokenParsed?;
|
|
15
|
+
private _tokenParsed?;
|
|
16
|
+
private keycloakClient?;
|
|
17
|
+
private mock;
|
|
18
|
+
constructor(input?: string | keycloak_js__default | KeycloakMock | Session, idToken?: string, refreshToken?: string);
|
|
19
|
+
get tokenParsed(): AccessTokenParsed | undefined;
|
|
20
|
+
get idTokenParsed(): TokenParsed | undefined;
|
|
21
|
+
get refreshTokenParsed(): TokenParsed | undefined;
|
|
22
|
+
get clientId(): string | undefined;
|
|
23
|
+
get email(): any;
|
|
24
|
+
get realm(): string | undefined;
|
|
25
|
+
get realmAccess(): keycloak_js.KeycloakRoles | undefined;
|
|
26
|
+
get resourceAccess(): keycloak_js.KeycloakResourceAccess | undefined;
|
|
27
|
+
get sessionId(): string | undefined;
|
|
28
|
+
get subject(): string | undefined;
|
|
29
|
+
get username(): string | undefined;
|
|
30
|
+
login(options?: KeycloakLoginOptions): Promise<void>;
|
|
31
|
+
logout(options?: KeycloakLogoutOptions): Promise<void>;
|
|
32
|
+
get authenticated(): boolean;
|
|
33
|
+
}
|
|
34
|
+
declare function useKeycloak(): Keycloak | undefined;
|
|
35
|
+
declare function getKeycloak(): Promise<Keycloak>;
|
|
36
|
+
|
|
37
|
+
export { Keycloak, getKeycloak, useKeycloak };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as keycloak_js from 'keycloak-js';
|
|
2
|
+
import keycloak_js__default, { KeycloakLoginOptions, KeycloakLogoutOptions } from 'keycloak-js';
|
|
3
|
+
import { AccessTokenParsed, TokenParsed } from '../token.js';
|
|
4
|
+
import { KeycloakMock } from '../types.js';
|
|
5
|
+
import { Session } from '../session/session.js';
|
|
6
|
+
import 'next-auth';
|
|
7
|
+
import 'next-auth/react';
|
|
8
|
+
|
|
9
|
+
declare class Keycloak {
|
|
10
|
+
token?: string;
|
|
11
|
+
idToken?: string;
|
|
12
|
+
refreshToken?: string;
|
|
13
|
+
private _idTokenParsed?;
|
|
14
|
+
private _refreshTokenParsed?;
|
|
15
|
+
private _tokenParsed?;
|
|
16
|
+
private keycloakClient?;
|
|
17
|
+
private mock;
|
|
18
|
+
constructor(input?: string | keycloak_js__default | KeycloakMock | Session, idToken?: string, refreshToken?: string);
|
|
19
|
+
get tokenParsed(): AccessTokenParsed | undefined;
|
|
20
|
+
get idTokenParsed(): TokenParsed | undefined;
|
|
21
|
+
get refreshTokenParsed(): TokenParsed | undefined;
|
|
22
|
+
get clientId(): string | undefined;
|
|
23
|
+
get email(): any;
|
|
24
|
+
get realm(): string | undefined;
|
|
25
|
+
get realmAccess(): keycloak_js.KeycloakRoles | undefined;
|
|
26
|
+
get resourceAccess(): keycloak_js.KeycloakResourceAccess | undefined;
|
|
27
|
+
get sessionId(): string | undefined;
|
|
28
|
+
get subject(): string | undefined;
|
|
29
|
+
get username(): string | undefined;
|
|
30
|
+
login(options?: KeycloakLoginOptions): Promise<void>;
|
|
31
|
+
logout(options?: KeycloakLogoutOptions): Promise<void>;
|
|
32
|
+
get authenticated(): boolean;
|
|
33
|
+
}
|
|
34
|
+
declare function useKeycloak(): Keycloak | undefined;
|
|
35
|
+
declare function getKeycloak(): Promise<Keycloak>;
|
|
36
|
+
|
|
37
|
+
export { Keycloak, getKeycloak, useKeycloak };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkZW4GP2I5js = require('../chunk-ZW4GP2I5.js');
|
|
6
|
+
require('../chunk-YACGLW5Q.js');
|
|
7
|
+
require('../chunk-NH335CDK.js');
|
|
8
|
+
require('../chunk-P57PW2II.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.Keycloak = _chunkZW4GP2I5js.Keycloak; exports.getKeycloak = _chunkZW4GP2I5js.getKeycloak; exports.useKeycloak = _chunkZW4GP2I5js.useKeycloak;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as keycloak_js from 'keycloak-js';
|
|
2
|
+
import keycloak_js__default, { KeycloakLoginOptions, KeycloakLogoutOptions } from 'keycloak-js';
|
|
3
|
+
import { AccessTokenParsed, TokenParsed } from '../token.mjs';
|
|
4
|
+
import { KeycloakMock } from '../types.mjs';
|
|
5
|
+
|
|
6
|
+
declare class Keycloak {
|
|
7
|
+
token: string;
|
|
8
|
+
idToken?: string;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
private _tokenParsed?;
|
|
11
|
+
private _idTokenParsed?;
|
|
12
|
+
private _refreshTokenParsed?;
|
|
13
|
+
private keycloakClient?;
|
|
14
|
+
private mock;
|
|
15
|
+
constructor(input: string | keycloak_js__default | KeycloakMock, idToken?: string, refreshToken?: string);
|
|
16
|
+
get tokenParsed(): AccessTokenParsed | undefined;
|
|
17
|
+
get idTokenParsed(): TokenParsed | undefined;
|
|
18
|
+
get refreshTokenParsed(): TokenParsed | undefined;
|
|
19
|
+
get clientId(): string | undefined;
|
|
20
|
+
get email(): any;
|
|
21
|
+
get realm(): string | undefined;
|
|
22
|
+
get realmAccess(): keycloak_js.KeycloakRoles | undefined;
|
|
23
|
+
get resourceAccess(): keycloak_js.KeycloakResourceAccess | undefined;
|
|
24
|
+
get sessionId(): string | undefined;
|
|
25
|
+
get subject(): string | undefined;
|
|
26
|
+
get username(): string | undefined;
|
|
27
|
+
login(options?: KeycloakLoginOptions): Promise<void>;
|
|
28
|
+
logout(options?: KeycloakLogoutOptions): Promise<void>;
|
|
29
|
+
isAuthenticated(): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
declare function useKeycloak(): Keycloak | undefined;
|
|
32
|
+
|
|
33
|
+
export { Keycloak, useKeycloak };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as keycloak_js from 'keycloak-js';
|
|
2
|
+
import keycloak_js__default, { KeycloakLoginOptions, KeycloakLogoutOptions } from 'keycloak-js';
|
|
3
|
+
import { AccessTokenParsed, TokenParsed } from '../token.js';
|
|
4
|
+
import { KeycloakMock } from '../types.js';
|
|
5
|
+
|
|
6
|
+
declare class Keycloak {
|
|
7
|
+
token: string;
|
|
8
|
+
idToken?: string;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
private _tokenParsed?;
|
|
11
|
+
private _idTokenParsed?;
|
|
12
|
+
private _refreshTokenParsed?;
|
|
13
|
+
private keycloakClient?;
|
|
14
|
+
private mock;
|
|
15
|
+
constructor(input: string | keycloak_js__default | KeycloakMock, idToken?: string, refreshToken?: string);
|
|
16
|
+
get tokenParsed(): AccessTokenParsed | undefined;
|
|
17
|
+
get idTokenParsed(): TokenParsed | undefined;
|
|
18
|
+
get refreshTokenParsed(): TokenParsed | undefined;
|
|
19
|
+
get clientId(): string | undefined;
|
|
20
|
+
get email(): any;
|
|
21
|
+
get realm(): string | undefined;
|
|
22
|
+
get realmAccess(): keycloak_js.KeycloakRoles | undefined;
|
|
23
|
+
get resourceAccess(): keycloak_js.KeycloakResourceAccess | undefined;
|
|
24
|
+
get sessionId(): string | undefined;
|
|
25
|
+
get subject(): string | undefined;
|
|
26
|
+
get username(): string | undefined;
|
|
27
|
+
login(options?: KeycloakLoginOptions): Promise<void>;
|
|
28
|
+
logout(options?: KeycloakLogoutOptions): Promise<void>;
|
|
29
|
+
isAuthenticated(): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
declare function useKeycloak(): Keycloak | undefined;
|
|
32
|
+
|
|
33
|
+
export { Keycloak, useKeycloak };
|
|
@@ -0,0 +1,134 @@
|
|
|
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 _chunkNH335CDKjs = require('../chunk-NH335CDK.js');
|
|
4
|
+
require('../chunk-P57PW2II.js');
|
|
5
|
+
|
|
6
|
+
// src/keycloak/keycloak.native.ts
|
|
7
|
+
var _multiplatformone = require('multiplatform.one');
|
|
8
|
+
var _jwtdecode = require('jwt-decode');
|
|
9
|
+
var _expokeycloakauth = require('expo-keycloak-auth');
|
|
10
|
+
var Keycloak = class {
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
constructor(input, idToken, refreshToken) {
|
|
20
|
+
if (typeof input === "string") {
|
|
21
|
+
this.token = input;
|
|
22
|
+
this.idToken = idToken;
|
|
23
|
+
this.refreshToken = refreshToken;
|
|
24
|
+
} else if (typeof input === "object") {
|
|
25
|
+
if (typeof input.init === "function") {
|
|
26
|
+
this.keycloakClient = input;
|
|
27
|
+
} else {
|
|
28
|
+
this.mock = input;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (this.token && !this._tokenParsed)
|
|
32
|
+
this._tokenParsed = _jwtdecode.jwtDecode.call(void 0, this.token);
|
|
33
|
+
if (this.idToken && !this._idTokenParsed)
|
|
34
|
+
this._idTokenParsed = _jwtdecode.jwtDecode.call(void 0, this.idToken);
|
|
35
|
+
if (this.refreshToken && !this._refreshTokenParsed) {
|
|
36
|
+
this._refreshTokenParsed = _jwtdecode.jwtDecode.call(void 0, this.refreshToken);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get tokenParsed() {
|
|
40
|
+
if (this.keycloakClient)
|
|
41
|
+
return this.keycloakClient.tokenParsed;
|
|
42
|
+
return this._tokenParsed;
|
|
43
|
+
}
|
|
44
|
+
get idTokenParsed() {
|
|
45
|
+
if (this.keycloakClient)
|
|
46
|
+
return this.keycloakClient.idTokenParsed;
|
|
47
|
+
return this._idTokenParsed;
|
|
48
|
+
}
|
|
49
|
+
get refreshTokenParsed() {
|
|
50
|
+
if (this.keycloakClient)
|
|
51
|
+
return this.keycloakClient.refreshTokenParsed;
|
|
52
|
+
return this._refreshTokenParsed;
|
|
53
|
+
}
|
|
54
|
+
get clientId() {
|
|
55
|
+
if (this.keycloakClient)
|
|
56
|
+
return this.keycloakClient.clientId;
|
|
57
|
+
return _optionalChain([this, 'access', _ => _.tokenParsed, 'optionalAccess', _2 => _2.azp]);
|
|
58
|
+
}
|
|
59
|
+
get email() {
|
|
60
|
+
if (this.keycloakClient)
|
|
61
|
+
return _optionalChain([this, 'access', _3 => _3.keycloakClient, 'access', _4 => _4.tokenParsed, 'optionalAccess', _5 => _5.email]);
|
|
62
|
+
if (this.mock)
|
|
63
|
+
return this.mock.email;
|
|
64
|
+
return _optionalChain([this, 'access', _6 => _6.tokenParsed, 'optionalAccess', _7 => _7.email]);
|
|
65
|
+
}
|
|
66
|
+
get realm() {
|
|
67
|
+
if (this.keycloakClient)
|
|
68
|
+
return this.keycloakClient.realm;
|
|
69
|
+
return _optionalChain([this, 'access', _8 => _8.tokenParsed, 'optionalAccess', _9 => _9.iss, 'optionalAccess', _10 => _10.split, 'call', _11 => _11("/"), 'access', _12 => _12.pop, 'call', _13 => _13()]);
|
|
70
|
+
}
|
|
71
|
+
get realmAccess() {
|
|
72
|
+
if (this.keycloakClient)
|
|
73
|
+
return this.keycloakClient.realmAccess;
|
|
74
|
+
return _optionalChain([this, 'access', _14 => _14.tokenParsed, 'optionalAccess', _15 => _15.realm_access]);
|
|
75
|
+
}
|
|
76
|
+
get resourceAccess() {
|
|
77
|
+
if (this.keycloakClient)
|
|
78
|
+
return this.keycloakClient.resourceAccess;
|
|
79
|
+
return _optionalChain([this, 'access', _16 => _16.tokenParsed, 'optionalAccess', _17 => _17.resource_access]);
|
|
80
|
+
}
|
|
81
|
+
get sessionId() {
|
|
82
|
+
if (this.keycloakClient)
|
|
83
|
+
return this.keycloakClient.sessionId;
|
|
84
|
+
return _optionalChain([this, 'access', _18 => _18.tokenParsed, 'optionalAccess', _19 => _19.session_state]);
|
|
85
|
+
}
|
|
86
|
+
get subject() {
|
|
87
|
+
if (this.keycloakClient)
|
|
88
|
+
return this.keycloakClient.subject;
|
|
89
|
+
return _optionalChain([this, 'access', _20 => _20.tokenParsed, 'optionalAccess', _21 => _21.sub]);
|
|
90
|
+
}
|
|
91
|
+
get username() {
|
|
92
|
+
if (this.mock)
|
|
93
|
+
return this.mock.username;
|
|
94
|
+
return _optionalChain([this, 'access', _22 => _22.tokenParsed, 'optionalAccess', _23 => _23.preferred_username]);
|
|
95
|
+
}
|
|
96
|
+
async login(options = {}) {
|
|
97
|
+
if (this.keycloakClient) {
|
|
98
|
+
await this.keycloakClient.login(options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async logout(options = {}) {
|
|
102
|
+
if (this.keycloakClient) {
|
|
103
|
+
await this.keycloakClient.logout(options);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async isAuthenticated() {
|
|
107
|
+
if (this.mock)
|
|
108
|
+
return true;
|
|
109
|
+
if (this.keycloakClient)
|
|
110
|
+
return !!this.keycloakClient.authenticated;
|
|
111
|
+
if (_multiplatformone.MultiPlatform.isNext)
|
|
112
|
+
return !!await _chunkNH335CDKjs.getSession.call(void 0, );
|
|
113
|
+
if (!_optionalChain([this, 'access', _24 => _24.tokenParsed, 'optionalAccess', _25 => _25.exp]))
|
|
114
|
+
return false;
|
|
115
|
+
return this.tokenParsed.exp > Date.now() / 1e3;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function useKeycloak() {
|
|
119
|
+
const { token, refreshToken, idToken } = _expokeycloakauth.useKeycloak.call(void 0, );
|
|
120
|
+
if (_multiplatformone.MultiPlatform.isServer)
|
|
121
|
+
return;
|
|
122
|
+
if (_multiplatformone.MultiPlatform.isStorybook) {
|
|
123
|
+
return new Keycloak({
|
|
124
|
+
email: "storybook@example.com",
|
|
125
|
+
username: "storybook"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (token)
|
|
129
|
+
return new Keycloak(token, idToken, refreshToken);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
exports.Keycloak = Keycloak; exports.useKeycloak = useKeycloak;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSession
|
|
3
|
+
} from "../chunk-FU4CT24B.mjs";
|
|
4
|
+
import "../chunk-ZFXKCRJC.mjs";
|
|
5
|
+
|
|
6
|
+
// src/keycloak/keycloak.native.ts
|
|
7
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
8
|
+
import { jwtDecode } from "jwt-decode";
|
|
9
|
+
import { useKeycloak as useExpoKeycloak } from "expo-keycloak-auth";
|
|
10
|
+
var Keycloak = class {
|
|
11
|
+
token;
|
|
12
|
+
idToken;
|
|
13
|
+
refreshToken;
|
|
14
|
+
_tokenParsed;
|
|
15
|
+
_idTokenParsed;
|
|
16
|
+
_refreshTokenParsed;
|
|
17
|
+
keycloakClient;
|
|
18
|
+
mock;
|
|
19
|
+
constructor(input, idToken, refreshToken) {
|
|
20
|
+
if (typeof input === "string") {
|
|
21
|
+
this.token = input;
|
|
22
|
+
this.idToken = idToken;
|
|
23
|
+
this.refreshToken = refreshToken;
|
|
24
|
+
} else if (typeof input === "object") {
|
|
25
|
+
if (typeof input.init === "function") {
|
|
26
|
+
this.keycloakClient = input;
|
|
27
|
+
} else {
|
|
28
|
+
this.mock = input;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (this.token && !this._tokenParsed)
|
|
32
|
+
this._tokenParsed = jwtDecode(this.token);
|
|
33
|
+
if (this.idToken && !this._idTokenParsed)
|
|
34
|
+
this._idTokenParsed = jwtDecode(this.idToken);
|
|
35
|
+
if (this.refreshToken && !this._refreshTokenParsed) {
|
|
36
|
+
this._refreshTokenParsed = jwtDecode(this.refreshToken);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get tokenParsed() {
|
|
40
|
+
if (this.keycloakClient)
|
|
41
|
+
return this.keycloakClient.tokenParsed;
|
|
42
|
+
return this._tokenParsed;
|
|
43
|
+
}
|
|
44
|
+
get idTokenParsed() {
|
|
45
|
+
if (this.keycloakClient)
|
|
46
|
+
return this.keycloakClient.idTokenParsed;
|
|
47
|
+
return this._idTokenParsed;
|
|
48
|
+
}
|
|
49
|
+
get refreshTokenParsed() {
|
|
50
|
+
if (this.keycloakClient)
|
|
51
|
+
return this.keycloakClient.refreshTokenParsed;
|
|
52
|
+
return this._refreshTokenParsed;
|
|
53
|
+
}
|
|
54
|
+
get clientId() {
|
|
55
|
+
if (this.keycloakClient)
|
|
56
|
+
return this.keycloakClient.clientId;
|
|
57
|
+
return this.tokenParsed?.azp;
|
|
58
|
+
}
|
|
59
|
+
get email() {
|
|
60
|
+
if (this.keycloakClient)
|
|
61
|
+
return this.keycloakClient.tokenParsed?.email;
|
|
62
|
+
if (this.mock)
|
|
63
|
+
return this.mock.email;
|
|
64
|
+
return this.tokenParsed?.email;
|
|
65
|
+
}
|
|
66
|
+
get realm() {
|
|
67
|
+
if (this.keycloakClient)
|
|
68
|
+
return this.keycloakClient.realm;
|
|
69
|
+
return this.tokenParsed?.iss?.split("/").pop();
|
|
70
|
+
}
|
|
71
|
+
get realmAccess() {
|
|
72
|
+
if (this.keycloakClient)
|
|
73
|
+
return this.keycloakClient.realmAccess;
|
|
74
|
+
return this.tokenParsed?.realm_access;
|
|
75
|
+
}
|
|
76
|
+
get resourceAccess() {
|
|
77
|
+
if (this.keycloakClient)
|
|
78
|
+
return this.keycloakClient.resourceAccess;
|
|
79
|
+
return this.tokenParsed?.resource_access;
|
|
80
|
+
}
|
|
81
|
+
get sessionId() {
|
|
82
|
+
if (this.keycloakClient)
|
|
83
|
+
return this.keycloakClient.sessionId;
|
|
84
|
+
return this.tokenParsed?.session_state;
|
|
85
|
+
}
|
|
86
|
+
get subject() {
|
|
87
|
+
if (this.keycloakClient)
|
|
88
|
+
return this.keycloakClient.subject;
|
|
89
|
+
return this.tokenParsed?.sub;
|
|
90
|
+
}
|
|
91
|
+
get username() {
|
|
92
|
+
if (this.mock)
|
|
93
|
+
return this.mock.username;
|
|
94
|
+
return this.tokenParsed?.preferred_username;
|
|
95
|
+
}
|
|
96
|
+
async login(options = {}) {
|
|
97
|
+
if (this.keycloakClient) {
|
|
98
|
+
await this.keycloakClient.login(options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async logout(options = {}) {
|
|
102
|
+
if (this.keycloakClient) {
|
|
103
|
+
await this.keycloakClient.logout(options);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async isAuthenticated() {
|
|
107
|
+
if (this.mock)
|
|
108
|
+
return true;
|
|
109
|
+
if (this.keycloakClient)
|
|
110
|
+
return !!this.keycloakClient.authenticated;
|
|
111
|
+
if (MultiPlatform.isNext)
|
|
112
|
+
return !!await getSession();
|
|
113
|
+
if (!this.tokenParsed?.exp)
|
|
114
|
+
return false;
|
|
115
|
+
return this.tokenParsed.exp > Date.now() / 1e3;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function useKeycloak() {
|
|
119
|
+
const { token, refreshToken, idToken } = useExpoKeycloak();
|
|
120
|
+
if (MultiPlatform.isServer)
|
|
121
|
+
return;
|
|
122
|
+
if (MultiPlatform.isStorybook) {
|
|
123
|
+
return new Keycloak({
|
|
124
|
+
email: "storybook@example.com",
|
|
125
|
+
username: "storybook"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (token)
|
|
129
|
+
return new Keycloak(token, idToken, refreshToken);
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
Keycloak,
|
|
133
|
+
useKeycloak
|
|
134
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import React__default, { PropsWithChildren } from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* File: /src/provider/
|
|
4
|
+
* File: /src/provider/AfterAuth.tsx
|
|
5
5
|
* Project: @multiplatform.one/keycloak
|
|
6
|
-
* File Created:
|
|
6
|
+
* File Created: 10-01-2024 12:41:33
|
|
7
7
|
* Author: Clay Risser
|
|
8
8
|
* -----
|
|
9
|
-
* BitSpur (c) Copyright 2021 -
|
|
9
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
10
10
|
*
|
|
11
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
12
|
* you may not use this file except in compliance with the License.
|
|
@@ -21,9 +21,8 @@ import { ReactNode, FC } from 'react';
|
|
|
21
21
|
* limitations under the License.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
interface AfterAuthProps {
|
|
25
|
-
children: ReactNode;
|
|
24
|
+
interface AfterAuthProps extends PropsWithChildren {
|
|
26
25
|
}
|
|
27
|
-
declare
|
|
26
|
+
declare function AfterAuth({ children }: AfterAuthProps): React__default.JSX.Element;
|
|
28
27
|
|
|
29
28
|
export { AfterAuth, type AfterAuthProps };
|