@basis-theory/basis-theory-js-encryption-azure
v1.0.0
Published
Azure (Key Vault) Encryption Provider for the [Basis Theory](https://basistheory.com/) JS [Encryption SDK](https://github.com/Basis-Theory/basis-theory-js-encryption).
Downloads
4
Maintainers
Keywords
Readme
BasisTheory JS Azure Encryption Provider
Azure (Key Vault) Encryption Provider for the Basis Theory JS Encryption SDK.
Installation
Using Node Package Manager
npm install --save @basis-theory/basis-theory-js-encryption-azure
Using Yarn
yarn add @basis-theory/basis-theory-js-encryption-azure
Documentation
For further documentation and examples, please refer to our Docs.
Usage
Initialization and Usage with BasisTheoryEncryption
It's required that user provides the vaulUrl to be used for fetching keys/secrets during initialization.
import { BasisTheoryEncryption } from '@basis-theory/basis-theory-js-encryption';
import { BasisTheoryAzureEncryptionProvider } from '@basis-theory/basis-theory-js-encryption-azure';
const azureProvider = new BasisTheoryAzureEncryptionProvider().init({
vaulUrl: 'https://custom-kms.vault.azure.net'
});
const btEncryption = await new BasisTheoryEncryption().init([azureProvider]);
Caching, VaultUrl and Additional Options
The default cache implementation uses node-cache, but users can implement their own from the interface. Users can also provide their own methods for fetching/saving keys using the keyVaultOptions
object.
import { BasisTheoryEncryption } from '@basis-theory/basis-theory-js-encryption';
import { BasisTheoryAzureEncryptionProvider } from '@basis-theory/basis-theory-js-encryption-azure';
const azureProvider = new BasisTheoryAzureEncryptionProvider().init({
cache: new CacheService(),
tokenCredential: new DefaultAzureCredential()
vaulUrl: 'https://custom-kms.vault.azure.net',
keyVaultOptions: {
rsaKeySize: 2048,
keyExpirationInDays: 90,
getKeyByKeyId: (keyId: string) => { return key; },
getKeyByName: (name: string, prov: string, alg: string) => { return key; },
saveKey: (key: ProviderEncryptionKey ) => { return key; },
},
});
const btEncryption = await new BasisTheoryEncryption().init([azureProvider]);
Development
The provided scripts with the SDK will check for all dependencies, build the solution, and run all tests.
Dependencies
- Docker
- Docker Compose
- NodeJS > 10.12.0
- Yarn
Build the SDK and run Tests
Run the following command from the root of the project:
make verify