Class: SdsdkZtdf
The SdsdkZtdf 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
toJson(): ZtdfJsonResult
- Description: Converts the instance to a serializable JSON object.
- Returns: ZtdfJsonResult
fromJson(input: ZtdfJsonResult)
- Description: Creates a new
SdsdkZtdfinstance from a JSON object. - Parameters:
input: ZtdfJsonResult
- Returns: A new
SdsdkZtdfinstance. - Throws:
SdsdkErrorif the input is invalid or required properties are missing.
⚠️ Note on serialized data persistence
When serializing (toJson,Buffer.from(...).toString('base64'), etc.) and deserializing (fromJson), 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
ZtdfJsonResult
Description: Serializable object containing all ZTDF information.
Properties:
Property Type Description metadata object ZTDF metadata metatdata.version number Version of ZtdfJsonResult (supported value: 1) manifest ZtdfManifest Object containing the manifest information payload Uint8Array Encrypted data as a byte array
ZtdfManifest
- Description: Object containing the ZTDF manifest. For more information refer to the ZTDF specification.
Example Usage
javascript
const jsonData = {
metadata: {
version: 1,
},
payload: new TextEncoder().encode('encryptedData'),
manifest: {
// Manifest properties
},
};
const ztdfInstance = SdsdkZtdf.fromJson(jsonData);
// Accessing instance properties
console.log(ztdfInstance.manifest);
console.log(ztdfInstance.payload);
// Converting the instance to a JSON object
const jsonData2 = ztdfInstance.toJson();
console.log(jsonData2);
// Serialize into base64 data
b64OfZtdfInstance = Buffer.from(JSON.stringify(jsonData2)).toString('base64');