Class NanoTDFClient

NanoTDF SDK Client

Example

import { clientSecretAuthProvider, NanoTDFClient } from '@opentdf/client';

const OIDC_ENDPOINT = 'http://localhost:65432/auth/realms/opentdf-demo';
const KAS_URL = 'http://localhost:65432/api/kas/';

const ciphertext = '...';
const client = new NanoTDFClient({
authProvider: await clientSecretAuthProvider({
clientId: 'tdf-client',
clientSecret: '123-456',
oidcOrigin: OIDC_ENDPOINT,
}),
kasEndpoint: KAS_URL
}
);
client.decrypt(ciphertext)
.then(plaintext => {
console.log('Plaintext', plaintext);
})
.catch(err => {
console.error('Some error occurred', err);
})

Hierarchy

  • default
    • NanoTDFClient

Constructors

  • Create new NanoTDF Client

    The Ephemeral Key Pair can either be provided or will be generate when fetching the entity object. Once set it cannot be changed. If a new ephemeral key is desired it a new client should be initialized. There is no performance impact for creating a new client IFF the ephemeral key pair is provided.

    Parameters

    • optsOrOldAuthProvider: AuthProvider | ClientConfig
    • Optional kasUrl: string
    • Optional ephemeralKeyPair: CryptoKeyPair
    • dpopEnabled: boolean = false

    Returns NanoTDFClient

Properties

allowedKases: OriginAllowList
authProvider: AuthProvider
dataAttributes: string[] = []
dissems: string[] = []
dpopEnabled: boolean
ephemeralKeyPair: Promise<CryptoKeyPair>
iv?: number
kasPubKey?: KasPublicKeyInfo
kasUrl: string
requestSignerKeyPair: Promise<CryptoKeyPair>
INITIAL_RELEASE_IV_SIZE: 3 = 3
IV_SIZE: 12 = 12
KAS_PROTOCOL: "kas" = 'kas'
KEY_ACCESS_REMOTE: "remote" = 'remote'
SDK_INITIAL_RELEASE: "0.0.0" = '0.0.0'

Methods

  • Add attribute to the TDF file/data

    Parameters

    • attribute: string

      The attribute that decides the access control of the TDF.

    Returns void

  • Decrypt ciphertext

    Pass a base64 string, TypedArray, or ArrayBuffer ciphertext and get a promise which resolves plaintext

    Parameters

    • ciphertext: string | ArrayBuffer | TypedArray

      Ciphertext to decrypt

    Returns Promise<ArrayBuffer>

  • Decrypt ciphertext of the legacy TDF, with the older, smaller i.v. calculation.

    Pass a base64 string, TypedArray, or ArrayBuffer ciphertext and get a promise which resolves plaintext

    Parameters

    • ciphertext: string | ArrayBuffer | TypedArray

      Ciphertext to decrypt

    Returns Promise<ArrayBuffer>

  • Encrypts the given data using the NanoTDF encryption scheme.

    Parameters

    • data: string | ArrayBuffer | TypedArray

      The data to be encrypted.

    • Optional options: EncryptOptions

      The encryption options (currently unused).

    Returns Promise<ArrayBuffer>

    A promise that resolves to the encrypted data as an ArrayBuffer.

    Throws

    If the initialization vector is not a number.

  • Explicitly get a new Entity Object using the supplied EntityAttributeService.

    This method is expected to be called at least once per encrypt/decrypt cycle. If the entityObject is expired then this will need to be called again.

    Returns Promise<void>

    Security

    the ephemeralKeyPair must be set in the constructor if desired to use here. If this is wished to be changed then a new client should be initialized.

    Performance

    key pair is generated when the entity object is fetched IFF the ephemeralKeyPair is not set. This will either be set on the first call or passed in the constructor.

  • Rewrap key

    Parameters

    • nanoTdfHeader: ArrayBuffer | TypedArray

      the full header for the nanotdf

    • kasRewrapUrl: string

      key access server's rewrap endpoint

    • magicNumberVersion: ArrayBuffer | TypedArray

      nanotdf container version

    • clientVersion: string

      version of the client, as SemVer

    Returns Promise<CryptoKey>

    Important

    the fetchEntityObject method must be called prior to

Generated using TypeDoc