FISSION IPFS Web API
A TypeScript client library for access accessing the FISSION Web API.
Installing
$ npm install --save @fission-suit/client
API
Utility
getGatewayURL
Returns a formatted gateway url for a given CID.
Params:
- cid: CID (string) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { getGatewayURL } from '@fission-suite/client'
const formattedURL = getGatewayURL("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u")
Unauthenticated
register
Registers a user for the Fission service.
Params:
- username: string required
- password: string required
- email: string
Example:
import { register } from '@fission-suite/client'
await register("username", "password", "email@email.com")
peers
Gets the address for all IPFS nodes in the Fission Network.
Example:
import { peers } from '@fission-suite/client'
await peers()
content
Returns content at given CID.
Params:
- cid: CID (string) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { content } from '@fission-suite/client'
const helloWorld = await content("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u")
Authenticated
These methods require a username/password from the fission webserver. These can be provisioned through our Fission CLI.
verify
Verifies the given credentialls.
Params:
- auth: Auth ({username: string, password: string}) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { verify } from '@fission-suite/client'
await verify({ username: "username", password: "password" })
resetPassword
Verifies the given credentialls.
Params:
- auth: Auth ({username: string, password: string}) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { resetPassword } from '@fission-suite/client'
await resetPassword("newPassword", { username: "username", password: "password" })
add
Adds content to IPFS and returns the CID of that content.
Params:
- content: Content (json, string, file-stream) required
- auth: Auth ({username: string, password: string}) required
- baseURL: string defaults to fission web-api at
https://runfission.com
- name: string optional name for your file, defaults to
undefined
Example:
import { add } from '@fission-suite/client'
const auth = { username: "username", password: "password" }
const content = {
key1: 123,
key2: 456
}
const cid = await add(content, auth)
remove
Unpins content from Fission server and disassociates CID with user account.
Params:
- cid: CID (string) required
- auth: Auth ({username: string, password: string}) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { remove } from '@fission-suite/client'
const auth = { username: "username", password: "password" }
await remove("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u", auth)
pin
Pins content to Fission server.
Params:
- cid: CID (string) required
- auth: Auth ({username: string, password: string}) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { pin } from '@fission-suite/client'
const auth = { username: "username", password: "password" }
await pin("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u", auth)
cids
Gets all CIDs associated with the given user.
Params:
- auth: Auth ({username: string, password: string}) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { cids } from '@fission-suite/client'
const auth = { username: "username", password: "password" }
await cids(auth)
updateDNS
Updates the users associated subdomain to point at the given CID
Params:
- cid: CID (string) required
- auth: Auth ({username: string, password: string}) required
- baseURL: string defaults to fission web-api at
https://runfission.com
Example:
import { updateDNS } from '@fission-suite/client'
const auth = { username: "username", password: "password" }
await updateDNS("QmYwXpFw1QGAWxEnQWFwLuVpdbupaBcEz2DTTRRRsCt9WR", auth)
Fission objects
For repeated calls, instantiate a fission object:
import Fission, { FissionUser } from '@fission-suite/client'
const fission = new Fission("https://someurl.com")
const helloWorld = await fission.content("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u")
const fissionUser = fission.login("username", "password")
const cid = await fissionUser.add("Check this out!")
await fissionUser.pin(cid)
const cids = fissionUser.cids()
Testing
- Run
npm i
- Run tests with:
npm run test
- Or achieve developer zen with
npm run test:watch