@opentdf/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

An OpenTDF Library for Browser Applications

This project presents client code to write and read a OpenTDF data formats. This included NanoTDF and collections and Base TDF3.

Usage

NanoTDF

import { type Chunker, OpenTDF } from '@opentdf/sdk';

const oidcCredentials: RefreshTokenCredentials = {
  clientId: keycloakClientId,
  exchange: 'refresh',
  refreshToken: refreshToken,
  oidcOrigin: keycloakUrl,
};
const authProvider = await AuthProviders.refreshAuthProvider(oidcCredentials);
const client = new OpenTDF({
  authProvider,
  defaultCreateOptions: {
    defaultKASEndpoint: kasEndpoint, // Server used for Key Access Control
  },
  dpopKeys: authProvider.getSigningKey(),
});
const cipherText = await client.createNanoTDF({
  source: { type: 'stream', location: source },
});

const clearText = await client.read({ type: 'stream', location: cipherText });

ZTDF

import { type Chunker, OpenTDF } from '@opentdf/sdk';

const oidcCredentials: RefreshTokenCredentials = {
  clientId: keycloakClientId,
  exchange: 'refresh',
  refreshToken: refreshToken,
  oidcOrigin: keycloakUrl,
};
const authProvider = await AuthProviders.refreshAuthProvider(oidcCredentials);
const client = new OpenTDF({
  authProvider,
  defaultCreateOptions: {
    defaultKASEndpoint: kasEndpoint, // Server used for Key Access Control
  },
  dpopKeys: authProvider.getSigningKey(),
});
const cipherText = await client.createZTDF({
  source: { type: 'stream', location: source },
  autoconfigure: false,
});

const clearText = await client.read({ type: 'stream', location: cipherText });

/@opentdf/sdk/

    Package Sidebar

    Install

    npm i @opentdf/sdk

    Weekly Downloads

    1,569

    Version

    0.3.1

    License

    BSD-3-Clause-Clear

    Unpacked Size

    2.28 MB

    Total Files

    536

    Last publish

    Collaborators

    • pflynn-virtru
    • the_krakatoa
    • virtru-admin
    • opentdf-bot