Skip to main content
reference

GenericStore

Constructors

constructor

constructor(_storeClient: StoreClient)

NameTypeDescription
_storeClientStoreClient

Fields

storeId

get storeId(): string

Methods

delete

Deletes Store.

async delete()

TypeDescription
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)

NameTypeDescription
pageIndexnumber
optionsListOptionsoptional options object

TypeDescription
Promise<PagingList<PrivmxFile>> `PagingList<File>

info

Returns info about Store.

async info()

TypeDescription
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)

NameTypeDescription
eventTypeTtype of event to listen for
callback(payload: Extract<StoreFileCreatedEvent, {type: T;}> | Extract<StoreFileUpdatedEvent, {type: T;}> | Extract<StoreFileDeletedEvent, {type: T;}>)=>voidcallback function to execute when the event occurs

TypeDescription
SubscribeForChannel<"storeFiles"> & { removeEventListener: ()=>void; } object containing the

streamData

Allows you to handle streaming data to a Store.

async streamData(newFile: StoreFilePayload)

NameTypeDescription
newFileStoreFilePayloadfile to be streamed

TypeDescription
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;
})

NameTypeDescription
newFile.fileFilefile to send
newFile.privateMetaUint8Arraycontains confidential data that will be encrypted before being sent to server
newFile.publicMetaUint8Arraycontains metadata that is not encrypted

TypeDescription
Promise<FileUploader> instance of

subscribeForFileEvents

Subscribes to file-related events on current Store: - `storeFileCreated` - `storeFileDeleted` - `storeFileUpdated`

async subscribeForFileEvents()

TypeDescription
Promise<SubscribeForChannel<"storeFiles">> <'storeFiles'> `Promise<SubscribeForChannel<'storeFiles'>>

unsubscribeFromFileEvents

Unsubscribes from file-related events in the Store.

async unsubscribeFromFileEvents()

TypeDescription
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;
})

NameTypeDescription
newStore.managersUserWithPubKey[]list of UserWithPubKey with management rights to this Store
newStore.options{ force: boolean; forceGenerateNewKey: boolean; }
newStore.privateMetaUint8Array(encrypted) metadata
newStore.publicMetaUint8Arraypublic (unencrypted) metadata
newStore.usersUserWithPubKey[]list of UserWithPubKey with access to this Store
newStore.versionnumberversion number of the Store data

TypeDescription
Promise<void> promise that resolves when the Store update is complete

uploadData

Upload file to server.

async uploadData(newFile: StoreFilePayload, progressCallback: (progress: number)=>void)

NameTypeDescription
newFileStoreFilePayload`StoreFilePayload` object
progressCallback(progress: number)=>voidoptional callback function called after fetching each file chunk

TypeDescription
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)

NameTypeDescription
newFile.fileFilefile to upload
newFile.privateMetaUint8Arrayoptional (encrypted) metadata
newFile.publicMetaUint8Arrayoptional public (unencrypted) metadata
progressCallback(progress: number)=>voidoptional callback function called after fetching each file chunk

TypeDescription
Promise<string> ID of the uploaded file