New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

antena

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antena - npm Package Compare versions

Comparing version 1.2.1 to 2.0.0

browser/attach.js

7

package.json
{
"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": [

# 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`
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