Mark Villacampa and NachoSoto
84806ad86e
Improve sandbox detector for macOS apps ( #3549 )
...
Checking for the presence of `Xcode/DerivedData` in the receipt path was
failing for TestFlight builds or if the .app bundle generated by Xcode
was moved from the folder.
Additionally, checking for `MASReceipt/receipt` seems less robust than
simply using compiler directives.
Instead, for macOS apps, we check the environment embedded in the receipt and alternatively check the signature of the app bundle.
---------
Co-authored-by: NachoSoto <NachoSoto@users.noreply.github.com >
2024-01-09 19:12:47 +01:00
NachoSoto
b3875a9380
Exposed PurchasesReceiptParser and AppleReceipt ( #2153 )
...
Initial step for [CSDK-17]. Fixes [CSDK-523].
### Changes:
- Renamed `ReceiptParser` to `PurchasesReceiptParser` to avoid name
collision with future SPM `ReceiptParser`
- Exposed `ReceiptParser`, `AppleReceipt`,
`PurchasesReceiptParser.Error`
- Added new types to `SwiftAPITester`
- Added docs to these types
- Moved `LoggerType` to be available to `ReceiptParser`
- Moved `DateFormatter+Extensions` to be available to `ReceiptParser`
- Moved `Codable+Extensions` to be available to `ReceiptParser`
- Created `ReceiptParserLogger` for `ReceiptParser`
[CSDK-17]:
https://revenuecats.atlassian.net/browse/CSDK-17?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[CSDK-523]:
https://revenuecats.atlassian.net/browse/CSDK-523?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-12-22 10:09:12 -08:00
NachoSoto
8d6f80b362
Added a few performance improvements for ReceiptParser ( #2124 )
2022-12-13 11:08:21 -08:00
NachoSoto
2cca7deadb
ReceiptParser.parse always throws ReceiptParser.Error (#2099 )
...
This will be used for [CSDK-17].
Since this will be a public API, we want to make sure we provide
consistent and documented errors.
This changes a few thrown `BitShiftError`s into `ReceiptParser.Error`.
[CSDK-17]:
https://revenuecats.atlassian.net/browse/CSDK-17?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-12-08 17:17:57 -08:00
NachoSoto
8b4a9ecbca
PostReceiptDataOperation: log Apple error when purchase equals expiration date (#2038 )
...
A large amount of flaky integration tests are due to this bug, so
detecting it early in the logs will help debug this.
Radar: `FB11767559`.
`productType` is missing in `StoreKitTest` purchases, so I changed
`isSubscription` to default to checking if there is an expiration when
the type is `.unknown`.
To simplify the code, I changed `ProductType?` to be non-optional, since
we already have `.unknown` as a case.
### Example:
```
[00:27:56]: ▸ 2022-11-09 00:27:56.000533+0000 BackendIntegrationTestsHostApp[3942:17000] [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Posting receipt: {
[00:27:56]: ▸ "opaque_value" : "1n+XXw8AAAA=",
[00:27:56]: ▸ "sha1_hash" : "unR7vAzPaUlB0TtZ09z5jMyqqAs=",
[00:27:56]: ▸ "bundle_id" : "com.revenuecat.StoreKitTestApp",
[00:27:56]: ▸ "in_app_purchases" : [
[00:27:56]: ▸ {
[00:27:56]: ▸ "quantity" : 1,
[00:27:56]: ▸ "product_id" : "com.revenuecat.weekly_1.99.3_day_intro",
[00:27:56]: ▸ "purchase_date" : "2022-11-09T00:27:50Z",
[00:27:56]: ▸ "transaction_id" : "0",
[00:27:56]: ▸ "is_in_intro_offer_period" : true,
[00:27:56]: ▸ "expires_date" : "2022-11-09T00:27:50Z"
[00:27:56]: ▸ },
[00:27:56]: ▸ {
[00:27:56]: ▸ "product_id" : "com.revenuecat.weekly_1.99.3_day_intro",
[00:27:56]: ▸ "quantity" : 1,
[00:27:56]: ▸ "transaction_id" : "1",
[00:27:56]: ▸ "is_in_intro_offer_period" : false,
[00:27:56]: ▸ "expires_date" : "2022-11-09T00:28:00Z",
[00:27:56]: ▸ "original_purchase_date" : "2022-11-09T00:27:50Z",
[00:27:56]: ▸ "original_transaction_id" : "0",
[00:27:56]: ▸ "purchase_date" : "2022-11-09T00:27:50Z"
[00:27:56]: ▸ }
[00:27:56]: ▸ ],
[00:27:56]: ▸ "application_version" : "1",
[00:27:56]: ▸ "creation_date" : "2022-11-09T00:27:55Z",
[00:27:56]: ▸ "expiration_date" : "4001-01-01T00:00:00Z"
[00:27:56]: ▸ }
[00:27:56]: ▸ 2022-11-09 00:27:56.000710+0000 BackendIntegrationTestsHostApp[3942:17000] [Purchases] - ERROR: 🍎 ‼️ Receipt for product 'com.revenuecat.weekly_1.99.3_day_intro' has the same purchase (2022-11-09 00:27:50 +0000) and expiration (2022-11-09 00:27:50 +0000) dates. This is likely a StoreKit bug.
```
2022-11-09 11:18:52 -08:00
NachoSoto
9ad9e9b108
Moved InAppPurchase into AppleReceipt ( #1942 )
...
The name `InAppPurchase` is too general. This type in particular is
specific to the content of `AppleReceipt`, so nesting it makes that
clear.
Follow up to #1933 .
2022-09-28 08:40:17 -07:00
NachoSoto
adf6353c83
AppleReceipt: refactored declarations into nested types (#1933 )
...
Before this change we had a lot of global types. Now they're all nested
inside of `AppleReceipt`, `InAppPurchase`, and `InAppPurchaseBuilder`.
2022-09-23 10:38:14 -07:00
NachoSoto
aae60d0f51
ReceiptParser: Sendable conformance (#1825 )
...
For [CSDK-379].
Extracted from #1795 to make it easier to review this in isolation.
Also made `ASN1ObjectIdentifierBuilder` an `enum` since we don't need to create instances of it to use it.
[CSDK-379]: https://revenuecats.atlassian.net/browse/CSDK-379?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-08-22 16:01:19 -07:00
aboedo
4d6c7bd5b8
More tests for receipt parsing with storekit test ( #1456 )
...
* made a few attributes that aren't present in SKTest receipts optional, added test with IAP
* added more tests for every field in the receipt
* fixed a few places where `asDict` wasn't correctly considering nullability in the IAP receipt fields
2022-04-06 15:44:00 -03:00
aboedo
fb193e37c8
Fix: ASN1 length calculation for indefinite-length ( #1452 )
...
* fixed length calculation for indefinite-length containers
* temporarily removed the early return from empty receipts
* fixed length calculation when parsing receipts with indefinite length
* fix linting
2022-04-06 11:02:59 -03:00
aboedo
cab0053885
Fix: local receipt parsing for StoreKitTest - part 1 ( #1446 )
...
* added basic ugly test
* fixed local receipt parsing for sktest, broke regular receipt parsing temporarily
* updated length calculation so that it works for both storekit test and regular receipts
* updated test to allow for missing OriginalAppVersion in receipt
* fixed linting in imports
* fixed checks for non-storekitTest receipts
* added a longer comment to explain the length == 0 case
* cleaned up the still-ugly tests for the receipt parser
2022-04-05 16:18:06 -03:00
aboedo
f5697de730
renamed Purchases folder to Sources ( #1416 )
...
* renamed `Purchases` folder to `Sources`
* temporarily enabling installation test jobs
* re-disabling installation test jobs
2022-03-28 11:53:24 -03:00