Created
January 20, 2023 09:47
-
-
Save Kaival-Patel/1c4a4514fd0524461f72d07a894a9fb8 to your computer and use it in GitHub Desktop.
Registration Implementation for Passkeys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func signUpWith(userName: String, anchor: ASPresentationAnchor) { | |
| self.authenticationAnchor = anchor | |
| let publicKeyCredentialProvider = ASAuthorizationPlatformPublicKeyCredentialProvider(relyingPartyIdentifier: domain) | |
| // Fetch the challenge from the server. The challenge needs to be unique for each request. | |
| // The userID is the identifier for the user's account. | |
| let challenge = Data() | |
| let userID = Data(UUID().uuidString.utf8) | |
| let registrationRequest = publicKeyCredentialProvider.createCredentialRegistrationRequest(challenge: challenge, | |
| name: userName, userID: userID) | |
| // Use only ASAuthorizationPlatformPublicKeyCredentialRegistrationRequests or | |
| // ASAuthorizationSecurityKeyPublicKeyCredentialRegistrationRequests here. | |
| let authController = ASAuthorizationController(authorizationRequests: [ registrationRequest ] ) | |
| authController.delegate = self | |
| authController.presentationContextProvider = self | |
| authController.performRequests() | |
| isPerformingModalReqest = true | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment