sdk
/
0.1.0-beta.1718
sdk 0.1.0-beta.1718
Install from the command line:
Learn more about npm packages
$ npm install @opentdf/sdk@0.1.0-beta.1718
Install via package.json:
"@opentdf/sdk": "0.1.0-beta.1718"
About this version
This project presents client code to write and read a OpenTDF data formats. This included NanoTDF, Dataset TDF, and ZTDF.
const oidcCredentials: RefreshTokenCredentials = {
clientId: keycloakClientId,
exchange: 'refresh',
refreshToken: refreshToken,
oidcOrigin: keycloakUrl,
}
const authProvider = await AuthProviders.refreshAuthProvider(oidcCredentials);
const client = new NanoTDFClient({authProvider, kasEndpoint});
const cipherText = await client.encrypt(plainText);
const clearText = await client.decrypt(cipherText);
const client = new TDF3Client({
clientId: "tdf-client",
kasEndpoint: 'http://localhost/kas',
refreshToken: 'token', // Here is only difference in usage, browser build needs oidc tocken
oidcOrigin: 'http://localhost/oidc',
});
const source = new ReadableStream({
pull(controller) {
controller.enqueue(new TextEncoder().encode(string));
controller.close();
},
});
const ciphertextStream = await client.encrypt({ offline: true, source });
// Optionally: Save ciphertextStream to file or remote here.
// For demo purposes, we pipe to decrypt.
const plaintextStream = await client.decrypt({
source: { type: 'stream', location: ciphertextStream }
});
const plaintext = await plaintextStream.toString(); // could be also ct.toFile('img.jpg');
console.log(`deciphered text :${plaintext}`);
- The 'RemoteStorage' features have been moved into a separate library, @opentdf/remote-storage.
- We have replaced all usages of node's
Buffer
with the web-friendlierUInt8Array
. You will most likely see this in the return types of some functions.
Assets
- sdk-0.1.0-beta.1718.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0