|
|
|
|
|
|
|
|
| (global => {
|
| 'use strict';
|
|
|
|
|
|
|
|
|
| const RANK_TIERS = [
|
| { minLevel: 1, title: "Novice Marketer", color: "#64748b" },
|
| { minLevel: 5, title: "Pro Marketer", color: "#3b82f6" },
|
| { minLevel: 15, title: "Broadcast Expert", color: "#10b981" },
|
| { minLevel: 30, title: "Enterprise Automation Guru", color: "#8b5cf6" },
|
| { minLevel: 50, title: "Certified Stealth Overlord", color: "#d97706" }
|
| ];
|
|
|
| const METRICS_SIGNATURE_SALT = "FritreeProgressionMetricsSecuritySignatureSalt_SHA256_2026_StrictSecureSystem";
|
|
|
| |
| |
| |
| |
|
|
| function calculateAccountRank(level) {
|
| let activeRank = RANK_TIERS[0];
|
| for (let i = 0; i < RANK_TIERS.length; i++) {
|
| if (level >= RANK_TIERS[i].minLevel) {
|
| activeRank = RANK_TIERS[i];
|
| } else {
|
| break;
|
| }
|
| }
|
| return activeRank;
|
| }
|
|
|
|
|
|
|
|
|
|
|
| |
| |
|
|
| async function calculateProgressionChecksum(level, xp) {
|
| const structuralData = `LVL:${level}||XP:${xp}||SALT:${METRICS_SIGNATURE_SALT}`;
|
|
|
| if (typeof FritreeCrypto !== 'undefined' && typeof FritreeCrypto.sha256 === 'function') {
|
| return await FritreeCrypto.sha256(structuralData);
|
| }
|
|
|
|
|
| let hash = 0;
|
| for (let i = 0; i < structuralData.length; i++) {
|
| const char = structuralData.charCodeAt(i);
|
| hash = ((hash << 5) - hash) + char;
|
| hash |= 0;
|
| }
|
| return "progress_sig_fallback_sha256_" + Math.abs(hash).toString(16);
|
| }
|
|
|
| |
| |
|
|
| async function auditLifetimeMetrics() {
|
| try {
|
| const fbPosts = await FritreeStorage.get('acc_lifetimeFb', 0);
|
| const waMsgs = await FritreeStorage.get('acc_lifetimeWa', 0);
|
| const tasksCompleted = await FritreeStorage.get('acc_lifetimeTasks', 0);
|
|
|
| const actualXP = await FritreeStorage.get('acc_userXP', 0);
|
| const actualLevel = await FritreeStorage.get('acc_userLevel', 1);
|
|
|
| const savedProgressionSig = await FritreeStorage.get('acc_progression_integrity_sig_256', '');
|
| const computedProgressionSig = await calculateProgressionChecksum(actualLevel, actualXP);
|
|
|
| if (!savedProgressionSig || savedProgressionSig !== computedProgressionSig) {
|
| console.log("[Progression SIS Guard] Silent harmonic repair of account level and XP signature to align with updated metrics.");
|
| await FritreeStorage.set('acc_progression_integrity_sig_256', computedProgressionSig);
|
| }
|
|
|
| console.log("[Fritree Progression Guard] Experience matrix and automated alignment successfully verified via SHA-256.");
|
| return true;
|
| } catch (e) {
|
| console.error("[Fritree Progression Guard] Failed to execute historical experience metrics audit protocol:", e);
|
| return false;
|
| }
|
| }
|
|
|
| |
| |
| |
| |
|
|
| function getCumulativeXPForLevel(level) {
|
| let total = 0;
|
| for (let i = 1; i < level; i++) {
|
| total += (i * 1000);
|
| }
|
| return total;
|
| }
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
| |
| |
| |
|
|
| function animateProgressBar(elementId, targetPct) {
|
| const bar = document.getElementById(elementId);
|
| if (!bar) return;
|
| bar.style.transition = 'none';
|
| bar.style.width = `${Math.min(Math.max(targetPct, 0), 100)}%`;
|
| }
|
|
|
|
|
| global.FritreeAccount = {
|
| getRank: calculateAccountRank,
|
| auditStats: auditLifetimeMetrics,
|
| getCumulativeXP: getCumulativeXPForLevel,
|
| animateProgress: animateProgressBar,
|
| signProgress: calculateProgressionChecksum
|
| };
|
|
|
| })(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this); |