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

diffusion

Package Overview
Dependencies
Maintainers
1
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diffusion - npm Package Compare versions

Comparing version 5.5.6 to 5.6.0

src/features/client-control.js

28

package.json
{
"name": "diffusion",
"version": "5.5.6",
"version": "5.6.0",
"description": "Diffusion Javascript UCI client",

@@ -17,22 +17,22 @@ "keywords" : ["diffusion", "reappt", "websockets", "data"],

"dependencies" : {
"inherits" : "2.0",
"hashmap" : "1.1.0",
"long" : "2.1.0",
"loglevel" : "1.1.0",
"when" : "3.7.2",
"ws" : "0.6.3"
"inherits" : "2.0.1",
"hashmap" : "2.0.3",
"long" : "2.2.5",
"loglevel" : "1.4.0",
"when" : "3.7.3",
"ws" : "0.8.0"
},
"devDependencies" : {
"gulp" : "3.6.2",
"sinon" : "1.10.3",
"mkdirp" : "0.5.0",
"gulp" : "3.9.0",
"sinon" : "1.16.1",
"mkdirp" : "0.5.1",
"horaa" : "0.1.2-alpha",
"saywhen" : "1.0.0",
"gulp-jscs" : "3.0.0",
"saywhen" : "1.1.0",
"gulp-jscs" : "1.4.0",
"browserify" : "4.1.5",
"buffer-equal" : "0.0.1",
"gulp-beautify" : "1.1.0",
"vinyl-source-stream" : "0.1.1"
"gulp-beautify" : "1.1.2",
"vinyl-source-stream" : "1.1.0"
}
}

@@ -54,2 +54,3 @@ ## Diffusion JavaScript API

#### Subscriptions

@@ -56,0 +57,0 @@

@@ -7,3 +7,3 @@ var interface = require('util/interface').interface;

* <P>
* RecordContent is produced by {@link Metadata.RecordContent#parse}. It should not be constructed manually.
* RecordContent is produced by {@link Metadata.RecordContent#parse}. It should not be constructed manually.
*

@@ -108,3 +108,3 @@ * @example

* @example
* // Get values directly from the record
* // Get values directly from the record
* var foo = record.get('foo');

@@ -124,3 +124,3 @@ * var bar = record.get('bar');

* Get the value for a given field name. An optional index may be provided if the metadata allows for multiple
* values under this field.
* values under this field.
* <P>

@@ -193,8 +193,8 @@ * If the value doesn't exist, this will return <code>undefined</code>.

* var builder = metadata.builder();
*
*
* // Add a record with a single field value
* builder.add('foo', {
* bar : "hello world"
* builder.add('foo', {
* bar : "hello world"
* });
*
*
* // Create a content instance

@@ -211,4 +211,4 @@ * var content = builder.build();

* <br />
* If the metadata this builder was created for does not support the record name or field values provided, an
* exception will be thrown.
* If the metadata this builder was created for does not support the record name or field values provided, an
* exception will be thrown.
* <P>

@@ -238,3 +238,3 @@ * If the metadata for this record specifies a maximum {@link Metadata.RecordContent.Occurs} value, then an error

* @returns {RecordContent.Builder.Record} A record builder
* @throws An Error if the supplied arguments are invalid for this builder
* @throws An Error if the supplied arguments are invalid for this builder
* @function RecordContent.Builder#add

@@ -260,4 +260,4 @@ */

* // Set a specific field for the first record.
* builder.set('bar', {
* a : "world"
* builder.set('bar', {
* a : "world"
* }, 0);

@@ -268,3 +268,3 @@ *

* @param {Number} [index=0] - The record index to set values for
* @returns {RecordContent.Builder.Record} A record builder
* @returns {RecordContent.Builder.Record} A record builder
* @throws An Error if the supplied arguments are unsupported by the associated metadata

@@ -282,3 +282,28 @@ * @function RecordContent.Builder#set

*/
'build'
'build',
/**
* Convenience function for adding records and building {@link RecordContent} in a single call.
* <p>
* See {@link RecordContent.Builder#add} and {@link RecordContent.Builder#build}.
* <p>
*
* @example
* builder.addAndBuild('foo', { 'bar' : 'wibble', 'baz' : 'wobble' });
*
* @param {String} name - The name to add a record for
* @param {Object} [fields] - Optional set of named fields
* @returns {RecordContent} the content
* @throws An Error if the supplied arguments are invalid for this builder
* @function RecordContent.Builder#addAndBuild
*/
'addAndBuild',
/**
* Convenience function for setting records and building {@link RecordContent} in a single call.
* <p>
* See {@link RecordContent.Builder#set} and {@link RecordContent.Builder#build}.
*/
'setAndBuild'
]);

@@ -285,0 +310,0 @@

@@ -5,2 +5,3 @@ var SessionImpl = require('session/session-impl');

var ErrorReport = require('services/error-report');
var ClientControl = require('services/control/client-control-options');

@@ -13,2 +14,4 @@ var Emitter = require('events/emitter');

var logger = log.create('Diffusion');
/**

@@ -26,5 +29,5 @@ * The top-level Diffusion API.

*/
version : '5.5.6',
version : '5.6.0',
build : '6_dev#internal',
build : '0_dev#internal',

@@ -81,2 +84,4 @@ /**

function onClose(reason) {
logger.debug('Session closed', reason);
session.off({

@@ -91,2 +96,4 @@ connect : onConnect,

function onConnect(session) {
logger.info('Session connected', session.toString());
session.off({

@@ -123,5 +130,10 @@ connect : onConnect,

*/
errorReport : ErrorReport
errorReport : ErrorReport,
/**
* Access {@link ClientControl}.
*/
clients : ClientControl
};
module.exports = diffusion;
var interface = require('util/interface').interface;
/**

@@ -4,0 +3,0 @@ * Messages Feature.

@@ -151,3 +151,3 @@ var interface = require('util/interface').interface;

* var metadata = new diffusion.metadata.RecordContent();
* var record = metata.addRecord('name');
* var record = metadata.addRecord('name');
*

@@ -308,7 +308,7 @@ * @example

* // Add a field with a default value
* var mfield = mrecord.addField('field', 123);
* var fieldMeta = recordMeta.addField('field', 123);
*
* @example
* // Add a field with specified type that repeats three times
* var mfield = mrecord.addField('field', new diffusion.metadata.Integer(0), 3);
* var fieldMeta = recordMeta.addField('field', new diffusion.metadata.Integer(0), 3);
*

@@ -332,7 +332,7 @@ * @function Metadata.RecordContent.Record#addField

* // Get the field named 'foo'
* var mfield = mrecord.getField('foo');
* var fieldMeta = recordMeta.getField('foo');
*
* @example
* // Get the first field that was added
* var mfield = mrecord.getField(0);
* var fieldMeta = recordMeta.getField(0);
*

@@ -339,0 +339,0 @@ * @function Metadata.RecordContent.Record#getField

@@ -18,2 +18,4 @@ var topicSelectorParser = require('topics/topic-selector-parser');

var logger = require('util/logger').create('Session.Messages');
// Used because of the serialised form of SessionSendRequest requires a CID

@@ -91,2 +93,4 @@ var dummyCID = ConversationId.fromString("0");

if (internal.checkConnected(emitter)) {
logger.debug('Adding message handler', path);
var params = {

@@ -101,5 +105,9 @@ definition : Services.SEND_RECEIVER_CLIENT,

active : function(close) {
logger.debug('Message handler active', path);
handler.onActive(close);
},
respond : function(response) {
logger.debug('Message handler response', path);
var message = {

@@ -119,2 +127,4 @@ session : response.sender.toString(),

close : function() {
logger.debug('Message handler closed', path);
handler.onClose();

@@ -159,4 +169,6 @@ }

if (err) {
logger.debug('Message send failed', path);
emitter.error(err);
} else {
logger.debug('Message send complete', path);
emitter.emit('complete', {

@@ -194,6 +206,7 @@ path : path,

var request;
if (recipient) {
var request;
var session = parseSessionId(recipient);
if (session) {

@@ -208,2 +221,3 @@ request = {

logger.debug('Sending message to session', request);
sessionSender.send(request, sendCallback);

@@ -218,18 +232,15 @@ } else { // Try recipient as a client filter.

};
logger.debug('Sending message to filter', request);
filterSender.send(request, sendCallback);
}
} else {
sender.send({
request = {
path : path,
content : message,
content : message,
options : options
}, function(err, result) {
if (err) {
emitter.error(err);
} else {
emitter.emit('complete', {
path : path
});
}
});
};
logger.debug('Sending message to server', request);
sender.send(request, sendCallback);
}

@@ -236,0 +247,0 @@ }

@@ -21,3 +21,3 @@ var CHANGE_PRINCIPAL = require('services/services').CHANGE_PRINCIPAL;

var requireNonNull = require('util/require-non-null');
var log = require('util/logger').create('Security');
var log = require('util/logger').create('Session.Security');

@@ -105,2 +105,4 @@ var GlobalPermission = {

if (internal.checkConnected(emitter)) {
log.debug('Changing principal', principal);
changePrincipal.send({

@@ -131,2 +133,4 @@ principal : principal,

if (internal.checkConnected(emitter)) {
log.debug('Getting security configuration');
getConfiguration.send(null, function(err, response) {

@@ -149,2 +153,4 @@ if (err) {

if (internal.checkConnected(emitter)) {
log.debug('Getting system authentication');
getSystemAuthentication.send(null, function(err, response) {

@@ -190,2 +196,3 @@ if (err) {

this.updateSecurityStore = function(script) {
log.debug('Updating security store');
return updateStore(updateSecurityConfiguration, script);

@@ -195,2 +202,3 @@ };

this.updateAuthenticationStore = function(script) {
log.debug('Updating authentication store');
return updateStore(updateSystemAuthentication, script);

@@ -197,0 +205,0 @@ };

@@ -18,2 +18,4 @@ var implements = require('util/interface').implements;

var logger = require('util/logger').create('Session.Topics');
module.exports = implements(api.TopicControl, function TopicControlImpl(internal) {

@@ -56,2 +58,4 @@ var serviceLocator = internal.getServiceLocator();

if (internal.checkConnected(emitter)) {
logger.debug('Adding topic', path);
ADD_SERVICE.send({

@@ -66,2 +70,3 @@ path : path, details : meta, content : content

case 1:
logger.debug("Topic add complete", path);
emitter.emit('complete', {

@@ -76,2 +81,4 @@ topic : path,

if (result.reason === AddResult.EXISTS) {
logger.debug("Topic add complete (already exists)", path);
emitter.emit('complete', {

@@ -82,2 +89,3 @@ topic : path,

} else {
logger.debug("Topic add failed", path);
emitter.error(result.reason);

@@ -103,2 +111,4 @@ }

if (internal.checkConnected(emitter)) {
logger.debug('Removing topic', path);
REMOVE_SERVICE.send({

@@ -108,4 +118,8 @@ topic_name : path

if (error) {
logger.debug('Topic removal failed', path);
emitter.error(error);
} else {
logger.debug('Topic removal complete', path);
emitter.emit('complete');

@@ -124,2 +138,4 @@ }

if (internal.checkConnected(emitter)) {
logger.debug('Registering removeWithSession', path);
var params = new WillParams(path, WillParams.Will.REMOVE_TOPICS);

@@ -129,4 +145,7 @@

if (err) {
logger.debug('removeWithSession registration failed', path);
emitter.error(err);
} else if (result === WillResult.SUCCESS) {
logger.debug('removeWithSession registration complete', path);
var registered = true;

@@ -139,2 +158,4 @@

if (registered && internal.checkConnected(dEmitter)) {
logger.debug('Deregistering removeWithSession', path);
TOPIC_WILL_DEREGISTRATION.send(params, function(err, result) {

@@ -159,2 +180,3 @@ if (err) {

} else {
logger.debug('removeWithSession registration failed', path);
emitter.error(new Error('REGISTRATION_CONFLICT'));

@@ -173,2 +195,4 @@ }

if (internal.checkConnected(emitter)) {
logger.debug('Updating topic', path);
UPDATE_SERVICE.send({

@@ -179,6 +203,12 @@ topic_path : path,

if (error) {
logger.debug('Update failed', path);
emitter.error(error);
} else if (result.isError) {
logger.debug('Update failed', path);
emitter.error(result.reason);
} else {
logger.debug('Update complete', path);
emitter.emit('complete', path);

@@ -185,0 +215,0 @@ }

@@ -18,2 +18,3 @@ var HashMap = require('hashmap').HashMap;

var arrays = require('util/array');
var logger = require('util/logger').create('Session');

@@ -47,2 +48,4 @@ module.exports = implements(Topics, function TopicsImpl(internal, session) {

this.subscribe = function(topic, callback) {
logger.debug('Subscribing', topic);
var selector = topicSelectorParser(topic);

@@ -75,2 +78,4 @@

this.unsubscribe = function(topic) {
logger.debug('Unubscribing', topic);
unsubscribe.send(topicSelectorParser(topic));

@@ -77,0 +82,0 @@ };

@@ -117,2 +117,5 @@ var Emitter = require('events/emitter');

if (fsm.change('connecting')) {
// Timeout applied for reconnect attempts from initial disconnect
var reconnectTimeout;
// Construct a creation request

@@ -139,2 +142,8 @@ var request = ConnectionRequest.connect();

emitter.emit('disconnect', reason);
reconnectTimeout = setTimeout(function() {
if (fsm.state !== 'connected') {
abort(CloseReason.CONNECTION_TIMEOUT);
}
}, opts.reconnect.timeout);
}

@@ -160,5 +169,6 @@

log.info('Connected, session id: ', response.identity.toString());
emitter.emit('connect', response.identity);
} else if (response.response === ResponseCode.RECONNECTED) {
clearTimeout(reconnectTimeout);
log.info('Reconnected session');

@@ -168,8 +178,8 @@ emitter.emit('reconnect');

} else {
log.debug('Unknown connection response: ', response);
log.trace('Unknown connection response: ', response);
}
});
log.info('Connecting with options:', opts);
log.debug('Connecting with request:', request);
log.debug('Connecting with options:', opts);
log.trace('Connecting with request:', request);

@@ -176,0 +186,0 @@ try {

@@ -35,3 +35,3 @@ var CommandHeader = require('services/command-header');

log.debug('Sending command request: ' + header, command);
log.trace('Sending command request: ' + header, command);

@@ -45,3 +45,3 @@ sender(msg);

if (listener) {
log.debug('Received command request for service: ' + header);
log.trace('Received command request for service: ' + header);

@@ -58,3 +58,3 @@ listener(header, input);

function handleResponse(header, input) {
log.debug('Received command response: ' + header);
log.trace('Received command response: ' + header);
conversations.respond(header.cid, input);

@@ -61,0 +61,0 @@ }

@@ -14,3 +14,3 @@ var HashMap = require('hashmap').HashMap;

* @param {ServiceDefinition} definition - The service definition.
* @returns {Service|null} The service, if one exists, otherwise null.
* @returns {Service|null} The service, if one exists, otherwise undefined.
*/

@@ -17,0 +17,0 @@ this.get = function(definition) {

@@ -55,3 +55,3 @@ var implements = require('util/interface').implements;

index = index || 0;
if (fields[name][index] !== undefined) {

@@ -132,3 +132,3 @@ fields[name][index] = value;

insertFields(record, record.set, fields);
return record;

@@ -165,4 +165,15 @@ } else {

};
this.addAndBuild = function(name, value) {
this.add(name, value);
return this.build();
};
this.setAndBuild = function(name, fields, index) {
this.set(name, fields, index);
return this.build();
};
});
module.exports = RecordBuilder;

@@ -101,2 +101,10 @@ var Services = require('services/services');

module.exports.registerSessionPropertiesListener =
function registerSessionPropertiesListener(internal, params, adapter) {
var listener = registerHandler(internal, params, adapter,
Services.SET_SESSION_PROPERTIES_LISTENER,
Services.SET_SESSION_PROPERTIES_LISTENER); // TODO: Deregister?
return listener;
};
module.exports.ResponseHandlerState = ResponseHandlerState;

@@ -5,3 +5,3 @@ module.exports = {

PROTOCOL_BYTE : 35,
PROTOCOL_VERSION : 5
};
PROTOCOL_VERSION : 6
};

@@ -139,3 +139,14 @@ var HashMap = require('hashmap').HashMap;

);
serialisers.set(
require('services/control/get-session-properties'),
require('services/control/get-session-properties-serialiser')
);
serialisers.set(
require('services/control/set-session-properties-listener'),
require('services/control/set-session-properties-listener-serialiser')
);
serialisers.set(
require('services/control/session-properties-event'),
require('services/control/session-properties-event-serialiser')
);
module.exports = serialisers;

@@ -41,2 +41,6 @@ var TopicSelector = require('../../topics/topic-selector');

var GetSessionProperties = require('services/control/get-session-properties');
var SetSessionPropertiesListener = require('services/control/set-session-properties-listener');
var SessionPropertiesEvent = require('services/control/session-properties-event');
module.exports = {

@@ -204,3 +208,21 @@ SUBSCRIBE : {

response : FilterSendResult
},
GET_SESSION_PROPERTIES : {
id : 67,
name : "Get session properties",
request : GetSessionProperties,
response : GetSessionProperties
},
SET_SESSION_PROPERTIES_LISTENER : {
id : 69,
name : "Set session properties listener",
request : SetSessionPropertiesListener,
response : SetSessionPropertiesListener
},
SESSION_PROPERTIES_EVENT : {
id : 70,
name : "Session properties event",
request : SessionPropertiesEvent,
response : SessionPropertiesEvent
}
};

@@ -18,2 +18,6 @@ var Codec = require('io/codec');

write : function(output, request) {
if (request.topic_path === undefined ||
request.topic_path === null) {
throw new Error('Topic path is undefined or null');
}
Codec.writeString(output, request.topic_path);

@@ -20,0 +24,0 @@ UpdateSerialiser.write(output, request.update);

var split = require('util/string').split;
var cache = require('util/memoize');
var arr = require('util/array');

@@ -29,11 +30,19 @@ // API Topic Selector

}
if (arguments.length > 1) {
expression = arr.argumentsToArray(arguments);
}
if (expression instanceof Array) {
var actual = [];
expression.forEach(function(s) {
if (!(s instanceof TopicSelector)) {
throw new Error("Can only parse arrays of Topic Selectors");
}
if (s instanceof TopicSelector) {
actual.push(s);
} else {
actual.push(parse(s));
}
});
return new SelectorSet(expression);
return new SelectorSet(actual);
}

@@ -40,0 +49,0 @@

@@ -33,2 +33,3 @@ var encodeAsString = require('v4-stack/credential-tunnel').encodeAsString;

uri += '&ca=' + req.capabilities;
uri += '&r=' + opts.reconnect.timeout;

@@ -35,0 +36,0 @@ if (req.token) {

@@ -89,3 +89,3 @@ var connectionResponseDeserialiser = require('protocol/connection-response-deserialiser');

logger.debug('Received connection handshake response');
logger.trace('Received connection handshake response');

@@ -97,3 +97,3 @@ var response;

} catch (e) {
logger.debug('Unable to deserialise handshake response', e);
logger.trace('Unable to deserialise handshake response', e);

@@ -106,3 +106,3 @@ closeReason = CloseReason.HANDSHAKE_ERROR;

logger.debug('Connection response: ', response.response);
logger.trace('Connection response: ', response.response);

@@ -109,0 +109,0 @@ if (response.success && fsm.change('connected')) {

@@ -1,2 +0,1 @@

// Namespaced features

@@ -6,2 +5,3 @@ var Messages = require('api/features/messages');

var TopicControl = require('api/features/topic-control');
var ClientControl = require('api/features/client-control');

@@ -21,3 +21,3 @@ // Features to implement

* <P>
* When a connected session loses its connection to the server, it will close if {@link Session.Options}
* When a connected session loses its connection to the server, it will close if {@link Session.Options}
* <code>reconnect</code> is not enabled. If reconnect is enabled then the session will enter a

@@ -28,10 +28,10 @@ * <code>disconnected</code> state. Once disconnected, any API methods that involve the server will automatically fail.

* The session will attempt to reconnect to the server on a regular basis. This will continue until the server responds;
* at which point the session will attempt to recover its previous connection.
* at which point the session will attempt to recover its previous connection.
* <P>
* If the reconnection is succesful the session will become connected again and emit a <code>reconnect</code> event.
* If the reconnection is succesful the session will become connected again and emit a <code>reconnect</code> event.
* Any prior subscriptions will continue to receive data.
* <P>
* If the server rejects the reconnection, the session will be closed.
* If the server rejects the reconnection, the session will be closed.
* <P>
* Sessions emit events to notify listeners of changes in state. Certain events will provide arguments to any callback
* Sessions emit events to notify listeners of changes in state. Certain events will provide arguments to any callback
* functions that have been registered.

@@ -84,3 +84,3 @@ * <h5>Events:</h5>

* reconnect : function() {
* console.log(('Phew, reconnected!');
* console.log('Phew, reconnected!');
* },

@@ -126,3 +126,3 @@ * error : function(error) {

});
/**

@@ -166,2 +166,8 @@ * Close this session's connection to the server.

/**
* Exposes client control capabilities via {@link Session.clients}.
* @property Session.clients
*/
this.clients = new ClientControl(internalSession, this);
this.toString = function() {

@@ -168,0 +174,0 @@ return "Session<" + self.sessionID + " " + internalSession.getState() + ">";

@@ -83,3 +83,3 @@ var parser = require('topics/topic-selector-parser');

* Selector sets are the preferred way to combine expressions.
* <code>anyOf("a", "b")</code> is equivalent to the full-path expression "
* <code>parse("a", "b")</code> is equivalent to the full-path expression "
* <code>*[a|b]</code>", but can be evaluated more efficiently by the

@@ -339,4 +339,13 @@ * server.

*
* @param {String|Array} expression - The pattern expression.
* @return {TopicSelector} The topic selector. If an array is provided,
* @example
* // Simple selector
* var selector = diffusion.selectors.parse(">a/b");
*
*
* @example
* // Creating a selector set
* var selectorSet = diffusion.selectors.parse(">a", ">b");
*
* @param {...String} expression - The pattern expression(s).
* @return {TopicSelector} The topic selector. If multiple expressions are provided,
* this will return a <code>SELECTOR_SET</code> that will match if any of the

@@ -343,0 +352,0 @@ * provided <code>selectors</code> match.

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