@multiplatform.one/keycloak 0.0.2 → 0.0.4
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/esm/Authenticated.js +8 -19
- package/esm/Authenticated.js.map +1 -1
- package/esm/authConfig.js +2 -2
- package/esm/authConfig.js.map +1 -1
- package/esm/expo/ExpoKeycloakContext.js +28 -0
- package/esm/expo/ExpoKeycloakContext.js.map +1 -0
- package/esm/expo/ExpoKeycloakProvider.js +113 -0
- package/esm/expo/ExpoKeycloakProvider.js.map +1 -0
- package/esm/expo/KeycloakContext.js +28 -0
- package/esm/expo/KeycloakContext.js.map +1 -0
- package/esm/expo/KeycloakProvider.js +142 -0
- package/esm/expo/KeycloakProvider.js.map +1 -0
- package/esm/expo/const.js +42 -0
- package/esm/expo/const.js.map +1 -0
- package/esm/expo/helpers.js +56 -0
- package/esm/expo/helpers.js.map +1 -0
- package/esm/expo/index.js +28 -0
- package/esm/expo/index.js.map +1 -0
- package/esm/expo/useExpoKeycloak.js +44 -0
- package/esm/expo/useExpoKeycloak.js.map +1 -0
- package/esm/expo/useTokenStorage.js +153 -0
- package/esm/expo/useTokenStorage.js.map +1 -0
- package/esm/hooks/useCurrentRouteName.js +2 -3
- package/esm/hooks/useCurrentRouteName.js.map +1 -1
- package/esm/hooks/useKeycloak/index.js +1 -1
- package/esm/hooks/useKeycloak/index.js.map +1 -1
- package/esm/hooks/useKeycloak/useKeycloak.js +17 -24
- package/esm/hooks/useKeycloak/useKeycloak.js.map +1 -1
- package/esm/hooks/useKeycloak/useKeycloak.native.js +39 -24
- package/esm/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
- package/esm/hooks/useLogin.js +12 -30
- package/esm/hooks/useLogin.js.map +1 -1
- package/esm/provider/afterAuth.js +21 -39
- package/esm/provider/afterAuth.js.map +1 -1
- package/esm/provider/index.js +11 -28
- package/esm/provider/index.js.map +1 -1
- package/esm/provider/keycloakProvider.js +55 -100
- package/esm/provider/keycloakProvider.js.map +1 -1
- package/esm/provider/keycloakProvider.native.js +12 -11
- package/esm/provider/keycloakProvider.native.js.map +1 -1
- package/esm/state/index.js +2 -2
- package/esm/state/index.js.map +1 -1
- package/lib/Authenticated.js +38 -26
- package/lib/Authenticated.js.map +1 -1
- package/lib/authConfig.js +2 -4
- package/lib/authConfig.js.map +1 -1
- package/lib/expo/ExpoKeycloakContext.d.ts +32 -0
- package/lib/expo/ExpoKeycloakContext.js +47 -0
- package/lib/expo/ExpoKeycloakContext.js.map +1 -0
- package/lib/expo/ExpoKeycloakProvider.d.ts +37 -0
- package/lib/expo/ExpoKeycloakProvider.js +130 -0
- package/lib/expo/ExpoKeycloakProvider.js.map +1 -0
- package/lib/expo/KeycloakContext.d.ts +32 -0
- package/lib/expo/KeycloakContext.js +49 -0
- package/lib/expo/KeycloakContext.js.map +1 -0
- package/lib/expo/KeycloakProvider.d.ts +37 -0
- package/lib/expo/KeycloakProvider.js +138 -0
- package/lib/expo/KeycloakProvider.js.map +1 -0
- package/lib/expo/const.d.ts +33 -0
- package/lib/expo/const.js +66 -0
- package/lib/expo/const.js.map +1 -0
- package/lib/expo/helpers.d.ts +41 -0
- package/lib/expo/helpers.js +77 -0
- package/lib/expo/helpers.js.map +1 -0
- package/lib/expo/index.d.ts +26 -0
- package/lib/expo/index.js +50 -0
- package/lib/expo/index.js.map +1 -0
- package/lib/expo/useExpoKeycloak.d.ts +31 -0
- package/lib/expo/useExpoKeycloak.js +62 -0
- package/lib/expo/useExpoKeycloak.js.map +1 -0
- package/lib/expo/useTokenStorage.d.ts +36 -0
- package/lib/expo/useTokenStorage.js +166 -0
- package/lib/expo/useTokenStorage.js.map +1 -0
- package/lib/hooks/index.js +3 -9
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useAuthConfig.js +0 -2
- package/lib/hooks/useAuthConfig.js.map +1 -1
- package/lib/hooks/useCurrentRouteName.js +6 -8
- package/lib/hooks/useCurrentRouteName.js.map +1 -1
- package/lib/hooks/useKeycloak/index.d.ts +9 -5
- package/lib/hooks/useKeycloak/index.js +1 -7
- package/lib/hooks/useKeycloak/index.js.map +1 -1
- package/lib/hooks/useKeycloak/useKeycloak.js +45 -30
- package/lib/hooks/useKeycloak/useKeycloak.js.map +1 -1
- package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +12 -4
- package/lib/hooks/useKeycloak/useKeycloak.native.js +40 -28
- package/lib/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
- package/lib/hooks/useLogin.js +16 -25
- package/lib/hooks/useLogin.js.map +1 -1
- package/lib/index.js +4 -10
- package/lib/index.js.map +1 -1
- package/lib/provider/afterAuth.js +52 -52
- package/lib/provider/afterAuth.js.map +1 -1
- package/lib/provider/index.js +44 -43
- package/lib/provider/index.js.map +1 -1
- package/lib/provider/keycloakProvider.js +93 -114
- package/lib/provider/keycloakProvider.js.map +1 -1
- package/lib/provider/keycloakProvider.native.js +39 -15
- package/lib/provider/keycloakProvider.native.js.map +1 -1
- package/lib/state/index.js +3 -5
- package/lib/state/index.js.map +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/types.js +2 -4
- package/lib/types.js.map +1 -1
- package/package.json +3 -2
- package/src/expo/ExpoKeycloakContext.ts +41 -0
- package/src/expo/ExpoKeycloakProvider.tsx +139 -0
- package/src/expo/NOTES +1 -0
- package/src/expo/const.ts +42 -0
- package/src/expo/helpers.ts +74 -0
- package/src/{@types/expoKeycloakAuth.d.ts → expo/index.ts} +6 -7
- package/src/expo/useExpoKeycloak.ts +44 -0
- package/src/expo/useTokenStorage.ts +168 -0
- package/src/hooks/useKeycloak/index.ts +13 -5
- package/src/hooks/useKeycloak/useKeycloak.native.ts +48 -11
- package/src/provider/keycloakProvider.native.tsx +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentRouteName.js","names":["useCurrentRouteName","MultiPlatform","isStorybook","isNext","router","useRouter","route","useRoute","name"],"sources":["../../src/hooks/useCurrentRouteName.ts"],"sourcesContent":["/**\n * File: /src/hooks/useCurrentRouteName.ts\n * Project: app\n * File Created: 08-11-2022 08:38:23\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:24:27\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 { 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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrentRouteName.js","names":["useCurrentRouteName","MultiPlatform","isStorybook","isNext","router","useRouter","route","useRoute","name"],"sources":["../../src/hooks/useCurrentRouteName.ts"],"sourcesContent":["/**\n * File: /src/hooks/useCurrentRouteName.ts\n * Project: app\n * File Created: 08-11-2022 08:38:23\n * Author: Clay Risser\n * -----\n * Last Modified: 25-11-2022 10:24:27\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 { 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"],"mappings":";;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAMO,SAASA,mBAAmB,GAAG;IACpC,IAAIC,4BAAa,CAACC,WAAW,EAAE,EAAE,OAAO,IAAI;IAC5C,IAAID,4BAAa,CAACE,MAAM,EAAE,EAAE;MAC1B,MAAMC,MAAM,GAAG,IAAAC,iBAAS,GAAE;MAC1B,OAAOD,MAAM,CAACE,KAAK;IACrB;IACA,MAAMA,KAAK,GAAG,IAAAC,gBAAQ,GAAE;IACxB,OAAOD,KAAK,CAACE,IAAI;EACnB;AAAC"}
|
|
@@ -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: 26-11-2022 09:28:49
|
|
8
8
|
* Modified By: Clay Risser
|
|
9
9
|
* -----
|
|
10
10
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -21,13 +21,17 @@
|
|
|
21
21
|
* See the License for the specific language governing permissions and
|
|
22
22
|
* limitations under the License.
|
|
23
23
|
*/
|
|
24
|
-
import type { KeycloakTokenParsed } from "keycloak-js";
|
|
24
|
+
import type { KeycloakResourceAccess, KeycloakRoles, KeycloakTokenParsed } from "keycloak-js";
|
|
25
25
|
export * from "./useKeycloak";
|
|
26
26
|
export interface IKeycloak {
|
|
27
27
|
authenticated?: boolean;
|
|
28
|
-
|
|
28
|
+
realmAccess?: KeycloakRoles;
|
|
29
29
|
refreshToken?: string;
|
|
30
|
+
refreshTokenParsed?: KeycloakTokenParsed;
|
|
31
|
+
resourceAccess?: KeycloakResourceAccess;
|
|
32
|
+
subject?: string;
|
|
33
|
+
token?: string;
|
|
30
34
|
tokenParsed?: KeycloakTokenParsed;
|
|
31
|
-
login: () => unknown;
|
|
32
|
-
logout: () => unknown;
|
|
35
|
+
login: () => Promise<unknown> | unknown;
|
|
36
|
+
logout: () => Promise<unknown> | unknown;
|
|
33
37
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
require("core-js/modules/esnext.global-this.js");
|
|
2
|
-
require("core-js/modules/es.object.define-property.js");
|
|
3
|
-
require("core-js/modules/es.array.for-each.js");
|
|
4
|
-
require("core-js/modules/es.object.to-string.js");
|
|
5
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
6
|
-
require("core-js/modules/es.object.keys.js");
|
|
7
1
|
(function (global, factory) {
|
|
8
2
|
if (typeof define === "function" && define.amd) {
|
|
9
3
|
define(["exports", "./useKeycloak"], factory);
|
|
@@ -27,7 +21,7 @@ require("core-js/modules/es.object.keys.js");
|
|
|
27
21
|
if (key in _exports && _exports[key] === _useKeycloak[key]) return;
|
|
28
22
|
Object.defineProperty(_exports, key, {
|
|
29
23
|
enumerable: true,
|
|
30
|
-
get: function
|
|
24
|
+
get: function () {
|
|
31
25
|
return _useKeycloak[key];
|
|
32
26
|
}
|
|
33
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"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:
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"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: 26-11-2022 09:28:49\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 {\n KeycloakResourceAccess,\n KeycloakRoles,\n KeycloakTokenParsed,\n} from \"keycloak-js\";\nexport * from \"./useKeycloak\";\n\nexport interface IKeycloak {\n authenticated?: boolean;\n realmAccess?: KeycloakRoles;\n refreshToken?: string;\n refreshTokenParsed?: KeycloakTokenParsed;\n resourceAccess?: KeycloakResourceAccess;\n subject?: string;\n token?: string;\n tokenParsed?: KeycloakTokenParsed;\n login: () => Promise<unknown> | unknown;\n logout: () => Promise<unknown> | unknown;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;EA6BA;IAAA;IAAA;IAAA;MAAA;MAAA;QAAA;MAAA;IAAA;EAAA;AAA8B"}
|
|
@@ -1,54 +1,69 @@
|
|
|
1
|
-
require("core-js/modules/esnext.global-this.js");
|
|
2
|
-
require("core-js/modules/es.object.define-property.js");
|
|
3
|
-
require("core-js/modules/es.object.keys.js");
|
|
4
|
-
require("core-js/modules/es.symbol.js");
|
|
5
|
-
require("core-js/modules/es.array.filter.js");
|
|
6
|
-
require("core-js/modules/es.object.to-string.js");
|
|
7
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
8
|
-
require("core-js/modules/es.array.for-each.js");
|
|
9
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
10
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
11
|
-
require("core-js/modules/es.object.define-properties.js");
|
|
12
1
|
(function (global, factory) {
|
|
13
2
|
if (typeof define === "function" && define.amd) {
|
|
14
|
-
define(["exports", "
|
|
3
|
+
define(["exports", "multiplatform.one", "@react-keycloak/web", "@react-keycloak/ssr", "../useAuthConfig"], factory);
|
|
15
4
|
} else if (typeof exports !== "undefined") {
|
|
16
|
-
factory(exports, require("
|
|
5
|
+
factory(exports, require("multiplatform.one"), require("@react-keycloak/web"), require("@react-keycloak/ssr"), require("../useAuthConfig"));
|
|
17
6
|
} else {
|
|
18
7
|
var mod = {
|
|
19
8
|
exports: {}
|
|
20
9
|
};
|
|
21
|
-
factory(mod.exports, global.
|
|
10
|
+
factory(mod.exports, global.multiplatform, global.web, global.ssr, global.useAuthConfig);
|
|
22
11
|
global.useKeycloak = mod.exports;
|
|
23
12
|
}
|
|
24
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports,
|
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _multiplatform, _web, _ssr, _useAuthConfig) {
|
|
25
14
|
"use strict";
|
|
26
15
|
|
|
27
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
28
16
|
Object.defineProperty(_exports, "__esModule", {
|
|
29
17
|
value: true
|
|
30
18
|
});
|
|
31
19
|
_exports.useKeycloak = useKeycloak;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
/**
|
|
21
|
+
* File: /src/hooks/useKeycloak/useKeycloak.ts
|
|
22
|
+
* Project: app
|
|
23
|
+
* File Created: 08-11-2022 06:04:59
|
|
24
|
+
* Author: Clay Risser
|
|
25
|
+
* -----
|
|
26
|
+
* Last Modified: 25-11-2022 10:22:57
|
|
27
|
+
* Modified By: Clay Risser
|
|
28
|
+
* -----
|
|
29
|
+
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
30
|
+
*
|
|
31
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
|
+
* you may not use this file except in compliance with the License.
|
|
33
|
+
* You may obtain a copy of the License at
|
|
34
|
+
*
|
|
35
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
36
|
+
*
|
|
37
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
39
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
+
* See the License for the specific language governing permissions and
|
|
41
|
+
* limitations under the License.
|
|
42
|
+
*/
|
|
43
|
+
|
|
35
44
|
function useKeycloak() {
|
|
36
|
-
|
|
45
|
+
const authConfig = (0, _useAuthConfig.useAuthConfig)();
|
|
37
46
|
if (_multiplatform.MultiPlatform.isStorybook()) return {
|
|
38
47
|
authenticated: true
|
|
39
48
|
};
|
|
40
49
|
if (_multiplatform.MultiPlatform.isNext() && authConfig.ssr) {
|
|
41
|
-
|
|
42
|
-
ssrKeycloak
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
const {
|
|
51
|
+
keycloak: ssrKeycloak,
|
|
52
|
+
initialized
|
|
53
|
+
} = (0, _ssr.useKeycloak)();
|
|
54
|
+
const keycloak = {
|
|
55
|
+
...ssrKeycloak
|
|
56
|
+
};
|
|
57
|
+
if (!initialized) keycloak.authenticated = undefined;
|
|
58
|
+
return keycloak;
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
reactKeycloak
|
|
50
|
-
initialized
|
|
51
|
-
|
|
60
|
+
const {
|
|
61
|
+
keycloak: reactKeycloak,
|
|
62
|
+
initialized
|
|
63
|
+
} = (0, _web.useKeycloak)();
|
|
64
|
+
const keycloak = {
|
|
65
|
+
...reactKeycloak
|
|
66
|
+
};
|
|
52
67
|
if (!initialized) keycloak.authenticated = undefined;
|
|
53
68
|
return keycloak;
|
|
54
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeycloak.js","names":["useKeycloak","authConfig","useAuthConfig","MultiPlatform","isStorybook","authenticated","isNext","ssr","
|
|
1
|
+
{"version":3,"file":"useKeycloak.js","names":["useKeycloak","authConfig","useAuthConfig","MultiPlatform","isStorybook","authenticated","isNext","ssr","keycloak","ssrKeycloak","initialized","useSsrKeycloak","undefined","reactKeycloak","useReactKeycloak"],"sources":["../../../src/hooks/useKeycloak/useKeycloak.ts"],"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: 25-11-2022 10:22:57\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 Keycloak from \"keycloak-js\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useKeycloak as useReactKeycloak } from \"@react-keycloak/web\";\nimport { useKeycloak as useSsrKeycloak } from \"@react-keycloak/ssr\";\nimport { IKeycloak } from \"./index\";\nimport { useAuthConfig } from \"../useAuthConfig\";\n\nexport function useKeycloak() {\n const authConfig = useAuthConfig();\n if (MultiPlatform.isStorybook()) return { authenticated: true } as IKeycloak;\n if (MultiPlatform.isNext() && authConfig.ssr) {\n const { keycloak: ssrKeycloak, initialized } = useSsrKeycloak();\n const keycloak = { ...ssrKeycloak } as Keycloak;\n if (!initialized) keycloak.authenticated = undefined;\n return keycloak as IKeycloak;\n }\n const { keycloak: reactKeycloak, initialized } = useReactKeycloak();\n const keycloak = { ...reactKeycloak } as Keycloak;\n if (!initialized) keycloak.authenticated = undefined;\n return keycloak as IKeycloak;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EASO,SAASA,WAAW,GAAG;IAC5B,MAAMC,UAAU,GAAG,IAAAC,4BAAa,GAAE;IAClC,IAAIC,4BAAa,CAACC,WAAW,EAAE,EAAE,OAAO;MAAEC,aAAa,EAAE;IAAK,CAAC;IAC/D,IAAIF,4BAAa,CAACG,MAAM,EAAE,IAAIL,UAAU,CAACM,GAAG,EAAE;MAC5C,MAAM;QAAEC,QAAQ,EAAEC,WAAW;QAAEC;MAAY,CAAC,GAAG,IAAAC,gBAAc,GAAE;MAC/D,MAAMH,QAAQ,GAAG;QAAE,GAAGC;MAAY,CAAa;MAC/C,IAAI,CAACC,WAAW,EAAEF,QAAQ,CAACH,aAAa,GAAGO,SAAS;MACpD,OAAOJ,QAAQ;IACjB;IACA,MAAM;MAAEA,QAAQ,EAAEK,aAAa;MAAEH;IAAY,CAAC,GAAG,IAAAI,gBAAgB,GAAE;IACnE,MAAMN,QAAQ,GAAG;MAAE,GAAGK;IAAc,CAAa;IACjD,IAAI,CAACH,WAAW,EAAEF,QAAQ,CAACH,aAAa,GAAGO,SAAS;IACpD,OAAOJ,QAAQ;EACjB;AAAC"}
|
|
@@ -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: 26-11-2022 09:05:23
|
|
8
8
|
* Modified By: Clay Risser
|
|
9
9
|
* -----
|
|
10
10
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -21,14 +21,22 @@
|
|
|
21
21
|
* See the License for the specific language governing permissions and
|
|
22
22
|
* limitations under the License.
|
|
23
23
|
*/
|
|
24
|
-
import
|
|
24
|
+
import "core-js/actual/atob";
|
|
25
|
+
import "core-js/actual/escape";
|
|
26
|
+
import { AuthRequestPromptOptions, AuthSessionResult } from "expo-auth-session";
|
|
25
27
|
import { IKeycloak } from "./index";
|
|
28
|
+
import { KeycloakResourceAccess, KeycloakRoles, KeycloakTokenParsed } from "keycloak-js";
|
|
26
29
|
export declare function useKeycloak(): IKeycloak;
|
|
27
30
|
export declare class ExpoKeycloak implements IKeycloak {
|
|
28
|
-
login: () => unknown;
|
|
29
31
|
logout: () => unknown;
|
|
30
32
|
token?: string | undefined;
|
|
33
|
+
refreshToken?: string | undefined;
|
|
31
34
|
authenticated?: boolean;
|
|
32
35
|
tokenParsed?: KeycloakTokenParsed;
|
|
33
|
-
|
|
36
|
+
refreshTokenParsed?: KeycloakTokenParsed;
|
|
37
|
+
subject?: string;
|
|
38
|
+
realmAccess?: KeycloakRoles;
|
|
39
|
+
resourceAccess?: KeycloakResourceAccess;
|
|
40
|
+
login: () => Promise<unknown> | unknown;
|
|
41
|
+
constructor(ready: boolean, isLoggedIn: boolean | undefined, login: (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult | undefined>, logout: () => unknown, token?: string | undefined, refreshToken?: string | undefined);
|
|
34
42
|
}
|
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
require("core-js/modules/esnext.global-this.js");
|
|
2
|
-
require("core-js/modules/es.object.define-property.js");
|
|
3
1
|
(function (global, factory) {
|
|
4
2
|
if (typeof define === "function" && define.amd) {
|
|
5
|
-
define(["exports", "core-js/
|
|
3
|
+
define(["exports", "core-js/actual/atob", "core-js/actual/escape", "multiplatform.one", "../../expo"], factory);
|
|
6
4
|
} else if (typeof exports !== "undefined") {
|
|
7
|
-
factory(exports, require("core-js/
|
|
5
|
+
factory(exports, require("core-js/actual/atob"), require("core-js/actual/escape"), require("multiplatform.one"), require("../../expo"));
|
|
8
6
|
} else {
|
|
9
7
|
var mod = {
|
|
10
8
|
exports: {}
|
|
11
9
|
};
|
|
12
|
-
factory(mod.exports, global.
|
|
10
|
+
factory(mod.exports, global.atob, global.escape, global.multiplatform, global.expo);
|
|
13
11
|
global.useKeycloakNative = mod.exports;
|
|
14
12
|
}
|
|
15
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports,
|
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _atob, _escape, _multiplatform, _expo) {
|
|
16
14
|
"use strict";
|
|
17
15
|
|
|
18
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
19
16
|
Object.defineProperty(_exports, "__esModule", {
|
|
20
17
|
value: true
|
|
21
18
|
});
|
|
22
19
|
_exports.ExpoKeycloak = void 0;
|
|
23
20
|
_exports.useKeycloak = useKeycloak;
|
|
24
|
-
_createClass2 = _interopRequireDefault(_createClass2);
|
|
25
|
-
_classCallCheck2 = _interopRequireDefault(_classCallCheck2);
|
|
26
21
|
/**
|
|
27
22
|
* File: /src/hooks/useKeycloak/useKeycloak.native.ts
|
|
28
23
|
* Project: app
|
|
29
24
|
* File Created: 08-11-2022 14:10:25
|
|
30
25
|
* Author: Clay Risser
|
|
31
26
|
* -----
|
|
32
|
-
* Last Modified:
|
|
27
|
+
* Last Modified: 26-11-2022 09:05:23
|
|
33
28
|
* Modified By: Clay Risser
|
|
34
29
|
* -----
|
|
35
30
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -51,27 +46,44 @@ require("core-js/modules/es.object.define-property.js");
|
|
|
51
46
|
if (_multiplatform.MultiPlatform.isStorybook()) return {
|
|
52
47
|
authenticated: true
|
|
53
48
|
};
|
|
54
|
-
|
|
55
|
-
ready
|
|
56
|
-
login
|
|
57
|
-
isLoggedIn
|
|
58
|
-
token
|
|
59
|
-
logout
|
|
60
|
-
|
|
49
|
+
const {
|
|
50
|
+
ready,
|
|
51
|
+
login,
|
|
52
|
+
isLoggedIn,
|
|
53
|
+
token,
|
|
54
|
+
logout,
|
|
55
|
+
refreshToken
|
|
56
|
+
} = (0, _expo.useExpoKeycloak)();
|
|
57
|
+
const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || undefined, refreshToken || undefined);
|
|
61
58
|
return keycloak;
|
|
62
59
|
}
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.
|
|
60
|
+
class ExpoKeycloak {
|
|
61
|
+
constructor(ready, isLoggedIn, login, logout, token, refreshToken) {
|
|
62
|
+
this.logout = logout;
|
|
63
|
+
this.token = token;
|
|
64
|
+
this.refreshToken = refreshToken;
|
|
65
|
+
this.authenticated = void 0;
|
|
66
|
+
this.tokenParsed = void 0;
|
|
67
|
+
this.refreshTokenParsed = void 0;
|
|
68
|
+
this.subject = void 0;
|
|
69
|
+
this.realmAccess = void 0;
|
|
70
|
+
this.resourceAccess = void 0;
|
|
71
|
+
this.login = void 0;
|
|
72
|
+
if (ready) this.authenticated = isLoggedIn;
|
|
73
|
+
if (this.authenticated) {
|
|
74
|
+
if (this.token) this.tokenParsed = decodeToken(this.token);
|
|
75
|
+
if (this.refreshToken) {
|
|
76
|
+
this.refreshTokenParsed = decodeToken(this.refreshToken);
|
|
77
|
+
}
|
|
78
|
+
if (this.tokenParsed) {
|
|
79
|
+
this.subject = this.tokenParsed.sub;
|
|
80
|
+
this.realmAccess = this.tokenParsed.realm_access;
|
|
81
|
+
this.resourceAccess = this.tokenParsed.resource_access;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
this.login = () => login();
|
|
73
85
|
}
|
|
74
|
-
}
|
|
86
|
+
}
|
|
75
87
|
_exports.ExpoKeycloak = ExpoKeycloak;
|
|
76
88
|
function decodeToken(str) {
|
|
77
89
|
str = str.split(".")[1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeycloak.native.js","names":["useKeycloak","MultiPlatform","isStorybook","authenticated","
|
|
1
|
+
{"version":3,"file":"useKeycloak.native.js","names":["useKeycloak","MultiPlatform","isStorybook","authenticated","ready","login","isLoggedIn","token","logout","refreshToken","useExpoKeycloak","keycloak","ExpoKeycloak","undefined","constructor","tokenParsed","refreshTokenParsed","subject","realmAccess","resourceAccess","decodeToken","sub","realm_access","resource_access","str","split","replace","length","decodeURIComponent","escape","atob","JSON","parse"],"sources":["../../../src/hooks/useKeycloak/useKeycloak.native.ts"],"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: 26-11-2022 09:05:23\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 \"core-js/actual/atob\";\nimport \"core-js/actual/escape\";\nimport { AuthRequestPromptOptions, AuthSessionResult } from \"expo-auth-session\";\nimport { IKeycloak } from \"./index\";\nimport {\n KeycloakResourceAccess,\n KeycloakRoles,\n KeycloakTokenParsed,\n} from \"keycloak-js\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useExpoKeycloak } from \"../../expo\";\n\nexport function useKeycloak() {\n if (MultiPlatform.isStorybook()) return { authenticated: true } as IKeycloak;\n const { ready, login, isLoggedIn, token, logout, refreshToken } =\n useExpoKeycloak();\n const keycloak = new ExpoKeycloak(\n ready,\n isLoggedIn,\n login,\n logout,\n token || undefined,\n refreshToken || undefined\n );\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> | unknown;\n\n constructor(\n ready: boolean,\n isLoggedIn: boolean | undefined,\n login: (\n options?: AuthRequestPromptOptions\n ) => Promise<AuthSessionResult | undefined>,\n public logout: () => 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"],"mappings":";;;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAcO,SAASA,WAAW,GAAG;IAC5B,IAAIC,4BAAa,CAACC,WAAW,EAAE,EAAE,OAAO;MAAEC,aAAa,EAAE;IAAK,CAAC;IAC/D,MAAM;MAAEC,KAAK;MAAEC,KAAK;MAAEC,UAAU;MAAEC,KAAK;MAAEC,MAAM;MAAEC;IAAa,CAAC,GAC7D,IAAAC,qBAAe,GAAE;IACnB,MAAMC,QAAQ,GAAG,IAAIC,YAAY,CAC/BR,KAAK,EACLE,UAAU,EACVD,KAAK,EACLG,MAAM,EACND,KAAK,IAAIM,SAAS,EAClBJ,YAAY,IAAII,SAAS,CAC1B;IACD,OAAOF,QAAQ;EACjB;EAEO,MAAMC,YAAY,CAAsB;IAe7CE,WAAW,CACTV,KAAc,EACdE,UAA+B,EAC/BD,KAE2C,EACpCG,MAAqB,EACrBD,KAAc,EACdE,YAAqB,EAC5B;MAAA,KAHOD,MAAqB,GAArBA,MAAqB;MAAA,KACrBD,KAAc,GAAdA,KAAc;MAAA,KACdE,YAAqB,GAArBA,YAAqB;MAAA,KAtB9BN,aAAa;MAAA,KAEbY,WAAW;MAAA,KAEXC,kBAAkB;MAAA,KAElBC,OAAO;MAAA,KAEPC,WAAW;MAAA,KAEXC,cAAc;MAAA,KAEdd,KAAK;MAYH,IAAID,KAAK,EAAE,IAAI,CAACD,aAAa,GAAGG,UAAU;MAC1C,IAAI,IAAI,CAACH,aAAa,EAAE;QACtB,IAAI,IAAI,CAACI,KAAK,EAAE,IAAI,CAACQ,WAAW,GAAGK,WAAW,CAAC,IAAI,CAACb,KAAK,CAAC;QAC1D,IAAI,IAAI,CAACE,YAAY,EAAE;UACrB,IAAI,CAACO,kBAAkB,GAAGI,WAAW,CAAC,IAAI,CAACX,YAAY,CAAC;QAC1D;QACA,IAAI,IAAI,CAACM,WAAW,EAAE;UACpB,IAAI,CAACE,OAAO,GAAG,IAAI,CAACF,WAAW,CAACM,GAAG;UACnC,IAAI,CAACH,WAAW,GAAG,IAAI,CAACH,WAAW,CAACO,YAAY;UAChD,IAAI,CAACH,cAAc,GAAG,IAAI,CAACJ,WAAW,CAACQ,eAAe;QACxD;MACF;MACA,IAAI,CAAClB,KAAK,GAAG,MAAMA,KAAK,EAAE;IAC5B;EACF;EAAC;EAED,SAASe,WAAW,CAACI,GAAW,EAAE;IAChCA,GAAG,GAAGA,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACvBD,GAAG,GAAGA,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;IAC5BF,GAAG,GAAGA,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;IAC5B,QAAQF,GAAG,CAACG,MAAM,GAAG,CAAC;MACpB,KAAK,CAAC;QACJ;MACF,KAAK,CAAC;QACJH,GAAG,IAAI,IAAI;QACX;MACF,KAAK,CAAC;QACJA,GAAG,IAAI,GAAG;QACV;MACF;QACE,MAAM,eAAe;IAAC;IAE1BA,GAAG,GAAGI,kBAAkB,CAACC,MAAM,CAACC,IAAI,CAACN,GAAG,CAAC,CAAC,CAAC;IAC3CA,GAAG,GAAGO,IAAI,CAACC,KAAK,CAACR,GAAG,CAAC;IACrB,OAAOA,GAAG;EACZ;AAAC"}
|
package/lib/hooks/useLogin.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
require("core-js/modules/esnext.global-this.js");
|
|
2
|
-
require("core-js/modules/es.object.define-property.js");
|
|
3
1
|
(function (global, factory) {
|
|
4
2
|
if (typeof define === "function" && define.amd) {
|
|
5
|
-
define(["exports", "
|
|
3
|
+
define(["exports", "@risserlabs/solito/router", "multiplatform.one", "./useCurrentRouteName", "./useKeycloak/useKeycloak", "./useAuthConfig"], factory);
|
|
6
4
|
} else if (typeof exports !== "undefined") {
|
|
7
|
-
factory(exports, require("
|
|
5
|
+
factory(exports, require("@risserlabs/solito/router"), require("multiplatform.one"), require("./useCurrentRouteName"), require("./useKeycloak/useKeycloak"), require("./useAuthConfig"));
|
|
8
6
|
} else {
|
|
9
7
|
var mod = {
|
|
10
8
|
exports: {}
|
|
11
9
|
};
|
|
12
|
-
factory(mod.exports, global.
|
|
10
|
+
factory(mod.exports, global.router, global.multiplatform, global.useCurrentRouteName, global.useKeycloak, global.useAuthConfig);
|
|
13
11
|
global.useLogin = mod.exports;
|
|
14
12
|
}
|
|
15
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports,
|
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _router, _multiplatform, _useCurrentRouteName, _useKeycloak, _useAuthConfig) {
|
|
16
14
|
"use strict";
|
|
17
15
|
|
|
18
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
19
16
|
Object.defineProperty(_exports, "__esModule", {
|
|
20
17
|
value: true
|
|
21
18
|
});
|
|
22
19
|
_exports.useLogin = useLogin;
|
|
23
|
-
_newArrowCheck2 = _interopRequireDefault(_newArrowCheck2);
|
|
24
20
|
/**
|
|
25
21
|
* File: /src/hooks/useLogin.ts
|
|
26
22
|
* Project: app
|
|
@@ -46,29 +42,24 @@ require("core-js/modules/es.object.define-property.js");
|
|
|
46
42
|
*/
|
|
47
43
|
|
|
48
44
|
function useLogin(loginRoute) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var authConfig = (0, _useAuthConfig.useAuthConfig)();
|
|
56
|
-
var currentRouteName = (0, _useCurrentRouteName.useCurrentRouteName)();
|
|
57
|
-
var router = (0, _router.useRouter)();
|
|
58
|
-
return function () {
|
|
59
|
-
(0, _newArrowCheck2["default"])(this, _this);
|
|
45
|
+
if (_multiplatform.MultiPlatform.isStorybook()) return () => null;
|
|
46
|
+
const keycloak = (0, _useKeycloak.useKeycloak)();
|
|
47
|
+
const authConfig = (0, _useAuthConfig.useAuthConfig)();
|
|
48
|
+
const currentRouteName = (0, _useCurrentRouteName.useCurrentRouteName)();
|
|
49
|
+
const router = (0, _router.useRouter)();
|
|
50
|
+
return () => {
|
|
60
51
|
if (!loginRoute) loginRoute = authConfig.loginRoute;
|
|
61
52
|
if (!loginRoute) {
|
|
62
53
|
keycloak.login();
|
|
63
54
|
return;
|
|
64
55
|
}
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
const url = new URL(`x://${loginRoute}`);
|
|
57
|
+
const searchParams = new URLSearchParams(url.search);
|
|
67
58
|
if (currentRouteName) searchParams.append("backTo", currentRouteName);
|
|
68
|
-
|
|
69
|
-
if (query.length) query =
|
|
70
|
-
router.push(
|
|
71
|
-
}
|
|
59
|
+
let query = searchParams.toString();
|
|
60
|
+
if (query.length) query = `?${query}`;
|
|
61
|
+
router.push(`${url.pathname.substring(2)}${query}`);
|
|
62
|
+
};
|
|
72
63
|
}
|
|
73
64
|
});
|
|
74
65
|
//# sourceMappingURL=useLogin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLogin.js","names":["useLogin","loginRoute","MultiPlatform","isStorybook","keycloak","useKeycloak","authConfig","useAuthConfig","currentRouteName","useCurrentRouteName","router","useRouter","login","url","URL","searchParams","URLSearchParams","search","append","query","toString","length","push","pathname","substring"],"sources":["../../src/hooks/useLogin.ts"],"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-11-2022 10:36:32\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 { useRouter } from \"@risserlabs/solito/router\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useCurrentRouteName } from \"./useCurrentRouteName\";\nimport { useKeycloak } from \"./useKeycloak/useKeycloak\";\nimport { useAuthConfig } from \"./useAuthConfig\";\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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLogin.js","names":["useLogin","loginRoute","MultiPlatform","isStorybook","keycloak","useKeycloak","authConfig","useAuthConfig","currentRouteName","useCurrentRouteName","router","useRouter","login","url","URL","searchParams","URLSearchParams","search","append","query","toString","length","push","pathname","substring"],"sources":["../../src/hooks/useLogin.ts"],"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-11-2022 10:36:32\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 { useRouter } from \"@risserlabs/solito/router\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport { useCurrentRouteName } from \"./useCurrentRouteName\";\nimport { useKeycloak } from \"./useKeycloak/useKeycloak\";\nimport { useAuthConfig } from \"./useAuthConfig\";\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"],"mappings":";;;;;;;;;;;;;;;;;;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAQO,SAASA,QAAQ,CAACC,UAAmB,EAAE;IAC5C,IAAIC,4BAAa,CAACC,WAAW,EAAE,EAAE,OAAO,MAAM,IAAI;IAClD,MAAMC,QAAQ,GAAG,IAAAC,wBAAW,GAAE;IAC9B,MAAMC,UAAU,GAAG,IAAAC,4BAAa,GAAE;IAClC,MAAMC,gBAAgB,GAAG,IAAAC,wCAAmB,GAAE;IAC9C,MAAMC,MAAM,GAAG,IAAAC,iBAAS,GAAE;IAC1B,OAAO,MAAM;MACX,IAAI,CAACV,UAAU,EAAEA,UAAU,GAAGK,UAAU,CAACL,UAAU;MACnD,IAAI,CAACA,UAAU,EAAE;QACfG,QAAQ,CAACQ,KAAK,EAAE;QAChB;MACF;MACA,MAAMC,GAAG,GAAG,IAAIC,GAAG,CAAE,OAAMb,UAAW,EAAC,CAAC;MACxC,MAAMc,YAAY,GAAG,IAAIC,eAAe,CAACH,GAAG,CAACI,MAAM,CAAC;MACpD,IAAIT,gBAAgB,EAAEO,YAAY,CAACG,MAAM,CAAC,QAAQ,EAAEV,gBAAgB,CAAC;MACrE,IAAIW,KAAK,GAAGJ,YAAY,CAACK,QAAQ,EAAE;MACnC,IAAID,KAAK,CAACE,MAAM,EAAEF,KAAK,GAAI,IAAGA,KAAM,EAAC;MACrCT,MAAM,CAACY,IAAI,CAAE,GAAET,GAAG,CAACU,QAAQ,CAACC,SAAS,CAAC,CAAC,CAAE,GAAEL,KAAM,EAAC,CAAC;IACrD,CAAC;EACH;AAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
require("core-js/modules/esnext.global-this.js");
|
|
2
|
-
require("core-js/modules/es.object.define-property.js");
|
|
3
|
-
require("core-js/modules/es.array.for-each.js");
|
|
4
|
-
require("core-js/modules/es.object.to-string.js");
|
|
5
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
6
|
-
require("core-js/modules/es.object.keys.js");
|
|
7
1
|
(function (global, factory) {
|
|
8
2
|
if (typeof define === "function" && define.amd) {
|
|
9
3
|
define(["exports", "./Authenticated", "./authConfig", "./hooks", "./provider"], factory);
|
|
@@ -27,7 +21,7 @@ require("core-js/modules/es.object.keys.js");
|
|
|
27
21
|
if (key in _exports && _exports[key] === _Authenticated[key]) return;
|
|
28
22
|
Object.defineProperty(_exports, key, {
|
|
29
23
|
enumerable: true,
|
|
30
|
-
get: function
|
|
24
|
+
get: function () {
|
|
31
25
|
return _Authenticated[key];
|
|
32
26
|
}
|
|
33
27
|
});
|
|
@@ -37,7 +31,7 @@ require("core-js/modules/es.object.keys.js");
|
|
|
37
31
|
if (key in _exports && _exports[key] === _authConfig[key]) return;
|
|
38
32
|
Object.defineProperty(_exports, key, {
|
|
39
33
|
enumerable: true,
|
|
40
|
-
get: function
|
|
34
|
+
get: function () {
|
|
41
35
|
return _authConfig[key];
|
|
42
36
|
}
|
|
43
37
|
});
|
|
@@ -47,7 +41,7 @@ require("core-js/modules/es.object.keys.js");
|
|
|
47
41
|
if (key in _exports && _exports[key] === _hooks[key]) return;
|
|
48
42
|
Object.defineProperty(_exports, key, {
|
|
49
43
|
enumerable: true,
|
|
50
|
-
get: function
|
|
44
|
+
get: function () {
|
|
51
45
|
return _hooks[key];
|
|
52
46
|
}
|
|
53
47
|
});
|
|
@@ -57,7 +51,7 @@ require("core-js/modules/es.object.keys.js");
|
|
|
57
51
|
if (key in _exports && _exports[key] === _provider[key]) return;
|
|
58
52
|
Object.defineProperty(_exports, key, {
|
|
59
53
|
enumerable: true,
|
|
60
|
-
get: function
|
|
54
|
+
get: function () {
|
|
61
55
|
return _provider[key];
|
|
62
56
|
}
|
|
63
57
|
});
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;EAwBA;IAAA;IAAA;IAAA;MAAA;MAAA;QAAA;MAAA;IAAA;EAAA;EACA;IAAA;IAAA;IAAA;MAAA;MAAA;QAAA;MAAA;IAAA;EAAA;EACA;IAAA;IAAA;IAAA;MAAA;MAAA;QAAA;MAAA;IAAA;EAAA;EACA;IAAA;IAAA;IAAA;MAAA;MAAA;QAAA;MAAA;IAAA;EAAA;AAA2B"}
|