Files
WT-Offline/packages/blk/src/stable-guid.ts
T

18 lines
922 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 server 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}`;
}