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

rsocket-core

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rsocket-core - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

build/CompositeMetadata.js

318

build/index.js

@@ -20,3 +20,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

Object.defineProperty(exports, '__esModule', {value: true});
exports.Lease = (exports.Leases = (exports.JsonSerializers = (exports.JsonSerializer = (exports.IdentitySerializers = (exports.IdentitySerializer = (exports.UTF8Encoder = (exports.Utf8Encoders = (exports.BufferEncoder = (exports.BufferEncoders = (exports.writeUInt24BE = (exports.toBuffer = (exports.readUInt24BE = (exports.createBuffer = (exports.byteLength = (exports.serializeFrameWithLength = (exports.serializeFrame = (exports.deserializeFrames = (exports.deserializeFrameWithLength = (exports.deserializeFrame = (exports.printFrame = (exports.isResumeEnable = (exports.isRespond = (exports.isNext = (exports.isMetadata = (exports.isLease = (exports.isIgnore = (exports.isComplete = (exports.getErrorCodeExplanation = (exports.createErrorFromFrame = (exports.MAX_VERSION = (exports.MAX_STREAM_ID = (exports.MAX_RESUME_LENGTH = (exports.MAX_MIME_LENGTH = (exports.MAX_LIFETIME = (exports.MAX_KEEPALIVE = (exports.MAX_CODE = (exports.FRAME_TYPES = (exports.FRAME_TYPE_OFFFSET = (exports.FLAGS = (exports.FLAGS_MASK = (exports.ERROR_EXPLANATIONS = (exports.ERROR_CODES = (exports.CONNECTION_STREAM_ID = (exports.RSocketResumableTransport = (exports.RSocketServer = (exports.RSocketClient = undefined))))))))))))))))))))))))))))))))))))))))))))));
exports.encodeAndAddWellKnownMetadata = (exports.encodeAndAddCustomMetadata = (exports.ExplicitMimeTimeEntry = (exports.WellKnownMimeTypeEntry = (exports.ReservedMimeTypeEntry = (exports.CompositeMetadata = (exports.MESSAGE_RSOCKET_COMPOSITE_METADATA = (exports.MESSAGE_RSOCKET_ROUTING = (exports.MESSAGE_RSOCKET_TRACING_ZIPKIN = (exports.APPLICATION_CLOUDEVENTS_JSON = (exports.APPLICATION_JAVA_OBJECT = (exports.APPLICATION_HESSIAN = (exports.VIDEO_VP8 = (exports.VIDEO_H265 = (exports.VIDEO_H264 = (exports.TEXT_XML = (exports.TEXT_PLAIN = (exports.TEXT_HTML = (exports.TEXT_CSV = (exports.TEXT_CSS = (exports.MULTIPART_MIXED = (exports.IMAGE_TIFF = (exports.IMAGE_PNG = (exports.IMAGE_JPEG = (exports.IMAGE_HEIF = (exports.IMAGE_HEIF_SEQUENCE = (exports.IMAGE_HEIC = (exports.IMAGE_HEIC_SEQUENCE = (exports.IMAGE_GIG = (exports.IMAGE_BMP = (exports.AUDIO_VORBIS = (exports.AUDIO_OPUS = (exports.AUDIO_OGG = (exports.AUDIO_MPEG = (exports.AUDIO_MPEG3 = (exports.AUDIO_MP4 = (exports.AUDIO_MP3 = (exports.AUDIO_AAC = (exports.APPLICATION_ZIP = (exports.APPLICATION_XML = (exports.APPLICATION_PROTOBUF = (exports.APPLICATION_THRIFT = (exports.APPLICATION_PDF = (exports.APPLICATION_OCTET_STREAM = (exports.APPLICATION_JSON = (exports.APPLICATION_JAVASCRIPT = (exports.APPLICATION_GZIP = (exports.APPLICATION_GRAPHQL = (exports.APPLICATION_CBOR = (exports.APPLICATION_AVRO = (exports.UNKNOWN_RESERVED_MIME_TYPE = (exports.UNPARSEABLE_MIME_TYPE = (exports.Lease = (exports.Leases = (exports.JsonSerializers = (exports.JsonSerializer = (exports.IdentitySerializers = (exports.IdentitySerializer = (exports.UTF8Encoder = (exports.Utf8Encoders = (exports.BufferEncoder = (exports.BufferEncoders = (exports.writeUInt24BE = (exports.toBuffer = (exports.readUInt24BE = (exports.createBuffer = (exports.byteLength = (exports.serializeFrameWithLength = (exports.serializeFrame = (exports.deserializeFrames = (exports.deserializeFrameWithLength = (exports.deserializeFrame = (exports.printFrame = (exports.isResumeEnable = (exports.isRespond = (exports.isNext = (exports.isMetadata = (exports.isLease = (exports.isIgnore = (exports.isComplete = (exports.getErrorCodeExplanation = (exports.createErrorFromFrame = (exports.MAX_VERSION = (exports.MAX_STREAM_ID = (exports.MAX_RESUME_LENGTH = (exports.MAX_MIME_LENGTH = (exports.MAX_LIFETIME = (exports.MAX_KEEPALIVE = (exports.MAX_CODE = (exports.FRAME_TYPES = (exports.FRAME_TYPE_OFFFSET = (exports.FLAGS = (exports.FLAGS_MASK = (exports.ERROR_EXPLANATIONS = (exports.ERROR_CODES = (exports.CONNECTION_STREAM_ID = (exports.WellKnownMimeType = (exports.RSocketResumableTransport = (exports.RSocketServer = (exports.RSocketClient = undefined)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
var _RSocketFrame = require('./RSocketFrame');

@@ -292,2 +292,316 @@ Object.defineProperty(exports, 'CONNECTION_STREAM_ID', {

});
var _WellKnownMimeType = require('./WellKnownMimeType');
Object.defineProperty(exports, 'UNPARSEABLE_MIME_TYPE', {
enumerable: true,
get: function() {
return _WellKnownMimeType.UNPARSEABLE_MIME_TYPE;
},
});
Object.defineProperty(exports, 'UNKNOWN_RESERVED_MIME_TYPE', {
enumerable: true,
get: function() {
return _WellKnownMimeType.UNKNOWN_RESERVED_MIME_TYPE;
},
});
Object.defineProperty(exports, 'APPLICATION_AVRO', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_AVRO;
},
});
Object.defineProperty(exports, 'APPLICATION_CBOR', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_CBOR;
},
});
Object.defineProperty(exports, 'APPLICATION_GRAPHQL', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_GRAPHQL;
},
});
Object.defineProperty(exports, 'APPLICATION_GZIP', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_GZIP;
},
});
Object.defineProperty(exports, 'APPLICATION_JAVASCRIPT', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_JAVASCRIPT;
},
});
Object.defineProperty(exports, 'APPLICATION_JSON', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_JSON;
},
});
Object.defineProperty(exports, 'APPLICATION_OCTET_STREAM', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_OCTET_STREAM;
},
});
Object.defineProperty(exports, 'APPLICATION_PDF', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_PDF;
},
});
Object.defineProperty(exports, 'APPLICATION_THRIFT', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_THRIFT;
},
});
Object.defineProperty(exports, 'APPLICATION_PROTOBUF', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_PROTOBUF;
},
});
Object.defineProperty(exports, 'APPLICATION_XML', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_XML;
},
});
Object.defineProperty(exports, 'APPLICATION_ZIP', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_ZIP;
},
});
Object.defineProperty(exports, 'AUDIO_AAC', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_AAC;
},
});
Object.defineProperty(exports, 'AUDIO_MP3', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_MP3;
},
});
Object.defineProperty(exports, 'AUDIO_MP4', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_MP4;
},
});
Object.defineProperty(exports, 'AUDIO_MPEG3', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_MPEG3;
},
});
Object.defineProperty(exports, 'AUDIO_MPEG', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_MPEG;
},
});
Object.defineProperty(exports, 'AUDIO_OGG', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_OGG;
},
});
Object.defineProperty(exports, 'AUDIO_OPUS', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_OPUS;
},
});
Object.defineProperty(exports, 'AUDIO_VORBIS', {
enumerable: true,
get: function() {
return _WellKnownMimeType.AUDIO_VORBIS;
},
});
Object.defineProperty(exports, 'IMAGE_BMP', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_BMP;
},
});
Object.defineProperty(exports, 'IMAGE_GIG', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_GIG;
},
});
Object.defineProperty(exports, 'IMAGE_HEIC_SEQUENCE', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_HEIC_SEQUENCE;
},
});
Object.defineProperty(exports, 'IMAGE_HEIC', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_HEIC;
},
});
Object.defineProperty(exports, 'IMAGE_HEIF_SEQUENCE', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_HEIF_SEQUENCE;
},
});
Object.defineProperty(exports, 'IMAGE_HEIF', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_HEIF;
},
});
Object.defineProperty(exports, 'IMAGE_JPEG', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_JPEG;
},
});
Object.defineProperty(exports, 'IMAGE_PNG', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_PNG;
},
});
Object.defineProperty(exports, 'IMAGE_TIFF', {
enumerable: true,
get: function() {
return _WellKnownMimeType.IMAGE_TIFF;
},
});
Object.defineProperty(exports, 'MULTIPART_MIXED', {
enumerable: true,
get: function() {
return _WellKnownMimeType.MULTIPART_MIXED;
},
});
Object.defineProperty(exports, 'TEXT_CSS', {
enumerable: true,
get: function() {
return _WellKnownMimeType.TEXT_CSS;
},
});
Object.defineProperty(exports, 'TEXT_CSV', {
enumerable: true,
get: function() {
return _WellKnownMimeType.TEXT_CSV;
},
});
Object.defineProperty(exports, 'TEXT_HTML', {
enumerable: true,
get: function() {
return _WellKnownMimeType.TEXT_HTML;
},
});
Object.defineProperty(exports, 'TEXT_PLAIN', {
enumerable: true,
get: function() {
return _WellKnownMimeType.TEXT_PLAIN;
},
});
Object.defineProperty(exports, 'TEXT_XML', {
enumerable: true,
get: function() {
return _WellKnownMimeType.TEXT_XML;
},
});
Object.defineProperty(exports, 'VIDEO_H264', {
enumerable: true,
get: function() {
return _WellKnownMimeType.VIDEO_H264;
},
});
Object.defineProperty(exports, 'VIDEO_H265', {
enumerable: true,
get: function() {
return _WellKnownMimeType.VIDEO_H265;
},
});
Object.defineProperty(exports, 'VIDEO_VP8', {
enumerable: true,
get: function() {
return _WellKnownMimeType.VIDEO_VP8;
},
});
Object.defineProperty(exports, 'APPLICATION_HESSIAN', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_HESSIAN;
},
});
Object.defineProperty(exports, 'APPLICATION_JAVA_OBJECT', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_JAVA_OBJECT;
},
});
Object.defineProperty(exports, 'APPLICATION_CLOUDEVENTS_JSON', {
enumerable: true,
get: function() {
return _WellKnownMimeType.APPLICATION_CLOUDEVENTS_JSON;
},
});
Object.defineProperty(exports, 'MESSAGE_RSOCKET_TRACING_ZIPKIN', {
enumerable: true,
get: function() {
return _WellKnownMimeType.MESSAGE_RSOCKET_TRACING_ZIPKIN;
},
});
Object.defineProperty(exports, 'MESSAGE_RSOCKET_ROUTING', {
enumerable: true,
get: function() {
return _WellKnownMimeType.MESSAGE_RSOCKET_ROUTING;
},
});
Object.defineProperty(exports, 'MESSAGE_RSOCKET_COMPOSITE_METADATA', {
enumerable: true,
get: function() {
return _WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA;
},
});
var _CompositeMetadata = require('./CompositeMetadata');
Object.defineProperty(exports, 'CompositeMetadata', {
enumerable: true,
get: function() {
return _CompositeMetadata.CompositeMetadata;
},
});
Object.defineProperty(exports, 'ReservedMimeTypeEntry', {
enumerable: true,
get: function() {
return _CompositeMetadata.ReservedMimeTypeEntry;
},
});
Object.defineProperty(exports, 'WellKnownMimeTypeEntry', {
enumerable: true,
get: function() {
return _CompositeMetadata.WellKnownMimeTypeEntry;
},
});
Object.defineProperty(exports, 'ExplicitMimeTimeEntry', {
enumerable: true,
get: function() {
return _CompositeMetadata.ExplicitMimeTimeEntry;
},
});
Object.defineProperty(exports, 'encodeAndAddCustomMetadata', {
enumerable: true,
get: function() {
return _CompositeMetadata.encodeAndAddCustomMetadata;
},
});
Object.defineProperty(exports, 'encodeAndAddWellKnownMetadata', {
enumerable: true,
get: function() {
return _CompositeMetadata.encodeAndAddWellKnownMetadata;
},
});
var _RSocketClient = require('./RSocketClient');

@@ -301,2 +615,3 @@ var _RSocketClient2 = _interopRequireDefault(_RSocketClient);

);
var _WellKnownMimeType2 = _interopRequireDefault(_WellKnownMimeType);
function _interopRequireDefault(obj) {

@@ -308,1 +623,2 @@ return obj && obj.__esModule ? obj : {default: obj};

exports.RSocketResumableTransport = _RSocketResumableTransport2.default;
exports.WellKnownMimeType = _WellKnownMimeType2.default;

@@ -16,3 +16,3 @@ 'use strict';

const bufferExists = typeof global !== 'undefined' &&
global.hasOwnProperty('Buffer'); // export const LiteBuffer = bufferExists ? gloval.Buffer : Buffer;
global.hasOwnProperty('Buffer');
const LiteBuffer = (exports.LiteBuffer = bufferExists ? global.Buffer : Buffer);

@@ -194,2 +194,35 @@ function Buffer(arg, encodingOrOffset, length) {

Buffer.concat = function concat(list, length) {
if (!Array.isArray(list)) {
throw new TypeError('"list" argument must be an Array of Buffers');
}
if (list.length === 0) {
return Buffer.alloc(0);
}
let i;
if (length === undefined) {
length = 0;
for (i = 0; i < list.length; ++i) {
length += list[i].length;
}
}
const buffer = Buffer.alloc(length);
let pos = 0;
for (i = 0; i < list.length; ++i) {
let buf = list[i];
if (isInstance(buf, Uint8Array)) {
buf = Buffer.from(buf);
}
if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers');
}
buf.copy(buffer, pos);
pos += buf.length;
}
return buffer;
};
Buffer.prototype._isBuffer = true;

@@ -196,0 +229,0 @@

35

build/RSocketClient.js

@@ -44,2 +44,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

constructor(config) {
this._checkConfig(config);
this._cancel = null;

@@ -90,2 +91,19 @@ this._config = config;

}
_checkConfig(config) {
const navigator = window && window.navigator;
const setup = config.setup;
const keepAlive = setup && setup.keepAlive;
if (
keepAlive > 30000 &&
navigator &&
navigator.userAgent &&
(navigator.userAgent.includes('Trident') ||
navigator.userAgent.includes('Edg'))
) {
console.warn(
'rsocket-js: Due to a browser bug, Internet Explorer and Edge users may experience WebSocket instability with keepAlive values longer than 30 seconds.'
);
}
}
}

@@ -113,7 +131,11 @@ exports.default = RSocketClient;

}
const {keepAlive, lifetime} = config.setup;
this._machine = (0, _RSocketMachine.createClientMachine)(
connection,
subscriber => connection.receive().subscribe(subscriber),
lifetime,
config.serializers,
config.responder,
config.errorHandler,
requesterLeaseHandler,

@@ -127,15 +149,2 @@ responderLeaseHandler

// Send KEEPALIVE frames
const {keepAlive} = config.setup;
const navigator = config.navigator;
if (
keepAlive > 30000 &&
navigator &&
navigator.userAgent &&
(navigator.userAgent.includes('Trident') ||
navigator.userAgent.includes('Edg'))
) {
console.warn(
'rsocket-js: Due to a browser bug, Internet Explorer and Edge users may experience WebSocket instability with keepAlive values longer than 30 seconds.'
);
}
const keepAliveFrames = (0, _rsocketFlowable.every)(keepAlive).map(() => ({

@@ -142,0 +151,0 @@ data: null,

@@ -107,3 +107,5 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

connectionPublisher,
keepAliveTimeout,
serializers,
errorHandler,
requesterLeaseHandler,

@@ -116,4 +118,6 @@ responderLeaseHandler

connectionPublisher,
keepAliveTimeout,
serializers,
undefined,
errorHandler,
requesterLeaseHandler,

@@ -126,4 +130,6 @@ responderLeaseHandler

connectionPublisher,
keepAliveTimeout,
serializers,
requestHandler,
errorHandler,
requesterLeaseHandler,

@@ -136,4 +142,6 @@ responderLeaseHandler

connectionPublisher,
keepAliveTimeout,
serializers,
requestHandler,
errorHandler,
requesterLeaseHandler,

@@ -149,4 +157,6 @@ responderLeaseHandler

connectionPublisher,
keepAliveTimeout,
serializers,
requestHandler,
errorHandler,
requesterLeaseHandler,

@@ -175,2 +185,8 @@ responderLeaseHandler

);
const handle = this._keepAliveTimerHandle;
if (handle) {
clearTimeout(handle);
this._keepAliveTimerHandle = null;
}
};

@@ -193,3 +209,4 @@ this._handleFrame = frame => {

_RSocketSerialization.IdentitySerializers;
this._requestHandler = new ResponderWrapper(requestHandler); // Subscribe to completion/errors before sending anything
this._requestHandler = new ResponderWrapper(requestHandler);
this._errorHandler = errorHandler; // Subscribe to completion/errors before sending anything
connectionPublisher({

@@ -219,2 +236,19 @@ onComplete: this._handleTransportClose,

});
const MIN_TICK_DURATION = 100;
this._keepAliveLastReceivedMillis = Date.now();
const keepAliveHandler = () => {
const now = Date.now();
const noKeepAliveDuration = now - this._keepAliveLastReceivedMillis;
if (noKeepAliveDuration >= keepAliveTimeout) {
this._handleConnectionError(
new Error(`No keep-alive acks for ${keepAliveTimeout} millis`)
);
} else {
this._keepAliveTimerHandle = setTimeout(
keepAliveHandler,
Math.max(MIN_TICK_DURATION, keepAliveTimeout - noKeepAliveDuration)
);
}
};
this._keepAliveTimerHandle = setTimeout(keepAliveHandler, keepAliveTimeout);
}

@@ -237,3 +271,2 @@ setRequestHandler(requestHandler) {

if (this._useLeaseOrError(this._requesterLeaseHandler)) {
//todo need to signal error to user provided error handler
return;

@@ -508,8 +541,12 @@ }

this._connection.close();
const errorHandler = this._errorHandler;
if (errorHandler) {
errorHandler(error);
}
}
/**
* Handle a frame received from the transport client.
*/ /**
* Handle connection frames (stream id === 0).
*/ _handleConnectionFrame(
* Handle a frame received from the transport client.
*/ /**
* Handle connection frames (stream id === 0).
*/ _handleConnectionFrame(
frame

@@ -525,2 +562,3 @@ ) {

case _RSocketFrame.FRAME_TYPES.KEEPALIVE:
this._keepAliveLastReceivedMillis = Date.now();
if ((0, _RSocketFrame.isRespond)(frame.flags)) {

@@ -527,0 +565,0 @@ this._connection.sendOne(

@@ -104,3 +104,5 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

},
frame.lifetime,
serializers,
this._config.errorHandler,
requesterLeaseHandler,

@@ -107,0 +109,0 @@ responderLeaseHandler

{
"name": "rsocket-core",
"description": "RSocket core",
"version": "0.0.16",
"version": "0.0.17",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

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 not supported yet

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