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

ataraxia-local

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ataraxia-local - npm Package Compare versions

Comparing version 0.8.2 to 0.9.0

9

dist/cjs/MachineLocalTransport.js

@@ -56,3 +56,5 @@ "use strict";

var local_machine_network_1 = require("local-machine-network");
var ataraxia_1 = require("ataraxia");
var transport_1 = require("ataraxia/transport");
var AUTH = [new ataraxia_1.AnonymousAuth()];
/**

@@ -69,2 +71,5 @@ * Machine local transport. Uses Unix sockets to connect to peers on the

_this.path = (options && options.path) || os_1.tmpdir();
if (options === null || options === void 0 ? void 0 : options.onLeader) {
_this.leaderEvent.subscribe(options.onLeader);
}
return _this;

@@ -109,4 +114,4 @@ }

handlePeer = function (socket, server) {
var peer = new LocalPeer(_this.network);
peer.setSocket(socket);
var peer = new LocalPeer(_this.network, AUTH);
peer.setStream(socket);
if (server) {

@@ -113,0 +118,0 @@ peer.negotiateAsServer();

@@ -12,2 +12,7 @@ import { Subscribable } from 'atvik';

path?: string;
/**
* Optional function that will be run if this instance becomes the leader
* of the local network.
*/
onLeader?: () => void;
}

@@ -14,0 +19,0 @@ /**

{
"name": "ataraxia-local",
"version": "0.8.2",
"version": "0.9.0",
"description": "Machine-local transport for Ataraxia P2P messaging",

@@ -18,5 +18,5 @@ "license": "MIT",

"dependencies": {
"ataraxia": "^0.8.2",
"ataraxia": "^0.9.0",
"atvik": "^1.0.0",
"debug": "^4.1.1",
"debug": "^4.3.1",
"local-machine-network": "^0.3.0"

@@ -26,10 +26,10 @@ },

"@types/debug": "^4.1.5",
"@types/jest": "^25.2.1",
"@types/jest": "^26.0.23",
"@types/msgpack-lite": "^0.1.7",
"@types/node": "^13.11.1",
"jest": "^25.3.0",
"ts-jest": "^25.3.1",
"typescript": "^3.8.3"
"@types/node": "^15.6.1",
"jest": "^27.0.3",
"ts-jest": "^27.0.1",
"typescript": "^4.3.2"
},
"gitHead": "f8cfc619854b1195a271831a8b0e83476244d4e6"
"gitHead": "05cd2a79c8b45c1695eeb9a189c005f66e920266"
}

@@ -22,15 +22,12 @@ # ataraxia-local

// Setup a network with anonymous authentication
// Setup a network
const net = new Network({
name: 'name-of-your-app-or-network',
authentication: [
new AnonymousAuth()
transports: [
new MachineLocalTransport()
]
});
net.addTransport(new MachineLocalTransport());
net.start()
.then(...)
.catch(...);
await net.start();
```

@@ -46,24 +43,42 @@

// Setup a network with anonymous authentication
// Setup a network
const net = new Network({
name: 'name-of-your-app-or-network',
authentication: [
new AnonymousAuth()
]
});
const local = new MachineLocalTransport();
local.onLeader(() => {
/*
* The leader event is emitted when this instance becomes the leader
* of the machine-local network. This instance will now handle
* connections to other machines in the network.
*/
net.addTransport(new TCPTransport());
});
net.addTransport(local);
net.addTransport(new MachineLocalTransport([
onLeader: () => {
/*
* The leader event is emitted when this instance becomes the leader
* of the machine-local network. This instance will now handle
* connections to other machines in the network.
*/
net.addTransport(new TCPTransport({
discovery: new TCPPeerMDNSDiscovery(),
net.start()
.then(...)
.catch(...);
authentication: [
new AnonymousAuth()
]
}));
}
]);
await net.start();
```
## API
* `new MachineLocalTransport(options)`
Create a new instance of the transport.
* `options`
* `path?: string`, path of the local socket. If not specified the transport
defaults to creating a socket in the temporary directory of the system
using the name of the network.
* `onLeader?: () => void`, function that will be run if this instance
becomes the leader of the local network.
* `onLeader(callback: () => void)`
Event emitted if this transport becomes the leader of the local network.

@@ -7,5 +7,8 @@ import { join } from 'path';

import { AnonymousAuth } from 'ataraxia';
import { AbstractTransport, StreamingPeer, TransportOptions, DisconnectReason } from 'ataraxia/transport';
import { Socket } from 'net';
const AUTH = [ new AnonymousAuth() ];
/**

@@ -20,2 +23,8 @@ * Options available for MachineLocalTransport.

path?: string;
/**
* Optional function that will be run if this instance becomes the leader
* of the local network.
*/
onLeader?: () => void;
}

@@ -41,2 +50,6 @@

this.path = (options && options.path) || tmpdir();
if(options?.onLeader) {
this.leaderEvent.subscribe(options.onLeader);
}
}

@@ -72,4 +85,4 @@

const handlePeer = (socket: Socket, server: boolean) => {
const peer = new LocalPeer(this.network);
peer.setSocket(socket);
const peer = new LocalPeer(this.network, AUTH);
peer.setStream(socket);
if(server) {

@@ -76,0 +89,0 @@ peer.negotiateAsServer();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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