diff --git a/src/backend/controllers/share/ShareController.ts b/src/backend/controllers/share/ShareController.ts index 4f490c23a..dbd80b5e9 100644 --- a/src/backend/controllers/share/ShareController.ts +++ b/src/backend/controllers/share/ShareController.ts @@ -245,6 +245,7 @@ export class ShareController extends PuterController { issuer: share.issuer.username, holder: share.holder.username, created_at: share.createdAt, + inherited_from: share.inheritedFrom ?? null, }; } diff --git a/src/docs/src/FS/getShares.md b/src/docs/src/FS/getShares.md index 2780c25ce..e868ccb1c 100644 --- a/src/docs/src/FS/getShares.md +++ b/src/docs/src/FS/getShares.md @@ -28,7 +28,9 @@ An object with the following properties: ## Return value -A `Promise` that resolves to an array of share objects, each with `uid`, `mode`, `path`, `entryUid`, `isDir`, `issuer` and `holder`. +A `Promise` that resolves to an array of share objects, each with `uid`, `mode`, `path`, `entryUid`, `isDir`, `issuer`, `holder` and `inheritedFrom`. + +`inheritedFrom` is the path of the shared ancestor an access comes from, or `null` when the share is on the item itself. Access inherited from a parent folder is **managed on that folder** — withdrawing it here is not possible, because the grant does not live on this item. The list includes shares granted by **anyone** holding `manage` on the item, not only your own. That is how an owner sees what someone they trusted has re-shared. diff --git a/src/docs/src/FS/share.md b/src/docs/src/FS/share.md index c8fc57a5a..3a3ad8eca 100644 --- a/src/docs/src/FS/share.md +++ b/src/docs/src/FS/share.md @@ -55,6 +55,7 @@ A `Promise` that resolves to an array of share objects, one per recipient/item p - `isDir` (Boolean) - Whether the shared item is a directory. - `issuer` (String) - Username of whoever granted the share. - `holder` (String) - Username of whoever received it. +- `inheritedFrom` (String) - Path of the shared ancestor this access comes from, or `null` when the share is on the item itself. Sharing the same item with the same person again **replaces** their access rather than adding a second share, so raising someone from `read` to `write` is just another call. diff --git a/src/puter-js/src/modules/FileSystem/operations/shareUtil.js b/src/puter-js/src/modules/FileSystem/operations/shareUtil.js index f2b8735a7..23f26461f 100644 --- a/src/puter-js/src/modules/FileSystem/operations/shareUtil.js +++ b/src/puter-js/src/modules/FileSystem/operations/shareUtil.js @@ -65,4 +65,5 @@ export const toShare = (row) => ({ isDir: Boolean(row.is_dir ?? row.isDir), issuer: /** @type {string | null} */ (row.issuer ?? null), holder: /** @type {string | null} */ (row.holder ?? null), + inheritedFrom: /** @type {string | null} */ (row.inherited_from ?? null), }); diff --git a/src/puter-js/src/modules/FileSystem/types.js b/src/puter-js/src/modules/FileSystem/types.js index 1e86b565f..797648afd 100644 --- a/src/puter-js/src/modules/FileSystem/types.js +++ b/src/puter-js/src/modules/FileSystem/types.js @@ -296,6 +296,7 @@ * @property {boolean} isDir Whether the shared item is a directory. * @property {string | null} issuer Username of whoever granted it. * @property {string | null} holder Username of whoever received it. + * @property {string | null} [inheritedFrom] Shared ancestor this access comes from, if any. */ /**