Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard cleanup #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
13 changes: 5 additions & 8 deletions AppStoreServerApi/AppleAppstoreClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Dynamic;
using System.Net.Http.Headers;
using System.Security.Cryptography;
Expand Down Expand Up @@ -93,6 +92,7 @@ private bool TokenExpired
}

#region Request utilities

private async Task<T?> MakeRequest<T>(string url)
{
var token = this.GetToken();
Expand Down Expand Up @@ -143,7 +143,7 @@ private ECDsa GetEllipticCurveAlgorithm()
});
}

public ECDsaSecurityKey GetEcdsaSecuritKey()
public ECDsaSecurityKey GetEcdsaSecurityKey()
{
var signatureAlgorithm = GetEllipticCurveAlgorithm();
var eCDsaSecurityKey = new ECDsaSecurityKey(signatureAlgorithm)
Expand All @@ -164,7 +164,7 @@ private string GetToken()
var now = DateTime.Now;
var expiry = now.AddSeconds(MaxTokenAge);

ECDsaSecurityKey eCDsaSecurityKey = GetEcdsaSecuritKey();
ECDsaSecurityKey eCDsaSecurityKey = GetEcdsaSecurityKey();

var handler = new JsonWebTokenHandler();
string jwt = handler.CreateToken(new SecurityTokenDescriptor
Expand All @@ -187,14 +187,10 @@ private string GetToken()
return jwt;
}

/*private int GetUnixTimestamp(DateTime dateTime)
{
var time = (dateTime.ToUniversalTime() - new DateTime(1970, 1, 1));
return (int)(time.TotalMilliseconds + 0.5);
}*/
#endregion

#region Decode signed fields

public List<JWSTransactionDecodedPayload> DecodeTransactions(List<string> signedTransactions)
{
return signedTransactions.Select(s => DecodeJWS<JWSTransactionDecodedPayload>(s)).ToList();
Expand Down Expand Up @@ -282,6 +278,7 @@ private static List<X509Certificate2> ValidateCertificate(List<string> certifica

return x509certs;
}

#endregion
}
}
9 changes: 2 additions & 7 deletions AppStoreServerApi/Models/AppleEnvironment.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/environment
public class AppleEnvironment
{
public const string Production = "Production";
Expand Down
9 changes: 1 addition & 8 deletions AppStoreServerApi/Models/AutoRenewStatus.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{

// https://developer.apple.com/documentation/appstoreserverapi/autorenewstatus
public enum AutoRenewStatus
{
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/CertificateValidationException.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
public class CertificateValidationException: Exception
{
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/DecodedNotificationPayload.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
public class DecodedNotificationPayload
{
Expand Down
9 changes: 1 addition & 8 deletions AppStoreServerApi/Models/ExpirationIntent.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{

// https://developer.apple.com/documentation/appstoreserverapi/expirationintent
public enum ExpirationIntent
{
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/HistoryResponse.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/historyresponse
public class HistoryResponse
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/JWSDecodedHeader.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/jwsdecodedheader
public class JWSDecodedHeader
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/JWSRenewalInfoDecodedPayload.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfodecodedpayload
public class JWSRenewalInfoDecodedPayload
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/JWSTransactionDecodedPayload.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/jwstransactiondecodedpayload
public class JWSTransactionDecodedPayload
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/LastTransactionsItem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/lasttransactionsitem
public class LastTransactionsItem
Expand Down
4 changes: 1 addition & 3 deletions AppStoreServerApi/Models/NotificationData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
public class NotificationData
{
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/NotificationSubtype.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
public class NotificationSubtype
{
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/NotificationType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreservernotifications/notificationtype
public class NotificationType
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/OfferType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/offertype
public enum OfferType
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/OrderLookupResponse.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/orderlookupresponse
public class OrderLookupResponse
Expand Down
9 changes: 2 additions & 7 deletions AppStoreServerApi/Models/OrderLookupStatus.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/orderlookupstatus
public enum OrderLookupStatus
{
Valid = 0,
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/OwnershipType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/inappownershiptype
public class OwnershipType
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/PriceIncreaseStatus.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/priceincreasestatus
public enum PriceIncreaseStatus
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/StatusResponse.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/statusresponse
public class StatusResponse
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/SubscriptionGroupIdentifierItem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/subscriptiongroupidentifieritem
public class SubscriptionGroupIdentifierItem
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/SubscriptionStatus.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/status
public enum SubscriptionStatus
Expand Down
8 changes: 1 addition & 7 deletions AppStoreServerApi/Models/TransactionType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppStoreServerApi.Models
namespace AppStoreServerApi.Models
{
// https://developer.apple.com/documentation/appstoreserverapi/type
public class TransactionType
Expand Down