akeyless-client-commons 1.0.181 → 1.0.183
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/components/index.js +54 -35
- package/dist/components/index.mjs +45 -26
- package/dist/helpers/index.d.mts +15 -13
- package/dist/helpers/index.d.ts +15 -13
- package/dist/helpers/index.js +176 -153
- package/dist/helpers/index.mjs +163 -144
- package/dist/hooks/index.js +75 -56
- package/dist/hooks/index.mjs +66 -47
- package/package.json +2 -2
package/dist/helpers/index.mjs
CHANGED
|
@@ -280,73 +280,25 @@ var is_iccid = function(number) {
|
|
|
280
280
|
if (!number.startsWith("89")) return false;
|
|
281
281
|
return true;
|
|
282
282
|
};
|
|
283
|
-
// src/helpers/
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (startLat === endLat || startLng === endLng) {
|
|
289
|
-
return 0;
|
|
283
|
+
// src/helpers/permissions.ts
|
|
284
|
+
var checkUserPermissions = function(userPermissions, entity, permissions, mode2) {
|
|
285
|
+
var userValues = userPermissions[entity];
|
|
286
|
+
if (!userValues) {
|
|
287
|
+
return false;
|
|
290
288
|
}
|
|
291
|
-
if (
|
|
292
|
-
return
|
|
289
|
+
if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
290
|
+
return true;
|
|
293
291
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var endLngRad = endLng * Math.PI / 180;
|
|
298
|
-
var dLon = endLngRad - startLngRad;
|
|
299
|
-
var y = Math.sin(dLon) * Math.cos(endLatRad);
|
|
300
|
-
var x = Math.cos(startLatRad) * Math.sin(endLatRad) - Math.sin(startLatRad) * Math.cos(endLatRad) * Math.cos(dLon);
|
|
301
|
-
var bearing = Math.atan2(y, x) * 180 / Math.PI;
|
|
302
|
-
return (bearing + 360) % 360;
|
|
303
|
-
};
|
|
304
|
-
var renderOnce = function() {
|
|
305
|
-
return true;
|
|
306
|
-
};
|
|
307
|
-
var propsAreEqual = function(prevProps, nextProps) {
|
|
308
|
-
return isEqual(prevProps, nextProps);
|
|
309
|
-
};
|
|
310
|
-
var getUserCountryByIp = /*#__PURE__*/ function() {
|
|
311
|
-
var _ref = _async_to_generator(function() {
|
|
312
|
-
var response, error;
|
|
313
|
-
return _ts_generator(this, function(_state) {
|
|
314
|
-
switch(_state.label){
|
|
315
|
-
case 0:
|
|
316
|
-
_state.trys.push([
|
|
317
|
-
0,
|
|
318
|
-
2,
|
|
319
|
-
,
|
|
320
|
-
3
|
|
321
|
-
]);
|
|
322
|
-
return [
|
|
323
|
-
4,
|
|
324
|
-
axios.get("https://ipapi.co/json/")
|
|
325
|
-
];
|
|
326
|
-
case 1:
|
|
327
|
-
response = _state.sent();
|
|
328
|
-
return [
|
|
329
|
-
2,
|
|
330
|
-
(response.data.country_code || CountryOptions.IL).toLowerCase()
|
|
331
|
-
];
|
|
332
|
-
case 2:
|
|
333
|
-
error = _state.sent();
|
|
334
|
-
console.error("Error fetching Country:", error);
|
|
335
|
-
return [
|
|
336
|
-
2,
|
|
337
|
-
CountryOptions.IL
|
|
338
|
-
];
|
|
339
|
-
case 3:
|
|
340
|
-
return [
|
|
341
|
-
2
|
|
342
|
-
];
|
|
343
|
-
}
|
|
292
|
+
if (mode2 === "every") {
|
|
293
|
+
return permissions.every(function(permission) {
|
|
294
|
+
return userValues[permission];
|
|
344
295
|
});
|
|
296
|
+
}
|
|
297
|
+
return permissions.some(function(permission) {
|
|
298
|
+
return userValues[permission];
|
|
345
299
|
});
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
};
|
|
349
|
-
}();
|
|
300
|
+
};
|
|
301
|
+
checkUserPermissions({}, "dashboard", []);
|
|
350
302
|
var parsePermissions = function(object) {
|
|
351
303
|
if (!(object === null || object === void 0 ? void 0 : object.features)) {
|
|
352
304
|
return {};
|
|
@@ -445,82 +397,6 @@ var initializeUserPermissions = /*#__PURE__*/ function() {
|
|
|
445
397
|
return _ref.apply(this, arguments);
|
|
446
398
|
};
|
|
447
399
|
}();
|
|
448
|
-
var userNameFormat = function(user) {
|
|
449
|
-
return "".concat((user === null || user === void 0 ? void 0 : user.first_name) || "", " ").concat((user === null || user === void 0 ? void 0 : user.last_name) || "").trim();
|
|
450
|
-
};
|
|
451
|
-
var multiStringFormat = function(str1, str2, str3) {
|
|
452
|
-
return "".concat(str1, " ").concat(str2 || "", " ").concat(str3 || "").trim();
|
|
453
|
-
};
|
|
454
|
-
var getLocationUrl = function(lng, lat) {
|
|
455
|
-
return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
|
|
456
|
-
};
|
|
457
|
-
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
458
|
-
var _ref = {
|
|
459
|
-
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
|
|
460
|
-
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
|
|
461
|
-
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
462
|
-
var getFixedNumber = function() {
|
|
463
|
-
var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
464
|
-
var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
|
|
465
|
-
return String(sum_value);
|
|
466
|
-
};
|
|
467
|
-
var getAddressByGeo = /*#__PURE__*/ function() {
|
|
468
|
-
var _ref = _async_to_generator(function(param, currentLanguage) {
|
|
469
|
-
var lat, lng, language, apiKey, url, _response_data, response, error;
|
|
470
|
-
return _ts_generator(this, function(_state) {
|
|
471
|
-
switch(_state.label){
|
|
472
|
-
case 0:
|
|
473
|
-
lat = param.lat, lng = param.lng;
|
|
474
|
-
language = currentLanguage === LanguageOptions.He ? "iw" : "en";
|
|
475
|
-
apiKey = isNodeEnv ? process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY : import.meta.env.VITE_api_google_key;
|
|
476
|
-
url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=".concat(lat, ",").concat(lng, "&key=").concat(apiKey, "&language=").concat(language);
|
|
477
|
-
_state.label = 1;
|
|
478
|
-
case 1:
|
|
479
|
-
_state.trys.push([
|
|
480
|
-
1,
|
|
481
|
-
3,
|
|
482
|
-
,
|
|
483
|
-
4
|
|
484
|
-
]);
|
|
485
|
-
return [
|
|
486
|
-
4,
|
|
487
|
-
axios.get(url)
|
|
488
|
-
];
|
|
489
|
-
case 2:
|
|
490
|
-
response = _state.sent();
|
|
491
|
-
if (response === null || response === void 0 ? void 0 : (_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.results[0]) {
|
|
492
|
-
return [
|
|
493
|
-
2,
|
|
494
|
-
response.data.results[0].formatted_address.slice(0, 35)
|
|
495
|
-
];
|
|
496
|
-
} else {
|
|
497
|
-
return [
|
|
498
|
-
2,
|
|
499
|
-
"address not found"
|
|
500
|
-
];
|
|
501
|
-
}
|
|
502
|
-
return [
|
|
503
|
-
3,
|
|
504
|
-
4
|
|
505
|
-
];
|
|
506
|
-
case 3:
|
|
507
|
-
error = _state.sent();
|
|
508
|
-
console.error("getAddressByGeo error:", error);
|
|
509
|
-
return [
|
|
510
|
-
3,
|
|
511
|
-
4
|
|
512
|
-
];
|
|
513
|
-
case 4:
|
|
514
|
-
return [
|
|
515
|
-
2
|
|
516
|
-
];
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
});
|
|
520
|
-
return function getAddressByGeo(_, currentLanguage) {
|
|
521
|
-
return _ref.apply(this, arguments);
|
|
522
|
-
};
|
|
523
|
-
}();
|
|
524
400
|
// src/helpers/firebase.ts
|
|
525
401
|
var initApp = function() {
|
|
526
402
|
var isNodeEnv2 = typeof process !== "undefined" && process.env;
|
|
@@ -940,7 +816,7 @@ var delete_document = /*#__PURE__*/ function() {
|
|
|
940
816
|
return _ref.apply(this, arguments);
|
|
941
817
|
};
|
|
942
818
|
}();
|
|
943
|
-
var
|
|
819
|
+
var query_document = /*#__PURE__*/ function() {
|
|
944
820
|
var _ref = _async_to_generator(function(collection_path, field_name, operator, value) {
|
|
945
821
|
var ignore_log, q, query_snapshot, documents, error;
|
|
946
822
|
var _arguments = arguments;
|
|
@@ -989,7 +865,7 @@ var query_document2 = /*#__PURE__*/ function() {
|
|
|
989
865
|
}
|
|
990
866
|
});
|
|
991
867
|
});
|
|
992
|
-
return function
|
|
868
|
+
return function query_document(collection_path, field_name, operator, value) {
|
|
993
869
|
return _ref.apply(this, arguments);
|
|
994
870
|
};
|
|
995
871
|
}();
|
|
@@ -1364,7 +1240,7 @@ var getUserByPhone = /*#__PURE__*/ function() {
|
|
|
1364
1240
|
];
|
|
1365
1241
|
return [
|
|
1366
1242
|
4,
|
|
1367
|
-
|
|
1243
|
+
query_document("nx-users", "phone_number", "in", phones, true)
|
|
1368
1244
|
];
|
|
1369
1245
|
case 1:
|
|
1370
1246
|
return [
|
|
@@ -1385,7 +1261,7 @@ var getUserByEmail = /*#__PURE__*/ function() {
|
|
|
1385
1261
|
case 0:
|
|
1386
1262
|
return [
|
|
1387
1263
|
4,
|
|
1388
|
-
|
|
1264
|
+
query_document("nx-users", "email", "==", email, true)
|
|
1389
1265
|
];
|
|
1390
1266
|
case 1:
|
|
1391
1267
|
return [
|
|
@@ -1533,6 +1409,149 @@ var validateUserStatusAndPermissions = function(user, app2) {
|
|
|
1533
1409
|
}
|
|
1534
1410
|
return userPermissions;
|
|
1535
1411
|
};
|
|
1412
|
+
// src/helpers/global.ts
|
|
1413
|
+
import { CountryOptions, LanguageOptions } from "akeyless-types-commons";
|
|
1414
|
+
import axios from "axios";
|
|
1415
|
+
import { isEqual } from "lodash";
|
|
1416
|
+
var calculateBearing = function(startLat, startLng, endLat, endLng) {
|
|
1417
|
+
if (startLat === endLat || startLng === endLng) {
|
|
1418
|
+
return 0;
|
|
1419
|
+
}
|
|
1420
|
+
if (startLat === void 0 || startLng === void 0 || endLat === void 0 || endLng === void 0) {
|
|
1421
|
+
return 0;
|
|
1422
|
+
}
|
|
1423
|
+
var startLatRad = startLat * Math.PI / 180;
|
|
1424
|
+
var startLngRad = startLng * Math.PI / 180;
|
|
1425
|
+
var endLatRad = endLat * Math.PI / 180;
|
|
1426
|
+
var endLngRad = endLng * Math.PI / 180;
|
|
1427
|
+
var dLon = endLngRad - startLngRad;
|
|
1428
|
+
var y = Math.sin(dLon) * Math.cos(endLatRad);
|
|
1429
|
+
var x = Math.cos(startLatRad) * Math.sin(endLatRad) - Math.sin(startLatRad) * Math.cos(endLatRad) * Math.cos(dLon);
|
|
1430
|
+
var bearing = Math.atan2(y, x) * 180 / Math.PI;
|
|
1431
|
+
return (bearing + 360) % 360;
|
|
1432
|
+
};
|
|
1433
|
+
var renderOnce = function() {
|
|
1434
|
+
return true;
|
|
1435
|
+
};
|
|
1436
|
+
var propsAreEqual = function(prevProps, nextProps) {
|
|
1437
|
+
return isEqual(prevProps, nextProps);
|
|
1438
|
+
};
|
|
1439
|
+
var getUserCountryByIp = /*#__PURE__*/ function() {
|
|
1440
|
+
var _ref = _async_to_generator(function() {
|
|
1441
|
+
var response, error;
|
|
1442
|
+
return _ts_generator(this, function(_state) {
|
|
1443
|
+
switch(_state.label){
|
|
1444
|
+
case 0:
|
|
1445
|
+
_state.trys.push([
|
|
1446
|
+
0,
|
|
1447
|
+
2,
|
|
1448
|
+
,
|
|
1449
|
+
3
|
|
1450
|
+
]);
|
|
1451
|
+
return [
|
|
1452
|
+
4,
|
|
1453
|
+
axios.get("https://ipapi.co/json/")
|
|
1454
|
+
];
|
|
1455
|
+
case 1:
|
|
1456
|
+
response = _state.sent();
|
|
1457
|
+
return [
|
|
1458
|
+
2,
|
|
1459
|
+
(response.data.country_code || CountryOptions.IL).toLowerCase()
|
|
1460
|
+
];
|
|
1461
|
+
case 2:
|
|
1462
|
+
error = _state.sent();
|
|
1463
|
+
console.error("Error fetching Country:", error);
|
|
1464
|
+
return [
|
|
1465
|
+
2,
|
|
1466
|
+
CountryOptions.IL
|
|
1467
|
+
];
|
|
1468
|
+
case 3:
|
|
1469
|
+
return [
|
|
1470
|
+
2
|
|
1471
|
+
];
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
});
|
|
1475
|
+
return function getUserCountryByIp() {
|
|
1476
|
+
return _ref.apply(this, arguments);
|
|
1477
|
+
};
|
|
1478
|
+
}();
|
|
1479
|
+
var userNameFormat = function(user) {
|
|
1480
|
+
return "".concat((user === null || user === void 0 ? void 0 : user.first_name) || "", " ").concat((user === null || user === void 0 ? void 0 : user.last_name) || "").trim();
|
|
1481
|
+
};
|
|
1482
|
+
var multiStringFormat = function(str1, str2, str3) {
|
|
1483
|
+
return "".concat(str1, " ").concat(str2 || "", " ").concat(str3 || "").trim();
|
|
1484
|
+
};
|
|
1485
|
+
var getLocationUrl = function(lng, lat) {
|
|
1486
|
+
return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
|
|
1487
|
+
};
|
|
1488
|
+
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
1489
|
+
var _ref = {
|
|
1490
|
+
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
|
|
1491
|
+
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
|
|
1492
|
+
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
1493
|
+
var getFixedNumber = function() {
|
|
1494
|
+
var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
1495
|
+
var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
|
|
1496
|
+
return String(sum_value);
|
|
1497
|
+
};
|
|
1498
|
+
var getAddressByGeo = /*#__PURE__*/ function() {
|
|
1499
|
+
var _ref = _async_to_generator(function(param, currentLanguage) {
|
|
1500
|
+
var lat, lng, language, apiKey, url, _response_data, response, error;
|
|
1501
|
+
return _ts_generator(this, function(_state) {
|
|
1502
|
+
switch(_state.label){
|
|
1503
|
+
case 0:
|
|
1504
|
+
lat = param.lat, lng = param.lng;
|
|
1505
|
+
language = currentLanguage === LanguageOptions.He ? "iw" : "en";
|
|
1506
|
+
apiKey = isNodeEnv ? process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY : import.meta.env.VITE_api_google_key;
|
|
1507
|
+
url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=".concat(lat, ",").concat(lng, "&key=").concat(apiKey, "&language=").concat(language);
|
|
1508
|
+
_state.label = 1;
|
|
1509
|
+
case 1:
|
|
1510
|
+
_state.trys.push([
|
|
1511
|
+
1,
|
|
1512
|
+
3,
|
|
1513
|
+
,
|
|
1514
|
+
4
|
|
1515
|
+
]);
|
|
1516
|
+
return [
|
|
1517
|
+
4,
|
|
1518
|
+
axios.get(url)
|
|
1519
|
+
];
|
|
1520
|
+
case 2:
|
|
1521
|
+
response = _state.sent();
|
|
1522
|
+
if (response === null || response === void 0 ? void 0 : (_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.results[0]) {
|
|
1523
|
+
return [
|
|
1524
|
+
2,
|
|
1525
|
+
response.data.results[0].formatted_address.slice(0, 35)
|
|
1526
|
+
];
|
|
1527
|
+
} else {
|
|
1528
|
+
return [
|
|
1529
|
+
2,
|
|
1530
|
+
"address not found"
|
|
1531
|
+
];
|
|
1532
|
+
}
|
|
1533
|
+
return [
|
|
1534
|
+
3,
|
|
1535
|
+
4
|
|
1536
|
+
];
|
|
1537
|
+
case 3:
|
|
1538
|
+
error = _state.sent();
|
|
1539
|
+
console.error("getAddressByGeo error:", error);
|
|
1540
|
+
return [
|
|
1541
|
+
3,
|
|
1542
|
+
4
|
|
1543
|
+
];
|
|
1544
|
+
case 4:
|
|
1545
|
+
return [
|
|
1546
|
+
2
|
|
1547
|
+
];
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
});
|
|
1551
|
+
return function getAddressByGeo(_, currentLanguage) {
|
|
1552
|
+
return _ref.apply(this, arguments);
|
|
1553
|
+
};
|
|
1554
|
+
}();
|
|
1536
1555
|
// src/helpers/forms.ts
|
|
1537
1556
|
import XRegExp from "xregexp";
|
|
1538
1557
|
var textRegex = XRegExp("[^\\p{L}\\s-]", "gu");
|
|
@@ -1800,5 +1819,5 @@ var nx_api_call = /*#__PURE__*/ function() {
|
|
|
1800
1819
|
return _ref.apply(this, arguments);
|
|
1801
1820
|
};
|
|
1802
1821
|
}();
|
|
1803
|
-
export { addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterDomain, carsRegex, chartsRegex, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFixedNumber, getFormCheckboxValue, getFormElementValue, getLocationUrl, getUserByEmail, getUserByIdentifier, getUserByPhone, getUserCountryByIp, get_all_documents, get_document_by_id, get_international_phone_number, googleLoginProvider, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, numbersOnlyRegex, numbersRegex, nx_api_call, parseMultiSelectInput, parsePermissions, priceRegex, propsAreEqual,
|
|
1822
|
+
export { addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterDomain, carsRegex, chartsRegex, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFixedNumber, getFormCheckboxValue, getFormElementValue, getLocationUrl, getUserByEmail, getUserByIdentifier, getUserByPhone, getUserCountryByIp, get_all_documents, get_document_by_id, get_international_phone_number, googleLoginProvider, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, numbersOnlyRegex, numbersRegex, nx_api_call, parseMultiSelectInput, parsePermissions, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateUserStatusAndPermissions };
|
|
1804
1823
|
//# sourceMappingURL=index.mjs.map
|
package/dist/hooks/index.js
CHANGED
|
@@ -273,67 +273,36 @@ var import_firestore = require("firebase/firestore");
|
|
|
273
273
|
var import_react = require("react");
|
|
274
274
|
// src/helpers/phoneNumber.ts
|
|
275
275
|
var import_libphonenumber_js = require("libphonenumber-js");
|
|
276
|
-
// src/helpers/
|
|
277
|
-
var
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
0,
|
|
289
|
-
2,
|
|
290
|
-
,
|
|
291
|
-
3
|
|
292
|
-
]);
|
|
293
|
-
return [
|
|
294
|
-
4,
|
|
295
|
-
import_axios.default.get("https://ipapi.co/json/")
|
|
296
|
-
];
|
|
297
|
-
case 1:
|
|
298
|
-
response = _state.sent();
|
|
299
|
-
return [
|
|
300
|
-
2,
|
|
301
|
-
(response.data.country_code || import_akeyless_types_commons.CountryOptions.IL).toLowerCase()
|
|
302
|
-
];
|
|
303
|
-
case 2:
|
|
304
|
-
error = _state.sent();
|
|
305
|
-
console.error("Error fetching Country:", error);
|
|
306
|
-
return [
|
|
307
|
-
2,
|
|
308
|
-
import_akeyless_types_commons.CountryOptions.IL
|
|
309
|
-
];
|
|
310
|
-
case 3:
|
|
311
|
-
return [
|
|
312
|
-
2
|
|
313
|
-
];
|
|
314
|
-
}
|
|
276
|
+
// src/helpers/permissions.ts
|
|
277
|
+
var checkUserPermissions = function(userPermissions, entity, permissions, mode2) {
|
|
278
|
+
var userValues = userPermissions[entity];
|
|
279
|
+
if (!userValues) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
if (mode2 === "every") {
|
|
286
|
+
return permissions.every(function(permission) {
|
|
287
|
+
return userValues[permission];
|
|
315
288
|
});
|
|
289
|
+
}
|
|
290
|
+
return permissions.some(function(permission) {
|
|
291
|
+
return userValues[permission];
|
|
316
292
|
});
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
};
|
|
320
|
-
}();
|
|
321
|
-
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
322
|
-
var _ref = {
|
|
323
|
-
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import_meta.env.VITE_MODE,
|
|
324
|
-
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import_meta.env.VITE_is_local) === "true"
|
|
325
|
-
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
293
|
+
};
|
|
294
|
+
checkUserPermissions({}, "dashboard", []);
|
|
326
295
|
// src/helpers/firebase.ts
|
|
327
|
-
var
|
|
296
|
+
var import_meta = {};
|
|
328
297
|
var initApp = function() {
|
|
329
298
|
var isNodeEnv2 = typeof process !== "undefined" && process.env;
|
|
330
299
|
var firebaseConfig = {
|
|
331
|
-
apiKey: isNodeEnv2 ? process.env.NEXT_PUBLIC_API_KEY :
|
|
332
|
-
authDomain: isNodeEnv2 ? process.env.NEXT_PUBLIC_AUTH_DOMAIN :
|
|
333
|
-
projectId: isNodeEnv2 ? process.env.NEXT_PUBLIC_PROJECT_ID :
|
|
334
|
-
storageBucket: isNodeEnv2 ? process.env.NEXT_PUBLIC_STORAGE_BUCKET :
|
|
335
|
-
messagingSenderId: isNodeEnv2 ? process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID :
|
|
336
|
-
appId: isNodeEnv2 ? process.env.NEXT_PUBLIC_APP_ID :
|
|
300
|
+
apiKey: isNodeEnv2 ? process.env.NEXT_PUBLIC_API_KEY : import_meta.env.VITE_API_KEY,
|
|
301
|
+
authDomain: isNodeEnv2 ? process.env.NEXT_PUBLIC_AUTH_DOMAIN : import_meta.env.VITE_AUTH_DOMAIN,
|
|
302
|
+
projectId: isNodeEnv2 ? process.env.NEXT_PUBLIC_PROJECT_ID : import_meta.env.VITE_PROJECT_ID,
|
|
303
|
+
storageBucket: isNodeEnv2 ? process.env.NEXT_PUBLIC_STORAGE_BUCKET : import_meta.env.VITE_STORAGE_BUCKET,
|
|
304
|
+
messagingSenderId: isNodeEnv2 ? process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID : import_meta.env.VITE_MESSAGING_SENDER_ID,
|
|
305
|
+
appId: isNodeEnv2 ? process.env.NEXT_PUBLIC_APP_ID : import_meta.env.VITE_APP_ID
|
|
337
306
|
};
|
|
338
307
|
try {
|
|
339
308
|
var app2 = (0, import_app.initializeApp)(firebaseConfig);
|
|
@@ -342,7 +311,7 @@ var initApp = function() {
|
|
|
342
311
|
var db2 = (0, import_firestore.getFirestore)(app2);
|
|
343
312
|
var storage2 = (0, import_storage.getStorage)(app2);
|
|
344
313
|
var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
|
|
345
|
-
var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY :
|
|
314
|
+
var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta.env.VITE_RECAPTCHA_SITE_KEY;
|
|
346
315
|
var result = {
|
|
347
316
|
db: db2,
|
|
348
317
|
auth: auth2,
|
|
@@ -466,6 +435,56 @@ var snapshot = function(config, snapshotsFirstTime) {
|
|
|
466
435
|
unsubscribe: unsubscribe
|
|
467
436
|
};
|
|
468
437
|
};
|
|
438
|
+
// src/helpers/global.ts
|
|
439
|
+
var import_akeyless_types_commons = require("akeyless-types-commons");
|
|
440
|
+
var import_axios = __toESM(require("axios"));
|
|
441
|
+
var import_lodash = require("lodash");
|
|
442
|
+
var import_meta2 = {};
|
|
443
|
+
var getUserCountryByIp = /*#__PURE__*/ function() {
|
|
444
|
+
var _ref = _async_to_generator(function() {
|
|
445
|
+
var response, error;
|
|
446
|
+
return _ts_generator(this, function(_state) {
|
|
447
|
+
switch(_state.label){
|
|
448
|
+
case 0:
|
|
449
|
+
_state.trys.push([
|
|
450
|
+
0,
|
|
451
|
+
2,
|
|
452
|
+
,
|
|
453
|
+
3
|
|
454
|
+
]);
|
|
455
|
+
return [
|
|
456
|
+
4,
|
|
457
|
+
import_axios.default.get("https://ipapi.co/json/")
|
|
458
|
+
];
|
|
459
|
+
case 1:
|
|
460
|
+
response = _state.sent();
|
|
461
|
+
return [
|
|
462
|
+
2,
|
|
463
|
+
(response.data.country_code || import_akeyless_types_commons.CountryOptions.IL).toLowerCase()
|
|
464
|
+
];
|
|
465
|
+
case 2:
|
|
466
|
+
error = _state.sent();
|
|
467
|
+
console.error("Error fetching Country:", error);
|
|
468
|
+
return [
|
|
469
|
+
2,
|
|
470
|
+
import_akeyless_types_commons.CountryOptions.IL
|
|
471
|
+
];
|
|
472
|
+
case 3:
|
|
473
|
+
return [
|
|
474
|
+
2
|
|
475
|
+
];
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
return function getUserCountryByIp() {
|
|
480
|
+
return _ref.apply(this, arguments);
|
|
481
|
+
};
|
|
482
|
+
}();
|
|
483
|
+
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
484
|
+
var _ref = {
|
|
485
|
+
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import_meta2.env.VITE_MODE,
|
|
486
|
+
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import_meta2.env.VITE_is_local) === "true"
|
|
487
|
+
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
469
488
|
// src/helpers/forms.ts
|
|
470
489
|
var import_xregexp = __toESM(require("xregexp"));
|
|
471
490
|
var textRegex = (0, import_xregexp.default)("[^\\p{L}\\s-]", "gu");
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -187,55 +187,25 @@ import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, Tim
|
|
|
187
187
|
import { useCallback } from "react";
|
|
188
188
|
// src/helpers/phoneNumber.ts
|
|
189
189
|
import { parsePhoneNumberFromString } from "libphonenumber-js";
|
|
190
|
-
// src/helpers/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
2,
|
|
203
|
-
,
|
|
204
|
-
3
|
|
205
|
-
]);
|
|
206
|
-
return [
|
|
207
|
-
4,
|
|
208
|
-
axios.get("https://ipapi.co/json/")
|
|
209
|
-
];
|
|
210
|
-
case 1:
|
|
211
|
-
response = _state.sent();
|
|
212
|
-
return [
|
|
213
|
-
2,
|
|
214
|
-
(response.data.country_code || CountryOptions.IL).toLowerCase()
|
|
215
|
-
];
|
|
216
|
-
case 2:
|
|
217
|
-
error = _state.sent();
|
|
218
|
-
console.error("Error fetching Country:", error);
|
|
219
|
-
return [
|
|
220
|
-
2,
|
|
221
|
-
CountryOptions.IL
|
|
222
|
-
];
|
|
223
|
-
case 3:
|
|
224
|
-
return [
|
|
225
|
-
2
|
|
226
|
-
];
|
|
227
|
-
}
|
|
190
|
+
// src/helpers/permissions.ts
|
|
191
|
+
var checkUserPermissions = function(userPermissions, entity, permissions, mode2) {
|
|
192
|
+
var userValues = userPermissions[entity];
|
|
193
|
+
if (!userValues) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (mode2 === "every") {
|
|
200
|
+
return permissions.every(function(permission) {
|
|
201
|
+
return userValues[permission];
|
|
228
202
|
});
|
|
203
|
+
}
|
|
204
|
+
return permissions.some(function(permission) {
|
|
205
|
+
return userValues[permission];
|
|
229
206
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
};
|
|
233
|
-
}();
|
|
234
|
-
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
235
|
-
var _ref = {
|
|
236
|
-
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
|
|
237
|
-
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
|
|
238
|
-
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
207
|
+
};
|
|
208
|
+
checkUserPermissions({}, "dashboard", []);
|
|
239
209
|
// src/helpers/firebase.ts
|
|
240
210
|
var initApp = function() {
|
|
241
211
|
var isNodeEnv2 = typeof process !== "undefined" && process.env;
|
|
@@ -378,6 +348,55 @@ var snapshot = function(config, snapshotsFirstTime) {
|
|
|
378
348
|
unsubscribe: unsubscribe
|
|
379
349
|
};
|
|
380
350
|
};
|
|
351
|
+
// src/helpers/global.ts
|
|
352
|
+
import { CountryOptions, LanguageOptions } from "akeyless-types-commons";
|
|
353
|
+
import axios from "axios";
|
|
354
|
+
import { isEqual } from "lodash";
|
|
355
|
+
var getUserCountryByIp = /*#__PURE__*/ function() {
|
|
356
|
+
var _ref = _async_to_generator(function() {
|
|
357
|
+
var response, error;
|
|
358
|
+
return _ts_generator(this, function(_state) {
|
|
359
|
+
switch(_state.label){
|
|
360
|
+
case 0:
|
|
361
|
+
_state.trys.push([
|
|
362
|
+
0,
|
|
363
|
+
2,
|
|
364
|
+
,
|
|
365
|
+
3
|
|
366
|
+
]);
|
|
367
|
+
return [
|
|
368
|
+
4,
|
|
369
|
+
axios.get("https://ipapi.co/json/")
|
|
370
|
+
];
|
|
371
|
+
case 1:
|
|
372
|
+
response = _state.sent();
|
|
373
|
+
return [
|
|
374
|
+
2,
|
|
375
|
+
(response.data.country_code || CountryOptions.IL).toLowerCase()
|
|
376
|
+
];
|
|
377
|
+
case 2:
|
|
378
|
+
error = _state.sent();
|
|
379
|
+
console.error("Error fetching Country:", error);
|
|
380
|
+
return [
|
|
381
|
+
2,
|
|
382
|
+
CountryOptions.IL
|
|
383
|
+
];
|
|
384
|
+
case 3:
|
|
385
|
+
return [
|
|
386
|
+
2
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
return function getUserCountryByIp() {
|
|
392
|
+
return _ref.apply(this, arguments);
|
|
393
|
+
};
|
|
394
|
+
}();
|
|
395
|
+
var isNodeEnv = typeof process !== "undefined" && process.env;
|
|
396
|
+
var _ref = {
|
|
397
|
+
mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
|
|
398
|
+
isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
|
|
399
|
+
}, mode = _ref.mode, isLocal = _ref.isLocal;
|
|
381
400
|
// src/helpers/forms.ts
|
|
382
401
|
import XRegExp from "xregexp";
|
|
383
402
|
var textRegex = XRegExp("[^\\p{L}\\s-]", "gu");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akeyless-client-commons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.183",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsup",
|
|
6
6
|
"deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@radix-ui/react-progress": "^1.1.1",
|
|
17
17
|
"@radix-ui/react-slot": "^1.1.2",
|
|
18
18
|
"@types/lodash": "^4.17.13",
|
|
19
|
-
"akeyless-types-commons": "^1.0.
|
|
19
|
+
"akeyless-types-commons": "^1.0.18",
|
|
20
20
|
"assets": "^3.0.1",
|
|
21
21
|
"axios": "^1.7.9",
|
|
22
22
|
"class-variance-authority": "^0.7.0",
|