KeeperSecurity.Vault Namespace

Provides types for loading and storing the Keeper Vault data.

Example

C#
using System;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using KeeperSecurity.Authentication;
using KeeperSecurity.Vault;

internal static class Program
{
   private static async Task Main()
   {
       IAuthentication auth = await ConnectToKeeperAs("username@company.com");
       var vault = new VaultOnline(auth);
       Console.WriteLine("\nRetrieving records...");
       await vault.SyncDown();

       Console.WriteLine($"Hello {auth.Username}!");
       Console.WriteLine($"Your vault has {vault.RecordCount} records.");

       // Find record with title "Google"
       var search = vault.KeeperRecords.FirstOrDefault(x => string.Compare(x.Title, "Google", StringComparison.InvariantCultureIgnoreCase) == 0);
       // Create a record if it does not exist.
       if (search == null)
       {
           var typed = new TypedRecord("login")
           {
               Title = "Google",
               Notes = "Stores google credentials"
           };
           var loginRecord = new TypedRecordFacade<LoginRecordType>(typed);
           loginRecord.Fields.Login = "/Account Name/";
           loginRecord.Fields.Password = "/Account Password/";
           loginRecord.Fields.Url = "https://google.com";

           search = await vault.CreateRecord(typed);
       }

       // Update record
       if (search is TypedRecord tr)
       {
           var recordField = new RecordTypeField("secret", "Security Token");
           if (!tr.FindTypedField(recordField, out var rf))
           {
               rf = recordField.CreateTypedField();
               tr.Custom.Add(rf);
           }
           var tokenValue = rf.ObjectValue == null ? "1" : rf.ObjectValue.ToString() + "1";
       }
       else if (search is PasswordRecord pr)
       {
           pr.SetCustomField("Security Token", "11111111");
       }
       search = await vault.UpdateRecord(search);

       // find file attachment
       var attachment = vault.RecordAttachments(search)
           .FirstOrDefault(x => string.Equals(x.Title, "google", StringComparison.InvariantCultureIgnoreCase));
       if (attachment == null)
       {
           // Upload local file "google.txt"
           var uploadTask = new FileAttachmentUploadTask("google.txt")
           {
               Title = "Google",
           };
           await vault.UploadAttachment(search, uploadTask);
       }
       else
       {
           // Download attachment into local file "google.txt"
           await using var stream = File.OpenWrite("google.txt");
           await vault.DownloadAttachment(search, attachment.Id, stream);

           // Delete attachment. Remove it from the record 
           await vault.DeleteAttachment(search, attachment.Id);
       }

       // Find shared folder with name "Google".
       var sharedFolder = vault.SharedFolders
           .FirstOrDefault(x => string.Compare(x.Name, "Google", StringComparison.InvariantCultureIgnoreCase) == 0);
       if (sharedFolder == null)
       {
           // Create shared folder.
           var folder = await vault.CreateFolder("Google", null, new SharedFolderOptions
           {
               ManageRecords = true,
               ManageUsers = false,
               CanEdit = false,
               CanShare = false,
           });
           vault.TryGetSharedFolder(folder.FolderUid, out sharedFolder);
       }

       // Add user to shared folder.
       await vault.PutUserToSharedFolder(sharedFolder.Uid, "user@google.com", UserType.User, new SharedFolderUserOptions
       {
           ManageRecords = false,
           ManageUsers = false,
       });

       // Add record to shared folder.
       await vault.MoveRecords(new[] { new RecordPath { RecordUid = search.Uid } }, sharedFolder.Uid, true);
   }
}

Classes

ApplicationRecord Represents a Keeper Secret Manager Application Record.
AttachmentFile Represents attachment file.
AttachmentFileThumb Represents a thumbnail of attachment.
AttachmentUploadTask Creates an attachment upload task.
BatchResult Represents Batch Vault Updater Summary
BatchVaultOperations Represents Batch Vault Updater
CustomField Represents a custom field.
ExternalRecordShare Represents External / One-Time Share
ExternalRecordShareExtensions Miscellaneous External Share Methods
ExtraField Represents an extra field.
FieldType Record Types Schema: Field Type definition.
FieldTypeAddress "address" field type
FieldTypeBankAccount "bankAccount" field type
FieldTypeHost "host" field type
FieldTypeKeyPair "keyPair" field type
FieldTypeName "name" field type
FieldTypePasskey "passkey" field type
FieldTypePaymentCard "paymentCard" field type
FieldTypePhone "phone" field type
FieldTypeSecurityQuestion "securityQuestion" field type
FileAttachmentUploadTask Creates a file attachment upload task.
FileRecord Represents a Keeper File Record.
FolderData 
FolderNode Represents folder.
InMemoryKeeperStorage Provides in memory implementation of IKeeperStorage interface.
KeeperImport Keeper Import methods
KeeperRecord Represents generic Keeper Record
NoActiveShareWithUserException Represents an exception that occurs when current user requests other user's public for the first time.
PasswordRecord Represents a Legacy Keeper Record.
RecordField Record Types Schema: Field definition.
RecordHistory Represents a record history
RecordPath Represents a record in folder.
RecordSharePermissions Represent record sharing information
RecordType Record Types Schema: Record Type definition.
RecordTypeField Record Types Schema: Record Field definition.
RecordTypesConstants Record Types Schema: Fields
SharedFolder Represents Shared Folder.
SharedFolderOptions Defines shared folder user and record permissions.
SharedFolderPermission Represents shared folder user permissions.
SharedFolderRecord Represents shared folder record permissions.
SharedFolderRecordOptions Represents shared folder record permissions.
SharedFolderRecordPermissions Represents record permissions in shared folder.
SharedFolderUserOptions Defines shared folder user permissions.
ShareWithUsers Represent user list available for sharing
SqliteKeeperStorage 
SyncDownRestExtension 
Team Represents team properties that user is member of.
TeamInfo Represents basic team properties.
TypedFieldT Represents a typed field.
TypedRecord Represents a Typed Record
UserRecordPermissions Represents record permissions for user.
VaultData Represents Keeper vault loaded from the IKeeperStorage and decrypted.
VaultException The exception that is thrown by the Vault module.
VaultOnline Represents Keeper Vault connected to Keeper server.
VaultOnlineSecretManagerConfiguration 

Interfaces

IAttachment Defines property for file attachment
IAttachmentUploadTask Defines properties of file upload task.
IBatchVaultOperations Declares Batch Vault Updater methods
IFieldTypeSerialize Defines access methods for compound record types
IKeeperStorage Defines properties for offline Keeper vault storage.
IRecordAccessPath Defines record access path properties.
IRecordShareOptions Defines shared folder record permissions.
IRecordTypeField Defines common properties for Record Field
ISecretManager Define methods for Keeper Secret Maneger (KSM)
ISecretManagerConfiguration Defines properties of Secrets Manager configuration
ISerializeTypedField Defines methods for typed field serialization
ISharedFolderAccessPath Defines shared folder access path properties.
ISharedFolderPermission Defines properties for shared folder user permissions.
IStorageFolder Defines properties for folder storage.
IStorageFolderRecord Defines properties record-folder link.
IStorageNonSharedData Defines non-shared data storage.
IStorageRecord Defines Record storage properties.
IStorageRecordKey Defines Record Key Metadata storage.
IStorageRecordType Defines Record Types storage properties.
IStorageSharedFolder Defines properties for shared folder storage.
IStorageSharedFolderKey Defines shared folder key storage.
IStorageTeam Defines properties for team storage.
IStorageUserEmail Defines user's email storage properties
IThumbnailUploadTask Defines properties of thumbnail upload task.
ITypedField Defines properties for typed record field
IUserShareOptions Defines shared folder user permissions.
IVault Defines methods for modifying the vault records and folders.
IVaultData Defines properties and methods of decrypted Vault data.
IVaultFileAttachment Defines methods to manipulate file attachments.
IVaultSettings Defines vault settings properties
IVaultSharedFolder Defines methods to manipulate Shared Folders.
IVaultUi Defines methods for interaction between Vault API and user.

Enumerations

FolderType Specifies folder types.
KeyType Specifies key used for entity encryption.
RecordChange 
RecordFieldMultiple Specifies if Record Field allows multiple values.
RecordMatch Represents record existing match strategy
RecordTypeScope Specifies Record Type Scope
Severity Specifies log message severity
UserType Specifies shared folder user type.

See Also