Skip to content

Verify iOS purchases and check auto-renewable subscription access - #405

Open
orlyd wants to merge 4 commits into
base44:mainfrom
orlyd:codex/ios-one-time-purchases
Open

orlyd wants to merge 4 commits into
base44:mainfrom
orlyd:codex/ios-one-time-purchases

Conversation

@orlyd

@orlyd orlyd commented Dec 2, 2026 •

Copy link
Copy Markdown

Intent (for reviewers)

Let an authenticated app backend deliver one-time iOS purchases and check current access for auto-renewable subscriptions. The server-only entry point is @base44/sdk/iap. It accepts an explicit app identity, environment, and product catalog. The main SDK entry remains free of Apple verification code.

The one-time helper returns the verified transaction ID and quantity. The application records the grant once and acknowledges it after delivery. The subscription service binds the original transaction ID to the current account and checks the latest status with Apple when access is needed. A one-time purchase snapshot still needs separate reconciliation for later refunds.

Summary

  • Provide appAccountTokenFor and createApplePurchaseVerifier for consumable and non-consumable StoreKit purchases.
  • Validate the Apple certificate chain and signature, bundle ID, environment, purchaser account token, ownership, catalog product type, quantity, and revocation fields. Production and Sandbox are configured separately.
  • Add createAppleSubscriptionService with verifyPurchase for enrollment and getStatus for live entitlements. It limits the Apple response to the stored subscription, verifies signed grace deadlines, and respects cancellation through the paid period, expiration, billing retry, and revocation. App Store Server API keys stay in the backend.
  • Load the Apple verifier during an active request so a Cloudflare Worker can import the SDK and configure it at module scope.

Dependency review

Adds Apple’s official @apple/app-store-server-library@3.1.0 and updates package-lock.json. The server entry uses a native fetch adapter for Apple’s binary certificate status response and timeout. The build declares the existing locked rolldown@1.0.3 directly and includes the bundled license notices. Its Node type dependency requires the lockfile’s Node type definitions to move to a compatible version. The trust anchors come from Apple PKI. The npm runtime advisory lookup returned one existing advisory for ws@8.21.0, already locked on main. GHSA-37g9-w4hg-h9qr

Verification

  • SDK build, type checks, lint, and reference-doc generation.
  • All 529 App SDK tests, 165 Platform SDK tests, and both built-package smoke tests passed. Signed fixtures cover retries, permanent unlocks, renewed transactions, paid-through cancellation, grace, expiration, billing retry, revocation, account and environment isolation, and Apple API failure. An intercepted Apple Sandbox HTTP request exercised the real Server API client with an ephemeral test signing key.
  • The packed SDK ran through Base44 Functions compiler 0.4.0 in local workerd. A controlled App Store endpoint verified the authorization JWT. A synthetic certificate authority and signed OCSP replies verified that the real Apple library accepts a good certificate and rejects a revoked one. These were local endpoints, with no live merchant key or Apple Sandbox purchase.
  • Checked that the root import and existing extensionless and explicit .js deep imports still work without loading the Apple verifier.

Generated with Codex.

codex added 3 commits December 2, 2026 16:01
Expose a server-only verifier for cataloged consumables and permanent unlocks. Use the Apple certificate chain and account token before returning the fields needed for retry-safe delivery.

Co-authored-by: Codex <noreply@openai.com>
Defer loading the Apple crypto library until verification so backend functions can configure their verifier at module scope. Cover startup ordering alongside signed-purchase tests.

Co-authored-by: Codex <noreply@openai.com>
Bind enrollment to the authenticated account and refresh its original transaction through Apple. Verify current product, ownership, expiration and billing grace before granting access.

Co-authored-by: Codex <noreply@openai.com>
@orlyd orlyd changed the title Verify one-time iOS purchases in backend functions Verify iOS purchases and check auto-renewable subscription access Dec 2, 2026
Bundle the request-scoped Apple library with a native fetch adapter for binary certificate status responses. Check the shipped entry point in CI and include third-party license notices.

Co-authored-by: Codex <noreply@openai.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants