@arkitektbedriftene/fe-lib 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/oidc.es.js +17 -17
  2. package/package.json +1 -1
package/dist/oidc.es.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { jsx as A } from "react/jsx-runtime";
2
- import { createContext as S, useContext as w, useMemo as x, useEffect as m, useState as U, useRef as v, useCallback as C } from "react";
2
+ import { createContext as p, useContext as x, useMemo as v, useEffect as m, useState as U, useRef as w, useCallback as C } from "react";
3
3
  export * from "oidc-client-ts";
4
4
  import E from "use-local-storage-state";
5
5
  import { jwtDecode as k } from "jwt-decode";
6
- const I = S(
6
+ const I = p(
7
7
  null
8
8
  ), L = () => {
9
- const e = w(I);
9
+ const e = x(I);
10
10
  if (!e)
11
11
  throw new Error(
12
12
  "useImpersonationContext must be used within a ImpersonationContextProvider"
@@ -17,7 +17,7 @@ const I = S(
17
17
  }) => {
18
18
  const [t, c] = E("impersonationState", {
19
19
  defaultValue: {}
20
- }), s = x(() => ({
20
+ }), s = v(() => ({
21
21
  accessToken: t == null ? void 0 : t.accessToken,
22
22
  userInfo: t == null ? void 0 : t.userInfo,
23
23
  setImpersonation: (n, o) => {
@@ -64,7 +64,7 @@ const N = [
64
64
  "3"
65
65
  ], J = [
66
66
  "0"
67
- ], P = ({
67
+ ], R = ({
68
68
  userManager: e,
69
69
  context: t,
70
70
  children: c
@@ -75,7 +75,7 @@ const N = [
75
75
  isAuthenticated: !1,
76
76
  isError: !1,
77
77
  error: null
78
- }), o = v(!1);
78
+ }), o = w(!1);
79
79
  m(() => {
80
80
  o.current || (o.current = !0, (async () => {
81
81
  try {
@@ -116,7 +116,7 @@ const N = [
116
116
  });
117
117
  };
118
118
  e.events.addUserUnloaded(u);
119
- const p = (d) => {
119
+ const S = (d) => {
120
120
  n({
121
121
  ...s,
122
122
  isLoading: !1,
@@ -124,8 +124,8 @@ const N = [
124
124
  error: d
125
125
  });
126
126
  };
127
- return e.events.addSilentRenewError(p), () => {
128
- e.events.removeUserLoaded(r), e.events.removeUserUnloaded(u), e.events.removeSilentRenewError(p);
127
+ return e.events.addSilentRenewError(S), () => {
128
+ e.events.removeUserLoaded(r), e.events.removeUserUnloaded(u), e.events.removeSilentRenewError(S);
129
129
  };
130
130
  }, [e]);
131
131
  const a = C(async () => {
@@ -140,7 +140,7 @@ const N = [
140
140
  }, [e]), i = C(
141
141
  async (r) => {
142
142
  try {
143
- window.self !== window.top ? await e.signinPopup(r) : await e.signinRedirect(r);
143
+ await e.signinRedirect(r);
144
144
  } catch (u) {
145
145
  console.error(u);
146
146
  }
@@ -155,7 +155,7 @@ const N = [
155
155
  }
156
156
  },
157
157
  [e]
158
- ), f = x(
158
+ ), f = v(
159
159
  () => ({
160
160
  state: s,
161
161
  handleSigninCallback: a,
@@ -166,15 +166,15 @@ const N = [
166
166
  );
167
167
  return /* @__PURE__ */ A(t.Provider, { value: f, children: c });
168
168
  }, h = (e) => {
169
- const t = w(e);
169
+ const t = x(e);
170
170
  if (!t)
171
171
  throw new Error("useAuthContext must be used within an AuthProvider");
172
172
  return t;
173
- }, R = (e) => {
173
+ }, P = (e) => {
174
174
  const { state: t } = h(e);
175
175
  return t;
176
176
  }, b = (e, t) => {
177
- const { state: c, handleSigninCallback: s } = h(e), n = v(!1);
177
+ const { state: c, handleSigninCallback: s } = h(e), n = w(!1);
178
178
  return m(() => {
179
179
  n.current || (n.current = !0, s().then(
180
180
  (o) => new Promise(
@@ -183,12 +183,12 @@ const N = [
183
183
  ).then((o) => t == null ? void 0 : t(o)));
184
184
  }, [s]), c;
185
185
  }, K = (e) => {
186
- const t = S(null);
186
+ const t = p(null);
187
187
  return {
188
188
  AuthContext: t,
189
- AuthProvider: ({ children: i }) => /* @__PURE__ */ A(P, { userManager: e, context: t, children: i }),
189
+ AuthProvider: ({ children: i }) => /* @__PURE__ */ A(R, { userManager: e, context: t, children: i }),
190
190
  useAuthContext: () => h(t),
191
- useAuthState: () => R(t),
191
+ useAuthState: () => P(t),
192
192
  useSigninCallback: (i) => b(t, i),
193
193
  getAccessToken: async () => {
194
194
  const i = await e.getUser();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkitektbedriftene/fe-lib",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {