Coder Social home page Coder Social logo

arcana-js-sdk's Introduction

arcana-js-sdk

Inlude arcana.js in your of html

<script src="../path/to/sdk/arcana.js"></script>

Create a arcana intance

// address: Smart contract address of app
// private key: Secp256K private key
// convergence: seceret for a specific user
const arcanaInstance = new arcana.Arcana(address, privateKey, convergence);

Uploader

const Uploader = arcanaInstance.getUploader();
// file: Blob format
Uploader.upload(file);

Downloader

const Downloader = arcanaInstance.getDownloader();
// did: DID of file which you want to download
Downloader.download(did);

Access

const Access = new arcanaInstance.getAccess();

Share a file

// did: DID of file to be shared
// publicKey: recipients public key
// validity: For how long will be the user able to download the file
Access.share([did], [publicKey], [validity]);

Revoke access

// did: DID of file from which access is removed
// address: Address of the user who's access is getting revoked
Access.revoke(did, address);

Change File owner

// address: new owner's address
Access.changeFileOwner(did, address);

Delete File

Access.deleteFile(did);

FallBack Functions

1. Upload

1.1 On Success
uploader.onSuccess = () => {
  console.log('Completed file upload');
};
1.2 On Error
uploader.onError = (err) => {
  console.log('Error', err);
};
1.3 On Progress
uploader.onProgress = (bytesUploaded: number, bytesTotal: number) => {
  console.log("Completed", bytesUploaded, "out of", bytesTotal)
};

2. Download

2.1 On Success
downloader.onSuccess = () => {
  console.log('Completed file download');
};
2.2 On Progress
downloader.onProgress = (bytesDownloaded: number, bytesTotal: number) => {
  console.log("Completed", bytesDownloaded, "out of", bytesTotal)
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.