This project is focused on providing web client support for the OpenTDF family of data protection formats and protocols. Notably, it is a web-friendly library @opentdf/client
, and tools and support for testing it and building it into web applications.
Do you want a quick demonstration of OpenTDF? See Quickstart
Ready to begin integrating into your system?
Start a local, blank cluster. See Integrate
// currently we support only ESM import
import { AuthProviders, NanoTDFClient } from '@opentdf/client';
const oidcCredentials: RefreshTokenCredentials = {
clientId: keycloakClientId,
exchange: 'refresh',
refreshToken: refreshToken,
oidcOrigin: keycloakUrlWithRealm,
}
const authProvider = await AuthProviders.refreshAuthProvider(oidcCredentials);
const client = new NanoTDFClient(authProvider, access);
const cipherText = await client.encrypt(plainText);
const clearText = await client.decrypt(cipherText);
For files:
// currently we support only ESM import
import { FileClient } from '@opentdf/client';
// for file Encryption
const fileClient = new FileClient(
{ ...oidcCredentials, kasEndpoint }, ['userWeGrantAccessTo']
);
const cipherStream = await fileClient.encrypt('originalFile.jpeg');
await cipherStream.toFile('encryptedFile.tdf');
const fromReadStream = await fileClient.decrypt(fs.createReadStream('encryptedFile.tdf'));
await fromReadStream.toFile('decryptedFile.jpeg')
FileClient encrypt/decrypt supports Webstream, Node stream, Buffer, Array Buffer, String (as path to file).
Review examples to see how to integrate. See Examples
make dist
Developing with this code requires a recent version of npm
and node
.
-
Install nvm
- see https://github.com/nvm-sh/nvm#installing-and-updating
nvm use
will installnpm
andnode
To check out, build, and validate your installation, and test the sample web application, you may:
nvm use
make test
make start