๐ API Reference
Complete API reference for the PasskeymeSDK iOS framework.
The PasskeymeSDK provides native iOS APIs for passkey authentication using the AuthenticationServices framework and WebKit components.
๐ฑ PasskeymeSDKโ
Configurationโ
configure(debug:timeout:)
โ
Configures the PasskeymeSDK with global settings.
PasskeymeSDK.configure(
debug: Bool = false,
timeout: TimeInterval = 60.0
)
Parameters:
debug
: Enable debug logging and development modetimeout
: Network request timeout in seconds
Example:
// Production configuration
PasskeymeSDK.configure(debug: false, timeout: 30.0)
// Development configuration
PasskeymeSDK.configure(debug: true, timeout: 120.0)
๐ PasskeyAuthenticatorโ
The main authentication class for passkey operations.
Initializationโ
init(apiBaseURL:webViewConfiguration:delegate:)
โ
Creates a new PasskeyAuthenticator instance.
init(
apiBaseURL: String,
webViewConfiguration: WKWebViewConfiguration? = nil,
delegate: PasskeyAuthenticatorDelegate? = nil
)
Parameters:
apiBaseURL
: Base URL for Passkeyme API endpointswebViewConfiguration
: Optional WebKit configurationdelegate
: Delegate for authentication events
Example:
let authenticator = PasskeyAuthenticator(
apiBaseURL: "https://api.passkeyme.com",
delegate: self
)
Propertiesโ
delegate
โ
weak var delegate: PasskeyAuthenticatorDelegate?
Delegate that receives authentication events and callbacks.
isReady
โ
var isReady: Bool { get }
Returns true
if the authenticator is ready to perform operations.
currentWebView
โ
var currentWebView: WKWebView? { get }
The currently active WebView used for authentication flows.
Methodsโ
register(options:)
โ
Initiates passkey registration for a new user.
func register(options: PasskeyRegistrationOptions) async throws -> PasskeyRegistrationResult
Parameters:
options
: Configuration options for registration
Returns: PasskeyRegistrationResult
containing registration details
Throws: PasskeyError
on failure
Example:
let options = PasskeyRegistrationOptions(
userId: "user123",
userName: "john@example.com",
displayName: "John Doe"
)
do {
let result = try await authenticator.register(options: options)
print("Registration successful: \(result.credentialId)")
} catch {
print("Registration failed: \(error)")
}
authenticate(options:)
โ
Performs passkey authentication for an existing user.
func authenticate(options: PasskeyAuthenticationOptions) async throws -> PasskeyAuthenticationResult
Parameters:
options
: Configuration options for authentication
Returns: PasskeyAuthenticationResult
containing authentication details
Throws: PasskeyError
on failure
Example:
let options = PasskeyAuthenticationOptions(
userId: "user123",
challenge: "server_challenge"
)
do {
let result = try await authenticator.authenticate(options: options)
print("Authentication successful: \(result.userId)")
} catch {
print("Authentication failed: \(error)")
}
triggerPasskeymeAuth(authId:data:configuration:)
โ
Triggers Passkeyme hosted authentication flow.
func triggerPasskeymeAuth(
authId: String,
data: [String: Any]? = nil,
configuration: PasskeymeConfiguration? = nil
) async throws -> PasskeymeAuthResult
Parameters:
authId
: Authentication session identifierdata
: Optional additional data for the authentication flowconfiguration
: Optional configuration for the hosted flow
Returns: PasskeymeAuthResult
containing authentication result
Throws: PasskeyError
on failure
Example:
let configuration = PasskeymeConfiguration(
domain: "your-domain.com",
theme: .light,
language: "en"
)
do {
let result = try await authenticator.triggerPasskeymeAuth(
authId: "auth_session_123",
data: ["custom_field": "value"],
configuration: configuration
)
print("Hosted auth successful: \(result.token)")
} catch {
print("Hosted auth failed: \(error)")
}
isUserVerifyingPlatformAuthenticatorAvailable()
โ
Checks if platform authenticator is available.
func isUserVerifyingPlatformAuthenticatorAvailable() async -> Bool
Returns: true
if platform authenticator is available
Example:
let isAvailable = await authenticator.isUserVerifyingPlatformAuthenticatorAvailable()
if isAvailable {
print("Passkeys are supported on this device")
} else {
print("Passkeys not available")
}
cancel()
โ
Cancels any ongoing authentication operation.
func cancel()
Example:
// Cancel ongoing operation
authenticator.cancel()
๐ Data Modelsโ
PasskeyRegistrationOptionsโ
Configuration options for passkey registration.
struct PasskeyRegistrationOptions {
let userId: String
let userName: String
let displayName: String
let challenge: String?
let timeout: TimeInterval?
let authenticatorSelection: AuthenticatorSelection?
let attestation: AttestationConveyancePreference?
let extensions: AuthenticationExtensions?
}
Properties:
userId
: Unique identifier for the useruserName
: User's username (typically email)displayName
: Human-readable display namechallenge
: Server-generated challenge (optional)timeout
: Operation timeout in secondsauthenticatorSelection
: Authenticator selection criteriaattestation
: Attestation conveyance preferenceextensions
: WebAuthn extensions
Example:
let options = PasskeyRegistrationOptions(
userId: "user_12345",
userName: "john.doe@example.com",
displayName: "John Doe",
challenge: nil, // SDK will generate
timeout: 60.0,
authenticatorSelection: AuthenticatorSelection(
userVerification: .required,
residentKey: .required
),
attestation: .none,
extensions: nil
)
PasskeyAuthenticationOptionsโ
Configuration options for passkey authentication.
struct PasskeyAuthenticationOptions {
let userId: String?
let challenge: String?
let timeout: TimeInterval?
let userVerification: UserVerificationRequirement?
let allowCredentials: [PublicKeyCredentialDescriptor]?
let extensions: AuthenticationExtensions?
}
Properties:
userId
: User identifier (optional for usernameless flow)challenge
: Server-generated challengetimeout
: Operation timeout in secondsuserVerification
: User verification requirementallowCredentials
: List of allowed credentialsextensions
: WebAuthn extensions
Example:
let options = PasskeyAuthenticationOptions(
userId: "user_12345",
challenge: "server_challenge_string",
timeout: 60.0,
userVerification: .required,
allowCredentials: nil, // Allow any credential
extensions: nil
)
PasskeymeConfigurationโ
Configuration for Passkeyme hosted authentication.
struct PasskeymeConfiguration {
let domain: String
let theme: PasskeymeTheme?
let language: String?
let customization: PasskeymeCustomization?
let developmentMode: Bool?
}
Properties:
domain
: Your registered domaintheme
: UI theme preferencelanguage
: Preferred language codecustomization
: Custom UI elementsdevelopmentMode
: Enable development mode
Example:
let config = PasskeymeConfiguration(
domain: "myapp.com",
theme: .dark,
language: "en",
customization: PasskeymeCustomization(
primaryColor: "#007AFF",
logoURL: "https://myapp.com/logo.png"
),
developmentMode: false
)
Result Typesโ
PasskeyRegistrationResult
โ
Result of a successful passkey registration.
struct PasskeyRegistrationResult {
let credentialId: String
let publicKey: String
let attestationObject: String
let clientDataJSON: String
let userId: String
let transports: [AuthenticatorTransport]
}
PasskeyAuthenticationResult
โ
Result of a successful passkey authentication.
struct PasskeyAuthenticationResult {
let credentialId: String
let authenticatorData: String
let signature: String
let clientDataJSON: String
let userId: String
let userHandle: String?
}
PasskeymeAuthResult
โ
Result of a successful Passkeyme hosted authentication.
struct PasskeymeAuthResult {
let token: String
let userId: String
let email: String?
let userData: [String: Any]?
let authMethod: String
let timestamp: Date
}
๐ฏ Delegate Protocolโ
PasskeyAuthenticatorDelegateโ
Delegate protocol for receiving authentication events.
protocol PasskeyAuthenticatorDelegate: AnyObject {
func authenticator(_ authenticator: PasskeyAuthenticator, didStartOperation operation: PasskeyOperation)
func authenticator(_ authenticator: PasskeyAuthenticator, didCompleteOperation operation: PasskeyOperation, with result: Any)
func authenticator(_ authenticator: PasskeyAuthenticator, didFailOperation operation: PasskeyOperation, with error: PasskeyError)
func authenticator(_ authenticator: PasskeyAuthenticator, didCancelOperation operation: PasskeyOperation)
func authenticator(_ authenticator: PasskeyAuthenticator, didUpdateProgress progress: PasskeyProgress)
}
Methods:
didStartOperation
โ
Called when an operation begins.
func authenticator(_ authenticator: PasskeyAuthenticator, didStartOperation operation: PasskeyOperation)
didCompleteOperation
โ
Called when an operation completes successfully.
func authenticator(_ authenticator: PasskeyAuthenticator, didCompleteOperation operation: PasskeyOperation, with result: Any)
didFailOperation
โ
Called when an operation fails.
func authenticator(_ authenticator: PasskeyAuthenticator, didFailOperation operation: PasskeyOperation, with error: PasskeyError)
didCancelOperation
โ
Called when an operation is cancelled.
func authenticator(_ authenticator: PasskeyAuthenticator, didCancelOperation operation: PasskeyOperation)
didUpdateProgress
โ
Called when operation progress updates.
func authenticator(_ authenticator: PasskeyAuthenticator, didUpdateProgress progress: PasskeyProgress)
Example Implementation:
extension ViewController: PasskeyAuthenticatorDelegate {
func authenticator(_ authenticator: PasskeyAuthenticator, didStartOperation operation: PasskeyOperation) {
DispatchQueue.main.async {
self.showLoading(for: operation)
}
}
func authenticator(_ authenticator: PasskeyAuthenticator, didCompleteOperation operation: PasskeyOperation, with result: Any) {
DispatchQueue.main.async {
self.hideLoading()
self.handleSuccess(operation: operation, result: result)
}
}
func authenticator(_ authenticator: PasskeyAuthenticator, didFailOperation operation: PasskeyOperation, with error: PasskeyError) {
DispatchQueue.main.async {
self.hideLoading()
self.showError(error)
}
}
func authenticator(_ authenticator: PasskeyAuthenticator, didCancelOperation operation: PasskeyOperation) {
DispatchQueue.main.async {
self.hideLoading()
}
}
func authenticator(_ authenticator: PasskeyAuthenticator, didUpdateProgress progress: PasskeyProgress) {
DispatchQueue.main.async {
self.updateProgress(progress)
}
}
}
๐ง Enumerationsโ
PasskeyOperationโ
Types of passkey operations.
enum PasskeyOperation {
case registration
case authentication
case hostedAuth
case availabilityCheck
}
PasskeyErrorโ
Error types that can occur during passkey operations.
enum PasskeyError: Error, LocalizedError {
case notSupported
case cancelled
case timeout
case networkError(Error)
case invalidConfiguration
case authenticationFailed
case registrationFailed
case userVerificationFailed
case unknownError(String)
var errorDescription: String? {
switch self {
case .notSupported:
return "Passkeys are not supported on this device"
case .cancelled:
return "Operation was cancelled by user"
case .timeout:
return "Operation timed out"
case .networkError(let error):
return "Network error: \(error.localizedDescription)"
case .invalidConfiguration:
return "Invalid configuration provided"
case .authenticationFailed:
return "Authentication failed"
case .registrationFailed:
return "Registration failed"
case .userVerificationFailed:
return "User verification failed"
case .unknownError(let message):
return "Unknown error: \(message)"
}
}
}
PasskeymeThemeโ
UI theme options for Passkeyme hosted authentication.
enum PasskeymeTheme {
case light
case dark
case auto
}
UserVerificationRequirementโ
User verification requirements for authentication.
enum UserVerificationRequirement {
case required
case preferred
case discouraged
}
AuthenticatorTransportโ
Available authenticator transport methods.
enum AuthenticatorTransport {
case usb
case nfc
case ble
case internal
case hybrid
}
๐ Supporting Typesโ
AuthenticatorSelectionโ
Criteria for authenticator selection.
struct AuthenticatorSelection {
let authenticatorAttachment: AuthenticatorAttachment?
let userVerification: UserVerificationRequirement
let residentKey: ResidentKeyRequirement?
}
enum AuthenticatorAttachment {
case platform
case crossPlatform
}
enum ResidentKeyRequirement {
case required
case preferred
case discouraged
}
PublicKeyCredentialDescriptorโ
Descriptor for existing credentials.
struct PublicKeyCredentialDescriptor {
let type: String
let id: Data
let transports: [AuthenticatorTransport]?
}
PasskeyProgressโ
Progress information for ongoing operations.
struct PasskeyProgress {
let operation: PasskeyOperation
let stage: ProgressStage
let message: String?
let progress: Float // 0.0 to 1.0
}
enum ProgressStage {
case initializing
case authenticating
case processing
case completing
}
PasskeymeCustomizationโ
Customization options for hosted authentication UI.
struct PasskeymeCustomization {
let primaryColor: String?
let logoURL: String?
let brandName: String?
let customCSS: String?
}
๐งช Testing Utilitiesโ
PasskeyTestUtilsโ
Utilities for testing passkey functionality.
class PasskeyTestUtils {
static func createMockRegistrationOptions() -> PasskeyRegistrationOptions
static func createMockAuthenticationOptions() -> PasskeyAuthenticationOptions
static func isRunningInSimulator() -> Bool
static func mockPlatformAuthenticatorAvailability() -> Bool
}
Example:
#if DEBUG
let mockOptions = PasskeyTestUtils.createMockRegistrationOptions()
let isSimulator = PasskeyTestUtils.isRunningInSimulator()
if isSimulator {
// Use mock implementation for simulator testing
let mockResult = createMockRegistrationResult()
completion(.success(mockResult))
}
#endif
๐ Extensionsโ
WKWebViewConfiguration Extensionsโ
extension WKWebViewConfiguration {
static func passkeyConfiguration() -> WKWebViewConfiguration
func enablePasskeySupport()
func configureForSecureAuthentication()
}
ASAuthorizationController Extensionsโ
extension ASAuthorizationController {
convenience init(passkeyRequest: ASAuthorizationPlatformPublicKeyCredentialProvider.CredentialRegistrationRequest)
convenience init(passkeyRequest: ASAuthorizationPlatformPublicKeyCredentialProvider.CredentialAssertionRequest)
}
โ ๏ธ Important Notesโ
Platform Requirementsโ
- iOS 16.0+ for full passkey support
- iOS 15.0+ for basic WebAuthn functionality
- Xcode 14.0+ for development
- Valid Apple Developer account for Associated Domains
Associated Domainsโ
Your app must include the Associated Domains capability with:
webcredentials:your-domain.com
Network Securityโ
All API endpoints must use HTTPS. The SDK will reject HTTP connections in production.
Memory Managementโ
The SDK uses automatic reference counting (ARC). Ensure you maintain strong references to the PasskeyAuthenticator
instance while operations are in progress.
Thread Safetyโ
All SDK methods are thread-safe and can be called from any queue. Delegate callbacks are dispatched on the main queue.
This API reference provides complete documentation for integrating passkey authentication in your iOS application using the PasskeymeSDK framework.