Socket
Socket
Sign inDemoInstall

@fleekhq/space-client

Package Overview
Dependencies
3
Maintainers
6
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.1.2

3

dist/client.d.ts
import grpcWeb, { ClientReadableStream } from 'grpc-web';
import { SpaceApiClient } from './definitions/SpaceServiceClientPb';
import { OpenFilePayload, CreateBucketPayload, AddItemsPayload, CreateFolderPayload, BackupKeysByPassphrasePayload, RecoverKeysByPassphrasePayload, ToggleFusePayload, GetFuseDriveStatusPayload, ListDirectoriesPayload, ListDirectoryPayload, ToggleBucketBackupPayload, ShareBucketPayload, JoinBucketPayload, ReadNotificationPayload, GetNotificationsPayload, RestoreKeyPairViaMnemonicPayload, GetSharedWithMeFilesPayload, ShareFilesViaPublicKeyPayload, GeneratePublicFileLinkPayload, TestKeysPassphrasePayload, SetNotificationsLastSeenAtPayload, HandleFilesInvitationPayload, OpenPublicFilePayload, SearchFilesPayload } from './types';
import { TextileEventResponse, ListDirectoriesResponse, ToggleBucketBackupResponse, OpenFileResponse, CreateBucketResponse, AddItemsResponse, CreateFolderResponse, BackupKeysByPassphraseResponse, RecoverKeysByPassphraseResponse, FuseDriveResponse, FileEventResponse, FileInfoEventResponse, ListBucketsResponse, ListDirectoryResponse, ShareBucketResponse, JoinBucketResponse, GetPublicKeyResponse, NotificationEventResponse, ReadNotificationResponse, GetNotificationsResponse, HandleFilesInvitationResponse, DeleteKeyPairResponse, GetUsageInfoResponse, GetStoredMnemonicResponse, RestoreKeyPairViaMnemonicResponse, GetSharedWithMeFilesResponse, ShareFilesViaPublicKeyResponse, GetAPISessionTokensResponse, GetRecentlySharedWithResponse, GeneratePublicFileLinkResponse, TestKeysPassphraseResponse, SetNotificationsLastSeenAtResponse, GenerateKeyPairResponse, OpenPublicFileResponse, SearchFilesResponse } from './definitions/space_pb';
import { TextileEventResponse, ListDirectoriesResponse, ToggleBucketBackupResponse, OpenFileResponse, CreateBucketResponse, AddItemsResponse, CreateFolderResponse, BackupKeysByPassphraseResponse, RecoverKeysByPassphraseResponse, FuseDriveResponse, FileEventResponse, ListBucketsResponse, ListDirectoryResponse, ShareBucketResponse, JoinBucketResponse, GetPublicKeyResponse, NotificationEventResponse, ReadNotificationResponse, GetNotificationsResponse, HandleFilesInvitationResponse, DeleteKeyPairResponse, GetUsageInfoResponse, GetStoredMnemonicResponse, RestoreKeyPairViaMnemonicResponse, GetSharedWithMeFilesResponse, ShareFilesViaPublicKeyResponse, GetAPISessionTokensResponse, GetRecentlySharedWithResponse, GeneratePublicFileLinkResponse, TestKeysPassphraseResponse, SetNotificationsLastSeenAtResponse, GenerateKeyPairResponse, OpenPublicFileResponse, SearchFilesResponse } from './definitions/space_pb';
export interface SpaceClientOpts {

@@ -18,3 +18,2 @@ url: string;

toggleBucketBackup(payload: ToggleBucketBackupPayload, metadata?: grpcWeb.Metadata): Promise<ToggleBucketBackupResponse>;
fileInfoSubscribe(metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream<FileInfoEventResponse>;
txlSubscribe(metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream<TextileEventResponse>;

@@ -21,0 +20,0 @@ openFile(payload: OpenFilePayload, metadata?: grpcWeb.Metadata): Promise<OpenFileResponse>;

@@ -58,6 +58,2 @@ "use strict";

}
fileInfoSubscribe(metadata = {}) {
const request = new empty_pb_1.Empty();
return this.instance.fileInfoSubscribe(request, metadata);
}
txlSubscribe(metadata = {}) {

@@ -64,0 +60,0 @@ const request = new empty_pb_1.Empty();

@@ -8,3 +8,3 @@ /**

import * as google_protobuf_empty_pb from 'google-protobuf/google/protobuf/empty_pb';
import { AddItemsRequest, AddItemsResponse, BackupKeysByPassphraseRequest, BackupKeysByPassphraseResponse, BucketBackupRestoreRequest, BucketBackupRestoreResponse, CreateBucketRequest, CreateBucketResponse, CreateFolderRequest, CreateFolderResponse, CreateLocalKeysBackupRequest, CreateLocalKeysBackupResponse, DeleteAccountRequest, DeleteAccountResponse, DeleteKeyPairRequest, DeleteKeyPairResponse, FileEventResponse, FileInfoEventResponse, FuseDriveResponse, GenerateKeyPairRequest, GenerateKeyPairResponse, GeneratePublicFileLinkRequest, GeneratePublicFileLinkResponse, GetAPISessionTokensRequest, GetAPISessionTokensResponse, GetNotificationsRequest, GetNotificationsResponse, GetPublicKeyRequest, GetPublicKeyResponse, GetRecentlySharedWithRequest, GetRecentlySharedWithResponse, GetSharedWithMeFilesRequest, GetSharedWithMeFilesResponse, GetStoredMnemonicRequest, GetStoredMnemonicResponse, GetUsageInfoRequest, GetUsageInfoResponse, HandleFilesInvitationRequest, HandleFilesInvitationResponse, JoinBucketRequest, JoinBucketResponse, ListBucketsRequest, ListBucketsResponse, ListDirectoriesRequest, ListDirectoriesResponse, ListDirectoryRequest, ListDirectoryResponse, NotificationEventResponse, OpenFileRequest, OpenFileResponse, OpenPublicFileRequest, OpenPublicFileResponse, ReadNotificationRequest, ReadNotificationResponse, RecoverKeysByLocalBackupRequest, RecoverKeysByLocalBackupResponse, RecoverKeysByPassphraseRequest, RecoverKeysByPassphraseResponse, RestoreKeyPairViaMnemonicRequest, RestoreKeyPairViaMnemonicResponse, SearchFilesRequest, SearchFilesResponse, SetNotificationsLastSeenAtRequest, SetNotificationsLastSeenAtResponse, ShareBucketRequest, ShareBucketResponse, ShareFilesViaPublicKeyRequest, ShareFilesViaPublicKeyResponse, TestKeysPassphraseRequest, TestKeysPassphraseResponse, TextileEventResponse, ToggleBucketBackupRequest, ToggleBucketBackupResponse, ToggleFuseRequest } from './space_pb';
import { AddItemsRequest, AddItemsResponse, BackupKeysByPassphraseRequest, BackupKeysByPassphraseResponse, BucketBackupRestoreRequest, BucketBackupRestoreResponse, CreateBucketRequest, CreateBucketResponse, CreateFolderRequest, CreateFolderResponse, CreateLocalKeysBackupRequest, CreateLocalKeysBackupResponse, DeleteAccountRequest, DeleteAccountResponse, DeleteKeyPairRequest, DeleteKeyPairResponse, FileEventResponse, FuseDriveResponse, GenerateKeyPairRequest, GenerateKeyPairResponse, GeneratePublicFileLinkRequest, GeneratePublicFileLinkResponse, GetAPISessionTokensRequest, GetAPISessionTokensResponse, GetNotificationsRequest, GetNotificationsResponse, GetPublicKeyRequest, GetPublicKeyResponse, GetRecentlySharedWithRequest, GetRecentlySharedWithResponse, GetSharedWithMeFilesRequest, GetSharedWithMeFilesResponse, GetStoredMnemonicRequest, GetStoredMnemonicResponse, GetUsageInfoRequest, GetUsageInfoResponse, HandleFilesInvitationRequest, HandleFilesInvitationResponse, JoinBucketRequest, JoinBucketResponse, ListBucketsRequest, ListBucketsResponse, ListDirectoriesRequest, ListDirectoriesResponse, ListDirectoryRequest, ListDirectoryResponse, NotificationEventResponse, OpenFileRequest, OpenFileResponse, OpenPublicFileRequest, OpenPublicFileResponse, ReadNotificationRequest, ReadNotificationResponse, RecoverKeysByLocalBackupRequest, RecoverKeysByLocalBackupResponse, RecoverKeysByPassphraseRequest, RecoverKeysByPassphraseResponse, RestoreKeyPairViaMnemonicRequest, RestoreKeyPairViaMnemonicResponse, SearchFilesRequest, SearchFilesResponse, SetNotificationsLastSeenAtRequest, SetNotificationsLastSeenAtResponse, ShareBucketRequest, ShareBucketResponse, ShareFilesViaPublicKeyRequest, ShareFilesViaPublicKeyResponse, TestKeysPassphraseRequest, TestKeysPassphraseResponse, TextileEventResponse, ToggleBucketBackupRequest, ToggleBucketBackupResponse, ToggleFuseRequest } from './space_pb';
export declare class SpaceApiClient {

@@ -50,4 +50,2 @@ client_: grpcWeb.AbstractClientBase;

subscribe(request: google_protobuf_empty_pb.Empty, metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream<FileEventResponse>;
methodInfoFileInfoSubscribe: grpcWeb.AbstractClientBase.MethodInfo<google_protobuf_empty_pb.Empty, FileInfoEventResponse>;
fileInfoSubscribe(request: google_protobuf_empty_pb.Empty, metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream<FileInfoEventResponse>;
methodInfoTxlSubscribe: grpcWeb.AbstractClientBase.MethodInfo<google_protobuf_empty_pb.Empty, TextileEventResponse>;

@@ -54,0 +52,0 @@ txlSubscribe(request: google_protobuf_empty_pb.Empty, metadata?: grpcWeb.Metadata): grpcWeb.ClientReadableStream<TextileEventResponse>;

@@ -62,5 +62,2 @@ "use strict";

}, space_pb_1.FileEventResponse.deserializeBinary);
this.methodInfoFileInfoSubscribe = new grpcWeb.AbstractClientBase.MethodInfo(space_pb_1.FileInfoEventResponse, (request) => {
return request.serializeBinary();
}, space_pb_1.FileInfoEventResponse.deserializeBinary);
this.methodInfoTxlSubscribe = new grpcWeb.AbstractClientBase.MethodInfo(space_pb_1.TextileEventResponse, (request) => {

@@ -228,5 +225,2 @@ return request.serializeBinary();

}
fileInfoSubscribe(request, metadata) {
return this.client_.serverStreaming(new URL('/space.SpaceApi/FileInfoSubscribe', this.hostname_).toString(), request, metadata || {}, this.methodInfoFileInfoSubscribe);
}
txlSubscribe(request, metadata) {

@@ -233,0 +227,0 @@ return this.client_.serverStreaming(new URL('/space.SpaceApi/TxlSubscribe', this.hostname_).toString(), request, metadata || {}, this.methodInfoTxlSubscribe);

@@ -62,7 +62,2 @@ import { Empty } from 'google-protobuf/google/protobuf/empty_pb';

};
SpaceClient.prototype.fileInfoSubscribe = function (metadata) {
if (metadata === void 0) { metadata = {}; }
var request = new Empty();
return this.instance.fileInfoSubscribe(request, metadata);
};
SpaceClient.prototype.txlSubscribe = function (metadata) {

@@ -69,0 +64,0 @@ if (metadata === void 0) { metadata = {}; }

@@ -10,3 +10,3 @@ /**

import * as grpcWeb from 'grpc-web';
import { AddItemsResponse, BackupKeysByPassphraseResponse, BucketBackupRestoreResponse, CreateBucketResponse, CreateFolderResponse, CreateLocalKeysBackupResponse, DeleteAccountResponse, DeleteKeyPairResponse, FileEventResponse, FileInfoEventResponse, FuseDriveResponse, GenerateKeyPairResponse, GeneratePublicFileLinkResponse, GetAPISessionTokensResponse, GetNotificationsResponse, GetPublicKeyResponse, GetRecentlySharedWithResponse, GetSharedWithMeFilesResponse, GetStoredMnemonicResponse, GetUsageInfoResponse, HandleFilesInvitationResponse, JoinBucketResponse, ListBucketsResponse, ListDirectoriesResponse, ListDirectoryResponse, NotificationEventResponse, OpenFileResponse, OpenPublicFileResponse, ReadNotificationResponse, RecoverKeysByLocalBackupResponse, RecoverKeysByPassphraseResponse, RestoreKeyPairViaMnemonicResponse, SearchFilesResponse, SetNotificationsLastSeenAtResponse, ShareBucketResponse, ShareFilesViaPublicKeyResponse, TestKeysPassphraseResponse, TextileEventResponse, ToggleBucketBackupResponse } from './space_pb';
import { AddItemsResponse, BackupKeysByPassphraseResponse, BucketBackupRestoreResponse, CreateBucketResponse, CreateFolderResponse, CreateLocalKeysBackupResponse, DeleteAccountResponse, DeleteKeyPairResponse, FileEventResponse, FuseDriveResponse, GenerateKeyPairResponse, GeneratePublicFileLinkResponse, GetAPISessionTokensResponse, GetNotificationsResponse, GetPublicKeyResponse, GetRecentlySharedWithResponse, GetSharedWithMeFilesResponse, GetStoredMnemonicResponse, GetUsageInfoResponse, HandleFilesInvitationResponse, JoinBucketResponse, ListBucketsResponse, ListDirectoriesResponse, ListDirectoryResponse, NotificationEventResponse, OpenFileResponse, OpenPublicFileResponse, ReadNotificationResponse, RecoverKeysByLocalBackupResponse, RecoverKeysByPassphraseResponse, RestoreKeyPairViaMnemonicResponse, SearchFilesResponse, SetNotificationsLastSeenAtResponse, ShareBucketResponse, ShareFilesViaPublicKeyResponse, TestKeysPassphraseResponse, TextileEventResponse, ToggleBucketBackupResponse } from './space_pb';
var SpaceApiClient = /** @class */ (function () {

@@ -41,5 +41,2 @@ function SpaceApiClient(hostname, credentials, options) {

}, FileEventResponse.deserializeBinary);
this.methodInfoFileInfoSubscribe = new grpcWeb.AbstractClientBase.MethodInfo(FileInfoEventResponse, function (request) {
return request.serializeBinary();
}, FileInfoEventResponse.deserializeBinary);
this.methodInfoTxlSubscribe = new grpcWeb.AbstractClientBase.MethodInfo(TextileEventResponse, function (request) {

@@ -207,5 +204,2 @@ return request.serializeBinary();

};
SpaceApiClient.prototype.fileInfoSubscribe = function (request, metadata) {
return this.client_.serverStreaming(new URL('/space.SpaceApi/FileInfoSubscribe', this.hostname_).toString(), request, metadata || {}, this.methodInfoFileInfoSubscribe);
};
SpaceApiClient.prototype.txlSubscribe = function (request, metadata) {

@@ -212,0 +206,0 @@ return this.client_.serverStreaming(new URL('/space.SpaceApi/TxlSubscribe', this.hostname_).toString(), request, metadata || {}, this.methodInfoTxlSubscribe);

{
"name": "@fleekhq/space-client",
"version": "1.1.1",
"version": "1.1.2",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "module": "dist/esm/index.js",

@@ -57,2 +57,84 @@ ![Publish Action Status](https://github.com/FleekHQ/space-client/workflows/Publish/badge.svg?branch=master)

## Generate Protobuf Messages and Client Service Stub
### Step 1: Download the binary tools required to generate protobuf messages and client services:
> if you already have the tools, you can skip this step
In order to generate the Protobuf Messages and Client Service Stub you need:
- `protoc` binary
- `protoc-gen-grpc-web` plugin
#### Install `protoc`
Go to the latest release page of protobuf and download the binary for your OS: https://github.com/protocolbuffers/protobuf/releases
In this example we are going to use OSX, so the file that we need is `protoc-3.13.0-osx-x86_64.zip` (https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-osx-x86_64.zip)
Unzip the file, rename the uncompressed file to `protoc` and move it to the `bin` directory on your OS (make sure to change the permissions of the file):
```bash
$ sudo mv ~/Downloads/protoc /usr/local/bin/
$ sudo chmod 777 /usr/local/bin/protoc
```
#### Install `protoc-gen-grpc-web`
Go to the latest release page of grpc-web and download the binary for your OS: https://github.com/grpc/grpc-web/releases
In this example we are going to use OSX, so the file that we need is `protoc-gen-grpc-web-1.2.1-darwin-x86_64` (https://github.com/grpc/grpc-web/releases/download/1.2.1/protoc-gen-grpc-web-1.2.1-darwin-x86_64)
Rename the file to `protoc-gen-grpc-web` and move it to the `bin` directory on your OS (make sure to change the permissions of the file):
```bash
$ sudo mv ~/Downloads/protoc-gen-grpc-web /usr/local/bin/
$ sudo chmod 777 /usr/local/bin/protoc-gen-grpc-web
```
### Step 2: Prepare the `space.proto` file
Download the latest version of the `space.proto` from `master` branch: https://github.com/FleekHQ/space-daemon/blob/master/grpc/proto/space.proto
If you need to update the `space.proto` from the `develop` branch, you can go to: https://github.com/FleekHQ/space-daemon/blob/develop/grpc/proto/space.proto
Download the `space.proto` into `/src/definitions/space.proto` on this project
Then, using a text editor that supports regex (like vscode), open the space.proto and find by the following regex:
```
(import "google/api/annotations.proto";|(option \(google.api.http\) = \{(\n){0,1}(.*: .*|\n)*.*\};))
```
remove all the coincidences, and save the file:
![example](https://gpuente-team-bucket.storage.fleek.co/2020-11-04%2016.54.11.gif)
### Step 3: Generate Protobuf Messages and Client Service Stub
Open a terminal and move into the definitions folder:
```bash
cd src/definitions
```
then execute the following command:
```bash
protoc -I=. space.proto \
--js_out=import_style=commonjs:. \
--grpc-web_out=import_style=typescript,mode=grpcwebtext:.
```
the command is going to generate 3 files: `space_pb.d.ts`, `space_pb.js` and `SpaceServiceClientPb.ts`
### Step 4: Test the build
Once you successfully generated the protobuf messages and the client service stub, you have to test that the build is passing with this new version of the `space.proto`:
```bash
yarn build
```
If the build fails, means that you have to update `src/client.ts` file with the latest versions of the types generated.
## API

@@ -475,4 +557,20 @@

Returns a ReadableStream that notifies when something changed on the bucket (data stream returns the event type + the entry affected).
Event type can be one of `[ENTRY_ADDED, ENTRY_DELETED, ENTRY_UPDATED]`
Event type can be one of:
```protobuf
enum EventType {
ENTRY_ADDED = 0;
ENTRY_DELETED = 1;
ENTRY_UPDATED = 2;
ENTRY_BACKUP_IN_PROGRESS = 3;
ENTRY_BACKUP_READY = 4;
ENTRY_RESTORE_IN_PROGRESS = 5;
ENTRY_RESTORE_READY = 6;
FOLDER_ADDED = 7;
FOLDER_DELETED = 8;
FOLDER_UPDATED = 9;
}
```
example:
```js

@@ -484,13 +582,18 @@ const subscribeStream = client.subscribe();

const entry = res.getEntry();
const bucket = res.getBucket();
const dbId = res.getDbid();
console.log('eventType', eventType.toString());
console.log('path', entry.getPath());
console.log('name', entry.getName());
console.log('isDir', entry.getIsdir());
console.log('created', entry.getCreated());
console.log('updated', entry.getUpdated());
console.log('ipfsHash', entry.getIpfshash());
console.log('sizeInBytes', entry.getSizeinbytes());
console.log('fileExtension', entry.getFileextension());
});
console.log('subscribe data:', {
dbId,
bucket,
eventType: eventType.toString(),
path: entry.getPath(),
name: entry.getName(),
isDir: entry.getIsdir(),
created: entry.getCreated(),
updated: entry.getUpdated(),
ipfsHash: entry.getIpfshash(),
sizeInBytes: entry.getSizeinbytes(),
fileExtension: entry.getFileextension(),
});
```

@@ -1130,4 +1233,10 @@

const entries = entriesList.map((entry) => {
const entries = entriesList.map((item) => {
const dbId = item.getDbid();
const entry = item.getEntry();
const bucket = item.getBucket();
return {
dbId,
bucket,
path: entry.getPath(),

@@ -1134,0 +1243,0 @@ name: entry.getName(),

@@ -13,3 +13,2 @@ // We disable the type checking because it interferes with jest's mocking function

addItems: jest.fn(),
fileInfoSubscribe: jest.fn(),
txlSubscribe: jest.fn(),

@@ -77,8 +76,2 @@ openFile: jest.fn(),

it('fileInfoSubscribe makes the right requests', async () => {
client.fileInfoSubscribe({});
expect(client.instance.fileInfoSubscribe).toHaveBeenCalledTimes(1);
});
it('openFile makes the right requests', async () => {

@@ -85,0 +78,0 @@ client.openFile({

@@ -53,3 +53,2 @@ import grpcWeb, { ClientReadableStream } from 'grpc-web';

FileEventResponse,
FileInfoEventResponse,
ListBucketsRequest,

@@ -211,10 +210,2 @@ ListBucketsResponse,

fileInfoSubscribe(
metadata: grpcWeb.Metadata = {},
): grpcWeb.ClientReadableStream<FileInfoEventResponse> {
const request = new Empty();
return this.instance.fileInfoSubscribe(request, metadata);
}
txlSubscribe(

@@ -221,0 +212,0 @@ metadata: grpcWeb.Metadata = {},

@@ -36,3 +36,2 @@ /**

FileEventResponse,
FileInfoEventResponse,
FuseDriveResponse,

@@ -444,20 +443,2 @@ GenerateKeyPairRequest,

methodInfoFileInfoSubscribe = new grpcWeb.AbstractClientBase.MethodInfo(
FileInfoEventResponse,
(request: google_protobuf_empty_pb.Empty) => {
return request.serializeBinary();
},
FileInfoEventResponse.deserializeBinary
);
fileInfoSubscribe(
request: google_protobuf_empty_pb.Empty,
metadata?: grpcWeb.Metadata) {
return this.client_.serverStreaming(
new URL('/space.SpaceApi/FileInfoSubscribe', this.hostname_).toString(),
request,
metadata || {},
this.methodInfoFileInfoSubscribe);
}
methodInfoTxlSubscribe = new grpcWeb.AbstractClientBase.MethodInfo(

@@ -464,0 +445,0 @@ TextileEventResponse,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc