Skip to content
sdk / 0.1.0-beta.1705

sdk 0.1.0-beta.1705

Install from the command line:
Learn more about npm packages
$ npm install @opentdf/sdk@0.1.0-beta.1705
Install via package.json:
"@opentdf/sdk": "0.1.0-beta.1705"

About this version

An OpenTDF Library for Browser Applications

This project presents client code to write and read a OpenTDF data formats. This included NanoTDF, Dataset TDF, and ZTDF.

Usage

NanoTDF

  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);

ZTDF

  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}`);

Upgrading from 1.x

  • 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-friendlier UInt8Array. You will most likely see this in the return types of some functions.

Details

  • sdk
  • @opentdf opentdf
  • 19 days ago
  • BSD-3-Clause-Clear
  • 53 dependencies

Assets

  • sdk-0.1.0-beta.1705.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0