Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/DivineoBunker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DivineoBunker:
def __init__(self):
# 🛡️ Configuración Maestra (abvetos.com)
self.secret_key = os.getenv("LVT_SECRET_KEY", "DEVELOPMENT_SECRET_DO_NOT_USE_IN_PROD")
self.secret_key_bytes = self.secret_key.encode() # Pre-encoded for performance
self.patent = "PCT/EP2025/067317"
self.algorithm_v = "V10_Divineo_Shopify_Final"

Expand Down Expand Up @@ -35,7 +36,8 @@ def _verify_auth(self, user_id, token):
try:
ts, sig = token.split('.')
if int(time.time()) - int(ts) > 600: return False # Ventana 10 min
expected = hmac.new(self.secret_key.encode(), f"{user_id}:{ts}".encode(), hashlib.sha256).hexdigest()
# Use pre-encoded key to save CPU cycles on every request
expected = hmac.new(self.secret_key_bytes, f"{user_id}:{ts}".encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(sig, expected)
except: return False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a bare except clause is generally discouraged. It catches all exceptions, including system-exiting exceptions like SystemExit and KeyboardInterrupt, which can hide serious problems and make debugging difficult. It's better to catch specific exceptions that you expect might occur, or at least except Exception:.

Suggested change
except: return False
except Exception: return False


Expand Down
Binary file modified backend/__pycache__/jules_engine.cpython-312.pyc
Binary file not shown.
Binary file modified backend/__pycache__/main.cpython-312.pyc
Binary file not shown.
Binary file modified backend/__pycache__/models.cpython-312.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@

# 🛡️ Configuración Maestra (abvetos.com) - Secrets moved to environment variables
SECRET_KEY = os.getenv("LVT_SECRET_KEY", "DEVELOPMENT_SECRET_DO_NOT_USE_IN_PROD")
SECRET_KEY_BYTES = SECRET_KEY.encode() # Pre-encoded for performance
PATENT = "PCT/EP2025/067317"

def verify_auth(user_id: str, token: str) -> bool:
try:
ts, sig = token.split('.')
if int(time.time()) - int(ts) > 600: return False # Ventana 10 min
expected = hmac.new(SECRET_KEY.encode(), f"{user_id}:{ts}".encode(), hashlib.sha256).hexdigest()
# Use pre-encoded key to save CPU cycles on every request
expected = hmac.new(SECRET_KEY_BYTES, f"{user_id}:{ts}".encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(sig, expected)
except: return False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a bare except clause is generally discouraged. It catches all exceptions, including system-exiting exceptions like SystemExit and KeyboardInterrupt, which can hide serious problems and make debugging difficult. It's better to catch specific exceptions that you expect might occur, or at least except Exception:.

Suggested change
except: return False
except Exception: return False


Expand All @@ -50,7 +52,7 @@ def calculate_fit(user_waist: float, item_id: str):
return is_perfect, round(fit_index, 3), item

@app.post("/api/recommend")
async def recommend_garment(scan: UserScan, garment_id: str = "BALMAIN_SS26_SLIM"):
def recommend_garment(scan: UserScan, garment_id: str = "BALMAIN_SS26_SLIM"):
# 1. Seguridad y Handshake
if not verify_auth(scan.user_id, scan.token):
raise HTTPException(status_code=403, detail="Acceso restringido al búnker.")
Expand Down
1 change: 0 additions & 1 deletion backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ class Garment(BaseModel):
}
}

GARMENT_DB = list(SHOPIFY_INVENTORY.values())
Binary file modified backend/tests/__pycache__/test_main.cpython-312-pytest-9.0.2.pyc
Binary file not shown.
12 changes: 10 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class TryOnYouBunker {
this.selectedGarmentId = "BALMAIN_SS26_SLIM";
this.version = "11.0.0";
this.biometricAnalyzer = new MediaPipeBiometricAnalyzer();
// Cache frequently accessed DOM elements
this.resultContainer = null;
this.resultText = null;
this.shopifyInventory = {
"BALMAIN_SS26_SLIM": {
"name": "Balmain Slim-Fit Jeans",
Expand All @@ -57,6 +60,9 @@ class TryOnYouBunker {
'background: #C5A46D; color: #141619; font-weight: bold; padding: 2px 4px;',
'background: #141619; color: #C5A46D; padding: 2px 4px;');

this.resultContainer = document.getElementById('jules-result');
this.resultText = document.getElementById('recommendation-text');
Comment on lines +63 to +64
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Caching DOM elements is a great performance enhancement. However, if getElementById returns null because the element doesn't exist in the DOM when init() is called, it will lead to a TypeError later in handleDivineoExecution. It would be more robust to verify that these elements were found and log an error if they are missing, which helps in debugging.

Suggested change
this.resultContainer = document.getElementById('jules-result');
this.resultText = document.getElementById('recommendation-text');
this.resultContainer = document.getElementById('jules-result');
this.resultText = document.getElementById('recommendation-text');
if (!this.resultContainer || !this.resultText) {
console.error('Bunker UI Error: Critical display elements #jules-result or #recommendation-text not found in DOM during initialization.');
}


this.setupEventListeners();
this.applyLuxuryTransitions();
this.initializeBiometrics();
Expand Down Expand Up @@ -105,8 +111,8 @@ class TryOnYouBunker {
const formData = new FormData(event.target);
const eventType = formData.get('event_type');

const resultContainer = document.getElementById('jules-result');
const resultText = document.getElementById('recommendation-text');
const resultContainer = this.resultContainer;
const resultText = this.resultText;
const submitBtn = event.target.querySelector('button[type="submit"]');

try {
Expand Down Expand Up @@ -210,6 +216,8 @@ class TryOnYouBunker {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
// Unobserve to save resources after animation is triggered
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
Expand Down
Loading