akeyless-client-commons 1.0.69 → 1.0.71

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,95 @@ 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
+ email: user.email,
1053
+ phone_number: user.phone_number
1054
+ } : null
1055
+ };
1056
+ return [
1057
+ 4,
1058
+ (0, import_firestore.setDoc)(ref, _object_spread_props(_object_spread({}, data), {
1059
+ datetime: fire_base_TIME_TEMP()
1060
+ }))
1061
+ ];
1062
+ case 1:
1063
+ _state.sent();
1064
+ return [
1065
+ 2,
1066
+ data
1067
+ ];
1068
+ case 2:
1069
+ error = _state.sent();
1070
+ console.log(error);
1071
+ return [
1072
+ 3,
1073
+ 3
1074
+ ];
1075
+ case 3:
1076
+ return [
1077
+ 2
1078
+ ];
1079
+ }
1080
+ });
1081
+ });
1082
+ return function addAuditRecord(action, entity, details, user) {
1083
+ return _ref.apply(this, arguments);
1084
+ };
1085
+ }();
951
1086
  var validateUserStatusAndPermissions = function(user, app2) {
952
1087
  if (!user || user.status === "deleted") {
953
1088
  throw new Error("user_not_found");
@@ -1149,9 +1284,9 @@ var LoginWithGoogleButton = function(param) {
1149
1284
  case 0:
1150
1285
  _state.trys.push([
1151
1286
  0,
1152
- 5,
1153
1287
  6,
1154
- 7
1288
+ 7,
1289
+ 8
1155
1290
  ]);
1156
1291
  setIsLoading(true);
1157
1292
  return [
@@ -1175,28 +1310,34 @@ var LoginWithGoogleButton = function(param) {
1175
1310
  userPermissions = validateUserStatusAndPermissions(dbUser, appName);
1176
1311
  return [
1177
1312
  4,
1178
- onClick(e, dbUser, token, userPermissions)
1313
+ addLoginAudit(dbUser, appName, "google")
1179
1314
  ];
1180
1315
  case 4:
1181
1316
  _state.sent();
1182
1317
  return [
1183
- 3,
1184
- 7
1318
+ 4,
1319
+ onClick(e, dbUser, token, userPermissions)
1185
1320
  ];
1186
1321
  case 5:
1322
+ _state.sent();
1323
+ return [
1324
+ 3,
1325
+ 8
1326
+ ];
1327
+ case 6:
1187
1328
  error = _state.sent();
1188
1329
  console.error("error from login with google:", error);
1189
1330
  onError === null || onError === void 0 ? void 0 : onError(error);
1190
1331
  return [
1191
1332
  3,
1192
- 7
1333
+ 8
1193
1334
  ];
1194
- case 6:
1335
+ case 7:
1195
1336
  setIsLoading(false);
1196
1337
  return [
1197
1338
  7
1198
1339
  ];
1199
- case 7:
1340
+ case 8:
1200
1341
  return [
1201
1342
  2
1202
1343
  ];
@@ -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,95 @@ 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
+ email: user.email,
852
+ phone_number: user.phone_number
853
+ } : null
854
+ };
855
+ return [
856
+ 4,
857
+ setDoc(ref, _object_spread_props(_object_spread({}, data), {
858
+ datetime: fire_base_TIME_TEMP()
859
+ }))
860
+ ];
861
+ case 1:
862
+ _state.sent();
863
+ return [
864
+ 2,
865
+ data
866
+ ];
867
+ case 2:
868
+ error = _state.sent();
869
+ console.log(error);
870
+ return [
871
+ 3,
872
+ 3
873
+ ];
874
+ case 3:
875
+ return [
876
+ 2
877
+ ];
878
+ }
879
+ });
880
+ });
881
+ return function addAuditRecord(action, entity, details, user) {
882
+ return _ref.apply(this, arguments);
883
+ };
884
+ }();
750
885
  var validateUserStatusAndPermissions = function(user, app2) {
751
886
  if (!user || user.status === "deleted") {
752
887
  throw new Error("user_not_found");
@@ -948,9 +1083,9 @@ var LoginWithGoogleButton = function(param) {
948
1083
  case 0:
949
1084
  _state.trys.push([
950
1085
  0,
951
- 5,
952
1086
  6,
953
- 7
1087
+ 7,
1088
+ 8
954
1089
  ]);
955
1090
  setIsLoading(true);
956
1091
  return [
@@ -974,28 +1109,34 @@ var LoginWithGoogleButton = function(param) {
974
1109
  userPermissions = validateUserStatusAndPermissions(dbUser, appName);
975
1110
  return [
976
1111
  4,
977
- onClick(e, dbUser, token, userPermissions)
1112
+ addLoginAudit(dbUser, appName, "google")
978
1113
  ];
979
1114
  case 4:
980
1115
  _state.sent();
981
1116
  return [
982
- 3,
983
- 7
1117
+ 4,
1118
+ onClick(e, dbUser, token, userPermissions)
984
1119
  ];
985
1120
  case 5:
1121
+ _state.sent();
1122
+ return [
1123
+ 3,
1124
+ 8
1125
+ ];
1126
+ case 6:
986
1127
  error = _state.sent();
987
1128
  console.error("error from login with google:", error);
988
1129
  onError === null || onError === void 0 ? void 0 : onError(error);
989
1130
  return [
990
1131
  3,
991
- 7
1132
+ 8
992
1133
  ];
993
- case 6:
1134
+ case 7:
994
1135
  setIsLoading(false);
995
1136
  return [
996
1137
  7
997
1138
  ];
998
- case 7:
1139
+ case 8:
999
1140
  return [
1000
1141
  2
1001
1142
  ];
@@ -143,6 +143,8 @@ declare const addAuditRecord: (action: string, entity: string, details: TObject<
143
143
  id: string;
144
144
  name: string;
145
145
  clients: string[];
146
+ email: string;
147
+ phone_number: string;
146
148
  };
147
149
  }>;
148
150
  declare const validateUserStatusAndPermissions: (user: NxUser, app: AppName) => TObject<TObject<boolean>>;
@@ -143,6 +143,8 @@ declare const addAuditRecord: (action: string, entity: string, details: TObject<
143
143
  id: string;
144
144
  name: string;
145
145
  clients: string[];
146
+ email: string;
147
+ phone_number: string;
146
148
  };
147
149
  }>;
148
150
  declare const validateUserStatusAndPermissions: (user: NxUser, app: AppName) => TObject<TObject<boolean>>;
@@ -1741,7 +1741,9 @@ var addAuditRecord = /*#__PURE__*/ function() {
1741
1741
  user: user ? {
1742
1742
  id: user.id,
1743
1743
  name: "".concat(user.first_name || "", " ").concat(user.last_name || "").trim(),
1744
- clients: user.clients
1744
+ clients: user.clients,
1745
+ email: user.email,
1746
+ phone_number: user.phone_number
1745
1747
  } : null
1746
1748
  };
1747
1749
  return [
@@ -1422,7 +1422,9 @@ var addAuditRecord = /*#__PURE__*/ function() {
1422
1422
  user: user ? {
1423
1423
  id: user.id,
1424
1424
  name: "".concat(user.first_name || "", " ").concat(user.last_name || "").trim(),
1425
- clients: user.clients
1425
+ clients: user.clients,
1426
+ email: user.email,
1427
+ phone_number: user.phone_number
1426
1428
  } : null
1427
1429
  };
1428
1430
  return [
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.71",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",