Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose passkey options #10

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The TurnkeySDK is built to support macOS, iOS, tvOS, watchOS, and visionOS, maki
To integrate the TurnkeySDK into your Swift project, you need to add it as a dependency in your Package.swift file:

```swift
.package(url: "https://github.com/tkhq/swift-sdk", from: "1.2.1")
.package(url: "https://github.com/tkhq/swift-sdk", from: "1.2.2")
```

## Usage
Expand Down
10 changes: 6 additions & 4 deletions Sources/Shared/PasskeyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public class PasskeyManager: NSObject, ASAuthorizationControllerDelegate,

/// Initiates the registration of a new passkey.
/// - Parameter email: The email address associated with the new passkey.
public func registerPasskey(email: String) {
public func registerPasskey(email: String, options: ASAuthorizationController.RequestOptions = [])
{

let challenge = generateRandomBuffer()
let userID = Data(UUID().uuidString.utf8)
Expand All @@ -77,14 +78,15 @@ public class PasskeyManager: NSObject, ASAuthorizationControllerDelegate,
])
authorizationController.delegate = self
authorizationController.presentationContextProvider = self
authorizationController.performRequests()
authorizationController.performRequests(options: options)

isPerformingModalRequest = true
}

/// Initiates the assertion of a passkey using the specified challenge.
/// - Parameter challenge: The challenge data used for passkey assertion.
public func assertPasskey(challenge: Data) {
public func assertPasskey(challenge: Data, options: ASAuthorizationController.RequestOptions = [])
{
let publicKeyCredentialProvider = ASAuthorizationPlatformPublicKeyCredentialProvider(
relyingPartyIdentifier: rpId)

Expand All @@ -94,7 +96,7 @@ public class PasskeyManager: NSObject, ASAuthorizationControllerDelegate,
let authController = ASAuthorizationController(authorizationRequests: [assertionRequest])
authController.delegate = self
authController.presentationContextProvider = self
authController.performRequests()
authController.performRequests(options: options)

isPerformingModalRequest = true
}
Expand Down