# Plan limits और pricing rules को अपने public bundle से बाहर रखें

Client JavaScript में plan limits, quota thresholds और feature-flag rules आपके commercial model के specification की तरह पढ़े जाते हैं। उन्हें पढ़ने योग्य न रहने देने का तरीका, और फिर भी क्या observable रहता है।

Source: https://www.afterpack.dev/hi/docs/use-cases/pricing-logic

Plan limits, quota thresholds और feature-flag rules आमतौर पर client bundle में पहुँच जाते हैं, जहाँ कोई competitor या customer उन्हें सीधे फ़ाइल से पढ़ सकता है।

## Plain JavaScript में आपकी pricing table एक spec की तरह पढ़ी जाती है

Pricing table, quota map और feature flags की सूची, जब plain JavaScript में हों, तो आपके commercial model के documentation की तरह पढ़ी जाती हैं। कोई भी bundle खोलकर देख सकता है कि आपके tiers कहाँ बँटते हैं, upsell किससे trigger होता है, और कौन-से flags किन features को gate करते हैं।

उस bundle पर एक coding agent का एक pass बिखरे values को एक व्यवस्थित spec में बदल देता है। उस spec की नकल की जा सकती है, support ticket में उस पर बहस की जा सकती है, या आपके ध्यान में आने से पहले ही किसी limit को बायपास करने में उसका इस्तेमाल हो सकता है।

## Encoded values, दोबारा लिखी गई संरचना

किसी भी positive [`complexity`](https://www.afterpack.dev/hi/docs/config#complexity) target पर string literals encode होते हैं, इसलिए plan के नाम, flag keys और messages आपकी serve की गई फ़ाइल में पढ़ने लायक text नहीं रहते। `light` पर numbers पढ़े जा सकते हैं: price table या quota threshold सीधे अंकों में दिखती है। `medium` और ऊपर, ज़्यादातर integers encode होते हैं और उनके आसपास की संरचना भी दोबारा लिखी जाती है। Output पर मेहनत करने वाला reader एक equivalent computation पाता है और उससे उसे फिर बनाना पड़ता है कि आपके rules का मतलब क्या था।

Rotation ही recover की गई copy को उपयोगी बने रहने से रोकता है। हर release पर एक नया [seed](https://www.afterpack.dev/hi/docs/config#seed) का मतलब है कि किसी ने पिछली बार जो भी reconstruct किया, वह एक ऐसी build का वर्णन करता है जिसे आप अब serve नहीं करते।

## आपके rules वाले module पर target बढ़ाएँ

पूरे bundle को [preset](https://www.afterpack.dev/hi/docs/presets) की सीढ़ी पर एक पायदान ऊपर ले जाएँ, या जब किसी preset की granularity फ़िट न हो तो target सीधे सेट करें:

```json
{
  "preset": "medium",
  "complexity": 40
}
```

केवल आपके rules वाले module को mark करने के लिए, एक directive इस्तेमाल करें। [Directives](https://www.afterpack.dev/hi/docs/directives) [Pro](https://www.afterpack.dev/hi/docs/tiers) builds पर प्रभावी होते हैं।

```ts
/* @afterpack preset=extreme */
export function resolveQuota(plan: Plan, usage: Usage): number {
  return TIER_LIMITS[plan.tier] - usage.consumed;
}
/* @afterpack end */
```

[`strings.leaks.max`](https://www.afterpack.dev/hi/docs/config#strings-leaks-max) "कोई पढ़ने योग्य literal नहीं बचा" को आँख से जाँचने वाली चीज़ के बजाय एक build gate बना देता है। Failure [`DIAG_SURVIVING_READABLE_LITERAL`](https://www.afterpack.dev/hi/docs/diagnostics) का नाम बताता है और उस literal की ओर इशारा करता है जो बच निकला।

## कोई literal बचे तो build fail करें

CI में [`--strings.leaks.max=0`](https://www.afterpack.dev/hi/docs/config#strings-leaks-max) के साथ build करें और nonzero exit को failed build मानें। फिर [Protection Map](https://www.afterpack.dev/hi/docs/protection-map) खोलें और जाँचें कि rules module उसी target पर रंगा है जो आपने उसके लिए सेट किया था।

## आप कुछ भी ship करें, क्या observable रहता है

Build को rotate करने से आपके rules की scrape की गई copy अगली release पर पुरानी पड़ जाती है, और यही हिस्सा काम का है। जो values केवल bundle के अंदर पढ़े जाने के लिए मौजूद हैं, वे यहाँ scope में हैं; आपकी UI जो price दिखाती है या आपकी API जो limit लौटाती है, वह bundle के रूप से स्वतंत्र observable रहता है, इसलिए page पर दिखने वाली हर चीज़ को public मानें और हर limit server पर लागू करें।

## आगे

- [Threat model](https://www.afterpack.dev/hi/docs/threat-model): एक static reader क्या recover कर सकता है और क्या नहीं।
- [Presets](https://www.afterpack.dev/hi/docs/presets): पूरी सीढ़ी और हर स्तर का complexity target।
- [Protection Map](https://www.afterpack.dev/hi/docs/protection-map): पुष्टि करें कि rules module को वही treatment मिला जो आपने configure किया था।
