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

freedom

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

freedom - npm Package Compare versions

Comparing version 0.5.0-rc2 to 0.5.0

2

bower.json
{
"name": "freedom",
"version": "0.5.0-rc2",
"version": "0.5.0",
"homepage": "http://freedomjs.com",

@@ -5,0 +5,0 @@ "repository": {

/*globals fdom:true */
/*jslint indent:2,sloppy:true */
fdom.apis.set("core", {
'createChannel': {type: "method", value: [], ret: {
channel: "proxy",
identifier: "string"
fdom.apis.set('core', {
'createChannel': {type: 'method', value: [], ret: {
channel: 'proxy',
identifier: 'string'
}},
'bindChannel': {type: "method", value: ["string"], ret: "proxy"},
'getId': {type: "method", value: [], ret: ["array", "string"]}
'bindChannel': {type: 'method', value: ['string'], ret: 'proxy'},
'getId': {type: 'method', value: [], ret: ['array', 'string']}
});
fdom.apis.set("core.view", {
'open': {type: "method", value: ["string", {
'file': "string",
'code': "string"
fdom.apis.set('core.view', {
'open': {type: 'method', value: ['string', {
'file': 'string',
'code': 'string'
}]},
'show': {type: "method", value: []},
'close': {type: "method", value: []},
'postMessage': {type: "method", value: ["object"]},
'show': {type: 'method', value: []},
'close': {type: 'method', value: []},
'postMessage': {type: 'method', value: ['object']},
'message': {type: "event", value: "object"},
'onClose': {type: "event", value: []}
'message': {type: 'event', value: 'object'},
'onClose': {type: 'event', value: []}
});
fdom.apis.set("core.storage", {
'keys': {type: "method", value: [], ret: ["array", "string"]},
'get': {type: "method", value: ["string"], ret: "string"},
'set': {type: "method", value: ["string", "string"], ret: "string"},
'remove': {type: "method", value: ["string"], ret: "string"},
'clear': {type: "method", value: []}
fdom.apis.set('core.storage', {
'keys': {type: 'method', value: [], ret: ['array', 'string']},
'get': {type: 'method', value: ['string'], ret: 'string'},
'set': {type: 'method', value: ['string', 'string'], ret: 'string'},
'remove': {type: 'method', value: ['string'], ret: 'string'},
'clear': {type: 'method', value: []}
});
// A TCP Socket.
fdom.apis.set("core.tcpsocket", {
fdom.apis.set('core.tcpsocket', {
// Sockets may be constructed bound to a pre-existing id, as in the case of

@@ -40,3 +40,3 @@ // interacting with a socket accpeted by a server. If no Id is specified, a

'constructor': {
value: ["number"]
value: ['number']
},

@@ -47,21 +47,50 @@

'getInfo': {
type: "method",
type: 'method',
value: [],
ret: {
"connected": "boolean",
"localAddress": "string",
"localPort": "number",
"peerAddress": "string",
"peerPort": "number"
'connected': 'boolean',
'localAddress': 'string',
'localPort': 'number',
'peerAddress': 'string',
'peerPort': 'number'
}
},
/**
* error codes and default messages that may be returned on failures.
*/
'ERRCODE': {type: 'constant', value: {
/** GENERAL **/
'SUCCESS': 'Success!',
// Unknown
'UNKNOWN': 'Unknown error',
// Socket is already connected
'ALREADY_CONNECTED': 'Socket already connected',
// Invalid Argument, client error
'INVALID_ARGUMENT': 'Invalid argument',
// Connection timed out.
'TIMED_OUT': 'Timed out',
// Operation cannot complete because socket is not connected.
'NOT_CONNECTED': 'Socket not connected',
// Socket reset because of change in network state.
'NETWORK_CHANGED': 'Network changed',
// Connection closed
'CONNECTION_CLOSED': 'Connection closed gracefully',
// Connection Reset
'CONNECTION_RESET': 'Connection reset',
// Connection Refused
'CONNECTION_REFUSED': 'Connection refused',
// Generic Failure
'CONNECTION_FAILED': 'Connection failed'
}},
// Close a socket. Will Fail if the socket is not connected or already
// closed.
'close': {
type: "method",
type: 'method',
value: [],
err: {
"errcode": "string",
"message": "string"
'errcode': 'string',
'message': 'string'
}

@@ -71,26 +100,26 @@ },

// Receive notification that the socket has disconnected.
'onDisconnect': {type: "event", value: {
"errcode": "string",
"message": "string"
'onDisconnect': {type: 'event', value: {
'errcode': 'string',
'message': 'string'
}},
// Connect to a host and port.
// Fails with an error if connection fails.
'connect': {
type: "method",
value: ["string", "number"],
type: 'method',
value: ['string', 'number'],
err: {
"errcode": "string",
"message": "string"
'errcode': 'string',
'message': 'string'
}
},
// Write buffer data to a socket.
// Fails with an error if write fails.
'write': {
type: "method",
value: ["buffer"],
type: 'method',
value: ['buffer'],
err: {
"errcode": "string",
"message": "string"
'errcode': 'string',
'message': 'string'
}

@@ -101,4 +130,4 @@ },

'onData': {
type: "event",
value: {"data": "buffer"}
type: 'event',
value: {'data': 'buffer'}
},

@@ -110,7 +139,7 @@

'listen': {
type: "method",
value: ["string", "number"],
type: 'method',
value: ['string', 'number'],
err: {
"errcode": "string",
"message": "string"
'errcode': 'string',
'message': 'string'
}

@@ -122,6 +151,6 @@ },

// Host and port information provide information about the remote peer.
'onConnection': {type: "event", value: {
"socket": "number",
"host": "string",
"port": "number"
'onConnection': {type: 'event', value: {
'socket': 'number',
'host': 'string',
'port': 'number'
}}

@@ -135,2 +164,21 @@ });

fdom.apis.set('core.udpsocket', {
/**
* error codes and default messages that may be returned on failures.
*/
'ERRCODE': {type: 'constant', value: {
/** GENERAL **/
'SUCCESS': 'Success!',
// Unknown
'UNKNOWN': 'Unknown error',
// Socket is already bound
'ALREADY_BOUND': 'Socket already bound',
// Invalid Argument, client error
'INVALID_ARGUMENT': 'Invalid argument',
// Socket reset because of change in network state.
'NETWORK_CHANGED': 'Network changed',
// Failure to send data
'SNED_FAILED': 'Send failed'
}},
// Creates a socket, binds it to an interface and port and listens for

@@ -205,12 +253,12 @@ // messages, dispatching each message as on onData event.

fdom.apis.set("core.runtime", {
'createApp': {type: "method", value: ["string", "proxy"]},
'resolve': {type: "method", value: ["string", "string"]},
'needFile': {type: 'event', value: ["string", "string"]}
fdom.apis.set('core.runtime', {
'createApp': {type: 'method', value: ['string', 'proxy']},
'resolve': {type: 'method', value: ['string', 'string']},
'needFile': {type: 'event', value: ['string', 'string']}
});
fdom.apis.set('core.echo', {
'setup': {type: "method", value: ["string"]},
'send': {type: "method", value: ["string"]},
'message': {type: "event", value: "string"}
'setup': {type: 'method', value: ['string']},
'send': {type: 'method', value: ['string']},
'message': {type: 'event', value: 'string'}
});

@@ -222,15 +270,15 @@

'setup': {
type: "method",
type: 'method',
value: [
// The freedom.js channel identifier used to setup a signalling chanel.
"string",
'string',
// The peerName, used debugging and console messages.
"string",
'string',
// The list of STUN servers to use.
// The format of a single entry is stun:HOST:PORT, where HOST
// and PORT are a stun server hostname and port, respectively.
["array", "string"],
['array', 'string'],
// Whether to immediately initiate a connection before fulfilling return
// promise.
"boolean"
'boolean'
]

@@ -240,46 +288,63 @@ },

// Send a message to the peer.
'send': {type: "method", value: [{
'send': {type: 'method', value: [{
// Data channel id. If provided, will be used as the channel label.
// The behavior is undefined if the channel label doesn't exist.
"channelLabel": "string",
'channelLabel': 'string',
// One of the bellow should be defined; this is the data to send.
"text": "string",
"binary": "blob",
"buffer": "buffer"
'text': 'string',
'binary': 'blob',
'buffer': 'buffer'
}]},
// Called when we get a message from the peer.
'onReceived': {type: "event", value: {
'onReceived': {type: 'event', value: {
// The label/id of the data channel.
"channelLabel": "string",
'channelLabel': 'string',
// One the below will be specified.
"text": "string",
"binary": "blob",
"buffer": "buffer"
'text': 'string',
'binary': 'blob',
'buffer': 'buffer'
}},
// Open the data channel with this label.
'openDataChannel': {type: "method", value: ["string"]},
'openDataChannel': {type: 'method', value: ['string']},
// Close the data channel with this label.
'closeDataChannel': {type: "method", value: ["string"]},
'closeDataChannel': {type: 'method', value: ['string']},
// A channel with this id has been opened.
'onOpenDataChannel': {type: "event", value: {"channelId": "string"}},
'onOpenDataChannel': {type: 'event', value: {'channelId': 'string'}},
// The channale with this id has been closed.
'onCloseDataChannel': {type: "event", value: {"channelId": "string"}},
'onCloseDataChannel': {type: 'event', value: {'channelId': 'string'}},
// Returns the number of bytes that have queued using "send", but not
// Returns the number of bytes that have queued using 'send', but not
// yet sent out. Currently just exposes:
// http://www.w3.org/TR/webrtc/#widl-RTCDataChannel-bufferedAmount
"getBufferedAmount": {type: "method",
value: ["string"],
ret: "number"},
'getBufferedAmount': {type: 'method',
value: ['string'],
ret: 'number'},
// Returns local SDP headers from createOffer.
'getInfo': {type: 'method', value: [], ret: 'string'},
'createOffer': {type: 'method', value: [{
// Optional :RTCOfferOptions object.
offerToReceiveVideo: 'number',
offerToReceiveAudio: 'number',
voiceActivityDetection: 'boolean',
iceRestart: 'boolean'
}],
ret: {
// Fulfills with a :RTCSessionDescription
'type': 'string', // Should always be 'offer'.
'sdp': 'string'
}
},
// Close the peer connection.
'close': {type: "method", value: []},
'close': {type: 'method', value: []},
// The peer connection has been closed.
'onClose': {type: "event", value: {}}
'onClose': {type: 'event', value: {}}
});
fdom.apis.set("core.websocket", {
fdom.apis.set('core.websocket', {
// Constructs new websocket. Errors in construction are passed on

@@ -289,5 +354,5 @@ // through the onError event.

// URL to connect through
"string",
'string',
// Protocols
["array", "string"]
['array', 'string']
]},

@@ -297,15 +362,15 @@ // Send the data to the other side of this connection. Only one of

'send': {
type: "method",
type: 'method',
value: [{
"text": "string",
"binary": "blob",
"buffer": "buffer"
'text': 'string',
'binary': 'blob',
'buffer': 'buffer'
}],
err: {
"errcode": "string",
"message": "string"
'errcode': 'string',
'message': 'string'
}
},
'getReadyState': {
type: "method",
type: 'method',
value: [],

@@ -316,15 +381,15 @@ // 0 -> CONNECTING

// 3 -> CLOSED
ret: "number"
ret: 'number'
},
"getBufferedAmount": {type: "method",
value: ["string"],
ret: "number"},
'getBufferedAmount': {type: 'method',
value: ['string'],
ret: 'number'},
'close': {
type: "method",
type: 'method',
// The first argument is a status code from
// https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
value: ["number", "string"],
value: ['number', 'string'],
err: {
"errcode": "string",
"message": "string"
'errcode': 'string',
'message': 'string'
}

@@ -337,5 +402,5 @@ },

value: {
"text": "string",
"binary": "blob",
"buffer": "buffer"
'text': 'string',
'binary': 'blob',
'buffer': 'buffer'
}

@@ -350,4 +415,4 @@ },

value: {
"errcode": "string",
"message": "string"
'errcode': 'string',
'message': 'string'
}

@@ -360,7 +425,7 @@ },

value: {
"code": "number",
"reason": "string",
"wasClean": "boolean"
'code': 'number',
'reason': 'string',
'wasClean': 'boolean'
}
}
});
{
"name": "freedom",
"description": "Embracing a distributed web",
"version": "0.5.0-rc2",
"version": "0.5.0",
"homepage": "http://freedomjs.com",

@@ -6,0 +6,0 @@ "bugs": {

@@ -97,2 +97,8 @@ /*globals fdom:true, console, RTCPeerConnection, webkitRTCPeerConnection */

SimpleDataPeer.prototype.createOffer = function (constaints, continuation) {
this.pc.createOffer(continuation, function() {
console.error('core.peerconnection createOffer failed.');
}, constaints);
};
SimpleDataPeer.prototype.runWhenConnected = function (func) {

@@ -451,2 +457,6 @@ if (this.pcState === SimpleDataPeerState.CONNECTED) {

PeerConnection.prototype.createOffer = function (constraints, continuation) {
this.peer.createOffer(constraints, continuation);
};
// TODO: delay continuation until the open callback from _peer is called.

@@ -453,0 +463,0 @@ PeerConnection.prototype.openDataChannel = function (channelId, continuation) {

@@ -39,3 +39,17 @@ describe("fdom.apis", function() {

});
it("should register core providers in promise style", function(done) {
var provider = function(arg) { this.arg = arg };
api.set('customCore', provider);
api.register('customCore', provider, 'providePromises');
var channel = api.getCore('customCore', 12);
channel.then(function(prov) {
var obj = new prov();
expect(api.getInterfaceStyle('customCore')).toEqual('providePromises');
expect(obj.arg).toEqual(12);
done();
});
});
it("allows late registration of core providers", function(done) {

@@ -42,0 +56,0 @@ var provider = function(arg) { this.arg = arg };

@@ -8,3 +8,3 @@ /*globals fdom:true, Promise */

/**
* The API registry for FreeDOM. Used to look up requested APIs,
* The API registry for freedom.js. Used to look up requested APIs,
* and provides a bridge for core APIs to act like normal APIs.

@@ -51,12 +51,18 @@ * @Class API

* @param {Function} constructor the function to create a provider for the API.
* @param {String?} style The style the provider is written in. Valid styles
* are documented in fdom.port.Provider.prototype.getInterface. Defaults to
* provideAsynchronous
*/
Api.prototype.register = function(name, constructor) {
Api.prototype.register = function(name, constructor, style) {
var i;
this.providers[name] = constructor;
this.providers[name] = {
constructor: constructor,
style: style || 'provideAsynchronous'
};
if (this.waiters[name]) {
for (i = 0; i < this.waiters[name].length; i += 1) {
this.waiters[name][i][0](constructor.bind({},
this.waiters[name][i][2]));
this.waiters[name][i].resolve(constructor.bind({},
this.waiters[name][i].from));
}

@@ -79,3 +85,3 @@ delete this.waiters[name];

if (this.providers[name]) {
resolve(this.providers[name].bind({}, from));
resolve(this.providers[name].constructor.bind({}, from));
} else {

@@ -85,3 +91,7 @@ if (!this.waiters[name]) {

}
this.waiters[name].push([resolve, reject, from]);
this.waiters[name].push({
resolve: resolve,
reject: reject,
from: from
});
}

@@ -96,4 +106,22 @@ } else {

/**
* Get the style in which a core API is written.
* This method is guaranteed to know the style of a provider returned from
* a previous getCore call, and so does not use promises.
* @method getInterfaceStyle
* @param {String} name The name of the provider.
* @returns {String} The coding style, as used by
* fdom.port.Provider.prototype.getInterface.
*/
Api.prototype.getInterfaceStyle = function(name) {
if (this.providers[name]) {
return this.providers[name].style;
} else {
fdom.debug.warn('Api.getInterfaceStyle for unknown provider: ' + name);
return undefined;
}
};
/**
* Defines fdom.apis for fdom module registry and core provider registation.
*/
fdom.apis = new Api();

@@ -306,4 +306,5 @@ /*globals fdom:true */

var i, channels = ['default'], name, dep,
finishLink = function(dep, provider) {
dep.getInterface().provideAsynchronous(provider);
finishLink = function(dep, name, provider) {
var style = fdom.apis.getInterfaceStyle(name);
dep.getInterface()[style](provider);
};

@@ -316,3 +317,3 @@ if (this.manifest.permissions) {

dep = new fdom.port.Provider(fdom.apis.get(name).definition);
fdom.apis.getCore(name, this).then(finishLink.bind(this, dep));
fdom.apis.getCore(name, this).then(finishLink.bind(this, dep, name));

@@ -319,0 +320,0 @@ this.emit(this.controlChannel, {

@@ -7,2 +7,2 @@

})(this);
//# sourceMappingURL=freedom.map.js
//# sourceMappingURL=freedom.js.map

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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