Skip to content

feat: [ENG-36536] tokens ts and new architecture#75

Open
cesaroeduardo wants to merge 3 commits intomainfrom
ENG-36536-tokens-ts-and-new-architecture
Open

feat: [ENG-36536] tokens ts and new architecture#75
cesaroeduardo wants to merge 3 commits intomainfrom
ENG-36536-tokens-ts-and-new-architecture

Conversation

@cesaroeduardo
Copy link
Contributor

@cesaroeduardo cesaroeduardo commented Feb 19, 2026

Jira: https://aziontech.atlassian.net/browse/ENG-36536

Summary

  • Implements a new, market-aligned design-tokens architecture with white-label brand tokens and semantic tokens.
  • Standardizes token consumption to be Tailwind-oriented, reducing onboarding/learning curve and making usage more consistent across products.
  • Includes fixes to ensure downstream consumers can reliably use the updated tokens.

Problems & Solutions

  • Problem: Existing token organization made it harder to scale, white-label, and onboard new contributors.
    Solution: Created new tokens following a market standard proposal, introducing brand (white-label) tokens and a clearer primitives/semantic separation.
  • Problem: Token consumption varied across consumers, increasing cognitive load and the chance of inconsistent usage.
    Solution: Shifted semantics to be fully oriented for Tailwind usage, providing a predictable, standardized way to consume tokens.
  • Problem: Architecture changes can break downstream integrations.
    Solution: Added consumption fixes to keep consumers stable while migrating to the new structure.

Changes Made

  • Added new tokens following a market-aligned proposal:
  • Introduced white-label brand tokens to support brand theming and customization.
  • Introduced semantic tokens designed for direct, consistent usage via Tailwind (reduced learning curve + standardized consumption patterns).
  • Reworked token structure across primitives and semantics, plus build outputs to reflect the new organization.
  • Applied fixes to improve token consumption and prevent regressions in downstream projects.

Testing Checklist

  • Consume tokens in site and validate the new tokens in dark and light themes.
  • Consume tokens in console-kit and validate the new tokens in dark and light themes.
  • Consume tokens in docs and validate the new tokens in dark and light themes.
  • Confirm no conflicts (e.g., duplicated token names, unexpected overrides, incorrect CSS vars/Tailwind mapping) across integrations.

deepMerge(target[key], value);
return;
}
target[key] = value;

Check warning

Code scanning / CodeQL

Prototype-polluting function Medium

Properties are copied from
source
to
target
without guarding against prototype pollution.

Copilot Autofix

AI 8 days ago

In general, to fix prototype pollution in deep-merge / deep-assignment helpers, you must prevent writes to dangerous keys (__proto__, constructor, prototype) and/or ensure that you only recurse into properties that are own properties of the destination object, not arbitrary prototype chains. The simplest and least intrusive fix here is to filter out dangerous keys before assigning them to target.

For this specific deepMerge in scripts/figma-sync.js, the best fix without changing existing functionality is to add an early-continue guard inside the Object.entries(source).forEach loop that skips any key that could lead to prototype pollution. That means checking key and ignoring "__proto__", "constructor", and "prototype" before we touch target[key]. This preserves all existing behavior for normal keys, avoids changing call sites, and doesn’t require new imports or external libraries. The changes are localized to the deepMerge function (lines 52–65).

Concretely:

  • Inside the forEach(([key, value]) => { ... }) callback, right after we obtain key and value, add:

    if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
      return;
    }
  • Leave the rest of the logic intact so that merging semantics for safe keys are unchanged.

No new methods or imports are required.

Suggested changeset 1
scripts/figma-sync.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/figma-sync.js b/scripts/figma-sync.js
--- a/scripts/figma-sync.js
+++ b/scripts/figma-sync.js
@@ -52,6 +52,10 @@
 const deepMerge = (target, source) => {
   if (!source || typeof source !== 'object') return target;
   Object.entries(source).forEach(([key, value]) => {
+    // Guard against prototype pollution by blocking dangerous keys.
+    if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
+      return;
+    }
     if (value && typeof value === 'object' && !Array.isArray(value)) {
       if (!target[key] || typeof target[key] !== 'object') {
         target[key] = {};
EOF
@@ -52,6 +52,10 @@
const deepMerge = (target, source) => {
if (!source || typeof source !== 'object') return target;
Object.entries(source).forEach(([key, value]) => {
// Guard against prototype pollution by blocking dangerous keys.
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
return;
}
if (value && typeof value === 'object' && !Array.isArray(value)) {
if (!target[key] || typeof target[key] !== 'object') {
target[key] = {};
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cesaroeduardo faz sentido o que o github apontou?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants