Skip to content

Instantly share code, notes, and snippets.

@snaketh4x0r
Last active July 15, 2020 05:02
Show Gist options
  • Save snaketh4x0r/a27adbd334a07d1e4b4035b651145ed6 to your computer and use it in GitHub Desktop.
Save snaketh4x0r/a27adbd334a07d1e4b4035b651145ed6 to your computer and use it in GitHub Desktop.
//start space daemon
//migrate to test directory and run this script
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const { SpaceClient } = require('@fleekhq/space-client');
// default port exposed by the daemon for client connection is 9998
const client = new SpaceClient({
url: `http://0.0.0.0:9998`,
});
const asyncFunc = async () => {
const res = await client.joinBucket({
bucket: 'my-bucket',
threadInfo: {
key: 'bd425grpqzrlcyp4etd44hmxu43if4med4yvr7oz4lb6btuhxfq6cbbipjcmz4zh3at3lqw2w5q5nlybdegrinbnlq3thclpwi7e2n7i',
addresses: [ '/ip4/127.0.0.1/tcp/4006/p2p/12D3KooWGYXjWob4iRkApRyLNVbSmroaNfDabWSKdEQkKMhmAPKE/thread/bafk3mrkrqmh3f4qfdfovbllt3ki3bxi3cxpgncqqz4a6wjlbpfshmzq',
'/ip4/192.168.1.6/tcp/4006/p2p/12D3KooWGYXjWob4iRkApRyLNVbSmroaNfDabWSKdEQkKMhmAPKE/thread/bafk3mrkrqmh3f4qfdfovbllt3ki3bxi3cxpgncqqz4a6wjlbpfshmzq',
'/ip4/122.161.109.149/tcp/4006/p2p/12D3KooWGYXjWob4iRkApRyLNVbSmroaNfDabWSKdEQkKMhmAPKE/thread/bafk3mrkrqmh3f4qfdfovbllt3ki3bxi3cxpgncqqz4a6wjlbpfshmzq' ],
},
});
asyncFunc();
console.log('result', res.getResult());
@snaketh4x0r
Copy link
Author

output after running

C:\Users\lazypuppet\Desktop\test.js:15
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

@snaketh4x0r
Copy link
Author

time="2020-07-15T10:13:04+05:30" level=debug msg="Running mode" DevMode=false
time="2020-07-15T10:13:05+05:30" level=debug msg="Running daemon with profiler. Visit http://localhost:6060/debug/pprof"
2020/07/15 10:13:05 Error loading .env file. Using defaults
time="2020-07-15T10:13:05+05:30" level=info msg="using path ~/.fleek-space for store"
badger 2020/07/15 10:13:08 INFO: All 0 tables opened in 0s
badger 2020/07/15 10:13:09 INFO: Replaying file id: 0 at offset: 0
badger 2020/07/15 10:13:10 INFO: Replay took: 172.5849ms
badger 2020/07/15 10:13:10 DEBUG: Value log discard stats empty
time="2020-07-15T10:13:10+05:30" level=debug msg="Starting Component" name=Store
time="2020-07-15T10:13:10+05:30" level=debug msg="Starting Component" name=FolderWatcher
time="2020-07-15T10:13:53+05:30" level=info msg="Welcome to bucket" peerID=12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H
time="2020-07-15T10:13:53+05:30" level=debug msg="Starting Component" name=BucketDaemon
time="2020-07-15T10:13:53+05:30" level=debug msg="Starting Async Component" name=TextileClient
time="2020-07-15T10:13:53+05:30" level=debug msg="Generating key pair..."
time="2020-07-15T10:13:54+05:30" level=debug msg="Error generating key pair, key might already exist"
time="2020-07-15T10:13:54+05:30" level=debug msg="Error while executing GenerateKeyPair. Key pair already exists. Use GenerateKeyPairWithForce if you want to override it."
time="2020-07-15T10:13:54+05:30" level=debug msg="Starting Textile Client..."
time="2020-07-15T10:13:54+05:30" level=debug msg="Creating buckets client in 127.0.0.1:3006"
time="2020-07-15T10:13:54+05:30" level=debug msg="Creating threads client in 127.0.0.1:3006"
time="2020-07-15T10:13:54+05:30" level=debug msg="Creating default bucket..."
time="2020-07-15T10:13:54+05:30" level=debug msg="Creating a new bucket with slug personal"
time="2020-07-15T10:13:54+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:13:54+05:30" level=debug msg="No persisted mountFuseDrive state found"
time="2020-07-15T10:13:54+05:30" level=debug msg="Starting Component" name=FuseController
time="2020-07-15T10:13:54+05:30" level=debug msg="Thread ID found in local store"
time="2020-07-15T10:13:54+05:30" level=debug msg="Starting Async Component" name=BucketSync
time="2020-07-15T10:13:54+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:13:54+05:30" level=debug msg="Thread ID found in local store"
time="2020-07-15T10:13:55+05:30" level=warning msg="BucketData already exists" bucketSlug=personal
time="2020-07-15T10:13:55+05:30" level=debug msg="Textile Client initialized successfully"
time="2020-07-15T10:13:55+05:30" level=debug msg="start watching open files ..."
time="2020-07-15T10:13:55+05:30" level=debug msg="Starting Async Component" name=gRPCServer
time="2020-07-15T10:13:55+05:30" level=debug msg="Starting watcher in bucketsync"
time="2020-07-15T10:13:55+05:30" level=info msg="listening on address [::]:9999"
time="2020-07-15T10:13:55+05:30" level=debug msg="Starting textile thread listener in bucketsync"
time="2020-07-15T10:13:55+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:13:55+05:30" level=debug msg="Thread ID found in local store"
time="2020-07-15T10:13:55+05:30" level=debug msg="Starting watcher" filePath="[]"
time="2020-07-15T10:13:55+05:30" level=debug msg="Starting textile threadsc listener"
time="2020-07-15T10:13:57+05:30" level=info msg="REST server is starting" port=9997
time="2020-07-15T10:13:57+05:30" level=info msg="gRPC-web proxy server started on Port 9998"
time="2020-07-15T10:13:57+05:30" level=info msg="gRPC server started on Port 9999"
time="2020-07-15T10:13:57+05:30" level=info msg="Daemon ready"

@snaketh4x0r
Copy link
Author

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
C:\Users\lazypuppet\Desktop\testproj\src\test.js:22
console.log('result', res.getResult());

SyntaxError: Unexpected end of input
�[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)�[39m
�[90m at Module._compile (internal/modules/cjs/loader.js:1122:27)�[39m
�[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)�[39m
�[90m at Module.load (internal/modules/cjs/loader.js:1002:32)�[39m
�[90m at Function.Module._load (internal/modules/cjs/loader.js:901:14)�[39m
�[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)�[39m
�[90m at internal/main/run_main_module.js:18:47�[39m

C:\Users\lazypuppet\Desktop\testproj\src>

@snaketh4x0r
Copy link
Author

C:\Users\lazypuppet\Desktop\testproj\src>node test.js
creating bucket...
{
wrappers_: null,
messageId_: undefined,
arrayIndexOffset_: -1,
array: [
'bafzbeieclz5nk65lcsfdh6ispujhkf55p5ztqw6taj4xfxmptmdydtc27m',
'buckettoshare1594789044480',
'/ipfs/bafybeiffkco7hm2bca2uyqpvpjnqdl7kf65e6bsv6r7mqy4gobt53otbym',
1594789053190182400,
1594789053190182400
],
pivot_: 1.7976931348623157e+308,
convertedPrimitiveFields_: {}
}
creating folder...
folder created!
fetchig directory...
{
code: 2,
message: 'invalid path "\\ipfs\\bafybeifltfvyqwidmaaeb3z4ljbhvucmfrphrcfw2fqoavenceft7d3bzu": selected encoding not supported',
metadata: {
'access-control-expose-headers': 'Vary, Date, Content-Type, Grpc-Status, Grpc-Message, grpc-status, grpc-message',
'content-type': 'application/grpc-web-text',
'grpc-message': 'invalid path "\\ipfs\\bafybeifltfvyqwidmaaeb3z4ljbhvucmfrphrcfw2fqoavenceft7d3bzu": selected encoding not supported',
'grpc-status': '2',
vary: 'Origin',
connection: 'close',
'transfer-encoding': 'chunked'
}
}
sharing bucket...
{
bucket: 'buckettoshare1594789044480',
key: 'bjpkpt3wqkhf7os6zlwi2itplyxjs6tmgcbiqxdn4rgeqgcrvhmgidz2an3pcxmcr2zhs6v324n45xuvym543lz5qkjoa7tfs2o3fyii',
addressList: [
'/ip4/127.0.0.1/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei',
'/ip4/192.168.43.151/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei',
'/ip4/157.33.234.252/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei',
'/ip4/157.33.198.184/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei'
],
addresses: '/ip4/127.0.0.1/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei, /ip4/192.168.43.151/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei, /ip4/157.33.234.252/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei, /ip4/157.33.198.184/tcp/4006/p2p/12D3KooWGWzytUr7X9GfoBbGwPdDmeT42MFGaoP8wNxmWMMiyb6H/thread/bafksufublxb7pd63roskj574xcyyxzet3m3juxwysjrjnla4ddh3wei'
}

@snaketh4x0r
Copy link
Author

time="2020-07-15T10:27:25+05:30" level=debug msg="Creating a new bucket with slug buckettoshare1594789044480"
time="2020-07-15T10:27:25+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:27:25+05:30" level=debug msg="Thread ID not found in local store. Generating a new one..."
time="2020-07-15T10:27:25+05:30" level=debug msg="Creating Thread DB"
time="2020-07-15T10:27:25+05:30" level=debug msg="Generating bucket"
time="2020-07-15T10:27:34+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:27:34+05:30" level=debug msg="Thread ID found in local store"
time="2020-07-15T10:27:55+05:30" level=debug msg="Fetching thread id from local store"
time="2020-07-15T10:27:55+05:30" level=debug msg="Thread ID found in local store"
time="2020-07-15T10:27:55+05:30" level=error msg="Error in ListDir -- ERROR -- rpc error: code = Unknown desc = invalid path "\\ipfs\\bafybeifltfvyqwidmaaeb3z4ljbhvucmfrphrcfw2fqoavenceft7d3bzu": selected encoding not supported[]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment