peers / js-binarypack Goto Github PK
View Code? Open in Web Editor NEWThis project forked from binaryjs/js-binarypack
Binary JSON like serialization with binary types
License: MIT License
This project forked from binaryjs/js-binarypack
Binary JSON like serialization with binary types
License: MIT License
In version 1.0.1, support for Blob and File types was available. However, it seems that support for Blob and File types has been removed in version 2.0.0 after the introduction of TypeScript. The error message states, Type 'function Blob() { [native code] }' not yet supported.
Now that PeerJS is using the 2.0.0 version of js-binarypack, I would like to request the addition of support for Blob and File types in version 2.*.
Steps to reproduce: Essentially, just conn.send( '𨋢' )
using the default binary serialization. See full example below.
Expected behaviour: Data is sent and received correctly.
Actual behaviour: The receiving peer crashes inside util.unpack
, because the sender sent garbled data.
Cause
This happens when sending any Unicode codepoint above U+FFFF:
'\uD860\uDEE2'
.utf8Length
wrongly assumes each individual surrogate becomes three UTF-8 bytes (i.e. a total of six bytes for a surrogate pair).util.unpack
.Fix: #10
Workaround: Using JSON serialization (instead of the default binary) avoids the crash (but has certain other disadvantages).
Full code to reproduce the error
var peer1 = new Peer();
peer1.on( 'open', function ( id ) {
var peer2 = new Peer();
peer2.on( 'open', function() {
var conn2 = peer2.connect( id );
// But using JSON serialization, instead of the default binary, avoids the crash
//var conn2 = peer2.connect( id, { serialization: 'json' } );
conn2.on( 'open', function () {
// Send U+282E2, the Cantonese word for 'elevator'
// (but it could be any of the 93,000 Unicode codepoints above U+FFFF)
conn2.send( '𨋢' );
} );
} );
} );
peer1.on( 'connection', function ( conn1 ) {
conn1.on( 'data', function ( data ) {
// This never runs: util.unpack crashes before we get this far
console.log( 'received: ' + data );
} );
} );
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These branches will be created by Renovate only once you click their checkbox below.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
package.json
@biomejs/biome 1.5.3
@jest/globals ^29.7.0
@parcel/packager-ts ^2.8.3
@parcel/transformer-typescript-types ^2.8.3
@semantic-release/changelog ^6.0.2
@semantic-release/git ^10.0.1
@typescript-eslint/eslint-plugin ^6.0.0
eslint ^8.34.0
parcel ^2.8.3
semantic-release ^23.0.0
typescript ^5.0.0
node >= 14.0.0
.github/workflows/bun.yml
actions/checkout v4
oven-sh/setup-bun v1
.github/workflows/prettier.yml
actions/checkout v4
biomejs/setup-biome v2
.github/workflows/release.yml
actions/checkout v4
oven-sh/setup-bun v1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.