/Passwork

A .NET Standard Connector for Passwork Pro (self hosted) edition

Primary LanguageC#MIT LicenseMIT

nuget badge

.NET Connector for Passwork Pro

A .NET Standard 2.1 library for the REST API of Passwork Pro (self hosted) instance. Based on v4 of the REST API.

This .NET Connector uses a database-like context object, to access vaults, folders and passwords. It supports both master password enabled/disabled situations.

Getting started

Get yourself a context object, which gives access to all options.

//create the client 
var client = new Client("https://your-server/api/v4/");

//get the context object by login
var ctx = await client.Login("<apikey>", "<optional masterpassword>");

//Adding a vault, returns a `IVault` object.
var vault = await ctx.AddVault("SampleVault", false);

//With the vault object , you can add Folders (and passwords directly in the vault).
var folder = vault.AddFolder("SampleFolder");

//Creating a password in the folder object you just obtained.
var p = folder.CreatePassword();
p.Name = "Hello";
p.Pass = "Some secretpassword";
await p.Save();

To read the password field and the custom fields in an IPassword object, you must first unlock the secrets by calling Unlock. Example:

var folder = await vault.GetFolderByName("MyFolder");
var passes = await folder.GetPasswords();

//lets use the first password in this folder.
var p = passes[0];
await p.Unlock();

//after Unlock , the password is readable
Console.WriteLine($"{p.Pass}");

You can also search passwords, based on some query string, or tags, or colors. Searching can start from the context, or from a specific vault.

var passes = await ctx.Query()
                    .WhereFieldsLike("vpn")
                    .WhereTag("topsecret")
                    .Get();

Context

From the context object you receive, after the login, you can perform the following methods.

Methods (async) Returns
AddVault(string name, bool isPrivate) IVault
GetVaults() IVault[]
GetVaultByName(string name) IVault
GetVaultByID(string id) IVault
GetPasswordByID(string id) IPassword
GetPasswordsRecent() IPassword[]
GetPasswordsFavorite() IPassword[]
GetTags() string[]
GetColors() int[]

IVault

Properties are Id, Name

Methods (async) Returns
CreatePassword() INewPassword
GetPasswords() IPassword[]
GetFolders() IFolder[]
GetFolderByName(string name) IFolder
AddFolder(string name) IFolder
Delete() bool
GetColors() int[]
GetTags() string[]

IFolder

Properties are : Id, Name, AmountFolders, AmountPasswords.

Methods (async) Returns
Refresh() -
AddFolder(string name) IFolder
Rename(string name) IFolder
GetFolders() IFolder[]
CreatePassword() INewPassword
GetPasswords() IPassword[]
Delete() bool

INewPassword

Properties are : Id, Name, Url, Password, Login, Description, Tags, Color, CustomRecords.

An password object which is just created and not yet saved to the database. Calling save will return you IPassword , with more methods.

Methods (async) Returns
Save() IPassword

IPassword

Extension of INewPassword, provides additional methods.

Methods (async) Returns
Save() -
Unlock() -
Delete() bool
SetFavorite(bool IsFavorite) -
AddAttachment(name, byte[] content) -
GetAttachments() IAttachment

IAttachment

Properties are : Id , Name

Methods (async) Returns
GetContent() byte[]
Delete() bool