@elrondnetwork/attest
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@elrondnetwork/attest

The npm package of the Elrond Attest service, built using Node.js and Typescript.

Requirements

  • Node.js version 14.16.0+
  • Npm version 6.14.0+

Dependencies

Exposed types

  • AttestApi - creates an instance of the AttestApi
  • HashResult - represents the result of a hashing operation

Exposed functions

Note that these may be subject to change

  • webHash - hashes its inputs -> to be used by browser-based applications
  • cliHash - hashes its inputs -> to be used by cli-based applications

Usage

AttestApi

Note that the following methods may be subject to change

// In both examples, base url refers to the url of 
// the ElrondAttest api

// Initialization with api key
const api = AttestApi.withApiKey(apiKey, baseUrl)

// Initialization with access token
const api = AttestApi.withToken(token, baseUrl)

// Fetching account data
api.account() // returns an Axios promise

// Creating a file attestation
const input = {
    type: 'file',
    sha256: 'some hash here'
}

api.create(input) // returns an Axios promise

// Creating an object attestation
const input = {
    type: 'object',
    sha256: 'some hash here',
    object: {
        //...
    }
}

api.create(input) // returns an Axios promise

// Fetching the user's attested files
api.accountRecords() // returns an Axios promise

// Verifying if a file is attested

const hashOfFileToVerify = 'some hash'

api.records(hashOfFileToVerify)

HashResult

type HashResult = {
    type: 'file' | 'object',
    sha256: string,
    object?: object
}

webHash

// An already read file
const file = {}

// Callback for setting progress
// receives a number between 0 & 100 representing progress
// returns void
const setProgress = progress => {}

// Callback called on finalization
// receives a HashResult object representing the hashed file
// returns void
const onFinalize = hashResult => {} 

webHash(file, setProgress, onFinalize)

cliHash

const path = 'Path to file...'

cliHash(path) // Returns Promise<HashResult>

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    1

Package Sidebar

Install

npm i @elrondnetwork/attest

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

42.5 kB

Total Files

47

Last publish

Collaborators

  • lucian.mincu