akeyless-client-commons 1.0.69 → 1.0.70

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.
@@ -328,9 +328,10 @@ interface GoogleSvgProps {
328
328
  height?: string;
329
329
  viewBox?: string;
330
330
  }
331
+ type LoginWithGoogleCallback = (e: MouseEvent<HTMLButtonElement>, user: NxUser, token: string, userPermissions: TObject<TObject<boolean>>) => Promise<void>;
331
332
  interface LoginWithGoogleButtonProps {
332
333
  label: string;
333
- onClick: (e: MouseEvent<HTMLButtonElement>, user: NxUser, token: string, userPermissions: TObject<TObject<boolean>>) => Promise<void>;
334
+ onClick: LoginWithGoogleCallback;
334
335
  className?: string;
335
336
  containerClassName?: string;
336
337
  loaderProps?: LoaderProps;
@@ -544,4 +545,4 @@ interface CodeInputProps {
544
545
  }
545
546
  declare function CodeInput({ codeValue, setCodeValue, className, slotContainerClassName, direction }: CodeInputProps): react_jsx_runtime.JSX.Element;
546
547
 
547
- export { Badge, type BadgeProps, BooleanUi, Button, ButtonDisplay, Checkbox, CodeInput, ConfirmForm, DatePicker, DurationUI, ElementLabel, ErrorBoundary, ExportToExcel, Filter, type FilterProps, GeoUi, type GeoUiProps, Input, InputContainer, InternationalPhonePicker, Loader, type LoaderProps, LoginWithGoogleButton, MaxRowsLabel, ModularForm, MultiSelect, type MultipleSelectorOption, type MultipleSelectorProps, type MultipleSelectorRef, NumberUI, type NumberUIProps, PhoneUI, ProgressComponent, Search, type SearchSelectOptions, type SearchSelectProps, SelectContainer, SelectWithSearch, Summary, Table, TableBody, TableButton, TableCell, TableContext, TableHead, type TableProps, TableProvider, type TableProviderType, TableRow, TextAreaContainer, TimesUI, type UseFilterProps, Version, badgeVariants, buttonVariants, getFixedNumber, useDebounce, useSortValues };
548
+ export { Badge, type BadgeProps, BooleanUi, Button, ButtonDisplay, Checkbox, CodeInput, ConfirmForm, DatePicker, DurationUI, ElementLabel, ErrorBoundary, ExportToExcel, Filter, type FilterProps, GeoUi, type GeoUiProps, Input, InputContainer, InternationalPhonePicker, Loader, type LoaderProps, LoginWithGoogleButton, type LoginWithGoogleCallback, MaxRowsLabel, ModularForm, MultiSelect, type MultipleSelectorOption, type MultipleSelectorProps, type MultipleSelectorRef, NumberUI, type NumberUIProps, PhoneUI, ProgressComponent, Search, type SearchSelectOptions, type SearchSelectProps, SelectContainer, SelectWithSearch, Summary, Table, TableBody, TableButton, TableCell, TableContext, TableHead, type TableProps, TableProvider, type TableProviderType, TableRow, TextAreaContainer, TimesUI, type UseFilterProps, Version, badgeVariants, buttonVariants, getFixedNumber, useDebounce, useSortValues };
@@ -328,9 +328,10 @@ interface GoogleSvgProps {
328
328
  height?: string;
329
329
  viewBox?: string;
330
330
  }
331
+ type LoginWithGoogleCallback = (e: MouseEvent<HTMLButtonElement>, user: NxUser, token: string, userPermissions: TObject<TObject<boolean>>) => Promise<void>;
331
332
  interface LoginWithGoogleButtonProps {
332
333
  label: string;
333
- onClick: (e: MouseEvent<HTMLButtonElement>, user: NxUser, token: string, userPermissions: TObject<TObject<boolean>>) => Promise<void>;
334
+ onClick: LoginWithGoogleCallback;
334
335
  className?: string;
335
336
  containerClassName?: string;
336
337
  loaderProps?: LoaderProps;
@@ -544,4 +545,4 @@ interface CodeInputProps {
544
545
  }
545
546
  declare function CodeInput({ codeValue, setCodeValue, className, slotContainerClassName, direction }: CodeInputProps): react_jsx_runtime.JSX.Element;
546
547
 
547
- export { Badge, type BadgeProps, BooleanUi, Button, ButtonDisplay, Checkbox, CodeInput, ConfirmForm, DatePicker, DurationUI, ElementLabel, ErrorBoundary, ExportToExcel, Filter, type FilterProps, GeoUi, type GeoUiProps, Input, InputContainer, InternationalPhonePicker, Loader, type LoaderProps, LoginWithGoogleButton, MaxRowsLabel, ModularForm, MultiSelect, type MultipleSelectorOption, type MultipleSelectorProps, type MultipleSelectorRef, NumberUI, type NumberUIProps, PhoneUI, ProgressComponent, Search, type SearchSelectOptions, type SearchSelectProps, SelectContainer, SelectWithSearch, Summary, Table, TableBody, TableButton, TableCell, TableContext, TableHead, type TableProps, TableProvider, type TableProviderType, TableRow, TextAreaContainer, TimesUI, type UseFilterProps, Version, badgeVariants, buttonVariants, getFixedNumber, useDebounce, useSortValues };
548
+ export { Badge, type BadgeProps, BooleanUi, Button, ButtonDisplay, Checkbox, CodeInput, ConfirmForm, DatePicker, DurationUI, ElementLabel, ErrorBoundary, ExportToExcel, Filter, type FilterProps, GeoUi, type GeoUiProps, Input, InputContainer, InternationalPhonePicker, Loader, type LoaderProps, LoginWithGoogleButton, type LoginWithGoogleCallback, MaxRowsLabel, ModularForm, MultiSelect, type MultipleSelectorOption, type MultipleSelectorProps, type MultipleSelectorRef, NumberUI, type NumberUIProps, PhoneUI, ProgressComponent, Search, type SearchSelectOptions, type SearchSelectProps, SelectContainer, SelectWithSearch, Summary, Table, TableBody, TableButton, TableCell, TableContext, TableHead, type TableProps, TableProvider, type TableProviderType, TableRow, TextAreaContainer, TimesUI, type UseFilterProps, Version, badgeVariants, buttonVariants, getFixedNumber, useDebounce, useSortValues };
@@ -813,6 +813,52 @@ var simpleExtractData = function(doc2) {
813
813
  id: doc2.id
814
814
  });
815
815
  };
816
+ var set_document = /*#__PURE__*/ function() {
817
+ var _ref = _async_to_generator(function(collection_path, doc_id, data) {
818
+ var doc_ref, error;
819
+ return _ts_generator(this, function(_state) {
820
+ switch(_state.label){
821
+ case 0:
822
+ _state.trys.push([
823
+ 0,
824
+ 2,
825
+ ,
826
+ 3
827
+ ]);
828
+ doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
829
+ return [
830
+ 4,
831
+ (0, import_firestore.setDoc)(doc_ref, data, {
832
+ merge: true
833
+ })
834
+ ];
835
+ case 1:
836
+ _state.sent();
837
+ return [
838
+ 2,
839
+ true
840
+ ];
841
+ case 2:
842
+ error = _state.sent();
843
+ console.error("Failed to create document by id: ".concat(doc_id, " in collection: ").concat(collection_path), {
844
+ error: error,
845
+ data: data
846
+ });
847
+ return [
848
+ 2,
849
+ false
850
+ ];
851
+ case 3:
852
+ return [
853
+ 2
854
+ ];
855
+ }
856
+ });
857
+ });
858
+ return function set_document(collection_path, doc_id, data) {
859
+ return _ref.apply(this, arguments);
860
+ };
861
+ }();
816
862
  var query_document2 = /*#__PURE__*/ function() {
817
863
  var _ref = _async_to_generator(function(collection_path, field_name, operator, value) {
818
864
  var ignore_log, q, query_snapshot, documents, error;
@@ -948,6 +994,93 @@ var getUserByIdentifier = /*#__PURE__*/ function() {
948
994
  return _ref.apply(this, arguments);
949
995
  };
950
996
  }();
997
+ var addLoginAudit = /*#__PURE__*/ function() {
998
+ var _ref = _async_to_generator(function(user, app2, loginBy) {
999
+ var details;
1000
+ return _ts_generator(this, function(_state) {
1001
+ switch(_state.label){
1002
+ case 0:
1003
+ details = {
1004
+ app: app2,
1005
+ login_by: loginBy
1006
+ };
1007
+ return [
1008
+ 4,
1009
+ set_document("nx-users", user.id, {
1010
+ last_login: fire_base_TIME_TEMP()
1011
+ })
1012
+ ];
1013
+ case 1:
1014
+ _state.sent();
1015
+ return [
1016
+ 4,
1017
+ addAuditRecord("login", app2, details, user)
1018
+ ];
1019
+ case 2:
1020
+ _state.sent();
1021
+ return [
1022
+ 2
1023
+ ];
1024
+ }
1025
+ });
1026
+ });
1027
+ return function addLoginAudit(user, app2, loginBy) {
1028
+ return _ref.apply(this, arguments);
1029
+ };
1030
+ }();
1031
+ var addAuditRecord = /*#__PURE__*/ function() {
1032
+ var _ref = _async_to_generator(function(action, entity, details, user) {
1033
+ var ref, data, error;
1034
+ return _ts_generator(this, function(_state) {
1035
+ switch(_state.label){
1036
+ case 0:
1037
+ _state.trys.push([
1038
+ 0,
1039
+ 2,
1040
+ ,
1041
+ 3
1042
+ ]);
1043
+ ref = (0, import_firestore.doc)(collections.audit);
1044
+ data = {
1045
+ action: action,
1046
+ entity: entity,
1047
+ details: details,
1048
+ user: user ? {
1049
+ id: user.id,
1050
+ name: "".concat(user.first_name || "", " ").concat(user.last_name || "").trim(),
1051
+ clients: user.clients
1052
+ } : null
1053
+ };
1054
+ return [
1055
+ 4,
1056
+ (0, import_firestore.setDoc)(ref, _object_spread_props(_object_spread({}, data), {
1057
+ datetime: fire_base_TIME_TEMP()
1058
+ }))
1059
+ ];
1060
+ case 1:
1061
+ _state.sent();
1062
+ return [
1063
+ 2,
1064
+ data
1065
+ ];
1066
+ case 2:
1067
+ error = _state.sent();
1068
+ console.log(error);
1069
+ return [
1070
+ 3,
1071
+ 3
1072
+ ];
1073
+ case 3:
1074
+ return [
1075
+ 2
1076
+ ];
1077
+ }
1078
+ });
1079
+ });
1080
+ return function addAuditRecord(action, entity, details, user) {
1081
+ return _ref.apply(this, arguments);
1082
+ };
1083
+ }();
951
1084
  var validateUserStatusAndPermissions = function(user, app2) {
952
1085
  if (!user || user.status === "deleted") {
953
1086
  throw new Error("user_not_found");
@@ -1149,9 +1282,9 @@ var LoginWithGoogleButton = function(param) {
1149
1282
  case 0:
1150
1283
  _state.trys.push([
1151
1284
  0,
1152
- 5,
1153
1285
  6,
1154
- 7
1286
+ 7,
1287
+ 8
1155
1288
  ]);
1156
1289
  setIsLoading(true);
1157
1290
  return [
@@ -1175,28 +1308,34 @@ var LoginWithGoogleButton = function(param) {
1175
1308
  userPermissions = validateUserStatusAndPermissions(dbUser, appName);
1176
1309
  return [
1177
1310
  4,
1178
- onClick(e, dbUser, token, userPermissions)
1311
+ addLoginAudit(dbUser, appName, "google")
1179
1312
  ];
1180
1313
  case 4:
1181
1314
  _state.sent();
1182
1315
  return [
1183
- 3,
1184
- 7
1316
+ 4,
1317
+ onClick(e, dbUser, token, userPermissions)
1185
1318
  ];
1186
1319
  case 5:
1320
+ _state.sent();
1321
+ return [
1322
+ 3,
1323
+ 8
1324
+ ];
1325
+ case 6:
1187
1326
  error = _state.sent();
1188
1327
  console.error("error from login with google:", error);
1189
1328
  onError === null || onError === void 0 ? void 0 : onError(error);
1190
1329
  return [
1191
1330
  3,
1192
- 7
1331
+ 8
1193
1332
  ];
1194
- case 6:
1333
+ case 7:
1195
1334
  setIsLoading(false);
1196
1335
  return [
1197
1336
  7
1198
1337
  ];
1199
- case 7:
1338
+ case 8:
1200
1339
  return [
1201
1340
  2
1202
1341
  ];
@@ -612,6 +612,52 @@ var simpleExtractData = function(doc2) {
612
612
  id: doc2.id
613
613
  });
614
614
  };
615
+ var set_document = /*#__PURE__*/ function() {
616
+ var _ref = _async_to_generator(function(collection_path, doc_id, data) {
617
+ var doc_ref, error;
618
+ return _ts_generator(this, function(_state) {
619
+ switch(_state.label){
620
+ case 0:
621
+ _state.trys.push([
622
+ 0,
623
+ 2,
624
+ ,
625
+ 3
626
+ ]);
627
+ doc_ref = doc(db, collection_path, doc_id);
628
+ return [
629
+ 4,
630
+ setDoc(doc_ref, data, {
631
+ merge: true
632
+ })
633
+ ];
634
+ case 1:
635
+ _state.sent();
636
+ return [
637
+ 2,
638
+ true
639
+ ];
640
+ case 2:
641
+ error = _state.sent();
642
+ console.error("Failed to create document by id: ".concat(doc_id, " in collection: ").concat(collection_path), {
643
+ error: error,
644
+ data: data
645
+ });
646
+ return [
647
+ 2,
648
+ false
649
+ ];
650
+ case 3:
651
+ return [
652
+ 2
653
+ ];
654
+ }
655
+ });
656
+ });
657
+ return function set_document(collection_path, doc_id, data) {
658
+ return _ref.apply(this, arguments);
659
+ };
660
+ }();
615
661
  var query_document2 = /*#__PURE__*/ function() {
616
662
  var _ref = _async_to_generator(function(collection_path, field_name, operator, value) {
617
663
  var ignore_log, q, query_snapshot, documents, error;
@@ -747,6 +793,93 @@ var getUserByIdentifier = /*#__PURE__*/ function() {
747
793
  return _ref.apply(this, arguments);
748
794
  };
749
795
  }();
796
+ var addLoginAudit = /*#__PURE__*/ function() {
797
+ var _ref = _async_to_generator(function(user, app2, loginBy) {
798
+ var details;
799
+ return _ts_generator(this, function(_state) {
800
+ switch(_state.label){
801
+ case 0:
802
+ details = {
803
+ app: app2,
804
+ login_by: loginBy
805
+ };
806
+ return [
807
+ 4,
808
+ set_document("nx-users", user.id, {
809
+ last_login: fire_base_TIME_TEMP()
810
+ })
811
+ ];
812
+ case 1:
813
+ _state.sent();
814
+ return [
815
+ 4,
816
+ addAuditRecord("login", app2, details, user)
817
+ ];
818
+ case 2:
819
+ _state.sent();
820
+ return [
821
+ 2
822
+ ];
823
+ }
824
+ });
825
+ });
826
+ return function addLoginAudit(user, app2, loginBy) {
827
+ return _ref.apply(this, arguments);
828
+ };
829
+ }();
830
+ var addAuditRecord = /*#__PURE__*/ function() {
831
+ var _ref = _async_to_generator(function(action, entity, details, user) {
832
+ var ref, data, error;
833
+ return _ts_generator(this, function(_state) {
834
+ switch(_state.label){
835
+ case 0:
836
+ _state.trys.push([
837
+ 0,
838
+ 2,
839
+ ,
840
+ 3
841
+ ]);
842
+ ref = doc(collections.audit);
843
+ data = {
844
+ action: action,
845
+ entity: entity,
846
+ details: details,
847
+ user: user ? {
848
+ id: user.id,
849
+ name: "".concat(user.first_name || "", " ").concat(user.last_name || "").trim(),
850
+ clients: user.clients
851
+ } : null
852
+ };
853
+ return [
854
+ 4,
855
+ setDoc(ref, _object_spread_props(_object_spread({}, data), {
856
+ datetime: fire_base_TIME_TEMP()
857
+ }))
858
+ ];
859
+ case 1:
860
+ _state.sent();
861
+ return [
862
+ 2,
863
+ data
864
+ ];
865
+ case 2:
866
+ error = _state.sent();
867
+ console.log(error);
868
+ return [
869
+ 3,
870
+ 3
871
+ ];
872
+ case 3:
873
+ return [
874
+ 2
875
+ ];
876
+ }
877
+ });
878
+ });
879
+ return function addAuditRecord(action, entity, details, user) {
880
+ return _ref.apply(this, arguments);
881
+ };
882
+ }();
750
883
  var validateUserStatusAndPermissions = function(user, app2) {
751
884
  if (!user || user.status === "deleted") {
752
885
  throw new Error("user_not_found");
@@ -948,9 +1081,9 @@ var LoginWithGoogleButton = function(param) {
948
1081
  case 0:
949
1082
  _state.trys.push([
950
1083
  0,
951
- 5,
952
1084
  6,
953
- 7
1085
+ 7,
1086
+ 8
954
1087
  ]);
955
1088
  setIsLoading(true);
956
1089
  return [
@@ -974,28 +1107,34 @@ var LoginWithGoogleButton = function(param) {
974
1107
  userPermissions = validateUserStatusAndPermissions(dbUser, appName);
975
1108
  return [
976
1109
  4,
977
- onClick(e, dbUser, token, userPermissions)
1110
+ addLoginAudit(dbUser, appName, "google")
978
1111
  ];
979
1112
  case 4:
980
1113
  _state.sent();
981
1114
  return [
982
- 3,
983
- 7
1115
+ 4,
1116
+ onClick(e, dbUser, token, userPermissions)
984
1117
  ];
985
1118
  case 5:
1119
+ _state.sent();
1120
+ return [
1121
+ 3,
1122
+ 8
1123
+ ];
1124
+ case 6:
986
1125
  error = _state.sent();
987
1126
  console.error("error from login with google:", error);
988
1127
  onError === null || onError === void 0 ? void 0 : onError(error);
989
1128
  return [
990
1129
  3,
991
- 7
1130
+ 8
992
1131
  ];
993
- case 6:
1132
+ case 7:
994
1133
  setIsLoading(false);
995
1134
  return [
996
1135
  7
997
1136
  ];
998
- case 7:
1137
+ case 8:
999
1138
  return [
1000
1139
  2
1001
1140
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.0.69",
3
+ "version": "1.0.70",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",