@multiplatform.one/keycloak 0.3.33 → 0.7.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/lib/index.js +34 -0
- package/package.json +32 -48
- package/src/@types/coreJsPure.d.ts +8 -8
- package/dist/esm/Authenticated.mjs +0 -40
- package/dist/esm/Authenticated.mjs.map +0 -7
- package/dist/esm/authConfig.mjs +0 -12
- package/dist/esm/authConfig.mjs.map +0 -7
- package/dist/esm/hooks/index.mjs +0 -7
- package/dist/esm/hooks/index.mjs.map +0 -7
- package/dist/esm/hooks/useAuthConfig.mjs +0 -9
- package/dist/esm/hooks/useAuthConfig.mjs.map +0 -7
- package/dist/esm/hooks/useCurrentRouteName/index.mjs +0 -17
- package/dist/esm/hooks/useCurrentRouteName/index.mjs.map +0 -7
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs +0 -12
- package/dist/esm/hooks/useCurrentRouteName/index.native.mjs.map +0 -7
- package/dist/esm/hooks/useKeycloak/index.mjs +0 -2
- package/dist/esm/hooks/useKeycloak/index.mjs.map +0 -7
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs +0 -527
- package/dist/esm/hooks/useKeycloak/useKeycloak.mjs.map +0 -7
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs +0 -108
- package/dist/esm/hooks/useKeycloak/useKeycloak.native.mjs.map +0 -7
- package/dist/esm/hooks/useLogin.mjs +0 -35
- package/dist/esm/hooks/useLogin.mjs.map +0 -7
- package/dist/esm/hooks/useTokensFromQuery/index.mjs +0 -12
- package/dist/esm/hooks/useTokensFromQuery/index.mjs.map +0 -7
- package/dist/esm/hooks/useTokensFromQuery/index.native.mjs +0 -7
- package/dist/esm/hooks/useTokensFromQuery/index.native.mjs.map +0 -7
- package/dist/esm/hooks/useTokensFromState.mjs +0 -10
- package/dist/esm/hooks/useTokensFromState.mjs.map +0 -7
- package/dist/esm/index.mjs +0 -5
- package/dist/esm/index.mjs.map +0 -7
- package/dist/esm/provider/afterAuth.mjs +0 -43
- package/dist/esm/provider/afterAuth.mjs.map +0 -7
- package/dist/esm/provider/index.mjs +0 -136
- package/dist/esm/provider/index.mjs.map +0 -7
- package/dist/esm/provider/keycloakProvider.mjs +0 -338
- package/dist/esm/provider/keycloakProvider.mjs.map +0 -7
- package/dist/esm/provider/keycloakProvider.native.mjs +0 -69
- package/dist/esm/provider/keycloakProvider.native.mjs.map +0 -7
- package/dist/esm/state/index.mjs +0 -16
- package/dist/esm/state/index.mjs.map +0 -7
- package/dist/esm/types.mjs +0 -5
- package/dist/esm/types.mjs.map +0 -7
- package/dist/esm/util.mjs +0 -26
- package/dist/esm/util.mjs.map +0 -7
- package/dist/jsx/Authenticated.mjs +0 -35
- package/dist/jsx/Authenticated.mjs.map +0 -7
- package/dist/jsx/authConfig.mjs +0 -12
- package/dist/jsx/authConfig.mjs.map +0 -7
- package/dist/jsx/hooks/index.mjs +0 -7
- package/dist/jsx/hooks/index.mjs.map +0 -7
- package/dist/jsx/hooks/useAuthConfig.mjs +0 -9
- package/dist/jsx/hooks/useAuthConfig.mjs.map +0 -7
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs +0 -17
- package/dist/jsx/hooks/useCurrentRouteName/index.mjs.map +0 -7
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs +0 -12
- package/dist/jsx/hooks/useCurrentRouteName/index.native.mjs.map +0 -7
- package/dist/jsx/hooks/useKeycloak/index.mjs +0 -2
- package/dist/jsx/hooks/useKeycloak/index.mjs.map +0 -7
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs +0 -76
- package/dist/jsx/hooks/useKeycloak/useKeycloak.mjs.map +0 -7
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs +0 -58
- package/dist/jsx/hooks/useKeycloak/useKeycloak.native.mjs.map +0 -7
- package/dist/jsx/hooks/useLogin.mjs +0 -33
- package/dist/jsx/hooks/useLogin.mjs.map +0 -7
- package/dist/jsx/hooks/useTokensFromQuery/index.mjs +0 -10
- package/dist/jsx/hooks/useTokensFromQuery/index.mjs.map +0 -7
- package/dist/jsx/hooks/useTokensFromQuery/index.native.mjs +0 -5
- package/dist/jsx/hooks/useTokensFromQuery/index.native.mjs.map +0 -7
- package/dist/jsx/hooks/useTokensFromState.mjs +0 -10
- package/dist/jsx/hooks/useTokensFromState.mjs.map +0 -7
- package/dist/jsx/index.mjs +0 -5
- package/dist/jsx/index.mjs.map +0 -7
- package/dist/jsx/provider/afterAuth.mjs +0 -42
- package/dist/jsx/provider/afterAuth.mjs.map +0 -7
- package/dist/jsx/provider/index.mjs +0 -61
- package/dist/jsx/provider/index.mjs.map +0 -7
- package/dist/jsx/provider/keycloakProvider.mjs +0 -247
- package/dist/jsx/provider/keycloakProvider.mjs.map +0 -7
- package/dist/jsx/provider/keycloakProvider.native.mjs +0 -14
- package/dist/jsx/provider/keycloakProvider.native.mjs.map +0 -7
- package/dist/jsx/state/index.mjs +0 -19
- package/dist/jsx/state/index.mjs.map +0 -7
- package/dist/jsx/types.mjs +0 -5
- package/dist/jsx/types.mjs.map +0 -7
- package/dist/jsx/util.mjs +0 -25
- package/dist/jsx/util.mjs.map +0 -7
- package/dist/lib/Authenticated.d.ts +0 -32
- package/dist/lib/Authenticated.js +0 -75
- package/dist/lib/Authenticated.js.map +0 -7
- package/dist/lib/authConfig.d.ts +0 -34
- package/dist/lib/authConfig.js +0 -37
- package/dist/lib/authConfig.js.map +0 -7
- package/dist/lib/hooks/index.d.ts +0 -29
- package/dist/lib/hooks/index.js +0 -33
- package/dist/lib/hooks/index.js.map +0 -7
- package/dist/lib/hooks/useAuthConfig.d.ts +0 -24
- package/dist/lib/hooks/useAuthConfig.js +0 -33
- package/dist/lib/hooks/useAuthConfig.js.map +0 -7
- package/dist/lib/hooks/useCurrentRouteName/index.d.ts +0 -24
- package/dist/lib/hooks/useCurrentRouteName/index.js +0 -41
- package/dist/lib/hooks/useCurrentRouteName/index.js.map +0 -7
- package/dist/lib/hooks/useCurrentRouteName/index.native.d.ts +0 -24
- package/dist/lib/hooks/useCurrentRouteName/index.native.js +0 -36
- package/dist/lib/hooks/useCurrentRouteName/index.native.js.map +0 -7
- package/dist/lib/hooks/useKeycloak/index.d.ts +0 -47
- package/dist/lib/hooks/useKeycloak/index.js +0 -23
- package/dist/lib/hooks/useKeycloak/index.js.map +0 -7
- package/dist/lib/hooks/useKeycloak/useKeycloak.d.ts +0 -42
- package/dist/lib/hooks/useKeycloak/useKeycloak.js +0 -111
- package/dist/lib/hooks/useKeycloak/useKeycloak.js.map +0 -7
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.d.ts +0 -40
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js +0 -93
- package/dist/lib/hooks/useKeycloak/useKeycloak.native.js.map +0 -7
- package/dist/lib/hooks/useLogin.d.ts +0 -24
- package/dist/lib/hooks/useLogin.js +0 -57
- package/dist/lib/hooks/useLogin.js.map +0 -7
- package/dist/lib/hooks/useTokensFromQuery/index.d.ts +0 -24
- package/dist/lib/hooks/useTokensFromQuery/index.js +0 -34
- package/dist/lib/hooks/useTokensFromQuery/index.js.map +0 -7
- package/dist/lib/hooks/useTokensFromQuery/index.native.d.ts +0 -24
- package/dist/lib/hooks/useTokensFromQuery/index.native.js +0 -29
- package/dist/lib/hooks/useTokensFromQuery/index.native.js.map +0 -7
- package/dist/lib/hooks/useTokensFromState.d.ts +0 -24
- package/dist/lib/hooks/useTokensFromState.js +0 -34
- package/dist/lib/hooks/useTokensFromState.js.map +0 -7
- package/dist/lib/index.d.ts +0 -27
- package/dist/lib/index.js +0 -29
- package/dist/lib/index.js.map +0 -7
- package/dist/lib/provider/afterAuth.d.ts +0 -28
- package/dist/lib/provider/afterAuth.js +0 -67
- package/dist/lib/provider/afterAuth.js.map +0 -7
- package/dist/lib/provider/index.d.ts +0 -38
- package/dist/lib/provider/index.js +0 -131
- package/dist/lib/provider/index.js.map +0 -7
- package/dist/lib/provider/keycloakProvider.d.ts +0 -41
- package/dist/lib/provider/keycloakProvider.js +0 -305
- package/dist/lib/provider/keycloakProvider.js.map +0 -7
- package/dist/lib/provider/keycloakProvider.native.d.ts +0 -26
- package/dist/lib/provider/keycloakProvider.native.js +0 -55
- package/dist/lib/provider/keycloakProvider.native.js.map +0 -7
- package/dist/lib/state/index.d.ts +0 -24
- package/dist/lib/state/index.js +0 -43
- package/dist/lib/state/index.js.map +0 -7
- package/dist/lib/tsconfig.build.tsbuildinfo +0 -1
- package/dist/lib/types.d.ts +0 -39
- package/dist/lib/types.js +0 -25
- package/dist/lib/types.js.map +0 -7
- package/dist/lib/util.d.ts +0 -25
- package/dist/lib/util.js +0 -51
- package/dist/lib/util.js.map +0 -7
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __objRest = (source, exclude) => {
|
|
24
|
-
var target = {};
|
|
25
|
-
for (var prop in source)
|
|
26
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
-
target[prop] = source[prop];
|
|
28
|
-
if (source != null && __getOwnPropSymbols)
|
|
29
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
-
target[prop] = source[prop];
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
};
|
|
35
|
-
var __export = (target, all) => {
|
|
36
|
-
for (var name in all)
|
|
37
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
-
};
|
|
39
|
-
var __copyProps = (to, from, except, desc) => {
|
|
40
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
-
for (let key of __getOwnPropNames(from))
|
|
42
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
-
}
|
|
45
|
-
return to;
|
|
46
|
-
};
|
|
47
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
48
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
49
|
-
var provider_exports = {};
|
|
50
|
-
__export(provider_exports, {
|
|
51
|
-
AuthProvider: () => AuthProvider
|
|
52
|
-
});
|
|
53
|
-
module.exports = __toCommonJS(provider_exports);
|
|
54
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
55
|
-
var import_react = require("react");
|
|
56
|
-
var import_authConfig = require("../authConfig");
|
|
57
|
-
var import_keycloakProvider = require("./keycloakProvider");
|
|
58
|
-
var import_hooks = require("../hooks");
|
|
59
|
-
var import_config = require("app/config");
|
|
60
|
-
__reExport(provider_exports, require("./keycloakProvider"), module.exports);
|
|
61
|
-
const persist = import_config.config.get("KEYCLOAK_PERSIST") === "1";
|
|
62
|
-
const AuthProvider = (_a) => {
|
|
63
|
-
var _b = _a, {
|
|
64
|
-
realm: realm,
|
|
65
|
-
clientId,
|
|
66
|
-
baseUrl,
|
|
67
|
-
debug: debug,
|
|
68
|
-
ensureFreshness,
|
|
69
|
-
loginRoute,
|
|
70
|
-
messageHandlerKeys,
|
|
71
|
-
ssr,
|
|
72
|
-
children: children,
|
|
73
|
-
cookies,
|
|
74
|
-
disabled,
|
|
75
|
-
loadingComponent,
|
|
76
|
-
onEvent,
|
|
77
|
-
onTokens
|
|
78
|
-
} = _b, keycloakInitOptions = __objRest(_b, [
|
|
79
|
-
// keycloak config
|
|
80
|
-
"realm",
|
|
81
|
-
"clientId",
|
|
82
|
-
"baseUrl",
|
|
83
|
-
// auth config
|
|
84
|
-
"debug",
|
|
85
|
-
"ensureFreshness",
|
|
86
|
-
"loginRoute",
|
|
87
|
-
"messageHandlerKeys",
|
|
88
|
-
"ssr",
|
|
89
|
-
// props
|
|
90
|
-
"children",
|
|
91
|
-
"cookies",
|
|
92
|
-
"disabled",
|
|
93
|
-
"loadingComponent",
|
|
94
|
-
"onEvent",
|
|
95
|
-
"onTokens"
|
|
96
|
-
]);
|
|
97
|
-
const tokensFromQuery = (0, import_hooks.useTokensFromQuery)();
|
|
98
|
-
const tokensFromState = (0, import_hooks.useTokensFromState)();
|
|
99
|
-
const authConfig = (0, import_react.useMemo)(
|
|
100
|
-
() => __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, import_authConfig.defaultAuthConfig), typeof debug !== "undefined" ? { debug } : {}), typeof ensureFreshness !== "undefined" ? { ensureFreshness } : {}), typeof loginRoute !== "undefined" ? { loginRoute } : {}), typeof messageHandlerKeys !== "undefined" ? { messageHandlerKeys } : {}), {
|
|
101
|
-
persist: !tokensFromState && !tokensFromQuery && cookies && ssr ? false : typeof persist !== "undefined" ? persist : import_authConfig.defaultAuthConfig.persist,
|
|
102
|
-
ssr: !tokensFromState && !tokensFromQuery && cookies ? typeof ssr !== "undefined" ? ssr : import_authConfig.defaultAuthConfig.ssr : false
|
|
103
|
-
}),
|
|
104
|
-
[debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr]
|
|
105
|
-
);
|
|
106
|
-
if (disabled) {
|
|
107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_authConfig.AuthConfigContext.Provider, { value: authConfig, children });
|
|
108
|
-
}
|
|
109
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_authConfig.AuthConfigContext.Provider, { value: authConfig, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
-
import_keycloakProvider.KeycloakProvider,
|
|
111
|
-
{
|
|
112
|
-
cookies,
|
|
113
|
-
keycloakConfig: {
|
|
114
|
-
realm: realm || "main",
|
|
115
|
-
clientId: clientId || "app",
|
|
116
|
-
url: baseUrl
|
|
117
|
-
},
|
|
118
|
-
keycloakInitOptions,
|
|
119
|
-
loadingComponent,
|
|
120
|
-
onEvent,
|
|
121
|
-
onTokens,
|
|
122
|
-
children
|
|
123
|
-
}
|
|
124
|
-
) });
|
|
125
|
-
};
|
|
126
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
-
0 && (module.exports = {
|
|
128
|
-
AuthProvider,
|
|
129
|
-
...require("./keycloakProvider")
|
|
130
|
-
});
|
|
131
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/provider/index.tsx"],
|
|
4
|
-
"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, { useMemo } from 'react';\nimport type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';\nimport type { AuthConfig } from '../authConfig';\nimport type { FC, ComponentType, ReactNode } from 'react';\nimport type { KeycloakConfig, KeycloakInitOptions } from '@bitspur/keycloak-js';\nimport { AuthConfigContext, defaultAuthConfig } from '../authConfig';\nimport { KeycloakProvider } from './keycloakProvider';\nimport { useTokensFromState, useTokensFromQuery } from '../hooks';\n// @ts-ignore\nimport { config } from 'app/config';\n\nexport interface AuthProviderProps\n extends Partial<Omit<AuthConfig, 'persist'>>,\n Partial<Omit<KeycloakConfig, 'url'>>,\n KeycloakInitOptions {\n children: ReactNode;\n cookies?: unknown;\n disabled?: boolean;\n baseUrl?: string;\n loadingComponent?: ComponentType;\n onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;\n onTokens?: (tokens: AuthClientTokens) => void;\n}\n\nconst persist = config.get('KEYCLOAK_PERSIST') === '1';\n\nexport const AuthProvider: FC<AuthProviderProps> = ({\n // keycloak config\n realm,\n clientId,\n baseUrl,\n // auth config\n debug,\n ensureFreshness,\n loginRoute,\n messageHandlerKeys,\n ssr,\n // props\n children,\n cookies,\n disabled,\n loadingComponent,\n onEvent,\n onTokens,\n ...keycloakInitOptions\n}: AuthProviderProps) => {\n const tokensFromQuery = useTokensFromQuery();\n const tokensFromState = useTokensFromState();\n const authConfig = useMemo(\n () => ({\n ...defaultAuthConfig,\n ...(typeof debug !== 'undefined' ? { debug } : {}),\n ...(typeof ensureFreshness !== 'undefined' ? { ensureFreshness } : {}),\n ...(typeof loginRoute !== 'undefined' ? { loginRoute } : {}),\n ...(typeof messageHandlerKeys !== 'undefined' ? { messageHandlerKeys } : {}),\n persist:\n !tokensFromState && !tokensFromQuery && cookies && ssr\n ? false\n : typeof persist !== 'undefined'\n ? persist\n : defaultAuthConfig.persist,\n ssr:\n !tokensFromState && !tokensFromQuery && cookies\n ? typeof ssr !== 'undefined'\n ? ssr\n : defaultAuthConfig.ssr\n : false,\n }),\n [debug, ensureFreshness, loginRoute, messageHandlerKeys, persist, ssr],\n );\n\n if (disabled) {\n return <AuthConfigContext.Provider value={authConfig}>{children}</AuthConfigContext.Provider>;\n }\n\n return (\n <AuthConfigContext.Provider value={authConfig}>\n <KeycloakProvider\n cookies={cookies}\n keycloakConfig={{\n realm: realm || 'main',\n clientId: clientId || 'app',\n url: baseUrl,\n }}\n keycloakInitOptions={keycloakInitOptions}\n loadingComponent={loadingComponent}\n onEvent={onEvent}\n onTokens={onTokens}\n >\n {children}\n </KeycloakProvider>\n </AuthConfigContext.Provider>\n );\n};\n\nexport * from './keycloakProvider';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgGW;AAxEX,mBAA+B;AAK/B,wBAAqD;AACrD,8BAAiC;AACjC,mBAAuD;AAEvD,oBAAuB;AAsFvB,6BAAc,+BAvHd;AAgDA,MAAM,UAAU,qBAAO,IAAI,kBAAkB,MAAM;AAE5C,MAAM,eAAsC,CAAC,OAmB3B;AAnB2B,eAElD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAnEF,IAkDoD,IAkB/C,gCAlB+C,IAkB/C;AAAA;AAAA,IAhBH;AAAA,I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created: 08-11-2022 03:12:43
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 22-11-2022 18:07:46
|
|
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
|
-
import type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';
|
|
25
|
-
import type { KeycloakInitOptions, KeycloakConfig } from '@bitspur/keycloak-js';
|
|
26
|
-
import type { ReactNode, ComponentType } from 'react';
|
|
27
|
-
export interface KeycloakProviderProps {
|
|
28
|
-
children: ReactNode;
|
|
29
|
-
cookies?: unknown;
|
|
30
|
-
keycloakConfig: KeycloakConfig;
|
|
31
|
-
keycloakInitOptions?: KeycloakInitOptions;
|
|
32
|
-
loadingComponent?: ComponentType;
|
|
33
|
-
onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;
|
|
34
|
-
onTokens?: (tokens: AuthClientTokens) => void;
|
|
35
|
-
}
|
|
36
|
-
export declare function KeycloakProvider({ children, cookies, keycloakConfig, keycloakInitOptions, loadingComponent, onEvent, onTokens, }: KeycloakProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
export declare const defaultKeycloakInitOptions: KeycloakInitOptions;
|
|
38
|
-
export interface MessageSchema {
|
|
39
|
-
type: string;
|
|
40
|
-
payload?: string;
|
|
41
|
-
}
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let key of __getOwnPropNames(from))
|
|
29
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
-
}
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
-
mod
|
|
41
|
-
));
|
|
42
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
-
var keycloakProvider_exports = {};
|
|
44
|
-
__export(keycloakProvider_exports, {
|
|
45
|
-
KeycloakProvider: () => KeycloakProvider,
|
|
46
|
-
defaultKeycloakInitOptions: () => defaultKeycloakInitOptions
|
|
47
|
-
});
|
|
48
|
-
module.exports = __toCommonJS(keycloakProvider_exports);
|
|
49
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
-
var import_keycloak_js = __toESM(require("@bitspur/keycloak-js"));
|
|
51
|
-
var import_react = require("react");
|
|
52
|
-
var import_afterAuth = require("./afterAuth");
|
|
53
|
-
var import_multiplatform = require("multiplatform.one");
|
|
54
|
-
var import_react_keycloak_web = require("@bitspur/react-keycloak-web");
|
|
55
|
-
var import_react_keycloak_ssr = require("@bitspur/react-keycloak-ssr");
|
|
56
|
-
var import_useAuthConfig = require("../hooks/useAuthConfig");
|
|
57
|
-
var import_state = require("../state");
|
|
58
|
-
var import_router = require("next/router");
|
|
59
|
-
var import_util = require("../util");
|
|
60
|
-
const logger = console;
|
|
61
|
-
function KeycloakProvider({
|
|
62
|
-
children,
|
|
63
|
-
cookies,
|
|
64
|
-
keycloakConfig,
|
|
65
|
-
keycloakInitOptions,
|
|
66
|
-
loadingComponent,
|
|
67
|
-
onEvent,
|
|
68
|
-
onTokens
|
|
69
|
-
}) {
|
|
70
|
-
var _a, _b, _c;
|
|
71
|
-
const { debug, ensureFreshness, persist, messageHandlerKeys, ssr } = (0, import_useAuthConfig.useAuthConfig)();
|
|
72
|
-
const authState = (0, import_state.useAuthState)();
|
|
73
|
-
const LoadingComponent = loadingComponent || (() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: debug ? "authenticating" : null }));
|
|
74
|
-
const { query } = import_multiplatform.MultiPlatform.isNext ? (0, import_router.useRouter)() : { query: {} };
|
|
75
|
-
const [refreshToken, setRefreshToken] = (0, import_react.useState)(
|
|
76
|
-
(0, import_util.validToken)(
|
|
77
|
-
ensureFreshness && ("refreshToken" in query && (((_a = query.refreshToken) == null ? void 0 : _a.toString()) || true) || persist && authState.refreshToken) || false
|
|
78
|
-
)
|
|
79
|
-
);
|
|
80
|
-
const [idToken, setIdToken] = (0, import_react.useState)(
|
|
81
|
-
(0, import_util.validToken)(
|
|
82
|
-
"idToken" in query && (((_b = query.idToken) == null ? void 0 : _b.toString()) || true) || persist && authState.idToken || false,
|
|
83
|
-
refreshToken
|
|
84
|
-
)
|
|
85
|
-
);
|
|
86
|
-
const [token, setToken] = (0, import_react.useState)(
|
|
87
|
-
(0, import_util.validToken)(
|
|
88
|
-
"token" in query && (((_c = query.token) == null ? void 0 : _c.toString()) || true) || persist && authState.token || false,
|
|
89
|
-
refreshToken
|
|
90
|
-
)
|
|
91
|
-
);
|
|
92
|
-
(0, import_react.useEffect)(() => {
|
|
93
|
-
var _a2, _b2;
|
|
94
|
-
if (token !== true && refreshToken !== true && idToken !== true)
|
|
95
|
-
return;
|
|
96
|
-
if (debug)
|
|
97
|
-
logger.debug("post message", JSON.stringify({ type: "LOADED" }));
|
|
98
|
-
(messageHandlerKeys || []).forEach((key) => {
|
|
99
|
-
var _a3, _b3, _c2;
|
|
100
|
-
(_c2 = (_b3 = (_a3 = window == null ? void 0 : window.webkit) == null ? void 0 : _a3.messageHandlers) == null ? void 0 : _b3[key]) == null ? void 0 : _c2.postMessage(JSON.stringify({ type: "LOADED" }));
|
|
101
|
-
});
|
|
102
|
-
(_a2 = window == null ? void 0 : window.ReactNativeWebView) == null ? void 0 : _a2.postMessage(JSON.stringify({ type: "LOADED" }));
|
|
103
|
-
(_b2 = window == null ? void 0 : window.parent) == null ? void 0 : _b2.postMessage(JSON.stringify({ type: "LOADED" }));
|
|
104
|
-
}, []);
|
|
105
|
-
(0, import_react.useEffect)(() => {
|
|
106
|
-
if (refreshToken !== true)
|
|
107
|
-
return;
|
|
108
|
-
const messageCallback = (e) => {
|
|
109
|
-
let data = (e == null ? void 0 : e.data) || null;
|
|
110
|
-
if (typeof data === "string") {
|
|
111
|
-
try {
|
|
112
|
-
data = JSON.parse(data);
|
|
113
|
-
} catch (err) {
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (debug)
|
|
117
|
-
logger.debug("received message", JSON.stringify(data));
|
|
118
|
-
const message = data;
|
|
119
|
-
if (!message.type)
|
|
120
|
-
return;
|
|
121
|
-
if (message.type.toUpperCase() === "REFRESH_TOKEN" && message.payload) {
|
|
122
|
-
if (debug)
|
|
123
|
-
logger.debug("setting refresh token", message.payload);
|
|
124
|
-
setRefreshToken((0, import_util.validToken)(message.payload));
|
|
125
|
-
window.removeEventListener("message", messageCallback);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
if (debug) {
|
|
129
|
-
logger.debug(
|
|
130
|
-
"listening for message",
|
|
131
|
-
JSON.stringify({
|
|
132
|
-
type: "REFRESH_TOKEN",
|
|
133
|
-
payload: "<some_refresh_token>"
|
|
134
|
-
})
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
window.addEventListener("message", messageCallback);
|
|
138
|
-
return () => {
|
|
139
|
-
window.removeEventListener("message", messageCallback);
|
|
140
|
-
};
|
|
141
|
-
}, []);
|
|
142
|
-
(0, import_react.useEffect)(() => {
|
|
143
|
-
if (token !== true)
|
|
144
|
-
return;
|
|
145
|
-
const messageCallback = (e) => {
|
|
146
|
-
let data = (e == null ? void 0 : e.data) || null;
|
|
147
|
-
if (typeof data === "string") {
|
|
148
|
-
try {
|
|
149
|
-
data = JSON.parse(data);
|
|
150
|
-
} catch (err) {
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (debug)
|
|
154
|
-
logger.debug("received message", JSON.stringify(data));
|
|
155
|
-
const message = data;
|
|
156
|
-
if (!message.type)
|
|
157
|
-
return;
|
|
158
|
-
if (message.type.toUpperCase() === "TOKEN" && message.payload) {
|
|
159
|
-
if (debug)
|
|
160
|
-
logger.debug("setting token", message.payload);
|
|
161
|
-
setToken((0, import_util.validToken)(message.payload, refreshToken));
|
|
162
|
-
window.removeEventListener("message", messageCallback);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
if (debug) {
|
|
166
|
-
logger.debug(
|
|
167
|
-
"listening for message",
|
|
168
|
-
JSON.stringify({
|
|
169
|
-
type: "TOKEN",
|
|
170
|
-
payload: "<some_token>"
|
|
171
|
-
})
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
window.addEventListener("message", messageCallback);
|
|
175
|
-
return () => {
|
|
176
|
-
window.removeEventListener("message", messageCallback);
|
|
177
|
-
};
|
|
178
|
-
}, []);
|
|
179
|
-
(0, import_react.useEffect)(() => {
|
|
180
|
-
if (idToken !== true)
|
|
181
|
-
return;
|
|
182
|
-
const messageCallback = (e) => {
|
|
183
|
-
let data = (e == null ? void 0 : e.data) || null;
|
|
184
|
-
if (typeof data === "string") {
|
|
185
|
-
try {
|
|
186
|
-
data = JSON.parse(data);
|
|
187
|
-
} catch (err) {
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (debug)
|
|
191
|
-
logger.debug("received message", JSON.stringify(data));
|
|
192
|
-
const message = data;
|
|
193
|
-
if (!message.type)
|
|
194
|
-
return;
|
|
195
|
-
if (message.type.toUpperCase() === "ID_TOKEN" && message.payload) {
|
|
196
|
-
if (debug)
|
|
197
|
-
logger.debug("setting id token", message.payload);
|
|
198
|
-
setIdToken((0, import_util.validToken)(message.payload, refreshToken));
|
|
199
|
-
window.removeEventListener("message", messageCallback);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
if (debug) {
|
|
203
|
-
logger.debug(
|
|
204
|
-
"listening for message",
|
|
205
|
-
JSON.stringify({
|
|
206
|
-
type: "ID_TOKEN",
|
|
207
|
-
payload: "<some_id_token>"
|
|
208
|
-
})
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
window.addEventListener("message", messageCallback);
|
|
212
|
-
return () => {
|
|
213
|
-
window.removeEventListener("message", messageCallback);
|
|
214
|
-
};
|
|
215
|
-
}, []);
|
|
216
|
-
const handleEvent = (0, import_react.useCallback)((eventType, error) => {
|
|
217
|
-
if (error) {
|
|
218
|
-
if (typeof error === "string")
|
|
219
|
-
throw new Error(error);
|
|
220
|
-
const err = new Error(error.error);
|
|
221
|
-
err.errorDescription = error.error_description;
|
|
222
|
-
throw err;
|
|
223
|
-
}
|
|
224
|
-
if (onEvent)
|
|
225
|
-
onEvent(eventType, error);
|
|
226
|
-
}, []);
|
|
227
|
-
const keycloak = (0, import_react.useMemo)(
|
|
228
|
-
() => typeof window !== "undefined" && new import_keycloak_js.default({
|
|
229
|
-
url: keycloakConfig.url,
|
|
230
|
-
realm: keycloakConfig.realm,
|
|
231
|
-
clientId: keycloakConfig.clientId
|
|
232
|
-
}),
|
|
233
|
-
[keycloakInitOptions, token, refreshToken, idToken]
|
|
234
|
-
);
|
|
235
|
-
const initOptions = (0, import_react.useMemo)(() => {
|
|
236
|
-
const initOptions2 = __spreadValues(__spreadValues({}, defaultKeycloakInitOptions), keycloakInitOptions);
|
|
237
|
-
if (debug)
|
|
238
|
-
initOptions2.enableLogging = true;
|
|
239
|
-
if (token && typeof token === "string") {
|
|
240
|
-
initOptions2.token = token;
|
|
241
|
-
initOptions2.timeSkew = 0;
|
|
242
|
-
if (idToken && typeof idToken === "string")
|
|
243
|
-
initOptions2.idToken = idToken;
|
|
244
|
-
if (refreshToken && typeof refreshToken === "string")
|
|
245
|
-
initOptions2.refreshToken = refreshToken;
|
|
246
|
-
}
|
|
247
|
-
if (typeof window !== "undefined" && window.self !== window.top || token && !refreshToken) {
|
|
248
|
-
initOptions2.checkLoginIframe = false;
|
|
249
|
-
initOptions2.flow = "implicit";
|
|
250
|
-
initOptions2.onLoad = void 0;
|
|
251
|
-
}
|
|
252
|
-
return initOptions2;
|
|
253
|
-
}, [keycloakInitOptions, token, refreshToken, idToken]);
|
|
254
|
-
if (token === true || idToken === true || refreshToken === true)
|
|
255
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComponent, {});
|
|
256
|
-
if (cookies && ssr) {
|
|
257
|
-
return (
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
260
|
-
import_react_keycloak_ssr.SSRKeycloakProvider,
|
|
261
|
-
{
|
|
262
|
-
LoadingComponent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComponent, {}),
|
|
263
|
-
autoRefreshToken: initOptions.checkLoginIframe,
|
|
264
|
-
initOptions,
|
|
265
|
-
onEvent: handleEvent,
|
|
266
|
-
onTokens,
|
|
267
|
-
persistor: (0, import_react_keycloak_ssr.SSRCookies)(cookies),
|
|
268
|
-
keycloakConfig: {
|
|
269
|
-
clientId: keycloakConfig.clientId,
|
|
270
|
-
realm: keycloakConfig.realm,
|
|
271
|
-
url: keycloakConfig.url
|
|
272
|
-
},
|
|
273
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_afterAuth.AfterAuth, { children })
|
|
274
|
-
}
|
|
275
|
-
)
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
if (!keycloak)
|
|
279
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComponent, {});
|
|
280
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
281
|
-
import_react_keycloak_web.ReactKeycloakProvider,
|
|
282
|
-
{
|
|
283
|
-
LoadingComponent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComponent, {}),
|
|
284
|
-
authClient: keycloak,
|
|
285
|
-
autoRefreshToken: initOptions.checkLoginIframe,
|
|
286
|
-
initOptions,
|
|
287
|
-
onEvent: handleEvent,
|
|
288
|
-
onTokens,
|
|
289
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_afterAuth.AfterAuth, { children })
|
|
290
|
-
}
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
const defaultKeycloakInitOptions = {
|
|
294
|
-
checkLoginIframe: true,
|
|
295
|
-
checkLoginIframeInterval: 5,
|
|
296
|
-
enableLogging: false,
|
|
297
|
-
onLoad: "check-sso",
|
|
298
|
-
pkceMethod: "S256"
|
|
299
|
-
};
|
|
300
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
301
|
-
0 && (module.exports = {
|
|
302
|
-
KeycloakProvider,
|
|
303
|
-
defaultKeycloakInitOptions
|
|
304
|
-
});
|
|
305
|
-
//# sourceMappingURL=keycloakProvider.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/provider/keycloakProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * File: /auth/provider/keycloakProvider.tsx\n * Project: app\n * File Created: 08-11-2022 03:12:43\n * Author: Clay Risser\n * -----\n * Last Modified: 22-11-2022 18:07:46\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 '@bitspur/keycloak-js';\nimport React, { useMemo, useEffect, useState, useCallback } from 'react';\nimport type { AuthClientEvent, AuthClientError, AuthClientTokens } from '@bitspur/react-keycloak-core';\nimport type { KeycloakInitOptions, KeycloakConfig } from '@bitspur/keycloak-js';\nimport type { ReactNode, ComponentType } from 'react';\nimport { AfterAuth } from './afterAuth';\nimport { MultiPlatform } from 'multiplatform.one';\nimport { ReactKeycloakProvider } from '@bitspur/react-keycloak-web';\nimport { SSRKeycloakProvider, SSRCookies } from '@bitspur/react-keycloak-ssr';\nimport { useAuthConfig } from '../hooks/useAuthConfig';\nimport { useAuthState } from '../state';\nimport { useRouter } from 'next/router';\nimport { validToken } from '../util';\n\nexport interface KeycloakProviderProps {\n children: ReactNode;\n cookies?: unknown;\n keycloakConfig: KeycloakConfig;\n keycloakInitOptions?: KeycloakInitOptions;\n loadingComponent?: ComponentType;\n onEvent?: (eventType: AuthClientEvent, error?: AuthClientError) => void;\n onTokens?: (tokens: AuthClientTokens) => void;\n}\n\nconst logger = console;\n\nexport function KeycloakProvider({\n children,\n cookies,\n keycloakConfig,\n keycloakInitOptions,\n loadingComponent,\n onEvent,\n onTokens,\n}: KeycloakProviderProps) {\n const { debug, ensureFreshness, persist, messageHandlerKeys, ssr } = useAuthConfig();\n const authState = useAuthState();\n const LoadingComponent = loadingComponent || (() => <>{debug ? 'authenticating' : null}</>);\n const { query } = MultiPlatform.isNext ? useRouter() : { query: {} };\n const [refreshToken, setRefreshToken] = useState<string | boolean>(\n validToken(\n (ensureFreshness &&\n (('refreshToken' in query && (query.refreshToken?.toString() || true)) ||\n (persist && authState.refreshToken))) ||\n false,\n ),\n );\n const [idToken, setIdToken] = useState<string | boolean>(\n validToken(\n ('idToken' in query && (query.idToken?.toString() || true)) || (persist && authState.idToken) || false,\n refreshToken,\n ),\n );\n const [token, setToken] = useState<string | boolean>(\n validToken(\n ('token' in query && (query.token?.toString() || true)) || (persist && authState.token) || false,\n refreshToken,\n ),\n );\n\n useEffect(() => {\n if (token !== true && refreshToken !== true && idToken !== true) return;\n if (debug) logger.debug('post message', JSON.stringify({ type: 'LOADED' }));\n (messageHandlerKeys || []).forEach((key: string) => {\n window?.webkit?.messageHandlers?.[key]?.postMessage(JSON.stringify({ type: 'LOADED' }));\n });\n window?.ReactNativeWebView?.postMessage(JSON.stringify({ type: 'LOADED' }));\n window?.parent?.postMessage(JSON.stringify({ type: 'LOADED' }));\n }, []);\n\n useEffect(() => {\n if (refreshToken !== true) return;\n const messageCallback = (e: MessageEvent<any>) => {\n let data = e?.data || null;\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data);\n } catch (err) {}\n }\n if (debug) logger.debug('received message', JSON.stringify(data));\n const message: MessageSchema = data;\n if (!message.type) return;\n if (message.type.toUpperCase() === 'REFRESH_TOKEN' && message.payload) {\n if (debug) logger.debug('setting refresh token', message.payload);\n setRefreshToken(validToken(message.payload));\n window.removeEventListener('message', messageCallback);\n }\n };\n if (debug) {\n logger.debug(\n 'listening for message',\n JSON.stringify({\n type: 'REFRESH_TOKEN',\n payload: '<some_refresh_token>',\n }),\n );\n }\n window.addEventListener('message', messageCallback);\n return () => {\n window.removeEventListener('message', messageCallback);\n };\n }, []);\n\n useEffect(() => {\n if (token !== true) return;\n const messageCallback = (e: MessageEvent<any>) => {\n let data = e?.data || null;\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data);\n } catch (err) {}\n }\n if (debug) logger.debug('received message', JSON.stringify(data));\n const message: MessageSchema = data;\n if (!message.type) return;\n if (message.type.toUpperCase() === 'TOKEN' && message.payload) {\n if (debug) logger.debug('setting token', message.payload);\n setToken(validToken(message.payload, refreshToken));\n window.removeEventListener('message', messageCallback);\n }\n };\n if (debug) {\n logger.debug(\n 'listening for message',\n JSON.stringify({\n type: 'TOKEN',\n payload: '<some_token>',\n }),\n );\n }\n window.addEventListener('message', messageCallback);\n return () => {\n window.removeEventListener('message', messageCallback);\n };\n }, []);\n\n useEffect(() => {\n if (idToken !== true) return;\n const messageCallback = (e: MessageEvent<any>) => {\n let data = e?.data || null;\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data);\n } catch (err) {}\n }\n if (debug) logger.debug('received message', JSON.stringify(data));\n const message: MessageSchema = data;\n if (!message.type) return;\n if (message.type.toUpperCase() === 'ID_TOKEN' && message.payload) {\n if (debug) logger.debug('setting id token', message.payload);\n setIdToken(validToken(message.payload, refreshToken));\n window.removeEventListener('message', messageCallback);\n }\n };\n if (debug) {\n logger.debug(\n 'listening for message',\n JSON.stringify({\n type: 'ID_TOKEN',\n payload: '<some_id_token>',\n }),\n );\n }\n window.addEventListener('message', messageCallback);\n return () => {\n window.removeEventListener('message', messageCallback);\n };\n }, []);\n\n const handleEvent = useCallback((eventType: AuthClientEvent, error?: AuthClientError) => {\n if (error) {\n if (typeof error === 'string') throw new Error(error);\n const err: Error & { errorDescription?: string } = new Error(error.error);\n err.errorDescription = error.error_description;\n throw err;\n }\n if (onEvent) onEvent(eventType, error);\n }, []);\n\n const keycloak = useMemo(\n () =>\n typeof window !== 'undefined' &&\n new Keycloak({\n url: keycloakConfig.url,\n realm: keycloakConfig.realm,\n clientId: keycloakConfig.clientId,\n }),\n [keycloakInitOptions, token, refreshToken, idToken],\n );\n\n const initOptions = useMemo(() => {\n const initOptions = {\n ...defaultKeycloakInitOptions,\n ...keycloakInitOptions,\n };\n if (debug) initOptions.enableLogging = true;\n if (token && typeof token === 'string') {\n initOptions.token = token;\n initOptions.timeSkew = 0;\n if (idToken && typeof idToken === 'string') initOptions.idToken = idToken;\n if (refreshToken && typeof refreshToken === 'string') initOptions.refreshToken = refreshToken;\n }\n if ((typeof window !== 'undefined' && window.self !== window.top) || (token && !refreshToken)) {\n initOptions.checkLoginIframe = false;\n initOptions.flow = 'implicit';\n initOptions.onLoad = undefined;\n }\n return initOptions;\n }, [keycloakInitOptions, token, refreshToken, idToken]);\n\n if (token === true || idToken === true || refreshToken === true) return <LoadingComponent />;\n if (cookies && ssr) {\n return (\n // @ts-ignore\n <SSRKeycloakProvider\n LoadingComponent={<LoadingComponent />}\n autoRefreshToken={initOptions.checkLoginIframe}\n initOptions={initOptions}\n onEvent={handleEvent}\n onTokens={onTokens}\n persistor={SSRCookies(cookies)}\n keycloakConfig={{\n clientId: keycloakConfig.clientId,\n realm: keycloakConfig.realm,\n url: keycloakConfig.url,\n }}\n >\n <AfterAuth>{children}</AfterAuth>\n </SSRKeycloakProvider>\n );\n }\n if (!keycloak) return <LoadingComponent />;\n return (\n <ReactKeycloakProvider\n LoadingComponent={<LoadingComponent />}\n authClient={keycloak}\n autoRefreshToken={initOptions.checkLoginIframe}\n initOptions={initOptions}\n onEvent={handleEvent}\n onTokens={onTokens}\n >\n <AfterAuth>{children}</AfterAuth>\n </ReactKeycloakProvider>\n );\n}\n\nexport const defaultKeycloakInitOptions: KeycloakInitOptions = {\n checkLoginIframe: true,\n checkLoginIframeInterval: 5,\n enableLogging: false,\n onLoad: 'check-sso',\n pkceMethod: 'S256',\n};\n\nexport interface MessageSchema {\n type: string;\n payload?: string;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6DsD;AArCtD,yBAAqB;AACrB,mBAAiE;AAIjE,uBAA0B;AAC1B,2BAA8B;AAC9B,gCAAsC;AACtC,gCAAgD;AAChD,2BAA8B;AAC9B,mBAA6B;AAC7B,oBAA0B;AAC1B,kBAA2B;AAY3B,MAAM,SAAS;AAER,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA0B;AA1D1B;AA2DE,QAAM,EAAE,OAAO,iBAAiB,SAAS,oBAAoB,IAAI,QAAI,oCAAc;AACnF,QAAM,gBAAY,2BAAa;AAC/B,QAAM,mBAAmB,qBAAqB,MAAM,2EAAG,kBAAQ,mBAAmB,MAAK;AACvF,QAAM,EAAE,MAAM,IAAI,mCA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AgB;AAAA,YACd,UAAU,eAAe;AAAA,YACzB,OAAO,eAAe;AAAA,YACtB,KAAK,eAAe;AAAA,UACtB;AAAA,UAEA,sDAAC,8BAAW,UAAS;AAAA;AAAA,MACvB;AAAA;AAAA,EAEJ;AACA,MAAI,CAAC;AAAU,WAAO,4CAAC,oBAAiB;AACxC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,kBAAkB,4CAAC,oBAAiB;AAAA,MACpC,YAAY;AAAA,MACZ,kBAAkB,YAAY;AAAA,MAC9B;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MAEA,sDAAC,8BAAW,UAAS;AAAA;AAAA,EACvB;AAEJ;AAEO,MAAM,6BAAkD;AAAA,EAC7D,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,YAAY;AACd;",
|
|
6
|
-
"names": ["_a", "_b", "_c", "Keycloak", "initOptions"]
|
|
7
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /auth/provider/keycloakProvider.native.tsx
|
|
3
|
-
* Project: app
|
|
4
|
-
* File Created: 08-11-2022 03:12:37
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 22-11-2022 17:52:31
|
|
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
|
-
import type { FC } from 'react';
|
|
25
|
-
import type { KeycloakProviderProps } from './keycloakProvider';
|
|
26
|
-
export declare const KeycloakProvider: FC<KeycloakProviderProps>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __export = (target, all) => {
|
|
24
|
-
for (var name in all)
|
|
25
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
-
};
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (let key of __getOwnPropNames(from))
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
-
var keycloakProvider_native_exports = {};
|
|
37
|
-
__export(keycloakProvider_native_exports, {
|
|
38
|
-
KeycloakProvider: () => KeycloakProvider
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(keycloakProvider_native_exports);
|
|
41
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
-
var import_afterAuth = require("./afterAuth");
|
|
43
|
-
var import_expo_keycloak_auth = require("expo-keycloak-auth");
|
|
44
|
-
const KeycloakProvider = ({ children, keycloakConfig }) => {
|
|
45
|
-
const clonedKeycloakConfig = __spreadProps(__spreadValues({}, keycloakConfig), {
|
|
46
|
-
url: keycloakConfig.url
|
|
47
|
-
});
|
|
48
|
-
delete keycloakConfig.baseUrl;
|
|
49
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_expo_keycloak_auth.KeycloakProvider, __spreadProps(__spreadValues({}, clonedKeycloakConfig), { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_afterAuth.AfterAuth, { children }) }));
|
|
50
|
-
};
|
|
51
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
-
0 && (module.exports = {
|
|
53
|
-
KeycloakProvider
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=keycloakProvider.native.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/provider/keycloakProvider.native.tsx"],
|
|
4
|
-
"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 from 'react';\nimport type { FC } from 'react';\nimport type { KeycloakConfig } from '@bitspur/keycloak-js';\nimport type { KeycloakProviderProps } from './keycloakProvider';\nimport { AfterAuth } from './afterAuth';\nimport { KeycloakProvider as ExpoKeycloakProvider } from 'expo-keycloak-auth';\n\nexport const KeycloakProvider: FC<KeycloakProviderProps> = ({ children, keycloakConfig }: KeycloakProviderProps) => {\n const clonedKeycloakConfig = {\n ...(keycloakConfig as Omit<KeycloakConfig, 'baseUrl'>),\n url: keycloakConfig.url,\n };\n // @ts-ignore\n delete keycloakConfig.baseUrl;\n return (\n <ExpoKeycloakProvider {...clonedKeycloakConfig}>\n <AfterAuth>{children}</AfterAuth>\n </ExpoKeycloakProvider>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCM;AAZN,uBAA0B;AAC1B,gCAAyD;AAElD,MAAM,mBAA8C,CAAC,EAAE,UAAU,eAAe,MAA6B;AAClH,QAAM,uBAAuB,iCACvB,iBADuB;AAAA,IAE3B,KAAK,eAAe;AAAA,EACtB;AAEA,SAAO,eAAe;AACtB,SACE,4CAAC,0BAAAA,kBAAA,iCAAyB,uBAAzB,EACC,sDAAC,8BAAW,UAAS,IACvB;AAEJ;",
|
|
6
|
-
"names": ["ExpoKeycloakProvider"]
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /src/state/index.ts
|
|
3
|
-
* Project: app
|
|
4
|
-
* File Created: 22-11-2022 17:40:53
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* Last Modified: 26-05-2023 07:31:04
|
|
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
|
-
export declare function useAuthState(): any;
|