Open-source Xbox-inspired desktop launcher for Xodus on Linux
TypeScript
[source-only] fix(dlc): distinguish bundle and license-only content offers
Dominik Svoboda89b9e809106c
diff --git a/src/main/game-content.test.ts b/src/main/game-content.test.tsindex dafded2..1245311 100644--- a/src/main/game-content.test.ts+++ b/src/main/game-content.test.ts@@ -74,6 +74,19 @@ it('offers a real backend license check for a bundle child without manufacturingexpect(result.packages.map(pkg=>pkg.productId)).toEqual([OWN]);expect(result.items[1].status).toBe('unlicensed');});+it('marks bundle-included license-only add-ons as included, not unlicensed (#324)', () => {+ const data = { Products: [+ { ...product(BASE, 'Game'), DisplaySkuAvailabilities: [sku([{ ...pkg('Example.Base_hash'), MainPackageFamilyNameForDlc: '' }])] },+ { ...product(OWN), DisplaySkuAvailabilities: [{ Sku: { Properties: { IsTrial: false, Packages: null, BundledSkus: [{ BigId: PAID }] } } }] },+ { ...product(GP), DisplaySkuAvailabilities: [{ Sku: { Properties: { IsTrial: false, Packages: [] } } }] },+ { ...product(PAID), DisplaySkuAvailabilities: [{ Sku: { Properties: { IsTrial: false, Packages: [] } } }] },+ ] };+ const result = contentOffers(contentManifest(baseXml), data, {}, [OWN, GP]);+ expect(result.items.map(item => [item.productId, item.status, item.access])).toEqual([+ [OWN, 'bundle', undefined], [GP, 'license-only', undefined], [PAID, 'unlicensed', undefined],+ ]);+ expect(result.packages).toEqual([]);+});it('rejects unsupported architectures, formats, trial SKUs, ambiguous packages and foreign base families', () => {for (const change of [{ PackageFormat: 'APPX' }, { Architectures: ['arm64'] }, { PlatformDependencies: [] }, { MainPackageFamilyNameForDlc: 'Other.Base_hash' }, { ContentId: 'https://evil.invalid/download' }]) {const data = catalog(); Object.assign(data.Products[1].DisplaySkuAvailabilities[0].Sku.Properties.Packages[0], change);diff --git a/src/main/game-content.ts b/src/main/game-content.tsindex 964de4b..76f6818 100644--- a/src/main/game-content.ts+++ b/src/main/game-content.ts@@ -218,17 +218,23 @@ export function contentOffers(base: Manifest, catalog: unknown, access: Access,const product = byId.get(id);const title = product?.LocalizedProperties?.find((row: RecordValue) => typeof row?.ProductTitle === 'string')?.ProductTitle?.slice(0, 300) || id;const licensed = access[id];+ const skus = contentSkus(product ?? {});+ const bundled = product?.ProductType === 'Durable' && skus.some(props => Array.isArray(props.BundledSkus) && props.BundledSkus.length);+ const licenseOnly = product?.ProductType === 'Durable' && skus.length && skus.every(props => (props.PackagesDeclared ?? Object.hasOwn(props, 'Packages'))+ && (props.Packages === null || Array.isArray(props.Packages) && props.Packages.length === 0));if (!licensed) {const pkg = verify.includes(id) ? packageChoice(base, baseProduct, product) : undefined;if (pkg) { selected.push(pkg); return { productId: id, title, status: 'verify', downloadBytes: pkg.downloadBytes,note: 'Included in an active offer. Xodus must verify this add-on license before downloading.' }; }+ if (verify.includes(id) && bundled)+ return { productId: id, title, status: 'bundle', note: 'Included in an active offer. Its related add-ons are listed separately.' };+ if (verify.includes(id) && licenseOnly)+ return { productId: id, title, status: 'license-only', note: 'Included in an active offer. No download is required; the game must verify this license through the runtime.' };return { productId: id, title, status: 'unlicensed', note: 'No active account license was verified.' };}- const skus = contentSkus(product ?? {});- if (product?.ProductType === 'Durable' && skus.some(props => Array.isArray(props.BundledSkus) && props.BundledSkus.length))+ if (bundled)return { productId: id, title, access: licensed, status: 'bundle', note: 'Content bundle. Its related add-ons are listed separately.' };- if (product?.ProductType === 'Durable' && skus.length && skus.every(props => (props.PackagesDeclared ?? Object.hasOwn(props, 'Packages'))- && (props.Packages === null || Array.isArray(props.Packages) && props.Packages.length === 0)))+ if (licenseOnly)return { productId: id, title, access: licensed, status: 'license-only', note: 'No download required. The game must verify this license through the runtime.' };const pkg = packageChoice(base, baseProduct, product);if (!pkg) return { productId: id, title, access: licensed, status: 'unsupported', note: 'No unambiguous related PC MSIXVC content package was verified.' };diff --git a/src/renderer/game-content.test.tsx b/src/renderer/game-content.test.tsxindex 2476320..2da8e7f 100644--- a/src/renderer/game-content.test.tsx+++ b/src/renderer/game-content.test.tsx@@ -33,3 +33,13 @@ it('shows package-free licenses and bundles without pretending that there are fiexpect(html).toContain('No download required');expect(html).toContain('Content bundle');expect(html).toContain('Other access');expect(html).not.toContain('<button');expect(html).not.toContain('Unsupported package');});++it('renders bundle-included license-only rows as unverified with no download, not owned or unavailable', () => {+ const html = renderToStaticMarkup(<ContentList plan={{ ...plan, items: [+ { productId: 'BUNDLE', title: 'Digital Deluxe add-on', status: 'bundle', note: 'Included in an active offer. Its related add-ons are listed separately.' },+ { productId: 'PASS', title: 'Season Pass', status: 'license-only', note: 'Included in an active offer. No download is required; the game must verify this license through the runtime.' },+ ] }} disabled={false} install={() => { throw Error('must not install'); }} />);+ expect(html.match(/License not verified/g)).toHaveLength(2);+ expect(html).toContain('Content bundle'); expect(html).toContain('No download required');+ expect(html).not.toContain('Owned'); expect(html).not.toContain('Unavailable'); expect(html).not.toContain('<button');+});