Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fleekhq/space-client

Package Overview
Dependencies
Maintainers
6
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fleekhq/space-client - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

dist/client.d.ts

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

url: string;
defaultBucket?: string;
options?: SpaceApiClient['options_'];

@@ -12,2 +13,3 @@ credentials?: SpaceApiClient['credentials_'];

declare class SpaceClient {
defaultBucket: string;
instance: SpaceApiClient;

@@ -14,0 +16,0 @@ constructor(opts: SpaceClientOpts);

34

dist/client.js

@@ -6,5 +6,7 @@ "use strict";

const space_pb_1 = require("./definitions/space_pb");
const DEFAULT_BUCKET = 'personal';
class SpaceClient {
constructor(opts) {
const { url, options, credentials, } = opts;
const { url, options, credentials, defaultBucket = DEFAULT_BUCKET, } = opts;
this.defaultBucket = defaultBucket;
this.instance = new SpaceServiceClientPb_1.SpaceApiClient(url, credentials, options);

@@ -16,4 +18,5 @@ }

const path = payload.path.replace(/^\//, '');
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);
this.instance.listDirectory(request, metadata, (err, res) => {

@@ -31,3 +34,4 @@ if (err) {

const request = new space_pb_1.ListDirectoriesRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setBucket(bucket || this.defaultBucket);
this.instance.listDirectories(request, metadata, (err, res) => {

@@ -50,4 +54,5 @@ if (err) {

const path = payload.path.replace(/^\//, '');
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);
this.instance.openFile(request, metadata, (err, res) => {

@@ -78,5 +83,6 @@ if (err) {

const targetPath = payload.targetPath.replace(/^\//, '');
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setTargetpath(targetPath);
request.setSourcepathsList(payload.sourcePaths);
request.setBucket(bucket || this.defaultBucket);
const stream = this.instance.addItems(request, metadata);

@@ -89,4 +95,5 @@ return stream;

const path = payload.path.replace(/^\//, '');
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);
this.instance.createFolder(request, metadata, (err, res) => {

@@ -136,4 +143,5 @@ if (err) {

const request = new space_pb_1.ShareBucketViaEmailRequest();
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setEmail(payload.email);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);
this.instance.shareBucketViaEmail(request, metadata, (err, res) => {

@@ -151,5 +159,6 @@ if (err) {

const request = new space_pb_1.ShareBucketViaIdentityRequest();
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setIdentitytype(space_pb_1.IdentityType[payload.identityType]);
request.setIdentityvalue(payload.identityValue);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);
this.instance.shareBucketViaIdentity(request, metadata, (err, res) => {

@@ -172,4 +181,5 @@ if (err) {

const request = new space_pb_1.GenerateFileShareLinkRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setFilepath(payload.filePath);
request.setBucket(bucket || this.defaultBucket);
this.instance.generateFileShareLink(request, metadata, (err, res) => {

@@ -279,3 +289,4 @@ if (err) {

const request = new space_pb_1.ShareBucketRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setBucket(bucket || this.defaultBucket);
this.instance.shareBucket(request, metadata, (err, res) => {

@@ -296,4 +307,5 @@ if (err) {

const request = new space_pb_1.JoinBucketRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setThreadinfo(threadInfo);
request.setBucket(bucket || this.defaultBucket);
this.instance.joinBucket(request, metadata, (err, res) => {

@@ -300,0 +312,0 @@ if (err) {

import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
import { SpaceApiClient } from './definitions/SpaceServiceClientPb';
import { ListDirectoriesRequest, OpenFileRequest, CreateBucketRequest, AddItemsRequest, CreateFolderRequest, GetIdentityByUsernameRequest, CreateUsernameAndEmailRequest, ShareBucketViaEmailRequest, ShareBucketViaIdentityRequest, GenerateFileShareLinkRequest, BackupKeysByPassphraseRequest, RecoverKeysByPassphraseRequest, ToggleFuseRequest, IdentityType, ListBucketsRequest, ListDirectoryRequest, ShareBucketRequest, JoinBucketRequest, ThreadInfo, } from './definitions/space_pb';
var DEFAULT_BUCKET = 'personal';
var SpaceClient = /** @class */ (function () {
function SpaceClient(opts) {
var url = opts.url, options = opts.options, credentials = opts.credentials;
var url = opts.url, options = opts.options, credentials = opts.credentials, _a = opts.defaultBucket, defaultBucket = _a === void 0 ? DEFAULT_BUCKET : _a;
this.defaultBucket = defaultBucket;
this.instance = new SpaceApiClient(url, credentials, options);

@@ -15,4 +17,5 @@ }

var path = payload.path.replace(/^\//, '');
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || _this.defaultBucket);
_this.instance.listDirectory(request, metadata, function (err, res) {

@@ -32,3 +35,4 @@ if (err) {

var request = new ListDirectoriesRequest();
request.setBucket(payload.bucket);
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setBucket(bucket || _this.defaultBucket);
_this.instance.listDirectories(request, metadata, function (err, res) {

@@ -54,4 +58,5 @@ if (err) {

var path = payload.path.replace(/^\//, '');
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || _this.defaultBucket);
_this.instance.openFile(request, metadata, function (err, res) {

@@ -85,5 +90,6 @@ if (err) {

var targetPath = payload.targetPath.replace(/^\//, '');
request.setBucket(payload.bucket);
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setTargetpath(targetPath);
request.setSourcepathsList(payload.sourcePaths);
request.setBucket(bucket || this.defaultBucket);
var stream = this.instance.addItems(request, metadata);

@@ -98,4 +104,5 @@ return stream;

var path = payload.path.replace(/^\//, '');
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || _this.defaultBucket);
_this.instance.createFolder(request, metadata, function (err, res) {

@@ -151,4 +158,5 @@ if (err) {

var request = new ShareBucketViaEmailRequest();
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setEmail(payload.email);
request.setBucket(payload.bucket);
request.setBucket(bucket || _this.defaultBucket);
_this.instance.shareBucketViaEmail(request, metadata, function (err, res) {

@@ -168,5 +176,6 @@ if (err) {

var request = new ShareBucketViaIdentityRequest();
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setIdentitytype(IdentityType[payload.identityType]);
request.setIdentityvalue(payload.identityValue);
request.setBucket(payload.bucket);
request.setBucket(bucket || _this.defaultBucket);
_this.instance.shareBucketViaIdentity(request, metadata, function (err, res) {

@@ -191,4 +200,5 @@ if (err) {

var request = new GenerateFileShareLinkRequest();
request.setBucket(payload.bucket);
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setFilepath(payload.filePath);
request.setBucket(bucket || _this.defaultBucket);
_this.instance.generateFileShareLink(request, metadata, function (err, res) {

@@ -311,3 +321,4 @@ if (err) {

var request = new ShareBucketRequest();
request.setBucket(payload.bucket);
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setBucket(bucket || _this.defaultBucket);
_this.instance.shareBucket(request, metadata, function (err, res) {

@@ -330,4 +341,5 @@ if (err) {

var request = new JoinBucketRequest();
request.setBucket(payload.bucket);
var bucket = payload.bucket === '' ? null : payload.bucket;
request.setThreadinfo(threadInfo);
request.setBucket(bucket || _this.defaultBucket);
_this.instance.joinBucket(request, metadata, function (err, res) {

@@ -334,0 +346,0 @@ if (err) {

export interface ListDirectoryPayload {
path: string;
bucket: string;
bucket?: string;
}
export interface OpenFilePayload {
path: string;
bucket: string;
bucket?: string;
}

@@ -13,3 +13,3 @@ export interface CreateBucketPayload {

export interface AddItemsPayload {
bucket: string;
bucket?: string;
targetPath: string;

@@ -20,3 +20,3 @@ sourcePaths: string[];

path: string;
bucket: string;
bucket?: string;
}

@@ -31,3 +31,3 @@ export interface GetIdentityByUsernamePayload {

export interface ShareBucketViaEmailPayload {
bucket: string;
bucket?: string;
email: string;

@@ -38,6 +38,6 @@ }

identityValue: string;
bucket: string;
bucket?: string;
}
export interface GenerateFileShareLinkPayload {
bucket: string;
bucket?: string;
filePath: string;

@@ -57,6 +57,6 @@ }

export interface ListDirectoriesPayload {
bucket: string;
bucket?: string;
}
export interface ShareBucketPayload {
bucket: string;
bucket?: string;
}

@@ -68,3 +68,3 @@ export interface JoinBucketPayload {

};
bucket: string;
bucket?: string;
}
{
"name": "@fleekhq/space-client",
"version": "0.1.4",
"version": "0.1.5",
"main": "dist/index.js",

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

@@ -56,6 +56,31 @@ # Space Client

#### .listDirectory({ path: string, bucket: string })
#### class SpaceClient(opts)
Use this class to create space client instances able to interact with space-daemon
Options:
- `opts.url`: <em>**(string, required)**</em> space dameon url + port (`https://0.0.0.0:9998`)
- `opts.defaultBucket?`: <em>**(string, optional)**</em> change the default bucket. This value is used when you don't pass the bucket param on some of the methods below. if you don't pass this property, `personal` bucket is going to be used as default value (`personal` bucket is created by default when you run space-daemon for the first time).
- `opts.options?`: <em>**(object, optional)**</em> [grpc-web](https://github.com/grpc/grpc-web) client options.
- `opts.credentials?`: <em>**(object, optional)**</em> [grpc-web](https://github.com/grpc/grpc-web) client credentials.
```js
import { SpaceClient } from '@fleekhq/space-client';
const opts = {
url: 'http://0.0.0.0:9998',
defaultBucket: 'my-bucket',
};
const client = new SpaceClient(opts);
```
#### .listDirectory({ path: string, bucket?: string })
Returns the folder or files in the path directory.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.
```js

@@ -94,5 +119,6 @@ client

#### .listDirectories({ bucket: string })
#### .listDirectories({ bucket?: string })
Returns a Promise that resolves to an array of Directories representing all the folders and files inside the bucket.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -145,5 +171,6 @@ ```js

#### .openFile({ path: string, bucket: string })
#### .openFile({ path: string, bucket?: string })
Copies the file referenced by the path arg to a temp folder and returns a Promise that resolves to the file location
Copies the file referenced by the path arg to a temp folder and returns a Promise that resolves to the file location.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -201,5 +228,6 @@ ```js

#### .addItems({ bucket: string, targetPath: string, sourcePaths: string[] })
#### .addItems({ bucket?: string, targetPath: string, sourcePaths: string[] })
Add new items. Returns a readable stream to resolves the new items
Add new items. Returns a readable stream to resolves the new items.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -226,5 +254,6 @@ ```js

#### .createFolder({ path: string, bucket: string })
#### .createFolder({ path: string, bucket?: string })
Creates a new empty folder. Returns a Promise that resolves to the new folder
Creates a new empty folder. Returns a Promise that resolves to the new folder.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -250,3 +279,3 @@ ```js

Create a new username with/out email. Returns a Promise that resolves to the username
Create a new username with/out email. Returns a Promise that resolves to the username.

@@ -272,3 +301,3 @@ ```js

Get an indentity based on a username. Returns a Promise that resolves if a username already exists
Get an indentity based on a username. Returns a Promise that resolves if a username already exists.

@@ -294,7 +323,8 @@ ```js

#### `[WIP]` <em>.shareBucketViaEmail({ bucket: string, email: string })</em>
#### `[WIP]` <em>.shareBucketViaEmail({ bucket?: string, email: string })</em>
> this method is still not supported by [space-daemon](https://github.com/FleekHQ/space-daemon)
Shares a bucket via email
Shares a bucket via email.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -324,5 +354,6 @@ ```js

#### .shareBucketViaIdentity({ identityType: 'USERNAME' | 'EMAIL', identityValue: string, bucket: string })
#### .shareBucketViaIdentity({ identityType: 'USERNAME' | 'EMAIL', identityValue: string, bucket?: string })
Shares a bucket via identity
Shares a bucket via identity.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -356,7 +387,8 @@ ```js

#### `[WIP]` <em>.generateFileShareLink({ bucket: string, filePath: string })</em>
#### `[WIP]` <em>.generateFileShareLink({ bucket?: string, filePath: string })</em>
> this method is still not supported by [space-daemon](https://github.com/FleekHQ/space-daemon)
Generates a share link
Generates a share link.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -553,5 +585,6 @@ ```js

#### .shareBucket({ bucket: string })
#### .shareBucket({ bucket?: string })
Shares a bucket. Returns a promis that resolves to the threadInfo (required to join a bucket)
Shares a bucket. Returns a promis that resolves to the threadInfo (required to join a bucket).
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -583,5 +616,6 @@ ```js

#### .joinBucket({ bucket: string, threadInfo: { key: string, addresses: [string] } })
#### .joinBucket({ bucket: string?, threadInfo: { key: string, addresses: [string] } })
Joins a shared bucket
Joins a shared bucket.
If you don't specify the `bucket` property, `client.defaultBucket` value is going to be used instead.

@@ -588,0 +622,0 @@ ```js

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

url: string;
defaultBucket?: string;
options?: SpaceApiClient['options_'];

@@ -73,3 +74,7 @@ credentials?: SpaceApiClient['credentials_'];

const DEFAULT_BUCKET = 'personal';
class SpaceClient {
defaultBucket: string;
instance: SpaceApiClient;

@@ -82,4 +87,6 @@

credentials,
defaultBucket = DEFAULT_BUCKET,
} = opts;
this.defaultBucket = defaultBucket;
this.instance = new SpaceApiClient(url, credentials, options);

@@ -96,4 +103,6 @@ }

const bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);

@@ -121,4 +130,6 @@ this.instance.listDirectory(

const request = new ListDirectoriesRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setBucket(bucket || this.defaultBucket);
this.instance.listDirectories(

@@ -155,4 +166,6 @@ request,

const bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);

@@ -204,5 +217,8 @@ this.instance.openFile(

request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setTargetpath(targetPath);
request.setSourcepathsList(payload.sourcePaths);
request.setBucket(bucket || this.defaultBucket);
const stream = this.instance.addItems(request, metadata);

@@ -221,4 +237,6 @@

const bucket = payload.bucket === '' ? null : payload.bucket;
request.setPath(path);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);

@@ -298,4 +316,6 @@ this.instance.createFolder(

const request = new ShareBucketViaEmailRequest();
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setEmail(payload.email);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);

@@ -323,5 +343,7 @@ this.instance.shareBucketViaEmail(

const request = new ShareBucketViaIdentityRequest();
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setIdentitytype(IdentityType[payload.identityType]);
request.setIdentityvalue(payload.identityValue);
request.setBucket(payload.bucket);
request.setBucket(bucket || this.defaultBucket);

@@ -354,4 +376,6 @@ this.instance.shareBucketViaIdentity(

const request = new GenerateFileShareLinkRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setFilepath(payload.filePath);
request.setBucket(bucket || this.defaultBucket);

@@ -524,4 +548,6 @@ this.instance.generateFileShareLink(

const request = new ShareBucketRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setBucket(bucket || this.defaultBucket);
this.instance.shareBucket(

@@ -552,4 +578,6 @@ request,

const request = new JoinBucketRequest();
request.setBucket(payload.bucket);
const bucket = payload.bucket === '' ? null : payload.bucket;
request.setThreadinfo(threadInfo);
request.setBucket(bucket || this.defaultBucket);

@@ -556,0 +584,0 @@ this.instance.joinBucket(

export interface ListDirectoryPayload {
path: string;
bucket: string;
bucket?: string;
}

@@ -8,3 +8,3 @@

path: string;
bucket: string;
bucket?: string;
}

@@ -17,3 +17,3 @@

export interface AddItemsPayload {
bucket: string;
bucket?: string;
targetPath: string;

@@ -25,3 +25,3 @@ sourcePaths: string[];

path: string;
bucket: string;
bucket?: string;
}

@@ -39,3 +39,3 @@

export interface ShareBucketViaEmailPayload {
bucket: string;
bucket?: string;
email: string;

@@ -47,7 +47,7 @@ }

identityValue: string;
bucket: string;
bucket?: string;
}
export interface GenerateFileShareLinkPayload {
bucket: string;
bucket?: string;
filePath: string;

@@ -72,7 +72,7 @@ }

export interface ListDirectoriesPayload {
bucket: string;
bucket?: string;
}
export interface ShareBucketPayload {
bucket: string;
bucket?: string;
}

@@ -85,3 +85,3 @@

};
bucket: string;
bucket?: string;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc