Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions native/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,27 @@ 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);
*authTicket = SteamUser()->GetAuthSessionTicket(ticket,1024,(uint32*)size, NULL);
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<int> *m_call ) {
m_call->Cancel();
delete m_call;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions native/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
27 changes: 27 additions & 0 deletions steam/Api.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<Int>, authTicket : hl.Ref<Int> ) : 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; }
Expand Down