@elrondnetwork/evertrail.web
v0.0.2@elrondnetwork/evertrail.web
The Browser implementation of the Elrond Evertrail service, built using Node.js and Typescript.
Requirements
- Node.js version 14.16.0+
- Npm version 6.14.0+
- Typescript version 4.2.3+
Dependencies
- rxjs version 6.6.6+
- evertrail.core
Usage
// Creating a hash
import { hash } from '@elrondnetwork/evertrail.web'
// (file: File) => Promise<HashResult>
const hashResult = await hash(file) // regular Web API file,
// see https://developer.mozilla.org/en-US/docs/Web/API/File
// Creating the evertrail client
import { evertrail } from '@elrondnetwork/evertrail.web'
// Only one of the following fields should be used at once
const authorization = {
token: 'sampleToken',
}
const client = evertrail({ authorization })
// The client can then be used to access the trail functions
// Fetching an user's account
// () => Promise<Result>
const account = await client.account()
// Fetching an user's trails
// Both of the following fields are nullable
const parameter = {
sha256: 'some hash', // Last hash after which to fetch trails
timeStamp: 'some timestamp' // Last timestamp after which to fetch trails
}
// (input: TrailParameter) => Promise<Result>
const trails = await client.trails(parameter)
// Creating an trail
const input = {
file,
options: {
shouldStoreObject: true // Flag to store generated object alongside trail
}
}
// (input: { file: File, onProgress?: onProgress, options?: Options }) => Promise<Result>
const createResponse = await client.create(input)
// Verifying if a file is already trailed
const input = "some existing hash" // Or use the reader if you don't already have a hash
const verifyResponse = await client.verify(input)
Exposed types
TokenAuthorization: { baseUrl: string, token: string }
Type to be used for authorizing the client by access token
EvertrailWeb: { trails, account, create, verify }
Type of the evertrail client