Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aria2

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aria2 - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

42

Aria2.js

@@ -9,3 +9,7 @@ ;(function (global) {

if (typeof module !== 'undefined' && module.exports) {
function isNode () {
return typeof module !== 'undefined' && module.exports
}
if (isNode()) {
WebSocket = require('ws')

@@ -32,3 +36,2 @@ b64 = function (str) {

Aria2.prototype.http = function (m, fn) {
// FIXME json-rpc post wouldn't work
var opts = {

@@ -38,16 +41,24 @@ 'host': this.host,

'path': this.path,
'secure': this.secure,
'query': {
'method': m.method,
'id': m.id
}
'secure': this.secure
}
if (Array.isArray(m.params) && m.params.length > 0) {
opts.query.params = b64(JSON.stringify(m.params))
var content = {
method: m.method,
id: m.id
}
// browser, use jsonp
if (!(typeof module !== 'undefined' && module.exports)) {
// use POST (default)
if (isNode() || !this.jsonp) {
opts.body = content
opts.method = 'POST'
if (Array.isArray(m.params) && m.params.length > 0) {
opts.body.params = m.params
}
// use JSONP
} else {
opts.query = content
opts.jsonp = 'jsoncallback'
if (Array.isArray(m.params) && m.params.length > 0) {
opts.query.params = b64(JSON.stringify(m.params))
}
}

@@ -57,6 +68,6 @@

httpclient.request(opts, function (err, res) {
httpclient.request(opts, function (err, res, body) {
if (err) return fn(err)
var msg = opts.jsonp ? res.body : JSON.parse(res.toString())
var msg = opts.jsonp ? body : JSON.parse(body.toString())
that._onmessage(msg)

@@ -275,3 +286,4 @@ })

'secret': '',
'path': '/jsonrpc'
'path': '/jsonrpc',
'jsonp': false
}

@@ -294,3 +306,3 @@

if (typeof module !== 'undefined' && module.exports) {
if (isNode()) {
module.exports = Aria2

@@ -297,0 +309,0 @@ } else {

@@ -26,3 +26,3 @@ #!/usr/bin/env node

.option('-u, --url [url]', 'websocket url to connect to', 'ws://localhost:6800/jsonrpc')
.option('-s --secret [secret]', 'aria2 secret to use')
.option('-s, --secret [secret]', 'aria2 secret to use')

@@ -29,0 +29,0 @@ // call

{
"name": "aria2",
"version": "1.2.1",
"version": "1.3.0",
"description": "Library and cli for aria2, \"The next generation download utility.\"",

@@ -35,3 +35,3 @@ "homepage": "https://github.com/sonnyp/aria2.js",

"commander": "^2.9.0",
"httpclient": "0.0.4",
"httpclient": "0.1.0",
"ws": "^1.0.1"

@@ -38,0 +38,0 @@ },

@@ -55,2 +55,3 @@ aria2.js

- [system.listMethods](https://aria2.github.io/manual/en/html/aria2c.html#system.listMethods)
- [system.listNotifications](https://aria2.github.io/manual/en/html/aria2c.html#system.listNotifications)
- [aria2 events](#aria2-events)

@@ -82,2 +83,4 @@ - [onDownloadStart](https://aria2.github.io/manual/en/html/aria2c.html#aria2.onDownloadStart)

```xml
<!-- optional for HTTP/JSONP support -->
<script src="node_modules/httpclient/bundle.js"></script>
<script src="node_modules/aria2/Aria2.js"></script>

@@ -111,8 +114,11 @@ ```

secret: '',
path: '/jsonrpc'
path: '/jsonrpc',
jsonp: false
}
```
Secret is optional and refers to [--rpc-secret](https://aria2.github.io/manual/en/html/aria2c.html#cmdoption--rpc-secret).
`secret` is optional and refers to [--rpc-secret](https://aria2.github.io/manual/en/html/aria2c.html#cmdoption--rpc-secret).
`jsonp: true` will make aria2.js uses [JSONP](https://en.wikipedia.org/wiki/JSONP) for non WebSocket requests, useful if you cannot make aria2c allow your origin. It has no effect on Node.js.
[↑](#aria2js)

@@ -165,3 +171,3 @@

Note that if you have passed the secret option to aria2.js, it will be automatically added it to every request so there is no need to include it.
If you have passed the secret option to aria2.js, it will be automatically added to every request so there is no need to include it.

@@ -168,0 +174,0 @@ When sending a request to aria2, if the WebSocket is closed, aria2.js will use the HTTP transport.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc