@multiplatform.one/keycloak 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/@types/coreJsPure.d.d.ts +2 -0
- package/lib/@types/coreJsPure.d.js +1 -0
- package/lib/@types/coreJsPure.d.mjs +0 -0
- package/lib/@types/expoKeycloakAuth.d.d.ts +28 -0
- package/lib/@types/expoKeycloakAuth.d.js +1 -0
- package/lib/@types/expoKeycloakAuth.d.mjs +0 -0
- package/lib/Authenticated.d.ts +36 -0
- package/lib/Authenticated.js +19 -0
- package/lib/Authenticated.mjs +20 -0
- package/lib/authConfig.d.ts +37 -0
- package/lib/authConfig.js +8 -0
- package/lib/authConfig.mjs +9 -0
- package/lib/chunk-2GUOEPFY.mjs +0 -0
- package/lib/chunk-3ZPHNEJL.js +11 -0
- package/lib/chunk-64PPU7Q3.mjs +13 -0
- package/lib/chunk-6NDWOV55.js +1 -0
- package/lib/chunk-6QZDLO3M.mjs +41 -0
- package/lib/chunk-73FF4BX7.js +78 -0
- package/lib/chunk-7MTPH6XK.mjs +26 -0
- package/lib/chunk-A7UBOIAL.js +13 -0
- package/lib/chunk-AD6VPMID.mjs +20 -0
- package/lib/chunk-AYKQVWMR.mjs +0 -0
- package/lib/chunk-BTHRDOLL.mjs +84 -0
- package/lib/chunk-C2FNSVJO.js +17 -0
- package/lib/chunk-CLO6HIJN.mjs +52 -0
- package/lib/chunk-DJW5IKQS.mjs +265 -0
- package/lib/chunk-JLIMB5OD.js +56 -0
- package/lib/chunk-JYEIPNPN.mjs +76 -0
- package/lib/chunk-K2MQYDVB.mjs +50 -0
- package/lib/chunk-KLLABHIC.js +13 -0
- package/lib/chunk-L5HMOY4M.mjs +18 -0
- package/lib/chunk-NHABU752.mjs +10 -0
- package/lib/chunk-NRD376XV.js +33 -0
- package/lib/chunk-NWRANDZ6.js +98 -0
- package/lib/chunk-NXTVYIBR.mjs +11 -0
- package/lib/chunk-OYWAYMFN.js +17 -0
- package/lib/chunk-QFP2JWHZ.js +443 -0
- package/lib/chunk-RTZ3CZKS.js +161 -0
- package/lib/chunk-S3M2DZ6G.js +460 -0
- package/lib/chunk-UBVYEZI3.js +1 -0
- package/lib/chunk-UOKDJT5L.mjs +16 -0
- package/lib/chunk-XXPGZHWZ.js +22 -0
- package/lib/chunk-Y4XMF3R6.mjs +13 -0
- package/lib/chunk-YGNNHTFE.js +12 -0
- package/lib/hooks/index.d.ts +9 -0
- package/lib/hooks/index.js +23 -0
- package/lib/hooks/index.mjs +34 -0
- package/lib/hooks/useAuthConfig.d.ts +29 -0
- package/lib/hooks/useAuthConfig.js +8 -0
- package/lib/hooks/useAuthConfig.mjs +8 -0
- package/lib/hooks/useCurrentRouteName/index.d.ts +26 -0
- package/lib/hooks/useCurrentRouteName/index.js +7 -0
- package/lib/hooks/useCurrentRouteName/index.mjs +7 -0
- package/lib/hooks/useCurrentRouteName/index.native.d.ts +26 -0
- package/lib/hooks/useCurrentRouteName/index.native.js +14 -0
- package/lib/hooks/useCurrentRouteName/index.native.mjs +14 -0
- package/lib/hooks/useKeycloak/index.d.ts +70 -0
- package/lib/hooks/useKeycloak/index.js +11 -0
- package/lib/hooks/useKeycloak/index.mjs +12 -0
- package/lib/hooks/useKeycloak/useKeycloak.d.ts +2 -0
- package/lib/hooks/useKeycloak/useKeycloak.js +10 -0
- package/lib/hooks/useKeycloak/useKeycloak.mjs +11 -0
- package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +44 -0
- package/lib/hooks/useKeycloak/useKeycloak.native.js +80 -0
- package/lib/hooks/useKeycloak/useKeycloak.native.mjs +69 -0
- package/lib/hooks/useLogin.d.ts +26 -0
- package/lib/hooks/useLogin.js +11 -0
- package/lib/hooks/useLogin.mjs +11 -0
- package/lib/hooks/useTokensFromQuery/index.d.ts +26 -0
- package/lib/hooks/useTokensFromQuery/index.js +7 -0
- package/lib/hooks/useTokensFromQuery/index.mjs +7 -0
- package/lib/hooks/useTokensFromQuery/index.native.d.ts +26 -0
- package/lib/hooks/useTokensFromQuery/index.native.js +10 -0
- package/lib/hooks/useTokensFromQuery/index.native.mjs +7 -0
- package/lib/hooks/useTokensFromState.d.ts +26 -0
- package/lib/hooks/useTokensFromState.js +9 -0
- package/lib/hooks/useTokensFromState.mjs +9 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.mjs +56 -0
- package/lib/provider/afterAuth.d.ts +32 -0
- package/lib/provider/afterAuth.js +18 -0
- package/lib/provider/afterAuth.mjs +18 -0
- package/lib/provider/index.d.ts +42 -0
- package/lib/provider/index.js +22 -0
- package/lib/provider/index.mjs +25 -0
- package/lib/provider/keycloakProvider.d.ts +45 -0
- package/lib/provider/keycloakProvider.js +20 -0
- package/lib/provider/keycloakProvider.mjs +21 -0
- package/lib/provider/keycloakProvider.native.d.ts +32 -0
- package/lib/provider/keycloakProvider.native.js +87 -0
- package/lib/provider/keycloakProvider.native.mjs +30 -0
- package/lib/state/index.d.ts +34 -0
- package/lib/state/index.js +7 -0
- package/lib/state/index.mjs +7 -0
- package/lib/types.d.ts +40 -0
- package/lib/types.js +8 -0
- package/lib/types.mjs +7 -0
- package/lib/util.d.ts +27 -0
- package/lib/util.js +8 -0
- package/lib/util.mjs +9 -0
- package/package.json +6 -6
|
@@ -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-XXPGZHWZ.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-NHABU752.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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
require("../../chunk-6NDWOV55.js");
|
|
6
|
+
var _chunkS3M2DZ6Gjs = require("../../chunk-S3M2DZ6G.js");
|
|
7
|
+
require("../../chunk-3ZPHNEJL.js");
|
|
8
|
+
require("../../chunk-A7UBOIAL.js");
|
|
9
|
+
require("../../chunk-XXPGZHWZ.js");
|
|
10
|
+
exports.Keycloak = _chunkS3M2DZ6Gjs.Keycloak;
|
|
11
|
+
exports.useKeycloak = _chunkS3M2DZ6Gjs.useKeycloak;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "../../chunk-2GUOEPFY.mjs";
|
|
2
|
+
import {
|
|
3
|
+
Keycloak,
|
|
4
|
+
useKeycloak
|
|
5
|
+
} from "../../chunk-BTHRDOLL.mjs";
|
|
6
|
+
import "../../chunk-Y4XMF3R6.mjs";
|
|
7
|
+
import "../../chunk-64PPU7Q3.mjs";
|
|
8
|
+
import "../../chunk-NHABU752.mjs";
|
|
9
|
+
export {
|
|
10
|
+
Keycloak,
|
|
11
|
+
useKeycloak
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _chunkS3M2DZ6Gjs = require("../../chunk-S3M2DZ6G.js");
|
|
6
|
+
require("../../chunk-3ZPHNEJL.js");
|
|
7
|
+
require("../../chunk-A7UBOIAL.js");
|
|
8
|
+
require("../../chunk-XXPGZHWZ.js");
|
|
9
|
+
exports.Keycloak = _chunkS3M2DZ6Gjs.Keycloak;
|
|
10
|
+
exports.useKeycloak = _chunkS3M2DZ6Gjs.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 _chunkXXPGZHWZjs = require("../../chunk-XXPGZHWZ.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
|
+
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "authenticated");
|
|
37
|
+
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "tokenParsed");
|
|
38
|
+
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "refreshTokenParsed");
|
|
39
|
+
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "subject");
|
|
40
|
+
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "realmAccess");
|
|
41
|
+
_chunkXXPGZHWZjs.__publicField.call(void 0, this, "resourceAccess");
|
|
42
|
+
_chunkXXPGZHWZjs.__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-NHABU752.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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _chunkNRD376XVjs = require("../chunk-NRD376XV.js");
|
|
6
|
+
require("../chunk-OYWAYMFN.js");
|
|
7
|
+
require("../chunk-S3M2DZ6G.js");
|
|
8
|
+
require("../chunk-3ZPHNEJL.js");
|
|
9
|
+
require("../chunk-A7UBOIAL.js");
|
|
10
|
+
require("../chunk-XXPGZHWZ.js");
|
|
11
|
+
exports.useLogin = _chunkNRD376XVjs.useLogin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/hooks/useTokensFromQuery/index.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 15-05-2023 01:54:44
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 16-05-2023 07:40:41
|
|
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 useTokensFromQuery(): boolean;
|
|
25
|
+
|
|
26
|
+
export { useTokensFromQuery };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/hooks/useTokensFromQuery/index.native.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 15-05-2023 01:54:48
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 16-05-2023 07:40:46
|
|
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 const useTokensFromQuery: () => boolean;
|
|
25
|
+
|
|
26
|
+
export { useTokensFromQuery };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
require("../../chunk-XXPGZHWZ.js");
|
|
6
|
+
// src/hooks/useTokensFromQuery/index.native.ts
|
|
7
|
+
var useTokensFromQuery = function() {
|
|
8
|
+
return false;
|
|
9
|
+
};
|
|
10
|
+
exports.useTokensFromQuery = useTokensFromQuery;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: /src/hooks/useTokensFromState.ts
|
|
3
|
+
* Project: @multiplatform.one/keycloak
|
|
4
|
+
* File Created: 16-05-2023 06:29:02
|
|
5
|
+
* Author: Clay Risser
|
|
6
|
+
* -----
|
|
7
|
+
* Last Modified: 16-05-2023 07:40:36
|
|
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 useTokensFromState(): boolean;
|
|
25
|
+
|
|
26
|
+
export { useTokensFromState };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _chunkYGNNHTFEjs = require("../chunk-YGNNHTFE.js");
|
|
6
|
+
require("../chunk-C2FNSVJO.js");
|
|
7
|
+
require("../chunk-NWRANDZ6.js");
|
|
8
|
+
require("../chunk-XXPGZHWZ.js");
|
|
9
|
+
exports.useTokensFromState = _chunkYGNNHTFEjs.useTokensFromState;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Authenticated, AuthenticatedProps, withAuthenticated } from './Authenticated.js';
|
|
2
|
+
export { AuthConfig, AuthConfigContext, defaultAuthConfig } from './authConfig.js';
|
|
3
|
+
export { useAuthConfig } from './hooks/useAuthConfig.js';
|
|
4
|
+
export { useCurrentRouteName } from './hooks/useCurrentRouteName/index.js';
|
|
5
|
+
export { IKeycloak, ITokenParsed, Keycloak, useKeycloak } from './hooks/useKeycloak/index.js';
|
|
6
|
+
export { useLogin } from './hooks/useLogin.js';
|
|
7
|
+
export { useTokensFromQuery } from './hooks/useTokensFromQuery/index.js';
|
|
8
|
+
export { useTokensFromState } from './hooks/useTokensFromState.js';
|
|
9
|
+
export { AuthProvider, AuthProviderProps } from './provider/index.js';
|
|
10
|
+
export { KeycloakProvider, KeycloakProviderProps, MessageSchema, defaultKeycloakInitOptions } from './provider/keycloakProvider.js';
|
|
11
|
+
import 'react';
|
|
12
|
+
import '@bitspur/keycloak-js';
|
|
13
|
+
import '@bitspur/react-keycloak-core';
|
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthProvider
|
|
3
|
+
} from "./chunk-JYEIPNPN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
KeycloakProvider,
|
|
6
|
+
defaultKeycloakInitOptions
|
|
7
|
+
} from "./chunk-DJW5IKQS.mjs";
|
|
8
|
+
import "./chunk-K2MQYDVB.mjs";
|
|
9
|
+
import {
|
|
10
|
+
Authenticated,
|
|
11
|
+
withAuthenticated
|
|
12
|
+
} from "./chunk-CLO6HIJN.mjs";
|
|
13
|
+
import "./chunk-AYKQVWMR.mjs";
|
|
14
|
+
import "./chunk-2GUOEPFY.mjs";
|
|
15
|
+
import {
|
|
16
|
+
useTokensFromQuery
|
|
17
|
+
} from "./chunk-NXTVYIBR.mjs";
|
|
18
|
+
import {
|
|
19
|
+
useLogin
|
|
20
|
+
} from "./chunk-6QZDLO3M.mjs";
|
|
21
|
+
import {
|
|
22
|
+
useCurrentRouteName
|
|
23
|
+
} from "./chunk-L5HMOY4M.mjs";
|
|
24
|
+
import {
|
|
25
|
+
Keycloak,
|
|
26
|
+
useKeycloak
|
|
27
|
+
} from "./chunk-BTHRDOLL.mjs";
|
|
28
|
+
import {
|
|
29
|
+
useAuthConfig
|
|
30
|
+
} from "./chunk-Y4XMF3R6.mjs";
|
|
31
|
+
import {
|
|
32
|
+
useTokensFromState
|
|
33
|
+
} from "./chunk-UOKDJT5L.mjs";
|
|
34
|
+
import "./chunk-AD6VPMID.mjs";
|
|
35
|
+
import {
|
|
36
|
+
AuthConfigContext,
|
|
37
|
+
defaultAuthConfig
|
|
38
|
+
} from "./chunk-64PPU7Q3.mjs";
|
|
39
|
+
import "./chunk-7MTPH6XK.mjs";
|
|
40
|
+
import "./chunk-NHABU752.mjs";
|
|
41
|
+
export {
|
|
42
|
+
AuthConfigContext,
|
|
43
|
+
AuthProvider,
|
|
44
|
+
Authenticated,
|
|
45
|
+
Keycloak,
|
|
46
|
+
KeycloakProvider,
|
|
47
|
+
defaultAuthConfig,
|
|
48
|
+
defaultKeycloakInitOptions,
|
|
49
|
+
useAuthConfig,
|
|
50
|
+
useCurrentRouteName,
|
|
51
|
+
useKeycloak,
|
|
52
|
+
useLogin,
|
|
53
|
+
useTokensFromQuery,
|
|
54
|
+
useTokensFromState,
|
|
55
|
+
withAuthenticated
|
|
56
|
+
};
|