@multiplatform.one/keycloak 7.6.3 → 7.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.
@@ -56,8 +56,128 @@ __export(index_exports, {
56
56
  });
57
57
  module.exports = __toCommonJS(index_exports);
58
58
 
59
+ // ../platform/src/platform/platformBase.ts
60
+ var import_constants = require("@tamagui/constants");
61
+ var platformOrder = [
62
+ "Ios",
63
+ "Android",
64
+ // Gnome outranks Native: the GTK target reports isNative (it is not a
65
+ // browser) but "gnome" is the precise answer callers want.
66
+ "Gnome",
67
+ "Native",
68
+ // Tauri outranks Desktop/Web the same way: the webview host reports isWeb
69
+ // and isDesktop, but "tauri" is the precise answer.
70
+ "Tauri",
71
+ "Desktop",
72
+ "ChromeExtension",
73
+ "FirefoxExtension",
74
+ "WebExtension",
75
+ "Next",
76
+ "Expo",
77
+ "Chrome",
78
+ "Firefox",
79
+ "Web",
80
+ "Browser",
81
+ "Client",
82
+ "Server",
83
+ "Iframe",
84
+ "Storybook"
85
+ ];
86
+ var platformBase = {
87
+ isAndroid: false,
88
+ isBrowser: false,
89
+ isChrome: import_constants.isChrome,
90
+ isChromeExtension: false,
91
+ isClient: import_constants.isClient,
92
+ isDesktop: false,
93
+ isExpo: false,
94
+ isFirefox: false,
95
+ isFirefoxExtension: false,
96
+ isGnome: false,
97
+ isIframe: false,
98
+ isIos: false,
99
+ isNative: false,
100
+ isNext: false,
101
+ isServer: import_constants.isServer,
102
+ isStorybook: import_constants.isWindowDefined && typeof window.__STORYBOOK_ADDONS_PREVIEW === "object",
103
+ isTauri: false,
104
+ isTouchable: import_constants.isTouchable,
105
+ isWeb: import_constants.isWeb,
106
+ isWebExtension: false,
107
+ isWebTouchable: import_constants.isWebTouchable,
108
+ isWindowDefined: import_constants.isWindowDefined,
109
+ preciseName: "unknown",
110
+ broadName: "unknown"
111
+ };
112
+ function getPreciseName(platform2) {
113
+ const flags = platform2;
114
+ for (const name of platformOrder) {
115
+ if (flags[`is${name}`]) {
116
+ return `${name[0].toLowerCase()}${name.slice(1)}`;
117
+ }
118
+ }
119
+ return "unknown";
120
+ }
121
+ function getBroadName(platform2) {
122
+ const flags = platform2;
123
+ for (const name of platformOrder.slice().reverse()) {
124
+ if (flags[`is${name}`]) {
125
+ return `${name[0].toLowerCase()}${name.slice(1)}`;
126
+ }
127
+ }
128
+ return "unknown";
129
+ }
130
+
131
+ // ../platform/src/platform/index.ts
132
+ var isIframe = (() => {
133
+ if (!platformBase.isWindowDefined) return false;
134
+ try {
135
+ return window.self !== window.top;
136
+ } catch {
137
+ return true;
138
+ }
139
+ })();
140
+ var isWebExtension = !!(typeof chrome !== "undefined" && !!chrome?.runtime?.id || typeof browser !== "undefined" && !!browser?.runtime?.id);
141
+ var platform = {
142
+ ...platformBase,
143
+ isChromeExtension: typeof chrome !== "undefined" && !!chrome?.runtime?.id,
144
+ isFirefoxExtension: typeof browser !== "undefined" && !!browser?.runtime?.id,
145
+ isIframe,
146
+ isWebExtension,
147
+ isBrowser: !!(platformBase.isWeb && platformBase.isWindowDefined && !isWebExtension),
148
+ isNext: platformBase.isWeb && (!platformBase.isWindowDefined || typeof window.__NEXT_DATA__ === "object"),
149
+ isFirefox: platformBase.isWindowDefined && !!(window?.navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1)
150
+ };
151
+ platform.preciseName = getPreciseName(platform);
152
+ platform.broadName = getBroadName(platform);
153
+
154
+ // ../platform/src/index.ts
155
+ var {
156
+ isAndroid,
157
+ isBrowser,
158
+ isChrome: isChrome2,
159
+ isChromeExtension,
160
+ isClient: isClient2,
161
+ isExpo,
162
+ isFirefox,
163
+ isFirefoxExtension,
164
+ isGnome,
165
+ isIframe: isIframe2,
166
+ isIos,
167
+ isNative,
168
+ isNext,
169
+ isServer: isServer2,
170
+ isStorybook,
171
+ isTauri,
172
+ isDesktop,
173
+ isTouchable: isTouchable2,
174
+ isWeb: isWeb2,
175
+ isWebExtension: isWebExtension2,
176
+ isWebTouchable: isWebTouchable2,
177
+ isWindowDefined: isWindowDefined2
178
+ } = platform;
179
+
59
180
  // src/Authenticated.tsx
60
- var import_platform6 = require("@multiplatform.one/platform");
61
181
  var import_react8 = require("react");
62
182
  var import_react_native = require("react-native");
63
183
 
@@ -75,26 +195,95 @@ function useAuthConfig() {
75
195
  }
76
196
 
77
197
  // src/hooks/useTokensFromQuery/index.ts
78
- var import_platform = require("@multiplatform.one/platform");
79
198
  function useTokensFromQuery() {
80
199
  const { iframeSso } = useAuthConfig();
81
- if (iframeSso || !import_platform.isIframe) return false;
200
+ if (iframeSso || !isIframe2) return false;
82
201
  const query = new URLSearchParams(
83
202
  typeof window === "undefined" ? "" : window?.location?.search || ""
84
203
  );
85
204
  return typeof query.get("idToken") === "string" || typeof query.get("token") === "string" || typeof query.get("refreshToken") === "string";
86
205
  }
87
206
 
207
+ // ../store/src/createStore.ts
208
+ var import_store2 = require("@tanstack/store");
209
+
210
+ // ../store/src/persist.ts
211
+ var import_store = require("@tanstack/store");
212
+ function createPersistStore(initialState, persistOptions) {
213
+ const { key, storage: storage2, serialize = JSON.stringify, deserialize = JSON.parse } = persistOptions;
214
+ let hydrated = false;
215
+ const store = new import_store.Store(initialState);
216
+ store.subscribe(() => {
217
+ if (hydrated) {
218
+ const serialized = serialize(store.state);
219
+ void Promise.resolve(storage2.setItem(key, serialized));
220
+ }
221
+ });
222
+ const rehydrate = async () => {
223
+ const raw = await Promise.resolve(storage2.getItem(key));
224
+ if (raw !== null) {
225
+ const deserialized = deserialize(raw);
226
+ store.setState(() => deserialized);
227
+ }
228
+ hydrated = true;
229
+ };
230
+ const clearPersistedState = async () => {
231
+ await Promise.resolve(storage2.removeItem(key));
232
+ };
233
+ void rehydrate();
234
+ const persistStore = store;
235
+ persistStore.rehydrate = rehydrate;
236
+ persistStore.clearPersistedState = clearPersistedState;
237
+ return persistStore;
238
+ }
239
+
240
+ // ../store/src/storage/index.ts
241
+ var noopStorage = {
242
+ getItem: () => null,
243
+ setItem: () => {
244
+ },
245
+ removeItem: () => {
246
+ }
247
+ };
248
+ function getStorage() {
249
+ if (typeof globalThis !== "undefined" && "localStorage" in globalThis && typeof globalThis.localStorage?.getItem === "function") {
250
+ return {
251
+ getItem: (name) => globalThis.localStorage.getItem(name) ?? null,
252
+ setItem: (name, value) => globalThis.localStorage.setItem(name, value),
253
+ removeItem: (name) => globalThis.localStorage.removeItem(name)
254
+ };
255
+ }
256
+ return noopStorage;
257
+ }
258
+ var storage = getStorage();
259
+
260
+ // ../store/src/createStore.ts
261
+ function createStore(initialState, options) {
262
+ if (options?.persist) {
263
+ return createPersistStore(initialState, {
264
+ key: options.name,
265
+ storage: options.storage ?? storage
266
+ });
267
+ }
268
+ return new import_store2.Store(initialState);
269
+ }
270
+
271
+ // ../store/src/index.ts
272
+ var import_store3 = require("@tanstack/store");
273
+ var import_react_store = require("@tanstack/react-store");
274
+ var import_react_store2 = require("@tanstack/react-store");
275
+ function useStore2(store, selector) {
276
+ return (0, import_react_store2.useStore)(store, selector ?? ((s) => s));
277
+ }
278
+
88
279
  // src/state.ts
89
- var import_store = require("@multiplatform.one/store");
90
- var import_platform2 = require("@multiplatform.one/platform");
91
- var persist = import_platform2.isIframe || !import_platform2.isBrowser && !import_platform2.isServer;
92
- var authStore = (0, import_store.createStore)(
280
+ var persist = isIframe2 || !isBrowser && !isServer2;
281
+ var authStore = createStore(
93
282
  { idToken: "", refreshToken: "", token: "" },
94
283
  { name: "auth", persist }
95
284
  );
96
285
  function useAuthStore() {
97
- const state = (0, import_store.useStore)(authStore);
286
+ const state = useStore2(authStore);
98
287
  return {
99
288
  ...state,
100
289
  setIdToken: (idToken) => authStore.setState((prev) => ({ ...prev, idToken })),
@@ -157,23 +346,48 @@ function useTokensFromStore() {
157
346
  }
158
347
 
159
348
  // src/keycloak/index.ts
160
- var import_platform5 = require("@multiplatform.one/platform");
161
349
  var import_react7 = require("react");
162
350
 
163
351
  // src/betterAuth/client.ts
164
352
  var import_react3 = require("better-auth/react");
165
353
  var import_plugins = require("better-auth/client/plugins");
166
- var import_platform3 = require("@multiplatform.one/platform");
167
354
  var _client;
168
355
  function getAuthClient(baseURL) {
169
356
  if (_client) return _client;
170
357
  _client = (0, import_react3.createAuthClient)({
171
- baseURL: baseURL || (import_platform3.isWeb && typeof window !== "undefined" ? window.location.origin : ""),
358
+ baseURL: baseURL || (isWeb2 && typeof window !== "undefined" ? window.location.origin : ""),
172
359
  plugins: [(0, import_plugins.genericOAuthClient)()]
173
360
  });
174
361
  return _client;
175
362
  }
176
363
 
364
+ // src/betterAuth/accountSelection.ts
365
+ var validationErrorCode = "VALIDATION_ERROR";
366
+ var known;
367
+ function currentSelection(userId) {
368
+ return userId ? { useAccountCookie: true, userId } : { useAccountCookie: true };
369
+ }
370
+ function legacySelection(providerId, userId) {
371
+ return userId ? { providerId, userId } : { providerId };
372
+ }
373
+ function isBodyRefusal(res) {
374
+ return res.status === 400 && res.body?.code === validationErrorCode;
375
+ }
376
+ async function requestAccessToken(providerId, send, userId) {
377
+ const current = () => currentSelection(userId);
378
+ const legacy = () => legacySelection(providerId, userId);
379
+ if (known === "legacy") return send(legacy());
380
+ if (known === "current") return send(current());
381
+ const first = await send(current());
382
+ if (!isBodyRefusal(first)) {
383
+ if (first.status !== 400) known = "current";
384
+ return first;
385
+ }
386
+ const second = await send(legacy());
387
+ if (!isBodyRefusal(second)) known = "legacy";
388
+ return second;
389
+ }
390
+
177
391
  // src/frappeToken.ts
178
392
  var cached;
179
393
  var pending;
@@ -211,17 +425,21 @@ async function getKeycloakBearerToken() {
211
425
  }
212
426
  async function fetchTokenOnce() {
213
427
  try {
214
- const res = await fetch(`${window.location.origin}/api/auth/get-access-token`, {
215
- method: "POST",
216
- credentials: "include",
217
- headers: { "Content-Type": "application/json" },
218
- body: JSON.stringify({ providerId: "keycloak" })
428
+ let payload = null;
429
+ const res = await requestAccessToken("keycloak", async (selection) => {
430
+ const response = await fetch(`${window.location.origin}/api/auth/get-access-token`, {
431
+ method: "POST",
432
+ credentials: "include",
433
+ headers: { "Content-Type": "application/json" },
434
+ body: JSON.stringify(selection)
435
+ });
436
+ payload = await response.json().catch(() => null);
437
+ return { status: response.status, body: payload };
219
438
  });
220
- if (!res.ok) {
221
- const body = await res.json().catch(() => null);
222
- return { ok: false, kind: classifyAccessTokenResponse(res.status, body) };
439
+ if (res.status < 200 || res.status >= 300) {
440
+ return { ok: false, kind: classifyAccessTokenResponse(res.status, res.body) };
223
441
  }
224
- const data = await res.json().catch(() => null);
442
+ const data = payload;
225
443
  if (!data?.accessToken) {
226
444
  return { ok: false, kind: "signed-out" };
227
445
  }
@@ -285,11 +503,10 @@ function watchKeycloakBearerTokenRevalidate() {
285
503
  }
286
504
 
287
505
  // src/session/index.ts
288
- var import_platform4 = require("@multiplatform.one/platform");
289
506
  var useSession = (_options) => {
290
507
  return { session: null, status: "unauthenticated" };
291
508
  };
292
- if (import_platform4.isBrowser) {
509
+ if (isBrowser) {
293
510
  useSession = (_options) => {
294
511
  const client = getAuthClient();
295
512
  const { data, isPending, error: _error } = client.useSession();
@@ -466,11 +683,11 @@ var Keycloak = class extends BaseKeycloak {
466
683
  this._clear();
467
684
  if (this._keycloakClient) {
468
685
  await this._keycloakClient.login(options);
469
- } else if (import_platform5.isBrowser && !import_platform5.isServer) {
686
+ } else if (isBrowser && !isServer2) {
470
687
  const client = getAuthClient();
471
688
  await client.signIn.social({
472
689
  provider: "keycloak",
473
- callbackURL: options.redirectUri || (import_platform5.isWeb ? window.location.href : "")
690
+ callbackURL: options.redirectUri || (isWeb2 ? window.location.href : "")
474
691
  });
475
692
  } else {
476
693
  await this._login?.(options);
@@ -494,12 +711,12 @@ var Keycloak = class extends BaseKeycloak {
494
711
  }
495
712
  window.location.href = `${origin}/api/auth/sign-out/sso?callbackURL=${encodeURIComponent(callbackURL)}`;
496
713
  return;
497
- } else if (import_platform5.isBrowser && !import_platform5.isServer) {
714
+ } else if (isBrowser && !isServer2) {
498
715
  const client = getAuthClient();
499
716
  await client.signOut({
500
717
  fetchOptions: {
501
718
  onSuccess: () => {
502
- if (options.redirectUri && import_platform5.isWeb) window.location.href = options.redirectUri;
719
+ if (options.redirectUri && isWeb2) window.location.href = options.redirectUri;
503
720
  }
504
721
  }
505
722
  });
@@ -514,7 +731,7 @@ function useKeycloak() {
514
731
  if (disabled) return null;
515
732
  if (keycloak) return keycloak;
516
733
  const { session, status } = useSession();
517
- if (import_platform5.isStorybook) {
734
+ if (isStorybook) {
518
735
  return new Keycloak(keycloakConfig, {
519
736
  email: "storybook@example.com",
520
737
  username: "storybook"
@@ -543,7 +760,7 @@ function Authenticated({
543
760
  const keycloak = useKeycloak();
544
761
  const tokensFromQuery = useTokensFromQuery();
545
762
  (0, import_react8.useEffect)(() => {
546
- if (!keycloak || !authConfig.iframeSso && import_platform6.isIframe || import_platform6.isServer || keycloak.authenticated || tokensFromQuery) {
763
+ if (!keycloak || !authConfig.iframeSso && isIframe2 || isServer2 || keycloak.authenticated || tokensFromQuery) {
547
764
  return;
548
765
  }
549
766
  keycloak?.login({
@@ -564,8 +781,86 @@ function withAuthenticated(Component, options = {}) {
564
781
  return (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Authenticated, { ...options, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...props }) });
565
782
  }
566
783
 
784
+ // ../logger/src/base.ts
785
+ var import_loglevel = __toESM(require("loglevel"));
786
+ var defaultLoggerConfig = {
787
+ name: "default",
788
+ type: "pretty",
789
+ level: true ? 1 /* Debug */ : 2 /* Info */
790
+ };
791
+ var BaseLogger = class {
792
+ constructor(config = {}) {
793
+ const { metadata, name, level } = typeof config === "string" ? { metadata: void 0, name: config, level: void 0 } : config;
794
+ this.metadata = metadata || {};
795
+ this.name = name || "default";
796
+ this.logger = name ? import_loglevel.default.getLogger(name) : import_loglevel.default;
797
+ if (level !== void 0) this.logger.setLevel(level);
798
+ this.transport = this.createTransport?.();
799
+ }
800
+ trace(...args) {
801
+ this.logger.trace(...args);
802
+ this.sendToTransport(0 /* Trace */, args);
803
+ }
804
+ debug(...args) {
805
+ this.logger.debug(...args);
806
+ this.sendToTransport(1 /* Debug */, args);
807
+ }
808
+ info(...args) {
809
+ this.logger.info(...args);
810
+ this.sendToTransport(2 /* Info */, args);
811
+ }
812
+ warn(...args) {
813
+ this.logger.warn(...args);
814
+ this.sendToTransport(3 /* Warn */, args);
815
+ }
816
+ error(...args) {
817
+ this.logger.error(...args);
818
+ this.sendToTransport(4 /* Error */, args);
819
+ }
820
+ log(...args) {
821
+ this.logger.debug(...args);
822
+ this.sendToTransport(1 /* Debug */, args);
823
+ }
824
+ sendToTransport(level, args) {
825
+ if (this.transport) {
826
+ this.transport.send({
827
+ level,
828
+ message: args[0],
829
+ args: args.slice(1),
830
+ platform: platform.preciseName,
831
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
832
+ });
833
+ }
834
+ }
835
+ getSubLogger(input) {
836
+ const subConfig = typeof input === "string" ? {
837
+ name: input,
838
+ metadata: this.metadata,
839
+ level: this.logger.getLevel()
840
+ } : {
841
+ ...input,
842
+ metadata: { ...this.metadata, ...input.metadata }
843
+ };
844
+ return new this.constructor(subConfig);
845
+ }
846
+ };
847
+
848
+ // ../logger/src/index.ts
849
+ var Logger = class extends BaseLogger {
850
+ constructor(config = {}) {
851
+ const metadata = {
852
+ platform: platform.preciseName
853
+ };
854
+ super({
855
+ name: metadata.platform,
856
+ ...typeof config === "string" ? { name: config } : config,
857
+ metadata
858
+ });
859
+ }
860
+ };
861
+ var logger = new Logger();
862
+
567
863
  // src/provider/AfterAuth.tsx
568
- var import_logger = require("@multiplatform.one/logger");
569
864
  var import_react9 = require("react");
570
865
  var import_jsx_runtime2 = require("react/jsx-runtime");
571
866
  function AfterAuth({ children, loadingComponent: _loadingComponent }) {
@@ -593,27 +888,27 @@ function AfterAuth({ children, loadingComponent: _loadingComponent }) {
593
888
  ]);
594
889
  (0, import_react9.useEffect)(() => {
595
890
  if (authConfig.debug && keycloak?.token) {
596
- import_logger.logger.debug("token", keycloak.token);
891
+ logger.debug("token", keycloak.token);
597
892
  }
598
893
  }, [authConfig.debug, keycloak?.token]);
599
894
  (0, import_react9.useEffect)(() => {
600
895
  if (authConfig.debug && keycloak?.idToken) {
601
- import_logger.logger.debug("idToken", keycloak.idToken);
896
+ logger.debug("idToken", keycloak.idToken);
602
897
  }
603
898
  }, [authConfig.debug, keycloak?.idToken]);
604
899
  (0, import_react9.useEffect)(() => {
605
900
  if (authConfig.debug && keycloak?.refreshToken) {
606
- import_logger.logger.debug("refreshToken", keycloak.refreshToken);
901
+ logger.debug("refreshToken", keycloak.refreshToken);
607
902
  }
608
903
  }, [authConfig.debug, keycloak?.refreshToken]);
609
904
  (0, import_react9.useEffect)(() => {
610
905
  if (authConfig.debug && keycloak?.authenticated) {
611
- import_logger.logger.debug("authenticated", keycloak.authenticated);
906
+ logger.debug("authenticated", keycloak.authenticated);
612
907
  }
613
908
  }, [authConfig.debug, keycloak?.authenticated]);
614
909
  (0, import_react9.useEffect)(() => {
615
910
  if (authConfig.debug && keycloak === null) {
616
- import_logger.logger.debug("keycloak disabled");
911
+ logger.debug("keycloak disabled");
617
912
  }
618
913
  }, [authConfig.debug, keycloak]);
619
914
  (0, import_react9.useEffect)(() => watchKeycloakBearerTokenRevalidate(), []);
@@ -622,8 +917,6 @@ function AfterAuth({ children, loadingComponent: _loadingComponent }) {
622
917
 
623
918
  // src/provider/authProvider/index.tsx
624
919
  var import_keycloak_js = __toESM(require("@multiplatform.one/keycloak-js"));
625
- var import_platform7 = require("@multiplatform.one/platform");
626
- var import_logger2 = require("@multiplatform.one/logger");
627
920
  var import_react10 = require("react");
628
921
 
629
922
  // src/Loading.tsx
@@ -660,7 +953,7 @@ function AuthProvider({
660
953
  loadingComponent
661
954
  }) {
662
955
  const { debug, messageHandlerKeys, iframeSso } = useAuthConfig();
663
- const query = new URLSearchParams(import_platform7.isWindowDefined ? window?.location?.search || "" : "");
956
+ const query = new URLSearchParams(isWindowDefined2 ? window?.location?.search || "" : "");
664
957
  const authStore2 = useAuthStore();
665
958
  const [keycloak, setKeycloak] = (0, import_react10.useState)();
666
959
  const idTokenQuery = query.get("idToken");
@@ -672,20 +965,20 @@ function AuthProvider({
672
965
  const [loadedMessagePosted, setLoadedMessagePosted] = (0, import_react10.useState)(false);
673
966
  const initialRefreshTokenQuery = (0, import_react10.useMemo)(
674
967
  () => validOrRefreshableToken(
675
- !iframeSso && import_platform7.isIframe || typeof refreshTokenQuery === "string" ? refreshTokenQuery || true : void 0
968
+ !iframeSso && isIframe2 || typeof refreshTokenQuery === "string" ? refreshTokenQuery || true : void 0
676
969
  ),
677
970
  [refreshTokenQuery, iframeSso]
678
971
  );
679
972
  const initialIdTokenQuery = (0, import_react10.useMemo)(
680
973
  () => validOrRefreshableToken(
681
- !iframeSso && import_platform7.isIframe || typeof idTokenQuery === "string" ? idTokenQuery || true : void 0,
974
+ !iframeSso && isIframe2 || typeof idTokenQuery === "string" ? idTokenQuery || true : void 0,
682
975
  initialRefreshTokenQuery
683
976
  ),
684
977
  [idTokenQuery, initialRefreshTokenQuery, iframeSso]
685
978
  );
686
979
  const initialTokenQuery = (0, import_react10.useMemo)(
687
980
  () => validOrRefreshableToken(
688
- import_platform7.isIframe ? typeof tokenQuery === "string" ? tokenQuery || true : void 0 : void 0,
981
+ isIframe2 ? typeof tokenQuery === "string" ? tokenQuery || true : void 0 : void 0,
689
982
  initialRefreshTokenQuery
690
983
  ),
691
984
  [tokenQuery, initialRefreshTokenQuery, iframeSso]
@@ -696,7 +989,7 @@ function AuthProvider({
696
989
  idToken: initialIdTokenQuery
697
990
  });
698
991
  const authSource = (0, import_react10.useMemo)(() => {
699
- if (!iframeSso && import_platform7.isIframe) {
992
+ if (!iframeSso && isIframe2) {
700
993
  if (initialTokenQuery) return "query" /* Query */;
701
994
  return "store" /* Store */;
702
995
  }
@@ -749,7 +1042,7 @@ function AuthProvider({
749
1042
  if (disabled || authSource !== "query" /* Query */ || tokens.token === true || tokens.refreshToken === true || tokens.idToken === true || loadedMessagePosted) {
750
1043
  return;
751
1044
  }
752
- if (debug) import_logger2.logger.debug("post message", JSON.stringify({ type: "LOADED" }));
1045
+ if (debug) logger.debug("post message", JSON.stringify({ type: "LOADED" }));
753
1046
  (messageHandlerKeys || []).forEach((key) => {
754
1047
  window?.webkit?.messageHandlers?.[key]?.postMessage(JSON.stringify({ type: "LOADED" }));
755
1048
  });
@@ -770,11 +1063,11 @@ function AuthProvider({
770
1063
  } catch {
771
1064
  }
772
1065
  }
773
- if (debug) import_logger2.logger.debug("received message", JSON.stringify(data));
1066
+ if (debug) logger.debug("received message", JSON.stringify(data));
774
1067
  const message = data;
775
1068
  if (!message.type) return;
776
1069
  if (message.type.toUpperCase() === "REFRESH_TOKEN" && message.payload) {
777
- if (debug) import_logger2.logger.debug("setting refresh token", message.payload);
1070
+ if (debug) logger.debug("setting refresh token", message.payload);
778
1071
  setTokens((tokens2) => ({
779
1072
  ...tokens2,
780
1073
  refreshToken: validOrRefreshableToken(message.payload)
@@ -784,7 +1077,7 @@ function AuthProvider({
784
1077
  }
785
1078
  }
786
1079
  if (debug) {
787
- import_logger2.logger.debug(
1080
+ logger.debug(
788
1081
  "listening for message",
789
1082
  JSON.stringify({
790
1083
  type: "REFRESH_TOKEN",
@@ -808,11 +1101,11 @@ function AuthProvider({
808
1101
  } catch {
809
1102
  }
810
1103
  }
811
- if (debug) import_logger2.logger.debug("received message", JSON.stringify(data));
1104
+ if (debug) logger.debug("received message", JSON.stringify(data));
812
1105
  const message = data;
813
1106
  if (!message.type) return;
814
1107
  if (message.type.toUpperCase() === "TOKEN" && message.payload) {
815
- if (debug) import_logger2.logger.debug("setting token", message.payload);
1108
+ if (debug) logger.debug("setting token", message.payload);
816
1109
  setTokens((tokens2) => ({
817
1110
  ...tokens2,
818
1111
  token: validOrRefreshableToken(message.payload, tokens2.refreshToken)
@@ -822,7 +1115,7 @@ function AuthProvider({
822
1115
  }
823
1116
  }
824
1117
  if (debug) {
825
- import_logger2.logger.debug(
1118
+ logger.debug(
826
1119
  "listening for message",
827
1120
  JSON.stringify({
828
1121
  type: "TOKEN",
@@ -846,11 +1139,11 @@ function AuthProvider({
846
1139
  } catch {
847
1140
  }
848
1141
  }
849
- if (debug) import_logger2.logger.debug("received message", JSON.stringify(data));
1142
+ if (debug) logger.debug("received message", JSON.stringify(data));
850
1143
  const message = data;
851
1144
  if (!message.type) return;
852
1145
  if (message.type.toUpperCase() === "ID_TOKEN" && message.payload) {
853
- if (debug) import_logger2.logger.debug("setting id token", message.payload);
1146
+ if (debug) logger.debug("setting id token", message.payload);
854
1147
  setTokens((tokens2) => ({
855
1148
  ...tokens2,
856
1149
  idToken: validOrRefreshableToken(message.payload, tokens2.refreshToken)
@@ -860,7 +1153,7 @@ function AuthProvider({
860
1153
  }
861
1154
  }
862
1155
  if (debug) {
863
- import_logger2.logger.debug(
1156
+ logger.debug(
864
1157
  "listening for message",
865
1158
  JSON.stringify({
866
1159
  type: "ID_TOKEN",
@@ -917,7 +1210,7 @@ function AuthProvider({
917
1210
  initOptions2.refreshToken = tokens.refreshToken;
918
1211
  }
919
1212
  }
920
- if (!iframeSso && import_platform7.isIframe || tokens.token && !tokens.refreshToken) {
1213
+ if (!iframeSso && isIframe2 || tokens.token && !tokens.refreshToken) {
921
1214
  initOptions2.checkLoginIframe = false;
922
1215
  initOptions2.flow = "implicit";
923
1216
  initOptions2.onLoad = void 0;
@@ -958,7 +1251,7 @@ function AuthProvider({
958
1251
  try {
959
1252
  await keycloakClient.updateToken(5);
960
1253
  } catch (err) {
961
- import_logger2.logger.warn(err);
1254
+ logger.warn(err);
962
1255
  setKeycloak(new Keycloak(keycloakConfig, keycloakClient));
963
1256
  }
964
1257
  };