@multiplatform.one/keycloak 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/hooks/useKeycloak/index.js +1 -1
- package/esm/hooks/useKeycloak/index.js.map +1 -1
- package/esm/hooks/useKeycloak/useKeycloak.native.js +2 -2
- package/esm/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
- package/esm/provider/keycloakProvider.native.js +1 -1
- package/esm/provider/keycloakProvider.native.js.map +1 -1
- package/lib/hooks/useKeycloak/index.d.ts +1 -1
- package/lib/hooks/useKeycloak/index.js.map +1 -1
- package/lib/hooks/useKeycloak/useKeycloak.native.d.ts +1 -1
- package/lib/hooks/useKeycloak/useKeycloak.native.js +6 -6
- package/lib/hooks/useKeycloak/useKeycloak.native.js.map +1 -1
- package/lib/provider/keycloakProvider.native.js +5 -5
- package/lib/provider/keycloakProvider.native.js.map +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/src/{expo/index.ts → @types/expoKeycloakAuth.d.ts} +7 -6
- package/src/hooks/useKeycloak/index.ts +1 -1
- package/src/hooks/useKeycloak/useKeycloak.native.ts +2 -2
- package/src/provider/keycloakProvider.native.tsx +1 -1
- package/esm/expo/ExpoKeycloakContext.js +0 -28
- package/esm/expo/ExpoKeycloakContext.js.map +0 -1
- package/esm/expo/ExpoKeycloakProvider.js +0 -113
- package/esm/expo/ExpoKeycloakProvider.js.map +0 -1
- package/esm/expo/const.js +0 -42
- package/esm/expo/const.js.map +0 -1
- package/esm/expo/helpers.js +0 -56
- package/esm/expo/helpers.js.map +0 -1
- package/esm/expo/index.js +0 -28
- package/esm/expo/index.js.map +0 -1
- package/esm/expo/useExpoKeycloak.js +0 -44
- package/esm/expo/useExpoKeycloak.js.map +0 -1
- package/esm/expo/useTokenStorage.js +0 -153
- package/esm/expo/useTokenStorage.js.map +0 -1
- package/lib/expo/ExpoKeycloakContext.d.ts +0 -32
- package/lib/expo/ExpoKeycloakContext.js +0 -47
- package/lib/expo/ExpoKeycloakContext.js.map +0 -1
- package/lib/expo/ExpoKeycloakProvider.d.ts +0 -37
- package/lib/expo/ExpoKeycloakProvider.js +0 -130
- package/lib/expo/ExpoKeycloakProvider.js.map +0 -1
- package/lib/expo/const.d.ts +0 -33
- package/lib/expo/const.js +0 -66
- package/lib/expo/const.js.map +0 -1
- package/lib/expo/helpers.d.ts +0 -41
- package/lib/expo/helpers.js +0 -77
- package/lib/expo/helpers.js.map +0 -1
- package/lib/expo/index.d.ts +0 -26
- package/lib/expo/index.js +0 -50
- package/lib/expo/index.js.map +0 -1
- package/lib/expo/useExpoKeycloak.d.ts +0 -31
- package/lib/expo/useExpoKeycloak.js +0 -62
- package/lib/expo/useExpoKeycloak.js.map +0 -1
- package/lib/expo/useTokenStorage.d.ts +0 -36
- package/lib/expo/useTokenStorage.js +0 -166
- package/lib/expo/useTokenStorage.js.map +0 -1
- package/src/expo/ExpoKeycloakContext.ts +0 -41
- package/src/expo/ExpoKeycloakProvider.tsx +0 -139
- package/src/expo/NOTES +0 -1
- package/src/expo/const.ts +0 -42
- package/src/expo/helpers.ts +0 -74
- package/src/expo/useExpoKeycloak.ts +0 -44
- package/src/expo/useTokenStorage.ts +0 -168
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified:
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 28-11-2022 14:56:28\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n KeycloakResourceAccess,\n KeycloakRoles,\n KeycloakTokenParsed,\n} from \"keycloak-js\";\nexport * from \"./useKeycloak\";\n\nexport interface IKeycloak {\n authenticated?: boolean;\n realmAccess?: KeycloakRoles;\n refreshToken?: string;\n refreshTokenParsed?: KeycloakTokenParsed;\n resourceAccess?: KeycloakResourceAccess;\n subject?: string;\n token?: string;\n tokenParsed?: KeycloakTokenParsed;\n login: () => Promise<unknown> | unknown;\n logout: () => Promise<unknown> | unknown;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AAA8B"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* File Created: 08-11-2022 14:10:25
|
|
5
5
|
* Author: Clay Risser
|
|
6
6
|
* -----
|
|
7
|
-
* Last Modified: 28-11-2022
|
|
7
|
+
* Last Modified: 28-11-2022 14:56:48
|
|
8
8
|
* Modified By: Clay Risser
|
|
9
9
|
* -----
|
|
10
10
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import atob from "core-js-pure/stable/atob";
|
|
26
26
|
import escape from "core-js-pure/stable/escape";
|
|
27
27
|
import { MultiPlatform } from "multiplatform.one";
|
|
28
|
-
import { useExpoKeycloak } from "
|
|
28
|
+
import { useKeycloak as useExpoKeycloak } from "expo-keycloak-auth";
|
|
29
29
|
export function useKeycloak() {
|
|
30
30
|
if (MultiPlatform.isStorybook()) return {
|
|
31
31
|
authenticated: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeycloak.native.js","names":["atob","escape","MultiPlatform","
|
|
1
|
+
{"version":3,"file":"useKeycloak.native.js","names":["atob","escape","MultiPlatform","useKeycloak","useExpoKeycloak","isStorybook","authenticated","ready","login","isLoggedIn","token","logout","refreshToken","keycloak","ExpoKeycloak","undefined","constructor","tokenParsed","refreshTokenParsed","subject","realmAccess","resourceAccess","decodeToken","sub","realm_access","resource_access","str","split","replace","length","decodeURIComponent","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-11-2022 14:56:48\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":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,0BAA0B;AAC3C,OAAOC,MAAM,MAAM,4BAA4B;AAE/C,SAASC,aAAa,QAAQ,mBAAmB;AAMjD,SAASC,WAAW,IAAIC,eAAe,QAAQ,oBAAoB;AAGnE,OAAO,SAASD,WAAW,GAAG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Ac,GAAG,IAAI,CAACJ,WAAW,CAACQ,eAAe;MACxD;IACF;IACA,IAAI,CAACjB,KAAK,GAAG,MAAMA,KAAK,EAAE;EAC5B;AACF;AAEA,SAASc,WAAW,CAACI,GAAW,EAAE;EAChCA,GAAG,GAAGA,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EACvBD,GAAG,GAAGA,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EAC5BF,GAAG,GAAGA,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EAC5B,QAAQF,GAAG,CAACG,MAAM,GAAG,CAAC;IACpB,KAAK,CAAC;MACJ;IACF,KAAK,CAAC;MACJH,GAAG,IAAI,IAAI;MACX;IACF,KAAK,CAAC;MACJA,GAAG,IAAI,GAAG;MACV;IACF;MACE,MAAM,eAAe;EAAC;EAE1BA,GAAG,GAAGI,kBAAkB,CAAC7B,MAAM,CAACD,IAAI,CAAC0B,GAAG,CAAC,CAAC,CAAC;EAC3CA,GAAG,GAAGK,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC;EACrB,OAAOA,GAAG;AACZ"}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from "react";
|
|
26
26
|
import { AfterAuth } from "./afterAuth";
|
|
27
|
-
import { ExpoKeycloakProvider } from "
|
|
27
|
+
import { KeycloakProvider as ExpoKeycloakProvider } from "expo-keycloak-auth";
|
|
28
28
|
export const KeycloakProvider = _ref => {
|
|
29
29
|
let {
|
|
30
30
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keycloakProvider.native.js","names":["React","AfterAuth","
|
|
1
|
+
{"version":3,"file":"keycloakProvider.native.js","names":["React","AfterAuth","KeycloakProvider","ExpoKeycloakProvider","children","keycloakConfig","clonedKeycloakConfig","url","baseUrl"],"sources":["../../src/provider/keycloakProvider.native.tsx"],"sourcesContent":["/**\n * File: /auth/provider/keycloakProvider.native.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:37\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 17:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { FC } from \"react\";\nimport type { KeycloakProviderProps } from \"./keycloakProvider\";\nimport { AfterAuth } from \"./afterAuth\";\nimport { KeycloakProvider as ExpoKeycloakProvider } from \"expo-keycloak-auth\";\nimport { KeycloakConfig } from \"keycloak-js\";\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({\n children,\n keycloakConfig,\n}: KeycloakProviderProps) => {\n const clonedKeycloakConfig = {\n ...(keycloakConfig as Omit<KeycloakConfig, \"baseUrl\">),\n url: keycloakConfig.baseUrl,\n };\n // @ts-ignore\n delete keycloakConfig.baseUrl;\n return (\n <ExpoKeycloakProvider {...clonedKeycloakConfig}>\n <AfterAuth>{children}</AfterAuth>\n </ExpoKeycloakProvider>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAc,OAAO;AAEjC,SAASC,SAAS;AAClB,SAASC,gBAAgB,IAAIC,oBAAoB,QAAQ,oBAAoB;AAG7E,OAAO,MAAMD,gBAA2C,GAAG,QAG9B;EAAA,IAH+B;IAC1DE,QAAQ;IACRC;EACqB,CAAC;EACtB,MAAMC,oBAAoB,GAAG;IAC3B,GAAID,cAAkD;IACtDE,GAAG,EAAEF,cAAc,CAACG;EACtB,CAAC;EACD;EACA,OAAOH,cAAc,CAACG,OAAO;EAC7B,oBACE,oBAAC,oBAAoB,EAAKF,oBAAoB,eAC5C,oBAAC,SAAS,QAAEF,QAAQ,CAAa,CACZ;AAE3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified:
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useKeycloak/index.ts"],"sourcesContent":["/**\n * File: /src/hooks/useKeycloak/index.ts\n * Project: app\n * File Created: 08-11-2022 14:10:44\n * Author: Clay Risser\n * -----\n * Last Modified: 28-11-2022 14:56:28\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n KeycloakResourceAccess,\n KeycloakRoles,\n KeycloakTokenParsed,\n} from \"keycloak-js\";\nexport * from \"./useKeycloak\";\n\nexport interface IKeycloak {\n authenticated?: boolean;\n realmAccess?: KeycloakRoles;\n refreshToken?: string;\n refreshTokenParsed?: KeycloakTokenParsed;\n resourceAccess?: KeycloakResourceAccess;\n subject?: string;\n token?: string;\n tokenParsed?: KeycloakTokenParsed;\n login: () => Promise<unknown> | unknown;\n logout: () => Promise<unknown> | unknown;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;EA6BA;IAAA;IAAA;IAAA;MAAA;MAAA;QAAA;MAAA;IAAA;EAAA;AAA8B"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "core-js-pure/stable/atob", "core-js-pure/stable/escape", "multiplatform.one", "
|
|
3
|
+
define(["exports", "core-js-pure/stable/atob", "core-js-pure/stable/escape", "multiplatform.one", "expo-keycloak-auth"], factory);
|
|
4
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("
|
|
5
|
+
factory(exports, require("core-js-pure/stable/atob"), require("core-js-pure/stable/escape"), require("multiplatform.one"), require("expo-keycloak-auth"));
|
|
6
6
|
} else {
|
|
7
7
|
var mod = {
|
|
8
8
|
exports: {}
|
|
9
9
|
};
|
|
10
|
-
factory(mod.exports, global.atob, global.escape, global.multiplatform, global.
|
|
10
|
+
factory(mod.exports, global.atob, global.escape, global.multiplatform, global.expoKeycloakAuth);
|
|
11
11
|
global.useKeycloakNative = mod.exports;
|
|
12
12
|
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _atob, _escape, _multiplatform,
|
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _atob, _escape, _multiplatform, _expoKeycloakAuth) {
|
|
14
14
|
"use strict";
|
|
15
15
|
|
|
16
16
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* File Created: 08-11-2022 14:10:25
|
|
28
28
|
* Author: Clay Risser
|
|
29
29
|
* -----
|
|
30
|
-
* Last Modified: 28-11-2022
|
|
30
|
+
* Last Modified: 28-11-2022 14:56:48
|
|
31
31
|
* Modified By: Clay Risser
|
|
32
32
|
* -----
|
|
33
33
|
* Risser Labs LLC (c) Copyright 2021 - 2022
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
token,
|
|
57
57
|
logout,
|
|
58
58
|
refreshToken
|
|
59
|
-
} = (0,
|
|
59
|
+
} = (0, _expoKeycloakAuth.useKeycloak)();
|
|
60
60
|
const keycloak = new ExpoKeycloak(ready, isLoggedIn, login, logout, token || undefined, refreshToken || undefined);
|
|
61
61
|
return keycloak;
|
|
62
62
|
}
|
|
@@ -1 +1 @@
|
|
|
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-11-2022
|
|
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-11-2022 14:56:48\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,EAAE,OAAO;MAAEC,aAAa,EAAE;IAAK,CAAC;IAC/D,MAAM;MAAEC,KAAK;MAAEC,KAAK;MAAEC,UAAU;MAAEC,KAAK;MAAEC,MAAM;MAAEC;IAAa,CAAC,GAC7D,IAAAC,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,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|
1
1
|
(function (global, factory) {
|
|
2
2
|
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "react", "./afterAuth", "
|
|
3
|
+
define(["exports", "react", "./afterAuth", "expo-keycloak-auth"], factory);
|
|
4
4
|
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("react"), require("./afterAuth"), require("
|
|
5
|
+
factory(exports, require("react"), require("./afterAuth"), require("expo-keycloak-auth"));
|
|
6
6
|
} else {
|
|
7
7
|
var mod = {
|
|
8
8
|
exports: {}
|
|
9
9
|
};
|
|
10
|
-
factory(mod.exports, global.react, global.afterAuth, global.
|
|
10
|
+
factory(mod.exports, global.react, global.afterAuth, global.expoKeycloakAuth);
|
|
11
11
|
global.keycloakProviderNative = mod.exports;
|
|
12
12
|
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _afterAuth,
|
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _afterAuth, _expoKeycloakAuth) {
|
|
14
14
|
"use strict";
|
|
15
15
|
|
|
16
16
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
};
|
|
55
55
|
// @ts-ignore
|
|
56
56
|
delete keycloakConfig.baseUrl;
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_expoKeycloakAuth.KeycloakProvider, clonedKeycloakConfig, /*#__PURE__*/_react.default.createElement(_afterAuth.AfterAuth, null, children));
|
|
58
58
|
};
|
|
59
59
|
_exports.KeycloakProvider = KeycloakProvider;
|
|
60
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keycloakProvider.native.js","names":["KeycloakProvider","children","keycloakConfig","clonedKeycloakConfig","url","baseUrl"],"sources":["../../src/provider/keycloakProvider.native.tsx"],"sourcesContent":["/**\n * File: /auth/provider/keycloakProvider.native.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:37\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 17:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { FC } from \"react\";\nimport type { KeycloakProviderProps } from \"./keycloakProvider\";\nimport { AfterAuth } from \"./afterAuth\";\nimport { ExpoKeycloakProvider } from \"
|
|
1
|
+
{"version":3,"file":"keycloakProvider.native.js","names":["KeycloakProvider","children","keycloakConfig","clonedKeycloakConfig","url","baseUrl"],"sources":["../../src/provider/keycloakProvider.native.tsx"],"sourcesContent":["/**\n * File: /auth/provider/keycloakProvider.native.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:37\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 17:52:31\n * Modified By: Clay Risser\n * -----\n * Risser Labs LLC (c) Copyright 2021 - 2022\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { FC } from \"react\";\nimport type { KeycloakProviderProps } from \"./keycloakProvider\";\nimport { AfterAuth } from \"./afterAuth\";\nimport { KeycloakProvider as ExpoKeycloakProvider } from \"expo-keycloak-auth\";\nimport { KeycloakConfig } from \"keycloak-js\";\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({\n children,\n keycloakConfig,\n}: KeycloakProviderProps) => {\n const clonedKeycloakConfig = {\n ...(keycloakConfig as Omit<KeycloakConfig, \"baseUrl\">),\n url: keycloakConfig.baseUrl,\n };\n // @ts-ignore\n delete keycloakConfig.baseUrl;\n return (\n <ExpoKeycloakProvider {...clonedKeycloakConfig}>\n <AfterAuth>{children}</AfterAuth>\n </ExpoKeycloakProvider>\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,MAAMA,gBAA2C,GAAG,QAG9B;IAAA,IAH+B;MAC1DC,QAAQ;MACRC;IACqB,CAAC;IACtB,MAAMC,oBAAoB,GAAG;MAC3B,GAAID,cAAkD;MACtDE,GAAG,EAAEF,cAAc,CAACG;IACtB,CAAC;IACD;IACA,OAAOH,cAAc,CAACG,OAAO;IAC7B,oBACE,6BAAC,kCAAoB,EAAKF,oBAAoB,eAC5C,6BAAC,oBAAS,QAAEF,QAAQ,CAAa,CACZ;EAE3B,CAAC;EAAC;AAAA"}
|