Files
WT-Offline/packages/blk/src/stable-guid.ts
T
N0VAN0M4LY a73635407d feat(store): add item deep links and marketplace coupon resale
Register bundle GUIDs at build time and return local store item URLs.
Route marketplace item links to the requested coupon. Update vehicle
and cosmetic prices from the marketplace snapshot and support selling
coupons back to the system at the configured fee.

Type checking, an isolated build, and local service checks passed.
In-game acceptance is pending.
2026-11-26 07:12:38 +08:00

19 lines
926 B
TypeScript

/**
* Deterministic GUID derived from a text (SHA-1, formatted 8-4-4-4-12, upper case). The build
* registers `stableGuid(<entitlement>)` for the offline vehicle packs in config/gui.blk
* `bundles/guid`, and the local service gives the same GUID to the same store product, so the
* game's `getBundleId` → `get_url_for_purchase` → `item_info.php` chain finds the pack
*. One definition, used by both packages.
*/
import { createHash } from 'node:crypto';
export function stableGuid(text: string): string {
const hex = createHash('sha1').update(`wto-bundle:${text}`).digest('hex').toUpperCase();
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
}
/** Entitlement name of a single-vehicle offline pack (store-catalogue.ts and the build agree on it). */
export function singleVehiclePackId(vehicle: string): string {
return `wto_pack_${vehicle}`;
}