Comparing version 1.2.1 to 2.0.0
{ | ||
"name": "antena", | ||
"description": "Isomorph http client", | ||
"version": "1.2.1", | ||
"description": "Isomorphic communication library", | ||
"version": "2.0.0", | ||
"author": { | ||
@@ -12,3 +12,4 @@ "name": "Laurent Christophe", | ||
"dependencies": { | ||
"ws": "^5.2.0" | ||
"posix-socket": "0.0.6", | ||
"ws": "^6.0.0" | ||
}, | ||
@@ -15,0 +16,0 @@ "keywords": [ |
118
README.md
# Antena | ||
Isomorph http client. | ||
Antena is yet an other communication library. | ||
## `antena = require("antena/node")(host, secure)` | ||
## Receptor | ||
* `host :: string | number` | ||
Example of valid host: | ||
* `"localhost:8080"` | ||
* `"localhost"` | ||
Use default http ports (443 if secure is truthy else 80). | ||
* `"8080` | ||
Same as `"localhost:8080"` | ||
* `8080` | ||
Same as `"localhost:8080"` | ||
* `/tmp/unix-domain-socket.sock` | ||
Unix domain sockets can only be used if secure is falsy. | ||
* `\\\\?\\pipe\window-pipe` | ||
Windows pipes can only be used if secure is falsy. | ||
* `secure :: boolean` | ||
### receptor = require("antena/receptor")() | ||
## `antena = require("antena/browser")(host, secure)` | ||
Create a new receptor. | ||
* `receptor :: antena.Receptor` | ||
* `host :: string | undefined` | ||
* `"localhost:8080"` | ||
* `"localhost"` | ||
Use default http ports (443 if secure is truthy else 80). | ||
* `undefined` | ||
Same as providing the page's host (`window.location.host`). | ||
* `secure :: boolean` | ||
Note that is the page is served accross `https`, this parameter will be overwritten to `true`; | ||
### receptor.attach(server, splitter) | ||
## `antena.request(method, path, headers, body, callback)` | ||
Attach a server to a receptor to handle communication with remote emitters. | ||
* `method :: string` | ||
* `path :: string` | ||
* `headers :: object` | ||
* `body :: string` | ||
* `callback(error, [status, message, headers, body])` | ||
* `error :: Error` | ||
* `status :: number` | ||
* `message :: string` | ||
* `headers :: object` | ||
* `body :: string` | ||
* `receptor :: antena.Receptor` | ||
* `server :: net.Server | http.Server | https.Server`: | ||
* `net.Server`: | ||
Handle connection from node emitters by listening to the `connection` event. | ||
* `http.Server | https.Server`: | ||
Handle connection from browser emitters by overwriting the `request` and `upgrade` listeners. | ||
Events whose url starts with the `splitter` parameter will be handled by Antena. | ||
Other events will be dispatched to *existing* event handlers. | ||
* `splitter :: string`, default `"__antena__"`: | ||
If `server` is a http(s) server, this string will be used to separate Antena traffic from regular traffic. | ||
## `[status, message, headers2, body2] = antena.request(method, path, headers1, body1)` | ||
### receptor.onrequest = (session, query, callback) => { ... } | ||
* `method :: string` | ||
* `path :: string` | ||
* `hearders1 :: object` | ||
* `body1 :: string` | ||
* `status :: number` | ||
Handler for `emitter.request(query)`. | ||
* `receptor :: antena.Receptor` | ||
* `session :: string` | ||
* `request :: string` | ||
* `callback :: function` | ||
* `result :: String` | ||
### receptor.onmessage = (session, message) => { ... } | ||
Handler for `emitter.send(message)`. | ||
* `receptor :: antena.Receptor` | ||
* `session :: string` | ||
* `message :: string` | ||
* `headers2 :: object` | ||
* `body2 :: string` | ||
## `websocket = antena.WebSocket(path)` | ||
## Emitter | ||
* `path :: string` | ||
* `websocket :: browser.WebSocket || ws.WebSocket` | ||
Browser style listeners: `onopen`, `onmessage`, `onerror` and `onclose` are isomorphic. | ||
### emitter = require("antena/emitter")(address, session) | ||
## `antena2 = antena1.fork(splitter)` | ||
* `address :: object | string | number | antena.Receptor`: | ||
Antena will choose between the three mode below: | ||
* Browser: if `window` is defined | ||
* `string`, splitter; eg `"__antena__"` is an alias for `{splitter:"__antena__"}` | ||
* `object`, options: | ||
* `secure :: boolean`, default: `location.protocol === "https:` | ||
* `hostname :: string`, default: `location.hostname` | ||
* `port :: number`, default: `location.port` | ||
* `splitter :: string`: default: `"__antena__"` | ||
* Node: if `window` is not defined and `address` is not an object | ||
* `number`, port number; eg `8080`: is an alias for `"[::1]:8080"` | ||
* `string` | ||
* Port string; eg `"8080"`: alias for `"[::1]:8080"` | ||
* Local socket address; eg `/tmp/antena.sock` | ||
* IPv4 and port; eg `127.0.0.1:8080` | ||
* IPv6 and port: eg `[::1]:8080` | ||
* Mock: if `window` is not defined and `address` is an object, address must be an `antena.Receptor` | ||
* `session :: string` | ||
* `splitter :: string` | ||
### result = emitter.request(query) | ||
## plaform = antena.platform | ||
* `emitter :: antena.Emitter` | ||
* `query :: string` | ||
* `result :: string` | ||
* `platform :: string` | ||
Either `"node"` or `"browser"`. | ||
### emitter.send(message) | ||
* `emitter :: antena.Emitter` | ||
* `message :: string` | ||
### emitter.onmessage = (message) => { ... } | ||
* `emitter :: antena.Emitter` | ||
* `message :: string` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
18245
11
424
83
3
2
4
+ Addedposix-socket@0.0.6
+ Addedposix-socket@0.0.6(transitive)
+ Addedws@6.2.3(transitive)
- Removedws@5.2.4(transitive)
Updatedws@^6.0.0