Open jaydipdeveloper opened 7 months ago
how to create request object of type RegistrationCredential
You decode this from the web browser or your app — you'll need to pass the result from beginRegistration()
to the client, have it sign that via a passkey, and supply it back to the server to be finalized and stored with finishRegistration()
. Have you already gone through the documentation here? https://swiftpackageindex.com/swift-server/webauthn-swift/main/documentation/webauthn/example-implementation
I'm using on native swift
let webAuthnManager = WebAuthnManager( configuration: WebAuthnManager.Configuration( relyingPartyID: "domain", relyingPartyName: "My Fancy Web App", relyingPartyOrigin: "https://domain.ai" ) )
Task {
let result = webAuthnManager.beginRegistration(user: PublicKeyCredentialUserEntity(id: self.generateRandomBytes(count: 10), name: "Jaydip", displayName: "Jaydip Finava"))
print(result)
let id = result.user.id.base64URLEncodedString()
let request = RegistrationCredential(id: id, type: .publicKey, rawID: result.challenge, attestationResponse: AuthenticatorAttestationResponse(clientDataJSON: result.challenge, attestationObject: result.challenge))
let confirmCredentialIDNotRegisteredYet: (String) async throws -> Bool = { credentialID in
return true
}
do {
let credential = try await webAuthnManager.finishRegistration(
challenge: result.challenge,
credentialCreationData: request,
confirmCredentialIDNotRegisteredYet: confirmCredentialIDNotRegisteredYet
)
print(credential)
} catch {
print(error)
}
}
Can you give me sample code in iOS Swift please?
This library is for a server backend, not an iOS app. Apple has documentation here for the iOS half of the equation, assuming you are interacting with a supported server: https://developer.apple.com/documentation/authenticationservices/connecting_to_a_service_with_passkeys
I need to do passkey like Dashlane iOS app
On Tue, 7 May 2024 at 6:36 PM, Dimitri Bouniol @.***> wrote:
This library is for a server backend, not an iOS app. Apple has documentation here for the iOS half of the equation, assuming you are interacting with a supported server: https://developer.apple.com/documentation/authenticationservices/connecting_to_a_service_with_passkeys
— Reply to this email directly, view it on GitHub https://github.com/swift-server/webauthn-swift/issues/66#issuecomment-2098364164, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOLYOFJ2OEB5DZTTITB4KPLZBDGW7AVCNFSM6AAAAABHKL5N3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJYGM3DIMJWGQ . You are receiving this because you authored the thread.Message ID: @.***>
WebAuthnError(reason: PassDemo.WebAuthnError.Reason.invalidAttestationObject)
let webAuthnManager = WebAuthnManager( configuration: WebAuthnManager.Configuration( relyingPartyID: "oloid.ai", relyingPartyName: "My Fancy Web App", relyingPartyOrigin: "https://oloid.ai" ) )
how to create request object of type RegistrationCredential?