@arkitektbedriftene/fe-lib 1.1.2 → 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 +124 -97
- package/dist/ui/components/Stack.d.ts +1 -1
- 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
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
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
|
-
import
|
|
5
|
-
import { jwtDecode as
|
|
6
|
-
const I =
|
|
4
|
+
import L from "use-local-storage-state";
|
|
5
|
+
import { jwtDecode as P } from "jwt-decode";
|
|
6
|
+
const I = x(
|
|
7
7
|
null
|
|
8
|
-
),
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
8
|
+
), g = () => {
|
|
9
|
+
const t = v(I);
|
|
10
|
+
if (!t)
|
|
11
11
|
throw new Error(
|
|
12
12
|
"useImpersonationContext must be used within a ImpersonationContextProvider"
|
|
13
13
|
);
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
children:
|
|
14
|
+
return t;
|
|
15
|
+
}, z = ({
|
|
16
|
+
children: t
|
|
17
17
|
}) => {
|
|
18
|
-
const [
|
|
18
|
+
const [e, c] = L("impersonationState", {
|
|
19
19
|
defaultValue: {}
|
|
20
|
-
}), s =
|
|
21
|
-
accessToken:
|
|
22
|
-
userInfo:
|
|
20
|
+
}), s = E(() => ({
|
|
21
|
+
accessToken: e == null ? void 0 : e.accessToken,
|
|
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
|
-
return /* @__PURE__ */
|
|
28
|
-
},
|
|
29
|
-
const { setImpersonation:
|
|
30
|
-
|
|
27
|
+
return /* @__PURE__ */ C(I.Provider, { value: s, children: t });
|
|
28
|
+
}, N = (t) => {
|
|
29
|
+
const { setImpersonation: e } = g();
|
|
30
|
+
h(() => {
|
|
31
31
|
const { search: c } = window.location, s = new URLSearchParams(c).get(
|
|
32
32
|
"impersonateAccessToken"
|
|
33
33
|
);
|
|
34
|
-
if (s &&
|
|
35
|
-
const n =
|
|
36
|
-
|
|
34
|
+
if (s && e) {
|
|
35
|
+
const n = P(s);
|
|
36
|
+
e(s, n), t();
|
|
37
37
|
}
|
|
38
38
|
}, []);
|
|
39
39
|
};
|
|
40
|
-
function
|
|
41
|
-
return JSON.parse(
|
|
40
|
+
function V(t) {
|
|
41
|
+
return JSON.parse(t).map((s) => {
|
|
42
42
|
const [
|
|
43
43
|
n,
|
|
44
44
|
o,
|
|
45
|
-
|
|
45
|
+
u,
|
|
46
46
|
i,
|
|
47
|
-
|
|
48
|
-
] = s.split("|"),
|
|
47
|
+
d
|
|
48
|
+
] = s.split("|"), m = i.split(",");
|
|
49
49
|
return {
|
|
50
50
|
CustomerExternalId: n,
|
|
51
51
|
CustomerFirmId: o,
|
|
52
|
-
CustomerFirmName:
|
|
53
|
-
CustomerUserRoles:
|
|
54
|
-
CustomerUserIsAdmin:
|
|
52
|
+
CustomerFirmName: u,
|
|
53
|
+
CustomerUserRoles: m,
|
|
54
|
+
CustomerUserIsAdmin: d === "True"
|
|
55
55
|
};
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const J = [
|
|
59
59
|
"97",
|
|
60
60
|
"131",
|
|
61
61
|
"132",
|
|
62
62
|
"141"
|
|
63
|
-
],
|
|
63
|
+
], K = [
|
|
64
64
|
"3"
|
|
65
|
-
],
|
|
65
|
+
], _ = [
|
|
66
66
|
"0"
|
|
67
|
-
],
|
|
68
|
-
userManager:
|
|
69
|
-
context:
|
|
67
|
+
], y = ({
|
|
68
|
+
userManager: t,
|
|
69
|
+
context: e,
|
|
70
70
|
children: c
|
|
71
71
|
}) => {
|
|
72
|
-
const [s, n] =
|
|
72
|
+
const [s, n] = k({
|
|
73
73
|
user: null,
|
|
74
74
|
isLoading: !0,
|
|
75
75
|
isAuthenticated: !1,
|
|
76
76
|
isError: !1,
|
|
77
77
|
error: null
|
|
78
|
-
}), o =
|
|
79
|
-
|
|
78
|
+
}), o = U(!1);
|
|
79
|
+
h(() => {
|
|
80
80
|
o.current || (o.current = !0, (async () => {
|
|
81
81
|
try {
|
|
82
|
-
const r = await
|
|
82
|
+
const r = await t.getUser();
|
|
83
83
|
n({
|
|
84
84
|
user: r,
|
|
85
85
|
isLoading: !1,
|
|
@@ -97,39 +97,39 @@ const N = [
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
})());
|
|
100
|
-
}, [
|
|
101
|
-
const r = (
|
|
100
|
+
}, [t]), h(() => {
|
|
101
|
+
const r = (f) => {
|
|
102
102
|
n({
|
|
103
|
-
user:
|
|
103
|
+
user: f,
|
|
104
104
|
isLoading: !1,
|
|
105
|
-
isAuthenticated: !
|
|
105
|
+
isAuthenticated: !f.expired,
|
|
106
106
|
isError: !1,
|
|
107
107
|
error: null
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
|
-
|
|
111
|
-
const
|
|
110
|
+
t.events.addUserLoaded(r);
|
|
111
|
+
const a = () => {
|
|
112
112
|
n({
|
|
113
113
|
...s,
|
|
114
114
|
user: null,
|
|
115
115
|
isAuthenticated: !1
|
|
116
116
|
});
|
|
117
117
|
};
|
|
118
|
-
|
|
119
|
-
const
|
|
118
|
+
t.events.addUserUnloaded(a);
|
|
119
|
+
const w = (f) => {
|
|
120
120
|
n({
|
|
121
121
|
...s,
|
|
122
122
|
isLoading: !1,
|
|
123
123
|
isError: !0,
|
|
124
|
-
error:
|
|
124
|
+
error: f
|
|
125
125
|
});
|
|
126
126
|
};
|
|
127
|
-
return
|
|
128
|
-
|
|
127
|
+
return t.events.addSilentRenewError(w), () => {
|
|
128
|
+
t.events.removeUserLoaded(r), t.events.removeUserUnloaded(a), t.events.removeSilentRenewError(w);
|
|
129
129
|
};
|
|
130
|
-
}, [
|
|
131
|
-
const
|
|
132
|
-
const r = await
|
|
130
|
+
}, [t]);
|
|
131
|
+
const u = l(async () => {
|
|
132
|
+
const r = await t.signinCallback();
|
|
133
133
|
return n({
|
|
134
134
|
user: r ?? null,
|
|
135
135
|
isLoading: !1,
|
|
@@ -137,72 +137,99 @@ const N = [
|
|
|
137
137
|
isError: !1,
|
|
138
138
|
error: null
|
|
139
139
|
}), r ?? void 0;
|
|
140
|
-
}, [
|
|
140
|
+
}, [t]), i = l(
|
|
141
141
|
async (r) => {
|
|
142
142
|
try {
|
|
143
|
-
await
|
|
144
|
-
} catch (
|
|
145
|
-
console.error(
|
|
143
|
+
await t.signinRedirect(r);
|
|
144
|
+
} catch (a) {
|
|
145
|
+
console.error(a);
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
|
-
[
|
|
149
|
-
),
|
|
148
|
+
[t]
|
|
149
|
+
), d = l(
|
|
150
|
+
async (r) => await t.signinPopup(r),
|
|
151
|
+
[t]
|
|
152
|
+
), m = l(
|
|
150
153
|
async (r) => {
|
|
151
154
|
try {
|
|
152
|
-
await
|
|
153
|
-
} catch (
|
|
154
|
-
|
|
155
|
+
return await t.signinSilent(r);
|
|
156
|
+
} catch (a) {
|
|
157
|
+
return n({
|
|
158
|
+
user: null,
|
|
159
|
+
isLoading: !1,
|
|
160
|
+
isAuthenticated: !1,
|
|
161
|
+
isError: !0,
|
|
162
|
+
error: a instanceof Error ? a : new Error("Unknown error during silent signin")
|
|
163
|
+
}), null;
|
|
155
164
|
}
|
|
156
165
|
},
|
|
157
|
-
[
|
|
158
|
-
),
|
|
166
|
+
[t]
|
|
167
|
+
), A = l(
|
|
168
|
+
async (r) => {
|
|
169
|
+
try {
|
|
170
|
+
await t.signoutRedirect(r);
|
|
171
|
+
} catch (a) {
|
|
172
|
+
console.error(a);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
[t]
|
|
176
|
+
), S = E(
|
|
159
177
|
() => ({
|
|
160
178
|
state: s,
|
|
161
|
-
handleSigninCallback:
|
|
179
|
+
handleSigninCallback: u,
|
|
162
180
|
redirectToSignin: i,
|
|
163
|
-
|
|
181
|
+
signinSilent: m,
|
|
182
|
+
signinPopup: d,
|
|
183
|
+
logout: A
|
|
164
184
|
}),
|
|
165
|
-
[
|
|
185
|
+
[
|
|
186
|
+
s,
|
|
187
|
+
u,
|
|
188
|
+
i,
|
|
189
|
+
m,
|
|
190
|
+
d,
|
|
191
|
+
A
|
|
192
|
+
]
|
|
166
193
|
);
|
|
167
|
-
return /* @__PURE__ */
|
|
168
|
-
},
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
194
|
+
return /* @__PURE__ */ C(e.Provider, { value: S, children: c });
|
|
195
|
+
}, p = (t) => {
|
|
196
|
+
const e = v(t);
|
|
197
|
+
if (!e)
|
|
171
198
|
throw new Error("useAuthContext must be used within an AuthProvider");
|
|
172
|
-
return
|
|
173
|
-
},
|
|
174
|
-
const { state:
|
|
175
|
-
return
|
|
176
|
-
}, b = (
|
|
177
|
-
const { state: c, handleSigninCallback: s } =
|
|
178
|
-
return
|
|
199
|
+
return e;
|
|
200
|
+
}, R = (t) => {
|
|
201
|
+
const { state: e } = p(t);
|
|
202
|
+
return e;
|
|
203
|
+
}, b = (t, e) => {
|
|
204
|
+
const { state: c, handleSigninCallback: s } = p(t), n = U(!1);
|
|
205
|
+
return h(() => {
|
|
179
206
|
n.current || (n.current = !0, s().then(
|
|
180
207
|
(o) => new Promise(
|
|
181
|
-
(
|
|
208
|
+
(u) => setTimeout(() => u(o), 0)
|
|
182
209
|
)
|
|
183
|
-
).then((o) =>
|
|
210
|
+
).then((o) => e == null ? void 0 : e(o)));
|
|
184
211
|
}, [s]), c;
|
|
185
|
-
},
|
|
186
|
-
const
|
|
212
|
+
}, q = (t) => {
|
|
213
|
+
const e = x(null);
|
|
187
214
|
return {
|
|
188
|
-
AuthContext:
|
|
189
|
-
AuthProvider: ({ children: i }) => /* @__PURE__ */
|
|
190
|
-
useAuthContext: () =>
|
|
191
|
-
useAuthState: () =>
|
|
192
|
-
useSigninCallback: (i) => b(
|
|
215
|
+
AuthContext: e,
|
|
216
|
+
AuthProvider: ({ children: i }) => /* @__PURE__ */ C(y, { userManager: t, context: e, children: i }),
|
|
217
|
+
useAuthContext: () => p(e),
|
|
218
|
+
useAuthState: () => R(e),
|
|
219
|
+
useSigninCallback: (i) => b(e, i),
|
|
193
220
|
getAccessToken: async () => {
|
|
194
|
-
const i = await
|
|
221
|
+
const i = await t.getUser();
|
|
195
222
|
return i ? i.access_token : null;
|
|
196
223
|
}
|
|
197
224
|
};
|
|
198
225
|
};
|
|
199
226
|
export {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
227
|
+
z as ImpersonationContextProvider,
|
|
228
|
+
J as ROLESAdminInCompany,
|
|
229
|
+
_ as ROLESAnsatt,
|
|
230
|
+
K as ROLESMAKSAdministrator,
|
|
231
|
+
q as createAuthContext,
|
|
232
|
+
V as parseUserProfileFCString,
|
|
233
|
+
N as useImpersonationCallback,
|
|
234
|
+
g as useImpersonationContext
|
|
208
235
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const Stack: import("@stitches/react/types/styled-component").StyledComponent<"div", {
|
|
2
2
|
direction?: "column" | "row" | undefined;
|
|
3
3
|
align?: "center" | "start" | undefined;
|
|
4
|
-
gap?: 0 | 1 | "0" | "1" | "2" | "3" | 2 | 3 | 4 | "4" | "6" | "8" | 6 | 8 | 5 | 7 | "
|
|
4
|
+
gap?: 0 | 1 | "0" | "1" | "2" | "3" | 2 | 3 | 4 | "4" | "5" | "6" | "8" | 6 | 8 | 5 | 7 | "7" | undefined;
|
|
5
5
|
}, {
|
|
6
6
|
lg: "(min-width: 1200px)";
|
|
7
7
|
print: "print";
|