1.3.0 • Published 8 months ago

@opentdf/client v1.3.0

Weekly downloads
-
License
BSD-3-Clause-Clea...
Repository
github
Last release
8 months ago

An OpenTDF Library for Browsers and NodeJS Clients

This project packages a set of javascript modules that can write and read a variety of OpenTDF data formats, including NanoTDF, Dataset TDF, and the TDF3 with JSON envelopes.

Usage

NanoTDF

  const oidcCredentials: RefreshTokenCredentials = {
    clientId: keycloakClientId,
    exchange: 'refresh',
    refreshToken: refreshToken,
    oidcOrigin: keycloakUrl,
  }
  const authProvider = await AuthProviders.refreshAuthProvider(oidcCredentials);
  const client = new NanoTDFClient(authProvider, access);
  const cipherText = await client.encrypt(plainText);
  const clearText = await client.decrypt(cipherText);

TDF3

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

Examples

Review examples to see how to integrate. See Examples

2.1.0-beta.1639

8 months ago

2.0.0-beta.1623

8 months ago

2.0.0-beta.1618

8 months ago

2.0.0-beta.1537

9 months ago

2.0.0-beta.1515

10 months ago

2.0.0-beta.1502

10 months ago

2.0.0-beta.1461

10 months ago

2.0.0-beta.1437

10 months ago

2.0.0-beta.1362

1 year ago

2.0.0-beta.1488

10 months ago

2.0.0-beta.1370

1 year ago

2.0.0-beta.1412

11 months ago

2.0.0-beta.1326

1 year ago

2.0.0-beta.1204

1 year ago

2.0.0-beta.1202

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

2.0.0-beta.1165

2 years ago

2.0.0-beta.1168

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0-beta.1000

2 years ago

1.3.0-beta.1069

2 years ago

1.2.1-beta.1016

2 years ago

2.0.0-beta.1150

2 years ago

2.0.0-beta.1096

2 years ago

1.1.0-beta.977

2 years ago

2.0.0-beta.1131

2 years ago

1.0.1-beta.925

2 years ago

2.0.0-beta.1179

2 years ago

1.3.1-beta.1080

2 years ago

1.3.0-beta.1073

2 years ago

1.2.0-beta.998

2 years ago

1.2.1-beta.1041

2 years ago

1.2.1-beta.1025

2 years ago

1.3.0-rc.1074

2 years ago

1.2.1-beta.1028

2 years ago

0.5.0-beta.786

2 years ago

1.0.0

2 years ago

1.0.0-rc.889

2 years ago

0.4.0-beta.784

2 years ago

0.5.0-rc.819

2 years ago

0.5.0-beta.791

2 years ago

0.5.0-beta.813

2 years ago

0.4.0-beta.739

2 years ago

0.4.0-beta.715

2 years ago

0.4.0-beta.765

2 years ago

0.4.0-beta.721

2 years ago

0.4.0-beta.654

2 years ago

0.4.0-beta.772

2 years ago

0.4.0-beta.661

2 years ago

0.4.0-beta.644

2 years ago

0.4.0-beta.607

2 years ago

0.4.0-beta.636

2 years ago

0.4.0-beta.501

2 years ago

0.4.0-beta.552

2 years ago

0.4.0-beta.540

2 years ago

0.3.0-beta.374

3 years ago

0.3.0-beta.364

3 years ago

0.3.0-beta.359

3 years ago