cozy-sharing 33.3.4 → 33.4.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/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [33.4.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.4.0...cozy-sharing@33.4.1) (2026-06-15)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **cozy-sharing:** Keep the owner avatar visible in the share modal ([f63ae1d](https://github.com/cozy/cozy-libs/commit/f63ae1de24de5ca7746b0c6da579f52fa5593806))
11
+
12
+ # [33.4.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.3.4...cozy-sharing@33.4.0) (2026-06-15)
13
+
14
+ ### Bug Fixes
15
+
16
+ - **cozy-sharing:** Prevent duplicate shared drive links ([0d93ae5](https://github.com/cozy/cozy-libs/commit/0d93ae50cba1d6fe9f6f070bba87b874119fffb7))
17
+ - **cozy-sharing:** Prevent repeated shared drive link fetches ([fa8833e](https://github.com/cozy/cozy-libs/commit/fa8833e058a5432eef6743923b38ed42916ea3e3))
18
+
19
+ ### Features
20
+
21
+ - **cozy-sharing:** Show shared drive links ([3736586](https://github.com/cozy/cozy-libs/commit/37365866117c630f730b108c69e56d0526fa5736))
22
+
6
23
  ## [33.3.4](https://github.com/cozy/cozy-libs/compare/cozy-sharing@33.3.3...cozy-sharing@33.3.4) (2026-06-11)
7
24
 
8
25
  ### Bug Fixes
@@ -547,42 +547,71 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
547
547
 
548
548
  _defineProperty(_this2, "shareByLink", /*#__PURE__*/function () {
549
549
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(document, options) {
550
- var resp;
550
+ var resp, permissions;
551
551
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
552
552
  while (1) switch (_context11.prev = _context11.next) {
553
553
  case 0:
554
+ _context11.prev = 0;
555
+
554
556
  if (!document.driveId) {
555
- _context11.next = 6;
557
+ _context11.next = 7;
556
558
  break;
557
559
  }
558
560
 
559
- _context11.next = 3;
561
+ _context11.next = 4;
560
562
  return _this2.createSharedDriveSharingLink(document, options);
561
563
 
562
- case 3:
564
+ case 4:
563
565
  _context11.t0 = _context11.sent;
564
- _context11.next = 9;
566
+ _context11.next = 10;
565
567
  break;
566
568
 
567
- case 6:
568
- _context11.next = 8;
569
+ case 7:
570
+ _context11.next = 9;
569
571
  return _this2.permissionCol.createSharingLink(document, options);
570
572
 
571
- case 8:
573
+ case 9:
572
574
  _context11.t0 = _context11.sent;
573
575
 
574
- case 9:
576
+ case 10:
575
577
  resp = _context11.t0;
576
578
 
577
579
  _this2.dispatch(addSharingLink(resp.data));
578
580
 
579
581
  return _context11.abrupt("return", resp);
580
582
 
581
- case 12:
583
+ case 15:
584
+ _context11.prev = 15;
585
+ _context11.t1 = _context11["catch"](0);
586
+
587
+ if (!(document.driveId && _context11.t1 && _context11.t1.status === 409)) {
588
+ _context11.next = 23;
589
+ break;
590
+ }
591
+
592
+ _context11.next = 20;
593
+ return _this2.fetchSharedDriveSharingLinks(document);
594
+
595
+ case 20:
596
+ permissions = _context11.sent;
597
+
598
+ if (!(permissions && permissions.length > 0)) {
599
+ _context11.next = 23;
600
+ break;
601
+ }
602
+
603
+ return _context11.abrupt("return", {
604
+ data: permissions[0]
605
+ });
606
+
607
+ case 23:
608
+ throw _context11.t1;
609
+
610
+ case 24:
582
611
  case "end":
583
612
  return _context11.stop();
584
613
  }
585
- }, _callee11);
614
+ }, _callee11, null, [[0, 15]]);
586
615
  }));
587
616
 
588
617
  return function (_x19, _x20) {
@@ -591,9 +620,11 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
591
620
  }());
592
621
 
593
622
  _defineProperty(_this2, "getFederatedShareLink", function (document) {
594
- if (!document.driveId) return null;
623
+ if (!(document !== null && document !== void 0 && document.driveId)) return null;
624
+ var documentId = document._id || document.id;
625
+ if (!documentId) return null;
595
626
 
596
- var permissions = _getDocumentPermissions(_this2.state, document._id);
627
+ var permissions = _getDocumentPermissions(_this2.state, documentId);
597
628
 
598
629
  var perm = permissions.find(function (p) {
599
630
  return getShortcode(p);
@@ -641,39 +672,99 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
641
672
  };
642
673
  }());
643
674
 
644
- _defineProperty(_this2, "updateSharedDrivePermissions", /*#__PURE__*/function () {
645
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(document, permissionDocument, updatedPermissions, options) {
646
- var client, expiresAt, password, drivePermissionCollection, resp;
675
+ _defineProperty(_this2, "fetchSharedDriveSharingLinks", /*#__PURE__*/function () {
676
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(document) {
677
+ var client, drivePermissionCollection, documentId, resp, permissions, existingPermissions, existingPermissionIds, newPermissions;
647
678
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
648
679
  while (1) switch (_context13.prev = _context13.next) {
680
+ case 0:
681
+ if (!(!document || !document.driveId)) {
682
+ _context13.next = 2;
683
+ break;
684
+ }
685
+
686
+ return _context13.abrupt("return", []);
687
+
688
+ case 2:
689
+ client = _this2.props.client;
690
+ drivePermissionCollection = client.collection('io.cozy.permissions', {
691
+ driveId: document.driveId
692
+ });
693
+ documentId = document._id || document.id;
694
+
695
+ if (documentId) {
696
+ _context13.next = 7;
697
+ break;
698
+ }
699
+
700
+ return _context13.abrupt("return", []);
701
+
702
+ case 7:
703
+ _context13.next = 9;
704
+ return drivePermissionCollection.findLinksByIds([documentId]);
705
+
706
+ case 9:
707
+ resp = _context13.sent;
708
+ permissions = resp.data || [];
709
+ existingPermissions = _getDocumentPermissions(_this2.state, documentId);
710
+ existingPermissionIds = existingPermissions.map(function (permission) {
711
+ return permission.id;
712
+ });
713
+ newPermissions = permissions.filter(function (permission) {
714
+ return !existingPermissionIds.includes(permission.id);
715
+ });
716
+
717
+ if (newPermissions.length > 0) {
718
+ _this2.dispatch(addSharingLink(newPermissions));
719
+ }
720
+
721
+ return _context13.abrupt("return", permissions);
722
+
723
+ case 16:
724
+ case "end":
725
+ return _context13.stop();
726
+ }
727
+ }, _callee13);
728
+ }));
729
+
730
+ return function (_x23) {
731
+ return _ref15.apply(this, arguments);
732
+ };
733
+ }());
734
+
735
+ _defineProperty(_this2, "updateSharedDrivePermissions", /*#__PURE__*/function () {
736
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(document, permissionDocument, updatedPermissions, options) {
737
+ var client, expiresAt, password, drivePermissionCollection, resp;
738
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
739
+ while (1) switch (_context14.prev = _context14.next) {
649
740
  case 0:
650
741
  client = _this2.props.client;
651
742
  expiresAt = options.expiresAt, password = options.password;
652
743
  drivePermissionCollection = client.collection('io.cozy.permissions', {
653
744
  driveId: document.driveId
654
745
  });
655
- _context13.next = 5;
746
+ _context14.next = 5;
656
747
  return drivePermissionCollection.add(permissionDocument, updatedPermissions, {
657
748
  expiresAt: expiresAt,
658
749
  password: password
659
750
  });
660
751
 
661
752
  case 5:
662
- resp = _context13.sent;
753
+ resp = _context14.sent;
663
754
 
664
755
  _this2.dispatch(updateSharingLink(resp.data));
665
756
 
666
- return _context13.abrupt("return", resp);
757
+ return _context14.abrupt("return", resp);
667
758
 
668
759
  case 8:
669
760
  case "end":
670
- return _context13.stop();
761
+ return _context14.stop();
671
762
  }
672
- }, _callee13);
763
+ }, _callee14);
673
764
  }));
674
765
 
675
- return function (_x23, _x24, _x25, _x26) {
676
- return _ref15.apply(this, arguments);
766
+ return function (_x24, _x25, _x26, _x27) {
767
+ return _ref16.apply(this, arguments);
677
768
  };
678
769
  }());
679
770
 
@@ -689,28 +780,28 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
689
780
  * @return {Array}
690
781
  */
691
782
  _defineProperty(_this2, "updateDocumentPermissions", /*#__PURE__*/function () {
692
- var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(document, options) {
783
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(document, options) {
693
784
  var verbs, expiresAt, password, permissions, responses;
694
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
695
- while (1) switch (_context15.prev = _context15.next) {
785
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
786
+ while (1) switch (_context16.prev = _context16.next) {
696
787
  case 0:
697
788
  verbs = options.verbs, expiresAt = options.expiresAt, password = options.password;
698
789
  permissions = _getDocumentPermissions(_this2.state, document.id);
699
790
 
700
791
  if (!(!permissions || permissions.length === 0)) {
701
- _context15.next = 4;
792
+ _context16.next = 4;
702
793
  break;
703
794
  }
704
795
 
705
- return _context15.abrupt("return", []);
796
+ return _context16.abrupt("return", []);
706
797
 
707
798
  case 4:
708
- _context15.next = 6;
799
+ _context16.next = 6;
709
800
  return Promise.all(permissions.map( /*#__PURE__*/function () {
710
- var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(permissionDocument) {
801
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(permissionDocument) {
711
802
  var updatedPermissions, resp;
712
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
713
- while (1) switch (_context14.prev = _context14.next) {
803
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
804
+ while (1) switch (_context15.prev = _context15.next) {
714
805
  case 0:
715
806
  updatedPermissions = permissionDocument.attributes.permissions;
716
807
  Object.keys(updatedPermissions).forEach(function (permType) {
@@ -718,114 +809,114 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
718
809
  });
719
810
 
720
811
  if (!document.driveId) {
721
- _context14.next = 8;
812
+ _context15.next = 8;
722
813
  break;
723
814
  }
724
815
 
725
- _context14.next = 5;
816
+ _context15.next = 5;
726
817
  return _this2.updateSharedDrivePermissions(document, permissionDocument, updatedPermissions, options);
727
818
 
728
819
  case 5:
729
- _context14.t0 = _context14.sent;
730
- _context14.next = 11;
820
+ _context15.t0 = _context15.sent;
821
+ _context15.next = 11;
731
822
  break;
732
823
 
733
824
  case 8:
734
- _context14.next = 10;
825
+ _context15.next = 10;
735
826
  return _this2.permissionCol.add(permissionDocument, updatedPermissions, {
736
827
  expiresAt: expiresAt,
737
828
  password: password
738
829
  });
739
830
 
740
831
  case 10:
741
- _context14.t0 = _context14.sent;
832
+ _context15.t0 = _context15.sent;
742
833
 
743
834
  case 11:
744
- resp = _context14.t0;
835
+ resp = _context15.t0;
745
836
 
746
837
  _this2.dispatch(updateSharingLink(resp.data));
747
838
 
748
- return _context14.abrupt("return", resp);
839
+ return _context15.abrupt("return", resp);
749
840
 
750
841
  case 14:
751
842
  case "end":
752
- return _context14.stop();
843
+ return _context15.stop();
753
844
  }
754
- }, _callee14);
845
+ }, _callee15);
755
846
  }));
756
847
 
757
- return function (_x29) {
758
- return _ref17.apply(this, arguments);
848
+ return function (_x30) {
849
+ return _ref18.apply(this, arguments);
759
850
  };
760
851
  }()));
761
852
 
762
853
  case 6:
763
- responses = _context15.sent;
764
- return _context15.abrupt("return", responses);
854
+ responses = _context16.sent;
855
+ return _context16.abrupt("return", responses);
765
856
 
766
857
  case 8:
767
858
  case "end":
768
- return _context15.stop();
859
+ return _context16.stop();
769
860
  }
770
- }, _callee15);
861
+ }, _callee16);
771
862
  }));
772
863
 
773
- return function (_x27, _x28) {
774
- return _ref16.apply(this, arguments);
864
+ return function (_x28, _x29) {
865
+ return _ref17.apply(this, arguments);
775
866
  };
776
867
  }());
777
868
 
778
869
  _defineProperty(_this2, "revokeSharedDriveSharingLink", /*#__PURE__*/function () {
779
- var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(document, perms) {
870
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(document, perms) {
780
871
  var client, drivePermissionCollection;
781
- return _regeneratorRuntime.wrap(function _callee16$(_context16) {
782
- while (1) switch (_context16.prev = _context16.next) {
872
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
873
+ while (1) switch (_context17.prev = _context17.next) {
783
874
  case 0:
784
875
  client = _this2.props.client;
785
876
  drivePermissionCollection = client.collection('io.cozy.permissions', {
786
877
  driveId: document.driveId
787
878
  });
788
- _context16.next = 4;
879
+ _context17.next = 4;
789
880
  return Promise.all(perms.map(function (p) {
790
881
  return drivePermissionCollection.destroy(p);
791
882
  }));
792
883
 
793
884
  case 4:
794
885
  case "end":
795
- return _context16.stop();
886
+ return _context17.stop();
796
887
  }
797
- }, _callee16);
888
+ }, _callee17);
798
889
  }));
799
890
 
800
- return function (_x30, _x31) {
801
- return _ref18.apply(this, arguments);
891
+ return function (_x31, _x32) {
892
+ return _ref19.apply(this, arguments);
802
893
  };
803
894
  }());
804
895
 
805
896
  _defineProperty(_this2, "revokeSharingLink", /*#__PURE__*/function () {
806
- var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(document) {
897
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(document) {
807
898
  var perms;
808
- return _regeneratorRuntime.wrap(function _callee17$(_context17) {
809
- while (1) switch (_context17.prev = _context17.next) {
899
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
900
+ while (1) switch (_context18.prev = _context18.next) {
810
901
  case 0:
811
902
  // Because some duplicate links have been created in the past, we must ensure
812
903
  // we revoke all of them
813
904
  perms = _getDocumentPermissions(_this2.state, document.id);
814
905
 
815
906
  if (!document.driveId) {
816
- _context17.next = 6;
907
+ _context18.next = 6;
817
908
  break;
818
909
  }
819
910
 
820
- _context17.next = 4;
911
+ _context18.next = 4;
821
912
  return _this2.revokeSharedDriveSharingLink(document, perms);
822
913
 
823
914
  case 4:
824
- _context17.next = 8;
915
+ _context18.next = 8;
825
916
  break;
826
917
 
827
918
  case 6:
828
- _context17.next = 8;
919
+ _context18.next = 8;
829
920
  return Promise.all(perms.map(function (p) {
830
921
  return _this2.permissionCol.destroy(p);
831
922
  }));
@@ -835,13 +926,13 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
835
926
 
836
927
  case 9:
837
928
  case "end":
838
- return _context17.stop();
929
+ return _context18.stop();
839
930
  }
840
- }, _callee17);
931
+ }, _callee18);
841
932
  }));
842
933
 
843
- return function (_x32) {
844
- return _ref19.apply(this, arguments);
934
+ return function (_x33) {
935
+ return _ref20.apply(this, arguments);
845
936
  };
846
937
  }());
847
938
 
@@ -921,6 +1012,7 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
921
1012
  revokeSelf: _this2.revokeSelf,
922
1013
  shareByLink: _this2.shareByLink,
923
1014
  getFederatedShareLink: _this2.getFederatedShareLink,
1015
+ fetchSharedDriveSharingLinks: _this2.fetchSharedDriveSharingLinks,
924
1016
  updateDocumentPermissions: _this2.updateDocumentPermissions,
925
1017
  revokeSharingLink: _this2.revokeSharingLink,
926
1018
  hasLoadedAtLeastOnePage: false,
@@ -965,14 +1057,14 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
965
1057
  }, {
966
1058
  key: "fetchAllSharings",
967
1059
  value: function () {
968
- var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
1060
+ var _fetchAllSharings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
969
1061
  var _this$props, doctype, client, _yield$Promise$all, _yield$Promise$all2, sharings, permissions, apps, sharedDocIds, resp, folderPaths, filePaths;
970
1062
 
971
- return _regeneratorRuntime.wrap(function _callee18$(_context18) {
972
- while (1) switch (_context18.prev = _context18.next) {
1063
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1064
+ while (1) switch (_context19.prev = _context19.next) {
973
1065
  case 0:
974
1066
  if (!this.isPublic) {
975
- _context18.next = 4;
1067
+ _context19.next = 4;
976
1068
  break;
977
1069
  }
978
1070
 
@@ -981,17 +1073,17 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
981
1073
  this.setState({
982
1074
  allLoaded: true
983
1075
  });
984
- return _context18.abrupt("return");
1076
+ return _context19.abrupt("return");
985
1077
 
986
1078
  case 4:
987
1079
  _this$props = this.props, doctype = _this$props.doctype, client = _this$props.client;
988
- _context18.next = 7;
1080
+ _context19.next = 7;
989
1081
  return Promise.all([this.sharingCol.findByDoctype(doctype, {
990
1082
  withSharedDocs: false
991
1083
  }), this.permissionCol.findLinksByDoctype(doctype), client.fetchQueryAndGetFromState(fetchApps())]);
992
1084
 
993
1085
  case 7:
994
- _yield$Promise$all = _context18.sent;
1086
+ _yield$Promise$all = _context19.sent;
995
1087
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
996
1088
  sharings = _yield$Promise$all2[0];
997
1089
  permissions = _yield$Promise$all2[1];
@@ -1005,35 +1097,35 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
1005
1097
  this.setState({
1006
1098
  hasLoadedAtLeastOnePage: true
1007
1099
  });
1008
- _context18.next = 16;
1100
+ _context19.next = 16;
1009
1101
  return fetchNextPermissions(permissions, this.dispatch, this.permissionCol);
1010
1102
 
1011
1103
  case 16:
1012
1104
  if (!(doctype === 'io.cozy.files')) {
1013
- _context18.next = 26;
1105
+ _context19.next = 26;
1014
1106
  break;
1015
1107
  }
1016
1108
 
1017
1109
  sharedDocIds = getSharedDocIdsBySharings(sharings);
1018
- _context18.next = 20;
1110
+ _context19.next = 20;
1019
1111
  return client.collection(doctype).all({
1020
1112
  keys: sharedDocIds
1021
1113
  });
1022
1114
 
1023
1115
  case 20:
1024
- resp = _context18.sent;
1116
+ resp = _context19.sent;
1025
1117
  folderPaths = resp.data.filter(function (f) {
1026
1118
  return f.type === 'directory' && !f.trashed;
1027
1119
  }).map(function (f) {
1028
1120
  return f.path;
1029
1121
  });
1030
- _context18.next = 24;
1122
+ _context19.next = 24;
1031
1123
  return fetchFilesPaths(client, doctype, resp.data.filter(function (f) {
1032
1124
  return f.type !== 'directory' && !f.trashed;
1033
1125
  }));
1034
1126
 
1035
1127
  case 24:
1036
- filePaths = _context18.sent;
1128
+ filePaths = _context19.sent;
1037
1129
  this.dispatch(receivePaths([].concat(_toConsumableArray(folderPaths), _toConsumableArray(filePaths))));
1038
1130
 
1039
1131
  case 26:
@@ -1043,9 +1135,9 @@ export var SharingProvider = /*#__PURE__*/function (_Component) {
1043
1135
 
1044
1136
  case 27:
1045
1137
  case "end":
1046
- return _context18.stop();
1138
+ return _context19.stop();
1047
1139
  }
1048
- }, _callee18, this);
1140
+ }, _callee19, this);
1049
1141
  }));
1050
1142
 
1051
1143
  function fetchAllSharings() {