Class: Bridge

Bridge

Represents a local HTTP(s) server that abstracts the upload and download of files away to a simple request. Files are encrypted to the given public key, split into shards for erasure codes. Prepped for distribution and queued for storing in the network. Bridge exposes a simple API for getting status of transfers and previously stored objects.

new Bridge(node, options)

Parameters:
Name Type Description
node Node
options object
Source:

Methods


addTrustedIdentity(request, response, next)

Adds a fingerprint to the trusted identities
Parameters:
Name Type Description
request object
response object
next function
Source:

audit(callback, callback)

Periodically call this to scan the object store for shards that need to be audited
Parameters:
Name Type Description
callback
callback function
Source:

authenticate(request, response, next)

Handles request authentication if defined
Parameters:
Name Type Description
request object
response object
next function
Source:

changePassphrase(request, response, next)

Changes the authentication passphrase
Parameters:
Name Type Description
request object
response object
next function
Source:

destroyObject(request, response, next)

Ends contracts with farmers for the object parts and removes reference to them
Parameters:
Name Type Description
request object
response object
next function
Source:

disableTotpSecret(request, response, next)

Disables TOTP two-factor-authentication
Parameters:
Name Type Description
request object
response object
next function
Source:

distribute(filepath, metadata, object, callback)

Takes the supplied file path and applies erasure codes, then attempts to distribute the shards across the network
Parameters:
Name Type Description
filepath string Path to the file to distribute
metadata object
object ObjectPointer
callback function
Source:
Returns:
Type
EventEmitter

downloadObject(request, response, next)

Downloads the object from the network
Parameters:
Name Type Description
request object
response object
next function
Source:

error(error, request, response, next)

Responds to requests with error code and message
Parameters:
Name Type Description
error error
request object
response object
next function
Source:

generateTotpSecret(request, response, next)

Generates a TOTP secret code
Parameters:
Name Type Description
request object
response object
next function
Source:

getBridgeSettings(request, response)

Returns this bridge's settings
Parameters:
Name Type Description
request object
response object
Source:

getNodeStatus(request, response, next)

Returns status information about the running node
Parameters:
Name Type Description
request object
response object
next function
Source:

getObjectInfo(request, response, next)

Gets object information by unique ID
Parameters:
Name Type Description
request object
response object
next function
Source:

getPeerReputationScore(identity, callback)

Calculates the percentile and relative usage allowance of the given identity
Parameters:
Name Type Description
identity string 160 bit node identity key
callback Directory~getPeerReputationScoreCallback
Source:

listen(port, hostname, callback)

Listens on the given port and hostname
Parameters:
Name Type Description
port number
hostname string
callback function
Source:

listObjects(request, response, next)

Scans the object database and returns all index entries
Parameters:
Name Type Description
request object
response object
next function
Source:

login(request, response, next)

Checks the passphrase against the local salted hash and sets a session cookie
Parameters:
Name Type Description
request object
response object
next function
Source:

logout(request, response)

Invalidates the authentication token supplied
Parameters:
Name Type Description
request object
response object
Source:

removeTrustedIdentity(request, response, next)

Removes a fingerprint from the trusted identities
Parameters:
Name Type Description
request object
response object
next function
Source:

resolveObject(request, response, next)

Accepts a body containing a magnet link, resolves the pointer and creates a local object pointer record, then returns it. Clients can follow with a GET /:id to download the object
Parameters:
Name Type Description
request object
response object
next function
Source:

retryUploadObject(request, response, next)

Retries the object upload
Parameters:
Name Type Description
request object
response object
next function
Source:

scoreAuditReports(callback)

Takes all audit reports and reaps them while applying their results to local peer profile reputation score, then publishes the compressed payload to the bootstrap directory
Parameters:
Name Type Description
callback function
Source:

setupTotpSecret(request, response, next)

Sets up TOTP secret
Parameters:
Name Type Description
request object
response object
next function
Source:

uploadObject(request, response, next)

Queues the object for upload to the network
Parameters:
Name Type Description
request object
response object
next function
Source: