-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sizing limits for custom UI #2199
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2199 +/- ##
=======================================
Coverage 96.58% 96.59%
=======================================
Files 332 332
Lines 7564 7582 +18
Branches 1171 1175 +4
=======================================
+ Hits 7306 7324 +18
Misses 258 258 ☔ View full report in Codecov by Sentry. |
import { nanoid } from 'nanoid'; | ||
|
||
import { constructState } from './utils'; | ||
|
||
const MAX_UI_CONTENT_SIZE = 256000; // 250 kb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This limit can probably be larger if we want it to be.
packages/snaps-utils/src/ui.ts
Outdated
*/ | ||
export function getTotalTextLength(component: Component): number { | ||
const { type } = component; | ||
if (type === NodeType.Panel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rows can contain text components too.
packages/snaps-controllers/src/interface/SnapInterfaceController.ts
Outdated
Show resolved
Hide resolved
b43b7ca
to
636d88c
Compare
…er.ts Co-authored-by: Maarten Zuidhoorn <[email protected]>
636d88c
to
ebadbd3
Compare
Adds sizing limits for custom UI input. Previously these inputs were only validated to have the proper formatting.
This PR adds logic to validate that the UI components provided by the Snap are within reasonable length. Both the entire UI component object is serialized to JSON and validated that it's total size is less than 250 kb. Also the total text used in the UI component is validated to be less than 50 kb.