cozy-sharing 37.5.1 → 37.5.2

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,12 @@
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
+ ## [37.5.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.5.1...cozy-sharing@37.5.2) (2026-08-26)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **cozy-sharing:** Guard canReshare against missing sharing ([56cc19d](https://github.com/cozy/cozy-libs/commit/56cc19d09eed55472646cdc04ce8f4c7f2eb7f1e))
11
+
6
12
  ## [37.5.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.5.0...cozy-sharing@37.5.1) (2026-08-25)
7
13
 
8
14
  ### Bug Fixes
package/dist/state.js CHANGED
@@ -417,6 +417,7 @@ export var canLeave = function canLeave(state, docId) {
417
417
  };
418
418
  export var canReshare = function canReshare(state, docId, instanceUri) {
419
419
  var sharing = getDocumentSharing(state, docId);
420
+ if (!sharing) return false;
420
421
  var me = sharing.attributes.members.find(matchingInstanceName(instanceUri));
421
422
 
422
423
  if (sharing.drive) {
@@ -4,7 +4,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
- import reducer, { receiveSharings, addSharing, addSharingLink, updateSharingLink, revokeSharingLink, getRecipients, getRecipientsFromSharing, revokeGroup, revokeRecipient, revokeSelf, updateSharing, matchingInstanceName, getSharingLink, hasSharedParent, hasSharedChild, getSharedDocIdsBySharings, getSharingType, getPermissionDocIds, getDocumentSharingType, getSharedParentPath, getExternalSharingIds, getRecipientsWithGroups } from './state';
7
+ import reducer, { canReshare, receiveSharings, addSharing, addSharingLink, updateSharingLink, revokeSharingLink, getRecipients, getRecipientsFromSharing, revokeGroup, revokeRecipient, revokeSelf, updateSharing, matchingInstanceName, getSharingLink, hasSharedParent, hasSharedChild, getSharedDocIdsBySharings, getSharingType, getPermissionDocIds, getDocumentSharingType, getSharedParentPath, getExternalSharingIds, getRecipientsWithGroups } from './state';
8
8
  import { SHARING_1, SHARING_2, SHARING_3, SHARING_READ_ONLY, PERM_1, PERM_2, PERM_WITHOUT_DOC, SHARING_NO_ACTIVE, SHARING_WITH_SHORTCUT } from '../__tests__/fixtures';
9
9
  describe('Sharing state', function () {
10
10
  it('should have a default state', function () {
@@ -730,6 +730,15 @@ describe('getDocumentSharingType', function () {
730
730
  }, 'folder_1')).toBe('one-way');
731
731
  });
732
732
  });
733
+ describe('canReshare', function () {
734
+ var state = {
735
+ byDocId: {},
736
+ sharings: []
737
+ };
738
+ it('should return false when the document has no sharing', function () {
739
+ expect(canReshare(state, 'unknown_doc', 'http://cozy.tools:8080')).toBe(false);
740
+ });
741
+ });
733
742
  describe('getSharedParentPath', function () {
734
743
  var state = {
735
744
  sharedPaths: ['/folder-1/sub-folder-1', '/folder-2', '/folder-3/sub-folder-3', '/folder-3/sub-folder-4']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "37.5.1",
3
+ "version": "37.5.2",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -59,7 +59,7 @@
59
59
  "cozy-intent": "^2.31.1",
60
60
  "cozy-minilog": "^3.10.1",
61
61
  "cozy-ui": "^140.5.0",
62
- "cozy-ui-plus": "^12.3.10",
62
+ "cozy-ui-plus": "^12.3.11",
63
63
  "jest": "30.3.0",
64
64
  "jest-environment-jsdom": "30.3.0",
65
65
  "react": "16.12.0",
@@ -85,5 +85,5 @@
85
85
  "sideEffects": [
86
86
  "*.css"
87
87
  ],
88
- "gitHead": "1f5ca5edaf02675c51870c3d525eef0112781453"
88
+ "gitHead": "c442a0903e06f8877c303548a9d22be5ee60bf01"
89
89
  }
package/src/state.js CHANGED
@@ -330,6 +330,7 @@ export const canLeave = (state, docId) => {
330
330
 
331
331
  export const canReshare = (state, docId, instanceUri) => {
332
332
  const sharing = getDocumentSharing(state, docId)
333
+ if (!sharing) return false
333
334
  const me = sharing.attributes.members.find(matchingInstanceName(instanceUri))
334
335
  if (sharing.drive) {
335
336
  return !sharing.org_drive && me && !me.read_only
package/src/state.spec.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import reducer, {
2
+ canReshare,
2
3
  receiveSharings,
3
4
  addSharing,
4
5
  addSharingLink,
@@ -981,6 +982,19 @@ describe('getDocumentSharingType', () => {
981
982
  })
982
983
  })
983
984
 
985
+ describe('canReshare', () => {
986
+ const state = {
987
+ byDocId: {},
988
+ sharings: []
989
+ }
990
+
991
+ it('should return false when the document has no sharing', () => {
992
+ expect(canReshare(state, 'unknown_doc', 'http://cozy.tools:8080')).toBe(
993
+ false
994
+ )
995
+ })
996
+ })
997
+
984
998
  describe('getSharedParentPath', () => {
985
999
  const state = {
986
1000
  sharedPaths: [