在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:rarepress/nebulus开源软件地址:https://github.com/rarepress/nebulus开源编程语言:JavaScript 100.0%开源软件介绍:Nebulus
Nebulus is an IPFS compatible file system that lets you work privately and locally while preserving all the authenticity traits of IPFS, as well as providing the ability to synchronize with the IPFS network. IPFS without the NetworkNebulus makes use of the encoding scheme of IPFS to represent files, without having to use the IPFS network. You no longer have to keep running an IPFS node to work with IPFS files. Simply work offline and publish to IPFS only when needed. Offline and Private IPFSNebulus lets you manage files in a manner identical to how files are stored on the public IPFS network, but privately. IPFS as Data PacketInstead of thinking of IPFS as just a "storage system", we can use IPFS as a data packet for private communication between multiple parties. This means you can store data in Nebulus, and directly send the data over any network transport mechanism without making it public. For example, we can think of a Nebula server that listens to IPFS messages. You don't have to use the IPFS DHT. Alice can directly post an IPFS data packet to Bob's server, privately. How it worksIPFS Hash as Symbolic LinkInstead of having to share everything on the public IPFS network, Nebulus computes the IPFS hash (CID) of the files, locally. Once the hash is calculated, a symbolic link is created. The symbolic link points to the original file, and has the file name of the calculated IPFS hash. We have two folders above:
Note that all files under the Offline FirstNebulus is an "Offline First" version of IPFS. Basically it lets you work with IPFS without having to share everything on the IPFS public network. IPFS is essentially a bundle of two things:
This means, to use IPFS you need to publish everything to the public network. With Nebulus, the network and the file system are unbundled and you can use IPFS privately, without having to publish everything to the public IPFS network. Like Git, for IPFSInstead of publishing everything to the public IPFS network immediately, you can work with IPFS files locally, and publish later: This is similar to how Git works (compared to centralized version control systems like SVN, where everyone needs to publish immediately to the central repository to take advantage of the version control features): When you use IPFS directly, // adding directly to IPFS means it's immediately shared on the public IPFS network
await ipfs.add(...) However with Nebulus, you now have the option to use Nebulus as an offline buffer. You can work privately and only publish to IPFS when needed: // 1. Privately add an IPFS file to the local file system
let cid = await nebulus.add(Buffer.from("Hello world"))
// 2. "Push" to the public IPFS network
nebulus.push(cid) Essentially, Nebulus unbundles the IPFS file format from the IPFS network. This unbundling means more flexibility. For example you can use other network transport protocols to replicate your IPFS files (such as HTTP, WebRTC, Hypercore, etc.) Use CasesProof of ExistenceSometimes you may want to openly publish a hash of a file before revealing the contents of the file. This way you can prove later that you had that file at that point in time. You can use Nebulus for this. This property can be used for various use cases such as: 1. Peer to Peer Proof of ExistenceCreate a Nebulus file, share its hash with someone over any channel to prove it existed at certain point in time (email, messaging apps, social media), and later reveal content. 2. Blockchain timestampingUse the IPFS encoding format to store files privately and timestamp on the blockchain (like Opentimestamps) without revealing the contents. 3. Mystery NFT CollectionCreate an NFT collection that does not reveal its contents initially, but later you can easily "upload" to IPFS with one line of code. Private Draft for IPFSYou may want to work with a whole archive of files that you'll publish to IPFS eventually. For example, you may have a folder structure that looks like this: /
index.html
avatar.png
item.html If you want to reference And because updating IPFS CIDS means publishing to IPFS, you have no choice but to make every version of your files public whenever you update. With Nebulus you can do everything locally without publishing. Private StorageNebulus provides a new way to store and serve IPFS files privately. Instead of serving your files to the public through the IPFS network, you can serve them privately to those who have permission to access the data. IPFS as Data PacketBecause Nebulus has unbundled the IPFS encoding format from the IPFS network, we can go further and ONLY use the IPFS for its encoding format. You can use IPFS only as a data packet for communicating between parties, instead of thinking of it as a public storage. For example,
Ephemeral IPFS
Sometimes you may only want to use the public IPFS network as a way to replicate your file once, but you may not care about the permance of the file. To be more precise, you may want to use the IPFS network as a replacement for Here's an example workflow:
You can use the await nebulus.connect()
nebulus.on("push", (cid) => {
// do something here
}) Because the You can take advantage of this feature when you are certain that whoever the file is intended for will pick it up eventually as long as it's discovered in the gateway. This way you don't have to run your own IPFS node. Install
ExamplesAdd a Buffer to Nebulusconst Nebulus = require('nebulus');
const nebulus = new Nebulus()
const run = async () => {
const buffer = Buffer.from("hello world")
const cid = await nebulus.add(buffer)
console.log("cid", cid)
}
run() Add a Local File to Nebulusconst Nebulus = require('nebulus')
const nebulus = new Nebulus()
const run = async () => {
await fs.promises.writeFile(__dirname + "/fixture/hello.txt", "hello world")
const cid = await nebulus.add(__dirname + "/fixture/hello.txt")
console.log("cid", cid)
}
run() Download a Web File to Nebulusconst Nebulus = require('nebulus')
const nebulus = new Nebulus()
const run = async () => {
const cid = await nebulus.download("https://ipfs.io/ipfs/bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e")
console.log("cid", cid)
}
run() Create a Folder on Nebulusconst Nebulus = require('nebulus')
const nebulus = new Nebulus()
const run = async () => {
const files = [
await nebulus.add("https://raw.githubusercontent.com/skogard/rarepress.js/0ad35d7da27a4d1e5f990a3bcf301e3fa9bae7ec/README.md"),
await nebulus.add("https://raw.githubusercontent.com/skogard/rarepress.js/0ad35d7da27a4d1e5f990a3bcf301e3fa9bae7ec/index.js"),
await nebulus.add("https://raw.githubusercontent.com/skogard/rarepress.js/0ad35d7da27a4d1e5f990a3bcf301e3fa9bae7ec/package.json"),
await nebulus.add("https://github.com/skogard/rarepress.js/raw/0ad35d7da27a4d1e5f990a3bcf301e3fa9bae7ec/press.png")
]
let cid = await nebulus.folder({
"readme.md": files[0],
"index.js": files[1],
"package.json": files[2],
"press.png": files[3]
})
let files = await fs.promises.readdir("storage/ipfs/" + cid)
cnosole.log("files", files)
}
run() Pull a File from IPFSconst Nebulus = require('nebulus')
const nebulus = new Nebulus()
const run = async (cid) => {
await nebulus.connect()
nebulus.on("pull", (pulled_cid) => {
console.log("pulled cid", pulled_cid)
fs.createReadWtream("storage/ipfs/" + pulled_cid).pipe(process.stdout)
})
nebulus.pull(cid)
}
const cid = "bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e"
run(cid) Push a File to IPFSconst Nebulus = require('nebulus')
const nebulus = new Nebulus()
const run = async (cid) => {
const buffer = Buffer.from("never gonna give you up")
const cid = await nebulus.add(buffer)
nebulus.on("push", (pushed_cid) => {
// check the following pushed URL in the browser
console.log("https://ipfs.io/ipfs/" + pushed_cid)
})
nebulus.push(cid)
} API
InitializingconstructorYou can initialize a Nebulus instance using a constructor: const Nebulus = require('nebulus')
const nebulus = new Nebulus(<options>) Where
The const Nebulus = require('nebulus')
const nebulus = new Nebulus({ path: "storage" }) will create a folder named If the const Nebulus = require('nebulus')
const nebulus = new Nebulus() Will create a Also, you can use the const Nebulus = require('nebulus')
const nebulus = new Nebulus({max: 100}) will create a Finally, you can pass in a const Nebulus = require('nebulus')
const nebulus = new Nebulus({
config: {
Addresses: {
Swarm: [
"/ip4/0.0.0.0/tcp/4030",
"/ip4/127.0.0.1/tcp/4031/ws"
],
API: "/ip4/127.0.0.1/tcp/5030",
Gateway: "/ip4/127.0.0.1/tcp/9100"
}
}
}) WritingaddAdd local data to Nebulus. Adding bufferconst buffer = Buffer.from("hello world")
const cid = await nebulus.add(buffer) Adding filesawait fs.promises.writeFile(__dirname + "/fixture/hello.txt", "hello world")
const cid = await nebulus.add(__dirname + "/fixture/hello.txt") downloadDownload external web files to Nebulus. Download from any URLconst cid = await nebulus.download("https://thisartworkdoesnotexist.com") Download from IPFS gatewayconst cid = await nebulus.download("https://ipfs.io/ipfs/bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e") folderCreate a depth-1 folder (Nested folders not yet supported) Add files and then create a folder with the CIDsconst file_cids = [
await nebulus.add(__dirname + "/fixture/aperank/aperank.png"),
await nebulus.add(__dirname + "/fixture/aperank/readme.md"),
await nebul |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论