Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn install --frozen-lockfile
- run: yarn run build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
node-version: '22.x'
- run: yarn install --frozen-lockfile
- run: yarn run build
- run: node --test --test-concurrency 1
Expand Down
52 changes: 22 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@filebase/sdk",
"version": "1.0.6",
"version": "2.0.0",
"description": "SDK for Interacting with Filebase Services [S3(Buckets, Objects), IPFS(Gateways, Pins) IPNS(Names)]",
"repository": {
"type": "git",
Expand All @@ -11,22 +11,19 @@
"module": "./src/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./src/index.js",
"types": "./dist/index.d.ts"
}
"node": {
"types": "./dist/node/index.d.ts",
"require": "./dist/node/index.js",
"import": "./dist/node/index.mjs"
},
"default": "./dist/browser/index.js"
},
"files": [
"dist",
"src"
],
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
},
"scripts": {
"build": "tsup src/index.js --format cjs --dts --clean",
"build": "tsup src/index.js",
"test": "node --test",
"doc": "jsdoc -c jsdoc.json"
},
Expand All @@ -38,28 +35,23 @@
"ipns",
"sdk",
"web3",
"distributed"
"distributed",
"decentralized"
],
"devDependencies": {
"clean-jsdoc-theme": "4.2.17",
"jsdoc": "4.0.2",
"prettier": "3.1.0",
"tsup": "8.0.1",
"typescript": "5.3.3"
"clean-jsdoc-theme": "4.3.0",
"esbuild": "^0.25.8",
"esbuild-plugins-node-modules-polyfill": "1.7.1",
"jsdoc": "4.0.4",
"prettier": "3.6.2",
"tsup": "8.5.0",
"typescript": "5.8.3",
"uuid": "11.1.0"
},
"dependencies": {
"@aws-sdk/client-s3": "3.478.0",
"@aws-sdk/lib-storage": "3.478.0",
"@helia/car": "1.0.4",
"@helia/mfs": "3.0.1",
"@helia/unixfs": "1.4.3",
"@ipld/car": "5.2.4",
"axios": "1.6.2",
"blockstore-fs": "1.1.10",
"blockstore-core": "4.4.1",
"datastore-core": "9.2.9",
"p-queue": "8.0.1",
"uuid": "9.0.1",
"winston": "3.12.0"
"@aws-sdk/client-s3": "3.842.0",
"@aws-sdk/s3-request-presigner": "3.844.0",
"axios": "1.10.0",
"ipns": "10.1.2"
}
}
126 changes: 52 additions & 74 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,77 @@
<h1 align="center">&#x2022; Filebase SDK &#x2022;</h1>
<p align="center">Developer Friendly [ <a href="https://docs.ipfs.tech/concepts/what-is-ipfs/" title="What is IPFS?">IPFS</a> | <a href="https://docs.ipfs.tech/concepts/ipns/" title="What is IPNS?">IPNS</a> | S3 ]</p>
# 🗂️ Filebase SDK

## About

The Filebase SDK provides a hybrid data management solution, blending S3-compatible cloud storage with IPFS
(InterPlanetary File System) pinning services. It features robust S3 bucket management, object handling for uploads and
downloads, and seamless integration with IPFS and IPNS (InterPlanetary Naming System) for decentralized storage
operations. The SDK supports advanced data tasks like compiling files into CAR (Content Addressable aRchive) formats and
ensures secure transactions through strong authentication. Designed for varied applications, the Filebase SDK is ideal
for scenarios demanding the dependability of cloud storage combined with the advantages of decentralized, peer-to-peer
storage, catering to diverse needs such as content distribution, data backup, and archival. Developing InterPlanetary
Applications has never been easier.
[![npm version](https://badge.fury.io/js/@filebase%2Fsdk.svg)](https://badge.fury.io/js/@filebase%2Fsdk)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

### JS Client
---
## About

Install the package using npm
The Filebase SDK for JavaScript offers a straightforward way to add decentralized storage to your applications. It lets your team easily work with IPFS and IPNS, handling the tricky parts for you.

```shell
npm install @filebase/sdk
```
Here's what you can do:

or yarn:
* Manage Storage: Easily create and control your storage spaces and gateways.
* Handle IPFS Files: Upload, download, and "pin" files to the IPFS network with ease.
* Control IPNS Names: Set up and find IPNS names to keep your content links consistent.
* Move Data: Quickly copy files between different storage spots.

```shell
yarn add @filebase/sdk
```
Just install it with `npm install @filebase/sdk`. This SDK helps your team quickly build solutions using the power of decentralized data. Check out the full guide for all the details!

### Getting started

The snippet below shows how to create a new bucket with `BucketManager`, upload a new object to IPFS
with `ObjectManager`, publish the object to IPNS with `NameManager`, delete the object with `ObjectManager` and finally
delete the bucket with `BucketManager`.
The snippet below shows how to create a new bucket, create a new gateway, upload a file to IPFS, publish the
file to IPNS.

To use the library in your project, use npm or yarn to install the [`@filebase/sdk`](https://www.npmjs.com/package/@filebase/sdk) module. Requires node.js 16+.
To use the library in your project, use npm to install the [
`@filebase/sdk`](https://www.npmjs.com/package/@filebase/sdk) module.

**node.js**

````js
// Import Classes
import {
BucketManager,
ObjectManager,
NameManager,
GatewayManager,
PinManager
} from '@filebase/sdk'

// Initialize BucketManager
const bucketManager = new BucketManager(S3_KEY, S3_SECRET);
// Import example
import {FilebaseClient} from '@filebase/sdk'

// Create bucket
const client = new FilebaseClient(clientKey, clientSecret);
const bucketName = `create-bucket-[random string]`;
await bucketManager.create(bucketName);
await client.createBucket(bucketName);

// Create New Gateway
const gatewayName = "myRandomGatewayName";
const myGateway = await client.createGateway(gatewayName);

// Upload File
const client = new FilebaseClient(clientKey, clientSecret, {
bucket: bucketName,
gateway: "https://myRandomGatewayName.myfilebase.com"
});
const fileName = `new-object`;
const uploadedFile = await client.uploadFile(fileName, new Blob(["Hello Filebase!"]));

// Initialize ObjectManager
const objectManager = new ObjectManager(S3_KEY, S3_SECRET, {
bucket: bucketName
// Pin File
const myNewPin = await client.pinFile("my-pin", "QmTJkc7crTuPG7xRmCQSz1yioBpCW3juFBtJPXhQfdCqGF");

// Download File
await client.downloadFile("/organized/my-object");
await client.fetchContentByCid(uploadedFile.cid, {
endpoint: "my-custom-gateway.myfilebase.com",
});
// Upload Object
const objectName = `new-object`;
const uploadedObject = await objectManager.upload(objectName, body);
// Download Object
await uploadedObject.download();
// Copy Object to a New Bucket

// Copy File to a New Bucket
const bucketCopyDestinationName = `copy-dest-bucket`
await bucketManager.create(bucketCopyDestinationName);
await objectManager.copy(`new-object`, bucketCopyDestinationName);
await client.createBucket(bucketCopyDestinationName);
await client.copyFile(`my-original-file`, 'my-copied-file', {
destinationBucket: bucketCopyDestinationName
});

// Initialize NameManager
const nameManager = new NameManager(S3_KEY, S3_SECRET);
// Create New IPNS Name with Broadcast Disabled
const ipnsLabel = `myFirstIpnsKey`;
const ipnsName = await nameManager.create(ipnsLabel, uploadedObject.cid, {
const ipnsName = await client.createIpnsName(ipnsLabel, uploadedObject.cid, {
enabled: true
});

// Initialize GatewayManager
const gatewayManager = new GatewayManager(S3_KEY, S3_SECRET);
// Create New Gateway
const gatewayName = "myRandomGatewayName";
const myGateway = await gatewayManager.create(gatewayName);

// Initialize PinManager
const pinManager = new PinManager(S3_KEY, S3_SECRET, {
bucket: bucketName,
gateway: {
endpoint: "https://myRandomGatewayName.myfilebase.com"
}
});
// Create New Pin with Metadata
const myNewPin = await pinManager.create("my-pin", "QmTJkc7crTuPG7xRmCQSz1yioBpCW3juFBtJPXhQfdCqGF", {
"application": "my-custom-app-on-filebase"
});
const downloadedFile = await client.fetchContentByIpnsName(ipnsLabel, {
endpoint: "my-gw.myfilebase.com"
})
````

Full API reference doc for the JS client are available at https://filebase.github.io/filebase-sdk

### Testing

Test are found in the `test` directory and are built to be run with the Node.js v20+ test runner.
Full API reference doc for the JS client are available at https://filebase.github.io/filebase-sdk
Loading
Loading