mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-28 07:35:55 +03:00
Added RequestEncryptedAppTicketAsync
This commit is contained in:
parent
503d8964ea
commit
a020474856
@ -114,6 +114,26 @@ public void IsPhoneRequiringVerification()
|
|||||||
{
|
{
|
||||||
Console.WriteLine( $"User.IsPhoneRequiringVerification: {SteamUser.IsPhoneRequiringVerification}" );
|
Console.WriteLine( $"User.IsPhoneRequiringVerification: {SteamUser.IsPhoneRequiringVerification}" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task RequestEncryptedAppTicketAsyncWithData()
|
||||||
|
{
|
||||||
|
var data = await SteamUser.RequestEncryptedAppTicketAsync( new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 } );
|
||||||
|
Assert.IsNotNull( data );
|
||||||
|
|
||||||
|
Console.WriteLine( $"data: {string.Join( "", data.Select( x => x.ToString( "x" ) ))}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task RequestEncryptedAppTicketAsync()
|
||||||
|
{
|
||||||
|
var data = await SteamUser.RequestEncryptedAppTicketAsync();
|
||||||
|
Assert.IsNotNull( data );
|
||||||
|
|
||||||
|
Console.WriteLine( $"data: {string.Join( "", data.Select( x => x.ToString( "x" ) ) )}" );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -338,5 +338,68 @@ public static async Task<string> GetStoreAuthUrlAsync( string url )
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsPhoneRequiringVerification => Internal.BIsPhoneRequiringVerification();
|
public static bool IsPhoneRequiringVerification => Internal.BIsPhoneRequiringVerification();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requests an application ticket encrypted with the secret "encrypted app ticket key".
|
||||||
|
/// The encryption key can be obtained from the Encrypted App Ticket Key page on the App Admin for your app.
|
||||||
|
/// There can only be one call pending, and this call is subject to a 60 second rate limit.
|
||||||
|
/// This can fail if you don't have an encrypted ticket set for your app here https://partner.steamgames.com/apps/sdkauth/
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<byte[]> RequestEncryptedAppTicketAsync( byte[] dataToInclude )
|
||||||
|
{
|
||||||
|
var dataPtr = Marshal.AllocHGlobal( dataToInclude.Length );
|
||||||
|
Marshal.Copy( dataToInclude, 0, dataPtr, dataToInclude.Length );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await Internal.RequestEncryptedAppTicket( dataPtr, dataToInclude.Length );
|
||||||
|
if ( !result.HasValue || result.Value.Result != Result.OK ) return null;
|
||||||
|
|
||||||
|
var ticketData = Marshal.AllocHGlobal( 1024 );
|
||||||
|
uint outSize = 0;
|
||||||
|
byte[] data = null;
|
||||||
|
|
||||||
|
if ( Internal.GetEncryptedAppTicket( ticketData, 1024, ref outSize ) )
|
||||||
|
{
|
||||||
|
data = new byte[outSize];
|
||||||
|
Marshal.Copy( ticketData, data, 0, (int) outSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal( ticketData );
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal( dataPtr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requests an application ticket encrypted with the secret "encrypted app ticket key".
|
||||||
|
/// The encryption key can be obtained from the Encrypted App Ticket Key page on the App Admin for your app.
|
||||||
|
/// There can only be one call pending, and this call is subject to a 60 second rate limit.
|
||||||
|
/// This can fail if you don't have an encrypted ticket set for your app here https://partner.steamgames.com/apps/sdkauth/
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<byte[]> RequestEncryptedAppTicketAsync()
|
||||||
|
{
|
||||||
|
var result = await Internal.RequestEncryptedAppTicket( IntPtr.Zero, 0 );
|
||||||
|
if ( !result.HasValue || result.Value.Result != Result.OK ) return null;
|
||||||
|
|
||||||
|
var ticketData = Marshal.AllocHGlobal( 1024 );
|
||||||
|
uint outSize = 0;
|
||||||
|
byte[] data = null;
|
||||||
|
|
||||||
|
if ( Internal.GetEncryptedAppTicket( ticketData, 1024, ref outSize ) )
|
||||||
|
{
|
||||||
|
data = new byte[outSize];
|
||||||
|
Marshal.Copy( ticketData, data, 0, (int)outSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal( ticketData );
|
||||||
|
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user