@multiplatform.one/keycloak 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Authenticated.mjs +25 -0
- package/dist/esm/Authenticated.mjs.map +7 -0
- package/dist/esm/authConfig.mjs +10 -0
- package/dist/esm/authConfig.mjs.map +7 -0
- package/dist/esm/hooks/index.mjs +4 -0
- package/dist/esm/hooks/index.mjs.map +7 -0
- package/dist/esm/hooks/useAuthConfig.mjs +9 -0
- package/dist/esm/hooks/useAuthConfig.mjs.map +7 -0
- package/dist/esm/hooks/useCurrentRouteName/index.mjs +17 -0
- package/dist/esm/hooks/useCurrentRouteName/index.mjs.map +7 -0
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs +12 -0
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/index.mjs +2 -0
- package/dist/esm/hooks/useKeycloak/index.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs +81 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs.map +7 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs +108 -0
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs.map +7 -0
- package/dist/esm/hooks/useLogin.mjs +35 -0
- package/dist/esm/hooks/useLogin.mjs.map +7 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/index.mjs.map +7 -0
- package/dist/esm/provider/afterAuth.mjs +29 -0
- package/dist/esm/provider/afterAuth.mjs.map +7 -0
- package/dist/esm/provider/index.mjs +73 -0
- package/dist/esm/provider/index.mjs.map +7 -0
- package/dist/esm/provider/keycloakProvider.mjs +275 -0
- package/dist/esm/provider/keycloakProvider.mjs.map +7 -0
- package/dist/esm/provider/keycloakProvider.native.mjs +69 -0
- package/dist/esm/provider/keycloakProvider.native.mjs.map +7 -0
- package/dist/esm/state/index.mjs +14 -0
- package/dist/esm/state/index.mjs.map +7 -0
- package/dist/esm/types.mjs +5 -0
- package/dist/esm/types.mjs.map +7 -0
- package/dist/jsx/Authenticated.mjs +20 -0
- package/dist/jsx/Authenticated.mjs.map +7 -0
- package/dist/jsx/authConfig.mjs +10 -0
- package/dist/jsx/authConfig.mjs.map +7 -0
- package/dist/jsx/hooks/index.mjs +4 -0
- package/dist/jsx/hooks/index.mjs.map +7 -0
- package/dist/jsx/hooks/useAuthConfig.mjs +9 -0
- package/dist/jsx/hooks/useAuthConfig.mjs.map +7 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs +17 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs.map +7 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs +12 -0
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/index.mjs +2 -0
- package/dist/jsx/hooks/useKeycloak/index.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs +25 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs.map +7 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs +58 -0
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs.map +7 -0
- package/dist/jsx/hooks/useLogin.mjs +33 -0
- package/dist/jsx/hooks/useLogin.mjs.map +7 -0
- package/dist/jsx/index.mjs +5 -0
- package/dist/jsx/index.mjs.map +7 -0
- package/dist/jsx/provider/afterAuth.mjs +28 -0
- package/dist/jsx/provider/afterAuth.mjs.map +7 -0
- package/dist/jsx/provider/index.mjs +20 -0
- package/dist/jsx/provider/index.mjs.map +7 -0
- package/dist/jsx/provider/keycloakProvider.mjs +158 -0
- package/dist/jsx/provider/keycloakProvider.mjs.map +7 -0
- package/dist/jsx/provider/keycloakProvider.native.mjs +14 -0
- package/dist/jsx/provider/keycloakProvider.native.mjs.map +7 -0
- package/dist/jsx/state/index.mjs +17 -0
- package/dist/jsx/state/index.mjs.map +7 -0
- package/dist/jsx/types.mjs +5 -0
- package/dist/jsx/types.mjs.map +7 -0
- package/{lib → dist/lib}/Authenticated.d.ts +1 -1
- package/dist/lib/Authenticated.js +60 -0
- package/dist/lib/Authenticated.js.map +7 -0
- package/dist/lib/authConfig.js +35 -0
- package/dist/lib/authConfig.js.map +7 -0
- package/{lib → dist/lib}/hooks/index.d.ts +3 -3
- package/dist/lib/hooks/index.js +21 -0
- package/dist/lib/hooks/index.js.map +7 -0
- package/dist/lib/hooks/useAuthConfig.js +33 -0
- package/dist/lib/hooks/useAuthConfig.js.map +7 -0
- package/{lib/hooks/useCurrentRouteName.d.ts → dist/lib/hooks/useCurrentRouteName/index.d.ts} +5 -5
- package/dist/lib/hooks/useCurrentRouteName/index.js +41 -0
- package/dist/lib/hooks/useCurrentRouteName/index.js.map +7 -0
- package/{esm/types.js → dist/lib/hooks/useCurrentRouteName/index.native.d.ts} +5 -7
- package/dist/lib/hooks/useCurrentRouteName/index.native.js +36 -0
- package/dist/lib/hooks/useCurrentRouteName/index.native.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/index.d.ts +2 -2
- package/dist/lib/hooks/useKeycloak/index.js +19 -0
- package/dist/lib/hooks/useKeycloak/index.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/useKeycloak.d.ts +2 -2
- package/dist/lib/hooks/useKeycloak/useKeycloak.js +63 -0
- package/dist/lib/hooks/useKeycloak/useKeycloak.js.map +7 -0
- package/{lib → dist/lib}/hooks/useKeycloak/useKeycloak.native.d.ts +4 -4
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js +93 -0
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js.map +7 -0
- package/{lib → dist/lib}/hooks/useLogin.d.ts +1 -1
- package/dist/lib/hooks/useLogin.js +57 -0
- package/dist/lib/hooks/useLogin.js.map +7 -0
- package/{lib → dist/lib}/index.d.ts +4 -4
- package/dist/lib/index.js +22 -0
- package/dist/lib/index.js.map +7 -0
- package/{lib → dist/lib}/provider/afterAuth.d.ts +1 -1
- package/dist/lib/provider/afterAuth.js +53 -0
- package/dist/lib/provider/afterAuth.js.map +7 -0
- package/{lib → dist/lib}/provider/index.d.ts +4 -4
- package/dist/lib/provider/index.js +61 -0
- package/dist/lib/provider/index.js.map +7 -0
- package/{lib → dist/lib}/provider/keycloakProvider.d.ts +2 -2
- package/dist/lib/provider/keycloakProvider.js +212 -0
- package/dist/lib/provider/keycloakProvider.js.map +7 -0
- package/{lib → dist/lib}/provider/keycloakProvider.native.d.ts +2 -2
- package/dist/lib/provider/keycloakProvider.native.js +55 -0
- package/dist/lib/provider/keycloakProvider.native.js.map +7 -0
- package/{esm/state/index.js → dist/lib/state/index.d.ts} +8 -13
- package/dist/lib/state/index.js +41 -0
- package/dist/lib/state/index.js.map +7 -0
- package/dist/lib/tsconfig.build.tsbuildinfo +1 -0
- package/dist/lib/types.js +27 -0
- package/dist/lib/types.js.map +7 -0
- package/package.json +43 -62
- package/src/@types/coreJsPure.d.ts +2 -2
- package/src/@types/expoKeycloakAuth.d.ts +1 -1
- package/src/Authenticated.tsx +5 -8
- package/src/authConfig.ts +1 -1
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useAuthConfig.ts +2 -2
- package/{esm/hooks/useCurrentRouteName.js → src/hooks/useCurrentRouteName/index.native.ts} +8 -13
- package/src/hooks/{useCurrentRouteName.ts → useCurrentRouteName/index.ts} +8 -8
- package/src/hooks/useKeycloak/index.ts +2 -6
- package/src/hooks/useKeycloak/useKeycloak.native.ts +18 -32
- package/src/hooks/useKeycloak/useKeycloak.ts +7 -7
- package/src/hooks/useLogin.ts +7 -7
- package/src/index.ts +4 -4
- package/src/provider/afterAuth.tsx +10 -11
- package/src/provider/index.tsx +9 -12
- package/src/provider/keycloakProvider.native.tsx +8 -10
- package/src/provider/keycloakProvider.tsx +44 -61
- package/src/state/index.ts +13 -10
- package/esm/Authenticated.js +0 -42
- package/esm/Authenticated.js.map +0 -1
- package/esm/authConfig.js +0 -30
- package/esm/authConfig.js.map +0 -1
- package/esm/hooks/index.js +0 -28
- package/esm/hooks/index.js.map +0 -1
- package/esm/hooks/useAuthConfig.js +0 -30
- package/esm/hooks/useAuthConfig.js.map +0 -1
- package/esm/hooks/useCurrentRouteName.js.map +0 -1
- package/esm/hooks/useKeycloak/index.js +0 -27
- package/esm/hooks/useKeycloak/index.js.map +0 -1
- package/esm/hooks/useKeycloak/useKeycloak.js +0 -55
- package/esm/hooks/useKeycloak/useKeycloak.js.map +0 -1
- package/esm/hooks/useKeycloak/useKeycloak.native.js +0 -91
- package/esm/hooks/useKeycloak/useKeycloak.native.js.map +0 -1
- package/esm/hooks/useLogin.js +0 -50
- package/esm/hooks/useLogin.js.map +0 -1
- package/esm/index.js +0 -29
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
- package/esm/provider/afterAuth.js +0 -58
- package/esm/provider/afterAuth.js.map +0 -1
- package/esm/provider/index.js +0 -43
- package/esm/provider/index.js.map +0 -1
- package/esm/provider/keycloakProvider.js +0 -175
- package/esm/provider/keycloakProvider.js.map +0 -1
- package/esm/provider/keycloakProvider.native.js +0 -41
- package/esm/provider/keycloakProvider.native.js.map +0 -1
- package/esm/state/index.js.map +0 -1
- package/esm/types.js.map +0 -1
- package/lib/Authenticated.js +0 -64
- package/lib/Authenticated.js.map +0 -1
- package/lib/authConfig.js +0 -51
- package/lib/authConfig.js.map +0 -1
- package/lib/hooks/index.js +0 -50
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useAuthConfig.js +0 -48
- package/lib/hooks/useAuthConfig.js.map +0 -1
- package/lib/hooks/useCurrentRouteName.js +0 -54
- package/lib/hooks/useCurrentRouteName.js.map +0 -1
- package/lib/hooks/useKeycloak/index.js +0 -30
- package/lib/hooks/useKeycloak/index.js.map +0 -1
- package/lib/hooks/useKeycloak/useKeycloak.js +0 -71
- package/lib/hooks/useKeycloak/useKeycloak.js.map +0 -1
- package/lib/hooks/useKeycloak/useKeycloak.native.js +0 -112
- package/lib/hooks/useKeycloak/useKeycloak.native.js.map +0 -1
- package/lib/hooks/useLogin.js +0 -65
- package/lib/hooks/useLogin.js.map +0 -1
- package/lib/index.js +0 -60
- package/lib/index.js.map +0 -1
- package/lib/package.json +0 -1
- package/lib/provider/afterAuth.js +0 -78
- package/lib/provider/afterAuth.js.map +0 -1
- package/lib/provider/index.js +0 -77
- package/lib/provider/index.js.map +0 -1
- package/lib/provider/keycloakProvider.js +0 -193
- package/lib/provider/keycloakProvider.js.map +0 -1
- package/lib/provider/keycloakProvider.native.js +0 -61
- package/lib/provider/keycloakProvider.native.js.map +0 -1
- package/lib/state/index.d.ts +0 -34
- package/lib/state/index.js +0 -55
- package/lib/state/index.js.map +0 -1
- package/lib/tsconfig.build.tsbuildinfo +0 -1
- package/lib/types.js +0 -46
- package/lib/types.js.map +0 -1
- /package/{lib → dist/lib}/authConfig.d.ts +0 -0
- /package/{lib → dist/lib}/hooks/useAuthConfig.d.ts +0 -0
- /package/{lib → dist/lib}/types.d.ts +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "multiplatform.one", "@react-keycloak/web", "@react-keycloak/ssr", "../useAuthConfig"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("multiplatform.one"), require("@react-keycloak/web"), require("@react-keycloak/ssr"), require("../useAuthConfig"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.multiplatform, global.web, global.ssr, global.useAuthConfig);
|
|
11
|
-
global.useKeycloak = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _multiplatform, _web, _ssr, _useAuthConfig) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
_exports.useKeycloak = useKeycloak;
|
|
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: 28-01-2023 13:48:24
|
|
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
|
-
|
|
44
|
-
function useKeycloak() {
|
|
45
|
-
const authConfig = (0, _useAuthConfig.useAuthConfig)();
|
|
46
|
-
if (_multiplatform.MultiPlatform.isStorybook) return {
|
|
47
|
-
authenticated: true
|
|
48
|
-
};
|
|
49
|
-
if (_multiplatform.MultiPlatform.isNext && authConfig.ssr) {
|
|
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;
|
|
59
|
-
}
|
|
60
|
-
const {
|
|
61
|
-
keycloak: reactKeycloak,
|
|
62
|
-
initialized
|
|
63
|
-
} = (0, _web.useKeycloak)();
|
|
64
|
-
const keycloak = {
|
|
65
|
-
...reactKeycloak
|
|
66
|
-
};
|
|
67
|
-
if (!initialized) keycloak.authenticated = undefined;
|
|
68
|
-
return keycloak;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
//# sourceMappingURL=useKeycloak.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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: 28-01-2023 13:48:24\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,OAAO;MAAEC,aAAa,EAAE;IAAK,CAAC;IAC7D,IAAIF,4BAAa,CAACG,MAAM,IAAIL,UAAU,CAACM,GAAG,EAAE;MAC1C,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"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "core-js-pure/stable/atob", "core-js-pure/stable/escape", "multiplatform.one", "expo-keycloak-auth"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("core-js-pure/stable/atob"), require("core-js-pure/stable/escape"), require("multiplatform.one"), require("expo-keycloak-auth"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.atob, global.escape, global.multiplatform, global.expoKeycloakAuth);
|
|
11
|
-
global.useKeycloakNative = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _atob, _escape, _multiplatform, _expoKeycloakAuth) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
17
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
});
|
|
20
|
-
_exports.ExpoKeycloak = void 0;
|
|
21
|
-
_exports.useKeycloak = useKeycloak;
|
|
22
|
-
_atob = _interopRequireDefault(_atob);
|
|
23
|
-
_escape = _interopRequireDefault(_escape);
|
|
24
|
-
/**
|
|
25
|
-
* File: /src/hooks/useKeycloak/useKeycloak.native.ts
|
|
26
|
-
* Project: app
|
|
27
|
-
* File Created: 08-11-2022 14:10:25
|
|
28
|
-
* Author: Clay Risser
|
|
29
|
-
* -----
|
|
30
|
-
* Last Modified: 28-01-2023 13:47:33
|
|
31
|
-
* Modified By: Clay Risser
|
|
32
|
-
* -----
|
|
33
|
-
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
34
|
-
*
|
|
35
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
36
|
-
* you may not use this file except in compliance with the License.
|
|
37
|
-
* You may obtain a copy of the License at
|
|
38
|
-
*
|
|
39
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
-
*
|
|
41
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
43
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
-
* See the License for the specific language governing permissions and
|
|
45
|
-
* limitations under the License.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
function useKeycloak() {
|
|
49
|
-
if (_multiplatform.MultiPlatform.isStorybook) return {
|
|
50
|
-
authenticated: true
|
|
51
|
-
};
|
|
52
|
-
const {
|
|
53
|
-
ready,
|
|
54
|
-
login,
|
|
55
|
-
isLoggedIn,
|
|
56
|
-
token,
|
|
57
|
-
logout,
|
|
58
|
-
refreshToken
|
|
59
|
-
} = (0, _expoKeycloakAuth.useKeycloak)();
|
|
60
|
-
const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || undefined, refreshToken || undefined);
|
|
61
|
-
return keycloak;
|
|
62
|
-
}
|
|
63
|
-
class ExpoKeycloak {
|
|
64
|
-
constructor(ready, isLoggedIn, login, logout, token, refreshToken) {
|
|
65
|
-
this.logout = logout;
|
|
66
|
-
this.token = token;
|
|
67
|
-
this.refreshToken = refreshToken;
|
|
68
|
-
this.authenticated = void 0;
|
|
69
|
-
this.tokenParsed = void 0;
|
|
70
|
-
this.refreshTokenParsed = void 0;
|
|
71
|
-
this.subject = void 0;
|
|
72
|
-
this.realmAccess = void 0;
|
|
73
|
-
this.resourceAccess = void 0;
|
|
74
|
-
this.login = void 0;
|
|
75
|
-
if (ready) this.authenticated = isLoggedIn;
|
|
76
|
-
if (this.authenticated) {
|
|
77
|
-
if (this.token) this.tokenParsed = decodeToken(this.token);
|
|
78
|
-
if (this.refreshToken) {
|
|
79
|
-
this.refreshTokenParsed = decodeToken(this.refreshToken);
|
|
80
|
-
}
|
|
81
|
-
if (this.tokenParsed) {
|
|
82
|
-
this.subject = this.tokenParsed.sub;
|
|
83
|
-
this.realmAccess = this.tokenParsed.realm_access;
|
|
84
|
-
this.resourceAccess = this.tokenParsed.resource_access;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
this.login = () => login();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
_exports.ExpoKeycloak = ExpoKeycloak;
|
|
91
|
-
function decodeToken(str) {
|
|
92
|
-
str = str.split(".")[1];
|
|
93
|
-
str = str.replace(/-/g, "+");
|
|
94
|
-
str = str.replace(/_/g, "/");
|
|
95
|
-
switch (str.length % 4) {
|
|
96
|
-
case 0:
|
|
97
|
-
break;
|
|
98
|
-
case 2:
|
|
99
|
-
str += "==";
|
|
100
|
-
break;
|
|
101
|
-
case 3:
|
|
102
|
-
str += "=";
|
|
103
|
-
break;
|
|
104
|
-
default:
|
|
105
|
-
throw "Invalid token";
|
|
106
|
-
}
|
|
107
|
-
str = decodeURIComponent((0, _escape.default)((0, _atob.default)(str)));
|
|
108
|
-
str = JSON.parse(str);
|
|
109
|
-
return str;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
//# sourceMappingURL=useKeycloak.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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: 28-01-2023 13:47:33\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 { AuthRequestPromptOptions, AuthSessionResult } from \"expo-auth-session\";\nimport { MultiPlatform } from \"multiplatform.one\";\nimport {\n KeycloakResourceAccess,\n KeycloakRoles,\n KeycloakTokenParsed,\n} from \"keycloak-js\";\nimport { useKeycloak as useExpoKeycloak } from \"expo-keycloak-auth\";\nimport { IKeycloak } from \"./index\";\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,OAAO;MAAEC,aAAa,EAAE;IAAK,CAAC;IAC7D,MAAM;MAAEC,KAAK;MAAEC,KAAK;MAAEC,UAAU;MAAEC,KAAK;MAAEC,MAAM;MAAEC;IAAa,CAAC,GAC7D,IAAAC,6BAAe,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,CAAC,IAAAC,eAAM,EAAC,IAAAC,aAAI,EAACN,GAAG,CAAC,CAAC,CAAC;IAC3CA,GAAG,GAAGO,IAAI,CAACC,KAAK,CAACR,GAAG,CAAC;IACrB,OAAOA,GAAG;EACZ;AAAC"}
|
package/lib/hooks/useLogin.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "solito/router", "multiplatform.one", "./useCurrentRouteName", "./useKeycloak/useKeycloak", "./useAuthConfig"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("solito/router"), require("multiplatform.one"), require("./useCurrentRouteName"), require("./useKeycloak/useKeycloak"), require("./useAuthConfig"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.router, global.multiplatform, global.useCurrentRouteName, global.useKeycloak, global.useAuthConfig);
|
|
11
|
-
global.useLogin = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _router, _multiplatform, _useCurrentRouteName, _useKeycloak, _useAuthConfig) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
_exports.useLogin = useLogin;
|
|
20
|
-
/**
|
|
21
|
-
* File: /src/hooks/useLogin.ts
|
|
22
|
-
* Project: app
|
|
23
|
-
* File Created: 08-11-2022 08:49:14
|
|
24
|
-
* Author: Clay Risser
|
|
25
|
-
* -----
|
|
26
|
-
* Last Modified: 28-01-2023 13:47:42
|
|
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
|
-
|
|
44
|
-
function useLogin(loginRoute) {
|
|
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 () => {
|
|
51
|
-
if (!loginRoute) loginRoute = authConfig.loginRoute;
|
|
52
|
-
if (!loginRoute) {
|
|
53
|
-
keycloak.login();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const url = new URL(`x://${loginRoute}`);
|
|
57
|
-
const searchParams = new URLSearchParams(url.search);
|
|
58
|
-
if (currentRouteName) searchParams.append("backTo", currentRouteName);
|
|
59
|
-
let query = searchParams.toString();
|
|
60
|
-
if (query.length) query = `?${query}`;
|
|
61
|
-
router.push(`${url.pathname.substring(2)}${query}`);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=useLogin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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: 28-01-2023 13:47: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 { useRouter } from \"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,OAAO,MAAM,IAAI;IAChD,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
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "./Authenticated", "./authConfig", "./hooks", "./provider"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("./Authenticated"), require("./authConfig"), require("./hooks"), require("./provider"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.Authenticated, global.authConfig, global.hooks, global.provider);
|
|
11
|
-
global.index = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _Authenticated, _authConfig, _hooks, _provider) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
Object.keys(_Authenticated).forEach(function (key) {
|
|
20
|
-
if (key === "default" || key === "__esModule") return;
|
|
21
|
-
if (key in _exports && _exports[key] === _Authenticated[key]) return;
|
|
22
|
-
Object.defineProperty(_exports, key, {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () {
|
|
25
|
-
return _Authenticated[key];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
Object.keys(_authConfig).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in _exports && _exports[key] === _authConfig[key]) return;
|
|
32
|
-
Object.defineProperty(_exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _authConfig[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
Object.keys(_hooks).forEach(function (key) {
|
|
40
|
-
if (key === "default" || key === "__esModule") return;
|
|
41
|
-
if (key in _exports && _exports[key] === _hooks[key]) return;
|
|
42
|
-
Object.defineProperty(_exports, key, {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _hooks[key];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
Object.keys(_provider).forEach(function (key) {
|
|
50
|
-
if (key === "default" || key === "__esModule") return;
|
|
51
|
-
if (key in _exports && _exports[key] === _provider[key]) return;
|
|
52
|
-
Object.defineProperty(_exports, key, {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return _provider[key];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "react", "../hooks", "../hooks/useAuthConfig", "../state"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("react"), require("../hooks"), require("../hooks/useAuthConfig"), require("../state"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.react, global.hooks, global.useAuthConfig, global.state);
|
|
11
|
-
global.afterAuth = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _hooks, _useAuthConfig, _state) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
_exports.AfterAuth = void 0;
|
|
20
|
-
_react = _interopRequireWildcard(_react);
|
|
21
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
/**
|
|
24
|
-
* File: /auth/provider/afterAuth.tsx
|
|
25
|
-
* Project: app
|
|
26
|
-
* File Created: 22-11-2022 17:49:58
|
|
27
|
-
* Author: Clay Risser
|
|
28
|
-
* -----
|
|
29
|
-
* Last Modified: 22-11-2022 18:00:39
|
|
30
|
-
* Modified By: Clay Risser
|
|
31
|
-
* -----
|
|
32
|
-
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
33
|
-
*
|
|
34
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
35
|
-
* you may not use this file except in compliance with the License.
|
|
36
|
-
* You may obtain a copy of the License at
|
|
37
|
-
*
|
|
38
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
39
|
-
*
|
|
40
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
41
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
42
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
43
|
-
* See the License for the specific language governing permissions and
|
|
44
|
-
* limitations under the License.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
const logger = console;
|
|
48
|
-
const AfterAuth = _ref => {
|
|
49
|
-
let {
|
|
50
|
-
children
|
|
51
|
-
} = _ref;
|
|
52
|
-
const authConfig = (0, _useAuthConfig.useAuthConfig)();
|
|
53
|
-
const {
|
|
54
|
-
token,
|
|
55
|
-
refreshToken,
|
|
56
|
-
authenticated
|
|
57
|
-
} = (0, _hooks.useKeycloak)();
|
|
58
|
-
const [, setAuth] = (0, _state.useAuthState)();
|
|
59
|
-
(0, _react.useEffect)(() => {
|
|
60
|
-
if (!authenticated) return;
|
|
61
|
-
if (token) {
|
|
62
|
-
setAuth({
|
|
63
|
-
token,
|
|
64
|
-
...(refreshToken ? {
|
|
65
|
-
refreshToken
|
|
66
|
-
} : {})
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}, [token, refreshToken]);
|
|
70
|
-
if (authConfig.debug) {
|
|
71
|
-
logger.debug("authenticated", authenticated);
|
|
72
|
-
logger.debug("token", token);
|
|
73
|
-
}
|
|
74
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
75
|
-
};
|
|
76
|
-
_exports.AfterAuth = AfterAuth;
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=afterAuth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"afterAuth.js","names":["logger","console","AfterAuth","children","authConfig","useAuthConfig","token","refreshToken","authenticated","useKeycloak","setAuth","useAuthState","useEffect","debug"],"sources":["../../src/provider/afterAuth.tsx"],"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, { FC, ReactNode, useEffect } from \"react\";\nimport { useKeycloak } from \"../hooks\";\nimport { useAuthConfig } from \"../hooks/useAuthConfig\";\nimport { useAuthState } from \"../state\";\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 { token, refreshToken, authenticated } = useKeycloak();\n const [, setAuth] = useAuthState();\n\n useEffect(() => {\n if (!authenticated) return;\n if (token) {\n setAuth({\n token,\n ...(refreshToken ? { refreshToken } : {}),\n });\n }\n }, [token, refreshToken]);\n\n if (authConfig.debug) {\n logger.debug(\"authenticated\", authenticated);\n logger.debug(\"token\", token);\n }\n return <>{children}</>;\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;;EAWA,MAAMA,MAAM,GAAGC,OAAO;EAEf,MAAMC,SAA6B,GAAG,QAAkC;IAAA,IAAjC;MAAEC;IAAyB,CAAC;IACxE,MAAMC,UAAU,GAAG,IAAAC,4BAAa,GAAE;IAClC,MAAM;MAAEC,KAAK;MAAEC,YAAY;MAAEC;IAAc,CAAC,GAAG,IAAAC,kBAAW,GAAE;IAC5D,MAAM,GAAGC,OAAO,CAAC,GAAG,IAAAC,mBAAY,GAAE;IAElC,IAAAC,gBAAS,EAAC,MAAM;MACd,IAAI,CAACJ,aAAa,EAAE;MACpB,IAAIF,KAAK,EAAE;QACTI,OAAO,CAAC;UACNJ,KAAK;UACL,IAAIC,YAAY,GAAG;YAAEA;UAAa,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC,CAAC;MACJ;IACF,CAAC,EAAE,CAACD,KAAK,EAAEC,YAAY,CAAC,CAAC;IAEzB,IAAIH,UAAU,CAACS,KAAK,EAAE;MACpBb,MAAM,CAACa,KAAK,CAAC,eAAe,EAAEL,aAAa,CAAC;MAC5CR,MAAM,CAACa,KAAK,CAAC,OAAO,EAAEP,KAAK,CAAC;IAC9B;IACA,oBAAO,4DAAGH,QAAQ,CAAI;EACxB,CAAC;EAAC;AAAA"}
|
package/lib/provider/index.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "react", "../authConfig", "./keycloakProvider"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("react"), require("../authConfig"), require("./keycloakProvider"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.react, global.authConfig, global.keycloakProvider);
|
|
11
|
-
global.index = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _authConfig, _keycloakProvider) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(_exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
var _exportNames = {
|
|
20
|
-
AuthProvider: true
|
|
21
|
-
};
|
|
22
|
-
_exports.AuthProvider = void 0;
|
|
23
|
-
_react = _interopRequireWildcard(_react);
|
|
24
|
-
Object.keys(_keycloakProvider).forEach(function (key) {
|
|
25
|
-
if (key === "default" || key === "__esModule") return;
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
27
|
-
if (key in _exports && _exports[key] === _keycloakProvider[key]) return;
|
|
28
|
-
Object.defineProperty(_exports, key, {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return _keycloakProvider[key];
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
36
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
/**
|
|
38
|
-
* File: /auth/provider/index.tsx
|
|
39
|
-
* Project: app
|
|
40
|
-
* File Created: 08-11-2022 06:33:07
|
|
41
|
-
* Author: Clay Risser
|
|
42
|
-
* -----
|
|
43
|
-
* Last Modified: 22-11-2022 18:00:13
|
|
44
|
-
* Modified By: Clay Risser
|
|
45
|
-
* -----
|
|
46
|
-
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
47
|
-
*
|
|
48
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
49
|
-
* you may not use this file except in compliance with the License.
|
|
50
|
-
* You may obtain a copy of the License at
|
|
51
|
-
*
|
|
52
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
53
|
-
*
|
|
54
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
55
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
56
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
57
|
-
* See the License for the specific language governing permissions and
|
|
58
|
-
* limitations under the License.
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
const AuthProvider = props => {
|
|
62
|
-
const {
|
|
63
|
-
authConfig,
|
|
64
|
-
debug
|
|
65
|
-
} = props;
|
|
66
|
-
const authConfigValue = (0, _react.useMemo)(() => ({
|
|
67
|
-
..._authConfig.defaultAuthConfig,
|
|
68
|
-
...authConfig,
|
|
69
|
-
debug: !!debug
|
|
70
|
-
}), []);
|
|
71
|
-
return /*#__PURE__*/_react.default.createElement(_authConfig.AuthConfigContext.Provider, {
|
|
72
|
-
value: authConfigValue
|
|
73
|
-
}, /*#__PURE__*/_react.default.createElement(_keycloakProvider.KeycloakProvider, props));
|
|
74
|
-
};
|
|
75
|
-
_exports.AuthProvider = AuthProvider;
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["AuthProvider","props","authConfig","debug","authConfigValue","useMemo","defaultAuthConfig"],"sources":["../../src/provider/index.tsx"],"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, { FC, useMemo } from \"react\";\nimport {\n AuthConfig,\n AuthConfigContext,\n defaultAuthConfig,\n} from \"../authConfig\";\nimport { KeycloakProvider, KeycloakProviderProps } from \"./keycloakProvider\";\n\nexport interface AuthProviderProps extends KeycloakProviderProps {\n authConfig?: Partial<AuthConfig>;\n}\n\nexport const AuthProvider: FC<AuthProviderProps> = (\n props: AuthProviderProps\n) => {\n const { authConfig, debug } = props;\n const authConfigValue = useMemo(\n () => ({\n ...defaultAuthConfig,\n ...authConfig,\n debug: !!debug,\n }),\n []\n );\n\n return (\n <AuthConfigContext.Provider value={authConfigValue}>\n <KeycloakProvider {...props} />\n </AuthConfigContext.Provider>\n );\n};\n\nexport * from \"./keycloakProvider\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAwDA;IAAA;IAAA;IAAA;IAAA;MAAA;MAAA;QAAA;MAAA;IAAA;EAAA;EAAmC;EAAA;EAxDnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAcO,MAAMA,YAAmC,GAC9CC,KAAwB,IACrB;IACH,MAAM;MAAEC,UAAU;MAAEC;IAAM,CAAC,GAAGF,KAAK;IACnC,MAAMG,eAAe,GAAG,IAAAC,cAAO,EAC7B,OAAO;MACL,GAAGC,6BAAiB;MACpB,GAAGJ,UAAU;MACbC,KAAK,EAAE,CAAC,CAACA;IACX,CAAC,CAAC,EACF,EAAE,CACH;IAED,oBACE,6BAAC,6BAAiB,CAAC,QAAQ;MAAC,KAAK,EAAEC;IAAgB,gBACjD,6BAAC,kCAAgB,EAAKH,KAAK,CAAI,CACJ;EAEjC,CAAC;EAAC;AAAA"}
|