@multiplatform.one/keycloak 1.0.13 → 1.0.15
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/cjs/Authenticated.js +3 -5
- package/dist/cjs/Authenticated.js.map +1 -1
- package/dist/cjs/Authenticated.native.js +7 -9
- package/dist/cjs/Authenticated.native.js.map +2 -2
- package/dist/cjs/authConfig.native.js.map +1 -1
- package/dist/cjs/hooks/index.native.js.map +1 -1
- package/dist/cjs/hooks/useAuthConfig.native.js.map +1 -1
- package/dist/cjs/hooks/useTokensFromQuery/index.js +1 -2
- package/dist/cjs/hooks/useTokensFromQuery/index.js.map +1 -1
- package/dist/cjs/hooks/useTokensFromQuery/index.native.js.map +1 -1
- package/dist/cjs/hooks/useTokensFromState.native.js.map +1 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/keycloak/config.native.js.map +1 -1
- package/dist/cjs/keycloak/context.native.js.map +1 -1
- package/dist/cjs/keycloak/index.native.js.map +1 -1
- package/dist/cjs/keycloak/keycloak.js +4 -19
- package/dist/cjs/keycloak/keycloak.js.map +1 -1
- package/dist/cjs/keycloak/keycloak.native.js +59 -61
- package/dist/cjs/keycloak/keycloak.native.js.map +2 -2
- package/dist/cjs/provider/AfterAuth.native.js.map +1 -1
- package/dist/cjs/provider/AuthProvider/AuthProvider.js +10 -10
- package/dist/cjs/provider/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/cjs/provider/AuthProvider/AuthProvider.native.js +61 -74
- package/dist/cjs/provider/AuthProvider/AuthProvider.native.js.map +2 -2
- package/dist/cjs/provider/AuthProvider/index.native.js.map +1 -1
- package/dist/cjs/provider/KeycloakProvider.native.js.map +1 -1
- package/dist/cjs/provider/index.native.js.map +1 -1
- package/dist/cjs/routes.js +4 -6
- package/dist/cjs/routes.js.map +1 -1
- package/dist/cjs/routes.native.js +71 -81
- package/dist/cjs/routes.native.js.map +3 -3
- package/dist/cjs/session/index.native.js.map +1 -1
- package/dist/cjs/session/session.js +3 -22
- package/dist/cjs/session/session.js.map +2 -2
- package/dist/cjs/session/session.native.js +53 -58
- package/dist/cjs/session/session.native.js.map +2 -2
- package/dist/cjs/state.native.js.map +1 -1
- package/dist/cjs/token.native.js.map +1 -1
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Authenticated.js +3 -5
- package/dist/esm/Authenticated.js.map +1 -1
- package/dist/esm/Authenticated.mjs +1 -1
- package/dist/esm/Authenticated.native.js +7 -9
- package/dist/esm/Authenticated.native.js.map +3 -3
- package/dist/esm/authConfig.native.js.map +1 -1
- package/dist/esm/hooks/index.native.js.map +1 -1
- package/dist/esm/hooks/useAuthConfig.native.js.map +1 -1
- package/dist/esm/hooks/useTokensFromQuery/index.js +1 -2
- package/dist/esm/hooks/useTokensFromQuery/index.js.map +1 -1
- package/dist/esm/hooks/useTokensFromQuery/index.native.js.map +1 -1
- package/dist/esm/hooks/useTokensFromState.native.js.map +1 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/keycloak/config.native.js.map +1 -1
- package/dist/esm/keycloak/context.native.js.map +1 -1
- package/dist/esm/keycloak/index.native.js.map +1 -1
- package/dist/esm/keycloak/keycloak.js +5 -20
- package/dist/esm/keycloak/keycloak.js.map +1 -1
- package/dist/esm/keycloak/keycloak.mjs +2 -13
- package/dist/esm/keycloak/keycloak.native.js +59 -61
- package/dist/esm/keycloak/keycloak.native.js.map +2 -2
- package/dist/esm/provider/AfterAuth.native.js.map +1 -1
- package/dist/esm/provider/AuthProvider/AuthProvider.js +10 -10
- package/dist/esm/provider/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/esm/provider/AuthProvider/AuthProvider.mjs +9 -5
- package/dist/esm/provider/AuthProvider/AuthProvider.native.js +61 -74
- package/dist/esm/provider/AuthProvider/AuthProvider.native.js.map +2 -2
- package/dist/esm/provider/AuthProvider/index.native.js.map +1 -1
- package/dist/esm/provider/KeycloakProvider.native.js.map +1 -1
- package/dist/esm/provider/index.native.js.map +1 -1
- package/dist/esm/routes.js +4 -6
- package/dist/esm/routes.js.map +1 -1
- package/dist/esm/routes.mjs +2 -2
- package/dist/esm/routes.native.js +71 -81
- package/dist/esm/routes.native.js.map +3 -3
- package/dist/esm/session/index.native.js.map +1 -1
- package/dist/esm/session/session.js +2 -13
- package/dist/esm/session/session.js.map +2 -2
- package/dist/esm/session/session.mjs +3 -12
- package/dist/esm/session/session.native.js +53 -58
- package/dist/esm/session/session.native.js.map +2 -2
- package/dist/esm/state.native.js.map +1 -1
- package/dist/esm/token.native.js.map +1 -1
- package/dist/jsx/Authenticated.js +3 -5
- package/dist/jsx/Authenticated.js.map +1 -1
- package/dist/jsx/Authenticated.mjs +1 -1
- package/dist/jsx/Authenticated.native.js +7 -9
- package/dist/jsx/Authenticated.native.js.map +3 -3
- package/dist/jsx/authConfig.native.js.map +1 -1
- package/dist/jsx/hooks/index.native.js.map +1 -1
- package/dist/jsx/hooks/useAuthConfig.native.js.map +1 -1
- package/dist/jsx/hooks/useTokensFromQuery/index.js +1 -2
- package/dist/jsx/hooks/useTokensFromQuery/index.js.map +1 -1
- package/dist/jsx/hooks/useTokensFromQuery/index.native.js.map +1 -1
- package/dist/jsx/hooks/useTokensFromState.native.js.map +1 -1
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/keycloak/config.native.js.map +1 -1
- package/dist/jsx/keycloak/context.native.js.map +1 -1
- package/dist/jsx/keycloak/index.native.js.map +1 -1
- package/dist/jsx/keycloak/keycloak.js +5 -20
- package/dist/jsx/keycloak/keycloak.js.map +1 -1
- package/dist/jsx/keycloak/keycloak.mjs +2 -13
- package/dist/jsx/keycloak/keycloak.native.js +59 -61
- package/dist/jsx/keycloak/keycloak.native.js.map +2 -2
- package/dist/jsx/provider/AfterAuth.native.js.map +1 -1
- package/dist/jsx/provider/AuthProvider/AuthProvider.js +10 -10
- package/dist/jsx/provider/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/jsx/provider/AuthProvider/AuthProvider.mjs +9 -5
- package/dist/jsx/provider/AuthProvider/AuthProvider.native.js +61 -74
- package/dist/jsx/provider/AuthProvider/AuthProvider.native.js.map +2 -2
- package/dist/jsx/provider/AuthProvider/index.native.js.map +1 -1
- package/dist/jsx/provider/KeycloakProvider.native.js.map +1 -1
- package/dist/jsx/provider/index.native.js.map +1 -1
- package/dist/jsx/routes.js +4 -6
- package/dist/jsx/routes.js.map +1 -1
- package/dist/jsx/routes.mjs +2 -2
- package/dist/jsx/routes.native.js +71 -81
- package/dist/jsx/routes.native.js.map +3 -3
- package/dist/jsx/session/index.native.js.map +1 -1
- package/dist/jsx/session/session.js +2 -13
- package/dist/jsx/session/session.js.map +2 -2
- package/dist/jsx/session/session.mjs +3 -12
- package/dist/jsx/session/session.native.js +53 -58
- package/dist/jsx/session/session.native.js.map +2 -2
- package/dist/jsx/state.native.js.map +1 -1
- package/dist/jsx/token.native.js.map +1 -1
- package/package.json +11 -13
- package/routes/index.d.ts +15 -15
- package/routes/index.js +15 -15
- package/src/@types/expoKeycloakAuth.d.ts +16 -16
- package/src/Authenticated.tsx +1 -2
- package/src/authConfig.ts +15 -15
- package/src/hooks/index.ts +15 -15
- package/src/hooks/useAuthConfig.ts +15 -15
- package/src/hooks/useTokensFromQuery/index.native.ts +15 -15
- package/src/hooks/useTokensFromQuery/index.ts +15 -15
- package/src/hooks/useTokensFromState.ts +15 -15
- package/src/index.ts +15 -15
- package/src/keycloak/config.ts +15 -15
- package/src/keycloak/context.ts +15 -15
- package/src/keycloak/index.ts +15 -15
- package/src/keycloak/keycloak.native.ts +15 -15
- package/src/keycloak/keycloak.ts +16 -36
- package/src/provider/AuthProvider/AuthProvider.tsx +7 -4
- package/src/provider/AuthProvider/index.ts +15 -15
- package/src/provider/index.ts +15 -15
- package/src/routes.ts +18 -21
- package/src/session/index.ts +15 -15
- package/src/session/session.native.ts +15 -15
- package/src/session/session.ts +18 -32
- package/src/state.ts +15 -15
- package/src/token.ts +15 -15
- package/src/types.ts +15 -15
- package/types/Authenticated.d.ts.map +1 -1
- package/types/keycloak/keycloak.d.ts +0 -2
- package/types/keycloak/keycloak.d.ts.map +1 -1
- package/types/provider/AuthProvider/AuthProvider.d.ts.map +1 -1
- package/types/routes.d.ts.map +1 -1
- package/types/session/session.d.ts +1 -2
- package/types/session/session.d.ts.map +1 -1
- package/dist/esm/hooks/useTokensFromQuery/index.native.mjs +0 -2
- package/dist/esm/keycloak/keycloak.native.mjs +0 -84
- package/dist/esm/provider/AuthProvider/AuthProvider.native.mjs +0 -111
- package/dist/esm/session/session.native.mjs +0 -7
- package/dist/jsx/hooks/useTokensFromQuery/index.native.mjs +0 -2
- package/dist/jsx/keycloak/keycloak.native.mjs +0 -84
- package/dist/jsx/provider/AuthProvider/AuthProvider.native.mjs +0 -111
- package/dist/jsx/session/session.native.mjs +0 -7
package/src/keycloak/config.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/keycloak/config.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 27-04-2024 10:53:19
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
'use client';
|
package/src/keycloak/context.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/keycloak/context.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
'use client';
|
package/src/keycloak/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/keycloak/index.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
export * from './config';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/keycloak/keycloak.native.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type KeycloakClient from 'keycloak-js';
|
package/src/keycloak/keycloak.ts
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/keycloak/keycloak.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type KeycloakClient from 'keycloak-js';
|
|
23
23
|
import type { AccessTokenParsed, TokenParsed } from '../token';
|
|
24
|
-
import type { AuthOptions } from 'next-auth';
|
|
25
24
|
import type { AuthRequestPromptOptions } from 'expo-auth-session';
|
|
26
25
|
import type { KeycloakMock } from '../types';
|
|
27
|
-
import type { KeycloakProfile } from 'next-auth/providers/keycloak';
|
|
28
|
-
import type { OAuthConfig } from 'next-auth/providers';
|
|
29
26
|
import type { Session } from '../session/session';
|
|
30
27
|
import { KeycloakConfigContext, type KeycloakConfig } from './config';
|
|
31
28
|
import { KeycloakContext } from './context';
|
|
32
29
|
import { MultiPlatform } from 'multiplatform.one';
|
|
33
|
-
import {
|
|
30
|
+
import { useSession } from '../session/session';
|
|
34
31
|
import { jwtDecode } from 'jwt-decode';
|
|
35
32
|
import { signIn, signOut } from 'next-auth/react';
|
|
36
33
|
import { useAuthConfig } from '../hooks';
|
|
@@ -215,20 +212,3 @@ export function useKeycloak() {
|
|
|
215
212
|
return new Keycloak(keycloakConfig, session as Session);
|
|
216
213
|
}
|
|
217
214
|
}
|
|
218
|
-
|
|
219
|
-
export async function getKeycloak(options?: AuthOptions, req?: any, res?: any) {
|
|
220
|
-
const keycloakProvider: OAuthConfig<KeycloakProfile> | undefined = options?.providers.find(
|
|
221
|
-
(provider) => provider.id === 'keycloak',
|
|
222
|
-
)?.options;
|
|
223
|
-
const parts = keycloakProvider?.issuer?.split('/realms/');
|
|
224
|
-
const keycloakConfig: KeycloakConfig = {
|
|
225
|
-
realm: parts?.[1]?.split('/')[0] || '',
|
|
226
|
-
url: parts?.[0] || '',
|
|
227
|
-
clientId: keycloakProvider?.clientId || '',
|
|
228
|
-
};
|
|
229
|
-
const session = await getSession(options, req, res);
|
|
230
|
-
if (session?.accessToken) {
|
|
231
|
-
return new Keycloak(keycloakConfig, session as Session);
|
|
232
|
-
}
|
|
233
|
-
return new Keycloak(keycloakConfig);
|
|
234
|
-
}
|
|
@@ -264,15 +264,18 @@ export function AuthProvider({ children, sessionProvider, keycloakInitOptions, k
|
|
|
264
264
|
}
|
|
265
265
|
}, []);
|
|
266
266
|
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
function render() {
|
|
268
|
+
return (
|
|
269
269
|
<KeycloakConfigContext.Provider value={keycloakConfig}>
|
|
270
270
|
<KeycloakContext.Provider value={keycloak}>
|
|
271
271
|
<AfterAuth>{children}</AfterAuth>
|
|
272
272
|
</KeycloakContext.Provider>
|
|
273
273
|
</KeycloakConfigContext.Provider>
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (MultiPlatform.isElectron) return render();
|
|
278
|
+
return <SessionProvider {...sessionProvider}>{render()}</SessionProvider>;
|
|
276
279
|
}
|
|
277
280
|
|
|
278
281
|
const defaultKeycloakInitOptions: KeycloakInitOptions = {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/provider/AuthProvider/index.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
export * from './AuthProvider';
|
package/src/provider/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/provider/index.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
export * from './AfterAuth';
|
package/src/routes.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/routes.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 23-04-2024 05:52:22
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type { AccessTokenParsed } from './token';
|
|
@@ -27,15 +27,12 @@ import type { Session } from './session';
|
|
|
27
27
|
import { getServerSession } from 'next-auth';
|
|
28
28
|
import { jwtDecode } from 'jwt-decode';
|
|
29
29
|
|
|
30
|
-
const KeycloakProvider = require('next-auth/providers/keycloak')
|
|
31
|
-
.default as typeof import('next-auth/providers/keycloak').default;
|
|
32
|
-
|
|
33
|
-
let _nextAuth: AuthOptions | undefined;
|
|
34
|
-
|
|
35
30
|
const NextAuth = require('next-auth').default as typeof import('next-auth').default;
|
|
36
31
|
const NextResponse = require('next/server').NextResponse as typeof import('next/server').NextResponse;
|
|
37
|
-
|
|
38
32
|
const logger = console;
|
|
33
|
+
let _nextAuth: AuthOptions | undefined;
|
|
34
|
+
const KeycloakProvider = require('next-auth/providers/keycloak')
|
|
35
|
+
.default as typeof import('next-auth/providers/keycloak').default;
|
|
39
36
|
|
|
40
37
|
export function createAuthHandler(options: AuthHandlerOptions) {
|
|
41
38
|
return NextAuth(createNextAuthOptions(options));
|
package/src/session/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/session/index.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
export * from './session';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/session/session.native.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type { SessionContextValue } from './session';
|
package/src/session/session.ts
CHANGED
|
@@ -1,42 +1,28 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/session/session.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
|
-
import type {
|
|
22
|
+
import type { Session as NextSession } from 'next-auth';
|
|
23
23
|
import type { SessionContextValue as NextSessionContextValue, UseSessionOptions } from 'next-auth/react';
|
|
24
24
|
import { MultiPlatform } from 'multiplatform.one';
|
|
25
|
-
import { useSession as useNextSession
|
|
26
|
-
|
|
27
|
-
let _getServerSession: ((options?: AuthOptions, req?: any, res?: any) => Promise<Session | null>) | undefined;
|
|
28
|
-
|
|
29
|
-
export async function getSession(options?: AuthOptions, req?: any, res?: any): Promise<Session | null> {
|
|
30
|
-
if (MultiPlatform.isServer) {
|
|
31
|
-
if (typeof _getServerSession === 'function') return _getServerSession(options as AuthOptions, req, res);
|
|
32
|
-
const getSession = (await import('next-auth')).getServerSession;
|
|
33
|
-
_getServerSession = (options?: AuthOptions, req?: any, res?: any) => {
|
|
34
|
-
return req && res ? getSession(req, res, options as any) : getSession(options as any);
|
|
35
|
-
};
|
|
36
|
-
return _getServerSession(options as AuthOptions, req, res);
|
|
37
|
-
}
|
|
38
|
-
return getNextSession();
|
|
39
|
-
}
|
|
25
|
+
import { useSession as useNextSession } from 'next-auth/react';
|
|
40
26
|
|
|
41
27
|
export type SessionContextValue<R extends boolean> = Partial<
|
|
42
28
|
Omit<NextSessionContextValue<R> & { session: Session }, 'data'>
|
|
@@ -46,7 +32,7 @@ let useSession = <R extends boolean>(_options?: UseSessionOptions<R>): SessionCo
|
|
|
46
32
|
return {};
|
|
47
33
|
};
|
|
48
34
|
|
|
49
|
-
if (MultiPlatform.isNext) {
|
|
35
|
+
if (MultiPlatform.isNext && !MultiPlatform.isElectron) {
|
|
50
36
|
useSession = <R extends boolean>(options?: UseSessionOptions<R>): SessionContextValue<R> => {
|
|
51
37
|
const nextSession = useNextSession(options);
|
|
52
38
|
return {
|
package/src/state.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/state.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { MultiPlatform } from 'multiplatform.one';
|
package/src/token.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* File: /src/token.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 04-04-2024 15:50:39
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* BitSpur (c) Copyright 2021 - 2024
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type { KeycloakTokenParsed } from 'keycloak-js';
|