Builds CryptoTokenKit security-token and smart-card integrations. Use for token-driver extensions, token sessions, TKSmartCard communication, NFC smart-card sessions, token-backed Keychain queries, token watching, certificate authentication, APDU handling, or PIN workflows.
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Use CryptoTokenKit for token-driver extensions, smart-card sessions, token-backed Keychain items, certificate authentication, and iOS/iPadOS 26+ NFC smart-card access.
API presence is not an access guarantee: extension points, entitlements,
hardware, and runtime support all matter. The login/keychain-unlock token
extension flow is macOS-specific, TKSmartCardSlotManager.default is optional,
and NFC smart-card slot creation requires iOS/iPadOS 26+.
CryptoTokenKit has three distinct modes:
TKSmartCard.Own token/smart-card sessions, token-backed items, APDUs, PIN operations, and
smart-card certificate authentication here. Route passkeys/WebAuthn and account
sign-in to authentication; route CryptoKit primitives, Secure Enclave,
ordinary Keychain architecture, pinning, and trust policy to swift-security.
| Type | Role | Important constraint |
|---|---|---|
TKTokenDriver, TKToken, TKTokenSession | Driver/token/session primitives | Extension behavior depends on platform and extension point |
TKSmartCardTokenDriver | Smart-card driver entry point | System login integration is a macOS extension flow |
TKSmartCard, TKSmartCardSlotManager | Reader discovery and APDU transport | Default manager may be nil |
TKTokenWatcher | Token insertion/removal | Retain it for the monitoring lifetime |
TKSmartCardSlotNFCSession | Temporary NFC-backed slot | iOS/iPadOS 26+; always end the session |
TKSmartCardTokenRegistrationManager | NFC token registration | iOS/iPadOS 26+ |
com.apple.ctk-tokens and the exact
com.apple.ctk.driver-class; the host app is only its delivery vehicle.TKTokenKeychainContents with stable, matching object IDs.
TKTokenKeychainKey capabilities must reflect the hardware.TKTokenSessionDelegate.supports returns true only for algorithms and
operations the token actually implements.send calls in withSession; for raw transmit, pair
beginSession and endSession on every path.errSecItemNotFound.TKTokenSmartCardPINAuthOperation from the real card format and
APDU layout; never log or retain PIN bytes.TKSmartCardSlotNFCSession, including error and cancellation paths.import CryptoTokenKit
guard let manager = TKSmartCardSlotManager.default else {
// Missing entitlement/access, unsupported runtime, or no smart-card service.
return
}On iOS/iPadOS 26+, also require manager.isNFCSupported() before creating an
NFC slot. Keep macOS configuration and system-authentication guidance outside
iOS-only branches. Do not force unwrap a manager, slot, card, certificate, or
keychain item obtained from hardware.
Handle TKError according to recovery semantics:
| Error | Expected response |
|---|---|
.canceledByUser | Stop quietly or restore prior UI state |
.authenticationFailed / .authenticationNeeded | Present bounded retry or authentication UI |
.tokenNotFound / .objectNotFound | Ask for reinsertion or refresh token contents |
.communicationError | End the session and offer a fresh attempt |
.corruptedData | Reject the response; do not parse or trust partial data |
.notImplemented | Disable the unsupported operation |
Preserve smart-card-specific status information in app errors without exposing secrets. Avoid blind retries of PIN or destructive card commands.
thienqo/ios-skills
6bf8b62
Canonical home
since May 23, 2026
Also appears in
on Sep 6, 2026
since May 22, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.