Skip to content

Commit

Permalink
Fixes left and right spray slot selections. Fixes user agent.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachrip committed Mar 30, 2024
1 parent 9ee2200 commit f4a4954
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
1 change: 0 additions & 1 deletion app/routes/loadouts/$loadoutId/sprays/left.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export async function loader({ params }: LoaderArgs) {
(entitlement) => entitlement.ItemID === spray.uuid
)
)
.filter((spray) => spray.category !== 'EAresSprayCategory::Contextual')
.sort((a, b) => a.displayName.localeCompare(b.displayName));

return json({
Expand Down
1 change: 0 additions & 1 deletion app/routes/loadouts/$loadoutId/sprays/right.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export async function loader({ params }: LoaderArgs) {
(entitlement) => entitlement.ItemID === spray.uuid
)
)
.filter((spray) => spray.category !== 'EAresSprayCategory::Contextual')
.sort((a, b) => a.displayName.localeCompare(b.displayName));

return json({
Expand Down
1 change: 0 additions & 1 deletion app/routes/loadouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ export const loader = async () => {

return json({
loadouts,
allAgents: valorantData.agents,
});
};

Expand Down
3 changes: 3 additions & 0 deletions app/utils.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ export async function getUser() {
headers: generateRequestHeaders({
accessToken: tokens.accessToken,
entitlementsToken: tokens.token,
riotClientVersion:
global.valorantData.version.riotClientVersion,
}),
}
);
Expand Down Expand Up @@ -286,6 +288,7 @@ export async function getUser() {
userShardRegionCache.set(tokens.subject, res);

return new User({
riotClientVersion: global.valorantData.version.riotClientVersion,
accessToken: tokens.accessToken,
entitlementsToken: tokens.token,
region: res.region,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "valpal",
"version": "0.0.8",
"version": "0.0.9",
"private": true,
"sideEffects": false,
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion server/userman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ export function generateRequestHeaders(
args: {
accessToken: string;
entitlementsToken: string;
riotClientVersion: string;
},
extraHeaders: Record<string, string> = {}
) {
const defaultHeaders = {
Authorization: `Bearer ${args.accessToken}`,
'X-Riot-Entitlements-JWT': args.entitlementsToken,
'X-Riot-ClientVersion': 'release-08.00-shipping-14-2191955',
'X-Riot-ClientVersion': args.riotClientVersion,
'X-Riot-ClientPlatform': btoa(
JSON.stringify({
platformType: 'PC',
Expand Down Expand Up @@ -79,6 +80,7 @@ export class User {
constructor(args: {
accessToken: string;
entitlementsToken: string;
riotClientVersion: string;
userId: string;
region: Regions;
shard: Shards;
Expand All @@ -89,6 +91,7 @@ export class User {
this.region = args.region;
this.shard = args.shard;
this.requestHeaders = generateRequestHeaders({
riotClientVersion: args.riotClientVersion,
accessToken: this.accessToken,
entitlementsToken: this.entitlementsToken,
});
Expand Down
16 changes: 15 additions & 1 deletion server/valorantApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,25 @@ async function getAgents() {
return data.data.filter((agent) => agent.isPlayableCharacter);
}

async function getVersion() {
const { data } = await httpClient.get<{
status: number;
data: { riotClientVersion: string };
}>('https://valorant-api.com/v1/version');

return data.data;
}

export async function initSkinData() {
const [weapons, buddies, sprays, playerCards, playerTitles, agents] =
const [weapons, buddies, sprays, playerCards, playerTitles, agents, version] =
await Promise.all([
getWeapons(),
getBuddies(),
getSprays(),
getPlayerCards(),
getPlayerTitles(),
getAgents(),
getVersion(),
]);

global.valorantData = {
Expand All @@ -82,6 +92,7 @@ export async function initSkinData() {
playerCards,
playerTitles,
agents,
version,
};
}

Expand All @@ -93,5 +104,8 @@ declare global {
playerCards: PlayerCard[];
playerTitles: PlayerTitle[];
agents: Agent[];
version: {
riotClientVersion: string;
};
};
}

0 comments on commit f4a4954

Please sign in to comment.