@multiplatform.one/keycloak 0.3.33 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +34 -0
- package/package.json +34 -48
- package/src/@types/coreJsPure.d.ts +8 -8
- package/dist/esm/Authenticated.mjs +0 -40
- package/dist/esm/Authenticated.mjs.map +0 -7
- package/dist/esm/authConfig.mjs +0 -12
- package/dist/esm/authConfig.mjs.map +0 -7
- package/dist/esm/hooks/index.mjs +0 -7
- package/dist/esm/hooks/index.mjs.map +0 -7
- package/dist/esm/hooks/useAuthConfig.mjs +0 -9
- package/dist/esm/hooks/useAuthConfig.mjs.map +0 -7
- package/dist/esm/hooks/useCurrentRouteName/index.mjs +0 -17
- package/dist/esm/hooks/useCurrentRouteName/index.mjs.map +0 -7
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs +0 -12
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs.map +0 -7
- package/dist/esm/hooks/useKeycloak/index.mjs +0 -2
- package/dist/esm/hooks/useKeycloak/index.mjs.map +0 -7
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs +0 -527
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs.map +0 -7
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs +0 -108
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs.map +0 -7
- package/dist/esm/hooks/useLogin.mjs +0 -35
- package/dist/esm/hooks/useLogin.mjs.map +0 -7
- package/dist/esm/hooks/useTokensFromQuery/index.mjs +0 -12
- package/dist/esm/hooks/useTokensFromQuery/index.mjs.map +0 -7
- package/dist/esm/hooks/useTokensFromQuery/index.native.mjs +0 -7
- package/dist/esm/hooks/useTokensFromQuery/index.native.mjs.map +0 -7
- package/dist/esm/hooks/useTokensFromState.mjs +0 -10
- package/dist/esm/hooks/useTokensFromState.mjs.map +0 -7
- package/dist/esm/index.mjs +0 -5
- package/dist/esm/index.mjs.map +0 -7
- package/dist/esm/provider/afterAuth.mjs +0 -43
- package/dist/esm/provider/afterAuth.mjs.map +0 -7
- package/dist/esm/provider/index.mjs +0 -136
- package/dist/esm/provider/index.mjs.map +0 -7
- package/dist/esm/provider/keycloakProvider.mjs +0 -338
- package/dist/esm/provider/keycloakProvider.mjs.map +0 -7
- package/dist/esm/provider/keycloakProvider.native.mjs +0 -69
- package/dist/esm/provider/keycloakProvider.native.mjs.map +0 -7
- package/dist/esm/state/index.mjs +0 -16
- package/dist/esm/state/index.mjs.map +0 -7
- package/dist/esm/types.mjs +0 -5
- package/dist/esm/types.mjs.map +0 -7
- package/dist/esm/util.mjs +0 -26
- package/dist/esm/util.mjs.map +0 -7
- package/dist/jsx/Authenticated.mjs +0 -35
- package/dist/jsx/Authenticated.mjs.map +0 -7
- package/dist/jsx/authConfig.mjs +0 -12
- package/dist/jsx/authConfig.mjs.map +0 -7
- package/dist/jsx/hooks/index.mjs +0 -7
- package/dist/jsx/hooks/index.mjs.map +0 -7
- package/dist/jsx/hooks/useAuthConfig.mjs +0 -9
- package/dist/jsx/hooks/useAuthConfig.mjs.map +0 -7
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs +0 -17
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs.map +0 -7
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs +0 -12
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs.map +0 -7
- package/dist/jsx/hooks/useKeycloak/index.mjs +0 -2
- package/dist/jsx/hooks/useKeycloak/index.mjs.map +0 -7
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs +0 -76
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs.map +0 -7
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs +0 -58
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs.map +0 -7
- package/dist/jsx/hooks/useLogin.mjs +0 -33
- package/dist/jsx/hooks/useLogin.mjs.map +0 -7
- package/dist/jsx/hooks/useTokensFromQuery/index.mjs +0 -10
- package/dist/jsx/hooks/useTokensFromQuery/index.mjs.map +0 -7
- package/dist/jsx/hooks/useTokensFromQuery/index.native.mjs +0 -5
- package/dist/jsx/hooks/useTokensFromQuery/index.native.mjs.map +0 -7
- package/dist/jsx/hooks/useTokensFromState.mjs +0 -10
- package/dist/jsx/hooks/useTokensFromState.mjs.map +0 -7
- package/dist/jsx/index.mjs +0 -5
- package/dist/jsx/index.mjs.map +0 -7
- package/dist/jsx/provider/afterAuth.mjs +0 -42
- package/dist/jsx/provider/afterAuth.mjs.map +0 -7
- package/dist/jsx/provider/index.mjs +0 -61
- package/dist/jsx/provider/index.mjs.map +0 -7
- package/dist/jsx/provider/keycloakProvider.mjs +0 -247
- package/dist/jsx/provider/keycloakProvider.mjs.map +0 -7
- package/dist/jsx/provider/keycloakProvider.native.mjs +0 -14
- package/dist/jsx/provider/keycloakProvider.native.mjs.map +0 -7
- package/dist/jsx/state/index.mjs +0 -19
- package/dist/jsx/state/index.mjs.map +0 -7
- package/dist/jsx/types.mjs +0 -5
- package/dist/jsx/types.mjs.map +0 -7
- package/dist/jsx/util.mjs +0 -25
- package/dist/jsx/util.mjs.map +0 -7
- package/dist/lib/Authenticated.d.ts +0 -32
- package/dist/lib/Authenticated.js +0 -75
- package/dist/lib/Authenticated.js.map +0 -7
- package/dist/lib/authConfig.d.ts +0 -34
- package/dist/lib/authConfig.js +0 -37
- package/dist/lib/authConfig.js.map +0 -7
- package/dist/lib/hooks/index.d.ts +0 -29
- package/dist/lib/hooks/index.js +0 -33
- package/dist/lib/hooks/index.js.map +0 -7
- package/dist/lib/hooks/useAuthConfig.d.ts +0 -24
- package/dist/lib/hooks/useAuthConfig.js +0 -33
- package/dist/lib/hooks/useAuthConfig.js.map +0 -7
- package/dist/lib/hooks/useCurrentRouteName/index.d.ts +0 -24
- package/dist/lib/hooks/useCurrentRouteName/index.js +0 -41
- package/dist/lib/hooks/useCurrentRouteName/index.js.map +0 -7
- package/dist/lib/hooks/useCurrentRouteName/index.native.d.ts +0 -24
- package/dist/lib/hooks/useCurrentRouteName/index.native.js +0 -36
- package/dist/lib/hooks/useCurrentRouteName/index.native.js.map +0 -7
- package/dist/lib/hooks/useKeycloak/index.d.ts +0 -47
- package/dist/lib/hooks/useKeycloak/index.js +0 -23
- package/dist/lib/hooks/useKeycloak/index.js.map +0 -7
- package/dist/lib/hooks/useKeycloak/useKeycloak.d.ts +0 -42
- package/dist/lib/hooks/useKeycloak/useKeycloak.js +0 -111
- package/dist/lib/hooks/useKeycloak/useKeycloak.js.map +0 -7
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.d.ts +0 -40
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js +0 -93
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js.map +0 -7
- package/dist/lib/hooks/useLogin.d.ts +0 -24
- package/dist/lib/hooks/useLogin.js +0 -57
- package/dist/lib/hooks/useLogin.js.map +0 -7
- package/dist/lib/hooks/useTokensFromQuery/index.d.ts +0 -24
- package/dist/lib/hooks/useTokensFromQuery/index.js +0 -34
- package/dist/lib/hooks/useTokensFromQuery/index.js.map +0 -7
- package/dist/lib/hooks/useTokensFromQuery/index.native.d.ts +0 -24
- package/dist/lib/hooks/useTokensFromQuery/index.native.js +0 -29
- package/dist/lib/hooks/useTokensFromQuery/index.native.js.map +0 -7
- package/dist/lib/hooks/useTokensFromState.d.ts +0 -24
- package/dist/lib/hooks/useTokensFromState.js +0 -34
- package/dist/lib/hooks/useTokensFromState.js.map +0 -7
- package/dist/lib/index.d.ts +0 -27
- package/dist/lib/index.js +0 -29
- package/dist/lib/index.js.map +0 -7
- package/dist/lib/provider/afterAuth.d.ts +0 -28
- package/dist/lib/provider/afterAuth.js +0 -67
- package/dist/lib/provider/afterAuth.js.map +0 -7
- package/dist/lib/provider/index.d.ts +0 -38
- package/dist/lib/provider/index.js +0 -131
- package/dist/lib/provider/index.js.map +0 -7
- package/dist/lib/provider/keycloakProvider.d.ts +0 -41
- package/dist/lib/provider/keycloakProvider.js +0 -305
- package/dist/lib/provider/keycloakProvider.js.map +0 -7
- package/dist/lib/provider/keycloakProvider.native.d.ts +0 -26
- package/dist/lib/provider/keycloakProvider.native.js +0 -55
- package/dist/lib/provider/keycloakProvider.native.js.map +0 -7
- package/dist/lib/state/index.d.ts +0 -24
- package/dist/lib/state/index.js +0 -43
- package/dist/lib/state/index.js.map +0 -7
- package/dist/lib/tsconfig.build.tsbuildinfo +0 -1
- package/dist/lib/types.d.ts +0 -39
- package/dist/lib/types.js +0 -25
- package/dist/lib/types.js.map +0 -7
- package/dist/lib/util.d.ts +0 -25
- package/dist/lib/util.js +0 -51
- package/dist/lib/util.js.map +0 -7
package/dist/jsx/hooks/index.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/index.ts\n * Project: app\n * File Created: 08-11-2022 06:34:56\n * Author: Clay Risser\n * -----\n * Last Modified: 26-05-2023 07:00:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './useAuthConfig';\nexport * from './useCurrentRouteName';\nexport * from './useKeycloak';\nexport * from './useLogin';\nexport * from './useTokensFromQuery';\nexport * from './useTokensFromState';\n"],
|
|
5
|
-
"mappings": "AAwBA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useAuthConfig.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useAuthConfig.ts\n * Project: app\n * File Created: 08-11-2022 09:20:41\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 09:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useContext } from 'react';\nimport { AuthConfigContext } from '../authConfig';\n\nexport function useAuthConfig() {\n return useContext(AuthConfigContext);\n}\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAE3B,SAAS,gBAAgB;AAC9B,SAAO,WAAW,iBAAiB;AACrC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
-
import { useRoute } from "@react-navigation/native";
|
|
3
|
-
import { useRouter } from "next/router";
|
|
4
|
-
function useCurrentRouteName() {
|
|
5
|
-
if (MultiPlatform.isStorybook)
|
|
6
|
-
return null;
|
|
7
|
-
if (MultiPlatform.isNext) {
|
|
8
|
-
const router = useRouter();
|
|
9
|
-
return router.route;
|
|
10
|
-
}
|
|
11
|
-
const route = useRoute();
|
|
12
|
-
return route.name;
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
useCurrentRouteName
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/hooks/useCurrentRouteName/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useCurrentRouteName/index.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 24-02-2023 06:30:32\n * Author: Clay Risser\n * -----\n * Last Modified: 24-02-2023 06:30:54\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022 - 2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useRoute } from '@react-navigation/native';\nimport { useRouter } from 'next/router';\n\nexport function useCurrentRouteName() {\n if (MultiPlatform.isStorybook) return null;\n if (MultiPlatform.isNext) {\n const router = useRouter();\n return router.route;\n }\n const route = useRoute();\n return route.name;\n}\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAEnB,SAAS,sBAAsB;AACpC,MAAI,cAAc;AAAa,WAAO;AACtC,MAAI,cAAc,QAAQ;AACxB,UAAM,SAAS,UAAU;AACzB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,QAAQ,SAAS;AACvB,SAAO,MAAM;AACf;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
-
import { useRoute } from "@react-navigation/native";
|
|
3
|
-
function useCurrentRouteName() {
|
|
4
|
-
if (MultiPlatform.isStorybook)
|
|
5
|
-
return null;
|
|
6
|
-
const route = useRoute();
|
|
7
|
-
return route.name;
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
useCurrentRouteName
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=index.native.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/hooks/useCurrentRouteName/index.native.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useCurrentRouteName/index.native.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 24-02-2023 06:30:36\n * Author: Clay Risser\n * -----\n * Last Modified: 24-02-2023 06:31:25\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022 - 2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useRoute } from '@react-navigation/native';\n\nexport function useCurrentRouteName() {\n if (MultiPlatform.isStorybook) return null;\n const route = useRoute();\n return route.name;\n}\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAElB,SAAS,sBAAsB;AACpC,MAAI,cAAc;AAAa,WAAO;AACtC,QAAM,QAAQ,SAAS;AACvB,SAAO,MAAM;AACf;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/hooks/useKeycloak/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 01-06-2023 13:55:42\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { KeycloakResourceAccess, KeycloakRoles, KeycloakTokenParsed } from '@bitspur/keycloak-js';\nexport * from './useKeycloak';\n\nexport interface IKeycloak {\n authenticated?: boolean;\n idToken?: string;\n realmAccess?: KeycloakRoles;\n refreshToken?: string;\n refreshTokenParsed?: KeycloakTokenParsed;\n resourceAccess?: KeycloakResourceAccess;\n subject?: string;\n token?: string;\n tokenParsed?: ITokenParsed;\n email?: string;\n username?: string;\n login: () => Promise<unknown>;\n logout: () => Promise<unknown>;\n}\n\nexport interface ITokenParsed extends KeycloakTokenParsed {\n 'allowed-origins'?: string[];\n email_verified?: boolean;\n preferred_username?: string;\n scope?: string;\n sid?: string;\n}\n"],
|
|
5
|
-
"mappings": "AAyBA,cAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
-
import { useAuthConfig } from "../useAuthConfig";
|
|
3
|
-
import { useKeycloak as useReactKeycloak } from "@bitspur/react-keycloak-web";
|
|
4
|
-
import { useKeycloak as useSsrKeycloak } from "@bitspur/react-keycloak-ssr";
|
|
5
|
-
function useKeycloak() {
|
|
6
|
-
const authConfig = useAuthConfig();
|
|
7
|
-
if (MultiPlatform.isStorybook) {
|
|
8
|
-
return new Keycloak(
|
|
9
|
-
{
|
|
10
|
-
email: "storybook@example.com",
|
|
11
|
-
login: async () => void 0,
|
|
12
|
-
logout: async () => void 0,
|
|
13
|
-
subject: "0",
|
|
14
|
-
username: "storybook"
|
|
15
|
-
},
|
|
16
|
-
true
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
if (MultiPlatform.isNext && authConfig.ssr) {
|
|
20
|
-
const { keycloak: keycloak2, initialized: initialized2 } = useSsrKeycloak();
|
|
21
|
-
return new Keycloak(keycloak2, initialized2);
|
|
22
|
-
}
|
|
23
|
-
const { keycloak, initialized } = useReactKeycloak();
|
|
24
|
-
return new Keycloak(keycloak, initialized);
|
|
25
|
-
}
|
|
26
|
-
class Keycloak {
|
|
27
|
-
constructor(keycloak, initialized) {
|
|
28
|
-
this.keycloak = keycloak;
|
|
29
|
-
this.authenticated = initialized ? keycloak?.authenticated : void 0;
|
|
30
|
-
}
|
|
31
|
-
get idToken() {
|
|
32
|
-
return this.keycloak?.idToken;
|
|
33
|
-
}
|
|
34
|
-
get realmAccess() {
|
|
35
|
-
return this.keycloak?.realmAccess;
|
|
36
|
-
}
|
|
37
|
-
get refreshToken() {
|
|
38
|
-
return this.keycloak?.refreshToken;
|
|
39
|
-
}
|
|
40
|
-
get refreshTokenParsed() {
|
|
41
|
-
return this.keycloak?.refreshTokenParsed;
|
|
42
|
-
}
|
|
43
|
-
get resourceAccess() {
|
|
44
|
-
return this.keycloak?.resourceAccess;
|
|
45
|
-
}
|
|
46
|
-
get subject() {
|
|
47
|
-
return this.keycloak?.subject;
|
|
48
|
-
}
|
|
49
|
-
get token() {
|
|
50
|
-
return this.keycloak?.token;
|
|
51
|
-
}
|
|
52
|
-
get tokenParsed() {
|
|
53
|
-
return this.keycloak?.tokenParsed;
|
|
54
|
-
}
|
|
55
|
-
get email() {
|
|
56
|
-
return this.keycloak?.tokenParsed?.email;
|
|
57
|
-
}
|
|
58
|
-
get username() {
|
|
59
|
-
return this.keycloak?.tokenParsed?.preferred_username;
|
|
60
|
-
}
|
|
61
|
-
async login() {
|
|
62
|
-
if (!this.keycloak)
|
|
63
|
-
return;
|
|
64
|
-
return this.keycloak.login();
|
|
65
|
-
}
|
|
66
|
-
async logout() {
|
|
67
|
-
if (!this.keycloak)
|
|
68
|
-
return;
|
|
69
|
-
return this.keycloak.logout();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
Keycloak,
|
|
74
|
-
useKeycloak
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=useKeycloak.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/hooks/useKeycloak/useKeycloak.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useKeycloak/useKeycloak.ts\n * Project: app\n * File Created: 08-11-2022 06:04:59\n * Author: Clay Risser\n * -----\n * Last Modified: 01-06-2023 14:02:40\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { IKeycloak } from './index';\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useAuthConfig } from '../useAuthConfig';\nimport { useKeycloak as useReactKeycloak } from '@bitspur/react-keycloak-web';\nimport { useKeycloak as useSsrKeycloak } from '@bitspur/react-keycloak-ssr';\n\nexport function useKeycloak() {\n const authConfig = useAuthConfig();\n if (MultiPlatform.isStorybook) {\n return new Keycloak(\n {\n email: 'storybook@example.com',\n login: async () => undefined,\n logout: async () => undefined,\n subject: '0',\n username: 'storybook',\n },\n true,\n );\n }\n if (MultiPlatform.isNext && authConfig.ssr) {\n const { keycloak, initialized } = useSsrKeycloak();\n return new Keycloak(keycloak, initialized);\n }\n const { keycloak, initialized } = useReactKeycloak();\n return new Keycloak(keycloak, initialized);\n}\n\nexport class Keycloak implements IKeycloak {\n authenticated?: boolean;\n\n constructor(private readonly keycloak: IKeycloak | undefined, initialized: boolean) {\n this.authenticated = initialized ? keycloak?.authenticated : undefined;\n }\n\n get idToken() {\n return this.keycloak?.idToken;\n }\n\n get realmAccess() {\n return this.keycloak?.realmAccess;\n }\n\n get refreshToken() {\n return this.keycloak?.refreshToken;\n }\n\n get refreshTokenParsed() {\n return this.keycloak?.refreshTokenParsed;\n }\n\n get resourceAccess() {\n return this.keycloak?.resourceAccess;\n }\n\n get subject() {\n return this.keycloak?.subject;\n }\n\n get token() {\n return this.keycloak?.token;\n }\n\n get tokenParsed() {\n return this.keycloak?.tokenParsed;\n }\n\n get email() {\n return this.keycloak?.tokenParsed?.email;\n }\n\n get username() {\n return this.keycloak?.tokenParsed?.preferred_username;\n }\n\n async login() {\n if (!this.keycloak) return;\n return this.keycloak.login();\n }\n\n async logout() {\n if (!this.keycloak) return;\n return this.keycloak.logout();\n }\n}\n"],
|
|
5
|
-
"mappings": "AAyBA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,eAAe,wBAAwB;AAChD,SAAS,eAAe,sBAAsB;AAEvC,SAAS,cAAc;AAC5B,QAAM,aAAa,cAAc;AACjC,MAAI,cAAc,aAAa;AAC7B,WAAO,IAAI;AAAA,MACT;AAAA,QACE,OAAO;AAAA,QACP,OAAO,YAAY;AAAA,QACnB,QAAQ,YAAY;AAAA,QACpB,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,cAAc,UAAU,WAAW,KAAK;AAC1C,UAAM,EAAE,UAAAA,WAAU,aAAAC,aAAY,IAAI,eAAe;AACjD,WAAO,IAAI,SAASD,WAAUC,YAAW;AAAA,EAC3C;AACA,QAAM,EAAE,UAAU,YAAY,IAAI,iBAAiB;AACnD,SAAO,IAAI,SAAS,UAAU,WAAW;AAC3C;AAEO,MAAM,SAA8B;AAAA,EAGzC,YAA6B,UAAiC,aAAsB;AAAvD;AAC3B,SAAK,gBAAgB,cAAc,UAAU,gBAAgB;AAAA,EAC/D;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,cAAc;AAChB,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,eAAe;AACjB,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,qBAAqB;AACvB,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,iBAAiB;AACnB,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,QAAQ;AACV,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,cAAc;AAChB,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,QAAQ;AACV,WAAO,KAAK,UAAU,aAAa;AAAA,EACrC;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,UAAU,aAAa;AAAA,EACrC;AAAA,EAEA,MAAM,QAAQ;AACZ,QAAI,CAAC,KAAK;AAAU;AACpB,WAAO,KAAK,SAAS,MAAM;AAAA,EAC7B;AAAA,EAEA,MAAM,SAAS;AACb,QAAI,CAAC,KAAK;AAAU;AACpB,WAAO,KAAK,SAAS,OAAO;AAAA,EAC9B;AACF;",
|
|
6
|
-
"names": ["keycloak", "initialized"]
|
|
7
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import atob from "core-js-pure/stable/atob";
|
|
2
|
-
import escape from "core-js-pure/stable/escape";
|
|
3
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
4
|
-
import { useKeycloak as useExpoKeycloak } from "expo-keycloak-auth";
|
|
5
|
-
function useKeycloak() {
|
|
6
|
-
if (MultiPlatform.isStorybook)
|
|
7
|
-
return { authenticated: true };
|
|
8
|
-
const { ready, login, isLoggedIn, token, logout, refreshToken } = useExpoKeycloak();
|
|
9
|
-
const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || void 0, refreshToken || void 0);
|
|
10
|
-
return keycloak;
|
|
11
|
-
}
|
|
12
|
-
class ExpoKeycloak {
|
|
13
|
-
constructor(ready, isLoggedIn, login, logout, token, refreshToken) {
|
|
14
|
-
this.logout = logout;
|
|
15
|
-
this.token = token;
|
|
16
|
-
this.refreshToken = refreshToken;
|
|
17
|
-
if (ready)
|
|
18
|
-
this.authenticated = isLoggedIn;
|
|
19
|
-
if (this.authenticated) {
|
|
20
|
-
if (this.token)
|
|
21
|
-
this.tokenParsed = decodeToken(this.token);
|
|
22
|
-
if (this.refreshToken) {
|
|
23
|
-
this.refreshTokenParsed = decodeToken(this.refreshToken);
|
|
24
|
-
}
|
|
25
|
-
if (this.tokenParsed) {
|
|
26
|
-
this.subject = this.tokenParsed.sub;
|
|
27
|
-
this.realmAccess = this.tokenParsed.realm_access;
|
|
28
|
-
this.resourceAccess = this.tokenParsed.resource_access;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
this.login = () => login();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function decodeToken(str) {
|
|
35
|
-
str = str.split(".")[1];
|
|
36
|
-
str = str.replace(/-/g, "+");
|
|
37
|
-
str = str.replace(/_/g, "/");
|
|
38
|
-
switch (str.length % 4) {
|
|
39
|
-
case 0:
|
|
40
|
-
break;
|
|
41
|
-
case 2:
|
|
42
|
-
str += "==";
|
|
43
|
-
break;
|
|
44
|
-
case 3:
|
|
45
|
-
str += "=";
|
|
46
|
-
break;
|
|
47
|
-
default:
|
|
48
|
-
throw "Invalid token";
|
|
49
|
-
}
|
|
50
|
-
str = decodeURIComponent(escape(atob(str)));
|
|
51
|
-
str = JSON.parse(str);
|
|
52
|
-
return str;
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
ExpoKeycloak,
|
|
56
|
-
useKeycloak
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=useKeycloak.native.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/hooks/useKeycloak/useKeycloak.native.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useKeycloak/useKeycloak.native.ts\n * Project: app\n * File Created: 08-11-2022 14:10:25\n * Author: Clay Risser\n * -----\n * Last Modified: 01-06-2023 14:04:46\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport atob from 'core-js-pure/stable/atob';\nimport escape from 'core-js-pure/stable/escape';\nimport type { AuthRequestPromptOptions, AuthSessionResult } from 'expo-auth-session';\nimport type { IKeycloak } from './index';\nimport type { KeycloakResourceAccess, KeycloakRoles, KeycloakTokenParsed } from '@bitspur/keycloak-js';\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useKeycloak as useExpoKeycloak } from 'expo-keycloak-auth';\n\nexport function useKeycloak() {\n if (MultiPlatform.isStorybook) return { authenticated: true } as IKeycloak;\n const { ready, login, isLoggedIn, token, logout, refreshToken } = useExpoKeycloak();\n const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || undefined, refreshToken || undefined);\n return keycloak as IKeycloak;\n}\n\nexport class ExpoKeycloak implements IKeycloak {\n authenticated?: boolean;\n\n tokenParsed?: KeycloakTokenParsed;\n\n refreshTokenParsed?: KeycloakTokenParsed;\n\n subject?: string;\n\n realmAccess?: KeycloakRoles;\n\n resourceAccess?: KeycloakResourceAccess;\n\n login: () => Promise<unknown>;\n\n constructor(\n ready: boolean,\n isLoggedIn: boolean | undefined,\n login: (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult | undefined>,\n public logout: () => Promise<unknown>,\n public token?: string,\n public refreshToken?: string,\n ) {\n if (ready) this.authenticated = isLoggedIn;\n if (this.authenticated) {\n if (this.token) this.tokenParsed = decodeToken(this.token);\n if (this.refreshToken) {\n this.refreshTokenParsed = decodeToken(this.refreshToken);\n }\n if (this.tokenParsed) {\n this.subject = this.tokenParsed.sub;\n this.realmAccess = this.tokenParsed.realm_access;\n this.resourceAccess = this.tokenParsed.resource_access;\n }\n }\n this.login = () => login();\n }\n}\n\nfunction decodeToken(str: string) {\n str = str.split('.')[1];\n str = str.replace(/-/g, '+');\n str = str.replace(/_/g, '/');\n switch (str.length % 4) {\n case 0:\n break;\n case 2:\n str += '==';\n break;\n case 3:\n str += '=';\n break;\n default:\n throw 'Invalid token';\n }\n str = decodeURIComponent(escape(atob(str)));\n str = JSON.parse(str);\n return str as unknown as KeycloakTokenParsed;\n}\n"],
|
|
5
|
-
"mappings": "AAwBA,OAAO,UAAU;AACjB,OAAO,YAAY;AAInB,SAAS,qBAAqB;AAC9B,SAAS,eAAe,uBAAuB;AAExC,SAAS,cAAc;AAC5B,MAAI,cAAc;AAAa,WAAO,EAAE,eAAe,KAAK;AAC5D,QAAM,EAAE,OAAO,OAAO,YAAY,OAAO,QAAQ,aAAa,IAAI,gBAAgB;AAClF,QAAM,WAAW,IAAI,aAAa,OAAO,YAAY,OAAO,QAAQ,SAAS,QAAW,gBAAgB,MAAS;AACjH,SAAO;AACT;AAEO,MAAM,aAAkC;AAAA,EAe7C,YACE,OACA,YACA,OACO,QACA,OACA,cACP;AAHO;AACA;AACA;AAEP,QAAI;AAAO,WAAK,gBAAgB;AAChC,QAAI,KAAK,eAAe;AACtB,UAAI,KAAK;AAAO,aAAK,cAAc,YAAY,KAAK,KAAK;AACzD,UAAI,KAAK,cAAc;AACrB,aAAK,qBAAqB,YAAY,KAAK,YAAY;AAAA,MACzD;AACA,UAAI,KAAK,aAAa;AACpB,aAAK,UAAU,KAAK,YAAY;AAChC,aAAK,cAAc,KAAK,YAAY;AACpC,aAAK,iBAAiB,KAAK,YAAY;AAAA,MACzC;AAAA,IACF;AACA,SAAK,QAAQ,MAAM,MAAM;AAAA,EAC3B;AACF;AAEA,SAAS,YAAY,KAAa;AAChC,QAAM,IAAI,MAAM,GAAG,EAAE,CAAC;AACtB,QAAM,IAAI,QAAQ,MAAM,GAAG;AAC3B,QAAM,IAAI,QAAQ,MAAM,GAAG;AAC3B,UAAQ,IAAI,SAAS,GAAG;AAAA,IACtB,KAAK;AACH;AAAA,IACF,KAAK;AACH,aAAO;AACP;AAAA,IACF,KAAK;AACH,aAAO;AACP;AAAA,IACF;AACE,YAAM;AAAA,EACV;AACA,QAAM,mBAAmB,OAAO,KAAK,GAAG,CAAC,CAAC;AAC1C,QAAM,KAAK,MAAM,GAAG;AACpB,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
-
import { useAuthConfig } from "./useAuthConfig";
|
|
3
|
-
import { useCurrentRouteName } from "./useCurrentRouteName";
|
|
4
|
-
import { useKeycloak } from "./useKeycloak/useKeycloak";
|
|
5
|
-
import { useRouter } from "solito/router";
|
|
6
|
-
function useLogin(loginRoute) {
|
|
7
|
-
if (MultiPlatform.isStorybook)
|
|
8
|
-
return () => null;
|
|
9
|
-
const keycloak = useKeycloak();
|
|
10
|
-
const authConfig = useAuthConfig();
|
|
11
|
-
const currentRouteName = useCurrentRouteName();
|
|
12
|
-
const router = useRouter();
|
|
13
|
-
return () => {
|
|
14
|
-
if (!loginRoute)
|
|
15
|
-
loginRoute = authConfig.loginRoute;
|
|
16
|
-
if (!loginRoute) {
|
|
17
|
-
keycloak.login();
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const url = new URL(`x://${loginRoute}`);
|
|
21
|
-
const searchParams = new URLSearchParams(url.search);
|
|
22
|
-
if (currentRouteName)
|
|
23
|
-
searchParams.append("backTo", currentRouteName);
|
|
24
|
-
let query = searchParams.toString();
|
|
25
|
-
if (query.length)
|
|
26
|
-
query = `?${query}`;
|
|
27
|
-
router.push(`${url.pathname.substring(2)}${query}`);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
useLogin
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=useLogin.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useLogin.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useLogin.ts\n * Project: app\n * File Created: 08-11-2022 08:49:14\n * Author: Clay Risser\n * -----\n * Last Modified: 25-04-2023 23:09:10\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useAuthConfig } from './useAuthConfig';\nimport { useCurrentRouteName } from './useCurrentRouteName';\nimport { useKeycloak } from './useKeycloak/useKeycloak';\nimport { useRouter } from 'solito/router';\n\nexport function useLogin(loginRoute?: string) {\n if (MultiPlatform.isStorybook) return () => null;\n const keycloak = useKeycloak();\n const authConfig = useAuthConfig();\n const currentRouteName = useCurrentRouteName();\n const router = useRouter();\n return () => {\n if (!loginRoute) loginRoute = authConfig.loginRoute;\n if (!loginRoute) {\n keycloak.login();\n return;\n }\n const url = new URL(`x://${loginRoute}`);\n const searchParams = new URLSearchParams(url.search);\n if (currentRouteName) searchParams.append('backTo', currentRouteName);\n let query = searchParams.toString();\n if (query.length) query = `?${query}`;\n router.push(`${url.pathname.substring(2)}${query}`);\n };\n}\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAEnB,SAAS,SAAS,YAAqB;AAC5C,MAAI,cAAc;AAAa,WAAO,MAAM;AAC5C,QAAM,WAAW,YAAY;AAC7B,QAAM,aAAa,cAAc;AACjC,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,SAAS,UAAU;AACzB,SAAO,MAAM;AACX,QAAI,CAAC;AAAY,mBAAa,WAAW;AACzC,QAAI,CAAC,YAAY;AACf,eAAS,MAAM;AACf;AAAA,IACF;AACA,UAAM,MAAM,IAAI,IAAI,OAAO,YAAY;AACvC,UAAM,eAAe,IAAI,gBAAgB,IAAI,MAAM;AACnD,QAAI;AAAkB,mBAAa,OAAO,UAAU,gBAAgB;AACpE,QAAI,QAAQ,aAAa,SAAS;AAClC,QAAI,MAAM;AAAQ,cAAQ,IAAI;AAC9B,WAAO,KAAK,GAAG,IAAI,SAAS,UAAU,CAAC,IAAI,OAAO;AAAA,EACpD;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MultiPlatform } from "multiplatform.one";
|
|
2
|
-
import { useRouter } from "next/router";
|
|
3
|
-
function useTokensFromQuery() {
|
|
4
|
-
const { query } = MultiPlatform.isNext ? useRouter() : { query: {} };
|
|
5
|
-
return "idToken" in query || "token" in query || "refreshToken" in query;
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
useTokensFromQuery
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/hooks/useTokensFromQuery/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useTokensFromQuery/index.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 15-05-2023 01:54:44\n * Author: Clay Risser\n * -----\n * Last Modified: 16-05-2023 07:40:41\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022 - 2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiPlatform } from 'multiplatform.one';\nimport { useRouter } from 'next/router';\n\nexport function useTokensFromQuery() {\n const { query } = MultiPlatform.isNext ? useRouter() : { query: {} };\n return 'idToken' in query || 'token' in query || 'refreshToken' in query;\n}\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAEnB,SAAS,qBAAqB;AACnC,QAAM,EAAE,MAAM,IAAI,cAAc,SAAS,UAAU,IAAI,EAAE,OAAO,CAAC,EAAE;AACnE,SAAO,aAAa,SAAS,WAAW,SAAS,kBAAkB;AACrE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/hooks/useTokensFromQuery/index.native.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useTokensFromQuery/index.native.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 15-05-2023 01:54:48\n * Author: Clay Risser\n * -----\n * Last Modified: 16-05-2023 07:40:46\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022 - 2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const useTokensFromQuery = () => false;\n"],
|
|
5
|
-
"mappings": "AAwBO,MAAM,qBAAqB,MAAM;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useAuthState } from "../state";
|
|
2
|
-
import { validToken } from "../util";
|
|
3
|
-
function useTokensFromState() {
|
|
4
|
-
const authState = useAuthState();
|
|
5
|
-
return !!validToken(authState.token, authState.refreshToken);
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
useTokensFromState
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=useTokensFromState.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useTokensFromState.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/hooks/useTokensFromState.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 16-05-2023 06:29:02\n * Author: Clay Risser\n * -----\n * Last Modified: 16-05-2023 07:40:36\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022 - 2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useAuthState } from '../state';\nimport { validToken } from '../util';\n\nexport function useTokensFromState() {\n const authState = useAuthState();\n return !!validToken(authState.token, authState.refreshToken);\n}\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,SAAS,qBAAqB;AACnC,QAAM,YAAY,aAAa;AAC/B,SAAO,CAAC,CAAC,WAAW,UAAU,OAAO,UAAU,YAAY;AAC7D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/jsx/index.mjs
DELETED
package/dist/jsx/index.mjs.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /src/index.ts\n * Project: @multiplatform.one/keycloak\n * File Created: 25-11-2022 09:51:55\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 09:52:06\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './Authenticated';\nexport * from './authConfig';\nexport * from './hooks';\nexport * from './provider';\n"],
|
|
5
|
-
"mappings": "AAwBA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { useAuthConfig } from "../hooks/useAuthConfig";
|
|
3
|
-
import { useAuthState } from "../state";
|
|
4
|
-
import { useKeycloak } from "../hooks";
|
|
5
|
-
const logger = console;
|
|
6
|
-
const AfterAuth = ({ children }) => {
|
|
7
|
-
const authConfig = useAuthConfig();
|
|
8
|
-
const authState = useAuthState();
|
|
9
|
-
const { token, refreshToken, authenticated, idToken } = useKeycloak();
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (!authenticated)
|
|
12
|
-
return;
|
|
13
|
-
if (authConfig.persist && token) {
|
|
14
|
-
authState.setToken(token);
|
|
15
|
-
if (idToken)
|
|
16
|
-
authState.setIdToken(idToken);
|
|
17
|
-
if (authConfig.ensureFreshness && refreshToken)
|
|
18
|
-
authState.setRefreshToken(refreshToken);
|
|
19
|
-
}
|
|
20
|
-
}, [token, refreshToken, idToken]);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (authConfig.debug && authState.token)
|
|
23
|
-
logger.debug("token", authState.token);
|
|
24
|
-
}, [authState.token]);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (authConfig.debug && authState.idToken)
|
|
27
|
-
logger.debug("idToken", authState.idToken);
|
|
28
|
-
}, [authState.idToken]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (authConfig.debug && authState.refreshToken)
|
|
31
|
-
logger.debug("refreshToken", authState.refreshToken);
|
|
32
|
-
}, [authState.refreshToken]);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (authConfig.debug)
|
|
35
|
-
logger.debug("authenticated", authenticated);
|
|
36
|
-
}, [authenticated]);
|
|
37
|
-
return <>{children}</>;
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
AfterAuth
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=afterAuth.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/provider/afterAuth.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /auth/provider/afterAuth.tsx\n * Project: app\n * File Created: 22-11-2022 17:49:58\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:00:39\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect } from 'react';\nimport type { FC, ReactNode } from 'react';\nimport { useAuthConfig } from '../hooks/useAuthConfig';\nimport { useAuthState } from '../state';\nimport { useKeycloak } from '../hooks';\n\nexport interface AfterAuthProps {\n children: ReactNode;\n}\n\nconst logger = console;\n\nexport const AfterAuth: FC<AfterAuthProps> = ({ children }: AfterAuthProps) => {\n const authConfig = useAuthConfig();\n const authState = useAuthState();\n const { token, refreshToken, authenticated, idToken } = useKeycloak();\n\n useEffect(() => {\n if (!authenticated) return;\n if (authConfig.persist && token) {\n authState.setToken(token);\n if (idToken) authState.setIdToken(idToken);\n if (authConfig.ensureFreshness && refreshToken) authState.setRefreshToken(refreshToken);\n }\n }, [token, refreshToken, idToken]);\n\n useEffect(() => {\n if (authConfig.debug && authState.token) logger.debug('token', authState.token);\n }, [authState.token]);\n\n useEffect(() => {\n if (authConfig.debug && authState.idToken) logger.debug('idToken', authState.idToken);\n }, [authState.idToken]);\n\n useEffect(() => {\n if (authConfig.debug && authState.refreshToken) logger.debug('refreshToken', authState.refreshToken);\n }, [authState.refreshToken]);\n\n useEffect(() => {\n if (authConfig.debug) logger.debug('authenticated', authenticated);\n }, [authenticated]);\n\n return <>{children}</>;\n};\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAgB,iBAAiB;AAEjC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAM5B,MAAM,SAAS;AAER,MAAM,YAAgC,CAAC,EAAE,SAAS,MAAsB;AAC7E,QAAM,aAAa,cAAc;AACjC,QAAM,YAAY,aAAa;AAC/B,QAAM,EAAE,OAAO,cAAc,eAAe,QAAQ,IAAI,YAAY;AAEpE,YAAU,MAAM;AACd,QAAI,CAAC;AAAe;AACpB,QAAI,WAAW,WAAW,OAAO;AAC/B,gBAAU,SAAS,KAAK;AACxB,UAAI;AAAS,kBAAU,WAAW,OAAO;AACzC,UAAI,WAAW,mBAAmB;AAAc,kBAAU,gBAAgB,YAAY;AAAA,IACxF;AAAA,EACF,GAAG,CAAC,OAAO,cAAc,OAAO,CAAC;AAEjC,YAAU,MAAM;AACd,QAAI,WAAW,SAAS,UAAU;AAAO,aAAO,MAAM,SAAS,UAAU,KAAK;AAAA,EAChF,GAAG,CAAC,UAAU,KAAK,CAAC;AAEpB,YAAU,MAAM;AACd,QAAI,WAAW,SAAS,UAAU;AAAS,aAAO,MAAM,WAAW,UAAU,OAAO;AAAA,EACtF,GAAG,CAAC,UAAU,OAAO,CAAC;AAEtB,YAAU,MAAM;AACd,QAAI,WAAW,SAAS,UAAU;AAAc,aAAO,MAAM,gBAAgB,UAAU,YAAY;AAAA,EACrG,GAAG,CAAC,UAAU,YAAY,CAAC;AAE3B,YAAU,MAAM;AACd,QAAI,WAAW;AAAO,aAAO,MAAM,iBAAiB,aAAa;AAAA,EACnE,GAAG,CAAC,aAAa,CAAC;AAElB,SAAO,GAAG,SAAS;AACrB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import { AuthConfigContext, defaultAuthConfig } from "../authConfig";
|
|
3
|
-
import { KeycloakProvider } from "./keycloakProvider";
|
|
4
|
-
import { useTokensFromState, useTokensFromQuery } from "../hooks";
|
|
5
|
-
import { config } from "app/config";
|
|
6
|
-
const persist = config.get("KEYCLOAK_PERSIST") === "1";
|
|
7
|
-
const AuthProvider = ({
|
|
8
|
-
// keycloak config
|
|
9
|
-
realm,
|
|
10
|
-
clientId,
|
|
11
|
-
baseUrl,
|
|
12
|
-
// auth config
|
|
13
|
-
debug,
|
|
14
|
-
ensureFreshness,
|
|
15
|
-
loginRoute,
|
|
16
|
-
messageHandlerKeys,
|
|
17
|
-
ssr,
|
|
18
|
-
// props
|
|
19
|
-
children,
|
|
20
|
-
cookies,
|
|
21
|
-
disabled,
|
|
22
|
-
loadingComponent,
|
|
23
|
-
onEvent,
|
|
24
|
-
onTokens,
|
|
25
|
-
...keycloakInitOptions
|
|
26
|
-
}) => {
|
|
27
|
-
const tokensFromQuery = useTokensFromQuery();
|
|
28
|
-
const tokensFromState = useTokensFromState();
|
|
29
|
-
const authConfig = useMemo(
|
|
30
|
-
() => ({
|
|
31
|
-
...defaultAuthConfig,
|
|
32
|
-
...typeof debug !== "undefined" ? { debug } : {},
|
|
33
|
-
...typeof ensureFreshness !== "undefined" ? { ensureFreshness } : {},
|
|
34
|
-
...typeof loginRoute !== "undefined" ? { loginRoute } : {},
|
|
35
|
-
...typeof messageHandlerKeys !== "undefined" ? { messageHandlerKeys } : {},
|
|
36
|
-
persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== "undefined" ? persist : defaultAuthConfig.persist,
|
|
37
|
-
ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== "undefined" ? ssr : defaultAuthConfig.ssr : false
|
|
38
|
-
}),
|
|
39
|
-
[debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr]
|
|
40
|
-
);
|
|
41
|
-
if (disabled) {
|
|
42
|
-
return <AuthConfigContext.Provider value={authConfig}>{children}</AuthConfigContext.Provider>;
|
|
43
|
-
}
|
|
44
|
-
return <AuthConfigContext.Provider value={authConfig}><KeycloakProvider
|
|
45
|
-
cookies={cookies}
|
|
46
|
-
keycloakConfig={{
|
|
47
|
-
realm: realm || "main",
|
|
48
|
-
clientId: clientId || "app",
|
|
49
|
-
url: baseUrl
|
|
50
|
-
}}
|
|
51
|
-
keycloakInitOptions={keycloakInitOptions}
|
|
52
|
-
loadingComponent={loadingComponent}
|
|
53
|
-
onEvent={onEvent}
|
|
54
|
-
onTokens={onTokens}
|
|
55
|
-
>{children}</KeycloakProvider></AuthConfigContext.Provider>;
|
|
56
|
-
};
|
|
57
|
-
export * from "./keycloakProvider";
|
|
58
|
-
export {
|
|
59
|
-
AuthProvider
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/provider/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /auth/provider/index.tsx\n * Project: app\n * File Created: 08-11-2022 06:33:07\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:00:13\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';\nimport type { AuthConfig } from '../authConfig';\nimport type { FC, ComponentType, ReactNode } from 'react';\nimport type { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';\nimport { AuthConfigContext, defaultAuthConfig } from '../authConfig';\nimport { KeycloakProvider } from './keycloakProvider';\nimport { useTokensFromState, useTokensFromQuery } from '../hooks';\n// @ts-ignore\nimport { config } from 'app/config';\n\nexport interface AuthProviderProps\n extends Partial<Omit<AuthConfig, 'persist'>>,\n Partial<Omit<KeycloakConfig, 'url'>>,\n KeycloakInitOptions {\n children: ReactNode;\n cookies?: unknown;\n disabled?: boolean;\n baseUrl?: string;\n loadingComponent?: ComponentType;\n onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;\n onTokens?: (tokens: AuthClientTokens) => void;\n}\n\nconst persist = config.get('KEYCLOAK_PERSIST') === '1';\n\nexport const AuthProvider: FC<AuthProviderProps> = ({\n // keycloak config\n realm,\n clientId,\n baseUrl,\n // auth config\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n ssr,\n // props\n children,\n cookies,\n disabled,\n loadingComponent,\n onEvent,\n onTokens,\n ...keycloakInitOptions\n}: AuthProviderProps) => {\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const authConfig = useMemo(\n () => ({\n ...defaultAuthConfig,\n ...(typeof debug !== 'undefined' ? { debug } : {}),\n ...(typeof ensureFreshness !== 'undefined' ? { ensureFreshness } : {}),\n ...(typeof loginRoute !== 'undefined' ? { loginRoute } : {}),\n ...(typeof messageHandlerKeys !== 'undefined' ? { messageHandlerKeys } : {}),\n persist:\n !tokensFromState && !tokensFromQuery && cookies && ssr\n ? false\n : typeof persist !== 'undefined'\n ? persist\n : defaultAuthConfig.persist,\n ssr:\n !tokensFromState && !tokensFromQuery && cookies\n ? typeof ssr !== 'undefined'\n ? ssr\n : defaultAuthConfig.ssr\n : false,\n }),\n [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr],\n );\n\n if (disabled) {\n return <AuthConfigContext.Provider value={authConfig}>{children}</AuthConfigContext.Provider>;\n }\n\n return (\n <AuthConfigContext.Provider value={authConfig}>\n <KeycloakProvider\n cookies={cookies}\n keycloakConfig={{\n realm: realm || 'main',\n clientId: clientId || 'app',\n url: baseUrl,\n }}\n keycloakInitOptions={keycloakInitOptions}\n loadingComponent={loadingComponent}\n onEvent={onEvent}\n onTokens={onTokens}\n >\n {children}\n </KeycloakProvider>\n </AuthConfigContext.Provider>\n );\n};\n\nexport * from './keycloakProvider';\n"],
|
|
5
|
-
"mappings": "AAwBA,SAAgB,eAAe;AAK/B,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,wBAAwB;AACjC,SAAS,oBAAoB,0BAA0B;AAEvD,SAAS,cAAc;AAevB,MAAM,UAAU,OAAO,IAAI,kBAAkB,MAAM;AAE5C,MAAM,eAAsC,CAAC;AAAA;AAAA,EAElD;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyB;AACvB,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,aAAa;AAAA,IACjB,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAI,OAAO,UAAU,cAAc,EAAE,MAAM,IAAI,CAAC;AAAA,MAChD,GAAI,OAAO,oBAAoB,cAAc,EAAE,gBAAgB,IAAI,CAAC;AAAA,MACpE,GAAI,OAAO,eAAe,cAAc,EAAE,WAAW,IAAI,CAAC;AAAA,MAC1D,GAAI,OAAO,uBAAuB,cAAc,EAAE,mBAAmB,IAAI,CAAC;AAAA,MAC1E,SACE,CAAC,mBAAmB,CAAC,mBAAmB,WAAW,MAC/C,QACA,OAAO,YAAY,cACnB,UACA,kBAAkB;AAAA,MACxB,KACE,CAAC,mBAAmB,CAAC,mBAAmB,UACpC,OAAO,QAAQ,cACb,MACA,kBAAkB,MACpB;AAAA,IACR;AAAA,IACA,CAAC,OAAO,iBAAiB,YAAY,oBAAoB,SAAS,GAAG;AAAA,EACvE;AAEA,MAAI,UAAU;AACZ,WAAO,CAAC,kBAAkB,SAAS,OAAO,aAAa,SAAS,EAAxD,kBAAkB;AAAA,EAC5B;AAEA,SACE,CAAC,kBAAkB,SAAS,OAAO,YACjC,CAAC;AAAA,IACC,SAAS;AAAA,IACT,gBAAgB;AAAA,MACd,OAAO,SAAS;AAAA,MAChB,UAAU,YAAY;AAAA,MACtB,KAAK;AAAA,IACP;AAAA,IACA,qBAAqB;AAAA,IACrB,kBAAkB;AAAA,IAClB,SAAS;AAAA,IACT,UAAU;AAAA,IAET,SACH,EAbC,iBAcH,EAfC,kBAAkB;AAiBvB;AAEA,cAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|