@arkitektbedriftene/fe-lib 1.2.0 → 1.2.1
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/dist/oidc/oidc.d.ts +2 -0
- package/dist/oidc.es.js +26 -32
- package/package.json +1 -1
package/dist/oidc/oidc.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type AuthContextData = {
|
|
|
14
14
|
state: AuthState;
|
|
15
15
|
handleSigninCallback: () => Promise<User | undefined>;
|
|
16
16
|
redirectToSignin: UserManager["signinRedirect"];
|
|
17
|
+
signinSilent: UserManager["signinSilent"];
|
|
18
|
+
signinPopup: UserManager["signinPopup"];
|
|
17
19
|
logout: UserManager["signoutRedirect"];
|
|
18
20
|
};
|
|
19
21
|
export type AuthProviderConfig = {
|
package/dist/oidc.es.js
CHANGED
|
@@ -2,10 +2,10 @@ import { jsx as C } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext as x, useContext as v, useMemo as E, useEffect as h, useState as k, useRef as U, useCallback as l } from "react";
|
|
3
3
|
export * from "oidc-client-ts";
|
|
4
4
|
import L from "use-local-storage-state";
|
|
5
|
-
import { jwtDecode as
|
|
5
|
+
import { jwtDecode as P } from "jwt-decode";
|
|
6
6
|
const I = x(
|
|
7
7
|
null
|
|
8
|
-
),
|
|
8
|
+
), g = () => {
|
|
9
9
|
const t = v(I);
|
|
10
10
|
if (!t)
|
|
11
11
|
throw new Error(
|
|
@@ -15,24 +15,24 @@ const I = x(
|
|
|
15
15
|
}, z = ({
|
|
16
16
|
children: t
|
|
17
17
|
}) => {
|
|
18
|
-
const [e,
|
|
18
|
+
const [e, c] = L("impersonationState", {
|
|
19
19
|
defaultValue: {}
|
|
20
20
|
}), s = E(() => ({
|
|
21
21
|
accessToken: e == null ? void 0 : e.accessToken,
|
|
22
22
|
userInfo: e == null ? void 0 : e.userInfo,
|
|
23
23
|
setImpersonation: (n, o) => {
|
|
24
|
-
|
|
24
|
+
c({ accessToken: n, userInfo: o });
|
|
25
25
|
}
|
|
26
26
|
}), []);
|
|
27
27
|
return /* @__PURE__ */ C(I.Provider, { value: s, children: t });
|
|
28
28
|
}, N = (t) => {
|
|
29
|
-
const { setImpersonation: e } =
|
|
29
|
+
const { setImpersonation: e } = g();
|
|
30
30
|
h(() => {
|
|
31
|
-
const { search:
|
|
31
|
+
const { search: c } = window.location, s = new URLSearchParams(c).get(
|
|
32
32
|
"impersonateAccessToken"
|
|
33
33
|
);
|
|
34
34
|
if (s && e) {
|
|
35
|
-
const n =
|
|
35
|
+
const n = P(s);
|
|
36
36
|
e(s, n), t();
|
|
37
37
|
}
|
|
38
38
|
}, []);
|
|
@@ -64,10 +64,10 @@ const J = [
|
|
|
64
64
|
"3"
|
|
65
65
|
], _ = [
|
|
66
66
|
"0"
|
|
67
|
-
],
|
|
67
|
+
], y = ({
|
|
68
68
|
userManager: t,
|
|
69
69
|
context: e,
|
|
70
|
-
children:
|
|
70
|
+
children: c
|
|
71
71
|
}) => {
|
|
72
72
|
const [s, n] = k({
|
|
73
73
|
user: null,
|
|
@@ -108,14 +108,14 @@ const J = [
|
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
110
|
t.events.addUserLoaded(r);
|
|
111
|
-
const
|
|
111
|
+
const a = () => {
|
|
112
112
|
n({
|
|
113
113
|
...s,
|
|
114
114
|
user: null,
|
|
115
115
|
isAuthenticated: !1
|
|
116
116
|
});
|
|
117
117
|
};
|
|
118
|
-
t.events.addUserUnloaded(
|
|
118
|
+
t.events.addUserUnloaded(a);
|
|
119
119
|
const w = (f) => {
|
|
120
120
|
n({
|
|
121
121
|
...s,
|
|
@@ -125,7 +125,7 @@ const J = [
|
|
|
125
125
|
});
|
|
126
126
|
};
|
|
127
127
|
return t.events.addSilentRenewError(w), () => {
|
|
128
|
-
t.events.removeUserLoaded(r), t.events.removeUserUnloaded(
|
|
128
|
+
t.events.removeUserLoaded(r), t.events.removeUserUnloaded(a), t.events.removeSilentRenewError(w);
|
|
129
129
|
};
|
|
130
130
|
}, [t]);
|
|
131
131
|
const u = l(async () => {
|
|
@@ -141,32 +141,26 @@ const J = [
|
|
|
141
141
|
async (r) => {
|
|
142
142
|
try {
|
|
143
143
|
await t.signinRedirect(r);
|
|
144
|
-
} catch (
|
|
145
|
-
console.error(
|
|
144
|
+
} catch (a) {
|
|
145
|
+
console.error(a);
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
148
|
[t]
|
|
149
149
|
), d = l(
|
|
150
|
-
async (r) =>
|
|
151
|
-
try {
|
|
152
|
-
await t.signinPopup(r);
|
|
153
|
-
} catch (c) {
|
|
154
|
-
console.error(c);
|
|
155
|
-
}
|
|
156
|
-
},
|
|
150
|
+
async (r) => await t.signinPopup(r),
|
|
157
151
|
[t]
|
|
158
152
|
), m = l(
|
|
159
153
|
async (r) => {
|
|
160
154
|
try {
|
|
161
155
|
return await t.signinSilent(r);
|
|
162
|
-
} catch (
|
|
163
|
-
n({
|
|
156
|
+
} catch (a) {
|
|
157
|
+
return n({
|
|
164
158
|
user: null,
|
|
165
159
|
isLoading: !1,
|
|
166
160
|
isAuthenticated: !1,
|
|
167
161
|
isError: !0,
|
|
168
|
-
error:
|
|
169
|
-
});
|
|
162
|
+
error: a instanceof Error ? a : new Error("Unknown error during silent signin")
|
|
163
|
+
}), null;
|
|
170
164
|
}
|
|
171
165
|
},
|
|
172
166
|
[t]
|
|
@@ -174,8 +168,8 @@ const J = [
|
|
|
174
168
|
async (r) => {
|
|
175
169
|
try {
|
|
176
170
|
await t.signoutRedirect(r);
|
|
177
|
-
} catch (
|
|
178
|
-
console.error(
|
|
171
|
+
} catch (a) {
|
|
172
|
+
console.error(a);
|
|
179
173
|
}
|
|
180
174
|
},
|
|
181
175
|
[t]
|
|
@@ -197,7 +191,7 @@ const J = [
|
|
|
197
191
|
A
|
|
198
192
|
]
|
|
199
193
|
);
|
|
200
|
-
return /* @__PURE__ */ C(e.Provider, { value: S, children:
|
|
194
|
+
return /* @__PURE__ */ C(e.Provider, { value: S, children: c });
|
|
201
195
|
}, p = (t) => {
|
|
202
196
|
const e = v(t);
|
|
203
197
|
if (!e)
|
|
@@ -207,19 +201,19 @@ const J = [
|
|
|
207
201
|
const { state: e } = p(t);
|
|
208
202
|
return e;
|
|
209
203
|
}, b = (t, e) => {
|
|
210
|
-
const { state:
|
|
204
|
+
const { state: c, handleSigninCallback: s } = p(t), n = U(!1);
|
|
211
205
|
return h(() => {
|
|
212
206
|
n.current || (n.current = !0, s().then(
|
|
213
207
|
(o) => new Promise(
|
|
214
208
|
(u) => setTimeout(() => u(o), 0)
|
|
215
209
|
)
|
|
216
210
|
).then((o) => e == null ? void 0 : e(o)));
|
|
217
|
-
}, [s]),
|
|
211
|
+
}, [s]), c;
|
|
218
212
|
}, q = (t) => {
|
|
219
213
|
const e = x(null);
|
|
220
214
|
return {
|
|
221
215
|
AuthContext: e,
|
|
222
|
-
AuthProvider: ({ children: i }) => /* @__PURE__ */ C(
|
|
216
|
+
AuthProvider: ({ children: i }) => /* @__PURE__ */ C(y, { userManager: t, context: e, children: i }),
|
|
223
217
|
useAuthContext: () => p(e),
|
|
224
218
|
useAuthState: () => R(e),
|
|
225
219
|
useSigninCallback: (i) => b(e, i),
|
|
@@ -237,5 +231,5 @@ export {
|
|
|
237
231
|
q as createAuthContext,
|
|
238
232
|
V as parseUserProfileFCString,
|
|
239
233
|
N as useImpersonationCallback,
|
|
240
|
-
|
|
234
|
+
g as useImpersonationContext
|
|
241
235
|
};
|