Ace4896.DBus.Services.Secrets 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ace4896.DBus.Services.Secrets --version 1.0.0                
NuGet\Install-Package Ace4896.DBus.Services.Secrets -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ace4896.DBus.Services.Secrets" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ace4896.DBus.Services.Secrets --version 1.0.0                
#r "nuget: Ace4896.DBus.Services.Secrets, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Ace4896.DBus.Services.Secrets as a Cake Addin
#addin nuget:?package=Ace4896.DBus.Services.Secrets&version=1.0.0

// Install Ace4896.DBus.Services.Secrets as a Cake Tool
#tool nuget:?package=Ace4896.DBus.Services.Secrets&version=1.0.0                

DBus.Services.Secrets

High-level .NET bindings for the D-Bus Secret Service API.

These bindings were made using Tmds.DBus.Protocol and Tmds.DBus.SourceGenerator, making them trimmer and AOT friendly.

Requirements

The bindings target .NET 6.0 and .NET 7.0.

Basic Usage

// Connect to the D-Bus Secret Service API
// Sessions can use either plaintext or encrypted transport
SecretService secretService = await SecretService.ConnectAsync(EncryptionType.Dh);  // DH Key Agreement for Encryption

// Items are stored in within collections
// Collections can be retrieved using their alias
// Note that collection retrieval can fail, so this would need to be handled
Collection? defaultCollection = await secretService.GetDefaultCollectionAsync();
if (defaultCollection == null)
{
    // ... handle case where collection is not found
}

// Items are created with the following:
// - Label - The displayed label in e.g. GNOME Keyring, KWallet etc.
// - Lookup Attributes - These are used to search for the item later
// - Secret - The secret value as a byte array
// - Content Type - A content type hint for the secret value
string itemLabel = "MySecretValue";
Dictionary<string, string> lookupAttributes = new()
{
    { "my-lookup-attribute", "my-lookup-attribute-value" }
};

byte[] secretValue = Encoding.UTF8.GetBytes("my secret value");
string contentType = "text/plain; charset=utf8";

// Note that item creation can fail, e.g. if the collection could not be unlocked
Item? createdItem = await defaultCollection.CreateItemAsync(label, lookupAttributes, secretBytes, contentType, true);
if (createdItem == null)
{
    // ... handle case where item creation failed
}

// Later, if we want to retrieve this secret value, we need to search using the same lookup attributes
// Note that it's possible for multiple items to match the provided lookup attributes
Item[] matchedItems = await defaultCollection.SearchItemsAsync(lookupAttributes);
foreach (Item matchedItem in matchedItems)
{
    byte[] matchedSecret = await item.GetSecretAsync();
    string matchedSecretString = Encoding.UTF8.GetString(secret);   // my secret value
}

Documentation

The API documentation is auto-generated using docfx, and can be found here.

To preview the generated documentation locally, run docfx docfx_project/docfx.json --serve, which will serve the website at http://localhost:8080.

License

These bindings are licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Ace4896.DBus.Services.Secrets:

Package Downloads
Nickvision.Aura

A cross-platform base for Nickvision applications

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 601 2/21/2024
1.2.1 274 11/18/2023
1.2.0 12,797 9/12/2023
1.1.0 1,847 7/14/2023
1.0.0 230 7/14/2023