Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

Commit 68587b6

Browse files
committed
refresh Steam session when expired
1 parent 4509c96 commit 68587b6

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66
This project does not adhere to Semantic Versioning.
77

88
## [Unreleased]
9+
### Added
10+
* Steam sessions will now be refreshed if required
11+
912
### Docs
1013
* Add readme
1114

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ The extension loads an [offscreen Leetify page in the background](src/offscreen/
1414

1515
Then [it requests the GCPD pages](src/gcpd.ts) for Scrimmage (which includes CS2LT matches) and [extracts matches from the response](src/offscreen/dom-parser.ts), one after another, until it doesn't find any more matches that still have a demo download link. It [sends the demo download links and the timestamps of each match to Leetify](src/leetify-match-uploader.ts) (via the access token from before), which saves all new matches as manual uploads. They'll show up on the [Data Sources](https://leetify.com/app/data-sources) page and will be queued; after a bit of waiting (usually no more than a few minutes), they'll also show up in your [Match History](https://leetify.com/app/matches) on Leetify (but not on the Dashboard or Profile).
1616

17+
If your Steam session has expired and the extension can't actually load the GCPD page, it'll try to refresh your session.
18+
1719
After Scrimmage, the extension will again request GCPD pages for Wingman, filter out ranked or unranked matches ([if configured to do so](src/view/options.ts)), and send the found matches to Leetify.
1820

1921
You can independently enable or disable: the sync every 15 minutes, the sync on Leetify visits, and on GCPD visits.

manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
"host_permissions": [
5959
"https://leetify.com/*",
60-
"https://steamcommunity.com/my/gcpd/730"
60+
"https://steamcommunity.com/my/gcpd/730",
61+
"https://login.steampowered.com/jwt/refresh"
6162
]
6263
}

src/gcpd.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@ class Gcpd {
3737
url.searchParams.set('tab', tab);
3838
if (continueToken) url.searchParams.set('continue_token', continueToken);
3939

40-
const res = await fetch(url);
40+
let res = await fetch(url);
41+
42+
// Steam sessions expire after about a day and need to be refreshed.
43+
// We can do that by simply hitting the refresh endpoint, and asking it
44+
// to redirect us back to our original target. If this fails, we'll
45+
// error out and tell the user to log in to Steam.
46+
if (res.url.startsWith('https://steamcommunity.com/login/home')) {
47+
const refreshJwtUrl = new URL('https://login.steampowered.com/jwt/refresh');
48+
refreshJwtUrl.searchParams.set('redir', url.toString());
49+
50+
res = await fetch(refreshJwtUrl);
51+
}
52+
4153
if (!/^https:\/\/steamcommunity\.com\/(id\/[^/]+|profiles\/\d+)\/gcpd\/730/.test(res.url)) return GcpdError.STEAM_AUTH_FAILED;
4254

4355
const json = await res.json();

0 commit comments

Comments
 (0)