Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 2.48 KB

File metadata and controls

68 lines (46 loc) · 2.48 KB

Refactoring Complete: App Store Connect API SDK Integration

Summary

Successfully refactored the codebase to use the @rage-against-the-pixel/app-store-connect-api TypeScript SDK instead of manually crafting JWT tokens and making curl requests.

Changes Made

1. Added SDK Dependency

  • Installed @rage-against-the-pixel/app-store-connect-api package
  • Added to package.json dependencies

2. Created SDK Client Helper

  • Added createAppStoreConnectClient() function in lib.ts
  • Reads .p8 key file and initializes AppStoreConnectClient
  • Handles authentication automatically via the SDK

3. Refactored Certificate Creation

  • Replaced manual curl POST request with client.api.Certificates.certificatesCreateInstance()
  • Uses CertificateType.DEVELOPMENT enum for type safety
  • Improved error handling with SDK's structured error responses
  • Added null checks for optional response fields

4. Refactored Certificate Deletion

  • Replaced manual curl GET request with client.api.Certificates.certificatesGetCollection()
  • Replaced manual curl DELETE request with client.api.Certificates.certificatesDeleteInstance()
  • Uses SDK's typed responses for cleaner code

5. Removed Manual JWT Generation

  • Deleted entire generateJwtToken() function (~70 lines)
  • Removed OpenSSL-based JWT signing logic
  • SDK handles JWT generation internally using the jose library

6. Improved Type Safety

  • All API calls now use TypeScript types from the SDK
  • Proper enum usage for certificate types
  • Better compile-time error checking

Benefits

Cleaner Code: Removed ~100 lines of manual JWT and curl logic ✅ Type Safety: Full TypeScript support with auto-generated types ✅ Better Errors: Structured error responses from SDK ✅ Maintainability: SDK auto-updates with Apple's OpenAPI spec ✅ Less Dependencies: No longer need manual OpenSSL JWT signing ✅ Reliability: SDK handles edge cases and API changes

Code Size Impact

  • Before: ~1736kB compiled
  • After: ~2958kB compiled (+1222kB due to SDK and jose library)

The size increase is acceptable given the benefits of type safety, maintainability, and reduced custom code.

Testing Recommendations

  1. Test certificate creation with API key authentication
  2. Verify certificate appears in keychain
  3. Test post action cleanup
  4. Verify certificate is deleted from both keychain and App Store Connect
  5. Test error scenarios (invalid API key, network issues)
  6. Verify parallel job execution still works correctly