Skip to content

Commit

Permalink
refactor: rename getSpoofedHostname() -> createMachineName()
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadzurami committed Sep 4, 2024
1 parent 441b199 commit 931aa88
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/AuthenticationClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
createMachineId,
decodeJwt,
eresultError,
getSpoofedHostname,
createMachineName,
isJwtValidForAudience
} from './helpers';
import {
Expand Down Expand Up @@ -112,7 +112,7 @@ export default class AuthenticationClient extends EventEmitter {
if (details.platformType == EAuthTokenPlatformType.SteamClient) {
// For SteamClient logins, we also need a machine id and machine name
this._machineId = this._machineId === true ? createMachineId(details.accountName) : this._machineId;
this._clientFriendlyName = this._clientFriendlyName || getSpoofedHostname(details.accountName);
this._clientFriendlyName = this._clientFriendlyName || createMachineName(details.accountName);
}

let {websiteId, deviceDetails} = this._getPlatformData();
Expand Down Expand Up @@ -352,7 +352,7 @@ export default class AuthenticationClient extends EventEmitter {
_getPlatformData(): PlatformData {
switch (this._platformType) {
case EAuthTokenPlatformType.SteamClient:
let machineName = this._clientFriendlyName || getSpoofedHostname();
let machineName = this._clientFriendlyName || createMachineName();

let refererQuery = {
IN_CLIENT: 'true',
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function isJwtValidForAudience(jwt:string, audience:string, steamId?:stri
return (decodedToken.aud || []).includes(audience);
}

export function getSpoofedHostname(accountName?: string): string {
export function createMachineName(accountName?: string): string {
let hash = createHash('sha1');
hash.update(accountName || hostname());
let sha1 = hash.digest();
Expand Down
6 changes: 3 additions & 3 deletions test/LoginSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
LoginSession
} from '../src';
import {createTokenPair, protobufDecodeRequest} from './src/helpers';
import {getSpoofedHostname} from '../src/helpers';
import {createMachineName} from '../src/helpers';
import {
CAuthentication_BeginAuthSessionViaCredentials_Request_BinaryGuardData,
CAuthentication_BeginAuthSessionViaCredentials_Response,
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('LoginSession tests', () => {
});

expect(req.device_details).toMatchObject({
device_friendly_name: getSpoofedHostname(LOGIN_USERNAME),
device_friendly_name: createMachineName(LOGIN_USERNAME),
platform_type: EAuthTokenPlatformType.SteamClient,
os_type: 20,
gaming_device_type: 1
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('LoginSession tests', () => {
remember_login: true,
website_id: 'Unknown',
device_details: {
device_friendly_name: getSpoofedHostname(LOGIN_USERNAME),
device_friendly_name: createMachineName(LOGIN_USERNAME),
platform_type: EAuthTokenPlatformType.SteamClient,
os_type: 20,
gaming_device_type: 1,
Expand Down

0 comments on commit 931aa88

Please sign in to comment.