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.3.0 to 5.5.0

src/error-report.js

2

package.json
{
"name": "diffusion",
"version": "5.3.0",
"version": "5.5.0",
"description": "Diffusion Javascript UCI client",

@@ -5,0 +5,0 @@ "keywords" : ["diffusion", "reappt", "websockets", "data"],

var SessionImpl = require('session/session-impl');
var Metadata = require('metadata/metadata');
var TopicSelectors = require('./topics/topic-selectors');
var ErrorReport = require('services/error-report');

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

*/
version : '5.3.0',
version : '5.5.0',
build : '0_dev#internal',
build : '0_01#30948',

@@ -113,5 +114,10 @@ /**

*/
metadata : Metadata
metadata : Metadata,
/**
* Access {@link ErrorReport}.
*/
errorReport : ErrorReport
};
module.exports = diffusion;

@@ -25,10 +25,10 @@ var interface = require('util/interface').interface;

* <P>
* An optional argument of a SessionId may be provided, in order to send the message to a specific session. Messages
* sent to a specific session will be received if that session has established a {@link
* An optional argument may be provided to target a specific session or a collection of sessions that satisfy a
* given filter string. Messages sent will be received if that session has established a {@link
* Session.messages.MessageStream MessageStream} for the same message path. The ability to send messages to specific
* sessions is determined by permissions assigned to the sender.
* sessions or via a filter is determined by permissions assigned to the sender.
* <P>
* If no session id is given, the message will be sent to the server and dispatched to a control client that has
* registered a {@link Session.messages.MessageHandler MessageHandler} for the same, or higher, path. There is no
* guarantee that a MessageHandler will have been established for the path that the message is sent on.
* If no session id or filter is given, the message will be sent to the server and dispatched to a control client
* that has registered a {@link Session.messages.MessageHandler MessageHandler} for the same, or higher, path.
* There is no guarantee that a MessageHandler will have been established for the path that the message is sent on.
* <P>

@@ -44,5 +44,9 @@ *

*
* @example
* // Send a message with a filter
* session.messages.send('baz', 'world', '$Principal is "john"');
*
* @param {String} path - The message path
* @param {Object} message - The message value
* @param {String} [sessionID] - The target recipient
* @param {String} [sessionID|filter] - The target recipient's Session ID or a filter string.
* @returns {Result} The result of the send operation

@@ -121,3 +125,4 @@ * @function Session.messages#send

* @param {String} path - The message path to handle
* @param {Session.messages.MessageHandler} handler - The message handler
* @param {Session.messages.MessageHandler} handler - The message handler
* @param {Array} [keys] - Message keys to register for this session
* @returns {Result} The registration result

@@ -124,0 +129,0 @@ * @function Session.messages#addHandler

@@ -14,12 +14,2 @@ var interface = require('util/interface').interface;

/**
* An error report from the server.
*
* @typedef {Object} Session.security.ErrorReport
* @property {String} message The error message
* @property {Number} line The line at which the problem was found
* @property {Number} column The column at which the problem was found
*/
var ErrorReport = interface('ErrorReport', ['message', 'line', 'column']);
/**
* A principal in the system authentication store.

@@ -394,4 +384,4 @@ *

/**
* Send a command script to the server to update the security store. Scripts may be produced from builders, such
* as {@link SecurityScriptBuilder} or {@link SystemAuthenticationScriptBuilder}.
* Send a command script to the server to update the security store. The script may be produced by the
* builder {@link SecurityScriptBuilder}.
* <P>

@@ -405,6 +395,6 @@ * If the script is applied without error to the server, the operation result will complete successfully.

* @returns {Result} A {@link Result}
* @function Session.security#updateStore
* @function Session.security#updateSecurityStore
*
* @example
* session.security.updateStore(script).then(function() {
* session.security.updateSecurityStore(script).then(function() {
* console.log('Security configuration updated');

@@ -415,3 +405,25 @@ * }, function(err) {

*/
'updateStore',
'updateSecurityStore',
/**
* Send a command script to the server to update the authentication store. The script may be produced by the
* builder {@link SystemAuthenticationScriptBuilder}.
* <P>
* If the script is applied without error to the server, the operation result will complete successfully.
* <p>
* If any command in the script fails, none of the changes will be applied, and the result will be failed with an
* error object.
*
* @param {String} Script - The command script
* @returns {Result} A {@link Result}
* @function Session.security#updateAuthenticationStore
*
* @example
* session.security.updateAuthenticationStore(script).then(function() {
* console.log('Authentication configuration updated');
* }, function(err) {
* console.log('Failed to update security configuration', err);
* });
*/
'updateAuthenticationStore',

@@ -444,3 +456,2 @@ /**

Security.Role = Role;
Security.ErrorReport = ErrorReport;
Security.SystemPrincipal = SystemPrincipal;

@@ -447,0 +458,0 @@

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

* // Remove all topics under 'foo'
* session.topics.removeOnClose('foo').on({
* session.topics.removeWithSession('foo').on({
* complete : function(deregister) {

@@ -153,0 +153,0 @@ * // Registration complete

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

// Returns a session ID if parseable, else false.
function parseSessionId(str) {
try {
var sid = SessionId.fromString(str);
return sid;
}
catch(err) {
return false;
}
}
module.exports = implements(api, function MessagesImpl(internal) {

@@ -41,2 +52,3 @@ var conversationSet = internal.getConversationSet();

var sessionSender = serviceLocator.obtain(Services.SEND_TO_SESSION);
var filterSender = serviceLocator.obtain(Services.SEND_TO_FILTER);

@@ -57,3 +69,3 @@ var streams = [];

internal.getServiceRegistry().add(Services.SEND_TO_SESSION, {
internal.getServiceRegistry().add(Services.SEND_RECEIVER_CLIENT, {
onRequest : function(internal, message, callback) {

@@ -65,3 +77,3 @@ callback.respond();

this.addHandler = function(path, handler) {
this.addHandler = function(path, handler, keys) {
// The registration code will return it's own result - we only make our own for error propagation

@@ -83,5 +95,6 @@ var emitter = new Emitter();

var params = {
definition : Services.SEND_TO_SESSION,
definition : Services.SEND_RECEIVER_CLIENT,
group : ControlGroup.DEFAULT,
path : path
path : path,
keys : keys !== undefined ? keys : {}
};

@@ -99,5 +112,8 @@

};
// Only set properties if there are some present.
var properties = response.sessionProperties;
if (properties && Object.keys(properties).length > 0) {
message.properties = properties;
}
handler.onMessage(message);
return false;

@@ -110,3 +126,3 @@ },

return registration.registerTopicHandler(internal, params, adapter);
return registration.registerMessageHandler(internal, params, adapter);
} else {

@@ -144,2 +160,20 @@ return result;

var sendCallback = function(err, result) {
if (err) {
emitter.error(err);
} else {
emitter.emit('complete', {
path : path,
recipient : recipient
});
}
};
// Arguments are somewhat flexible for this method.
// path and message are fixed in the first two positions.
// After that, there may be:
// 1. options and recipient.
// 2. Just a recipient.
// The recipient may either be a Session ID (passed as a string),
// or a SendFilter.
if (options && typeof options === 'string') {

@@ -164,29 +198,25 @@ recipient = options;

if (recipient) {
var session;
var request;
try {
session = SessionId.fromString(recipient);
} catch (e) {
emitter.error(e);
return result;
var session = parseSessionId(recipient);
if (session) {
request = {
path : path,
content : message,
session : session,
options : options,
cid : dummyCID
};
sessionSender.send(request, sendCallback);
} else { // Try recipient as a client filter.
request = {
path : path,
content : message,
filter : recipient,
options : options,
cid : dummyCID
};
filterSender.send(request, sendCallback);
}
var request = {
path : path,
content : message,
session : session,
options : options,
cid : dummyCID
};
sessionSender.send(request, function(err, result) {
if (err) {
emitter.error(err);
} else {
emitter.emit('complete', {
path : path,
recipient : recipient
});
}
});
} else {

@@ -205,3 +235,3 @@ sender.send({

}
});
});
}

@@ -208,0 +238,0 @@ }

@@ -42,14 +42,2 @@ var CHANGE_PRINCIPAL = require('services/services').CHANGE_PRINCIPAL;

var ErrorReport = implements(api.ErrorReport, {
__constructor : function ErrorReport(message, line, column) {
this.message = requireNonNull(message);
this.line = line || 0;
this.column = column || 0;
},
toString : function() {
return "ErrorReport [" + this.message + " at [" + this.line + ":" + this.column + "]]";
}
});
var SecurityConfiguration = implements(api.SecurityConfiguration, {

@@ -85,3 +73,3 @@ __constructor : function Configuration(anonymous, named, roles) {

ABSTAIN : { id : 2, value : 'abstain' },
fromString : function(val) {

@@ -107,3 +95,4 @@ return this[val.toUpperCase()];

var updateSystemAuthentication = internal.getServiceLocator().obtain(UPDATE_SYSTEM_AUTHENTICATION);
var updateSecurityConfiguration = internal.getServiceLocator().obtain(UPDATE_SECURITY_CONFIGURATION);
this.getPrincipal = function() {

@@ -168,34 +157,46 @@ return internal.getPrincipal();

}
return result;
};
this.updateStore = function(script) {
var emitter = new Emitter();
var result = new Result(emitter);
var updateStoreCallback = function(err, result, emitter) {
if (err) {
emitter.error(err);
} else if (result.errors.length > 0) {
emitter.error(result.errors);
} else {
emitter.emit('complete');
}
};
var updateStore = function(updater, script) {
var emitter = new Emitter();
var result = new Result(emitter);
if (script === "") {
emitter.emit('complete');
} else if (!script || typeof script !== 'string') {
if (script === "") {
emitter.emit('complete');
} else if (!script || typeof script !== 'string') {
emitter.error(new Error('Invalid argument for script:' + script));
} else if (internal.checkConnected(emitter)) {
updateSystemAuthentication.send(new SecurityCommandScript(script), function(err, result) {
if (err) {
emitter.error(err);
} else if (result.errors.length > 0) {
emitter.error(result.errors);
} else {
emitter.emit('complete');
}
} else if (internal.checkConnected(emitter)) {
updater.send(new SecurityCommandScript(script), function(err, result) {
updateStoreCallback(err, result, emitter);
});
}
return result;
};
this.securityScriptBuilder = function(script) {
}
return result;
};
this.updateSecurityStore = function(script) {
return updateStore(updateSecurityConfiguration, script);
};
this.updateAuthenticationStore = function(script) {
return updateStore(updateSystemAuthentication, script);
};
this.securityScriptBuilder = function(script) {
return new SecurityScriptBuilder(script);
};
this.authenticationScriptBuilder = function(script) {
this.authenticationScriptBuilder = function(script) {
return new AuthenticationScriptBuilder(script);

@@ -209,3 +210,2 @@ };

module.exports.Security = Security;
module.exports.ErrorReport = ErrorReport;
module.exports.SystemPrincipal = SystemPrincipal;

@@ -212,0 +212,0 @@

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

function SecurityScriptBuilderImpl(commands) {
commands = commands || "";
var withCommand = function(command) {

@@ -20,3 +20,3 @@ if (commands) {

}
return new SecurityScriptBuilder(command);

@@ -23,0 +23,0 @@ };

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

commands = commands || "";
commands = commands || "";

@@ -20,3 +20,3 @@ // Create a new ScriptBuilder, appended with a new command.

}
return new SystemAuthenticationScriptBuilder(command);

@@ -23,0 +23,0 @@ };

@@ -30,3 +30,3 @@ // Quote any necessary characters within a string

function permissionsToString(permissions) {
return '[' + permissions.map(quoteAndEscape).join(' ') + ']';
return '[' + permissions.join(' ') + ']';
}

@@ -33,0 +33,0 @@

@@ -25,3 +25,3 @@ var Services = require('services/services');

var result = new Result(emitter);
if (state !== ResponseHandlerState.CLOSED) {

@@ -40,3 +40,3 @@ deregistration(cid, function(err) {

}
return result;

@@ -57,3 +57,3 @@ };

return adapter.respond(response);
}
}
}

@@ -90,11 +90,13 @@ };

module.exports.registerTopicHandler = function registerTopicHandler(internal, params, adapter) {
return registerHandler(internal, params, adapter,
Services.TOPIC_CONTROL_REGISTRATION,
Services.TOPIC_CONTROL_DEREGISTRATION);
module.exports.registerMessageHandler = function registerMessageHandler(internal, params, adapter) {
var handler = registerHandler(internal, params, adapter,
Services.MESSAGE_RECEIVER_CONTROL_REGISTRATION,
Services.MESSAGE_RECEIVER_CONTROL_DEREGISTRATION);
return handler;
};
module.exports.registerServerHandler = function registerServerHandler(internal, params, adapter) {
return registerHandler(internal, params, adapter,
Services.SERVER_CONTROL_REGISTRATION,
return registerHandler(internal, params, adapter,
Services.SERVER_CONTROL_REGISTRATION,
Services.SERVER_CONTROL_DEREGISTRATION);

@@ -101,0 +103,0 @@ };

var Codec = require('io/codec');
var ErrorReportSerialiser = require('./error-report-serialiser');
var ErrorReportSerialiser = require('../error-report-serialiser');

@@ -16,2 +16,2 @@ var SecurityCommandScriptResult = require('./security-command-script-result');

module.exports = serialiser;
module.exports = serialiser;

@@ -15,3 +15,3 @@ var ControlRegistrationParamsSerialiser = require('services/control/control-registration-params-serialiser');

write : function(output, request) {
ControlRegistrationParamsSerialiser.write(output, request.params);
ControlRegistrationParamsSerialiser.write(output, request.params);
ConversationIDSerialiser.write(output, request.cid);

@@ -18,0 +18,0 @@ }

@@ -17,3 +17,2 @@ var SessionSendRequest = require('./session-send-request');

var cid = CIDSerialiser.read(input);
return {

@@ -20,0 +19,0 @@ cid : cid,

@@ -12,2 +12,5 @@ var HashMap = require('hashmap').HashMap;

var ErrorReport = require('services/error-report');
var ErrorReportSerialiser = require('services/error-report-serialiser.js');
var serialisers = new HashMap();

@@ -18,2 +21,3 @@

serialisers.set(TopicSelector, TopicSelectorSerialiser);
serialisers.set(ErrorReport, ErrorReportSerialiser);

@@ -74,6 +78,2 @@ serialisers.set(null, {

serialisers.set(
security.ErrorReport,
require('./authentication/error-report-serialiser')
);
serialisers.set(
security.SystemAuthenticationConfiguration,

@@ -122,3 +122,23 @@ require('./authentication/system-authentication-configuration-serialiser')

);
serialisers.set(
require('./send/session-forward-send-request'),
require('./send/session-forward-send-request-serialiser')
);
serialisers.set(
require('services/control/message-receiver-control-registration-request'),
require('services/control/message-receiver-control-registration-request-serialiser')
);
serialisers.set(
require('services/control/message-receiver-control-registration-params'),
require('services/control/message-receiver-control-registration-params-serialiser')
);
serialisers.set(
require('./send/filter-send-request'),
require('./send/filter-send-request-serialiser')
);
serialisers.set(
require('./send/filter-send-result'),
require('./send/filter-send-result-serialiser')
);
module.exports = serialisers;

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

var SessionForwardSendRequest = require('services/send/session-forward-send-request');
var MessageReceiverControlRegistrationRequest =
require('services/control/message-receiver-control-registration-request');
var MessageReceiverControlRegistrationParams =
require('services/control/message-receiver-control-registration-params');
var FilterSendRequest = require('services/send/filter-send-request');
var FilterSendResult = require('services/send/filter-send-result');
module.exports = {

@@ -171,3 +180,27 @@ SUBSCRIBE : {

response : null
},
SEND_RECEIVER_CLIENT : {
id : 62,
name : "Control Client Send Service",
request : SessionForwardSendRequest,
response : null
},
MESSAGE_RECEIVER_CONTROL_REGISTRATION : {
id : 63,
name : "Message Receiver Control Registration",
request : MessageReceiverControlRegistrationRequest,
response : null
},
MESSAGE_RECEIVER_CONTROL_DEREGISTRATION : {
id : 64,
name : "Message Receiver Control Deregistration",
request : MessageReceiverControlRegistrationParams,
response : null
},
SEND_TO_FILTER : {
id : 29,
name : "Send to filter",
request : FilterSendRequest,
response : FilterSendResult
}
};
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