ocm-types 0.2.1

Types required to implement the OpenCloudMesh filesharing protocol
Documentation
// SPDX-FileCopyrightText: 2026 Matthias Kraus <info@opengeomesh.org>
//
// SPDX-License-Identifier: LGPL-3.0-or-later

use serde::{Deserialize, Serialize};


#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WebAppProperties {
    /// An URI to a client-browsable view of the remote resource,
    /// such that
    /// users may use a web application available at the sender site.
    /// The URI SHOULD be relative, such as a key or a UUID, in which case
    /// the prefix exposed by the `/.well-known/ocm` endpoint MUST be used
    /// to access the resource, or it MAY be absolute, including a hostname.
    /// The latter is NOT recommended because of security concerns.
    /// In all cases, for a `folder` resource, the composed URI acts
    /// as the root path, such that other files located within SHOULD
    /// be accessible by appending their relative path to that URI.
    pub uri: String,
    /// The permissions granted to the sharee.
    pub view_mode: WebAppViewMode,
    /// An optional secret to be used to access the remote web
    /// app, such as
    /// a bearer token. To prevent leaking it in logs it MUST NOT appear
    /// in any URI. If a `code` is provided, then the sending host MUST
    /// accept the short-lived bearer token when serving the web app,
    /// which can be exchanged in the code flow interaction. The exchange
    /// MAY already have happened if the recipient accessed the underlying
    /// resource via WebDAV, in a multi-protocol scenario. In this case,
    /// the `sharedSecret` SHOULD be omitted.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub shared_secret: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum WebAppViewMode {
    /// `read` allows read-only access including download of a copy.
    Read,
    /// `write` allows create, update, and delete rights on the resource.
    Write,
    /// `share` allows re-sharing rights on the resource.
    Share,
}