Skip to content

Commit

Permalink
fix: xcloud & login
Browse files Browse the repository at this point in the history
  • Loading branch information
Geocld committed Oct 6, 2024
1 parent ac2e047 commit 6099974
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 33 deletions.
56 changes: 43 additions & 13 deletions app/background.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/preload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 28 additions & 14 deletions main/helpers/titlemanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export default class TitleManager {
.then(res => {
if (res.status === 200) {
officialTitles = res.data.Products;
console.log('officialTitles:', officialTitles);
}
resolve(officialTitles);
})
Expand All @@ -85,40 +84,55 @@ export default class TitleManager {
getGamePassProducts(titles) {
return new Promise((resolve, reject) => {
const productIdQueue = [];
const v2TitleMap = {};
if (!Array.isArray(titles)) {
resolve([]);
}
titles.forEach(title => {
if (title.details && title.details.productId) {
productIdQueue.push(title.details.productId);
v2TitleMap[title.details.productId] = title;
}
});

// Get officialTitles
this.getOfficialTitles().then((officialTitles: any) => {
const mergeProductIds = [
...new Set([...productIdQueue, ...officialTitles]),
];

this._http.post('catalog.gamepass.com', '/v3/products?market=US&language=en-US&hydration=RemoteHighSapphire0', { // RemoteLowJade0
this._http.post('catalog.gamepass.com', '/v3/products?market=US&language=en-US&hydration=RemoteLowJade0', { // RemoteLowJade0
'Products': mergeProductIds,
}, {
'ms-cv': 0,
'calling-app-name': 'Xbox Cloud Gaming Web',
'calling-app-version': '24.17.63',

}).then((result:any) => {
const products = result.Products;
const mergedTitles = [];
for (const key in products) {
mergedTitles.push({
productId: key,
...products[key],
});
}).then((result: any) => {
if (result && result.Products) {
const products = result.Products;
const mergedTitles = [];
for (const key in products) {
if (v2TitleMap[key]) {
mergedTitles.push({
productId: key,
...products[key],
...v2TitleMap[key],
});
} else {
mergedTitles.push({
productId: key,
...products[key],
});
}
}
mergedTitles.sort((a, b) =>
a.ProductTitle.localeCompare(b.ProductTitle),
);
resolve(mergedTitles);
} else {
resolve([]);
}
mergedTitles.sort((a, b) =>
a.ProductTitle.localeCompare(b.ProductTitle),
);
resolve(mergedTitles);
}).catch(e => {
console.log('getGamePassProducts error:', e);
reject(e);
Expand Down
22 changes: 20 additions & 2 deletions main/xal/xal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ export default class Xal {
return crypto.randomBytes(bytes).toString('base64url')
}

getDeviceTokenHack() {
console.log('getDeviceTokenHack...')
return new Promise<DeviceToken>((resolve, reject) => {
this.getDeviceToken().then(deviceToken => {
console.log('getDeviceToken success:', deviceToken)
resolve(deviceToken)
})
.catch(error => {
if (error.statuscode == 400) {
console.log('device token get error, retry...')
return this.getDeviceTokenHack().then(resolve).catch(reject)
} else {
reject(error)
}
})
})
}

getDeviceToken() {
console.log('getDeviceToken...')
return new Promise<DeviceToken>((resolve, reject) => {
Expand Down Expand Up @@ -444,7 +462,7 @@ export default class Xal {

try {
const userToken = await this.refreshUserToken(curUserToken)
const deviceToken = await this.getDeviceToken()
const deviceToken = await this.getDeviceTokenHack()
const sisuToken = await this.doSisuAuthorization(userToken, deviceToken)

tokenStore.setUserToken(userToken)
Expand Down Expand Up @@ -508,7 +526,7 @@ export default class Xal {
}

async getRedirectUri(){
const deviceToken = await this.getDeviceToken()
const deviceToken = await this.getDeviceTokenHack()
const codeChallange = await this.getCodeChallange()
const state = this.getRandomState()
const sisuAuth = await this.doSisuAuthentication(deviceToken, codeChallange, state)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "xstreaming",
"description": "xstreaming",
"version": "1.0.2",
"version": "1.0.3",
"author": "Geocld <[email protected]>",
"main": "app/background.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion renderer/components/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function ActionBar(props) {
}

{
props.connectState === CONNECTED && (
(props.connectState === CONNECTED && props.type !== 'cloud') && (
<DropdownItem key="longPressNexus" onClick={handleLongPressNexus}>
{t("Long press Nexus")}
</DropdownItem>
Expand Down
3 changes: 2 additions & 1 deletion renderer/components/TitleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ function TitleModal(props) {
};

const handleStartGame = () => {
console.log("titleItem:", titleItem);
// console.log("titleItem:", titleItem);
const titleId = titleItem.titleId || titleItem.XCloudTitleId;
console.log("titleId:", titleId)
router.push({
pathname: `/${locale}/stream`,
query: { serverid: XCLOUD_PREFIX + titleId }
Expand Down
4 changes: 4 additions & 0 deletions renderer/pages/[locale]/stream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function Stream() {
const [showFailed, setShowFailed] = useState(false);
const [showWarning, setShowWarning] = useState(false);
const [showDisplay, setShowDisplay] = useState(false);
const [streamingType, setStreamingType] = useState('');
const connectStateRef = useRef("");
const keepaliveInterval = useRef(null);
const streamStateInterval = useRef(null);
Expand All @@ -41,6 +42,8 @@ function Stream() {
serverId = serverId.split("_")[1];
}

setStreamingType(streamType)

if (xPlayer !== undefined) {
xPlayer.bind();

Expand Down Expand Up @@ -418,6 +421,7 @@ function Stream() {
<>
<ActionBar
connectState={connectState}
type={streamingType}
onDisconnect={onDisconnect}
onTogglePerformance={() => {
setShowPerformance(!showPerformance);
Expand Down
1 change: 1 addition & 0 deletions renderer/pages/[locale]/xcloud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function Xcloud() {
}
}
});
console.log("_recentTitles:", _recentTitles);
setRecentNewTitles(_recentTitles);
setLoading(false);
});
Expand Down

0 comments on commit 6099974

Please sign in to comment.