@archbase/security 3.0.23 → 4.0.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/dist/index.js +86 -86
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -80,8 +80,8 @@ class Vt {
|
|
|
80
80
|
const o = Rt(s.access_token);
|
|
81
81
|
if (!o)
|
|
82
82
|
return !0;
|
|
83
|
-
const
|
|
84
|
-
return
|
|
83
|
+
const c = Math.floor(Date.now() / 1e3), l = o.exp;
|
|
84
|
+
return c > l - t;
|
|
85
85
|
} catch {
|
|
86
86
|
return !0;
|
|
87
87
|
}
|
|
@@ -189,8 +189,8 @@ async function Jt(r, e) {
|
|
|
189
189
|
...r.extraAuthParameters
|
|
190
190
|
});
|
|
191
191
|
r.scope !== void 0 && o.append("scope", r.scope), sessionStorage.removeItem(_e);
|
|
192
|
-
const
|
|
193
|
-
|
|
192
|
+
const c = e ?? r.state;
|
|
193
|
+
c && (sessionStorage.setItem(_e, c), o.append("state", c)), r?.preLogin && r.preLogin(), window.location.replace(`${r.authorizationEndpoint}?${o.toString()}`);
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
function Kt(r) {
|
|
@@ -233,7 +233,7 @@ A autenticação ocorreu?`);
|
|
|
233
233
|
};
|
|
234
234
|
return ot(e.tokenEndpoint, s);
|
|
235
235
|
};
|
|
236
|
-
function Xt(r, e, t, s, o,
|
|
236
|
+
function Xt(r, e, t, s, o, c) {
|
|
237
237
|
const l = new URLSearchParams({
|
|
238
238
|
token: t || e,
|
|
239
239
|
token_type_hint: t ? "refresh_token" : "access_token",
|
|
@@ -242,7 +242,7 @@ function Xt(r, e, t, s, o, a) {
|
|
|
242
242
|
ui_locales: window.navigator.languages.reduce((i, u) => i + " " + u),
|
|
243
243
|
...r.extraLogoutParameters
|
|
244
244
|
});
|
|
245
|
-
s && l.append("id_token_hint", s), o && l.append("state", o),
|
|
245
|
+
s && l.append("id_token_hint", s), o && l.append("state", o), c && l.append("logout_hint", c), window.location.replace(`${r.logoutEndpoint}?${l.toString()}`);
|
|
246
246
|
}
|
|
247
247
|
function Qt(r) {
|
|
248
248
|
const e = r.get("state"), t = sessionStorage.getItem(_e);
|
|
@@ -252,7 +252,7 @@ function Qt(r) {
|
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
254
|
function Z(r, e, t) {
|
|
255
|
-
const s = t === "session" ? sessionStorage : localStorage, [o,
|
|
255
|
+
const s = t === "session" ? sessionStorage : localStorage, [o, c] = f(() => {
|
|
256
256
|
const i = s.getItem(r);
|
|
257
257
|
try {
|
|
258
258
|
return i ? JSON.parse(i) : e;
|
|
@@ -265,19 +265,19 @@ Error: ${u.message}`
|
|
|
265
265
|
}
|
|
266
266
|
}), l = (i) => {
|
|
267
267
|
if (i === void 0) {
|
|
268
|
-
|
|
268
|
+
c(i), s.removeItem(r);
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
try {
|
|
272
272
|
const u = i instanceof Function ? i(o) : i;
|
|
273
|
-
|
|
273
|
+
c(u), s.setItem(r, JSON.stringify(u));
|
|
274
274
|
} catch {
|
|
275
275
|
console.log(`Falha ao armazenar valor '${i}' para chave '${r}'`);
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
278
|
return z(() => {
|
|
279
279
|
const i = (u) => {
|
|
280
|
-
u.storageArea === s && u.key === r &&
|
|
280
|
+
u.storageArea === s && u.key === r && c(JSON.parse(u.newValue ?? ""));
|
|
281
281
|
};
|
|
282
282
|
return window.addEventListener("storage", i, !1), () => window.removeEventListener("storage", i, !1);
|
|
283
283
|
}), [o, l];
|
|
@@ -295,7 +295,7 @@ function Zt(r) {
|
|
|
295
295
|
clearURL: t = !0,
|
|
296
296
|
decodeToken: s = !0,
|
|
297
297
|
scope: o = void 0,
|
|
298
|
-
preLogin:
|
|
298
|
+
preLogin: c = () => null,
|
|
299
299
|
postLogin: l = () => null,
|
|
300
300
|
onRefreshTokenExpire: i = void 0,
|
|
301
301
|
storage: u = "local"
|
|
@@ -305,7 +305,7 @@ function Zt(r) {
|
|
|
305
305
|
clearURL: t,
|
|
306
306
|
decodeToken: s,
|
|
307
307
|
scope: o,
|
|
308
|
-
preLogin:
|
|
308
|
+
preLogin: c,
|
|
309
309
|
postLogin: l,
|
|
310
310
|
onRefreshTokenExpire: i,
|
|
311
311
|
storage: u
|
|
@@ -379,7 +379,7 @@ const ge = (r) => {
|
|
|
379
379
|
"ROCP_refreshToken",
|
|
380
380
|
void 0,
|
|
381
381
|
t.storage
|
|
382
|
-
), [
|
|
382
|
+
), [c, l] = Z(
|
|
383
383
|
"ROCP_refreshTokenExpire",
|
|
384
384
|
oe(2 * ne),
|
|
385
385
|
t.storage
|
|
@@ -424,13 +424,13 @@ const ge = (r) => {
|
|
|
424
424
|
l(oe(w)), C(p.id_token);
|
|
425
425
|
try {
|
|
426
426
|
p.id_token && N(ge(p.id_token));
|
|
427
|
-
} catch (
|
|
428
|
-
console.warn(`Falha ao decodificar idToken: ${
|
|
427
|
+
} catch (a) {
|
|
428
|
+
console.warn(`Falha ao decodificar idToken: ${a.message}`);
|
|
429
429
|
}
|
|
430
430
|
try {
|
|
431
431
|
t.decodeToken && O(ge(p.access_token));
|
|
432
|
-
} catch (
|
|
433
|
-
console.warn(`Falha ao decodificar o token de acesso: ${
|
|
432
|
+
} catch (a) {
|
|
433
|
+
console.warn(`Falha ao decodificar o token de acesso: ${a.message}`);
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
function Y(p = !1) {
|
|
@@ -438,7 +438,7 @@ const ge = (r) => {
|
|
|
438
438
|
}
|
|
439
439
|
function $(p = !1) {
|
|
440
440
|
if (i && He(m) && !(x && !p)) {
|
|
441
|
-
if (He(
|
|
441
|
+
if (He(c))
|
|
442
442
|
return Y(p);
|
|
443
443
|
if (s) {
|
|
444
444
|
U(!0), Yt({ config: t, refreshToken: s }).then((n) => H(n)).catch((n) => {
|
|
@@ -458,7 +458,7 @@ const ge = (r) => {
|
|
|
458
458
|
);
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
z(() => (P = setInterval(() => $(), 1e4), () => clearInterval(P)), [i, s,
|
|
461
|
+
z(() => (P = setInterval(() => $(), 1e4), () => clearInterval(P)), [i, s, c, m]);
|
|
462
462
|
const X = Ke(!1);
|
|
463
463
|
return z(() => {
|
|
464
464
|
if (E) {
|
|
@@ -633,8 +633,8 @@ function Ur() {
|
|
|
633
633
|
return V.getInstance();
|
|
634
634
|
}
|
|
635
635
|
var ae = /* @__PURE__ */ ((r) => (r.USER = "user", r.PROFILE = "profile", r.GROUP = "group", r))(ae || {}), or = Object.defineProperty, v = (r, e, t, s) => {
|
|
636
|
-
for (var o = void 0,
|
|
637
|
-
(l = r[
|
|
636
|
+
for (var o = void 0, c = r.length - 1, l; c >= 0; c--)
|
|
637
|
+
(l = r[c]) && (o = l(e, t, o) || o);
|
|
638
638
|
return o && or(e, t, o), o;
|
|
639
639
|
}, nr = /* @__PURE__ */ ((r) => (r.VIEW = "VIEW", r.API = "API", r))(nr || {});
|
|
640
640
|
const it = class at {
|
|
@@ -1113,12 +1113,12 @@ class yt extends ce {
|
|
|
1113
1113
|
return e.isNovoToken;
|
|
1114
1114
|
}
|
|
1115
1115
|
async create(e, t, s, o) {
|
|
1116
|
-
const
|
|
1116
|
+
const c = await this.client.post(
|
|
1117
1117
|
`${this.getEndpoint()}/create?email=${e}&expirationDate=${t}&name=${s}&description=${o}`,
|
|
1118
1118
|
void 0,
|
|
1119
1119
|
this.configureHeaders()
|
|
1120
1120
|
);
|
|
1121
|
-
return this.transform(
|
|
1121
|
+
return this.transform(c);
|
|
1122
1122
|
}
|
|
1123
1123
|
async revoke(e) {
|
|
1124
1124
|
await this.client.post(
|
|
@@ -1229,7 +1229,7 @@ function Dr({
|
|
|
1229
1229
|
onClickForgotPassword: t,
|
|
1230
1230
|
loginLabel: s = "Email",
|
|
1231
1231
|
loginPlaceholder: o,
|
|
1232
|
-
afterInputs:
|
|
1232
|
+
afterInputs: c,
|
|
1233
1233
|
showMockUsersSelector: l = !1,
|
|
1234
1234
|
mockUsers: i = [],
|
|
1235
1235
|
mockUsersGroupMap: u,
|
|
@@ -1260,21 +1260,21 @@ function Dr({
|
|
|
1260
1260
|
value: g.email,
|
|
1261
1261
|
label: g.email
|
|
1262
1262
|
}));
|
|
1263
|
-
const
|
|
1263
|
+
const a = i.reduce((g, T) => {
|
|
1264
1264
|
const j = u[T.type];
|
|
1265
1265
|
return j && (g[j] || (g[j] = []), g[j].push({
|
|
1266
1266
|
value: T.email,
|
|
1267
1267
|
label: T.email
|
|
1268
1268
|
})), g;
|
|
1269
1269
|
}, {});
|
|
1270
|
-
return Object.entries(
|
|
1270
|
+
return Object.entries(a).map(([g, T]) => ({
|
|
1271
1271
|
group: g,
|
|
1272
1272
|
items: T
|
|
1273
1273
|
}));
|
|
1274
1274
|
}, n = () => {
|
|
1275
1275
|
if (H) {
|
|
1276
|
-
const
|
|
1277
|
-
|
|
1276
|
+
const a = i.find((g) => g.email === H);
|
|
1277
|
+
a && (N(a.email), A(a.password), $());
|
|
1278
1278
|
}
|
|
1279
1279
|
}, w = {
|
|
1280
1280
|
withBorder: !0,
|
|
@@ -1315,7 +1315,7 @@ function Dr({
|
|
|
1315
1315
|
placeholder: "Selecione um usuário mock",
|
|
1316
1316
|
data: p(),
|
|
1317
1317
|
value: H,
|
|
1318
|
-
onChange: Y,
|
|
1318
|
+
onChange: (a) => Y(a ?? ""),
|
|
1319
1319
|
searchable: !0,
|
|
1320
1320
|
clearable: !0,
|
|
1321
1321
|
style: { flexGrow: 1 }
|
|
@@ -1343,8 +1343,8 @@ function Dr({
|
|
|
1343
1343
|
rightSection: C ? /* @__PURE__ */ d(Xe, { size: "xs" }) : null,
|
|
1344
1344
|
value: D || "",
|
|
1345
1345
|
required: !0,
|
|
1346
|
-
onChange: (
|
|
1347
|
-
N(
|
|
1346
|
+
onChange: (a) => {
|
|
1347
|
+
N(a.currentTarget.value), b?.(a.currentTarget.value), $();
|
|
1348
1348
|
}
|
|
1349
1349
|
}
|
|
1350
1350
|
),
|
|
@@ -1353,8 +1353,8 @@ function Dr({
|
|
|
1353
1353
|
{
|
|
1354
1354
|
label: S().t("archbase:Password"),
|
|
1355
1355
|
placeholder: S().t("archbase:Sua senha"),
|
|
1356
|
-
onChange: (
|
|
1357
|
-
A(
|
|
1356
|
+
onChange: (a) => {
|
|
1357
|
+
A(a.currentTarget.value), $();
|
|
1358
1358
|
},
|
|
1359
1359
|
value: k || "",
|
|
1360
1360
|
required: !0,
|
|
@@ -1367,8 +1367,8 @@ function Dr({
|
|
|
1367
1367
|
{
|
|
1368
1368
|
label: S().t("archbase:Lembre-me"),
|
|
1369
1369
|
checked: P,
|
|
1370
|
-
onChange: (
|
|
1371
|
-
const g =
|
|
1370
|
+
onChange: (a) => {
|
|
1371
|
+
const g = a.currentTarget.checked;
|
|
1372
1372
|
W(g), g || O();
|
|
1373
1373
|
}
|
|
1374
1374
|
}
|
|
@@ -1386,7 +1386,7 @@ function Dr({
|
|
|
1386
1386
|
}
|
|
1387
1387
|
)
|
|
1388
1388
|
] }),
|
|
1389
|
-
m?.afterInputs ||
|
|
1389
|
+
m?.afterInputs || c,
|
|
1390
1390
|
/* @__PURE__ */ d(
|
|
1391
1391
|
ie,
|
|
1392
1392
|
{
|
|
@@ -1410,18 +1410,18 @@ const cr = {
|
|
|
1410
1410
|
padding: 30,
|
|
1411
1411
|
marginTop: 30
|
|
1412
1412
|
};
|
|
1413
|
-
function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClickBackToLogin: s, validatePassword: o, validateToken:
|
|
1413
|
+
function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClickBackToLogin: s, validatePassword: o, validateToken: c, initialEmail: l = "", description: i, style: u }) {
|
|
1414
1414
|
const m = Qe(), b = Ut(), { colorScheme: h } = Lt(), [C, E] = f(r ?? ""), [y, x] = f(l), [U, _] = f(""), [O, D] = f(""), [N, k] = f(""), [A, P] = f(!1), [W, L] = f(""), [B, H] = f(""), [Y, $] = f(""), [X, p] = f("");
|
|
1415
|
-
async function n(
|
|
1416
|
-
|
|
1415
|
+
async function n(a) {
|
|
1416
|
+
a && (_t(a) ? await e(a).then(() => {
|
|
1417
1417
|
We.showSuccess(`${S().t("archbase:Um e-mail com instruções para redefinir sua senha foi enviado. Verifique sua caixa de entrada.")}`), P(!0);
|
|
1418
1418
|
}).catch(() => {
|
|
1419
1419
|
}) : L(`${S().t("archbase:Email inválido")}`));
|
|
1420
1420
|
}
|
|
1421
|
-
async function w(
|
|
1422
|
-
if (
|
|
1421
|
+
async function w(a, g, T, j) {
|
|
1422
|
+
if (a && g && T) {
|
|
1423
1423
|
let xe = "", ke = "", Fe = "";
|
|
1424
|
-
|
|
1424
|
+
c && (xe = c(), $(xe)), o && (ke = o(), $(ke)), T !== j && (Fe = `${S().t("archbase:A nova senha e a confirmação devem ser iguais.")}`, p(Fe)), !ke && !xe && await t(a, g, T).then(() => {
|
|
1425
1425
|
We.showSuccess(`${S().t("archbase:Senha redefinida com sucesso.")}`), s(), P(!1);
|
|
1426
1426
|
}).catch(() => {
|
|
1427
1427
|
E(r || `${S().t("archbase:Erro ao redefinir senha.")}`);
|
|
@@ -1464,8 +1464,8 @@ function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClick
|
|
|
1464
1464
|
placeholder: `${S().t("archbase:Código enviado no seu e-mail")}`,
|
|
1465
1465
|
value: U || "",
|
|
1466
1466
|
required: !0,
|
|
1467
|
-
onChange: (
|
|
1468
|
-
_(
|
|
1467
|
+
onChange: (a) => {
|
|
1468
|
+
_(a.currentTarget.value), H("");
|
|
1469
1469
|
},
|
|
1470
1470
|
error: B
|
|
1471
1471
|
}
|
|
@@ -1475,8 +1475,8 @@ function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClick
|
|
|
1475
1475
|
{
|
|
1476
1476
|
label: S().t("archbase:Nova senha"),
|
|
1477
1477
|
placeholder: S().t("archbase:Nova senha"),
|
|
1478
|
-
onChange: (
|
|
1479
|
-
D(
|
|
1478
|
+
onChange: (a) => {
|
|
1479
|
+
D(a.currentTarget.value), $(""), p("");
|
|
1480
1480
|
},
|
|
1481
1481
|
value: O,
|
|
1482
1482
|
required: !0,
|
|
@@ -1488,8 +1488,8 @@ function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClick
|
|
|
1488
1488
|
{
|
|
1489
1489
|
label: S().t("archbase:Confirmar senha"),
|
|
1490
1490
|
placeholder: S().t("archbase:Confirmar senha"),
|
|
1491
|
-
onChange: (
|
|
1492
|
-
k(
|
|
1491
|
+
onChange: (a) => {
|
|
1492
|
+
k(a.currentTarget.value), p("");
|
|
1493
1493
|
},
|
|
1494
1494
|
value: N || "",
|
|
1495
1495
|
required: !0,
|
|
@@ -1539,8 +1539,8 @@ function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClick
|
|
|
1539
1539
|
placeholder: `${S().t("archbase:usuario@email.com")}`,
|
|
1540
1540
|
value: y || "",
|
|
1541
1541
|
required: !0,
|
|
1542
|
-
onChange: (
|
|
1543
|
-
x(
|
|
1542
|
+
onChange: (a) => {
|
|
1543
|
+
x(a.currentTarget.value), L("");
|
|
1544
1544
|
},
|
|
1545
1545
|
error: W
|
|
1546
1546
|
}
|
|
@@ -1572,18 +1572,18 @@ function Rr({ error: r, onSendResetPasswordEmail: e, onResetPassword: t, onClick
|
|
|
1572
1572
|
);
|
|
1573
1573
|
}
|
|
1574
1574
|
const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourceName: r, resourceDescription: e, enableSecurity: t = !0 }) => {
|
|
1575
|
-
const s = qe(At), o = lr(),
|
|
1575
|
+
const s = qe(At), o = lr(), c = o?.isAdmin ?? !1, l = o?.id, i = Ke(l), u = Je(() => {
|
|
1576
1576
|
if (!t)
|
|
1577
1577
|
return null;
|
|
1578
1578
|
const m = l ? `${r}_${l}` : r;
|
|
1579
1579
|
if (s && s.existsValue(m)) {
|
|
1580
1580
|
const h = s.getValue(m);
|
|
1581
|
-
if (h && h.isAdmin ===
|
|
1581
|
+
if (h && h.isAdmin === c)
|
|
1582
1582
|
return h;
|
|
1583
1583
|
}
|
|
1584
|
-
const b = new nt(r, e,
|
|
1584
|
+
const b = new nt(r, e, c);
|
|
1585
1585
|
return s && l && s.setValue(m, b), b;
|
|
1586
|
-
}, [t, r, e,
|
|
1586
|
+
}, [t, r, e, c, l]);
|
|
1587
1587
|
return z(() => {
|
|
1588
1588
|
i.current = l;
|
|
1589
1589
|
}, [l]), { securityManager: u };
|
|
@@ -1597,7 +1597,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1597
1597
|
(n) => n.get(G.TokenManager)
|
|
1598
1598
|
), s = ve(
|
|
1599
1599
|
(n) => n.get(G.Authenticator)
|
|
1600
|
-
), [o,
|
|
1600
|
+
), [o, c] = f(null), [l, i] = f(!1), [u, m] = f(!0), [b, h] = f(!1), [C, E] = f(!1), [y, x] = f(""), [U, _] = f(""), [O, D] = f(null), N = qe(At), k = {
|
|
1601
1601
|
hasContextualLogin: typeof s.loginWithContext == "function",
|
|
1602
1602
|
hasFlexibleLogin: typeof s.loginFlexible == "function",
|
|
1603
1603
|
hasSocialLogin: typeof s.loginSocial == "function",
|
|
@@ -1607,27 +1607,27 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1607
1607
|
z(() => {
|
|
1608
1608
|
const n = t.getUsername();
|
|
1609
1609
|
if (n && n != "" && _(n), k.hasContextSupport && t.getContext) {
|
|
1610
|
-
const
|
|
1611
|
-
if (
|
|
1610
|
+
const a = t.getContext();
|
|
1611
|
+
if (a)
|
|
1612
1612
|
try {
|
|
1613
|
-
const g = typeof
|
|
1613
|
+
const g = typeof a == "string" ? JSON.parse(a) : a;
|
|
1614
1614
|
D(g);
|
|
1615
1615
|
} catch (g) {
|
|
1616
1616
|
console.warn("Erro ao carregar contexto salvo:", g);
|
|
1617
1617
|
}
|
|
1618
1618
|
}
|
|
1619
1619
|
const w = t.getToken();
|
|
1620
|
-
w && (h(!0), x(""), E(!1),
|
|
1620
|
+
w && (h(!0), x(""), E(!1), c(w)), m(!1);
|
|
1621
1621
|
}, []);
|
|
1622
1622
|
const A = () => {
|
|
1623
1623
|
E(!1), x("");
|
|
1624
1624
|
}, P = (n) => {
|
|
1625
1625
|
i(!1), h(!1), t.clearToken(), n && t.clearUsernameAndPassword(), k.hasContextSupport && t.clearContext && t.clearContext(), _(""), D(null), x(""), E(!1), N.clearAllValues();
|
|
1626
|
-
}, W = async (n, w,
|
|
1626
|
+
}, W = async (n, w, a) => {
|
|
1627
1627
|
try {
|
|
1628
1628
|
i(!0), h(!1);
|
|
1629
1629
|
const g = await s.login(n, w);
|
|
1630
|
-
t.saveToken(g),
|
|
1630
|
+
t.saveToken(g), a && t.saveUsernameAndPassword(n, w), t.saveUsername(n), _(n), c(g), i(!1), h(!0);
|
|
1631
1631
|
} catch (g) {
|
|
1632
1632
|
i(!1), h(!1), x(ee(g)), E(!0);
|
|
1633
1633
|
}
|
|
@@ -1636,40 +1636,40 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1636
1636
|
throw new Error("Login contextual não suportado por esta implementação do ArchbaseAuthenticator");
|
|
1637
1637
|
try {
|
|
1638
1638
|
i(!0), h(!1);
|
|
1639
|
-
const { context:
|
|
1639
|
+
const { context: a, user: g, ...T } = await s.loginWithContext(n), j = {
|
|
1640
1640
|
scope: "",
|
|
1641
1641
|
ext_expires_in: T.expires_in,
|
|
1642
1642
|
...T
|
|
1643
1643
|
};
|
|
1644
|
-
t.saveToken(j), w ? t.saveUsernameAndPassword(n.email, n.password) : t.clearUsernameAndPassword(), t.saveUsername(n.email), k.hasContextSupport && t.saveContext &&
|
|
1645
|
-
} catch (
|
|
1646
|
-
throw i(!1), h(!1), x(ee(
|
|
1644
|
+
t.saveToken(j), w ? t.saveUsernameAndPassword(n.email, n.password) : t.clearUsernameAndPassword(), t.saveUsername(n.email), k.hasContextSupport && t.saveContext && a && (t.saveContext(JSON.stringify(a)), D(a)), _(n.email), c(j), i(!1), h(!0);
|
|
1645
|
+
} catch (a) {
|
|
1646
|
+
throw i(!1), h(!1), x(ee(a)), E(!0), a;
|
|
1647
1647
|
}
|
|
1648
1648
|
}, B = async (n, w = !1) => {
|
|
1649
1649
|
if (!k.hasFlexibleLogin || !s.loginFlexible)
|
|
1650
1650
|
throw new Error("Login flexível não suportado por esta implementação do ArchbaseAuthenticator");
|
|
1651
1651
|
try {
|
|
1652
1652
|
i(!0), h(!1);
|
|
1653
|
-
const { context:
|
|
1653
|
+
const { context: a, user: g, ...T } = await s.loginFlexible(n), j = {
|
|
1654
1654
|
scope: "",
|
|
1655
1655
|
ext_expires_in: T.expires_in,
|
|
1656
1656
|
...T
|
|
1657
1657
|
};
|
|
1658
|
-
t.saveToken(j), w && t.saveUsernameAndPassword(n.identifier, n.password), t.saveUsername(g.email || n.identifier), k.hasContextSupport && t.saveContext &&
|
|
1659
|
-
} catch (
|
|
1660
|
-
throw i(!1), h(!1), x(ee(
|
|
1658
|
+
t.saveToken(j), w && t.saveUsernameAndPassword(n.identifier, n.password), t.saveUsername(g.email || n.identifier), k.hasContextSupport && t.saveContext && a && (t.saveContext(JSON.stringify(a)), D(a)), _(g.email || n.identifier), c(j), i(!1), h(!0);
|
|
1659
|
+
} catch (a) {
|
|
1660
|
+
throw i(!1), h(!1), x(ee(a)), E(!0), a;
|
|
1661
1661
|
}
|
|
1662
1662
|
}, H = async (n) => {
|
|
1663
1663
|
if (!k.hasSocialLogin || !s.loginSocial)
|
|
1664
1664
|
throw new Error("Login social não suportado por esta implementação do ArchbaseAuthenticator");
|
|
1665
1665
|
try {
|
|
1666
1666
|
i(!0), h(!1);
|
|
1667
|
-
const { context: w, user:
|
|
1667
|
+
const { context: w, user: a, ...g } = await s.loginSocial(n), T = {
|
|
1668
1668
|
scope: "",
|
|
1669
1669
|
ext_expires_in: g.expires_in,
|
|
1670
1670
|
...g
|
|
1671
1671
|
};
|
|
1672
|
-
t.saveToken(T), t.saveUsername(
|
|
1672
|
+
t.saveToken(T), t.saveUsername(a.email), k.hasContextSupport && t.saveContext && w && (t.saveContext(JSON.stringify(w)), D(w)), _(a.email), c(T), i(!1), h(!0);
|
|
1673
1673
|
} catch (w) {
|
|
1674
1674
|
throw i(!1), h(!1), x(ee(w)), E(!0), w;
|
|
1675
1675
|
}
|
|
@@ -1696,7 +1696,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1696
1696
|
if (o)
|
|
1697
1697
|
try {
|
|
1698
1698
|
const n = await s.refreshToken(o?.refresh_token);
|
|
1699
|
-
t.saveToken(n),
|
|
1699
|
+
t.saveToken(n), c(n);
|
|
1700
1700
|
} catch (n) {
|
|
1701
1701
|
console.error("Erro ao renovar o token:", n), P();
|
|
1702
1702
|
}
|
|
@@ -1776,7 +1776,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1776
1776
|
user: e,
|
|
1777
1777
|
onError: t
|
|
1778
1778
|
}) => {
|
|
1779
|
-
const [s, o] = f(!1), [
|
|
1779
|
+
const [s, o] = f(!1), [c, l] = f(null), [i] = f([]), u = e?.isAdministrator || !1, m = pe((y) => u ? !0 : i.includes(y), [i, u]), b = pe((y) => u ? !0 : y.some((x) => i.includes(x)), [i, u]), h = pe((y) => u ? !0 : y.every((x) => i.includes(x)), [i, u]), C = pe((y) => {
|
|
1780
1780
|
l(y), y && t && t(y);
|
|
1781
1781
|
}, [t]), E = {
|
|
1782
1782
|
user: e,
|
|
@@ -1785,7 +1785,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1785
1785
|
hasAnyGlobalPermission: b,
|
|
1786
1786
|
hasAllGlobalPermissions: h,
|
|
1787
1787
|
isAdmin: u,
|
|
1788
|
-
error:
|
|
1788
|
+
error: c,
|
|
1789
1789
|
setError: C
|
|
1790
1790
|
};
|
|
1791
1791
|
return /* @__PURE__ */ d($e.Provider, { value: E, children: r });
|
|
@@ -1795,7 +1795,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1795
1795
|
resourceDescription: t,
|
|
1796
1796
|
requiredPermissions: s = [],
|
|
1797
1797
|
fallbackComponent: o,
|
|
1798
|
-
loadingComponent:
|
|
1798
|
+
loadingComponent: c,
|
|
1799
1799
|
onSecurityReady: l,
|
|
1800
1800
|
onError: i
|
|
1801
1801
|
}) => {
|
|
@@ -1821,7 +1821,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1821
1821
|
}
|
|
1822
1822
|
})();
|
|
1823
1823
|
}, [e, t, m, b, l, i]), E)
|
|
1824
|
-
return
|
|
1824
|
+
return c ? /* @__PURE__ */ d(te, { children: c }) : /* @__PURE__ */ d(dr, {});
|
|
1825
1825
|
if (x)
|
|
1826
1826
|
return /* @__PURE__ */ d("div", { className: "archbase-security-error", children: /* @__PURE__ */ R("div", { children: [
|
|
1827
1827
|
"Erro ao carregar permissões: ",
|
|
@@ -1862,13 +1862,13 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1862
1862
|
throw new Error("useArchbaseViewSecurity deve ser usado dentro de um ArchbaseViewSecurityProvider");
|
|
1863
1863
|
return r;
|
|
1864
1864
|
}, $r = (r, e) => {
|
|
1865
|
-
const t = je(), { hasPermission: s, hasAnyPermission: o, hasAllPermissions:
|
|
1865
|
+
const t = je(), { hasPermission: s, hasAnyPermission: o, hasAllPermissions: c, registerAction: l, securityManager: i, isLoading: u, error: m } = t;
|
|
1866
1866
|
return Ge.useEffect(() => {
|
|
1867
1867
|
r && e && (l("create", `Criar ${e}`), l("edit", `Editar ${e}`), l("delete", `Deletar ${e}`), l("view", `Visualizar ${e}`), l("list", `Listar ${e}`));
|
|
1868
1868
|
}, [r, e, l]), {
|
|
1869
1869
|
hasPermission: s,
|
|
1870
1870
|
hasAnyPermission: o,
|
|
1871
|
-
hasAllPermissions:
|
|
1871
|
+
hasAllPermissions: c,
|
|
1872
1872
|
registerAction: l,
|
|
1873
1873
|
securityManager: i,
|
|
1874
1874
|
canCreate: s("create"),
|
|
@@ -1893,7 +1893,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1893
1893
|
requiredPermissions: t = [],
|
|
1894
1894
|
requireAll: s = !0,
|
|
1895
1895
|
actionDescription: o,
|
|
1896
|
-
fallback:
|
|
1896
|
+
fallback: c = null,
|
|
1897
1897
|
autoRegister: l = !0
|
|
1898
1898
|
}) => {
|
|
1899
1899
|
const { hasPermission: i, hasAnyPermission: u, hasAllPermissions: m, registerAction: b } = je();
|
|
@@ -1901,14 +1901,14 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1901
1901
|
l && e && o && b(e, o);
|
|
1902
1902
|
}, [e, o, l, b]);
|
|
1903
1903
|
let h = !1;
|
|
1904
|
-
return e ? h = i(e) : t.length > 0 ? h = s ? m(t) : u(t) : h = !0, h ? /* @__PURE__ */ d(te, { children: r }) : /* @__PURE__ */ d(te, { children:
|
|
1904
|
+
return e ? h = i(e) : t.length > 0 ? h = s ? m(t) : u(t) : h = !0, h ? /* @__PURE__ */ d(te, { children: r }) : /* @__PURE__ */ d(te, { children: c });
|
|
1905
1905
|
}, Fr = ({
|
|
1906
1906
|
actionName: r,
|
|
1907
1907
|
actionDescription: e,
|
|
1908
1908
|
children: t,
|
|
1909
1909
|
onClick: s,
|
|
1910
1910
|
disabled: o = !1,
|
|
1911
|
-
className:
|
|
1911
|
+
className: c = "",
|
|
1912
1912
|
style: l = {},
|
|
1913
1913
|
variant: i = "primary",
|
|
1914
1914
|
size: u = "medium",
|
|
@@ -1916,7 +1916,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1916
1916
|
}) => {
|
|
1917
1917
|
const b = () => {
|
|
1918
1918
|
const C = "archbase-secure-btn", E = `archbase-secure-btn--${i}`, y = `archbase-secure-btn--${u}`;
|
|
1919
|
-
return `${C} ${E} ${y} ${
|
|
1919
|
+
return `${C} ${E} ${y} ${c}`.trim();
|
|
1920
1920
|
}, h = () => {
|
|
1921
1921
|
const C = {
|
|
1922
1922
|
small: { padding: "4px 8px", fontSize: "12px" },
|
|
@@ -1965,7 +1965,7 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1965
1965
|
actionDescription: t,
|
|
1966
1966
|
showLabel: s = !0,
|
|
1967
1967
|
label: o,
|
|
1968
|
-
fallbackText:
|
|
1968
|
+
fallbackText: c = "Campo não disponível",
|
|
1969
1969
|
fallbackComponent: l
|
|
1970
1970
|
}) => e ? /* @__PURE__ */ d(
|
|
1971
1971
|
Et,
|
|
@@ -1984,19 +1984,19 @@ const lr = () => Dt().user, At = "archbaseSecurityManagerStore", Nr = ({ resourc
|
|
|
1984
1984
|
o,
|
|
1985
1985
|
": "
|
|
1986
1986
|
] }),
|
|
1987
|
-
|
|
1987
|
+
c
|
|
1988
1988
|
] }),
|
|
1989
1989
|
children: r
|
|
1990
1990
|
}
|
|
1991
1991
|
) : /* @__PURE__ */ d(te, { children: r });
|
|
1992
1992
|
function zr(r, e) {
|
|
1993
1993
|
return function(s) {
|
|
1994
|
-
const { resourceName: o, resourceDescription:
|
|
1994
|
+
const { resourceName: o, resourceDescription: c, requiredPermissions: l, fallbackComponent: i } = e;
|
|
1995
1995
|
return /* @__PURE__ */ d(
|
|
1996
1996
|
ur,
|
|
1997
1997
|
{
|
|
1998
1998
|
resourceName: o,
|
|
1999
|
-
resourceDescription:
|
|
1999
|
+
resourceDescription: c,
|
|
2000
2000
|
requiredPermissions: l,
|
|
2001
2001
|
fallbackComponent: i,
|
|
2002
2002
|
children: /* @__PURE__ */ d(r, { ...s })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archbase/security",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Security and authentication components for Archbase React",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"author": "Edson Martins",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@archbase/components": "
|
|
29
|
-
"@archbase/core": "
|
|
30
|
-
"@archbase/data": "
|
|
31
|
-
"@archbase/layout": "
|
|
28
|
+
"@archbase/components": "4.0.0",
|
|
29
|
+
"@archbase/core": "4.0.0",
|
|
30
|
+
"@archbase/data": "4.0.0",
|
|
31
|
+
"@archbase/layout": "4.0.0",
|
|
32
32
|
"crypto-js": "^4.1.1",
|
|
33
33
|
"i18next": "^25.3.1",
|
|
34
34
|
"inversify": "^6.0.1",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"vitest": "^2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mantine/core": "
|
|
57
|
-
"@mantine/dates": "
|
|
58
|
-
"@mantine/hooks": "
|
|
59
|
-
"@mantine/modals": "
|
|
60
|
-
"@mantine/notifications": "
|
|
56
|
+
"@mantine/core": "9.1.1",
|
|
57
|
+
"@mantine/dates": "9.1.1",
|
|
58
|
+
"@mantine/hooks": "9.1.1",
|
|
59
|
+
"@mantine/modals": "9.1.1",
|
|
60
|
+
"@mantine/notifications": "9.1.1",
|
|
61
61
|
"@tabler/icons-react": "^3.27.0",
|
|
62
62
|
"react": ">=18.0.0",
|
|
63
63
|
"react-dom": ">=18.0.0"
|