@multiplatform.one/keycloak 0.3.32 → 0.3.33
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/dist/esm/hooks/useKeycloak/index.mjs.map +1 -1
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs +481 -45
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs.map +3 -3
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs.map +1 -1
- package/dist/jsx/hooks/useKeycloak/index.mjs.map +1 -1
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs +59 -15
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs.map +2 -2
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs.map +1 -1
- package/dist/lib/hooks/useKeycloak/index.d.ts +3 -4
- package/dist/lib/hooks/useKeycloak/index.js.map +1 -1
- package/dist/lib/hooks/useKeycloak/useKeycloak.d.ts +19 -2
- package/dist/lib/hooks/useKeycloak/useKeycloak.js +70 -31
- package/dist/lib/hooks/useKeycloak/useKeycloak.js.map +2 -2
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.d.ts +4 -4
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
- package/dist/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/hooks/useKeycloak/index.ts +3 -4
- package/src/hooks/useKeycloak/useKeycloak.native.ts +3 -3
- package/src/hooks/useKeycloak/useKeycloak.ts +71 -16
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* File Created: 08-11-2022 14:10:44
|
|
5
5
|
* Author: Clay Risser
|
|
6
6
|
* -----
|
|
7
|
-
* Last Modified:
|
|
7
|
+
* Last Modified: 01-06-2023 13:55:42
|
|
8
8
|
* Modified By: Clay Risser
|
|
9
9
|
* -----
|
|
10
10
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -37,9 +37,8 @@ export interface IKeycloak {
|
|
|
37
37
|
tokenParsed?: ITokenParsed;
|
|
38
38
|
email?: string;
|
|
39
39
|
username?: string;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
logout: () => Promise<unknown> | unknown;
|
|
40
|
+
login: () => Promise<unknown>;
|
|
41
|
+
logout: () => Promise<unknown>;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
export interface ITokenParsed extends KeycloakTokenParsed {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* File Created: 08-11-2022 14:10:25
|
|
5
5
|
* Author: Clay Risser
|
|
6
6
|
* -----
|
|
7
|
-
* Last Modified:
|
|
7
|
+
* Last Modified: 01-06-2023 14:04:46
|
|
8
8
|
* Modified By: Clay Risser
|
|
9
9
|
* -----
|
|
10
10
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -50,13 +50,13 @@ export class ExpoKeycloak implements IKeycloak {
|
|
|
50
50
|
|
|
51
51
|
resourceAccess?: KeycloakResourceAccess;
|
|
52
52
|
|
|
53
|
-
login: () => Promise<unknown
|
|
53
|
+
login: () => Promise<unknown>;
|
|
54
54
|
|
|
55
55
|
constructor(
|
|
56
56
|
ready: boolean,
|
|
57
57
|
isLoggedIn: boolean | undefined,
|
|
58
58
|
login: (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult | undefined>,
|
|
59
|
-
public logout: () => unknown
|
|
59
|
+
public logout: () => Promise<unknown>,
|
|
60
60
|
public token?: string,
|
|
61
61
|
public refreshToken?: string,
|
|
62
62
|
) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* File Created: 08-11-2022 06:04:59
|
|
5
5
|
* Author: Clay Risser
|
|
6
6
|
* -----
|
|
7
|
-
* Last Modified:
|
|
7
|
+
* Last Modified: 01-06-2023 14:02:40
|
|
8
8
|
* Modified By: Clay Risser
|
|
9
9
|
* -----
|
|
10
10
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -31,24 +31,79 @@ import { useKeycloak as useSsrKeycloak } from '@bitspur/react-keycloak-ssr';
|
|
|
31
31
|
export function useKeycloak() {
|
|
32
32
|
const authConfig = useAuthConfig();
|
|
33
33
|
if (MultiPlatform.isStorybook) {
|
|
34
|
-
return
|
|
34
|
+
return new Keycloak(
|
|
35
|
+
{
|
|
36
|
+
email: 'storybook@example.com',
|
|
37
|
+
login: async () => undefined,
|
|
38
|
+
logout: async () => undefined,
|
|
39
|
+
subject: '0',
|
|
40
|
+
username: 'storybook',
|
|
41
|
+
},
|
|
42
|
+
true,
|
|
43
|
+
);
|
|
35
44
|
}
|
|
36
45
|
if (MultiPlatform.isNext && authConfig.ssr) {
|
|
37
46
|
const { keycloak, initialized } = useSsrKeycloak();
|
|
38
|
-
return
|
|
39
|
-
...keycloak,
|
|
40
|
-
authenticated: initialized ? keycloak?.authenticated : undefined,
|
|
41
|
-
email: keycloak?.tokenParsed?.email,
|
|
42
|
-
userId: keycloak?.tokenParsed?.sub,
|
|
43
|
-
username: keycloak?.tokenParsed?.preferred_username,
|
|
44
|
-
} as IKeycloak;
|
|
47
|
+
return new Keycloak(keycloak, initialized);
|
|
45
48
|
}
|
|
46
49
|
const { keycloak, initialized } = useReactKeycloak();
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
return new Keycloak(keycloak, initialized);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class Keycloak implements IKeycloak {
|
|
54
|
+
authenticated?: boolean;
|
|
55
|
+
|
|
56
|
+
constructor(private readonly keycloak: IKeycloak | undefined, initialized: boolean) {
|
|
57
|
+
this.authenticated = initialized ? keycloak?.authenticated : undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get idToken() {
|
|
61
|
+
return this.keycloak?.idToken;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get realmAccess() {
|
|
65
|
+
return this.keycloak?.realmAccess;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get refreshToken() {
|
|
69
|
+
return this.keycloak?.refreshToken;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get refreshTokenParsed() {
|
|
73
|
+
return this.keycloak?.refreshTokenParsed;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get resourceAccess() {
|
|
77
|
+
return this.keycloak?.resourceAccess;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get subject() {
|
|
81
|
+
return this.keycloak?.subject;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get token() {
|
|
85
|
+
return this.keycloak?.token;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get tokenParsed() {
|
|
89
|
+
return this.keycloak?.tokenParsed;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get email() {
|
|
93
|
+
return this.keycloak?.tokenParsed?.email;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get username() {
|
|
97
|
+
return this.keycloak?.tokenParsed?.preferred_username;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async login() {
|
|
101
|
+
if (!this.keycloak) return;
|
|
102
|
+
return this.keycloak.login();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async logout() {
|
|
106
|
+
if (!this.keycloak) return;
|
|
107
|
+
return this.keycloak.logout();
|
|
108
|
+
}
|
|
54
109
|
}
|