Add AppTransaction environment property to match Apple's official API #93
+26
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an inconsistency in the
AppTransaction
model where the property was namedreceiptType
instead ofenvironment
, which doesn't match Apple's official API documentation.Changes Made
receiptType
toenvironment
inAppTransaction.swift
to match Apple's official documentationreceiptType
to useenvironment
insteadCodingKeys
and serialization logic to useenvironment
"environment"
key instead of"receiptType"
environment
andreceiptType
fields to maintain compatibility with existing signed JWT tokens in test dataFiles Changed
Sources/AppStoreServerLibrary/Models/AppTransaction.swift
- Main property rename and backward compatibilitySources/AppStoreServerLibrary/SignedDataVerifier.swift
- Updated reference in verification logicTests/AppStoreServerLibraryTests/XcodeSignedDataVerifierTests.swift
- Updated test assertionsTests/AppStoreServerLibraryTests/SignedModelTests.swift
- Updated test assertionsTests/AppStoreServerLibraryTests/resources/models/appTransaction.json
- Updated test dataWhy This Change
The library was inconsistent with Apple's official API. Other models in the same library (like
JWSTransactionDecodedPayload
) correctly useenvironment
, butAppTransaction
was usingreceiptType
. This creates confusion and inconsistency for developers using the library.Backward Compatibility
The change includes backward compatibility to handle existing signed JWT tokens that may still contain the old
receiptType
field name, ensuring existing integrations continue to work while new code can use the correctenvironment
property name.Testing
All tests pass, including the Xcode signed data tests that use pre-signed JWT tokens with the old field name.