/safe_app_csharp

Primary LanguageC#BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

safe_app_csharp NuGet

.NET wrapper package for safe-api.

safe_app is a native library which exposes high level API for application development on SAFE Network. It exposes API for authorisation and to manage data on the network.

Maintainer: Ravinder Jangra (ravinder.jangra@maidsafe.net)

Build Status

CI service Platform Status
Azure DevOps .NET Core MacOS, Android x86_64, iOS Build status
Azure DevOps .NET Core Linux Build Status
AppVeyor .NET Core Windows Build status Coverage Status

Table of Contents

  1. Overview
  2. Supported Platforms
  3. API Usage
  4. Documentation
  5. Development
  6. Contributing
  7. Useful resources
  8. Copyrights
  9. Further Help
  10. License

This project contains the C# bindings and API wrappers for the safe_app and mock safe_authenticator. The native libraries, bindings and API wrapper are built and published as a NuGet package. The latest version can be fetched from the MaidSafe.SafeApp NuGet package.

At a very high level, this package includes:

  • C# API for devs for easy app development.
  • safe-api and mock safe_authenticator bindings. These bindings are one to one mapping to the FFI functions exposed from safe_api and safe_authenicator native libraries.
  • Native libraries generated from safe-api containing required logic to connect, read and write data on the SAFE Network.

Supported Platforms

  • Xamarin.Android ( >=5.0. ABI: armeabi-v7a, x86_64)
  • Xamarin.iOS ( >= 1.0, ABI: ARM64, x64)
  • .NET Standard 2.0 (for usage via portable libs)
  • .NET Core 2.2 (for use via .NET Core targets. Runtime support limited to x64)
  • .NET Framework 4.7.2 (for use via classic .NET Framework targets. Platform support limited to x64)

API Usage

To develop desktop and mobile apps for the SAFE Network install the latest MaidSafe.SafeApp package from NuGet.

This package provides support for mock and non-mock network. By default, non-mock API are used in the package.

Using Mock API

  • Mock API can be used by adding a SAFE_APP_MOCK flag in your project properties at Properties > Build > conditional compilation symbols.
  • When the mock feature is used, a local mock vault file is generated which simulates network operations used to store and retrieve data. The app will then interface with this file rather than the live SAFE network.

Authentication

  • Applications must be authenticated via the SAFE Authenticator to work with the SAFE Network.
  • The desktop authenticator is packed and shipped with the SAFE browser.
  • On mobile devices, use the SAFE Authenticator mobile application.

Documentation

The documentation for the latest safe_app_csharp API is available at docs.maidsafe.net/safe_app_csharp.

We use DocFX to generate static HTML API documentation pages from XML code comments. The API docs are generated and published automatically during the CI build.

To generate a local copy of the API docs, install DocFX and run the following command:

docfx .\docs\docfx.json

Development

Project structure

  • SafeApp: C# API for safe_api
    • Fetch, Inspect, Files, Keys, Wallet, XorUrl
  • SafeApp.AppBindings:
    • safe_api and safe_app IPC bindings generated from safe_api and safe_client_libs
    • Contains native libraries for the platform
  • SafeApp.MockAuthBindings:
    • Mock Safe authentication C# API
    • mock safe_authenticator bindings generated from safe_client_libs
    • Classes required for mock auth functionality
  • SafeApp.Core: Contains
    • Constants used in SafeApp
    • Binding utilities and helper functions

Interoperability between C# managed and unmanaged code

Platform invoke is a service that enables managed code to call unmanaged functions that are implemented in dynamic link libraries or native libraries. It locates and invokes an exported function and marshals its arguments (integers, strings, arrays, structures, and so on) across the interoperation boundary as needed. Check links in useful resources section to know more about how P/Invoke works in different .NET environments and platforms.

Interfacing with Safe Client Libs

The package uses native code written in Rust and compiled into platform specific code. Learn more about the safe_client_libs in the SAFE client libraries wiki.

Instructions to update the bindings can be found in the Update Bindings file.

Tests

We use shared unit tests for safe_app and mock safe_authenticator API which can be run on all supported platforms.

Packaging

Instructions to generate the NuGet package can be found in the Package Instructions file.

Tools required

Contributing

As an open source project we're excited to accept contributions to the code from outside of MaidSafe, and are striving to make that as easy and clean as possible.

With enforced linting and commit style clearly laid out, as well as a list of more accessible issues for any project labeled with Help Wanted.

Useful resources

Copyrights

Copyrights in the SAFE Network are retained by their contributors. No copyright assignment is required to contribute to this project.

Further Help

Get your developer related questions clarified on SAFE Dev Forum. If you're looking to share any other ideas or thoughts on the SAFE Network you can reach out on SAFE Network Forum

License

This SAFE Network library is dual-licensed under the Modified BSD (LICENSE-BSD https://opensource.org/licenses/BSD-3-Clause) or the MIT license (LICENSE-MIT https://opensource.org/licenses/MIT) at your option.