Class: Ztdf
The Ztdf class represents a container of encrypted data in the Zero Trust Data Format (ZTDF). It contains the methods and properties needed to manage the encrypted data and its associated manifest.
Properties
manifest
- Type:
ZtdfManifest - Description: The manifest associated with the encrypted data.
payload
- Type:
Uint8Array - Description: The encrypted data as a byte array.
Methods
static fromManifestAndPayload(manifest: ZtdfManifest, payload: Uint8Array): Ztdf
- Description: Static method to create an instance from the manifest and payload.
- Parameters:
manifest: The manifest associated with the encrypted data.payload: The encrypted data as a byte array.
- Returns: A new
Ztdfinstance. - Throws:
SdsdkErrorif the input is invalid or required properties are missing.
static fromZip(zipBuffer: Uint8Array): Promise<Ztdf>
- Description: Static method to create an instance from a zip buffer.
- Parameters:
zipBuffer: A Uint8Array representation of a ztdf file.
- Returns: A new
Ztdfinstance. - Throws:
SdsdkErrorif the input is invalid or required properties are missing.
toZip(): Promise<Uint8Array>
- Description: Converts the instance into a serializable buffer in ZIP format.
- Returns: Promise<Uint8Array>
- Throws:
SdsdkErrorif the input is invalid or required properties are missing.
⚠️ Note on serialized data persistence
When serializing (toZip) and deserializing (fromZip), some platforms such as web browsers enforce size limits on local storage mechanisms (e.g.,localStorage,sessionStorage). These limitations are not handled by the SDK.
👉 The client application is responsible for compatibility and must choose an appropriate persistence strategy (e.g., using IndexedDB, server-side storage, etc.) depending on platform constraints and application requirements.
Types
ZtdfManifest
- Description: Object containing the ZTDF manifest. For more information refer to the ZTDF specification.
Examples
javascript
const config: SdsdkConfiguration = {
// for more details, see class: Sdsdk
}
const sdsdkInstance = new Sdsdk(config);
const ztdf = await sdsdkInstance.encrypt({
data: new TextEncoder().encode('encryptedData')
})
const zipSerialization = await ztdf.toZip()
// persistence of the zip in the database, in a file, etc...
const ztdfInstance = await Ztdf.fromZip(zipSerialization)
const decryptedData = await sdsdk.decrypt(ztdfInstance);