You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

braid-http

Package Overview
Dependencies
Maintainers
0
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

braid-http - npm Package Compare versions

Comparing version

to
1.3.44

26

braid-http-client.js

@@ -312,3 +312,3 @@ // var peer = Math.random().toString(36).substr(2)

if (mux_params !== false &&
(params.headers.has('multiplex-at') ||
(params.headers.has('multiplex-through') ||
(params.headers.has('subscribe') &&

@@ -838,3 +838,3 @@ braid_fetch.subscription_counts?.[origin] >

// (the overriding is done by the tests)
var mux_key = params.headers.get('multiplex-at')?.split('/')[3] ?? origin
var mux_key = params.headers.get('multiplex-through')?.split('/')[3] ?? origin

@@ -845,3 +845,3 @@ // create a new multiplexer if it doesn't exist for this origin

// make up a new multiplexer id (unless it is being overriden)
var multiplexer = params.headers.get('multiplex-at')?.split('/')[3] ?? Math.random().toString(36).slice(2)
var multiplexer = params.headers.get('multiplex-through')?.split('/')[3] ?? Math.random().toString(36).slice(2)

@@ -861,3 +861,3 @@ var requests = new Map()

try {
r = await braid_fetch(`${origin}/.well-known/multiplex/${multiplexer}`, {method: 'POST', headers: {'Multiplex-Version': multiplex_version}, retry: true})
r = await braid_fetch(`${origin}/.well-known/multiplexer/${multiplexer}`, {method: 'POST', headers: {'Multiplex-Version': multiplex_version}, retry: true})

@@ -882,3 +882,3 @@ if (!r.ok) throw new Error('status not ok: ' + r.status)

try {
await braid_fetch(`${origin}/.well-known/multiplex/${multiplexer}/${request}`, {
await braid_fetch(`${origin}/.well-known/multiplexer/${multiplexer}/${request}`, {
method: 'DELETE',

@@ -903,11 +903,11 @@ headers: { 'Multiplex-Version': multiplex_version }, retry: true

// (unless the user is specifically asking for multiplexing)
if ((await promise_done(mux_promise)) && (await mux_promise) === false && !params.headers.get('multiplex-at'))
if ((await promise_done(mux_promise)) && (await mux_promise) === false && !params.headers.get('multiplex-through'))
return await normal_fetch(url, params)
// make up a new request id (unless it is being overriden)
var request = params.headers.get('multiplex-at')?.split('/')[4] ?? Math.random().toString(36).slice(2)
var request = params.headers.get('multiplex-through')?.split('/')[4] ?? Math.random().toString(36).slice(2)
// add the Multiplex-At header without affecting the underlying params
// add the Multiplex-Through header without affecting the underlying params
var mux_headers = new Headers(params.headers)
mux_headers.set('Multiplex-At', `/.well-known/multiplex/${multiplexer}/${request}`)
mux_headers.set('Multiplex-Through', `/.well-known/multiplexer/${multiplexer}/${request}`)
mux_headers.set('Multiplex-Version', multiplex_version)

@@ -949,3 +949,3 @@ params = {...params, headers: mux_headers}

try {
var r = await braid_fetch(`${origin}${params.headers.get('multiplex-at')}`, {
var r = await braid_fetch(`${origin}${params.headers.get('multiplex-through')}`, {
method: 'DELETE',

@@ -980,5 +980,5 @@ headers: { 'Multiplex-Version': multiplex_version }, retry: true

if (res.status !== 293) throw new Error('Could not establish multiplexed request ' + params.headers.get('multiplex-at') + ', got status: ' + res.status)
if (res.status !== 293) throw new Error('Could not establish multiplexed request ' + params.headers.get('multiplex-through') + ', got status: ' + res.status)
if (res.headers.get('Multiplex-Version') !== multiplex_version) throw new Error('Could not establish multiplexed request ' + params.headers.get('multiplex-at') + ', got unknown version: ' + res.headers.get('Multiplex-Version'))
if (res.headers.get('Multiplex-Version') !== multiplex_version) throw new Error('Could not establish multiplexed request ' + params.headers.get('multiplex-through') + ', got unknown version: ' + res.headers.get('Multiplex-Version'))

@@ -1096,3 +1096,3 @@ // we want to present the illusion that the connection is still open,

var headerStr = new TextDecoder().decode(buffers[0].slice(0, header_length))
var m = headerStr.match(/^[\r\n]*((\d+) bytes for|close|start) request ([A-Za-z0-9_-]+)\r\n$/)
var m = headerStr.match(/^[\r\n]*((\d+) bytes for|close|start) response ([A-Za-z0-9_-]+)\r\n$/)

@@ -1099,0 +1099,0 @@ if (!m) throw new Error('invalid multiplex header')

@@ -248,3 +248,3 @@ var assert = require('assert')

if ((braidify.enable_multiplex ?? true) &&
(req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplex/')) &&
(req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplexer/')) &&
req.headers['multiplex-version'] === multiplex_version) {

@@ -327,11 +327,11 @@

// a Multiplex-At header means the user wants to send the
// a Multiplex-Through header means the user wants to send the
// results of this request to the provided multiplexer,
// tagged with the given request id
if ((braidify.enable_multiplex ?? true) &&
req.headers['multiplex-at'] &&
req.headers['multiplex-through'] &&
req.headers['multiplex-version'] === multiplex_version) {
// parse the multiplexer id and request id from the header
var [multiplexer, request] = req.headers['multiplex-at'].split('/').slice(3)
var [multiplexer, request] = req.headers['multiplex-through'].split('/').slice(3)

@@ -355,3 +355,3 @@ // find the multiplexer object (contains a response object)

m.res.write(`start request ${request}\r\n`)
m.res.write(`start response ${request}\r\n`)

@@ -379,3 +379,3 @@ // let the requester know we've multiplexed their response

':status': 293,
'Multiplex-At': req.headers['multiplex-at'],
'Multiplex-Through': req.headers['multiplex-through'],
'Multiplex-Version': multiplex_version,

@@ -388,3 +388,3 @@ ...Object.fromEntries(cors_headers)

og_socket.write('HTTP/1.1 293 Responded via multiplexer\r\n')
og_socket.write(`Multiplex-At: ${req.headers['multiplex-at']}\r\n`)
og_socket.write(`Multiplex-Through: ${req.headers['multiplex-through']}\r\n`)
og_socket.write(`Multiplex-Version: ${multiplex_version}\r\n`)

@@ -415,10 +415,4 @@ cors_headers.forEach(([key, value]) =>

var len = Buffer.isBuffer(chunk) ? chunk.length : Buffer.byteLength(chunk, encoding)
this.multiplexer.res.write(`${len} bytes for request ${this.request}\r\n`)
this.multiplexer.res.write(`${len} bytes for response ${this.request}\r\n`)
this.multiplexer.res.write(chunk, encoding, callback)
// console.log(`wrote:`)
// console.log(`${len} bytes for request /${this.request}\r\n`)
// if (Buffer.isBuffer(chunk)) console.log(new TextDecoder().decode(chunk))
// else console.log('STRING?: ' + chunk)
} catch (e) {

@@ -446,3 +440,3 @@ callback(e)

// we want to send a special message to the multiplexer saying so
res2.on('finish', () => m.res.write(`close request ${request}\r\n`))
res2.on('finish', () => m.res.write(`close response ${request}\r\n`))

@@ -449,0 +443,0 @@ // we want access to "res" to be forwarded to our fake "res2",

{
"name": "braid-http",
"version": "1.3.43",
"version": "1.3.44",
"description": "An implementation of Braid-HTTP for Node.js and Browsers",

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