К основному содержанию
скилл CX Codex

apple — скилл для Claude Code: эмулятор Sign in with Apple

Локальный эмулятор Apple OIDC для разработки и тестирования авторизации через Apple. Поднимает сервер с discovery-документом, выдачей токенов и JWKS.

Apache-2.0 224 установок ★ 2 075 обновлён 2026-10-25

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add vercel-labs/emulate --skill apple -a claude-code
Открыть на GitHub

Что делает apple

Скилл запускает эмулятор Sign in with Apple на localhost:4000 (порт можно задать). Внутри — полный OIDC-поток: authorization endpoint с выбором пользователя, token exchange с RS256 ID-токенами, PKCE, form_post и JWKS для проверки подписей. Можно настроить список пользователей и OAuth-клиентов через YAML-конфиг: email, имя, is_private_email (даст адрес @privaterelay.appleid.com). Без конфига принимает любой client_id; с конфигом проверяет redirect_uri строго.

Агент умеет поднять эмулятор командой npx emulate --service apple, прокинуть переменную APPLE_EMULATOR_URL в Auth.js или Passport.js, настроить seed-файл с пользователями и клиентами. Работает с curl для ручных запросов к OIDC-эндпоинтам. Без эмулятора тестировать Apple OAuth локально не выйдет: реальные URL Apple недоступны из localhost.

Разрешённые инструменты: npx emulate:*, curl:*.

Какие задачи решает

  • протестировать Sign in with Apple без боевого Apple Developer аккаунта
  • эмулировать OIDC discovery и token exchange для локальной разработки
  • проверить обработку приватных email (@privaterelay.appleid.com)
  • настроить несколько тестовых пользователей Apple с разными email и именами
  • отладить интеграцию Auth.js или Passport.js с Apple OAuth локально

Примеры запросов агенту

  • Подними эмулятор Apple на порту 4004 и покажи OIDC discovery URL
  • Настрой seed-конфиг для эмулятора: два пользователя, один с приватным email, клиент com.myapp.service
  • Прокинь APPLE_EMULATOR_URL в Auth.js провайдер Apple и выведи код конфигурации

Как установить apple

1Через Skills CLI (Vercel)

npx skills add vercel-labs/emulate --skill apple -a claude-code

2Вручную: положить файлы

~/.claude/skills/apple/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/apple/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы об apple

Как установить apple в Claude Code?

Выполни npx skills add vercel-labs/emulate --skill apple -a claude-code, скилл появится в ~/.claude/skills/apple/SKILL.md.

Что делает скилл apple?

Запускает локальный эмулятор Sign in with Apple с OIDC-эндпоинтами, token exchange, RS256 ID-токенами и JWKS. Позволяет тестировать авторизацию через Apple без реальных Apple API.

Какие OAuth-клиенты работают с эмулятором?

Без seed-конфига эмулятор принимает любой client_id. Если настроить oauth_clients в YAML, проверка client_id и redirect_uri станет строгой — как у реального Apple.

Исходный текст

SKILL.md · Apache-2.0
---
name: apple
description: Emulated Sign in with Apple / Apple OIDC for local development and testing. Use when the user needs to test Apple sign-in locally, emulate Apple OIDC discovery, handle Apple token exchange, configure Apple OAuth clients, or work with Apple userinfo without hitting real Apple APIs. Triggers include "Apple OAuth", "emulate Apple", "mock Apple login", "test Apple sign-in", "Sign in with Apple", "Apple OIDC", "local Apple auth", or any task requiring a local Apple OAuth/OIDC provider.
allowed-tools: Bash(npx emulate:*), Bash(curl:*)
---

# Apple Sign In Emulator

Sign in with Apple emulation with authorization code flow, PKCE support, RS256 ID tokens, and OIDC discovery.

## Start

Local listeners bind to `127.0.0.1` by default. For access from containers or other machines, pass `--host 0.0.0.0` to the CLI or `hostname: '0.0.0.0'` to `createEmulator`. Configure `--base-url` or `baseUrl` for advertised URLs reachable by those clients.

```bash
# Apple only
npx emulate --service apple

# Default port (when run alone)
# http://localhost:4000
```

Or programmatically:

```typescript
import { createEmulator } from 'emulate'

const apple = await createEmulator({ service: 'apple', port: 4004 })
// apple.url === 'http://localhost:4004'
```

## Pointing Your App at the Emulator

### Environment Variable

```bash
APPLE_EMULATOR_URL=http://localhost:4004
```

### OAuth URL Mapping

| Real Apple URL | Emulator URL |
|----------------|-------------|
| `https://appleid.apple.com/.well-known/openid-configuration` | `$APPLE_EMULATOR_URL/.well-known/openid-configuration` |
| `https://appleid.apple.com/auth/authorize` | `$APPLE_EMULATOR_URL/auth/authorize` |
| `https://appleid.apple.com/auth/token` | `$APPLE_EMULATOR_URL/auth/token` |
| `https://appleid.apple.com/auth/keys` | `$APPLE_EMULATOR_URL/auth/keys` |
| `https://appleid.apple.com/auth/revoke` | `$APPLE_EMULATOR_URL/auth/revoke` |

### Auth.js / NextAuth.js

```typescript
import Apple from '@auth/core/providers/apple'

Apple({
  clientId: process.env.APPLE_CLIENT_ID,
  clientSecret: process.env.APPLE_CLIENT_SECRET,
  authorization: {
    url: `${process.env.APPLE_EMULATOR_URL}/auth/authorize`,
    params: { scope: 'openid email name', response_mode: 'form_post' },
  },
  token: {
    url: `${process.env.APPLE_EMULATOR_URL}/auth/token`,
  },
  jwks_endpoint: `${process.env.APPLE_EMULATOR_URL}/auth/keys`,
})
```

### Passport.js

```typescript
import { Strategy as AppleStrategy } from 'passport-apple'

const APPLE_URL = process.env.APPLE_EMULATOR_URL ?? 'https://appleid.apple.com'

new AppleStrategy({
  clientID: process.env.APPLE_CLIENT_ID,
  teamID: process.env.APPLE_TEAM_ID,
  keyID: process.env.APPLE_KEY_ID,
  callbackURL: 'http://localhost:3000/api/auth/callback/apple',
  authorizationURL: `${APPLE_URL}/auth/authorize`,
  tokenURL: `${APPLE_URL}/auth/token`,
}, verifyCallback)
```

## Seed Config

```yaml
apple:
  users:
    - email: [email protected]
      name: Test User
      given_name: Test
      family_name: User
    - email: [email protected]
      name: Private User
      is_private_email: true
  oauth_clients:
    - client_id: com.example.app
      team_id: TEAM001
      name: My Apple App
      redirect_uris:
        - http://localhost:3000/api/auth/callback/apple
```

When no OAuth clients are configured, the emulator accepts any `client_id`. With clients configured, strict validation is enforced for `client_id` and `redirect_uri`.

Users with `is_private_email: true` get a generated `@privaterelay.appleid.com` email in the `id_token` instead of their real email.

## API Endpoints

### OIDC Discovery

```bash
curl http://localhost:4004/.well-known/openid-configuration
```

Returns the standard OIDC discovery document with all endpoints pointing to the emulator:

```json
{
  "issuer": "http://localhost:4004",
  "authorization_endpoint": "http://localhost:4004/auth/authorize",
  "token_endpoint": "http://localhost:4004/auth/token",
  "jwks_uri": "http://localhost:4004/auth/keys",
  "revocation_endpoint": "http://localhost:4004/auth/revoke",
  "response_types_supported": ["code"],
  "subject_types_supported": ["pairwise"],
  "id_token_signing_alg_values_supported": ["RS256"],
  "scopes_supported": ["openid", "email", "name"],
  "token_endpoint_auth_methods_supported": ["client_secret_post"],
  "response_modes_supported": ["query", "fragment", "form_post"]
}
```

### JWKS

```bash
curl http://localhost:4004/auth/keys
```

Returns an RSA public key (`kid`: `emulate-apple-1`) for verifying `id_token` signatures.

### Authorization

```bash
# Browser flow: redirects to a user picker page
curl -v "http://localhost:4004/auth/authorize?\
client_id=com.example.app&\
redirect_uri=http://localhost:3000/api/auth/callback/apple&\
scope=openid+email+name&\
response_type=code&\
state=random-state&\
nonce=random-nonce&\
response_mode=form_post"
```

Query parameters:

| Param | Description |
|-------|-------------|
| `client_id` | OAuth client ID (Apple Services ID) |
| `redirect_uri` | Callback URL |
| `scope` | Space-separated scopes (`openid email name`) |
| `state` | Opaque state for CSRF protection |
| `nonce` | Nonce for ID token (optional) |
| `response_mode` | `query` (default), `form_post`, or `fragment` |

The emulator renders an HTML page where you select a seeded user. After selection, it redirects (or auto-submits a form for `form_post`) to `redirect_uri` with `code` and `state`. On the **first** authorization per user/client pair, a `user` JSON blob is also included (matching Apple's real behavior).

### Token Exchange

```bash
curl -X POST http://localhost:4004/auth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "code=<authorization_code>&\
client_id=com.example.app&\
client_secret=<client_secret>&\
grant_type=authorization_code"
```

Returns:

```json
{
  "access_token": "apple_...",
  "refresh_token": "r_apple_...",
  "id_token": "<jwt>",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

The `id_token` is an RS256 JWT containing `sub`, `email`, `email_verified` (string), `is_private_email` (string), `real_user_status`, `auth_time`, and optional `nonce`.

### Refresh Token

```bash
curl -X POST http://localhost:4004/auth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "refresh_token=r_apple_...&\
client_id=com.example.app&\
grant_type=refresh_token"
```

Returns a new `access_token` and `id_token`. No new `refresh_token` is issued on refresh (matching Apple's behavior).

### Token Revocation

```bash
curl -X POST http://localhost:4004/auth/revoke \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "token=apple_..."
```

Returns `200 OK`. The token is removed from the emulator's token map.

## Common Patterns

### Full Authorization Code Flow

```bash
APPLE_URL="http://localhost:4004"
CLIENT_ID="com.example.app"
REDIRECT_URI="http://localhost:3000/api/auth/callback/apple"

# 1. Open in browser (user picks a seeded account)
#    $APPLE_URL/auth/authorize?client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI&scope=openid+email+name&response_type=code&state=abc&response_mode=form_post

# 2. After user selection, emulator posts to:
#    $REDIRECT_URI with code=<code>&state=abc (and user JSON on first auth)

# 3. Exchange code for tokens
curl -X POST $APPLE_URL/auth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "code=<code>&client_id=$CLIENT_ID&grant_type=authorization_code"

# 4. Decode the id_token JWT to get user info
```

### Private Relay Email

When a user has `is_private_email: true` in the seed config, the `id_token` will contain a generated `@privaterelay.appleid.com` email instead of the user's real email. This matches Apple's Hide My Email behavior.

## Custom emulators alongside built-ins

Use `npx emulate init --custom inventory` to scaffold a third-party API emulator and test. Register it in `emulate.config.ts` with `defineConfig` from `emulate`, alongside built-in entries such as `{ emulator: "apple" }`. Run `npx emulate start --watch` to reload imports and inspect custom state at the printed `/_emulate` URL. Successful reloads reset the run to seed. Existing flat seed configs still work; `--config` selects an explicit file. For authoring and testing third-party API emulators, see https://emulate.dev/docs/custom-emulators.

© vercel-labs · Apache-2.0 · vercel-labs/emulate

Похожие скиллы

Все скиллы по теме «Безопасность» →
sign-in-with-vercel официальный Vercel Labs Скилл sign-in-with-vercel для Codex и ChatGPT. Объясняет, как подключить вход через аккаунт Vercel по OAuth 2.0 и OpenID Connect, когда приложение не хранит пароли и не заводит собственные аккаунты. CX Codex GP ChatGPT +1 4установок competition-oauth-oidc-chain zhaoxuya520 Скилл competition-oauth-oidc-chain для Claude Code разбирает цепочки OAuth и OIDC, перенаправления, параметры обратного вызова и токены. Запускается после активации координатора песочницы CTF. CX Codex +1 109установок omni-auth cheaper-inference Скилл omni-auth для Claude Code и Codex настраивает авторизацию OmniRoute через API-ключи, сессии и MFA. Запрашивает Bearer-доступ, cookie сессии и параметры входа. CX Codex +1 1 400установок oauth2-authentication manutej Скилл oauth2-authentication помогает спроектировать и внедрить авторизацию по протоколам OAuth2 и OpenID Connect. Пригодится при настройке входа через соцсети, защите API и обмене токенов через PKCE. CX Codex +1 603установок oauth2-oidc-implementer patricio0312rev Скилл oauth2-oidc-implementer настраивает авторизацию OAuth 2.0 и OpenID Connect, создаёт роуты входа с PKCE и организует безопасный обмен токенов. CX Codex +1 369установок aws-auth aws Скилл aws-auth для Claude Code добавляет аутентификацию пользователей через Amazon Cognito в веб- и мобильные приложения. Настраивает вход, MFA, OAuth и защиту API. CX Codex +1 5 700установок

Из того же набора12

Весь набор →
stripe Эмулятор Stripe API для локальной разработки и тестирования платежей. Обрабатывает платежи без обращения к реальным серверам Stripe, позволяет тестировать checkout, работать с webhook и SDK. CX Codex +1 294установок resend Скилл запускает локальный Resend API, который принимает письма, сохраняет их в памяти и отдаёт через REST или UI. Реальные письма не отправляются. CX Codex +1 246установок aws Скилл aws для Claude Code поднимает локальную эмуляцию сервисов AWS для отладки приложений без обращения к реальному облаку. CX Codex +1 241установок github Запускает локальную эмуляцию GitHub REST API с сохранением состояния. Помогает тестировать вебхуки, OAuth-авторизацию и GitHub Apps без реальных запросов к api.github.com. CX Codex +1 228установок vercel Эмулирует REST API платформы Vercel на локальной машине для тестов интеграций, OAuth и деплоев. CX Codex +1 220установок slack Локально эмулирует Slack Web API для разработки и тестирования интеграций без обращения к реальному Slack. CX Codex +1 212установок next Подключает эмуляторы к Next.js App Router через @emulators/adapter-next. Настраивает OAuth, тестовые данные и сохранение состояния. CX Codex +1 204установок microsoft Локальный эмулятор Microsoft Entra ID (Azure AD) с поддержкой OAuth 2.0 и OpenID Connect. Нужен, чтобы тестировать вход через Microsoft без реальных API — PKCE, client credentials, RS256 токены. CX Codex +1 196установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой