Socket
Book a DemoInstallSign in
Socket

@telios/telios-client-backend

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telios/telios-client-backend

A reusable backend to for telios email clients to use between desktop and mobile.

Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
8
166.67%
Maintainers
1
Weekly downloads
 
Created
Source

telios-backend

Build Status

A reusable backend to for telios email clients to use between desktop and mobile.

Installation

npm i --save @telios/telios-client-backend

Usage

Electron example:

const path = require('path')
const fs = require('fs')
const { fork } = require('child_process')
const { remote } = require('electron')
const userDataPath = remote.app.getPath('userData')
const filePath = path.join(__dirname, '/node_modules/telios-client-backend/index.js')

let cwd = path.join(__dirname, '..');

if (!fs.existsSync(path.join(cwd, 'app.asar'))) {
  cwd = null;
}

const child = fork(filePath, [userDataPath, 'development'], {
  stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
  cwd
})

// listen for channel events
child.on('message', m => {
  const { event, data, error } = m

  if(error) this.emit(event, error)
  
  this.emit(event, data)
})

child.stderr.on('error', data => {
  this.emit('error', data.toString())
})

// Send channel events
child.send({ 
  event: 'account:create', 
  payload: {
    email: 'alice@telios.io',
    password: 'letmein123',
    vcode: 'btester1',
    recoveryEmail: 'alice@mail.com'
  }
})

Mobile example:

const bridge = require('rn-bridge')
const { ClientBackend } = require('telios-client-backend')
const { ClientBackend } = require('@telios/telios-client-backend');

const channel = bridge.channel

const userDataPath = bridge.app.datadir()
const env = 'development'

// Instantiate backend
ClientBackend(channel, userDataPath, env)

channel.send({ 
  event: 'account:create', 
  payload: {
    email: 'alice@telios.io',
    password: 'letmein123',
    vcode: 'btester1',
    recoveryEmail: 'alice@mail.com'
  }
})

channel.on('account:create:error', error => {
  // handle error
})

channel.on('account:create:success', data => {
  // handle success
})

Drive API

channel.on('drive:network:updated', data => {})

Account API

channel.send({ event: 'account:create', payload })

const payload = {
  email: 'alice@telios.io',
  password: 'letmein123',
  vcode: 'testcode123',
  recoveryEmail: 'alice@mail.com'
}

channel.send({ event: 'account:login', payload })

const payload = {
  email: 'alice@telios.io',
  password: 'letmein123'
}

channel.send({ event: 'account:logout' })

Mailbox API

channel.send({ event: 'mailbox:register', payload })

const payload = {
    account_key,
    addr: 'alice@telios.io'
  }

channel.send({ event: 'mailbox:getNewMailMeta' })

channel.send({ event: 'mailbox:markArrayAsSynced', payload })

const payload = {
  msgArray: ['emailId1', 'emailId2']
}

channel.send({ event: 'mailbox:getMailboxes' })

channel.send({ event: 'mailbox:saveMailbox', payload })

const payload = {
  address: 'bob@telios.io'
}

Email API

Contacts API

Folder API

FAQs

Package last updated on 17 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts