Limits and security
A custom widget runs in a sandbox: an isolated frame with no access to your Streamed account. This page lists what that rules out, how to handle text from viewers, and every limit.
The sandbox
The widget is a page with no origin of its own (an "opaque" origin). It can run scripts, load files from the internet and play sound, but:
- No browser storage.
localStorage,sessionStorage,indexedDBand cookies throw an error. Use the store. - No dialogs or pop-ups.
alert(),confirm(),prompt(),window.open()and forms do nothing. - Only HTTPS. Scripts, styles, fonts, images, sounds, videos,
fetch, WebSockets (wss:) and frames must come fromhttps:addresses (images, sounds and fonts may also bedata:, images and soundsblob:). Plainhttp:is blocked. Your media from the gallery always works. - Cross-origin requests.
fetchis sent from the originnull, without cookies. It works with APIs that allow every origin (Access-Control-Allow-Origin: *). - No referrer is sent, so the widget's address does not leak to other sites.
- No camera, microphone, location, screen capture, USB or payment APIs.
- It cannot reach the page around it, other widgets, or Streamed: the only way out is
SE_API.
Untrusted text
Names and messages come from viewers. A name like <img src=x onerror=…> runs code if you insert it as HTML. In the sandbox that cannot reach your account, but it can still take over what your overlay shows on stream.
- Insert
name,message,data.text,data.displayName,senderand anything from other sites withtextContent(jQuery:.text()), neverinnerHTML(jQuery:.html(),.append(string)). renderedTextof a chat message is the one exception: Streamed has escaped it, so it is safe withinnerHTML.- Do not build HTML strings out of event data, and do not put event data into
style,hreforsrcwithout checking it.
// Wrong: a viewer's name becomes HTML
el.innerHTML = `<b>${event.name}</b> followed!`;
// Right
const b = document.createElement('b');
b.textContent = event.name;
el.replaceChildren(b, ' followed!');Who can see what
The address of an overlay or layer works like a password: anyone who has it can open the widget, read your variables, and read and change the store of your custom widgets. Never put secrets (API keys, passwords) into a widget's code or fields.
Limits
| What | Limit |
|---|---|
| HTML, CSS, JS | 1 MB each |
| The whole widget | 3.5 MB |
| Fields | 200 |
| Values in Data | 300 |
| A text value | 64 KB |
| A list value | 50 items |
| Dropdown options | 1000 |
| A label | 256 characters |
| A group name | 128 characters |
| A store value | 64 KB |
| Store keys per account | 100 |
| Store writes per widget | 10 per 10 seconds |
| A store call without answer | gives up after 10 seconds |
| Variables per account | 100 |
| A variable's value | 500 characters |
| A variable's name | 32 characters |
Recent events (recents, -recent) |
25 |
| Events counted at load | 200 (2000 within the current stream) |
| Events waiting while the widget loads | 100 |
| An imported file | 2 MB |