GenericStore
Constructors
constructor
constructor(_storeClient: StoreClient)
Name | Type | Description |
---|---|---|
_storeClient | StoreClient |
Fields
storeId
get storeId(): string
Methods
delete
Deletes Store.
async delete()
Type | Description |
---|---|
Promise<void> | promise that resolves to a boolean indicating whether the Store was successfully deleted |
getFiles
Gets a list of files in the Store.
async getFiles(pageIndex: number, options: ListOptions)
Name | Type | Description |
---|---|---|
pageIndex | number | |
options | ListOptions | optional options object |
Type | Description |
---|---|
Promise<PagingList<PrivmxFile>> | `PagingList<File> |
info
Returns info about Store.
async info()
Type | Description |
---|---|
Promise<Store> | Store |
on
Registers an event listener for Store file-related events.
on(eventType: T, callback: (payload: Extract<StoreFileCreatedEvent, {type: T;}> | Extract<StoreFileUpdatedEvent, {type: T;}> | Extract<StoreFileDeletedEvent, {type: T;}>)=>void)
Name | Type | Description |
---|---|---|
eventType | T | type of event to listen for |
callback | (payload: Extract<StoreFileCreatedEvent, {type: T;}> | Extract<StoreFileUpdatedEvent, {type: T;}> | Extract<StoreFileDeletedEvent, {type: T;}>)=>void | callback function to execute when the event occurs |
Type | Description |
---|---|
SubscribeForChannel<"storeFiles"> & {
removeEventListener: ()=>void;
} | object containing the |
streamData
Allows you to handle streaming data to a Store.
async streamData(newFile: StoreFilePayload)
Name | Type | Description |
---|---|---|
newFile | StoreFilePayload | file to be streamed |
Type | Description |
---|---|
Promise<StreamUploader> | - promise that resolves to a |
streamFile
Allows you to handle streaming a file from web File Handler.
async streamFile(newFile: {
file: File;
privateMeta: Uint8Array;
publicMeta: Uint8Array;
})
Name | Type | Description |
---|---|---|
newFile.file | File | file to send |
newFile.privateMeta | Uint8Array | contains confidential data that will be encrypted before being sent to server |
newFile.publicMeta | Uint8Array | contains metadata that is not encrypted |
Type | Description |
---|---|
Promise<FileUploader> | instance of |
subscribeForFileEvents
Subscribes to file-related events on current Store: - `storeFileCreated` - `storeFileDeleted` - `storeFileUpdated`
async subscribeForFileEvents()
Type | Description |
---|---|
Promise<SubscribeForChannel<"storeFiles">> | <'storeFiles'> `Promise<SubscribeForChannel<'storeFiles'>> |
unsubscribeFromFileEvents
Unsubscribes from file-related events in the Store.
async unsubscribeFromFileEvents()
Type | Description |
---|---|
Promise<void> | a promise that resolves with void |
update
Updates Store by overriding fields with new ones. When updating, Bridge will check version number. Updates of Store with different version number will be rejected. Version number is incremented after every update.
async update(newStore: {
managers: UserWithPubKey[];
options: {
force: boolean;
forceGenerateNewKey: boolean;
};
privateMeta: Uint8Array;
publicMeta: Uint8Array;
users: UserWithPubKey[];
version: number;
})
Name | Type | Description |
---|---|---|
newStore.managers | UserWithPubKey[] | list of UserWithPubKey with management rights to this Store |
newStore.options | {
force: boolean;
forceGenerateNewKey: boolean;
} | |
newStore.privateMeta | Uint8Array | (encrypted) metadata |
newStore.publicMeta | Uint8Array | public (unencrypted) metadata |
newStore.users | UserWithPubKey[] | list of UserWithPubKey with access to this Store |
newStore.version | number | version number of the Store data |
Type | Description |
---|---|
Promise<void> | promise that resolves when the Store update is complete |
uploadData
Upload file to server.
async uploadData(newFile: StoreFilePayload, progressCallback: (progress: number)=>void)
Name | Type | Description |
---|---|---|
newFile | StoreFilePayload | `StoreFilePayload` object |
progressCallback | (progress: number)=>void | optional callback function called after fetching each file chunk |
Type | Description |
---|---|
Promise<string> | ID of uploaded file |
uploadFile
Function used to upload a file from a browser File `File` handle.
async uploadFile(newFile: {
file: File;
privateMeta: Uint8Array;
publicMeta: Uint8Array;
}, progressCallback: (progress: number)=>void)
Name | Type | Description |
---|---|---|
newFile.file | File | file to upload |
newFile.privateMeta | Uint8Array | optional (encrypted) metadata |
newFile.publicMeta | Uint8Array | optional public (unencrypted) metadata |
progressCallback | (progress: number)=>void | optional callback function called after fetching each file chunk |
Type | Description |
---|---|
Promise<string> | ID of the uploaded file |