Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ npm i -S @nextcloud/sharing

## Usage

There are two entry points provided:
There are three entry points provided:

- The main entry point `@nextcloud/sharing` provides general utils for file sharing
- The _public_ entry point `@nextcloud/sharing/public` provides utils for handling public file shares
- The _ui_ entry point `@nextcloud/sharing/ui` provides API bindings to interact with the files sharing interface in the files app.
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-PackageSupplier = "Nextcloud GmbH <https://nextcloud.com/impressum/>"
SPDX-PackageDownloadLocation = "https://github.com/nextcloud-libraries/nextcloud-sharing"

[[annotations]]
path = ["package.json", "package-lock.json", "tsconfig.json"]
path = ["package.json", "package-lock.json", "**/tsconfig.json"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2021 Nextcloud GmbH and Nextcloud contributors"
SPDX-License-Identifier = "GPL-3.0-or-later"
45 changes: 2 additions & 43 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,5 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

/** @deprecated will be removed with the next version use `ShareType` instead */
export enum Type {
SHARE_TYPE_USER = 0,
SHARE_TYPE_GROUP = 1,
SHARE_TYPE_LINK = 3,
SHARE_TYPE_EMAIL = 4,
SHARE_TYPE_REMOTE = 6,
SHARE_TYPE_CIRCLE = 7,
SHARE_TYPE_GUEST = 8,
SHARE_TYPE_REMOTE_GROUP = 9,
SHARE_TYPE_ROOM = 10,
SHARE_TYPE_DECK = 12,
/**
* @since 26.0.0
*/
SHARE_TYPE_FEDERATED_GROUP = 14,
}

export enum ShareType {
User = 0,
Group = 1,
Link = 3,
Email = 4,
Remote = 6,
/**
* Was called `Circle` before Nextcloud 29
*/
Team = 7,
Guest = 8,
RemoteGroup = 9,
Room = 10,
Deck = 12,
/**
* @since 26.0.0
*/
FederatedGroup = 14,
/**
* Third party share types
*
* @since 25.0.0
*/
ScienceMesh = 15,
}
export type * from './share/index.ts'
export { ShareType } from './share/index.ts'
158 changes: 158 additions & 0 deletions lib/share/Share.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import type { ShareType } from './ShareType.ts'

export type ShareAttribute = {
value: boolean
key: string
scope: string
}

export interface IGenericShare {
/**
* The share id
*/
id: number

/**
* The share type
*/
type: ShareType

/**
* The generic share attributes
*/
attributes: ShareAttribute[]

/**
* The share creation timestamp (in seconds since UNIX epoch)
*/
createdTime: number

/**
* The share permissions for the share receiver.
*
* A bitmask of the share permissions like `SharePermission.Read | SharePermission.Write`.
* These are not the permissions for the current user but for the share recipient (shareWith).
*/
permissions: number

/**
* Whether the current user can edit this share.
* Only relevant for existing shares.
*/
readonly canEdit: boolean

/**
* Whether the current user can delete this share.
* Only relevant for existing shares.
*/
readonly canDelete: boolean

/**
* The uid of the share owner
*/
owner: string

/**
* The displayname of the share owner
*/
ownerDisplayname: string

/**
* Get the share with entity id
*/
shareWith: string

/**
* The displayname of the entity this was shared with
*/
shareWithDisplayname: string

/**
* In case of multiple shares with the same entity this is the unique displayname.
*/
shareWithDisplaynameUnique: string

/**
* The uid of the owner of the shared file or folder.
*/
fileOwner: string

/**
* The displayname of the owner of the shared file or folder.
*/
fileOwnerDisplayname: string

/**
* Hide the download functionalities for the shared nodes.
* This obfuscates the download buttons for such shares.
*/
hideDownload: boolean

/**
* Have a mail been sent to the share recipient
*/
mailSend: boolean

/**
* The share note
*/
note?: string

/**
* The share label
*/
label?: string

/**
* The share expiration date in "YYYY-MM-DD HH:mm" format
*/
expireDate?: `${number}-${number}-${number} ${number}:${number}`
}

export interface ILinkShare extends IGenericShare {
/**
* @inheritdoc
*/
type: ShareType.Link | ShareType.Email

/**
* The share token
*/
token: string

/**
* The share password
*/
password: string

/**
* Password expiration time as "YYYY-MM-DD HH:mm" format
*/
passwordExpirationTime: `${number}-${number}-${number} ${number}:${number}`

/**
* Password should be sent to recipient using Nextcloud Talk
*/
sendPasswordByTalk: boolean
}

export interface IRemoteShare extends IGenericShare {
/**
* @inheritdoc
*/
type: ShareType.Remote | ShareType.RemoteGroup

/**
* Is the share from a trusted remote server
*/
isTrustedServer: boolean
}

export type IInternalShare = IGenericShare

export type IShare = ILinkShare | IInternalShare | IRemoteShare
30 changes: 30 additions & 0 deletions lib/share/ShareType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

export enum ShareType {
User = 0,
Group = 1,
Link = 3,
Email = 4,
Remote = 6,
/**
* Was called `Circle` before Nextcloud 29
*/
Team = 7,
Guest = 8,
RemoteGroup = 9,
Room = 10,
Deck = 12,
/**
* @since 26.0.0
*/
FederatedGroup = 14,
/**
* Third party share types
*
* @since 25.0.0
*/
ScienceMesh = 15,
}
8 changes: 8 additions & 0 deletions lib/share/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

export type * from './Share.ts'

export { ShareType } from './ShareType.ts'
10 changes: 10 additions & 0 deletions lib/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

export type * from './sidebar-action.ts'
export type * from './sidebar-section.ts'

export * from './sidebar-action.ts'
export * from './sidebar-section.ts'
Loading