megajs
Unofficial JavaScript SDK for MEGA
Last updated 2 months ago by qgustavor .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install megajs 
SYNC missed versions from official npm registry.

MEGAJS

Unofficial JavaScript SDK for MEGA

Installation

npm install megajs
const mega = require('megajs') // or
import mega from 'megajs'

You can also load it in a browser using <script src="https://unpkg.com/megajs/dist/main.node-cjs.js"></script>, which exports the library in the mega global variable. You can also use import * as mega from 'https://unpkg.com/megajs/dist/main.browser-es.js'.

For more details, API documentation and examples check wiki: https://github.com/qgustavor/mega/wiki

The bundled files are available via npm and UNPKG.

For CLI usage check MEGAJS CLI: https://github.com/qgustavor/megajs-cli

Implementation notes

Only part of the file related API is implemented. For now implementing contact and chat functions seems out of scope.

Cryptography is mostly ported from browser code. In Node some parts are optimized: AES operations are done using native crypto. Sadly WebCrypto don't support streaming so in browser the old pure JavaScript implementation is used. The RSA operations aren't optimized as currently there isn't any need to improve that.

This module works in the browser: the "main.browser-umd.js" is a build using the UMD format where Node specific modules, like crypto and request modules, were replaced with browser equivalents. If you want to use tree shaking then use the "main.browser-es.js" bundle. This module wasn't tested in other environments.

Fork objectives

This package started as a fork, with the following objectives:

  • Make the original package work in browsers again: even following the instructions from the original library it stopped working because some dependencies used __proto__, which is non-standard and isn't supported in many browsers. Also the updated versions of those libraries broke backyards compatibility;
  • Reduce dependencies and replace big dependencies with smaller ones, like crypto libraries, which usually are huge;
  • Rewrite code using the new JavaScript syntax, allowing to use Rollup, which can generate smaller bundles;
  • Make tests work again after the changes above;
  • Continue the original library development implementing new features and improving performance.

Request package was replaced with a shim based in browser-request and xhr-stream, which additional changes in order to make it work inside Service Workers. Crypto was replaced with secure-random.

As there were many changes there isn't any plan to merge those changes into the original library, unless the original author accept those massive changes. That's why I put "js" in the name, which is silly because both libraries use JavaScript. At least it's better than other ideas I had, like "mega2", "mega-es" and "modern-mega".

Contributing

When contributing fork the project, clone it, run npm install, change the library as you want, run tests using npm run test and build the bundled versions using npm run build. Before creating a pull request, please, run tests.

Current Tags

  • 0.17.0                                ...           latest (2 months ago)

49 Versions

  • 0.17.0                                ...           2 months ago
  • 0.16.2                                ...           2 months ago
  • 0.16.1                                ...           7 months ago
  • 0.16.0                                ...           a year ago
  • 0.15.7                                ...           2 years ago
  • 0.15.6                                ...           2 years ago
  • 0.15.5                                ...           2 years ago
  • 0.15.4                                ...           2 years ago
  • 0.15.3                                ...           2 years ago
  • 0.15.2                                ...           2 years ago
  • 0.15.1                                ...           2 years ago
  • 0.15.0                                ...           2 years ago
  • 0.14.1                                ...           2 years ago
  • 0.14.0                                ...           2 years ago
  • 0.13.3                                ...           2 years ago
  • 0.13.2                                ...           2 years ago
  • 0.13.1                                ...           3 years ago
  • 0.13.0                                ...           3 years ago
  • 0.12.8                                ...           3 years ago
  • 0.12.7                                ...           3 years ago
  • 0.12.6                                ...           3 years ago
  • 0.12.5                                ...           3 years ago
  • 0.12.4                                ...           3 years ago
  • 0.12.3                                ...           3 years ago
  • 0.12.2                                ...           3 years ago
  • 0.12.1                                ...           3 years ago
  • 0.12.0                                ...           3 years ago
  • 0.11.5                                ...           3 years ago
  • 0.11.4                                ...           3 years ago
  • 0.11.3                                ...           3 years ago
  • 0.11.2                                ...           3 years ago
  • 0.11.1                                ...           3 years ago
  • 0.11.0                                ...           3 years ago
  • 0.10.7                                ...           3 years ago
  • 0.10.6                                ...           3 years ago
  • 0.10.5                                ...           3 years ago
  • 0.10.4                                ...           3 years ago
  • 0.10.3                                ...           3 years ago
  • 0.10.2                                ...           3 years ago
  • 0.10.1                                ...           3 years ago
  • 0.10.0                                ...           3 years ago
  • 0.9.1                                ...           3 years ago
  • 0.9.0                                ...           3 years ago
  • 0.8.5                                ...           3 years ago
  • 0.8.4                                ...           3 years ago
  • 0.8.3                                ...           3 years ago
  • 0.8.2                                ...           3 years ago
  • 0.8.1                                ...           3 years ago
  • 0.8.0                                ...           3 years ago

Copyright 2014 - 2016 © taobao.org |