0.3.6 ā€¢ Published 3 years ago

sync-files-cipher v0.3.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

One-way encrypted client-server file synchronization (mirroring) package in nodejs over sockets (SFC)

šŸ  Homepage

Install

npm install sync-files-cipher

How to use server

const { createServer } = require('sync-files-cipher')
createServer(
    '8BZ3pCTp71LX5I//QsBYdz7w4JHXNVehSBXuXnScdqg=',
    'AAAAAAAAAAAAAAAAAAAAAA==',
    () => { console.log("Server listening");}
)

CreateServer function

Create a socket server and start listen connections, return a nodejs net.Server instance

createServer(aesKey, iv, onLIstenCallback, port )
ArgumentTypeDescription
aesKeyStringThe key is the raw key used by the algorithm. Must be utf8 encoded string, see nodejs crypto for more details.
ivStringIs an initialization vector. Must be utf8 encoded string, see nodejs crypto for more details.
onLIstenCallbackFunctionThe callback when server is listening.
portNumberThe port, default 9000.

How to use client

const { sync } = require('sync-files-cipher')
    // start to sync files or directory
    const watcher = await sync(
        '/clientpath',
        function (eventType, pathChanged) {
          console.log(eventType, pathChanged);
        },
        function (error) {
          console.log(error);
        },
        '/prefix'
    );

    // stop sync
    watcher.close()
    .then(() => console.log("Watcher closed"))

Sync function

Sync the file client with backup files when there are changes, return a nodejs FSWatcher instance

  sync (pathToWatch, userWatchCallback, userErrorCallback, pathPrefix, port, host
)
ArgumentTypeDescription
pathToWatchStringThe path to watch.
userWatchCallbackFunctionThe callback to call when sync is executed and passes the enent type and the path changed.
userErrorCallbackFunctionThe callback to call when sync is crashed.
pathPrefixStringThe prefix path for use in server for sync upfiles, default empty.
portNumberThe server port, default 9000
hostStringThe prefix path, default empty

Event types

TypeDescription
ADD_DIRRuns when a directory is added.
SYNCIt runs when they add a new file or file change.
REMOVE_DIRRuns when a directory is deleted.
REMOVE_FILERuns when a file is deleted.

Close function

Stop watching.

watcherInstance.close()
    .then(() => 
    console.log("Watcher closed"))

Authors

šŸ‘¤ Juan Francisco Javier Perez Rivero, Deiver Guerra Carrascal

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2021 Juan Francisco Javier Perez Rivero, Deiver Guerra Carrascal. This project is MIT licensed.


This README was generated with ā¤ļø by readme-md-generator

0.3.6

3 years ago

0.3.5

3 years ago

0.3.2

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago