forked from ceifa/steamworks.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.d.ts
468 lines (468 loc) · 16.7 KB
/
client.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
export declare function init(appId?: number | undefined | null): void
export declare function restartAppIfNecessary(appId: number): boolean
export declare function runCallbacks(): void
export interface PlayerSteamId {
steamId64: bigint
steamId32: string
accountId: number
}
export declare namespace achievement {
export function activate(achievement: string): boolean
export function isActivated(achievement: string): boolean
export function clear(achievement: string): boolean
}
export declare namespace apps {
export function isSubscribedApp(appId: number): boolean
export function isAppInstalled(appId: number): boolean
export function isDlcInstalled(appId: number): boolean
export function isSubscribedFromFreeWeekend(): boolean
export function isVacBanned(): boolean
export function isCybercafe(): boolean
export function isLowViolence(): boolean
export function isSubscribed(): boolean
export function appBuildId(): number
export function appInstallDir(appId: number): string
export function appOwner(): PlayerSteamId
export function availableGameLanguages(): Array<string>
export function currentGameLanguage(): string
export function currentBetaName(): string | null
export function achievements(): Array<string>
}
export declare namespace auth {
/**
* @param steamId64 - The user steam id or game server steam id. Use as NetworkIdentity of the remote system that will authenticate the ticket. If it is peer-to-peer then the user steam ID. If it is a game server, then the game server steam ID may be used if it was obtained from a trusted 3rd party
* @param timeoutSeconds - The number of seconds to wait for the ticket to be validated. Default value is 10 seconds.
*/
export function getSessionTicketWithSteamId(steamId64: bigint, timeoutSeconds?: number | undefined | null): Promise<Ticket>
/**
* @param ip - The string of IPv4 or IPv6 address. Use as NetworkIdentity of the remote system that will authenticate the ticket.
* @param timeoutSeconds - The number of seconds to wait for the ticket to be validated. Default value is 10 seconds.
*/
export function getSessionTicketWithIp(ip: string, timeoutSeconds?: number | undefined | null): Promise<Ticket>
export function getAuthTicketForWebApi(identity: string, timeoutSeconds?: number | undefined | null): Promise<Ticket>
export class Ticket {
cancel(): void
getBytes(): Buffer
}
}
export declare namespace callback {
export const enum SteamCallback {
PersonaStateChange = 0,
SteamServersConnected = 1,
SteamServersDisconnected = 2,
SteamServerConnectFailure = 3,
LobbyDataUpdate = 4,
LobbyChatUpdate = 5,
P2PSessionRequest = 6,
P2PSessionConnectFail = 7,
GameLobbyJoinRequested = 8,
MicroTxnAuthorizationResponse = 9
}
export function register<C extends keyof import('./callbacks').CallbackReturns>(steamCallback: C, handler: (value: import('./callbacks').CallbackReturns[C]) => void): Handle
export class Handle {
disconnect(): void
}
}
export declare namespace cloud {
export function isEnabledForAccount(): boolean
export function isEnabledForApp(): boolean
export function setEnabledForApp(enabled: boolean): void
export function readFile(name: string): string
export function writeFile(name: string, content: string): boolean
export function deleteFile(name: string): boolean
export function fileExists(name: string): boolean
export function listFiles(): Array<FileInfo>
export class FileInfo {
name: string
size: bigint
}
}
export declare namespace input {
export const enum InputType {
Unknown = 'Unknown',
SteamController = 'SteamController',
XBox360Controller = 'XBox360Controller',
XBoxOneController = 'XBoxOneController',
GenericGamepad = 'GenericGamepad',
PS4Controller = 'PS4Controller',
AppleMFiController = 'AppleMFiController',
AndroidController = 'AndroidController',
SwitchJoyConPair = 'SwitchJoyConPair',
SwitchJoyConSingle = 'SwitchJoyConSingle',
SwitchProController = 'SwitchProController',
MobileTouch = 'MobileTouch',
PS3Controller = 'PS3Controller',
PS5Controller = 'PS5Controller',
SteamDeckController = 'SteamDeckController'
}
export interface AnalogActionVector {
x: number
y: number
}
export function init(): void
export function getControllers(): Array<Controller>
export function getActionSet(actionSetName: string): bigint
export function getDigitalAction(actionName: string): bigint
export function getAnalogAction(actionName: string): bigint
export function shutdown(): void
export class Controller {
activateActionSet(actionSetHandle: bigint): void
isDigitalActionPressed(actionHandle: bigint): boolean
getAnalogActionVector(actionHandle: bigint): AnalogActionVector
getType(): InputType
getHandle(): bigint
}
}
export declare namespace localplayer {
export function getSteamId(): PlayerSteamId
export function getName(): string
export function getLevel(): number
/** @returns the 2 digit ISO 3166-1-alpha-2 format country code which client is running in, e.g. "US" or "UK". */
export function getIpCountry(): string
export function setRichPresence(key: string, value?: string | undefined | null): void
}
export declare namespace matchmaking {
export const enum LobbyType {
Private = 0,
FriendsOnly = 1,
Public = 2,
Invisible = 3
}
export function createLobby(lobbyType: LobbyType, maxMembers: number): Promise<Lobby>
export function joinLobby(lobbyId: bigint): Promise<Lobby>
export function getLobbies(): Promise<Array<Lobby>>
export class Lobby {
id: bigint
join(): Promise<Lobby>
leave(): void
openInviteDialog(): void
getMemberCount(): bigint
getMemberLimit(): bigint | null
getMembers(): Array<PlayerSteamId>
getOwner(): PlayerSteamId
setJoinable(joinable: boolean): boolean
getData(key: string): string | null
setData(key: string, value: string): boolean
deleteData(key: string): boolean
/** Get an object containing all the lobby data */
getFullData(): Record<string, string>
/**
* Merge current lobby data with provided data in a single batch
* @returns true if all data was set successfully
*/
mergeFullData(data: Record<string, string>): boolean
}
}
export declare namespace networking {
export interface P2PPacket {
data: Buffer
size: number
steamId: PlayerSteamId
}
/** The method used to send a packet */
export const enum SendType {
/**
* Send the packet directly over udp.
*
* Can't be larger than 1200 bytes
*/
Unreliable = 0,
/**
* Like `Unreliable` but doesn't buffer packets
* sent before the connection has started.
*/
UnreliableNoDelay = 1,
/**
* Reliable packet sending.
*
* Can't be larger than 1 megabyte.
*/
Reliable = 2,
/**
* Like `Reliable` but applies the nagle
* algorithm to packets being sent
*/
ReliableWithBuffering = 3
}
export function sendP2PPacket(steamId64: bigint, sendType: SendType, data: Buffer): boolean
export function isP2PPacketAvailable(): number
export function readP2PPacket(size: number): P2PPacket
export function acceptP2PSession(steamId64: bigint): void
}
export declare namespace overlay {
export const enum Dialog {
Friends = 0,
Community = 1,
Players = 2,
Settings = 3,
OfficialGameGroup = 4,
Stats = 5,
Achievements = 6
}
export const enum StoreFlag {
None = 0,
AddToCart = 1,
AddToCartAndShow = 2
}
export function activateDialog(dialog: Dialog): void
export function activateDialogToUser(dialog: Dialog, steamId64: bigint): void
export function activateInviteDialog(lobbyId: bigint): void
export function activateToWebPage(url: string): void
export function activateToStore(appId: number, flag: StoreFlag): void
}
export declare namespace stats {
export function getInt(name: string): number | null
export function setInt(name: string, value: number): boolean
export function store(): boolean
export function resetAll(achievementsToo: boolean): boolean
}
export declare namespace utils {
export function getAppId(): number
export function getServerRealTime(): number
export function isSteamRunningOnSteamDeck(): boolean
export const enum GamepadTextInputMode {
Normal = 0,
Password = 1
}
export const enum GamepadTextInputLineMode {
SingleLine = 0,
MultipleLines = 1
}
/** @returns the entered text, or null if cancelled or could not show the input */
export function showGamepadTextInput(inputMode: GamepadTextInputMode, inputLineMode: GamepadTextInputLineMode, description: string, maxCharacters: number, existingText?: string | undefined | null): Promise<string | null>
export const enum FloatingGamepadTextInputMode {
SingleLine = 0,
MultipleLines = 1,
Email = 2,
Numeric = 3
}
/** @returns true if the floating keyboard was shown, otherwise, false */
export function showFloatingGamepadTextInput(keyboardMode: FloatingGamepadTextInputMode, x: number, y: number, width: number, height: number): Promise<boolean>
}
export declare namespace workshop {
export interface UgcResult {
itemId: bigint
needsToAcceptAgreement: boolean
}
export const enum UgcItemVisibility {
Public = 0,
FriendsOnly = 1,
Private = 2,
Unlisted = 3
}
export interface UgcUpdate {
title?: string
description?: string
changeNote?: string
previewPath?: string
contentPath?: string
tags?: Array<string>
visibility?: UgcItemVisibility
}
export interface InstallInfo {
folder: string
sizeOnDisk: bigint
timestamp: number
}
export interface DownloadInfo {
current: bigint
total: bigint
}
export const enum UpdateStatus {
Invalid = 0,
PreparingConfig = 1,
PreparingContent = 2,
UploadingContent = 3,
UploadingPreviewFile = 4,
CommittingChanges = 5
}
export interface UpdateProgress {
status: UpdateStatus
progress: bigint
total: bigint
}
export function createItem(appId?: number | undefined | null): Promise<UgcResult>
export function updateItem(itemId: bigint, updateDetails: UgcUpdate, appId?: number | undefined | null): Promise<UgcResult>
export function updateItemWithCallback(itemId: bigint, updateDetails: UgcUpdate, appId: number | undefined | null, successCallback: (data: UgcResult) => void, errorCallback: (err: any) => void, progressCallback?: (data: UpdateProgress) => void, progressCallbackIntervalMs?: number | undefined | null): void
/**
* Subscribe to a workshop item. It will be downloaded and installed as soon as possible.
*
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#SubscribeItem}
*/
export function subscribe(itemId: bigint): Promise<void>
/**
* Unsubscribe from a workshop item. This will result in the item being removed after the game quits.
*
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#UnsubscribeItem}
*/
export function unsubscribe(itemId: bigint): Promise<void>
/**
* Gets the current state of a workshop item on this client. States can be combined.
*
* @returns a number with the current item state, e.g. 9
* 9 = 1 (The current user is subscribed to this item) + 8 (The item needs an update)
*
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#GetItemState}
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#EItemState}
*/
export function state(itemId: bigint): number
/**
* Gets info about currently installed content on the disc for workshop item.
*
* @returns an object with the the properties {folder, size_on_disk, timestamp}
*
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#GetItemInstallInfo}
*/
export function installInfo(itemId: bigint): InstallInfo | null
/**
* Get info about a pending download of a workshop item.
*
* @returns an object with the properties {current, total}
*
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#GetItemDownloadInfo}
*/
export function downloadInfo(itemId: bigint): DownloadInfo | null
/**
* Download or update a workshop item.
*
* @param highPriority - If high priority is true, start the download in high priority mode, pausing any existing in-progress Steam downloads and immediately begin downloading this workshop item.
* @returns true or false
*
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#DownloadItem}
*/
export function download(itemId: bigint, highPriority: boolean): boolean
/**
* Get all subscribed workshop items.
* @returns an array of subscribed workshop item ids
*/
export function getSubscribedItems(): Array<bigint>
export const enum UGCQueryType {
RankedByVote = 0,
RankedByPublicationDate = 1,
AcceptedForGameRankedByAcceptanceDate = 2,
RankedByTrend = 3,
FavoritedByFriendsRankedByPublicationDate = 4,
CreatedByFriendsRankedByPublicationDate = 5,
RankedByNumTimesReported = 6,
CreatedByFollowedUsersRankedByPublicationDate = 7,
NotYetRated = 8,
RankedByTotalVotesAsc = 9,
RankedByVotesUp = 10,
RankedByTextSearch = 11,
RankedByTotalUniqueSubscriptions = 12,
RankedByPlaytimeTrend = 13,
RankedByTotalPlaytime = 14,
RankedByAveragePlaytimeTrend = 15,
RankedByLifetimeAveragePlaytime = 16,
RankedByPlaytimeSessionsTrend = 17,
RankedByLifetimePlaytimeSessions = 18,
RankedByLastUpdatedDate = 19
}
export const enum UGCType {
Items = 0,
ItemsMtx = 1,
ItemsReadyToUse = 2,
Collections = 3,
Artwork = 4,
Videos = 5,
Screenshots = 6,
AllGuides = 7,
WebGuides = 8,
IntegratedGuides = 9,
UsableInGame = 10,
ControllerBindings = 11,
GameManagedItems = 12,
All = 13
}
export const enum UserListType {
Published = 0,
VotedOn = 1,
VotedUp = 2,
VotedDown = 3,
Favorited = 4,
Subscribed = 5,
UsedOrPlayed = 6,
Followed = 7
}
export const enum UserListOrder {
CreationOrderAsc = 0,
CreationOrderDesc = 1,
TitleAsc = 2,
LastUpdatedDesc = 3,
SubscriptionDateDesc = 4,
VoteScoreDesc = 5,
ForModeration = 6
}
export interface WorkshopItemStatistic {
numSubscriptions?: bigint
numFavorites?: bigint
numFollowers?: bigint
numUniqueSubscriptions?: bigint
numUniqueFavorites?: bigint
numUniqueFollowers?: bigint
numUniqueWebsiteViews?: bigint
reportScore?: bigint
numSecondsPlayed?: bigint
numPlaytimeSessions?: bigint
numComments?: bigint
numSecondsPlayedDuringTimePeriod?: bigint
numPlaytimeSessionsDuringTimePeriod?: bigint
}
export interface WorkshopItem {
publishedFileId: bigint
creatorAppId?: number
consumerAppId?: number
title: string
description: string
owner: PlayerSteamId
/** Time created in unix epoch seconds format */
timeCreated: number
/** Time updated in unix epoch seconds format */
timeUpdated: number
/** Time when the user added the published item to their list (not always applicable), provided in Unix epoch format (time since Jan 1st, 1970). */
timeAddedToUserList: number
visibility: UgcItemVisibility
banned: boolean
acceptedForUse: boolean
tags: Array<string>
tagsTruncated: boolean
url: string
numUpvotes: number
numDownvotes: number
numChildren: number
previewUrl?: string
statistics: WorkshopItemStatistic
}
export interface WorkshopPaginatedResult {
items: Array<WorkshopItem | undefined | null>
returnedResults: number
totalResults: number
wasCached: boolean
}
export interface WorkshopItemsResult {
items: Array<WorkshopItem | undefined | null>
wasCached: boolean
}
export interface WorkshopItemQueryConfig {
cachedResponseMaxAge?: number
includeMetadata?: boolean
includeLongDescription?: boolean
includeAdditionalPreviews?: boolean
onlyIds?: boolean
onlyTotal?: boolean
language?: string
matchAnyTag?: boolean
requiredTags?: Array<string>
excludedTags?: Array<string>
searchText?: string
rankedByTrendDays?: number
}
export interface AppIDs {
creator?: number
consumer?: number
}
export function getItem(item: bigint, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopItem | null>
export function getItems(items: Array<bigint>, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopItemsResult>
export function getAllItems(page: number, queryType: UGCQueryType, itemType: UGCType, creatorAppId: number, consumerAppId: number, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopPaginatedResult>
export function getUserItems(page: number, accountId: number, listType: UserListType, itemType: UGCType, sortOrder: UserListOrder, appIds: AppIDs, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopPaginatedResult>
}