Skip to content

Commit dafb8d9

Browse files
committed
feat: Migrate to SwiftAsn1
1 parent 5455e8c commit dafb8d9

116 files changed

Lines changed: 6959 additions & 2589 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pull_request.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
macos:
11+
name: macOS (Build & Test)
12+
runs-on: macos-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Build
16+
run: swift build -v
17+
- name: Test
18+
run: swift test -v
19+
20+
ios:
21+
name: iOS (Build & Test)
22+
runs-on: macos-26
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: List available simulators
26+
run: |
27+
xcrun simctl list devices
28+
xcodebuild -showsdks
29+
- name: Build
30+
run: xcodebuild build -scheme TPInAppReceipt -destination 'platform=iOS Simulator,OS=latest,name=iPhone 17' -skipPackagePluginValidation SWIFT_STRICT_CONCURRENCY=targeted
31+
- name: Test
32+
run: xcodebuild test -scheme TPInAppReceipt -destination 'platform=iOS Simulator,OS=latest,name=iPhone 17' -skipPackagePluginValidation SWIFT_STRICT_CONCURRENCY=targeted
33+
34+
linux:
35+
name: Linux (Build & Test)
36+
runs-on: ubuntu-latest
37+
container: swift:6.0
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Show Swift & OS info
42+
run: |
43+
swift --version
44+
uname -a
45+
46+
- name: Restore swift package cache
47+
uses: actions/cache@v4
48+
with:
49+
path: |
50+
.build
51+
.swiftpm
52+
key: ${{ runner.os }}-swift-${{ hashFiles('**/Package.resolved') }}
53+
54+
- name: Resolve Packages
55+
run: swift package resolve -v
56+
57+
- name: Build
58+
run: swift build -v
59+
60+
- name: Test
61+
run: swift test -v

.github/workflows/swift.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.gitignore

Lines changed: 12 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,13 @@
1-
# Xcode
2-
#
3-
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4-
5-
## Build generated
6-
build/
7-
DerivedData/
8-
Packages/
9-
iOS Example/ViewController.swift
10-
11-
## Various settings
12-
*.pbxuser
13-
!default.pbxuser
14-
*.mode1v3
15-
!default.mode1v3
16-
*.mode2v3
17-
!default.mode2v3
18-
*.perspectivev3
19-
!default.perspectivev3
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
205
xcuserdata/
21-
22-
## Other
23-
*.moved-aside
24-
*.xcuserstate
25-
26-
## Obj-C/Swift specific
27-
*.hmap
28-
*.ipa
29-
*.dSYM.zip
30-
*.dSYM
31-
32-
## Playgrounds
33-
timeline.xctimeline
34-
playground.xcworkspace
35-
36-
# Swift Package Manager
37-
#
38-
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
39-
# Packages/
40-
.build/
41-
42-
# CocoaPods
43-
#
44-
# We recommend against adding the Pods directory to your .gitignore. However
45-
# you should judge for yourself, the pros and cons are mentioned at:
46-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
47-
#
48-
# Pods/
49-
50-
# Carthage
51-
#
52-
# Add this line if you want to avoid checking in source code from Carthage dependencies.
53-
# Carthage/Checkouts
54-
55-
Carthage/Build
56-
57-
# fastlane
58-
#
59-
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
60-
# screenshots whenever they are needed.
61-
# For more information about the recommended setup visit:
62-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
63-
64-
fastlane/report.xml
65-
fastlane/Preview.html
66-
fastlane/screenshots
67-
fastlane/test_output
68-
69-
# AppCode
70-
.idea
71-
72-
TPInAppReceiptTests/MyDevice.swift
73-
74-
.swiftpm/
6+
DerivedData/
7+
.swiftpm/config/registries.json
8+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
9+
.netrc
10+
Package.resolved
11+
.swiftpm
12+
/out
13+
.claude

.spi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [TPInAppReceipt]

.swift-format

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentation" : {
6+
"spaces" : 4
7+
},
8+
"indentConditionalCompilationBlocks" : false,
9+
"indentSwitchCaseLabels" : false,
10+
"lineBreakAroundMultilineExpressionChainComponents" : false,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : true,
13+
"lineBreakBeforeEachGenericRequirement" : true,
14+
"lineLength" : 120,
15+
"maximumBlankLines" : 1,
16+
"prioritizeKeepingFunctionOutputTogether" : true,
17+
"respectsExistingLineBreaks" : true,
18+
"rules" : {
19+
"AllPublicDeclarationsHaveDocumentation" : false,
20+
"AlwaysUseLowerCamelCase" : false,
21+
"AmbiguousTrailingClosureOverload" : true,
22+
"BeginDocumentationCommentWithOneLineSummary" : false,
23+
"DoNotUseSemicolons" : true,
24+
"DontRepeatTypeInStaticProperties" : true,
25+
"FileScopedDeclarationPrivacy" : true,
26+
"FullyIndirectEnum" : true,
27+
"GroupNumericLiterals" : true,
28+
"IdentifiersMustBeASCII" : true,
29+
"NeverForceUnwrap" : false,
30+
"NeverUseForceTry" : false,
31+
"NeverUseImplicitlyUnwrappedOptionals" : false,
32+
"NoAccessLevelOnExtensionDeclaration" : true,
33+
"NoAssignmentInExpressions" : true,
34+
"NoBlockComments" : true,
35+
"NoCasesWithOnlyFallthrough" : true,
36+
"NoEmptyTrailingClosureParentheses" : true,
37+
"NoLabelsInCasePatterns" : false,
38+
"NoLeadingUnderscores" : false,
39+
"NoParensAroundConditions" : true,
40+
"NoVoidReturnOnFunctionSignature" : true,
41+
"OneCasePerLine" : true,
42+
"OneVariableDeclarationPerLine" : true,
43+
"OnlyOneTrailingClosureArgument" : true,
44+
"OrderedImports" : false,
45+
"ReturnVoidInsteadOfEmptyTuple" : true,
46+
"UseEarlyExits" : true,
47+
"UseLetInEveryBoundCaseVariable" : false,
48+
"UseShorthandTypeNames" : true,
49+
"UseSingleLinePropertyGetter" : false,
50+
"UseSynthesizedInitializer" : false,
51+
"UseTripleSlashForDocumentationComments" : true,
52+
"UseWhereClausesInForLoops" : false,
53+
"ValidateDocumentationComments" : false
54+
},
55+
"spacesAroundRangeFormationOperators" : false,
56+
"tabWidth" : 4,
57+
"version" : 1
58+
}

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
## 4.0.0
4+
5+
### Breaking Changes
6+
7+
- `InAppReceipt` class replaced by `AppReceipt` typealias over `ContentInfo<SignedData<InAppReceiptPayload>>`
8+
- Sync validation (`try receipt.verify()`) replaced by async (`await receipt.validate()`)
9+
- Error types renamed: `IARError``AppReceiptError`, `ReceiptValidatorError`
10+
- `originalAppVersion` is now `String?` (was `String`)
11+
- `ageRating` is now `String?` (was `String`)
12+
- Minimum platforms raised: iOS 13+, macOS 10.15+, tvOS 13+
13+
- Swift tools version: 6.0
14+
- Removed Objective-C support
15+
- Removed CocoaPods support
16+
17+
### New
18+
19+
- Full PKCS#7 structure: `ContentInfo`, `SignedData`, `EncapsulatedContentInfo`, `SignerInfo`, `AlgorithmIdentifier`, etc.
20+
- Composable validation via `@VerifierBuilder` and `ReceiptValidator`
21+
- X.509 certificate chain verification using swift-certificates
22+
- Signature verification using swift-crypto
23+
- New receipt fields: `environment`, `appStoreID`, `transactionDate`, `fulfillmentToolVersion`, `developerID`, `downloadID`, `installerVersionID`
24+
- `InAppReceiptPayload.Environment` enum (`.production`, `.sandbox`, `.xcode`, `.productionSandbox`)
25+
- `InAppPurchase.Type` enum (`.consumable`, `.nonConsumable`, `.autoRenewableSubscription`, `.nonRenewingSubscription`)
26+
- Blocking API via `@_spi(Blocking)`: `local_blocking`, `validate_blocking()`
27+
- Pluggable decoder via `AppReceiptDecoder.Engine` protocol
28+
- DocC documentation
29+
- Privacy manifest (`PrivacyInfo.xcprivacy`)
30+
- visionOS support
31+
32+
### Dependencies
33+
34+
- Removed: ASN1Swift
35+
- Added: [swift-asn1](https://github.com/apple/swift-asn1) 1.5.0+, [swift-certificates](https://github.com/apple/swift-certificates) 1.15.1+, [swift-crypto](https://github.com/apple/swift-crypto) 4.2.0+

CONTRIBUTING.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,54 @@
11
# Contributing to TPInAppReceipt
22

3-
### All contributions to TPInAppReceipt are welcome.
3+
Thank you for your interest in contributing to TPInAppReceipt! This document provides guidelines and instructions for contributing.
44

5-
If you want to help developing TPInAppReceipt, please take a look for any opened issue or you can introduce a new functionality.
5+
## Reporting Bugs
66

7-
### Increase unit test coverage
7+
If you find a bug, please open an issue on [GitHub Issues](https://github.com/tikhop/TPInAppReceipt/issues) with:
88

9-
Additional unit test coverage is welcome.
9+
- A clear, descriptive title
10+
- Steps to reproduce the issue
11+
- Expected behavior vs actual behavior
12+
- Swift version and platform information
13+
- Minimal code example if possible
1014

11-
## Issues
15+
## Suggesting Features
1216

13-
If TPInAppReceipt doesn't work as you expect, please review [any open issues](https://github.com/tikhop/TPInAppReceipt/issues) before opening a new one.
17+
Feature requests are welcome! Please open an issue with:
18+
19+
- A clear description of the feature
20+
- Use cases and motivation
21+
- Any implementation ideas you may have
22+
23+
## Pull Request Process
24+
25+
1. Fork the repository and create your branch from `master`
26+
2. Make your changes and ensure tests pass
27+
3. Add tests for any new functionality
28+
4. Update documentation if needed
29+
5. Submit a pull request with a clear description of your changes
30+
31+
### PR Guidelines
32+
33+
- Keep changes focused and atomic
34+
- Follow existing code patterns
35+
- Ensure all tests pass before submitting
36+
37+
## Code Style
38+
39+
This project follows Swift conventions. Please reference `.swift-format` for formatting guidelines.
40+
41+
To format all files: `swift format -i . --recursive`
42+
43+
Key points:
44+
- Keep lines reasonably short
45+
- Use meaningful variable and function names
46+
47+
## Testing Requirements
48+
49+
All contributions should include appropriate tests:
50+
51+
- Run existing tests with `swift test`
52+
- Add unit tests for new functionality
53+
54+
Thank you for contributing!

Documentation/UseInObjCProject.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016-present Pavel Tikhoneko
3+
Copyright (c) 2016-Present Pavel Tikhonenko
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Package.resolved

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)