npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@superfan-app/apple-music-auth

v0.1.16

Published

Apple Music OAuth module for Expo

Downloads

186

Readme

@superfan-app/apple-music-auth

A modern Expo module for Apple Music authentication in React Native apps. This module provides seamless integration with MusicKit for Apple Music authentication and token management.

Features

  • 🎵 Complete Apple Music authentication via MusicKit
  • 🔑 Developer and User token management
  • 📱 iOS 15.0+ support via native SDK
  • ⚡️ Modern Expo development workflow
  • 🛡️ Secure token caching
  • 🔧 TypeScript support
  • 📝 Comprehensive error handling

Installation

npx expo install @superfan-app/apple-music-auth

This module requires the Expo Development Client (not compatible with Expo Go):

npx expo install expo-dev-client

Configuration

  1. Set up Apple Music capabilities in your Xcode project

  2. Obtain your Apple Music developer token from the Apple Developer Portal

  3. (Optional) Configure your app.json/app.config.js:

{
  "expo": {
    "plugins": [
      [
        "@superfan-app/apple-music-auth",
        {
          "usageDescription": "We need access to Apple Music to personalize your experience"
        }
      ]
    ]
  }
}

If no configuration is provided, the module will use default settings:

  • A default usage description message will be shown in the permission dialog
  • iOS settings will be configured automatically for MusicKit compatibility

Usage

  1. Wrap your app with the provider:
import { AppleMusicAuthProvider } from '@superfan-app/apple-music-auth';

export default function App() {
  return (
    <AppleMusicAuthProvider developerToken="your-developer-token">
      <MainApp />
    </AppleMusicAuthProvider>
  );
}
  1. Use the hook in your components:
import { useAppleMusicAuth } from '@superfan-app/apple-music-auth';

function MainScreen() {
  const { 
    authState,
    requestAuthorization,
    getUserToken,
    isAuthenticating,
    error
  } = useAppleMusicAuth();

  const handleAuth = async () => {
    try {
      const status = await requestAuthorization();
      if (status === 'authorized') {
        const userToken = await getUserToken();
        // Use the user token for API calls
      }
    } catch (err) {
      console.error('Authentication failed:', err);
    }
  };

  if (isAuthenticating) {
    return <ActivityIndicator />;
  }

  if (error) {
    return <Text>Error: {error.message}</Text>;
  }

  return (
    <View>
      <Text>Status: {authState.status}</Text>
      <Button onPress={handleAuth} title="Authenticate" />
    </View>
  );
}

API Reference

AppleMusicAuthProvider

Provider component that manages authentication state.

<AppleMusicAuthProvider developerToken?: string>
  {children}
</AppleMusicAuthProvider>

Props:

  • developerToken: Optional developer token to initialize the provider

useAppleMusicAuth()

Hook for accessing authentication state and methods.

Returns:

  • authState: { status: string, developerToken?: string, userToken?: string }
  • requestAuthorization(): Promise<string> - Request user authorization
  • setDeveloperToken(token: string): void - Set the developer token
  • getDeveloperToken(): Promise<string> - Get the developer token
  • getUserToken(): Promise<string> - Get the user token
  • isAuthenticating: boolean - Authentication in progress
  • error: AppleMusicAuthError | null - Last error

Authorization Status Types

Possible values for authState.status:

  • 'authorized' - User has granted access
  • 'denied' - User has denied access
  • 'notDetermined' - User hasn't been asked for permission
  • 'restricted' - Access is restricted
  • 'unknown' - Status cannot be determined

Development Workflow

  1. Clean installation:
npm install
npm run build
  1. Clean build:
npx expo prebuild --clean
  1. Run on iOS:
npx expo run:ios

Troubleshooting

Common Issues

  1. "Cannot find native module 'AppleMusicAuth'":

    npx expo prebuild --clean
    npx expo run:ios
  2. Build errors:

    npm run clean
    npm run build
    npx expo prebuild --clean
  3. Authentication errors:

    • Verify your developer token
    • Check Apple Music capabilities in Xcode
    • Ensure proper entitlements
    • Check iOS version (requires 15.0+)

Security

  • Tokens are cached in memory
  • Automatic token management
  • Proper error handling and recovery
  • Uses Apple's secure MusicKit framework

Requirements

  • Expo SDK 47+
  • iOS 15.0+
  • Node.js 14.0+
  • Expo Development Client