@multiplatform.one/keycloak 0.7.1 → 0.7.3

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.
Files changed (125) hide show
  1. package/lib/@types/coreJsPure.d.d.mts +2 -0
  2. package/lib/@types/coreJsPure.d.d.ts +2 -0
  3. package/lib/@types/coreJsPure.d.js +1 -0
  4. package/lib/@types/coreJsPure.d.mjs +0 -0
  5. package/lib/@types/expoKeycloakAuth.d.d.mts +28 -0
  6. package/lib/@types/expoKeycloakAuth.d.d.ts +28 -0
  7. package/lib/@types/expoKeycloakAuth.d.js +1 -0
  8. package/lib/@types/expoKeycloakAuth.d.mjs +0 -0
  9. package/lib/Authenticated.d.mts +36 -0
  10. package/lib/Authenticated.d.ts +36 -0
  11. package/lib/Authenticated.js +19 -0
  12. package/lib/Authenticated.mjs +20 -0
  13. package/lib/authConfig.d.mts +37 -0
  14. package/lib/authConfig.d.ts +37 -0
  15. package/lib/authConfig.js +8 -0
  16. package/lib/authConfig.mjs +9 -0
  17. package/lib/chunk-2GUOEPFY.mjs +0 -0
  18. package/lib/chunk-3ZPHNEJL.js +11 -0
  19. package/lib/chunk-64PPU7Q3.mjs +13 -0
  20. package/lib/chunk-6NDWOV55.js +1 -0
  21. package/lib/chunk-7MTPH6XK.mjs +26 -0
  22. package/lib/chunk-A7UBOIAL.js +13 -0
  23. package/lib/chunk-AD6VPMID.mjs +20 -0
  24. package/lib/chunk-AOKVCTMY.mjs +76 -0
  25. package/lib/chunk-AYKQVWMR.mjs +0 -0
  26. package/lib/chunk-BJ2OPIMW.js +78 -0
  27. package/lib/chunk-BTCP7NB3.js +443 -0
  28. package/lib/chunk-C2FNSVJO.js +17 -0
  29. package/lib/chunk-DKRUDENY.mjs +265 -0
  30. package/lib/chunk-E2X33LSD.js +460 -0
  31. package/lib/chunk-FXGWERIA.js +161 -0
  32. package/lib/chunk-HDNHCVXT.js +33 -0
  33. package/lib/chunk-KLLABHIC.js +13 -0
  34. package/lib/chunk-KMAXXKJT.js +22 -0
  35. package/lib/chunk-L5HMOY4M.mjs +18 -0
  36. package/lib/chunk-NU2SJ3ST.mjs +84 -0
  37. package/lib/chunk-NWRANDZ6.js +98 -0
  38. package/lib/chunk-NXTVYIBR.mjs +11 -0
  39. package/lib/chunk-OYWAYMFN.js +17 -0
  40. package/lib/chunk-S237YNYQ.mjs +10 -0
  41. package/lib/chunk-SK4YK6KE.mjs +50 -0
  42. package/lib/chunk-UBCNCE73.js +56 -0
  43. package/lib/chunk-UBVYEZI3.js +1 -0
  44. package/lib/chunk-UOKDJT5L.mjs +16 -0
  45. package/lib/chunk-VLUTEDDM.mjs +41 -0
  46. package/lib/chunk-Y4XMF3R6.mjs +13 -0
  47. package/lib/chunk-YGNNHTFE.js +12 -0
  48. package/lib/chunk-ZVG3OFME.mjs +52 -0
  49. package/lib/hooks/index.d.mts +9 -0
  50. package/lib/hooks/index.d.ts +9 -0
  51. package/lib/hooks/index.js +23 -0
  52. package/lib/hooks/index.mjs +34 -0
  53. package/lib/hooks/useAuthConfig.d.mts +29 -0
  54. package/lib/hooks/useAuthConfig.d.ts +29 -0
  55. package/lib/hooks/useAuthConfig.js +8 -0
  56. package/lib/hooks/useAuthConfig.mjs +8 -0
  57. package/lib/hooks/useCurrentRouteName/index.d.mts +26 -0
  58. package/lib/hooks/useCurrentRouteName/index.d.ts +26 -0
  59. package/lib/hooks/useCurrentRouteName/index.js +7 -0
  60. package/lib/hooks/useCurrentRouteName/index.mjs +7 -0
  61. package/lib/hooks/useCurrentRouteName/index.native.d.mts +26 -0
  62. package/lib/hooks/useCurrentRouteName/index.native.d.ts +26 -0
  63. package/lib/hooks/useCurrentRouteName/index.native.js +14 -0
  64. package/lib/hooks/useCurrentRouteName/index.native.mjs +14 -0
  65. package/lib/hooks/useKeycloak/index.d.mts +70 -0
  66. package/lib/hooks/useKeycloak/index.d.ts +70 -0
  67. package/lib/hooks/useKeycloak/index.js +11 -0
  68. package/lib/hooks/useKeycloak/index.mjs +12 -0
  69. package/lib/hooks/useKeycloak/useKeycloak.d.mts +2 -0
  70. package/lib/hooks/useKeycloak/useKeycloak.d.ts +2 -0
  71. package/lib/hooks/useKeycloak/useKeycloak.js +10 -0
  72. package/lib/hooks/useKeycloak/useKeycloak.mjs +11 -0
  73. package/lib/hooks/useKeycloak/useKeycloak.native.d.mts +44 -0
  74. package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +44 -0
  75. package/lib/hooks/useKeycloak/useKeycloak.native.js +80 -0
  76. package/lib/hooks/useKeycloak/useKeycloak.native.mjs +69 -0
  77. package/lib/hooks/useLogin.d.mts +26 -0
  78. package/lib/hooks/useLogin.d.ts +26 -0
  79. package/lib/hooks/useLogin.js +11 -0
  80. package/lib/hooks/useLogin.mjs +11 -0
  81. package/lib/hooks/useTokensFromQuery/index.d.mts +26 -0
  82. package/lib/hooks/useTokensFromQuery/index.d.ts +26 -0
  83. package/lib/hooks/useTokensFromQuery/index.js +7 -0
  84. package/lib/hooks/useTokensFromQuery/index.mjs +7 -0
  85. package/lib/hooks/useTokensFromQuery/index.native.d.mts +26 -0
  86. package/lib/hooks/useTokensFromQuery/index.native.d.ts +26 -0
  87. package/lib/hooks/useTokensFromQuery/index.native.js +10 -0
  88. package/lib/hooks/useTokensFromQuery/index.native.mjs +7 -0
  89. package/lib/hooks/useTokensFromState.d.mts +26 -0
  90. package/lib/hooks/useTokensFromState.d.ts +26 -0
  91. package/lib/hooks/useTokensFromState.js +9 -0
  92. package/lib/hooks/useTokensFromState.mjs +9 -0
  93. package/lib/index.d.mts +13 -0
  94. package/lib/index.d.ts +13 -0
  95. package/lib/index.js +15 -15
  96. package/lib/index.mjs +56 -0
  97. package/lib/provider/afterAuth.d.mts +32 -0
  98. package/lib/provider/afterAuth.d.ts +32 -0
  99. package/lib/provider/afterAuth.js +18 -0
  100. package/lib/provider/afterAuth.mjs +18 -0
  101. package/lib/provider/index.d.mts +42 -0
  102. package/lib/provider/index.d.ts +42 -0
  103. package/lib/provider/index.js +22 -0
  104. package/lib/provider/index.mjs +25 -0
  105. package/lib/provider/keycloakProvider.d.mts +45 -0
  106. package/lib/provider/keycloakProvider.d.ts +45 -0
  107. package/lib/provider/keycloakProvider.js +20 -0
  108. package/lib/provider/keycloakProvider.mjs +21 -0
  109. package/lib/provider/keycloakProvider.native.d.mts +32 -0
  110. package/lib/provider/keycloakProvider.native.d.ts +32 -0
  111. package/lib/provider/keycloakProvider.native.js +87 -0
  112. package/lib/provider/keycloakProvider.native.mjs +30 -0
  113. package/lib/state/index.d.mts +34 -0
  114. package/lib/state/index.d.ts +34 -0
  115. package/lib/state/index.js +7 -0
  116. package/lib/state/index.mjs +7 -0
  117. package/lib/types.d.mts +40 -0
  118. package/lib/types.d.ts +40 -0
  119. package/lib/types.js +8 -0
  120. package/lib/types.mjs +7 -0
  121. package/lib/util.d.mts +27 -0
  122. package/lib/util.d.ts +27 -0
  123. package/lib/util.js +8 -0
  124. package/lib/util.mjs +9 -0
  125. package/package.json +30 -30
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File: /src/hooks/useCurrentRouteName/index.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 24-02-2023 06:30:32
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 24-02-2023 06:30:54
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022 - 2023
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ declare function useCurrentRouteName(): string | null;
25
+
26
+ export { useCurrentRouteName };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File: /src/hooks/useCurrentRouteName/index.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 24-02-2023 06:30:32
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 24-02-2023 06:30:54
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022 - 2023
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ declare function useCurrentRouteName(): string | null;
25
+
26
+ export { useCurrentRouteName };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _chunkOYWAYMFNjs = require("../../chunk-OYWAYMFN.js");
6
+ require("../../chunk-KMAXXKJT.js");
7
+ exports.useCurrentRouteName = _chunkOYWAYMFNjs.useCurrentRouteName;
@@ -0,0 +1,7 @@
1
+ import {
2
+ useCurrentRouteName
3
+ } from "../../chunk-L5HMOY4M.mjs";
4
+ import "../../chunk-S237YNYQ.mjs";
5
+ export {
6
+ useCurrentRouteName
7
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File: /src/hooks/useCurrentRouteName/index.native.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 24-02-2023 06:30:36
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 24-02-2023 06:31:25
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022 - 2023
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ declare function useCurrentRouteName(): string | null;
25
+
26
+ export { useCurrentRouteName };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File: /src/hooks/useCurrentRouteName/index.native.ts
3
+ * Project: @multiplatform.one/keycloak
4
+ * File Created: 24-02-2023 06:30:36
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 24-02-2023 06:31:25
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2022 - 2023
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ declare function useCurrentRouteName(): string | null;
25
+
26
+ export { useCurrentRouteName };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ require("../../chunk-KMAXXKJT.js");
6
+ // src/hooks/useCurrentRouteName/index.native.ts
7
+ var _multiplatformone = require("multiplatform.one");
8
+ var _native = require("@react-navigation/native");
9
+ function useCurrentRouteName() {
10
+ if (_multiplatformone.MultiPlatform.isStorybook) return null;
11
+ var route = _native.useRoute.call(void 0);
12
+ return route.name;
13
+ }
14
+ exports.useCurrentRouteName = useCurrentRouteName;
@@ -0,0 +1,14 @@
1
+ import "../../chunk-S237YNYQ.mjs";
2
+
3
+ // src/hooks/useCurrentRouteName/index.native.ts
4
+ import { MultiPlatform } from "multiplatform.one";
5
+ import { useRoute } from "@react-navigation/native";
6
+ function useCurrentRouteName() {
7
+ if (MultiPlatform.isStorybook)
8
+ return null;
9
+ const route = useRoute();
10
+ return route.name;
11
+ }
12
+ export {
13
+ useCurrentRouteName
14
+ };
@@ -0,0 +1,70 @@
1
+ import * as _bitspur_keycloak_js from '@bitspur/keycloak-js';
2
+ import { KeycloakRoles, KeycloakTokenParsed, KeycloakResourceAccess } from '@bitspur/keycloak-js';
3
+
4
+ declare function useKeycloak(): Keycloak;
5
+ declare class Keycloak implements IKeycloak {
6
+ private readonly keycloak;
7
+ authenticated?: boolean;
8
+ constructor(keycloak: IKeycloak | undefined, initialized: boolean);
9
+ get idToken(): string | undefined;
10
+ get realmAccess(): _bitspur_keycloak_js.KeycloakRoles | undefined;
11
+ get refreshToken(): string | undefined;
12
+ get refreshTokenParsed(): _bitspur_keycloak_js.KeycloakTokenParsed | undefined;
13
+ get resourceAccess(): _bitspur_keycloak_js.KeycloakResourceAccess | undefined;
14
+ get subject(): string | undefined;
15
+ get token(): string | undefined;
16
+ get tokenParsed(): ITokenParsed | undefined;
17
+ get email(): any;
18
+ get username(): string | undefined;
19
+ login(): Promise<unknown>;
20
+ logout(): Promise<unknown>;
21
+ }
22
+
23
+ /**
24
+ * File: /src/hooks/useKeycloak/index.ts
25
+ * Project: app
26
+ * File Created: 08-11-2022 14:10:44
27
+ * Author: Clay Risser
28
+ * -----
29
+ * Last Modified: 01-06-2023 13:55:42
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
+ interface IKeycloak {
48
+ authenticated?: boolean;
49
+ idToken?: string;
50
+ realmAccess?: KeycloakRoles;
51
+ refreshToken?: string;
52
+ refreshTokenParsed?: KeycloakTokenParsed;
53
+ resourceAccess?: KeycloakResourceAccess;
54
+ subject?: string;
55
+ token?: string;
56
+ tokenParsed?: ITokenParsed;
57
+ email?: string;
58
+ username?: string;
59
+ login: () => Promise<unknown>;
60
+ logout: () => Promise<unknown>;
61
+ }
62
+ interface ITokenParsed extends KeycloakTokenParsed {
63
+ 'allowed-origins'?: string[];
64
+ email_verified?: boolean;
65
+ preferred_username?: string;
66
+ scope?: string;
67
+ sid?: string;
68
+ }
69
+
70
+ export { IKeycloak, ITokenParsed, Keycloak, useKeycloak };
@@ -0,0 +1,70 @@
1
+ import * as _bitspur_keycloak_js from '@bitspur/keycloak-js';
2
+ import { KeycloakRoles, KeycloakTokenParsed, KeycloakResourceAccess } from '@bitspur/keycloak-js';
3
+
4
+ declare function useKeycloak(): Keycloak;
5
+ declare class Keycloak implements IKeycloak {
6
+ private readonly keycloak;
7
+ authenticated?: boolean;
8
+ constructor(keycloak: IKeycloak | undefined, initialized: boolean);
9
+ get idToken(): string | undefined;
10
+ get realmAccess(): _bitspur_keycloak_js.KeycloakRoles | undefined;
11
+ get refreshToken(): string | undefined;
12
+ get refreshTokenParsed(): _bitspur_keycloak_js.KeycloakTokenParsed | undefined;
13
+ get resourceAccess(): _bitspur_keycloak_js.KeycloakResourceAccess | undefined;
14
+ get subject(): string | undefined;
15
+ get token(): string | undefined;
16
+ get tokenParsed(): ITokenParsed | undefined;
17
+ get email(): any;
18
+ get username(): string | undefined;
19
+ login(): Promise<unknown>;
20
+ logout(): Promise<unknown>;
21
+ }
22
+
23
+ /**
24
+ * File: /src/hooks/useKeycloak/index.ts
25
+ * Project: app
26
+ * File Created: 08-11-2022 14:10:44
27
+ * Author: Clay Risser
28
+ * -----
29
+ * Last Modified: 01-06-2023 13:55:42
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
+ interface IKeycloak {
48
+ authenticated?: boolean;
49
+ idToken?: string;
50
+ realmAccess?: KeycloakRoles;
51
+ refreshToken?: string;
52
+ refreshTokenParsed?: KeycloakTokenParsed;
53
+ resourceAccess?: KeycloakResourceAccess;
54
+ subject?: string;
55
+ token?: string;
56
+ tokenParsed?: ITokenParsed;
57
+ email?: string;
58
+ username?: string;
59
+ login: () => Promise<unknown>;
60
+ logout: () => Promise<unknown>;
61
+ }
62
+ interface ITokenParsed extends KeycloakTokenParsed {
63
+ 'allowed-origins'?: string[];
64
+ email_verified?: boolean;
65
+ preferred_username?: string;
66
+ scope?: string;
67
+ sid?: string;
68
+ }
69
+
70
+ export { IKeycloak, ITokenParsed, Keycloak, useKeycloak };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ require("../../chunk-6NDWOV55.js");
6
+ var _chunkE2X33LSDjs = require("../../chunk-E2X33LSD.js");
7
+ require("../../chunk-3ZPHNEJL.js");
8
+ require("../../chunk-A7UBOIAL.js");
9
+ require("../../chunk-KMAXXKJT.js");
10
+ exports.Keycloak = _chunkE2X33LSDjs.Keycloak;
11
+ exports.useKeycloak = _chunkE2X33LSDjs.useKeycloak;
@@ -0,0 +1,12 @@
1
+ import "../../chunk-2GUOEPFY.mjs";
2
+ import {
3
+ Keycloak,
4
+ useKeycloak
5
+ } from "../../chunk-NU2SJ3ST.mjs";
6
+ import "../../chunk-Y4XMF3R6.mjs";
7
+ import "../../chunk-64PPU7Q3.mjs";
8
+ import "../../chunk-S237YNYQ.mjs";
9
+ export {
10
+ Keycloak,
11
+ useKeycloak
12
+ };
@@ -0,0 +1,2 @@
1
+ export { Keycloak, useKeycloak } from './index.mjs';
2
+ import '@bitspur/keycloak-js';
@@ -0,0 +1,2 @@
1
+ export { Keycloak, useKeycloak } from './index.js';
2
+ import '@bitspur/keycloak-js';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _chunkE2X33LSDjs = require("../../chunk-E2X33LSD.js");
6
+ require("../../chunk-3ZPHNEJL.js");
7
+ require("../../chunk-A7UBOIAL.js");
8
+ require("../../chunk-KMAXXKJT.js");
9
+ exports.Keycloak = _chunkE2X33LSDjs.Keycloak;
10
+ exports.useKeycloak = _chunkE2X33LSDjs.useKeycloak;
@@ -0,0 +1,11 @@
1
+ import {
2
+ Keycloak,
3
+ useKeycloak
4
+ } from "../../chunk-NU2SJ3ST.mjs";
5
+ import "../../chunk-Y4XMF3R6.mjs";
6
+ import "../../chunk-64PPU7Q3.mjs";
7
+ import "../../chunk-S237YNYQ.mjs";
8
+ export {
9
+ Keycloak,
10
+ useKeycloak
11
+ };
@@ -0,0 +1,44 @@
1
+ import { AuthRequestPromptOptions, AuthSessionResult } from 'expo-auth-session';
2
+ import { IKeycloak } from './index.mjs';
3
+ import { KeycloakTokenParsed, KeycloakRoles, KeycloakResourceAccess } from '@bitspur/keycloak-js';
4
+
5
+ /**
6
+ * File: /src/hooks/useKeycloak/useKeycloak.native.ts
7
+ * Project: app
8
+ * File Created: 08-11-2022 14:10:25
9
+ * Author: Clay Risser
10
+ * -----
11
+ * Last Modified: 01-06-2023 14:04:46
12
+ * Modified By: Clay Risser
13
+ * -----
14
+ * Risser Labs LLC (c) Copyright 2021 - 2022
15
+ *
16
+ * Licensed under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" BASIS,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ */
28
+
29
+ declare function useKeycloak(): IKeycloak;
30
+ declare class ExpoKeycloak implements IKeycloak {
31
+ logout: () => Promise<unknown>;
32
+ token?: string | undefined;
33
+ refreshToken?: string | undefined;
34
+ authenticated?: boolean;
35
+ tokenParsed?: KeycloakTokenParsed;
36
+ refreshTokenParsed?: KeycloakTokenParsed;
37
+ subject?: string;
38
+ realmAccess?: KeycloakRoles;
39
+ resourceAccess?: KeycloakResourceAccess;
40
+ login: () => Promise<unknown>;
41
+ constructor(ready: boolean, isLoggedIn: boolean | undefined, login: (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult | undefined>, logout: () => Promise<unknown>, token?: string | undefined, refreshToken?: string | undefined);
42
+ }
43
+
44
+ export { ExpoKeycloak, useKeycloak };
@@ -0,0 +1,44 @@
1
+ import { AuthRequestPromptOptions, AuthSessionResult } from 'expo-auth-session';
2
+ import { IKeycloak } from './index.js';
3
+ import { KeycloakTokenParsed, KeycloakRoles, KeycloakResourceAccess } from '@bitspur/keycloak-js';
4
+
5
+ /**
6
+ * File: /src/hooks/useKeycloak/useKeycloak.native.ts
7
+ * Project: app
8
+ * File Created: 08-11-2022 14:10:25
9
+ * Author: Clay Risser
10
+ * -----
11
+ * Last Modified: 01-06-2023 14:04:46
12
+ * Modified By: Clay Risser
13
+ * -----
14
+ * Risser Labs LLC (c) Copyright 2021 - 2022
15
+ *
16
+ * Licensed under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" BASIS,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ */
28
+
29
+ declare function useKeycloak(): IKeycloak;
30
+ declare class ExpoKeycloak implements IKeycloak {
31
+ logout: () => Promise<unknown>;
32
+ token?: string | undefined;
33
+ refreshToken?: string | undefined;
34
+ authenticated?: boolean;
35
+ tokenParsed?: KeycloakTokenParsed;
36
+ refreshTokenParsed?: KeycloakTokenParsed;
37
+ subject?: string;
38
+ realmAccess?: KeycloakRoles;
39
+ resourceAccess?: KeycloakResourceAccess;
40
+ login: () => Promise<unknown>;
41
+ constructor(ready: boolean, isLoggedIn: boolean | undefined, login: (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult | undefined>, logout: () => Promise<unknown>, token?: string | undefined, refreshToken?: string | undefined);
42
+ }
43
+
44
+ export { ExpoKeycloak, useKeycloak };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ function _class_call_check(instance, Constructor) {
3
+ if (!(instance instanceof Constructor)) {
4
+ throw new TypeError("Cannot call a class as a function");
5
+ }
6
+ }
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
15
+ var _chunkKMAXXKJTjs = require("../../chunk-KMAXXKJT.js");
16
+ // src/hooks/useKeycloak/useKeycloak.native.ts
17
+ var _atob = require("core-js-pure/stable/atob");
18
+ var _atob2 = _interopRequireDefault(_atob);
19
+ var _escape = require("core-js-pure/stable/escape");
20
+ var _escape2 = _interopRequireDefault(_escape);
21
+ var _multiplatformone = require("multiplatform.one");
22
+ var _expokeycloakauth = require("expo-keycloak-auth");
23
+ function useKeycloak() {
24
+ if (_multiplatformone.MultiPlatform.isStorybook) return {
25
+ authenticated: true
26
+ };
27
+ var _expokeycloakauth_useKeycloak_call = _expokeycloakauth.useKeycloak.call(void 0), ready = _expokeycloakauth_useKeycloak_call.ready, login = _expokeycloakauth_useKeycloak_call.login, isLoggedIn = _expokeycloakauth_useKeycloak_call.isLoggedIn, token = _expokeycloakauth_useKeycloak_call.token, logout = _expokeycloakauth_useKeycloak_call.logout, refreshToken = _expokeycloakauth_useKeycloak_call.refreshToken;
28
+ var keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || void 0, refreshToken || void 0);
29
+ return keycloak;
30
+ }
31
+ var ExpoKeycloak = function ExpoKeycloak(ready, isLoggedIn, login, logout, token, refreshToken) {
32
+ _class_call_check(this, ExpoKeycloak);
33
+ this.logout = logout;
34
+ this.token = token;
35
+ this.refreshToken = refreshToken;
36
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "authenticated");
37
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "tokenParsed");
38
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "refreshTokenParsed");
39
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "subject");
40
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "realmAccess");
41
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "resourceAccess");
42
+ _chunkKMAXXKJTjs.__publicField.call(void 0, this, "login");
43
+ if (ready) this.authenticated = isLoggedIn;
44
+ if (this.authenticated) {
45
+ if (this.token) this.tokenParsed = decodeToken(this.token);
46
+ if (this.refreshToken) {
47
+ this.refreshTokenParsed = decodeToken(this.refreshToken);
48
+ }
49
+ if (this.tokenParsed) {
50
+ this.subject = this.tokenParsed.sub;
51
+ this.realmAccess = this.tokenParsed.realm_access;
52
+ this.resourceAccess = this.tokenParsed.resource_access;
53
+ }
54
+ }
55
+ this.login = function() {
56
+ return login();
57
+ };
58
+ };
59
+ function decodeToken(str) {
60
+ str = str.split(".")[1];
61
+ str = str.replace(/-/g, "+");
62
+ str = str.replace(/_/g, "/");
63
+ switch(str.length % 4){
64
+ case 0:
65
+ break;
66
+ case 2:
67
+ str += "==";
68
+ break;
69
+ case 3:
70
+ str += "=";
71
+ break;
72
+ default:
73
+ throw "Invalid token";
74
+ }
75
+ str = decodeURIComponent(_escape2.default.call(void 0, _atob2.default.call(void 0, str)));
76
+ str = JSON.parse(str);
77
+ return str;
78
+ }
79
+ exports.ExpoKeycloak = ExpoKeycloak;
80
+ exports.useKeycloak = useKeycloak;
@@ -0,0 +1,69 @@
1
+ import {
2
+ __publicField
3
+ } from "../../chunk-S237YNYQ.mjs";
4
+
5
+ // src/hooks/useKeycloak/useKeycloak.native.ts
6
+ import atob from "core-js-pure/stable/atob";
7
+ import escape from "core-js-pure/stable/escape";
8
+ import { MultiPlatform } from "multiplatform.one";
9
+ import { useKeycloak as useExpoKeycloak } from "expo-keycloak-auth";
10
+ function useKeycloak() {
11
+ if (MultiPlatform.isStorybook)
12
+ return { authenticated: true };
13
+ const { ready, login, isLoggedIn, token, logout, refreshToken } = useExpoKeycloak();
14
+ const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || void 0, refreshToken || void 0);
15
+ return keycloak;
16
+ }
17
+ var ExpoKeycloak = class {
18
+ constructor(ready, isLoggedIn, login, logout, token, refreshToken) {
19
+ this.logout = logout;
20
+ this.token = token;
21
+ this.refreshToken = refreshToken;
22
+ __publicField(this, "authenticated");
23
+ __publicField(this, "tokenParsed");
24
+ __publicField(this, "refreshTokenParsed");
25
+ __publicField(this, "subject");
26
+ __publicField(this, "realmAccess");
27
+ __publicField(this, "resourceAccess");
28
+ __publicField(this, "login");
29
+ if (ready)
30
+ this.authenticated = isLoggedIn;
31
+ if (this.authenticated) {
32
+ if (this.token)
33
+ this.tokenParsed = decodeToken(this.token);
34
+ if (this.refreshToken) {
35
+ this.refreshTokenParsed = decodeToken(this.refreshToken);
36
+ }
37
+ if (this.tokenParsed) {
38
+ this.subject = this.tokenParsed.sub;
39
+ this.realmAccess = this.tokenParsed.realm_access;
40
+ this.resourceAccess = this.tokenParsed.resource_access;
41
+ }
42
+ }
43
+ this.login = () => login();
44
+ }
45
+ };
46
+ function decodeToken(str) {
47
+ str = str.split(".")[1];
48
+ str = str.replace(/-/g, "+");
49
+ str = str.replace(/_/g, "/");
50
+ switch (str.length % 4) {
51
+ case 0:
52
+ break;
53
+ case 2:
54
+ str += "==";
55
+ break;
56
+ case 3:
57
+ str += "=";
58
+ break;
59
+ default:
60
+ throw "Invalid token";
61
+ }
62
+ str = decodeURIComponent(escape(atob(str)));
63
+ str = JSON.parse(str);
64
+ return str;
65
+ }
66
+ export {
67
+ ExpoKeycloak,
68
+ useKeycloak
69
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File: /src/hooks/useLogin.ts
3
+ * Project: app
4
+ * File Created: 08-11-2022 08:49:14
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 25-04-2023 23:09:10
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2021 - 2022
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ declare function useLogin(loginRoute?: string): () => void;
25
+
26
+ export { useLogin };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File: /src/hooks/useLogin.ts
3
+ * Project: app
4
+ * File Created: 08-11-2022 08:49:14
5
+ * Author: Clay Risser
6
+ * -----
7
+ * Last Modified: 25-04-2023 23:09:10
8
+ * Modified By: Clay Risser
9
+ * -----
10
+ * Risser Labs LLC (c) Copyright 2021 - 2022
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ declare function useLogin(loginRoute?: string): () => void;
25
+
26
+ export { useLogin };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _chunkHDNHCVXTjs = require("../chunk-HDNHCVXT.js");
6
+ require("../chunk-OYWAYMFN.js");
7
+ require("../chunk-E2X33LSD.js");
8
+ require("../chunk-3ZPHNEJL.js");
9
+ require("../chunk-A7UBOIAL.js");
10
+ require("../chunk-KMAXXKJT.js");
11
+ exports.useLogin = _chunkHDNHCVXTjs.useLogin;