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.
b64Payload
- Type:
string
- Description: The encrypted data as a Base64-encoded string.
Methods
toJson(): ZtdfJsonResult
- Description: Converts the instance to a serializable JSON object.
- Returns: ZtdfJsonResult
fromJson(input: ZtdfJsonResult)
- Description: Creates a new
SdsdkZtdf
instance from a JSON object. - Parameters:
input
: ZtdfJsonResult
- Returns: A new
SdsdkZtdf
instance. - Throws:
SdsdkError
if the input is invalid or required properties are missing.
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) b64payload string Encrypted payload encoded in base64 manifest ZtdfManifest Object containing the manifest information
ZtdfManifest
- Description: object containing the ZTDF manifest, for more information refer to the ZTDF specification
Example Usage
javascript
const jsonData = {
metadata: {
version: 1,
},
b64payload: 'aBase64EncodedString',
manifest: {
// Manifest properties
},
};
const ztdfInstance = SdsdkZtdf.fromJson(jsonData);
// Accessing instance properties
console.log(ztdfInstance.manifest);
console.log(ztdfInstance.payload);
console.log(ztdfInstance.b64Payload);
// 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');