From 020a37795781b76e4e37bf493f5a3b264e8d21fb Mon Sep 17 00:00:00 2001 From: Rollin'Barrel Date: Sun, 21 Sep 2025 11:26:34 +0300 Subject: [PATCH 1/2] add Api.getAuthTicketForWebApi --- native/common.cpp | 15 +++++++++++++++ steam/Api.hx | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/native/common.cpp b/native/common.cpp index b9d5f64..9334caa 100644 --- a/native/common.cpp +++ b/native/common.cpp @@ -209,6 +209,16 @@ vdynamic *CallbackHandler::EncodeAuthSessionTicketResponse(GetAuthSessionTicketR return ret.value; } +vdynamic *CallbackHandler::EncodeTicketForWebApiResponse(GetTicketForWebApiResponse_t *d) { + vbyte *ticket = hl_copy_bytes(d->m_rgubTicket, d->m_cubTicket); + + HLValue ret; + ret.Set("authTicket", d->m_hAuthTicket); + ret.Set("result", d->m_eResult); + ret.Set("length", d->m_cubTicket); + hl_dyn_setp(ret.value, hl_hash_utf8("data"), &hlt_bytes, ticket); + return ret.value; +} HL_PRIM vbyte *HL_NAME(get_auth_ticket)( int *size, int *authTicket ) { vbyte *ticket = hl_alloc_bytes(1024); @@ -216,6 +226,10 @@ HL_PRIM vbyte *HL_NAME(get_auth_ticket)( int *size, int *authTicket ) { return ticket; } +HL_PRIM int HL_NAME(get_auth_ticket_for_web_api)( vbyte* identity ) { + return SteamUser()->GetAuthTicketForWebApi((char *)identity); +} + HL_PRIM void HL_NAME(cancel_call_result)( CClosureCallResult *m_call ) { m_call->Cancel(); delete m_call; @@ -348,6 +362,7 @@ DEFINE_PRIM(_BOOL, is_steam_running_on_steam_deck, _NO_ARG); DEFINE_PRIM(_BOOL, is_steam_running, _NO_ARG); DEFINE_PRIM(_BYTES, get_current_game_language, _NO_ARG); DEFINE_PRIM(_BYTES, get_auth_ticket, _REF(_I32) _REF(_I32)); +DEFINE_PRIM(_I32, get_auth_ticket_for_web_api, _BYTES); DEFINE_PRIM(_VOID, request_encrypted_app_ticket, _BYTES _I32 _FUN(_VOID, _BYTES _I32)); DEFINE_PRIM(_VOID, cancel_call_result, _CRESULT); DEFINE_PRIM(_BYTES, get_current_beta_name, _NO_ARG); diff --git a/steam/Api.hx b/steam/Api.hx index 8372399..3422b30 100644 --- a/steam/Api.hx +++ b/steam/Api.hx @@ -92,6 +92,15 @@ class Api } }); + // GetTicketForWebApiResponse_t + registerGlobalEvent(100 + 68, function(data:{authTicket:Int, result:Int, length:Int, data:hl.Bytes}){ + var cb = authTicketForWebApiCallbacks.get(data.authTicket); + if( cb !=null ){ + cb(data.result, data.data.toBytes(data.length)); + authTicketForWebApiCallbacks.remove(data.authTicket); + } + }); + // if we get this far, the dlls loaded ok and we need Steam to init. // otherwise, we're trying to run the Steam version without the Steam client active = _Init(steamWrap_onEvent, onGlobalEvent); @@ -410,6 +419,23 @@ class Api return ticket.toBytes(size); } + public static function getAuthTicketForWebApi(identity:String, ?onReady ) { + var authTicket = _GetAuthTicketForWebApi(@:privateAccess identity.toUtf8()); + if( authTicket == 0 ) + return; + if( onReady != null ){ + authTicketForWebApiCallbacks.set(authTicket, onReady); + // Timeout + haxe.Timer.delay(function(){ + var cb = authTicketForWebApiCallbacks.get(authTicket); + if( cb != null ){ + cb(-1, null); + authTicketForWebApiCallbacks.remove(authTicket); + } + }, 15000); //15sec + } + } + public static function getEncryptedAppTicket(data : haxe.io.Bytes, onReady : haxe.io.Bytes->Void ) : Void { var hlb = data != null ? hl.Bytes.fromBytes(data) : null; var len = data != null ? data.length : 0; @@ -539,6 +565,7 @@ class Api @:hlNative("steam","is_steam_running") private static function _IsSteamRunning() : Bool { return false; } @:hlNative("steam","get_current_game_language") private static function _GetCurrentGameLanguage() : hl.Bytes { return null; } @:hlNative("steam","get_auth_ticket") private static function _GetAuthTicket( size : hl.Ref, authTicket : hl.Ref ) : hl.Bytes { return null; } + @:hlNative("steam","get_auth_ticket_for_web_api") private static function _GetAuthTicketForWebApi(identity:hl.Bytes) : Int { return 0; }; @:hlNative("?steam","request_encrypted_app_ticket") private static function _RequestEncryptedAppTicket( data : hl.Bytes, size : Int, encryptedAppTicket : (hl.Bytes, Int) -> Void ) : Void { return; } @:hlNative("steam","open_overlay") private static function _OpenOverlay( url : hl.Bytes ) : Bool { return false; } @:hlNative("steam","get_current_beta_name") private static function _GetCurrentBetaName() : hl.Bytes { return null; } From 4e4933a770c1a3319aee7c74527b90a6144cdc23 Mon Sep 17 00:00:00 2001 From: Rollin'Barrel Date: Sun, 21 Sep 2025 11:27:07 +0300 Subject: [PATCH 2/2] add EVENT_DECL for GetTicketForWebApiResponse_t --- native/events.h | 1 + 1 file changed, 1 insertion(+) diff --git a/native/events.h b/native/events.h index 73bd848..0b882b8 100644 --- a/native/events.h +++ b/native/events.h @@ -2,6 +2,7 @@ EVENT_DECL( PersonaChange, PersonaStateChange_t ) EVENT_DECL( OverlayActivated, GameOverlayActivated_t ) EVENT_DECL( AuthSessionTicketResponse, GetAuthSessionTicketResponse_t ) +EVENT_DECL( TicketForWebApiResponse, GetTicketForWebApiResponse_t ) // matchmaking EVENT_DECL( LobbyData, LobbyDataUpdate_t )