BasisTheory.net 1.27.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package BasisTheory.net --version 1.27.1                
NuGet\Install-Package BasisTheory.net -Version 1.27.1                
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="BasisTheory.net" Version="1.27.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BasisTheory.net --version 1.27.1                
#r "nuget: BasisTheory.net, 1.27.1"                
#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 BasisTheory.net as a Cake Addin
#addin nuget:?package=BasisTheory.net&version=1.27.1

// Install BasisTheory.net as a Cake Tool
#tool nuget:?package=BasisTheory.net&version=1.27.1                

Basis Theory .NET SDK

NuGet Verify

The Basis Theory .NET SDK for .NET Core 2.1+, .NET Standard 2.1+, and .NET Framework 4.6.1+.

Installation

Using the .NET Core command-line interface (CLI) tools:

dotnet add package BasisTheory.net

Using the NuGet Command Line Interface (CLI):

nuget install BasisTheory.net

Using the Package Manager Console:

Install-Package BasisTheory.net

Documentation

For a complete list of endpoints and examples, please refer to our API docs

Usage

Per-request configuration

All of the service methods accept an optional RequestOptions object. This is used if you want to set a correlation ID or if you want to set a per-request BT-API-KEY

var requestOptions = new RequestOptions();
requestOptions.ApiKey = "API KEY";
requestOptions.CorrelationId = Guid.NewGuid().ToString();

Using a custom HttpClient

Each client can be configured to use a custom HttpClient:

var httpClient = new HttpClient();
var client = new TokenClient(apiKey, httpClient: httpClient);

Setting a custom API Url

Each client can set a custom API Url, such as calling a deployed instance of the Token Proxy.

var client = new TokenClient(apiKey, apiBaseUrl: "https://token-proxy.somedomain.com");

AspNetCore Setup

See complete documentation in the BasisTheory.net.AspNetCore project

Encryption and Key Management

Encryption and Key Management is provided to enable you to manage your own data encryption and key storage with your KMS provider of choice.

Key Management

var rsaProviderKeyFactory = new RSAKeyVaultProviderKeyFactory();

var providerKeyService = new ProviderKeyService(new CachingService(), 
  new List<IProviderKeyFactory> { 
    rsaProviderKeyFactory 
  });

// Retrieves or creates a key by name with a registered IProviderKeyFactory for the provided provider and algorithm
var providerEncryptionKey = providerKeyService.GetOrCreateKeyAsync("encryption-key", "AZURE", "RSA");

providerEncryptionKey = providerKeyService.GetKeyByKeyIdAsync(providerEncryptionKey.KeyId);

Encrypt and Decrypt

// Encryption Factory which has a provider and algorithm implementation for the ProviderEncryptionKey
var rsaEncryptionFactory = new RSAKeyVaultEncryptionFactory();
var encryptionService = new EncryptionService(new List<IEncryptionFactory> { 
  rsaEncryptionFactory 
});

// Provider Encryption Key which was generated from the ProviderKeyService
var providerEncryptionKey = new ProviderEncryptionKey {
  KeyId = Guid.NewGuid().ToString(),
  ProviderKeyId = "https://custom-kms.vault.azure.net/keys/encryption-key/809b10a3cedb83e83bbaeb5e8c762fab",
  Algorithm = "RSA",
  Provider = "AZURE"
};

// Encrypt string to get back a wrapped EncryptedData with a reference to the ProvderEncryptionKey
var encryptedData = encryptionService.Encrypt("My Super Secret", providerEncryptionKey);

// Use Encrypted Data and Provider Encryption Key to decrypt the the value and get back the original plaintext
var plaintext = encryptionService.Decrypt(encryptedData, providerEncryptionKey);

Development

The provided scripts with the SDK will check for all dependencies, start docker, build the solution, and run all tests.

Dependencies

Build the SDK and run Tests

Run the following command from the root of the project:

make verify
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on BasisTheory.net:

Package Downloads
BasisTheory.net.AspNetCore

Basis Theory .NET AspNetCore Extensions

BasisTheory.net.Encryption.Azure

Basis Theory .NET Azure Encryption Provider

BasisTheory.net.Encryption.Azure.AspNetCore

Basis Theory .NET Azure Encryption AspNetCore Extensions

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 32 11/14/2024
3.2.0 77 10/17/2024
3.1.0 201 7/10/2024
3.0.0 116 7/2/2024
2.4.0 391 6/25/2024
2.3.0 1,004 5/8/2024
2.2.0 121 5/3/2024
2.1.0 3,406 3/28/2024
2.0.0 8,725 1/16/2024
1.53.2 191 12/20/2023
1.52.0 747 11/17/2023
1.51.0 854 10/6/2023
1.50.0 683 8/29/2023
1.49.0 1,797 5/16/2023
1.48.2 331 5/9/2023
1.45.1 1,768 1/23/2023
1.45.0 433 1/17/2023
1.44.0 970 11/29/2022
1.43.0 1,081 11/17/2022
1.42.0 1,389 10/21/2022
1.41.0 1,971 9/15/2022
1.39.0 2,297 7/28/2022
1.38.0 1,322 7/20/2022
1.37.1 1,634 7/13/2022
1.37.0 1,240 7/7/2022
1.36.1 1,448 6/30/2022
1.36.0 1,363 6/18/2022
1.35.0 1,196 6/16/2022
1.34.0 1,460 6/10/2022
1.33.0 1,202 6/8/2022
1.32.0 1,484 6/3/2022
1.31.0 1,204 6/2/2022
1.30.0 1,211 5/31/2022
1.29.0 1,193 5/26/2022
1.28.0 2,184 4/6/2022
1.27.1 1,238 4/4/2022
1.27.0 1,259 4/4/2022
1.26.0 1,480 3/21/2022
1.25.0 1,351 3/17/2022
1.24.0 1,803 1/31/2022
1.23.0 1,429 1/13/2022
1.22.0 1,270 1/11/2022
1.21.0 1,228 1/11/2022
1.20.0 1,140 1/10/2022
1.19.0 676 1/3/2022
1.18.0 4,346 11/24/2021
1.17.0 3,638 11/24/2021
1.16.0 1,103 11/8/2021
1.15.0 938 11/3/2021
1.14.0 840 11/2/2021
1.13.0 824 11/1/2021
1.12.0 828 11/1/2021
1.11.0 962 10/29/2021
1.10.0 822 10/28/2021
1.9.0 910 10/27/2021
1.8.0 922 10/26/2021
1.7.0 1,026 10/20/2021
1.6.0 1,218 10/14/2021
1.5.0 812 10/14/2021
1.4.0 1,502 8/22/2021
1.3.0 873 8/22/2021
1.2.3 813 8/22/2021
1.2.2 979 8/15/2021
1.2.1 799 8/15/2021
1.2.0 806 8/15/2021
1.1.0 847 8/14/2021
1.0.1 825 8/14/2021
1.0.0 987 8/8/2021