Skip to content

Add support for 6 additional Apple APIs#1

Merged
zekedou merged 5 commits intocozy-elixir:mainfrom
dl-alexandre:main
Apr 14, 2026
Merged

Add support for 6 additional Apple APIs#1
zekedou merged 5 commits intocozy-elixir:mainfrom
dl-alexandre:main

Conversation

@dl-alexandre
Copy link
Copy Markdown

This PR adds comprehensive support for 6 additional Apple APIs that are commonly needed for server-side Apple development:

New APIs Added

1. DeviceCheckAPI (Apple.DeviceCheckAPI)

  • Token generation for DeviceCheck fraud prevention API
  • 1-hour token expiration (per Apple requirements)
  • Production and development environment URL helpers
  • Used to validate device tokens and query/update device state bits

2. MapkitJSAPI (Apple.MapkitJSAPI)

  • JWT token generation for Apple Maps web embedding
  • Optional origin restriction for domain validation
  • 1-hour token expiration
  • Enables embedding Apple Maps in web applications

3. AppleMusicAPI (Apple.AppleMusicAPI)

  • Developer token generation for Apple Music catalog access
  • Configurable expiration (default 30 days, max 6 months)
  • User library access support (with Music User Token)
  • Storefront and localization helpers

4. GameCenterAPI (Apple.GameCenterAPI)

  • Token generation for Game Center server access
  • 1-hour token expiration
  • Base URL helper for API endpoints
  • Enables server-side leaderboards and achievements management

5. CloudKitAPI (Apple.CloudKitAPI)

  • Server-to-server token generation for CloudKit Web Services
  • 1-hour token expiration
  • Support for both development and production environments
  • Database URL helpers for public, private, and shared databases

6. AppleDeveloperAPI (Apple.AppleDeveloperAPI)

  • Token generation for App Store Connect API (20-minute expiration)
  • Resource path helpers for:
    • Certificates management (/certificates)
    • Provisioning profiles (/profiles)
    • Device registration (/devices)
    • Bundle IDs and capabilities (/bundleIds)
  • Individual resource path helpers for specific IDs

Type Definitions

Each API includes comprehensive type definitions in Apple.Types.* modules:

  • Apple.Types.DeviceCheck
  • Apple.Types.AppleMusic
  • Apple.Types.GameCenter
  • Apple.Types.CloudKit
  • Apple.Types.AppleDeveloper

All types include detailed documentation on how to obtain credentials from Apple Developer portals.

Design Consistency

All implementations follow the existing patterns in the library:

  • Use of JOSE library for JWT signing (ES256)
  • Consistent build_auth_token!/3 function signatures
  • Proper type specifications and @spec attributes
  • Comprehensive @moduledoc with usage examples
  • Links to official Apple documentation
  • Updated mix.exs documentation groups

Testing

  • All modules compile successfully: mix compile
  • Follows existing code style and conventions
  • Documentation generated cleanly with mix docs

Related

These additions significantly expand the library's coverage of Apple's server-to-server APIs, making it a more complete utility library for Apple SDK development.

- Add Apple.Types.DeviceCheck with type definitions for DeviceCheck API
- Add Apple.DeviceCheckAPI for token generation and API endpoints
  - Supports both production and development environments
  - 1-hour token expiration as per Apple documentation
- Add Apple.MapkitJSAPI for MapKit JS web embedding
  - Supports optional origin restriction for domain validation
  - 1-hour token expiration for web token authorization
- Update mix.exs to include new modules in documentation groups

These additions extend the library to cover two commonly requested Apple APIs
that were previously missing from the utilities collection.
- Add Apple.Types.AppleMusic with type definitions for Music API
  - key_id, private_key, user_token types
  - storefront and language localization types
- Add Apple.AppleMusicAPI for MusicKit integration
  - Developer token generation with configurable expiration (default 30 days, max 6 months)
  - Helper functions for API endpoint URLs (catalog and library)
  - Support for both catalog access and user-specific library access
- Update mix.exs documentation groups

Apple Music API allows access to:
  - Apple Music catalog (songs, albums, artists, playlists)
  - User library and personal playlists
  - Search functionality
  - Personalized recommendations
- Add Apple.Types.GameCenter with type definitions
  - team_id, key_id, private_key for authentication
  - bundle_id for app identification
  - player_id, leaderboard_id, achievement_id for Game Center entities
- Add Apple.GameCenterAPI for server-side Game Center access
  - Token generation with 1-hour expiration
  - Base URL helper for API endpoint construction

Game Center API enables server-side:
  - Leaderboard management and score submission
  - Achievement tracking and progress
  - Player data access
  - Matchmaking (when supported by Apple)
- Add Apple.Types.CloudKit with type definitions
  - container_id for iCloud container identification
  - key_id, private_key for Server-to-Server authentication
  - record_id, record_type for CloudKit data structures
  - environment type for development/production
- Add Apple.CloudKitAPI for server-side CloudKit access
  - Token generation for CloudKit Web Services
  - Base URL helper for both development and production
  - Database URL helper for specific database access

CloudKit Web Services enables server-side:
  - Record management (CRUD operations)
  - Asset upload and download
  - Query execution
  - Database subscription management
- Add Apple.Types.AppleDeveloper with comprehensive type definitions
  - team_id, key_id, private_key for App Store Connect API authentication
  - certificate_id, profile_id, device_id, bundle_id resource identifiers
  - certificate_type, profile_type, device_status, device_class enums
  - Detailed documentation for all Apple Developer portal workflows
- Add Apple.AppleDeveloperAPI for developer account management
  - Token generation with 20-minute expiration (App Store Connect API limit)
  - Base URL and resource path helpers for:
    - /certificates - Certificate management (CSR, download, revoke)
    - /profiles - Provisioning profile management
    - /devices - Device registration (UDIDs for testing)
    - /bundleIds - App ID and capability management
  - Individual resource path helpers for specific IDs

Apple Developer API enables automated CI/CD workflows:
  - Certificate renewal and management
  - Device registration for testing teams
  - Provisioning profile updates
  - App capability configuration
@zekedou
Copy link
Copy Markdown
Contributor

zekedou commented Apr 14, 2026

I'll review the code later.

@zekedou zekedou merged commit d710566 into cozy-elixir:main Apr 14, 2026
0 of 9 checks passed
@zekedou
Copy link
Copy Markdown
Contributor

zekedou commented Apr 14, 2026

Thanks for your hard work. I've made some naming and style changes and released v0.6.0.

@zekedou
Copy link
Copy Markdown
Contributor

zekedou commented Apr 14, 2026

One more thing to note: the author email of the commits is dl-alexandre@noreply.codeberg.org — not sure if that's intentional. The direct result is that your avatar doesn't show up in the contributors list.

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