
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
text-encoding-shim
Advanced tools
Simple lightweight polyfill for the Text Encoding API, supporting UTF-8 only
When I was looking for a simple lightweight polyfill that works great with TypeScript I was not happy with the results. While a couple polyfills exist, they either broke in my special setup and lead to unexpected results or they implemented a bunch of features that I did not even want to have. So I wrote my own shim.
Get it via npm by adding text-encoding-shim
to your package.json
or run:
npm install text-encoding-shim
Get it via Bower by adding it to your bower.json
or run:
bower install --save text-encoding-shim
Altenatively you can simply download this project folder from Gitlab and add it to your html script tags like so:
<script type="text/javascript" src="text-encoding-shim/index.js"></script>
If you are using TypeScript you do not need to create a definition file. This project already includes one. If you are still using typings you may need to run this command to copy the file:
typings install --save --global npm:text-encoding-shim
This polyfill utilizes the Universal Module Definition (UMD) and be used with either a module loader or standalone. If you import it by adding a script tag you do not have to do anything else. It will automatically be bound to the global scope.
var TextEncodingShim = require('text-encoding-shim');
var TextEncoder = TextEncodingShim.TextEncoder;
var TextDecoder = TextEncodingShim.TextDecoder;
define([TextEncodingShim], function() {
//...
});
import { TextEncoder, TextDecoder } from 'text-encoding-shim';
var uint8array = new TextEncoder('utf-8').encode(string);
var string = new TextDecoder('utf-8').decode(uint8array);
If a native implementation is available it will always be handled preferred to this polyfill. Just like native implementations of Mozilla Firefox or Google Chrome, this library only supports UTF-8 encoding. This makes it so fast. If you need additional encodings, check out this more advanced polyfill.
FAQs
Simple lightweight polyfill for the Text Encoding API, supporting UTF-8 only
The npm package text-encoding-shim receives a total of 4,026 weekly downloads. As such, text-encoding-shim popularity was classified as popular.
We found that text-encoding-shim demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.