getProtectedData
This method allows the user to retrieve all protected data for a given owner, data schema, or both.
Results are ordered by creationTimestamp
desc.
TIP
A data schema is the metadata describing the contents of the protected data object. The schema is returned as part of the protectData method invocation.
Usage
const listProtectedData = await dataProtectorCore.getProtectedData({
owner: '0xa0c15e...',
requiredSchema: {
email: 'string',
},
});
Parameters
import { type GetProtectedDataParams } from '@iexec/dataprotector';
protectedDataAddress Optional
Type: AddressOrENS
Returns the protected data associated with this address.
Returns an empty array if the protected data is not found.
const oneProtectedData = await dataProtectorCore.getProtectedData({
protectedDataAddress: '0x123abc...',
});
requiredSchema Optional
Type: SearchableDataSchema
Provides a list of protected data objects matching this schema.
const listProtectedData = await dataProtectorCore.getProtectedData({
requiredSchema: {
email: 'string',
},
});
It's also possible to provide a list of accepted types for one schema field:
const listProtectedData = await dataProtectorCore.getProtectedData({
requiredSchema: {
picture: ['image/png', 'image/jpeg'],
},
});
Available types are listed here.
owner Optional
Type: AddressOrENS
Provides a list of protected data objects owned by the user with this ETH address.
const listProtectedData = await dataProtectorCore.getProtectedData({
owner: '0xa0c15e...',
});
createdAfterTimestamp Optional
Type: number
Provides a list of protected data objects created after this timestamp value. The provided value should be in seconds.
const listProtectedData = await dataProtectorCore.getProtectedData({
owner: '0xa0c15e...',
createdAfterTimestamp: 1710257612, // March 12, 2024 15:33:32 GMT
});
page Optional
Type: number
Default: 0
Specifies the results page to return. Pages are indexed starting at page 0. If using this field you may also specify a pageSize
to control the size of the results.
const listProtectedData = await dataProtectorCore.getProtectedData({
owner: '0xa0c15e...',
createdAfterTimestamp: 1710257612, // March 12, 2024 15:33:32 GMT
page: 1,
});
pageSize Optional
Type: number
Default: 1000
Range: [10...1000]
Specifies the number of records in each page of the result set. This is used in conjunction with the optional page
parameter to constrain the size of the result.
const listProtectedData = await dataProtectorCore.getProtectedData({
owner: '0xa0c15e...',
createdAfterTimestamp: 1710257612, // March 12, 2024 15:33:32 GMT
page: 1,
pageSize: 100,
});
Return value
import { type ProtectedData } from '@iexec/dataprotector';
See ProtectedData