@questnetwork/quest-os-js

0.9.4 • Public • Published

Completion Help Wanted Version 0.9.4 Version 0.9.5 Sponsors

Quest OS JS

Lead Maintainer

StationedInTheField

Description

Unified API for the QuestNetwork dStack. Use with our example app: qDesk.

Main strategy is to create a Quest Network / IPFS / Ethereum interface that even kids can easily understand.

Quest OS offers encrypted channels, persistent storage, peer management, timelines, posts and more. It it used to load add-on modules, like quest-coral-js to use IPFS DAGs, or quest-dolphin-js to use IPFS GossipSub.

Security

Completion 1.0.0 EC AES

Quest OS uses 4096 Bit RSA-OAEP encryption, 256 Bit AES-CBC encryption and NIST P-521 EC signatures.

Installation & Usage

npm install @questnetwork/quest-os-js@0.9.4

OR

git clone https://github.com/QuestNetwork/quest-os-js && cd quest-os-js && git checkout 0.9.3 && cd ..

API

async boot(config)

Boots the operating system. The GitHub branches master/0.9.2/0.9.3+ boot with:

JavaScript/NodeJS

import { qOS } from '@questnetwork/quest-os-js'
// configure with a bootstrap swarm peer, for testing you can use:
let config = {
  ipfs: {
        Swarm: [<swarm star peer ip>,<swarm star peer ip>],
        API: '',
        Gateway: ''
  },
  version: <version>
  dev: <true/false>
};
// boot the operating system
qOS.boot().then( () => {
  //the operating system is online, build the future
})

TypeScript/Angular Service

import { Injectable } from '@angular/core';
import { qOS }  from '@questnetwork/quest-os-js';
import * as swarmJson from '../swarm.json';
import  packageJson from '../../../package.json';
const version = packageJson.version;

@Injectable({
  providedIn: 'root'
})
export class QuestOSService {
  public os;
  ready = false;
  config;
  constructor() {
    this.config = {
      ipfs: {
        Swarm: swarmJson['ipfs']['Swarm'],
        API: '',
        Gateway: ''
      },
      version: version,
      dev: swarmJson['dev']
    };
    this.os = qOS;
  }
  async boot(){
      try{
        await this.os.boot(this.config);
        this.ready = true;
      }
      catch(e){
        throw(e);
      }
  }
}

isReady()

Returns true once boot is complete, otherwise returns false.

if(<os>.isReady()){
  console.log("Ready To Sign In");
};

onReady()

Returns a Subject that pushes next when boot is complete

if(<os>.onReady().subsribe( () => {
  console.log("Ready To Sign In");
});

reboot()

Reboots the entire system

<os>.reboot();

utilities.engine.detect()

Returns a string 'node', 'electron' or 'browser'

if(<os>.utilities.engine.detect() == 'node'){
  console.log("Hello Universe");
};

enableSaveLock()

Bee

Locks the system from saving any changes

<os>.enableSaveLock();

disableSaveLock()

Bee

Unlocks the system from saving changes and saves changes normally

<os>.disableSaveLock();

setStorageLocation(location)

Bee

Sets the storage location for the app. Normally Quest OS does this automatically and you do not need to call this function. Possible locations are: "Download","LocalStorage" or "ConfigFile"

<os>.setStorageLocation("LocalStorage");

getStorageLocation(location)

Bee

Returns a string with the current storage location

<os>.getStorageLocation();

signIn(config = {})

Bee

Activates Accounts. Empty config creates a new account

<os>.signIn({});

signOut()

Bee

Deactivates Accounts And Restarts The Interface On The Web, Closes The Current Window In Electron

<os>.signOut();

onSignIn()

Bee

Returns a subscribable Subject that fires when the account is signed in.

<os>.onSignIn().subscribe( () => {
  console.log("Hello Universe");
});

isSignedIn()

Bee

Returns a boolean true or false

if(<os>.isSignedIn()){
  console.log("Hello Universe");
};

channel

async channel.create(dirtyChannelName, parentFolderId = "")

Bee Ocean

Returns the clean channel name

let claenChannelName = await <os>.channel.create('propaganda');

channel.remove(cleanChannelName)

Bee Ocean

Removes a channel

<os>.channel.remove('propaganda----1234');

channel.listen(cleanChannelName)

Ocean

Returns a Subject that forwards non-system channel messages.

<os>.channel.listen('propaganda----1234').subscribe( msg ){
  console.log(msg);
}

async channel.publish(cleanChannelName, message, type = 'CHANNEL_MESSAGE')

Ocean

Returns a Subject that forwards non-system channel messages.

await <os>.channel.publish('propaganda----1234',"Hello Universe");

channel.challenge

channel.challenge.enable(cleanChannelName)

Ocean

Opens the channel to everyone who can solve the Captcha provided by Quest Image Captcha JS

<os>.channel.challenge.enable('propaganda----1234');

channel.challenge.disable(cleanChannelName)

Ocean

Closes the channel to invite only participation

<os>.channel.challenge.disable('propaganda----1234');

channel.challenge.isEnabled(cleanChannelName)

Ocean

if(<os>.isEnabled()){
  console.log("Hello Universe");
};

channel.invite

channel.invite.create(cleanChannelName,newInviteCodeMax, exportFolders = false)

Bee Ocean

Creates a new channel invite, specify max uses of this invite code and whether or not to include your folder structure.

<os>.channel.invite.create('propaganda----1234',5,true);

channel.invite.remove(cleanChannelName,link)

Bee Ocean

Removes a channel invite

<os>.channel.invite.remove('propaganda----1234',"5448495320495320414e2045585452454d454c59204c4f4e4720414e4420494e56414c494420494e5649544520434f4445");

channel.invite.get(channel)

Ocean

Gets all invites for a channel

let invites = <os>.channel.invite.get('propaganda----1234');

channel.invite.get(channel)

Ocean

Gets all invites for a channel

let invites = <os>.channel.invite.get('propaganda----1234');

Unfortunately nobody is working on a detailed API documentation yet, until then check out the source in qDesk Messages 0.9.3+ to see how to use the OS.

We recommend to use our quest-cli to test and build the package. It allows you to bootstrap your Quest Network apps with the same peers and settings.

Pro Tip: Put a file in your /bin that runs the quest-cli like so node /path/to/quest-cli/index.js from any folder on your system. It's much nicer!

Features

0.9.2

0.9.3

  • Quest Social JS
  • Documentation Extended
  • Easier Access
  • Offer "LocalStorage" As A Storage Container On The Web To Stay Signed In

0.9.4 Change Peer Configuration in browser, Electron and on NodeJS

Roadmap

0.9.4

  • Democratically block or mute peers
  • Faux requests. Send request in channel, wait for response, deliver response as if it was an http request.

Support Us

Please consider supporting us, so that we can build a non-profit for this project (ツ)

Ethereum Bitcoin
0xBC2A050E7B87610Bc29657e7e7901DdBA6f2D34E bc1qujrqa3s34r5h0exgmmcuf8ejhyydm8wwja4fmq

License

GNU Affero GPLv3

Readme

Keywords

none

Package Sidebar

Install

npm i @questnetwork/quest-os-js

Weekly Downloads

1

Version

0.9.4

License

AGPL-3.0

Unpacked Size

130 kB

Total Files

16

Last publish

Collaborators

  • stationedinthefield